From 74ec0169520d9e214ca7f9a75570d8a3a52e93ad Mon Sep 17 00:00:00 2001 From: Kelly Rossmoyer Date: Fri, 4 Feb 2022 14:00:16 -0800 Subject: [PATCH] Enable PowerStatsHAL to read NFC power state stats This change adds support to PowerStatsHAL on sunfish devices for reading NFC power state stats for inclusion with other subsystem power state stats. The data is already present in sysfs; this CL (in combination with the associated selinux change) simply adds reading of that data. Bug: 217388683 Test: lshal debug android.hardware.power.stats@1.0::IPowerStats/default Test: cat /sys/class/misc/st21nfc/device/power_stats Change-Id: Ie0dc14880ba57722c2c43c8cf40783bcd3ff14b9 --- powerstats/service.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/powerstats/service.cpp b/powerstats/service.cpp index c4d4c4ff..4a76e4a6 100644 --- a/powerstats/service.cpp +++ b/powerstats/service.cpp @@ -128,6 +128,30 @@ int main(int /* argc */, char ** /* argv */) { std::vector{"Off", "LP", "1080x2340@60"}); service->addStateResidencyDataProvider(displaySdp); + // Add NFC power entity + StateResidencyConfig nfcStateConfig = { + .entryCountSupported = true, + .entryCountPrefix = "Cumulative count:", + .totalTimeSupported = true, + .totalTimePrefix = "Cumulative duration msec:", + .lastEntrySupported = true, + .lastEntryPrefix = "Last entry timestamp msec:" + }; + std::vector> nfcStateHeaders = { + std::make_pair("Idle", "Idle mode:"), + std::make_pair("Active", "Active mode:"), + std::make_pair("Active-RW", "Active Reader/Writer mode:"), + }; + + sp nfcSdp = + new GenericStateResidencyDataProvider("/sys/class/misc/st21nfc/device/power_stats"); + + uint32_t nfcId = service->addPowerEntity("NFC", PowerEntityType::SUBSYSTEM); + nfcSdp->addEntity(nfcId, + PowerEntityConfig(generateGenericStateResidencyConfigs(nfcStateConfig, nfcStateHeaders))); + + service->addStateResidencyDataProvider(nfcSdp); + // Add Power Entities that require the Aidl data provider auto aidlSdp = sp::make(); uint32_t citadelId = service->addPowerEntity("Citadel", PowerEntityType::SUBSYSTEM);