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

Commit b41d0634 authored by Piyush Mehrotra's avatar Piyush Mehrotra
Browse files

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
parent 810a82f1
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -434,7 +434,9 @@ class WorkspaceItemProcessor(
                    !c.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_RESTORE_STARTED) &&
                        !isSafeMode &&
                        (si == null) &&
                        (lapi == null)
                        (lapi == null) &&
                        !(Flags.enableSupportForArchiving() &&
                            pmHelper.isAppArchived(component.packageName))
                ) {
                    // Restore never started
                    c.markDeleted(
+19 −0
Original line number Diff line number Diff line
@@ -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
     */