power: Add global debug property for override config path properly
An init trigger would restart powerhal as early as the property was
loaded and it is hopefully early than any clients would try to connect.
Also remove the obsolete restart hook with audio.
Bug: 218872105
Test: boot
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: Ib55897f65709a963016b729f213718aae5af8e8c
diff --git a/aidl/power-libperfmgr/android.hardware.power-service.mediatek-libperfmgr.rc b/aidl/power-libperfmgr/android.hardware.power-service.mediatek-libperfmgr.rc
index a0766e2..51755f1 100644
--- a/aidl/power-libperfmgr/android.hardware.power-service.mediatek-libperfmgr.rc
+++ b/aidl/power-libperfmgr/android.hardware.power-service.mediatek-libperfmgr.rc
@@ -7,18 +7,13 @@
on late-fs
start vendor.power-hal-aidl
-# restart powerHAL when framework died
+# Restart powerHAL when framework died
on property:init.svc.zygote=restarting && property:vendor.mediatek.powerhal.state=*
setprop vendor.mediatek.powerhal.state ""
setprop vendor.mediatek.powerhal.audio ""
setprop vendor.mediatek.powerhal.rendering ""
restart vendor.power-hal-aidl
-# restart powerHAL when audioHAL died
-on property:init.svc.vendor.audio-hal-2-0=restarting && property:vendor.mediatek.powerhal.audio=AUDIO_STREAMING_LOW_LATENCY
- setprop vendor.mediatek.powerhal.audio ""
- restart vendor.power-hal-aidl
-
# Clean up after b/163539793 resolved
on property:vendor.mediatek.powerhal.dalvik.vm.dex2oat-threads=*
setprop dalvik.vm.dex2oat-threads ${vendor.mediatek.powerhal.dalvik.vm.dex2oat-threads}
@@ -27,3 +22,10 @@
on property:vendor.mediatek.powerhal.dalvik.vm.dex2oat-cpu-set=*
setprop dalvik.vm.dex2oat-cpu-set ${vendor.mediatek.powerhal.dalvik.vm.dex2oat-cpu-set}
setprop dalvik.vm.restore-dex2oat-cpu-set ${vendor.mediatek.powerhal.dalvik.vm.dex2oat-cpu-set}
+
+# Restart powerHAL when debug property set
+on property:ro.debuggable=1 && property:vendor.mediatek.powerhal.config.debug=*
+ restart vendor.power-hal-aidl
+
+on property:persist.vendor.mediatek.powerhal.config.debug=*
+ setprop vendor.mediatek.powerhal.config.debug ${persist.vendor.mediatek.powerhal.config.debug}
diff --git a/aidl/power-libperfmgr/service.cpp b/aidl/power-libperfmgr/service.cpp
index a3dd31c..e787479 100644
--- a/aidl/power-libperfmgr/service.cpp
+++ b/aidl/power-libperfmgr/service.cpp
@@ -39,9 +39,14 @@
constexpr std::string_view kConfigDefaultFileName("powerhint.json");
int main() {
- const std::string config_path =
- "/vendor/etc/" +
- android::base::GetProperty(kConfigProperty.data(), kConfigDefaultFileName.data());
+ std::string config_path = "/vendor/etc/";
+ if (android::base::GetBoolProperty(kConfigDebugPathProperty.data(), false)) {
+ config_path = "/data/vendor/etc/";
+ LOG(WARNING) << "Xiaomi Power HAL AIDL Service is using debug config from: " << config_path;
+ }
+ config_path.append(
+ android::base::GetProperty(kConfigProperty.data(), kConfigDefaultFileName.data()));
+
LOG(INFO) << "Xiaomi Power HAL AIDL Service with Extension is starting with config: "
<< config_path;
@@ -69,23 +74,14 @@
CHECK(status == STATUS_OK);
LOG(INFO) << "Xiaomi Power HAL AIDL Service with Extension is started.";
+ if (::android::base::GetIntProperty("vendor.mediatek.powerhal.adpf.rate", -1) != -1) {
+ PowerHintMonitor::getInstance()->start();
+ PowerSessionManager::getInstance()->setHintManager(hm);
+ }
+
std::thread initThread([&]() {
::android::base::WaitForProperty(kPowerHalInitProp.data(), "1");
hm->Start();
-
- // use debug config for ADPF tuning.
- if (android::base::GetBoolProperty(kConfigDebugPathProperty.data(), false)) {
- const std::string debug_config_path =
- "/data/vendor/etc/" + android::base::GetProperty(kConfigProperty.data(),
- kConfigDefaultFileName.data());
- hm = HintManager::GetFromJSON(debug_config_path, false);
- LOG(WARNING) << "Xiaomi Power HAL AIDL Service with Extension is reloading with config: "
- << debug_config_path;
- }
- if (::android::base::GetIntProperty("vendor.mediatek.powerhal.adpf.rate", -1) != -1) {
- PowerHintMonitor::getInstance()->start();
- PowerSessionManager::getInstance()->setHintManager(hm);
- }
});
initThread.detach();