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

Commit 364105af authored by Ioana Alexandru's avatar Ioana Alexandru Committed by Automerger Merge Worker
Browse files

Check URIs in notification public version. am: 67cd169d

parents 19281f9b 67cd169d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2761,6 +2761,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
@@ -4482,6 +4482,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");