Merge "A2DP sink: Set local Bluetooth Address in AudioSystem to decode packet" into q-keystone-qcom-dev
diff --git a/src/com/android/bluetooth/a2dpsink/A2dpSinkStateMachine.java b/src/com/android/bluetooth/a2dpsink/A2dpSinkStateMachine.java
old mode 100644
new mode 100755
index 2bfbb2b..7ea611a
--- a/src/com/android/bluetooth/a2dpsink/A2dpSinkStateMachine.java
+++ b/src/com/android/bluetooth/a2dpsink/A2dpSinkStateMachine.java
@@ -15,12 +15,14 @@
  */
 package com.android.bluetooth.a2dpsink;
 
+import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothA2dpSink;
 import android.bluetooth.BluetoothAudioConfig;
 import android.bluetooth.BluetoothDevice;
 import android.bluetooth.BluetoothProfile;
 import android.content.Intent;
 import android.media.AudioFormat;
+import android.media.AudioSystem;
 import android.os.Message;
 import android.util.Log;
 
@@ -43,6 +45,7 @@
     //100->199 Internal Events
     protected static final int CLEANUP = 100;
     private static final int CONNECT_TIMEOUT = 101;
+    private static final String BT_ADDR_KEY = "bt_addr";
 
     //200->299 Events from Native
     static final int STACK_EVENT = 200;
@@ -56,6 +59,7 @@
     protected final Connecting mConnecting;
     protected final Connected mConnected;
     protected final Disconnecting mDisconnecting;
+    private BluetoothAdapter mAdapter;
 
     protected int mMostRecentState = BluetoothProfile.STATE_DISCONNECTED;
     protected BluetoothAudioConfig mAudioConfig = null;
@@ -71,12 +75,19 @@
         mConnecting = new Connecting();
         mConnected = new Connected();
         mDisconnecting = new Disconnecting();
+        mAdapter = BluetoothAdapter.getDefaultAdapter();
 
         addState(mDisconnected);
         addState(mConnecting);
         addState(mConnected);
         addState(mDisconnecting);
 
+        if (mAdapter != null) {
+            String bdAddr = mAdapter.getAddress();
+            AudioSystem.setParameters(BT_ADDR_KEY + "=" + bdAddr);
+            Log.e(TAG, "AudioSystem.setParameters, Key: " + BT_ADDR_KEY + " Value: " + bdAddr);
+        }
+
         setInitialState(mDisconnected);
     }