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

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

Merge "Switch to active BT route when changing focus" into pi-dev

am: 61d00cca

Change-Id: Ibd0d61c9d72ee85818bb4778b73ef9e176a72611
parents cac47bc0 61d00cca
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -56,8 +56,8 @@ public class BluetoothHeadsetProxy {
        return mBluetoothHeadset.getConnectionState(device);
    }

    public boolean isAudioConnected(BluetoothDevice device) {
        return mBluetoothHeadset.isAudioConnected(device);
    public int getAudioState(BluetoothDevice device) {
        return mBluetoothHeadset.getAudioState(device);
    }

    public boolean connectAudio() {
+5 −2
Original line number Diff line number Diff line
@@ -1470,7 +1470,10 @@ public class CallAudioRouteStateMachine extends StateMachine {
            BluetoothDevice connectedDevice =
                    mBluetoothRouteManager.getBluetoothAudioConnectedDevice();
            if (address == null && connectedDevice != null) {
                // null means connect to any device, so don't bother reconnecting
                // null means connect to any device, so don't bother reconnecting. Also, send a
                // message to ourselves telling us that BT audio is already connected.
                Log.i(this, "HFP audio already on. Skipping connecting.");
                sendInternalMessage(BT_AUDIO_CONNECTED);
                return;
            }
            if (connectedDevice == null || !Objects.equals(address, connectedDevice.getAddress())) {
@@ -1648,7 +1651,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
        return UserHandle.USER_OWNER;
    }

    private boolean isInActiveState() {
    public boolean isInActiveState() {
        AudioState currentState = (AudioState) getCurrentState();
        if (currentState == null) {
            Log.w(this, "Current state is null, assuming inactive state");
+3 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.telecom.bluetooth;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadset;
import android.content.Context;
import android.os.Message;
import android.telecom.Log;
@@ -653,7 +654,8 @@ public class BluetoothRouteManager extends StateMachine {

        for (int i = 0; i < deviceList.size(); i++) {
            BluetoothDevice device = deviceList.get(i);
            boolean isAudioOn = bluetoothHeadset.isAudioConnected(device);
            boolean isAudioOn = bluetoothHeadset.getAudioState(device)
                    != BluetoothHeadset.STATE_AUDIO_DISCONNECTED;
            Log.v(this, "isBluetoothAudioConnected: ==> isAudioOn = " + isAudioOn
                    + "for headset: " + device);
            if (isAudioOn) {
+3 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.telecom.tests;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadset;
import android.content.ContentResolver;
import android.os.Parcel;
import android.telecom.Log;
@@ -130,7 +131,8 @@ public class BluetoothRouteManagerTest extends TelecomTestCase {
        when(mDeviceManager.getConnectedDevices()).thenReturn(Arrays.asList(devices));
        when(mHeadsetProxy.getConnectedDevices()).thenReturn(Arrays.asList(devices));
        if (activeDevice != null) {
            when(mHeadsetProxy.isAudioConnected(eq(activeDevice))).thenReturn(true);
            when(mHeadsetProxy.getAudioState(eq(activeDevice)))
                    .thenReturn(BluetoothHeadset.STATE_AUDIO_CONNECTED);
        }
        doAnswer(invocation -> {
            BluetoothDevice first = getFirstExcluding(devices,
+3 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.telecom.tests;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadset;
import android.content.ContentResolver;
import android.test.suitebuilder.annotation.SmallTest;

@@ -306,7 +307,8 @@ public class BluetoothRouteTransitionTests extends TelecomTestCase {
        when(mHeadsetProxy.getConnectedDevices()).thenReturn(Arrays.asList(devices));
        when(mHeadsetProxy.getActiveDevice()).thenReturn(activeDevice);
        if (audioOnDevice != null) {
            when(mHeadsetProxy.isAudioConnected(eq(audioOnDevice))).thenReturn(true);
            when(mHeadsetProxy.getAudioState(eq(audioOnDevice)))
                    .thenReturn(BluetoothHeadset.STATE_AUDIO_CONNECTED);
        }
        doAnswer(invocation -> {
            BluetoothDevice first = getFirstExcluding(devices,
Loading