summaryrefslogtreecommitdiffstats
path: root/libs/androidfw
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2015-10-26 13:28:12 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2015-10-26 13:28:12 -0700
commit80fc95f5eb0321444dbd73ec9ef901ad67c33828 (patch)
treeac2a1d0126ac3febc810f147fe9032d258b92955 /libs/androidfw
parent9611ba2cdb1860f12fedf65cd6ffb7c6d7f08ae7 (diff)
parentf1642d87c5cc6783f5ef16e3cbadbd098f086111 (diff)
downloadframeworks_base-80fc95f5eb0321444dbd73ec9ef901ad67c33828.zip
frameworks_base-80fc95f5eb0321444dbd73ec9ef901ad67c33828.tar.gz
frameworks_base-80fc95f5eb0321444dbd73ec9ef901ad67c33828.tar.bz2
Merge "base: Fix the problems for runtime overlay."
Diffstat (limited to 'libs/androidfw')
-rw-r--r--libs/androidfw/AssetManager.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp
index 2dc1c96..4f62204 100644
--- a/libs/androidfw/AssetManager.cpp
+++ b/libs/androidfw/AssetManager.cpp
@@ -224,6 +224,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());
@@ -237,10 +242,6 @@ bool AssetManager::addAssetPath(const String8& path, int32_t* cookie)
}
#endif
- if (mResources != NULL) {
- appendPathToResTable(ap);
- }
-
return true;
}
@@ -303,7 +304,8 @@ bool AssetManager::addOverlayPath(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;
@@ -610,7 +612,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;
@@ -622,17 +624,16 @@ 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.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) {
@@ -650,20 +651,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);
+ sharedRes->add(ass, idmap, *entryIdx + 1, false);
#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);
@@ -685,7 +686,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);
+ mResources->add(ass, idmap, *entryIdx + 1, !shared);
}
onlyEmptyResources = false;
@@ -694,7 +695,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) {
@@ -734,7 +735,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;
}