From 8def461aa16c781275fb02b5693bf43e79193a9b Mon Sep 17 00:00:00 2001 From: Andrew Cole Date: Wed, 7 Feb 2024 11:43:23 -0800 Subject: [PATCH] Sort Apps During setApps We found this potential edge case during the creation of AllAppsSearchImageTest. Search in all apps uses a binary search which requires the list of mApps to be sorted, which before the function setApps did not do. This could lead to other edge cases of bugs either in test or production. Bug: b/318867282 Flag: None Test: AllAppsSearchImageTest Change-Id: Iccd57fa8a51c725e8c161cbdf96f77fdc86d42b7 --- src/com/android/launcher3/allapps/AllAppsStore.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/allapps/AllAppsStore.java b/src/com/android/launcher3/allapps/AllAppsStore.java index 051cf50ccc..009a2aa6b7 100644 --- a/src/com/android/launcher3/allapps/AllAppsStore.java +++ b/src/com/android/launcher3/allapps/AllAppsStore.java @@ -93,11 +93,14 @@ public class AllAppsStore { * Sets the current set of apps and sets mapping for {@link PackageUserKey} to Uid for * the current set of apps. * - *

Note that shouldPreinflate param should be set to {@code false} for taskbar, because this - * method is too late to preinflate all apps, as user will open all apps in the same frame. + *

Note that shouldPreinflate param should be set to {@code false} for taskbar, because + * this method is too late to preinflate all apps, as user will open all apps in the frame + * + *

Param: apps are required to be sorted using the comparator COMPONENT_KEY_COMPARATOR + * in order to enable binary search on the mApps store */ public void setApps(@Nullable AppInfo[] apps, int flags, Map map, - boolean shouldPreinflate) { + boolean shouldPreinflate) { mApps = apps == null ? EMPTY_ARRAY : apps; mModelFlags = flags; notifyUpdate();