summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClark Scheff <clark@cyngn.com>2014-06-25 13:46:47 -0700
committerClark Scheff <clark@cyngn.com>2014-06-26 09:37:57 -0700
commit92f77e77e097e59f9ec8d7bc64324f1987230af6 (patch)
tree805e97d716ef4aa1b25bcb5a2c39a65db42a626f
parent66f586f8535acf37e741e2c116b2c5645b6ce55c (diff)
downloadandroid_packages_providers_ThemesProvider-92f77e77e097e59f9ec8d7bc64324f1987230af6.tar.gz
android_packages_providers_ThemesProvider-92f77e77e097e59f9ec8d7bc64324f1987230af6.tar.bz2
android_packages_providers_ThemesProvider-92f77e77e097e59f9ec8d7bc64324f1987230af6.zip
Reapply theme components in a runnable.
We need to give other apps a chance to finish processing the ACTION_PACKAGE_REPLACED before reapplying the updated theme components. An example of this behavior can be seen when a legacy icon pack is applied and is updated. Some Google services, such as google play, FC when this happens. Change-Id: If526223e6d318b4240fa765abb53dbe61f9ce746
-rw-r--r--src/org/cyanogenmod/themes/provider/ThemePackageHelper.java21
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);