Loading core/java/android/app/Notification.java +11 −1 Original line number Diff line number Diff line Loading @@ -2684,7 +2684,17 @@ public class Notification implements Parcelable if (headsUpContentView != null) headsUpContentView.visitUris(visitor); if (extras != null) { visitor.accept(extras.getParcelable(EXTRA_AUDIO_CONTENTS_URI)); // NOTE: The documentation of EXTRA_AUDIO_CONTENTS_URI explicitly says that it is a // String representation of a Uri, but the previous implementation (and unit test) of // this method has always treated it as a Uri object. Given the inconsistency, // supporting both going forward is the safest choice. Object audioContentsUri = extras.get(EXTRA_AUDIO_CONTENTS_URI); if (audioContentsUri instanceof Uri) { visitor.accept((Uri) audioContentsUri); } else if (audioContentsUri instanceof String) { visitor.accept(Uri.parse((String) audioContentsUri)); } if (extras.containsKey(EXTRA_BACKGROUND_IMAGE_URI)) { visitor.accept(Uri.parse(extras.getString(EXTRA_BACKGROUND_IMAGE_URI))); } Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -4037,6 +4037,24 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { verify(visitor, times(1)).accept(eq(backgroundImage)); } @Test public void testVisitUris_audioContentsString() throws Exception { final Uri audioContents = Uri.parse("content://com.example/audio"); Bundle extras = new Bundle(); extras.putString(Notification.EXTRA_AUDIO_CONTENTS_URI, audioContents.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)); } @Test public void testSetNotificationPolicy_preP_setOldFields() { ZenModeHelper mZenModeHelper = mock(ZenModeHelper.class); Loading Loading
core/java/android/app/Notification.java +11 −1 Original line number Diff line number Diff line Loading @@ -2684,7 +2684,17 @@ public class Notification implements Parcelable if (headsUpContentView != null) headsUpContentView.visitUris(visitor); if (extras != null) { visitor.accept(extras.getParcelable(EXTRA_AUDIO_CONTENTS_URI)); // NOTE: The documentation of EXTRA_AUDIO_CONTENTS_URI explicitly says that it is a // String representation of a Uri, but the previous implementation (and unit test) of // this method has always treated it as a Uri object. Given the inconsistency, // supporting both going forward is the safest choice. Object audioContentsUri = extras.get(EXTRA_AUDIO_CONTENTS_URI); if (audioContentsUri instanceof Uri) { visitor.accept((Uri) audioContentsUri); } else if (audioContentsUri instanceof String) { visitor.accept(Uri.parse((String) audioContentsUri)); } if (extras.containsKey(EXTRA_BACKGROUND_IMAGE_URI)) { visitor.accept(Uri.parse(extras.getString(EXTRA_BACKGROUND_IMAGE_URI))); } Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -4037,6 +4037,24 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { verify(visitor, times(1)).accept(eq(backgroundImage)); } @Test public void testVisitUris_audioContentsString() throws Exception { final Uri audioContents = Uri.parse("content://com.example/audio"); Bundle extras = new Bundle(); extras.putString(Notification.EXTRA_AUDIO_CONTENTS_URI, audioContents.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)); } @Test public void testSetNotificationPolicy_preP_setOldFields() { ZenModeHelper mZenModeHelper = mock(ZenModeHelper.class); Loading