Snap for 11059422 from fc4015ffd836e4e3302fd620182fba1d501de466 to 24Q1-release
Change-Id: I0da4f19066ced8ee221b993d3506172147f3d19f
This commit is contained in:
commit
2e7113927a
@ -18,15 +18,18 @@
|
||||
|
||||
#include <android/binder_process.h>
|
||||
#include <battery_mitigation/BatteryMitigation.h>
|
||||
#include <battery_mitigation/BatteryMitigationService.h>
|
||||
#include <sys/resource.h>
|
||||
#include <system/thread_defs.h>
|
||||
|
||||
#define COUNT_LIMIT 10
|
||||
|
||||
using android::hardware::google::pixel::BatteryMitigation;
|
||||
using android::hardware::google::pixel::BatteryMitigationService;
|
||||
using android::hardware::google::pixel::MitigationConfig;
|
||||
|
||||
android::sp<BatteryMitigation> bmSp;
|
||||
android::sp<BatteryMitigationService> batteryMitigationService;
|
||||
|
||||
const struct MitigationConfig::Config cfg = {
|
||||
.SystemPath = {
|
||||
@ -86,10 +89,52 @@ const struct MitigationConfig::EventThreadConfig eventThreadCfg = {
|
||||
.TriggeredIdxPath = "/sys/devices/virtual/pmic/mitigation/br_stats/triggered_idx",
|
||||
.BrownoutStatsPath = "/sys/devices/virtual/pmic/mitigation/br_stats/stats",
|
||||
.StoringPath = "/data/vendor/mitigation/thismeal.bin",
|
||||
.BackupPath = "/data/vendor/mitigation/lastmeal.bin",
|
||||
.ParsedThismealPath = "/data/vendor/mitigation/thismeal.txt",
|
||||
.ParsedLastmealPath = "/data/vendor/mitigation/lastmeal.txt",
|
||||
.FvpStatsPath = "/sys/devices/platform/acpm_stats/fvp_stats",
|
||||
.PmicCommon = {
|
||||
/* Main Pmic */
|
||||
{
|
||||
.OdpmDir = "/sys/bus/iio/devices/iio:device0",
|
||||
.OdpmEnabledRailsPath = "/sys/bus/iio/devices/iio:device0/enabled_rails",
|
||||
.PmicNamePath = "/sys/bus/iio/devices/iio:device0/name",
|
||||
},
|
||||
/* Sub Pmic */
|
||||
{
|
||||
.OdpmDir = "/sys/bus/iio/devices/iio:device1",
|
||||
.OdpmEnabledRailsPath = "/sys/bus/iio/devices/iio:device1/enabled_rails",
|
||||
.PmicNamePath = "/sys/bus/iio/devices/iio:device1/name",
|
||||
},
|
||||
},
|
||||
.PlatformSpecific = {
|
||||
/* MIN_SUPPORTED_PLATFORM */
|
||||
{
|
||||
.MainPmicName = "s2mpg10-odpm\n",
|
||||
.SubPmicName = "s2mpg11-odpm\n",
|
||||
.PcieModemPath = "/sys/devices/platform/11920000.pcie/power_stats",
|
||||
.PcieWifiPath = "/sys/devices/platform/14520000.pcie/power_stats",
|
||||
},
|
||||
{
|
||||
.MainPmicName = "s2mpg12-odpm\n",
|
||||
.SubPmicName = "s2mpg13-odpm\n",
|
||||
.PcieModemPath = "/sys/devices/platform/11920000.pcie/power_stats",
|
||||
.PcieWifiPath = "/sys/devices/platform/14520000.pcie/power_stats",
|
||||
},
|
||||
{
|
||||
.MainPmicName = "s2mpg14-odpm\n",
|
||||
.SubPmicName = "s2mpg15-odpm\n",
|
||||
.PcieModemPath = "/sys/devices/platform/12100000.pcie/power_stats",
|
||||
.PcieWifiPath = "/sys/devices/platform/13120000.pcie/power_stats",
|
||||
},
|
||||
/* MAX_SUPPORTED_PLATFORM */
|
||||
{
|
||||
.MainPmicName = "s2mpg14-odpm\n",
|
||||
.SubPmicName = "s2mpg15-odpm\n",
|
||||
.PcieModemPath = "/sys/devices/platform/12100000.pcie/power_stats",
|
||||
.PcieWifiPath = "/sys/devices/platform/13120000.pcie/power_stats",
|
||||
},
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
const char kReadyFilePath[] = "/sys/devices/virtual/pmic/mitigation/instruction/ready";
|
||||
@ -106,31 +151,60 @@ std::string GetSystemProperty(std::string property) {
|
||||
return std::string(value);
|
||||
}
|
||||
|
||||
int main(int /*argc*/, char ** /*argv*/) {
|
||||
int main(int argc, char **argv) {
|
||||
std::string cdt = GetSystemProperty(kCDTProperty);
|
||||
int platformNum = atoi(cdt.substr(5, 1).c_str());
|
||||
batteryMitigationService = new BatteryMitigationService(eventThreadCfg,
|
||||
platformNum);
|
||||
if (!batteryMitigationService) {
|
||||
return 0;
|
||||
}
|
||||
bool platformSupported = batteryMitigationService->isPlatformSupported();
|
||||
bool brownoutStatsBinarySupported = batteryMitigationService->isBrownoutStatsBinarySupported();
|
||||
if (argc == 2) {
|
||||
if(strcmp(argv[1], "-d") == 0 &&
|
||||
brownoutStatsBinarySupported &&
|
||||
platformSupported) {
|
||||
/* Create thismeal.txt from thismeal.bin */
|
||||
batteryMitigationService->genParsedMeal(eventThreadCfg.ParsedThismealPath);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_AUDIO);
|
||||
auto batteryMitigationStartTime = std::chrono::system_clock::now();
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(1);
|
||||
ABinderProcess_startThreadPool();
|
||||
bmSp = new BatteryMitigation(cfg, eventThreadCfg);
|
||||
|
||||
bool mitigationLogTimeValid;
|
||||
std::string reason = android::base::GetProperty(kBRRequestedProperty, "");
|
||||
if (brownoutStatsBinarySupported) {
|
||||
/* Create lastmeal.txt if the dump time in thismeal.bin are valid */
|
||||
mitigationLogTimeValid = batteryMitigationService->isTimeValid(eventThreadCfg.StoringPath,
|
||||
batteryMitigationStartTime);
|
||||
if (!reason.empty() && mitigationLogTimeValid &&
|
||||
batteryMitigationService->genParsedMeal(eventThreadCfg.ParsedLastmealPath)) {
|
||||
android::base::SetProperty(kLastMealProperty, "1");
|
||||
}
|
||||
/* Start BrownoutEventThread to poll brownout event from kernel */
|
||||
batteryMitigationService->startBrownoutEventThread();
|
||||
} else{
|
||||
bmSp = new BatteryMitigation(cfg);
|
||||
if (!bmSp) {
|
||||
return 0;
|
||||
}
|
||||
std::string cdt = GetSystemProperty(kCDTProperty);
|
||||
int platform_num = atoi(cdt.substr(5, 1).c_str());
|
||||
if (platform_num >= MIN_SUPPORTED_PLATFORM) {
|
||||
bmSp->startBrownoutEventThread();
|
||||
}
|
||||
bool mitigationLogTimeValid = bmSp->isMitigationLogTimeValid(batteryMitigationStartTime,
|
||||
mitigationLogTimeValid = bmSp->isMitigationLogTimeValid(batteryMitigationStartTime,
|
||||
cfg.LogFilePath,
|
||||
cfg.TimestampFormat,
|
||||
kTimestampRegex);
|
||||
std::string reason = android::base::GetProperty(kBRRequestedProperty, "");
|
||||
if (!reason.empty() && mitigationLogTimeValid) {
|
||||
std::ifstream src(cfg.LogFilePath, std::ios::in);
|
||||
std::ofstream dst(kLastMealPath, std::ios::out);
|
||||
dst << src.rdbuf();
|
||||
android::base::SetProperty(kLastMealProperty, "1");
|
||||
}
|
||||
}
|
||||
|
||||
bool isBatteryMitigationReady = false;
|
||||
std::string ready_str;
|
||||
int val = 0;
|
||||
|
1
diagnosticstool/diagnosticstool.mk
Normal file
1
diagnosticstool/diagnosticstool.mk
Normal file
@ -0,0 +1 @@
|
||||
PRODUCT_PRIVATE_SEPOLICY_DIRS += device/google/gs-common/diagnosticstool/sepolicy
|
4
diagnosticstool/sepolicy/diagnosticstool_app.te
Normal file
4
diagnosticstool/sepolicy/diagnosticstool_app.te
Normal file
@ -0,0 +1,4 @@
|
||||
type diagnosticstool_app, domain;
|
||||
app_domain(diagnosticstool_app)
|
||||
|
||||
allow diagnosticstool_app app_api_service:service_manager find;
|
2
diagnosticstool/sepolicy/seapp_contexts
Normal file
2
diagnosticstool/sepolicy/seapp_contexts
Normal file
@ -0,0 +1,2 @@
|
||||
# Diagnostics Tool
|
||||
user=_app seinfo=platform name=com.google.android.apps.diagnosticstool domain=diagnosticstool_app isPrivApp=true levelFrom=user
|
Loading…
x
Reference in New Issue
Block a user