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

Commit 877da315 authored by Rohit Goyal's avatar Rohit Goyal Committed by Cherrypicker Worker
Browse files

Bugfix: Remove widgets and deep shortcuts of app which gets archived.

* Once app is archived, remove widgets and deep shortcuts corresponding to the app from the home screen.
* However during backup & restore, widgets should not be removed if they are being restored.

Test: verified bugfix locally.
Bug: 326567866
Flag: ACONFIG com.android.launcher3.enable_support_for_archiving DEVELOPMENT
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:bef2930f5a29655f6c403f2d5eefd4e99a733b04)
Merged-In: Ib3a112aadc7bd901fd6a0ba86f472ec6acf8d626
Change-Id: Ib3a112aadc7bd901fd6a0ba86f472ec6acf8d626
parent 2ade8f20
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -78,10 +78,12 @@ public class ShortcutsChangedTask extends BaseModelUpdateTask {

        if (!matchingWorkspaceItems.isEmpty()) {
            if (mShortcuts.isEmpty()) {
                PackageManagerHelper packageManagerHelper = new PackageManagerHelper(
                        app.getContext());
                // Verify that the app is indeed installed.
                if (!new PackageManagerHelper(app.getContext())
                        .isAppInstalled(mPackageName, mUser)) {
                    // App is not installed, ignoring package events
                if (!packageManagerHelper.isAppInstalled(mPackageName, mUser)
                        && !packageManagerHelper.isAppArchivedForUser(mPackageName, mUser)) {
                    // App is not installed or archived, ignoring package events
                    return;
                }
            }
+17 −1
Original line number Diff line number Diff line
@@ -104,6 +104,21 @@ public class PackageManagerHelper {
        return info != null;
    }

    /**
     * Returns whether the target app is archived for a given user
     */
    public boolean isAppArchivedForUser(@NonNull final String packageName,
            @NonNull final UserHandle user) {
        if (!Utilities.enableSupportForArchiving()) {
            return false;
        }
        final ApplicationInfo info = getApplicationInfo(
                // LauncherApps does not support long flags currently. Since archived apps are
                // subset of uninstalled apps, this filter also includes archived apps.
                packageName, user, PackageManager.MATCH_UNINSTALLED_PACKAGES);
        return info != null && info.isArchived;
    }

    /**
     * Returns whether the target app is in archived state
     */
@@ -251,6 +266,7 @@ public class PackageManagerHelper {

    /**
     * Returns true if Launcher has the permission to access shortcuts.
     *
     * @see LauncherApps#hasShortcutHostPermission()
     */
    public static boolean hasShortcutsPermission(Context context) {