diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2021-11-09 20:55:07 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-11-09 20:55:07 +0000 |
commit | f9fadba02702054b799e8d52942a217cbe0cb46c (patch) | |
tree | 6ffac83d00b7c3397f9c3f2b938d4dd4fe8e188e | |
parent | c041a684e5290efb5542a0300a0449ebe8c378db (diff) | |
parent | e36e1c2c6aed4b9acd1191a81f98b16e1f0e62b9 (diff) | |
download | Bluetooth-f9fadba02702054b799e8d52942a217cbe0cb46c.tar.gz |
Merge "leaudio: Try reconnect other set members on incoming connection"
-rw-r--r-- | src/com/android/bluetooth/le_audio/LeAudioService.java | 64 |
1 files changed, 39 insertions, 25 deletions
diff --git a/src/com/android/bluetooth/le_audio/LeAudioService.java b/src/com/android/bluetooth/le_audio/LeAudioService.java index f803b3808..da5828e12 100644 --- a/src/com/android/bluetooth/le_audio/LeAudioService.java +++ b/src/com/android/bluetooth/le_audio/LeAudioService.java @@ -421,12 +421,6 @@ public class LeAudioService extends ProfileService { return false; } - int groupId = getGroupId(device); - - if (DBG) { - Log.d(TAG, "connect(): " + device + " group id: " + groupId); - } - synchronized (mStateMachines) { LeAudioStateMachine sm = getOrCreateStateMachine(device); if (sm == null) { @@ -437,25 +431,7 @@ public class LeAudioService extends ProfileService { } // Connect other devices from this group - if (groupId != LE_AUDIO_GROUP_ID_INVALID) { - for (BluetoothDevice storedDevice : mDeviceGroupIdMap.keySet()) { - if (device.equals(storedDevice)) { - continue; - } - if (getGroupId(storedDevice) != groupId) { - continue; - } - synchronized (mStateMachines) { - LeAudioStateMachine sm = getOrCreateStateMachine(storedDevice); - if (sm == null) { - Log.e(TAG, "Ignored connect request for " + storedDevice - + " : no state machine"); - continue; - } - sm.sendMessage(LeAudioStateMachine.CONNECT); - } - } - } + connectSet(device); return true; } @@ -889,6 +865,42 @@ public class LeAudioService extends ProfileService { return activeDevices; } + void connectSet(BluetoothDevice device) { + int groupId = getGroupId(device); + if (groupId == LE_AUDIO_GROUP_ID_INVALID) { + return; + } + + if (DBG) { + Log.d(TAG, "connect() others from group id: " + groupId); + } + + for (BluetoothDevice storedDevice : mDeviceGroupIdMap.keySet()) { + if (device.equals(storedDevice)) { + continue; + } + + if (getGroupId(storedDevice) != groupId) { + continue; + } + + if (DBG) { + Log.d(TAG, "connect(): " + device); + } + + synchronized (mStateMachines) { + LeAudioStateMachine sm = getOrCreateStateMachine(storedDevice); + if (sm == null) { + Log.e(TAG, "Ignored connect request for " + storedDevice + + " : no state machine"); + continue; + } + sm.sendMessage(LeAudioStateMachine.CONNECT); + } + } + + } + // Suppressed since this is part of a local process @SuppressLint("AndroidFrameworkRequiresPermission") void messageFromNative(LeAudioStackEvent stackEvent) { @@ -905,6 +917,8 @@ public class LeAudioService extends ProfileService { case LeAudioStackEvent.CONNECTION_STATE_CONNECTED: case LeAudioStackEvent.CONNECTION_STATE_CONNECTING: sm = getOrCreateStateMachine(device); + /* Incoming connection try to connect other devices from the group */ + connectSet(device); break; default: break; |