powerstats: Add config support for AdaptiveDvfs data provider
Bug: 273415531 Test: dumpsys android.hardware.power.stats.IPowerStats/default Change-Id: I48bd1ec622680a3c93d15b571fbf21579f0e21ed Signed-off-by: Darren Hsu <darrenhsu@google.com>
This commit is contained in:
parent
75a5c5dceb
commit
529b618a7c
@ -25,6 +25,9 @@
|
||||
using android::base::Split;
|
||||
using android::base::Trim;
|
||||
|
||||
static const std::string pathSuffix = "/time_in_state";
|
||||
static const std::string stateSuffix = "MHz";
|
||||
|
||||
namespace aidl {
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
@ -34,33 +37,35 @@ namespace stats {
|
||||
AdaptiveDvfsStateResidencyDataProvider::AdaptiveDvfsStateResidencyDataProvider(
|
||||
std::string path,
|
||||
uint64_t clockRate,
|
||||
std::string powerEntityName,
|
||||
std::string freqPath)
|
||||
std::vector<std::pair<std::string, std::string>> powerEntities)
|
||||
: DvfsStateResidencyDataProvider(path, clockRate, {}) {
|
||||
size_t len = 0;
|
||||
char *line = nullptr;
|
||||
std::vector<std::pair<std::string, std::string>> states = {};
|
||||
std::vector<std::string> parts;
|
||||
|
||||
for (int32_t i = 0; i < powerEntities.size(); i++) {
|
||||
std::string freqPath = powerEntities[i].second + pathSuffix;
|
||||
std::unique_ptr<FILE, decltype(&fclose)> fp(fopen(freqPath.c_str(), "r"), fclose);
|
||||
if (!fp) {
|
||||
PLOG(ERROR) << __func__ << ":Failed to open file " << freqPath;
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
size_t len = 0;
|
||||
char *line = nullptr;
|
||||
std::string suffix = "MHz";
|
||||
std::vector<std::pair<std::string, std::string>> states = {};
|
||||
std::vector<std::string> parts;
|
||||
std::string freqStr;
|
||||
|
||||
while (getline(&line, &len, fp.get()) != -1) {
|
||||
parts = Split(line, " ");
|
||||
parts = Split(Trim(std::string(line)), " ");
|
||||
if (parts.size() > 0) {
|
||||
freqStr = Trim(parts[0]);
|
||||
std::string freqStr = Trim(parts[0]);
|
||||
states.push_back(std::make_pair(
|
||||
freqStr.substr(0, freqStr.length() - 3) + suffix,
|
||||
freqStr.substr(0, freqStr.length() - 3) + stateSuffix,
|
||||
freqStr));
|
||||
}
|
||||
}
|
||||
|
||||
mPowerEntities.push_back({powerEntityName, std::move(states)});
|
||||
mPowerEntities.push_back({powerEntities[i].first, std::move(states)});
|
||||
}
|
||||
|
||||
free(line);
|
||||
}
|
||||
|
||||
bool AdaptiveDvfsStateResidencyDataProvider::getStateResidencies(
|
||||
|
@ -103,6 +103,10 @@ bool DvfsStateResidencyDataProvider::getStateResidencies(
|
||||
it = residencies->find(mPowerEntities[powerEntityIndex].powerEntityName + nameSuffix);
|
||||
}
|
||||
|
||||
// The given string is last state for each entity.
|
||||
if (StartsWith(Trim(std::string(line)), "last_freq_change_time_ns:"))
|
||||
it = residencies->end();
|
||||
|
||||
if (it != residencies->end()) {
|
||||
stateId = matchState(line, mPowerEntities[powerEntityIndex]);
|
||||
|
||||
|
@ -28,14 +28,12 @@ class AdaptiveDvfsStateResidencyDataProvider : public DvfsStateResidencyDataProv
|
||||
/*
|
||||
* path - path to dvfs sysfs node.
|
||||
* clockRate - clock rate in KHz.
|
||||
* powerEntityName - power entity name to parse.
|
||||
* freqPath - path to frequency table.
|
||||
* powerEntities - list of power entity pairs (name to power entity, path to frequency table)
|
||||
*/
|
||||
AdaptiveDvfsStateResidencyDataProvider(
|
||||
std::string path,
|
||||
uint64_t clockRate,
|
||||
std::string powerEntityName,
|
||||
std::string freqPath);
|
||||
std::vector<std::pair<std::string, std::string>> powerEntities);
|
||||
~AdaptiveDvfsStateResidencyDataProvider() = default;
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user