From 21a3d1ad686dee97b9cf0ed80389ee2ab0d48013 Mon Sep 17 00:00:00 2001 From: MÃ¥rten Kongstad Date: Thu, 2 Jun 2016 09:35:31 +0200 Subject: OMS: integrate OverlayManagerService into framework Hand over ownership of overlays to OverlayManagerService. Changes to a package's overlays are propagated using the activity life cycle. Affected activities will be recreated as needed. This provides a well-defined point to modify an application's assets while the application is paused. Consolidate how overlays targeting the system and overlays targeting regular applications are handled. Previously, system overlays were handled as a special case. Now, everything is handled identically. As a side effect, the call to idmap --scan during Zygote boot has become obsolete and is removed. Information on what overlays to use is recorded in ApplicationInfo.resourceDirs. The PackageManagerService is responsible for the creation of ApplicationInfo objects. The OverlayManagerService is responsible for informing the PackageManagerService in advance about what resourceDirs to use. When launching an application, the ApplicationInfo is already populated with up-to-date information about overlays. When enabling or disabling an overlay for a running application, the OverlayManagerService first notifies the PackageManagerService about the updated resourceDirs. It then tells the ActivityManagerService to push the new ApplicationInfo object to the application's ActivityThread. Finally the application requests its ResourcesManager to create new ResourcesImpl objects based on the updated paths. Co-authored-by: Martin Wallgren Signed-off-by: Zoran Jovanovic Bug: 31052947 Test: run tests from 'OMS: tests for OverlayManagerService' Change-Id: Idc96dae6fc075d5373aa055bbf50e919136d7353 --- cmds/idmap/idmap.cpp | 55 ---------------------------------------------------- 1 file changed, 55 deletions(-) (limited to 'cmds/idmap/idmap.cpp') diff --git a/cmds/idmap/idmap.cpp b/cmds/idmap/idmap.cpp index 3ab191553625..d388977e8e2f 100644 --- a/cmds/idmap/idmap.cpp +++ b/cmds/idmap/idmap.cpp @@ -13,8 +13,6 @@ SYNOPSIS \n\ idmap --help \n\ idmap --fd target overlay fd \n\ idmap --path target overlay idmap \n\ - idmap --scan target-package-name-to-look-for path-to-target-apk dir-to-hold-idmaps \\\ - dir-to-scan [additional-dir-to-scan [additional-dir-to-scan [...]]]\n\ idmap --inspect idmap \n\ \n\ DESCRIPTION \n\ @@ -48,11 +46,6 @@ OPTIONS \n\ \n\ --path: create idmap for target package 'target' (path to apk) and overlay package \n\ 'overlay' (path to apk); write results to 'idmap' (path). \n\ -\n\ - --scan: non-recursively search directory 'dir-to-scan' (path) for overlay packages with \n\ - target package 'target-package-name-to-look-for' (package name) present at\n\ - 'path-to-target-apk' (path to apk). For each overlay package found, create an\n\ - idmap file in 'dir-to-hold-idmaps' (path). \n\ \n\ --inspect: decode the binary format of 'idmap' (path) and display the contents in a \n\ debug-friendly format. \n\ @@ -97,16 +90,6 @@ EXAMPLES \n\ NOTES \n\ This tool and its expected invocation from installd is modelled on dexopt."; - bool verify_directory_readable(const char *path) - { - return access(path, R_OK | X_OK) == 0; - } - - bool verify_directory_writable(const char *path) - { - return access(path, W_OK) == 0; - } - bool verify_file_readable(const char *path) { return access(path, R_OK) == 0; @@ -167,36 +150,6 @@ NOTES \n\ return idmap_create_path(target_apk_path, overlay_apk_path, idmap_path); } - int maybe_scan(const char *target_package_name, const char *target_apk_path, - const char *idmap_dir, const android::Vector *overlay_dirs) - { - if (!verify_root_or_system()) { - fprintf(stderr, "error: permission denied: not user root or user system\n"); - return -1; - } - - if (!verify_file_readable(target_apk_path)) { - ALOGD("error: failed to read apk %s: %s\n", target_apk_path, strerror(errno)); - return -1; - } - - if (!verify_directory_writable(idmap_dir)) { - ALOGD("error: no write access to %s: %s\n", idmap_dir, strerror(errno)); - return -1; - } - - const size_t N = overlay_dirs->size(); - for (size_t i = 0; i < N; i++) { - const char *dir = overlay_dirs->itemAt(i); - if (!verify_directory_readable(dir)) { - ALOGD("error: no read access to %s: %s\n", dir, strerror(errno)); - return -1; - } - } - - return idmap_scan(target_package_name, target_apk_path, idmap_dir, overlay_dirs); - } - int maybe_inspect(const char *idmap_path) { // anyone (not just root or system) may do --inspect @@ -235,14 +188,6 @@ int main(int argc, char **argv) return maybe_create_path(argv[2], argv[3], argv[4]); } - if (argc >= 6 && !strcmp(argv[1], "--scan")) { - android::Vector v; - for (int i = 5; i < argc; i++) { - v.push(argv[i]); - } - return maybe_scan(argv[2], argv[3], argv[4], &v); - } - if (argc == 3 && !strcmp(argv[1], "--inspect")) { return maybe_inspect(argv[2]); } -- cgit v1.2.3-59-g8ed1b