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
This commit is contained in:
@@ -3639,10 +3639,66 @@ public class Workspace extends SmoothPagedView
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
@@ -3664,7 +3720,7 @@ public class Workspace extends SmoothPagedView
|
||||
final ComponentName name = intent.getComponent();
|
||||
|
||||
if (name != null) {
|
||||
if (packageNames.contains(name.getPackageName())) {
|
||||
if (componentNames.contains(name)) {
|
||||
LauncherModel.deleteItemFromDatabase(mLauncher, info);
|
||||
childrenToRemove.add(view);
|
||||
}
|
||||
@@ -3682,7 +3738,7 @@ public class Workspace extends SmoothPagedView
|
||||
final ComponentName name = intent.getComponent();
|
||||
|
||||
if (name != null) {
|
||||
if (packageNames.contains(name.getPackageName())) {
|
||||
if (componentNames.contains(name)) {
|
||||
appsToRemoveFromFolder.add(appInfo);
|
||||
}
|
||||
}
|
||||
@@ -3695,7 +3751,7 @@ public class Workspace extends SmoothPagedView
|
||||
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);
|
||||
}
|
||||
@@ -3740,8 +3796,7 @@ public class Workspace extends SmoothPagedView
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user