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

Commit 1ecd00f1 authored by Brad Ebinger's avatar Brad Ebinger Committed by Android (Google) Code Review
Browse files

Merge "Removes the use_stream_voice_call_tones flag" into main

parents ac9948ed a6869a3a
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -45,17 +45,6 @@ flag {
    }
}

# OWNER=breadley TARGET=24Q4
flag {
  name: "use_stream_voice_call_tones"
  namespace: "telecom"
  description: "Use STREAM_VOICE_CALL only for ToneGenerator"
  bug: "363262590"
  metadata {
      purpose: PURPOSE_BUGFIX
    }
}

# OWNER=breadley TARGET=25Q2
flag {
  name: "enable_respond_via_sms_manager_async"
+1 −26
Original line number Diff line number Diff line
@@ -375,7 +375,7 @@ public class InCallTonePlayer extends Thread {
                    throw new IllegalStateException("Bad toneId: " + mToneId);
            }

            int stream = getStreamType(toneType);
            int stream = AudioManager.STREAM_VOICE_CALL;
            if (toneType != ToneGenerator.TONE_UNKNOWN) {
                playToneGeneratorTone(stream, toneVolume, toneType, toneLengthMillis);
            } else if (mediaResourceId != TONE_RESOURCE_ID_UNDEFINED) {
@@ -387,31 +387,6 @@ public class InCallTonePlayer extends Thread {
        }
    }

    /**
     * @param toneType The ToneGenerator tone type
     * @return The ToneGenerator stream type
     */
    private int getStreamType(int toneType) {
        if (mFeatureFlags.useStreamVoiceCallTones()) {
            return AudioManager.STREAM_VOICE_CALL;
        }

        int stream = AudioManager.STREAM_VOICE_CALL;
        if (mCallAudioRoutePeripheralAdapter.isBluetoothAudioOn()) {
            stream = AudioManager.STREAM_BLUETOOTH_SCO;
        }
        if (toneType != ToneGenerator.TONE_UNKNOWN) {
            if (stream == AudioManager.STREAM_BLUETOOTH_SCO) {
                // Override audio stream for BT le device and hearing aid device
                if (mCallAudioRoutePeripheralAdapter.isLeAudioDeviceOn()
                        || mCallAudioRoutePeripheralAdapter.isHearingAidDeviceOn()) {
                    stream = AudioManager.STREAM_VOICE_CALL;
                }
            }
        }
        return stream;
    }

    /**
     * Play a tone generated by the {@link ToneGenerator}.
     * @param stream The stream on which the tone will be played.
+0 −50
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ import com.android.server.telecom.TelecomSystem;
import com.android.server.telecom.WiredHeadsetManager;
import com.android.server.telecom.bluetooth.BluetoothDeviceManager;
import com.android.server.telecom.bluetooth.BluetoothRouteManager;
import com.android.server.telecom.flags.FeatureFlags;

import org.junit.After;
import org.junit.Before;
@@ -209,53 +208,9 @@ public class InCallTonePlayerTest extends TelecomTestCase {
                eq(true));
    }

    /**
     * Only applicable when {@link FeatureFlags#useStreamVoiceCallTones()} is false and we use
     * STREAM_BLUETOOTH_SCO for tones.
     */
    @SmallTest
    @Test
    public void testRingbackToneAudioStreamHeadset() {
        when(mFeatureFlags.useStreamVoiceCallTones()).thenReturn(false);
        when(mAudioManagerAdapter.isVolumeOverZero()).thenReturn(true);
        setConnectedBluetoothDevice(false /*isLe*/, false /*isHearingAid*/);

        mInCallTonePlayer = mFactory.createPlayer(mCall, InCallTonePlayer.TONE_RING_BACK);
        assertTrue(mInCallTonePlayer.startTone());

        verify(mToneGeneratorFactory, timeout(TEST_TIMEOUT))
                .get(eq(AudioManager.STREAM_BLUETOOTH_SCO), anyInt());
        verify(mCallAudioManager).setIsTonePlaying(any(Call.class), eq(true));
    }

    /**
     * Only applicable when {@link FeatureFlags#useStreamVoiceCallTones()} is false and we use
     * STREAM_BLUETOOTH_SCO for tones.
     */
    @SmallTest
    @Test
    public void testCallWaitingToneAudioStreamHeadset() {
        when(mFeatureFlags.useStreamVoiceCallTones()).thenReturn(false);
        when(mAudioManagerAdapter.isVolumeOverZero()).thenReturn(true);
        setConnectedBluetoothDevice(false /*isLe*/, false /*isHearingAid*/);

        mInCallTonePlayer = mFactory.createPlayer(mCall, InCallTonePlayer.TONE_CALL_WAITING);
        assertTrue(mInCallTonePlayer.startTone());

        verify(mToneGeneratorFactory, timeout(TEST_TIMEOUT))
                .get(eq(AudioManager.STREAM_BLUETOOTH_SCO), anyInt());
        verify(mCallAudioManager).setIsTonePlaying(any(Call.class), eq(true));
    }


    /**
     * Only applicable when {@link FeatureFlags#useStreamVoiceCallTones()} is true and we use
     * STREAM_VOICE_CALL for ALL tones.
     */
    @SmallTest
    @Test
    public void testRingbackToneAudioStreamSco() {
        when(mFeatureFlags.useStreamVoiceCallTones()).thenReturn(true);
        when(mAudioManagerAdapter.isVolumeOverZero()).thenReturn(true);
        setConnectedBluetoothDevice(false /*isLe*/, false /*isHearingAid*/);

@@ -267,14 +222,9 @@ public class InCallTonePlayerTest extends TelecomTestCase {
        verify(mCallAudioManager).setIsTonePlaying(any(Call.class), eq(true));
    }

    /**
     * Only applicable when {@link FeatureFlags#useStreamVoiceCallTones()} is true and we use
     * STREAM_VOICE_CALL for ALL tones.
     */
    @SmallTest
    @Test
    public void testRingbackToneAudioStreamLe() {
        when(mFeatureFlags.useStreamVoiceCallTones()).thenReturn(true);
        when(mAudioManagerAdapter.isVolumeOverZero()).thenReturn(true);
        setConnectedBluetoothDevice(true /*isLe*/, false /*isHearingAid*/);