summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothCodecStatus.java
diff options
context:
space:
mode:
authorEtienne Ruffieux <eruffieux@google.com>2021-10-05 17:11:45 +0000
committerEtienne Ruffieux <eruffieux@google.com>2021-12-03 23:08:50 +0000
commit55a03869afdab02fd0737daf3f78151959e0d32c (patch)
tree2c70c790b1068b2f8469773ae5d99292801cedfd /framework/java/android/bluetooth/BluetoothCodecStatus.java
parent5e2d28891b44d6d62fa737f3cb5a08592f9b9250 (diff)
Make BluetoothCodecConfig and BluetoothCodecStatus public.
Made BluetoothCodecConfig and BluetoothCodecStatus public, added Builder to BluetoothCodecConfig, added accessor for SOURCE_CODEC_TYPE_MAX and changed Arrays returns to List. Tag: #feature Bug: 200202780 Bug: 170678351 Test: BluetoothCodecConfigTest & BluetoothCodecStatusTest NoNonSdkCheck: Only user actually requested the changes Change-Id: Ic61b7087f53f45781f7e0eecca8b6d983093a22d
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothCodecStatus.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothCodecStatus.java111
1 files changed, 47 insertions, 64 deletions
diff --git a/framework/java/android/bluetooth/BluetoothCodecStatus.java b/framework/java/android/bluetooth/BluetoothCodecStatus.java
index 7764ebeb2e..02606feb3b 100644
--- a/framework/java/android/bluetooth/BluetoothCodecStatus.java
+++ b/framework/java/android/bluetooth/BluetoothCodecStatus.java
@@ -16,12 +16,13 @@
package android.bluetooth;
+import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.compat.annotation.UnsupportedAppUsage;
import android.os.Parcel;
import android.os.Parcelable;
-import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
import java.util.Objects;
/**
@@ -29,8 +30,6 @@ import java.util.Objects;
* A2DP source device.
*
* {@see BluetoothA2dp}
- *
- * {@hide}
*/
public final class BluetoothCodecStatus implements Parcelable {
/**
@@ -39,22 +38,27 @@ 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.extra.CODEC_STATUS";
private final @Nullable BluetoothCodecConfig mCodecConfig;
- private final BluetoothCodecConfig[] mCodecsLocalCapabilities;
- private final BluetoothCodecConfig[] mCodecsSelectableCapabilities;
+ private final @Nullable List<BluetoothCodecConfig> mCodecsLocalCapabilities;
+ private final @Nullable List<BluetoothCodecConfig> mCodecsSelectableCapabilities;
public BluetoothCodecStatus(@Nullable BluetoothCodecConfig codecConfig,
- @Nullable BluetoothCodecConfig[] codecsLocalCapabilities,
- @Nullable BluetoothCodecConfig[] codecsSelectableCapabilities) {
+ @Nullable List<BluetoothCodecConfig> codecsLocalCapabilities,
+ @Nullable List<BluetoothCodecConfig> codecsSelectableCapabilities) {
mCodecConfig = codecConfig;
mCodecsLocalCapabilities = codecsLocalCapabilities;
mCodecsSelectableCapabilities = codecsSelectableCapabilities;
}
+ private BluetoothCodecStatus(Parcel in) {
+ mCodecConfig = in.readTypedObject(BluetoothCodecConfig.CREATOR);
+ mCodecsLocalCapabilities = in.createTypedArrayList(BluetoothCodecConfig.CREATOR);
+ mCodecsSelectableCapabilities = in.createTypedArrayList(BluetoothCodecConfig.CREATOR);
+ }
+
@Override
public boolean equals(@Nullable Object o) {
if (o instanceof BluetoothCodecStatus) {
@@ -68,26 +72,25 @@ public final class BluetoothCodecStatus implements Parcelable {
}
/**
- * Checks whether two arrays of capabilities contain same capabilities.
- * The order of the capabilities in each array is ignored.
+ * Checks whether two lists of capabilities contain same capabilities.
+ * The order of the capabilities in each list is ignored.
*
- * @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
+ * @param c1 the first list of capabilities to compare
+ * @param c2 the second list of capabilities to compare
+ * @return {@code true} if both lists contain same capabilities
*/
- public static boolean sameCapabilities(BluetoothCodecConfig[] c1,
- BluetoothCodecConfig[] c2) {
+ private static boolean sameCapabilities(@Nullable List<BluetoothCodecConfig> c1,
+ @Nullable List<BluetoothCodecConfig> c2) {
if (c1 == null) {
return (c2 == null);
}
if (c2 == null) {
return false;
}
- if (c1.length != c2.length) {
+ if (c1.size() != c2.size()) {
return false;
}
- return Arrays.asList(c1).containsAll(Arrays.asList(c2));
+ return c1.containsAll(c2);
}
/**
@@ -95,10 +98,9 @@ public final class BluetoothCodecStatus implements Parcelable {
* Any parameters of the codec config with NONE value will be considered a wildcard matching.
*
* @param codecConfig the codec config to compare against
- * @return true if the codec config matches, otherwise false
- * @hide
+ * @return {@code true} if the codec config matches, {@code false} otherwise
*/
- public boolean isCodecConfigSelectable(BluetoothCodecConfig codecConfig) {
+ public boolean isCodecConfigSelectable(@Nullable BluetoothCodecConfig codecConfig) {
if (codecConfig == null || !codecConfig.hasSingleSampleRate()
|| !codecConfig.hasSingleBitsPerSample() || !codecConfig.hasSingleChannelMode()) {
return false;
@@ -128,10 +130,7 @@ public final class BluetoothCodecStatus implements Parcelable {
}
/**
- * Returns a hash based on the codec config and local capabilities
- *
- * @return a hash based on the config values
- * @hide
+ * Returns a hash based on the codec config and local capabilities.
*/
@Override
public int hashCode() {
@@ -139,17 +138,19 @@ public final class BluetoothCodecStatus implements Parcelable {
mCodecsLocalCapabilities);
}
+ /**
+ * Returns a {@link String} that describes each BluetoothCodecStatus parameter
+ * current value.
+ */
@Override
public String toString() {
return "{mCodecConfig:" + mCodecConfig
- + ",mCodecsLocalCapabilities:" + Arrays.toString(mCodecsLocalCapabilities)
- + ",mCodecsSelectableCapabilities:" + Arrays.toString(mCodecsSelectableCapabilities)
+ + ",mCodecsLocalCapabilities:" + mCodecsLocalCapabilities
+ + ",mCodecsSelectableCapabilities:" + mCodecsSelectableCapabilities
+ "}";
}
/**
- * Always returns 0
- *
* @return 0
* @hide
*/
@@ -161,16 +162,7 @@ public final class BluetoothCodecStatus implements Parcelable {
public static final @android.annotation.NonNull Parcelable.Creator<BluetoothCodecStatus> CREATOR =
new Parcelable.Creator<BluetoothCodecStatus>() {
public BluetoothCodecStatus createFromParcel(Parcel in) {
- final BluetoothCodecConfig codecConfig = in.readTypedObject(
- BluetoothCodecConfig.CREATOR);
- final BluetoothCodecConfig[] codecsLocalCapabilities = in.createTypedArray(
- BluetoothCodecConfig.CREATOR);
- final BluetoothCodecConfig[] codecsSelectableCapabilities = in.createTypedArray(
- BluetoothCodecConfig.CREATOR);
-
- return new BluetoothCodecStatus(codecConfig,
- codecsLocalCapabilities,
- codecsSelectableCapabilities);
+ return new BluetoothCodecStatus(in);
}
public BluetoothCodecStatus[] newArray(int size) {
@@ -179,47 +171,38 @@ public final class BluetoothCodecStatus implements Parcelable {
};
/**
- * Flattens the object to a parcel
+ * 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
+ * @param out The Parcel in which the object should be written
+ * @param flags Additional flags about how the object should be written
*/
@Override
- public void writeToParcel(Parcel out, int flags) {
+ public void writeToParcel(@NonNull Parcel out, int flags) {
out.writeTypedObject(mCodecConfig, 0);
- out.writeTypedArray(mCodecsLocalCapabilities, 0);
- out.writeTypedArray(mCodecsSelectableCapabilities, 0);
+ out.writeTypedList(mCodecsLocalCapabilities);
+ out.writeTypedList(mCodecsSelectableCapabilities);
}
/**
- * Gets the current codec configuration.
- *
- * @return the current codec configuration
+ * Returns the current codec configuration.
*/
- @UnsupportedAppUsage
public @Nullable BluetoothCodecConfig getCodecConfig() {
return mCodecConfig;
}
/**
- * Gets the codecs local capabilities.
- *
- * @return an array with the codecs local capabilities
+ * Returns the codecs local capabilities.
*/
- @UnsupportedAppUsage
- public @Nullable BluetoothCodecConfig[] getCodecsLocalCapabilities() {
- return mCodecsLocalCapabilities;
+ public @NonNull List<BluetoothCodecConfig> getCodecsLocalCapabilities() {
+ return (mCodecsLocalCapabilities == null)
+ ? Collections.emptyList() : mCodecsLocalCapabilities;
}
/**
- * Gets the codecs selectable capabilities.
- *
- * @return an array with the codecs selectable capabilities
+ * Returns the codecs selectable capabilities.
*/
- @UnsupportedAppUsage
- public @Nullable BluetoothCodecConfig[] getCodecsSelectableCapabilities() {
- return mCodecsSelectableCapabilities;
+ public @NonNull List<BluetoothCodecConfig> getCodecsSelectableCapabilities() {
+ return (mCodecsSelectableCapabilities == null)
+ ? Collections.emptyList() : mCodecsSelectableCapabilities;
}
}