allow dumpstate to execute files under vendor/bin/dump

Bug: 240530709
Test: adb bugreport has the same result
Change-Id: I76a82ef6402d6bfb53d21d63c354d934ffb06c57
This commit is contained in:
Adam Shih 2022-09-15 14:09:36 +08:00 committed by TreeHugger Robot
parent 4abe8cc283
commit 02c91097f8
3 changed files with 19 additions and 8 deletions

View file

@ -238,7 +238,6 @@ Dumpstate::Dumpstate()
{ "aoc", [this](int fd) { dumpAoCSection(fd); } }, { "aoc", [this](int fd) { dumpAoCSection(fd); } },
{ "ramdump", [this](int fd) { dumpRamdumpSection(fd); } }, { "ramdump", [this](int fd) { dumpRamdumpSection(fd); } },
{ "misc", [this](int fd) { dumpMiscSection(fd); } }, { "misc", [this](int fd) { dumpMiscSection(fd); } },
{ "dump", [this](int fd) { dumpSection(fd); } },
{ "trusty", [this](int fd) { dumpTrustySection(fd); } }, { "trusty", [this](int fd) { dumpTrustySection(fd); } },
{ "led", [this](int fd) { dumpLEDSection(fd); } }, { "led", [this](int fd) { dumpLEDSection(fd); } },
}, },
@ -268,6 +267,24 @@ void Dumpstate::dumpTextSection(int fd, const std::string &sectionName) {
} }
} }
// Execute all 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) {
// Skip '.', '..'
if (entry->d_name[0] == '.') {
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);
}
}
if (dumpAll) { if (dumpAll) {
return; return;
} }
@ -1126,11 +1143,6 @@ void Dumpstate::dumpMiscSection(int fd) {
DumpFileToFd(fd, "VENDOR PROC DUMP", "/proc/vendor_sched/dump_task"); DumpFileToFd(fd, "VENDOR PROC DUMP", "/proc/vendor_sched/dump_task");
} }
// Dump scripts under vendor/bin/dump
void Dumpstate::dumpSection(int fd) {
RunCommandToFd(fd, "dump", {"/vendor/bin/dump/dump_gsc.sh"});
}
void Dumpstate::dumpTrustySection(int fd) { void Dumpstate::dumpTrustySection(int fd) {
RunCommandToFd(fd, "Trusty TEE0 Logs", {"/vendor/bin/sh", "-c", "cat /dev/trusty-log0"}, CommandOptions::WithTimeout(1).Build()); RunCommandToFd(fd, "Trusty TEE0 Logs", {"/vendor/bin/sh", "-c", "cat /dev/trusty-log0"}, CommandOptions::WithTimeout(1).Build());
} }

View file

@ -67,7 +67,6 @@ class Dumpstate : public BnDumpstateDevice {
void dumpAoCSection(int fd); void dumpAoCSection(int fd);
void dumpRamdumpSection(int fd); void dumpRamdumpSection(int fd);
void dumpMiscSection(int fd); void dumpMiscSection(int fd);
void dumpSection(int fd);
void dumpTrustySection(int fd); void dumpTrustySection(int fd);
void dumpLEDSection(int fd); void dumpLEDSection(int fd);

View file

@ -1,5 +1,5 @@
service vendor.dumpstate-default /vendor/bin/hw/android.hardware.dumpstate-service.gs201 service vendor.dumpstate-default /vendor/bin/hw/android.hardware.dumpstate-service.gs201
class hal class hal
user system user system
group system group system shell
interface aidl android.hardware.dumpstate.IDumpstateDevice/default interface aidl android.hardware.dumpstate.IDumpstateDevice/default