Fix widget restore for pre-archived apps

Widgets which were expected to be restored, were missing for apps which were pre-archived.
The fix adds checks for archived apps when processing widgets and ensures that icon with cloud overlay is present on the widget.

Test: Flashed device with build containing this fix.
    Screenshot right after SuW- http://shortn/_LoLudMXEaT
Bug: 321297173
Flag: ACONFIG com.android.launcher3.enable_support_for_archiving DEVELOPMENT
Change-Id: Ic5fd6b5b2a12f7b2b053ee4ec7c5c7330f0d07e1
This commit is contained in:
Piyush Mehrotra
2024-01-29 17:38:02 +00:00
parent 9ac91ffa63
commit b2decf8046
2 changed files with 20 additions and 1 deletions
@@ -433,7 +433,9 @@ class WorkspaceItemProcessor(
!c.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_RESTORE_STARTED) &&
!isSafeMode &&
(si == null) &&
(lapi == null)
(lapi == null) &&
!(Utilities.enableSupportForArchiving() &&
pmHelper.isAppArchived(component.packageName))
) {
// Restore never started
c.markDeleted(
@@ -106,6 +106,23 @@ public class PackageManagerHelper {
return info != null;
}
/**
* Returns whether the target app is in archived state
*/
@SuppressWarnings("NewApi")
public boolean isAppArchived(@NonNull final String packageName) {
final ApplicationInfo info;
try {
info = mPm.getPackageInfo(packageName,
PackageManager.PackageInfoFlags.of(
PackageManager.MATCH_ARCHIVED_PACKAGES)).applicationInfo;
return info.isArchived;
} catch (NameNotFoundException e) {
Log.e(TAG, "Failed to get applicationInfo for package: " + packageName, e);
return false;
}
}
/**
* Returns the application info for the provided package or null
*/