diff options
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); } |