am 429a8eac: Merge change I59214d5d into eclair-mr2
Merge commit '429a8eaccc133b2ebf610cccf26c4ad323a18ef3' into eclair-mr2-plus-aosp * commit '429a8eaccc133b2ebf610cccf26c4ad323a18ef3': Add a new priority for Auto Connection of A2DP.
This commit is contained in:
@@ -42,7 +42,7 @@ import java.util.HashSet;
|
||||
*
|
||||
* Currently the BluetoothA2dp service runs in the system server and this
|
||||
* proxy object will be immediately bound to the service on construction.
|
||||
*
|
||||
*
|
||||
* Currently this class provides methods to connect to A2DP audio sinks.
|
||||
*
|
||||
* @hide
|
||||
@@ -74,9 +74,12 @@ public final class BluetoothA2dp {
|
||||
/** Playing implies connected */
|
||||
public static final int STATE_PLAYING = 4;
|
||||
|
||||
/** Default priority for a2dp devices that we try to auto-connect
|
||||
* and allow incoming connections */
|
||||
public static final int PRIORITY_AUTO_CONNECT = 1000;
|
||||
/** Default priority for a2dp devices that should allow incoming
|
||||
* connections */
|
||||
public static final int PRIORITY_AUTO = 100;
|
||||
public static final int PRIORITY_ON = 100;
|
||||
/** Default priority for a2dp devices that should not allow incoming
|
||||
* connections */
|
||||
public static final int PRIORITY_OFF = 0;
|
||||
|
||||
@@ -96,7 +96,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
|
||||
BluetoothDevice.ERROR);
|
||||
switch(bondState) {
|
||||
case BluetoothDevice.BOND_BONDED:
|
||||
setSinkPriority(device, BluetoothA2dp.PRIORITY_AUTO);
|
||||
setSinkPriority(device, BluetoothA2dp.PRIORITY_ON);
|
||||
break;
|
||||
case BluetoothDevice.BOND_BONDING:
|
||||
case BluetoothDevice.BOND_NONE:
|
||||
@@ -104,7 +104,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
|
||||
break;
|
||||
}
|
||||
} else if (action.equals(BluetoothDevice.ACTION_ACL_CONNECTED)) {
|
||||
if (getSinkPriority(device) > BluetoothA2dp.PRIORITY_OFF &&
|
||||
if (getSinkPriority(device) == BluetoothA2dp.PRIORITY_AUTO_CONNECT &&
|
||||
isSinkDevice(device)) {
|
||||
// This device is a preferred sink. Make an A2DP connection
|
||||
// after a delay. We delay to avoid connection collisions,
|
||||
@@ -171,7 +171,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
|
||||
// check bluetooth is still on, device is still preferred, and
|
||||
// nothing is currently connected
|
||||
if (mBluetoothService.isEnabled() &&
|
||||
getSinkPriority(device) > BluetoothA2dp.PRIORITY_OFF &&
|
||||
getSinkPriority(device) == BluetoothA2dp.PRIORITY_AUTO_CONNECT &&
|
||||
lookupSinksMatchingStates(new int[] {
|
||||
BluetoothA2dp.STATE_CONNECTING,
|
||||
BluetoothA2dp.STATE_CONNECTED,
|
||||
@@ -328,6 +328,9 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Sink is being disconnected, downgrade priority from AUTO_CONNECT.
|
||||
setSinkPriority(device, BluetoothA2dp.PRIORITY_ON);
|
||||
|
||||
// State is CONNECTING or CONNECTED or PLAYING
|
||||
if (!disconnectSinkNative(path)) {
|
||||
return false;
|
||||
@@ -450,6 +453,14 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
|
||||
if (state == BluetoothA2dp.STATE_CONNECTING) {
|
||||
mAudioManager.setParameters("A2dpSuspended=false");
|
||||
}
|
||||
|
||||
if (state == BluetoothA2dp.STATE_CONNECTING ||
|
||||
state == BluetoothA2dp.STATE_CONNECTED) {
|
||||
// We have connected or attempting to connect.
|
||||
// Bump priority
|
||||
setSinkPriority(device, BluetoothA2dp.PRIORITY_AUTO_CONNECT);
|
||||
}
|
||||
|
||||
Intent intent = new Intent(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
|
||||
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
|
||||
intent.putExtra(BluetoothA2dp.EXTRA_PREVIOUS_SINK_STATE, prevState);
|
||||
|
||||
Reference in New Issue
Block a user