powerstats: Add GPS state residency
Bug: 181577366 Test: dumpsys android.hardware.power.stats.IPowerStats/default Change-Id: I0fa4356542a838618e712e9b0abbf02b99db7f3a
This commit is contained in:
parent
5b50e7384a
commit
3cc937165b
2 changed files with 33 additions and 0 deletions
|
@ -169,6 +169,9 @@ on init
|
|||
# Charge stats (write 0)
|
||||
chown system system /sys/class/power_supply/battery/charge_stats
|
||||
|
||||
# Power Stats HAL
|
||||
chown system system /dev/bbd_pwrstat
|
||||
|
||||
# start watchdogd
|
||||
start watchdogd
|
||||
|
||||
|
|
|
@ -494,6 +494,36 @@ void addMobileRadio(std::shared_ptr<PowerStats> p)
|
|||
|
||||
void addGNSS(std::shared_ptr<PowerStats> p)
|
||||
{
|
||||
// A constant to represent the number of microseconds in one millisecond.
|
||||
const int US_TO_MS = 1000;
|
||||
|
||||
// gnss power_stats are reported in microseconds. The transform function
|
||||
// converts microseconds to milliseconds.
|
||||
std::function<uint64_t(uint64_t)> gnssUsToMs = [](uint64_t a) { return a / US_TO_MS; };
|
||||
|
||||
const GenericStateResidencyDataProvider::StateResidencyConfig gnssStateConfig = {
|
||||
.entryCountSupported = true,
|
||||
.entryCountPrefix = "count:",
|
||||
.totalTimeSupported = true,
|
||||
.totalTimePrefix = "duration_usec:",
|
||||
.totalTimeTransform = gnssUsToMs,
|
||||
.lastEntrySupported = true,
|
||||
.lastEntryPrefix = "last_entry_timestamp_usec:",
|
||||
.lastEntryTransform = gnssUsToMs,
|
||||
};
|
||||
|
||||
const std::vector<std::pair<std::string, std::string>> gnssStateHeaders = {
|
||||
std::make_pair("ON", "GPS_ON:"),
|
||||
std::make_pair("OFF", "GPS_OFF:"),
|
||||
};
|
||||
|
||||
std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> cfgs;
|
||||
cfgs.emplace_back(generateGenericStateResidencyConfigs(gnssStateConfig, gnssStateHeaders),
|
||||
"GPS", "");
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<GenericStateResidencyDataProvider>(
|
||||
"/dev/bbd_pwrstat", cfgs));
|
||||
|
||||
p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterConsumer(p,
|
||||
EnergyConsumerType::GNSS, "GPS", {"L9S_GNSS_CORE"}));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue