summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoe Onorato <joeo@android.com>2010-05-04 12:12:41 -0700
committerJoe Onorato <joeo@android.com>2010-05-04 14:43:16 -0700
commitfad1fb5ed46473af0a6da4324e9e3fa45bd9f6e8 (patch)
tree19b5342f3278f6005e948e156166739a38335038 /src
parentc15bd51dbfb476503922791b109a78216afad12e (diff)
downloadandroid_packages_apps_Trebuchet-fad1fb5ed46473af0a6da4324e9e3fa45bd9f6e8.tar.gz
android_packages_apps_Trebuchet-fad1fb5ed46473af0a6da4324e9e3fa45bd9f6e8.tar.bz2
android_packages_apps_Trebuchet-fad1fb5ed46473af0a6da4324e9e3fa45bd9f6e8.zip
Tweak locking in launcher so mLock isn't held while the slow stuff happens.
Bug 2652948 Change-Id: I9d386395278830ead5deda17b8b09e0dcfeff989
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/IconCache.java28
-rw-r--r--src/com/android/launcher2/LauncherModel.java5
2 files changed, 19 insertions, 14 deletions
diff --git a/src/com/android/launcher2/IconCache.java b/src/com/android/launcher2/IconCache.java
index 04762e944..4bb7d08c0 100644
--- a/src/com/android/launcher2/IconCache.java
+++ b/src/com/android/launcher2/IconCache.java
@@ -100,24 +100,28 @@ public class IconCache {
}
public Bitmap getIcon(Intent intent) {
- final ResolveInfo resolveInfo = mPackageManager.resolveActivity(intent, 0);
- ComponentName component = intent.getComponent();
+ synchronized (mCache) {
+ final ResolveInfo resolveInfo = mPackageManager.resolveActivity(intent, 0);
+ ComponentName component = intent.getComponent();
- if (resolveInfo == null || component == null) {
- return mDefaultIcon;
- }
+ if (resolveInfo == null || component == null) {
+ return mDefaultIcon;
+ }
- CacheEntry entry = cacheLocked(component, resolveInfo);
- return entry.icon;
+ CacheEntry entry = cacheLocked(component, resolveInfo);
+ return entry.icon;
+ }
}
public Bitmap getIcon(ComponentName component, ResolveInfo resolveInfo) {
- if (resolveInfo == null || component == null) {
- return null;
- }
+ synchronized (mCache) {
+ if (resolveInfo == null || component == null) {
+ return null;
+ }
- CacheEntry entry = cacheLocked(component, resolveInfo);
- return entry.icon;
+ CacheEntry entry = cacheLocked(component, resolveInfo);
+ return entry.icon;
+ }
}
private CacheEntry cacheLocked(ComponentName componentName, ResolveInfo info) {
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index d5b585900..a8672008c 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -73,6 +73,7 @@ public class LauncherModel extends BroadcastReceiver {
private boolean mBeforeFirstLoad = true; // only access this from main thread
private WeakReference<Callbacks> mCallbacks;
+ private final Object mAllAppsListLock = new Object();
private AllAppsList mAllAppsList;
private IconCache mIconCache;
@@ -306,7 +307,7 @@ public class LauncherModel extends BroadcastReceiver {
ArrayList<ApplicationInfo> removed = null;
ArrayList<ApplicationInfo> modified = null;
- synchronized (mLock) {
+ synchronized (mAllAppsListLock) {
if (mBeforeFirstLoad) {
// If we haven't even loaded yet, don't bother, since we'll just pick
// up the changes.
@@ -1047,7 +1048,7 @@ public class LauncherModel extends BroadcastReceiver {
int i=0;
int batchSize = -1;
while (i < N && !mStopped) {
- synchronized (mLock) {
+ synchronized (mAllAppsListLock) {
if (i == 0) {
// This needs to happen inside the same lock block as when we
// prepare the first batch for bindAllApplications. Otherwise