Merge "Remove redundant UUID parsing in GattService"
diff --git a/src/com/android/bluetooth/gatt/GattService.java b/src/com/android/bluetooth/gatt/GattService.java
index 3a3c080..04a9874 100644
--- a/src/com/android/bluetooth/gatt/GattService.java
+++ b/src/com/android/bluetooth/gatt/GattService.java
@@ -1028,27 +1028,10 @@
                     + Integer.toHexString(advertisingSid) + ", txPower=" + txPower + ", rssi="
                     + rssi + ", periodicAdvInt=0x" + Integer.toHexString(periodicAdvInt));
         }
-        List<UUID> remoteUuids = parseUuids(advData);
 
         byte[] legacyAdvData = Arrays.copyOfRange(advData, 0, 62);
 
         for (ScanClient client : mScanManager.getRegularScanQueue()) {
-            if (client.uuids.length > 0) {
-                int matches = 0;
-                for (UUID search : client.uuids) {
-                    for (UUID remote : remoteUuids) {
-                        if (remote.equals(search)) {
-                            ++matches;
-                            break; // Only count 1st match in case of duplicates
-                        }
-                    }
-                }
-
-                if (matches < client.uuids.length) {
-                    continue;
-                }
-            }
-
             ScannerMap.App app = mScannerMap.getById(client.scannerId);
             if (app == null) {
                 continue;
@@ -3279,41 +3262,6 @@
         }
     }
 
-    @VisibleForTesting
-    List<UUID> parseUuids(byte[] advData) {
-        List<UUID> uuids = new ArrayList<UUID>();
-
-        int offset = 0;
-        while (offset < (advData.length - 2)) {
-            int len = Byte.toUnsignedInt(advData[offset++]);
-            if (len == 0) {
-                break;
-            }
-
-            int type = advData[offset++];
-            switch (type) {
-                case 0x02: // Partial list of 16-bit UUIDs
-                case 0x03: // Complete list of 16-bit UUIDs
-                    while (len > 1) {
-                        int uuid16 = advData[offset++];
-                        uuid16 += (advData[offset++] << 8);
-                        len -= 2;
-                        String uuid_prefix = Integer.toHexString(uuid16);
-                        // Pad zeroes to make uuid_prefix length exactly 8.
-                        uuids.add(UUID.fromString(UUID_ZERO_PAD.substring(uuid_prefix.length())
-                                                  + uuid_prefix + UUID_SUFFIX));
-                    }
-                    break;
-
-                default:
-                    offset += (len - 1);
-                    break;
-            }
-        }
-
-        return uuids;
-    }
-
     void dumpRegisterId(StringBuilder sb) {
         sb.append("  Scanner:\n");
         for (Integer appId : mScannerMap.getAllAppsIds()) {
diff --git a/src/com/android/bluetooth/gatt/ScanClient.java b/src/com/android/bluetooth/gatt/ScanClient.java
index 9f17cc0..ade4992 100644
--- a/src/com/android/bluetooth/gatt/ScanClient.java
+++ b/src/com/android/bluetooth/gatt/ScanClient.java
@@ -24,7 +24,6 @@
 
 import java.util.List;
 import java.util.Objects;
-import java.util.UUID;
 
 /**
  * Helper class identifying a client that has requested LE scan results.
@@ -33,7 +32,6 @@
  */
 /* package */class ScanClient {
     public int scannerId;
-    public UUID[] uuids;
     public ScanSettings settings;
     public ScanSettings passiveSettings;
     public int appUid;
@@ -56,26 +54,16 @@
             new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();
 
     ScanClient(int scannerId) {
-        this(scannerId, new UUID[0], DEFAULT_SCAN_SETTINGS, null, null);
-    }
-
-    ScanClient(int scannerId, UUID[] uuids) {
-        this(scannerId, uuids, DEFAULT_SCAN_SETTINGS, null, null);
+        this(scannerId, DEFAULT_SCAN_SETTINGS, null, null);
     }
 
     ScanClient(int scannerId, ScanSettings settings, List<ScanFilter> filters) {
-        this(scannerId, new UUID[0], settings, filters, null);
+        this(scannerId, settings, filters, null);
     }
 
     ScanClient(int scannerId, ScanSettings settings, List<ScanFilter> filters,
             List<List<ResultStorageDescriptor>> storages) {
-        this(scannerId, new UUID[0], settings, filters, storages);
-    }
-
-    private ScanClient(int scannerId, UUID[] uuids, ScanSettings settings, List<ScanFilter> filters,
-            List<List<ResultStorageDescriptor>> storages) {
         this.scannerId = scannerId;
-        this.uuids = uuids;
         this.settings = settings;
         this.passiveSettings = null;
         this.filters = filters;
diff --git a/tests/unit/src/com/android/bluetooth/gatt/GattServiceTest.java b/tests/unit/src/com/android/bluetooth/gatt/GattServiceTest.java
index 4274040..2f7a84e 100644
--- a/tests/unit/src/com/android/bluetooth/gatt/GattServiceTest.java
+++ b/tests/unit/src/com/android/bluetooth/gatt/GattServiceTest.java
@@ -23,9 +23,6 @@
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 
-import java.util.List;
-import java.util.UUID;
-
 /**
  * Test cases for {@link GattService}.
  */
@@ -92,24 +89,4 @@
         });
         Assert.assertEquals(99700000000L, timestampNanos);
     }
-
-    @Test
-    public void testParseUuids() {
-        // Experimentally observed raw advertiser data.
-        // It contains a partial list of service class UUIDs.
-        String rawHexAdvData = "0201061BFF570102FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF03E060719405"
-                          + "D310094D6920536D6172742042616E6420350302E0FE";
-        String expected_uuid_str = "fffffde0-0000-1000-8000-00805f9b34fb";
-        // Convert to byte array and test.
-        int len = rawHexAdvData.length();
-        byte[] advData = new byte[len / 2];
-        for (int i = 0; i < len; i += 2) {
-            advData[i / 2] = (byte) ((Character.digit(rawHexAdvData.charAt(i), 16) << 4)
-                                + Character.digit(rawHexAdvData.charAt(i + 1), 16));
-        }
-        List<UUID> uuids = mService.parseUuids(advData);
-        Assert.assertEquals(1, uuids.size());
-        Assert.assertEquals(expected_uuid_str, uuids.get(0).toString());
-    }
-
 }