OSDN Git Service

Add opportunistic ble scan mode. (1/2)
authorWei Wang <weiwa@google.com>
Tue, 13 Jan 2015 04:02:37 +0000 (20:02 -0800)
committerTom Turney <tturney@google.com>
Tue, 17 Mar 2015 22:04:01 +0000 (22:04 +0000)
Bug: 19003667
Change-Id: Ibed7e9ec604cb11a58736d168d3d19ece53fc77a
(cherry picked from commit 7508ddf8b53bf350a3424ef71f1ce62ea17006b8)

core/java/android/bluetooth/le/ScanSettings.java

index 7eae439..5bdfdb5 100644 (file)
@@ -25,6 +25,15 @@ import android.os.Parcelable;
  * parameters for the scan.
  */
 public final class ScanSettings implements Parcelable {
+
+    /**
+     * A special Bluetooth LE scan mode. Applications using this scan mode will passively listen for
+     * other scan results without starting BLE scans themselves.
+     *
+     * @hide
+     */
+    public static final int SCAN_MODE_OPPORTUNISTIC = -1;
+
     /**
      * Perform Bluetooth LE scan in low power mode. This is the default scan mode as it consumes the
      * least power.
@@ -177,7 +186,7 @@ public final class ScanSettings implements Parcelable {
          * @throws IllegalArgumentException If the {@code scanMode} is invalid.
          */
         public Builder setScanMode(int scanMode) {
-            if (scanMode < SCAN_MODE_LOW_POWER || scanMode > SCAN_MODE_LOW_LATENCY) {
+            if (scanMode < SCAN_MODE_OPPORTUNISTIC || scanMode > SCAN_MODE_LOW_LATENCY) {
                 throw new IllegalArgumentException("invalid scan mode " + scanMode);
             }
             mScanMode = scanMode;