UI Improvement: Persist archived app icon on workspace in case app uninstallation is cancelled.

Test: verified bugfix locally.
Bug: 319213296
Flag: ACONFIG com.android.launcher3.enable_support_for_archiving DEVELOPMENT
Change-Id: Id9ba2ea833e8360ac8aa2c765beff402cff12ae2
This commit is contained in:
Rohit Goyal
2024-01-26 02:17:05 +05:30
parent b2f38376c4
commit c475f22d8b
2 changed files with 93 additions and 2 deletions
@@ -16,6 +16,8 @@
package com.android.launcher3.util;
import static com.android.launcher3.Flags.enableSupportForArchiving;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
@@ -112,8 +114,7 @@ public class PackageManagerHelper {
@NonNull final UserHandle user, final int flags) {
try {
ApplicationInfo info = mLauncherApps.getApplicationInfo(packageName, flags, user);
return (info.flags & ApplicationInfo.FLAG_INSTALLED) == 0 || !info.enabled
? null : info;
return !isPackageInstalledOrArchived(info) || !info.enabled ? null : info;
} catch (PackageManager.NameNotFoundException e) {
return null;
}
@@ -253,4 +254,11 @@ public class PackageManagerHelper {
}
return 100;
}
/** Returns true in case app is installed on the device or in archived state. */
@SuppressWarnings("NewApi")
private boolean isPackageInstalledOrArchived(ApplicationInfo info) {
return (info.flags & ApplicationInfo.FLAG_INSTALLED) != 0 || (
enableSupportForArchiving() && info.isArchived);
}
}