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

Commit 8a15fcec authored by Pranav Madapurmath's avatar Pranav Madapurmath
Browse files

Change active audio route to use set/clear communication APIs.

Currently, only the active speaker route, BT LE audio and BT heaing aid
audio use these APIs when entering/exiting these routes. We also need to
set the communication device for the other active routes such as for
earpiece, headset, and BT SCO. The important concept of this bug is
pairing each request made to change audio routes with setting the
communication device for the correpsonding device.

Additionally, there's an edge case where we can be in a quiescent route
while in-call. This happens with BT when we receive a SWITCH_FOCUS to
transition into the active route and the BT connection fails. We
fall back to the QuiescentEarpieceRoute instead of ActiveEarpieceRoute.
The code logic for QuiescentBluetoothRoute has been changed to
transition into the ActiveBluetoothRoute first and then attempt to
set BT on in ActiveBluetoothRoute#enter.

This CL also takes care of an existing issue of not being able to switch
between multiple LE audio devices. This required changing the logic in
BluetoothDeviceManager#setLeAudioCommunicationDevice to be aware of the
specific device we're trying to set the communication device for.

Bug: 244452873
Bug: 270029273
Bug: 239491709
Test: Unit
Change-Id: I68d38ab50c9f4f49b1a4ef67c51023d1b61d7047
parent 1f147dbe
Loading
Loading
Loading
Loading
+134 −1
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import com.android.server.telecom.bluetooth.BluetoothRouteManager;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Executor;
@@ -234,6 +235,9 @@ public class CallAudioRouteStateMachine extends StateMachine {

    public static final String NAME = CallAudioRouteStateMachine.class.getName();

    private boolean mActiveEarpieceSetAsCommunicationDevice = false;
    private boolean mActiveHeadsetSetAsCommunicationDevice = false;

    @Override
    protected void onPreHandleMessage(Message msg) {
        if (msg.obj != null && msg.obj instanceof SomeArgs) {
@@ -371,6 +375,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
        public void enter() {
            super.enter();
            setSpeakerphoneOn(false);
            setActiveEarpieceCommunicationDevice();
            CallAudioState newState = new CallAudioState(mIsMuted, ROUTE_EARPIECE,
                    mAvailableRoutes, null,
                    mBluetoothRouteManager.getConnectedDevices());
@@ -401,6 +406,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
                case SWITCH_BLUETOOTH:
                case USER_SWITCH_BLUETOOTH:
                    if ((mAvailableRoutes & ROUTE_BLUETOOTH) != 0) {
                        clearActiveEarpieceCommunicationDevice();
                        if (mAudioFocusType == ACTIVE_FOCUS
                                || mBluetoothRouteManager.isInbandRingingEnabled()) {
                            String address = (msg.obj instanceof SomeArgs) ?
@@ -417,6 +423,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
                case SWITCH_HEADSET:
                case USER_SWITCH_HEADSET:
                    if ((mAvailableRoutes & ROUTE_WIRED_HEADSET) != 0) {
                        clearActiveEarpieceCommunicationDevice();
                        transitionTo(mActiveHeadsetRoute);
                    } else {
                        Log.w(this, "Ignoring switch to headset command. Not available.");
@@ -426,6 +433,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
                    // fall through; we want to switch to speaker mode when docked and in a call.
                case SWITCH_SPEAKER:
                case USER_SWITCH_SPEAKER:
                    clearActiveEarpieceCommunicationDevice();
                    setSpeakerphoneOn(true);
                    // fall through
                case SPEAKER_ON:
@@ -579,6 +587,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
        public void enter() {
            super.enter();
            setSpeakerphoneOn(false);
            setActiveHeadsetCommunicationDevice();
            CallAudioState newState = new CallAudioState(mIsMuted, ROUTE_WIRED_HEADSET,
                    mAvailableRoutes, null, mBluetoothRouteManager.getConnectedDevices());
            setSystemAudioState(newState, true);
@@ -600,6 +609,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
                case SWITCH_EARPIECE:
                case USER_SWITCH_EARPIECE:
                    if ((mAvailableRoutes & ROUTE_EARPIECE) != 0) {
                        clearActiveHeadsetCommunicationDevice();
                        transitionTo(mActiveEarpieceRoute);
                    } else {
                        Log.w(this, "Ignoring switch to earpiece command. Not available.");
@@ -615,6 +625,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
                                || mBluetoothRouteManager.isInbandRingingEnabled()) {
                            String address = (msg.obj instanceof SomeArgs) ?
                                    (String) ((SomeArgs) msg.obj).arg2 : null;
                            clearActiveHeadsetCommunicationDevice();
                            // Omit transition to ActiveBluetoothRoute until actual connection.
                            setBluetoothOn(address);
                        } else {
@@ -631,6 +642,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
                    return HANDLED;
                case SWITCH_SPEAKER:
                case USER_SWITCH_SPEAKER:
                    clearActiveHeadsetCommunicationDevice();
                    setSpeakerphoneOn(true);
                    // fall through
                case SPEAKER_ON:
@@ -793,6 +805,12 @@ public class CallAudioRouteStateMachine extends StateMachine {
        public void enter() {
            super.enter();
            setSpeakerphoneOn(false);
            // Try arbitrarily connecting to BT audio if we haven't already. This handles
            // the edge case of when the audio route is in a quiescent route while in-call and
            // the BT connection fails to be set. Previously, the logic was to setBluetoothOn in
            // ACTIVE_FOCUS but the route would still remain in a quiescent route, so instead we
            // should be transitioning directly into the active route.
            setBluetoothOn(null);
            CallAudioState newState = new CallAudioState(mIsMuted, ROUTE_BLUETOOTH,
                    mAvailableRoutes, mBluetoothRouteManager.getBluetoothAudioConnectedDevice(),
                    mBluetoothRouteManager.getConnectedDevices());
@@ -1065,7 +1083,9 @@ public class CallAudioRouteStateMachine extends StateMachine {
                    return HANDLED;
                case SWITCH_FOCUS:
                    if (msg.arg1 == ACTIVE_FOCUS) {
                        setBluetoothOn(null);
                        // It is possible that the connection to BT will fail while in-call, in
                        // which case, we want to transition into the active route.
                        transitionTo(mActiveBluetoothRoute);
                    } else if (msg.arg1 == RINGING_FOCUS) {
                        if (mBluetoothRouteManager.isInbandRingingEnabled()) {
                            setBluetoothOn(null);
@@ -1789,6 +1809,119 @@ public class CallAudioRouteStateMachine extends StateMachine {
        }
    }

    private void setActiveHeadsetCommunicationDevice() {
        Log.i(this, "setActiveHeadsetCommunicationDevice");

        if (mActiveHeadsetSetAsCommunicationDevice) {
            Log.i(this, "mActiveHeadsetSetAsCommunicationDevice already set");
            return;
        }

        AudioDeviceInfo activeHeadset = null;
        List<AudioDeviceInfo> devices = mAudioManager.getAvailableCommunicationDevices();
        if (devices.size() == 0) {
            Log.w(this, "No communication devices available.");
            return;
        }

        for (AudioDeviceInfo device : devices) {
            Log.i(this, "Available device type: " + device.getType());
            if (device.getType() == AudioDeviceInfo.TYPE_WIRED_HEADSET
                    || device.getType() == AudioDeviceInfo.TYPE_USB_HEADSET) {
                activeHeadset = device;
                break;
            }
        }

        if (activeHeadset == null) {
            Log.w(this, "No activeHeadset device available");
            return;
        }


        // Turn TYPE_WIRED_HEADSET ON.
        boolean result = mAudioManager.setCommunicationDevice(activeHeadset);
        if (!result) {
            Log.w(this, "Could not set activeHeadset device");
        } else {
            Log.i(this, "activeHeadset device set");
            mActiveHeadsetSetAsCommunicationDevice = true;
        }
    }

    private void setActiveEarpieceCommunicationDevice() {
        Log.i(this, "setActiveEarpieceCommunicationDevice");

        if (mActiveEarpieceSetAsCommunicationDevice) {
            Log.i(this, "mActiveEarpieceSetAsCommunicationDevice already set");
            return;
        }

        AudioDeviceInfo activeEarpiece = null;
        List<AudioDeviceInfo> devices = mAudioManager.getAvailableCommunicationDevices();
        if (devices.size() == 0) {
            Log.w(this, "No communication devices available.");
            return;
        }

        for (AudioDeviceInfo device : devices) {
            Log.i(this, "Available device type: " + device.getType());
            if (device.getType() == AudioDeviceInfo.TYPE_BUILTIN_EARPIECE) {
                activeEarpiece = device;
                break;
            }
        }

        if (activeEarpiece == null) {
            Log.w(this, "No active earpiece device available");
            return;
        }

        // Turn TYPE_BUILTIN_EARPIECE ON.
        boolean result = mAudioManager.setCommunicationDevice(activeEarpiece);
        if (!result) {
            Log.w(this, "Could not set active earpiece device");
        } else {
            Log.i(this, "Active earpiece device set");
            mActiveEarpieceSetAsCommunicationDevice = true;
        }
    }

    public void clearActiveEarpieceCommunicationDevice() {
        Log.i(this, "clearActiveEarpieceCommunicationDevice:" +
                "mActiveEarpieceSetAsCommunicationDevice = " +
                mActiveEarpieceSetAsCommunicationDevice);

        if (!mActiveEarpieceSetAsCommunicationDevice) {
            return;
        }
        mActiveEarpieceSetAsCommunicationDevice = false;

        AudioDeviceInfo audioDeviceInfo = mAudioManager.getCommunicationDevice();
        if (audioDeviceInfo != null && audioDeviceInfo.getType()
                == AudioDeviceInfo.TYPE_BUILTIN_EARPIECE) {
            mAudioManager.clearCommunicationDevice();
        }
    }

    public void clearActiveHeadsetCommunicationDevice() {
        Log.i(this, "clearActiveHeadsetCommunicationDevice:" +
                "mActiveHeadsetSetAsCommunicationDevice = " +
                mActiveHeadsetSetAsCommunicationDevice);

        if (!mActiveHeadsetSetAsCommunicationDevice) {
            return;
        }
        mActiveHeadsetSetAsCommunicationDevice = false;

        AudioDeviceInfo audioDeviceInfo = mAudioManager.getCommunicationDevice();
        if (audioDeviceInfo != null && (audioDeviceInfo.getType()
                == AudioDeviceInfo.TYPE_WIRED_HEADSET
                || audioDeviceInfo.getType() == AudioDeviceInfo.TYPE_USB_HEADSET)) {
            mAudioManager.clearCommunicationDevice();
        }
    }

    private void setMuteOn(boolean mute) {
        mIsMuted = mute;
        Log.addEvent(mCallsManager.getForegroundCall(), mute ?
+130 −25
Original line number Diff line number Diff line
@@ -189,7 +189,9 @@ public class BluetoothDeviceManager {
    private boolean mLeAudioSetAsCommunicationDevice = false;
    private String mLeAudioDevice;
    private String mHearingAidDevice;
    private String mScoDevice;
    private boolean mHearingAidSetAsCommunicationDevice = false;
    private boolean mScoSetAsCommunicationDevice = false;
    private BluetoothDevice mBluetoothHearingAidActiveDeviceCache;
    private BluetoothAdapter mBluetoothAdapter;
    private AudioManager mAudioManager;
@@ -398,12 +400,13 @@ public class BluetoothDeviceManager {
    }

    public void disconnectAudio() {
        disconnectSco();
        disconnectScoAudio();
        clearLeAudioCommunicationDevice();
        clearHearingAidCommunicationDevice();
    }

    public void disconnectSco() {
    public void disconnectScoAudio() {
        clearScoAudioCommunicationDevice();
        if (mBluetoothHeadset == null) {
            Log.w(this, "Trying to disconnect audio but no headset service exists.");
        } else {
@@ -419,6 +422,10 @@ public class BluetoothDeviceManager {
        return mHearingAidSetAsCommunicationDevice;
    }

    public boolean isScoSetAsCommunicationDevice() {
        return mScoSetAsCommunicationDevice;
    }

    public void clearLeAudioCommunicationDevice() {
        Log.i(this, "clearLeAudioCommunicationDevice: mLeAudioSetAsCommunicationDevice = " +
                mLeAudioSetAsCommunicationDevice + " device = " + mLeAudioDevice);
@@ -468,11 +475,36 @@ public class BluetoothDeviceManager {
        }
    }

    public boolean setLeAudioCommunicationDevice() {
    public void clearScoAudioCommunicationDevice() {
        Log.i(this, "clearScoCommunicationDevice: mScoSetAsCommunicationDevice = "
                + mScoSetAsCommunicationDevice);
        if (!mScoSetAsCommunicationDevice) {
            return;
        }
        mScoSetAsCommunicationDevice = false;
        if (mScoDevice != null) {
            mBluetoothRouteManager.onAudioLost(mScoDevice);
            mScoDevice = null;
        }

        if (mAudioManager == null) {
            Log.i(this, "clearScoCommunicationDevice: mAudioManager is null");
            return;
        }

        AudioDeviceInfo audioDeviceInfo = mAudioManager.getCommunicationDevice();
        if (audioDeviceInfo != null && audioDeviceInfo.getType()
                == AudioDeviceInfo.TYPE_BLUETOOTH_SCO) {
            mAudioManager.clearCommunicationDevice();
        }
    }

    public boolean setLeAudioCommunicationDevice(BluetoothDevice leAudioDevice) {
        Log.i(this, "setLeAudioCommunicationDevice");

        if (mLeAudioSetAsCommunicationDevice) {
            Log.i(this, "setLeAudioCommunicationDevice already set");
        // Ensure that the device being set isn't one we have set already.
        if (mLeAudioSetAsCommunicationDevice && leAudioDevice.getAddress().equals(mLeAudioDevice)) {
            Log.i(this, "No change in LE audio device.");
            return true;
        }

@@ -490,7 +522,9 @@ public class BluetoothDeviceManager {

        for (AudioDeviceInfo device : devices) {
            Log.i(this, " Available device type:  " + device.getType());
            if (device.getType() == AudioDeviceInfo.TYPE_BLE_HEADSET) {
            // Make sure we find a device that hasn't been set already.
            if (device.getType() == AudioDeviceInfo.TYPE_BLE_HEADSET
                    && !device.getAddress().equals(mLeAudioDevice)) {
                bleHeadset = device;
                break;
            }
@@ -501,8 +535,13 @@ public class BluetoothDeviceManager {
            return false;
        }

        // clear hearing aid communication device if set
        // Clear hearing aid or SCO communication device if set
        clearHearingAidCommunicationDevice();
        clearScoAudioCommunicationDevice();
        // Check if another LE audio device was set as the communication device already and clear it
        if (mLeAudioDevice != null) {
            clearLeAudioCommunicationDevice();
        }

        // Turn BLE_OUT_HEADSET ON.
        boolean result = mAudioManager.setCommunicationDevice(bleHeadset);
@@ -550,8 +589,9 @@ public class BluetoothDeviceManager {
            return false;
        }

        // clear LE audio communication device if set
        // clear LE or SCO audio communication device if set
        clearLeAudioCommunicationDevice();
        clearScoAudioCommunicationDevice();

        // Turn hearing aid ON.
        boolean result = mAudioManager.setCommunicationDevice(hearingAid);
@@ -565,6 +605,54 @@ public class BluetoothDeviceManager {
        return result;
    }

    public boolean setScoAudioCommunicationDevice() {
        Log.i(this, "setScoCommunicationDevice");

        if (mScoSetAsCommunicationDevice) {
            Log.i(this, "mScoSetAsCommunicationDevice already set");
            return true;
        }

        if (mAudioManager == null) {
            Log.w(this, "mAudioManager is null");
            return false;
        }

        AudioDeviceInfo scoAudio = null;
        List<AudioDeviceInfo> devices = mAudioManager.getAvailableCommunicationDevices();
        if (devices.size() == 0) {
            Log.w(this, "No communication devices available.");
            return false;
        }

        for (AudioDeviceInfo device : devices) {
            Log.i(this, "Available device type:  " + device.getType());
            if (device.getType() == AudioDeviceInfo.TYPE_BLUETOOTH_SCO) {
                scoAudio = device;
                break;
            }
        }

        if (scoAudio == null) {
            Log.w(this, "No scoAudio device available");
            return false;
        }

        // clear LE or hearing aid audio communication device if set
        clearLeAudioCommunicationDevice();
        clearHearingAidCommunicationDevice();

        // Set SCO communication device.
        boolean result = mAudioManager.setCommunicationDevice(scoAudio);
        if (!result) {
            Log.w(this, "Could not set scoAudio device");
            return false;
        }
        mScoSetAsCommunicationDevice = true;
        mScoDevice = scoAudio.getAddress();
        return true;
    }

    // Connect audio to the bluetooth device at address, checking to see whether it's
    // le audio, hearing aid or a HFP device, and using the proper BT API.
    public boolean connectAudio(String address, boolean switchingBtDevices) {
@@ -578,10 +666,11 @@ public class BluetoothDeviceManager {
                    device, BluetoothAdapter.ACTIVE_DEVICE_ALL)) {

                /* ACTION_ACTIVE_DEVICE_CHANGED intent will trigger setting communication device.
                 * Only after receiving ACTION_ACTIVE_DEVICE_CHANGED it is known that device that
                 * will be audio switched to is available to be choose as communication device */
                 * Only after receiving ACTION_ACTIVE_DEVICE_CHANGED is it known that the device
                 * that will be audio switched to is available to be chosen as communication device.
                 */
                if (!switchingBtDevices) {
                    return setLeAudioCommunicationDevice();
                    return setLeAudioCommunicationDevice(device);
                }

                return true;
@@ -597,8 +686,9 @@ public class BluetoothDeviceManager {
                    BluetoothAdapter.ACTIVE_DEVICE_ALL)) {

                /* ACTION_ACTIVE_DEVICE_CHANGED intent will trigger setting communication device.
                 * Only after receiving ACTION_ACTIVE_DEVICE_CHANGED it is known that device that
                 * will be audio switched to is available to be choose as communication device */
                 * Only after receiving ACTION_ACTIVE_DEVICE_CHANGED is it known that the device
                 * that will be audio switched to is available to be chosen as communication device.
                 */
                if (!switchingBtDevices) {
                    return setHearingAidCommunicationDevice();
                }
@@ -618,9 +708,24 @@ public class BluetoothDeviceManager {
                Log.w(this, "Couldn't set active device to %s", address);
                return false;
            }
            /* ACTION_ACTIVE_DEVICE_CHANGED intent will trigger setting communication device.
             * Only after receiving ACTION_ACTIVE_DEVICE_CHANGED is it known that the device that
             * will be audio switched to is available to be chosen as communication device.
             */
            if (!switchingBtDevices && !setScoAudioCommunicationDevice()) {
                // If the communication device cannot be set, we should not try connecting the SCO
                // audio device
                return false;
            }
            int scoConnectionRequest = mBluetoothHeadset.connectAudio();
            return scoConnectionRequest == BluetoothStatusCodes.SUCCESS ||
                scoConnectionRequest == BluetoothStatusCodes.ERROR_AUDIO_DEVICE_ALREADY_CONNECTED;
            boolean scoSuccessfulConnection = scoConnectionRequest ==
                    BluetoothStatusCodes.SUCCESS || scoConnectionRequest ==
                    BluetoothStatusCodes.ERROR_AUDIO_DEVICE_ALREADY_CONNECTED;
            if (!scoSuccessfulConnection) {
                // Clear communication device if we're unable to connect to BT headset audio
                clearScoAudioCommunicationDevice();
            }
            return scoSuccessfulConnection;
        } else {
            Log.w(this, "Attempting to turn on audio for a disconnected device");
            return false;
+31 −11
Original line number Diff line number Diff line
@@ -630,6 +630,9 @@ public class BluetoothRouteManager extends StateMachine {
            }
        } else if (deviceType == BluetoothDeviceManager.DEVICE_TYPE_HEADSET) {
            mHfpActiveDeviceCache = device;
            if (device == null) {
                mDeviceManager.clearScoAudioCommunicationDevice();
            }
        } else {
            return;
        }
@@ -783,19 +786,21 @@ public class BluetoothRouteManager extends StateMachine {

        int activeDevices = 0;
        if (bluetoothHeadset != null) {
            for (BluetoothDevice device : bluetoothAdapter.getActiveDevices(
                        BluetoothProfile.HEADSET)) {
                hfpAudioOnDevice = device;
                break;
            }

            if (hfpAudioOnDevice != null && bluetoothHeadset.getAudioState(hfpAudioOnDevice)
                    == BluetoothHeadset.STATE_AUDIO_DISCONNECTED) {
                hfpAudioOnDevice = null;
            } else {
            /* We can have a case where we have an active headset device but neither
               BluetoothDeviceManager#connectAudio nor
               BluetoothStateReceiver#handleActiveDeviceChanged have been called to set the
               communication device. In this case, we should count the active device and try to set
               the communication device.
            */
            if (mDeviceManager.isScoSetAsCommunicationDevice() ||
                    bluetoothAdapter.getActiveDevices(BluetoothProfile.HEADSET) != null) {
                mDeviceManager.setScoAudioCommunicationDevice();
                hfpAudioOnDevice = getHfpAudioOnDevice(bluetoothAdapter, bluetoothHeadset);
                if (hfpAudioOnDevice != null) {
                    activeDevices++;
                }
            }
        }

        if (bluetoothHearingAid != null) {
            if (mDeviceManager.isHearingAidSetAsCommunicationDevice()) {
@@ -842,6 +847,21 @@ public class BluetoothRouteManager extends StateMachine {
        return hfpAudioOnDevice;
    }

    private BluetoothDevice getHfpAudioOnDevice(BluetoothAdapter bluetoothAdapter,
            BluetoothHeadset bluetoothHeadset) {
        BluetoothDevice hfpAudioOnDevice = null;
        for (BluetoothDevice device : bluetoothAdapter.getActiveDevices(
                BluetoothProfile.HEADSET)) {
            hfpAudioOnDevice = device;
            break;
        }

        if (hfpAudioOnDevice != null && bluetoothHeadset.getAudioState(hfpAudioOnDevice)
                == BluetoothHeadset.STATE_AUDIO_DISCONNECTED) {
            hfpAudioOnDevice = null;
        }
        return hfpAudioOnDevice;
    }
    /**
     * Check if in-band ringing is currently enabled. In-band ringing could be disabled during an
     * active connection.
+35 −31
Original line number Diff line number Diff line
@@ -166,8 +166,7 @@ public class BluetoothStateReceiver extends BroadcastReceiver {
                BluetoothDeviceManager.getDeviceTypeString(deviceType));

        mBluetoothRouteManager.onActiveDeviceChanged(device, deviceType);
        if (deviceType == BluetoothDeviceManager.DEVICE_TYPE_HEARING_AID ||
            deviceType == BluetoothDeviceManager.DEVICE_TYPE_LE_AUDIO) {

        Session session = Log.createSubsession();
        SomeArgs args = SomeArgs.obtain();
        args.arg1 = session;
@@ -179,26 +178,31 @@ public class BluetoothStateReceiver extends BroadcastReceiver {
                return;
            }
            args.arg2 = device.getAddress();

            if (deviceType == BluetoothDeviceManager.DEVICE_TYPE_LE_AUDIO) {
                /* In Le Audio case, once device got Active, the Telecom needs to make sure it
                 * is set as communication device before we can say that BT_AUDIO_IS_ON
                 */
                    if (!mBluetoothDeviceManager.setLeAudioCommunicationDevice()) {
                if (!mBluetoothDeviceManager.setLeAudioCommunicationDevice(device)) {
                    Log.w(LOG_TAG,
                                "Device %s cannot be use as LE audio communication device.",
                            "Device %s cannot be used as LE audio communication device.",
                            device);
                    return;
                }
                } else {
            } else if (deviceType == BluetoothDeviceManager.DEVICE_TYPE_HEARING_AID) {
                /* deviceType == BluetoothDeviceManager.DEVICE_TYPE_HEARING_AID */
                if (!mBluetoothDeviceManager.setHearingAidCommunicationDevice()) {
                    Log.w(LOG_TAG,
                                "Device %s cannot be use as hearing aid communication device.",
                            "Device %s cannot be used as hearing aid communication device.",
                            device);
                } else {
                    mBluetoothRouteManager.sendMessage(BT_AUDIO_IS_ON, args);
                }
            } else {
                /* deviceType == BluetoothDeviceManager.DEVICE_TYPE_HEADSET */
                if (!mBluetoothDeviceManager.setScoAudioCommunicationDevice()) {
                    Log.w(LOG_TAG,
                            "Device %s cannot be used as SCO audio communication device.",
                            device);
                }
            }
        }
+1 −1
Original line number Diff line number Diff line
@@ -641,7 +641,7 @@ public class BasicCallTests extends TelecomSystemTest {
                .getCallAudioRouteStateMachine().getHandler(), TEST_TIMEOUT);
        ArgumentCaptor<AudioDeviceInfo> infoArgumentCaptor =
                ArgumentCaptor.forClass(AudioDeviceInfo.class);
        verify(audioManager, timeout(TEST_TIMEOUT)).setCommunicationDevice(
        verify(audioManager, timeout(TEST_TIMEOUT).atLeast(1)).setCommunicationDevice(
                infoArgumentCaptor.capture());
        assertEquals(AudioDeviceInfo.TYPE_BUILTIN_SPEAKER, infoArgumentCaptor.getValue().getType());
        mInCallServiceFixtureX.mInCallAdapter.setAudioRoute(CallAudioState.ROUTE_EARPIECE, null);
Loading