summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndy Mast <andy@cyngn.com>2014-06-30 17:46:34 -0700
committerAndy Mast <andy@cyngn.com>2014-07-07 13:59:23 -0700
commit76d3f1541b092a2b1dc749bea73c425553372a82 (patch)
tree77b6f74fac233a3974c35c7c8ff8351f7fd23204 /src
parent3378148542cd387b4559cb51d3a7c025fa24a0b7 (diff)
downloadandroid_packages_providers_ThemesProvider-76d3f1541b092a2b1dc749bea73c425553372a82.zip
android_packages_providers_ThemesProvider-76d3f1541b092a2b1dc749bea73c425553372a82.tar.gz
android_packages_providers_ThemesProvider-76d3f1541b092a2b1dc749bea73c425553372a82.tar.bz2
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
Diffstat (limited to 'src')
-rw-r--r--src/org/cyanogenmod/themes/provider/ThemePackageHelper.java30
1 files changed, 18 insertions, 12 deletions
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<String> reApply = new LinkedList<String>(); // 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);
}