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

Commit 0b02a881 authored by d34d's avatar d34d
Browse files

CM11 Themes: Fix how common resources are found

During the boot process, application info may not be fully
available and createPackageContext can throw a null pointer which
causes a theme's resource-cache to be cleared.  If this theme is
in /system/app or /system/priv-app the theme will still be installed
but applying it will result in styles not being applied.

Change-Id: I4094bdd923edc1d829024404a4ce1b72709bd4f1
parent dbd3649b
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -5407,6 +5407,7 @@ public class PackageManagerService extends IPackageManager.Stub {
                    insertIntoOverlayMap(target, pkg);
                    generateIdmap(target, pkg);
                } catch(Exception e) {
                    Log.w(TAG, "Unable to process theme " + pkgName, e);
                    mLastScanError = PackageManager.INSTALL_FAILED_INTERNAL_ERROR;
                    uninstallThemeForAllApps(pkg);
                    return null;
@@ -5484,12 +5485,10 @@ public class PackageManagerService extends IPackageManager.Stub {
    private boolean hasCommonResources(PackageParser.Package pkg) throws Exception {
        boolean ret = false;
        // check if assets/overlays/common exists in this theme
        Context themeContext = mContext.createPackageContext(pkg.packageName, 0);
        if (themeContext != null) {
            AssetManager assets = themeContext.getAssets();
        AssetManager assets = new AssetManager();
        assets.addAssetPath(pkg.mScanPath);
        String[] common = assets.list("overlays/common");
        if (common != null && common.length > 0) ret = true;
        }
        return ret;
    }