From 10fe43dba05074d1d4e4d6e6fbca5238879151b3 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Fri, 13 Nov 2020 10:59:00 -0800 Subject: [PATCH] power: add a property for config file Test: build Bug: 173222103 Signed-off-by: Wei Wang Change-Id: I14e7e0aa349e446f6889cbfc9a914f5314438e6b --- aidl/power-libperfmgr/service.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/aidl/power-libperfmgr/service.cpp b/aidl/power-libperfmgr/service.cpp index 4634ea11..54e9388f 100644 --- a/aidl/power-libperfmgr/service.cpp +++ b/aidl/power-libperfmgr/service.cpp @@ -30,16 +30,21 @@ using aidl::google::hardware::power::impl::pixel::Power; using aidl::google::hardware::power::impl::pixel::PowerExt; using ::android::perfmgr::HintManager; -constexpr char kPowerHalConfigPath[] = "/vendor/etc/powerhint.json"; -constexpr char kPowerHalInitProp[] = "vendor.powerhal.init"; +constexpr std::string_view kPowerHalInitProp("vendor.powerhal.init"); +constexpr std::string_view kConfigProperty("vendor.powerhal.config"); +constexpr std::string_view kConfigDefaultFileName("powerhint.json"); int main() { - LOG(INFO) << "Pixel Power HAL AIDL Service with Extension is starting."; + const std::string config_path = + "/vendor/etc/" + + android::base::GetProperty(kConfigProperty.data(), kConfigDefaultFileName.data()); + LOG(INFO) << "Pixel Power HAL AIDL Service with Extension is starting with config: " + << config_path; // Parse config but do not start the looper - std::shared_ptr hm = HintManager::GetFromJSON(kPowerHalConfigPath, false); + std::shared_ptr hm = HintManager::GetFromJSON(config_path, false); if (!hm) { - LOG(FATAL) << "Invalid config: " << kPowerHalConfigPath; + LOG(FATAL) << "Invalid config: " << config_path; } // single thread @@ -61,7 +66,7 @@ int main() { LOG(INFO) << "Pixel Power HAL AIDL Service with Extension is started."; std::thread initThread([&]() { - ::android::base::WaitForProperty(kPowerHalInitProp, "1"); + ::android::base::WaitForProperty(kPowerHalInitProp.data(), "1"); hm->Start(); }); initThread.detach();