Loading src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java +12 −11 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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: Loading Loading @@ -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)) { Loading @@ -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); Loading Loading @@ -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: Loading Loading @@ -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); Loading Loading @@ -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; } Loading Loading @@ -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( Loading Loading
src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java +12 −11 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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: Loading Loading @@ -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)) { Loading @@ -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); Loading Loading @@ -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: Loading Loading @@ -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); Loading Loading @@ -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; } Loading Loading @@ -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( Loading