Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b62a3ec authored by Grace Jia's avatar Grace Jia
Browse files

Revert "Avoid entering to the connected state of an inactive device in"

This reverts commit f7c970e4.

Reason for revert: This is unflagged code; we can re-add with a flag at a later date.
Bug: 300236761

Change-Id: Ia22ddaaf414d37a022527237f4081118c22320b9
parent 82dce2df
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -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.List;
import java.util.Objects;
@@ -140,7 +142,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) {
@@ -284,7 +286,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:
@@ -324,7 +326,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)) {
@@ -341,7 +343,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);
@@ -401,7 +403,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:
@@ -463,7 +465,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);
@@ -796,7 +798,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;
        }

@@ -832,10 +834,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(