diff --git a/libwvdrmengine/aidl_include/WVDrmFactory.h b/libwvdrmengine/aidl_include/WVDrmFactory.h index 394964a8..7dcf0a00 100644 --- a/libwvdrmengine/aidl_include/WVDrmFactory.h +++ b/libwvdrmengine/aidl_include/WVDrmFactory.h @@ -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; }; diff --git a/libwvdrmengine/aidl_src/WVDrmFactory.cpp b/libwvdrmengine/aidl_src/WVDrmFactory.cpp index d87d87be..50f1388c 100644 --- a/libwvdrmengine/aidl_src/WVDrmFactory.cpp +++ b/libwvdrmengine/aidl_src/WVDrmFactory.cpp @@ -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{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);