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

Commit 131cf250 authored by Jakub Tyszkowski's avatar Jakub Tyszkowski
Browse files

Bass: Fix parsing BaseData Codec ID

BAP specification requires the codec ID to be 5 octets long. There is no
such thing as shortened (1 octet in size) codec ID with value 0xFE.
This removes the confusing code that will never be executed with BAP
compliant BASE advertisings.

Bug: 328181940
Test: atest BluetoothInstrumentationTests
Flag: EXEMPT; Removes dead code
Change-Id: I16ec4934c01a3a244d5f0c9e96217c5d6e42ba8f
parent 96a7bfb8
Loading
Loading
Loading
Loading
+3 −21
Original line number Diff line number Diff line
@@ -33,13 +33,11 @@ import java.util.Set;
/** Helper class to parse the Broadcast Announcement BASE data */
class BaseData {
    private static final String TAG = "Bassclient-BaseData";
    private static final byte UNKNOWN_CODEC = (byte) 0xFE;
    private static final int METADATA_LEVEL1 = 1;
    private static final int METADATA_LEVEL2 = 2;
    private static final int METADATA_LEVEL3 = 3;
    private static final int METADATA_PRESENTATIONDELAY_LENGTH = 3;
    private static final int METADATA_CODEC_LENGTH = 5;
    private static final int METADATA_UNKNOWN_CODEC_LENGTH = 1;
    private static final int CODEC_CONFIGURATION_SAMPLE_RATE_TYPE = 0x01;
    private static final int CODEC_CONFIGURATION_FRAME_DURATION_TYPE = 0x02;
    private static final int CODEC_CONFIGURATION_CHANNEL_ALLOCATION_TYPE = 0x03;
@@ -97,10 +95,6 @@ class BaseData {
            log("BaseInformation is Initialized");
        }

        boolean isCodecIdUnknown() {
            return (codecId != null && codecId[4] == (byte) UNKNOWN_CODEC);
        }

        void print() {
            log("**BEGIN: Base Information**");
            log("**Level: " + level + "***");
@@ -193,21 +187,9 @@ class BaseData {
        BaseInformation node = new BaseInformation();
        node.level = METADATA_LEVEL2;
        node.subGroupId = groupIndex;
        node.numSubGroups = serviceData[offset++];
        if (serviceData[offset] == (byte) UNKNOWN_CODEC) {
            // Place It in the last byte of codecID
            System.arraycopy(
                    serviceData,
                    offset,
                    node.codecId,
                    METADATA_CODEC_LENGTH - 1,
                    METADATA_UNKNOWN_CODEC_LENGTH);
            offset += METADATA_UNKNOWN_CODEC_LENGTH;
            log("codecId is FE");
        } else {
        node.numSubGroups = serviceData[offset++]; // NumBis
        System.arraycopy(serviceData, offset, node.codecId, 0, METADATA_CODEC_LENGTH);
        offset += METADATA_CODEC_LENGTH;
        }
        node.codecConfigLength = serviceData[offset++] & 0xff;
        if (node.codecConfigLength != 0) {
            node.codecConfigInfo = new byte[node.codecConfigLength];