From d71c5a94264ba764a139de41c753b9d6e6521d27 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Fri, 30 Jun 2017 13:34:01 -0400 Subject: [PATCH] Allow setup apps to colorize notifications. Fixes: 63147379 Test: runtest systemui-notification, core tests Change-Id: I2077a9fd563826d978d0dc01be89dd0bbc09eebf --- core/java/android/app/Notification.java | 16 ++++++- core/res/AndroidManifest.xml | 5 ++ .../src/android/app/NotificationTest.java | 47 +++++++++++++++++-- .../NotificationManagerService.java | 10 ++++ .../notification/NotificationRecord.java | 6 ++- .../NotificationManagerServiceTest.java | 24 ++++++++++ 6 files changed, 102 insertions(+), 6 deletions(-) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 4f9ed834318f8..32f01a0d885bd 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -559,6 +559,11 @@ public class Notification implements Parcelable @SystemApi public static final int FLAG_AUTOGROUP_SUMMARY = 0x00000400; + /** + * @hide + */ + public static final int FLAG_CAN_COLORIZE = 0x00000800; + public int flags; /** @hide */ @@ -5150,7 +5155,16 @@ public class Notification implements Parcelable if (isColorizedMedia()) { return true; } - return extras.getBoolean(EXTRA_COLORIZED) && isForegroundService(); + return extras.getBoolean(EXTRA_COLORIZED) + && (hasColorizedPermission() || isForegroundService()); + } + + /** + * Returns whether an app can colorize due to the android.permission.USE_COLORIZED_NOTIFICATIONS + * permission. The permission is checked when a notification is enqueued. + */ + private boolean hasColorizedPermission() { + return (flags & Notification.FLAG_CAN_COLORIZE) != 0; } /** diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index f5b84676c4ec4..1e9355cc0d33a 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -3193,6 +3193,11 @@ + + +