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

Commit 97e0da85 authored by android-build-prod (mdb)'s avatar android-build-prod (mdb) Committed by Gerrit Code Review
Browse files

Merge "AdapterProperties: Always set the scan mode on enable/disable"

parents 7db5a5a7 e2464686
Loading
Loading
Loading
Loading
+10 −31
Original line number Diff line number Diff line
@@ -897,49 +897,28 @@ class AdapterProperties {
            mProfilesConnected = 0;
            mProfilesConnecting = 0;
            mProfilesDisconnecting = 0;
            // When BT is being turned on, all adapter properties will be sent in 1
            // callback. At this stage, set the scan mode.
            if (getState() == BluetoothAdapter.STATE_TURNING_ON
                    && mScanMode == BluetoothAdapter.SCAN_MODE_NONE) {
                    /* mDiscoverableTimeout is part of the
                       adapterPropertyChangedCallback received before
                       onBluetoothReady */
                if (mDiscoverableTimeout != 0) {
            // adapterPropertyChangedCallback has already been received.  Set the scan mode.
            setScanMode(AbstractionLayer.BT_SCAN_MODE_CONNECTABLE);
                } else /* if timeout == never (0) at startup */ {
                    setScanMode(AbstractionLayer.BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
                }
                    /* though not always required, this keeps NV up-to date on first-boot after
                    flash */
            // This keeps NV up-to date on first-boot after flash.
            setDiscoverableTimeout(mDiscoverableTimeout);
        }
    }
    }

    void onBleDisable() {
        // Sequence BLE_ON to STATE_OFF - that is _complete_ OFF state.
        // When BT disable is invoked, set the scan_mode to NONE
        // so no incoming connections are possible
        debugLog("onBleDisable");
        if (getState() == BluetoothAdapter.STATE_BLE_TURNING_OFF) {
        // Set the scan_mode to NONE (no incoming connections).
        setScanMode(AbstractionLayer.BT_SCAN_MODE_NONE);
    }
    }

    void onBluetoothDisable() {
        // From STATE_ON to BLE_ON
        // When BT disable is invoked, set the scan_mode to NONE
        // so no incoming connections are possible

        //Set flag to indicate we are disabling. When property change of scan mode done
        //continue with disable sequence
        debugLog("onBluetoothDisable()");
        if (getState() == BluetoothAdapter.STATE_TURNING_OFF) {
        // Turn off any Device Search/Inquiry
        mService.cancelDiscovery();
        // Set the scan_mode to NONE (no incoming connections).
        setScanMode(AbstractionLayer.BT_SCAN_MODE_NONE);
    }
    }

    void discoveryStateChangeCallback(int state) {
        infoLog("Callback:discoveryStateChangeCallback with state:" + state);