Remove unnecessary invokation on AppSearch

There are some legacy logic which attempts to load shortcuts from xml
file, which in most cases ended up calling AppSearchSession#putDocuments
with an empty list because there are nothing to write into AppSearch.
Since this is happening for every package that has a shortcut, these
invokations collectively added some delay when launcher is starting.
This CL removes the invokations altogether since they are not needed in
the first place.

Bug: 183982287
Test: flash the device, reboot and observe
Test: atest ShortcutManagerTest1 ShortcutManagerTest2
ShortcutManagerTest3 ShortcutManagerTest4 ShortcutManagerTest5
ShortcutManagerTest6 ShortcutManagerTest7 ShortcutManagerTest8
ShortcutManagerTest9 ShortcutManagerTest10 ShortcutManagerTest11
Test: atest CtsShortcutManagerTestCases

Change-Id: I57bd9ed93c1a2068a090ff3d67906702481220fd
This commit is contained in:
Pinyao Ting
2021-03-29 18:26:16 -07:00
parent c3f2588fed
commit 06445c2da1

View File

@@ -2187,6 +2187,10 @@ class ShortcutPackage extends ShortcutPackageItem {
private void saveShortcut(@NonNull final Collection<ShortcutInfo> shortcuts) {
Objects.requireNonNull(shortcuts);
if (shortcuts.isEmpty()) {
// No need to invoke AppSearch when there's nothing to save.
return;
}
ConcurrentUtils.waitForFutureNoInterrupt(
runInAppSearch(session -> {
final AndroidFuture<Boolean> future = new AndroidFuture<>();