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
diff --git a/src/com/android/bluetooth/a2dp/A2dpStateMachine.java b/src/com/android/bluetooth/a2dp/A2dpStateMachine.java
index e0df8b2..cc8f88d 100644
--- a/src/com/android/bluetooth/a2dp/A2dpStateMachine.java
+++ b/src/com/android/bluetooth/a2dp/A2dpStateMachine.java
@@ -596,7 +596,7 @@
 
     boolean isConnected() {
         synchronized (this) {
-            return (getCurrentState() == mConnected);
+            return (getConnectionState() == BluetoothProfile.STATE_CONNECTED);
         }
     }