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
This commit is contained in:
Jon Miranda
2019-10-24 13:27:11 -07:00
parent 892cf58a6a
commit 26256f79c3
2 changed files with 24 additions and 19 deletions

View File

@@ -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