Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e3afefc3 authored by Rongxuan Liu's avatar Rongxuan Liu Committed by Automerger Merge Worker
Browse files

Merge "[le audio] Add length check for broadcast code and name" am: b1e81b7f

parents 4562c8ce b1e81b7f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1568,7 +1568,7 @@ public class BassClientStateMachineTest {
                .setSourceDevice(testDevice, BluetoothDevice.ADDRESS_TYPE_RANDOM)
                .setSourceAdvertisingSid(testAdvertiserSid)
                .setBroadcastId(testBroadcastId)
                .setBroadcastCode(new byte[] { 0x00 })
                .setBroadcastCode(new byte[] { 0x00, 0x01, 0x00, 0x02 })
                .setPaSyncInterval(testPaSyncInterval)
                .setPresentationDelayMicros(testPresentationDelayMs);
        // builder expect at least one subgroup
+1 −1
Original line number Diff line number Diff line
@@ -468,7 +468,7 @@ public class LeAudioBroadcastServiceTest {
    @Test
    public void testGetAllBroadcastMetadata() {
        int broadcastId = 243;
        byte[] code = {0x00, 0x01, 0x00};
        byte[] code = {0x00, 0x01, 0x00, 0x02};

        BluetoothLeAudioContentMetadata.Builder meta_builder =
                new BluetoothLeAudioContentMetadata.Builder();
+19 −5
Original line number Diff line number Diff line
@@ -265,13 +265,23 @@ public final class BluetoothLeBroadcastSettings implements Parcelable {
        /**
         * Set broadcast name for the broadcast group.
         *
         * <p>As defined in Public Broadcast Profile V1.0, section 5.1.
         * Broadcast_Name AD Type is a UTF-8 encoded string containing a minimum of 4 characters
         * and a maximum of 32 human-readable characters.
         *
         * @param broadcastName Broadcast name for this broadcast group, null if no name provided
         * @throws IllegalArgumentException if name is non-null and its length is less than 4
         * characters or greater than 32 characters
         * @return this builder
         * @hide
         */
        @SystemApi
        @NonNull
        public Builder setBroadcastName(@Nullable String broadcastName) {
            if (broadcastName != null
                    && ((broadcastName.length() > 32) || (broadcastName.length() < 4))) {
                throw new IllegalArgumentException("Invalid broadcast name length");
            }
            mBroadcastName = broadcastName;
            return this;
        }
@@ -280,20 +290,24 @@ public final class BluetoothLeBroadcastSettings implements Parcelable {
         * Set the Broadcast Code currently set for this broadcast group.
         *
         * <p>Only needed when encryption is enabled
         *
         * <p>As defined in Volume 3, Part C, Section 3.2.6 of Bluetooth Core Specification, Version
         * As defined in Volume 3, Part C, Section 3.2.6 of Bluetooth Core Specification, Version
         * 5.3, Broadcast Code is used to encrypt a broadcast audio stream.
         *
         * <p>It must be a UTF-8 string that has at least 4 octets and should not exceed 16 octets.
         * It must be a UTF-8 string that has at least 4 octets and should not exceed 16 octets.
         *
         * @param broadcastCode Broadcast Code for this broadcast group, null if code is not
         *     required
         *     required for non-encrypted broadcast
         * @throws IllegalArgumentException if name is non-null and its length is less than 4
         * characters or greater than 16 characters
         * @return this builder
         * @hide
         */
        @SystemApi
        @NonNull
        public Builder setBroadcastCode(@Nullable byte[] broadcastCode) {
            if (broadcastCode != null
                    && ((broadcastCode.length > 16) || (broadcastCode.length < 4))) {
                throw new IllegalArgumentException("Invalid broadcast code length");
            }
            mBroadcastCode = broadcastCode;
            return this;
        }