From b4a09628fca7678648a51918493eb50dd56166e1 Mon Sep 17 00:00:00 2001 From: Lyn Date: Fri, 20 Jan 2023 18:36:12 +0000 Subject: [PATCH 1/2] Add API: NotificationManager canSendFullScreenIntent Bug: 243421660 Test: cts Change-Id: Ida295e3435c0985ca1dd8a1fe068011537154264 --- core/api/current.txt | 1 + .../java/android/app/NotificationManager.java | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/core/api/current.txt b/core/api/current.txt index 53890eb5539df..fcf61f5b78fa3 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -6703,6 +6703,7 @@ package android.app { method public boolean areNotificationsEnabled(); method public boolean areNotificationsPaused(); method public boolean canNotifyAsPackage(@NonNull String); + method public boolean canSendFullScreenIntent(); method public void cancel(int); method public void cancel(@Nullable String, int); method public void cancelAll(); diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java index f6d27ad08b009..4e94a1dcf6422 100644 --- a/core/java/android/app/NotificationManager.java +++ b/core/java/android/app/NotificationManager.java @@ -31,6 +31,7 @@ import android.compat.annotation.UnsupportedAppUsage; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.PermissionChecker; import android.content.pm.ParceledListSlice; import android.content.pm.ShortcutInfo; import android.graphics.drawable.Icon; @@ -854,6 +855,32 @@ public class NotificationManager { } } + /** + * Returns whether the calling app can send fullscreen intents. + *

From Android {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, apps may not have + * permission to use {@link android.Manifest.permission#USE_FULL_SCREEN_INTENT}. If permission + * is denied, notification will show up as an expanded heads up notification on lockscreen. + *

To request access, add the {@link android.Manifest.permission#USE_FULL_SCREEN_INTENT} + * permission to your manifest, and use + * {@link android.provider.Settings#ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT}. + */ + public boolean canSendFullScreenIntent() { + final int result = PermissionChecker.checkPermissionForPreflight(mContext, + android.Manifest.permission.USE_FULL_SCREEN_INTENT, + mContext.getAttributionSource()); + + switch (result) { + case PermissionChecker.PERMISSION_GRANTED: + return true; + case PermissionChecker.PERMISSION_SOFT_DENIED: + case PermissionChecker.PERMISSION_HARD_DENIED: + return false; + default: + if (localLOGV) Log.v(TAG, "Unknown PermissionChecker result: " + result); + return false; + } + } + /** * Creates a group container for {@link NotificationChannel} objects. * From 3f9478e88800ef7d483e01cbba087ecb1737b0d5 Mon Sep 17 00:00:00 2001 From: Lyn Date: Wed, 11 Jan 2023 17:03:53 +0000 Subject: [PATCH 2/2] Add API: intent to launch app-specific settings page to manage FSI permission Bug: 243421660 Change-Id: I5f713f9205ce52d75f09f478e0cc479ca8585e51 --- core/api/current.txt | 1 + core/java/android/provider/Settings.java | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/core/api/current.txt b/core/api/current.txt index fcf61f5b78fa3..ce98246de54b6 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -36606,6 +36606,7 @@ package android.provider { field public static final String ACTION_MANAGE_ALL_SIM_PROFILES_SETTINGS = "android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS"; field public static final String ACTION_MANAGE_APPLICATIONS_SETTINGS = "android.settings.MANAGE_APPLICATIONS_SETTINGS"; field public static final String ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION = "android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION"; + field public static final String ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT = "android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT"; field public static final String ACTION_MANAGE_DEFAULT_APPS_SETTINGS = "android.settings.MANAGE_DEFAULT_APPS_SETTINGS"; field public static final String ACTION_MANAGE_OVERLAY_PERMISSION = "android.settings.action.MANAGE_OVERLAY_PERMISSION"; field public static final String ACTION_MANAGE_SUPERVISOR_RESTRICTED_SETTING = "android.settings.MANAGE_SUPERVISOR_RESTRICTED_SETTING"; diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 925547d865483..b903c568556f1 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -19215,6 +19215,18 @@ public final class Settings { public static final String ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION = "android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION"; + /** + * Activity Action: Show screen for controlling whether an app can send full screen intents. + *

+ * Input: the intent's data URI must specify the application package name for which you want + * to manage full screen intents. + *

+ * Output: Nothing. + */ + @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) + public static final String ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT = + "android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT"; + /** * Activity Action: For system or preinstalled apps to show their {@link Activity} embedded * in Settings app on large screen devices.