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

Commit ca90765c authored by jonerlin's avatar jonerlin Committed by Myles Watson
Browse files

A2dp: Check the value of mConnectionState in isConnected

* There could be potential critical timing to cause
java.lang.ArrayIndexOutOfBoundsException: index=-1, when a2dp state machine
exit one state to enter another state. at this timing, the mStateStackTopIndex
value of mStateStack be set to -1.
* Checking mConnectionState value which maintained in A2dpStateMachine to avoid
this AndroidRuntime exception.

Bug: 142217033
Test: Enable Bluetooth -> Connect Bluetooth headset -> Disconnect
Bluetooth headset -> Disable Bluetooth then check a2dp state machine log.
Change-Id: Ifdd3e96b84496cef04a70d95b5b64eca81e5db9c
parent eac7d5a3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -596,7 +596,7 @@ final class A2dpStateMachine extends StateMachine {

    boolean isConnected() {
        synchronized (this) {
            return (getCurrentState() == mConnected);
            return (getConnectionState() == BluetoothProfile.STATE_CONNECTED);
        }
    }