Loading src/com/android/server/telecom/BluetoothHeadsetProxy.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -56,8 +56,8 @@ public class BluetoothHeadsetProxy { return mBluetoothHeadset.getConnectionState(device); return mBluetoothHeadset.getConnectionState(device); } } public boolean isAudioConnected(BluetoothDevice device) { public int getAudioState(BluetoothDevice device) { return mBluetoothHeadset.isAudioConnected(device); return mBluetoothHeadset.getAudioState(device); } } public boolean connectAudio() { public boolean connectAudio() { Loading src/com/android/server/telecom/CallAudioRouteStateMachine.java +5 −2 Original line number Original line Diff line number Diff line Loading @@ -1452,7 +1452,10 @@ public class CallAudioRouteStateMachine extends StateMachine { BluetoothDevice connectedDevice = BluetoothDevice connectedDevice = mBluetoothRouteManager.getBluetoothAudioConnectedDevice(); mBluetoothRouteManager.getBluetoothAudioConnectedDevice(); if (address == null && connectedDevice != null) { 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; return; } } if (connectedDevice == null || !Objects.equals(address, connectedDevice.getAddress())) { if (connectedDevice == null || !Objects.equals(address, connectedDevice.getAddress())) { Loading Loading @@ -1630,7 +1633,7 @@ public class CallAudioRouteStateMachine extends StateMachine { return UserHandle.USER_OWNER; return UserHandle.USER_OWNER; } } private boolean isInActiveState() { public boolean isInActiveState() { AudioState currentState = (AudioState) getCurrentState(); AudioState currentState = (AudioState) getCurrentState(); if (currentState == null) { if (currentState == null) { Log.w(this, "Current state is null, assuming inactive state"); Log.w(this, "Current state is null, assuming inactive state"); Loading src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java +3 −1 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.telecom.bluetooth; package com.android.server.telecom.bluetooth; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHeadset; import android.content.Context; import android.content.Context; import android.os.Message; import android.os.Message; import android.telecom.Log; import android.telecom.Log; Loading Loading @@ -653,7 +654,8 @@ public class BluetoothRouteManager extends StateMachine { for (int i = 0; i < deviceList.size(); i++) { for (int i = 0; i < deviceList.size(); i++) { BluetoothDevice device = deviceList.get(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 Log.v(this, "isBluetoothAudioConnected: ==> isAudioOn = " + isAudioOn + "for headset: " + device); + "for headset: " + device); if (isAudioOn) { if (isAudioOn) { Loading tests/src/com/android/server/telecom/tests/BluetoothRouteManagerTest.java +3 −1 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.telecom.tests; package com.android.server.telecom.tests; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHeadset; import android.content.ContentResolver; import android.content.ContentResolver; import android.os.Parcel; import android.os.Parcel; import android.telecom.Log; import android.telecom.Log; Loading Loading @@ -130,7 +131,8 @@ public class BluetoothRouteManagerTest extends TelecomTestCase { when(mDeviceManager.getConnectedDevices()).thenReturn(Arrays.asList(devices)); when(mDeviceManager.getConnectedDevices()).thenReturn(Arrays.asList(devices)); when(mHeadsetProxy.getConnectedDevices()).thenReturn(Arrays.asList(devices)); when(mHeadsetProxy.getConnectedDevices()).thenReturn(Arrays.asList(devices)); if (activeDevice != null) { if (activeDevice != null) { when(mHeadsetProxy.isAudioConnected(eq(activeDevice))).thenReturn(true); when(mHeadsetProxy.getAudioState(eq(activeDevice))) .thenReturn(BluetoothHeadset.STATE_AUDIO_CONNECTED); } } doAnswer(invocation -> { doAnswer(invocation -> { BluetoothDevice first = getFirstExcluding(devices, BluetoothDevice first = getFirstExcluding(devices, Loading tests/src/com/android/server/telecom/tests/BluetoothRouteTransitionTests.java +3 −1 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.telecom.tests; package com.android.server.telecom.tests; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHeadset; import android.content.ContentResolver; import android.content.ContentResolver; import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest; Loading Loading @@ -306,7 +307,8 @@ public class BluetoothRouteTransitionTests extends TelecomTestCase { when(mHeadsetProxy.getConnectedDevices()).thenReturn(Arrays.asList(devices)); when(mHeadsetProxy.getConnectedDevices()).thenReturn(Arrays.asList(devices)); when(mHeadsetProxy.getActiveDevice()).thenReturn(activeDevice); when(mHeadsetProxy.getActiveDevice()).thenReturn(activeDevice); if (audioOnDevice != null) { if (audioOnDevice != null) { when(mHeadsetProxy.isAudioConnected(eq(audioOnDevice))).thenReturn(true); when(mHeadsetProxy.getAudioState(eq(audioOnDevice))) .thenReturn(BluetoothHeadset.STATE_AUDIO_CONNECTED); } } doAnswer(invocation -> { doAnswer(invocation -> { BluetoothDevice first = getFirstExcluding(devices, BluetoothDevice first = getFirstExcluding(devices, Loading Loading
src/com/android/server/telecom/BluetoothHeadsetProxy.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -56,8 +56,8 @@ public class BluetoothHeadsetProxy { return mBluetoothHeadset.getConnectionState(device); return mBluetoothHeadset.getConnectionState(device); } } public boolean isAudioConnected(BluetoothDevice device) { public int getAudioState(BluetoothDevice device) { return mBluetoothHeadset.isAudioConnected(device); return mBluetoothHeadset.getAudioState(device); } } public boolean connectAudio() { public boolean connectAudio() { Loading
src/com/android/server/telecom/CallAudioRouteStateMachine.java +5 −2 Original line number Original line Diff line number Diff line Loading @@ -1452,7 +1452,10 @@ public class CallAudioRouteStateMachine extends StateMachine { BluetoothDevice connectedDevice = BluetoothDevice connectedDevice = mBluetoothRouteManager.getBluetoothAudioConnectedDevice(); mBluetoothRouteManager.getBluetoothAudioConnectedDevice(); if (address == null && connectedDevice != null) { 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; return; } } if (connectedDevice == null || !Objects.equals(address, connectedDevice.getAddress())) { if (connectedDevice == null || !Objects.equals(address, connectedDevice.getAddress())) { Loading Loading @@ -1630,7 +1633,7 @@ public class CallAudioRouteStateMachine extends StateMachine { return UserHandle.USER_OWNER; return UserHandle.USER_OWNER; } } private boolean isInActiveState() { public boolean isInActiveState() { AudioState currentState = (AudioState) getCurrentState(); AudioState currentState = (AudioState) getCurrentState(); if (currentState == null) { if (currentState == null) { Log.w(this, "Current state is null, assuming inactive state"); Log.w(this, "Current state is null, assuming inactive state"); Loading
src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java +3 −1 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.telecom.bluetooth; package com.android.server.telecom.bluetooth; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHeadset; import android.content.Context; import android.content.Context; import android.os.Message; import android.os.Message; import android.telecom.Log; import android.telecom.Log; Loading Loading @@ -653,7 +654,8 @@ public class BluetoothRouteManager extends StateMachine { for (int i = 0; i < deviceList.size(); i++) { for (int i = 0; i < deviceList.size(); i++) { BluetoothDevice device = deviceList.get(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 Log.v(this, "isBluetoothAudioConnected: ==> isAudioOn = " + isAudioOn + "for headset: " + device); + "for headset: " + device); if (isAudioOn) { if (isAudioOn) { Loading
tests/src/com/android/server/telecom/tests/BluetoothRouteManagerTest.java +3 −1 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.telecom.tests; package com.android.server.telecom.tests; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHeadset; import android.content.ContentResolver; import android.content.ContentResolver; import android.os.Parcel; import android.os.Parcel; import android.telecom.Log; import android.telecom.Log; Loading Loading @@ -130,7 +131,8 @@ public class BluetoothRouteManagerTest extends TelecomTestCase { when(mDeviceManager.getConnectedDevices()).thenReturn(Arrays.asList(devices)); when(mDeviceManager.getConnectedDevices()).thenReturn(Arrays.asList(devices)); when(mHeadsetProxy.getConnectedDevices()).thenReturn(Arrays.asList(devices)); when(mHeadsetProxy.getConnectedDevices()).thenReturn(Arrays.asList(devices)); if (activeDevice != null) { if (activeDevice != null) { when(mHeadsetProxy.isAudioConnected(eq(activeDevice))).thenReturn(true); when(mHeadsetProxy.getAudioState(eq(activeDevice))) .thenReturn(BluetoothHeadset.STATE_AUDIO_CONNECTED); } } doAnswer(invocation -> { doAnswer(invocation -> { BluetoothDevice first = getFirstExcluding(devices, BluetoothDevice first = getFirstExcluding(devices, Loading
tests/src/com/android/server/telecom/tests/BluetoothRouteTransitionTests.java +3 −1 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.telecom.tests; package com.android.server.telecom.tests; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHeadset; import android.content.ContentResolver; import android.content.ContentResolver; import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest; Loading Loading @@ -306,7 +307,8 @@ public class BluetoothRouteTransitionTests extends TelecomTestCase { when(mHeadsetProxy.getConnectedDevices()).thenReturn(Arrays.asList(devices)); when(mHeadsetProxy.getConnectedDevices()).thenReturn(Arrays.asList(devices)); when(mHeadsetProxy.getActiveDevice()).thenReturn(activeDevice); when(mHeadsetProxy.getActiveDevice()).thenReturn(activeDevice); if (audioOnDevice != null) { if (audioOnDevice != null) { when(mHeadsetProxy.isAudioConnected(eq(audioOnDevice))).thenReturn(true); when(mHeadsetProxy.getAudioState(eq(audioOnDevice))) .thenReturn(BluetoothHeadset.STATE_AUDIO_CONNECTED); } } doAnswer(invocation -> { doAnswer(invocation -> { BluetoothDevice first = getFirstExcluding(devices, BluetoothDevice first = getFirstExcluding(devices, Loading