diff options
author | Jack He <siyuanh@google.com> | 2022-03-09 22:16:10 -0800 |
---|---|---|
committer | Jack He <siyuanh@google.com> | 2022-03-10 11:30:45 -0800 |
commit | 0c6507d57d6141e35a7e4236e266b2dfdde0224c (patch) | |
tree | 55354bbe19952aa31fb8d2fb4cce422294235a5e /framework/java/android/bluetooth/BluetoothLeBroadcastMetadata.java | |
parent | 7328d681709eb22ba708218dd010d70e4b40556f (diff) |
Broadcast API adjustment
* Enforce raw bytes vs. structured value consistency in metadata classes
* Enforce required parameters in builder
* Rename getMaximumNumberOfBroadcast to getMaximumNumberOfBroadcasts
* Added utility method to parse and serialize LTV array
Fixes: 218683032
Bug: 218683032
Test: atest BluetoothInstrumentationTests, cts tests
Tag: #feature
Change-Id: Ia10f414bdc958b75e94276d3f645687f8b9635f9
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothLeBroadcastMetadata.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothLeBroadcastMetadata.java | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothLeBroadcastMetadata.java b/framework/java/android/bluetooth/BluetoothLeBroadcastMetadata.java index 1810818c98..2e748b9619 100644 --- a/framework/java/android/bluetooth/BluetoothLeBroadcastMetadata.java +++ b/framework/java/android/bluetooth/BluetoothLeBroadcastMetadata.java @@ -478,6 +478,15 @@ public final class BluetoothLeBroadcastMetadata implements Parcelable { */ @SystemApi public @NonNull BluetoothLeBroadcastMetadata build() { + if (mSourceAddressType == BluetoothDevice.ADDRESS_TYPE_UNKNOWN) { + throw new IllegalArgumentException("SourceAddressTyp cannot be unknown"); + } + if (mSourceDevice == null) { + throw new IllegalArgumentException("SourceDevice cannot be null"); + } + if (mSubgroups.isEmpty()) { + throw new IllegalArgumentException("Must contain at least one subgroup"); + } return new BluetoothLeBroadcastMetadata(mSourceAddressType, mSourceDevice, mSourceAdvertisingSid, mBroadcastId, mPaSyncInterval, mIsEncrypted, mBroadcastCode, mPresentationDelayMicros, mSubgroups); |