Hfp: maintain Headset state in mCurrentState

* In current HeadsetStateMachine design, there could be potential
critical timing to cause java.lang.ArrayIndexOutOfBoundsException:
index=-1, when Headset state machine exit one state to enter another
state. at this timing, the mStateStackTopIndex value of mStateStack be
set to -1.
* Checking the current connection/audio state value maintained in
mCurrentState to avoid this AndroidRuntime exception.

Bug: 153219427
Bug: 151704635
Test: Enable Bluetooth -> Connect Bluetooth headset -> Disconnect
Bluetooth headset -> Disable Bluetooth then check Headset state
machine log

Change-Id: I3042f8b1400a464e65d4424cbd4ea32029e88dc9
1 file changed