From f28f843d74bd597b9ed05d921461b341f88f1831 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Mon, 16 Sep 2019 18:09:24 -0700 Subject: [PATCH] Fix app crash on deep shortcut restore Although the recovery logic for app shortcuts and deep shortcuts are mostly the same, in deepshortcut's case we don't care about the component name. This CL fixes the bug where we reset the intent if the activity a deepshortcut points to is not found. resetting the intent is problematic as we'll need the shortcut id (which is stored as an extra on the intent) to recover the deep shortcut using pinned shortcuts. Bug: 140819317 Change-Id: I22f0266b98a9f6175303cc92a85397e240443250 --- src/com/android/launcher3/model/LoaderTask.java | 5 +++-- src/com/android/launcher3/model/ShortcutsChangedTask.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java index c9daced517..ae164c5629 100644 --- a/src/com/android/launcher3/model/LoaderTask.java +++ b/src/com/android/launcher3/model/LoaderTask.java @@ -19,7 +19,6 @@ package com.android.launcher3.model; import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_LOCKED_USER; import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_SAFEMODE; import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_SUSPENDED; -import static com.android.launcher3.compat.PackageInstallerCompat.getUserHandle; import static com.android.launcher3.model.LoaderResults.filterCurrentWorkspaceItems; import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; import static com.android.launcher3.util.PackageManagerHelper.isSystemApp; @@ -401,7 +400,9 @@ public class LoaderTask implements Runnable { boolean validTarget = TextUtils.isEmpty(targetPkg) || mLauncherApps.isPackageEnabledForProfile(targetPkg, c.user); - if (cn != null && validTarget) { + // If it's a deep shortcut, we'll use pinned shortcuts to restore it + if (cn != null && validTarget && c.itemType + != LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) { // If the apk is present and the shortcut points to a specific // component. diff --git a/src/com/android/launcher3/model/ShortcutsChangedTask.java b/src/com/android/launcher3/model/ShortcutsChangedTask.java index c3cd9d07bd..6c358b1709 100644 --- a/src/com/android/launcher3/model/ShortcutsChangedTask.java +++ b/src/com/android/launcher3/model/ShortcutsChangedTask.java @@ -64,7 +64,7 @@ public class ShortcutsChangedTask extends BaseModelUpdateTask { for (ItemInfo itemInfo : dataModel.itemsIdMap) { if (itemInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) { WorkspaceItemInfo si = (WorkspaceItemInfo) itemInfo; - if (si.getIntent().getPackage().equals(mPackageName) && si.user.equals(mUser)) { + if (mPackageName.equals(si.getIntent().getPackage()) && si.user.equals(mUser)) { keyToShortcutInfo.addToList(ShortcutKey.fromItemInfo(si), si); allIds.add(si.getDeepShortcutId()); }