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

Commit 36e142d1 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by android-build-merger
Browse files

Merge "Add 32 and 128 bit Service Data parsing." am: 725e212de3 am: 2acc8e28dd

am: 138f75bbc8

Change-Id: I8c821ed86a85892af7a77c4a8080a1e9fde9fdfa
parents 22bae24d 9d4d34ea
Loading
Loading
Loading
Loading
+12 −4
Original line number Original line Diff line number Diff line
@@ -47,7 +47,9 @@ public final class ScanRecord {
    private static final int DATA_TYPE_LOCAL_NAME_SHORT = 0x08;
    private static final int DATA_TYPE_LOCAL_NAME_SHORT = 0x08;
    private static final int DATA_TYPE_LOCAL_NAME_COMPLETE = 0x09;
    private static final int DATA_TYPE_LOCAL_NAME_COMPLETE = 0x09;
    private static final int DATA_TYPE_TX_POWER_LEVEL = 0x0A;
    private static final int DATA_TYPE_TX_POWER_LEVEL = 0x0A;
    private static final int DATA_TYPE_SERVICE_DATA = 0x16;
    private static final int DATA_TYPE_SERVICE_DATA_16_BIT = 0x16;
    private static final int DATA_TYPE_SERVICE_DATA_32_BIT = 0x20;
    private static final int DATA_TYPE_SERVICE_DATA_128_BIT = 0x21;
    private static final int DATA_TYPE_MANUFACTURER_SPECIFIC_DATA = 0xFF;
    private static final int DATA_TYPE_MANUFACTURER_SPECIFIC_DATA = 0xFF;


    // Flags of the advertising data.
    // Flags of the advertising data.
@@ -224,10 +226,16 @@ public final class ScanRecord {
                    case DATA_TYPE_TX_POWER_LEVEL:
                    case DATA_TYPE_TX_POWER_LEVEL:
                        txPowerLevel = scanRecord[currentPos];
                        txPowerLevel = scanRecord[currentPos];
                        break;
                        break;
                    case DATA_TYPE_SERVICE_DATA:
                    case DATA_TYPE_SERVICE_DATA_16_BIT:
                        // The first two bytes of the service data are service data UUID in little
                    case DATA_TYPE_SERVICE_DATA_32_BIT:
                        // endian. The rest bytes are service data.
                    case DATA_TYPE_SERVICE_DATA_128_BIT:
                        int serviceUuidLength = BluetoothUuid.UUID_BYTES_16_BIT;
                        int serviceUuidLength = BluetoothUuid.UUID_BYTES_16_BIT;
                        if (fieldType == DATA_TYPE_SERVICE_DATA_32_BIT) {
                         serviceUuidLength = BluetoothUuid.UUID_BYTES_32_BIT;
                        } else if (fieldType == DATA_TYPE_SERVICE_DATA_128_BIT) {
                         serviceUuidLength = BluetoothUuid.UUID_BYTES_128_BIT;
                        }

                        byte[] serviceDataUuidBytes = extractBytes(scanRecord, currentPos,
                        byte[] serviceDataUuidBytes = extractBytes(scanRecord, currentPos,
                                serviceUuidLength);
                                serviceUuidLength);
                        ParcelUuid serviceDataUuid = BluetoothUuid.parseUuidFrom(
                        ParcelUuid serviceDataUuid = BluetoothUuid.parseUuidFrom(