Parse EXTRA_BACKGROUND_IMAGE_URI from String
It looks like it should be a Uri, but it's actually just a flat string.
Also updated the documentation to warn about this particular format of
bear trap and added a small test for the two non-message cases that we
have at the moment.
Test: atest frameworks/base/services/tests/uiservicestests/src/com/android/server/notification
Bug: 78689601
Change-Id: I50171451194bb725f31e7d6f2d1e8f0888b0a2aa
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index c5b8019..f18b92a 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -1110,11 +1110,11 @@
public static final String EXTRA_ALLOW_DURING_SETUP = "android.allowDuringSetup";
/**
- * {@link #extras} key: A
- * {@link android.content.ContentUris content URI} pointing to an image that can be displayed
- * in the background when the notification is selected. Used on television platforms.
- * The URI must point to an image stream suitable for passing into
- * {@link android.graphics.BitmapFactory#decodeStream(java.io.InputStream)
+ * {@link #extras} key:
+ * flat {@link String} representation of a {@link android.content.ContentUris content URI}
+ * pointing to an image that can be displayed in the background when the notification is
+ * selected. Used on television platforms. The URI must point to an image stream suitable for
+ * passing into {@link android.graphics.BitmapFactory#decodeStream(java.io.InputStream)
* BitmapFactory.decodeStream}; all other content types will be ignored.
*/
public static final String EXTRA_BACKGROUND_IMAGE_URI = "android.backgroundImageUri";
@@ -2335,7 +2335,9 @@
if (extras != null) {
visitor.accept(extras.getParcelable(EXTRA_AUDIO_CONTENTS_URI));
- visitor.accept(extras.getParcelable(EXTRA_BACKGROUND_IMAGE_URI));
+ if (extras.containsKey(EXTRA_BACKGROUND_IMAGE_URI)) {
+ visitor.accept(Uri.parse(extras.getString(EXTRA_BACKGROUND_IMAGE_URI)));
+ }
}
if (MessagingStyle.class.equals(getNotificationStyle()) && extras != null) {