Search in sources :

Example 36 with ScanFilter

use of android.bluetooth.le.ScanFilter in project android_wear_for_ios by shiitakeo.

the class BLEService method create_scan_filter.

@TargetApi(21)
private List<ScanFilter> create_scan_filter() {
    //        ScanFilter filter = new ScanFilter.Builder().setServiceUuid(ParcelUuid.fromString(service_ancs)).build();
    ScanFilter filter = new ScanFilter.Builder().setServiceUuid(ParcelUuid.fromString(service_blank)).build();
    List<ScanFilter> list = new ArrayList<ScanFilter>(1);
    list.add(filter);
    return list;
}
Also used : ScanFilter(android.bluetooth.le.ScanFilter) ArrayList(java.util.ArrayList) TargetApi(android.annotation.TargetApi)

Example 37 with ScanFilter

use of android.bluetooth.le.ScanFilter in project android_frameworks_base by AOSPA.

the class ScanFilterTest method testDeviceFilter.

@SmallTest
public void testDeviceFilter() {
    ScanFilter filter = mFilterBuilder.setDeviceAddress(DEVICE_MAC).build();
    assertTrue("device filter fails", filter.matches(mScanResult));
    filter = mFilterBuilder.setDeviceAddress("11:22:33:44:55:66").build();
    assertFalse("device filter fails", filter.matches(mScanResult));
}
Also used : ScanFilter(android.bluetooth.le.ScanFilter) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 38 with ScanFilter

use of android.bluetooth.le.ScanFilter in project android_frameworks_base by AOSPA.

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));
}
Also used : ScanFilter(android.bluetooth.le.ScanFilter) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 39 with ScanFilter

use of android.bluetooth.le.ScanFilter in project android_frameworks_base by AOSPA.

the class ScanFilterTest method testReadWriteParcelForFilter.

private void testReadWriteParcelForFilter(ScanFilter filter) {
    Parcel parcel = Parcel.obtain();
    filter.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    ScanFilter filterFromParcel = ScanFilter.CREATOR.createFromParcel(parcel);
    assertEquals(filter, filterFromParcel);
}
Also used : Parcel(android.os.Parcel) ScanFilter(android.bluetooth.le.ScanFilter)

Example 40 with ScanFilter

use of android.bluetooth.le.ScanFilter in project android_frameworks_base by AOSPA.

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);
}
Also used : ParcelUuid(android.os.ParcelUuid) ScanFilter(android.bluetooth.le.ScanFilter) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

ScanFilter (android.bluetooth.le.ScanFilter)52 SmallTest (android.test.suitebuilder.annotation.SmallTest)30 ParcelUuid (android.os.ParcelUuid)19 ScanSettings (android.bluetooth.le.ScanSettings)11 BluetoothLeScanner (android.bluetooth.le.BluetoothLeScanner)10 ArrayList (java.util.ArrayList)9 RequiresPermission (android.annotation.RequiresPermission)5 TargetApi (android.annotation.TargetApi)5 ScanCallback (android.bluetooth.le.ScanCallback)5 ScanRecord (android.bluetooth.le.ScanRecord)5 ScanResult (android.bluetooth.le.ScanResult)5 Message (android.os.Message)5 Parcel (android.os.Parcel)5 RemoteException (android.os.RemoteException)5 UUID (java.util.UUID)5 NonNull (android.support.annotation.NonNull)3 QueryBuilder (de.greenrobot.dao.query.QueryBuilder)2 BeaconParser (org.altbeacon.beacon.BeaconParser)1