diff options
| author | 2018-01-21 00:33:40 +0000 | |
|---|---|---|
| committer | 2018-01-21 00:33:40 +0000 | |
| commit | 65ff8a65b63881e421fa451c11b1aab80ba18dc5 (patch) | |
| tree | 9fbfe50d3bb8d9e751d50d7b1a289ceb7cf4310d | |
| parent | ccc31988eece3a828c478a38c3d2da03d0924968 (diff) | |
| parent | 5bd12d0bf47b1f3f8b2dc74cc02ab46447f55706 (diff) | |
Merge "Multi-A2DP support - add a new internal API to suppress Audio Noisy intent" am: 7e3b1832c4
am: 5bd12d0bf4
Change-Id: I52b1adc5ce9f3dea56b0045581d7736cbe62de73
| -rw-r--r-- | media/java/android/media/AudioManager.java | 27 | ||||
| -rw-r--r-- | media/java/android/media/IAudioService.aidl | 3 | ||||
| -rw-r--r-- | services/core/java/com/android/server/audio/AudioService.java | 16 |
3 files changed, 42 insertions, 4 deletions
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index 3df17068725e..339c7678bef8 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -3629,6 +3629,33 @@ public class AudioManager { } /** + * 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. * @param device Bluetooth device whose configuration has changed. * {@hide} diff --git a/media/java/android/media/IAudioService.aidl b/media/java/android/media/IAudioService.aidl index bb6ae9863d31..6c6522328e8d 100644 --- a/media/java/android/media/IAudioService.aidl +++ b/media/java/android/media/IAudioService.aidl @@ -203,5 +203,8 @@ interface IAudioService { 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 } diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 5eb2a8d2066f..f54b243038f2 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -4103,22 +4103,30 @@ public class AudioService extends IAudioService.Stub 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)) { return 0; } return setBluetoothA2dpDeviceConnectionStateInt( - device, state, profile, AudioSystem.DEVICE_NONE); + device, state, profile, suppressNoisyIntent, AudioSystem.DEVICE_NONE); } public int setBluetoothA2dpDeviceConnectionStateInt( - BluetoothDevice device, int state, int profile, int musicDevice) + BluetoothDevice device, int state, int profile, boolean suppressNoisyIntent, + int musicDevice) { int delay; if (profile != BluetoothProfile.A2DP && profile != BluetoothProfile.A2DP_SINK) { throw new IllegalArgumentException("invalid profile " + profile); } synchronized (mConnectedDevices) { - if (profile == BluetoothProfile.A2DP) { + if (profile == BluetoothProfile.A2DP && !suppressNoisyIntent) { int intState = (state == BluetoothA2dp.STATE_CONNECTED) ? 1 : 0; delay = checkSendBecomingNoisyIntent(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, intState, musicDevice); @@ -5368,7 +5376,7 @@ public class AudioService extends IAudioService.Stub // consistent with audio policy manager state setBluetoothA2dpDeviceConnectionStateInt( btDevice, BluetoothA2dp.STATE_DISCONNECTED, BluetoothProfile.A2DP, - musicDevice); + false /* suppressNoisyIntent */, musicDevice); } } } |