summaryrefslogtreecommitdiff
path: root/dumpstate
diff options
context:
space:
mode:
authorAdam Shih <adamshih@google.com>2022-11-02 13:00:36 +0800
committerAdam Shih <adamshih@google.com>2022-11-02 06:52:00 +0000
commitd59bc448e2a712cbc0688d519b31c2ee387d7b22 (patch)
treecc7fef19891ae4e098b2b5569877304a1592aa6b /dumpstate
parent4313df1cc55d3c0eac4200f8256287d370d7d93b (diff)
downloadgs201-d59bc448e2a712cbc0688d519b31c2ee387d7b22.tar.gz
align user experience on Android bug tool
Bug: 255250616 Test: adb shell dumpsys android.hardware.dumpstate.IDumpstateDevice/default wlan Change-Id: Ibefd8f9fff91cf6ece1f09dd6b207b6f9c97df4d
Diffstat (limited to 'dumpstate')
-rw-r--r--dumpstate/Dumpstate.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/dumpstate/Dumpstate.cpp b/dumpstate/Dumpstate.cpp
index adf51b4..af913fd 100644
--- a/dumpstate/Dumpstate.cpp
+++ b/dumpstate/Dumpstate.cpp
@@ -246,6 +246,7 @@ Dumpstate::Dumpstate()
// if the specified section is not supported.
void Dumpstate::dumpTextSection(int fd, const std::string &sectionName) {
bool dumpAll = (sectionName == kAllSections);
+ std::string dumpFiles;
for (const auto &section : mTextSections) {
if (dumpAll || sectionName == section.first) {
@@ -259,22 +260,29 @@ void Dumpstate::dumpTextSection(int fd, const std::string &sectionName) {
}
}
- // Execute all programs under vendor/bin/dump/
+ // Execute all or designated programs under vendor/bin/dump/
std::unique_ptr<DIR, decltype(&closedir)> dir(opendir("/vendor/bin/dump"), closedir);
if (!dir) {
- ALOGE("Fail To Open Dir vendor/bin/dump/");
- } else {
- dirent *entry;
- while ((entry = readdir(dir.get())) != nullptr) {
+ ALOGE("Fail To Open Dir vendor/bin/dump/");
+ ::android::base::WriteStringToFd("Fail To Open Dir vendor/bin/dump/\n", fd);
+ return;
+ }
+ dirent *entry;
+ while ((entry = readdir(dir.get())) != nullptr) {
// Skip '.', '..'
if (entry->d_name[0] == '.') {
- continue;
+ continue;
}
std::string bin(entry->d_name);
- auto startTime = startSection(fd, "/vendor/bin/dump/"+bin);
- RunCommandToFd(fd, "/vendor/bin/dump/"+bin, {"/vendor/bin/dump/"+bin});
- endSection(fd, "/vendor/bin/dump/"+bin, startTime);
- }
+ dumpFiles = dumpFiles + " " + bin;
+ if (dumpAll || sectionName == bin) {
+ auto startTime = startSection(fd, bin);
+ RunCommandToFd(fd, "/vendor/bin/dump/"+bin, {"/vendor/bin/dump/"+bin});
+ endSection(fd, bin, startTime);
+ if (!dumpAll) {
+ return;
+ }
+ }
}
if (dumpAll) {
@@ -287,6 +295,7 @@ void Dumpstate::dumpTextSection(int fd, const std::string &sectionName) {
for (const auto &section : mTextSections) {
::android::base::WriteStringToFd(" " + section.first, fd);
}
+ ::android::base::WriteStringToFd(dumpFiles, fd);
::android::base::WriteStringToFd("\nNote: sections with attachments (e.g. modem) are"
"not avalable from the command line.\n", fd);
}