diff options
author | Jon Miranda <jonmiranda@google.com> | 2019-10-24 13:27:11 -0700 |
---|---|---|
committer | Jon Miranda <jonmiranda@google.com> | 2019-10-24 13:27:41 -0700 |
commit | 26256f79c37f34e09e4d4461a3c94eb1b475da6c (patch) | |
tree | d8b6871825e57a30be83bb0f0e7fab5883734b78 /src/com/android/launcher3/model/AddWorkspaceItemsTask.java | |
parent | 892cf58a6a014de22e8588af4f5f63add1fa23d7 (diff) |
Fix work profile promise icon bugs.
- We did not pass in the user when creating the workspace item infos.
- Added check for if app is installed before adding item to workspace
to prevent any stale promise icons. This seems to happen when uninstalling
and then immediately reinstalling an application.
Bug: 141556707
Change-Id: I2db2d8da449c37eb248a59fbc9e7b517f50855c1
Diffstat (limited to 'src/com/android/launcher3/model/AddWorkspaceItemsTask.java')
-rw-r--r-- | src/com/android/launcher3/model/AddWorkspaceItemsTask.java | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/com/android/launcher3/model/AddWorkspaceItemsTask.java b/src/com/android/launcher3/model/AddWorkspaceItemsTask.java index 227bb22e2e..2d62c9ee77 100644 --- a/src/com/android/launcher3/model/AddWorkspaceItemsTask.java +++ b/src/com/android/launcher3/model/AddWorkspaceItemsTask.java @@ -117,25 +117,30 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask { } SessionInfo sessionInfo = packageInstaller.getActiveSessionInfo(item.user, packageName); + List<LauncherActivityInfo> activities = launcherApps + .getActivityList(packageName, item.user); + boolean hasActivity = activities != null && !activities.isEmpty(); + if (sessionInfo == null) { - List<LauncherActivityInfo> activities = launcherApps - .getActivityList(packageName, item.user); - if (activities != null && !activities.isEmpty()) { - // App was installed while launcher was in the background. - itemInfo = new AppInfo(app.getContext(), activities.get(0), item.user) - .makeWorkspaceItem(); - WorkspaceItemInfo wii = (WorkspaceItemInfo) itemInfo; - wii.title = ""; - wii.applyFrom(app.getIconCache().getDefaultIcon(item.user)); - app.getIconCache().getTitleAndIcon(wii, - ((WorkspaceItemInfo) itemInfo).usingLowResIcon()); - } else { + if (!hasActivity) { // Session was cancelled, do not add. continue; } } else { workspaceInfo.setInstallProgress((int) sessionInfo.getProgress()); } + + if (hasActivity) { + // App was installed while launcher was in the background, + // or app was already installed for another user. + itemInfo = new AppInfo(app.getContext(), activities.get(0), item.user) + .makeWorkspaceItem(); + WorkspaceItemInfo wii = (WorkspaceItemInfo) itemInfo; + wii.title = ""; + wii.applyFrom(app.getIconCache().getDefaultIcon(item.user)); + app.getIconCache().getTitleAndIcon(wii, + ((WorkspaceItemInfo) itemInfo).usingLowResIcon()); + } } // Add the shortcut to the db |