diff options
| author | 2024-10-30 16:27:56 -0700 | |
|---|---|---|
| committer | 2024-11-01 09:53:02 -0700 | |
| commit | f31aa6ceb8d6ecb7d207ee7ddc19fd8100ab87d8 (patch) | |
| tree | 6c23dcb2d971c993986587a1eaa6116ec0ebc52b | |
| parent | 575fff61bf65994bab1b74630d7a6e302750553b (diff) | |
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
| -rw-r--r-- | core/api/current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/appwidget/AppWidgetManager.java | 3 | ||||
| -rw-r--r-- | core/java/android/appwidget/AppWidgetProviderInfo.java | 15 | ||||
| -rw-r--r-- | core/java/android/appwidget/flags.aconfig | 9 | ||||
| -rw-r--r-- | core/res/res/values/attrs.xml | 2 |
5 files changed, 29 insertions, 1 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index 4cb791a9db1f..26fb0703908b 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -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 diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java index d8142fd9687c..8f20ea034cf6 100644 --- a/core/java/android/appwidget/AppWidgetManager.java +++ b/core/java/android/appwidget/AppWidgetManager.java @@ -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"; diff --git a/core/java/android/appwidget/AppWidgetProviderInfo.java b/core/java/android/appwidget/AppWidgetProviderInfo.java index 1a80cac2f06a..75c76d16ac5c 100644 --- a/core/java/android/appwidget/AppWidgetProviderInfo.java +++ b/core/java/android/appwidget/AppWidgetProviderInfo.java @@ -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 {} diff --git a/core/java/android/appwidget/flags.aconfig b/core/java/android/appwidget/flags.aconfig index e5c94fccfe28..ce515761551c 100644 --- a/core/java/android/appwidget/flags.aconfig +++ b/core/java/android/appwidget/flags.aconfig @@ -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 +} diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index d750ff6623f2..81d8fd50eb9e 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -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. --> |