diff options
author | Jack He <siyuanh@google.com> | 2022-03-18 21:29:40 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-03-18 21:29:40 +0000 |
commit | 1d217bbbd400352c8c348adaf7f82a853e130b85 (patch) | |
tree | d31e8b5c9de6277929f84a26b612be038a28435e /framework/java/android/bluetooth/BluetoothLeBroadcastChannel.java | |
parent | b0cd974f7a0ad27f73a48117d36038222147b36d (diff) | |
parent | a0a323827e1a19f30d6e7b899282f3a8493b1c4d (diff) |
Merge changes from topic "bt-api-fix-v2" am: 1b64f3f923 am: 3fb9307c84 am: a0a323827e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2030692
Change-Id: Ie5334acca6d00ea3ca870d3f5ca4832ccdde8ebc
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); } |