summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2013-05-01 16:53:33 -0700
committerSteve Kondik <shade@chemlab.org>2013-08-17 02:35:26 -0700
commit84725ce59c6659758fa568f0275686781280116d (patch)
tree794967fdde21acc35e74d305cc361f83557fe5b3 /src/com
parent4747cf1a489aefa8c7f81c2d0b9ffe294351c398 (diff)
downloadandroid_packages_apps_Trebuchet-84725ce59c6659758fa568f0275686781280116d.tar.gz
android_packages_apps_Trebuchet-84725ce59c6659758fa568f0275686781280116d.tar.bz2
android_packages_apps_Trebuchet-84725ce59c6659758fa568f0275686781280116d.zip
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
Diffstat (limited to 'src/com')
-rw-r--r--src/com/cyanogenmod/trebuchet/ApplicationInfo.java6
-rwxr-xr-xsrc/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java24
-rw-r--r--src/com/cyanogenmod/trebuchet/DragController.java9
-rw-r--r--src/com/cyanogenmod/trebuchet/Launcher.java28
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherModel.java27
-rw-r--r--src/com/cyanogenmod/trebuchet/ShortcutInfo.java6
-rw-r--r--src/com/cyanogenmod/trebuchet/Workspace.java73
7 files changed, 109 insertions, 64 deletions
diff --git a/src/com/cyanogenmod/trebuchet/ApplicationInfo.java b/src/com/cyanogenmod/trebuchet/ApplicationInfo.java
index e5a45872b..e7cc13e39 100644
--- a/src/com/cyanogenmod/trebuchet/ApplicationInfo.java
+++ b/src/com/cyanogenmod/trebuchet/ApplicationInfo.java
@@ -97,12 +97,6 @@ class ApplicationInfo extends ItemInfo {
firstInstallTime = info.firstInstallTime;
}
- /** Returns the package name that the shortcut's intent will resolve to, or an empty string if
- * none exists. */
- String getPackageName() {
- return super.getPackageName(intent);
- }
-
/**
* Creates the application intent based on a component name and various launch flags.
* Sets {@link #itemType} to {@link LauncherSettings.BaseLauncherColumns#ITEM_TYPE_APPLICATION}.
diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
index 6596a7933..6fe2db96f 100755
--- a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
@@ -2186,16 +2186,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
return -1;
}
- private int findAppByPackage(List<ApplicationInfo> list, String packageName) {
- int length = list.size();
- for (int i = 0; i < length; ++i) {
- ApplicationInfo info = list.get(i);
- if (ItemInfo.getPackageName(info.intent).equals(packageName)) {
- return i;
- }
- }
- return -1;
- }
private void removeAppsWithoutInvalidate(ArrayList<ApplicationInfo> list) {
// loop through all the apps and remove apps that have the same component
for (ApplicationInfo info : list) {
@@ -2205,18 +2195,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
}
- private void removeAppsWithPackageNameWithoutInvalidate(ArrayList<String> packageNames) {
- // loop through all the package names and remove apps that have the same package name
- for (String pn : packageNames) {
- int removeIndex = findAppByPackage(mApps, pn);
- while (removeIndex > -1) {
- mApps.remove(removeIndex);
- removeIndex = findAppByPackage(mApps, pn);
- }
- }
- }
- public void removeApps(ArrayList<String> packageNames) {
- removeAppsWithPackageNameWithoutInvalidate(packageNames);
+ public void removeApps(ArrayList<ApplicationInfo> appInfos) {
+ removeAppsWithoutInvalidate(appInfos);
filterAppsWithoutInvalidate();
updatePageCountsAndInvalidateData();
}
diff --git a/src/com/cyanogenmod/trebuchet/DragController.java b/src/com/cyanogenmod/trebuchet/DragController.java
index f7e45fad3..45b22c2d7 100644
--- a/src/com/cyanogenmod/trebuchet/DragController.java
+++ b/src/com/cyanogenmod/trebuchet/DragController.java
@@ -326,18 +326,19 @@ public class DragController {
}
endDrag();
}
- public void onAppsRemoved(ArrayList<String> packageNames) {
+ public void onAppsRemoved(ArrayList<ApplicationInfo> appInfos) {
// Cancel the current drag if we are removing an app that we are dragging
if (mDragObject != null) {
Object rawDragInfo = mDragObject.dragInfo;
if (rawDragInfo instanceof ShortcutInfo) {
ShortcutInfo dragInfo = (ShortcutInfo) rawDragInfo;
- for (String pn : packageNames) {
+ for (ApplicationInfo info : appInfos) {
// Added null checks to prevent NPE we've seen in the wild
if (dragInfo != null &&
dragInfo.intent != null) {
- boolean isSamePackage = dragInfo.getPackageName().equals(pn);
- if (isSamePackage) {
+ boolean isSameComponent =
+ dragInfo.intent.getComponent().equals(info.componentName);
+ if (isSameComponent) {
cancelDrag();
return;
}
diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java
index 3901fec1a..3cdc61df1 100644
--- a/src/com/cyanogenmod/trebuchet/Launcher.java
+++ b/src/com/cyanogenmod/trebuchet/Launcher.java
@@ -4151,21 +4151,37 @@ public final class Launcher extends Activity
}
/**
- * A package was uninstalled.
+ * A package was uninstalled. We take both the super set of packageNames
+ * in addition to specific applications to remove, the reason being that
+ * this can be called when a package is updated as well. In that scenario,
+ * we only remove specific components from the workspace, where as
+ * package-removal should clear all items by package name.
*
* Implementation of the method from LauncherModel.Callbacks.
*/
- public void bindAppsRemoved(ArrayList<String> packageNames, boolean permanent) {
- if (permanent) {
- mWorkspace.removeItems(packageNames);
+ public void bindComponentsRemoved(final ArrayList<String> packageNames,
+ final ArrayList<ApplicationInfo> appInfos,
+ final boolean matchPackageNamesOnly) {
+ if (waitUntilResume(new Runnable() {
+ public void run() {
+ bindComponentsRemoved(packageNames, appInfos, matchPackageNamesOnly);
+ }
+ })) {
+ return;
+ }
+
+ if (matchPackageNamesOnly) {
+ mWorkspace.removeItemsByPackageName(packageNames);
+ } else {
+ mWorkspace.removeItemsByApplicationInfo(appInfos);
}
if (mAppsCustomizeContent != null) {
- mAppsCustomizeContent.removeApps(packageNames);
+ mAppsCustomizeContent.removeApps(appInfos);
}
// Notify the drag controller
- mDragController.onAppsRemoved(packageNames);
+ mDragController.onAppsRemoved(appInfos);
}
/**
diff --git a/src/com/cyanogenmod/trebuchet/LauncherModel.java b/src/com/cyanogenmod/trebuchet/LauncherModel.java
index 94829242a..91f0e794e 100644
--- a/src/com/cyanogenmod/trebuchet/LauncherModel.java
+++ b/src/com/cyanogenmod/trebuchet/LauncherModel.java
@@ -51,6 +51,7 @@ import com.cyanogenmod.trebuchet.preference.PreferencesProvider;
import java.lang.ref.WeakReference;
import java.net.URISyntaxException;
import java.text.Collator;
+import java.util.Arrays;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -155,7 +156,9 @@ public class LauncherModel extends BroadcastReceiver {
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(ArrayList<Object> widgetsAndShortcuts);
public boolean isAllAppsVisible();
public void bindSearchablesChanged();
@@ -2143,6 +2146,7 @@ public class LauncherModel extends BroadcastReceiver {
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);
@@ -2152,14 +2156,9 @@ public class LauncherModel extends BroadcastReceiver {
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();
-
- removedPackageNames.addAll(Arrays.asList(packages));
}
final Callbacks callbacks = mCallbacks != null ? mCallbacks.get() : null;
@@ -2190,13 +2189,19 @@ public class LauncherModel extends BroadcastReceiver {
}
});
}
- 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) {
- callbacks.bindAppsRemoved(removedPackageNames, permanent);
+ if (callbacks == cb && cb != null) {
+ callbacks.bindComponentsRemoved(removedPackageNames,
+ removedApps, permanent);
}
}
});
diff --git a/src/com/cyanogenmod/trebuchet/ShortcutInfo.java b/src/com/cyanogenmod/trebuchet/ShortcutInfo.java
index d08700c02..2924de675 100644
--- a/src/com/cyanogenmod/trebuchet/ShortcutInfo.java
+++ b/src/com/cyanogenmod/trebuchet/ShortcutInfo.java
@@ -113,12 +113,6 @@ class ShortcutInfo extends ItemInfo {
return mIcon;
}
- /** Returns the package name that the shortcut's intent will resolve to, or an empty string if
- * none exists. */
- String getPackageName() {
- return super.getPackageName(intent);
- }
-
public void updateIcon(IconCache iconCache) {
mIcon = iconCache.getIcon(intent);
usingFallbackIcon = iconCache.isDefaultIcon(mIcon);
diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java
index c226f153f..453859b5b 100644
--- a/src/com/cyanogenmod/trebuchet/Workspace.java
+++ b/src/com/cyanogenmod/trebuchet/Workspace.java
@@ -4330,10 +4330,66 @@ public class Workspace extends PagedView
}
}
- void removeItems(final ArrayList<String> packages) {
- final HashSet<String> packageNames = new HashSet<String>();
+ // Removes ALL items that match a given package name, this is usually called when a package
+ // has been removed and we want to remove all components (widgets, shortcuts, apps) that
+ // belong to that package.
+ void removeItemsByPackageName(final ArrayList<String> packages) {
+ HashSet<String> packageNames = new HashSet<String>();
packageNames.addAll(packages);
+ // Just create a hash table of all the specific components that this will affect
+ HashSet<ComponentName> cns = new HashSet<ComponentName>();
+ ArrayList<CellLayout> cellLayouts = getWorkspaceAndHotseatCellLayouts();
+ for (CellLayout layoutParent : cellLayouts) {
+ ViewGroup layout = layoutParent.getShortcutsAndWidgets();
+ int childCount = layout.getChildCount();
+ for (int i = 0; i < childCount; ++i) {
+ View view = layout.getChildAt(i);
+ Object tag = view.getTag();
+
+ if (tag instanceof ShortcutInfo) {
+ ShortcutInfo info = (ShortcutInfo) tag;
+ ComponentName cn = info.intent.getComponent();
+ if (packageNames.contains(cn.getPackageName())) {
+ cns.add(cn);
+ }
+ } else if (tag instanceof FolderInfo) {
+ FolderInfo info = (FolderInfo) tag;
+ for (ShortcutInfo s : info.contents) {
+ ComponentName cn = s.intent.getComponent();
+ if (packageNames.contains(cn.getPackageName())) {
+ cns.add(cn);
+ }
+ }
+ } else if (tag instanceof LauncherAppWidgetInfo) {
+ LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) tag;
+ ComponentName cn = info.providerName;
+ if (packageNames.contains(cn.getPackageName())) {
+ cns.add(cn);
+ }
+ }
+ }
+ }
+
+ // Remove all the things
+ removeItemsByComponentName(cns);
+ }
+
+ // Removes items that match the application info specified, when applications are removed
+ // as a part of an update, this is called to ensure that other widgets and application
+ // shortcuts are not removed.
+ void removeItemsByApplicationInfo(final ArrayList<ApplicationInfo> appInfos) {
+ // Just create a hash table of all the specific components that this will affect
+ HashSet<ComponentName> cns = new HashSet<ComponentName>();
+ for (ApplicationInfo info : appInfos) {
+ cns.add(info.componentName);
+ }
+
+ // Remove all the things
+ removeItemsByComponentName(cns);
+ }
+
+ void removeItemsByComponentName(final HashSet<ComponentName> componentNames) {
ArrayList<CellLayout> cellLayouts = getWorkspaceAndHotseatCellLayouts();
for (final CellLayout layoutParent: cellLayouts) {
final ViewGroup layout = layoutParent.getShortcutsAndWidgets();
@@ -4355,15 +4411,15 @@ public class Workspace extends PagedView
if (intent != null) {
final ComponentName name = intent.getComponent();
- if (name != null && packageNames.contains(name.getPackageName())) {
+ if (name != null && componentNames.contains(name)) {
LauncherModel.deleteItemFromDatabase(mLauncher, info);
childrenToRemove.add(view);
}
}
} else if (tag instanceof LiveFolderInfo) {
final LiveFolderInfo info = (LiveFolderInfo) tag;
- String folderPkg = info.receiver.getPackageName();
- if (packageNames.contains(folderPkg)) {
+ final ComponentName name = info.receiver;
+ if (name != null && componentNames.contains(name)) {
LauncherModel.deleteItemFromDatabase(mLauncher, info);
childrenToRemove.add(view);
}
@@ -4378,7 +4434,7 @@ public class Workspace extends PagedView
final ComponentName name = intent.getComponent();
if (name != null) {
- if (packageNames.contains(name.getPackageName())) {
+ if (componentNames.contains(name)) {
appsToRemoveFromFolder.add(appInfo);
}
}
@@ -4391,7 +4447,7 @@ public class Workspace extends PagedView
final LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) tag;
final ComponentName provider = info.providerName;
if (provider != null) {
- if (packageNames.contains(provider.getPackageName())) {
+ if (componentNames.contains(provider)) {
LauncherModel.deleteItemFromDatabase(mLauncher, info);
childrenToRemove.add(view);
}
@@ -4436,8 +4492,7 @@ public class Workspace extends PagedView
while (iter.hasNext()) {
try {
Intent intent = Intent.parseUri(iter.next(), 0);
- String pn = ItemInfo.getPackageName(intent);
- if (packageNames.contains(pn)) {
+ if (componentNames.contains(intent.getComponent())) {
iter.remove();
}