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

Commit e2627aa5 authored by Hall Liu's avatar Hall Liu Committed by android-build-merger
Browse files

Merge "Make changes to CARSM and BRM for multi-hfp" am: cc2b17ae

am: ebf50e50

Change-Id: Ia531d80484f6c2e1ee39ba84fc01286891e7ae68
parents bfad7c30 ebf50e50
Loading
Loading
Loading
Loading
+28 −38
Original line number Diff line number Diff line
@@ -46,45 +46,35 @@ public class CallAudioRoutePeripheralAdapter implements WiredHeadsetManager.List
    }

    @Override
    public void onBluetoothStateChange(int oldState, int newState) {
        switch (oldState) {
            case BluetoothRouteManager.BLUETOOTH_DISCONNECTED:
            case BluetoothRouteManager.BLUETOOTH_UNINITIALIZED:
                switch (newState) {
                    case BluetoothRouteManager.BLUETOOTH_DEVICE_CONNECTED:
                    case BluetoothRouteManager.BLUETOOTH_AUDIO_CONNECTED:
    public void onBluetoothDeviceListChanged() {
        mCallAudioRouteStateMachine.sendMessageWithSessionInfo(
                                CallAudioRouteStateMachine.CONNECT_BLUETOOTH);
                        break;
                CallAudioRouteStateMachine.BLUETOOTH_DEVICE_LIST_CHANGED);
    }
                break;
            case BluetoothRouteManager.BLUETOOTH_DEVICE_CONNECTED:
                switch (newState) {
                    case BluetoothRouteManager.BLUETOOTH_DISCONNECTED:
                        mCallAudioRouteStateMachine.sendMessageWithSessionInfo(
                                CallAudioRouteStateMachine.DISCONNECT_BLUETOOTH);
                        break;
                    case BluetoothRouteManager.BLUETOOTH_AUDIO_CONNECTED:

    @Override
    public void onBluetoothDeviceAvailable() {
        mCallAudioRouteStateMachine.sendMessageWithSessionInfo(
                                CallAudioRouteStateMachine.SWITCH_BLUETOOTH);
                        break;
                CallAudioRouteStateMachine.CONNECT_BLUETOOTH);
    }
                break;
            case BluetoothRouteManager.BLUETOOTH_AUDIO_CONNECTED:
            case BluetoothRouteManager.BLUETOOTH_AUDIO_PENDING:
                switch (newState) {
                    case BluetoothRouteManager.BLUETOOTH_DISCONNECTED:

    @Override
    public void onBluetoothDeviceUnavailable() {
        mCallAudioRouteStateMachine.sendMessageWithSessionInfo(
                CallAudioRouteStateMachine.DISCONNECT_BLUETOOTH);
                        break;
                    case BluetoothRouteManager.BLUETOOTH_DEVICE_CONNECTED:
                        mCallAudioRouteStateMachine.sendMessageWithSessionInfo(
                                CallAudioRouteStateMachine.BT_AUDIO_DISCONNECT);
                        break;
    }
                break;

    @Override
    public void onBluetoothAudioConnected() {
        mCallAudioRouteStateMachine.sendMessageWithSessionInfo(
                CallAudioRouteStateMachine.BT_AUDIO_CONNECTED);
    }

    @Override
    public void onBluetoothAudioDisconnected() {
        mCallAudioRouteStateMachine.sendMessageWithSessionInfo(
                CallAudioRouteStateMachine.BT_AUDIO_DISCONNECTED);
    }

    /**
      * Updates the audio route when the headset plugged in state changes. For example, if audio is
      * being routed over speakerphone and a headset is plugged in then switch to wired headset.
+123 −40

File changed.

Preview size limit exceeded, changes collapsed.

+7 −3
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public class BluetoothDeviceManager {
                                    mConnectedDevicesByAddress.values());
                            mConnectedDevicesByAddress.clear();
                            for (BluetoothDevice device : devicesToRemove) {
                                mBluetoothRouteManager.onDeviceLost(device);
                                mBluetoothRouteManager.onDeviceLost(device.getAddress());
                            }
                        }
                    } finally {
@@ -106,13 +106,13 @@ public class BluetoothDeviceManager {
                        if (bluetoothHeadsetState == BluetoothHeadset.STATE_CONNECTED) {
                            if (!mConnectedDevicesByAddress.containsKey(device.getAddress())) {
                                mConnectedDevicesByAddress.put(device.getAddress(), device);
                                mBluetoothRouteManager.onDeviceAdded(device);
                                mBluetoothRouteManager.onDeviceAdded(device.getAddress());
                            }
                        } else if (bluetoothHeadsetState == BluetoothHeadset.STATE_DISCONNECTED
                                || bluetoothHeadsetState == BluetoothHeadset.STATE_DISCONNECTING) {
                            if (mConnectedDevicesByAddress.containsKey(device.getAddress())) {
                                mConnectedDevicesByAddress.remove(device.getAddress());
                                mBluetoothRouteManager.onDeviceLost(device);
                                mBluetoothRouteManager.onDeviceLost(device.getAddress());
                            }
                        }
                    }
@@ -151,6 +151,10 @@ public class BluetoothDeviceManager {
        return mConnectedDevicesByAddress.size();
    }

    public Collection<BluetoothDevice> getConnectedDevices() {
        return mConnectedDevicesByAddress.values();
    }

    public String getMostRecentlyConnectedDevice(String excludeAddress) {
        String result = null;
        synchronized (mLock) {
+74 −102

File changed.

Preview size limit exceeded, changes collapsed.

+2 −2
Original line number Diff line number Diff line
@@ -139,8 +139,8 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase {
                buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device2));
        serviceListenerUnderTest.onServiceDisconnected(0);

        verify(mRouteManager).onDeviceLost(device1);
        verify(mRouteManager).onDeviceLost(device2);
        verify(mRouteManager).onDeviceLost(device1.getAddress());
        verify(mRouteManager).onDeviceLost(device2.getAddress());
        assertNull(mBluetoothDeviceManager.getHeadsetService());
        assertEquals(0, mBluetoothDeviceManager.getNumConnectedDevices());
    }
Loading