From d869d274556a7b52488396b3e27725615eecf433 Mon Sep 17 00:00:00 2001 From: Pinyao Ting Date: Wed, 1 Jun 2022 14:43:45 -0700 Subject: [PATCH] Fix the issue pinned shortcuts went missing after reboot A performance improvement was made in a previous CL which refrains from saving all shortcuts from all packages whenever a change was made, rather, we will now only persists all shortcuts from specific package that were changed by the event. However that CL failed to address the event when shortcuts are pinned by a launcher. When a shortcut is pinned, both the package that owns the shortcut and the launcher that is pinning the shortcut needs to be persisted to disk. This CL completes the second half of the story by persisting the pinned state after pinned state is updated. Bug: 232775206 Test: manual Change-Id: Ib673f96c5e1233284c3660ddb4ac0a0d91356924 --- services/core/java/com/android/server/pm/ShortcutPackage.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/pm/ShortcutPackage.java b/services/core/java/com/android/server/pm/ShortcutPackage.java index fa0c6c393cdc5..0c601bfde05ac 100644 --- a/services/core/java/com/android/server/pm/ShortcutPackage.java +++ b/services/core/java/com/android/server/pm/ShortcutPackage.java @@ -706,7 +706,7 @@ class ShortcutPackage extends ShortcutPackageItem { } pinnedShortcuts.addAll(pinned); }); - // Then, update the pinned state if necessary. + // Secondly, update the pinned state if necessary. final List pinned = findAll(pinnedShortcuts); if (pinned != null) { pinned.forEach(si -> { @@ -720,6 +720,8 @@ class ShortcutPackage extends ShortcutPackageItem { si.clearFlags(ShortcutInfo.FLAG_PINNED); } }); + // Then, schedule a background job to persist the pinned states. + mShortcutUser.forAllLaunchers(ShortcutPackageItem::scheduleSave); // Lastly, remove the ones that are no longer pinned, cached nor dynamic. removeOrphans();