diff options
Diffstat (limited to 'libs/androidfw/AssetManager.cpp')
-rw-r--r-- | libs/androidfw/AssetManager.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp index 52ab361..251d47b 100644 --- a/libs/androidfw/AssetManager.cpp +++ b/libs/androidfw/AssetManager.cpp @@ -83,6 +83,8 @@ static Asset* const kExcludedAsset = (Asset*) 0xd000000d; static volatile int32_t gCount = 0; +const char* AssetManager::RESOURCES_FILENAME = "resources.arsc"; + namespace { // Transform string /a/b/c.apk to /data/resource-cache/a@b@c.apk@idmap String8 idmapPathForPackagePath(const String8& pkgPath) @@ -239,6 +241,29 @@ bool AssetManager::addAssetPath(const String8& path, int32_t* cookie) return true; } +bool AssetManager::createIdmap(const char* targetApkPath, const char* overlayApkPath, + uint32_t targetCrc, uint32_t overlayCrc, uint32_t** outData, uint32_t* outSize) +{ + AutoMutex _l(mLock); + const String8 paths[2] = { String8(targetApkPath), String8(overlayApkPath) }; + ResTable tables[2]; + + for (int i = 0; i < 2; ++i) { + asset_path ap; + ap.type = kFileTypeRegular; + ap.path = paths[i]; + Asset* ass = openNonAssetInPathLocked("resources.arsc", Asset::ACCESS_BUFFER, ap); + if (ass == NULL) { + ALOGW("failed to find resources.arsc in %s\n", ap.path.string()); + return false; + } + tables[i].add(ass, (void*)1, false); + } + + return tables[0].createIdmap(tables[1], targetCrc, overlayCrc, + targetApkPath, overlayApkPath, (void**)outData, outSize) == NO_ERROR; +} + bool AssetManager::isIdmapStaleLocked(const String8& originalPath, const String8& overlayPath, const String8& idmapPath) { @@ -335,7 +360,7 @@ bool AssetManager::createIdmapFileLocked(const String8& originalPath, const Stri ALOGW("failed to find resources.arsc in %s\n", ap.path.string()); goto error; } - tables[i].add(ass, (void*)1, false); + tables[i].add(ass, 1, false /* copyData */, NULL /* idMap */); } if (!getZipEntryCrcLocked(originalPath, "resources.arsc", &originalCrc)) { @@ -682,7 +707,7 @@ const ResTable* AssetManager::getResTable(bool required) const // can quickly copy it out for others. ALOGV("Creating shared resources for %s", ap.path.string()); sharedRes = new ResTable(); - sharedRes->add(ass, (void*)(i+1), false, idmap); + sharedRes->add(ass, i + 1, false, idmap); sharedRes = const_cast<AssetManager*>(this)-> mZipSet.setZipResourceTable(ap.path, sharedRes); } @@ -706,7 +731,7 @@ const ResTable* AssetManager::getResTable(bool required) const rt->add(sharedRes); } else { ALOGV("Parsing resources for %s", ap.path.string()); - rt->add(ass, (void*)(i+1), !shared, idmap); + rt->add(ass, i + 1, !shared, idmap); } if (!shared) { |