diff options
author | MÃ¥rten Kongstad <marten.kongstad@sonymobile.com> | 2016-06-02 09:35:31 +0200 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2017-02-21 14:29:43 -0800 |
commit | 21a3d1ad686dee97b9cf0ed80389ee2ab0d48013 (patch) | |
tree | 79a415bcc73f60cda6dbac4ca414b22741c47266 /libs/androidfw/AssetManager.cpp | |
parent | f9bd2944694539f1dce74d420156cc50bbb4af14 (diff) |
OMS: integrate OverlayManagerService into framework
Hand over ownership of overlays to OverlayManagerService.
Changes to a package's overlays are propagated using the activity life
cycle. Affected activities will be recreated as needed. This provides a
well-defined point to modify an application's assets while the
application is paused.
Consolidate how overlays targeting the system and overlays targeting
regular applications are handled. Previously, system overlays were
handled as a special case. Now, everything is handled identically. As a
side effect, the call to idmap --scan during Zygote boot has become
obsolete and is removed.
Information on what overlays to use is recorded in
ApplicationInfo.resourceDirs. The PackageManagerService is responsible
for the creation of ApplicationInfo objects. The OverlayManagerService
is responsible for informing the PackageManagerService in advance about
what resourceDirs to use.
When launching an application, the ApplicationInfo is already populated
with up-to-date information about overlays.
When enabling or disabling an overlay for a running application, the
OverlayManagerService first notifies the PackageManagerService about the
updated resourceDirs. It then tells the ActivityManagerService to push
the new ApplicationInfo object to the application's ActivityThread.
Finally the application requests its ResourcesManager to create new
ResourcesImpl objects based on the updated paths.
Co-authored-by: Martin Wallgren <martin.wallgren@sonymobile.com>
Signed-off-by: Zoran Jovanovic <zoran.jovanovic@sonymobile.com>
Bug: 31052947
Test: run tests from 'OMS: tests for OverlayManagerService'
Change-Id: Idc96dae6fc075d5373aa055bbf50e919136d7353
Diffstat (limited to 'libs/androidfw/AssetManager.cpp')
-rw-r--r-- | libs/androidfw/AssetManager.cpp | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp index acacd7654cf1..84111ae0d499 100644 --- a/libs/androidfw/AssetManager.cpp +++ b/libs/androidfw/AssetManager.cpp @@ -202,15 +202,6 @@ bool AssetManager::addAssetPath( *cookie = static_cast<int32_t>(mAssetPaths.size()); } -#ifdef __ANDROID__ - // Load overlays, if any - asset_path oap; - for (size_t idx = 0; mZipSet.getOverlay(ap.path, idx, &oap); idx++) { - oap.isSystemAsset = isSystemAsset; - mAssetPaths.add(oap); - } -#endif - if (mResources != NULL) { appendPathToResTable(ap, appAsLib); } @@ -493,11 +484,6 @@ FileType AssetManager::getFileType(const char* fileName) } bool AssetManager::appendPathToResTable(const asset_path& ap, bool appAsLib) const { - // skip those ap's that correspond to system overlays - if (ap.isSystemOverlay) { - return true; - } - Asset* ass = NULL; ResTable* sharedRes = NULL; bool shared = true; @@ -539,14 +525,6 @@ bool AssetManager::appendPathToResTable(const asset_path& ap, bool appAsLib) con ALOGV("Creating shared resources for %s", ap.path.string()); sharedRes = new ResTable(); sharedRes->add(ass, idmap, nextEntryIdx + 1, false); -#ifdef __ANDROID__ - 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); -#endif sharedRes = const_cast<AssetManager*>(this)-> mZipSet.setZipResourceTable(ap.path, sharedRes); } @@ -655,58 +633,6 @@ Asset* AssetManager::openIdmapLocked(const struct asset_path& ap) const return ass; } -void AssetManager::addSystemOverlays(const char* pathOverlaysList, - const String8& targetPackagePath, ResTable* sharedRes, size_t offset) const -{ - FILE* fin = fopen(pathOverlaysList, "r"); - if (fin == NULL) { - return; - } - -#ifndef _WIN32 - if (TEMP_FAILURE_RETRY(flock(fileno(fin), LOCK_SH)) != 0) { - fclose(fin); - return; - } -#endif - char buf[1024]; - while (fgets(buf, sizeof(buf), fin)) { - // format of each line: - // <path to apk><space><path to idmap><newline> - char* space = strchr(buf, ' '); - char* newline = strchr(buf, '\n'); - asset_path oap; - - if (space == NULL || newline == NULL || newline < space) { - continue; - } - - oap.path = String8(buf, space - buf); - oap.type = kFileTypeRegular; - oap.idmap = String8(space + 1, newline - space - 1); - oap.isSystemOverlay = true; - - Asset* oass = const_cast<AssetManager*>(this)-> - openNonAssetInPathLocked("resources.arsc", - Asset::ACCESS_BUFFER, - oap); - - if (oass != NULL) { - Asset* oidmap = openIdmapLocked(oap); - offset++; - sharedRes->add(oass, oidmap, offset + 1, false); - const_cast<AssetManager*>(this)->mAssetPaths.add(oap); - const_cast<AssetManager*>(this)->mZipSet.addOverlay(targetPackagePath, oap); - delete oidmap; - } - } - -#ifndef _WIN32 - TEMP_FAILURE_RETRY(flock(fileno(fin), LOCK_UN)); -#endif - fclose(fin); -} - const ResTable& AssetManager::getResources(bool required) const { const ResTable* rt = getResTable(required); @@ -1446,20 +1372,6 @@ bool AssetManager::SharedZip::isUpToDate() return mModWhen == modWhen; } -void AssetManager::SharedZip::addOverlay(const asset_path& ap) -{ - mOverlays.add(ap); -} - -bool AssetManager::SharedZip::getOverlay(size_t idx, asset_path* out) const -{ - if (idx >= mOverlays.size()) { - return false; - } - *out = mOverlays[idx]; - return true; -} - AssetManager::SharedZip::~SharedZip() { if (kIsDebug) { @@ -1578,22 +1490,6 @@ bool AssetManager::ZipSet::isUpToDate() return true; } -void AssetManager::ZipSet::addOverlay(const String8& path, const asset_path& overlay) -{ - int idx = getIndex(path); - sp<SharedZip> zip = mZipFile[idx]; - zip->addOverlay(overlay); -} - -bool AssetManager::ZipSet::getOverlay(const String8& path, size_t idx, asset_path* out) const -{ - sp<SharedZip> zip = SharedZip::get(path, false); - if (zip == NULL) { - return false; - } - return zip->getOverlay(idx, out); -} - /* * Compute the zip file's index. * |