powerstats: use display MRR state residency data provider

Bug: 317193845
Test: vts-tradefed run vts -m VtsHalPowerStatsTargetTest
Change-Id: If0b226c02eeee67f3dbc3bd0f7551ccb1f13bfee
Signed-off-by: Darren Hsu <darrenhsu@google.com>
This commit is contained in:
Darren Hsu 2023-12-20 20:49:37 +08:00
parent ca3359d2e4
commit ec47f620fe
2 changed files with 57 additions and 41 deletions

View file

@ -26,6 +26,7 @@
#include <android/binder_manager.h> #include <android/binder_manager.h>
#include <android/binder_process.h> #include <android/binder_process.h>
#include <log/log.h> #include <log/log.h>
#include <sys/stat.h>
using aidl::android::hardware::power::stats::DisplayStateResidencyDataProvider; using aidl::android::hardware::power::stats::DisplayStateResidencyDataProvider;
using aidl::android::hardware::power::stats::EnergyConsumerType; using aidl::android::hardware::power::stats::EnergyConsumerType;
@ -33,6 +34,9 @@ using aidl::android::hardware::power::stats::PowerStatsEnergyConsumer;
void addDisplay(std::shared_ptr<PowerStats> p) { void addDisplay(std::shared_ptr<PowerStats> p) {
// Add display residency stats // Add display residency stats
struct stat buffer;
if (stat("/sys/class/backlight/panel0-backlight/time_in_state", &buffer)) {
// time_in_state doesn't exist
std::vector<std::string> states = { std::vector<std::string> states = {
"Off", "Off",
"LP: 1008x2244@1", "LP: 1008x2244@1",
@ -64,6 +68,10 @@ void addDisplay(std::shared_ptr<PowerStats> p) {
"Display", "Display",
"/sys/class/backlight/panel0-backlight/state", "/sys/class/backlight/panel0-backlight/state",
states)); states));
} else {
// time_in_state exists
addDisplayMRR(p);
}
// Add display energy consumer // Add display energy consumer
p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterConsumer( p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterConsumer(

View file

@ -26,6 +26,7 @@
#include <android/binder_manager.h> #include <android/binder_manager.h>
#include <android/binder_process.h> #include <android/binder_process.h>
#include <log/log.h> #include <log/log.h>
#include <sys/stat.h>
using aidl::android::hardware::power::stats::DisplayStateResidencyDataProvider; using aidl::android::hardware::power::stats::DisplayStateResidencyDataProvider;
using aidl::android::hardware::power::stats::EnergyConsumerType; using aidl::android::hardware::power::stats::EnergyConsumerType;
@ -33,6 +34,9 @@ using aidl::android::hardware::power::stats::PowerStatsEnergyConsumer;
void addDisplay(std::shared_ptr<PowerStats> p) { void addDisplay(std::shared_ptr<PowerStats> p) {
// Add display residency stats // Add display residency stats
struct stat buffer;
if (stat("/sys/class/backlight/panel0-backlight/time_in_state", &buffer)) {
// time_in_state doesn't exist
std::vector<std::string> states = { std::vector<std::string> states = {
"Off", "Off",
"LP: 1080x2400@30", "LP: 1080x2400@30",
@ -45,6 +49,10 @@ void addDisplay(std::shared_ptr<PowerStats> p) {
"Display", "Display",
"/sys/class/backlight/panel0-backlight/state", "/sys/class/backlight/panel0-backlight/state",
states)); states));
} else {
// time_in_state exists
addDisplayMRR(p);
}
// Add display energy consumer // Add display energy consumer
p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterConsumer( p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterConsumer(