powerstats: use display MRR state residency data provider

Bug: 322457937
Test: vts-tradefed run vts -m VtsHalPowerStatsTargetTest
Change-Id: I65f2f1d8818295ac76525c1ebf4bbdd36ce0b5ff
Signed-off-by: Darren Hsu <darrenhsu@google.com>
This commit is contained in:
Darren Hsu 2024-01-26 17:41:23 +08:00
parent cb44b9b0b1
commit 83e6cc5af1

View file

@ -28,6 +28,7 @@
#include <android/binder_manager.h>
#include <android/binder_process.h>
#include <log/log.h>
#include <sys/stat.h>
using aidl::android::hardware::power::stats::DevfreqStateResidencyDataProvider;
using aidl::android::hardware::power::stats::DisplayStateResidencyDataProvider;
@ -37,14 +38,21 @@ using aidl::android::hardware::power::stats::PowerStatsEnergyConsumer;
void addDisplay(std::shared_ptr<PowerStats> p) {
// Add display residency stats
std::vector<std::string> states = {
"Off",
"On: 1600x2560@60",
"HBM: 1600x2560@60"};
struct stat buffer;
if (!stat("/sys/class/drm/card0/device/primary-panel/time_in_state", &buffer)) {
// time_in_state exists
addDisplayMrr(p);
} else {
// time_in_state doesn't exist
std::vector<std::string> states = {
"Off",
"On: 1600x2560@60",
"HBM: 1600x2560@60"};
p->addStateResidencyDataProvider(std::make_unique<DisplayStateResidencyDataProvider>("Display",
"/sys/class/backlight/panel0-backlight/state",
states));
p->addStateResidencyDataProvider(std::make_unique<DisplayStateResidencyDataProvider>("Display",
"/sys/class/backlight/panel0-backlight/state",
states));
}
// Add display energy consumer
p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterConsumer(