Update dump() for Aidl HALs.

Merged from http://go/wvgerrit/146589

lshal is for hidl HALs only, dumpsys is for aidl HALs.
Add option "-a" to dump both CDM metrics and properties
because adb bugreport calls dump() with option "-a".

Test: adb bugreport

Bug: 220996660
Change-Id: Ib2a73f3f9f353b8435735dd019a547b62b066725
This commit is contained in:
Edwin
2022-02-23 17:45:44 -08:00
parent 3fa23b250b
commit b5284c5376
2 changed files with 24 additions and 13 deletions

View File

@@ -56,6 +56,7 @@ struct WVDrmFactory : public ::aidl::android::hardware::drm::BnDrmFactory {
static std::string stringToHex(const std::string& input);
static void printCdmMetrics(int fd);
static void printCdmProperties(int fd);
static void printUsage(int fd);
friend class WVDrmFactoryTestPeer;
};

View File

@@ -251,6 +251,15 @@ void WVDrmFactory::printCdmProperties(int fd) {
}
}
void WVDrmFactory::printUsage(int fd) {
dprintf(fd, "\nDefault to print all info if no arguments are used.\n");
dprintf(fd, "Optional arguments are:\n");
dprintf(fd, "\ta:print all info | m:cdm metrics | p:cdm properties\n");
dprintf(fd,
"Usage: adb shell dumpsys "
"android.hardware.drm::IDrmFactory/widevine [-a|-h|-m|-p]\n");
}
binder_status_t WVDrmFactory::dump(int fd, const char** args,
uint32_t numArgs) {
if (fd < 0) {
@@ -258,31 +267,32 @@ binder_status_t WVDrmFactory::dump(int fd, const char** args,
return STATUS_BAD_VALUE;
}
dprintf(fd, "\nDefault to print all info if no arguments are used.\n");
dprintf(fd, "Optional arguments are:\n");
dprintf(fd, "\tm:cdm metrics | p:cdm properties\n");
dprintf(fd,
"Usage: adb shell lshal debug "
"android.hardware.drm@1.3::IDrmFactory/widevine [m|p]\n");
bool dumpCdmProperties, dumpCdmMetrics = false;
if (numArgs == 0) {
// default to print all info if no arguments are given
dumpCdmProperties = dumpCdmMetrics = true;
} else {
for (auto&& str : std::vector<std::string_view>{args, args + numArgs}) {
dprintf(fd, "args: %s\n", str.data());
string option = str.data();
if (option.find('m') != string::npos ||
option.find('M') != string::npos) {
if (option.find("-a") != string::npos ||
option.find("-A") != string::npos) {
dumpCdmProperties = dumpCdmMetrics = true;
} else if (option.find("-m") != string::npos ||
option.find("-M") != string::npos) {
dumpCdmMetrics = true;
}
if (option.find('p') != string::npos ||
option.find('P') != string::npos) {
} else if (option.find("-p") != string::npos ||
option.find("-P") != string::npos) {
dumpCdmProperties = true;
} else if (option.find("-h") != string::npos ||
option.find("-H") != string::npos) {
printUsage(fd);
} else {
dprintf(fd, "Invalid arg: %s\n", option.c_str());
printUsage(fd);
}
}
}
if (dumpCdmMetrics) printCdmMetrics(fd);
if (dumpCdmProperties) printCdmProperties(fd);
fsync(fd);