Search in sources :

Example 86 with ParcelUuid

use of android.os.ParcelUuid in project platform_frameworks_base by android.

the class AdvertiseDataTest method testManufacturerData.

@SmallTest
public void testManufacturerData() {
    Parcel parcel = Parcel.obtain();
    ParcelUuid uuid = ParcelUuid.fromString("0000110A-0000-1000-8000-00805F9B34FB");
    ParcelUuid uuid2 = ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB");
    int manufacturerId = 50;
    byte[] manufacturerData = new byte[] { (byte) 0xF0, 0x00, 0x02, 0x15 };
    AdvertiseData data = mAdvertiseDataBuilder.setIncludeDeviceName(true).addServiceUuid(uuid).addServiceUuid(uuid2).addManufacturerData(manufacturerId, manufacturerData).build();
    data.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    AdvertiseData dataFromParcel = AdvertiseData.CREATOR.createFromParcel(parcel);
    assertEquals(data, dataFromParcel);
}
Also used : ParcelUuid(android.os.ParcelUuid) Parcel(android.os.Parcel) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 87 with ParcelUuid

use of android.os.ParcelUuid in project platform_frameworks_base by android.

the class AdvertiseDataTest method testServiceData.

@SmallTest
public void testServiceData() {
    Parcel parcel = Parcel.obtain();
    ParcelUuid uuid = ParcelUuid.fromString("0000110A-0000-1000-8000-00805F9B34FB");
    byte[] serviceData = new byte[] { (byte) 0xF0, 0x00, 0x02, 0x15 };
    AdvertiseData data = mAdvertiseDataBuilder.setIncludeDeviceName(true).addServiceData(uuid, serviceData).build();
    data.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    AdvertiseData dataFromParcel = AdvertiseData.CREATOR.createFromParcel(parcel);
    assertEquals(data, dataFromParcel);
}
Also used : ParcelUuid(android.os.ParcelUuid) Parcel(android.os.Parcel) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 88 with ParcelUuid

use of android.os.ParcelUuid in project platform_frameworks_base by android.

the class AdvertiseDataTest method testEmptyServiceData.

@SmallTest
public void testEmptyServiceData() {
    Parcel parcel = Parcel.obtain();
    ParcelUuid uuid = ParcelUuid.fromString("0000110A-0000-1000-8000-00805F9B34FB");
    byte[] serviceData = new byte[0];
    AdvertiseData data = mAdvertiseDataBuilder.setIncludeDeviceName(true).addServiceData(uuid, serviceData).build();
    data.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    AdvertiseData dataFromParcel = AdvertiseData.CREATOR.createFromParcel(parcel);
    assertEquals(data, dataFromParcel);
}
Also used : ParcelUuid(android.os.ParcelUuid) Parcel(android.os.Parcel) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 89 with ParcelUuid

use of android.os.ParcelUuid in project platform_frameworks_base by android.

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)

Example 90 with ParcelUuid

use of android.os.ParcelUuid in project platform_frameworks_base by android.

the class ScanFilterTest method testsetServiceDataFilter.

@SmallTest
public void testsetServiceDataFilter() {
    byte[] setServiceData = new byte[] { 0x50, 0x64 };
    ParcelUuid serviceDataUuid = ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB");
    ScanFilter filter = mFilterBuilder.setServiceData(serviceDataUuid, setServiceData).build();
    assertTrue("service data filter fails", filter.matches(mScanResult));
    byte[] emptyData = new byte[0];
    filter = mFilterBuilder.setServiceData(serviceDataUuid, emptyData).build();
    assertTrue("service data filter fails", filter.matches(mScanResult));
    byte[] prefixData = new byte[] { 0x50 };
    filter = mFilterBuilder.setServiceData(serviceDataUuid, prefixData).build();
    assertTrue("service data filter fails", filter.matches(mScanResult));
    byte[] nonMatchData = new byte[] { 0x51, 0x64 };
    byte[] mask = new byte[] { (byte) 0x00, (byte) 0xFF };
    filter = mFilterBuilder.setServiceData(serviceDataUuid, nonMatchData, mask).build();
    assertTrue("partial service data filter fails", filter.matches(mScanResult));
    filter = mFilterBuilder.setServiceData(serviceDataUuid, nonMatchData).build();
    assertFalse("service data filter fails", filter.matches(mScanResult));
}
Also used : ParcelUuid(android.os.ParcelUuid) ScanFilter(android.bluetooth.le.ScanFilter) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

ParcelUuid (android.os.ParcelUuid)147 SmallTest (android.test.suitebuilder.annotation.SmallTest)43 RemoteException (android.os.RemoteException)29 UUID (java.util.UUID)24 ArrayList (java.util.ArrayList)23 GenericSoundModel (android.hardware.soundtrigger.SoundTrigger.GenericSoundModel)20 Parcel (android.os.Parcel)20 ScanFilter (android.bluetooth.le.ScanFilter)19 RecognitionConfig (android.hardware.soundtrigger.SoundTrigger.RecognitionConfig)12 LargeTest (android.test.suitebuilder.annotation.LargeTest)12 ScanRecord (android.bluetooth.le.ScanRecord)10 BluetoothDevice (android.bluetooth.BluetoothDevice)9 Socket (java.net.Socket)9 DataOutputStream (java.io.DataOutputStream)8 ByteBuffer (java.nio.ByteBuffer)8 SparseArray (android.util.SparseArray)6 RequiresPermission (android.annotation.RequiresPermission)5 BluetoothClass (android.bluetooth.BluetoothClass)5 BluetoothLeScanner (android.bluetooth.le.BluetoothLeScanner)5 ScanCallback (android.bluetooth.le.ScanCallback)5