Merge "Multi-A2DP support - add a new internal API to suppress Audio Noisy intent"
am: 7e3b1832c4
Change-Id: I4b75e8565dc0b80d6ca3825e87370a72c726bd25
This commit is contained in:
@@ -3628,6 +3628,33 @@ public class AudioManager {
|
|||||||
return delay;
|
return delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate A2DP source or sink connection state change and eventually suppress
|
||||||
|
* the {@link AudioManager.ACTION_AUDIO_BECOMING_NOISY} intent.
|
||||||
|
* @param device Bluetooth device connected/disconnected
|
||||||
|
* @param state new connection state (BluetoothProfile.STATE_xxx)
|
||||||
|
* @param profile profile for the A2DP device
|
||||||
|
* (either {@link android.bluetooth.BluetoothProfile.A2DP} or
|
||||||
|
* {@link android.bluetooth.BluetoothProfile.A2DP_SINK})
|
||||||
|
* @param suppressNoisyIntent if true the
|
||||||
|
* {@link AudioManager.ACTION_AUDIO_BECOMING_NOISY} intent will not be sent.
|
||||||
|
* @return a delay in ms that the caller should wait before broadcasting
|
||||||
|
* BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED intent.
|
||||||
|
* {@hide}
|
||||||
|
*/
|
||||||
|
public int setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(
|
||||||
|
BluetoothDevice device, int state, int profile, boolean suppressNoisyIntent) {
|
||||||
|
final IAudioService service = getService();
|
||||||
|
int delay = 0;
|
||||||
|
try {
|
||||||
|
delay = service.setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(device,
|
||||||
|
state, profile, suppressNoisyIntent);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw e.rethrowFromSystemServer();
|
||||||
|
}
|
||||||
|
return delay;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicate A2DP device configuration has changed.
|
* Indicate A2DP device configuration has changed.
|
||||||
* @param device Bluetooth device whose configuration has changed.
|
* @param device Bluetooth device whose configuration has changed.
|
||||||
|
|||||||
@@ -203,5 +203,8 @@ interface IAudioService {
|
|||||||
|
|
||||||
oneway void playerHasOpPlayAudio(in int piid, in boolean hasOpPlayAudio);
|
oneway void playerHasOpPlayAudio(in int piid, in boolean hasOpPlayAudio);
|
||||||
|
|
||||||
|
int setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(in BluetoothDevice device,
|
||||||
|
int state, int profile, boolean suppressNoisyIntent);
|
||||||
|
|
||||||
// WARNING: read warning at top of file, it is recommended to add new methods at the end
|
// WARNING: read warning at top of file, it is recommended to add new methods at the end
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4102,23 +4102,31 @@ public class AudioService extends IAudioService.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int setBluetoothA2dpDeviceConnectionState(BluetoothDevice device, int state, int profile)
|
public int setBluetoothA2dpDeviceConnectionState(BluetoothDevice device, int state, int profile)
|
||||||
|
{
|
||||||
|
return setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(
|
||||||
|
device, state, profile, false /* suppressNoisyIntent */);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(BluetoothDevice device,
|
||||||
|
int state, int profile, boolean suppressNoisyIntent)
|
||||||
{
|
{
|
||||||
if (mAudioHandler.hasMessages(MSG_SET_A2DP_SINK_CONNECTION_STATE, device)) {
|
if (mAudioHandler.hasMessages(MSG_SET_A2DP_SINK_CONNECTION_STATE, device)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return setBluetoothA2dpDeviceConnectionStateInt(
|
return setBluetoothA2dpDeviceConnectionStateInt(
|
||||||
device, state, profile, AudioSystem.DEVICE_NONE);
|
device, state, profile, suppressNoisyIntent, AudioSystem.DEVICE_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int setBluetoothA2dpDeviceConnectionStateInt(
|
public int setBluetoothA2dpDeviceConnectionStateInt(
|
||||||
BluetoothDevice device, int state, int profile, int musicDevice)
|
BluetoothDevice device, int state, int profile, boolean suppressNoisyIntent,
|
||||||
|
int musicDevice)
|
||||||
{
|
{
|
||||||
int delay;
|
int delay;
|
||||||
if (profile != BluetoothProfile.A2DP && profile != BluetoothProfile.A2DP_SINK) {
|
if (profile != BluetoothProfile.A2DP && profile != BluetoothProfile.A2DP_SINK) {
|
||||||
throw new IllegalArgumentException("invalid profile " + profile);
|
throw new IllegalArgumentException("invalid profile " + profile);
|
||||||
}
|
}
|
||||||
synchronized (mConnectedDevices) {
|
synchronized (mConnectedDevices) {
|
||||||
if (profile == BluetoothProfile.A2DP) {
|
if (profile == BluetoothProfile.A2DP && !suppressNoisyIntent) {
|
||||||
int intState = (state == BluetoothA2dp.STATE_CONNECTED) ? 1 : 0;
|
int intState = (state == BluetoothA2dp.STATE_CONNECTED) ? 1 : 0;
|
||||||
delay = checkSendBecomingNoisyIntent(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,
|
delay = checkSendBecomingNoisyIntent(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,
|
||||||
intState, musicDevice);
|
intState, musicDevice);
|
||||||
@@ -5368,7 +5376,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
// consistent with audio policy manager state
|
// consistent with audio policy manager state
|
||||||
setBluetoothA2dpDeviceConnectionStateInt(
|
setBluetoothA2dpDeviceConnectionStateInt(
|
||||||
btDevice, BluetoothA2dp.STATE_DISCONNECTED, BluetoothProfile.A2DP,
|
btDevice, BluetoothA2dp.STATE_DISCONNECTED, BluetoothProfile.A2DP,
|
||||||
musicDevice);
|
false /* suppressNoisyIntent */, musicDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user