Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2d38b1c4 authored by Grant Menke's avatar Grant Menke
Browse files

Remove the EnsureInCarRinging flag.

Removes the flag and obsolete code related to EnsureInCarRinging. Updates the UT to ensure correct behavior now that the flag has been completely removed.

Flag: EXEMPT flag cleanup
Fixes: 409610414
Test: atest RingerTest
Change-Id: I22390d4ef36214ac67106a67a1ad1c87b3978e34
parent 115c5a0b
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -9,15 +9,6 @@ flag {
  bug: "282113261"
}

# OWNER=grantmenke TARGET=24Q4
flag {
  name: "ensure_in_car_ringing"
  namespace: "telecom"
  description: "Gates whether to ensure that when a user is in their car, they are able to hear ringing for an incoming call."
  bug: "348708398"
}


# OWNER=tjstuart TARGET=25Q1
flag {
  name: "get_ringer_mode_anom_report"
+3 −4
Original line number Diff line number Diff line
@@ -444,10 +444,9 @@ public class CallAudioManager extends CallsManagerListenerBase {

    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public void onRingerModeChange() {
        if (mFeatureFlags.ensureInCarRinging()) {
        // Stop the current ringtone before attempting to start the new ringtone:
        stopRinging();
        }

        mCallAudioModeStateMachine.sendMessageWithArgs(
                CallAudioModeStateMachine.RINGER_MODE_CHANGE, makeArgsForModeStateMachine());
    }
+5 −8
Original line number Diff line number Diff line
@@ -787,14 +787,11 @@ public class Ringer {

        boolean isVolumeOverZero;

        if (mFlags.ensureInCarRinging()) {
        AudioAttributes aa = new AudioAttributes.Builder()
                .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
                .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION).build();
        isVolumeOverZero = mAudioManager.shouldNotificationSoundPlay(aa);
        } else {
            isVolumeOverZero = mAudioManager.getStreamVolume(AudioManager.STREAM_RING) > 0;
        }

        timer.record("isVolumeOverZero");
        boolean shouldRingForContact = shouldRingForContact(call);
        timer.record("shouldRingForContact");
+2 −2
Original line number Diff line number Diff line
@@ -319,7 +319,7 @@ public class MissedInformationTest extends TelecomSystemTest {
        mCallsManager.onCallFilteringComplete(mIncomingCall, result, false);

        // Wait for ringer attributes build completed
        verify(mAudioManager, timeout(TEST_TIMEOUT_MILLIS)).getStreamVolume(anyInt());
        verify(mAudioManager, timeout(TEST_TIMEOUT_MILLIS)).shouldNotificationSoundPlay(any());
        mCallsManager.getRinger().waitForAttributesCompletion();

        mCallsManager.markCallAsDisconnected(mIncomingCall,
@@ -343,7 +343,7 @@ public class MissedInformationTest extends TelecomSystemTest {
        mCallsManager.onCallFilteringComplete(mIncomingCall, result, false);

        // Wait for ringer attributes build completed
        verify(mAudioManager, timeout(TEST_TIMEOUT_MILLIS)).getStreamVolume(anyInt());
        verify(mAudioManager, timeout(TEST_TIMEOUT_MILLIS)).shouldNotificationSoundPlay(any());
        mCallsManager.getRinger().waitForAttributesCompletion();

        mCallsManager.markCallAsDisconnected(mIncomingCall,
+36 −17
Original line number Diff line number Diff line
@@ -154,10 +154,10 @@ public class RingerTest extends TelecomTestCase {
        super.setUp();
        mContext = spy(mComponentContextFixture.getTestDouble().getApplicationContext());
        when(mFeatureFlags.telecomResolveHiddenDependencies()).thenReturn(true);
        when(mFeatureFlags.ensureInCarRinging()).thenReturn(false);
        doReturn(URI_VIBRATION_EFFECT).when(spyVibrationEffectProxy).get(any(), any());
        when(mockPlayerFactory.createPlayer(any(Call.class), anyInt())).thenReturn(mockTonePlayer);
        mockAudioManager = mContext.getSystemService(AudioManager.class);
        mockAudioManager = mock(AudioManager.class);
        when(mContext.getSystemService(AudioManager.class)).thenReturn(mockAudioManager);
        when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
        when(mockVibrator.getInfo()).thenReturn(mockVibratorInfo);
        when(mockSystemSettingsUtil.isHapticPlaybackSupported(any(Context.class)))
@@ -457,7 +457,6 @@ public class RingerTest extends TelecomTestCase {
    @SmallTest
    @Test
    public void testAudibleRingWhenNotificationSoundShouldPlay() throws Exception {
        when(mFeatureFlags.ensureInCarRinging()).thenReturn(true);
        Ringtone mockRingtone = ensureRingtoneMocked();

        mRingerUnderTest.startCallWaiting(mockCall1);
@@ -468,9 +467,11 @@ public class RingerTest extends TelecomTestCase {
        when(mockAudioManager.shouldNotificationSoundPlay(aa)).thenReturn(true);
        enableVibrationWhenRinging();

        // This will set AudioManager#getStreamVolume to 0. This test ensures that whether a
        // ringtone is audible is controlled by AudioManager#shouldNotificationSoundPlay instead:
        ensureRingerIsNotAudible();
        // This will set AudioManager#getStreamVolume to 0. This test ensures that
        // whether a ringtone is audible is controlled by AudioManager#shouldNotificationSoundPlay
        // instead:
        when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
        when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(0);

        // Ensure an audible ringtone is played:
        assertTrue(startRingingAndWaitForAsync(mockCall2, false));
@@ -487,7 +488,6 @@ public class RingerTest extends TelecomTestCase {
    @SmallTest
    @Test
    public void testNoAudibleRingWhenNotificationSoundShouldNotPlay() throws Exception {
        when(mFeatureFlags.ensureInCarRinging()).thenReturn(true);
        Ringtone mockRingtone = ensureRingtoneMocked();

        mRingerUnderTest.startCallWaiting(mockCall1);
@@ -498,9 +498,11 @@ public class RingerTest extends TelecomTestCase {
        when(mockAudioManager.shouldNotificationSoundPlay(aa)).thenReturn(false);
        enableVibrationWhenRinging();

        // This will set AudioManager#getStreamVolume to 100. This test ensures that whether a
        // ringtone is audible is controlled by AudioManager#shouldNotificationSoundPlay instead:
        ensureRingerIsAudible();
        // This will set AudioManager#getStreamVolume to 100. This test ensures that
        // whether a ringtone is audible is controlled by AudioManager#shouldNotificationSoundPlay
        // instead:
        when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
        when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(100);

        // Ensure no audible ringtone is played:
        assertFalse(startRingingAndWaitForAsync(mockCall2, false));
@@ -520,6 +522,8 @@ public class RingerTest extends TelecomTestCase {
        mRingerUnderTest.startCallWaiting(mockCall1);
        when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
        enableVibrationWhenRinging();
        // Need audio to be considered playable
        ensureRingerIsAudible();
        // The ringtone isn't known to be null until the async portion after the call completes,
        // so startRinging still returns true here as there should nominally be a ringtone.
        // Notably, vibration still happens in this scenario.
@@ -545,7 +549,8 @@ public class RingerTest extends TelecomTestCase {
        when(mockRingtoneFactory.getRingtone(any(Call.class), eq(null), anyBoolean()))
            .thenReturn(new Pair(FAKE_RINGTONE_URI, mockRingtone));
        when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
        when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(0);
        when(mockAudioManager.shouldNotificationSoundPlay(any(AudioAttributes.class)))
                .thenReturn(false);
        enableVibrationWhenRinging();
        assertFalse(startRingingAndWaitForAsync(mockCall2, false));
        verify(mockTonePlayer).stopTone();
@@ -562,7 +567,8 @@ public class RingerTest extends TelecomTestCase {
        createRingerUnderTest();  // Needed after changing haptic playback support.
        mRingerUnderTest.startCallWaiting(mockCall1);
        when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
        when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(0);
        when(mockAudioManager.shouldNotificationSoundPlay(any(AudioAttributes.class)))
                .thenReturn(false);
        enableVibrationWhenRinging();
        assertFalse(startRingingAndWaitForAsync(mockCall2, false));
        verify(mockTonePlayer).stopTone();
@@ -581,6 +587,8 @@ public class RingerTest extends TelecomTestCase {
        when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
        when(mockRingtone.getUri()).thenReturn(FAKE_RINGTONE_URI);
        enableVibrationWhenRinging();
        // Need audio to be considered playable
        ensureRingerIsAudible();
        assertTrue(startRingingAndWaitForAsync(mockCall2, false));
        verify(mockTonePlayer).stopTone();
        verify(mockRingtoneFactory, atLeastOnce())
@@ -631,7 +639,8 @@ public class RingerTest extends TelecomTestCase {
    public void testSilentRingWithHfpStillAcquiresFocus() throws Exception {
        mRingerUnderTest.startCallWaiting(mockCall1);
        when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
        when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(0);
        when(mockAudioManager.shouldNotificationSoundPlay(any(AudioAttributes.class)))
                .thenReturn(false);
        enableVibrationOnlyWhenNotRinging();
        assertTrue(startRingingAndWaitForAsync(mockCall2, true));
        verify(mockTonePlayer).stopTone();
@@ -650,7 +659,8 @@ public class RingerTest extends TelecomTestCase {
        when(mockNotificationManager.getCurrentInterruptionFilter()).thenReturn(
                NotificationManager.INTERRUPTION_FILTER_PRIORITY);
        when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_SILENT);
        when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(100);
        when(mockAudioManager.shouldNotificationSoundPlay(any(AudioAttributes.class)))
                .thenReturn(true);
        enableVibrationWhenRinging();
        assertTrue(startRingingAndWaitForAsync(mockCall2, true));
        verify(mockRingtoneFactory, atLeastOnce())
@@ -796,6 +806,9 @@ public class RingerTest extends TelecomTestCase {
        when(mockCall2.wasDndCheckComputedForCall()).thenReturn(false);
        when(mockCall2.getHandle()).thenReturn(Uri.parse(""));

        // Ringer needs to be audible to start flash/ring
        ensureRingerIsAudible();

        assertTrue(mRingerUnderTest.shouldRingForContact(mockCall2));
        assertTrue(startRingingAndWaitForAsync(mockCall2, false));
        verify(mockAccessibilityManagerAdapter, atLeastOnce())
@@ -822,6 +835,9 @@ public class RingerTest extends TelecomTestCase {
        when(mockCall2.wasDndCheckComputedForCall()).thenReturn(false);
        when(mockCall2.getHandle()).thenReturn(Uri.parse(""));

        // Ringer needs to be audible to start flash/ring
        ensureRingerIsAudible();

        assertTrue(mRingerUnderTest.shouldRingForContact(mockCall2));
        assertTrue(mRingerUnderTest.startRinging(mockCall2, false));
        mRingerUnderTest.stopRinging();
@@ -872,7 +888,8 @@ public class RingerTest extends TelecomTestCase {

            mRingerUnderTest.startCallWaiting(mockCall1);
            when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
            when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(0);
            when(mockAudioManager.shouldNotificationSoundPlay(any(AudioAttributes.class)))
                    .thenReturn(false);
            enableVibrationWhenRinging();
            assertFalse(startRingingAndWaitForAsync(mockCall2, false));

@@ -904,12 +921,14 @@ public class RingerTest extends TelecomTestCase {

    private void ensureRingerIsAudible() {
        when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
        when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(100);
        when(mockAudioManager.shouldNotificationSoundPlay(any(AudioAttributes.class)))
                .thenReturn(true);
    }

    private void ensureRingerIsNotAudible() {
        when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
        when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(0);
        when(mockAudioManager.shouldNotificationSoundPlay(any(AudioAttributes.class)))
                .thenReturn(false);
    }

    private void enableVibrationWhenRinging() {