summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2021-04-20 03:31:28 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-04-20 03:31:28 +0000
commit2b8dce1db14c39c27767ac63e54e3613e82b75fb (patch)
treee1064cf0f67aed58f18f0bc87c927c6c70e96239 /core/java
parent37ae0fceaa82ea41b5d422f2f84e7a497dcd112a (diff)
parentda5eb08ae3641dfa7b93ce126c0c764f5a571b97 (diff)
Merge "Set a floor value for BLE Batch Scan report delay of 5000ms" am: ce2a2c80dd am: da5eb08ae3
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1676810 Change-Id: Ia8dc4c371e4c1c082c22e58eff0825f156717625
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/bluetooth/le/ScanSettings.java29
1 files changed, 23 insertions, 6 deletions
diff --git a/core/java/android/bluetooth/le/ScanSettings.java b/core/java/android/bluetooth/le/ScanSettings.java
index 368d1eecade4..f3e971a0bb30 100644
--- a/core/java/android/bluetooth/le/ScanSettings.java
+++ b/core/java/android/bluetooth/le/ScanSettings.java
@@ -20,6 +20,7 @@ import android.annotation.SystemApi;
import android.bluetooth.BluetoothDevice;
import android.os.Parcel;
import android.os.Parcelable;
+import android.provider.DeviceConfig;
/**
* Bluetooth LE scan settings are passed to {@link BluetoothLeScanner#startScan} to define the
@@ -141,6 +142,12 @@ public final class ScanSettings implements Parcelable {
*/
public static final int PHY_LE_ALL_SUPPORTED = 255;
+ /**
+ * The default floor value for report delays greater than 0 in
+ * {@link Builder#setReportDelay(long)}.
+ */
+ private static final long DEFAULT_REPORT_DELAY_FLOOR = 5000;
+
// Bluetooth LE scan mode.
private int mScanMode;
@@ -345,18 +352,28 @@ public final class ScanSettings implements Parcelable {
}
/**
- * Set report delay timestamp for Bluetooth LE scan.
+ * Set report delay timestamp for Bluetooth LE scan. If set to 0, you will be notified of
+ * scan results immediately. If &gt; 0, scan results are queued up and delivered after the
+ * requested delay or 5000 milliseconds (whichever is higher). Note scan results may be
+ * delivered sooner if the internal buffers fill up.
*
- * @param reportDelayMillis Delay of report in milliseconds. 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 reportDelayMillis} &lt; 0.
+ * @param reportDelayMillis how frequently scan results should be delivered in
+ * milliseconds
+ * @throws IllegalArgumentException if {@code reportDelayMillis} &lt; 0
*/
public Builder setReportDelay(long reportDelayMillis) {
if (reportDelayMillis < 0) {
throw new IllegalArgumentException("reportDelay must be > 0");
}
- mReportDelayMillis = reportDelayMillis;
+
+ long floor = DeviceConfig.getLong(DeviceConfig.NAMESPACE_BLUETOOTH, "report_delay",
+ DEFAULT_REPORT_DELAY_FLOOR);
+
+ if (reportDelayMillis > 0 && reportDelayMillis < floor) {
+ mReportDelayMillis = floor;
+ } else {
+ mReportDelayMillis = reportDelayMillis;
+ }
return this;
}