Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b2d84c2 authored by Piyush Mehrotra's avatar Piyush Mehrotra Committed by Android (Google) Code Review
Browse files

Merge "Fix widget restore for pre-archived apps" into main

parents c2f73d90 b2decf80
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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(
+17 −0
Original line number Diff line number Diff line
@@ -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
     */