Loading core/java/android/app/Notification.java +8 −6 Original line number Diff line number Diff line Loading @@ -1110,11 +1110,11 @@ public class Notification implements Parcelable 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"; Loading Loading @@ -2335,7 +2335,9 @@ public class Notification implements Parcelable 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) { Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Consumer; @SmallTest @RunWith(AndroidTestingRunner.class) Loading Loading @@ -2548,6 +2549,27 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { anyInt(), anyInt()); } @Test public void testVisitUris() throws Exception { final Uri audioContents = Uri.parse("content://com.example/audio"); final Uri backgroundImage = Uri.parse("content://com.example/background"); Bundle extras = new Bundle(); extras.putParcelable(Notification.EXTRA_AUDIO_CONTENTS_URI, audioContents); extras.putString(Notification.EXTRA_BACKGROUND_IMAGE_URI, backgroundImage.toString()); Notification n = new Notification.Builder(mContext, "a") .setContentTitle("notification with uris") .setSmallIcon(android.R.drawable.sym_def_app_icon) .addExtras(extras) .build(); Consumer<Uri> visitor = (Consumer<Uri>) spy(Consumer.class); n.visitUris(visitor); verify(visitor, times(1)).accept(eq(audioContents)); verify(visitor, times(1)).accept(eq(backgroundImage)); } @Test public void testSetNotificationPolicy_preP_setOldFields() { ZenModeHelper mZenModeHelper = mock(ZenModeHelper.class); Loading Loading
core/java/android/app/Notification.java +8 −6 Original line number Diff line number Diff line Loading @@ -1110,11 +1110,11 @@ public class Notification implements Parcelable 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"; Loading Loading @@ -2335,7 +2335,9 @@ public class Notification implements Parcelable 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) { Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Consumer; @SmallTest @RunWith(AndroidTestingRunner.class) Loading Loading @@ -2548,6 +2549,27 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { anyInt(), anyInt()); } @Test public void testVisitUris() throws Exception { final Uri audioContents = Uri.parse("content://com.example/audio"); final Uri backgroundImage = Uri.parse("content://com.example/background"); Bundle extras = new Bundle(); extras.putParcelable(Notification.EXTRA_AUDIO_CONTENTS_URI, audioContents); extras.putString(Notification.EXTRA_BACKGROUND_IMAGE_URI, backgroundImage.toString()); Notification n = new Notification.Builder(mContext, "a") .setContentTitle("notification with uris") .setSmallIcon(android.R.drawable.sym_def_app_icon) .addExtras(extras) .build(); Consumer<Uri> visitor = (Consumer<Uri>) spy(Consumer.class); n.visitUris(visitor); verify(visitor, times(1)).accept(eq(audioContents)); verify(visitor, times(1)).accept(eq(backgroundImage)); } @Test public void testSetNotificationPolicy_preP_setOldFields() { ZenModeHelper mZenModeHelper = mock(ZenModeHelper.class); Loading