summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrace Jia <xiaotonj@google.com>2023-11-30 19:13:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2023-11-30 19:13:55 +0000
commitae5f17bc2707ad87ccbd20202f4e021513734341 (patch)
tree6cfb133a220418701053c4eed3ef428b91440df2
parentd73740be32950fb8c2e83bd20a6a9a7614417831 (diff)
parent9b62a3ec1c4caf5e06589427cef5848f72aa9c54 (diff)
downloadTelecomm-ae5f17bc2707ad87ccbd20202f4e021513734341.tar.gz
Merge "Revert "Avoid entering to the connected state of an inactive device in"" into main
-rw-r--r--src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java b/src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java
index 644d9aeda..ceabd669a 100644
--- a/src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java
+++ b/src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java
@@ -21,8 +21,8 @@ import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadset;
import android.bluetooth.BluetoothHearingAid;
-import android.bluetooth.BluetoothLeAudio;
import android.bluetooth.BluetoothProfile;
+import android.bluetooth.BluetoothLeAudio;
import android.content.Context;
import android.media.AudioDeviceInfo;
import android.os.Message;
@@ -40,10 +40,12 @@ import com.android.server.telecom.TelecomSystem;
import com.android.server.telecom.Timeouts;
import com.android.server.telecom.flags.FeatureFlags;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@@ -138,7 +140,7 @@ public class BluetoothRouteManager extends StateMachine {
Log.w(LOG_TAG, "Entering AudioOff state but device %s appears to be connected. " +
"Switching to audio-on state for that device.", erroneouslyConnectedDevice);
// change this to just transition to the new audio on state
- transitionToActualState(null /* excludeAddress */);
+ transitionToActualState();
}
cleanupStatesForDisconnectedDevices();
if (mListener != null) {
@@ -261,7 +263,7 @@ public class BluetoothRouteManager extends StateMachine {
case LOST_DEVICE:
removeDevice((String) args.arg2);
if (Objects.equals(address, mDeviceAddress)) {
- transitionToActualState(null /* excludeAddress */);
+ transitionToActualState();
}
break;
case CONNECT_BT:
@@ -301,7 +303,7 @@ public class BluetoothRouteManager extends StateMachine {
case CONNECTION_TIMEOUT:
Log.i(LOG_TAG, "Connection with device %s timed out.",
mDeviceAddress);
- transitionToActualState(null /* excludeAddress */);
+ transitionToActualState();
break;
case BT_AUDIO_IS_ON:
if (Objects.equals(mDeviceAddress, address)) {
@@ -318,7 +320,7 @@ public class BluetoothRouteManager extends StateMachine {
if (Objects.equals(mDeviceAddress, address) || address == null) {
Log.i(LOG_TAG, "Connection with device %s failed.",
mDeviceAddress);
- transitionToActualState(address);
+ transitionToActualState();
} else {
Log.w(LOG_TAG, "Got BT lost message for device %s while" +
" connecting to %s.", address, mDeviceAddress);
@@ -378,7 +380,7 @@ public class BluetoothRouteManager extends StateMachine {
case LOST_DEVICE:
removeDevice((String) args.arg2);
if (Objects.equals(address, mDeviceAddress)) {
- transitionToActualState(null /* excludeAddress */);
+ transitionToActualState();
}
break;
case CONNECT_BT:
@@ -440,7 +442,7 @@ public class BluetoothRouteManager extends StateMachine {
case BT_AUDIO_LOST:
if (Objects.equals(mDeviceAddress, address) || address == null) {
Log.i(LOG_TAG, "BT connection with device %s lost.", mDeviceAddress);
- transitionToActualState(address);
+ transitionToActualState();
} else {
Log.w(LOG_TAG, "Got BT lost message for device %s while" +
" connected to %s.", address, mDeviceAddress);
@@ -769,7 +771,7 @@ public class BluetoothRouteManager extends StateMachine {
actualAddress)) {
Log.i(this, "trying to connect to already connected device -- skipping connection"
+ " and going into the actual connected state.");
- transitionToActualState(null /* excludeAddress */);
+ transitionToActualState();
return null;
}
@@ -805,10 +807,9 @@ public class BluetoothRouteManager extends StateMachine {
return null;
}
- private void transitionToActualState(String excludeAddress) {
+ private void transitionToActualState() {
BluetoothDevice possiblyAlreadyConnectedDevice = getBluetoothAudioConnectedDevice();
- if (possiblyAlreadyConnectedDevice != null
- && !possiblyAlreadyConnectedDevice.getAddress().equals(excludeAddress)) {
+ if (possiblyAlreadyConnectedDevice != null) {
Log.i(LOG_TAG, "Device %s is already connected; going to AudioConnected.",
possiblyAlreadyConnectedDevice);
transitionTo(getConnectedStateForAddress(