use of android.bluetooth.le.ScanFilter in project android_frameworks_base by crdroidandroid.
the class ScanFilterTest method testManufacturerSpecificData.
@SmallTest
public void testManufacturerSpecificData() {
byte[] setManufacturerData = new byte[] { 0x02, 0x15 };
int manufacturerId = 0xE0;
ScanFilter filter = mFilterBuilder.setManufacturerData(manufacturerId, setManufacturerData).build();
assertTrue("manufacturer data filter fails", filter.matches(mScanResult));
byte[] emptyData = new byte[0];
filter = mFilterBuilder.setManufacturerData(manufacturerId, emptyData).build();
assertTrue("manufacturer data filter fails", filter.matches(mScanResult));
byte[] prefixData = new byte[] { 0x02 };
filter = mFilterBuilder.setManufacturerData(manufacturerId, prefixData).build();
assertTrue("manufacturer data filter fails", filter.matches(mScanResult));
// Test data mask
byte[] nonMatchData = new byte[] { 0x02, 0x14 };
filter = mFilterBuilder.setManufacturerData(manufacturerId, nonMatchData).build();
assertFalse("manufacturer data filter fails", filter.matches(mScanResult));
byte[] mask = new byte[] { (byte) 0xFF, (byte) 0x00 };
filter = mFilterBuilder.setManufacturerData(manufacturerId, nonMatchData, mask).build();
assertTrue("partial setManufacturerData filter fails", filter.matches(mScanResult));
}
use of android.bluetooth.le.ScanFilter in project android_frameworks_base by crdroidandroid.
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));
}
Aggregations