summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGubbala Venugopal Rao <vgubba@codeaurora.org>2014-01-28 19:10:54 +0530
committerGaurav Asati <gasati@codeaurora.org>2014-03-11 17:41:09 +0530
commitddee5f0eb419e22208782c3467e7365f537562d2 (patch)
treed4f67e668995deefd69944c50078587edde39916 /src
parent936fb9c86140291d93367e18dbaaf6a9b5f88904 (diff)
downloadandroid_packages_apps_Bluetooth-ddee5f0eb419e22208782c3467e7365f537562d2.tar.gz
android_packages_apps_Bluetooth-ddee5f0eb419e22208782c3467e7365f537562d2.tar.bz2
android_packages_apps_Bluetooth-ddee5f0eb419e22208782c3467e7365f537562d2.zip
Bluetooth: Check for last connected A2dp Sep type
Changes made to check last connected A2dp Sep type before sending conection Request as A2dp SRC. CRs-fixed: 599358 Change-Id: Ibb8aad022520f73a6f041cb8ab06bd535f0ef516
Diffstat (limited to 'src')
-rw-r--r--src/com/android/bluetooth/a2dp/A2dpService.java22
-rw-r--r--src/com/android/bluetooth/a2dp/A2dpStateMachine.java8
-rw-r--r--src/com/android/bluetooth/btservice/AdapterService.java1
3 files changed, 31 insertions, 0 deletions
diff --git a/src/com/android/bluetooth/a2dp/A2dpService.java b/src/com/android/bluetooth/a2dp/A2dpService.java
index 902b6849c..22c6081b9 100644
--- a/src/com/android/bluetooth/a2dp/A2dpService.java
+++ b/src/com/android/bluetooth/a2dp/A2dpService.java
@@ -201,6 +201,28 @@ public class A2dpService extends ProfileService {
return priority;
}
+ public boolean setLastConnectedA2dpSepType(BluetoothDevice device, int sepType) {
+ enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
+ "Need BLUETOOTH_ADMIN permission");
+
+ Log.d(TAG,"setLastConnectedA2dpSepType: " + sepType);
+
+ Settings.Global.putInt(getContentResolver(),
+ Settings.Global.getBluetoothLastConnectedA2dpSepTypeKey(device.getAddress()),
+ sepType);
+ return true;
+ }
+
+ public int getLastConnectedA2dpSepType(BluetoothDevice device) {
+ enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
+ "Need BLUETOOTH_ADMIN permission");
+ int sepType = Settings.Global.getInt(getContentResolver(),
+ Settings.Global.getBluetoothLastConnectedA2dpSepTypeKey(device.getAddress()),
+ BluetoothProfile.PROFILE_A2DP_UNDEFINED);
+ return sepType;
+ }
+
+
/* Absolute volume implementation */
public boolean isAvrcpAbsoluteVolumeSupported() {
return mAvrcp.isAbsoluteVolumeSupported();
diff --git a/src/com/android/bluetooth/a2dp/A2dpStateMachine.java b/src/com/android/bluetooth/a2dp/A2dpStateMachine.java
index 642a0a228..6bb9441d7 100644
--- a/src/com/android/bluetooth/a2dp/A2dpStateMachine.java
+++ b/src/com/android/bluetooth/a2dp/A2dpStateMachine.java
@@ -773,10 +773,18 @@ final class A2dpStateMachine extends StateMachine {
if (!isSrcNative(getByteAddress(device))) {
delay = mAudioManager.setBluetoothA2dpDeviceConnectionState(device, newState);
log("Peer Device is SNK");
+ if (newState == BluetoothProfile.STATE_CONNECTED) {
+ mService.setLastConnectedA2dpSepType (device,
+ BluetoothProfile.PROFILE_A2DP_SNK);
+ }
}
else {
delay = 0;
log("Peer Device is SRC");
+ if (newState == BluetoothProfile.STATE_CONNECTED) {
+ mService.setLastConnectedA2dpSepType (device,
+ BluetoothProfile.PROFILE_A2DP_SRC);
+ }
}
mWakeLock.acquire();
mIntentBroadcastHandler.sendMessageDelayed(mIntentBroadcastHandler.obtainMessage(
diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java
index 88066c5e8..a62a20729 100644
--- a/src/com/android/bluetooth/btservice/AdapterService.java
+++ b/src/com/android/bluetooth/btservice/AdapterService.java
@@ -1279,6 +1279,7 @@ public class AdapterService extends Service {
}
else if((a2dpConnDevList.isEmpty()) &&
(a2dpService.getPriority(device) >= BluetoothProfile.PRIORITY_ON) &&
+ (a2dpService.getLastConnectedA2dpSepType(device) == BluetoothProfile.PROFILE_A2DP_SNK)&&
(hsConnected || (hsService.getPriority(device) == BluetoothProfile.PRIORITY_OFF))) {
a2dpService.connect(device);
}