From 6542c71b08808a09d292b65e94c1d00d3e8d231b Mon Sep 17 00:00:00 2001 From: d34d Date: Wed, 27 Jan 2016 17:41:24 -0800 Subject: Themes: Process applied themes before boot finishes Because apps on /system can change during a reboot, think OTA, we need to make sure the currently applied theme(s) are processed before boot completes, otherwise bad things will happen. Change-Id: Ib286af2d5578723265b3df3936d9fe5c8665a9da TICKET: CYNGNOS-1726 --- .../android/server/pm/PackageManagerService.java | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index f69ed7d..8abb9f0 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -15386,6 +15386,9 @@ public class PackageManagerService extends IPackageManager.Stub { int[] grantPermissionsUserIds = EMPTY_INT_ARRAY; synchronized (mPackages) { + // process applied themes so their resources are up to date and ready use + processAppliedThemes(); + // Verify that all of the preferred activity components actually // exist. It is possible for applications to be updated and at // that point remove a previously declared activity component that @@ -17749,6 +17752,44 @@ public class PackageManagerService extends IPackageManager.Stub { } } + /** + * Makes sure resources and idmaps for themes that are applied are up to date. This should only + * impact boots when something on /system has changed. + */ + private void processAppliedThemes() { + ThemeConfig themeConfig = ThemeConfig.getBootTheme(mContext.getContentResolver()); + if (themeConfig == null) return; + + // gather up all the themes applied and then process them + Set themesToProcess = new ArraySet(); + // process theme set for icons + if (themeConfig.getIconPackPkgName() != null) { + themesToProcess.add(themeConfig.getIconPackPkgName()); + } + // process theme set for non-app specific overlays + if (themeConfig.getOverlayPkgName() != null) { + themesToProcess.add(themeConfig.getOverlayPkgName()); + } + // process theme set for status bar + if (themeConfig.getOverlayForStatusBar() != null) { + themesToProcess.add(themeConfig.getOverlayForStatusBar()); + } + // process theme set for navigation bar + if (themeConfig.getOverlayForNavBar() != null) { + themesToProcess.add(themeConfig.getOverlayForNavBar()); + } + // process themes set for specific apps + Map appThemesMap = themeConfig.getAppThemes(); + for (String themePkgName : appThemesMap.keySet()) { + themesToProcess.add(themePkgName); + } + + // now start the processing + for (String themePkgName : themesToProcess) { + processThemeResources(themePkgName); + } + } + private void createAndSetCustomResources() { Configuration tempConfiguration = new Configuration(); String mcc = SystemProperties.get("ro.prebundled.mcc"); -- cgit v1.1