diff --git a/Android.bp b/Android.bp index 53daff9a..7aedf81c 100644 --- a/Android.bp +++ b/Android.bp @@ -1,5 +1,6 @@ soong_namespace { imports: [ + "hardware/google/pixel", "hardware/qcom/bootctrl", "hardware/qcom/msm8998", ], diff --git a/BoardConfig.mk b/BoardConfig.mk index c5c66de3..34a761df 100644 --- a/BoardConfig.mk +++ b/BoardConfig.mk @@ -56,6 +56,7 @@ TARGET_NO_KERNEL := false TARGET_NO_RECOVERY := true BOARD_USES_RECOVERY_AS_BOOT := true BOARD_BUILD_SYSTEM_ROOT_IMAGE := true +BOARD_USES_METADATA_PARTITION := true # Partitions (listed in the file) to be wiped under recovery. TARGET_RECOVERY_WIPE := device/google/wahoo/recovery.wipe @@ -85,7 +86,7 @@ TARGET_COPY_OUT_VENDOR := vendor # Install odex files into the other system image BOARD_USES_SYSTEM_OTHER_ODEX := true -BOARD_ROOT_EXTRA_FOLDERS := persist firmware +BOARD_ROOT_EXTRA_FOLDERS := persist firmware metadata BOARD_VENDOR_SEPOLICY_DIRS += device/google/wahoo/sepolicy/vendor BOARD_PLAT_PUBLIC_SEPOLICY_DIR := device/google/wahoo/sepolicy/public @@ -147,7 +148,7 @@ VSYNC_EVENT_PHASE_OFFSET_NS := 2000000 SF_VSYNC_EVENT_PHASE_OFFSET_NS := 6000000 # Display -TARGET_HAS_WIDE_COLOR_DISPLAY := true +TARGET_HAS_WIDE_COLOR_DISPLAY := false TARGET_HAS_HDR_DISPLAY := false TARGET_USES_COLOR_METADATA := true diff --git a/CleanSpec.mk b/CleanSpec.mk index 23dc9ed0..0f7e7282 100644 --- a/CleanSpec.mk +++ b/CleanSpec.mk @@ -177,13 +177,13 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/lib64/hw/*) # Remove android.hardware.audio*@2.0 implementation $(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/lib/hw/android.hardware.audio*@2.0-impl.so) -# Remove Clearkey HAL 1.0 -$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.drm@1.0-service.clearkey.rc) -$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/bin/hw/android.hardware.drm@1.0-service.clearkey) +# Remove Clearkey HAL 1.1 +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.drm@1.1-service.clearkey.rc) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/bin/hw/android.hardware.drm@1.1-service.clearkey) -# Remove Widevine HAL 1.0 -$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.drm@1.0-service.widevine.rc) -$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/bin/hw/android.hardware.drm@1.0-service.widevine) +# Remove Widevine HAL 1.1 +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.drm@1.1-service.widevine.rc) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/bin/hw/android.hardware.drm@1.1-service.widevine) # Remove healthd $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/healthd) @@ -196,5 +196,11 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.ke # Move libnfc-nci.conf to /vendor $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/libnfc-nci.conf) +# Remove android.hardware.graphics.mapper@2.0-impl +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/lib/hw/android.hardware.graphics.mapper@2.0-impl.so) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/lib64/hw/android.hardware.graphics.mapper@2.0-impl.so) +# Rename power HAL +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.power@1.2-service.wahoo-libperfmgr.rc) + # Remove obsolete android.hardware.boot@1.0-impl-wrapper.recovery.so $(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/system/lib64/hw/android.hardware.boot@1.0-impl-wrapper.recovery.so) diff --git a/audio_policy_configuration.xml b/audio_policy_configuration.xml index 4ad3f6d2..38b267df 100644 --- a/audio_policy_configuration.xml +++ b/audio_policy_configuration.xml @@ -84,6 +84,11 @@ samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000" channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK,AUDIO_CHANNEL_INDEX_MASK_3"/> + + + + + + + + - - - - - @@ -124,6 +118,26 @@ + + + + + + + + + + + + + + + + + + diff --git a/device.mk b/device.mk index e6e56fd1..77257f70 100755 --- a/device.mk +++ b/device.mk @@ -1,5 +1,5 @@ # -# Copyright (C) 2016 The Android Open-Source Project +# Copyright (C) 2018 The Android Open-Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,6 +14,12 @@ # limitations under the License. # +# Installs gsi keys into ramdisk, to boot a GSI with verified boot. +$(call inherit-product, $(SRC_TARGET_DIR)/product/gsi_keys.mk) + +# Enable updating of APEXes +$(call inherit-product, $(SRC_TARGET_DIR)/product/updatable_apex.mk) + ifneq (,$(filter 27, $(PRODUCT_EXTRA_VNDK_VERSIONS))) _vndk_test := true endif @@ -31,6 +37,8 @@ PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \ PRODUCT_SOONG_NAMESPACES += \ device/google/wahoo \ + vendor/google/camera \ + hardware/google/pixel \ hardware/qcom/msm8998 PRODUCT_COPY_FILES += \ @@ -40,7 +48,7 @@ PRODUCT_COPY_FILES += \ # Set the SVN for the targeted MR release PRODUCT_PROPERTY_OVERRIDES += \ - ro.vendor.build.svn=27 + ro.vendor.build.svn=29 # Enforce privapp-permissions whitelist PRODUCT_PROPERTY_OVERRIDES += \ @@ -55,7 +63,7 @@ SRC_MEDIA_HAL_DIR := hardware/qcom/media/msm8998 SRC_DISPLAY_HAL_DIR := hardware/qcom/display/msm8998 SRC_CAMERA_HAL_DIR := hardware/qcom/camera/msm8998 -TARGET_SYSTEM_PROP := $(LOCAL_PATH)/system.prop +TARGET_SYSTEM_PROP := $(TARGET_SYSTEM_PROP) $(LOCAL_PATH)/system.prop # Get kernel-headers $(call inherit-product, hardware/qcom/msm8998/msm8998.mk) @@ -86,9 +94,8 @@ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/uinput-fpc.idc:$(TARGET_COPY_OUT_VENDOR)/usr/idc/uinput-fpc.idc \ $(LOCAL_PATH)/init.qcom.devstart.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.qcom.devstart.sh \ $(LOCAL_PATH)/init.qcom.ipastart.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.qcom.ipastart.sh \ - $(LOCAL_PATH)/init.qcom.wlan.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.qcom.wlan.sh \ $(LOCAL_PATH)/init.insmod.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.insmod.sh \ - $(LOCAL_PATH)/init.ramoops.sh:$(TARGET_COPY_OUT_SYSTEM)/bin/init.ramoops.sh \ + $(LOCAL_PATH)/init.ramoops.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.ramoops.sh \ frameworks/native/services/vr/virtual_touchpad/idc/vr-virtual-touchpad-0.idc:$(TARGET_COPY_OUT_VENDOR)/usr/idc/vr-virtual-touchpad-0.idc \ frameworks/native/services/vr/virtual_touchpad/idc/vr-virtual-touchpad-1.idc:$(TARGET_COPY_OUT_VENDOR)/usr/idc/vr-virtual-touchpad-1.idc @@ -130,9 +137,14 @@ PRODUCT_PACKAGES += \ # The following modules are included in debuggable builds only. PRODUCT_PACKAGES_DEBUG += \ + a_sns_test \ bootctl \ update_engine_client +# Write flags to the vendor space in /misc partition. +PRODUCT_PACKAGES += \ + misc_writer + PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.camera.flash-autofocus.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.flash-autofocus.xml \ frameworks/native/data/etc/android.hardware.camera.front.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.front.xml \ @@ -177,10 +189,11 @@ PRODUCT_COPY_FILES += \ # power HAL PRODUCT_PACKAGES += \ - android.hardware.power@1.2-service.wahoo-libperfmgr + android.hardware.power@1.3-service.pixel-libperfmgr -PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/powerhint.json:$(TARGET_COPY_OUT_VENDOR)/etc/powerhint.json +# power.stats HAL +PRODUCT_PACKAGES += \ + android.hardware.power.stats@1.0-service.pixel # health HAL PRODUCT_PACKAGES += \ @@ -312,7 +325,7 @@ PRODUCT_PACKAGES += \ gralloc.msm8998 \ android.hardware.graphics.allocator@2.0-impl:64 \ android.hardware.graphics.allocator@2.0-service \ - android.hardware.graphics.mapper@2.0-impl \ + android.hardware.graphics.mapper@2.0-impl-2.1 \ libbt-vendor # RenderScript HAL @@ -358,8 +371,8 @@ PRODUCT_PROPERTY_OVERRIDES += \ PRODUCT_PACKAGES += \ android.hardware.drm@1.0-impl:32 \ android.hardware.drm@1.0-service \ - android.hardware.drm@1.1-service.widevine \ - android.hardware.drm@1.1-service.clearkey \ + android.hardware.drm@1.2-service.clearkey \ + android.hardware.drm@1.2-service.widevine \ move_widevine_data.sh # NFC packages @@ -391,6 +404,8 @@ PRODUCT_PACKAGES += \ android.hardware.camera.provider@2.4-service \ camera.device@3.2-impl \ camera.msm8998 \ + libgooglecamerahal \ + libgoogle_camera_hal_tests \ libqomx_core \ libmmjpeg_interface \ libmmcamera_interface @@ -426,9 +441,9 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ android.hardware.vibrator@1.2-service.wahoo -# Thermal packages +# Thermal HAL PRODUCT_PACKAGES += \ - android.hardware.thermal@1.1-impl-wahoo + android.hardware.thermal@2.0-service.pixel #GNSS HAL PRODUCT_PACKAGES += \ @@ -439,10 +454,6 @@ PRODUCT_PACKAGES += \ android.hardware.gnss@1.0-impl-qti \ android.hardware.gnss@1.0-service-qti -# VR HAL -PRODUCT_PACKAGES += \ - android.hardware.vr@1.0-service.wahoo \ - PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/sec_config:$(TARGET_COPY_OUT_VENDOR)/etc/sec_config @@ -456,11 +467,14 @@ WPA += wpa_supplicant_wcn.conf WPA += wpa_supplicant PRODUCT_PACKAGES += $(WPA) +ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT))) +PRODUCT_PACKAGES += wpa_cli +endif + # Wifi PRODUCT_PACKAGES += \ android.hardware.wifi@1.0-service \ wificond \ - wifilogd \ libwpa_client LIB_NL := libnl_2 @@ -484,9 +498,9 @@ PRODUCT_PACKAGES += \ audio.bluetooth.default PRODUCT_PACKAGES += \ - android.hardware.audio@4.0-impl:32 \ - android.hardware.audio.effect@4.0-impl:32 \ - android.hardware.soundtrigger@2.1-impl:32 \ + android.hardware.audio@5.0-impl:32 \ + android.hardware.audio.effect@5.0-impl:32 \ + android.hardware.soundtrigger@2.2-impl:32 \ android.hardware.bluetooth.audio@2.0-impl \ android.hardware.audio@2.0-service @@ -544,6 +558,15 @@ PRODUCT_COPY_FILES += \ frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_video.xml \ $(LOCAL_PATH)/media_profiles_V1_0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_profiles_V1_0.xml \ +# Codec2 modules +PRODUCT_PACKAGES += \ + com.android.media.swcodec \ + libsfplugin_ccodec \ + +# Codec2 switch +PRODUCT_PROPERTY_OVERRIDES += \ + debug.media.codec2=2 \ + PRODUCT_PROPERTY_OVERRIDES += \ audio.snd_card.open.retries=50 @@ -553,6 +576,8 @@ PRODUCT_COPY_FILES += \ # Fingerprint HIDL implementation PRODUCT_PACKAGES += \ android.hardware.biometrics.fingerprint@2.1-service.fpc +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/init.fingerprint.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.fingerprint.sh \ PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.fingerprint.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.fingerprint.xml @@ -669,3 +694,27 @@ ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT))) PRODUCT_PROPERTY_OVERRIDES += \ persist.vendor.usb.usbradio.config=diag endif + +# default atrace HAL +PRODUCT_PACKAGES += \ + android.hardware.atrace@1.0-service + +PRODUCT_DEFAULT_PROPERTY_OVERRIDES += ro.surface_flinger.use_color_management=true +PRODUCT_DEFAULT_PROPERTY_OVERRIDES += ro.surface_flinger.protected_contents=true + +# Early phase offset configuration for SurfaceFlinger +PRODUCT_PROPERTY_OVERRIDES += \ + debug.sf.early_phase_offset_ns=1500000 +PRODUCT_PROPERTY_OVERRIDES += \ + debug.sf.early_app_phase_offset_ns=1500000 +PRODUCT_PROPERTY_OVERRIDES += \ + debug.sf.early_gl_phase_offset_ns=3000000 +PRODUCT_PROPERTY_OVERRIDES += \ + debug.sf.early_gl_app_phase_offset_ns=15000000 + +# Use /product/etc/fstab.postinstall to mount system_other. +PRODUCT_PRODUCT_PROPERTIES += \ + ro.postinstall.fstab.prefix=/product + +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/fstab.postinstall:$(TARGET_COPY_OUT_PRODUCT)/etc/fstab.postinstall diff --git a/dumpstate/DumpstateDevice.cpp b/dumpstate/DumpstateDevice.cpp index 929e4348..4c1c21ec 100755 --- a/dumpstate/DumpstateDevice.cpp +++ b/dumpstate/DumpstateDevice.cpp @@ -21,6 +21,8 @@ #include #include #include +#include + #include #include @@ -227,6 +229,11 @@ static void DumpTouch(int fd) { // Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow. Return DumpstateDevice::dumpstateBoard(const hidl_handle& handle) { + // Exit when dump is completed since this is a lazy HAL. + addPostCommandTask([]() { + exit(0); + }); + if (handle == nullptr || handle->numFds < 1) { ALOGE("no FDs\n"); return Void(); @@ -272,8 +279,15 @@ Return DumpstateDevice::dumpstateBoard(const hidl_handle& handle) { DumpFileToFd(fd, "PD Engine", "/d/pd_engine/usbpd0"); DumpFileToFd(fd, "smblib-usb logs", "/d/ipc_logging/smblib/log"); DumpFileToFd(fd, "ipc-local-ports", "/d/msm_ipc_router/dump_local_ports"); + DumpFileToFd(fd, "ipc-servers", "/d/msm_ipc_router/dump_servers"); + RunCommandToFd(fd, "ipc-logs", + {"/vendor/bin/sh", "-c", + "for f in `ls /d/ipc_logging/*_IPCRTR/log` ; do echo \"------ $f\\n`cat " + "$f`\\n\" ; done"}); DumpTouch(fd); RunCommandToFd(fd, "USB Device Descriptors", {"/vendor/bin/sh", "-c", "cd /sys/bus/usb/devices/1-1 && cat product && cat bcdDevice; cat descriptors | od -t x1 -w16 -N96"}); + DumpFileToFd(fd, "Pixel trace", "/d/tracing/instances/pixel-trace/trace"); + // Timeout after 3s RunCommandToFd(fd, "QSEE logs", {"/vendor/bin/sh", "-c", "/vendor/bin/timeout 3 cat /d/tzdbg/qsee_log"}); RunCommandToFd(fd, "Power supply properties", {"/vendor/bin/sh", "-c", "for f in /sys/class/power_supply/*/uevent ; do echo \"\n------ $f\" ; cat $f ; done"}); diff --git a/dumpstate/android.hardware.dumpstate@1.0-service.wahoo.rc b/dumpstate/android.hardware.dumpstate@1.0-service.wahoo.rc index 4c024a0b..950da390 100644 --- a/dumpstate/android.hardware.dumpstate@1.0-service.wahoo.rc +++ b/dumpstate/android.hardware.dumpstate@1.0-service.wahoo.rc @@ -3,6 +3,8 @@ service vendor.dumpstate-1-0 /vendor/bin/hw/android.hardware.dumpstate@1.0-servi user system group system interface android.hardware.dumpstate@1.0::IDumpstateDevice default + oneshot + disabled on boot chmod 0444 /sys/kernel/debug/tzdbg/qsee_log diff --git a/fstab.hardware b/fstab.hardware index d2fc516f..e7059b2c 100644 --- a/fstab.hardware +++ b/fstab.hardware @@ -2,8 +2,9 @@ # /dev/block/platform/soc/1da4000.ufshc/by-name/system / ext4 ro,barrier=1 wait,slotselect,avb -/dev/block/platform/soc/1da4000.ufshc/by-name/userdata /data ext4 errors=panic,noatime,nosuid,nodev,barrier=1,noauto_da_alloc latemount,wait,check,formattable,fileencryption=ice:aes-256-heh,eraseblk=16777216,logicalblk=4096,quota,reservedsize=128M +/dev/block/platform/soc/1da4000.ufshc/by-name/metadata /metadata ext4 noatime,nosuid,nodev,discard,sync wait,formattable +/dev/block/platform/soc/1da4000.ufshc/by-name/userdata /data ext4 errors=panic,noatime,nosuid,nodev,barrier=1,noauto_da_alloc latemount,wait,check,formattable,fileencryption=ice:aes-256-heh,eraseblk=16777216,logicalblk=4096,quota,reservedsize=128M,checkpoint=block /dev/block/platform/soc/1da4000.ufshc/by-name/misc /misc emmc defaults defaults /dev/block/platform/soc/1da4000.ufshc/by-name/modem /firmware vfat ro,shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337,context=u:object_r:firmware_file:s0 wait,slotselect /devices/soc/a800000.ssusb/a800000.dwc3* auto vfat defaults voldmanaged=usb:auto -/dev/block/zram0 none swap defaults zramsize=536870912,max_comp_streams=8 +/dev/block/zram0 none swap defaults zramsize=2147483648,max_comp_streams=8 diff --git a/fstab.postinstall b/fstab.postinstall new file mode 100644 index 00000000..df8f77b7 --- /dev/null +++ b/fstab.postinstall @@ -0,0 +1,17 @@ +# +# Copyright (C) 2019 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +/dev/block/by-name/system /postinstall ext4 ro,nosuid,nodev,noexec slotselect_other,avb_keys=/product/etc/security/avb/system_other.avbpubkey diff --git a/health/LearnedCapacityBackupRestore.cpp b/health/LearnedCapacityBackupRestore.cpp index 48fe4610..cf8de8d3 100644 --- a/health/LearnedCapacityBackupRestore.cpp +++ b/health/LearnedCapacityBackupRestore.cpp @@ -25,17 +25,28 @@ static constexpr char kChgFullFile[] = "sys/class/power_supply/bms/charge_full"; static constexpr char kSysCFPersistFile[] = "/persist/battery/qcom_charge_full"; static constexpr int kBuffSize = 256; -LearnedCapacityBackupRestore::LearnedCapacityBackupRestore() {} +LearnedCapacityBackupRestore::LearnedCapacityBackupRestore() : sw_cap_(0), hw_cap_(0) {} void LearnedCapacityBackupRestore::Restore() { ReadFromStorage(); ReadFromSRAM(); - UpdateAndSave(); + if (sw_cap_ == 0) { + // First backup + sw_cap_ = hw_cap_; + SaveToStorage(); + } else { + // Always restore backup value + SaveToSRAM(); + } } void LearnedCapacityBackupRestore::Backup() { ReadFromSRAM(); - UpdateAndSave(); + if (sw_cap_ != hw_cap_) { + // Always backup the new FG computed learned capacity + sw_cap_ = hw_cap_; + SaveToStorage(); + } } void LearnedCapacityBackupRestore::ReadFromStorage() { @@ -90,24 +101,6 @@ void LearnedCapacityBackupRestore::SaveToSRAM() { LOG(ERROR) << "Write data error: " << strerror(errno); } -void LearnedCapacityBackupRestore::UpdateAndSave() { - bool backup = false; - bool restore = false; - if (hw_cap_) { - if ((hw_cap_ < sw_cap_) || (sw_cap_ == 0)) { - sw_cap_ = hw_cap_; - backup = true; - } else if (hw_cap_ > sw_cap_) { - hw_cap_ = sw_cap_; - restore = true; - } - } - if (restore) - SaveToSRAM(); - if (backup) - SaveToStorage(); -} - } // namespace health } // namespace wahoo } // namespace google diff --git a/health/LearnedCapacityBackupRestore.h b/health/LearnedCapacityBackupRestore.h index 13d38e25..da9e5643 100644 --- a/health/LearnedCapacityBackupRestore.h +++ b/health/LearnedCapacityBackupRestore.h @@ -41,7 +41,6 @@ class LearnedCapacityBackupRestore { void SaveToStorage(); void ReadFromSRAM(); void SaveToSRAM(); - void UpdateAndSave(); }; } // namespace health diff --git a/init.fingerprint.sh b/init.fingerprint.sh new file mode 100755 index 00000000..413fd9ed --- /dev/null +++ b/init.fingerprint.sh @@ -0,0 +1,48 @@ +#!/vendor/bin/sh +# /vendor/bin/init.fingerprint.sh [max_init_retry_times] + +# fps_hal service prop +fps_svc_prop='init.svc.vendor.fps_hal' +# fps_hal service name +fps_svc_name='vendor.fps_hal' +# fps_hal service init retry count +init_retry_count_prop='vendor.fps.init_retry.count' +# fps_hal service init succeed +init_succeed_prop='vendor.fps.init.succeed' +# Define maximum init retry times as default 10 +max_times=10 + +# Deal with the input parameter +if [ "$#" -ge 1 ]; then + # Check is it positive number or not + # If so, then set maximum times as $1 + # If not, $max_times keeps in default value + if [ "$1" -eq "$1" ] && [ "$1" -gt 0 ]; then + max_times=$1 + echo $max_times + fi +fi + +# fps_hal service init retry count +init_retry_count=0 + +while [ "$init_retry_count" -le "$max_times" ] +do + # debouncing time for init processing + sleep 5 + # Get fps_hal service state and count init retry times + fps_svc_state=$(getprop $fps_svc_prop) + if [ "$fps_svc_state" == "stopped" ]; then + if [ "$init_retry_count" -lt "$max_times" ]; then + init_retry_count=$((init_retry_count+1)) + setprop $init_retry_count_prop $init_retry_count + setprop $init_succeed_prop false + start $fps_svc_name + else + break; + fi + elif [ "$fps_svc_state" == "running" ]; then + setprop $init_succeed_prop true + break + fi +done diff --git a/init.hardware.rc b/init.hardware.rc index 31f5bb5f..48b91d54 100644 --- a/init.hardware.rc +++ b/init.hardware.rc @@ -17,6 +17,10 @@ import /vendor/etc/init/hw/init.${ro.hardware}.usb.rc on charger + # Set runtime stune value + write /dev/stune/schedtune.prefer_idle 0 + write /dev/stune/schedtune.boost 0 + # Offline CPUs write /sys/devices/system/cpu/cpu2/online 0 write /sys/devices/system/cpu/cpu3/online 0 write /sys/devices/system/cpu/cpu4/online 0 @@ -80,6 +84,10 @@ on init write /sys/devices/system/cpu/cpufreq/policy4/schedutil/up_rate_limit_us 500 write /sys/devices/system/cpu/cpufreq/policy4/schedutil/down_rate_limit_us 20000 + # Set boottime stune value + write /dev/stune/schedtune.prefer_idle 1 + write /dev/stune/schedtune.boost 100 + # set default schedTune value for foreground/top-app write /dev/stune/foreground/schedtune.prefer_idle 1 write /dev/stune/top-app/schedtune.boost 10 @@ -159,6 +167,9 @@ on init write /sys/block/zram0/comp_algorithm lz4 write /proc/sys/vm/page-cluster 0 +on init + setprop vendor.thermal.config thermal_info_config.json + on fs mount_all /vendor/etc/fstab.${ro.hardware} --early @@ -188,6 +199,9 @@ on fs chmod 0770 /persist/rfs/apq/gnss chmod 0770 /persist/hlos_rfs + # b/78019660 Remove unlabeled persist_rfs_file + rm /persist/rfs/msm/mpss/server_check.txt + # for android.hardware.health@2.0-service.marlin cycle count backup mkdir /persist/battery 0700 system system @@ -227,20 +241,6 @@ on post-fs # Wait qseecomd started wait_for_prop sys.listeners.registered true -on property:sys.user.0.ce_available=true - mkdir /data/misc_ce/0/ramoops - start vendor.ramoops_sh - -on property:sys.ramoops.decrypted=true - mount pstore pstore /sys/fs/pstore - chown system log /sys/fs/pstore - chown system log /sys/fs/pstore/console-ramoops - chmod 0440 /sys/fs/pstore/console-ramoops - chown system log /sys/fs/pstore/console-ramoops-0 - chmod 0440 /sys/fs/pstore/console-ramoops-0 - chown system log /sys/fs/pstore/pmsg-ramoops-0 - chmod 0440 /sys/fs/pstore/pmsg-ramoops-0 - on property:sys.listeners.registered=true # load IPA FWs start vendor.ipastart_sh @@ -255,6 +255,9 @@ on post-fs-data # b/38496103 Setup debug folders for display mkdir /data/vendor/display 0770 system graphics + # b/65834073 Create rfs folder for tftp_server + mkdir /data/vendor/tombstones/rfs 0770 root system + # keep that at the end of on post-fs-data # Set indication (checked by vold) that we have finished this action setprop vold.post_fs_data_done 1 @@ -335,7 +338,7 @@ on zygote-start mkdir /data/misc/dash 0770 media audio # Create directory for radio - mkdir /data/vendor/radio 0771 system radio + mkdir /data/vendor/radio 0773 system radio # Create directory used by display clients mkdir /data/misc/display 0770 system graphics @@ -386,14 +389,6 @@ on zygote-start # b/62837579 elabel directory mkdir /data/misc/elabel 0700 system system - # Setup permission for powerHAL - chown system system /dev/stune/top-app/schedtune.boost - chown system system /dev/cpu_dma_latency - chown system system /sys/class/kgsl/kgsl-3d0/devfreq/min_freq - chown system system /sys/class/kgsl/kgsl-3d0/devfreq/max_freq - chown system system /sys/class/devfreq/soc:qcom,gpubw/min_freq - chown system system /sys/devices/soc/soc:qcom,cpubw/devfreq/soc:qcom,cpubw/min_freq - on early-boot # wait for devices wait_for_prop sys.qcom.devup 1 @@ -480,19 +475,15 @@ on boot # default country code setprop ro.boot.wificountrycode 00 - # Encrypted ramoops - umount /sys/fs/pstore - chmod 770 /dev/access-ramoops - chown system system /dev/access-ramoops - chmod 770 /dev/access-metadata - chown system system /dev/access-metadata - # Make the ftm4 command node writeable from dumpstate chown system system /sys/devices/virtual/input/ftm4_touch/cmd # ftm4 VR mode chown system system /sys/devices/virtual/input/ftm4_touch/vrmode + # WLAN debug access + chown system system /d/icnss/stats + service vendor.init-elabel-sh /system/bin/init.elabel.sh class late_start user system @@ -508,7 +499,7 @@ service vendor.init-radio-sh /vendor/bin/init.radio.sh service vendor.folio_daemon /system/bin/folio_daemon class late_start user system - group system + group system uhid disabled on property:init.svc.zygote=running @@ -517,7 +508,10 @@ on property:init.svc.zygote=running on property:init.svc.zygote=stopped stop vendor.folio_daemon -service vendor.thermal-engine /vendor/bin/thermal-engine -c ${sys.qcom.thermalcfg:-/vendor/etc/thermal-engine.conf} +on property:vendor.qcom.thermalcfg=* + restart vendor.thermal-engine + +service vendor.thermal-engine /vendor/bin/thermal-engine -c ${vendor.qcom.thermalcfg:-/vendor/etc/thermal-engine.conf} class hal user root group root system diag @@ -559,12 +553,14 @@ service vendor.per_proxy /vendor/bin/pm-proxy disabled on property:sys.post_boot.parsed=1 - # Setup permission for powerHAL - chown system system /sys/devices/soc/soc:qcom,cpubw/devfreq/soc:qcom,cpubw/bw_hwmon/hyst_trigger_count - chown system system /sys/devices/soc/soc:qcom,cpubw/devfreq/soc:qcom,cpubw/bw_hwmon/hist_memory - chown system system /sys/devices/soc/soc:qcom,cpubw/devfreq/soc:qcom,cpubw/bw_hwmon/hyst_length + # Enable PowerHAL hint processing + setprop vendor.powerhal.init 1 on property:sys.boot_completed=1 + # Set runtime stune value + write /dev/stune/schedtune.prefer_idle 0 + write /dev/stune/schedtune.boost 0 + # Enable power setting and set sys.post_boot.parsed to 1 start vendor.power_sh @@ -618,6 +614,7 @@ on property:sys.boot_completed=1 # we don't want to run swapon_all at that time. on sys-boot-completed-set && property:persist.sys.zram_enabled=1 swapon_all /vendor/etc/fstab.${ro.hardware} + write /proc/sys/vm/swappiness 100 on property:init.svc.vendor.per_mgr=running start vendor.per_proxy @@ -691,6 +688,7 @@ service wpa_supplicant /vendor/bin/hw/wpa_supplicant \ # group wifi inet keystore interface android.hardware.wifi.supplicant@1.0::ISupplicant default interface android.hardware.wifi.supplicant@1.1::ISupplicant default + interface android.hardware.wifi.supplicant@1.2::ISupplicant default class main socket wpa_wlan0 dgram 660 wifi wifi disabled @@ -820,13 +818,6 @@ service vendor.devstart_sh /vendor/bin/init.qcom.devstart.sh disabled oneshot -service vendor.wlan_sh /vendor/bin/init.qcom.wlan.sh - class main - user root - group root - disabled - oneshot - service vendor.ipastart_sh /vendor/bin/init.qcom.ipastart.sh class main user system @@ -841,13 +832,6 @@ service vendor.insmod_sh /vendor/bin/init.insmod.sh disabled oneshot -service vendor.ramoops_sh /system/bin/init.ramoops.sh - class main - user root - group root system - disabled - oneshot - # b/70518189 vDSO experiments on property:sys.vdso=* write /sys/module/vdso/parameters/enable_32 1 @@ -863,13 +847,51 @@ on property:sys.vdso=64 on property:sys.vdso=32 write /sys/module/vdso/parameters/enable_64 0 -on property:wlan.driver.status=ok - # Get the wlan driver/fw version - start vendor.wlan_sh - # charger driver exposes now finer grain control, map demo mode to those properties # demo mode can only be exit wipping data which will also reset the persist properties on property:sys.retaildemo.enabled=1 setprop persist.vendor.charge.stop.level 35 setprop persist.vendor.charge.start.level 30 +on property:sys.boot_completed=1 + # Create pixel-trace. + # At this moment, only mm_event is available. If others want to put more, + # it should get hard review from pixel-perf-team. + + mkdir /sys/kernel/debug/tracing/instances/pixel-trace 755 system system + chown system system /sys/kernel/debug/tracing/instances/pixel-trace/trace + chmod 0660 /sys/kernel/debug/tracing/instances/pixel-trace/trace + chown system system /sys/kernel/debug/tracing/instances/pixel-trace/tracing_on + chmod 0660 /sys/kernel/debug/tracing/instances/pixel-trace/tracing_on + write /sys/kernel/debug/tracing/instances/pixel-trace/buffer_size_kb 64 + write /sys/kernel/debug/tracing/instances/pixel-trace/events/mm_event/enable 1 + +# turns off tracing right before bugreporting to keep more traces +on property:init.svc.dumpstatez=running + write /d/tracing/instances/pixel-trace/tracing_on 0 + +on property:init.svc.dumpstatez=stopped + write /d/tracing/instances/pixel-trace/tracing_on 1 + +on property:init.svc.bugreport=running + write /d/tracing/instances/pixel-trace/tracing_on 0 + +on property:init.svc.bugreport=stopped + write /d/tracing/instances/pixel-trace/tracing_on 1 + +# init-fingerprint-sh is for stopping fps_hal after init retry fail serval times +# It keeps running until max init retry or fps_hal running successfully +# vendor.fps_hal restarts until max init retry times +# +# /vendor/bin/init.fingerprint.sh [max_init_retry_times] +service init-fingerprint-sh /vendor/bin/init.fingerprint.sh 10 + group root + user root + disabled + oneshot + +on property:sys.boot_completed=1 + start init-fingerprint-sh + +on property:vendor.fps.init.succeed=true && property:init.svc.vendor.fps_hal=stopped + start init-fingerprint-sh diff --git a/init.hardware.usb.rc b/init.hardware.usb.rc index 09ae4d53..a73170fc 100644 --- a/init.hardware.usb.rc +++ b/init.hardware.usb.rc @@ -43,7 +43,7 @@ on early-boot write /config/usb_gadget/g1/os_desc/qw_sign "MSFT100" mkdir /dev/usb-ffs 0775 shell shell mkdir /dev/usb-ffs/adb 0770 shell shell - mount functionfs adb /dev/usb-ffs/adb rmode=0770,fmode=0660,uid=2000,gid=2000 + mount functionfs adb /dev/usb-ffs/adb rmode=0770,fmode=0660,uid=2000,gid=2000,no_disconnect=1 mkdir /dev/usb-ffs/mtp 0770 mtp mtp mkdir /dev/usb-ffs/ptp 0770 mtp mtp mount functionfs mtp /dev/usb-ffs/mtp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1 diff --git a/init.qcom.wlan.sh b/init.qcom.wlan.sh deleted file mode 100644 index 0d14fabf..00000000 --- a/init.qcom.wlan.sh +++ /dev/null @@ -1,6 +0,0 @@ -#! /vendor/bin/sh - -wlan_driver_version=`cat /sys/kernel/wifi/wlan/driver_version` -setprop vendor.wlan.driver.version "$wlan_driver_version" -wlan_fw_version=`cat /sys/kernel/wifi/wlan/fw/0/version` -setprop vendor.wlan.firmware.version "$wlan_fw_version" diff --git a/init.ramoops.sh b/init.ramoops.sh index 4c57a1a1..37b69e54 100644 --- a/init.ramoops.sh +++ b/init.ramoops.sh @@ -1,4 +1,4 @@ -#!/system/bin/sh +#!/vendor/bin/sh # Decrypt the keys and write them to the kernel ramoops -D @@ -7,11 +7,11 @@ if [ $? -eq 0 ]; then # Pivot (and decrypt) echo 1 > /sys/devices/virtual/ramoops/pstore/use_alt else - setprop sys.ramoops.decryption.error $? + setprop vendor.ramoops.decryption.error $? fi # Trigger remount of pstore regardless of decryption state -setprop sys.ramoops.decrypted true +setprop vendor.ramoops.decrypted true # Generate keys (if none exist), and load the keys to carveout if [[ $(getprop ro.hardware) == "walleye" ]]; then diff --git a/manifest.xml b/manifest.xml index 25800a72..d708a3cd 100644 --- a/manifest.xml +++ b/manifest.xml @@ -2,7 +2,7 @@ android.hardware.audio hwbinder - 4.0 + 5.0 IDevicesFactory default @@ -11,7 +11,7 @@ android.hardware.audio.effect hwbinder - 4.0 + 5.0 IEffectsFactory default @@ -92,10 +92,10 @@ IDrmFactory default - @1.1::ICryptoFactory/clearkey - @1.1::IDrmFactory/clearkey - @1.1::ICryptoFactory/widevine - @1.1::IDrmFactory/widevine + @1.2::ICryptoFactory/clearkey + @1.2::IDrmFactory/clearkey + @1.2::ICryptoFactory/widevine + @1.2::IDrmFactory/widevine android.hardware.dumpstate @@ -145,7 +145,7 @@ android.hardware.graphics.mapper passthrough - 2.0 + 2.1 IMapper default @@ -219,11 +219,11 @@ - android.hardware.power + android.hardware.power.stats hwbinder - 1.2 + 1.0 - IPower + IPowerStats default @@ -270,7 +270,7 @@ android.hardware.soundtrigger hwbinder - 2.1 + 2.2 ISoundTriggerHw default @@ -294,15 +294,6 @@ default - - android.hardware.thermal - hwbinder - 1.1 - - IThermal - default - - android.hardware.usb hwbinder @@ -330,15 +321,6 @@ default - - android.hardware.vr - hwbinder - 1.0 - - IVr - default - - android.hardware.weaver hwbinder @@ -351,7 +333,7 @@ android.hardware.wifi hwbinder - 1.2 + 1.3 IWifi default @@ -360,7 +342,7 @@ android.hardware.wifi.hostapd hwbinder - 1.0 + 1.1 IHostapd default @@ -369,7 +351,7 @@ android.hardware.wifi.supplicant hwbinder - 1.1 + 1.2 ISupplicant default diff --git a/media_codecs.xml b/media_codecs.xml index 1e314e20..82580bc5 100644 --- a/media_codecs.xml +++ b/media_codecs.xml @@ -128,6 +128,11 @@ Only the three quirks included above are recognized at this point: + + + + + @@ -140,6 +145,9 @@ Only the three quirks included above are recognized at this point: + + + @@ -152,6 +160,9 @@ Only the three quirks included above are recognized at this point: + + + @@ -165,6 +176,11 @@ Only the three quirks included above are recognized at this point: + + + + + @@ -178,6 +194,11 @@ Only the three quirks included above are recognized at this point: + + + + + @@ -193,6 +214,9 @@ Only the three quirks included above are recognized at this point: + + + @@ -207,10 +231,13 @@ Only the three quirks included above are recognized at this point: + + + - + @@ -219,6 +246,8 @@ Only the three quirks included above are recognized at this point: + + @@ -230,6 +259,8 @@ Only the three quirks included above are recognized at this point: + + @@ -243,6 +274,9 @@ Only the three quirks included above are recognized at this point: + + + @@ -256,6 +290,9 @@ Only the three quirks included above are recognized at this point: + + + @@ -270,6 +307,9 @@ Only the three quirks included above are recognized at this point: + + + @@ -283,6 +323,9 @@ Only the three quirks included above are recognized at this point: + + + @@ -297,6 +340,9 @@ Only the three quirks included above are recognized at this point: + + + diff --git a/media_codecs_performance.xml b/media_codecs_performance.xml index d496f912..f08fd908 100644 --- a/media_codecs_performance.xml +++ b/media_codecs_performance.xml @@ -1,5 +1,5 @@ - - - - - + + + + + - - - - + + + + + + + + + + + - - - - - - + + + + + + + + - - - - - + + + + + + - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - - + + + + + - - - - + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + - - - + + + + + - - - - - - + + + + + + + + + + + - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml index 8856a017..11112fdd 100755 --- a/overlay/frameworks/base/core/res/res/values/config.xml +++ b/overlay/frameworks/base/core/res/res/values/config.xml @@ -73,6 +73,11 @@ 2 + + 2 + true @@ -217,6 +222,11 @@ 8 + + true + false @@ -232,7 +242,7 @@ - com.android.systemui/com.android.systemui.doze.DozeService + com.android.systemui/com.android.systemui.doze.DozeService @@ -255,7 +265,7 @@ true - org.codeaurora.ims + org.codeaurora.ims true @@ -350,12 +360,15 @@ true - - com.google.android.gms:com.google.android.GoogleCamera:com.google.intelligence.sense:com.google.android.settings.intelligence - Pixel 2 htc + + + true + + + true diff --git a/overlay/packages/apps/Bluetooth/res/values/config.xml b/overlay/packages/apps/Bluetooth/res/values/config.xml index 6db14c05..e4031055 100644 --- a/overlay/packages/apps/Bluetooth/res/values/config.xml +++ b/overlay/packages/apps/Bluetooth/res/values/config.xml @@ -29,4 +29,5 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --> true + true diff --git a/power-libperfmgr/InteractionHandler.cpp b/power-libperfmgr/InteractionHandler.cpp deleted file mode 100644 index b8ce3ef1..00000000 --- a/power-libperfmgr/InteractionHandler.cpp +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -//#define LOG_NDEBUG 0 - -#define LOG_TAG "android.hardware.power@1.2-service.wahoo-libperfmgr" -#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL) - -#include -#include -#include -#include -#include -#include -#include - -#include "InteractionHandler.h" - -#define FB_IDLE_PATH "/sys/class/graphics/fb0/idle_state" -#define MAX_LENGTH 64 - -#define MSINSEC 1000L -#define USINMS 1000000L - -InteractionHandler::InteractionHandler(std::shared_ptr const & hint_manager) - : mState(INTERACTION_STATE_UNINITIALIZED), - mWaitMs(100), - mMinDurationMs(1400), - mMaxDurationMs(5650), - mDurationMs(0), - mHintManager(hint_manager) { -} - -InteractionHandler::~InteractionHandler() { - Exit(); -} - -bool InteractionHandler::Init() { - std::lock_guard lk(mLock); - - if (mState != INTERACTION_STATE_UNINITIALIZED) - return true; - - mIdleFd = open(FB_IDLE_PATH, O_RDONLY); - if (mIdleFd < 0) { - ALOGE("Unable to open idle state path (%d)", errno); - return false; - } - - mEventFd = eventfd(0, EFD_NONBLOCK); - if (mEventFd < 0) { - ALOGE("Unable to create event fd (%d)", errno); - close(mIdleFd); - return false; - } - - mState = INTERACTION_STATE_IDLE; - mThread = std::unique_ptr( - new std::thread(&InteractionHandler::Routine, this)); - - return true; -} - -void InteractionHandler::Exit() { - std::unique_lock lk(mLock); - if (mState == INTERACTION_STATE_UNINITIALIZED) - return; - - AbortWaitLocked(); - mState = INTERACTION_STATE_UNINITIALIZED; - lk.unlock(); - - mCond.notify_all(); - mThread->join(); - - close(mEventFd); - close(mIdleFd); -} - -void InteractionHandler::PerfLock() { - ALOGV("%s: acquiring perf lock", __func__); - if (!mHintManager->DoHint("INTERACTION")) { - ALOGE("%s: do hint INTERACTION failed", __func__); - } - ATRACE_INT("interaction_lock", 1); -} - -void InteractionHandler::PerfRel() { - ALOGV("%s: releasing perf lock", __func__); - if (!mHintManager->EndHint("INTERACTION")) { - ALOGE("%s: end hint INTERACTION failed", __func__); - } - ATRACE_INT("interaction_lock", 0); -} - -long long InteractionHandler::CalcTimespecDiffMs(struct timespec start, - struct timespec end) { - long long diff_in_us = 0; - diff_in_us += (end.tv_sec - start.tv_sec) * MSINSEC; - diff_in_us += (end.tv_nsec - start.tv_nsec) / USINMS; - return diff_in_us; -} - -void InteractionHandler::Acquire(int32_t duration) { - ATRACE_CALL(); - - std::lock_guard lk(mLock); - if (mState == INTERACTION_STATE_UNINITIALIZED) { - ALOGW("%s: called while uninitialized", __func__); - return; - } - - int inputDuration = duration + 650; - int finalDuration; - if (inputDuration > mMaxDurationMs) - finalDuration = mMaxDurationMs; - else if (inputDuration > mMinDurationMs) - finalDuration = inputDuration; - else - finalDuration = mMinDurationMs; - - struct timespec cur_timespec; - clock_gettime(CLOCK_MONOTONIC, &cur_timespec); - if (mState != INTERACTION_STATE_IDLE && finalDuration <= mDurationMs) { - long long elapsed_time = CalcTimespecDiffMs(mLastTimespec, cur_timespec); - // don't hint if previous hint's duration covers this hint's duration - if (elapsed_time <= (mDurationMs - finalDuration)) { - ALOGV("%s: Previous duration (%d) cover this (%d) elapsed: %lld", - __func__, mDurationMs, finalDuration, elapsed_time); - return; - } - } - mLastTimespec = cur_timespec; - mDurationMs = finalDuration; - - ALOGV("%s: input: %d final duration: %d", __func__, - duration, finalDuration); - - if (mState == INTERACTION_STATE_WAITING) - AbortWaitLocked(); - else if (mState == INTERACTION_STATE_IDLE) - PerfLock(); - - mState = INTERACTION_STATE_INTERACTION; - mCond.notify_one(); -} - -void InteractionHandler::Release() { - std::lock_guard lk(mLock); - if (mState == INTERACTION_STATE_WAITING) { - ATRACE_CALL(); - PerfRel(); - mState = INTERACTION_STATE_IDLE; - } else { - // clear any wait aborts pending in event fd - uint64_t val; - ssize_t ret = read(mEventFd, &val, sizeof(val)); - - ALOGW_IF(ret < 0, "%s: failed to clear eventfd (%zd, %d)", - __func__, ret, errno); - } -} - -// should be called while locked -void InteractionHandler::AbortWaitLocked() { - uint64_t val = 1; - ssize_t ret = write(mEventFd, &val, sizeof(val)); - if (ret != sizeof(val)) - ALOGW("Unable to write to event fd (%zd)", ret); -} - -void InteractionHandler::WaitForIdle(int32_t wait_ms, int32_t timeout_ms) { - char data[MAX_LENGTH]; - ssize_t ret; - struct pollfd pfd[2]; - - ATRACE_CALL(); - - ALOGV("%s: wait:%d timeout:%d", __func__, wait_ms, timeout_ms); - - pfd[0].fd = mEventFd; - pfd[0].events = POLLIN; - pfd[1].fd = mIdleFd; - pfd[1].events = POLLPRI | POLLERR; - - ret = poll(pfd, 1, wait_ms); - if (ret > 0) { - ALOGV("%s: wait aborted", __func__); - return; - } else if (ret < 0) { - ALOGE("%s: error in poll while waiting", __func__); - return; - } - - ret = pread(mIdleFd, data, sizeof(data), 0); - if (!ret) { - ALOGE("%s: Unexpected EOF!", __func__); - return; - } - - if (!strncmp(data, "idle", 4)) { - ALOGV("%s: already idle", __func__); - return; - } - - ret = poll(pfd, 2, timeout_ms); - if (ret < 0) - ALOGE("%s: Error on waiting for idle (%zd)", __func__, ret); - else if (ret == 0) - ALOGV("%s: timed out waiting for idle", __func__); - else if (pfd[0].revents) - ALOGV("%s: wait for idle aborted", __func__); - else if (pfd[1].revents) - ALOGV("%s: idle detected", __func__); -} - -void InteractionHandler::Routine() { - std::unique_lock lk(mLock, std::defer_lock); - - while (true) { - lk.lock(); - mCond.wait(lk, [&] { return mState != INTERACTION_STATE_IDLE; }); - if (mState == INTERACTION_STATE_UNINITIALIZED) - return; - mState = INTERACTION_STATE_WAITING; - lk.unlock(); - - WaitForIdle(mWaitMs, mDurationMs); - Release(); - } -} diff --git a/power-libperfmgr/InteractionHandler.h b/power-libperfmgr/InteractionHandler.h deleted file mode 100644 index 893c72f0..00000000 --- a/power-libperfmgr/InteractionHandler.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INTERACTIONHANDLER_H -#define INTERACTIONHANDLER_H - -#include -#include -#include - -#include - -using ::android::perfmgr::HintManager; - -enum interaction_state { - INTERACTION_STATE_UNINITIALIZED, - INTERACTION_STATE_IDLE, - INTERACTION_STATE_INTERACTION, - INTERACTION_STATE_WAITING, -}; - -struct InteractionHandler { - InteractionHandler(std::shared_ptr const & hint_manager); - ~InteractionHandler(); - bool Init(); - void Exit(); - void Acquire(int32_t duration); - - private: - void Release(); - void WaitForIdle(int32_t wait_ms, int32_t timeout_ms); - void AbortWaitLocked(); - void Routine(); - - void PerfLock(); - void PerfRel(); - - long long CalcTimespecDiffMs(struct timespec start, struct timespec end); - - enum interaction_state mState; - - int mIdleFd; - int mEventFd; - - int32_t mWaitMs; - int32_t mMinDurationMs; - int32_t mMaxDurationMs; - int32_t mDurationMs; - - struct timespec mLastTimespec; - - std::unique_ptr mThread; - std::mutex mLock; - std::condition_variable mCond; - std::shared_ptr mHintManager; -}; - -#endif //INTERACTIONHANDLER_H diff --git a/power-libperfmgr/Power.cpp b/power-libperfmgr/Power.cpp deleted file mode 100644 index 8a009c33..00000000 --- a/power-libperfmgr/Power.cpp +++ /dev/null @@ -1,546 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL) -#define LOG_TAG "android.hardware.power@1.2-service.wahoo-libperfmgr" - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include "Power.h" -#include "power-helper.h" - -/* RPM runs at 19.2Mhz. Divide by 19200 for msec */ -#define RPM_CLK 19200 - -extern struct stat_pair rpm_stat_map[]; - -namespace android { -namespace hardware { -namespace power { -namespace V1_2 { -namespace implementation { - -using ::android::hardware::power::V1_0::Feature; -using ::android::hardware::power::V1_0::PowerStatePlatformSleepState; -using ::android::hardware::power::V1_0::Status; -using ::android::hardware::power::V1_1::PowerStateSubsystem; -using ::android::hardware::power::V1_1::PowerStateSubsystemSleepState; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; - -Power::Power() : - mHintManager(HintManager::GetFromJSON("/vendor/etc/powerhint.json")), - mInteractionHandler(mHintManager), - mVRModeOn(false), - mSustainedPerfModeOn(false), - mEncoderModeOn(false) { - mInteractionHandler.Init(); - - std::string state = android::base::GetProperty(kPowerHalStateProp, ""); - if (state == "VIDEO_ENCODE") { - ALOGI("Initialize with VIDEO_ENCODE on"); - mHintManager->DoHint("VIDEO_ENCODE"); - mEncoderModeOn = true; - } else if (state == "SUSTAINED_PERFORMANCE") { - ALOGI("Initialize with SUSTAINED_PERFORMANCE on"); - mHintManager->DoHint("SUSTAINED_PERFORMANCE"); - mSustainedPerfModeOn = true; - } else if (state == "VR_MODE") { - ALOGI("Initialize with VR_MODE on"); - mHintManager->DoHint("VR_MODE"); - mVRModeOn = true; - } else if (state == "VR_SUSTAINED_PERFORMANCE") { - ALOGI("Initialize with SUSTAINED_PERFORMANCE and VR_MODE on"); - mHintManager->DoHint("VR_SUSTAINED_PERFORMANCE"); - mSustainedPerfModeOn = true; - mVRModeOn = true; - } else { - ALOGI("Initialize PowerHAL"); - } - - state = android::base::GetProperty(kPowerHalAudioProp, ""); - if (state == "LOW_LATENCY") { - ALOGI("Initialize with AUDIO_LOW_LATENCY on"); - mHintManager->DoHint("AUDIO_LOW_LATENCY"); - } -} - -// Methods from ::android::hardware::power::V1_0::IPower follow. -Return Power::setInteractive(bool /* interactive */) { - return Void(); -} - -Return Power::powerHint(PowerHint_1_0 hint, int32_t data) { - if (!isSupportedGovernor()) { - return Void(); - } - - switch(hint) { - case PowerHint_1_0::INTERACTION: - if (mVRModeOn || mSustainedPerfModeOn) { - ALOGV("%s: ignoring due to other active perf hints", __func__); - } else { - mInteractionHandler.Acquire(data); - } - break; - case PowerHint_1_0::VIDEO_ENCODE: - if (mVRModeOn || mSustainedPerfModeOn) { - ALOGV("%s: ignoring due to other active perf hints", __func__); - break; - } - ATRACE_BEGIN("video_encode"); - if (mVRModeOn || mSustainedPerfModeOn) { - ALOGV("%s: ignoring due to other active perf hints", __func__); - } else { - if (data) { - // Hint until canceled - ATRACE_INT("video_encode_lock", 1); - mHintManager->DoHint("VIDEO_ENCODE"); - ALOGD("VIDEO_ENCODE ON"); - if (!android::base::SetProperty(kPowerHalStateProp, "VIDEO_ENCODE")) { - ALOGE("%s: could not set powerHAL state property to VIDEO_ENCODE", __func__); - } - mEncoderModeOn = true; - } else { - ATRACE_INT("video_encode_lock", 0); - mHintManager->EndHint("VIDEO_ENCODE"); - ALOGD("VIDEO_ENCODE OFF"); - if (!android::base::SetProperty(kPowerHalStateProp, "")) { - ALOGE("%s: could not clear powerHAL state property", __func__); - } - mEncoderModeOn = false; - } - } - ATRACE_END(); - break; - case PowerHint_1_0::SUSTAINED_PERFORMANCE: - if (data && !mSustainedPerfModeOn) { - ALOGD("SUSTAINED_PERFORMANCE ON"); - if (!mVRModeOn) { // Sustained mode only. - mHintManager->DoHint("SUSTAINED_PERFORMANCE"); - if (!android::base::SetProperty(kPowerHalStateProp, "SUSTAINED_PERFORMANCE")) { - ALOGE("%s: could not set powerHAL state property to SUSTAINED_PERFORMANCE", __func__); - } - } else { // Sustained + VR mode. - mHintManager->EndHint("VR_MODE"); - mHintManager->DoHint("VR_SUSTAINED_PERFORMANCE"); - if (!android::base::SetProperty(kPowerHalStateProp, "VR_SUSTAINED_PERFORMANCE")) { - ALOGE("%s: could not set powerHAL state property to VR_SUSTAINED_PERFORMANCE", __func__); - } - } - mSustainedPerfModeOn = true; - } else if (!data && mSustainedPerfModeOn) { - ALOGD("SUSTAINED_PERFORMANCE OFF"); - mHintManager->EndHint("VR_SUSTAINED_PERFORMANCE"); - mHintManager->EndHint("SUSTAINED_PERFORMANCE"); - if (mVRModeOn) { // Switch back to VR Mode. - mHintManager->DoHint("VR_MODE"); - if (!android::base::SetProperty(kPowerHalStateProp, "VR_MODE")) { - ALOGE("%s: could not set powerHAL state property to VR_MODE", __func__); - } - } else { - if (!android::base::SetProperty(kPowerHalStateProp, "")) { - ALOGE("%s: could not clear powerHAL state property", __func__); - } - } - mSustainedPerfModeOn = false; - } - break; - case PowerHint_1_0::VR_MODE: - if (data && !mVRModeOn) { - ALOGD("VR_MODE ON"); - if (!mSustainedPerfModeOn) { // VR mode only. - mHintManager->DoHint("VR_MODE"); - if (!android::base::SetProperty(kPowerHalStateProp, "VR_MODE")) { - ALOGE("%s: could not set powerHAL state property to VR_MODE", __func__); - } - } else { // Sustained + VR mode. - mHintManager->EndHint("SUSTAINED_PERFORMANCE"); - mHintManager->DoHint("VR_SUSTAINED_PERFORMANCE"); - if (!android::base::SetProperty(kPowerHalStateProp, "VR_SUSTAINED_PERFORMANCE")) { - ALOGE("%s: could not set powerHAL state property to VR_SUSTAINED_PERFORMANCE", __func__); - } - } - mVRModeOn = true; - } else if (!data && mVRModeOn) { - ALOGD("VR_MODE OFF"); - mHintManager->EndHint("VR_SUSTAINED_PERFORMANCE"); - mHintManager->EndHint("VR_MODE"); - if (mSustainedPerfModeOn) { // Switch back to sustained Mode. - mHintManager->DoHint("SUSTAINED_PERFORMANCE"); - if (!android::base::SetProperty(kPowerHalStateProp, "SUSTAINED_PERFORMANCE")) { - ALOGE("%s: could not set powerHAL state property to SUSTAINED_PERFORMANCE", __func__); - } - } else { - if (!android::base::SetProperty(kPowerHalStateProp, "")) { - ALOGE("%s: could not clear powerHAL state property", __func__); - } - } - mVRModeOn = false; - } - break; - case PowerHint_1_0::LAUNCH: - ATRACE_BEGIN("launch"); - if (mVRModeOn || mSustainedPerfModeOn) { - ALOGV("%s: ignoring due to other active perf hints", __func__); - } else { - if (data) { - // Hint until canceled - ATRACE_INT("launch_lock", 1); - mHintManager->DoHint("LAUNCH"); - ALOGD("LAUNCH ON"); - } else { - ATRACE_INT("launch_lock", 0); - mHintManager->EndHint("LAUNCH"); - ALOGD("LAUNCH OFF"); - } - } - ATRACE_END(); - break; - default: - break; - - } - return Void(); -} - -Return Power::setFeature(Feature /*feature*/, bool /*activate*/) { - //Nothing to do - return Void(); -} - -Return Power::getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) { - - hidl_vec states; - uint64_t stats[MAX_PLATFORM_STATS * MAX_RPM_PARAMS] = {0}; - uint64_t *values; - struct PowerStatePlatformSleepState *state; - int ret; - - states.resize(PLATFORM_SLEEP_MODES_COUNT); - - ret = extract_platform_stats(stats); - if (ret != 0) { - states.resize(0); - goto done; - } - - /* Update statistics for XO_shutdown */ - state = &states[RPM_MODE_XO]; - state->name = "XO_shutdown"; - values = stats + (RPM_MODE_XO * MAX_RPM_PARAMS); - - state->residencyInMsecSinceBoot = values[1]; - state->totalTransitions = values[0]; - state->supportedOnlyInSuspend = false; - state->voters.resize(XO_VOTERS); - for(size_t i = 0; i < XO_VOTERS; i++) { - int voter = static_cast(i + XO_VOTERS_START); - state->voters[i].name = rpm_stat_map[voter].label; - values = stats + (voter * MAX_RPM_PARAMS); - state->voters[i].totalTimeInMsecVotedForSinceBoot = values[0] / RPM_CLK; - state->voters[i].totalNumberOfTimesVotedSinceBoot = values[1]; - } - - /* Update statistics for VMIN state */ - state = &states[RPM_MODE_VMIN]; - state->name = "VMIN"; - values = stats + (RPM_MODE_VMIN * MAX_RPM_PARAMS); - - state->residencyInMsecSinceBoot = values[1]; - state->totalTransitions = values[0]; - state->supportedOnlyInSuspend = false; - state->voters.resize(VMIN_VOTERS); - //Note: No filling of state voters since VMIN_VOTERS = 0 - -done: - _hidl_cb(states, Status::SUCCESS); - return Void(); -} - -static int get_wlan_low_power_stats(struct PowerStateSubsystem *subsystem) { - uint64_t stats[WLAN_POWER_PARAMS_COUNT] = {0}; - struct PowerStateSubsystemSleepState *state; - - subsystem->name = "wlan"; - - if (extract_wlan_stats(stats) != 0) { - subsystem->states.resize(0); - return -1; - } - - subsystem->states.resize(WLAN_STATES_COUNT); - - /* Update statistics for Active State */ - state = &subsystem->states[WLAN_STATE_ACTIVE]; - state->name = "Active"; - state->residencyInMsecSinceBoot = stats[CUMULATIVE_TOTAL_ON_TIME_MS]; - state->totalTransitions = stats[DEEP_SLEEP_ENTER_COUNTER]; - state->lastEntryTimestampMs = 0; //FIXME need a new value from Qcom - state->supportedOnlyInSuspend = false; - - /* Update statistics for Deep-Sleep state */ - state = &subsystem->states[WLAN_STATE_DEEP_SLEEP]; - state->name = "Deep-Sleep"; - state->residencyInMsecSinceBoot = stats[CUMULATIVE_SLEEP_TIME_MS]; - state->totalTransitions = stats[DEEP_SLEEP_ENTER_COUNTER]; - state->lastEntryTimestampMs = stats[LAST_DEEP_SLEEP_ENTER_TSTAMP_MS]; - state->supportedOnlyInSuspend = false; - - return 0; -} - -enum easel_state { - EASEL_OFF = 0, - EASEL_ON, - EASEL_SUSPENDED, - NUM_EASEL_STATES -}; - -// Get low power stats for easel subsystem -static int get_easel_low_power_stats(struct PowerStateSubsystem *subsystem) { - // This implementation is a workaround to provide minimal visibility into - // Easel state behavior until canonical low power stats are supported. - // It takes an "external observer" snapshot of the current Easel state every - // time it is called, and synthesizes an artificial sleep state that will - // behave similarly to real stats if Easel gets "wedged" in the "on" state. - static std::mutex statsLock; - static uint64_t totalOnSnapshotCount = 0; - static uint64_t totalNotOnSnapshotCount = 0; - unsigned long currentState; - struct PowerStateSubsystemSleepState *state; - - subsystem->name = "Easel"; - - if (get_easel_state(¤tState) != 0) { - subsystem->states.resize(0); - return -1; - } - - if (currentState >= NUM_EASEL_STATES) { - ALOGE("%s: unrecognized Easel state(%lu)", __func__, currentState); - return -1; - } - - subsystem->states.resize(1); - - // Since we are storing stats locally but can have multiple parallel - // callers, locking is required to ensure stats are not corrupted. - std::lock_guard lk(statsLock); - - // Update statistics for synthetic sleep state. We combine OFF and - // SUSPENDED to act as a composite "not on" state so the numbers will behave - // like a real sleep state. - if ((currentState == EASEL_OFF) || (currentState == EASEL_SUSPENDED)) { - totalNotOnSnapshotCount++; - } else { - totalOnSnapshotCount++; - } - - // Update statistics for synthetic sleep state, where - // totalTransitions = cumulative count of Easel state0 (as seen by PowerHAL) - // residencyInMsecsSinceBoot = cumulative count of Easel state1 (as seen by - // PowerHAL) - // lastEntryTimestampMs = cumulative count of Easel state2 (as seen by - // PowerHAL) - state = &subsystem->states[0]; - state->name = "SyntheticSleep"; - state->totalTransitions = totalOnSnapshotCount; - state->residencyInMsecSinceBoot = totalNotOnSnapshotCount; - state->lastEntryTimestampMs = 0; // No added value for the workaround - state->supportedOnlyInSuspend = false; - - return 0; -} - -// Methods from ::android::hardware::power::V1_1::IPower follow. -Return Power::getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) { - hidl_vec subsystems; - - subsystems.resize(SUBSYSTEM_COUNT); - - // Get WLAN subsystem low power stats. - if (get_wlan_low_power_stats(&subsystems[SUBSYSTEM_WLAN]) != 0) { - ALOGE("%s: failed to process wlan stats", __func__); - } - - // Get Easel subsystem low power stats. - if (get_easel_low_power_stats(&subsystems[SUBSYSTEM_EASEL]) != 0) { - ALOGE("%s: failed to process Easel stats", __func__); - } - - _hidl_cb(subsystems, Status::SUCCESS); - return Void(); -} - -bool Power::isSupportedGovernor() { - std::string buf; - if (android::base::ReadFileToString("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", &buf)) { - buf = android::base::Trim(buf); - } - // Only support EAS 1.2, legacy EAS - if (buf == "schedutil" || buf == "sched") { - return true; - } else { - LOG(ERROR) << "Governor not supported by powerHAL, skipping"; - return false; - } -} - -Return Power::powerHintAsync(PowerHint_1_0 hint, int32_t data) { - // just call the normal power hint in this oneway function - return powerHint(hint, data); -} - -// Methods from ::android::hardware::power::V1_2::IPower follow. -Return Power::powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) { - if (!isSupportedGovernor()) { - return Void(); - } - - switch(hint) { - case PowerHint_1_2::AUDIO_LOW_LATENCY: - ATRACE_BEGIN("audio_low_latency"); - if (data) { - // Hint until canceled - ATRACE_INT("audio_low_latency_lock", 1); - mHintManager->DoHint("AUDIO_LOW_LATENCY"); - ALOGD("AUDIO LOW LATENCY ON"); - if (!android::base::SetProperty(kPowerHalAudioProp, "LOW_LATENCY")) { - ALOGE("%s: could not set powerHAL audio state property to LOW_LATENCY", __func__); - } - } else { - ATRACE_INT("audio_low_latency_lock", 0); - mHintManager->EndHint("AUDIO_LOW_LATENCY"); - ALOGD("AUDIO LOW LATENCY OFF"); - if (!android::base::SetProperty(kPowerHalAudioProp, "")) { - ALOGE("%s: could not clear powerHAL audio state property", __func__); - } - } - ATRACE_END(); - break; - case PowerHint_1_2::AUDIO_STREAMING: - ATRACE_BEGIN("audio_streaming"); - if (mVRModeOn || mSustainedPerfModeOn) { - ALOGV("%s: ignoring due to other active perf hints", __func__); - } else { - if (data) { - // Hint until canceled - ATRACE_INT("audio_streaming_lock", 1); - mHintManager->DoHint("AUDIO_STREAMING"); - ALOGD("AUDIO STREAMING ON"); - } else { - ATRACE_INT("audio_streaming_lock", 0); - mHintManager->EndHint("AUDIO_STREAMING"); - ALOGD("AUDIO STREAMING OFF"); - } - } - ATRACE_END(); - break; - case PowerHint_1_2::CAMERA_LAUNCH: - ATRACE_BEGIN("camera_launch"); - if (data > 0) { - ATRACE_INT("camera_launch_lock", 1); - mHintManager->DoHint("CAMERA_LAUNCH", std::chrono::milliseconds(data)); - ALOGD("CAMERA LAUNCH ON: %d MS, LAUNCH ON: 2500 MS", data); - // boosts 2.5s for launching - mHintManager->DoHint("LAUNCH", std::chrono::milliseconds(2500)); - } else if (data == 0) { - ATRACE_INT("camera_launch_lock", 0); - mHintManager->EndHint("CAMERA_LAUNCH"); - ALOGD("CAMERA LAUNCH OFF"); - } else { - ALOGE("CAMERA LAUNCH INVALID DATA: %d", data); - } - ATRACE_END(); - break; - case PowerHint_1_2::CAMERA_STREAMING: - ATRACE_BEGIN("camera_streaming"); - if (data > 0) { - ATRACE_INT("camera_streaming_lock", 1); - mHintManager->DoHint("CAMERA_STREAMING", std::chrono::milliseconds(data)); - ALOGD("CAMERA STREAMING ON: %d MS", data); - } else if (data == 0) { - ATRACE_INT("camera_streaming_lock", 0); - mHintManager->EndHint("CAMERA_STREAMING"); - ALOGD("CAMERA STREAMING OFF"); - } else { - ALOGE("CAMERA STREAMING INVALID DATA: %d", data); - } - ATRACE_END(); - break; - case PowerHint_1_2::CAMERA_SHOT: - ATRACE_BEGIN("camera_shot"); - if (data > 0) { - ATRACE_INT("camera_shot_lock", 1); - mHintManager->DoHint("CAMERA_SHOT", std::chrono::milliseconds(data)); - ALOGD("CAMERA SHOT ON: %d MS", data); - } else if (data == 0) { - ATRACE_INT("camera_shot_lock", 0); - mHintManager->EndHint("CAMERA_SHOT"); - ALOGD("CAMERA SHOT OFF"); - } else { - ALOGE("CAMERA SHOT INVALID DATA: %d", data); - } - ATRACE_END(); - break; - default: - return powerHint(static_cast(hint), data); - } - return Void(); -} - -constexpr const char* boolToString(bool b) { - return b ? "true" : "false"; -} - -Return Power::debug(const hidl_handle& handle, const hidl_vec&) { - if (handle != nullptr && handle->numFds >= 1) { - int fd = handle->data[0]; - - std::string buf(android::base::StringPrintf("HintManager Running: %s\n" - "VRMode: %s\n" - "SustainedPerformanceMode: %s\n" - "VideoEncodeMode: %s\n", - boolToString(mHintManager->IsRunning()), - boolToString(mVRModeOn), - boolToString(mSustainedPerfModeOn), - boolToString(mEncoderModeOn))); - // Dump nodes through libperfmgr - mHintManager->DumpToFd(fd); - if (!android::base::WriteStringToFd(buf, fd)) { - PLOG(ERROR) << "Failed to dump state to fd"; - } - fsync(fd); - } - return Void(); -} - -} // namespace implementation -} // namespace V1_2 -} // namespace power -} // namespace hardware -} // namespace android diff --git a/power-libperfmgr/Power.h b/power-libperfmgr/Power.h deleted file mode 100644 index a39323f2..00000000 --- a/power-libperfmgr/Power.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_HARDWARE_POWER_V1_2_POWER_H -#define ANDROID_HARDWARE_POWER_V1_2_POWER_H - -#include - -#include -#include -#include -#include - -#include "InteractionHandler.h" - -namespace android { -namespace hardware { -namespace power { -namespace V1_2 { -namespace implementation { - -using ::android::hardware::power::V1_0::Feature; -using ::android::hardware::power::V1_2::IPower; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::InteractionHandler; -using PowerHint_1_0 = ::android::hardware::power::V1_0::PowerHint; -using PowerHint_1_2 = ::android::hardware::power::V1_2::PowerHint; -using ::android::perfmgr::HintManager; - -constexpr char kPowerHalStateProp[] = "vendor.powerhal.state"; -constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio"; - -struct Power : public IPower { - // Methods from ::android::hardware::power::V1_0::IPower follow. - - Power(); - - Return setInteractive(bool /* interactive */) override; - Return powerHint(PowerHint_1_0 hint, int32_t data) override; - Return setFeature(Feature feature, bool activate) override; - Return getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) override; - - // Methods from ::android::hardware::power::V1_1::IPower follow. - Return getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) override; - Return powerHintAsync(PowerHint_1_0 hint, int32_t data) override; - - // Methods from ::android::hardware::power::V1_2::IPower follow. - Return powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) override; - - // Methods from ::android::hidl::base::V1_0::IBase follow. - Return debug(const hidl_handle& fd, const hidl_vec& args) override; - - private: - static bool isSupportedGovernor(); - - std::shared_ptr mHintManager; - InteractionHandler mInteractionHandler; - std::atomic mVRModeOn; - std::atomic mSustainedPerfModeOn; - std::atomic mEncoderModeOn; -}; - -} // namespace implementation -} // namespace V1_2 -} // namespace power -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_POWER_V1_2_POWER_H diff --git a/power-libperfmgr/android.hardware.power@1.2-service.wahoo-libperfmgr.rc b/power-libperfmgr/android.hardware.power@1.2-service.wahoo-libperfmgr.rc deleted file mode 100644 index d77b8f05..00000000 --- a/power-libperfmgr/android.hardware.power@1.2-service.wahoo-libperfmgr.rc +++ /dev/null @@ -1,21 +0,0 @@ -service vendor.power-hal-1-2 /vendor/bin/hw/android.hardware.power@1.2-service.wahoo-libperfmgr - class hal - user system - group system - -# restart powerHAL when framework died -on property:init.svc.zygote=restarting && property:vendor.powerhal.state=* - setprop vendor.powerhal.state "" - setprop vendor.powerhal.audio "" - restart vendor.power-hal-1-2 - -# restart powerHAL when cameraHAL died -on property:init.svc.vendor.camera-provider-2-4=restarting && property:vendor.powerhal.state=VIDEO_ENCODE - setprop vendor.powerhal.state "" - setprop vendor.powerhal.audio "" - restart vendor.power-hal-1-2 - -# restart powerHAL when audioHAL died -on property:init.svc.vendor.audio-hal-2-0=restarting && property:vendor.powerhal.audio=LOW_LATENCY - setprop vendor.powerhal.audio "" - restart vendor.power-hal-1-2 diff --git a/power-libperfmgr/power-helper.c b/power-libperfmgr/power-helper.c deleted file mode 100644 index 059e358c..00000000 --- a/power-libperfmgr/power-helper.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#define LOG_NIDEBUG 0 -#define LOG_TAG "android.hardware.power@1.2-service.wahoo-libperfmgr" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "power-helper.h" - -#ifndef RPM_SYSTEM_STAT -#define RPM_SYSTEM_STAT "/d/system_stats" -#endif - -#ifndef WLAN_POWER_STAT -#define WLAN_POWER_STAT "/d/wlan0/power_stats" -#endif - -#ifndef EASEL_STATE_FILE -#define EASEL_STATE_FILE "/sys/devices/virtual/misc/mnh_sm/state" -#endif - -#define ARRAY_SIZE(x) (sizeof((x))/sizeof((x)[0])) -#define LINE_SIZE 128 - -const char *rpm_stat_params[MAX_RPM_PARAMS] = { - "count", - "actual last sleep(msec)", -}; - -const char *master_stat_params[MAX_RPM_PARAMS] = { - "Accumulated XO duration", - "XO Count", -}; - -struct stat_pair rpm_stat_map[] = { - { RPM_MODE_XO, "RPM Mode:vlow", rpm_stat_params, ARRAY_SIZE(rpm_stat_params) }, - { RPM_MODE_VMIN, "RPM Mode:vmin", rpm_stat_params, ARRAY_SIZE(rpm_stat_params) }, - { VOTER_APSS, "APSS", master_stat_params, ARRAY_SIZE(master_stat_params) }, - { VOTER_MPSS, "MPSS", master_stat_params, ARRAY_SIZE(master_stat_params) }, - { VOTER_ADSP, "ADSP", master_stat_params, ARRAY_SIZE(master_stat_params) }, - { VOTER_SLPI, "SLPI", master_stat_params, ARRAY_SIZE(master_stat_params) }, -}; - - -const char *wlan_power_stat_params[] = { - "cumulative_sleep_time_ms", - "cumulative_total_on_time_ms", - "deep_sleep_enter_counter", - "last_deep_sleep_enter_tstamp_ms" -}; - -struct stat_pair wlan_stat_map[] = { - { WLAN_POWER_DEBUG_STATS, "POWER DEBUG STATS", wlan_power_stat_params, ARRAY_SIZE(wlan_power_stat_params) }, -}; - -static int parse_stats(const char **params, size_t params_size, - uint64_t *list, FILE *fp) { - ssize_t nread; - size_t len = LINE_SIZE; - char *line; - size_t params_read = 0; - size_t i; - - line = malloc(len); - if (!line) { - ALOGE("%s: no memory to hold line", __func__); - return -ENOMEM; - } - - while ((params_read < params_size) && - (nread = getline(&line, &len, fp) > 0)) { - char *key = line + strspn(line, " \t"); - char *value = strchr(key, ':'); - if (!value || (value > (line + len))) - continue; - *value++ = '\0'; - - for (i = 0; i < params_size; i++) { - if (!strcmp(key, params[i])) { - list[i] = strtoull(value, NULL, 0); - params_read++; - break; - } - } - } - free(line); - - return 0; -} - - -static int extract_stats(uint64_t *list, char *file, - struct stat_pair *map, size_t map_size) { - FILE *fp; - ssize_t read; - size_t len = LINE_SIZE; - char *line; - size_t i, stats_read = 0; - int ret = 0; - - fp = fopen(file, "re"); - if (fp == NULL) { - ALOGE("%s: failed to open: %s Error = %s", __func__, file, strerror(errno)); - return -errno; - } - - line = malloc(len); - if (!line) { - ALOGE("%s: no memory to hold line", __func__); - fclose(fp); - return -ENOMEM; - } - - while ((stats_read < map_size) && (read = getline(&line, &len, fp) != -1)) { - size_t begin = strspn(line, " \t"); - - for (i = 0; i < map_size; i++) { - if (!strncmp(line + begin, map[i].label, strlen(map[i].label))) { - stats_read++; - break; - } - } - - if (i == map_size) - continue; - - ret = parse_stats(map[i].parameters, map[i].num_parameters, - &list[map[i].stat * MAX_RPM_PARAMS], fp); - if (ret < 0) - break; - } - free(line); - fclose(fp); - - return ret; -} - -int extract_platform_stats(uint64_t *list) { - return extract_stats(list, RPM_SYSTEM_STAT, rpm_stat_map, ARRAY_SIZE(rpm_stat_map)); -} - -int extract_wlan_stats(uint64_t *list) { - return extract_stats(list, WLAN_POWER_STAT, wlan_stat_map, ARRAY_SIZE(wlan_stat_map)); -} - -int get_easel_state(unsigned long *current_state) { - FILE *fp = NULL; - static const size_t EASEL_STATE_LINE_SIZE = 16; - char buffer[EASEL_STATE_LINE_SIZE]; - char *parse_end = buffer; - unsigned long state; - - if (current_state == NULL) { - ALOGD("%s: null current_state pointer from caller", __func__); - return -1; - } - - fp = fopen(EASEL_STATE_FILE, "re"); - if (fp == NULL) { - ALOGE("%s: failed to open: %s Error = %s", __func__, EASEL_STATE_FILE, - strerror(errno)); - return -errno; - } - - if (fgets(buffer, EASEL_STATE_LINE_SIZE, fp) == NULL) { - fclose(fp); - ALOGE("%s: failed to read: %s", __func__, EASEL_STATE_FILE); - return -1; - } - - fclose(fp); - - parse_end = buffer; - state = strtoul(buffer, &parse_end, 10); - if ((parse_end == buffer) || (state > 2)) { - ALOGE("%s: unrecognized format: %s '%s'", __func__, EASEL_STATE_FILE, - buffer); - return -1; - } - - *current_state = state; - - return 0; -} - diff --git a/power-libperfmgr/power-helper.h b/power-libperfmgr/power-helper.h deleted file mode 100644 index 0e12396b..00000000 --- a/power-libperfmgr/power-helper.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __POWER_HELPER_H__ -#define __POWER_HELPER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -enum stats_type { - //Platform Stats - RPM_MODE_XO = 0, - RPM_MODE_VMIN, - RPM_MODE_MAX, - XO_VOTERS_START = RPM_MODE_MAX, - VOTER_APSS = XO_VOTERS_START, - VOTER_MPSS, - VOTER_ADSP, - VOTER_SLPI, - MAX_PLATFORM_STATS, - - //WLAN Stats - WLAN_POWER_DEBUG_STATS = 0, - MAX_WLAN_STATS, -}; - -enum subsystem_type { - SUBSYSTEM_WLAN = 0, - SUBSYSTEM_EASEL, - - //Don't add any lines after this line - SUBSYSTEM_COUNT -}; - -enum wlan_sleep_states { - WLAN_STATE_ACTIVE = 0, - WLAN_STATE_DEEP_SLEEP, - - //Don't add any lines after this line - WLAN_STATES_COUNT -}; - -enum wlan_power_params { - CUMULATIVE_SLEEP_TIME_MS = 0, - CUMULATIVE_TOTAL_ON_TIME_MS, - DEEP_SLEEP_ENTER_COUNTER, - LAST_DEEP_SLEEP_ENTER_TSTAMP_MS, - - //Don't add any lines after this line - WLAN_POWER_PARAMS_COUNT -}; - - -#define PLATFORM_SLEEP_MODES_COUNT RPM_MODE_MAX - -#define MAX_RPM_PARAMS 2 -#define XO_VOTERS (MAX_PLATFORM_STATS - XO_VOTERS_START) -#define VMIN_VOTERS 0 - -struct stat_pair { - enum stats_type stat; - const char *label; - const char **parameters; - size_t num_parameters; -}; - -int extract_platform_stats(uint64_t *list); -int extract_wlan_stats(uint64_t *list); -int get_easel_state(unsigned long *current_state); - -#ifdef __cplusplus -} -#endif - -#endif //__POWER_HELPER_H__ diff --git a/power-libperfmgr/service.cpp b/power-libperfmgr/service.cpp deleted file mode 100644 index c128f95d..00000000 --- a/power-libperfmgr/service.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "android.hardware.power@1.2-service.wahoo-libperfmgr" - -#include -#include - -#include "Power.h" - -using android::sp; -using android::status_t; -using android::OK; - -// libhwbinder: -using android::hardware::configureRpcThreadpool; -using android::hardware::joinRpcThreadpool; - -// Generated HIDL files -using android::hardware::power::V1_2::IPower; -using android::hardware::power::V1_2::implementation::Power; - -int main(int /* argc */, char** /* argv */) { - ALOGI("Power HAL Service 1.2 for Wahoo is starting"); - - android::sp service = new Power(); - if (service == nullptr) { - ALOGE("Can not create an instance of Power HAL Iface, exiting."); - return 1; - } - - configureRpcThreadpool(1, true /*callerWillJoin*/); - - status_t status = service->registerAsService(); - if (status != OK) { - ALOGE("Could not register service for Power HAL Iface (%d), exiting.", status); - return 1; - } - - ALOGI("Power Service is ready"); - joinRpcThreadpool(); - - // In normal operation, we don't expect the thread pool to exit - ALOGE("Power Service is shutting down"); - return 1; -} diff --git a/powerhint.json b/powerhint.json deleted file mode 100644 index f0789744..00000000 --- a/powerhint.json +++ /dev/null @@ -1,453 +0,0 @@ -{ - "Nodes": [ - { - "Name": "CPULittleClusterMaxFreq", - "Path": "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq", - "Values": [ - "1900800", - "1555200", - "1478400", - "1248000" - ], - "DefaultIndex": 0, - "ResetOnInit": true - }, - { - "Name": "CPULittleClusterMinFreq", - "Path": "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq", - "Values": [ - "1900800", - "1555200", - "1512000", - "1478400", - "1134000", - "0" - ], - "ResetOnInit": true - }, - { - "Name": "CPUBigClusterMaxFreq", - "Path": "/sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq", - "Values": [ - "2457600", - "1958400", - "1574400", - "1344000", - "1267200" - ], - "DefaultIndex": 0, - "ResetOnInit": true - }, - { - "Name": "CPUBigClusterMinFreq", - "Path": "/sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq", - "Values": [ - "2457600", - "1574400", - "1420800", - "1344000", - "1132800", - "0" - ], - "ResetOnInit": true - }, - { - "Name": "GPUMaxFreq", - "Path": "/sys/class/kgsl/kgsl-3d0/devfreq/max_freq", - "Values": [ - "342000000", - "414000000", - "515000000", - "710000000" - ], - "ResetOnInit": true - }, - { - "Name": "GPUMinFreq", - "Path": "/sys/class/kgsl/kgsl-3d0/devfreq/min_freq", - "Values": [ - "515000000", - "414000000", - "257000000" - ], - "ResetOnInit": true - }, - { - "Name": "GPUBusMinFreq", - "Path": "/sys/class/devfreq/soc:qcom,gpubw/min_freq", - "Values": [ - "11863", - "7759", - "0" - ], - "ResetOnInit": true - }, - { - "Name": "TASchedtuneBoost", - "Path": "/dev/stune/top-app/schedtune.boost", - "Values": [ - "50", - "10" - ], - "ResetOnInit": true - }, - { - "Name": "CPUBWHystTriggerCount", - "Path": "/sys/devices/soc/soc:qcom,cpubw/devfreq/soc:qcom,cpubw/bw_hwmon/hyst_trigger_count", - "Values": [ - "0", - "3" - ] - }, - { - "Name": "CPUBWHistMemory", - "Path": "/sys/devices/soc/soc:qcom,cpubw/devfreq/soc:qcom,cpubw/bw_hwmon/hist_memory", - "Values": [ - "0", - "20" - ] - }, - { - "Name": "CPUBWHystLength", - "Path": "/sys/devices/soc/soc:qcom,cpubw/devfreq/soc:qcom,cpubw/bw_hwmon/hyst_length", - "Values": [ - "0", - "10" - ] - }, - { - "Name": "CPUBWMinFreq", - "Path": "/sys/devices/soc/soc:qcom,cpubw/devfreq/soc:qcom,cpubw/min_freq", - "Values": [ - "13763", - "5195", - "1525", - "762" - ], - "ResetOnInit": true - }, - { - "Name": "PMQoSCpuDmaLatency", - "Path": "/dev/cpu_dma_latency", - "Values": [ - "44", - "100" - ], - "HoldFd": true - } - ], - "Actions": [ - { - "PowerHint": "VIDEO_ENCODE", - "Node": "CPUBigClusterMaxFreq", - "Duration": 0, - "Value": "1958400" - }, - { - "PowerHint": "SUSTAINED_PERFORMANCE", - "Node": "CPUBigClusterMaxFreq", - "Duration": 0, - "Value": "1267200" - }, - { - "PowerHint": "SUSTAINED_PERFORMANCE", - "Node": "CPULittleClusterMaxFreq", - "Duration": 0, - "Value": "1248000" - }, - { - "PowerHint": "SUSTAINED_PERFORMANCE", - "Node": "GPUMaxFreq", - "Duration": 0, - "Value": "342000000" - }, - { - "PowerHint": "VR_MODE", - "Node": "CPUBigClusterMaxFreq", - "Duration": 0, - "Value": "1574400" - }, - { - "PowerHint": "VR_MODE", - "Node": "CPUBigClusterMinFreq", - "Duration": 0, - "Value": "1574400" - }, - { - "PowerHint": "VR_MODE", - "Node": "CPULittleClusterMaxFreq", - "Duration": 0, - "Value": "1555200" - }, - { - "PowerHint": "VR_MODE", - "Node": "CPULittleClusterMinFreq", - "Duration": 0, - "Value": "1555200" - }, - { - "PowerHint": "VR_MODE", - "Node": "GPUMaxFreq", - "Duration": 0, - "Value": "515000000" - }, - { - "PowerHint": "VR_MODE", - "Node": "GPUMinFreq", - "Duration": 0, - "Value": "515000000" - }, - { - "PowerHint": "VR_MODE", - "Node": "GPUBusMinFreq", - "Duration": 0, - "Value": "11863" - }, - { - "PowerHint": "VR_SUSTAINED_PERFORMANCE", - "Node": "CPUBigClusterMaxFreq", - "Duration": 0, - "Value": "1344000" - }, - { - "PowerHint": "VR_SUSTAINED_PERFORMANCE", - "Node": "CPUBigClusterMinFreq", - "Duration": 0, - "Value": "1344000" - }, - { - "PowerHint": "VR_SUSTAINED_PERFORMANCE", - "Node": "CPULittleClusterMaxFreq", - "Duration": 0, - "Value": "1478400" - }, - { - "PowerHint": "VR_SUSTAINED_PERFORMANCE", - "Node": "CPULittleClusterMinFreq", - "Duration": 0, - "Value": "1478400" - }, - { - "PowerHint": "VR_SUSTAINED_PERFORMANCE", - "Node": "GPUMaxFreq", - "Duration": 0, - "Value": "414000000" - }, - { - "PowerHint": "VR_SUSTAINED_PERFORMANCE", - "Node": "GPUMinFreq", - "Duration": 0, - "Value": "414000000" - }, - { - "PowerHint": "VR_SUSTAINED_PERFORMANCE", - "Node": "GPUBusMinFreq", - "Duration": 0, - "Value": "7759" - }, - { - "PowerHint": "INTERACTION", - "Node": "CPUBigClusterMinFreq", - "Duration": 0, - "Value": "1132800" - }, - { - "PowerHint": "INTERACTION", - "Node": "CPULittleClusterMinFreq", - "Duration": 0, - "Value": "1134000" - }, - { - "PowerHint": "INTERACTION", - "Node": "TASchedtuneBoost", - "Duration": 0, - "Value": "50" - }, - { - "PowerHint": "INTERACTION", - "Node": "CPUBWHystTriggerCount", - "Duration": 0, - "Value": "0" - }, - { - "PowerHint": "INTERACTION", - "Node": "CPUBWHystLength", - "Duration": 0, - "Value": "0" - }, - { - "PowerHint": "INTERACTION", - "Node": "CPUBWHistMemory", - "Duration": 0, - "Value": "0" - }, - { - "PowerHint": "INTERACTION", - "Node": "CPUBWMinFreq", - "Duration": 0, - "Value": "5195" - }, - { - "PowerHint": "LAUNCH", - "Node": "CPUBigClusterMaxFreq", - "Duration": 5000, - "Value": "2457600" - }, - { - "PowerHint": "LAUNCH", - "Node": "CPUBigClusterMinFreq", - "Duration": 5000, - "Value": "2457600" - }, - { - "PowerHint": "LAUNCH", - "Node": "CPULittleClusterMinFreq", - "Duration": 5000, - "Value": "1900800" - }, - { - "PowerHint": "LAUNCH", - "Node": "PMQoSCpuDmaLatency", - "Duration": 5000, - "Value": "44" - }, - { - "PowerHint": "LAUNCH", - "Node": "CPUBWHystTriggerCount", - "Duration": 5000, - "Value": "0" - }, - { - "PowerHint": "LAUNCH", - "Node": "CPUBWHystLength", - "Duration": 5000, - "Value": "0" - }, - { - "PowerHint": "LAUNCH", - "Node": "CPUBWHistMemory", - "Duration": 5000, - "Value": "0" - }, - { - "PowerHint": "LAUNCH", - "Node": "CPUBWMinFreq", - "Duration": 5000, - "Value": "13763" - }, - { - "PowerHint": "CAMERA_LAUNCH", - "Node": "CPUBigClusterMaxFreq", - "Duration": 1000, - "Value": "2457600" - }, - { - "PowerHint": "CAMERA_LAUNCH", - "Node": "CPUBigClusterMinFreq", - "Duration": 1000, - "Value": "2457600" - }, - { - "PowerHint": "CAMERA_LAUNCH", - "Node": "CPULittleClusterMinFreq", - "Duration": 1000, - "Value": "1900800" - }, - { - "PowerHint": "CAMERA_LAUNCH", - "Node": "PMQoSCpuDmaLatency", - "Duration": 1000, - "Value": "44" - }, - { - "PowerHint": "CAMERA_STREAMING", - "Node": "CPUBigClusterMaxFreq", - "Duration": 1000, - "Value": "2457600" - }, - { - "PowerHint": "CAMERA_STREAMING", - "Node": "CPUBigClusterMinFreq", - "Duration": 1000, - "Value": "2457600" - }, - { - "PowerHint": "CAMERA_STREAMING", - "Node": "CPULittleClusterMinFreq", - "Duration": 1000, - "Value": "1900800" - }, - { - "PowerHint": "CAMERA_STREAMING", - "Node": "PMQoSCpuDmaLatency", - "Duration": 1000, - "Value": "44" - }, - { - "PowerHint": "CAMERA_SHOT", - "Node": "CPUBigClusterMaxFreq", - "Duration": 1000, - "Value": "2457600" - }, - { - "PowerHint": "CAMERA_SHOT", - "Node": "CPUBigClusterMinFreq", - "Duration": 1000, - "Value": "2457600" - }, - { - "PowerHint": "CAMERA_SHOT", - "Node": "CPULittleClusterMinFreq", - "Duration": 1000, - "Value": "1900800" - }, - { - "PowerHint": "CAMERA_SHOT", - "Node": "PMQoSCpuDmaLatency", - "Duration": 1000, - "Value": "44" - }, - { - "PowerHint": "CAMERA_SHOT", - "Node": "CPUBWHystTriggerCount", - "Duration": 1000, - "Value": "0" - }, - { - "PowerHint": "CAMERA_SHOT", - "Node": "CPUBWHystLength", - "Duration": 1000, - "Value": "0" - }, - { - "PowerHint": "CAMERA_SHOT", - "Node": "CPUBWHistMemory", - "Duration": 1000, - "Value": "0" - }, - { - "PowerHint": "CAMERA_SHOT", - "Node": "CPUBWMinFreq", - "Duration": 1000, - "Value": "13763" - }, - { - "PowerHint": "AUDIO_STREAMING", - "Node": "CPUBigClusterMinFreq", - "Duration": 2000, - "Value": "1420800" - }, - { - "PowerHint": "AUDIO_STREAMING", - "Node": "PMQoSCpuDmaLatency", - "Duration": 2000, - "Value": "44" - }, - { - "PowerHint": "AUDIO_LOW_LATENCY", - "Node": "PMQoSCpuDmaLatency", - "Duration": 0, - "Value": "44" - } - ] -} \ No newline at end of file diff --git a/powerhint.xml b/powerhint.xml deleted file mode 100755 index 01d6e424..00000000 --- a/powerhint.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/power-libperfmgr/Android.bp b/powerstats/Android.bp similarity index 68% rename from power-libperfmgr/Android.bp rename to powerstats/Android.bp index 8deca675..491498dd 100644 --- a/power-libperfmgr/Android.bp +++ b/powerstats/Android.bp @@ -13,25 +13,28 @@ // See the License for the specific language governing permissions and // limitations under the License. cc_binary { - name: "android.hardware.power@1.2-service.wahoo-libperfmgr", + name: "android.hardware.power.stats@1.0-service.pixel", relative_install_path: "hw", - init_rc: ["android.hardware.power@1.2-service.wahoo-libperfmgr.rc"], - srcs: ["service.cpp", "Power.cpp", "InteractionHandler.cpp", "power-helper.c"], + init_rc: ["android.hardware.power.stats@1.0-service.pixel.rc"], + srcs: ["service.cpp", "EaselStateResidencyDataProvider.cpp"], cflags: [ "-Wall", "-Werror", ], + static_libs: [ + "libpixelpowerstats", + ], shared_libs: [ "libbase", + "libcutils", "libhidlbase", "libhidltransport", + "libfmq", "liblog", "libutils", - "libcutils", - "android.hardware.power@1.0", - "android.hardware.power@1.1", - "android.hardware.power@1.2", - "libperfmgr", + "android.hardware.power.stats@1.0", + "pixelpowerstats_provider_aidl_interface-cpp", + "libbinder", ], - proprietary: true, + vendor: true, } diff --git a/powerstats/EaselStateResidencyDataProvider.cpp b/powerstats/EaselStateResidencyDataProvider.cpp new file mode 100644 index 00000000..6b5bdae8 --- /dev/null +++ b/powerstats/EaselStateResidencyDataProvider.cpp @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "easelstateresidency" + +#include +#include +#include "EaselStateResidencyDataProvider.h" + +namespace android { +namespace device { +namespace google { +namespace wahoo { +namespace powerstats { + +const uint32_t EASEL_SYNTHETIC_SLEEP_ID = 0; + +EaselStateResidencyDataProvider::EaselStateResidencyDataProvider(uint32_t id) : + mPowerEntityId(id), mTotalOnSnapshotCount(0), mTotalNotOnSnapshotCount(0) {} + +bool EaselStateResidencyDataProvider::getResults( + std::unordered_map &results) { + const std::string path = "/sys/devices/virtual/misc/mnh_sm/state"; + + enum easel_state { + EASEL_OFF = 0, + EASEL_ON, + EASEL_SUSPENDED, + NUM_EASEL_STATES + }; + + // Since we are storing stats locally but can have multiple parallel + // callers, locking is required to ensure stats are not corrupted. + std::lock_guard lock(mLock); + + std::ifstream inFile(path, std::ifstream::in); + if (!inFile.is_open()) { + PLOG(ERROR) << __func__ << ":Failed to open file " << path; + return false; + } + + unsigned long currentState; + if(!(inFile >> currentState) || currentState >= NUM_EASEL_STATES) { + PLOG(ERROR) << __func__ << ":Failed to parse " << path; + return false; + } + + // Update statistics for synthetic sleep state. We combine OFF and + // SUSPENDED to act as a composite "not on" state so the numbers will behave + // like a real sleep state. + if ((currentState == EASEL_OFF) || (currentState == EASEL_SUSPENDED)) { + mTotalNotOnSnapshotCount++; + } else { + mTotalOnSnapshotCount++; + } + + // Update statistics for synthetic sleep state, where + // totalStateEntryCount = cumulative count of Easel state0 and state2 + // (as seen by power.stats HAL) + // totalTimeInStateMs = cumulative count of Easel state1 (as seen by + // power.stats HAL) + PowerEntityStateResidencyResult result = { + .powerEntityId = mPowerEntityId, + .stateResidencyData = {{.powerEntityStateId = EASEL_SYNTHETIC_SLEEP_ID, + .totalStateEntryCount = mTotalOnSnapshotCount, + .totalTimeInStateMs = mTotalNotOnSnapshotCount, + .lastEntryTimestampMs = 0}} + }; + + results.emplace(std::make_pair(mPowerEntityId, result)); + return true; +} + + +std::vector EaselStateResidencyDataProvider::getStateSpaces() { + return { + {.powerEntityId = mPowerEntityId, + .states = { + { + .powerEntityStateId = EASEL_SYNTHETIC_SLEEP_ID, + .powerEntityStateName = "SyntheticSleep" + } + } + } + }; +} + +} // namespace powerstats +} // namespace wahoo +} // namespace google +} // namespace device +} // namespace android \ No newline at end of file diff --git a/powerstats/EaselStateResidencyDataProvider.h b/powerstats/EaselStateResidencyDataProvider.h new file mode 100644 index 00000000..2381078a --- /dev/null +++ b/powerstats/EaselStateResidencyDataProvider.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef DEVICE_GOOGLE_WAHOO_POWERSTATS_EASELSTATERESIDENCYDATAPROVIDER_H +#define DEVICE_GOOGLE_WAHOO_POWERSTATS_EASELSTATERESIDENCYDATAPROVIDER_H + +#include + +using android::hardware::power::stats::V1_0::PowerEntityStateResidencyResult; +using android::hardware::power::stats::V1_0::PowerEntityStateSpace; +using android::hardware::google::pixel::powerstats::IStateResidencyDataProvider; + +namespace android { +namespace device { +namespace google { +namespace wahoo { +namespace powerstats { + +class EaselStateResidencyDataProvider : public IStateResidencyDataProvider { + public: + EaselStateResidencyDataProvider(uint32_t id); + ~EaselStateResidencyDataProvider() = default; + bool getResults(std::unordered_map + &results) override; + std::vector getStateSpaces() override; + + private: + std::mutex mLock; + const uint32_t mPowerEntityId; + uint64_t mTotalOnSnapshotCount; + uint64_t mTotalNotOnSnapshotCount; +}; + +} // namespace powerstats +} // namespace wahoo +} // namespace google +} // namespace device +} // namespace android + +#endif // DEVICE_GOOGLE_WAHOO_POWERSTATS_EASELSTATERESIDENCYDATAPROVIDER_H diff --git a/powerstats/android.hardware.power.stats@1.0-service.pixel.rc b/powerstats/android.hardware.power.stats@1.0-service.pixel.rc new file mode 100644 index 00000000..6ba83c28 --- /dev/null +++ b/powerstats/android.hardware.power.stats@1.0-service.pixel.rc @@ -0,0 +1,4 @@ +service vendor.power.stats-hal-1-0 /vendor/bin/hw/android.hardware.power.stats@1.0-service.pixel + class hal + user system + group system diff --git a/powerstats/service.cpp b/powerstats/service.cpp new file mode 100644 index 00000000..ce71b6f1 --- /dev/null +++ b/powerstats/service.cpp @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "android.hardware.power.stats@1.0-service.pixel" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include "EaselStateResidencyDataProvider.h" + +using android::OK; +using android::sp; +using android::status_t; + +// libhwbinder: +using android::hardware::configureRpcThreadpool; +using android::hardware::joinRpcThreadpool; + +// Generated HIDL files +using android::hardware::power::stats::V1_0::IPowerStats; +using android::hardware::power::stats::V1_0::PowerEntityInfo; +using android::hardware::power::stats::V1_0::PowerEntityStateSpace; +using android::hardware::power::stats::V1_0::PowerEntityType; +using android::hardware::power::stats::V1_0::implementation::PowerStats; + +// Pixel specific +using android::hardware::google::pixel::powerstats::AidlStateResidencyDataProvider; +using android::hardware::google::pixel::powerstats::GenericStateResidencyDataProvider; +using android::hardware::google::pixel::powerstats::PowerEntityConfig; +using android::hardware::google::pixel::powerstats::StateResidencyConfig; +using android::hardware::google::pixel::powerstats::WlanStateResidencyDataProvider; + +// Wahoo specific +using android::device::google::wahoo::powerstats::EaselStateResidencyDataProvider; + +int main(int /* argc */, char ** /* argv */) { + ALOGI("power.stats service 1.0 is starting."); + + bool isDebuggable = android::base::GetBoolProperty("ro.debuggable", false); + + PowerStats *service = new PowerStats(); + + if (isDebuggable) { + // Add power entities related to rpmh + const uint64_t RPM_CLK = 19200; // RPM runs at 19.2Mhz. Divide by 19200 for msec + std::function rpmConvertToMs = [](uint64_t a) { return a / RPM_CLK; }; + std::vector rpmStateResidencyConfigs = { + {.name = "XO_shutdown", + .entryCountSupported = true, + .entryCountPrefix = "XO Count:", + .totalTimeSupported = true, + .totalTimePrefix = "Accumulated XO duration:", + .totalTimeTransform = rpmConvertToMs, + .lastEntrySupported = false}}; + + sp rpmSdp = + new GenericStateResidencyDataProvider("/d/system_stats"); + + uint32_t apssId = service->addPowerEntity("APSS", PowerEntityType::SUBSYSTEM); + rpmSdp->addEntity(apssId, PowerEntityConfig("APSS", rpmStateResidencyConfigs)); + + uint32_t mpssId = service->addPowerEntity("MPSS", PowerEntityType::SUBSYSTEM); + rpmSdp->addEntity(mpssId, PowerEntityConfig("MPSS", rpmStateResidencyConfigs)); + + uint32_t adspId = service->addPowerEntity("ADSP", PowerEntityType::SUBSYSTEM); + rpmSdp->addEntity(adspId, PowerEntityConfig("ADSP", rpmStateResidencyConfigs)); + + uint32_t slpiId = service->addPowerEntity("SLPI", PowerEntityType::SUBSYSTEM); + rpmSdp->addEntity(slpiId, PowerEntityConfig("SLPI", rpmStateResidencyConfigs)); + + service->addStateResidencyDataProvider(rpmSdp); + + // Add SoC power entity + std::vector socStateResidencyConfigs = { + {.name = "XO_shutdown", + .header = "RPM Mode:vlow", + .entryCountSupported = true, + .entryCountPrefix = "count:", + .totalTimeSupported = true, + .totalTimePrefix = "actual last sleep(msec):", + .lastEntrySupported = false}, + {.name = "VMIN", + .header = "RPM Mode:vmin", + .entryCountSupported = true, + .entryCountPrefix = "count:", + .totalTimeSupported = true, + .totalTimePrefix = "actual last sleep(msec):", + .lastEntrySupported = false}}; + + sp socSdp = + new GenericStateResidencyDataProvider("/d/system_stats"); + + uint32_t socId = service->addPowerEntity("SoC", PowerEntityType::POWER_DOMAIN); + socSdp->addEntity(socId, PowerEntityConfig(socStateResidencyConfigs)); + + service->addStateResidencyDataProvider(socSdp); + + // Add WLAN power entity + uint32_t wlanId = service->addPowerEntity("WLAN", PowerEntityType::SUBSYSTEM); + sp wlanSdp = + new WlanStateResidencyDataProvider(wlanId, "/d/wlan0/power_stats"); + service->addStateResidencyDataProvider(wlanSdp); + } + + // Add Easel power entity + uint32_t easelId = service->addPowerEntity("Easel", PowerEntityType::SUBSYSTEM); + sp easelSdp = new EaselStateResidencyDataProvider(easelId); + service->addStateResidencyDataProvider(easelSdp); + + // Add Power Entities that require the Aidl data provider + sp aidlSdp = new AidlStateResidencyDataProvider(); + // TODO(117585786): Add real power entities here + // uint32_t mock1Id = service->addPowerEntity("Mock1", PowerEntityType::SUBSYSTEM); + // aidlSdp->addEntity(mock1Id, "Mock1", {"state_a", "state_b"}); + // uint32_t mock2Id = service->addPowerEntity("Mock2", PowerEntityType::SUBSYSTEM); + // aidlSdp->addEntity(mock2Id, "Mock2", {"state_c", "state_d"}); + + auto serviceStatus = android::defaultServiceManager()->addService( + android::String16("power.stats-vendor"), aidlSdp); + if (serviceStatus != android::OK) { + ALOGE("Unable to register power.stats-vendor service %d", serviceStatus); + return 1; + } + sp ps{android::ProcessState::self()}; // Create non-HW binder threadpool + ps->startThreadPool(); + + service->addStateResidencyDataProvider(aidlSdp); + + // Configure the threadpool + configureRpcThreadpool(1, true /*callerWillJoin*/); + + status_t status = service->registerAsService(); + if (status != OK) { + ALOGE("Could not register service for power.stats HAL Iface (%d), exiting.", status); + return 1; + } + + ALOGI("power.stats service is ready"); + joinRpcThreadpool(); + + // In normal operation, we don't expect the thread pool to exit + ALOGE("power.stats service is shutting down"); + return 1; +} diff --git a/sepolicy/private/mediaswcodec.te b/sepolicy/private/mediaswcodec.te new file mode 100644 index 00000000..36907500 --- /dev/null +++ b/sepolicy/private/mediaswcodec.te @@ -0,0 +1,2 @@ +allow mediaswcodec gpu_device:chr_file { ioctl open read write }; + diff --git a/sepolicy/public/init.te b/sepolicy/public/init.te new file mode 100644 index 00000000..e93b2e89 --- /dev/null +++ b/sepolicy/public/init.te @@ -0,0 +1 @@ +allow init vold_data_file:dir { relabelfrom }; diff --git a/sepolicy/public/ueventd.te b/sepolicy/public/ueventd.te new file mode 100644 index 00000000..985c8ec4 --- /dev/null +++ b/sepolicy/public/ueventd.te @@ -0,0 +1 @@ +allow ueventd metadata_file:dir search; diff --git a/sepolicy/vendor/cameraserver.te b/sepolicy/vendor/cameraserver.te index 594f22a9..b9adc4c5 100644 --- a/sepolicy/vendor/cameraserver.te +++ b/sepolicy/vendor/cameraserver.te @@ -8,5 +8,4 @@ allow cameraserver sysfs_camera:dir search; allow cameraserver system_server:unix_stream_socket { read write }; -# TODO (b/37688918) Verify that this is actually needed and not a violation of treble binder_call(cameraserver, mediacodec) diff --git a/sepolicy/vendor/con_monitor.te b/sepolicy/vendor/con_monitor.te index 8730e566..e1ba346c 100644 --- a/sepolicy/vendor/con_monitor.te +++ b/sepolicy/vendor/con_monitor.te @@ -9,4 +9,4 @@ allow con_monitor_app radio_vendor_data_file:dir rw_dir_perms; allow con_monitor_app radio_vendor_data_file:file create_file_perms; allow con_monitor_app radio_service:service_manager find; allow con_monitor_app audioserver_service:service_manager find; -hal_client_domain(con_monitor_app, hal_power); \ No newline at end of file +hal_client_domain(con_monitor_app, hal_power_stats); \ No newline at end of file diff --git a/sepolicy/vendor/file.te b/sepolicy/vendor/file.te index 6f859044..8e8e364d 100644 --- a/sepolicy/vendor/file.te +++ b/sepolicy/vendor/file.te @@ -37,6 +37,7 @@ type debugfs_tzdbg, debugfs_type, fs_type; # /proc type proc_wifi_dbg, fs_type, proc_type; +type proc_swappiness, fs_type, proc_type; type qmuxd_socket, file_type; type netmgrd_socket, file_type; diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 345527ef..b66f65ae 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -167,35 +167,40 @@ /vendor/bin/oemlock_provision u:object_r:hal_bootctl_default_exec:s0 /vendor/bin/oemlock-bridge u:object_r:hal_bootctl_default_exec:s0 /vendor/bin/hw/android\.hardware\.usb@1\.1-service\.wahoo u:object_r:hal_usb_impl_exec:s0 -/vendor/bin/hw/android\.hardware\.power@1\.2-service\.wahoo-libperfmgr u:object_r:hal_power_default_exec:s0 +/vendor/bin/hw/android\.hardware\.power@1\.3-service\.pixel-libperfmgr u:object_r:hal_power_default_exec:s0 /vendor/bin/hw/android\.hardware\.power\.stats@1\.0-service\.pixel u:object_r:hal_power_stats_default_exec:s0 /vendor/bin/chre u:object_r:chre_exec:s0 /vendor/bin/time_daemon u:object_r:time_daemon_exec:s0 /vendor/bin/imsrcsd u:object_r:hal_rcsservice_exec:s0 /vendor/bin/init\.qcom\.devstart\.sh u:object_r:init-qcom-devstart-sh_exec:s0 /vendor/bin/init\.qcom\.ipastart\.sh u:object_r:init-qcom-ipastart-sh_exec:s0 -/vendor/bin/init\.qcom\.wlan\.sh u:object_r:init-qcom-wlan-sh_exec:s0 /vendor/bin/init\.insmod\.sh u:object_r:init-insmod-sh_exec:s0 /vendor/etc/init\.insmod\.cfg u:object_r:init-insmod-sh_exec:s0 /vendor/bin/init\.power\.sh u:object_r:init_power_exec:s0 /vendor/bin/init\.radio\.sh u:object_r:init_radio_exec:s0 /vendor/bin/ramoops u:object_r:ramoops_exec:s0 /vendor/bin/init\.ramoops\.sh u:object_r:ramoops_exec:s0 +/vendor/bin/init\.fingerprint\.sh u:object_r:init-fingerprint_exec:s0 /vendor/bin/hw/android\.hardware\.bluetooth@1\.0-service-qti u:object_r:hal_bluetooth_default_exec:s0 -/vendor/bin/hw/android\.hardware\.drm@1\.1-service\.widevine u:object_r:hal_drm_widevine_exec:s0 -/vendor/bin/hw/android\.hardware\.drm@1\.1-service\.clearkey u:object_r:hal_drm_clearkey_exec:s0 +/vendor/bin/hw/android\.hardware\.drm@1\.2-service\.clearkey u:object_r:hal_drm_clearkey_exec:s0 +/vendor/bin/hw/android\.hardware\.drm@1\.2-service-lazy\.clearkey u:object_r:hal_drm_clearkey_exec:s0 +/vendor/bin/hw/android\.hardware\.drm@1\.2-service\.widevine u:object_r:hal_drm_widevine_exec:s0 +/vendor/bin/hw/android\.hardware\.drm@1\.2-service-lazy\.widevine u:object_r:hal_drm_widevine_exec:s0 /vendor/bin/hw/android\.hardware\.vibrator@1\.2-service\.wahoo u:object_r:hal_vibrator_default_exec:s0 /vendor/bin/hw/android\.hardware\.health@2\.0-service\.wahoo u:object_r:hal_health_default_exec:s0 /vendor/bin/hw/android\.hardware\.keymaster@3\.0-service-qti u:object_r:hal_keymaster_qti_exec:s0 /vendor/bin/hw/android\.hardware\.gatekeeper@1\.0-service-qti u:object_r:hal_gatekeeper_qti_exec:s0 /vendor/bin/hw/android\.hardware\.gnss@1\.0-service-qti u:object_r:hal_gnss_qti_exec:s0 +/vendor/bin/hw/android\.hardware\.thermal@2\.0-service\.pixel u:object_r:hal_thermal_default_exec:s0 ############################################### # same-process HAL files and their dependencies # +/vendor/lib(64)?/hw/android\.hardware\.graphics\.mapper@2\.0-impl-2\.1\.so u:object_r:same_process_hal_file:s0 /vendor/lib(64)?/hw/gralloc\.msm8998\.so u:object_r:same_process_hal_file:s0 /vendor/lib(64)?/libqdMetaData\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/lib_aion_buffer\.so u:object_r:same_process_hal_file:s0 /vendor/lib(64)?/libqservice\.so u:object_r:same_process_hal_file:s0 /vendor/lib(64)?/libqdutils\.so u:object_r:same_process_hal_file:s0 /vendor/lib(64)?/libadreno_utils\.so u:object_r:same_process_hal_file:s0 diff --git a/sepolicy/vendor/genfs_contexts b/sepolicy/vendor/genfs_contexts index 28d1f7a0..46b5afff 100644 --- a/sepolicy/vendor/genfs_contexts +++ b/sepolicy/vendor/genfs_contexts @@ -3,6 +3,7 @@ genfscon proc /debug/fwdump u:object_r:proc_wifi_dbg:s genfscon proc /debugdriver/driverdump u:object_r:proc_wifi_dbg:s0 genfscon proc /ath_pktlog/cld u:object_r:proc_wifi_dbg:s0 genfscon proc /irq u:object_r:proc_irq:s0 +genfscon proc /sys/vm/swappiness u:object_r:proc_swappiness:s0 genfscon sysfs /devices/soc/soc:qcom,cpubw u:object_r:sysfs_msm_subsys:s0 genfscon sysfs /devices/soc/soc:qcom,mincpubw u:object_r:sysfs_msm_subsys:s0 diff --git a/sepolicy/vendor/hal_drm_clearkey.te b/sepolicy/vendor/hal_drm_clearkey.te index 5632c3b2..6d4a8152 100644 --- a/sepolicy/vendor/hal_drm_clearkey.te +++ b/sepolicy/vendor/hal_drm_clearkey.te @@ -1,4 +1,4 @@ -# policy for /vendor/bin/hw/android.hardware.drm@1.1-service.clearkey +# policy for /vendor/bin/hw/android.hardware.drm clearkey service type hal_drm_clearkey, domain; type hal_drm_clearkey_exec, exec_type, vendor_file_type, file_type; diff --git a/sepolicy/vendor/hal_drm_widevine.te b/sepolicy/vendor/hal_drm_widevine.te index 8e6eca1b..bfa6a6b2 100644 --- a/sepolicy/vendor/hal_drm_widevine.te +++ b/sepolicy/vendor/hal_drm_widevine.te @@ -1,4 +1,3 @@ -# policy for /vendor/bin/hw/android.hardware.drm@1.1-service.widevine type hal_drm_widevine, domain; type hal_drm_widevine_exec, exec_type, vendor_file_type, file_type; diff --git a/sepolicy/vendor/hal_dumpstate_impl.te b/sepolicy/vendor/hal_dumpstate_impl.te index 60c781bd..a2f8ffce 100644 --- a/sepolicy/vendor/hal_dumpstate_impl.te +++ b/sepolicy/vendor/hal_dumpstate_impl.te @@ -8,6 +8,10 @@ init_daemon_domain(hal_dumpstate_impl) allow hal_dumpstate_impl vendor_shell_exec:file rx_file_perms; allow hal_dumpstate_impl vendor_toolbox_exec:file rx_file_perms; +# Allow to read pixel-trace trace file +allow hal_dumpstate_impl debugfs_tracing_instances:dir search; +allow hal_dumpstate_impl debugfs_tracing_instances:file r_file_perms; + userdebug_or_eng(` # smlog_dump domain_auto_trans(hal_dumpstate_impl, smlog_dump_exec, smlog_dump) diff --git a/sepolicy/vendor/hal_graphics_composer_default.te b/sepolicy/vendor/hal_graphics_composer_default.te index 42aa3935..c5e36687 100644 --- a/sepolicy/vendor/hal_graphics_composer_default.te +++ b/sepolicy/vendor/hal_graphics_composer_default.te @@ -16,7 +16,6 @@ allow hal_graphics_composer_default hal_graphics_mapper_hwservice:hwservice_mana r_dir_file(hal_graphics_composer_default, sysfs_leds) -# TODO(b/37666508): Remove the following line upon resolution of the bug allow hal_graphics_composer_default video_device:chr_file rw_file_perms; # HWC_UeventThread diff --git a/sepolicy/vendor/hal_power_default.te b/sepolicy/vendor/hal_power_default.te index dce10ed5..7e6f60d3 100644 --- a/sepolicy/vendor/hal_power_default.te +++ b/sepolicy/vendor/hal_power_default.te @@ -1,15 +1,6 @@ allow hal_power_default sysfs_graphics:dir search; allow hal_power_default sysfs_graphics:file r_file_perms; -allow hal_power_default debugfs_rpm:file r_file_perms; - -allow hal_power_default debugfs_wlan:dir r_dir_perms; -allow hal_power_default debugfs_wlan:file r_file_perms; - -allow hal_power_default sysfs_easel:dir search; -allow hal_power_default sysfs_easel:file r_file_perms; - - # To do powerhint on nodes defined in powerhint.json allow hal_power_default sysfs_msm_subsys:dir search; allow hal_power_default sysfs_msm_subsys:file rw_file_perms; @@ -17,6 +8,11 @@ allow hal_power_default sysfs_devices_system_cpu:file rw_file_perms; allow hal_power_default latency_device:chr_file rw_file_perms; allow hal_power_default cgroup:dir search; allow hal_power_default cgroup:file rw_file_perms; +allow hal_power_default sysfs_touch:file w_file_perms; +allow hal_power_default sysfs_touch:dir search; # To get/set powerhal state property set_prop(hal_power_default, power_prop) + +# interact with thermal_config +set_prop(hal_power_default, thermal_prop) diff --git a/sepolicy/vendor/hal_power_stats_default.te b/sepolicy/vendor/hal_power_stats_default.te index da4c2989..5c773db3 100644 --- a/sepolicy/vendor/hal_power_stats_default.te +++ b/sepolicy/vendor/hal_power_stats_default.te @@ -1,6 +1,7 @@ # power.stats HAL needs access to rpm, and wlan sysfs nodes in /d/ r_dir_file(hal_power_stats_default, debugfs_rpm) r_dir_file(hal_power_stats_default, debugfs_wlan) +get_prop(hal_power_stats_default, exported_wifi_prop) # Needed to detect wifi on/off # power.stats HAL needs access to the easel sysfs node r_dir_file(hal_power_stats_default, sysfs_easel) diff --git a/sepolicy/vendor/hal_thermal_default.te b/sepolicy/vendor/hal_thermal_default.te new file mode 100644 index 00000000..13c129f6 --- /dev/null +++ b/sepolicy/vendor/hal_thermal_default.te @@ -0,0 +1,7 @@ +allow hal_thermal_default sysfs_thermal:dir r_dir_perms; +allow hal_thermal_default sysfs_thermal:file r_file_perms; +allow hal_thermal_default sysfs_thermal:lnk_file read; +allow hal_thermal_default proc_stat:file r_file_perms; + +# read thermal_config +get_prop(hal_thermal_default, thermal_prop) diff --git a/sepolicy/vendor/hal_vr.te b/sepolicy/vendor/hal_vr.te deleted file mode 100644 index a88dcb82..00000000 --- a/sepolicy/vendor/hal_vr.te +++ /dev/null @@ -1,6 +0,0 @@ -# interact with thermal_config -set_prop(hal_vr, thermal_prop) - -# Access to touch vrmode node -allow hal_vr sysfs_touch:dir r_dir_perms; -allow hal_vr sysfs_touch:file rw_file_perms; diff --git a/sepolicy/vendor/hal_wifi_default.te b/sepolicy/vendor/hal_wifi_default.te index a0155584..d6f02d59 100644 --- a/sepolicy/vendor/hal_wifi_default.te +++ b/sepolicy/vendor/hal_wifi_default.te @@ -11,6 +11,9 @@ allow hal_wifi_default wlan_device:chr_file w_file_perms; # Allow wifi hal to read debug info from the driver. r_dir_file(hal_wifi_default, proc_wifi_dbg) +# Write wlan driver/fw version into property +set_prop(hal_wifi_default, vendor_wifi_version) + dontaudit hal_wifi_default kernel:system module_request; dontaudit hal_wifi_default self:capability sys_module; @@ -19,4 +22,4 @@ userdebug_or_eng(` # Allow wifi hal to access wlan debugfs files and directories allow hal_wifi_default debugfs_wlan:dir r_dir_perms; -') \ No newline at end of file +') diff --git a/sepolicy/vendor/init-fingerprint.te b/sepolicy/vendor/init-fingerprint.te new file mode 100644 index 00000000..7053f0da --- /dev/null +++ b/sepolicy/vendor/init-fingerprint.te @@ -0,0 +1,10 @@ +type init-fingerprint, domain; +type init-fingerprint_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(init-fingerprint) + +allow init-fingerprint vendor_shell_exec:file rx_file_perms; +allow init-fingerprint vendor_toolbox_exec:file rx_file_perms; + +set_prop(init-fingerprint, vendor_fingerprint_prop) +set_prop(init-fingerprint, ctl_start_prop) diff --git a/sepolicy/vendor/init-wlan-sh.te b/sepolicy/vendor/init-wlan-sh.te deleted file mode 100644 index 3380c861..00000000 --- a/sepolicy/vendor/init-wlan-sh.te +++ /dev/null @@ -1,14 +0,0 @@ -type init-qcom-wlan-sh, domain; -type init-qcom-wlan-sh_exec, exec_type, vendor_file_type, file_type; - -init_daemon_domain(init-qcom-wlan-sh) - -allow init-qcom-wlan-sh vendor_shell_exec:file rx_file_perms; -allow init-qcom-wlan-sh vendor_toolbox_exec:file rx_file_perms; - -# Set the vendor.wlan.driver.version and vendor.wlan.firmware.version property -set_prop(init-qcom-wlan-sh, vendor_wifi_version) - -# /sys/kernel/wifi/wlan/driver_version and /sys/kernel/wifi/wlan/fw/0/version -allow init-qcom-wlan-sh sysfs_msm_wlan:dir r_dir_perms; -allow init-qcom-wlan-sh sysfs_msm_wlan:file r_file_perms; diff --git a/sepolicy/vendor/location.te b/sepolicy/vendor/location.te index 67471df6..02f8d4a1 100644 --- a/sepolicy/vendor/location.te +++ b/sepolicy/vendor/location.te @@ -35,7 +35,7 @@ r_dir_file(location, sysfs_type) dontaudit location kernel:system module_request; -allow location proc_net:file r_file_perms; +allow location proc_net_type:file r_file_perms; # execute /vendor/bin/lowi-server allow location location_exec:file rx_file_perms; @@ -46,4 +46,4 @@ allow location location_data_file:{ file sock_file } create_file_perms; userdebug_or_eng(` allow location diag_device:chr_file rw_file_perms; -') \ No newline at end of file +') diff --git a/sepolicy/vendor/netmgrd.te b/sepolicy/vendor/netmgrd.te index 7bbcc592..2dce2413 100644 --- a/sepolicy/vendor/netmgrd.te +++ b/sepolicy/vendor/netmgrd.te @@ -43,7 +43,7 @@ dontaudit netmgrd diag_device:chr_file rw_file_perms; #Ignore if device loading for private IOCTL failed dontaudit netmgrd kernel:system { module_request }; -allow netmgrd proc_net:file rw_file_perms; +allow netmgrd proc_net_type:file rw_file_perms; allow netmgrd netmgr_data_file:dir rw_dir_perms; allow netmgrd netmgr_data_file:file create_file_perms; diff --git a/sepolicy/vendor/property.te b/sepolicy/vendor/property.te index 594a4f56..f6628b03 100644 --- a/sepolicy/vendor/property.te +++ b/sepolicy/vendor/property.te @@ -25,3 +25,6 @@ type vendor_usb_config_prop, property_type; type vendor_charge_prop, property_type; type vendor_nfc_prop, property_type; type vendor_ramoops_prop, property_type; + +# fingerprint +type vendor_fingerprint_prop, property_type; diff --git a/sepolicy/vendor/property_contexts b/sepolicy/vendor/property_contexts index a8c28e77..83081751 100644 --- a/sepolicy/vendor/property_contexts +++ b/sepolicy/vendor/property_contexts @@ -17,15 +17,18 @@ vendor.debug.ssrdump u:object_r:vendor_ssr_prop:s0 persist.sys.cnss. u:object_r:cnss_diag_prop:s0 sys.listeners.registered u:object_r:tee_listener_prop:s0 wc_transport. u:object_r:wc_prop:s0 -sys.qcom.thermalcfg u:object_r:thermal_prop:s0 -ctl.vendor.thermal-engine u:object_r:thermal_prop:s0 +vendor.qcom.thermalcfg u:object_r:thermal_prop:s0 +vendor.thermal.config u:object_r:thermal_prop:s0 persist.sys.modem.diag. u:object_r:modem_diag_prop:s0 sys.modem.diag. u:object_r:modem_diag_prop:s0 sys.time.set u:object_r:sys_time_prop:s0 persist.radio.atfwd.start u:object_r:atfwd_start_prop:s0 sys.logger.bluetooth u:object_r:bluetooth_log_prop:s0 -vendor.powerhal.state u:object_r:power_prop:s0 -vendor.powerhal.audio u:object_r:power_prop:s0 +vendor.powerhal.state u:object_r:power_prop:s0 +vendor.powerhal.audio u:object_r:power_prop:s0 +vendor.powerhal.lpm u:object_r:power_prop:s0 +vendor.powerhal.init u:object_r:power_prop:s0 +vendor.powerhal.rendering u:object_r:power_prop:s0 vendor.wlan.driver.version u:object_r:vendor_wifi_version:s0 vendor.wlan.firmware.version u:object_r:vendor_wifi_version:s0 persist.vendor.usb.config u:object_r:vendor_usb_config_prop:s0 @@ -53,6 +56,9 @@ vendor.debug.egl.changepixelformat u:object_r:public_vendor_default_prop:s0 vendor.debug.prerotation.disable u:object_r:public_vendor_default_prop:s0 vendor.debug.rs. u:object_r:public_vendor_default_prop:s0 vendor.debug.egl.swapinterval u:object_r:public_vendor_default_prop:s0 +vendor.gralloc.disable_ubwc u:object_r:public_vendor_default_prop:s0 +vendor.debug.egl.profiler u:object_r:public_vendor_default_prop:s0 +vendor.gralloc.enable_ahardware_buffer u:object_r:public_vendor_default_prop:s0 # public_vendor_system_prop # They are public_vendor_system_props for vendor-specific extension. @@ -214,3 +220,7 @@ persist.vendor.nfc. u:object_r:vendor_nfc_prop:s0 # ramoops vendor.ramoops. u:object_r:vendor_ramoops_prop:s0 + +# fingerprint +vendor.fps.init.succeed u:object_r:vendor_fingerprint_prop:s0 +vendor.fps.init_retry.count u:object_r:vendor_fingerprint_prop:s0 diff --git a/sepolicy/vendor/ramdump.te b/sepolicy/vendor/ramdump.te index 7514dead..e0592272 100644 --- a/sepolicy/vendor/ramdump.te +++ b/sepolicy/vendor/ramdump.te @@ -22,5 +22,7 @@ userdebug_or_eng(` # read from /fstab.taimen allow ramdump rootfs:file r_file_perms; + dontaudit ramdump metadata_file:dir search; + r_dir_file(ramdump, sysfs_type) ') diff --git a/sepolicy/vendor/seapp_contexts b/sepolicy/vendor/seapp_contexts index a4f429ba..e1f512c9 100644 --- a/sepolicy/vendor/seapp_contexts +++ b/sepolicy/vendor/seapp_contexts @@ -1,7 +1,7 @@ user=system seinfo=platform name=com.google.SSRestartDetector domain=ssr_detector_app type=system_app_data_file user=_app seinfo=platform name=com.android.pixellogger domain=logger_app type=app_data_file levelFrom=all user=_app seinfo=platform name=com.android.ramdump domain=ramdump_app type=app_data_file levelFrom=all -user=_app seinfo=platform name=com.google.mds domain=mds_app type=app_data_file levelFrom=all +user=_app seinfo=google name=com.google.mds domain=mds_app type=app_data_file levelFrom=all #TODO Remove user "system" when b/63588267 is resolved user=system seinfo=platform name=com.qualcomm.telephony domain=qtelephony type=system_app_data_file @@ -29,4 +29,4 @@ user=_app seinfo=platform name=com.qualcomm.timeservice domain=timeservice_app t user=_app seinfo=easel name=com.google.android.imaging.easel.service domain=easelservice_app type=app_data_file levelFrom=user #Domain for connectivity monitor -user=radio seinfo=platform name=com.google.android.connectivitymonitor domain=con_monitor_app type=app_data_file levelFrom=all +user=_app isPrivApp=true seinfo=platform name=com.google.android.connectivitymonitor domain=con_monitor_app type=app_data_file levelFrom=all diff --git a/sepolicy/vendor/system_server.te b/sepolicy/vendor/system_server.te index 31c7ff72..d7b84619 100644 --- a/sepolicy/vendor/system_server.te +++ b/sepolicy/vendor/system_server.te @@ -23,5 +23,3 @@ typeattribute system_server system_writes_vendor_properties_violators; set_prop(system_server, public_vendor_system_prop) dontaudit system_server self:capability sys_module; - -allow system_server thermal_service:service_manager find; diff --git a/sepolicy/vendor/thermal-engine.te b/sepolicy/vendor/thermal-engine.te index bc1ab540..2bd2bd95 100644 --- a/sepolicy/vendor/thermal-engine.te +++ b/sepolicy/vendor/thermal-engine.te @@ -19,8 +19,6 @@ allow thermal-engine sysfs_rmtfs:dir search; allow thermal-engine sysfs_rmtfs:file r_file_perms; # to read /proc/stat allow thermal-engine proc_stat:file { getattr open read }; -# IThermal Thermal HAL -hal_server_domain(thermal-engine, hal_thermal) allow thermal-engine thermal_device:chr_file rw_file_perms; diff --git a/sepolicy/vendor/thermalserviced.te b/sepolicy/vendor/thermalserviced.te deleted file mode 100644 index aa6a0857..00000000 --- a/sepolicy/vendor/thermalserviced.te +++ /dev/null @@ -1 +0,0 @@ -binder_call(thermalserviced, system_server) diff --git a/sepolicy/vendor/vendor_init.te b/sepolicy/vendor/vendor_init.te index b74bba47..0953dcb0 100644 --- a/sepolicy/vendor/vendor_init.te +++ b/sepolicy/vendor/vendor_init.te @@ -11,6 +11,7 @@ allow vendor_init { allow vendor_init debugfs_clk:file w_file_perms; allow vendor_init proc_uid_cpupower:file write; +allow vendor_init proc_swappiness:file w_file_perms; dontaudit vendor_init kernel:system module_request; # Allow vendor_init to write to /proc/sysrq-trigger on userdebug and eng builds @@ -29,3 +30,9 @@ set_prop(vendor_init, vendor_charge_prop) dontaudit vendor_init unlabeled:dir getattr; dontaudit vendor_init unlabeled:file getattr; + +allow vendor_init debugfs_tracing_instances:dir create_dir_perms; +allow vendor_init debugfs_tracing_instances:file w_file_perms; + +# Write to touch vrmode node +allow vendor_init sysfs_touch:file w_file_perms; diff --git a/sepolicy/vendor/wcnss_service.te b/sepolicy/vendor/wcnss_service.te index a6f143c2..a6123328 100644 --- a/sepolicy/vendor/wcnss_service.te +++ b/sepolicy/vendor/wcnss_service.te @@ -12,7 +12,7 @@ allow wcnss_service per_mgr_service:service_manager find; allow wcnss_service vendor_shell_exec:file rx_file_perms; allow wcnss_service vendor_toolbox_exec:file rx_file_perms; -allow wcnss_service proc_net:file w_file_perms; +allow wcnss_service proc_net_type:file { getattr w_file_perms }; allow wcnss_service self:socket create_socket_perms; allowxperm wcnss_service self:socket ioctl msm_sock_ipc_ioctls; @@ -23,8 +23,6 @@ allow wcnss_service self:netlink_socket create_socket_perms_no_ioctl; allow wcnss_service cnss_vendor_data_file:dir create_dir_perms; allow wcnss_service cnss_vendor_data_file:file create_file_perms; -allow wcnss_service proc_net:file getattr; - r_dir_file(wcnss_service, sysfs_msm_subsys) # pkt logging for cnss_diag userdebug_or_eng(` diff --git a/sound_trigger_platform_info.xml b/sound_trigger_platform_info.xml index 0ce2d6ab..8a478465 100644 --- a/sound_trigger_platform_info.xml +++ b/sound_trigger_platform_info.xml @@ -33,6 +33,7 @@ + @@ -52,6 +53,7 @@ + @@ -71,6 +73,7 @@ + diff --git a/thermal/Android.bp b/thermal/Android.bp deleted file mode 100644 index 43c003ea..00000000 --- a/thermal/Android.bp +++ /dev/null @@ -1,21 +0,0 @@ -cc_library { - name: "android.hardware.thermal@1.1-wahoo", - defaults: ["hidl_defaults"], - owner: "qcom", - vendor: true, - relative_install_path: "hw", - srcs: [ - "sensors.cpp", - "Thermal.cpp", - "thermal-helper.cpp", - ], - export_include_dirs: ["."], - shared_libs: [ - "libbase", - "libhidlbase", - "libhidltransport", - "libutils", - "android.hardware.thermal@1.0", - "android.hardware.thermal@1.1", - ], -} diff --git a/thermal/Thermal.cpp b/thermal/Thermal.cpp deleted file mode 100644 index b47a54d8..00000000 --- a/thermal/Thermal.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include -#include - -#include "Thermal.h" -#include "thermal-helper.h" - -namespace android { -namespace hardware { -namespace thermal { -namespace V1_1 { -namespace implementation { - -Thermal::Thermal() : enabled(initThermal()) {} - -namespace { - -// Saves the IThermalCallback client object registered from the -// framework for sending thermal events to the framework thermal event bus. -sp gThermalCallback; - -struct ThermalDeathRecipient : hidl_death_recipient { - virtual void serviceDied( - uint64_t cookie __unused, const wp& who __unused) { - gThermalCallback = nullptr; - LOG(ERROR) << "IThermalCallback HIDL service died"; - } -}; - -sp gThermalCallbackDied = nullptr; - -} // anonymous namespace - -// Methods from ::android::hardware::thermal::V1_0::IThermal follow. -Return Thermal::getTemperatures(getTemperatures_cb _hidl_cb) { - ThermalStatus status; - status.code = ThermalStatusCode::SUCCESS; - hidl_vec temperatures; - temperatures.resize(kTemperatureNum); - - if (!enabled) { - status.code = ThermalStatusCode::FAILURE; - status.debugMessage = "Unsupported hardware"; - _hidl_cb(status, temperatures); - LOG(ERROR) << "ThermalHAL not initialized properly."; - return Void(); - } - - if (fillTemperatures(&temperatures) != kTemperatureNum) { - status.code = ThermalStatusCode::FAILURE; - status.debugMessage = "Error reading thermal sensors."; - } - _hidl_cb(status, temperatures); - - for (auto& t : temperatures) { - LOG(DEBUG) << "getTemperatures " - << " Type: " << static_cast(t.type) - << " Name: " << t.name - << " CurrentValue: " << t.currentValue - << " ThrottlingThreshold: " << t.throttlingThreshold - << " ShutdownThreshold: " << t.shutdownThreshold - << " VrThrottlingThreshold: " << t.vrThrottlingThreshold; - } - - return Void(); -} - -Return Thermal::getCpuUsages(getCpuUsages_cb _hidl_cb) { - ThermalStatus status; - status.code = ThermalStatusCode::SUCCESS; - hidl_vec cpuUsages; - cpuUsages.resize(kCpuNum); - - if (!enabled) { - status.code = ThermalStatusCode::FAILURE; - status.debugMessage = "Unsupported hardware"; - _hidl_cb(status, cpuUsages); - LOG(ERROR) << "ThermalHAL not initialized properly."; - return Void(); - } - - ssize_t ret = fillCpuUsages(&cpuUsages); - if (ret < 0) { - status.code = ThermalStatusCode::FAILURE; - status.debugMessage = strerror(-ret); - } - - for (auto& u : cpuUsages) { - LOG(DEBUG) << "getCpuUsages " - << " Name: " << u.name - << " Active: " << u.active - << " Total: " << u.total - << " IsOnline: " << u.isOnline; - } - - _hidl_cb(status, cpuUsages); - return Void(); -} - -Return Thermal::getCoolingDevices(getCoolingDevices_cb _hidl_cb) { - ThermalStatus status; - status.code = ThermalStatusCode::SUCCESS; - hidl_vec coolingDevices; - - if (!enabled) { - status.code = ThermalStatusCode::FAILURE; - status.debugMessage = "Unsupported hardware"; - _hidl_cb(status, coolingDevices); - LOG(ERROR) << "ThermalHAL not initialized properly."; - return Void(); - } - - LOG(DEBUG) << "No Cooling Device"; - _hidl_cb(status, coolingDevices); - return Void(); -} - -// Methods from ::android::hardware::thermal::V1_1::IThermal follow. - -Return Thermal::registerThermalCallback( - const sp& callback) { - gThermalCallback = callback; - - if (gThermalCallback != nullptr) { - if (gThermalCallbackDied == nullptr) - gThermalCallbackDied = new ThermalDeathRecipient(); - - if (gThermalCallbackDied != nullptr) - gThermalCallback->linkToDeath( - gThermalCallbackDied, 0x451F /* cookie, unused */); - LOG(INFO) << "ThermalCallback registered"; - } else { - LOG(INFO) << "ThermalCallback unregistered"; - } - return Void(); -} - -// Local functions used internally by thermal-engine follow. - -std::string Thermal::getSkinSensorType() { - return getTargetSkinSensorType(); -} - -void Thermal::notifyThrottling( - bool isThrottling, const Temperature& temperature) { - if (gThermalCallback != nullptr) { - Return ret = - gThermalCallback->notifyThrottling(isThrottling, temperature); - if (!ret.isOk()) { - if (ret.isDeadObject()) { - gThermalCallback = nullptr; - LOG(WARNING) << "Dropped throttling event, ThermalCallback died"; - } else { - LOG(WARNING) << - "Failed to send throttling event to ThermalCallback"; - } - } - } else { - LOG(WARNING) << - "Dropped throttling event, no ThermalCallback registered"; - } -} - -Return Thermal::debug(const hidl_handle& handle, const hidl_vec&) { - if (handle != nullptr && handle->numFds >= 1) { - int fd = handle->data[0]; - std::ostringstream dump_buf; - - if (!enabled) { - dump_buf << "ThermalHAL not initialized properly." << std::endl; - } else { - hidl_vec temperatures; - hidl_vec cpu_usages; - cpu_usages.resize(kCpuNum); - temperatures.resize(kTemperatureNum); - - dump_buf << "getTemperatures:" << std::endl; - if (fillTemperatures(&temperatures) != kTemperatureNum) { - dump_buf << "Failed to read thermal sensors." << std::endl; - } else { - for (const auto& t : temperatures) { - dump_buf << "Name: " << t.name - << " Type: " << android::hardware::thermal::V1_0::toString(t.type) - << " CurrentValue: " << t.currentValue - << " ThrottlingThreshold: " << t.throttlingThreshold - << " ShutdownThreshold: " << t.shutdownThreshold - << " VrThrottlingThreshold: " << t.vrThrottlingThreshold - << std::endl; - } - } - - dump_buf << "getCpuUsages:" << std::endl; - ssize_t ret = fillCpuUsages(&cpu_usages); - if (ret < 0) { - dump_buf << "Failed to get CPU usages." << std::endl; - } else { - for (const auto& usage : cpu_usages) { - dump_buf << "Name: " << usage.name - << " Active: " << usage.active - << " Total: " << usage.total - << " IsOnline: " << usage.isOnline - << std::endl; - } - } - - } - std::string buf = dump_buf.str(); - if (!android::base::WriteStringToFd(buf, fd)) { - PLOG(ERROR) << "Failed to dump state to fd"; - } - fsync(fd); - } - return Void(); -} - -} // namespace implementation -} // namespace V1_1 -} // namespace thermal -} // namespace hardware -} // namespace android diff --git a/thermal/Thermal.h b/thermal/Thermal.h deleted file mode 100644 index 270f0663..00000000 --- a/thermal/Thermal.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef ANDROID_HARDWARE_THERMAL_V1_1_WAHOO_THERMAL_H -#define ANDROID_HARDWARE_THERMAL_V1_1_WAHOO_THERMAL_H - -#include -#include -#include -#include - -namespace android { -namespace hardware { -namespace thermal { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::thermal::V1_0::CoolingDevice; -using ::android::hardware::thermal::V1_0::CpuUsage; -using ::android::hardware::thermal::V1_0::Temperature; -using ::android::hardware::thermal::V1_0::ThermalStatus; -using ::android::hardware::thermal::V1_0::ThermalStatusCode; -using ::android::hardware::thermal::V1_1::IThermal; -using ::android::hardware::thermal::V1_1::IThermalCallback; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_death_recipient; -using ::android::hidl::base::V1_0::IBase; -using ::android::sp; - -struct Thermal : public IThermal { - // Local functions used internally by thermal-engine follow. - std::string getSkinSensorType(); - void notifyThrottling(bool isThrottling, const Temperature& temperature); - Thermal(); - // Methods from ::android::hardware::thermal::V1_0::IThermal follow. - Return getTemperatures(getTemperatures_cb _hidl_cb) override; - Return getCpuUsages(getCpuUsages_cb _hidl_cb) override; - Return getCoolingDevices(getCoolingDevices_cb _hidl_cb) override; - // Methods from ::android::hardware::thermal::V1_1::IThermal follow. - Return registerThermalCallback( - const sp& callback) override; - // Methods from ::android::hidl::base::V1_0::IBase follow. - Return debug(const hidl_handle& fd, const hidl_vec& args) override; - private: - bool enabled; -}; - -} // namespace implementation -} // namespace V1_1 -} // namespace thermal -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_THERMAL_V1_1_WAHOO_THERMAL_H diff --git a/thermal/sensors.cpp b/thermal/sensors.cpp deleted file mode 100644 index 7df880bd..00000000 --- a/thermal/sensors.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include -#include -#include -#include -#include "sensors.h" - -namespace android { -namespace hardware { -namespace thermal { -namespace V1_1 { -namespace implementation { - -std::string Sensors::getSensorPath(const std::string& sensor_name) { - if (sensor_name_to_data_map_.find(sensor_name) != - sensor_name_to_data_map_.end()) { - return std::get<0>(sensor_name_to_data_map_.at(sensor_name)); - } - return ""; -} - -bool Sensors::addSensor( - const std::string& sensor_name, const std::string& path, - const float throttling_threshold, const float shutdown_threshold, - const float vr_threshold, const TemperatureType& type) { - return sensor_name_to_data_map_.emplace( - sensor_name, std::make_tuple( - path, throttling_threshold, shutdown_threshold, - vr_threshold, type)).second; -} - -bool Sensors::readSensorFile( - const std::string& sensor_name, std::string* data, - std::string* file_path) const { - std::string sensor_reading; - if (sensor_name_to_data_map_.find(sensor_name) == - sensor_name_to_data_map_.end()) { - *data = ""; - *file_path = ""; - return false; - } - - android::base::ReadFileToString( - std::get<0>(sensor_name_to_data_map_.at(sensor_name)), &sensor_reading); - // Strip the newline. - *data = ::android::base::Trim(sensor_reading); - *file_path = std::get<0>(sensor_name_to_data_map_.at(sensor_name)); - return true; -} - -bool Sensors::readTemperature( - const std::string& sensor_name, const float mult, - Temperature* out) const { - if (sensor_name_to_data_map_.find(sensor_name) == - sensor_name_to_data_map_.end()) { - return false; - } - - std::string sensor_reading; - std::string path; - readSensorFile(sensor_name, &sensor_reading, &path); - - auto sensor = sensor_name_to_data_map_.at(sensor_name); - out->name = sensor_name; - out->currentValue = std::stoi(sensor_reading) * mult; - out->throttlingThreshold = std::get<1>(sensor); - out->shutdownThreshold = std::get<2>(sensor); - out->vrThrottlingThreshold = std::get<3>(sensor); - out->type = std::get<4>(sensor); - - LOG(DEBUG) << android::base::StringPrintf( - "readTemperature: %s, %d, %s, %g, %g, %g, %g", - path.c_str(), out->type, out->name.c_str(), out->currentValue, - out->throttlingThreshold, out->shutdownThreshold, - out->vrThrottlingThreshold); - return true; -} - -} // namespace implementation -} // namespace V1_1 -} // namespace thermal -} // namespace hardware -} // namespace android diff --git a/thermal/sensors.h b/thermal/sensors.h deleted file mode 100644 index 4924ac27..00000000 --- a/thermal/sensors.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __SENSORS_H__ -#define __SENSORS_H__ - -#include -#include -#include - -#include - -namespace android { -namespace hardware { -namespace thermal { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::thermal::V1_0::Temperature; -using ::android::hardware::thermal::V1_0::TemperatureType; - -class Sensors { - public: - Sensors() = default; - ~Sensors() = default; - Sensors(const Sensors&) = delete; - void operator=(const Sensors&) = delete; - - std::string getSensorPath(const std::string& sensor_name); - // Returns true if add was successful, false otherwise. - bool addSensor( - const std::string& sensor_name, const std::string& path, - const float throttling_threshold, const float shutdown_threshold, - const float vr_threshold, const TemperatureType& type); - // If sensor is not found in the sensor names to path map, this will set - // data and file path to empty and return false. If the sensor is found, - // this function will fill in data and file_path accordingly then return - // true. - bool readSensorFile( - const std::string& sensor_name, std::string* data, - std::string* file_path) const; - bool readTemperature( - const std::string& sensor_name, const float mult, - Temperature* out) const; - size_t getNumSensors() const { return sensor_name_to_data_map_.size(); } - - private: - // A map containing sensor names along with its thermal zone number, its - // thresholds, and its type. The tuple is formatted as such: - // - std::unordered_map> - sensor_name_to_data_map_; -}; - -} // namespace implementation -} // namespace V1_1 -} // namespace thermal -} // namespace hardware -} // namespace android - -#endif // __SENSORS_H__ - diff --git a/thermal/thermal-helper.cpp b/thermal/thermal-helper.cpp deleted file mode 100644 index 6e9cf17d..00000000 --- a/thermal/thermal-helper.cpp +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "sensors.h" -#include "thermal-helper.h" - -namespace android { -namespace hardware { -namespace thermal { -namespace V1_1 { -namespace implementation { - -constexpr const char kThermalSensorsRoot[] = "/sys/class/thermal"; -constexpr char kThermalZoneDirSuffix[] = "thermal_zone"; -constexpr char kSensorTypeFileSuffix[] = "type"; -constexpr char kTemperatureFileSuffix[] = "temp"; -// This is a golden set of thermal sensor names, their types, and their -// multiplier. Used when we read in sensor values. The tuple value stored is -// formatted as such: -// -const std::unordered_map> -kValidThermalSensorsMap = { - {"tsens_tz_sensor1", {TemperatureType::CPU, 0.1}}, // CPU0 - {"tsens_tz_sensor2", {TemperatureType::CPU, 0.1}}, // CPU1 - {"tsens_tz_sensor4", {TemperatureType::CPU, 0.1}}, // CPU2 - {"tsens_tz_sensor3", {TemperatureType::CPU, 0.1}}, // CPU3 - {"tsens_tz_sensor7", {TemperatureType::CPU, 0.1}}, // CPU4 - {"tsens_tz_sensor8", {TemperatureType::CPU, 0.1}}, // CPU5 - {"tsens_tz_sensor9", {TemperatureType::CPU, 0.1}}, // CPU6 - {"tsens_tz_sensor10", {TemperatureType::CPU, 0.1}}, // CPU7 - // GPU thermal sensor. - {"tsens_tz_sensor13", {TemperatureType::GPU, 0.1}}, - // Battery thermal sensor. - {"battery", {TemperatureType::BATTERY, 0.001}}, - // Skin thermal sensors. We use back_therm for walleye. For taimen we use - // bd_therm and bd_therm2. - {"back_therm", {TemperatureType::SKIN, 1.}}, - {"bd_therm", {TemperatureType::SKIN, 1.}}, - {"bd_therm2", {TemperatureType::SKIN, 1.}}, - // USBC thermal sensor. - {"usb_port_temp", {TemperatureType::UNKNOWN, 0.1}}, -}; - -namespace { - -using ::android::hardware::thermal::V1_0::TemperatureType; - -static std::string gSkinSensorType; -static unsigned int gSkinThrottlingThreshold; -static unsigned int gSkinShutdownThreshold; -static unsigned int gVrThrottledBelowMin; -Sensors gSensors; - -// A map containing hardcoded thresholds per sensor type. Its not const -// because initThermal() will modify the skin sensor thresholds depending on the -// hardware type. The tuple is formatted as follows: -// -std::unordered_map> -gSensorTypeToThresholdsMap = { - {TemperatureType::CPU, {kCpuThrottlingThreshold, kCpuShutdownThreshold, - kCpuThrottlingThreshold}}, - {TemperatureType::GPU, {NAN, NAN, NAN}}, - {TemperatureType::BATTERY, {NAN, kBatteryShutdownThreshold, NAN}}, - {TemperatureType::SKIN, {NAN, NAN, NAN}}, - {TemperatureType::UNKNOWN, {NAN, NAN, NAN}} -}; - -bool initializeSensors() { - auto thermal_zone_dir = std::unique_ptr( - opendir(kThermalSensorsRoot), closedir); - struct dirent* dp; - size_t num_thermal_zones = 0; - while ((dp = readdir(thermal_zone_dir.get())) != nullptr) { - std::string dir_name(dp->d_name); - if (dir_name.find(kThermalZoneDirSuffix) != std::string::npos) { - ++num_thermal_zones; - } - } - - for (size_t sensor_zone_num = 0; sensor_zone_num < num_thermal_zones; - ++sensor_zone_num) { - std::string path = android::base::StringPrintf("%s/%s%zu", - kThermalSensorsRoot, - kThermalZoneDirSuffix, - sensor_zone_num); - std::string sensor_name; - if (android::base::ReadFileToString( - path + "/" + kSensorTypeFileSuffix, &sensor_name)) { - sensor_name = android::base::Trim(sensor_name); - if (kValidThermalSensorsMap.find(sensor_name) != - kValidThermalSensorsMap.end()) { - TemperatureType type = std::get<0>( - kValidThermalSensorsMap.at(sensor_name)); - auto thresholds = gSensorTypeToThresholdsMap.at(type); - if (!gSensors.addSensor( - sensor_name, path + "/" + kTemperatureFileSuffix, - std::get<0>(thresholds), std::get<1>(thresholds), - std::get<2>(thresholds), type)) { - LOG(ERROR) << "Could not add " << sensor_name - << "to sensors map"; - } - } - } - } - return (gSensors.getNumSensors() == kTemperatureNum); -} - -} // namespace - -/** - * Initialization constants based on platform - * - * @return true on success or false on error. - */ -bool initThermal() { - std::string hardware = android::base::GetProperty("ro.hardware", ""); - if (hardware == "walleye") { - LOG(ERROR) << "Initialization on Walleye"; - gSkinThrottlingThreshold = kWalleyeSkinThrottlingThreshold; - gSkinShutdownThreshold = kWalleyeSkinShutdownThreshold; - gVrThrottledBelowMin = kWalleyeVrThrottledBelowMin; - } else if (hardware == "taimen") { - std::string rev = android::base::GetProperty("ro.revision", ""); - if (rev == "rev_a" || rev == "rev_b") { - LOG(ERROR) << "Initialization on Taimen pre revision C"; - gSkinThrottlingThreshold = kTaimenRabSkinThrottlingThreshold; - gSkinShutdownThreshold = kTaimenRabSkinShutdownThreshold; - gVrThrottledBelowMin = kTaimenRabVrThrottledBelowMin; - } else { - LOG(ERROR) << "Initialization on Taimen revision C and later"; - gSkinThrottlingThreshold = kTaimenRcSkinThrottlingThreshold; - gSkinShutdownThreshold = kTaimenRcSkinShutdownThreshold; - gVrThrottledBelowMin = kTaimenRcVrThrottledBelowMin; - } - } else { - LOG(ERROR) << "Unsupported hardware: " << hardware; - return false; - } - gSensorTypeToThresholdsMap[TemperatureType::SKIN] = - std::make_tuple(gSkinThrottlingThreshold, gSkinShutdownThreshold, - gVrThrottledBelowMin); - return initializeSensors(); -} - -ssize_t fillTemperatures(hidl_vec* temperatures) { - temperatures->resize(gSensors.getNumSensors()); - ssize_t current_index = 0; - for (const auto& name_type_mult_pair : kValidThermalSensorsMap) { - Temperature temp; - if (gSensors.readTemperature(name_type_mult_pair.first, - std::get<1>(name_type_mult_pair.second), - &temp)) { - (*temperatures)[current_index] = temp; - ++current_index; - } - } - return current_index; -} - -ssize_t fillCpuUsages(hidl_vec *cpuUsages) { - int vals, cpu_num, online; - ssize_t read; - uint64_t user, nice, system, idle, active, total; - char *line = NULL; - size_t len = 0; - size_t size = 0; - char file_name[PATH_MAX]; - FILE *file; - FILE *cpu_file; - - if (cpuUsages == NULL || cpuUsages->size() < kCpuNum ) { - LOG(ERROR) << "fillCpuUsages: incorrect buffer"; - return -EINVAL; - } - - file = fopen(kCpuUsageFile, "r"); - if (file == NULL) { - PLOG(ERROR) << "fillCpuUsages: failed to open file (" << kCpuUsageFile << ")"; - return -errno; - } - - while ((read = getline(&line, &len, file)) != -1) { - // Skip non "cpu[0-9]" lines. - if (strnlen(line, read) < 4 || strncmp(line, "cpu", 3) != 0 || !isdigit(line[3])) { - free(line); - line = NULL; - len = 0; - continue; - } - - vals = sscanf(line, "cpu%d %" SCNu64 " %" SCNu64 " %" SCNu64 " %" SCNu64, &cpu_num, &user, - &nice, &system, &idle); - - free(line); - line = NULL; - len = 0; - - if (vals != 5 || size == kCpuNum) { - if (vals != 5) { - PLOG(ERROR) << "fillCpuUsages: failed to read CPU information from file (" - << kCpuUsageFile << ")"; - } else { - PLOG(ERROR) << "fillCpuUsages: file has incorrect format (" - << kCpuUsageFile << ")"; - } - fclose(file); - return errno ? -errno : -EIO; - } - - active = user + nice + system; - total = active + idle; - - // Read online CPU information. - snprintf(file_name, PATH_MAX, kCpuOnlineFileFormat, cpu_num); - cpu_file = fopen(file_name, "r"); - online = 0; - if (cpu_file == NULL) { - PLOG(ERROR) << "fillCpuUsages: failed to open file (" << file_name << ")"; - fclose(file); - return -errno; - } - if (1 != fscanf(cpu_file, "%d", &online)) { - PLOG(ERROR) << "fillCpuUsages: failed to read CPU online information from file (" - << file_name << ")"; - fclose(file); - fclose(cpu_file); - return errno ? -errno : -EIO; - } - fclose(cpu_file); - - (*cpuUsages)[size].name = kCpuLabel[size]; - (*cpuUsages)[size].active = active; - (*cpuUsages)[size].total = total; - (*cpuUsages)[size].isOnline = static_cast(online); - - LOG(DEBUG) << "fillCpuUsages: "<< kCpuLabel[size] << ": " - << active << " " << total << " " << online; - size++; - } - fclose(file); - - if (size != kCpuNum) { - PLOG(ERROR) << "fillCpuUsages: file has incorrect format (" << kCpuUsageFile << ")"; - return -EIO; - } - return kCpuNum; -} - -std::string getTargetSkinSensorType() { - return gSkinSensorType; -} - -} // namespace implementation -} // namespace V1_1 -} // namespace thermal -} // namespace hardware -} // namespace android diff --git a/thermal/thermal-helper.h b/thermal/thermal-helper.h deleted file mode 100644 index ef0b61ff..00000000 --- a/thermal/thermal-helper.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2017, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __THERMAL_HELPER_H__ -#define __THERMAL_HELPER_H__ - -#include - -namespace android { -namespace hardware { -namespace thermal { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::thermal::V1_0::CpuUsage; -using ::android::hardware::thermal::V1_0::Temperature; -using ::android::hardware::thermal::V1_0::TemperatureType; - -constexpr const char *kCpuUsageFile = "/proc/stat"; -constexpr const char *kTemperatureFileFormat = "/sys/class/thermal/thermal_zone%d/temp"; -constexpr const char *kCpuOnlineFileFormat = "/sys/devices/system/cpu/cpu%d/online"; - -// thermal-engine.conf -constexpr unsigned int kWalleyeSkinThrottlingThreshold = 40; -constexpr unsigned int kWalleyeSkinShutdownThreshold = 56; -constexpr unsigned int kWalleyeVrThrottledBelowMin = 52; - -constexpr unsigned int kTaimenRabSkinThrottlingThreshold = 49; -constexpr unsigned int kTaimenRabSkinShutdownThreshold = 66; -constexpr unsigned int kTaimenRabVrThrottledBelowMin = 62; - -constexpr unsigned int kTaimenRcSkinThrottlingThreshold = 38; -constexpr unsigned int kTaimenRcSkinShutdownThreshold = 54; -constexpr unsigned int kTaimenRcVrThrottledBelowMin = 50; - -constexpr unsigned int kCpuNum = 8; - -constexpr const char *kCpuLabel[kCpuNum] = { - "CPU0", "CPU1", "CPU2", "CPU3", "CPU4", "CPU5", "CPU6", "CPU7"}; - -// Sum of kCpuNum + 4 for GPU, BATTERY, SKIN, and USB-C. -constexpr unsigned int kTemperatureNum = 4 + kCpuNum; - -// qcom, therm-reset-temp -constexpr unsigned int kCpuShutdownThreshold = 115; -// qcom,freq-mitigation-temp -constexpr unsigned int kCpuThrottlingThreshold = 95; - -// config_shutdownBatteryTemperature in overlay/frameworks/base/core/res/res/values/config.xml -constexpr unsigned int kBatteryShutdownThreshold = 60; - - -bool initThermal(); -ssize_t fillTemperatures(hidl_vec *temperatures); -ssize_t fillCpuUsages(hidl_vec *cpuUsages); -std::string getTargetSkinSensorType(); - -} // namespace implementation -} // namespace V1_1 -} // namespace thermal -} // namespace hardware -} // namespace android - -#endif //__THERMAL_HELPER_H__ diff --git a/vibrator/OWNERS b/vibrator/OWNERS new file mode 100644 index 00000000..2c0d70d5 --- /dev/null +++ b/vibrator/OWNERS @@ -0,0 +1,2 @@ +dtwlin@google.com +michaelwr@google.com diff --git a/vibrator/Vibrator.cpp b/vibrator/Vibrator.cpp index 96576848..ff66d8e0 100644 --- a/vibrator/Vibrator.cpp +++ b/vibrator/Vibrator.cpp @@ -176,15 +176,30 @@ static uint8_t convertEffectStrength(EffectStrength strength) { } Return Vibrator::perform(V1_0::Effect effect, EffectStrength strength, perform_cb _hidl_cb) { - return performEffect(static_cast(effect), strength, _hidl_cb); + return performWrapper(effect, strength, _hidl_cb); } Return Vibrator::perform_1_1(V1_1::Effect_1_1 effect, EffectStrength strength, perform_cb _hidl_cb) { - return performEffect(static_cast(effect), strength, _hidl_cb); + return performWrapper(effect, strength, _hidl_cb); } Return Vibrator::perform_1_2(Effect effect, EffectStrength strength, perform_cb _hidl_cb) { + return performWrapper(effect, strength, _hidl_cb); +} + +template +Return Vibrator::performWrapper(T effect, EffectStrength strength, perform_cb _hidl_cb) { + auto validEffectRange = hidl_enum_range(); + if (effect < *validEffectRange.begin() || effect > *std::prev(validEffectRange.end())) { + _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); + return Void(); + } + auto validStrengthRange = hidl_enum_range(); + if (strength < *validStrengthRange.begin() || strength > *std::prev(validStrengthRange.end())) { + _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); + return Void(); + } return performEffect(static_cast(effect), strength, _hidl_cb); } diff --git a/vibrator/Vibrator.h b/vibrator/Vibrator.h index f9daf7cd..24510d76 100644 --- a/vibrator/Vibrator.h +++ b/vibrator/Vibrator.h @@ -50,6 +50,8 @@ public: private: Return on(uint32_t timeoutMs, bool forceOpenLoop, bool isWaveform); + template + Return performWrapper(T effect, EffectStrength strength, perform_cb _hidl_cb); Return performEffect(Effect effect, EffectStrength strength, perform_cb _hidl_cb); std::ofstream mActivate; std::ofstream mDuration; diff --git a/vr/Android.bp b/vr/Android.bp deleted file mode 100644 index 99aef7d8..00000000 --- a/vr/Android.bp +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright (C) 2017 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -cc_binary { - name: "android.hardware.vr@1.0-service.wahoo", - relative_install_path: "hw", - init_rc: ["android.hardware.vr@1.0-service.wahoo.rc"], - srcs: ["service.cpp", "VrDevice.cpp"], - cflags: ["-Werror", "-Wall"], - shared_libs: [ - "libbase", - "libhidlbase", - "libhidltransport", - "liblog", - "libutils", - "android.hardware.vr@1.0", - ], - proprietary: true, -} diff --git a/vr/NOTICE b/vr/NOTICE deleted file mode 100644 index 667db97b..00000000 --- a/vr/NOTICE +++ /dev/null @@ -1,10 +0,0 @@ -Copyright (C) 2017 The Android Open Source Project - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/vr/VrDevice.cpp b/vr/VrDevice.cpp deleted file mode 100644 index e5cd94dd..00000000 --- a/vr/VrDevice.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "VrDevice" - -#include -#include -#include -#include - -#include "VrDevice.h" - -namespace android { -namespace hardware { -namespace vr { -namespace V1_0 { -namespace implementation { - -constexpr char kTouchVRModeSysfs[] = "/sys/devices/virtual/input/ftm4_touch/vrmode"; - -VrDevice::VrDevice() : mVRmode(false) { - std::string hardware = android::base::GetProperty("ro.hardware", ""); - if (hardware == "taimen") { - mFtm4Touch = true; - } else { - mFtm4Touch = false; - } -} - -Return VrDevice::init() { - // NOOP - return Void(); -} - -Return VrDevice::setVrMode(bool enabled) { - mVRmode = enabled; - if (enabled) { - if (!android::base::SetProperty("sys.qcom.thermalcfg", - "/vendor/etc/thermal-engine-vr.conf")) { - LOG(ERROR) << "Couldn't set thermal_engine enable property"; - return Void(); - } - } else { - if (!android::base::SetProperty("sys.qcom.thermalcfg", - "/vendor/etc/thermal-engine.conf")) { - LOG(ERROR) << "Couldn't set thermal_engine disable property"; - return Void(); - } - } - if (!android::base::SetProperty("ctl.restart", "vendor.thermal-engine")) { - LOG(ERROR) << "Couldn't set thermal_engine restart property"; - } - - if (mFtm4Touch && - !android::base::WriteStringToFile((enabled ? "1" : "0"), kTouchVRModeSysfs)) { - PLOG(ERROR) << "Failed to write to vrmode sysfs node with :" << enabled; - } - - return Void(); -} - -Return VrDevice::debug(const hidl_handle& handle, const hidl_vec&) { - if (handle != nullptr && handle->numFds >= 1) { - int fd = handle->data[0]; - std::string buf(android::base::StringPrintf("VRMode: %s\n", - (mVRmode ? "true" : "false"))); - if (!android::base::WriteStringToFd(buf, fd)) { - PLOG(ERROR) << "Failed to dump state to fd"; - } - fsync(fd); - } - return Void(); -} - -} // namespace implementation -} // namespace V1_0 -} // namespace vr -} // namespace hardware -} // namespace android diff --git a/vr/VrDevice.h b/vr/VrDevice.h deleted file mode 100644 index 7bc3e149..00000000 --- a/vr/VrDevice.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef ANDROID_HARDWARE_VR_V1_0_VR_H -#define ANDROID_HARDWARE_VR_V1_0_VR_H - -#include - -namespace android { -namespace hardware { -namespace vr { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::vr::V1_0::IVr; -using ::android::hardware::Return; - -struct VrDevice : public IVr { - VrDevice(); - - Return init() override; - Return setVrMode(bool enabled) override; - Return debug(const hidl_handle& handle, const hidl_vec&) override; - private: - // Taimen display touch sensitivity for VR Mode (b/37515573) - bool mFtm4Touch; - bool mVRmode; -}; - -} // namespace implementation -} // namespace V1_0 -} // namespace vr -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_VR_V1_0_VR_H diff --git a/vr/android.hardware.vr@1.0-service.wahoo.rc b/vr/android.hardware.vr@1.0-service.wahoo.rc deleted file mode 100644 index 10f3ac96..00000000 --- a/vr/android.hardware.vr@1.0-service.wahoo.rc +++ /dev/null @@ -1,10 +0,0 @@ -service vendor.vr-wahoo-1-0 /vendor/bin/hw/android.hardware.vr@1.0-service.wahoo - class hal - user system - group system - -# reset touch and thermal-engine when framework died and thermal-engine is in VR mode -on property:init.svc.zygote=restarting && property:sys.qcom.thermalcfg=/vendor/etc/thermal-engine-vr.conf - write /sys/devices/virtual/input/ftm4_touch/vrmode 0 - setprop sys.qcom.thermalcfg "/vendor/etc/thermal-engine.conf" - restart vendor.thermal-engine diff --git a/vr/service.cpp b/vr/service.cpp deleted file mode 100644 index a04991b0..00000000 --- a/vr/service.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#define LOG_TAG "android.hardware.vr@1.0-service.wahoo" - -#include -#include -#include -#include - -#include "VrDevice.h" - -using ::android::hardware::configureRpcThreadpool; -using ::android::hardware::joinRpcThreadpool; -using ::android::hardware::vr::V1_0::implementation::VrDevice; -using ::android::hardware::vr::V1_0::IVr; -using ::android::sp; - -int main(int /* argc */, char* /* argv */ []) { - sp vr = new VrDevice; - configureRpcThreadpool(1, true); - CHECK_EQ(vr->registerAsService(), android::NO_ERROR) - << "Failed to register vr HAL"; - joinRpcThreadpool(); - return 0; -} diff --git a/wpa_supplicant_overlay.conf b/wpa_supplicant_overlay.conf index bb1906c3..16c28040 100644 --- a/wpa_supplicant_overlay.conf +++ b/wpa_supplicant_overlay.conf @@ -2,3 +2,7 @@ disable_scan_offload=1 p2p_disabled=1 tdls_external_control=1 bss_max_count=512 +interworking=1 +hs20=1 +auto_interworking=0 +bss_no_flush_when_down=1