diff options
author | Andriy Naborskyy <andriyn@google.com> | 2023-04-21 18:03:55 +0000 |
---|---|---|
committer | Andriy Naborskyy <andriyn@google.com> | 2023-04-22 00:25:34 +0000 |
commit | c2bb2f86ed7d611a160af196ca01fcc0a09d5b28 (patch) | |
tree | be9351ab662b86f5237e9662446d8d0c05ec8614 /tests | |
parent | 278eccab9c71b9fe89e06da9dab2e2b92ed93e67 (diff) | |
download | CellBroadcastReceiver-c2bb2f86ed7d611a160af196ca01fcc0a09d5b28.tar.gz |
Watch embeded info sound
Workaround for watch platform to include info resource into app.
Sound resource is from clockwork/audio_assets/notifications/Tethys.ogg
Bug: 277640773
Bug: 279183006
Test: receive 911 message in TW mcc should play notification sound.
Change-Id: I90f4bb74ee21f6b3d507ea8ba00aca81b55f3c24
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastAlertAudioTest.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastAlertAudioTest.java b/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastAlertAudioTest.java index 6cb54d98d..ac5544c5c 100644 --- a/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastAlertAudioTest.java +++ b/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastAlertAudioTest.java @@ -119,6 +119,15 @@ public class CellBroadcastAlertAudioTest extends super.tearDown(); } + private Intent createStartAudioIntent() { + Intent intent = new Intent(mContext, CellBroadcastAlertAudio.class); + intent.putExtra(CellBroadcastAlertAudio.ALERT_AUDIO_MESSAGE_BODY, + TEST_MESSAGE_BODY); + intent.putExtra(CellBroadcastAlertAudio.ALERT_AUDIO_VIBRATION_PATTERN_EXTRA, + TEST_VIBRATION_PATTERN); + return intent; + } + public void testStartService() throws Throwable { PhoneStateListenerHandler phoneStateListenerHandler = new PhoneStateListenerHandler( "testStartService", @@ -145,6 +154,45 @@ public class CellBroadcastAlertAudioTest extends phoneStateListenerHandler.quit(); } + public void testPlayAlertToneInfo() throws Throwable { + setWatchFeatureEnabled(false); + doReturn(AudioManager.RINGER_MODE_NORMAL).when( + mMockedAudioManager).getRingerMode(); + PhoneStateListenerHandler phoneStateListenerHandler = new PhoneStateListenerHandler( + "testPlayAlertToneInfo", + () -> { + Intent intent = createStartAudioIntent(); + intent.putExtra(CellBroadcastAlertAudio.ALERT_AUDIO_TONE_TYPE, + CellBroadcastAlertService.AlertType.INFO); + startService(intent); + }); + phoneStateListenerHandler.start(); + waitUntilReady(); + verify(mMockedAudioManager).getRingerMode(); + verify(mMockedVibrator).vibrate(any(), any(AudioAttributes.class)); + phoneStateListenerHandler.quit(); + } + + public void testPlayAlertToneInfoForWatch() throws Throwable { + setWatchFeatureEnabled(true); + doReturn(AudioManager.RINGER_MODE_NORMAL).when( + mMockedAudioManager).getRingerMode(); + PhoneStateListenerHandler phoneStateListenerHandler = new PhoneStateListenerHandler( + "testPlayAlertToneInfoForWatch", + () -> { + + Intent intent = createStartAudioIntent(); + intent.putExtra(CellBroadcastAlertAudio.ALERT_AUDIO_TONE_TYPE, + CellBroadcastAlertService.AlertType.INFO); + startService(intent); + }); + phoneStateListenerHandler.start(); + waitUntilReady(); + verify(mMockedAudioManager).getRingerMode(); + verify(mMockedVibrator).vibrate(any(), any(AudioAttributes.class)); + phoneStateListenerHandler.quit(); + } + /** * If the user is currently not in a call and the override DND flag is set, the volume will be * set to max. |