Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f31aa6ce authored by Zak Cohen's avatar Zak Cohen
Browse files

Adds AppWidget category not_keyguard.

Apps can set the category to hint to appwidget surfaces that implement
keyguard style features that these widgets shouldn't be shown there.

This is required as some keyguard style appwidget hosts offer to show
all widgets, whether the keyguard category is set or not, with user consent
This category allows apps that want to provide a stronger signal, than the
absense of the keyguard category, that they should not be shown on the
keyguard.

Adding the category doesn't change the behavior of AppWidgetManager queries
it doesn't itself implement any restrictions. This is because
AppWidgetManager doesn't know what kind of surface the widgets will be
displayed on, so delegates that to the surface itself.

Bug: 365169792
Test: Follow up on widget picker
Flag: EXEMPT can't flag a single attr entry
Change-Id: Ie6701085765ae7f36d4dba59e7c5e3281c67eb0a
parent 575fff61
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -9790,6 +9790,7 @@ package android.appwidget {
    field public static final int RESIZE_VERTICAL = 2; // 0x2
    field public static final int WIDGET_CATEGORY_HOME_SCREEN = 1; // 0x1
    field public static final int WIDGET_CATEGORY_KEYGUARD = 2; // 0x2
    field @FlaggedApi("android.appwidget.flags.not_keyguard_category") public static final int WIDGET_CATEGORY_NOT_KEYGUARD = 8; // 0x8
    field public static final int WIDGET_CATEGORY_SEARCHBOX = 4; // 0x4
    field public static final int WIDGET_FEATURE_CONFIGURATION_OPTIONAL = 4; // 0x4
    field public static final int WIDGET_FEATURE_HIDE_FROM_PICKER = 2; // 0x2
+2 −1
Original line number Diff line number Diff line
@@ -246,7 +246,8 @@ public class AppWidgetManager {
     * this widget. Can have the value {@link
     * AppWidgetProviderInfo#WIDGET_CATEGORY_HOME_SCREEN} or {@link
     * AppWidgetProviderInfo#WIDGET_CATEGORY_KEYGUARD} or {@link
     * AppWidgetProviderInfo#WIDGET_CATEGORY_SEARCHBOX}.
     * AppWidgetProviderInfo#WIDGET_CATEGORY_SEARCHBOX} or {@link
     * AppWidgetProviderInfo#WIDGET_CATEGORY_NOT_KEYGUARD}.
     */
    public static final String OPTION_APPWIDGET_HOST_CATEGORY = "appWidgetCategory";

+15 −0
Original line number Diff line number Diff line
@@ -93,11 +93,26 @@ public class AppWidgetProviderInfo implements Parcelable {
     */
    public static final int WIDGET_CATEGORY_SEARCHBOX = 4;

    /**
     * Indicates that the widget should never be shown on the keyguard.
     *
     * <p>Some keyguard style features may decide that {@link #WIDGET_CATEGORY_KEYGUARD} isn't
     * required to be added by an app to show on the feature when chosen by a user.
     * This category allows for a stronger statement about placement of the widget that, even in the
     * above case, this widget should not be offered on the keyguard.
     *
     * <p>Setting this category doesn't change the behavior of AppWidgetManager queries, it is the
     * responsibility of the widget surface to respect this value.
     */
    @FlaggedApi(android.appwidget.flags.Flags.FLAG_NOT_KEYGUARD_CATEGORY)
    public static final int WIDGET_CATEGORY_NOT_KEYGUARD = 8;

    /** @hide */
    @IntDef(flag = true, prefix = { "FLAG_" }, value = {
            WIDGET_CATEGORY_HOME_SCREEN,
            WIDGET_CATEGORY_KEYGUARD,
            WIDGET_CATEGORY_SEARCHBOX,
            WIDGET_CATEGORY_NOT_KEYGUARD,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface CategoryFlags {}
+9 −0
Original line number Diff line number Diff line
@@ -83,3 +83,12 @@ flag {
  is_exported: true
  is_fixed_read_only: true
}

flag {
  name: "not_keyguard_category"
  namespace: "app_widgets"
  description: "Adds the NOT_KEYGUARD category to AppWidgetInfo categories"
  bug: "365169792"
  is_exported: true
  is_fixed_read_only: true
}
+2 −0
Original line number Diff line number Diff line
@@ -9238,6 +9238,8 @@
            <flag name="home_screen" value="0x1" />
            <flag name="keyguard" value="0x2" />
            <flag name="searchbox" value="0x4" />
            <!-- @FlaggedApi("android.appwidget.flags.not_keyguard_category") -->
            <flag name="not_keyguard" value="0x8" />
        </attr>
        <!-- Flags indicating various features supported by the widget. These are hints to the
         widget host, and do not actually change the behavior of the widget. -->