summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/le/ScanSettings.java
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
commit0afb91d1a96bb0068f9b32ec9a99f8391feb5537 (patch)
tree8b28a67077d0d46b2e850a9cd6d947e20e7ecc03 /framework/java/android/bluetooth/le/ScanSettings.java
parent23bde57df4ffc46f8d518f775c2367bda84c78e3 (diff)
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 'framework/java/android/bluetooth/le/ScanSettings.java')
-rw-r--r--framework/java/android/bluetooth/le/ScanSettings.java34
1 files changed, 21 insertions, 13 deletions
diff --git a/framework/java/android/bluetooth/le/ScanSettings.java b/framework/java/android/bluetooth/le/ScanSettings.java
index 20977026d3..2f86d09ec0 100644
--- a/framework/java/android/bluetooth/le/ScanSettings.java
+++ b/framework/java/android/bluetooth/le/ScanSettings.java
@@ -45,7 +45,7 @@ public final class ScanSettings implements Parcelable {
public static final int SCAN_MODE_LOW_LATENCY = 2;
/**
- * Triggger a callback for every Bluetooth advertisement found that matches the
+ * Trigger a callback for every Bluetooth advertisement found that matches the
* filter criteria. If no filter is active, all advertisement packets are reported.
*/
public static final int CALLBACK_TYPE_ALL_MATCHES = 1;
@@ -87,7 +87,7 @@ public final class ScanSettings implements Parcelable {
private int mScanResultType;
// Time of delay for reporting the scan result
- private long mReportDelaySeconds;
+ private long mReportDelayMillis;
public int getScanMode() {
return mScanMode;
@@ -104,8 +104,8 @@ public final class ScanSettings implements Parcelable {
/**
* Returns report delay timestamp based on the device clock.
*/
- public long getReportDelaySeconds() {
- return mReportDelaySeconds;
+ public long getReportDelayMillis() {
+ return mReportDelayMillis;
}
private ScanSettings(int scanMode, int callbackType, int scanResultType,
@@ -113,14 +113,14 @@ public final class ScanSettings implements Parcelable {
mScanMode = scanMode;
mCallbackType = callbackType;
mScanResultType = scanResultType;
- mReportDelaySeconds = reportDelaySeconds;
+ mReportDelayMillis = reportDelaySeconds;
}
private ScanSettings(Parcel in) {
mScanMode = in.readInt();
mCallbackType = in.readInt();
mScanResultType = in.readInt();
- mReportDelaySeconds = in.readLong();
+ mReportDelayMillis = in.readLong();
}
@Override
@@ -128,7 +128,7 @@ public final class ScanSettings implements Parcelable {
dest.writeInt(mScanMode);
dest.writeInt(mCallbackType);
dest.writeInt(mScanResultType);
- dest.writeLong(mReportDelaySeconds);
+ dest.writeLong(mReportDelayMillis);
}
@Override
@@ -136,6 +136,9 @@ public final class ScanSettings implements Parcelable {
return 0;
}
+ /**
+ * @hide
+ */
public static final Parcelable.Creator<ScanSettings>
CREATOR = new Creator<ScanSettings>() {
@Override
@@ -156,7 +159,7 @@ public final class ScanSettings implements Parcelable {
private int mScanMode = SCAN_MODE_LOW_POWER;
private int mCallbackType = CALLBACK_TYPE_ALL_MATCHES;
private int mScanResultType = SCAN_RESULT_TYPE_FULL;
- private long mReportDelaySeconds = 0;
+ private long mReportDelayMillis = 0;
/**
* Set scan mode for Bluetooth LE scan.
@@ -212,13 +215,18 @@ public final class ScanSettings implements Parcelable {
/**
* Set report delay timestamp for Bluetooth LE scan.
- * @param reportDelaySeconds Set to 0 to be notified of results immediately.
- * Values &gt;0 causes the scan results to be queued
+ * @param reportDelayMillis Set to 0 to be notified of results immediately.
+ * Values &gt; 0 causes the scan results to be queued
* up and delivered after the requested delay or when
* the internal buffers fill up.
+ * @throws IllegalArgumentException If {@code reportDelaySeconds} &lt; 0.
+ *
*/
- public Builder setReportDelaySeconds(long reportDelaySeconds) {
- mReportDelaySeconds = reportDelaySeconds;
+ public Builder setReportDelayMillis(long reportDelayMillis) {
+ if (reportDelayMillis < 0) {
+ throw new IllegalArgumentException("reportDelaySeconds must be > 0");
+ }
+ mReportDelayMillis = reportDelayMillis;
return this;
}
@@ -227,7 +235,7 @@ public final class ScanSettings implements Parcelable {
*/
public ScanSettings build() {
return new ScanSettings(mScanMode, mCallbackType, mScanResultType,
- mReportDelaySeconds);
+ mReportDelayMillis);
}
}
}