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

Commit 3ff90472 authored by Charles He's avatar Charles He
Browse files

Launcher3: fix app shortcuts for suspended apps

This CL fixes app shortcuts for suspended packages.

1) When DO/PO suspends an app, its pinned shortcuts are instantly grayed
out, but this is not persisted after the launcher restarts (e.g. device
reboot). We now enforce the launcher to check the suspended state when
loading the workspace, and gray out pinned shortcut icons accordingly.

2) When DO/PO suspends an app, its app shortcut popup is still
available. We now temporarily disable the popup when the app is
suspended, and persist the state across restarts.

Bug: 32365540
Test: manual, by following the steps in the bug above
Test: manual, by restarting the launcher package
Change-Id: I983d7c17fa198beca23b66459b50bd67b447bdd2
parent 7d093e75
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Handler;
import android.os.HandlerThread;
@@ -84,7 +83,6 @@ import com.android.launcher3.util.ViewOnDrawExecutor;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.lang.ref.WeakReference;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -1340,6 +1338,11 @@ public class LauncherModel extends BroadcastReceiver
                                        info = new ShortcutInfo(pinnedShortcut, context);
                                        info.iconBitmap = LauncherIcons
                                                .createShortcutIcon(pinnedShortcut, context);
                                        if (pmHelper.isAppSuspended(
                                                info.getTargetComponent().getPackageName(),
                                                info.user)) {
                                            info.isDisabled |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
                                        }
                                        intent = info.intent;
                                    } else {
                                        // Create a shortcut info in disabled mode for now.
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.launcher3.compat;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.LauncherActivityInfo;
import android.graphics.Rect;
import android.os.Bundle;
@@ -72,6 +73,7 @@ public abstract class LauncherAppsCompat {
            UserHandle user);
    public abstract void startActivityForProfile(ComponentName component, UserHandle user,
            Rect sourceBounds, Bundle opts);
    public abstract ApplicationInfo getApplicationInfo(String packageName, UserHandle user);
    public abstract void showAppDetailsForProfile(ComponentName component, UserHandle user);
    public abstract void addOnAppsChangedCallback(OnAppsChangedCallbackCompat listener);
    public abstract void removeOnAppsChangedCallback(OnAppsChangedCallbackCompat listener);
+7 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.launcher3.compat;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.LauncherApps;
import android.content.pm.PackageManager;
@@ -64,6 +65,12 @@ public class LauncherAppsCompatVL extends LauncherAppsCompat {
        mLauncherApps.startMainActivity(component, user, sourceBounds, opts);
    }

    @Override
    public ApplicationInfo getApplicationInfo(String packageName, UserHandle user) {
        List<LauncherActivityInfo> activityList = mLauncherApps.getActivityList(packageName, user);
        return activityList.size() > 0 ? activityList.get(0).getApplicationInfo() : null;
    }

    @Override
    public void showAppDetailsForProfile(ComponentName component, UserHandle user) {
        mLauncherApps.startAppDetailsActivity(component, user, null, null);
+6 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.launcher3.compat;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.LauncherApps;
import android.os.UserHandle;
@@ -33,6 +34,11 @@ public class LauncherAppsCompatVO extends LauncherAppsCompatVL {
        super(context);
    }

    @Override
    public ApplicationInfo getApplicationInfo(String packageName, UserHandle user) {
        return mLauncherApps.getApplicationInfo(packageName, 0, user);
    }

    @Override
    public List<ShortcutConfigActivityInfo> getCustomShortcutActivityList() {
        List<ShortcutConfigActivityInfo> result = new ArrayList<>();
+2 −1
Original line number Diff line number Diff line
@@ -65,7 +65,8 @@ public class DeepShortcutManager {
    }

    public static boolean supportsShortcuts(ItemInfo info) {
        return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
        return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION
                && !info.isDisabled();
    }

    public boolean wasLastCallSuccess() {
Loading