diff options
author | Rahul Sabnis <rahulsabnis@google.com> | 2019-12-12 13:29:19 -0800 |
---|---|---|
committer | Rahul Sabnis <rahulsabnis@google.com> | 2019-12-13 14:52:55 -0800 |
commit | 64c9d2eae343ec9dbdb4ac02a1af9e6126bc5ac3 (patch) | |
tree | 3b8d5e673916fb3e5bfcb73521b2bcedeab969be /framework/java/android/bluetooth/BluetoothA2dpSink.java | |
parent | 24dd49bbb2e10a7b7765f3b0c1730bc795f576bc (diff) |
Resolve BluetoothA2dpSink APIs used by Settings
Bug: 146082017
Test: Manual
Change-Id: Iebae62408c490cb9091b1f4e4a5a5e32321e2700
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothA2dpSink.java')
-rwxr-xr-x | framework/java/android/bluetooth/BluetoothA2dpSink.java | 103 |
1 files changed, 28 insertions, 75 deletions
diff --git a/framework/java/android/bluetooth/BluetoothA2dpSink.java b/framework/java/android/bluetooth/BluetoothA2dpSink.java index cf3367602a..c6957e1411 100755 --- a/framework/java/android/bluetooth/BluetoothA2dpSink.java +++ b/framework/java/android/bluetooth/BluetoothA2dpSink.java @@ -17,7 +17,9 @@ package android.bluetooth; import android.Manifest; +import android.annotation.Nullable; import android.annotation.RequiresPermission; +import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.annotation.UnsupportedAppUsage; import android.content.Context; @@ -39,6 +41,7 @@ import java.util.List; * * @hide */ +@SystemApi public final class BluetoothA2dpSink implements BluetoothProfile { private static final String TAG = "BluetoothA2dpSink"; private static final boolean DBG = true; @@ -59,71 +62,14 @@ public final class BluetoothA2dpSink implements BluetoothProfile { * {@link #STATE_DISCONNECTED}, {@link #STATE_CONNECTING}, * {@link #STATE_CONNECTED}, {@link #STATE_DISCONNECTING}. * - * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to - * receive. + * @hide */ + @SystemApi + @SuppressLint("ActionValue") + @RequiresPermission(Manifest.permission.BLUETOOTH) public static final String ACTION_CONNECTION_STATE_CHANGED = "android.bluetooth.a2dp-sink.profile.action.CONNECTION_STATE_CHANGED"; - /** - * Intent used to broadcast the change in the Playing state of the A2DP Sink - * profile. - * - * <p>This intent will have 3 extras: - * <ul> - * <li> {@link #EXTRA_STATE} - The current state of the profile. </li> - * <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile. </li> - * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li> - * </ul> - * - * <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of - * {@link #STATE_PLAYING}, {@link #STATE_NOT_PLAYING}, - * - * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to - * receive. - */ - public static final String ACTION_PLAYING_STATE_CHANGED = - "android.bluetooth.a2dp-sink.profile.action.PLAYING_STATE_CHANGED"; - - /** - * A2DP sink device is streaming music. This state can be one of - * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of - * {@link #ACTION_PLAYING_STATE_CHANGED} intent. - */ - public static final int STATE_PLAYING = 10; - - /** - * A2DP sink device is NOT streaming music. This state can be one of - * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of - * {@link #ACTION_PLAYING_STATE_CHANGED} intent. - */ - public static final int STATE_NOT_PLAYING = 11; - - /** - * Intent used to broadcast the change in the Playing state of the A2DP Sink - * profile. - * - * <p>This intent will have 3 extras: - * <ul> - * <li> {@link #EXTRA_AUDIO_CONFIG} - The audio configuration for the remote device. </li> - * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li> - * </ul> - * - * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to - * receive. - */ - public static final String ACTION_AUDIO_CONFIG_CHANGED = - "android.bluetooth.a2dp-sink.profile.action.AUDIO_CONFIG_CHANGED"; - - /** - * Extra for the {@link #ACTION_AUDIO_CONFIG_CHANGED} intent. - * - * This extra represents the current audio configuration of the A2DP source device. - * {@see BluetoothAudioConfig} - */ - public static final String EXTRA_AUDIO_CONFIG = - "android.bluetooth.a2dp-sink.profile.extra.AUDIO_CONFIG"; - private BluetoothAdapter mAdapter; private final BluetoothProfileConnector<IBluetoothA2dpSink> mProfileConnector = new BluetoothProfileConnector(this, BluetoothProfile.A2DP_SINK, @@ -170,13 +116,11 @@ public final class BluetoothA2dpSink implements BluetoothProfile { * the state. Users can get the connection state of the profile * from this intent. * - * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} - * permission. - * * @param device Remote Bluetooth Device * @return false on immediate error, true otherwise * @hide */ + @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN) public boolean connect(BluetoothDevice device) { if (DBG) log("connect(" + device + ")"); final IBluetoothA2dpSink service = getService(); @@ -210,14 +154,12 @@ public final class BluetoothA2dpSink implements BluetoothProfile { * {@link #STATE_DISCONNECTING} can be used to distinguish between the * two scenarios. * - * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} - * permission. - * * @param device Remote Bluetooth Device * @return false on immediate error, true otherwise * @hide */ @UnsupportedAppUsage + @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN) public boolean disconnect(BluetoothDevice device) { if (DBG) log("disconnect(" + device + ")"); final IBluetoothA2dpSink service = getService(); @@ -235,6 +177,8 @@ public final class BluetoothA2dpSink implements BluetoothProfile { /** * {@inheritDoc} + * + * @hide */ @Override public List<BluetoothDevice> getConnectedDevices() { @@ -254,6 +198,8 @@ public final class BluetoothA2dpSink implements BluetoothProfile { /** * {@inheritDoc} + * + * @hide */ @Override public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { @@ -273,6 +219,8 @@ public final class BluetoothA2dpSink implements BluetoothProfile { /** * {@inheritDoc} + * + * @hide */ @Override public int getConnectionState(BluetoothDevice device) { @@ -300,6 +248,8 @@ public final class BluetoothA2dpSink implements BluetoothProfile { * @return audio configuration for the device, or null * * {@see BluetoothAudioConfig} + * + * @hide */ public BluetoothAudioConfig getAudioConfig(BluetoothDevice device) { if (VDBG) log("getAudioConfig(" + device + ")"); @@ -347,7 +297,7 @@ public final class BluetoothA2dpSink implements BluetoothProfile { */ @SystemApi @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN) - public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) { + public boolean setConnectionPolicy(@Nullable BluetoothDevice device, int connectionPolicy) { if (DBG) log("setConnectionPolicy(" + device + ", " + connectionPolicy + ")"); final IBluetoothA2dpSink service = getService(); if (service != null && isEnabled() && isValidDevice(device)) { @@ -395,7 +345,7 @@ public final class BluetoothA2dpSink implements BluetoothProfile { */ @SystemApi @RequiresPermission(Manifest.permission.BLUETOOTH) - public int getConnectionPolicy(BluetoothDevice device) { + public int getConnectionPolicy(@Nullable BluetoothDevice device) { if (VDBG) log("getConnectionPolicy(" + device + ")"); final IBluetoothA2dpSink service = getService(); if (service != null && isEnabled() && isValidDevice(device)) { @@ -411,13 +361,16 @@ public final class BluetoothA2dpSink implements BluetoothProfile { } /** - * Check if A2DP profile is streaming music. - * - * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission. + * Check if audio is playing on the bluetooth device (A2DP profile is streaming music). * * @param device BluetoothDevice device + * @return true if audio is playing (A2dp is streaming music), false otherwise + * + * @hide */ - public boolean isA2dpPlaying(BluetoothDevice device) { + @SystemApi + @RequiresPermission(Manifest.permission.BLUETOOTH) + public boolean isAudioPlaying(@Nullable BluetoothDevice device) { final IBluetoothA2dpSink service = getService(); if (service != null && isEnabled() && isValidDevice(device)) { try { @@ -448,9 +401,9 @@ public final class BluetoothA2dpSink implements BluetoothProfile { return "connected"; case STATE_DISCONNECTING: return "disconnecting"; - case STATE_PLAYING: + case BluetoothA2dp.STATE_PLAYING: return "playing"; - case STATE_NOT_PLAYING: + case BluetoothA2dp.STATE_NOT_PLAYING: return "not playing"; default: return "<unknown state " + state + ">"; |