dump_power: fix the problem of not being able to dump properties
Bug: 309011602 Test: adb bugreport and check dumpstate_board.txt Change-Id: I8a6251e03bcf16b2c1f4242a724f1949dab75759 Signed-off-by: Jack Wu <wjack@google.com>
This commit is contained in:
parent
73d96fb40f
commit
5f6d9cc357
1 changed files with 107 additions and 50 deletions
|
@ -52,9 +52,20 @@ int getCommandOutput(const char *cmd, std::string *output) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isValidFile(const char *file) {
|
bool isValidFile(const char *file) {
|
||||||
if (!access(file, R_OK)) {
|
FILE *fp = fopen(file, "r");
|
||||||
|
if (fp != NULL) {
|
||||||
|
fclose(fp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isValidDir(const char *directory) {
|
||||||
|
DIR *dir = opendir(directory);
|
||||||
|
if (dir == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
closedir(dir);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,8 +178,8 @@ void dumpMaxFg() {
|
||||||
const char *maxfg [][2] = {
|
const char *maxfg [][2] = {
|
||||||
{"Power supply property maxfg", "/sys/class/power_supply/maxfg/uevent"},
|
{"Power supply property maxfg", "/sys/class/power_supply/maxfg/uevent"},
|
||||||
{"m5_state", "/sys/class/power_supply/maxfg/m5_model_state"},
|
{"m5_state", "/sys/class/power_supply/maxfg/m5_model_state"},
|
||||||
{"maxfg", "/dev/logbuffer_maxfg"},
|
{"maxfg logbuffer", "/dev/logbuffer_maxfg"},
|
||||||
{"maxfg", "/dev/logbuffer_maxfg_monitor"},
|
{"maxfg_monitor logbuffer", "/dev/logbuffer_maxfg_monitor"},
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *maxfgFlip [][2] = {
|
const char *maxfgFlip [][2] = {
|
||||||
|
@ -187,7 +198,7 @@ void dumpMaxFg() {
|
||||||
std::string content;
|
std::string content;
|
||||||
|
|
||||||
|
|
||||||
if (isValidFile(maxfgLoc)) {
|
if (isValidDir(maxfgLoc)) {
|
||||||
for (const auto &row : maxfg) {
|
for (const auto &row : maxfg) {
|
||||||
dumpFileContent(row[0], row[1]);
|
dumpFileContent(row[0], row[1]);
|
||||||
}
|
}
|
||||||
|
@ -205,8 +216,10 @@ void dumpMaxFg() {
|
||||||
void dumpPowerSupplyDock() {
|
void dumpPowerSupplyDock() {
|
||||||
const char* powerSupplyPropertyDockTitle = "Power supply property dock";
|
const char* powerSupplyPropertyDockTitle = "Power supply property dock";
|
||||||
const char* powerSupplyPropertyDockFile = "/sys/class/power_supply/dock/uevent";
|
const char* powerSupplyPropertyDockFile = "/sys/class/power_supply/dock/uevent";
|
||||||
|
if (isValidFile(powerSupplyPropertyDockFile)) {
|
||||||
dumpFileContent(powerSupplyPropertyDockTitle, powerSupplyPropertyDockFile);
|
dumpFileContent(powerSupplyPropertyDockTitle, powerSupplyPropertyDockFile);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void dumpLogBufferTcpm() {
|
void dumpLogBufferTcpm() {
|
||||||
const char* logbufferTcpmTitle = "Logbuffer TCPM";
|
const char* logbufferTcpmTitle = "Logbuffer TCPM";
|
||||||
|
@ -286,15 +299,19 @@ void dumpWc68() {
|
||||||
const char* wc68Title = "WC68";
|
const char* wc68Title = "WC68";
|
||||||
const char* wc68File = "/dev/logbuffer_wc68";
|
const char* wc68File = "/dev/logbuffer_wc68";
|
||||||
|
|
||||||
|
if (isValidFile(wc68File)) {
|
||||||
dumpFileContent(wc68Title, wc68File);
|
dumpFileContent(wc68Title, wc68File);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void dumpLn8411() {
|
void dumpLn8411() {
|
||||||
const char* ln8411Title = "LN8411";
|
const char* ln8411Title = "LN8411";
|
||||||
const char* ln8411File = "/dev/logbuffer_ln8411";
|
const char* ln8411File = "/dev/logbuffer_ln8411";
|
||||||
|
|
||||||
|
if (isValidFile(ln8411File)) {
|
||||||
dumpFileContent(ln8411Title, ln8411File);
|
dumpFileContent(ln8411Title, ln8411File);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void dumpBatteryHealth() {
|
void dumpBatteryHealth() {
|
||||||
const char* batteryHealth [][2] {
|
const char* batteryHealth [][2] {
|
||||||
|
@ -359,44 +376,18 @@ void dumpBatteryDefend() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dumpChgUserDebug() {
|
void printValuesOfDirectory(const char *directory, std::string debugfs, const char *strMatch) {
|
||||||
std::vector<std::string> files;
|
std::vector<std::string> files;
|
||||||
struct dirent *entry;
|
auto info = directory;
|
||||||
std::string content;
|
std::string content;
|
||||||
|
struct dirent *entry;
|
||||||
const char *chgUserDebug [][2] {
|
|
||||||
{"DC_registers dump", "/sys/class/power_supply/dc-mains/device/registers_dump"},
|
|
||||||
{"max77759_chg registers dump", "/d/max77759_chg/registers"},
|
|
||||||
{"max77729_pmic registers dump", "/d/max77729_pmic/registers"},
|
|
||||||
{"Charging table dump", "/d/google_battery/chg_raw_profile"},
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::string debugfs = "/d/";
|
|
||||||
const char *maxFgStrMatch = "maxfg";
|
|
||||||
|
|
||||||
const char *fgInfo [][2] {
|
|
||||||
{"fg_model", "fg_model"},
|
|
||||||
{"fg_alo_ver", "algo_ver"},
|
|
||||||
{"fg_model_ok", "model_ok"},
|
|
||||||
{"fg registers", "registers"},
|
|
||||||
{"Maxim FG NV RAM", "nv_registers"},
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!isUserBuild())
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (auto &row : chgUserDebug) {
|
|
||||||
dumpFileContent(row[0], row[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto &info : fgInfo) {
|
|
||||||
DIR *dir = opendir(debugfs.c_str());
|
DIR *dir = opendir(debugfs.c_str());
|
||||||
if (dir == NULL)
|
if (dir == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
printTitle(info[0]);
|
printTitle((debugfs + std::string(strMatch) + "/" + std::string(info)).c_str());
|
||||||
while ((entry = readdir(dir)) != NULL)
|
while ((entry = readdir(dir)) != NULL)
|
||||||
if (std::string(entry->d_name).find(maxFgStrMatch) != std::string::npos)
|
if (std::string(entry->d_name).find(strMatch) != std::string::npos)
|
||||||
files.push_back(entry->d_name);
|
files.push_back(entry->d_name);
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
||||||
|
@ -404,7 +395,7 @@ void dumpChgUserDebug() {
|
||||||
|
|
||||||
for (auto &file : files) {
|
for (auto &file : files) {
|
||||||
std::string fileDirectory = debugfs + file;
|
std::string fileDirectory = debugfs + file;
|
||||||
std::string fileLocation = fileDirectory + "/" + std::string(info[1]);
|
std::string fileLocation = fileDirectory + "/" + std::string(info);
|
||||||
if (!android::base::ReadFileToString(fileLocation, &content)) {
|
if (!android::base::ReadFileToString(fileLocation, &content)) {
|
||||||
content = "\n";
|
content = "\n";
|
||||||
}
|
}
|
||||||
|
@ -416,6 +407,72 @@ void dumpChgUserDebug() {
|
||||||
}
|
}
|
||||||
files.clear();
|
files.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dumpChgUserDebug() {
|
||||||
|
const char *chgDebugMax77759 [][2] {
|
||||||
|
{"max77759_chg registers dump", "/d/max77759_chg/registers"},
|
||||||
|
{"max77729_pmic registers dump", "/d/max77729_pmic/registers"},
|
||||||
|
};
|
||||||
|
const char *chgDebugMax77779 [][2] {
|
||||||
|
{"max77779_chg registers dump", "/d/max77779_chg/registers"},
|
||||||
|
{"max77779_pmic registers dump", "/d/max77779_pmic/registers"},
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::string debugfs = "/d/";
|
||||||
|
|
||||||
|
const char *maxFgDir = "/d/maxfg";
|
||||||
|
const char *maxFgStrMatch = "maxfg";
|
||||||
|
const char *maxFg77779StrMatch = "max77779fg";
|
||||||
|
const char *baseChgDir = "/d/max77759_chg";
|
||||||
|
const char *dcRegName = "DC_registers dump";
|
||||||
|
const char *dcRegDir = "/sys/class/power_supply/dc-mains/device/registers_dump";
|
||||||
|
const char *chgTblName = "Charging table dump";
|
||||||
|
const char *chgTblDir = "/d/google_battery/chg_raw_profile";
|
||||||
|
|
||||||
|
const char *maxFgInfo [] {
|
||||||
|
"fg_model",
|
||||||
|
"algo_ver",
|
||||||
|
"model_ok",
|
||||||
|
"registers",
|
||||||
|
"nv_registers",
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *max77779FgInfo [] {
|
||||||
|
"fg_model",
|
||||||
|
"algo_ver",
|
||||||
|
"model_ok",
|
||||||
|
"registers",
|
||||||
|
"debug_registers",
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isUserBuild())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isValidFile(dcRegDir)) {
|
||||||
|
dumpFileContent(dcRegName, dcRegDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isValidDir(baseChgDir)) {
|
||||||
|
for (auto &row : chgDebugMax77759) {
|
||||||
|
dumpFileContent(row[0], row[1]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (auto &row : chgDebugMax77779) {
|
||||||
|
dumpFileContent(row[0], row[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dumpFileContent(chgTblName, chgTblDir);
|
||||||
|
|
||||||
|
if (isValidDir(maxFgDir)) {
|
||||||
|
for (auto & directory : maxFgInfo) {
|
||||||
|
printValuesOfDirectory(directory, debugfs, maxFgStrMatch);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (auto & directory : max77779FgInfo) {
|
||||||
|
printValuesOfDirectory(directory, debugfs, maxFg77779StrMatch);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dumpBatteryEeprom() {
|
void dumpBatteryEeprom() {
|
||||||
|
@ -454,7 +511,7 @@ void dumpChargerStats() {
|
||||||
|
|
||||||
dumpFileContent(chgStatsTitle, chgStatsLocation);
|
dumpFileContent(chgStatsTitle, chgStatsLocation);
|
||||||
|
|
||||||
if (!isUserBuild())
|
if (isUserBuild())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (auto &stat : chargerStats) {
|
for (auto &stat : chargerStats) {
|
||||||
|
@ -509,7 +566,7 @@ void dumpGvoteables() {
|
||||||
std::vector<std::string> files;
|
std::vector<std::string> files;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!isUserBuild())
|
if (isUserBuild())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ret = getFilesInDir(directory, &files);
|
ret = getFilesInDir(directory, &files);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue