diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java index 19814d9e16..ab85ae62be 100644 --- a/src/com/android/launcher3/model/LoaderTask.java +++ b/src/com/android/launcher3/model/LoaderTask.java @@ -731,21 +731,25 @@ public class LoaderTask implements Runnable { LauncherActivityInfo app = apps.get(i); AppInfo appInfo = new AppInfo(app, mUserCache.getUserInfo(user), ApiWrapper.INSTANCE.get(mApp.getContext()), mPmHelper, quietMode); - if (Flags.enableSupportForArchiving()) { - if (app.getApplicationInfo().isArchived) { - // For archived apps, include progress info in case there is a pending - // install session post restart of device. - String appPackageName = app.getApplicationInfo().packageName; - SessionInfo si = mInstallingPkgsCached != null ? mInstallingPkgsCached.get( - new PackageUserKey(appPackageName, user)) - : mSessionHelper.getActiveSessionInfo(user, - appPackageName); - if (si != null) { - appInfo.runtimeStatusFlags |= FLAG_INSTALL_SESSION_ACTIVE; - appInfo.setProgressLevel((int) (si.getProgress() * 100), - PackageInstallInfo.STATUS_INSTALLING); + try { + if (Flags.enableSupportForArchiving()) { + if (app.getApplicationInfo().isArchived) { + // For archived apps, include progress info in case there is a pending + // install session post restart of device. + String appPackageName = app.getApplicationInfo().packageName; + SessionInfo si = mInstallingPkgsCached != null ? mInstallingPkgsCached.get( + new PackageUserKey(appPackageName, user)) + : mSessionHelper.getActiveSessionInfo(user, + appPackageName); + if (si != null) { + appInfo.runtimeStatusFlags |= FLAG_INSTALL_SESSION_ACTIVE; + appInfo.setProgressLevel((int) (si.getProgress() * 100), + PackageInstallInfo.STATUS_INSTALLING); + } } } + } catch (Throwable e) { + // Ignore any exceptions while trying to get the session info. } iconRequestInfos.add(new IconRequestInfo<>( diff --git a/src/com/android/launcher3/model/WorkspaceItemProcessor.kt b/src/com/android/launcher3/model/WorkspaceItemProcessor.kt index 90e47d66cc..1662ae0bed 100644 --- a/src/com/android/launcher3/model/WorkspaceItemProcessor.kt +++ b/src/com/android/launcher3/model/WorkspaceItemProcessor.kt @@ -340,28 +340,32 @@ class WorkspaceItemProcessor( pmHelper ) } - if ( - (c.restoreFlag != 0 || - Flags.enableSupportForArchiving() && - activityInfo != null && - activityInfo.applicationInfo.isArchived) && !TextUtils.isEmpty(targetPkg) - ) { - tempPackageKey.update(targetPkg, c.user) - val si = installingPkgs[tempPackageKey] - if (si == null) { - info.runtimeStatusFlags = - info.runtimeStatusFlags and - ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE.inv() - } else if ( - activityInfo == null || - (Flags.enableSupportForArchiving() && - activityInfo.applicationInfo.isArchived) + try { + if ( + Utilities.ATLEAST_U && (c.restoreFlag != 0 || + Flags.enableSupportForArchiving() && + activityInfo != null && + activityInfo.applicationInfo.isArchived) && !TextUtils.isEmpty(targetPkg) ) { - // For archived apps, include progress info in case there is - // a pending install session post restart of device. - val installProgress = (si.getProgress() * 100).toInt() - info.setProgressLevel(installProgress, PackageInstallInfo.STATUS_INSTALLING) + tempPackageKey.update(targetPkg, c.user) + val si = installingPkgs[tempPackageKey] + if (si == null) { + info.runtimeStatusFlags = + info.runtimeStatusFlags and + ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE.inv() + } else if ( + activityInfo == null || + (Flags.enableSupportForArchiving() && + activityInfo.applicationInfo.isArchived) + ) { + // For archived apps, include progress info in case there is + // a pending install session post restart of device. + val installProgress = (si.getProgress() * 100).toInt() + info.setProgressLevel(installProgress, PackageInstallInfo.STATUS_INSTALLING) + } } + } catch (t: Throwable) { + Log.e(TAG, "Error loading icon", t) } c.checkAndAddItem(info, bgDataModel, memoryLogger) } else {