Fixing issue where updating the visibility of one application can trigger all icons to disappear. (Bug 8757421)
- Also queueing bindComponentsRemoved() and bindPackagesUpdated() to wait for resume (Bug 8594153)
Change-Id: I44028fe79f6fa6bcd6b829e36f3f5b9ed756dc4d
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index 99808a6..00770b2 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -53,6 +53,7 @@
import java.lang.ref.WeakReference;
import java.net.URISyntaxException;
import java.text.Collator;
+import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -156,7 +157,9 @@
public void bindAllApplications(ArrayList<ApplicationInfo> apps);
public void bindAppsAdded(ArrayList<ApplicationInfo> apps);
public void bindAppsUpdated(ArrayList<ApplicationInfo> apps);
- public void bindAppsRemoved(ArrayList<String> packageNames, boolean permanent);
+ public void bindComponentsRemoved(ArrayList<String> packageNames,
+ ArrayList<ApplicationInfo> appInfos,
+ boolean matchPackageNamesOnly);
public void bindPackagesUpdated();
public boolean isAllAppsVisible();
public boolean isAllAppsButtonRank(int rank);
@@ -2009,6 +2012,7 @@
ArrayList<ApplicationInfo> added = null;
ArrayList<ApplicationInfo> modified = null;
+ final ArrayList<ApplicationInfo> removedApps = new ArrayList<ApplicationInfo>();
if (mBgAllAppsList.added.size() > 0) {
added = new ArrayList<ApplicationInfo>(mBgAllAppsList.added);
@@ -2018,16 +2022,9 @@
modified = new ArrayList<ApplicationInfo>(mBgAllAppsList.modified);
mBgAllAppsList.modified.clear();
}
- // We may be removing packages that have no associated launcher application, so we
- // pass through the removed package names directly.
- // NOTE: We flush the icon cache aggressively in removePackage() above.
- final ArrayList<String> removedPackageNames = new ArrayList<String>();
if (mBgAllAppsList.removed.size() > 0) {
+ removedApps.addAll(mBgAllAppsList.removed);
mBgAllAppsList.removed.clear();
-
- for (int i = 0; i < N; ++i) {
- removedPackageNames.add(packages[i]);
- }
}
final Callbacks callbacks = mCallbacks != null ? mCallbacks.get() : null;
@@ -2058,13 +2055,19 @@
}
});
}
- if (!removedPackageNames.isEmpty()) {
- final boolean permanent = mOp != OP_UNAVAILABLE;
+ // If a package has been removed, or an app has been removed as a result of
+ // an update (for example), make the removed callback.
+ if (mOp == OP_REMOVE || !removedApps.isEmpty()) {
+ final boolean permanent = (mOp == OP_REMOVE);
+ final ArrayList<String> removedPackageNames =
+ new ArrayList<String>(Arrays.asList(packages));
+
mHandler.post(new Runnable() {
public void run() {
Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
if (callbacks == cb && cb != null) {
- callbacks.bindAppsRemoved(removedPackageNames, permanent);
+ callbacks.bindComponentsRemoved(removedPackageNames,
+ removedApps, permanent);
}
}
});