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

Commit 81f1abbd authored by d34d's avatar d34d Committed by Gerrit Code Review
Browse files

Themes: Don't add common assets if files cannot be accessed

If resApkPath does not exist, asset manaager will load the resources
from the theme's apk which end up overriding resources in the 0x7f
package id.  This causes apps, such as SystemUI, to crash endlessly.

The correct behavior is to not add common overlay assets if the
files that are being passed in as paths cannot be accessed.  The
same behavior is already used in AssetManager::addOverlayPath()

Change-Id: If5e90baeda5f07973f268060dcb6d73dae657603
parent e9468390
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -361,8 +361,8 @@ bool AssetManager::addCommonOverlayPath(const String8& themePackagePath, int32_t
{
    AutoMutex _l(mLock);

    ALOGV("targetApkPath: %s, resArscPath %s, resApkPath %s, prefixPath %s",
            themePackagePath.string());
    ALOGV("targetApkPath: %s, resApkPath %s, prefixPath %s",
            themePackagePath.string(), resApkPath.string(), prefixPath.string());

    // Skip if we have it already.
    for (size_t i = 0; i < mAssetPaths.size(); ++i) {
@@ -372,6 +372,16 @@ bool AssetManager::addCommonOverlayPath(const String8& themePackagePath, int32_t
        }
    }

    if (access(themePackagePath.string(), R_OK) != 0) {
        ALOGW("failed to access file %s: %s\n", themePackagePath.string(), strerror(errno));
        return false;
    }

    if (access(resApkPath.string(), R_OK) != 0) {
        ALOGW("failed to access file %s: %s\n", resApkPath.string(), strerror(errno));
        return false;
    }

    asset_path oap;
    oap.path = themePackagePath;
    oap.type = ::getFileType(themePackagePath.string());