diff options
author | Jack He <siyuanh@google.com> | 2022-03-18 20:51:43 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2022-03-18 20:51:43 +0000 |
commit | 1b64f3f92317309686699b51b73a66395678f626 (patch) | |
tree | 48537fcaa205ff95115460d58af2948f1c630034 /framework/java/android/bluetooth/BluetoothLeBroadcastChannel.java | |
parent | a30a1a9eb767912d2098f4f45f67ac0b2cfc101d (diff) | |
parent | ee12f766d410a8d183bec4357626eadf591135ce (diff) |
Merge changes from topic "bt-api-fix-v2"
* changes:
Broadcast: Strict argument checking for data structures
Broadcast: Use subgroup information to derive whether channel preference
BluetoothClass: Add documentation for constants
hap: Verify non null call parameters
HAP: Split reason and error IntDefs for each callback
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothLeBroadcastChannel.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothLeBroadcastChannel.java | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/framework/java/android/bluetooth/BluetoothLeBroadcastChannel.java b/framework/java/android/bluetooth/BluetoothLeBroadcastChannel.java index 676692ae4a..05f7f4a56d 100644 --- a/framework/java/android/bluetooth/BluetoothLeBroadcastChannel.java +++ b/framework/java/android/bluetooth/BluetoothLeBroadcastChannel.java @@ -21,6 +21,8 @@ import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; +import java.util.Objects; + /** * This class contains the Broadcast Isochronous Channel level information as defined in the BASE * structure of the Basic Audio Profile. @@ -168,11 +170,17 @@ public final class BluetoothLeBroadcastChannel implements Parcelable { /** * Set the Broadcast Isochronous Channel index of this Broadcast Channel. * - * @return Broadcast Isochronous Channel index + * @param channelIndex Broadcast Isochronous Channel index + * @throws IllegalArgumentException if the input argument is not valid + * @return this builder * @hide */ @SystemApi public @NonNull Builder setChannelIndex(int channelIndex) { + if (channelIndex == UNKNOWN_VALUE_PLACEHOLDER) { + throw new IllegalArgumentException("channelIndex cannot be " + + UNKNOWN_VALUE_PLACEHOLDER); + } mChannelIndex = channelIndex; return this; } @@ -181,12 +189,14 @@ public final class BluetoothLeBroadcastChannel implements Parcelable { * Set the codec specific configuration for this Broadcast Channel. * * @param codecMetadata codec specific configuration for this Broadcast Channel + * @throws NullPointerException if codecMetadata is null * @return this builder * @hide */ @SystemApi public @NonNull Builder setCodecMetadata( @NonNull BluetoothLeAudioCodecConfigMetadata codecMetadata) { + Objects.requireNonNull(codecMetadata, "codecMetadata cannot be null"); mCodecMetadata = codecMetadata; return this; } @@ -195,13 +205,16 @@ public final class BluetoothLeBroadcastChannel implements Parcelable { * Build {@link BluetoothLeBroadcastChannel}. * * @return constructed {@link BluetoothLeBroadcastChannel} + * @throws NullPointerException if {@link NonNull} items are null * @throws IllegalArgumentException if the object cannot be built * @hide */ @SystemApi public @NonNull BluetoothLeBroadcastChannel build() { - if (mCodecMetadata == null) { - throw new IllegalArgumentException("codec metadata cannot be null"); + Objects.requireNonNull(mCodecMetadata, "codec metadata cannot be null"); + if (mChannelIndex == UNKNOWN_VALUE_PLACEHOLDER) { + throw new IllegalArgumentException("mChannelIndex cannot be " + + UNKNOWN_VALUE_PLACEHOLDER); } return new BluetoothLeBroadcastChannel(mIsSelected, mChannelIndex, mCodecMetadata); } |