Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40659fab authored by Ioana Alexandru's avatar Ioana Alexandru Committed by Android Build Coastguard Worker
Browse files

Check URIs in notification public version.

Bug: 276294099
Test: atest NotificationManagerServiceTest NotificationVisitUrisTest
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:67cd169d073486c7c047b80ab83843cdee69bf53)
Merged-In: I670198b213abb2cb29a9865eb9d1e897700508b4
Change-Id: I670198b213abb2cb29a9865eb9d1e897700508b4
parent f72b614d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2807,6 +2807,10 @@ public class Notification implements Parcelable
     * @hide
     */
    public void visitUris(@NonNull Consumer<Uri> visitor) {
        if (publicVersion != null) {
            publicVersion.visitUris(visitor);
        }
        visitor.accept(sound);
        if (tickerView != null) tickerView.visitUris(visitor);
+20 −0
Original line number Diff line number Diff line
@@ -5427,6 +5427,26 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        verify(visitor, times(1)).accept(eq(historyUri2));
    }

    @Test
    public void testVisitUris_publicVersion() throws Exception {
        final Icon smallIconPublic = Icon.createWithContentUri("content://media/small/icon");
        final Icon largeIconPrivate = Icon.createWithContentUri("content://media/large/icon");

        Notification publicVersion = new Notification.Builder(mContext, "a")
                .setContentTitle("notification with uris")
                .setSmallIcon(smallIconPublic)
                .build();
        Notification n = new Notification.Builder(mContext, "a")
                .setLargeIcon(largeIconPrivate)
                .setPublicVersion(publicVersion)
                .build();

        Consumer<Uri> visitor = (Consumer<Uri>) spy(Consumer.class);
        n.visitUris(visitor);
        verify(visitor, times(1)).accept(eq(smallIconPublic.getUri()));
        verify(visitor, times(1)).accept(eq(largeIconPrivate.getUri()));
    }

    @Test
    public void testVisitUris_audioContentsString() throws Exception {
        final Uri audioContents = Uri.parse("content://com.example/audio");