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

Commit e2639d78 authored by Irfan Sheriff's avatar Irfan Sheriff
Browse files

Switch to standard commands for pno & power save

Remove DRIVER commands and switch to cfg based commands

Bug: 6318223
Change-Id: I5e21c4bb554c2992a52fd3c1741629645b22ae43
parent ca7086f5
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -271,8 +271,7 @@
    <!-- Boolean indicating whether the wifi chipset supports background scanning mechanism.
         This mechanism allows the host to remain in suspend state and the dongle to actively
         scan and wake the host when a configured SSID is detected by the dongle. This chipset
         capability can provide power savings when wifi needs to be always kept on.
         The driver commands needed to support the feature are BGSCAN-START and BGSCAN-STOP -->
         capability can provide power savings when wifi needs to be always kept on. -->
    <bool translatable="false" name="config_wifi_background_scan_support">false</bool>

    <!-- Integer indicating wpa_supplicant scan interval in milliseconds -->
+10 −23
Original line number Diff line number Diff line
@@ -270,25 +270,6 @@ public class WifiNative {
            && doBooleanCommand("DRIVER RXFILTER-START");
    }

    public int getPowerMode() {
        String ret = doStringCommand("DRIVER GETPOWER");
        if (!TextUtils.isEmpty(ret)) {
            // reply comes back in the form "powermode = XX" where XX is the
            // number we're interested in.
            String[] tokens = ret.split(" = ");
            try {
                if (tokens.length == 2) return Integer.parseInt(tokens[1]);
            } catch (NumberFormatException e) {
                return -1;
            }
        }
        return -1;
    }

    public boolean setPowerMode(int mode) {
        return doBooleanCommand("DRIVER POWERMODE " + mode);
    }

    public int getBand() {
       String ret = doStringCommand("DRIVER GETBAND");
        if (!TextUtils.isEmpty(ret)) {
@@ -366,12 +347,10 @@ public class WifiNative {
    }

    public void enableBackgroundScan(boolean enable) {
        //Note: BGSCAN-START and BGSCAN-STOP are documented in core/res/res/values/config.xml
        //and will need an update if the names are changed
        if (enable) {
            doBooleanCommand("DRIVER BGSCAN-START");
            doBooleanCommand("SET pno 1");
        } else {
            doBooleanCommand("DRIVER BGSCAN-STOP");
            doBooleanCommand("SET pno 0");
        }
    }

@@ -467,6 +446,14 @@ public class WifiNative {
        return doBooleanCommand("SET interface=" + iface + " p2p_group_idle " + time);
    }

    public void setPowerSave(boolean enabled) {
        if (enabled) {
            doBooleanCommand("SET ps 1");
        } else {
            doBooleanCommand("SET ps 0");
        }
    }

    public boolean setP2pPowerSave(String iface, boolean enabled) {
        if (enabled) {
            return doBooleanCommand("P2P_SET interface=" + iface + " ps 1");
+14 −20
Original line number Diff line number Diff line
@@ -305,13 +305,11 @@ public class WifiStateMachine extends StateMachine {
    static final int CMD_RECONNECT                        = BASE + 75;
    /* Reassociate to a network */
    static final int CMD_REASSOCIATE                      = BASE + 76;
    /* Controls power mode and suspend mode optimizations
    /* Controls suspend mode optimizations
     *
     * When high perf mode is enabled, power mode is set to
     * POWER_MODE_ACTIVE and suspend mode optimizations are disabled
     * When high perf mode is enabled, suspend mode optimizations are disabled
     *
     * When high perf mode is disabled, power mode is set to
     * POWER_MODE_AUTO and suspend mode optimizations are enabled
     * When high perf mode is disabled, suspend mode optimizations are enabled
     *
     * Suspend mode optimizations include:
     * - packet filtering
@@ -374,11 +372,8 @@ public class WifiStateMachine extends StateMachine {
     */
    private static final int DEFAULT_MAX_DHCP_RETRIES = 9;

    static final int POWER_MODE_ACTIVE = 1;
    static final int POWER_MODE_AUTO = 0;

    /* Tracks the power mode for restoration after a DHCP request/renewal goes through */
    private int mPowerMode = POWER_MODE_AUTO;
    /* Tracks if power save is enabled in driver */
    private boolean mPowerSaveEnabled = true;;

    /**
     * Default framework scan interval in milliseconds. This is used in the scenario in which
@@ -1683,21 +1678,18 @@ public class WifiStateMachine extends StateMachine {
                    mWifiNative.BLUETOOTH_COEXISTENCE_MODE_DISABLED);
        }

        mPowerMode =  mWifiNative.getPowerMode();
        if (mPowerMode < 0) {
            // Handle the case where supplicant driver does not support
            // getPowerModeCommand.
            mPowerMode = WifiStateMachine.POWER_MODE_AUTO;
        }
        if (mPowerMode != WifiStateMachine.POWER_MODE_ACTIVE) {
            mWifiNative.setPowerMode(WifiStateMachine.POWER_MODE_ACTIVE);
        /* Disable power save during DHCP */
        if (mPowerSaveEnabled) {
            mPowerSaveEnabled = false;
            mWifiNative.setPowerSave(mPowerSaveEnabled);
        }
    }


    void handlePostDhcpSetup() {
        /* restore power mode */
        mWifiNative.setPowerMode(mPowerMode);
        /* Restore power save */
        mPowerSaveEnabled = true;
        mWifiNative.setPowerSave(mPowerSaveEnabled);

        // Set the coexistence mode back to its default value
        mWifiNative.setBluetoothCoexistenceMode(
@@ -2549,6 +2541,8 @@ public class WifiStateMachine extends StateMachine {
                mWifiNative.stopFilteringMulticastV4Packets();
            }

            mWifiNative.setPowerSave(mPowerSaveEnabled);

            if (mIsScanMode) {
                mWifiNative.setScanResultHandling(SCAN_ONLY_MODE);
                mWifiNative.disconnect();