Simplify some package update logic around restoring archived/unarchived shortcuts
- also avoids race condition where unarchived shortcut is not pinned in shortcut service after restore, and then marked as broken Bug: 375414891 Test: Launcher B&R w/ archiving Flag: com.android.launcher3.restore_archived_shortcuts Change-Id: I2b5331117be93d66e4acbded49b65cd5ce9f8f83
This commit is contained in:
1 parent
b38ab564be
commit
9e50a01e92
1 file changed
+18
-12
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user