Merge "Set a floor value for BLE Batch Scan report delay of 5000ms"
This commit is contained in:
@@ -20,6 +20,7 @@ import android.annotation.SystemApi;
|
|||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.provider.DeviceConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bluetooth LE scan settings are passed to {@link BluetoothLeScanner#startScan} to define the
|
* 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;
|
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.
|
// Bluetooth LE scan mode.
|
||||||
private int mScanMode;
|
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 > 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
|
* @param reportDelayMillis how frequently scan results should be delivered in
|
||||||
* results immediately. Values > 0 causes the scan results to be queued up and delivered
|
* milliseconds
|
||||||
* after the requested delay or when the internal buffers fill up.
|
* @throws IllegalArgumentException if {@code reportDelayMillis} < 0
|
||||||
* @throws IllegalArgumentException If {@code reportDelayMillis} < 0.
|
|
||||||
*/
|
*/
|
||||||
public Builder setReportDelay(long reportDelayMillis) {
|
public Builder setReportDelay(long reportDelayMillis) {
|
||||||
if (reportDelayMillis < 0) {
|
if (reportDelayMillis < 0) {
|
||||||
throw new IllegalArgumentException("reportDelay must be > 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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user