summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/le/ScanSettings.java
diff options
context:
space:
mode:
authorKai Shi <kaishi@google.com>2022-01-20 10:42:58 -0800
committerKai Shi <kaishi@google.com>2022-01-24 08:53:51 -0800
commit529d622d9976da1191c3d415bf3e882580955339 (patch)
tree9da98a0c35fc2896d663c93b7016dbaed7efed6f /framework/java/android/bluetooth/le/ScanSettings.java
parent0ade88c6039fb491f54d95e50edb45984be2c883 (diff)
BLE scan time optimization
BLE scan time optimization to reduce scan latency: 1)Reduce scan interval and window for low power, balanced and ambient scan modes. Balanced and ambient modes now have effectively the same settings. 2)Add screen off and screen off balanced modes with longer interval for the internal use. 3)For regular apps: Foregroud: original scan mode. Background + screen on: low power mode. Screen off: screen off mode. For foreground service: Screen on: original scan mode. Scree off: fall back to screen off/screen off balanced mode unless it requests low latency mode. 4)When App requests a new scan without recent request, its scan mode is upgraded temporarily for 6 seconds (configurable). Tag: #feature Bug: 214595841 Test: Run scan in low power, low latency and balanced scan modes with filtered and unfiltered settings both continuously and periodically. Make sure the scan mode is set correctly during screen on/off transition and background/foreground transition. Tested with multiple scan clients from both test app and other service apps. Change-Id: I291a1a80f24d431b681aae485692241dfb474c5a
Diffstat (limited to 'framework/java/android/bluetooth/le/ScanSettings.java')
-rw-r--r--framework/java/android/bluetooth/le/ScanSettings.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/le/ScanSettings.java b/framework/java/android/bluetooth/le/ScanSettings.java
index 1aa7cb5111..1f9d4caec5 100644
--- a/framework/java/android/bluetooth/le/ScanSettings.java
+++ b/framework/java/android/bluetooth/le/ScanSettings.java
@@ -62,6 +62,23 @@ public final class ScanSettings implements Parcelable {
public static final int SCAN_MODE_AMBIENT_DISCOVERY = 3;
/**
+ * Default Bluetooth LE scan mode when the screen is off.
+ * This mode has the low duty cycle and long scan interval which results in the lowest
+ * power consumption among all modes. It is for the framework internal use only.
+ *
+ * @hide
+ */
+ public static final int SCAN_MODE_SCREEN_OFF = 4;
+
+ /**
+ * Balanced Bluetooth LE scan mode for foreground service when the screen is off.
+ * It is for the framework internal use only.
+ *
+ * @hide
+ */
+ public static final int SCAN_MODE_SCREEN_OFF_BALANCED = 5;
+
+ /**
* Trigger a callback for every Bluetooth advertisement found that matches the filter criteria.
* If no filter is active, all advertisement packets are reported.
*/
@@ -292,6 +309,8 @@ public final class ScanSettings implements Parcelable {
case SCAN_MODE_BALANCED:
case SCAN_MODE_LOW_LATENCY:
case SCAN_MODE_AMBIENT_DISCOVERY:
+ case SCAN_MODE_SCREEN_OFF:
+ case SCAN_MODE_SCREEN_OFF_BALANCED:
mScanMode = scanMode;
break;
default: