diff options
author | d34d <clark@cyngn.com> | 2015-01-19 08:13:59 -0800 |
---|---|---|
committer | Clark Scheff <clark@cyngn.com> | 2015-10-27 10:38:48 -0700 |
commit | 75ab08fd9c9c1645335d12eeef734ff493bd0070 (patch) | |
tree | 60d7173f54cc7e38a125a7315d9cd3e6a26eecdf /cmds/idmap | |
parent | 607f76114ba5665c9ac7866da1a42cb89ccac6f2 (diff) | |
download | frameworks_base-75ab08fd9c9c1645335d12eeef734ff493bd0070.zip frameworks_base-75ab08fd9c9c1645335d12eeef734ff493bd0070.tar.gz frameworks_base-75ab08fd9c9c1645335d12eeef734ff493bd0070.tar.bz2 |
Themes: Restructure resource cache [1/2]
The new structure is as follows:
/data/resource-cache/
├─ theme1_pkg_name
| ├─ target1_pkg_name
| | ├─ idmap
| | └─ resources.apk
| ├─ target2_pkg_name
| ·
| ·
| ·
| ├─ targetN_pkg_name
| └─ icons
| ├─ hash
| └─ resources.apk
├─ theme2_pkg_name
·
·
·
└─ themeN_pkg_name
Change-Id: Id39688c88929733b42368c1f20ef0e25848a3390
Diffstat (limited to 'cmds/idmap')
-rw-r--r-- | cmds/idmap/create.cpp | 25 | ||||
-rw-r--r-- | cmds/idmap/idmap.cpp | 22 | ||||
-rw-r--r-- | cmds/idmap/idmap.h | 4 | ||||
-rw-r--r-- | cmds/idmap/scan.cpp | 3 |
4 files changed, 29 insertions, 25 deletions
diff --git a/cmds/idmap/create.cpp b/cmds/idmap/create.cpp index 8c07eb0..f706533 100644 --- a/cmds/idmap/create.cpp +++ b/cmds/idmap/create.cpp @@ -153,7 +153,8 @@ fail: } int create_idmap(const char *target_apk_path, const char *overlay_apk_path, - uint32_t target_hash, uint32_t overlay_hash, uint32_t **data, size_t *size) + const char *cache_path, uint32_t target_hash, uint32_t overlay_hash, uint32_t **data, + size_t *size) { uint32_t target_crc, overlay_crc; @@ -164,13 +165,14 @@ fail: overlay_crc = 0; AssetManager am; - bool b = am.createIdmap(target_apk_path, overlay_apk_path, target_crc, overlay_crc, - target_hash, overlay_hash, data, size); + bool b = am.createIdmap(target_apk_path, overlay_apk_path, cache_path, target_crc, + overlay_crc, target_hash, overlay_hash, data, size); return b ? 0 : -1; } int create_and_write_idmap(const char *target_apk_path, const char *overlay_apk_path, - uint32_t target_hash, uint32_t overlay_hash, int fd, bool check_if_stale) + const char *cache_path, uint32_t target_hash, uint32_t overlay_hash, int fd, + bool check_if_stale) { if (check_if_stale) { if (!is_idmap_stale_fd(target_apk_path, overlay_apk_path, fd)) { @@ -182,7 +184,7 @@ fail: uint32_t *data = NULL; size_t size; - if (create_idmap(target_apk_path, overlay_apk_path, target_hash, overlay_hash, + if (create_idmap(target_apk_path, overlay_apk_path, cache_path, target_hash, overlay_hash, &data, &size) == -1) { return -1; } @@ -198,7 +200,7 @@ fail: } int idmap_create_path(const char *target_apk_path, const char *overlay_apk_path, - uint32_t target_hash, uint32_t overlay_hash, + const char *cache_path, uint32_t target_hash, uint32_t overlay_hash, const char *idmap_path) { if (!is_idmap_stale_path(target_apk_path, overlay_apk_path, idmap_path)) { @@ -211,8 +213,8 @@ int idmap_create_path(const char *target_apk_path, const char *overlay_apk_path, return EXIT_FAILURE; } - int r = create_and_write_idmap(target_apk_path, overlay_apk_path, target_hash, overlay_hash, - fd, false); + int r = create_and_write_idmap(target_apk_path, overlay_apk_path, cache_path, + target_hash, overlay_hash, fd, false); close(fd); if (r != 0) { unlink(idmap_path); @@ -221,10 +223,9 @@ int idmap_create_path(const char *target_apk_path, const char *overlay_apk_path, } int idmap_create_fd(const char *target_apk_path, const char *overlay_apk_path, - uint32_t target_hash, uint32_t overlay_hash, - int fd) + const char *cache_path, uint32_t target_hash, uint32_t overlay_hash, int fd) { - return create_and_write_idmap(target_apk_path, overlay_apk_path, target_hash, overlay_hash, - fd, true) == 0 ? + return create_and_write_idmap(target_apk_path, overlay_apk_path, cache_path, target_hash, + overlay_hash, fd, true) == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/cmds/idmap/idmap.cpp b/cmds/idmap/idmap.cpp index 607cfd3..cc3f231 100644 --- a/cmds/idmap/idmap.cpp +++ b/cmds/idmap/idmap.cpp @@ -122,7 +122,8 @@ NOTES \n\ } int maybe_create_fd(const char *target_apk_path, const char *overlay_apk_path, - const char *idmap_str, const char *target_hash_str, const char *overlay_hash_str) + const char *cache_path, const char *idmap_str, const char *target_hash_str, + const char *overlay_hash_str) { // anyone (not just root or system) may do --fd -- the file has // already been opened by someone else on our behalf @@ -146,12 +147,13 @@ NOTES \n\ int target_hash = strtol(target_hash_str, 0, 10); int overlay_hash = strtol(overlay_hash_str, 0, 10); - return idmap_create_fd(target_apk_path, overlay_apk_path, target_hash, overlay_hash, - idmap_fd); + return idmap_create_fd(target_apk_path, overlay_apk_path, cache_path, target_hash, + overlay_hash, idmap_fd); } int maybe_create_path(const char *target_apk_path, const char *overlay_apk_path, - const char *idmap_path, const char *target_hash_str, const char *overlay_hash_str) + const char *cache_path, const char *idmap_path, const char *target_hash_str, + const char *overlay_hash_str) { if (!verify_root_or_system()) { fprintf(stderr, "error: permission denied: not user root or user system\n"); @@ -170,8 +172,8 @@ NOTES \n\ int target_hash = strtol(target_hash_str, 0, 10); int overlay_hash = strtol(overlay_hash_str, 0, 10); - return idmap_create_path(target_apk_path, overlay_apk_path, target_hash, overlay_hash, - idmap_path); + return idmap_create_path(target_apk_path, overlay_apk_path, cache_path, target_hash, + overlay_hash, idmap_path); } int maybe_scan(const char *overlay_dir, const char *target_package_name, @@ -230,12 +232,12 @@ int main(int argc, char **argv) return 0; } - if (argc == 7 && !strcmp(argv[1], "--fd")) { - return maybe_create_fd(argv[2], argv[3], argv[4], argv[5], argv[6]); + if (argc == 8 && !strcmp(argv[1], "--fd")) { + return maybe_create_fd(argv[2], argv[3], argv[4], argv[5], argv[6], argv[7]); } - if (argc == 7 && !strcmp(argv[1], "--path")) { - return maybe_create_path(argv[2], argv[3], argv[4], argv[5], argv[6]); + if (argc == 8 && !strcmp(argv[1], "--path")) { + return maybe_create_path(argv[2], argv[3], argv[4], argv[5], argv[6], argv[7]); } if (argc == 6 && !strcmp(argv[1], "--scan")) { diff --git a/cmds/idmap/idmap.h b/cmds/idmap/idmap.h index 1794db7..6a9c5ef 100644 --- a/cmds/idmap/idmap.h +++ b/cmds/idmap/idmap.h @@ -19,11 +19,11 @@ #endif int idmap_create_path(const char *target_apk_path, const char *overlay_apk_path, - uint32_t target_hash, uint32_t overlay_hash, + const char *cache_path, uint32_t target_hash, uint32_t overlay_hash, const char *idmap_path); int idmap_create_fd(const char *target_apk_path, const char *overlay_apk_path, - uint32_t target_hash, uint32_t overlay_hash, + const char *cache_path, uint32_t target_hash, uint32_t overlay_hash, int fd); // Regarding target_package_name: the idmap_scan implementation should diff --git a/cmds/idmap/scan.cpp b/cmds/idmap/scan.cpp index 62ad6a9..34118e6 100644 --- a/cmds/idmap/scan.cpp +++ b/cmds/idmap/scan.cpp @@ -203,7 +203,8 @@ int idmap_scan(const char *overlay_dir, const char *target_package_name, idmap_path.appendPath(flatten_path(overlay_apk_path + 1)); idmap_path.append("@idmap"); - if (idmap_create_path(target_apk_path, overlay_apk_path, 0, 0, idmap_path.string()) != 0) { + 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; |