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

Commit 4e18a400 authored by d34d's avatar d34d Committed by Clark Scheff
Browse files

CmRes: Attach themed cmsdk resources to assets

The cmsdk is beginning to contain some themable assets, like the
quick settings tiles for LiveDisplay and Themes so we need to attach
themed resources for the cmsdk in order for those themed resources
to be picked up.

Change-Id: I4f64d53d82c9edafbe624c3b2eafcda7332587fb
TICKET: CYNGNOS-2723
(cherry picked from commit fe5fb7b2)
parent 5945f0fe
Loading
Loading
Loading
Loading
+23 −0
Original line number Original line Diff line number Diff line
@@ -576,6 +576,7 @@ public class ResourcesManager {
        PackageInfo piTheme = null;
        PackageInfo piTheme = null;
        PackageInfo piTarget = null;
        PackageInfo piTarget = null;
        PackageInfo piAndroid = null;
        PackageInfo piAndroid = null;
        PackageInfo piCm = null;


        // Some apps run in process of another app (eg keyguard/systemUI) so we must get the
        // Some apps run in process of another app (eg keyguard/systemUI) so we must get the
        // package name from the res tables. The 0th base package name will be the android group.
        // package name from the res tables. The 0th base package name will be the android group.
@@ -609,16 +610,20 @@ public class ResourcesManager {
            }
            }
            piAndroid = getPackageManager().getPackageInfo("android", 0,
            piAndroid = getPackageManager().getPackageInfo("android", 0,
                    UserHandle.getCallingUserId());
                    UserHandle.getCallingUserId());
            piCm = getPackageManager().getPackageInfo("cyanogenmod.platform", 0,
                    UserHandle.getCallingUserId());
        } catch (RemoteException e) {
        } catch (RemoteException e) {
        }
        }


        if (piTheme == null || piTheme.applicationInfo == null ||
        if (piTheme == null || piTheme.applicationInfo == null ||
                    piTarget == null || piTarget.applicationInfo == null ||
                    piTarget == null || piTarget.applicationInfo == null ||
                    piAndroid == null || piAndroid.applicationInfo == null ||
                    piAndroid == null || piAndroid.applicationInfo == null ||
                    piCm == null || piCm.applicationInfo == null ||
                    piTheme.mOverlayTargets == null) {
                    piTheme.mOverlayTargets == null) {
            return false;
            return false;
        }
        }


        // Attach themed resources for target
        String themePackageName = piTheme.packageName;
        String themePackageName = piTheme.packageName;
        String themePath = piTheme.applicationInfo.publicSourceDir;
        String themePath = piTheme.applicationInfo.publicSourceDir;
        if (!piTarget.isThemeApk && piTheme.mOverlayTargets.contains(basePackageName)) {
        if (!piTarget.isThemeApk && piTheme.mOverlayTargets.contains(basePackageName)) {
@@ -638,6 +643,24 @@ public class ResourcesManager {
            }
            }
        }
        }


        // Attach themed resources for cmsdk
        if (!piTarget.isThemeApk && !piCm.packageName.equals(basePackageName) &&
                piTheme.mOverlayTargets.contains(piCm.packageName)) {
            String resCachePath= ThemeUtils.getTargetCacheDir(piCm.packageName,
                    piTheme.packageName);
            String prefixPath = ThemeUtils.getOverlayPathToTarget(piCm.packageName);
            String targetPackagePath = piCm.applicationInfo.publicSourceDir;
            String resApkPath = resCachePath + "/resources.apk";
            String idmapPath = ThemeUtils.getIdmapPath(piCm.packageName, piTheme.packageName);
            int cookie = assets.addOverlayPath(idmapPath, themePath,
                    resApkPath, targetPackagePath, prefixPath);
            if (cookie != 0) {
                assets.setThemePackageName(themePackageName);
                assets.addThemeCookie(cookie);
            }
        }

        // Attach themed resources for android framework
        if (!piTarget.isThemeApk && !"android".equals(basePackageName) &&
        if (!piTarget.isThemeApk && !"android".equals(basePackageName) &&
                piTheme.mOverlayTargets.contains("android")) {
                piTheme.mOverlayTargets.contains("android")) {
            String resCachePath= ThemeUtils.getTargetCacheDir(piAndroid.packageName,
            String resCachePath= ThemeUtils.getTargetCacheDir(piAndroid.packageName,