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:3b8bae4b85355038c2f5418db37f684fb135bd89)
Merged-In: Ice4985d13554dde3b65ba0c34bbac4085445699e
Change-Id: Ice4985d13554dde3b65ba0c34bbac4085445699e
diff --git a/dumpstate/dump_power.cpp b/dumpstate/dump_power.cpp
index e8e4a38..b522cf7 100644
--- a/dumpstate/dump_power.cpp
+++ b/dumpstate/dump_power.cpp
@@ -276,6 +276,48 @@
files.clear();
}
}
+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;
@@ -732,6 +774,7 @@
dumpPdEngine();
dumpBatteryHealth();
dumpBatteryDefend();
+ dumpBatteryCaretaker();
dumpChg();
dumpChgUserDebug();
dumpBatteryEeprom();