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: I32bc51ead2870670efc8eba24f17896aedcc3b9f
This commit is contained in:
Piyush Mehrotra
2024-02-05 15:53:19 +00:00
parent 810a82f13e
commit b41d0634af
2 changed files with 22 additions and 1 deletions
@@ -16,6 +16,9 @@
package com.android.launcher3.util;
import static android.content.pm.PackageManager.MATCH_ARCHIVED_PACKAGES;
import static com.android.launcher3.Flags.enableSupportForArchiving;
import android.content.ActivityNotFoundException;
@@ -106,6 +109,22 @@ 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(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
*/