summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Mast <andy@cyngn.com>2014-12-01 14:58:09 -0800
committerAndy Mast <andy@cyngn.com>2014-12-02 01:45:29 +0000
commit5149ef3803dd5ff6ba9c28161a7d7b0c8b227879 (patch)
tree7d5de096411eed516b9b7c64c63262976615e909
parent62290187159fd671fab62134be93d80d722e646f (diff)
downloadandroid_frameworks_base-5149ef3803dd5ff6ba9c28161a7d7b0c8b227879.tar.gz
android_frameworks_base-5149ef3803dd5ff6ba9c28161a7d7b0c8b227879.tar.bz2
android_frameworks_base-5149ef3803dd5ff6ba9c28161a7d7b0c8b227879.zip
Themes: Remove an app's icons from cache when installing
If an app is being updated then its icons will exist in cache. Go ahead and delete them so that they can be recreated. Change-Id: If0ee4388efd4aa146ebcdc46b1b0742f0852bad3 (cherry picked from commit 91cabc9b9006e8c2f06aa6cbbc237c4ca585e49d)
-rw-r--r--core/java/android/app/IconPackHelper.java18
-rw-r--r--services/java/com/android/server/pm/PackageManagerService.java12
2 files changed, 29 insertions, 1 deletions
diff --git a/core/java/android/app/IconPackHelper.java b/core/java/android/app/IconPackHelper.java
index 321a1d496c4..ceea8987c24 100644
--- a/core/java/android/app/IconPackHelper.java
+++ b/core/java/android/app/IconPackHelper.java
@@ -16,6 +16,7 @@
package android.app;
import java.io.File;
+import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -603,6 +604,23 @@ public class IconPackHelper {
getCachedIconName(pkgName, resId, density));
}
+
+ // Returns paths for all densities
+ public static String[] getCachedIconPaths(String pkgName) {
+ File iconCache = new File(ThemeUtils.SYSTEM_THEME_ICON_CACHE_DIR);
+ final String prefix = String.format("%s", pkgName);
+
+ FilenameFilter filter = new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String filename) {
+ return filename.startsWith(prefix);
+ }
+ };
+
+ String[] validPaths = iconCache.list(filter);
+ return validPaths != null ? validPaths : new String[0];
+ }
+
private static String getCachedIconName(String pkgName, int resId, int density) {
return String.format("%s_%08x_%d.png", pkgName, resId, density);
}
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index 1667ddea7f6..b7dd94da3f6 100644
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -5178,6 +5178,17 @@ public class PackageManagerService extends IPackageManager.Stub {
pkg.applicationInfo.themedIcon = id;
}
+ // Clear out any icon in the cache so it can be recomopsed if needed
+ final boolean isBootScan = (scanMode & SCAN_BOOTING) != 0;
+ if (!isBootScan) {
+ String[] iconPaths =
+ IconPackHelper.IconCustomizer.getCachedIconPaths(pkg.packageName);
+ for(String iconPath : iconPaths) {
+ File file = new File(ThemeUtils.SYSTEM_THEME_ICON_CACHE_DIR, iconPath);
+ file.delete();
+ }
+ }
+
// Add the new setting to mPackages
mPackages.put(pkg.applicationInfo.packageName, pkg);
// Make sure we don't accidentally delete its data.
@@ -5495,7 +5506,6 @@ public class PackageManagerService extends IPackageManager.Stub {
pkgSetting.setTimeStamp(scanFileTime);
- final boolean isBootScan = (scanMode & SCAN_BOOTING) != 0;
// Generate resources & idmaps if pkg is NOT a theme
// We must compile resources here because during the initial boot process we may get
// here before a default theme has had a chance to compile its resources