Loading framework/java/android/bluetooth/BluetoothA2dp.java +63 −38 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -32,6 +33,8 @@ import android.os.ParcelUuid; 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; Loading Loading @@ -154,13 +157,22 @@ public final class BluetoothA2dp implements BluetoothProfile { */ 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; /** Loading @@ -168,7 +180,7 @@ public final class BluetoothA2dp implements BluetoothProfile { * * @hide */ @UnsupportedAppUsage @SystemApi public static final int OPTIONAL_CODECS_NOT_SUPPORTED = 0; /** Loading @@ -176,16 +188,25 @@ public final class BluetoothA2dp implements BluetoothProfile { * * @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; /** Loading @@ -193,7 +214,7 @@ public final class BluetoothA2dp implements BluetoothProfile { * * @hide */ @UnsupportedAppUsage @SystemApi public static final int OPTIONAL_CODECS_PREF_DISABLED = 0; /** Loading @@ -201,7 +222,7 @@ public final class BluetoothA2dp implements BluetoothProfile { * * @hide */ @UnsupportedAppUsage @SystemApi public static final int OPTIONAL_CODECS_PREF_ENABLED = 1; private BluetoothAdapter mAdapter; Loading Loading @@ -248,13 +269,12 @@ public final class BluetoothA2dp 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) @UnsupportedAppUsage public boolean connect(BluetoothDevice device) { if (DBG) log("connect(" + device + ")"); Loading Loading @@ -289,13 +309,12 @@ public final class BluetoothA2dp 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 */ @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN) @UnsupportedAppUsage public boolean disconnect(BluetoothDevice device) { if (DBG) log("disconnect(" + device + ")"); Loading Loading @@ -384,14 +403,12 @@ public final class BluetoothA2dp implements BluetoothProfile { * {@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 + ")"); Loading @@ -412,16 +429,13 @@ public final class BluetoothA2dp implements BluetoothProfile { /** * 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 { Loading @@ -441,7 +455,7 @@ public final class BluetoothA2dp implements BluetoothProfile { * 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 Loading Loading @@ -626,8 +640,10 @@ public final class BluetoothA2dp implements BluetoothProfile { * @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(); Loading @@ -652,9 +668,10 @@ public final class BluetoothA2dp implements BluetoothProfile { * @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(); Loading @@ -676,8 +693,9 @@ public final class BluetoothA2dp implements BluetoothProfile { * 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); } Loading @@ -689,8 +707,9 @@ public final class BluetoothA2dp implements BluetoothProfile { * 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); } Loading Loading @@ -728,8 +747,10 @@ public final class BluetoothA2dp implements BluetoothProfile { * 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)) { Loading @@ -738,7 +759,7 @@ public final class BluetoothA2dp implements BluetoothProfile { 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; } } Loading @@ -751,8 +772,10 @@ public final class BluetoothA2dp implements BluetoothProfile { * 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)) { Loading @@ -761,7 +784,7 @@ public final class BluetoothA2dp implements BluetoothProfile { 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; } } Loading @@ -775,8 +798,10 @@ public final class BluetoothA2dp implements BluetoothProfile { * 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 Loading framework/java/android/bluetooth/BluetoothA2dpSink.java +1 −1 Original line number Diff line number Diff line Loading @@ -320,7 +320,7 @@ public final class BluetoothA2dpSink implements BluetoothProfile { * 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 Loading framework/java/android/bluetooth/BluetoothCodecConfig.java +132 −47 Original line number Diff line number Diff line Loading @@ -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; /** Loading @@ -29,78 +34,131 @@ import java.util.Objects; * * {@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; Loading @@ -114,8 +172,7 @@ public final class BluetoothCodecConfig implements Parcelable { mCodecSpecific4 = codecSpecific4; } @UnsupportedAppUsage public BluetoothCodecConfig(int codecType) { public BluetoothCodecConfig(@SourceCodecType int codecType) { mCodecType = codecType; mCodecPriority = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT; mSampleRate = BluetoothCodecConfig.SAMPLE_RATE_NONE; Loading Loading @@ -144,6 +201,12 @@ public final class BluetoothCodecConfig implements Parcelable { 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, Loading @@ -155,6 +218,7 @@ public final class BluetoothCodecConfig implements Parcelable { * 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) Loading Loading @@ -242,6 +306,12 @@ public final class BluetoothCodecConfig implements Parcelable { + ",mCodecSpecific4:" + mCodecSpecific4 + "}"; } /** * Always returns 0 * * @return 0 * @hide */ @Override public int describeContents() { return 0; Loading Loading @@ -271,6 +341,14 @@ public final class BluetoothCodecConfig implements Parcelable { } }; /** * 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); Loading @@ -289,7 +367,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @return the codec name */ public String getCodecName() { public @NonNull String getCodecName() { switch (mCodecType) { case SOURCE_CODEC_TYPE_SBC: return "SBC"; Loading @@ -315,8 +393,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @return the codec type */ @UnsupportedAppUsage public int getCodecType() { public @SourceCodecType int getCodecType() { return mCodecType; } Loading @@ -336,8 +413,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @return the codec priority */ @UnsupportedAppUsage public int getCodecPriority() { public @CodecPriority int getCodecPriority() { return mCodecPriority; } Loading @@ -347,9 +423,10 @@ public final class BluetoothCodecConfig implements Parcelable { * 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; } Loading @@ -366,8 +443,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @return the codec sample rate */ @UnsupportedAppUsage public int getSampleRate() { public @SampleRate int getSampleRate() { return mSampleRate; } Loading @@ -381,8 +457,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @return the codec bits per sample */ @UnsupportedAppUsage public int getBitsPerSample() { public @BitsPerSample int getBitsPerSample() { return mBitsPerSample; } Loading @@ -394,9 +469,10 @@ public final class BluetoothCodecConfig implements Parcelable { * {@link android.bluetooth.BluetoothCodecConfig#CHANNEL_MODE_STEREO} * * @return the codec channel mode * @hide */ @UnsupportedAppUsage public int getChannelMode() { public @ChannelMode int getChannelMode() { return mChannelMode; } Loading @@ -405,7 +481,6 @@ public final class BluetoothCodecConfig implements Parcelable { * * @return a codec specific value1. */ @UnsupportedAppUsage public long getCodecSpecific1() { return mCodecSpecific1; } Loading @@ -414,6 +489,7 @@ public final class BluetoothCodecConfig implements Parcelable { * Gets a codec specific value2. * * @return a codec specific value2 * @hide */ @UnsupportedAppUsage public long getCodecSpecific2() { Loading @@ -424,6 +500,7 @@ public final class BluetoothCodecConfig implements Parcelable { * Gets a codec specific value3. * * @return a codec specific value3 * @hide */ @UnsupportedAppUsage public long getCodecSpecific3() { Loading @@ -434,6 +511,7 @@ public final class BluetoothCodecConfig implements Parcelable { * Gets a codec specific value4. * * @return a codec specific value4 * @hide */ @UnsupportedAppUsage public long getCodecSpecific4() { Loading @@ -445,6 +523,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @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); Loading @@ -454,6 +533,7 @@ public final class BluetoothCodecConfig implements Parcelable { * 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); Loading @@ -463,6 +543,7 @@ public final class BluetoothCodecConfig implements Parcelable { * 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); Loading @@ -472,6 +553,7 @@ public final class BluetoothCodecConfig implements Parcelable { * 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); Loading @@ -482,6 +564,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @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 Loading @@ -495,6 +578,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @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) { Loading Loading @@ -526,6 +610,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @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) { Loading framework/java/android/bluetooth/BluetoothCodecStatus.java +30 −12 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -32,6 +32,7 @@ import java.util.Objects; * * {@hide} */ @SystemApi public final class BluetoothCodecStatus implements Parcelable { /** * Extra for the codec configuration intents of the individual profiles. Loading @@ -39,17 +40,16 @@ public final class BluetoothCodecStatus implements Parcelable { * 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; Loading @@ -74,6 +74,7 @@ public final class BluetoothCodecStatus implements Parcelable { * @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) { Loading @@ -95,6 +96,7 @@ public final class BluetoothCodecStatus implements Parcelable { * * @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() Loading Loading @@ -125,7 +127,12 @@ public final class BluetoothCodecStatus implements Parcelable { 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, Loading @@ -140,6 +147,12 @@ public final class BluetoothCodecStatus implements Parcelable { + "}"; } /** * Always returns 0 * * @return 0 * @hide */ @Override public int describeContents() { return 0; Loading @@ -165,6 +178,14 @@ public final class BluetoothCodecStatus implements Parcelable { } }; /** * 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); Loading @@ -177,7 +198,6 @@ public final class BluetoothCodecStatus implements Parcelable { * * @return the current codec configuration */ @UnsupportedAppUsage public @Nullable BluetoothCodecConfig getCodecConfig() { return mCodecConfig; } Loading @@ -187,8 +207,7 @@ public final class BluetoothCodecStatus implements Parcelable { * * @return an array with the codecs local capabilities */ @UnsupportedAppUsage public BluetoothCodecConfig[] getCodecsLocalCapabilities() { public @Nullable BluetoothCodecConfig[] getCodecsLocalCapabilities() { return mCodecsLocalCapabilities; } Loading @@ -197,8 +216,7 @@ public final class BluetoothCodecStatus implements Parcelable { * * @return an array with the codecs selectable capabilities */ @UnsupportedAppUsage public BluetoothCodecConfig[] getCodecsSelectableCapabilities() { public @Nullable BluetoothCodecConfig[] getCodecsSelectableCapabilities() { return mCodecsSelectableCapabilities; } } Loading
framework/java/android/bluetooth/BluetoothA2dp.java +63 −38 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -32,6 +33,8 @@ import android.os.ParcelUuid; 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; Loading Loading @@ -154,13 +157,22 @@ public final class BluetoothA2dp implements BluetoothProfile { */ 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; /** Loading @@ -168,7 +180,7 @@ public final class BluetoothA2dp implements BluetoothProfile { * * @hide */ @UnsupportedAppUsage @SystemApi public static final int OPTIONAL_CODECS_NOT_SUPPORTED = 0; /** Loading @@ -176,16 +188,25 @@ public final class BluetoothA2dp implements BluetoothProfile { * * @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; /** Loading @@ -193,7 +214,7 @@ public final class BluetoothA2dp implements BluetoothProfile { * * @hide */ @UnsupportedAppUsage @SystemApi public static final int OPTIONAL_CODECS_PREF_DISABLED = 0; /** Loading @@ -201,7 +222,7 @@ public final class BluetoothA2dp implements BluetoothProfile { * * @hide */ @UnsupportedAppUsage @SystemApi public static final int OPTIONAL_CODECS_PREF_ENABLED = 1; private BluetoothAdapter mAdapter; Loading Loading @@ -248,13 +269,12 @@ public final class BluetoothA2dp 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) @UnsupportedAppUsage public boolean connect(BluetoothDevice device) { if (DBG) log("connect(" + device + ")"); Loading Loading @@ -289,13 +309,12 @@ public final class BluetoothA2dp 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 */ @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN) @UnsupportedAppUsage public boolean disconnect(BluetoothDevice device) { if (DBG) log("disconnect(" + device + ")"); Loading Loading @@ -384,14 +403,12 @@ public final class BluetoothA2dp implements BluetoothProfile { * {@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 + ")"); Loading @@ -412,16 +429,13 @@ public final class BluetoothA2dp implements BluetoothProfile { /** * 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 { Loading @@ -441,7 +455,7 @@ public final class BluetoothA2dp implements BluetoothProfile { * 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 Loading Loading @@ -626,8 +640,10 @@ public final class BluetoothA2dp implements BluetoothProfile { * @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(); Loading @@ -652,9 +668,10 @@ public final class BluetoothA2dp implements BluetoothProfile { * @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(); Loading @@ -676,8 +693,9 @@ public final class BluetoothA2dp implements BluetoothProfile { * 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); } Loading @@ -689,8 +707,9 @@ public final class BluetoothA2dp implements BluetoothProfile { * 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); } Loading Loading @@ -728,8 +747,10 @@ public final class BluetoothA2dp implements BluetoothProfile { * 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)) { Loading @@ -738,7 +759,7 @@ public final class BluetoothA2dp implements BluetoothProfile { 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; } } Loading @@ -751,8 +772,10 @@ public final class BluetoothA2dp implements BluetoothProfile { * 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)) { Loading @@ -761,7 +784,7 @@ public final class BluetoothA2dp implements BluetoothProfile { 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; } } Loading @@ -775,8 +798,10 @@ public final class BluetoothA2dp implements BluetoothProfile { * 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 Loading
framework/java/android/bluetooth/BluetoothA2dpSink.java +1 −1 Original line number Diff line number Diff line Loading @@ -320,7 +320,7 @@ public final class BluetoothA2dpSink implements BluetoothProfile { * 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 Loading
framework/java/android/bluetooth/BluetoothCodecConfig.java +132 −47 Original line number Diff line number Diff line Loading @@ -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; /** Loading @@ -29,78 +34,131 @@ import java.util.Objects; * * {@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; Loading @@ -114,8 +172,7 @@ public final class BluetoothCodecConfig implements Parcelable { mCodecSpecific4 = codecSpecific4; } @UnsupportedAppUsage public BluetoothCodecConfig(int codecType) { public BluetoothCodecConfig(@SourceCodecType int codecType) { mCodecType = codecType; mCodecPriority = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT; mSampleRate = BluetoothCodecConfig.SAMPLE_RATE_NONE; Loading Loading @@ -144,6 +201,12 @@ public final class BluetoothCodecConfig implements Parcelable { 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, Loading @@ -155,6 +218,7 @@ public final class BluetoothCodecConfig implements Parcelable { * 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) Loading Loading @@ -242,6 +306,12 @@ public final class BluetoothCodecConfig implements Parcelable { + ",mCodecSpecific4:" + mCodecSpecific4 + "}"; } /** * Always returns 0 * * @return 0 * @hide */ @Override public int describeContents() { return 0; Loading Loading @@ -271,6 +341,14 @@ public final class BluetoothCodecConfig implements Parcelable { } }; /** * 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); Loading @@ -289,7 +367,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @return the codec name */ public String getCodecName() { public @NonNull String getCodecName() { switch (mCodecType) { case SOURCE_CODEC_TYPE_SBC: return "SBC"; Loading @@ -315,8 +393,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @return the codec type */ @UnsupportedAppUsage public int getCodecType() { public @SourceCodecType int getCodecType() { return mCodecType; } Loading @@ -336,8 +413,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @return the codec priority */ @UnsupportedAppUsage public int getCodecPriority() { public @CodecPriority int getCodecPriority() { return mCodecPriority; } Loading @@ -347,9 +423,10 @@ public final class BluetoothCodecConfig implements Parcelable { * 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; } Loading @@ -366,8 +443,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @return the codec sample rate */ @UnsupportedAppUsage public int getSampleRate() { public @SampleRate int getSampleRate() { return mSampleRate; } Loading @@ -381,8 +457,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @return the codec bits per sample */ @UnsupportedAppUsage public int getBitsPerSample() { public @BitsPerSample int getBitsPerSample() { return mBitsPerSample; } Loading @@ -394,9 +469,10 @@ public final class BluetoothCodecConfig implements Parcelable { * {@link android.bluetooth.BluetoothCodecConfig#CHANNEL_MODE_STEREO} * * @return the codec channel mode * @hide */ @UnsupportedAppUsage public int getChannelMode() { public @ChannelMode int getChannelMode() { return mChannelMode; } Loading @@ -405,7 +481,6 @@ public final class BluetoothCodecConfig implements Parcelable { * * @return a codec specific value1. */ @UnsupportedAppUsage public long getCodecSpecific1() { return mCodecSpecific1; } Loading @@ -414,6 +489,7 @@ public final class BluetoothCodecConfig implements Parcelable { * Gets a codec specific value2. * * @return a codec specific value2 * @hide */ @UnsupportedAppUsage public long getCodecSpecific2() { Loading @@ -424,6 +500,7 @@ public final class BluetoothCodecConfig implements Parcelable { * Gets a codec specific value3. * * @return a codec specific value3 * @hide */ @UnsupportedAppUsage public long getCodecSpecific3() { Loading @@ -434,6 +511,7 @@ public final class BluetoothCodecConfig implements Parcelable { * Gets a codec specific value4. * * @return a codec specific value4 * @hide */ @UnsupportedAppUsage public long getCodecSpecific4() { Loading @@ -445,6 +523,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @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); Loading @@ -454,6 +533,7 @@ public final class BluetoothCodecConfig implements Parcelable { * 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); Loading @@ -463,6 +543,7 @@ public final class BluetoothCodecConfig implements Parcelable { * 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); Loading @@ -472,6 +553,7 @@ public final class BluetoothCodecConfig implements Parcelable { * 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); Loading @@ -482,6 +564,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @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 Loading @@ -495,6 +578,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @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) { Loading Loading @@ -526,6 +610,7 @@ public final class BluetoothCodecConfig implements Parcelable { * * @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) { Loading
framework/java/android/bluetooth/BluetoothCodecStatus.java +30 −12 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -32,6 +32,7 @@ import java.util.Objects; * * {@hide} */ @SystemApi public final class BluetoothCodecStatus implements Parcelable { /** * Extra for the codec configuration intents of the individual profiles. Loading @@ -39,17 +40,16 @@ public final class BluetoothCodecStatus implements Parcelable { * 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; Loading @@ -74,6 +74,7 @@ public final class BluetoothCodecStatus implements Parcelable { * @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) { Loading @@ -95,6 +96,7 @@ public final class BluetoothCodecStatus implements Parcelable { * * @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() Loading Loading @@ -125,7 +127,12 @@ public final class BluetoothCodecStatus implements Parcelable { 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, Loading @@ -140,6 +147,12 @@ public final class BluetoothCodecStatus implements Parcelable { + "}"; } /** * Always returns 0 * * @return 0 * @hide */ @Override public int describeContents() { return 0; Loading @@ -165,6 +178,14 @@ public final class BluetoothCodecStatus implements Parcelable { } }; /** * 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); Loading @@ -177,7 +198,6 @@ public final class BluetoothCodecStatus implements Parcelable { * * @return the current codec configuration */ @UnsupportedAppUsage public @Nullable BluetoothCodecConfig getCodecConfig() { return mCodecConfig; } Loading @@ -187,8 +207,7 @@ public final class BluetoothCodecStatus implements Parcelable { * * @return an array with the codecs local capabilities */ @UnsupportedAppUsage public BluetoothCodecConfig[] getCodecsLocalCapabilities() { public @Nullable BluetoothCodecConfig[] getCodecsLocalCapabilities() { return mCodecsLocalCapabilities; } Loading @@ -197,8 +216,7 @@ public final class BluetoothCodecStatus implements Parcelable { * * @return an array with the codecs selectable capabilities */ @UnsupportedAppUsage public BluetoothCodecConfig[] getCodecsSelectableCapabilities() { public @Nullable BluetoothCodecConfig[] getCodecsSelectableCapabilities() { return mCodecsSelectableCapabilities; } }