Resolve BluetoothA2dp hidden APIs to resolve dependencies
Bug: 143240341
Test: Manual
Change-Id: Ib55e0fb106fa7b91ef4d3559da12ea2c048f1ae5
diff --git a/api/system-current.txt b/api/system-current.txt
index c459412..d87a9b0 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -1251,8 +1251,22 @@
package android.bluetooth {
public final class BluetoothA2dp implements android.bluetooth.BluetoothProfile {
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public void disableOptionalCodecs(@Nullable android.bluetooth.BluetoothDevice);
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public void enableOptionalCodecs(@Nullable android.bluetooth.BluetoothDevice);
+ method @Nullable @RequiresPermission(android.Manifest.permission.BLUETOOTH) public android.bluetooth.BluetoothDevice getActiveDevice();
+ method @Nullable @RequiresPermission(android.Manifest.permission.BLUETOOTH) public android.bluetooth.BluetoothCodecStatus getCodecStatus(@Nullable android.bluetooth.BluetoothDevice);
method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public int getConnectionPolicy(@NonNull android.bluetooth.BluetoothDevice);
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public int getOptionalCodecsEnabled(@Nullable android.bluetooth.BluetoothDevice);
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public void setCodecConfigPreference(@Nullable android.bluetooth.BluetoothDevice, @Nullable android.bluetooth.BluetoothCodecConfig);
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean setConnectionPolicy(@NonNull android.bluetooth.BluetoothDevice, int);
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public void setOptionalCodecsEnabled(@Nullable android.bluetooth.BluetoothDevice, int);
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public int supportsOptionalCodecs(@Nullable android.bluetooth.BluetoothDevice);
+ field public static final int OPTIONAL_CODECS_NOT_SUPPORTED = 0; // 0x0
+ field public static final int OPTIONAL_CODECS_PREF_DISABLED = 0; // 0x0
+ field public static final int OPTIONAL_CODECS_PREF_ENABLED = 1; // 0x1
+ field public static final int OPTIONAL_CODECS_PREF_UNKNOWN = -1; // 0xffffffff
+ field public static final int OPTIONAL_CODECS_SUPPORTED = 1; // 0x1
+ field public static final int OPTIONAL_CODECS_SUPPORT_UNKNOWN = -1; // 0xffffffff
}
public final class BluetoothAdapter {
@@ -1281,6 +1295,52 @@
method public void onMetadataChanged(@NonNull android.bluetooth.BluetoothDevice, int, @Nullable byte[]);
}
+ public final class BluetoothCodecConfig implements android.os.Parcelable {
+ ctor public BluetoothCodecConfig(int, int, int, int, int, long, long, long, long);
+ ctor public BluetoothCodecConfig(int);
+ method public int getBitsPerSample();
+ method @NonNull public String getCodecName();
+ method public int getCodecPriority();
+ method public long getCodecSpecific1();
+ method public int getCodecType();
+ method public int getSampleRate();
+ method public boolean isMandatoryCodec();
+ field public static final int BITS_PER_SAMPLE_16 = 1; // 0x1
+ field public static final int BITS_PER_SAMPLE_24 = 2; // 0x2
+ field public static final int BITS_PER_SAMPLE_32 = 4; // 0x4
+ field public static final int BITS_PER_SAMPLE_NONE = 0; // 0x0
+ field public static final int CHANNEL_MODE_MONO = 1; // 0x1
+ field public static final int CHANNEL_MODE_NONE = 0; // 0x0
+ field public static final int CHANNEL_MODE_STEREO = 2; // 0x2
+ field public static final int CODEC_PRIORITY_DEFAULT = 0; // 0x0
+ field public static final int CODEC_PRIORITY_DISABLED = -1; // 0xffffffff
+ field public static final int CODEC_PRIORITY_HIGHEST = 1000000; // 0xf4240
+ field @NonNull public static final android.os.Parcelable.Creator<android.bluetooth.BluetoothCodecConfig> CREATOR;
+ field public static final int SAMPLE_RATE_176400 = 16; // 0x10
+ field public static final int SAMPLE_RATE_192000 = 32; // 0x20
+ field public static final int SAMPLE_RATE_44100 = 1; // 0x1
+ field public static final int SAMPLE_RATE_48000 = 2; // 0x2
+ field public static final int SAMPLE_RATE_88200 = 4; // 0x4
+ field public static final int SAMPLE_RATE_96000 = 8; // 0x8
+ field public static final int SAMPLE_RATE_NONE = 0; // 0x0
+ field public static final int SOURCE_CODEC_TYPE_AAC = 1; // 0x1
+ field public static final int SOURCE_CODEC_TYPE_APTX = 2; // 0x2
+ field public static final int SOURCE_CODEC_TYPE_APTX_HD = 3; // 0x3
+ field public static final int SOURCE_CODEC_TYPE_INVALID = 1000000; // 0xf4240
+ field public static final int SOURCE_CODEC_TYPE_LDAC = 4; // 0x4
+ field public static final int SOURCE_CODEC_TYPE_MAX = 5; // 0x5
+ field public static final int SOURCE_CODEC_TYPE_SBC = 0; // 0x0
+ }
+
+ public final class BluetoothCodecStatus implements android.os.Parcelable {
+ ctor public BluetoothCodecStatus(@Nullable android.bluetooth.BluetoothCodecConfig, @Nullable android.bluetooth.BluetoothCodecConfig[], @Nullable android.bluetooth.BluetoothCodecConfig[]);
+ method @Nullable public android.bluetooth.BluetoothCodecConfig getCodecConfig();
+ method @Nullable public android.bluetooth.BluetoothCodecConfig[] getCodecsLocalCapabilities();
+ method @Nullable public android.bluetooth.BluetoothCodecConfig[] getCodecsSelectableCapabilities();
+ field @NonNull public static final android.os.Parcelable.Creator<android.bluetooth.BluetoothCodecStatus> CREATOR;
+ field public static final String EXTRA_CODEC_STATUS = "android.bluetooth.extra.CODEC_STATUS";
+ }
+
public final class BluetoothDevice implements android.os.Parcelable {
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean cancelBondProcess();
method @Nullable @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public byte[] getMetadata(int);
diff --git a/core/java/android/bluetooth/BluetoothA2dp.java b/core/java/android/bluetooth/BluetoothA2dp.java
index 8ed61b6..64df0e8 100644
--- a/core/java/android/bluetooth/BluetoothA2dp.java
+++ b/core/java/android/bluetooth/BluetoothA2dp.java
@@ -17,6 +17,7 @@
package android.bluetooth;
import android.Manifest;
+import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
@@ -32,6 +33,8 @@
import android.os.RemoteException;
import android.util.Log;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;
@@ -154,13 +157,22 @@
*/
public static final int STATE_NOT_PLAYING = 11;
+ /** @hide */
+ @IntDef(prefix = "OPTIONAL_CODECS_", value = {
+ OPTIONAL_CODECS_SUPPORT_UNKNOWN,
+ OPTIONAL_CODECS_NOT_SUPPORTED,
+ OPTIONAL_CODECS_SUPPORTED
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface OptionalCodecsSupportStatus {}
+
/**
* We don't have a stored preference for whether or not the given A2DP sink device supports
* optional codecs.
*
* @hide
*/
- @UnsupportedAppUsage
+ @SystemApi
public static final int OPTIONAL_CODECS_SUPPORT_UNKNOWN = -1;
/**
@@ -168,7 +180,7 @@
*
* @hide
*/
- @UnsupportedAppUsage
+ @SystemApi
public static final int OPTIONAL_CODECS_NOT_SUPPORTED = 0;
/**
@@ -176,16 +188,25 @@
*
* @hide
*/
- @UnsupportedAppUsage
+ @SystemApi
public static final int OPTIONAL_CODECS_SUPPORTED = 1;
+ /** @hide */
+ @IntDef(prefix = "OPTIONAL_CODECS_PREF_", value = {
+ OPTIONAL_CODECS_PREF_UNKNOWN,
+ OPTIONAL_CODECS_PREF_DISABLED,
+ OPTIONAL_CODECS_PREF_ENABLED
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface OptionalCodecsPreferenceStatus {}
+
/**
- * We don't have a stored preference for whether optional codecs should be enabled or disabled
- * for the given A2DP device.
+ * We don't have a stored preference for whether optional codecs should be enabled or
+ * disabled for the given A2DP device.
*
* @hide
*/
- @UnsupportedAppUsage
+ @SystemApi
public static final int OPTIONAL_CODECS_PREF_UNKNOWN = -1;
/**
@@ -193,7 +214,7 @@
*
* @hide
*/
- @UnsupportedAppUsage
+ @SystemApi
public static final int OPTIONAL_CODECS_PREF_DISABLED = 0;
/**
@@ -201,7 +222,7 @@
*
* @hide
*/
- @UnsupportedAppUsage
+ @SystemApi
public static final int OPTIONAL_CODECS_PREF_ENABLED = 1;
private BluetoothAdapter mAdapter;
@@ -248,13 +269,12 @@
* 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)
@UnsupportedAppUsage
public boolean connect(BluetoothDevice device) {
if (DBG) log("connect(" + device + ")");
@@ -289,13 +309,12 @@
* {@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
*/
+ @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
@UnsupportedAppUsage
public boolean disconnect(BluetoothDevice device) {
if (DBG) log("disconnect(" + device + ")");
@@ -384,14 +403,12 @@
* {@link #ACTION_ACTIVE_DEVICE_CHANGED} intent will be broadcasted
* with the active device.
*
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
- * permission.
- *
* @param device the remote Bluetooth device. Could be null to clear
* the active device and stop streaming audio to a Bluetooth device.
* @return false on immediate error, true otherwise
* @hide
*/
+ @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
@UnsupportedAppUsage
public boolean setActiveDevice(@Nullable BluetoothDevice device) {
if (DBG) log("setActiveDevice(" + device + ")");
@@ -412,16 +429,13 @@
/**
* Get the connected device that is active.
*
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
- * permission.
- *
* @return the connected device that is active or null if no device
* is active
* @hide
*/
- @RequiresPermission(Manifest.permission.BLUETOOTH)
+ @SystemApi
@Nullable
- @UnsupportedAppUsage
+ @RequiresPermission(Manifest.permission.BLUETOOTH)
public BluetoothDevice getActiveDevice() {
if (VDBG) log("getActiveDevice()");
try {
@@ -441,7 +455,7 @@
* Set priority of the profile
*
* <p> The device should already be paired.
- * Priority can be one of {@link #PRIORITY_ON} or {@link #PRIORITY_OFF},
+ * Priority can be one of {@link #PRIORITY_ON} or {@link #PRIORITY_OFF}
*
* @param device Paired bluetooth device
* @param priority
@@ -626,8 +640,10 @@
* @return the current codec status
* @hide
*/
- @UnsupportedAppUsage
- public @Nullable BluetoothCodecStatus getCodecStatus(BluetoothDevice device) {
+ @SystemApi
+ @Nullable
+ @RequiresPermission(Manifest.permission.BLUETOOTH)
+ public BluetoothCodecStatus getCodecStatus(@Nullable BluetoothDevice device) {
if (DBG) Log.d(TAG, "getCodecStatus(" + device + ")");
try {
final IBluetoothA2dp service = getService();
@@ -652,9 +668,10 @@
* @param codecConfig the codec configuration preference
* @hide
*/
- @UnsupportedAppUsage
- public void setCodecConfigPreference(BluetoothDevice device,
- BluetoothCodecConfig codecConfig) {
+ @SystemApi
+ @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ public void setCodecConfigPreference(@Nullable BluetoothDevice device,
+ @Nullable BluetoothCodecConfig codecConfig) {
if (DBG) Log.d(TAG, "setCodecConfigPreference(" + device + ")");
try {
final IBluetoothA2dp service = getService();
@@ -676,8 +693,9 @@
* active A2DP Bluetooth device.
* @hide
*/
- @UnsupportedAppUsage
- public void enableOptionalCodecs(BluetoothDevice device) {
+ @SystemApi
+ @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ public void enableOptionalCodecs(@Nullable BluetoothDevice device) {
if (DBG) Log.d(TAG, "enableOptionalCodecs(" + device + ")");
enableDisableOptionalCodecs(device, true);
}
@@ -689,8 +707,9 @@
* active A2DP Bluetooth device.
* @hide
*/
- @UnsupportedAppUsage
- public void disableOptionalCodecs(BluetoothDevice device) {
+ @SystemApi
+ @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ public void disableOptionalCodecs(@Nullable BluetoothDevice device) {
if (DBG) Log.d(TAG, "disableOptionalCodecs(" + device + ")");
enableDisableOptionalCodecs(device, false);
}
@@ -728,8 +747,10 @@
* OPTIONAL_CODECS_SUPPORTED.
* @hide
*/
- @UnsupportedAppUsage
- public int supportsOptionalCodecs(BluetoothDevice device) {
+ @SystemApi
+ @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
+ @OptionalCodecsSupportStatus
+ public int supportsOptionalCodecs(@Nullable BluetoothDevice device) {
try {
final IBluetoothA2dp service = getService();
if (service != null && isEnabled() && isValidDevice(device)) {
@@ -738,7 +759,7 @@
if (service == null) Log.w(TAG, "Proxy not attached to service");
return OPTIONAL_CODECS_SUPPORT_UNKNOWN;
} catch (RemoteException e) {
- Log.e(TAG, "Error talking to BT service in getSupportsOptionalCodecs()", e);
+ Log.e(TAG, "Error talking to BT service in supportsOptionalCodecs()", e);
return OPTIONAL_CODECS_SUPPORT_UNKNOWN;
}
}
@@ -751,8 +772,10 @@
* OPTIONAL_CODECS_PREF_DISABLED.
* @hide
*/
- @UnsupportedAppUsage
- public int getOptionalCodecsEnabled(BluetoothDevice device) {
+ @SystemApi
+ @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
+ @OptionalCodecsPreferenceStatus
+ public int getOptionalCodecsEnabled(@Nullable BluetoothDevice device) {
try {
final IBluetoothA2dp service = getService();
if (service != null && isEnabled() && isValidDevice(device)) {
@@ -761,7 +784,7 @@
if (service == null) Log.w(TAG, "Proxy not attached to service");
return OPTIONAL_CODECS_PREF_UNKNOWN;
} catch (RemoteException e) {
- Log.e(TAG, "Error talking to BT service in getSupportsOptionalCodecs()", e);
+ Log.e(TAG, "Error talking to BT service in getOptionalCodecsEnabled()", e);
return OPTIONAL_CODECS_PREF_UNKNOWN;
}
}
@@ -775,8 +798,10 @@
* OPTIONAL_CODECS_PREF_DISABLED.
* @hide
*/
- @UnsupportedAppUsage
- public void setOptionalCodecsEnabled(BluetoothDevice device, int value) {
+ @SystemApi
+ @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ public void setOptionalCodecsEnabled(@Nullable BluetoothDevice device,
+ @OptionalCodecsPreferenceStatus int value) {
try {
if (value != BluetoothA2dp.OPTIONAL_CODECS_PREF_UNKNOWN
&& value != BluetoothA2dp.OPTIONAL_CODECS_PREF_DISABLED
diff --git a/core/java/android/bluetooth/BluetoothA2dpSink.java b/core/java/android/bluetooth/BluetoothA2dpSink.java
index c17834a..cf33676 100755
--- a/core/java/android/bluetooth/BluetoothA2dpSink.java
+++ b/core/java/android/bluetooth/BluetoothA2dpSink.java
@@ -320,7 +320,7 @@
* Set priority of the profile
*
* <p> The device should already be paired.
- * Priority can be one of {@link #PRIORITY_ON} or {@link #PRIORITY_OFF},
+ * Priority can be one of {@link #PRIORITY_ON} or {@link #PRIORITY_OFF}
*
* @param device Paired bluetooth device
* @param priority
diff --git a/core/java/android/bluetooth/BluetoothCodecConfig.java b/core/java/android/bluetooth/BluetoothCodecConfig.java
index 36f3a1e..08d0797 100644
--- a/core/java/android/bluetooth/BluetoothCodecConfig.java
+++ b/core/java/android/bluetooth/BluetoothCodecConfig.java
@@ -16,10 +16,15 @@
package android.bluetooth;
+import android.annotation.IntDef;
+import android.annotation.NonNull;
+import android.annotation.SystemApi;
import android.annotation.UnsupportedAppUsage;
import android.os.Parcel;
import android.os.Parcelable;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.Objects;
/**
@@ -29,78 +34,131 @@
*
* {@hide}
*/
+@SystemApi
public final class BluetoothCodecConfig implements Parcelable {
// Add an entry for each source codec here.
// NOTE: The values should be same as those listed in the following file:
// hardware/libhardware/include/hardware/bt_av.h
- @UnsupportedAppUsage
+
+ /** @hide */
+ @IntDef(prefix = "SOURCE_CODEC_TYPE_", value = {
+ SOURCE_CODEC_TYPE_SBC,
+ SOURCE_CODEC_TYPE_AAC,
+ SOURCE_CODEC_TYPE_APTX,
+ SOURCE_CODEC_TYPE_APTX_HD,
+ SOURCE_CODEC_TYPE_LDAC,
+ SOURCE_CODEC_TYPE_MAX,
+ SOURCE_CODEC_TYPE_INVALID
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface SourceCodecType {}
+
public static final int SOURCE_CODEC_TYPE_SBC = 0;
- @UnsupportedAppUsage
+
public static final int SOURCE_CODEC_TYPE_AAC = 1;
- @UnsupportedAppUsage
+
public static final int SOURCE_CODEC_TYPE_APTX = 2;
- @UnsupportedAppUsage
+
public static final int SOURCE_CODEC_TYPE_APTX_HD = 3;
- @UnsupportedAppUsage
+
public static final int SOURCE_CODEC_TYPE_LDAC = 4;
- @UnsupportedAppUsage
+
public static final int SOURCE_CODEC_TYPE_MAX = 5;
- @UnsupportedAppUsage
+
public static final int SOURCE_CODEC_TYPE_INVALID = 1000 * 1000;
- @UnsupportedAppUsage
+ /** @hide */
+ @IntDef(prefix = "CODEC_PRIORITY_", value = {
+ CODEC_PRIORITY_DISABLED,
+ CODEC_PRIORITY_DEFAULT,
+ CODEC_PRIORITY_HIGHEST
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface CodecPriority {}
+
public static final int CODEC_PRIORITY_DISABLED = -1;
- @UnsupportedAppUsage
+
public static final int CODEC_PRIORITY_DEFAULT = 0;
- @UnsupportedAppUsage
+
public static final int CODEC_PRIORITY_HIGHEST = 1000 * 1000;
- @UnsupportedAppUsage
+
+ /** @hide */
+ @IntDef(prefix = "SAMPLE_RATE_", value = {
+ SAMPLE_RATE_NONE,
+ SAMPLE_RATE_44100,
+ SAMPLE_RATE_48000,
+ SAMPLE_RATE_88200,
+ SAMPLE_RATE_96000,
+ SAMPLE_RATE_176400,
+ SAMPLE_RATE_192000
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface SampleRate {}
+
public static final int SAMPLE_RATE_NONE = 0;
- @UnsupportedAppUsage
+
public static final int SAMPLE_RATE_44100 = 0x1 << 0;
- @UnsupportedAppUsage
+
public static final int SAMPLE_RATE_48000 = 0x1 << 1;
- @UnsupportedAppUsage
+
public static final int SAMPLE_RATE_88200 = 0x1 << 2;
- @UnsupportedAppUsage
+
public static final int SAMPLE_RATE_96000 = 0x1 << 3;
- @UnsupportedAppUsage
+
public static final int SAMPLE_RATE_176400 = 0x1 << 4;
- @UnsupportedAppUsage
+
public static final int SAMPLE_RATE_192000 = 0x1 << 5;
- @UnsupportedAppUsage
+
+ /** @hide */
+ @IntDef(prefix = "BITS_PER_SAMPLE_", value = {
+ BITS_PER_SAMPLE_NONE,
+ BITS_PER_SAMPLE_16,
+ BITS_PER_SAMPLE_24,
+ BITS_PER_SAMPLE_32
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface BitsPerSample {}
+
public static final int BITS_PER_SAMPLE_NONE = 0;
- @UnsupportedAppUsage
+
public static final int BITS_PER_SAMPLE_16 = 0x1 << 0;
- @UnsupportedAppUsage
+
public static final int BITS_PER_SAMPLE_24 = 0x1 << 1;
- @UnsupportedAppUsage
+
public static final int BITS_PER_SAMPLE_32 = 0x1 << 2;
- @UnsupportedAppUsage
+
+ /** @hide */
+ @IntDef(prefix = "CHANNEL_MODE_", value = {
+ CHANNEL_MODE_NONE,
+ CHANNEL_MODE_MONO,
+ CHANNEL_MODE_STEREO
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface ChannelMode {}
+
public static final int CHANNEL_MODE_NONE = 0;
- @UnsupportedAppUsage
+
public static final int CHANNEL_MODE_MONO = 0x1 << 0;
- @UnsupportedAppUsage
+
public static final int CHANNEL_MODE_STEREO = 0x1 << 1;
- private final int mCodecType;
- private int mCodecPriority;
- private final int mSampleRate;
- private final int mBitsPerSample;
- private final int mChannelMode;
+ private final @SourceCodecType int mCodecType;
+ private @CodecPriority int mCodecPriority;
+ private final @SampleRate int mSampleRate;
+ private final @BitsPerSample int mBitsPerSample;
+ private final @ChannelMode int mChannelMode;
private final long mCodecSpecific1;
private final long mCodecSpecific2;
private final long mCodecSpecific3;
private final long mCodecSpecific4;
- @UnsupportedAppUsage
- public BluetoothCodecConfig(int codecType, int codecPriority,
- int sampleRate, int bitsPerSample,
- int channelMode, long codecSpecific1,
+ public BluetoothCodecConfig(@SourceCodecType int codecType, @CodecPriority int codecPriority,
+ @SampleRate int sampleRate, @BitsPerSample int bitsPerSample,
+ @ChannelMode int channelMode, long codecSpecific1,
long codecSpecific2, long codecSpecific3,
long codecSpecific4) {
mCodecType = codecType;
@@ -114,8 +172,7 @@
mCodecSpecific4 = codecSpecific4;
}
- @UnsupportedAppUsage
- public BluetoothCodecConfig(int codecType) {
+ public BluetoothCodecConfig(@SourceCodecType int codecType) {
mCodecType = codecType;
mCodecPriority = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT;
mSampleRate = BluetoothCodecConfig.SAMPLE_RATE_NONE;
@@ -144,6 +201,12 @@
return false;
}
+ /**
+ * Returns a hash based on the config values
+ *
+ * @return a hash based on the config values
+ * @hide
+ */
@Override
public int hashCode() {
return Objects.hash(mCodecType, mCodecPriority, mSampleRate,
@@ -155,6 +218,7 @@
* Checks whether the object contains valid codec configuration.
*
* @return true if the object contains valid codec configuration, otherwise false.
+ * @hide
*/
public boolean isValid() {
return (mSampleRate != SAMPLE_RATE_NONE)
@@ -242,6 +306,12 @@
+ ",mCodecSpecific4:" + mCodecSpecific4 + "}";
}
+ /**
+ * Always returns 0
+ *
+ * @return 0
+ * @hide
+ */
@Override
public int describeContents() {
return 0;
@@ -271,6 +341,14 @@
}
};
+ /**
+ * Flattens the object to a parcel
+ *
+ * @param out The Parcel in which the object should be written.
+ * @param flags Additional flags about how the object should be written.
+ *
+ * @hide
+ */
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mCodecType);
@@ -289,7 +367,7 @@
*
* @return the codec name
*/
- public String getCodecName() {
+ public @NonNull String getCodecName() {
switch (mCodecType) {
case SOURCE_CODEC_TYPE_SBC:
return "SBC";
@@ -315,8 +393,7 @@
*
* @return the codec type
*/
- @UnsupportedAppUsage
- public int getCodecType() {
+ public @SourceCodecType int getCodecType() {
return mCodecType;
}
@@ -336,8 +413,7 @@
*
* @return the codec priority
*/
- @UnsupportedAppUsage
- public int getCodecPriority() {
+ public @CodecPriority int getCodecPriority() {
return mCodecPriority;
}
@@ -347,9 +423,10 @@
* means higher priority. If 0, reset to default.
*
* @param codecPriority the codec priority
+ * @hide
*/
@UnsupportedAppUsage
- public void setCodecPriority(int codecPriority) {
+ public void setCodecPriority(@CodecPriority int codecPriority) {
mCodecPriority = codecPriority;
}
@@ -366,8 +443,7 @@
*
* @return the codec sample rate
*/
- @UnsupportedAppUsage
- public int getSampleRate() {
+ public @SampleRate int getSampleRate() {
return mSampleRate;
}
@@ -381,8 +457,7 @@
*
* @return the codec bits per sample
*/
- @UnsupportedAppUsage
- public int getBitsPerSample() {
+ public @BitsPerSample int getBitsPerSample() {
return mBitsPerSample;
}
@@ -394,9 +469,10 @@
* {@link android.bluetooth.BluetoothCodecConfig#CHANNEL_MODE_STEREO}
*
* @return the codec channel mode
+ * @hide
*/
@UnsupportedAppUsage
- public int getChannelMode() {
+ public @ChannelMode int getChannelMode() {
return mChannelMode;
}
@@ -405,7 +481,6 @@
*
* @return a codec specific value1.
*/
- @UnsupportedAppUsage
public long getCodecSpecific1() {
return mCodecSpecific1;
}
@@ -414,6 +489,7 @@
* Gets a codec specific value2.
*
* @return a codec specific value2
+ * @hide
*/
@UnsupportedAppUsage
public long getCodecSpecific2() {
@@ -424,6 +500,7 @@
* Gets a codec specific value3.
*
* @return a codec specific value3
+ * @hide
*/
@UnsupportedAppUsage
public long getCodecSpecific3() {
@@ -434,6 +511,7 @@
* Gets a codec specific value4.
*
* @return a codec specific value4
+ * @hide
*/
@UnsupportedAppUsage
public long getCodecSpecific4() {
@@ -445,6 +523,7 @@
*
* @param valueSet the value set presented by a bitmask
* @return true if the valueSet contains zero or single bit, otherwise false.
+ * @hide
*/
private static boolean hasSingleBit(int valueSet) {
return (valueSet == 0 || (valueSet & (valueSet - 1)) == 0);
@@ -454,6 +533,7 @@
* Checks whether the object contains none or single sample rate.
*
* @return true if the object contains none or single sample rate, otherwise false.
+ * @hide
*/
public boolean hasSingleSampleRate() {
return hasSingleBit(mSampleRate);
@@ -463,6 +543,7 @@
* Checks whether the object contains none or single bits per sample.
*
* @return true if the object contains none or single bits per sample, otherwise false.
+ * @hide
*/
public boolean hasSingleBitsPerSample() {
return hasSingleBit(mBitsPerSample);
@@ -472,6 +553,7 @@
* Checks whether the object contains none or single channel mode.
*
* @return true if the object contains none or single channel mode, otherwise false.
+ * @hide
*/
public boolean hasSingleChannelMode() {
return hasSingleBit(mChannelMode);
@@ -482,6 +564,7 @@
*
* @param other the codec config to compare against
* @return true if the audio feeding parameters are same, otherwise false
+ * @hide
*/
public boolean sameAudioFeedingParameters(BluetoothCodecConfig other) {
return (other != null && other.mSampleRate == mSampleRate
@@ -495,6 +578,7 @@
*
* @param other the codec config to compare against
* @return true if the audio feeding parameters are similar, otherwise false.
+ * @hide
*/
public boolean similarCodecFeedingParameters(BluetoothCodecConfig other) {
if (other == null || mCodecType != other.mCodecType) {
@@ -526,6 +610,7 @@
*
* @param other the codec config to compare against
* @return true if the codec specific parameters are the same, otherwise false.
+ * @hide
*/
public boolean sameCodecSpecificParameters(BluetoothCodecConfig other) {
if (other == null && mCodecType != other.mCodecType) {
diff --git a/core/java/android/bluetooth/BluetoothCodecStatus.java b/core/java/android/bluetooth/BluetoothCodecStatus.java
index 58a764a..b6e7739 100644
--- a/core/java/android/bluetooth/BluetoothCodecStatus.java
+++ b/core/java/android/bluetooth/BluetoothCodecStatus.java
@@ -17,7 +17,7 @@
package android.bluetooth;
import android.annotation.Nullable;
-import android.annotation.UnsupportedAppUsage;
+import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
@@ -32,6 +32,7 @@
*
* {@hide}
*/
+@SystemApi
public final class BluetoothCodecStatus implements Parcelable {
/**
* Extra for the codec configuration intents of the individual profiles.
@@ -39,17 +40,16 @@
* This extra represents the current codec status of the A2DP
* profile.
*/
- @UnsupportedAppUsage
public static final String EXTRA_CODEC_STATUS =
- "android.bluetooth.codec.extra.CODEC_STATUS";
+ "android.bluetooth.extra.CODEC_STATUS";
private final @Nullable BluetoothCodecConfig mCodecConfig;
private final BluetoothCodecConfig[] mCodecsLocalCapabilities;
private final BluetoothCodecConfig[] mCodecsSelectableCapabilities;
- public BluetoothCodecStatus(BluetoothCodecConfig codecConfig,
- BluetoothCodecConfig[] codecsLocalCapabilities,
- BluetoothCodecConfig[] codecsSelectableCapabilities) {
+ public BluetoothCodecStatus(@Nullable BluetoothCodecConfig codecConfig,
+ @Nullable BluetoothCodecConfig[] codecsLocalCapabilities,
+ @Nullable BluetoothCodecConfig[] codecsSelectableCapabilities) {
mCodecConfig = codecConfig;
mCodecsLocalCapabilities = codecsLocalCapabilities;
mCodecsSelectableCapabilities = codecsSelectableCapabilities;
@@ -74,6 +74,7 @@
* @param c1 the first array of capabilities to compare
* @param c2 the second array of capabilities to compare
* @return true if both arrays contain same capabilities
+ * @hide
*/
public static boolean sameCapabilities(BluetoothCodecConfig[] c1,
BluetoothCodecConfig[] c2) {
@@ -95,6 +96,7 @@
*
* @param codecConfig the codec config to compare against
* @return true if the codec config matches, otherwise false
+ * @hide
*/
public boolean isCodecConfigSelectable(BluetoothCodecConfig codecConfig) {
if (codecConfig == null || !codecConfig.hasSingleSampleRate()
@@ -125,7 +127,12 @@
return false;
}
-
+ /**
+ * Returns a hash based on the codec config and local capabilities
+ *
+ * @return a hash based on the config values
+ * @hide
+ */
@Override
public int hashCode() {
return Objects.hash(mCodecConfig, mCodecsLocalCapabilities,
@@ -140,6 +147,12 @@
+ "}";
}
+ /**
+ * Always returns 0
+ *
+ * @return 0
+ * @hide
+ */
@Override
public int describeContents() {
return 0;
@@ -165,6 +178,14 @@
}
};
+ /**
+ * Flattens the object to a parcel
+ *
+ * @param out The Parcel in which the object should be written.
+ * @param flags Additional flags about how the object should be written.
+ *
+ * @hide
+ */
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeTypedObject(mCodecConfig, 0);
@@ -177,7 +198,6 @@
*
* @return the current codec configuration
*/
- @UnsupportedAppUsage
public @Nullable BluetoothCodecConfig getCodecConfig() {
return mCodecConfig;
}
@@ -187,8 +207,7 @@
*
* @return an array with the codecs local capabilities
*/
- @UnsupportedAppUsage
- public BluetoothCodecConfig[] getCodecsLocalCapabilities() {
+ public @Nullable BluetoothCodecConfig[] getCodecsLocalCapabilities() {
return mCodecsLocalCapabilities;
}
@@ -197,8 +216,7 @@
*
* @return an array with the codecs selectable capabilities
*/
- @UnsupportedAppUsage
- public BluetoothCodecConfig[] getCodecsSelectableCapabilities() {
+ public @Nullable BluetoothCodecConfig[] getCodecsSelectableCapabilities() {
return mCodecsSelectableCapabilities;
}
}