summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothLeBroadcastReceiveState.java
diff options
context:
space:
mode:
authorJack He <siyuanh@google.com>2022-03-18 21:29:40 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-03-18 21:29:40 +0000
commit1d217bbbd400352c8c348adaf7f82a853e130b85 (patch)
treed31e8b5c9de6277929f84a26b612be038a28435e /framework/java/android/bluetooth/BluetoothLeBroadcastReceiveState.java
parentb0cd974f7a0ad27f73a48117d36038222147b36d (diff)
parenta0a323827e1a19f30d6e7b899282f3a8493b1c4d (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/BluetoothLeBroadcastReceiveState.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothLeBroadcastReceiveState.java57
1 files changed, 52 insertions, 5 deletions
diff --git a/framework/java/android/bluetooth/BluetoothLeBroadcastReceiveState.java b/framework/java/android/bluetooth/BluetoothLeBroadcastReceiveState.java
index bab17ee797..70a2add80e 100644
--- a/framework/java/android/bluetooth/BluetoothLeBroadcastReceiveState.java
+++ b/framework/java/android/bluetooth/BluetoothLeBroadcastReceiveState.java
@@ -28,6 +28,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
/**
* The {@link BluetoothLeBroadcastReceiveState} is used by the BASS server to expose information
@@ -187,13 +188,59 @@ public final class BluetoothLeBroadcastReceiveState implements Parcelable {
/**
* Constructor to create a read-only {@link BluetoothLeBroadcastReceiveState} instance.
*
+ * @throws NullPointerException if sourceDevice, bisSyncState, or subgroupMetadata is null
+ * @throws IllegalArgumentException if sourceID is not [0, 0xFF] or if sourceAddressType
+ * is invalid or if bisSyncState.size() != numSubgroups or if subgroupMetadata.size() !=
+ * numSubgroups or if paSyncState or bigEncryptionState is not recognized bye IntDef
* @hide
*/
- public BluetoothLeBroadcastReceiveState(int sourceId, int sourceAddressType,
- BluetoothDevice sourceDevice, int sourceAdvertisingSid, int broadcastId,
- int paSyncState, int bigEncryptionState, byte[] badCode, int numSubgroups,
- List<Long> bisSyncState,
- List<BluetoothLeAudioContentMetadata> subgroupMetadata) {
+ public BluetoothLeBroadcastReceiveState(@IntRange(from = 0x00, to = 0xFF) int sourceId,
+ @BluetoothDevice.AddressType int sourceAddressType,
+ @NonNull BluetoothDevice sourceDevice, int sourceAdvertisingSid, int broadcastId,
+ @PaSyncState int paSyncState, @BigEncryptionState int bigEncryptionState,
+ byte[] badCode, @IntRange(from = 0x00) int numSubgroups,
+ @NonNull List<Long> bisSyncState,
+ @NonNull List<BluetoothLeAudioContentMetadata> subgroupMetadata) {
+ if (sourceId < 0x00 || sourceId > 0xFF) {
+ throw new IllegalArgumentException("sourceId " + sourceId
+ + " does not fall between 0x00 and 0xFF");
+ }
+ Objects.requireNonNull(sourceDevice, "sourceDevice cannot be null");
+ if (sourceAddressType == BluetoothDevice.ADDRESS_TYPE_UNKNOWN) {
+ throw new IllegalArgumentException("sourceAddressType cannot be ADDRESS_TYPE_UNKNOWN");
+ }
+ if (sourceAddressType != BluetoothDevice.ADDRESS_TYPE_RANDOM
+ && sourceAddressType != BluetoothDevice.ADDRESS_TYPE_PUBLIC) {
+ throw new IllegalArgumentException("sourceAddressType " + sourceAddressType
+ + " is invalid");
+ }
+ Objects.requireNonNull(bisSyncState, "bisSyncState cannot be null");
+ if (bisSyncState.size() != numSubgroups) {
+ throw new IllegalArgumentException("bisSyncState.size() " + bisSyncState.size()
+ + " must be equal to numSubgroups " + numSubgroups);
+ }
+ Objects.requireNonNull(subgroupMetadata, "subgroupMetadata cannot be null");
+ if (subgroupMetadata.size() != numSubgroups) {
+ throw new IllegalArgumentException("subgroupMetadata.size() "
+ + subgroupMetadata.size() + " must be equal to numSubgroups " + numSubgroups);
+ }
+ if (paSyncState != PA_SYNC_STATE_IDLE && paSyncState != PA_SYNC_STATE_SYNCINFO_REQUEST
+ && paSyncState != PA_SYNC_STATE_FAILED_TO_SYNCHRONIZE
+ && paSyncState != PA_SYNC_STATE_NO_PAST && paSyncState != PA_SYNC_STATE_INVALID) {
+ throw new IllegalArgumentException("unrecognized paSyncState " + paSyncState);
+ }
+ if (bigEncryptionState != BIG_ENCRYPTION_STATE_NOT_ENCRYPTED
+ && bigEncryptionState != BIG_ENCRYPTION_STATE_CODE_REQUIRED
+ && bigEncryptionState != BIG_ENCRYPTION_STATE_DECRYPTING
+ && bigEncryptionState != BIG_ENCRYPTION_STATE_BAD_CODE
+ && bigEncryptionState != BIG_ENCRYPTION_STATE_INVALID) {
+ throw new IllegalArgumentException("unrecognized bigEncryptionState "
+ + bigEncryptionState);
+ }
+ if (badCode != null && badCode.length != 16) {
+ throw new IllegalArgumentException("badCode must be 16 bytes long of null, but is "
+ + badCode.length + " + bytes long");
+ }
mSourceId = sourceId;
mSourceAddressType = sourceAddressType;
mSourceDevice = sourceDevice;