Loading android/app/src/com/android/bluetooth/Utils.java +10 −0 Original line number Diff line number Diff line Loading @@ -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()); Loading @@ -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++) { Loading android/app/src/com/android/bluetooth/bass_client/BassClientStateMachine.java +2 −2 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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) { Loading android/app/tests/unit/src/com/android/bluetooth/UtilsTest.java +11 −0 Original line number Diff line number Diff line Loading @@ -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}; Loading Loading
android/app/src/com/android/bluetooth/Utils.java +10 −0 Original line number Diff line number Diff line Loading @@ -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()); Loading @@ -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++) { Loading
android/app/src/com/android/bluetooth/bass_client/BassClientStateMachine.java +2 −2 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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) { Loading
android/app/tests/unit/src/com/android/bluetooth/UtilsTest.java +11 −0 Original line number Diff line number Diff line Loading @@ -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}; Loading