HearingAid: Check the value of mConnectionState in isConnected

* In current HearingAid state machine design, there could be potential
critical timing to cause java.lang.ArrayIndexOutOfBoundsException:
index=-1, when HearingAid 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
HearingAidStateMachine to avoid this AndroidRuntime exception.

Bug: 154663576
Test: Enable Bluetooth -> Connect Bluetooth headset -> Disconnect
Bluetooth headset -> Disable Bluetooth then check HearingAid state
machine log.

Change-Id: I21826a3e80d93b0cab7210d40975fa461485dcda
1 file changed