Merge "Simplify some package update logic around restoring archived/unarchived shortcuts" into main

This commit is contained in:
Charlie Anderson
2025-02-24 09:58:35 -08:00
committed by Android (Google) Code Review
@@ -239,25 +239,31 @@ public class PackageUpdatedTask implements ModelUpdateTask {
boolean isTargetValid = !cn.getClassName().equals(
IconCache.EMPTY_CLASS_NAME);
if (itemInfo.itemType == ITEM_TYPE_DEEP_SHORTCUT) {
int requestQuery = ShortcutRequest.PINNED;
if (Flags.restoreArchivedShortcuts()) {
// Avoid race condition where shortcut service has no record of
// unarchived shortcut being pinned after restore.
// Launcher should be source-of-truth for if shortcut is pinned.
requestQuery = ShortcutRequest.ALL;
}
List<ShortcutInfo> shortcut =
new ShortcutRequest(context, mUser)
.forPackage(cn.getPackageName(),
itemInfo.getDeepShortcutId())
.query(ShortcutRequest.PINNED);
if (shortcut.isEmpty()
&& !(Flags.restoreArchivedShortcuts()
&& !itemInfo.isArchived())
) {
.query(requestQuery);
if (shortcut.isEmpty()) {
isTargetValid = false;
if (DEBUG) {
Log.d(TAG, "Pinned Shortcut not found for updated"
+ " package=" + itemInfo.getTargetPackage());
}
} else if (!shortcut.isEmpty()) {
if (DEBUG) {
Log.d(TAG, "Found pinned shortcut for updated"
Log.d(TAG, "Shortcut not found for updated"
+ " package=" + itemInfo.getTargetPackage()
+ ", isTargetValid=" + isTargetValid);
+ ", isArchived=" + itemInfo.isArchived());
}
} else {
if (DEBUG) {
Log.d(TAG, "Found shortcut for updated"
+ " package=" + itemInfo.getTargetPackage()
+ ", isTargetValid=" + isTargetValid
+ ", isArchived=" + itemInfo.isArchived());
}
itemInfo.updateFromDeepShortcutInfo(shortcut.get(0), context);
infoUpdated = true;