Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 91ef4422 authored by Chienyuan Huang's avatar Chienyuan Huang Committed by Automerger Merge Worker
Browse files

Merge "Le Scan: Add ambient discovery mode (1/2)" am: 9e15e5a3

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1629277

Change-Id: I22fb8518bd1ab6f30b3de88905c60c538685e41b
parents 57e839dd 9e15e5a3
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -51,6 +51,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) {
            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;
        }