Ensure widgets from WidgetSections.xml are included in suggestions

Additionally, let only prediction system provide suggestions, since the
UI surface has been there for a while, adding locally filtered widgets
from app package isn't required.

Bug: 345520128
Test: Unit tests
Flag: EXEMPT bugfix
Change-Id: Ia97f0743fefeae750e07a694bb19d24a5cc11ffe
This commit is contained in:
Shamali P
2024-06-06 19:48:03 +00:00
committed by Shamali Patwa
parent f2a232acc5
commit d69e21f8fe
3 changed files with 29 additions and 31 deletions

View File

@@ -32,6 +32,7 @@ import com.android.launcher3.icons.ComponentWithLabelAndIcon;
import com.android.launcher3.icons.IconCache;
import com.android.launcher3.model.data.PackageItemInfo;
import com.android.launcher3.pm.ShortcutConfigActivityInfo;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.IntSet;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.util.Preconditions;
@@ -129,6 +130,22 @@ public class WidgetsModel {
return packagesToWidgets;
}
/**
* Returns a map of widget component keys to corresponding widget items. Excludes the
* shortcuts.
*/
public synchronized Map<ComponentKey, WidgetItem> getAllWidgetComponentsWithoutShortcuts() {
if (!WIDGETS_ENABLED) {
return Collections.emptyMap();
}
Map<ComponentKey, WidgetItem> widgetsMap = new HashMap<>();
mWidgetsList.forEach((packageItemInfo, widgetsAndShortcuts) ->
widgetsAndShortcuts.stream().filter(item -> item.widgetInfo != null).forEach(
item -> widgetsMap.put(new ComponentKey(item.componentName, item.user),
item)));
return widgetsMap;
}
/**
* @param packageUser If null, all widgets and shortcuts are updated and returned, otherwise
* only widgets and shortcuts associated with the package/user are.