diff options
Diffstat (limited to 'src/org/cyanogenmod/themes')
-rw-r--r-- | src/org/cyanogenmod/themes/provider/ThemePackageHelper.java | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java b/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java index d602315..0406178 100644 --- a/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java +++ b/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java @@ -26,6 +26,8 @@ import android.content.pm.ThemeUtils; import android.content.res.AssetManager; import android.content.res.ThemeManager; import android.database.Cursor; +import android.os.Handler; +import android.os.Looper; import android.provider.ThemesContract; import android.provider.ThemesContract.MixnMatchColumns; import android.provider.ThemesContract.ThemesColumns; @@ -143,7 +145,8 @@ public class ThemePackageHelper { context.getContentResolver().insert(ThemesColumns.CONTENT_URI, values); } - public static void updatePackage(Context context, String pkgName) throws NameNotFoundException { + public static void updatePackage(final Context context, final String pkgName) + throws NameNotFoundException { if (HOLO_DEFAULT.equals(pkgName)) { updateHoloPackageInternal(context); } else { @@ -157,8 +160,17 @@ public class ThemePackageHelper { updateLegacyIconPackInternal(context, pi, capabilities); } - // We should reapply any components that are currently applied for this theme. - reapplyInstalledComponentsForTheme(context, pkgName); + // Calling reapplyInstalledComponentsForTheme in a runnable posted to a handler gives + // other processes enough time to process the ACTION_PACKAGE_REPLACED before the theme + // change is completed and restarts apps due to config change. + Handler h = new Handler(Looper.getMainLooper()); + h.postDelayed(new Runnable() { + @Override + public void run() { + // We should reapply any components that are currently applied for this theme. + reapplyInstalledComponentsForTheme(context, pkgName); + } + }, 500); } } @@ -226,9 +238,6 @@ public class ThemePackageHelper { values.put(ThemesColumns.DATE_CREATED, System.currentTimeMillis()); values.put(ThemesColumns.LAST_UPDATE_TIME, pi.lastUpdateTime); - // Insert theme capabilities - insertCapabilities(capabilities, values); - String where = ThemesColumns.PKG_NAME + "=?"; String[] args = { pi.packageName }; context.getContentResolver().update(ThemesColumns.CONTENT_URI, values, where, args); |