summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcore/res/res/values/config.xml3
-rw-r--r--wifi/java/android/net/wifi/WifiNative.java33
-rw-r--r--wifi/java/android/net/wifi/WifiStateMachine.java34
3 files changed, 25 insertions, 45 deletions
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index acf63a1..472b19c 100755
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -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 -->
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();