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

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

Merge "[le audio] Fix bis sync state parsing with 0xFFFFFFFF" into main am: 35be463f

parents 2ef70f88 35be463f
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -317,6 +317,10 @@ public final class Utils {
        return byteArrayToInt(valueBuf, 0);
    }

    public static long byteArrayToLong(byte[] valueBuf) {
        return byteArrayToLong(valueBuf, 0);
    }

    public static short byteArrayToShort(byte[] valueBuf) {
        ByteBuffer converter = ByteBuffer.wrap(valueBuf);
        converter.order(ByteOrder.nativeOrder());
@@ -329,6 +333,12 @@ public final class Utils {
        return converter.getInt(offset);
    }

    public static long byteArrayToLong(byte[] valueBuf, int offset) {
        ByteBuffer converter = ByteBuffer.wrap(valueBuf);
        converter.order(ByteOrder.nativeOrder());
        return converter.getLong(offset);
    }

    public static String byteArrayToString(byte[] valueBuf) {
        StringBuilder sb = new StringBuilder();
        for (int idx = 0; idx < valueBuf.length; idx++) {
+2 −2
Original line number Diff line number Diff line
@@ -885,7 +885,7 @@ public class BassClientStateMachine extends StateMachine {
                    new ArrayList<BluetoothLeAudioContentMetadata>();
            ArrayList<Long> bisSyncState = new ArrayList<Long>();
            for (int i = 0; i < numSubGroups; i++) {
                byte[] bisSyncIndex = new byte[BassConstants.BCAST_RCVR_STATE_BIS_SYNC_SIZE];
                byte[] bisSyncIndex = new byte[Long.BYTES];
                System.arraycopy(
                        receiverState,
                        offset,
@@ -893,7 +893,7 @@ public class BassClientStateMachine extends StateMachine {
                        0,
                        BassConstants.BCAST_RCVR_STATE_BIS_SYNC_SIZE);
                offset += BassConstants.BCAST_RCVR_STATE_BIS_SYNC_SIZE;
                bisSyncState.add((long) Utils.byteArrayToInt(bisSyncIndex));
                bisSyncState.add((long) Utils.byteArrayToLong(bisSyncIndex));

                int metaDataLength = receiverState[offset++] & 0xFF;
                if (metaDataLength > 0) {
+11 −0
Original line number Diff line number Diff line
@@ -70,6 +70,17 @@ public class UtilsTest {
        assertThat(s).isEqualTo(0x0201);
    }

    @Test
    public void byteArrayToLong() {
        byte[] valueBuf =
                new byte[] {
                    (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04,
                    (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08
                };
        long s = Utils.byteArrayToLong(valueBuf);
        assertThat(s).isEqualTo(0x0807060504030201L);
    }

    @Test
    public void byteArrayToString() {
        byte[] valueBuf = new byte[] {0x01, 0x02};