diff options
Diffstat (limited to 'wifi/java')
-rw-r--r-- | wifi/java/android/net/wifi/WifiNative.java | 33 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 34 |
2 files changed, 24 insertions, 43 deletions
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java index 4ec2e02..26229be 100644 --- a/wifi/java/android/net/wifi/WifiNative.java +++ b/wifi/java/android/net/wifi/WifiNative.java @@ -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"); diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index ac0fbfa..0cc1380 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -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(); |