diff options
author | Steve Kondik <steve@cyngn.com> | 2015-11-04 10:43:28 -0800 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-11-04 10:58:59 -0800 |
commit | 8331d3e508498a19c296fed41b9d4b23ea960031 (patch) | |
tree | ab450acfb4e38ffdba3ae893a83a052cc0041783 /cmds/idmap | |
parent | b956432599de00a5edfeccc56615cb03c229c4e9 (diff) | |
parent | 64a04eb003d2af5bbc84db3062ee4d6a4194c513 (diff) | |
download | frameworks_base-8331d3e508498a19c296fed41b9d4b23ea960031.zip frameworks_base-8331d3e508498a19c296fed41b9d4b23ea960031.tar.gz frameworks_base-8331d3e508498a19c296fed41b9d4b23ea960031.tar.bz2 |
Merge branch 'LA.BF64.1.2.2_rb4.6' of git://codeaurora.org/platform/frameworks/base into cm-13.0
Change-Id: I261957864b149edb709e6f76ed382043f9a96936
Diffstat (limited to 'cmds/idmap')
-rw-r--r-- | cmds/idmap/inspect.cpp | 3 | ||||
-rw-r--r-- | cmds/idmap/scan.cpp | 100 |
2 files changed, 62 insertions, 41 deletions
diff --git a/cmds/idmap/inspect.cpp b/cmds/idmap/inspect.cpp index a7844a9..3087e6e 100644 --- a/cmds/idmap/inspect.cpp +++ b/cmds/idmap/inspect.cpp @@ -235,7 +235,8 @@ namespace { } status_t parse_data(IdmapBuffer& buf, const AssetManager& am) { - const uint32_t packageId = am.getResources().getBasePackageId(0); + const ResTable& rt = am.getResources(); + const uint32_t packageId = rt.getBasePackageId(rt.getBasePackageCount() - 1); uint16_t data16; status_t err = buf.nextUint16(&data16); diff --git a/cmds/idmap/scan.cpp b/cmds/idmap/scan.cpp index 34118e6..29b9cc3 100644 --- a/cmds/idmap/scan.cpp +++ b/cmds/idmap/scan.cpp @@ -165,6 +165,62 @@ namespace { delete dataMap; return priority; } + + int idmap_scan(const char *overlay_dir, const char *target_package_name, + const char *target_apk_path, const char *idmap_dir, + SortedVector<Overlay>& overlayVector) + { + DIR *dir = opendir(overlay_dir); + if (dir == NULL) { + return EXIT_FAILURE; + } + + struct dirent *dirent; + while ((dirent = readdir(dir)) != NULL) { + struct stat st; + char overlay_apk_path[PATH_MAX + 1]; + snprintf(overlay_apk_path, PATH_MAX, "%s/%s", overlay_dir, dirent->d_name); + if (stat(overlay_apk_path, &st) < 0) { + continue; + } + if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode)) { + continue; + } + + if (S_ISDIR(st.st_mode)) { + String8 dir_name = String8(overlay_apk_path).getPathLeaf(); + if (dir_name == "." || dir_name == "..") { + // Skip the "." and ".." dir. + continue; + } + idmap_scan(overlay_apk_path, target_package_name, target_apk_path, idmap_dir, + overlayVector); + } else { + int priority = parse_apk(overlay_apk_path, target_package_name); + if (priority < 0) { + continue; + } + + String8 idmap_path(idmap_dir); + idmap_path.appendPath(flatten_path(overlay_apk_path + 1)); + idmap_path.append("@idmap"); + + if (idmap_create_path(target_apk_path, overlay_apk_path, NULL, 0, 0, + idmap_path.string()) != 0) { + ALOGE("error: failed to create idmap for target=%s overlay=%s idmap=%s\n", + target_apk_path, overlay_apk_path, idmap_path.string()); + continue; + } + + Overlay overlay(String8(overlay_apk_path), idmap_path, priority); + overlayVector.add(overlay); + } + } + + closedir(dir); + + return EXIT_SUCCESS; + } } int idmap_scan(const char *overlay_dir, const char *target_package_name, @@ -176,49 +232,13 @@ int idmap_scan(const char *overlay_dir, const char *target_package_name, return EXIT_FAILURE; } - DIR *dir = opendir(overlay_dir); - if (dir == NULL) { - return EXIT_FAILURE; - } - SortedVector<Overlay> overlayVector; - struct dirent *dirent; - while ((dirent = readdir(dir)) != NULL) { - struct stat st; - char overlay_apk_path[PATH_MAX + 1]; - snprintf(overlay_apk_path, PATH_MAX, "%s/%s", overlay_dir, dirent->d_name); - if (stat(overlay_apk_path, &st) < 0) { - continue; - } - if (!S_ISREG(st.st_mode)) { - continue; - } - - int priority = parse_apk(overlay_apk_path, target_package_name); - if (priority < 0) { - continue; - } - - String8 idmap_path(idmap_dir); - idmap_path.appendPath(flatten_path(overlay_apk_path + 1)); - idmap_path.append("@idmap"); - - if (idmap_create_path(target_apk_path, overlay_apk_path, NULL, 0, 0, - idmap_path.string()) != 0) { - ALOGE("error: failed to create idmap for target=%s overlay=%s idmap=%s\n", - target_apk_path, overlay_apk_path, idmap_path.string()); - continue; - } - - Overlay overlay(String8(overlay_apk_path), idmap_path, priority); - overlayVector.add(overlay); - } - - closedir(dir); + int res = idmap_scan(overlay_dir, target_package_name, target_apk_path, idmap_dir, + overlayVector); - if (!writePackagesList(filename.string(), overlayVector)) { + if (res == EXIT_FAILURE || !writePackagesList(filename.string(), overlayVector)) { return EXIT_FAILURE; } - return EXIT_SUCCESS; + return res; } |