diff options
Diffstat (limited to 'core/java/android/app/ApplicationPackageManager.java')
| -rw-r--r-- | core/java/android/app/ApplicationPackageManager.java | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index 432e9b1..ab2739d 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -51,6 +51,7 @@ import android.net.Uri; import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; +import android.util.ArrayMap; import android.util.Log; import android.view.Display; @@ -859,26 +860,20 @@ final class ApplicationPackageManager extends PackageManager { boolean needCleanup = false; for (String ssp : pkgList) { synchronized (sSync) { - if (sIconCache.size() > 0) { - Iterator<ResourceName> it = sIconCache.keySet().iterator(); - while (it.hasNext()) { - ResourceName nm = it.next(); - if (nm.packageName.equals(ssp)) { - //Log.i(TAG, "Removing cached drawable for " + nm); - it.remove(); - needCleanup = true; - } + for (int i=sIconCache.size()-1; i>=0; i--) { + ResourceName nm = sIconCache.keyAt(i); + if (nm.packageName.equals(ssp)) { + //Log.i(TAG, "Removing cached drawable for " + nm); + sIconCache.removeAt(i); + needCleanup = true; } } - if (sStringCache.size() > 0) { - Iterator<ResourceName> it = sStringCache.keySet().iterator(); - while (it.hasNext()) { - ResourceName nm = it.next(); - if (nm.packageName.equals(ssp)) { - //Log.i(TAG, "Removing cached string for " + nm); - it.remove(); - needCleanup = true; - } + for (int i=sStringCache.size()-1; i>=0; i--) { + ResourceName nm = sStringCache.keyAt(i); + if (nm.packageName.equals(ssp)) { + //Log.i(TAG, "Removing cached string for " + nm); + sStringCache.removeAt(i); + needCleanup = true; } } } @@ -1335,8 +1330,8 @@ final class ApplicationPackageManager extends PackageManager { private final IPackageManager mPM; private static final Object sSync = new Object(); - private static HashMap<ResourceName, WeakReference<Drawable.ConstantState>> sIconCache - = new HashMap<ResourceName, WeakReference<Drawable.ConstantState>>(); - private static HashMap<ResourceName, WeakReference<CharSequence>> sStringCache - = new HashMap<ResourceName, WeakReference<CharSequence>>(); + private static ArrayMap<ResourceName, WeakReference<Drawable.ConstantState>> sIconCache + = new ArrayMap<ResourceName, WeakReference<Drawable.ConstantState>>(); + private static ArrayMap<ResourceName, WeakReference<CharSequence>> sStringCache + = new ArrayMap<ResourceName, WeakReference<CharSequence>>(); } |
