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

Commit 441f1231 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes from topic 'bt-fix-hfp-headset-state-machine'

* changes:
  HFP: Indicate profile as connected after SLC is established
  HFP: HeadsetStateMachine logging clean-up
parents a331cdb9 32cc7ed3
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -513,7 +513,8 @@ final class RemoteDevices {
        BluetoothDevice device = getDevice(address);

        if (device == null) {
            errorLog("aclStateChangeCallback: Device is NULL");
            errorLog("aclStateChangeCallback: device is NULL, address="
                    + Utils.getAddressStringFromByte(address) + ", newState=" + newState);
            return;
        }
        int state = mAdapterService.getState();
+11 −8
Original line number Diff line number Diff line
@@ -352,30 +352,34 @@ public class HeadsetService extends ProfileService {

    public boolean connect(BluetoothDevice device) {
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH ADMIN permission");

        Log.d(TAG, "connect: device=" + device);
        if (getPriority(device) == BluetoothProfile.PRIORITY_OFF) {
            Log.w(TAG, "connect: PRIORITY_OFF, device=" + device);
            return false;
        }

        int connectionState = mStateMachine.getConnectionState(device);
        Log.d(TAG, "connectionState = " + connectionState);
        if (connectionState == BluetoothProfile.STATE_CONNECTED
                || connectionState == BluetoothProfile.STATE_CONNECTING) {
            Log.w(TAG,
                    "connect: already connected/connecting, connectionState=" + connectionState
                            + ", device=" + device);
            return false;
        }

        mStateMachine.sendMessage(HeadsetStateMachine.CONNECT, device);
        return true;
    }

    boolean disconnect(BluetoothDevice device) {
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH ADMIN permission");
        Log.d(TAG, "disconnect: device=" + device);
        int connectionState = mStateMachine.getConnectionState(device);
        if (connectionState != BluetoothProfile.STATE_CONNECTED
                && connectionState != BluetoothProfile.STATE_CONNECTING) {
            Log.w(TAG,
                    "disconnect: not connected/connecting, connectionState=" + connectionState
                            + ", device=" + device);
            return false;
        }

        mStateMachine.sendMessage(HeadsetStateMachine.DISCONNECT, device);
        return true;
    }
@@ -483,12 +487,11 @@ public class HeadsetService extends ProfileService {
        // TODO(BT) BLUETOOTH or BLUETOOTH_ADMIN permission
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        if (!mStateMachine.isConnected()) {
            return false;
        }
        if (!mStateMachine.isSlcConnected()) {
            Log.w(TAG, "connectAudio: profile not connected");
            return false;
        }
        if (mStateMachine.isAudioOn()) {
            Log.w(TAG, "connectAudio: audio is already ON");
            return false;
        }
        mStateMachine.sendMessage(HeadsetStateMachine.CONNECT_AUDIO);
+298 −357

File changed.

Preview size limit exceeded, changes collapsed.