Loading src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java +42 −23 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHeadset; import android.bluetooth.BluetoothHearingAid; import android.bluetooth.BluetoothLeAudio; import android.bluetooth.BluetoothLeAudioCodecStatus; import android.bluetooth.BluetoothProfile; import android.bluetooth.BluetoothStatusCodes; import android.content.Context; Loading @@ -34,6 +35,7 @@ import com.android.internal.util.IndentingPrintWriter; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.concurrent.Executor; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.LinkedList; Loading @@ -47,6 +49,37 @@ public class BluetoothDeviceManager { public static final int DEVICE_TYPE_HEARING_AID = 1; public static final int DEVICE_TYPE_LE_AUDIO = 2; private BluetoothLeAudio.Callback mLeAudioCallbacks = new BluetoothLeAudio.Callback() { @Override public void onCodecConfigChanged(int groupId, BluetoothLeAudioCodecStatus status) {} @Override public void onGroupStatusChanged(int groupId, int groupStatus) {} @Override public void onGroupNodeAdded(BluetoothDevice device, int groupId) { Log.i(this, device.getAddress() + " group added " + groupId); if (device == null || groupId == BluetoothLeAudio.GROUP_ID_INVALID) { Log.w(this, "invalid parameter"); return; } synchronized (mLock) { mGroupsByDevice.put(device, groupId); } } @Override public void onGroupNodeRemoved(BluetoothDevice device, int groupId) { if (device == null || groupId == BluetoothLeAudio.GROUP_ID_INVALID) { Log.w(this, "invalid parameter"); return; } synchronized (mLock) { mGroupsByDevice.remove(device); } } }; private final BluetoothProfile.ServiceListener mBluetoothProfileServiceListener = new BluetoothProfile.ServiceListener() { @Override Loading @@ -66,6 +99,11 @@ public class BluetoothDeviceManager { mBluetoothLeAudioService = (BluetoothLeAudio) proxy; logString = "Got BluetoothLeAudio: " + mBluetoothLeAudioService; if (!mLeAudioCallbackRegistered) { mBluetoothLeAudioService.registerCallback( mExecutor, mLeAudioCallbacks); mLeAudioCallbackRegistered = true; } } else { logString = "Connected to non-requested bluetooth service." + " Not changing bluetooth headset."; Loading Loading @@ -145,11 +183,13 @@ public class BluetoothDeviceManager { private BluetoothRouteManager mBluetoothRouteManager; private BluetoothHeadset mBluetoothHeadset; private BluetoothHearingAid mBluetoothHearingAid; private boolean mLeAudioCallbackRegistered = false; private BluetoothLeAudio mBluetoothLeAudioService; private boolean mLeAudioSetAsCommunicationDevice = false; private BluetoothDevice mBluetoothHearingAidActiveDeviceCache; private BluetoothAdapter mBluetoothAdapter; private AudioManager mAudioManager; private Executor mExecutor; public BluetoothDeviceManager(Context context, BluetoothAdapter bluetoothAdapter) { if (bluetoothAdapter != null) { Loading @@ -161,6 +201,7 @@ public class BluetoothDeviceManager { bluetoothAdapter.getProfileProxy(context, mBluetoothProfileServiceListener, BluetoothProfile.LE_AUDIO); mAudioManager = context.getSystemService(AudioManager.class); mExecutor = context.getMainExecutor(); } } Loading Loading @@ -265,6 +306,7 @@ public class BluetoothDeviceManager { public void setLeAudioServiceForTesting(BluetoothLeAudio bluetoothLeAudio) { mBluetoothLeAudioService = bluetoothLeAudio; mBluetoothLeAudioService.registerCallback(mExecutor, mLeAudioCallbacks); } public static String getDeviceTypeString(int deviceType) { Loading Loading @@ -339,29 +381,6 @@ public class BluetoothDeviceManager { } } void onGroupNodeAdded(BluetoothDevice device, int groupId) { Log.i(this, device.getAddress() + " group added " + groupId); if (device == null || groupId == BluetoothLeAudio.GROUP_ID_INVALID) { Log.w(this, "invalid parameter"); return; } synchronized (mLock) { mGroupsByDevice.put(device, groupId); } } void onGroupNodeRemoved(BluetoothDevice device, int groupId) { if (device == null || groupId == BluetoothLeAudio.GROUP_ID_INVALID) { Log.w(this, "invalid parameter"); return; } synchronized (mLock) { mGroupsByDevice.remove(device); } } public void disconnectAudio() { if (mBluetoothAdapter != null) { for (BluetoothDevice device: mBluetoothAdapter.getActiveDevices( Loading src/com/android/server/telecom/bluetooth/BluetoothStateReceiver.java +0 −21 Original line number Diff line number Diff line Loading @@ -46,8 +46,6 @@ public class BluetoothStateReceiver extends BroadcastReceiver { INTENT_FILTER.addAction(BluetoothHearingAid.ACTION_ACTIVE_DEVICE_CHANGED); INTENT_FILTER.addAction(BluetoothLeAudio.ACTION_LE_AUDIO_CONNECTION_STATE_CHANGED); INTENT_FILTER.addAction(BluetoothLeAudio.ACTION_LE_AUDIO_ACTIVE_DEVICE_CHANGED); INTENT_FILTER.addAction(BluetoothLeAudio.ACTION_LE_AUDIO_GROUP_NODE_STATUS_CHANGED); INTENT_FILTER.addAction(BluetoothLeAudio.ACTION_LE_AUDIO_GROUP_STATUS_CHANGED); } // If not in a call, BSR won't listen to the Bluetooth stack's HFP on/off messages, since Loading @@ -74,9 +72,6 @@ public class BluetoothStateReceiver extends BroadcastReceiver { case BluetoothHeadset.ACTION_ACTIVE_DEVICE_CHANGED: handleActiveDeviceChanged(intent); break; case BluetoothLeAudio.ACTION_LE_AUDIO_GROUP_NODE_STATUS_CHANGED: handleGroupNodeStatusChanged(intent); break; } } finally { Log.endSession(); Loading Loading @@ -199,22 +194,6 @@ public class BluetoothStateReceiver extends BroadcastReceiver { } } private void handleGroupNodeStatusChanged(Intent intent) { BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); int groupId = intent.getIntExtra(BluetoothLeAudio.EXTRA_LE_AUDIO_GROUP_ID, BluetoothLeAudio.GROUP_ID_INVALID); int groupNodeStatus = intent.getIntExtra(BluetoothLeAudio.EXTRA_LE_AUDIO_GROUP_NODE_STATUS, -1); if (groupNodeStatus == BluetoothLeAudio.GROUP_NODE_ADDED) { mBluetoothDeviceManager.onGroupNodeAdded(device, groupId); } else { mBluetoothDeviceManager.onGroupNodeRemoved(device, groupId); } } public BluetoothDeviceManager getBluetoothDeviceManager() { return mBluetoothDeviceManager; } Loading src/com/android/server/telecom/components/UserCallIntentProcessor.java 100644 → 100755 +1 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ public class UserCallIntentProcessor { private void processOutgoingCallIntent(Intent intent, String callingPackageName, boolean canCallNonEmergency, boolean isLocalInvocation) { Uri handle = intent.getData(); if (handle == null) return; String scheme = handle.getScheme(); String uriString = handle.getSchemeSpecificPart(); Loading tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java +13 −30 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; Loading @@ -68,6 +69,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { BluetoothDeviceManager mBluetoothDeviceManager; BluetoothProfile.ServiceListener serviceListenerUnderTest; BluetoothStateReceiver receiverUnderTest; ArgumentCaptor<BluetoothLeAudio.Callback> leAudioCallbacksTest; private BluetoothDevice device1; private BluetoothDevice device2; Loading Loading @@ -109,7 +111,11 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { mBluetoothDeviceManager.setHeadsetServiceForTesting(mBluetoothHeadset); mBluetoothDeviceManager.setHearingAidServiceForTesting(mBluetoothHearingAid); leAudioCallbacksTest = ArgumentCaptor.forClass(BluetoothLeAudio.Callback.class); mBluetoothDeviceManager.setLeAudioServiceForTesting(mBluetoothLeAudio); verify(mBluetoothLeAudio).registerCallback(any(), leAudioCallbacksTest.capture()); } @Override Loading Loading @@ -162,8 +168,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device5, BluetoothDeviceManager.DEVICE_TYPE_LE_AUDIO)); receiverUnderTest.onReceive(mContext, buildGroupNodeStatusChangedIntent(1, device5, BluetoothLeAudio.GROUP_NODE_ADDED)); leAudioCallbacksTest.getValue().onGroupNodeAdded(device5, 1); when(mBluetoothLeAudio.getConnectedGroupLeadDevice(1)).thenReturn(device5); receiverUnderTest.onReceive(mContext, Loading @@ -172,8 +177,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device6, BluetoothDeviceManager.DEVICE_TYPE_LE_AUDIO)); receiverUnderTest.onReceive(mContext, buildGroupNodeStatusChangedIntent(2, device6, BluetoothLeAudio.GROUP_NODE_ADDED)); leAudioCallbacksTest.getValue().onGroupNodeAdded(device6, 2); when(mBluetoothLeAudio.getConnectedGroupLeadDevice(2)).thenReturn(device6); receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device3, Loading Loading @@ -216,13 +220,11 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device5, BluetoothDeviceManager.DEVICE_TYPE_LE_AUDIO)); receiverUnderTest.onReceive(mContext, buildGroupNodeStatusChangedIntent(1, device5, BluetoothLeAudio.GROUP_NODE_ADDED)); leAudioCallbacksTest.getValue().onGroupNodeAdded(device5, 1); receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device6, BluetoothDeviceManager.DEVICE_TYPE_LE_AUDIO)); receiverUnderTest.onReceive(mContext, buildGroupNodeStatusChangedIntent(1, device6, BluetoothLeAudio.GROUP_NODE_ADDED)); leAudioCallbacksTest.getValue().onGroupNodeAdded(device6, 1); when(mBluetoothLeAudio.getConnectedGroupLeadDevice(1)).thenReturn(device5); assertEquals(2, mBluetoothDeviceManager.getNumConnectedDevices()); assertEquals(2, mBluetoothDeviceManager.getUniqueConnectedDevices().size()); Loading Loading @@ -376,8 +378,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device5, BluetoothDeviceManager.DEVICE_TYPE_LE_AUDIO)); receiverUnderTest.onReceive(mContext, buildGroupNodeStatusChangedIntent(1, device5, BluetoothLeAudio.GROUP_NODE_ADDED)); leAudioCallbacksTest.getValue().onGroupNodeAdded(device5, 1); when(mAdapter.setActiveDevice(nullable(BluetoothDevice.class), eq(BluetoothAdapter.ACTIVE_DEVICE_ALL))).thenReturn(true); Loading Loading @@ -408,13 +409,11 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device5, BluetoothDeviceManager.DEVICE_TYPE_LE_AUDIO)); receiverUnderTest.onReceive(mContext, buildGroupNodeStatusChangedIntent(1, device5, BluetoothLeAudio.GROUP_NODE_ADDED)); leAudioCallbacksTest.getValue().onGroupNodeAdded(device5, 1); receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothLeAudio.STATE_CONNECTED, device6, BluetoothDeviceManager.DEVICE_TYPE_LE_AUDIO)); receiverUnderTest.onReceive(mContext, buildGroupNodeStatusChangedIntent(1, device6, BluetoothLeAudio.GROUP_NODE_ADDED)); leAudioCallbacksTest.getValue().onGroupNodeAdded(device6, 1); when(mAdapter.setActiveDevice(nullable(BluetoothDevice.class), eq(BluetoothAdapter.ACTIVE_DEVICE_ALL))).thenReturn(true); mBluetoothDeviceManager.connectAudio(device5.getAddress()); Loading Loading @@ -457,22 +456,6 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { return i; } private Intent buildGroupNodeStatusChangedIntent(int groupId, BluetoothDevice device, int nodeStatus) { Intent i = new Intent(BluetoothLeAudio.ACTION_LE_AUDIO_GROUP_NODE_STATUS_CHANGED); i.putExtra(BluetoothDevice.EXTRA_DEVICE, device); i.putExtra(BluetoothLeAudio.EXTRA_LE_AUDIO_GROUP_ID, groupId); i.putExtra(BluetoothLeAudio.EXTRA_LE_AUDIO_GROUP_NODE_STATUS, nodeStatus); return i; } private Intent buildGroupStatusChangedIntent(int groupId, int groupStatus) { Intent i = new Intent(BluetoothLeAudio.ACTION_LE_AUDIO_GROUP_STATUS_CHANGED); i.putExtra(BluetoothLeAudio.EXTRA_LE_AUDIO_GROUP_ID, groupId); i.putExtra(BluetoothLeAudio.EXTRA_LE_AUDIO_GROUP_STATUS, groupStatus); return i; } private BluetoothDevice makeBluetoothDevice(String address) { Parcel p1 = Parcel.obtain(); p1.writeString(address); Loading Loading
src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java +42 −23 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHeadset; import android.bluetooth.BluetoothHearingAid; import android.bluetooth.BluetoothLeAudio; import android.bluetooth.BluetoothLeAudioCodecStatus; import android.bluetooth.BluetoothProfile; import android.bluetooth.BluetoothStatusCodes; import android.content.Context; Loading @@ -34,6 +35,7 @@ import com.android.internal.util.IndentingPrintWriter; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.concurrent.Executor; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.LinkedList; Loading @@ -47,6 +49,37 @@ public class BluetoothDeviceManager { public static final int DEVICE_TYPE_HEARING_AID = 1; public static final int DEVICE_TYPE_LE_AUDIO = 2; private BluetoothLeAudio.Callback mLeAudioCallbacks = new BluetoothLeAudio.Callback() { @Override public void onCodecConfigChanged(int groupId, BluetoothLeAudioCodecStatus status) {} @Override public void onGroupStatusChanged(int groupId, int groupStatus) {} @Override public void onGroupNodeAdded(BluetoothDevice device, int groupId) { Log.i(this, device.getAddress() + " group added " + groupId); if (device == null || groupId == BluetoothLeAudio.GROUP_ID_INVALID) { Log.w(this, "invalid parameter"); return; } synchronized (mLock) { mGroupsByDevice.put(device, groupId); } } @Override public void onGroupNodeRemoved(BluetoothDevice device, int groupId) { if (device == null || groupId == BluetoothLeAudio.GROUP_ID_INVALID) { Log.w(this, "invalid parameter"); return; } synchronized (mLock) { mGroupsByDevice.remove(device); } } }; private final BluetoothProfile.ServiceListener mBluetoothProfileServiceListener = new BluetoothProfile.ServiceListener() { @Override Loading @@ -66,6 +99,11 @@ public class BluetoothDeviceManager { mBluetoothLeAudioService = (BluetoothLeAudio) proxy; logString = "Got BluetoothLeAudio: " + mBluetoothLeAudioService; if (!mLeAudioCallbackRegistered) { mBluetoothLeAudioService.registerCallback( mExecutor, mLeAudioCallbacks); mLeAudioCallbackRegistered = true; } } else { logString = "Connected to non-requested bluetooth service." + " Not changing bluetooth headset."; Loading Loading @@ -145,11 +183,13 @@ public class BluetoothDeviceManager { private BluetoothRouteManager mBluetoothRouteManager; private BluetoothHeadset mBluetoothHeadset; private BluetoothHearingAid mBluetoothHearingAid; private boolean mLeAudioCallbackRegistered = false; private BluetoothLeAudio mBluetoothLeAudioService; private boolean mLeAudioSetAsCommunicationDevice = false; private BluetoothDevice mBluetoothHearingAidActiveDeviceCache; private BluetoothAdapter mBluetoothAdapter; private AudioManager mAudioManager; private Executor mExecutor; public BluetoothDeviceManager(Context context, BluetoothAdapter bluetoothAdapter) { if (bluetoothAdapter != null) { Loading @@ -161,6 +201,7 @@ public class BluetoothDeviceManager { bluetoothAdapter.getProfileProxy(context, mBluetoothProfileServiceListener, BluetoothProfile.LE_AUDIO); mAudioManager = context.getSystemService(AudioManager.class); mExecutor = context.getMainExecutor(); } } Loading Loading @@ -265,6 +306,7 @@ public class BluetoothDeviceManager { public void setLeAudioServiceForTesting(BluetoothLeAudio bluetoothLeAudio) { mBluetoothLeAudioService = bluetoothLeAudio; mBluetoothLeAudioService.registerCallback(mExecutor, mLeAudioCallbacks); } public static String getDeviceTypeString(int deviceType) { Loading Loading @@ -339,29 +381,6 @@ public class BluetoothDeviceManager { } } void onGroupNodeAdded(BluetoothDevice device, int groupId) { Log.i(this, device.getAddress() + " group added " + groupId); if (device == null || groupId == BluetoothLeAudio.GROUP_ID_INVALID) { Log.w(this, "invalid parameter"); return; } synchronized (mLock) { mGroupsByDevice.put(device, groupId); } } void onGroupNodeRemoved(BluetoothDevice device, int groupId) { if (device == null || groupId == BluetoothLeAudio.GROUP_ID_INVALID) { Log.w(this, "invalid parameter"); return; } synchronized (mLock) { mGroupsByDevice.remove(device); } } public void disconnectAudio() { if (mBluetoothAdapter != null) { for (BluetoothDevice device: mBluetoothAdapter.getActiveDevices( Loading
src/com/android/server/telecom/bluetooth/BluetoothStateReceiver.java +0 −21 Original line number Diff line number Diff line Loading @@ -46,8 +46,6 @@ public class BluetoothStateReceiver extends BroadcastReceiver { INTENT_FILTER.addAction(BluetoothHearingAid.ACTION_ACTIVE_DEVICE_CHANGED); INTENT_FILTER.addAction(BluetoothLeAudio.ACTION_LE_AUDIO_CONNECTION_STATE_CHANGED); INTENT_FILTER.addAction(BluetoothLeAudio.ACTION_LE_AUDIO_ACTIVE_DEVICE_CHANGED); INTENT_FILTER.addAction(BluetoothLeAudio.ACTION_LE_AUDIO_GROUP_NODE_STATUS_CHANGED); INTENT_FILTER.addAction(BluetoothLeAudio.ACTION_LE_AUDIO_GROUP_STATUS_CHANGED); } // If not in a call, BSR won't listen to the Bluetooth stack's HFP on/off messages, since Loading @@ -74,9 +72,6 @@ public class BluetoothStateReceiver extends BroadcastReceiver { case BluetoothHeadset.ACTION_ACTIVE_DEVICE_CHANGED: handleActiveDeviceChanged(intent); break; case BluetoothLeAudio.ACTION_LE_AUDIO_GROUP_NODE_STATUS_CHANGED: handleGroupNodeStatusChanged(intent); break; } } finally { Log.endSession(); Loading Loading @@ -199,22 +194,6 @@ public class BluetoothStateReceiver extends BroadcastReceiver { } } private void handleGroupNodeStatusChanged(Intent intent) { BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); int groupId = intent.getIntExtra(BluetoothLeAudio.EXTRA_LE_AUDIO_GROUP_ID, BluetoothLeAudio.GROUP_ID_INVALID); int groupNodeStatus = intent.getIntExtra(BluetoothLeAudio.EXTRA_LE_AUDIO_GROUP_NODE_STATUS, -1); if (groupNodeStatus == BluetoothLeAudio.GROUP_NODE_ADDED) { mBluetoothDeviceManager.onGroupNodeAdded(device, groupId); } else { mBluetoothDeviceManager.onGroupNodeRemoved(device, groupId); } } public BluetoothDeviceManager getBluetoothDeviceManager() { return mBluetoothDeviceManager; } Loading
src/com/android/server/telecom/components/UserCallIntentProcessor.java 100644 → 100755 +1 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ public class UserCallIntentProcessor { private void processOutgoingCallIntent(Intent intent, String callingPackageName, boolean canCallNonEmergency, boolean isLocalInvocation) { Uri handle = intent.getData(); if (handle == null) return; String scheme = handle.getScheme(); String uriString = handle.getSchemeSpecificPart(); Loading
tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java +13 −30 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; Loading @@ -68,6 +69,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { BluetoothDeviceManager mBluetoothDeviceManager; BluetoothProfile.ServiceListener serviceListenerUnderTest; BluetoothStateReceiver receiverUnderTest; ArgumentCaptor<BluetoothLeAudio.Callback> leAudioCallbacksTest; private BluetoothDevice device1; private BluetoothDevice device2; Loading Loading @@ -109,7 +111,11 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { mBluetoothDeviceManager.setHeadsetServiceForTesting(mBluetoothHeadset); mBluetoothDeviceManager.setHearingAidServiceForTesting(mBluetoothHearingAid); leAudioCallbacksTest = ArgumentCaptor.forClass(BluetoothLeAudio.Callback.class); mBluetoothDeviceManager.setLeAudioServiceForTesting(mBluetoothLeAudio); verify(mBluetoothLeAudio).registerCallback(any(), leAudioCallbacksTest.capture()); } @Override Loading Loading @@ -162,8 +168,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device5, BluetoothDeviceManager.DEVICE_TYPE_LE_AUDIO)); receiverUnderTest.onReceive(mContext, buildGroupNodeStatusChangedIntent(1, device5, BluetoothLeAudio.GROUP_NODE_ADDED)); leAudioCallbacksTest.getValue().onGroupNodeAdded(device5, 1); when(mBluetoothLeAudio.getConnectedGroupLeadDevice(1)).thenReturn(device5); receiverUnderTest.onReceive(mContext, Loading @@ -172,8 +177,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device6, BluetoothDeviceManager.DEVICE_TYPE_LE_AUDIO)); receiverUnderTest.onReceive(mContext, buildGroupNodeStatusChangedIntent(2, device6, BluetoothLeAudio.GROUP_NODE_ADDED)); leAudioCallbacksTest.getValue().onGroupNodeAdded(device6, 2); when(mBluetoothLeAudio.getConnectedGroupLeadDevice(2)).thenReturn(device6); receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device3, Loading Loading @@ -216,13 +220,11 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device5, BluetoothDeviceManager.DEVICE_TYPE_LE_AUDIO)); receiverUnderTest.onReceive(mContext, buildGroupNodeStatusChangedIntent(1, device5, BluetoothLeAudio.GROUP_NODE_ADDED)); leAudioCallbacksTest.getValue().onGroupNodeAdded(device5, 1); receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device6, BluetoothDeviceManager.DEVICE_TYPE_LE_AUDIO)); receiverUnderTest.onReceive(mContext, buildGroupNodeStatusChangedIntent(1, device6, BluetoothLeAudio.GROUP_NODE_ADDED)); leAudioCallbacksTest.getValue().onGroupNodeAdded(device6, 1); when(mBluetoothLeAudio.getConnectedGroupLeadDevice(1)).thenReturn(device5); assertEquals(2, mBluetoothDeviceManager.getNumConnectedDevices()); assertEquals(2, mBluetoothDeviceManager.getUniqueConnectedDevices().size()); Loading Loading @@ -376,8 +378,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device5, BluetoothDeviceManager.DEVICE_TYPE_LE_AUDIO)); receiverUnderTest.onReceive(mContext, buildGroupNodeStatusChangedIntent(1, device5, BluetoothLeAudio.GROUP_NODE_ADDED)); leAudioCallbacksTest.getValue().onGroupNodeAdded(device5, 1); when(mAdapter.setActiveDevice(nullable(BluetoothDevice.class), eq(BluetoothAdapter.ACTIVE_DEVICE_ALL))).thenReturn(true); Loading Loading @@ -408,13 +409,11 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device5, BluetoothDeviceManager.DEVICE_TYPE_LE_AUDIO)); receiverUnderTest.onReceive(mContext, buildGroupNodeStatusChangedIntent(1, device5, BluetoothLeAudio.GROUP_NODE_ADDED)); leAudioCallbacksTest.getValue().onGroupNodeAdded(device5, 1); receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothLeAudio.STATE_CONNECTED, device6, BluetoothDeviceManager.DEVICE_TYPE_LE_AUDIO)); receiverUnderTest.onReceive(mContext, buildGroupNodeStatusChangedIntent(1, device6, BluetoothLeAudio.GROUP_NODE_ADDED)); leAudioCallbacksTest.getValue().onGroupNodeAdded(device6, 1); when(mAdapter.setActiveDevice(nullable(BluetoothDevice.class), eq(BluetoothAdapter.ACTIVE_DEVICE_ALL))).thenReturn(true); mBluetoothDeviceManager.connectAudio(device5.getAddress()); Loading Loading @@ -457,22 +456,6 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { return i; } private Intent buildGroupNodeStatusChangedIntent(int groupId, BluetoothDevice device, int nodeStatus) { Intent i = new Intent(BluetoothLeAudio.ACTION_LE_AUDIO_GROUP_NODE_STATUS_CHANGED); i.putExtra(BluetoothDevice.EXTRA_DEVICE, device); i.putExtra(BluetoothLeAudio.EXTRA_LE_AUDIO_GROUP_ID, groupId); i.putExtra(BluetoothLeAudio.EXTRA_LE_AUDIO_GROUP_NODE_STATUS, nodeStatus); return i; } private Intent buildGroupStatusChangedIntent(int groupId, int groupStatus) { Intent i = new Intent(BluetoothLeAudio.ACTION_LE_AUDIO_GROUP_STATUS_CHANGED); i.putExtra(BluetoothLeAudio.EXTRA_LE_AUDIO_GROUP_ID, groupId); i.putExtra(BluetoothLeAudio.EXTRA_LE_AUDIO_GROUP_STATUS, groupStatus); return i; } private BluetoothDevice makeBluetoothDevice(String address) { Parcel p1 = Parcel.obtain(); p1.writeString(address); Loading