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);
}
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);
}
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);
}
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);
}
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));
}
Aggregations