Fixing shortcut intent getting cleared during backup/restore

Bug: 174570283
Bug: 156871815
Test: Verified on device
Change-Id: Ie286ee783bfe96c5b2be28f0db5298caf3801e6d
This commit is contained in:
Sunny Goyal
2021-02-11 16:47:26 -08:00
parent 2268d7a937
commit 4c23ca768f
8 changed files with 42 additions and 20 deletions

View File

@@ -25,6 +25,7 @@ import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.shortcuts.ShortcutRequest;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.PackageManagerHelper;
import java.util.ArrayList;
import java.util.HashSet;
@@ -66,6 +67,14 @@ public class ShortcutsChangedTask extends BaseModelUpdateTask {
}
if (!matchingWorkspaceItems.isEmpty()) {
if (mShortcuts.isEmpty()) {
// Verify that the app is indeed installed.
if (!new PackageManagerHelper(app.getContext())
.isAppInstalled(mPackageName, mUser)) {
// App is not installed, ignoring package events
return;
}
}
// Update the workspace to reflect the changes to updated shortcuts residing on it.
List<String> allLauncherKnownIds = matchingWorkspaceItems.stream()
.map(WorkspaceItemInfo::getDeepShortcutId)