From ad5c2bf9983f6685d9ce6b2099ccdfd7ad83def9 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Tue, 9 Sep 2014 17:15:59 -0700 Subject: Updating shourcuts only when the corresponding user also matches the AppInfo issue: 17480447 Change-Id: I0afbd80e760b7b73b84e483be325b2e905d65a00 --- src/com/android/launcher3/Workspace.java | 43 +++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'src/com/android/launcher3') diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index f7a0df681..909cf5f8c 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -4801,6 +4801,25 @@ public class Workspace extends SmoothPagedView } void updateShortcutsAndWidgets(ArrayList apps) { + // Break the appinfo list per user + final HashMap> appsPerUser = + new HashMap>(); + for (AppInfo info : apps) { + ArrayList filtered = appsPerUser.get(info.user); + if (filtered == null) { + filtered = new ArrayList(); + appsPerUser.put(info.user, filtered); + } + filtered.add(info); + } + + for (Map.Entry> entry : appsPerUser.entrySet()) { + updateShortcutsAndWidgetsPerUser(entry.getValue(), entry.getKey()); + } + } + + private void updateShortcutsAndWidgetsPerUser(ArrayList apps, + final UserHandleCompat user) { // Create a map of the apps to test against final HashMap appsMap = new HashMap(); final HashSet pkgNames = new HashSet(); @@ -4808,9 +4827,8 @@ public class Workspace extends SmoothPagedView appsMap.put(ai.componentName, ai); pkgNames.add(ai.componentName.getPackageName()); } + final HashSet iconsToRemove = new HashSet(); - final HashMap> iconsToRemove = - new HashMap>(); mapOverItems(MAP_RECURSE, new ItemOperator() { @Override public boolean evaluate(ItemInfo info, View v, View parent) { @@ -4818,7 +4836,8 @@ public class Workspace extends SmoothPagedView ShortcutInfo shortcutInfo = (ShortcutInfo) info; ComponentName cn = shortcutInfo.getTargetComponent(); AppInfo appInfo = appsMap.get(cn); - if (cn != null && LauncherModel.isShortcutInfoUpdateable(info) + if (user.equals(shortcutInfo.user) && cn != null + && LauncherModel.isShortcutInfoUpdateable(info) && pkgNames.contains(cn.getPackageName())) { boolean promiseStateChanged = false; boolean infoUpdated = false; @@ -4841,13 +4860,7 @@ public class Workspace extends SmoothPagedView if ((intent == null) || (appsMap == null)) { // Could not find a default activity. Remove this item. - HashSet cnSet = iconsToRemove - .get(shortcutInfo.user); - if (cnSet == null) { - cnSet = new HashSet<>(); - iconsToRemove.put(shortcutInfo.user, cnSet); - } - cnSet.add(shortcutInfo.getTargetComponent()); + iconsToRemove.add(shortcutInfo.getTargetComponent()); // process next shortcut. return false; @@ -4894,12 +4907,11 @@ public class Workspace extends SmoothPagedView }); if (!iconsToRemove.isEmpty()) { - for (Map.Entry> entry : - iconsToRemove.entrySet()) { - removeItemsByComponentName(entry.getValue(), entry.getKey()); - } + removeItemsByComponentName(iconsToRemove, user); + } + if (user.equals(UserHandleCompat.myUserHandle())) { + restorePendingWidgets(pkgNames); } - restorePendingWidgets(pkgNames); } public void removeAbandonedPromise(String packageName, UserHandleCompat user) { @@ -4946,6 +4958,7 @@ public class Workspace extends SmoothPagedView } } + // Note that package states are sent only for myUser if (!completedPackages.isEmpty()) { restorePendingWidgets(completedPackages); } -- cgit v1.2.3