@Test @Config(sdk = Build.VERSION_CODES.KITKAT) public void filterUuidsOnKitkat() { ByteBuffer mockScanRecordBuffer = ByteBuffer.allocate(100).order(ByteOrder.LITTLE_ENDIAN) .put((byte) 17) .put((byte) 0x07) .putLong(INVALID_UUID.getLeastSignificantBits()) .putLong(INVALID_UUID.getMostSignificantBits()); byte[] mockScanRecord = Arrays.copyOf(mockScanRecordBuffer.array(), mockScanRecordBuffer.position()); Scanner.NewDeviceFoundListener listener = Mockito.mock(Scanner.NewDeviceFoundListener.class); TEST_CONFIGURATION.setNewDeviceFoundListener(listener); ArgumentCaptor<BluetoothAdapter.LeScanCallback> callbackCaptor = ArgumentCaptor.forClass(BluetoothAdapter.LeScanCallback.class); BluetoothAdapter testAdapter = Mockito.mock(BluetoothAdapter.class); LolipopLEScanner scanner = new LolipopLEScanner(TEST_CONFIGURATION); scanner.onStart(testAdapter, 0); Mockito.verify(testAdapter).startLeScan(callbackCaptor.capture()); callbackCaptor.getValue().onLeScan(Mockito.mock(BluetoothDevice.class), -10, mockScanRecord); }
@Override @SuppressWarnings({"SpellCheckingInspection", "deprecation"}) protected void onStart(BluetoothAdapter adapter, int scanMode) { boolean ret; UUID uuids[] = scannerConfiguration.getServiceUUIDs(); if (uuids.length > 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ret = adapter.startLeScan(uuids, callback); } else { ret = adapter.startLeScan(callback); } if (ret) { NeatleLogger.d("Bluetooth LE scan started."); } else { NeatleLogger.i("Bluetooth LE scan failed to start. State = " + adapter.getState()); } }
LolipopLEScanner extends BaseScanner { @Override @SuppressWarnings({"SpellCheckingInspection", "deprecation"}) protected void onStart(BluetoothAdapter adapter, int scanMode) { boolean ret; UUID uuids[] = scannerConfiguration.getServiceUUIDs(); if (uuids.length > 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ret = adapter.startLeScan(uuids, callback); } else { ret = adapter.startLeScan(callback); } if (ret) { NeatleLogger.d("Bluetooth LE scan started."); } else { NeatleLogger.i("Bluetooth LE scan failed to start. State = " + adapter.getState()); } } }
LolipopLEScanner extends BaseScanner { @Override @SuppressWarnings({"SpellCheckingInspection", "deprecation"}) protected void onStart(BluetoothAdapter adapter, int scanMode) { boolean ret; UUID uuids[] = scannerConfiguration.getServiceUUIDs(); if (uuids.length > 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ret = adapter.startLeScan(uuids, callback); } else { ret = adapter.startLeScan(callback); } if (ret) { NeatleLogger.d("Bluetooth LE scan started."); } else { NeatleLogger.i("Bluetooth LE scan failed to start. State = " + adapter.getState()); } } LolipopLEScanner(ScannerConfiguration settings); }
LolipopLEScanner extends BaseScanner { @Override @SuppressWarnings({"SpellCheckingInspection", "deprecation"}) protected void onStart(BluetoothAdapter adapter, int scanMode) { boolean ret; UUID uuids[] = scannerConfiguration.getServiceUUIDs(); if (uuids.length > 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ret = adapter.startLeScan(uuids, callback); } else { ret = adapter.startLeScan(callback); } if (ret) { NeatleLogger.d("Bluetooth LE scan started."); } else { NeatleLogger.i("Bluetooth LE scan failed to start. State = " + adapter.getState()); } } LolipopLEScanner(ScannerConfiguration settings);  }
LolipopLEScanner extends BaseScanner { @Override @SuppressWarnings({"SpellCheckingInspection", "deprecation"}) protected void onStart(BluetoothAdapter adapter, int scanMode) { boolean ret; UUID uuids[] = scannerConfiguration.getServiceUUIDs(); if (uuids.length > 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ret = adapter.startLeScan(uuids, callback); } else { ret = adapter.startLeScan(callback); } if (ret) { NeatleLogger.d("Bluetooth LE scan started."); } else { NeatleLogger.i("Bluetooth LE scan failed to start. State = " + adapter.getState()); } } LolipopLEScanner(ScannerConfiguration settings);   }