Merge "Visit Uris added by WearableExtender" into sc-dev am: 917c91ed5f am: aed7e0e6c4 am: 7ddb25c9c4 am: 4251379163

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23905843

Change-Id: I2d54c6ddc772bad7d8c1ad59261d9f375e1c52ec
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Matías Hernández
2023-07-07 15:48:51 +00:00
committed by Automerger Merge Worker
2 changed files with 36 additions and 1 deletions

View File

@@ -2138,6 +2138,10 @@ public class Notification implements Parcelable
} }
} }
private void visitUris(@NonNull Consumer<Uri> visitor) {
visitIconUri(visitor, getIcon());
}
@Override @Override
public Action clone() { public Action clone() {
return new Action( return new Action(
@@ -2823,7 +2827,7 @@ public class Notification implements Parcelable
if (actions != null) { if (actions != null) {
for (Action action : actions) { for (Action action : actions) {
visitIconUri(visitor, action.getIcon()); action.visitUris(visitor);
} }
} }
@@ -2912,6 +2916,11 @@ public class Notification implements Parcelable
if (mBubbleMetadata != null) { if (mBubbleMetadata != null) {
visitIconUri(visitor, mBubbleMetadata.getIcon()); visitIconUri(visitor, mBubbleMetadata.getIcon());
} }
if (extras != null && extras.containsKey(WearableExtender.EXTRA_WEARABLE_EXTENSIONS)) {
WearableExtender extender = new WearableExtender(this);
extender.visitUris(visitor);
}
} }
/** /**
@@ -11594,6 +11603,12 @@ public class Notification implements Parcelable
mFlags &= ~mask; mFlags &= ~mask;
} }
} }
private void visitUris(@NonNull Consumer<Uri> visitor) {
for (Action action : mActions) {
action.visitUris(visitor);
}
}
} }
/** /**

View File

@@ -5290,6 +5290,26 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
verify(visitor, times(1)).accept(eq(verificationIcon.getUri())); verify(visitor, times(1)).accept(eq(verificationIcon.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 @Test
public void testSetNotificationPolicy_preP_setOldFields() { public void testSetNotificationPolicy_preP_setOldFields() {
ZenModeHelper mZenModeHelper = mock(ZenModeHelper.class); ZenModeHelper mZenModeHelper = mock(ZenModeHelper.class);