summaryrefslogtreecommitdiffstats
path: root/libs/utils/AssetManager.cpp
diff options
context:
space:
mode:
authorSergey Ten <sergey.ten6@t-mobile.com>2009-03-30 10:08:11 -0700
committerJosh Guilfoyle <Josh.Guilfoyle@T-Mobile.com>2009-07-29 19:57:54 -0700
commit5924e96f5f4d6e7a1492bc446b6a21e03eea2fc1 (patch)
treeffbfcadcea40f05e99359e63358e4c00780eb0ec /libs/utils/AssetManager.cpp
parentc4b3fcb36f561fe7758709e64923cafd0f4a12b2 (diff)
downloadframeworks_base-5924e96f5f4d6e7a1492bc446b6a21e03eea2fc1.zip
frameworks_base-5924e96f5f4d6e7a1492bc446b6a21e03eea2fc1.tar.gz
frameworks_base-5924e96f5f4d6e7a1492bc446b6a21e03eea2fc1.tar.bz2
Add support for restoring asset paths stack in Asset Manager
Diffstat (limited to 'libs/utils/AssetManager.cpp')
-rw-r--r--libs/utils/AssetManager.cpp39
1 files changed, 29 insertions, 10 deletions
diff --git a/libs/utils/AssetManager.cpp b/libs/utils/AssetManager.cpp
index 447b801..624fd7e 100644
--- a/libs/utils/AssetManager.cpp
+++ b/libs/utils/AssetManager.cpp
@@ -122,7 +122,7 @@ bool AssetManager::addAssetPath(const String8& path, void** cookie)
return true;
}
}
-
+
LOGV("In %p Asset %s path: %s", this,
ap.type == kFileTypeDirectory ? "dir" : "zip", ap.path.string());
@@ -185,7 +185,7 @@ void AssetManager::setLocaleLocked(const char* locale)
delete[] mLocale;
}
mLocale = strdupNew(locale);
-
+
updateResourceParamsLocked();
}
@@ -591,7 +591,7 @@ Asset* AssetManager::openInLocaleVendorLocked(const char* fileName, AccessMode m
/* look at the filesystem on disk */
String8 path(createPathNameLocked(ap, locale, vendor));
path.appendPath(fileName);
-
+
String8 excludeName(path);
excludeName.append(kExcludeExtension);
if (::getFileType(excludeName.string()) != kFileTypeNonexistent) {
@@ -599,28 +599,28 @@ Asset* AssetManager::openInLocaleVendorLocked(const char* fileName, AccessMode m
//printf("+++ excluding '%s'\n", (const char*) excludeName);
return kExcludedAsset;
}
-
+
pAsset = openAssetFromFileLocked(path, mode);
-
+
if (pAsset == NULL) {
/* try again, this time with ".gz" */
path.append(".gz");
pAsset = openAssetFromFileLocked(path, mode);
}
-
+
if (pAsset != NULL)
pAsset->setAssetSource(path);
} else {
/* find in cache */
String8 path(createPathNameLocked(ap, locale, vendor));
path.appendPath(fileName);
-
+
AssetDir::FileInfo tmpInfo;
bool found = false;
-
+
String8 excludeName(path);
excludeName.append(kExcludeExtension);
-
+
if (mCache.indexOf(excludeName) != NAME_NOT_FOUND) {
/* go no farther */
//printf("+++ Excluding '%s'\n", (const char*) excludeName);
@@ -1384,7 +1384,7 @@ bool AssetManager::fncScanAndMergeDirLocked(
// XXX This is broken -- the filename cache needs to hold the base
// asset path separately from its filename.
-
+
partialPath = createPathNameLocked(ap, locale, vendor);
if (dirName[0] != '\0') {
partialPath.appendPath(dirName);
@@ -1635,3 +1635,22 @@ int AssetManager::ZipSet::getIndex(const String8& zip) const
return mZipPath.size()-1;
}
+/*
+ * Mark asset path "stack" to support un-install from the mAssetPaths.
+ */
+int AssetManager::markAssetPathStack()
+{
+ return (int)mAssetPaths.size();
+}
+
+/*
+ * Restore asset path "stack" by un-installing from the mAssetPaths
+ * all assets installed after restoreIndex.
+ */
+void AssetManager::restoreAssetPathStack(int restoreIndex)
+{
+ int i = (int)mAssetPaths.size();
+ while (i > restoreIndex) {
+ mAssetPaths.removeAt(--i);
+ }
+}