Update widgetsModel to return pickable vs all widgets separately.

Earlier wallpaper preview was reading widgets that were eligible for
displaying in picker, which means widgets that are marked as hidden in
picker wouldn't show up in wallpaper preview.

This fix updates widgets model to maintain map of all widgets (instead of just pickable widgets like before), so that the existing `getWidgetsByComponentKey` function used by wallpaper preview can see all widgets. And, updates picker specific methods to use separate functions (suffixed `forPicker` that filter out picker ineligible widgets when read by picker code).

Bug: 385695615
Test: WidgetsModelTest, WidgetsPredictionUpdateTaskTest and demo
Flag: EXEMPT BUGFIX
Change-Id: I59efe38be0ce1f8a956ba4be42fb6e8b48b5d323
This commit is contained in:
Shamali P
2025-02-20 18:33:25 +00:00
committed by Shamali Patwa
parent c7e545674d
commit f6efa25a49
8 changed files with 151 additions and 20 deletions

View File

@@ -322,13 +322,14 @@ public class WidgetPickerActivity extends BaseActivity {
stringCache.loadStrings(this);
bindStringCache(stringCache);
bindWidgets(mModel.getWidgetsByPackageItem(), mModel.getDefaultWidgetsFilter());
bindWidgets(mModel.getWidgetsByPackageItemForPicker(),
mModel.getDefaultWidgetsFilter());
// Open sheet once widgets are available, so that it doesn't interrupt the open
// animation.
openWidgetsSheet();
if (mUiSurface != null) {
mWidgetPredictionsRequester = new WidgetPredictionsRequester(app.getContext(),
mUiSurface, mModel.getWidgetsByComponentKey());
mUiSurface, mModel.getWidgetsByComponentKeyForPicker());
mWidgetPredictionsRequester.request(mAddedWidgets, this::bindRecommendedWidgets);
}
});