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

Commit d013fed9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Visit Uris added by WearableExtender" into rvc-dev am: 34523984

parents 99424fe5 34523984
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -1831,6 +1831,10 @@ public class Notification implements Parcelable
            }
        }

        private void visitUris(@NonNull Consumer<Uri> visitor) {
            visitIconUri(visitor, getIcon());
        }

        @Override
        public Action clone() {
            return new Action(
@@ -2508,7 +2512,7 @@ public class Notification implements Parcelable

        if (actions != null) {
            for (Action action : actions) {
                visitIconUri(visitor, action.getIcon());
                action.visitUris(visitor);
            }
        }

@@ -2579,6 +2583,11 @@ public class Notification implements Parcelable
        if (mBubbleMetadata != null) {
            visitIconUri(visitor, mBubbleMetadata.getIcon());
        }

        if (extras != null && extras.containsKey(WearableExtender.EXTRA_WEARABLE_EXTENSIONS)) {
            WearableExtender extender = new WearableExtender(this);
            extender.visitUris(visitor);
        }
    }

    /**
@@ -10288,6 +10297,12 @@ public class Notification implements Parcelable
                mFlags &= ~mask;
            }
        }

        private void visitUris(@NonNull Consumer<Uri> visitor) {
            for (Action action : mActions) {
                action.visitUris(visitor);
            }
        }
    }

    /**
+20 −0
Original line number Diff line number Diff line
@@ -4420,6 +4420,26 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        verify(visitor, times(1)).accept(eq(personIcon3.getUri()));
    }

    @Test
    public void testVisitUris_wearableExtender() {
        Icon actionIcon = Icon.createWithContentUri("content://media/action");
        Icon wearActionIcon = Icon.createWithContentUri("content://media/wearAction");
        PendingIntent intent = PendingIntent.getActivity(mContext, 0, new Intent(),
                PendingIntent.FLAG_IMMUTABLE);
        Notification n = new Notification.Builder(mContext, "a")
                .setSmallIcon(android.R.drawable.sym_def_app_icon)
                .addAction(new Notification.Action.Builder(actionIcon, "Hey!", intent).build())
                .extend(new Notification.WearableExtender().addAction(
                        new Notification.Action.Builder(wearActionIcon, "Wear!", intent).build()))
                .build();

        Consumer<Uri> visitor = (Consumer<Uri>) spy(Consumer.class);
        n.visitUris(visitor);

        verify(visitor).accept(eq(actionIcon.getUri()));
        verify(visitor).accept(eq(wearActionIcon.getUri()));
    }

    @Test
    public void testSetNotificationPolicy_preP_setOldFields() {
        ZenModeHelper mZenModeHelper = mock(ZenModeHelper.class);