From 76d3f1541b092a2b1dc749bea73c425553372a82 Mon Sep 17 00:00:00 2001 From: Andy Mast Date: Mon, 30 Jun 2014 17:46:34 -0700 Subject: Themes: Only reapply fonts, icons and overlays The provider and WP service can be out of sync. This is possibly by applying a theme and then separately going in and changing the WP. Prior to this patch, an updated theme would trigger all set theme elements to be reapplied, including the wallpaper of the set theme, even if the user had changed the WP to something else. The issue has been resolved by only applying theme elements which: (1) do not pose a risk of being out of sync in the provider (2) must be reapplied so as to not cause a FC. Change-Id: I00f12952a5ef040e8f368d0fade222a3e88d003e --- .../themes/provider/ThemePackageHelper.java | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java b/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java index 0accb55..feb4647 100644 --- a/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java +++ b/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java @@ -24,6 +24,8 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ThemeInfo; import android.content.pm.ThemeUtils; import android.content.res.AssetManager; +import android.content.res.Configuration; +import android.content.res.ThemeConfig; import android.content.res.ThemeManager; import android.database.Cursor; import android.provider.ThemesContract; @@ -350,20 +352,24 @@ public class ThemePackageHelper { } private static void reapplyInstalledComponentsForTheme(Context context, String pkgName) { + Configuration config = context.getResources().getConfiguration(); + if (config == null || config.themeConfig == null) return; + List reApply = new LinkedList(); // components to re-apply - Cursor mixnmatch = context.getContentResolver().query(MixnMatchColumns.CONTENT_URI, - null, null, null, null); - while (mixnmatch.moveToNext()) { - String mixnmatchKey = mixnmatch.getString(mixnmatch - .getColumnIndex(MixnMatchColumns.COL_KEY)); - String component = ThemesContract.MixnMatchColumns - .mixNMatchKeyToComponent(mixnmatchKey); - String pkg = mixnmatch.getString( - mixnmatch.getColumnIndex(MixnMatchColumns.COL_VALUE)); - if (pkgName.equals(pkg)) { - reApply.add(component); - } + // Other packages such as wallpaper can be changed outside of themes + // and are not tracked well by the provider. We only care to apply resources that may crash + // the system if they are not reapplied. + ThemeConfig themeConfig = config.themeConfig; + if (pkgName.equals(themeConfig.getFontPkgName())) { + reApply.add(ThemesColumns.MODIFIES_FONTS); + } + if (pkgName.equals(themeConfig.getIconPackPkgName())) { + reApply.add(ThemesColumns.MODIFIES_ICONS); } + if (pkgName.equals(themeConfig.getOverlayPkgName())) { + reApply.add(ThemesColumns.MODIFIES_OVERLAYS); + } + ThemeManager manager = (ThemeManager) context.getSystemService(Context.THEME_SERVICE); manager.requestThemeChange(pkgName, reApply); } -- cgit v1.2.3