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
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user