summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jakub Pawlowski <jpawlowski@google.com> 2017-05-26 13:59:55 -0700
committer Jakub Pawlowski <jpawlowski@google.com> 2017-05-26 16:24:40 -0700
commit50f8f3db274b51bf01510b702f0c669e0fd11d66 (patch)
treec18c72318b8a5601dee75eddc0ca5d84b99b078b
parente63965cef516777dae682103e0813b7f024dab62 (diff)
Add 32 and 128 bit Service Data parsing.
Bug: 62078132 Change-Id: I79ff75cd5ccbe346dca79693b074ff3cd09112dd (cherry picked from commit 45033a7e5799f2d957c7dad22eec0bfef94b3e16)
-rw-r--r--core/java/android/bluetooth/le/ScanRecord.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/core/java/android/bluetooth/le/ScanRecord.java b/core/java/android/bluetooth/le/ScanRecord.java
index f802e8d1295e..914e8fd9e07f 100644
--- a/core/java/android/bluetooth/le/ScanRecord.java
+++ b/core/java/android/bluetooth/le/ScanRecord.java
@@ -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_COMPLETE = 0x09;
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;
// Flags of the advertising data.
@@ -224,10 +226,16 @@ public final class ScanRecord {
case DATA_TYPE_TX_POWER_LEVEL:
txPowerLevel = scanRecord[currentPos];
break;
- case DATA_TYPE_SERVICE_DATA:
- // The first two bytes of the service data are service data UUID in little
- // endian. The rest bytes are service data.
+ case DATA_TYPE_SERVICE_DATA_16_BIT:
+ case DATA_TYPE_SERVICE_DATA_32_BIT:
+ case DATA_TYPE_SERVICE_DATA_128_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,
serviceUuidLength);
ParcelUuid serviceDataUuid = BluetoothUuid.parseUuidFrom(