Merge bd5eb264d2452f8c19555aab772278275a5de306 on remote branch
Change-Id: Ic5ccc95e4b1175da9a6f946736ebd1c962ac7e46
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);
}
diff --git a/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachine.java b/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachine.java
index ec85592..e0317f6 100644
--- a/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachine.java
+++ b/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachine.java
@@ -117,6 +117,7 @@
boolean mRemoteControlConnected = false;
boolean mBrowsingConnected = false;
final BrowseTree mBrowseTree;
+ private boolean smActive = false;
private AvrcpPlayer mAddressedPlayer = new AvrcpPlayer();
private RemoteDevice mRemoteDevice;
private int mPreviousPercentageVol = -1;
@@ -151,6 +152,7 @@
addState(mConnected);
addState(mDisconnecting);
+ smActive = true;
mGetFolderList = new GetFolderList();
addState(mGetFolderList, mConnected);
@@ -228,7 +230,7 @@
}
synchronized void onBrowsingConnected() {
- if (mBrowsingConnected) return;
+ if (mBrowsingConnected || (!smActive)) return;
mService.sBrowseTree.mRootNode.addChild(mBrowseTree.mRootNode);
BluetoothMediaBrowserService.notifyChanged(mService
.sBrowseTree.mRootNode);
@@ -237,7 +239,7 @@
}
synchronized void onBrowsingDisconnected() {
- if (!mBrowsingConnected) return;
+ if (!mBrowsingConnected || (!smActive)) return;
mAddressedPlayer.setPlayStatus(PlaybackState.STATE_ERROR);
mAddressedPlayer.updateCurrentTrack(null);
if (mBrowseTree != null && mBrowseTree.mNowPlayingNode != null) {
@@ -799,6 +801,9 @@
// If the receiver was never registered unregister will throw an
// IllegalArgumentException.
}
+ synchronized(AvrcpControllerStateMachine.this) {
+ smActive = false;
+ }
// we should disacrd, all currently queuedup messages.
quitNow();
}
diff --git a/src/com/android/bluetooth/hfp/HeadsetA2dpSync.java b/src/com/android/bluetooth/hfp/HeadsetA2dpSync.java
index 8adbdf2..d21d8b6 100644
--- a/src/com/android/bluetooth/hfp/HeadsetA2dpSync.java
+++ b/src/com/android/bluetooth/hfp/HeadsetA2dpSync.java
@@ -38,6 +38,8 @@
import android.util.Log;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
+import com.android.bluetooth.hearingaid.HearingAidService;
+import java.util.List;
/**
* Defines methods used for synchronization between HFP and A2DP
@@ -113,6 +115,17 @@
*/
public boolean suspendA2DP(int reason, BluetoothDevice device){
int a2dpState = isA2dpPlaying();
+
+ List<BluetoothDevice> HAActiveDevices = null;
+ HearingAidService mHaService = HearingAidService.getHearingAidService();
+ if (mHaService != null) {
+ HAActiveDevices = mHaService.getActiveDevices();
+ }
+ if (HAActiveDevices != null) {
+ Log.d(TAG,"Ignore suspendA2DP if active device is HearingAid");
+ return false;
+ }
+
Log.d(TAG," suspendA2DP currPlayingState = "+ a2dpState + " for reason " + reason
+ "mA2dpSuspendTriggered = " + mA2dpSuspendTriggered + " for device " + device);
if (mA2dpSuspendTriggered != A2DP_SUSPENDED_NOT_TRIGGERED) {
diff --git a/src/com/android/bluetooth/map/BluetoothMapMasInstance.java b/src/com/android/bluetooth/map/BluetoothMapMasInstance.java
index e4270b1..8e0b2d3 100644
--- a/src/com/android/bluetooth/map/BluetoothMapMasInstance.java
+++ b/src/com/android/bluetooth/map/BluetoothMapMasInstance.java
@@ -477,16 +477,17 @@
}
}
- public void setRemoteFeatureMask(int supportedFeatures, int remoteProfileVersion) {
- Log.d(mTag, "setRemoteFeatureMask supportedFeatures : "
+ public void setRemoteFeatureMask(int supportedFeatures, int remoteProfileVersion,
+ BluetoothDevice rd) {
+ if (D) Log.d(mTag, "setRemoteFeatureMask supportedFeatures "
+ Integer.toHexString(supportedFeatures) +", remoteProfileVersion: "
+ Integer.toHexString(remoteProfileVersion));
mPeerProfileVersion = remoteProfileVersion;
if (Utils.isPtsTestMode()) {
mRemoteFeatureMask =
SDP_MAP_MAS_FEATURES_ADV;
- } else if ((remoteProfileVersion > SDP_MAP_MAS_VERSION)
- && (!BluetoothMapFixes.isMapAdvDisabled())){
+ } else if ((remoteProfileVersion > SDP_MAP_MAS_VERSION_ADV)
+ && (!BluetoothMapFixes.isMapAdvDisabled() && BluetoothMapFixes.isRebonded(rd))){
mRemoteFeatureMask =
supportedFeatures & SDP_MAP_MAS_FEATURES_ADV;
} else {
diff --git a/src/com/android/bluetooth/map/BluetoothMapService.java b/src/com/android/bluetooth/map/BluetoothMapService.java
index 076916f..5c81376 100644
--- a/src/com/android/bluetooth/map/BluetoothMapService.java
+++ b/src/com/android/bluetooth/map/BluetoothMapService.java
@@ -1100,12 +1100,12 @@
mBluetoothMnsObexClient.setMnsRecord(mMnsRecord);
}
if (status != -1 && mMnsRecord != null) {
+ BluetoothMapFixes.showNotification(BluetoothMapService.this, remoteDevice);
for (int i = 0, c = mMasInstances.size(); i < c; i++) {
mMasInstances.valueAt(i)
.setRemoteFeatureMask(mMnsRecord.getSupportedFeatures(),
- mMnsRecord.getProfileVersion());
+ mMnsRecord.getProfileVersion(), remoteDevice);
}
- BluetoothMapFixes.showNotification(BluetoothMapService.this, remoteDevice);
}
if (mSdpSearchInitiated) {
mSdpSearchInitiated = false; // done searching