Loading cmds/dumpstate/dumpstate.cpp +31 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <dirent.h> #include <errno.h> #include <fcntl.h> #include <inttypes.h> #include <libgen.h> #include <limits.h> #include <stdbool.h> Loading Loading @@ -50,9 +51,11 @@ #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/unique_fd.h> #include <android/content/pm/IPackageManagerNative.h> #include <android/hardware/dumpstate/1.0/IDumpstateDevice.h> #include <android/hidl/manager/1.0/IServiceManager.h> #include <android/os/IIncidentCompanion.h> #include <binder/IServiceManager.h> #include <cutils/native_handle.h> #include <cutils/properties.h> #include <debuggerd/client.h> Loading Loading @@ -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<content::pm::IPackageManagerNative>(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 Loading Loading @@ -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"); Loading cmds/installd/Android.bp +10 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,10 @@ cc_binary { ], }, }, // Needs to be wherever installd is as it's execed by // installd. required: [ "migrate_legacy_obb_data.sh" ], } // OTA chroot tool Loading Loading @@ -254,3 +258,9 @@ sh_binary { "otapreopt_slot", ], } // Script to migrate legacy obb data. sh_binary { name: "migrate_legacy_obb_data.sh", src: "migrate_legacy_obb_data.sh" } cmds/installd/InstalldNativeService.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -2816,5 +2816,16 @@ binder::Status InstalldNativeService::prepareAppProfile(const std::string& packa return ok(); } binder::Status InstalldNativeService::migrateLegacyObbData() { ENFORCE_UID(AID_SYSTEM); // NOTE: The lint warning doesn't apply to the use of system(3) with // absolute parse and no command line arguments. if (system("/system/bin/migrate_legacy_obb_data.sh") != 0) { // NOLINT(cert-env33-c) LOG(ERROR) << "Unable to migrate legacy obb data"; } return ok(); } } // namespace installd } // namespace android cmds/installd/InstalldNativeService.h +2 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,8 @@ public: const std::string& codePath, const std::unique_ptr<std::string>& dexMetadata, bool* _aidl_return); binder::Status migrateLegacyObbData(); private: std::recursive_mutex mLock; Loading cmds/installd/binder/android/os/IInstalld.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,8 @@ interface IInstalld { void destroyAppDataSnapshot(@nullable @utf8InCpp String uuid, @utf8InCpp String packageName, int userId, long ceSnapshotInode, int snapshotId, int storageFlags); void migrateLegacyObbData(); const int FLAG_STORAGE_DE = 0x1; const int FLAG_STORAGE_CE = 0x2; const int FLAG_STORAGE_EXTERNAL = 0x4; Loading Loading
cmds/dumpstate/dumpstate.cpp +31 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <dirent.h> #include <errno.h> #include <fcntl.h> #include <inttypes.h> #include <libgen.h> #include <limits.h> #include <stdbool.h> Loading Loading @@ -50,9 +51,11 @@ #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/unique_fd.h> #include <android/content/pm/IPackageManagerNative.h> #include <android/hardware/dumpstate/1.0/IDumpstateDevice.h> #include <android/hidl/manager/1.0/IServiceManager.h> #include <android/os/IIncidentCompanion.h> #include <binder/IServiceManager.h> #include <cutils/native_handle.h> #include <cutils/properties.h> #include <debuggerd/client.h> Loading Loading @@ -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<content::pm::IPackageManagerNative>(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 Loading Loading @@ -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"); Loading
cmds/installd/Android.bp +10 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,10 @@ cc_binary { ], }, }, // Needs to be wherever installd is as it's execed by // installd. required: [ "migrate_legacy_obb_data.sh" ], } // OTA chroot tool Loading Loading @@ -254,3 +258,9 @@ sh_binary { "otapreopt_slot", ], } // Script to migrate legacy obb data. sh_binary { name: "migrate_legacy_obb_data.sh", src: "migrate_legacy_obb_data.sh" }
cmds/installd/InstalldNativeService.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -2816,5 +2816,16 @@ binder::Status InstalldNativeService::prepareAppProfile(const std::string& packa return ok(); } binder::Status InstalldNativeService::migrateLegacyObbData() { ENFORCE_UID(AID_SYSTEM); // NOTE: The lint warning doesn't apply to the use of system(3) with // absolute parse and no command line arguments. if (system("/system/bin/migrate_legacy_obb_data.sh") != 0) { // NOLINT(cert-env33-c) LOG(ERROR) << "Unable to migrate legacy obb data"; } return ok(); } } // namespace installd } // namespace android
cmds/installd/InstalldNativeService.h +2 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,8 @@ public: const std::string& codePath, const std::unique_ptr<std::string>& dexMetadata, bool* _aidl_return); binder::Status migrateLegacyObbData(); private: std::recursive_mutex mLock; Loading
cmds/installd/binder/android/os/IInstalld.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,8 @@ interface IInstalld { void destroyAppDataSnapshot(@nullable @utf8InCpp String uuid, @utf8InCpp String packageName, int userId, long ceSnapshotInode, int snapshotId, int storageFlags); void migrateLegacyObbData(); const int FLAG_STORAGE_DE = 0x1; const int FLAG_STORAGE_CE = 0x2; const int FLAG_STORAGE_EXTERNAL = 0x4; Loading