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

Commit d4ff0215 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix LE filters for 32 and 128-bit UUID service data"

parents 34cfeb48 b1847e89
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -204,19 +204,17 @@ import java.util.UUID;
    }

    private byte[] concate(ParcelUuid serviceDataUuid, byte[] serviceData) {
        int dataLen = 2 + (serviceData == null ? 0 : serviceData.length);
        byte[] uuid = BluetoothUuid.uuidToBytes(serviceDataUuid);

        int dataLen = uuid.length + (serviceData == null ? 0 : serviceData.length);
        // If data is too long, don't add it to hardware scan filter.
        if (dataLen > MAX_LEN_PER_FIELD) {
            return null;
        }
        byte[] concated = new byte[dataLen];
        // Extract 16 bit UUID value.
        int uuidValue = BluetoothUuid.getServiceIdentifierFromParcelUuid(serviceDataUuid);
        // First two bytes are service data UUID in little-endian.
        concated[0] = (byte) (uuidValue & 0xFF);
        concated[1] = (byte) ((uuidValue >> 8) & 0xFF);
        System.arraycopy(uuid, 0, concated, 0, uuid.length);
        if (serviceData != null) {
            System.arraycopy(serviceData, 0, concated, 2, serviceData.length);
            System.arraycopy(serviceData, 0, concated, uuid.length, serviceData.length);
        }
        return concated;
    }