summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.txt1
-rw-r--r--core/java/android/app/Notification.java3
-rw-r--r--core/res/AndroidManifest.xml6
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java40
4 files changed, 38 insertions, 12 deletions
diff --git a/api/current.txt b/api/current.txt
index 057303f04f54..bf1ec0209723 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -150,6 +150,7 @@ package android {
field public static final java.lang.String UPDATE_DEVICE_STATS = "android.permission.UPDATE_DEVICE_STATS";
field public static final java.lang.String USE_BIOMETRIC = "android.permission.USE_BIOMETRIC";
field public static final deprecated java.lang.String USE_FINGERPRINT = "android.permission.USE_FINGERPRINT";
+ field public static final java.lang.String USE_FULL_SCREEN_INTENT = "android.permission.USE_FULL_SCREEN_INTENT";
field public static final java.lang.String USE_SIP = "android.permission.USE_SIP";
field public static final java.lang.String VIBRATE = "android.permission.VIBRATE";
field public static final java.lang.String WAKE_LOCK = "android.permission.WAKE_LOCK";
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 5002a8125d44..90276c45702d 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -3848,6 +3848,9 @@ public class Notification implements Parcelable
* The system UI may choose to display a heads-up notification, instead of
* launching this intent, while the user is using the device.
* </p>
+ * <p>Apps targeting {@link Build.VERSION_CODES#Q} and above will have to request
+ * a permission ({@link android.Manifest.permission#USE_FULL_SCREEN_INTENT}) in order to
+ * use full screen intents.</p>
*
* @param intent The pending intent to launch.
* @param highPriority Passing true will cause this notification to be sent
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 6c3085ff2919..83c7700201aa 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -4206,6 +4206,12 @@
<permission android:name="android.permission.SMS_FINANCIAL_TRANSACTIONS"
android:protectionLevel="signature|appop" />
+ <!-- Required for apps targeting {@link android.os.Build.VERSION_CODES#P} that want to use
+ {@link android.app.Notification.Builder#setFullScreenIntent notification full screen
+ intents}. -->
+ <permission android:name="android.permission.USE_FULL_SCREEN_INTENT"
+ android:protectionLevel="normal" />
+
<!-- @SystemApi Allows requesting the framework broadcast the
{@link Intent#ACTION_DEVICE_CUSTOMIZATION_READY} intent.
@hide -->
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index ae27d0c07ea8..5f63932f2a67 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -4247,18 +4247,7 @@ public class NotificationManagerService extends SystemService {
// Fix the notification as best we can.
try {
- final ApplicationInfo ai = mPackageManagerClient.getApplicationInfoAsUser(
- pkg, PackageManager.MATCH_DEBUG_TRIAGED_MISSING,
- (userId == UserHandle.USER_ALL) ? USER_SYSTEM : userId);
- Notification.addFieldsFromContext(ai, notification);
-
- int canColorize = mPackageManagerClient.checkPermission(
- android.Manifest.permission.USE_COLORIZED_NOTIFICATIONS, pkg);
- if (canColorize == PERMISSION_GRANTED) {
- notification.flags |= Notification.FLAG_CAN_COLORIZE;
- } else {
- notification.flags &= ~Notification.FLAG_CAN_COLORIZE;
- }
+ fixNotification(notification, pkg, userId);
} catch (NameNotFoundException e) {
Slog.e(TAG, "Cannot create a context for sending app", e);
@@ -4359,6 +4348,33 @@ public class NotificationManagerService extends SystemService {
mHandler.post(new EnqueueNotificationRunnable(userId, r));
}
+ @VisibleForTesting
+ protected void fixNotification(Notification notification, String pkg, int userId)
+ throws NameNotFoundException {
+ final ApplicationInfo ai = mPackageManagerClient.getApplicationInfoAsUser(
+ pkg, PackageManager.MATCH_DEBUG_TRIAGED_MISSING,
+ (userId == UserHandle.USER_ALL) ? USER_SYSTEM : userId);
+ Notification.addFieldsFromContext(ai, notification);
+
+ int canColorize = mPackageManagerClient.checkPermission(
+ android.Manifest.permission.USE_COLORIZED_NOTIFICATIONS, pkg);
+ if (canColorize == PERMISSION_GRANTED) {
+ notification.flags |= Notification.FLAG_CAN_COLORIZE;
+ } else {
+ notification.flags &= ~Notification.FLAG_CAN_COLORIZE;
+ }
+
+ if (ai.targetSdkVersion >= Build.VERSION_CODES.Q) {
+ int fullscreenIntentPermission = mPackageManagerClient.checkPermission(
+ android.Manifest.permission.USE_FULL_SCREEN_INTENT, pkg);
+ if (fullscreenIntentPermission != PERMISSION_GRANTED) {
+ notification.fullScreenIntent = null;
+ Log.w(TAG, "Package " + pkg +
+ ": Use of fullScreenIntent requires the USE_FULL_SCREEN_INTENT permission");
+ }
+ }
+ }
+
private void doChannelWarningToast(CharSequence toastText) {
Binder.withCleanCallingIdentity(() -> {
final int defaultWarningEnabled = Build.IS_DEBUGGABLE ? 1 : 0;