dump_power: add battery caretaker dump into bugreport

logging for AACR(+H), AAFV, AACT, AACC and AACP Version

Bug: 384737509
Test: adb bugreport
Flag: EXEMPT bugfix
Signed-off-by: Jack Wu <wjack@google.com>
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:0c88c7620ae837df1078e29e48b467e7d1274072)
Merged-In: I9d36e6fcb25ee9f12b4fd2962207b1f4b592c2b3
Change-Id: I9d36e6fcb25ee9f12b4fd2962207b1f4b592c2b3
This commit is contained in:
Jack Wu 2024-12-20 17:43:54 +08:00 committed by Android Build Coastguard Worker
parent 8f500f49e4
commit 413efc2497

View file

@ -329,7 +329,7 @@ void dumpBatteryHealth() {
}
void dumpBatteryDefend() {
const char* defendConfig [][4] {
const char* defendConfig [][3] {
{"TRICKLE-DEFEND Config",
"/sys/devices/platform/google,battery/power_supply/battery/", "bd_"},
{"DWELL-DEFEND Config", "/sys/devices/platform/google,charger/", "charge_s"},
@ -374,6 +374,57 @@ void dumpBatteryDefend() {
}
}
void dumpBatteryCaretaker() {
const char* aacpConfig [][3] {
{"AACP Version",
"/sys/devices/platform/google,battery/power_supply/battery/", "aacp_"},
{"AACR Config",
"/sys/devices/platform/google,battery/power_supply/battery/", "aacr_"},
{"AAFV Config",
"/sys/devices/platform/google,battery/power_supply/battery/", "aafv_"},
{"AACT Config",
"/sys/devices/platform/google,battery/power_supply/battery/", "aact_"},
{"AACC",
"/sys/devices/platform/google,battery/power_supply/battery/", "aacc"},
};
std::vector<std::string> files;
struct dirent *entry;
std::string content;
std::string fileLocation;
for (auto &config : aacpConfig) {
DIR *dir = opendir(config[1]);
if (dir == NULL)
continue;
printTitle(config[0]);
while ((entry = readdir(dir)) != NULL) {
if (std::string(entry->d_name).find(config[2]) != std::string::npos &&
strncmp(config[2], entry->d_name, strlen(config[2])) == 0) {
files.push_back(entry->d_name);
}
}
closedir(dir);
sort(files.begin(), files.end());
for (auto &file : files) {
fileLocation = std::string(config[1]) + std::string(file);
if (!android::base::ReadFileToString(fileLocation, &content) || content.empty()) {
content = "\n";
}
printf("%s: %s", file.c_str(), content.c_str());
if (content.back() != '\n')
printf("\n");
}
files.clear();
}
}
void printValuesOfDirectory(const char *directory, std::string debugfs, const char *strMatch) {
std::vector<std::string> files;
auto info = directory;
@ -935,6 +986,7 @@ int main() {
dumpWc68();
dumpBatteryHealth();
dumpBatteryDefend();
dumpBatteryCaretaker();
dumpChg();
dumpChgUserDebug();
dumpBatteryEeprom();