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

Commit 6e680f9b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Deleting invalid icons when an app is restored" into ub-launcher3-edmonton-polish

parents 4534bd94 e48fe109
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
    private final Matrix mTmpMatrix = new Matrix();
    private final PathMeasure mPathMeasure = new PathMeasure();

    private final Context mContext;
    private final ItemInfoWithIcon mItem;

    // Path in [0, 100] bounds.
    private final Path mProgressPath;
@@ -106,7 +106,7 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
     */
    public PreloadIconDrawable(ItemInfoWithIcon info, Path progressPath, Context context) {
        super(info);
        mContext = context;
        mItem = info;
        mProgressPath = progressPath;
        mScaledTrackPath = new Path();
        mScaledProgressPath = new Path();
@@ -274,7 +274,7 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
            mTrackAlpha = MAX_PAINT_ALPHA;
            setIsDisabled(true);
        } else if (progress >= 1) {
            setIsDisabled(false);
            setIsDisabled(mItem.isDisabled());
            mScaledTrackPath.set(mScaledProgressPath);
            float fraction = (progress - 1) / COMPLETE_ANIM_FRACTION;

+28 −10
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.launcher3.model;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Process;
import android.os.UserHandle;
import android.util.ArrayMap;
@@ -42,6 +41,9 @@ import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.graphics.BitmapInfo;
import com.android.launcher3.graphics.LauncherIcons;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
import com.android.launcher3.util.FlagOp;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.LongArrayMap;
@@ -52,6 +54,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;

/**
 * Handles updates due to changes in package manager (app installed/updated/removed)
@@ -162,12 +165,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {

        final ArrayMap<ComponentName, AppInfo> addedOrUpdatedApps = new ArrayMap<>();
        if (!addedOrModified.isEmpty()) {
            scheduleCallbackTask(new CallbackTask() {
                @Override
                public void execute(Callbacks callbacks) {
                    callbacks.bindAppsAddedOrUpdated(addedOrModified);
                }
            });
            scheduleCallbackTask((callbacks) -> callbacks.bindAppsAddedOrUpdated(addedOrModified));
            for (AppInfo ai : addedOrModified) {
                addedOrUpdatedApps.put(ai.componentName, ai);
            }
@@ -213,11 +211,26 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
                            }

                            if (si.isPromise() && isNewApkAvailable) {
                                boolean isTargetValid = true;
                                if (si.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
                                    List<ShortcutInfoCompat> shortcut = DeepShortcutManager
                                            .getInstance(context).queryForPinnedShortcuts(
                                                    cn.getPackageName(),
                                                    Arrays.asList(si.getDeepShortcutId()), mUser);
                                    if (shortcut.isEmpty()) {
                                        isTargetValid = false;
                                    } else {
                                        si.updateFromDeepShortcutInfo(shortcut.get(0), context);
                                        infoUpdated = true;
                                    }
                                } else if (!cn.getClassName().equals(IconCache.EMPTY_CLASS_NAME)) {
                                    isTargetValid = LauncherAppsCompat.getInstance(context)
                                            .isActivityEnabledForProfile(cn, mUser);
                                }

                                if (si.hasStatusFlag(ShortcutInfo.FLAG_AUTOINSTALL_ICON)) {
                                    // Auto install icon
                                    LauncherAppsCompat launcherApps
                                            = LauncherAppsCompat.getInstance(context);
                                    if (!launcherApps.isActivityEnabledForProfile(cn, mUser)) {
                                    if (!isTargetValid) {
                                        // Try to find the best match activity.
                                        Intent intent = new PackageManagerHelper(context)
                                                .getAppLaunchIntent(cn.getPackageName(), mUser);
@@ -235,6 +248,11 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
                                            continue;
                                        }
                                    }
                                } else if (!isTargetValid) {
                                    removedShortcuts.put(si.id, true);
                                    FileLog.e(TAG, "Restored shortcut no longer valid "
                                            + si.intent);
                                    continue;
                                } else {
                                    si.status = ShortcutInfo.DEFAULT;
                                    infoUpdated = true;
+6 −1
Original line number Diff line number Diff line
@@ -181,7 +181,12 @@ public class DeepShortcutManager {
     * If packageName is null, returns all pinned shortcuts regardless of package.
     */
    public List<ShortcutInfoCompat> queryForPinnedShortcuts(String packageName, UserHandle user) {
        return query(ShortcutQuery.FLAG_MATCH_PINNED, packageName, null, null, user);
        return queryForPinnedShortcuts(packageName, null, user);
    }

    public List<ShortcutInfoCompat> queryForPinnedShortcuts(String packageName,
            List<String> shortcutIds, UserHandle user) {
        return query(ShortcutQuery.FLAG_MATCH_PINNED, packageName, null, shortcutIds, user);
    }

    public List<ShortcutInfoCompat> queryForAllShortcuts(UserHandle user) {