From 24e591bdd9692837d30a27f9a88d934a64925fba Mon Sep 17 00:00:00 2001 From: chungkai Date: Tue, 12 Jul 2022 09:44:05 +0000 Subject: [PATCH] powerhal: fix path for i2c peripheral device paths are changed when we enable parallel module loading and reorder the initializtaion of devices. Test: without error on L10 when booting Bug: 229794277 Signed-off-by: chungkai Change-Id: I2ce4e0556f9c7ea0e2ed5d3965ad567069524842 --- powerstats/service.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/powerstats/service.cpp b/powerstats/service.cpp index ef07d0e..3ee4bc7 100644 --- a/powerstats/service.cpp +++ b/powerstats/service.cpp @@ -26,6 +26,7 @@ #include #include #include +#include using aidl::android::hardware::power::stats::DisplayStateResidencyDataProvider; using aidl::android::hardware::power::stats::EnergyConsumerType; @@ -54,6 +55,8 @@ void addDisplay(std::shared_ptr p) { } int main() { + struct stat buffer; + LOG(INFO) << "Pixel PowerStats HAL AIDL Service is starting."; // single thread @@ -63,7 +66,21 @@ int main() { addGs201CommonDataProvidersQc(p); addDisplay(p); - addNFC(p, "/sys/devices/platform/10970000.hsi2c/i2c-4/i2c-st21nfc/power_stats"); + if (!stat("/sys/devices/platform/10970000.hsi2c/i2c-2/i2c-st21nfc/power_stats", &buffer)) { + addNFC(p, "/sys/devices/platform/10970000.hsi2c/i2c-2/i2c-st21nfc/power_stats"); + } else if (!stat("/sys/devices/platform/10970000.hsi2c/i2c-3/i2c-st21nfc/power_stats", &buffer)) { + addNFC(p, "/sys/devices/platform/10970000.hsi2c/i2c-3/i2c-st21nfc/power_stats"); + } else if (!stat("/sys/devices/platform/10970000.hsi2c/i2c-4/i2c-st21nfc/power_stats", &buffer)) { + addNFC(p, "/sys/devices/platform/10970000.hsi2c/i2c-4/i2c-st21nfc/power_stats"); + } else if (!stat("/sys/devices/platform/10970000.hsi2c/i2c-5/i2c-st21nfc/power_stats", &buffer)) { + addNFC(p, "/sys/devices/platform/10970000.hsi2c/i2c-5/i2c-st21nfc/power_stats"); + } else if (!stat("/sys/devices/platform/10970000.hsi2c/i2c-6/i2c-st21nfc/power_stats", &buffer)) { + addNFC(p, "/sys/devices/platform/10970000.hsi2c/i2c-6/i2c-st21nfc/power_stats"); + } else if (!stat("/sys/devices/platform/10970000.hsi2c/i2c-7/i2c-st21nfc/power_stats", &buffer)) { + addNFC(p, "/sys/devices/platform/10970000.hsi2c/i2c-7/i2c-st21nfc/power_stats"); + } else { + addNFC(p, "/sys/devices/platform/10970000.hsi2c/i2c-8/i2c-st21nfc/power_stats"); + } const std::string instance = std::string() + PowerStats::descriptor + "/default"; binder_status_t status = AServiceManager_addService(p->asBinder().get(), instance.c_str());