use of android.bluetooth.le.ScanFilter in project android_frameworks_base by AOSPA.
the class ScanFilterTest method testsetNameFilter.
@SmallTest
public void testsetNameFilter() {
ScanFilter filter = mFilterBuilder.setDeviceName("Ped").build();
assertTrue("setName filter fails", filter.matches(mScanResult));
filter = mFilterBuilder.setDeviceName("Pem").build();
assertFalse("setName filter fails", filter.matches(mScanResult));
}
use of android.bluetooth.le.ScanFilter in project android_frameworks_base by ResurrectionRemix.
the class KeyboardUI method startScanning.
private void startScanning() {
BluetoothLeScanner scanner = mLocalBluetoothAdapter.getBluetoothLeScanner();
ScanFilter filter = (new ScanFilter.Builder()).setDeviceName(mKeyboardName).build();
ScanSettings settings = (new ScanSettings.Builder()).setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES).setNumOfMatches(ScanSettings.MATCH_NUM_ONE_ADVERTISEMENT).setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).setReportDelay(0).build();
mScanCallback = new KeyboardScanCallback();
scanner.startScan(Arrays.asList(filter), settings, mScanCallback);
Message abortMsg = mHandler.obtainMessage(MSG_BLE_ABORT_SCAN, ++mScanAttempt, 0);
mHandler.sendMessageDelayed(abortMsg, BLUETOOTH_SCAN_TIMEOUT_MILLIS);
}
use of android.bluetooth.le.ScanFilter in project android_frameworks_base by ResurrectionRemix.
the class ScanFilterTest method testsetNameFilter.
@SmallTest
public void testsetNameFilter() {
ScanFilter filter = mFilterBuilder.setDeviceName("Ped").build();
assertTrue("setName filter fails", filter.matches(mScanResult));
filter = mFilterBuilder.setDeviceName("Pem").build();
assertFalse("setName filter fails", filter.matches(mScanResult));
}
use of android.bluetooth.le.ScanFilter in project android_frameworks_base by DirtyUnicorns.
the class ScanFilterTest method testsetServiceUuidFilter.
@SmallTest
public void testsetServiceUuidFilter() {
ScanFilter filter = mFilterBuilder.setServiceUuid(ParcelUuid.fromString("0000110A-0000-1000-8000-00805F9B34FB")).build();
assertTrue("uuid filter fails", filter.matches(mScanResult));
filter = mFilterBuilder.setServiceUuid(ParcelUuid.fromString("0000110C-0000-1000-8000-00805F9B34FB")).build();
assertFalse("uuid filter fails", filter.matches(mScanResult));
filter = mFilterBuilder.setServiceUuid(ParcelUuid.fromString("0000110C-0000-1000-8000-00805F9B34FB"), ParcelUuid.fromString("FFFFFFF0-FFFF-FFFF-FFFF-FFFFFFFFFFFF")).build();
assertTrue("uuid filter fails", filter.matches(mScanResult));
}
use of android.bluetooth.le.ScanFilter in project android_frameworks_base by DirtyUnicorns.
the class ScanFilterTest method testReadWriteParcel.
@SmallTest
public void testReadWriteParcel() {
ScanFilter filter = mFilterBuilder.build();
testReadWriteParcelForFilter(filter);
filter = mFilterBuilder.setDeviceName("Ped").build();
testReadWriteParcelForFilter(filter);
filter = mFilterBuilder.setDeviceAddress("11:22:33:44:55:66").build();
testReadWriteParcelForFilter(filter);
filter = mFilterBuilder.setServiceUuid(ParcelUuid.fromString("0000110C-0000-1000-8000-00805F9B34FB")).build();
testReadWriteParcelForFilter(filter);
filter = mFilterBuilder.setServiceUuid(ParcelUuid.fromString("0000110C-0000-1000-8000-00805F9B34FB"), ParcelUuid.fromString("FFFFFFF0-FFFF-FFFF-FFFF-FFFFFFFFFFFF")).build();
testReadWriteParcelForFilter(filter);
byte[] serviceData = new byte[] { 0x50, 0x64 };
ParcelUuid serviceDataUuid = ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB");
filter = mFilterBuilder.setServiceData(serviceDataUuid, serviceData).build();
testReadWriteParcelForFilter(filter);
filter = mFilterBuilder.setServiceData(serviceDataUuid, new byte[0]).build();
testReadWriteParcelForFilter(filter);
byte[] serviceDataMask = new byte[] { (byte) 0xFF, (byte) 0xFF };
filter = mFilterBuilder.setServiceData(serviceDataUuid, serviceData, serviceDataMask).build();
testReadWriteParcelForFilter(filter);
byte[] manufacturerData = new byte[] { 0x02, 0x15 };
int manufacturerId = 0xE0;
filter = mFilterBuilder.setManufacturerData(manufacturerId, manufacturerData).build();
testReadWriteParcelForFilter(filter);
filter = mFilterBuilder.setServiceData(serviceDataUuid, new byte[0]).build();
testReadWriteParcelForFilter(filter);
byte[] manufacturerDataMask = new byte[] { (byte) 0xFF, (byte) 0xFF };
filter = mFilterBuilder.setManufacturerData(manufacturerId, manufacturerData, manufacturerDataMask).build();
testReadWriteParcelForFilter(filter);
}
Aggregations