diff options
author | Brandon Maxwell <maxwelb@google.com> | 2016-01-29 17:49:28 -0800 |
---|---|---|
committer | Brandon Maxwell <maxwelb@google.com> | 2016-01-29 18:43:55 -0800 |
commit | 249c755441938ead47c01d27c168c4096e0d9769 (patch) | |
tree | 26cfe0ece4c8e622a314c613478ce97b36308456 /InCallUI | |
parent | cc7e5a7a71ecd3037802668be19935270f9c0216 (diff) |
Adding method to check if call waiting tone should be played
+ This method will be used in StatusBarNotifier to determine when
call waiting tones should be played instead of the standard ringtone
Change-Id: I4ad55f3870de5e63d03f4a5e8534680fa24556bd
Diffstat (limited to 'InCallUI')
3 files changed, 45 insertions, 0 deletions
diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java index 48e0b1c34..985c88565 100644 --- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java +++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java @@ -305,6 +305,9 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, notification.audioAttributes = audioAttributes.build(); notification.vibrate = VIBRATE_PATTERN; } + if (mDialerRingtoneManager.shouldPlayCallWaitingTone(callState)) { + // TODO (maxwelb) play call waiting + } if (mCurrentNotification != notificationType && mCurrentNotification != NOTIFICATION_NONE) { Log.i(this, "Previous notification already showing - cancelling " + mCurrentNotification); diff --git a/InCallUI/src/com/android/incallui/ringtone/DialerRingtoneManager.java b/InCallUI/src/com/android/incallui/ringtone/DialerRingtoneManager.java index ad580cb0d..8d4d068e1 100644 --- a/InCallUI/src/com/android/incallui/ringtone/DialerRingtoneManager.java +++ b/InCallUI/src/com/android/incallui/ringtone/DialerRingtoneManager.java @@ -53,6 +53,19 @@ public class DialerRingtoneManager { return mForceDialerRingingEnabled || IS_DIALER_RINGING_ENABLED; } + /** + * Determines if a call waiting tone should be played for the the given call state + * (see {@link State}). + * + * @param callState the call state for the call being checked. + * @return {@code true} if the call waiting tone should be played, {@code false} otherwise. + */ + public boolean shouldPlayCallWaitingTone(int callState) { + return CompatUtils.isNCompatible() + && isDialerRingingEnabled() + && callState == State.CALL_WAITING; + } + @NeededForTesting void forceDialerRingingEnabled() { mForceDialerRingingEnabled = true; diff --git a/InCallUI/tests/src/com/android/incallui/ringtone/RingtoneManagerTest.java b/InCallUI/tests/src/com/android/incallui/ringtone/RingtoneManagerTest.java index 768843e1c..f94f71daa 100644 --- a/InCallUI/tests/src/com/android/incallui/ringtone/RingtoneManagerTest.java +++ b/InCallUI/tests/src/com/android/incallui/ringtone/RingtoneManagerTest.java @@ -72,4 +72,33 @@ public class RingtoneManagerTest extends AndroidTestCase { assertTrue(mRingtoneManager.shouldPlayRingtone(State.INCOMING, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE))); } + + public void testShouldPlayCallWaitingTone_M() { + if (CompatUtils.isNCompatible()) { + return; + } + assertFalse(mRingtoneManager.shouldPlayCallWaitingTone(0)); + } + + public void testShouldPlayCallWaitingTone_N_NotCallWaiting() { + if (!CompatUtils.isNCompatible()) { + return; + } + assertFalse(mRingtoneManager.shouldPlayCallWaitingTone(State.ACTIVE)); + } + + // Specific case for incoming since it plays its own sound + public void testShouldPlayCallWaitingTone_N_Incoming() { + if (!CompatUtils.isNCompatible()) { + return; + } + assertFalse(mRingtoneManager.shouldPlayCallWaitingTone(State.INCOMING)); + } + + public void testShouldPlayCallWaitingTone_N() { + if (!CompatUtils.isNCompatible()) { + return; + } + assertTrue(mRingtoneManager.shouldPlayCallWaitingTone(State.CALL_WAITING)); + } } |