Merge "A2dp: update correct state to HeadsetA2dpSync while enter Disconnected" into q-keystone-qcom-dev
diff --git a/src/com/android/bluetooth/a2dp/A2dpStateMachine.java b/src/com/android/bluetooth/a2dp/A2dpStateMachine.java
index ceb6a4e..01018d0 100644
--- a/src/com/android/bluetooth/a2dp/A2dpStateMachine.java
+++ b/src/com/android/bluetooth/a2dp/A2dpStateMachine.java
@@ -159,7 +159,6 @@
if (mLastConnectionState != -1) {
// Don't broadcast during startup
- broadcastConnectionState(mConnectionState, mLastConnectionState);
if (mIsPlaying) {
Log.i(TAG, "Disconnected: stopped playing: " + mDevice);
mIsPlaying = false;
@@ -167,6 +166,7 @@
broadcastAudioState(BluetoothA2dp.STATE_NOT_PLAYING,
BluetoothA2dp.STATE_PLAYING);
}
+ broadcastConnectionState(mConnectionState, mLastConnectionState);
AdapterService adapterService = AdapterService.getAdapterService();
if (adapterService.isVendorIntfEnabled() &&
adapterService.isTwsPlusDevice(mDevice)) {
diff --git a/src/com/android/bluetooth/hfp/HeadsetA2dpSync.java b/src/com/android/bluetooth/hfp/HeadsetA2dpSync.java
index 37647af..7fb2e2d 100644
--- a/src/com/android/bluetooth/hfp/HeadsetA2dpSync.java
+++ b/src/com/android/bluetooth/hfp/HeadsetA2dpSync.java
@@ -195,7 +195,9 @@
}
switch(currState) {
case BluetoothA2dp.STATE_NOT_PLAYING:
- mA2dpConnState.put(device, A2DP_CONNECTED);
+ if (mA2dpConnState.containsKey(device)) {
+ mA2dpConnState.put(device, A2DP_CONNECTED);
+ }
/*
* send message to statemachine. We send message to SMs
* only when all devices moved to SUSPENDED.
@@ -207,7 +209,9 @@
}
break;
case BluetoothA2dp.STATE_PLAYING:
- mA2dpConnState.put(device, A2DP_PLAYING);
+ if (mA2dpConnState.containsKey(device)) {
+ mA2dpConnState.put(device, A2DP_PLAYING);
+ }
// if call/ ring is ongoing and we received playing,
// we need to suspend
if (mHeadsetService.isInCall() || mHeadsetService.isRinging()) {