summaryrefslogtreecommitdiffstats
path: root/core/tests/bluetoothtests
diff options
context:
space:
mode:
authorWei Wang <weiwa@google.com>2014-07-16 22:02:03 -0700
committerWei Wang <weiwa@google.com>2014-07-18 18:31:00 -0700
commit685c1758902a42a7beb030d8bbaed3f7ce6f6135 (patch)
treefdfdd29cb1811dc47f9179bf0392d6c1e279b9f9 /core/tests/bluetoothtests
parent3d63a9c7cd3f03ebcf67cc1bc3d53ada8a6ef577 (diff)
downloadframeworks_base-685c1758902a42a7beb030d8bbaed3f7ce6f6135.zip
frameworks_base-685c1758902a42a7beb030d8bbaed3f7ce6f6135.tar.gz
frameworks_base-685c1758902a42a7beb030d8bbaed3f7ce6f6135.tar.bz2
More API modification of BLE APIs (1/2).
Changed include: 1) Add serviceDataUuid to filter so it matches sanRecord and AdvertiseData. 2) Add raw bytes to ScanRecord and make ScanResult take a ScanRecord instead of raw bytes. 3) Change from setServiceUuid(List) to addServiceUuid(ParcelUuid). 4) Added include device name 5) Removed service not registered and added ADVERTISE_DATA_TOO_LARGE. 6) Fixed a few comments. Change-Id: Ibbe07183b1293835c4a84728d1cd2d61e5d627d3
Diffstat (limited to 'core/tests/bluetoothtests')
-rw-r--r--core/tests/bluetoothtests/src/android/bluetooth/le/ScanFilterTest.java18
-rw-r--r--core/tests/bluetoothtests/src/android/bluetooth/le/ScanResultTest.java3
2 files changed, 14 insertions, 7 deletions
diff --git a/core/tests/bluetoothtests/src/android/bluetooth/le/ScanFilterTest.java b/core/tests/bluetoothtests/src/android/bluetooth/le/ScanFilterTest.java
index e0a3a03..25ea227 100644
--- a/core/tests/bluetoothtests/src/android/bluetooth/le/ScanFilterTest.java
+++ b/core/tests/bluetoothtests/src/android/bluetooth/le/ScanFilterTest.java
@@ -18,6 +18,8 @@ package android.bluetooth.le;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
+import android.bluetooth.le.ScanFilter;
+import android.bluetooth.le.ScanRecord;
import android.os.Parcel;
import android.os.ParcelUuid;
import android.test.suitebuilder.annotation.SmallTest;
@@ -50,7 +52,8 @@ public class ScanFilterTest extends TestCase {
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
BluetoothDevice device = adapter.getRemoteDevice(DEVICE_MAC);
- mScanResult = new ScanResult(device, scanRecord, -10, 1397545200000000L);
+ mScanResult = new ScanResult(device, ScanRecord.parseFromBytes(scanRecord),
+ -10, 1397545200000000L);
mFilterBuilder = new ScanFilter.Builder();
}
@@ -94,17 +97,18 @@ public class ScanFilterTest extends TestCase {
public void testsetServiceDataFilter() {
byte[] setServiceData = new byte[] {
0x0b, 0x11, 0x50, 0x64 };
- ScanFilter filter = mFilterBuilder.setServiceData(setServiceData).build();
+ 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[] nonMatchData = new byte[] {
0x0b, 0x01, 0x50, 0x64 };
- filter = mFilterBuilder.setServiceData(nonMatchData).build();
+ filter = mFilterBuilder.setServiceData(serviceDataUuid, nonMatchData).build();
assertFalse("service data filter fails", filter.matches(mScanResult));
byte[] mask = new byte[] {
(byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0xFF };
- filter = mFilterBuilder.setServiceData(nonMatchData, mask).build();
+ filter = mFilterBuilder.setServiceData(serviceDataUuid, nonMatchData, mask).build();
assertTrue("partial service data filter fails", filter.matches(mScanResult));
}
@@ -152,12 +156,14 @@ public class ScanFilterTest extends TestCase {
byte[] setServiceData = new byte[] {
0x0b, 0x11, 0x50, 0x64 };
- filter = mFilterBuilder.setServiceData(setServiceData).build();
+ ParcelUuid serviceDataUuid = ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB");
+ filter = mFilterBuilder.setServiceData(serviceDataUuid, setServiceData).build();
testReadWriteParcelForFilter(filter);
byte[] serviceDataMask = new byte[] {
(byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0xFF };
- filter = mFilterBuilder.setServiceData(setServiceData, serviceDataMask).build();
+ filter = mFilterBuilder.setServiceData(serviceDataUuid, setServiceData, serviceDataMask)
+ .build();
testReadWriteParcelForFilter(filter);
byte[] manufacturerData = new byte[] {
diff --git a/core/tests/bluetoothtests/src/android/bluetooth/le/ScanResultTest.java b/core/tests/bluetoothtests/src/android/bluetooth/le/ScanResultTest.java
index 241e88f..01d5c59 100644
--- a/core/tests/bluetoothtests/src/android/bluetooth/le/ScanResultTest.java
+++ b/core/tests/bluetoothtests/src/android/bluetooth/le/ScanResultTest.java
@@ -43,7 +43,8 @@ public class ScanResultTest extends TestCase {
int rssi = -10;
long timestampMicros = 10000L;
- ScanResult result = new ScanResult(device, scanRecord, rssi, timestampMicros);
+ ScanResult result = new ScanResult(device, ScanRecord.parseFromBytes(scanRecord), rssi,
+ timestampMicros);
Parcel parcel = Parcel.obtain();
result.writeToParcel(parcel, 0);
// Need to reset parcel data position to the beginning.