Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7be76f4e authored by Andy Mast's avatar Andy Mast
Browse files

Cleanup theme assets when done with them

Before this patch if phone was left on long enough it would reboot
when a theme was applied due to files being left open.

Change-Id: I4c242249fcf6e8097789c3dd6690104296485784
parent cc13e509
Loading
Loading
Loading
Loading
+18 −10
Original line number Diff line number Diff line
@@ -936,6 +936,7 @@ bool AssetManager::updateResTableFromAssetPath(ResTable *rt, const asset_path& a
{
    Asset* ass = NULL;
    size_t cookiePos = (size_t)cookie;
    bool shared = true;

    assert(dirName != NULL);
    assert(ap != NULL);
@@ -946,6 +947,7 @@ bool AssetManager::updateResTableFromAssetPath(ResTable *rt, const asset_path& a
        // Res file is outside APK
        ass = const_cast<AssetManager*>(this)->
              openAssetFromFileLocked(ap.resfilePath, Asset::ACCESS_BUFFER);
        shared = false;
    } else if (ap.type != kFileTypeDirectory) {
        ass = const_cast<AssetManager*>(this)->
            mZipSet.getZipResourceTableAsset(ap.path);
@@ -965,7 +967,13 @@ bool AssetManager::updateResTableFromAssetPath(ResTable *rt, const asset_path& a
    status_t error = NO_ERROR;
    if (ass != NULL) {
        Asset* oidmap = openIdmapLocked(ap);
         error = rt->add(ass, cookie, false, oidmap);
        error = rt->add(ass, cookie, !shared, oidmap);
        if (!shared) {
            delete ass;
        }
        if (oidmap != NULL) {
            delete oidmap;
        }
    } else {
        ALOGW("Unable to load asset %s, ResTable not updated", ap.path.string());
    }