diff options
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)); + } } |