Check the feature flag before showing bubbles shortcut widget

Flag: com.android.wm.shell.enable_retrievable_bubbles
Bug: 340337839
Test: manual

Change-Id: I39424de3c448a1991a62dd198c195db5418788ba
This commit is contained in:
Ats Jenk
2024-05-22 14:57:32 -07:00
parent d226042cb5
commit cdc0e2c9c9

View File

@@ -41,6 +41,7 @@ import com.android.launcher3.widget.WidgetSections;
import com.android.launcher3.widget.model.WidgetsListBaseEntry;
import com.android.launcher3.widget.model.WidgetsListContentEntry;
import com.android.launcher3.widget.model.WidgetsListHeaderEntry;
import com.android.wm.shell.Flags;
import java.util.ArrayList;
import java.util.Arrays;
@@ -201,6 +202,7 @@ public class WidgetsModel {
// add and update.
mWidgetsList.putAll(rawWidgetsShortcuts.stream()
.filter(new WidgetValidityCheck(app))
.filter(new WidgetFlagCheck())
.flatMap(widgetItem -> getPackageUserKeys(app.getContext(), widgetItem).stream()
.map(key -> new Pair<>(packageItemInfoCache.getOrCreate(key), widgetItem)))
.collect(groupingBy(pair -> pair.first, mapping(pair -> pair.second, toList()))));
@@ -360,6 +362,21 @@ public class WidgetsModel {
}
}
private static class WidgetFlagCheck implements Predicate<WidgetItem> {
private static final String BUBBLES_SHORTCUT_WIDGET =
"com.android.systemui/com.android.wm.shell.bubbles.shortcut"
+ ".CreateBubbleShortcutActivity";
@Override
public boolean test(WidgetItem widgetItem) {
if (BUBBLES_SHORTCUT_WIDGET.equals(widgetItem.componentName.flattenToString())) {
return Flags.enableRetrievableBubbles();
}
return true;
}
}
private static final class PackageItemInfoCache {
private final Map<PackageUserKey, PackageItemInfo> mMap = new ArrayMap<>();