From a325a5702b93efc68b34934498abb787d758f848 Mon Sep 17 00:00:00 2001 From: Nikita Ioffe Date: Thu, 16 May 2019 19:49:47 +0100 Subject: Add information about Module Metadata Version into bugreport header * In case device supports mainline, the following line will be added to the header of a bugreport: Module Metadata version: * Otherwise this line will be omitted. Test: adb bugreport /tmp/bugreports Bug: 131774400 Change-Id: I03f8c10039381cf788ff353893c82a9beaaaaca8 --- cmds/dumpstate/dumpstate.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'cmds/dumpstate/dumpstate.cpp') diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 671c788b1f..31a1de03d9 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -50,9 +51,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -204,6 +207,30 @@ static bool IsFileEmpty(const std::string& file_path) { return file.tellg() <= 0; } +int64_t GetModuleMetadataVersion() { + auto binder = defaultServiceManager()->getService(android::String16("package_native")); + if (binder == nullptr) { + MYLOGE("Failed to retrieve package_native service"); + return 0L; + } + auto package_service = android::interface_cast(binder); + std::string package_name; + auto status = package_service->getModuleMetadataPackageName(&package_name); + if (!status.isOk()) { + MYLOGE("Failed to retrieve module metadata package name: %s", status.toString8().c_str()); + return 0L; + } + MYLOGD("Module metadata package name: %s", package_name.c_str()); + int64_t version_code; + status = package_service->getVersionCodeForPackage(android::String16(package_name.c_str()), + &version_code); + if (!status.isOk()) { + MYLOGE("Failed to retrieve module metadata version: %s", status.toString8().c_str()); + return 0L; + } + return version_code; +} + } // namespace } // namespace os } // namespace android @@ -741,6 +768,10 @@ void Dumpstate::PrintHeader() const { printf("Bootloader: %s\n", bootloader.c_str()); printf("Radio: %s\n", radio.c_str()); printf("Network: %s\n", network.c_str()); + int64_t module_metadata_version = android::os::GetModuleMetadataVersion(); + if (module_metadata_version != 0) { + printf("Module Metadata version: %" PRId64 "\n", module_metadata_version); + } printf("Kernel: "); DumpFileToFd(STDOUT_FILENO, "", "/proc/version"); -- cgit v1.2.3-59-g8ed1b