diff --git a/api/system-current.txt b/api/system-current.txt index d18c0dcb5ab31..9cf58413c3ba9 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -1350,6 +1350,14 @@ package android.bluetooth { field public static final int OPTIONAL_CODECS_SUPPORT_UNKNOWN = -1; // 0xffffffff } + public final class BluetoothA2dpSink implements android.bluetooth.BluetoothProfile { + method public void finalize(); + method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public int getConnectionPolicy(@Nullable android.bluetooth.BluetoothDevice); + method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean isAudioPlaying(@Nullable android.bluetooth.BluetoothDevice); + method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean setConnectionPolicy(@Nullable android.bluetooth.BluetoothDevice, int); + field @RequiresPermission(android.Manifest.permission.BLUETOOTH) public static final String ACTION_CONNECTION_STATE_CHANGED = "android.bluetooth.a2dp-sink.profile.action.CONNECTION_STATE_CHANGED"; + } + public final class BluetoothAdapter { method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean addOnMetadataChangedListener(@NonNull android.bluetooth.BluetoothDevice, @NonNull java.util.concurrent.Executor, @NonNull android.bluetooth.BluetoothAdapter.OnMetadataChangedListener); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean connectAllEnabledProfiles(@NonNull android.bluetooth.BluetoothDevice); diff --git a/core/java/android/bluetooth/BluetoothA2dpSink.java b/core/java/android/bluetooth/BluetoothA2dpSink.java index cf3367602aa99..c6957e14116bd 100755 --- a/core/java/android/bluetooth/BluetoothA2dpSink.java +++ b/core/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}. * - *
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. - * - *
This intent will have 3 extras: - *
{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of - * {@link #STATE_PLAYING}, {@link #STATE_NOT_PLAYING}, - * - *
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. - * - *
This intent will have 3 extras: - *
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 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.
*
- * 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 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 "