dump_gps: Support thinmd logs collect

Flag: EXEMPT logs collection.
Bug: 386286230
Test: b/386286230#comment3 bugreport example.
Change-Id: I93d385cd1a03aa55f63520626072d1bf7ccedb86
This commit is contained in:
Cheng Chang 2025-01-03 04:54:53 +00:00
parent 6e56542845
commit fe1d00ff58

View file

@ -39,8 +39,9 @@ static void copyDirectory(const std::string &source,
if (dir == nullptr) { if (dir == nullptr) {
return; return;
} }
struct stat st;
if (mkdir(outputDir.c_str(), 0777) == -1) { if (!(stat(outputDir.c_str(), &st) == 0 && S_ISDIR(st.st_mode)) &&
mkdir(outputDir.c_str(), 0777) == -1) {
closedir(dir); closedir(dir);
return; return;
} }
@ -54,8 +55,6 @@ static void copyDirectory(const std::string &source,
std::string sourcePath = source + "/" + entryName; std::string sourcePath = source + "/" + entryName;
std::string destPath = outputDir + "/" + entryName; std::string destPath = outputDir + "/" + entryName;
struct stat st;
if (stat(sourcePath.c_str(), &st) == 0) { if (stat(sourcePath.c_str(), &st) == 0) {
if (S_ISDIR(st.st_mode)) if (S_ISDIR(st.st_mode))
copyDirectory(sourcePath, destPath); copyDirectory(sourcePath, destPath);
@ -127,19 +126,32 @@ int main() {
int maxFileNum = ::android::base::GetIntProperty(GPS_LOG_NUMBER_PROPERTY, 20); int maxFileNum = ::android::base::GetIntProperty(GPS_LOG_NUMBER_PROPERTY, 20);
std::string outputDir = concatenatePath(BUGREPORT_PACKING_DIR, "gps"); std::string outputDir = concatenatePath(BUGREPORT_PACKING_DIR, "gps");
if (mkdir(outputDir.c_str(), 0777) == -1) { if (mkdir(outputDir.c_str(), 0777) == -1) {
printf("Unable to create folder: %s\n", outputDir.c_str()); printf("Unable to create folder: %s\n", outputDir.c_str());
return 0; return 0;
}
if (!::android::base::GetBoolProperty("vendor.gps.aol.collect.thinmd",
false)) {
printf("vendor.gps.aol.collect.thinmd is false. Collecting fils as "
"legacy Pixel.\n");
dumpLogs(GPS_TMP_LOG_DIRECTORY, outputDir.c_str(), 1, GPS_LOG_PREFIX);
dumpLogs(GPS_LOG_DIRECTORY, outputDir.c_str(), 3, GPS_MCU_LOG_PREFIX);
dumpLogs(GPS_LOG_DIRECTORY, outputDir.c_str(), maxFileNum,
GPS_LOG_PREFIX);
dumpLogs(GPS_MALLOC_LOG_DIRECTORY, outputDir.c_str(), 1,
GPS_MALLOC_LOG_PREFIX);
dumpLogsAscending(GPS_LOG_DIRECTORY, outputDir.c_str(), 5,
GPS_RAWLOG_PREFIX);
dumpLogs(GPS_LOG_DIRECTORY, outputDir.c_str(), 18,
GPS_MEMDUMP_LOG_PREFIX);
} else {
printf("vendor.gps.aol.collect.thinmd is true. Collecting fils as thin "
"modem.\n");
copyDirectory(GPS_LOG_DIRECTORY, outputDir.c_str());
} }
dumpLogs(GPS_TMP_LOG_DIRECTORY, outputDir.c_str(), 1, GPS_LOG_PREFIX);
dumpLogs(GPS_LOG_DIRECTORY, outputDir.c_str(), 3, GPS_MCU_LOG_PREFIX);
dumpLogs(GPS_LOG_DIRECTORY, outputDir.c_str(), maxFileNum, GPS_LOG_PREFIX);
dumpLogs(GPS_MALLOC_LOG_DIRECTORY, outputDir.c_str(), 1, GPS_MALLOC_LOG_PREFIX);
if (access(GPS_VENDOR_CHIP_INFO, F_OK) == 0) { if (access(GPS_VENDOR_CHIP_INFO, F_OK) == 0) {
copyFile(GPS_VENDOR_CHIP_INFO, concatenatePath(outputDir.c_str(), "chip.info").c_str()); copyFile(GPS_VENDOR_CHIP_INFO,
concatenatePath(outputDir.c_str(), "chip.info").c_str());
} }
dumpLogsAscending(GPS_LOG_DIRECTORY, outputDir.c_str(), 5, GPS_RAWLOG_PREFIX);
dumpLogs(GPS_LOG_DIRECTORY, outputDir.c_str(), 18, GPS_MEMDUMP_LOG_PREFIX);
copyDirectory(GPS_RESOURCE_DIRECTORY, concatenatePath(outputDir.c_str(), "resource")); copyDirectory(GPS_RESOURCE_DIRECTORY, concatenatePath(outputDir.c_str(), "resource"));
return 0; return 0;
} }