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 @@
+
+
+