Fix issue 2361949: A2DP suspend parameters set wrongly.

Move reset of A2DP suspend state from handleSinkStateChange() in BluetoothA2dpService to
BluetoothA2dp.ACTION_SINK_STATE_CHANGED intent receiver in AudioService.
Previous implementation could cause a false reset of suspend state if a new sink attempted to
connect while A2DP was suspended.
New implementation only resets A2DP suspend state when a new sink is actually connected.
diff --git a/core/java/android/server/BluetoothA2dpService.java b/core/java/android/server/BluetoothA2dpService.java
index 46145b9..8859339 100644
--- a/core/java/android/server/BluetoothA2dpService.java
+++ b/core/java/android/server/BluetoothA2dpService.java
@@ -459,10 +459,6 @@
             checkSinkSuspendState(state);
             mTargetA2dpState = -1;
 
-            if (state == BluetoothA2dp.STATE_CONNECTING) {
-                mAudioManager.setParameters("A2dpSuspended=false");
-            }
-
             if (getSinkPriority(device) > BluetoothA2dp.PRIORITY_OFF &&
                     state == BluetoothA2dp.STATE_CONNECTING ||
                     state == BluetoothA2dp.STATE_CONNECTED) {
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 4a1c2a5..d62f6c3 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -1438,6 +1438,8 @@
                     AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,
                                                          AudioSystem.DEVICE_STATE_AVAILABLE,
                                                          address);
+                    // Reset A2DP suspend state each time a new sink is connected
+                    AudioSystem.setParameters("A2dpSuspended=false");
                     mConnectedDevices.put( new Integer(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP),
                             address);
                 }