diff options
author | Calvin On <con@google.com> | 2023-04-14 02:03:42 +0000 |
---|---|---|
committer | Andriy Naborskyy <andriyn@google.com> | 2023-04-21 07:02:49 +0000 |
commit | 81e69eba548ce647cb9589c38c1b329ba016246b (patch) | |
tree | dc6da94d0f7d3972f0b63d48c0b3a7fa43a7e338 /tests | |
parent | 7546da88e4a84871715cbca92e80c4868bf0b489 (diff) | |
download | CellBroadcastReceiver-81e69eba548ce647cb9589c38c1b329ba016246b.tar.gz |
Generate unique CellBroadcast notifications on watch.
CellBroadcast notifications on the watch need to be unique
in order to not overwrite each other when they occur in succession.
Bug: 208530993
Test: Manual; trigger test alerts, verify notifications no longer
overwrite one another
Test: atest CellBroadcastReceiverOemUnitTests
Change-Id: I2dc4c2eea7fb50f744bb88a1cbc052fb3425f56c
Diffstat (limited to 'tests')
2 files changed, 8 insertions, 3 deletions
diff --git a/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastAlertServiceTest.java b/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastAlertServiceTest.java index a940fc353..8a28552d7 100644 --- a/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastAlertServiceTest.java +++ b/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastAlertServiceTest.java @@ -583,7 +583,7 @@ public class CellBroadcastAlertServiceTest extends Intent intent = new Intent(mContext, CellBroadcastAlertService.class); intent.setAction(SHOW_NEW_ALERT_ACTION); - SmsCbMessage message = createMessage(14788634); + SmsCbMessage message = createMessageForCmasMessageClass(0xbbaa, 0x1112, 0); intent.putExtra("message", message); startService(intent); @@ -627,7 +627,7 @@ public class CellBroadcastAlertServiceTest extends ArgumentCaptor<Notification> notificationCaptor = ArgumentCaptor.forClass(Notification.class); verify(mMockedNotificationManager, times(1)) - .notify(eq(CellBroadcastAlertService.NOTIFICATION_ID), notificationCaptor.capture()); + .notify(eq(0x1112bbaa), notificationCaptor.capture()); Notification notificationPosted = notificationCaptor.getValue(); assertTrue(notificationPosted.deleteIntent.isBroadcast()); assertEquals(1, notificationPosted.actions.length); diff --git a/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastInternalReceiverTest.java b/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastInternalReceiverTest.java index ebaa06ce5..8d879efe1 100644 --- a/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastInternalReceiverTest.java +++ b/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastInternalReceiverTest.java @@ -49,6 +49,8 @@ public class CellBroadcastInternalReceiverTest extends CellBroadcastTest { private Configuration mConfiguration = new Configuration(); private CellBroadcastInternalReceiver mReceiver; + private static final int TEST_NOTIFICATION_ID = 0x123; + @Before public void setUp() throws Exception { super.setUp(this.getClass().getSimpleName()); @@ -68,13 +70,16 @@ public class CellBroadcastInternalReceiverTest extends CellBroadcastTest { doReturn(mockNotificationManager).when(mContext) .getSystemService(Context.NOTIFICATION_SERVICE); doReturn(CellBroadcastReceiver.ACTION_MARK_AS_READ).when(mIntent).getAction(); + doReturn(TEST_NOTIFICATION_ID).when(mIntent).getIntExtra( + CellBroadcastReceiver.EXTRA_NOTIF_ID, + CellBroadcastAlertService.NOTIFICATION_ID); doNothing().when(mReceiver).getCellBroadcastTask(nullable(Context.class), anyLong()); mReceiver.onReceive(mContext, mIntent); verify(mIntent).getLongExtra(CellBroadcastReceiver.EXTRA_DELIVERY_TIME, -1); verify(mReceiver).getCellBroadcastTask(nullable(Context.class), anyLong()); - verify(mockNotificationManager).cancel(CellBroadcastAlertService.NOTIFICATION_ID); + verify(mockNotificationManager).cancel(TEST_NOTIFICATION_ID); } @Test |