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 /libs | |
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 'libs')
-rw-r--r-- | libs/androidfw/AssetManager.cpp | 37 | ||||
-rw-r--r-- | libs/androidfw/ResourceTypes.cpp | 6 |
2 files changed, 24 insertions, 19 deletions
diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp index 635aa5b..1add6c3 100644 --- a/libs/androidfw/AssetManager.cpp +++ b/libs/androidfw/AssetManager.cpp @@ -205,6 +205,11 @@ bool AssetManager::addAssetPath(const String8& path, int32_t* cookie) mAssetPaths.add(ap); + if (mResources != NULL) { + size_t index = mAssetPaths.size() - 1; + appendPathToResTable(ap, &index); + } + // new paths are always added at the end if (cookie) { *cookie = static_cast<int32_t>(mAssetPaths.size()); @@ -218,10 +223,6 @@ bool AssetManager::addAssetPath(const String8& path, int32_t* cookie) } #endif - if (mResources != NULL) { - appendPathToResTable(ap); - } - return true; } @@ -308,7 +309,8 @@ bool AssetManager::addOverlayPath(const String8& idmapPath, const String8& overl *cookie = static_cast<int32_t>(mAssetPaths.size()); if (mResources != NULL) { - appendPathToResTable(oap); + size_t index = mAssetPaths.size() - 1; + appendPathToResTable(oap, &index); } return true; @@ -349,7 +351,8 @@ bool AssetManager::addCommonOverlayPath(const String8& themePackagePath, int32_t *cookie = static_cast<int32_t>(mAssetPaths.size()); if (mResources != NULL) { - appendPathToResTable(oap); + size_t index = mAssetPaths.size() - 1; + appendPathToResTable(oap, &index); } return true; @@ -400,7 +403,8 @@ bool AssetManager::addIconPath(const String8& packagePath, int32_t* cookie, *cookie = static_cast<int32_t>(mAssetPaths.size()); if (mResources != NULL) { - appendPathToResTable(oap); + size_t index = mAssetPaths.size() - 1; + appendPathToResTable(oap, &index); } return true; @@ -795,7 +799,7 @@ FileType AssetManager::getFileType(const char* fileName) return kFileTypeRegular; } -bool AssetManager::appendPathToResTable(const asset_path& ap) const { +bool AssetManager::appendPathToResTable(const asset_path& ap, size_t* entryIdx) const { // skip those ap's that correspond to system overlays if (ap.isSystemOverlay) { return true; @@ -807,21 +811,20 @@ bool AssetManager::appendPathToResTable(const asset_path& ap) const { bool onlyEmptyResources = true; MY_TRACE_BEGIN(ap.path.string()); Asset* idmap = openIdmapLocked(ap); - size_t nextEntryIdx = mResources->getTableCount(); ALOGV("Looking for resource asset in '%s'\n", ap.path.string()); if (!ap.resApkPath.isEmpty()) { // Avoid using prefix path in this case since the compiled resApk will simply have resources.arsc in it ass = const_cast<AssetManager*>(this)->openNonAssetInPathLocked("resources.arsc", Asset::ACCESS_BUFFER, ap, false); shared = false; } else if (ap.type != kFileTypeDirectory) { - if (nextEntryIdx == 0) { + if (*entryIdx == 0) { // The first item is typically the framework resources, // which we want to avoid parsing every time. sharedRes = const_cast<AssetManager*>(this)-> mZipSet.getZipResourceTable(ap.path); if (sharedRes != NULL) { // skip ahead the number of system overlay packages preloaded - nextEntryIdx = sharedRes->getTableCount(); + *entryIdx += sharedRes->getTableCount() - 1; } } if (sharedRes == NULL) { @@ -839,20 +842,20 @@ bool AssetManager::appendPathToResTable(const asset_path& ap) const { } } - if (nextEntryIdx == 0 && ass != NULL) { + if (*entryIdx == 0 && ass != NULL) { // If this is the first resource table in the asset // manager, then we are going to cache it so that we // can quickly copy it out for others. ALOGV("Creating shared resources for %s", ap.path.string()); sharedRes = new ResTable(); - sharedRes->add(ass, idmap, nextEntryIdx + 1, false, ap.pkgIdOverride); + sharedRes->add(ass, idmap, *entryIdx + 1, false, ap.pkgIdOverride); #ifdef HAVE_ANDROID_OS const char* data = getenv("ANDROID_DATA"); LOG_ALWAYS_FATAL_IF(data == NULL, "ANDROID_DATA not set"); String8 overlaysListPath(data); overlaysListPath.appendPath(kResourceCache); overlaysListPath.appendPath("overlays.list"); - addSystemOverlays(overlaysListPath.string(), ap.path, sharedRes, nextEntryIdx); + addSystemOverlays(overlaysListPath.string(), ap.path, sharedRes, *entryIdx); #endif sharedRes = const_cast<AssetManager*>(this)-> mZipSet.setZipResourceTable(ap.path, sharedRes); @@ -874,7 +877,7 @@ bool AssetManager::appendPathToResTable(const asset_path& ap) const { mResources->add(sharedRes); } else { ALOGV("Parsing resources for %s", ap.path.string()); - mResources->add(ass, idmap, nextEntryIdx + 1, !shared, ap.pkgIdOverride); + mResources->add(ass, idmap, *entryIdx + 1, !shared, ap.pkgIdOverride); } onlyEmptyResources = false; @@ -883,7 +886,7 @@ bool AssetManager::appendPathToResTable(const asset_path& ap) const { } } else { ALOGV("Installing empty resources in to table %p\n", mResources); - mResources->addEmpty(nextEntryIdx + 1); + mResources->addEmpty(*entryIdx + 1); } if (idmap != NULL) { @@ -923,7 +926,7 @@ const ResTable* AssetManager::getResTable(bool required) const bool onlyEmptyResources = true; const size_t N = mAssetPaths.size(); for (size_t i=0; i<N; i++) { - bool empty = appendPathToResTable(mAssetPaths.itemAt(i)); + bool empty = appendPathToResTable(mAssetPaths.itemAt(i), &i); onlyEmptyResources = onlyEmptyResources && empty; } diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp index aa207e2..818e1c5 100644 --- a/libs/androidfw/ResourceTypes.cpp +++ b/libs/androidfw/ResourceTypes.cpp @@ -6533,8 +6533,10 @@ status_t ResTable::createIdmap(const ResTable& overlay, KeyedVector<uint8_t, IdmapTypeMap> map; - // overlaid packages are assumed to contain only one package group - const PackageGroup* pg = mPackageGroups[0]; + // Overlaid packages are assumed to contain only one package group or two package group + // as one is "system package(android)", and another is "application package". So we need + // to use the last package group to create idmap. + const PackageGroup* pg = mPackageGroups[mPackageGroups.size() - 1]; // starting size is header *outSize = ResTable::IDMAP_HEADER_SIZE_BYTES; |