Loading src/com/android/server/telecom/Ringer.java +15 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.app.NotificationManager; import android.content.Context; import android.os.VibrationEffect; import android.telecom.Log; import android.telecom.TelecomManager; import android.media.AudioAttributes; import android.media.AudioManager; import android.net.Uri; Loading Loading @@ -125,6 +126,7 @@ public class Ringer { boolean isSelfManaged = foregroundCall.isSelfManaged(); boolean isRingerAudible = isVolumeOverZero && shouldRingForContact && isRingtonePresent; boolean hasExternalRinger = hasExternalRinger(foregroundCall); // Acquire audio focus under any of the following conditions: // 1. Should ring for contact and there's an HFP device attached // 2. Volume is over zero, we should ring for the contact, and there's a audible ringtone Loading @@ -136,14 +138,16 @@ public class Ringer { // Don't do call waiting operations or vibration unless these are false. boolean isTheaterModeOn = mSystemSettingsUtil.isTheaterModeOn(mContext); boolean letDialerHandleRinging = mInCallController.doesConnectedDialerSupportRinging(); boolean endEarly = isTheaterModeOn || letDialerHandleRinging || isSelfManaged; boolean endEarly = isTheaterModeOn || letDialerHandleRinging || isSelfManaged || hasExternalRinger; if (endEarly) { if (letDialerHandleRinging) { Log.addEvent(foregroundCall, LogUtils.Events.SKIP_RINGING); } Log.i(this, "Ending early -- isTheaterModeOn=%s, letDialerHandleRinging=%s, " + "isSelfManaged=%s", isTheaterModeOn, letDialerHandleRinging, isSelfManaged); "isSelfManaged=%s, hasExternalRinger=%s", isTheaterModeOn, letDialerHandleRinging, isSelfManaged, hasExternalRinger); return shouldAcquireAudioFocus; } Loading Loading @@ -241,6 +245,15 @@ public class Ringer { return manager.matchesCallFilter(extras); } private boolean hasExternalRinger(Call foregroundCall) { Bundle intentExtras = foregroundCall.getIntentExtras(); if (intentExtras != null) { return intentExtras.getBoolean(TelecomManager.EXTRA_CALL_EXTERNAL_RINGER, false); } else { return false; } } private boolean shouldVibrate(Context context, Call call) { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); int ringerMode = audioManager.getRingerModeInternal(); Loading tests/src/com/android/server/telecom/tests/RingerTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.media.Ringtone; import android.os.Bundle; import android.os.VibrationEffect; import android.os.Vibrator; import android.telecom.TelecomManager; import android.test.suitebuilder.annotation.SmallTest; import com.android.server.telecom.AsyncRingtonePlayer; Loading Loading @@ -94,6 +95,22 @@ public class RingerTest extends TelecomTestCase { .vibrate(any(VibrationEffect.class), any(AudioAttributes.class)); } @SmallTest @Test public void testNoActionWithExternalRinger() { Bundle externalRingerExtra = new Bundle(); externalRingerExtra.putBoolean(TelecomManager.EXTRA_CALL_EXTERNAL_RINGER, true); when(mockCall1.getIntentExtras()).thenReturn(externalRingerExtra); when(mockCall2.getIntentExtras()).thenReturn(externalRingerExtra); // Start call waiting to make sure that it doesn't stop when we start ringing mRingerUnderTest.startCallWaiting(mockCall1); assertFalse(mRingerUnderTest.startRinging(mockCall2, false)); verify(mockTonePlayer, never()).stopTone(); verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class)); verify(mockVibrator, never()) .vibrate(any(VibrationEffect.class), any(AudioAttributes.class)); } @SmallTest @Test public void testNoActionWhenDialerRings() { Loading Loading
src/com/android/server/telecom/Ringer.java +15 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.app.NotificationManager; import android.content.Context; import android.os.VibrationEffect; import android.telecom.Log; import android.telecom.TelecomManager; import android.media.AudioAttributes; import android.media.AudioManager; import android.net.Uri; Loading Loading @@ -125,6 +126,7 @@ public class Ringer { boolean isSelfManaged = foregroundCall.isSelfManaged(); boolean isRingerAudible = isVolumeOverZero && shouldRingForContact && isRingtonePresent; boolean hasExternalRinger = hasExternalRinger(foregroundCall); // Acquire audio focus under any of the following conditions: // 1. Should ring for contact and there's an HFP device attached // 2. Volume is over zero, we should ring for the contact, and there's a audible ringtone Loading @@ -136,14 +138,16 @@ public class Ringer { // Don't do call waiting operations or vibration unless these are false. boolean isTheaterModeOn = mSystemSettingsUtil.isTheaterModeOn(mContext); boolean letDialerHandleRinging = mInCallController.doesConnectedDialerSupportRinging(); boolean endEarly = isTheaterModeOn || letDialerHandleRinging || isSelfManaged; boolean endEarly = isTheaterModeOn || letDialerHandleRinging || isSelfManaged || hasExternalRinger; if (endEarly) { if (letDialerHandleRinging) { Log.addEvent(foregroundCall, LogUtils.Events.SKIP_RINGING); } Log.i(this, "Ending early -- isTheaterModeOn=%s, letDialerHandleRinging=%s, " + "isSelfManaged=%s", isTheaterModeOn, letDialerHandleRinging, isSelfManaged); "isSelfManaged=%s, hasExternalRinger=%s", isTheaterModeOn, letDialerHandleRinging, isSelfManaged, hasExternalRinger); return shouldAcquireAudioFocus; } Loading Loading @@ -241,6 +245,15 @@ public class Ringer { return manager.matchesCallFilter(extras); } private boolean hasExternalRinger(Call foregroundCall) { Bundle intentExtras = foregroundCall.getIntentExtras(); if (intentExtras != null) { return intentExtras.getBoolean(TelecomManager.EXTRA_CALL_EXTERNAL_RINGER, false); } else { return false; } } private boolean shouldVibrate(Context context, Call call) { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); int ringerMode = audioManager.getRingerModeInternal(); Loading
tests/src/com/android/server/telecom/tests/RingerTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.media.Ringtone; import android.os.Bundle; import android.os.VibrationEffect; import android.os.Vibrator; import android.telecom.TelecomManager; import android.test.suitebuilder.annotation.SmallTest; import com.android.server.telecom.AsyncRingtonePlayer; Loading Loading @@ -94,6 +95,22 @@ public class RingerTest extends TelecomTestCase { .vibrate(any(VibrationEffect.class), any(AudioAttributes.class)); } @SmallTest @Test public void testNoActionWithExternalRinger() { Bundle externalRingerExtra = new Bundle(); externalRingerExtra.putBoolean(TelecomManager.EXTRA_CALL_EXTERNAL_RINGER, true); when(mockCall1.getIntentExtras()).thenReturn(externalRingerExtra); when(mockCall2.getIntentExtras()).thenReturn(externalRingerExtra); // Start call waiting to make sure that it doesn't stop when we start ringing mRingerUnderTest.startCallWaiting(mockCall1); assertFalse(mRingerUnderTest.startRinging(mockCall2, false)); verify(mockTonePlayer, never()).stopTone(); verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class)); verify(mockVibrator, never()) .vibrate(any(VibrationEffect.class), any(AudioAttributes.class)); } @SmallTest @Test public void testNoActionWhenDialerRings() { Loading