Search in sources :

Example 1 with ScanFilter

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

the class MusicControlActivity 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_ams)).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 2 with ScanFilter

use of android.bluetooth.le.ScanFilter in project platform_frameworks_base by android.

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 3 with ScanFilter

use of android.bluetooth.le.ScanFilter in project platform_frameworks_base by android.

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

Example 4 with ScanFilter

use of android.bluetooth.le.ScanFilter in project platform_frameworks_base by android.

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

Example 5 with ScanFilter

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

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)

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