diff options
| author | Chienyuan Huang <chienyuanhuang@google.com> | 2021-03-20 01:06:24 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-03-20 01:06:24 +0000 |
| commit | fedc9228f386d8e1e7487c1ea2386617cc770d1e (patch) | |
| tree | 87f0836089c4b7ccd2a33ca0ba57592716573f6d /core/java | |
| parent | f26d63feb39f4bd7038a26c32592893dee339c06 (diff) | |
| parent | c1b4ca0ef55d93cfdcea1860de16112c77b3ac4a (diff) | |
Merge "Le Scan: Add ambient discovery mode (1/2)" am: 4a47532570 am: c1b4ca0ef5
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1629277
Change-Id: I2dd373dc17b677d5d707d8112d69a04dd50ae101
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/bluetooth/le/ScanSettings.java | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/core/java/android/bluetooth/le/ScanSettings.java b/core/java/android/bluetooth/le/ScanSettings.java index 504118ec5da8..368d1eecade4 100644 --- a/core/java/android/bluetooth/le/ScanSettings.java +++ b/core/java/android/bluetooth/le/ScanSettings.java @@ -52,6 +52,16 @@ public final class ScanSettings implements Parcelable { public static final int SCAN_MODE_LOW_LATENCY = 2; /** + * Perform Bluetooth LE scan in ambient discovery mode. This mode has lower duty cycle and more + * aggressive scan interval than balanced mode that provides a good trade-off between scan + * latency and power consumption. + * + * @hide + */ + @SystemApi + public static final int SCAN_MODE_AMBIENT_DISCOVERY = 3; + + /** * Trigger a callback for every Bluetooth advertisement found that matches the filter criteria. * If no filter is active, all advertisement packets are reported. */ @@ -276,10 +286,17 @@ public final class ScanSettings implements Parcelable { * @throws IllegalArgumentException If the {@code scanMode} is invalid. */ public Builder setScanMode(int scanMode) { - if (scanMode < SCAN_MODE_OPPORTUNISTIC || scanMode > SCAN_MODE_LOW_LATENCY) { - throw new IllegalArgumentException("invalid scan mode " + scanMode); + switch (scanMode) { + case SCAN_MODE_OPPORTUNISTIC: + case SCAN_MODE_LOW_POWER: + case SCAN_MODE_BALANCED: + case SCAN_MODE_LOW_LATENCY: + case SCAN_MODE_AMBIENT_DISCOVERY: + mScanMode = scanMode; + break; + default: + throw new IllegalArgumentException("invalid scan mode " + scanMode); } - mScanMode = scanMode; return this; } |
