Skip to content

Commit

Permalink
Enable PowerStatsHAL to read NFC power state stats
Browse files Browse the repository at this point in the history
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 [email protected]::IPowerStats/default
Test: cat /sys/class/misc/st21nfc/device/power_stats
Change-Id: Ie0dc14880ba57722c2c43c8cf40783bcd3ff14b9
  • Loading branch information
krossmo committed Feb 4, 2022
1 parent 60e1254 commit 74ec016
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions powerstats/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,30 @@ int main(int /* argc */, char ** /* argv */) {
std::vector<std::string>{"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<std::pair<std::string, std::string>> nfcStateHeaders = {
std::make_pair("Idle", "Idle mode:"),
std::make_pair("Active", "Active mode:"),
std::make_pair("Active-RW", "Active Reader/Writer mode:"),
};

sp<GenericStateResidencyDataProvider> 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<AidlStateResidencyDataProvider>::make();
uint32_t citadelId = service->addPowerEntity("Citadel", PowerEntityType::SUBSYSTEM);
Expand Down

0 comments on commit 74ec016

Please sign in to comment.