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

Commit 81fec6be authored by Robert Greenwalt's avatar Robert Greenwalt
Browse files

Supsend/resume batched scans around dhcp.

Scanning while dhcp is running breaks dhcp, so stop the batched scans
when we need dhcp and start it up again after.

bug:10691401
Change-Id: Ifdeb6f35cfe4509b90fed1e1e694d0c107f24a7e
parent 8f435bac
Loading
Loading
Loading
Loading
+30 −3
Original line number Diff line number Diff line
@@ -228,6 +228,7 @@ public class WifiStateMachine extends StateMachine {
    private NetworkInfo mNetworkInfo;
    private SupplicantStateTracker mSupplicantStateTracker;
    private DhcpStateMachine mDhcpStateMachine;
    private boolean mDhcpActive = false;

    private class InterfaceObserver extends BaseNetworkObserver {
        private WifiStateMachine mWifiStateMachine;
@@ -848,6 +849,11 @@ public class WifiStateMachine extends StateMachine {
    }

    private void startBatchedScan() {
        if (mDhcpActive) {
            if (DBG) log("not starting Batched Scans due to DHCP");
            return;
        }

        // first grab any existing data
        retrieveBatchedScanData();

@@ -915,9 +921,11 @@ public class WifiStateMachine extends StateMachine {

    private void stopBatchedScan() {
        mAlarmManager.cancel(mBatchedScanIntervalIntent);
        if (mBatchedScanSettings != null) {
            retrieveBatchedScanData();
            mWifiNative.setBatchedScanSettings(null);
        }
    }

    private void setNextBatchedAlarm(int scansExpected) {

@@ -2201,6 +2209,7 @@ public class WifiStateMachine extends StateMachine {
    }

    void handlePreDhcpSetup() {
        mDhcpActive = true;
        if (!mBluetoothConnectionActive) {
            /*
             * There are problems setting the Wi-Fi driver's power
@@ -2230,6 +2239,8 @@ public class WifiStateMachine extends StateMachine {
        setSuspendOptimizationsNative(SUSPEND_DUE_TO_DHCP, false);
        mWifiNative.setPowerSave(false);

        stopBatchedScan();

        /* P2p discovery breaks dhcp, shut it down in order to get through this */
        Message msg = new Message();
        msg.what = WifiP2pService.BLOCK_DISCOVERY;
@@ -2268,6 +2279,12 @@ public class WifiStateMachine extends StateMachine {
        // Set the coexistence mode back to its default value
        mWifiNative.setBluetoothCoexistenceMode(
                mWifiNative.BLUETOOTH_COEXISTENCE_MODE_SENSE);

        mDhcpActive = false;

        if (mBatchedScanSettings != null) {
            startBatchedScan();
        }
    }

    private void handleSuccessfulIpConfiguration(DhcpResults dhcpResults) {
@@ -2915,6 +2932,8 @@ public class WifiStateMachine extends StateMachine {
                mWifiNative.stopFilteringMulticastV4Packets();
            }

            mDhcpActive = false;

            if (mBatchedScanSettings != null) {
                startBatchedScan();
            }
@@ -3483,6 +3502,14 @@ public class WifiStateMachine extends StateMachine {
            }
        }

        @Override
        public void exit() {
            // if we're leaving before this is done, cleanup
            if (mDhcpActive) {
                handlePostDhcpSetup();
            }
        }

        @Override
        public boolean processMessage(Message message) {
            switch (message.what) {
@@ -3675,7 +3702,7 @@ public class WifiStateMachine extends StateMachine {
                    transitionTo(mCaptivePortalCheckState);
                    break;
                default:
                    log(getName() + " what=" + message.what + " NOT_HANDLED");
                    if (DBG) log(getName() + " what=" + message.what + " NOT_HANDLED");
                    return NOT_HANDLED;
            }
            return HANDLED;