Fix race in LauncherModel that causes it to show duplicate icons.

Change-Id: I78130d6f237f476bc33a4718ca5ef245fe502857
This commit is contained in:
Joe Onorato
2010-04-20 15:43:37 -04:00
parent cbe7f20ad7
commit d65d08e709
3 changed files with 101 additions and 59 deletions

View File

@@ -57,8 +57,13 @@ class AllAppsList {
/**
* Add the supplied ApplicationInfo objects to the list, and enqueue it into the
* list to broadcast when notify() is called.
*
* If the app is already in the list, doesn't add it.
*/
public void add(ApplicationInfo info) {
if (findActivity(data, info.componentName)) {
return;
}
data.add(info);
added.add(info);
}
@@ -189,6 +194,20 @@ class AllAppsList {
return false;
}
/**
* Returns whether <em>apps</em> contains <em>component</em>.
*/
private static boolean findActivity(ArrayList<ApplicationInfo> apps, ComponentName component) {
final int N = apps.size();
for (int i=0; i<N; i++) {
final ApplicationInfo info = apps.get(i);
if (info.componentName.equals(component)) {
return true;
}
}
return false;
}
/**
* Find an ApplicationInfo object for the given packageName and className.
*/