diff options
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/WifiNative.java | 2 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateTracker.java | 29 |
2 files changed, 28 insertions, 3 deletions
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java index f98cd28..7a3282c 100644 --- a/wifi/java/android/net/wifi/WifiNative.java +++ b/wifi/java/android/net/wifi/WifiNative.java @@ -109,6 +109,8 @@ public class WifiNative { public native static boolean setPowerModeCommand(int mode); + public native static int getPowerModeCommand(); + public native static boolean setNumAllowedChannelsCommand(int numChannels); public native static int getNumAllowedChannelsCommand(); diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java index 2cec996..73cba93 100644 --- a/wifi/java/android/net/wifi/WifiStateTracker.java +++ b/wifi/java/android/net/wifi/WifiStateTracker.java @@ -2010,6 +2010,17 @@ public class WifiStateTracker extends Handler implements NetworkStateTracker { } /** + * Get power mode + * @return power mode + */ + public synchronized int getPowerMode() { + if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) { + return -1; + } + return WifiNative.getPowerModeCommand(); + } + + /** * Set power mode * @param mode * DRIVER_POWER_MODE_AUTO @@ -2342,6 +2353,8 @@ public class WifiStateTracker extends Handler implements NetworkStateTracker { case EVENT_DHCP_START: boolean modifiedBluetoothCoexistenceMode = false; + int powerMode = DRIVER_POWER_MODE_AUTO; + if (shouldDisableCoexistenceMode()) { /* * There are problems setting the Wi-Fi driver's power @@ -2365,8 +2378,16 @@ public class WifiStateTracker extends Handler implements NetworkStateTracker { setBluetoothCoexistenceMode( WifiNative.BLUETOOTH_COEXISTENCE_MODE_DISABLED); } - - setPowerMode(DRIVER_POWER_MODE_ACTIVE); + + powerMode = getPowerMode(); + if (powerMode < 0) { + // Handle the case where supplicant driver does not support + // getPowerModeCommand. + powerMode = DRIVER_POWER_MODE_AUTO; + } + if (powerMode != DRIVER_POWER_MODE_ACTIVE) { + setPowerMode(DRIVER_POWER_MODE_ACTIVE); + } synchronized (this) { // A new request is being made, so assume we will callback @@ -2382,7 +2403,9 @@ public class WifiStateTracker extends Handler implements NetworkStateTracker { NetworkUtils.getDhcpError()); } - setPowerMode(DRIVER_POWER_MODE_AUTO); + if (powerMode != DRIVER_POWER_MODE_ACTIVE) { + setPowerMode(powerMode); + } if (modifiedBluetoothCoexistenceMode) { // Set the coexistence mode back to its default value |