diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java index 7334d80dd6..e103f6663d 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java @@ -30,8 +30,10 @@ import android.app.prediction.AppPredictor; import android.app.prediction.AppTarget; import android.app.prediction.AppTargetEvent; import android.content.ComponentName; +import android.content.pm.ShortcutInfo; import android.os.Process; import android.util.Log; +import android.util.SparseArray; import android.view.HapticFeedbackConstants; import android.view.View; import android.view.ViewGroup; @@ -65,6 +67,7 @@ import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.popup.SystemShortcut; import com.android.launcher3.shortcuts.ShortcutKey; +import com.android.launcher3.shortcuts.ShortcutRequest; import com.android.launcher3.touch.ItemLongClickListener; import com.android.launcher3.uioverrides.PredictedAppIcon; import com.android.launcher3.uioverrides.QuickstepLauncher; @@ -379,16 +382,24 @@ public class HotseatPredictionController implements DragController.DragListener, mRestoreHelper.restoreBackup(); } StringBuilder predictionLog = new StringBuilder("predictedApps: [\n"); - ArrayList componentKeys = new ArrayList<>(); + ArrayList componentKeysToBeCached = new ArrayList<>(); + SparseArray requests = new SparseArray<>(); for (AppTarget appTarget : appTargets) { ComponentKey key; - if (appTarget.getShortcutInfo() != null) { - key = ShortcutKey.fromInfo(appTarget.getShortcutInfo()); + ShortcutRequest request = requests.get(appTarget.getUser().getIdentifier()); + if (request == null) { + request = new ShortcutRequest(mLauncher, appTarget.getUser()); + requests.put(appTarget.getUser().getIdentifier(), request); + } + List shortcutInfos = request.forPackage(appTarget.getPackageName(), + appTarget.getClassName()).query(ShortcutRequest.ALL); + if (!shortcutInfos.isEmpty()) { + key = ShortcutKey.fromInfo(shortcutInfos.get(0)); } else { key = new ComponentKey(new ComponentName(appTarget.getPackageName(), appTarget.getClassName()), appTarget.getUser()); + componentKeysToBeCached.add(key); } - componentKeys.add(key); predictionLog.append(key.toString()); predictionLog.append(",rank:"); predictionLog.append(appTarget.getRank()); @@ -401,7 +412,7 @@ public class HotseatPredictionController implements DragController.DragListener, } updateDependencies(); fillGapsWithPrediction(); - cachePredictionComponentKeysIfNecessary(componentKeys); + cachePredictionComponentKeysIfNecessary(componentKeysToBeCached); } private void cachePredictionComponentKeysIfNecessary(ArrayList componentKeys) { diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PredictedAppIcon.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PredictedAppIcon.java index 597c17b4e2..51d53fd29e 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PredictedAppIcon.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PredictedAppIcon.java @@ -36,6 +36,7 @@ import androidx.core.graphics.ColorUtils; import com.android.launcher3.CellLayout; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; +import com.android.launcher3.LauncherSettings; import com.android.launcher3.R; import com.android.launcher3.accessibility.LauncherAccessibilityDelegate; import com.android.launcher3.graphics.IconPalette; @@ -90,8 +91,9 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView implements public void onDraw(Canvas canvas) { int count = canvas.save(); if (!mIsPinned) { - boolean isBadged = getTag() instanceof WorkspaceItemInfo - && !Process.myUserHandle().equals(((ItemInfo) getTag()).user); + ItemInfo info = (ItemInfo) getTag(); + boolean isBadged = info != null && (!Process.myUserHandle().equals(info.user) + || info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT); drawEffect(canvas, isBadged); canvas.translate(getWidth() * RING_EFFECT_RATIO, getHeight() * RING_EFFECT_RATIO); canvas.scale(1 - 2 * RING_EFFECT_RATIO, 1 - 2 * RING_EFFECT_RATIO);