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

Commit 57959a2a authored by Mallikarjuna GB's avatar Mallikarjuna GB Committed by Linux Build Service Account
Browse files

Properly update profile connection state.

When DUT is toggled between various paired Headsets Connection
state is not updated properly in some scenarios.This is causing
Bluetooth icon to be in connected state even when no Headsets are
connected.

With this patch we will broadcast connection states in case of
failure and will make sure connected, connecting,disconnecting
devices count is never negative.

Change-Id: Icb1a7215ff6d9491afbb5f7f203ca0a2c6b7f43a
parent b1fef072
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -514,6 +514,9 @@ final class A2dpStateMachine extends StateMachine {
                        broadcastConnectionState(device, BluetoothProfile.STATE_DISCONNECTED,
                                       BluetoothProfile.STATE_CONNECTING);
                        break;
                    } else {
                        broadcastConnectionState(mCurrentDevice, BluetoothProfile.STATE_DISCONNECTING,
                                       BluetoothProfile.STATE_CONNECTED);
                    }

                    synchronized (A2dpStateMachine.this) {
@@ -532,7 +535,7 @@ final class A2dpStateMachine extends StateMachine {
                                   BluetoothProfile.STATE_CONNECTED);
                    if (!disconnectA2dpNative(getByteAddress(device))) {
                        broadcastConnectionState(device, BluetoothProfile.STATE_CONNECTED,
                                       BluetoothProfile.STATE_DISCONNECTED);
                                       BluetoothProfile.STATE_DISCONNECTING);
                        break;
                    }
                    transitionTo(mPending);
+12 −3
Original line number Diff line number Diff line
@@ -408,15 +408,24 @@ class AdapterProperties {
    private boolean updateCountersAndCheckForConnectionStateChange(int state, int prevState) {
        switch (prevState) {
            case BluetoothProfile.STATE_CONNECTING:
                if (mProfilesConnecting > 0)
                    mProfilesConnecting--;
                else
                    Log.e(TAG, "mProfilesConnecting " + mProfilesConnecting);
                break;

            case BluetoothProfile.STATE_CONNECTED:
                if (mProfilesConnected > 0)
                    mProfilesConnected--;
                else
                    Log.e(TAG, "mProfilesConnected " + mProfilesConnected);
                break;

            case BluetoothProfile.STATE_DISCONNECTING:
                if (mProfilesDisconnecting > 0)
                    mProfilesDisconnecting--;
                else
                    Log.e(TAG, "mProfilesDisconnecting " + mProfilesDisconnecting);
                break;
        }

+4 −1
Original line number Diff line number Diff line
@@ -823,6 +823,9 @@ final class HeadsetStateMachine extends StateMachine {
                    if (mConnectedDevicesList.contains(device)) {
                        Log.e(TAG, "ERROR: Connect received for already connected device, Ignore");
                        break;
                    } else {
                            broadcastConnectionState(mCurrentDevice, BluetoothProfile.STATE_DISCONNECTING,
                                       BluetoothProfile.STATE_CONNECTED);
                    }

                    if (!mRetryConnect.containsKey(device)) {
@@ -904,7 +907,7 @@ final class HeadsetStateMachine extends StateMachine {
                                   BluetoothProfile.STATE_CONNECTED);
                    if (!disconnectHfpNative(getByteAddress(device))) {
                        broadcastConnectionState(device, BluetoothProfile.STATE_CONNECTED,
                                       BluetoothProfile.STATE_DISCONNECTED);
                                       BluetoothProfile.STATE_DISCONNECTING);
                        break;
                    }