summaryrefslogtreecommitdiffstats
path: root/core/java/android/server/BluetoothA2dpService.java
diff options
context:
space:
mode:
authorJaikumar Ganesh <jaikumar@google.com>2010-10-12 15:15:55 -0700
committerJaikumar Ganesh <jaikumar@google.com>2010-10-12 16:42:45 -0700
commitbcf5cf47ed03f1a685fd1de8ed9dc4a6abf7b1e3 (patch)
tree85d2e108c4607feae69f792ce02ac81c7ca1ecbc /core/java/android/server/BluetoothA2dpService.java
parent844a6b3ccaff1ad1443ad985e4527b733ce97c0e (diff)
downloadframeworks_base-bcf5cf47ed03f1a685fd1de8ed9dc4a6abf7b1e3.zip
frameworks_base-bcf5cf47ed03f1a685fd1de8ed9dc4a6abf7b1e3.tar.gz
frameworks_base-bcf5cf47ed03f1a685fd1de8ed9dc4a6abf7b1e3.tar.bz2
Fix auto connection priority handling.
Bug: 3027023 1. user is connected to a headset. Headset is turned off. 2. User connects to another device. The priority of the first headset must be set to ON. We only have 1 device set at AUTO_CONNECT priority. 1. A remote headset sends an incoming connection. Don't set AUTO_CONNECT till its gets connected. 2. For outgoing connections, set it to AUTO_CONNECT in Connecting state since the user initated this connection. Change-Id: Iaa211bf22b1fd99850875f7eda686c47142173ba
Diffstat (limited to 'core/java/android/server/BluetoothA2dpService.java')
-rw-r--r--core/java/android/server/BluetoothA2dpService.java21
1 files changed, 8 insertions, 13 deletions
diff --git a/core/java/android/server/BluetoothA2dpService.java b/core/java/android/server/BluetoothA2dpService.java
index a52a221..5cbfe74 100644
--- a/core/java/android/server/BluetoothA2dpService.java
+++ b/core/java/android/server/BluetoothA2dpService.java
@@ -71,7 +71,6 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
private final BluetoothService mBluetoothService;
private final BluetoothAdapter mAdapter;
private int mTargetA2dpState;
- private boolean mAdjustedPriority = false;
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
@@ -326,7 +325,10 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
String path = mBluetoothService.getObjectPathFromAddress(device.getAddress());
- // State is DISCONNECTED
+ // State is DISCONNECTED and we are connecting.
+ if (getSinkPriority(device) < BluetoothA2dp.PRIORITY_AUTO_CONNECT) {
+ setSinkPriority(device, BluetoothA2dp.PRIORITY_AUTO_CONNECT);
+ }
handleSinkStateChange(device, state, BluetoothA2dp.STATE_CONNECTING);
if (!connectSinkNative(path)) {
@@ -491,14 +493,10 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
mTargetA2dpState = -1;
if (getSinkPriority(device) > BluetoothA2dp.PRIORITY_OFF &&
- state == BluetoothA2dp.STATE_CONNECTING ||
state == BluetoothA2dp.STATE_CONNECTED) {
// We have connected or attempting to connect.
// Bump priority
setSinkPriority(device, BluetoothA2dp.PRIORITY_AUTO_CONNECT);
- }
-
- if (state == BluetoothA2dp.STATE_CONNECTED) {
// We will only have 1 device with AUTO_CONNECT priority
// To be backward compatible set everyone else to have PRIORITY_ON
adjustOtherSinkPriorities(device);
@@ -515,14 +513,11 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
}
private void adjustOtherSinkPriorities(BluetoothDevice connectedDevice) {
- if (!mAdjustedPriority) {
- for (BluetoothDevice device : mAdapter.getBondedDevices()) {
- if (getSinkPriority(device) >= BluetoothA2dp.PRIORITY_AUTO_CONNECT &&
- !device.equals(connectedDevice)) {
- setSinkPriority(device, BluetoothA2dp.PRIORITY_ON);
- }
+ for (BluetoothDevice device : mAdapter.getBondedDevices()) {
+ if (getSinkPriority(device) >= BluetoothA2dp.PRIORITY_AUTO_CONNECT &&
+ !device.equals(connectedDevice)) {
+ setSinkPriority(device, BluetoothA2dp.PRIORITY_ON);
}
- mAdjustedPriority = true;
}
}