diff options
author | Irfan Sheriff <isheriff@google.com> | 2010-06-11 15:11:54 -0700 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2010-06-11 15:14:29 -0700 |
commit | 0631c608b0997efe5c0bd8e8955e65f1a7b3f32c (patch) | |
tree | ecae35e88e882af70d5101abe79dd3f1b7fbf32c /wifi/java/android | |
parent | 07d814075583230e92f79d52845ecc3fa36df0fd (diff) | |
parent | fdedc522993ccbde6ba95b519ac81e32449959c8 (diff) | |
download | frameworks_base-0631c608b0997efe5c0bd8e8955e65f1a7b3f32c.zip frameworks_base-0631c608b0997efe5c0bd8e8955e65f1a7b3f32c.tar.gz frameworks_base-0631c608b0997efe5c0bd8e8955e65f1a7b3f32c.tar.bz2 |
merge from open-source master
Change-Id: I8a950276787e9439420db396d0e32f88bd6e04cc
Diffstat (limited to 'wifi/java/android')
-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 3813015..a7c6ec1 100644 --- a/wifi/java/android/net/wifi/WifiStateTracker.java +++ b/wifi/java/android/net/wifi/WifiStateTracker.java @@ -1928,6 +1928,17 @@ public class WifiStateTracker extends 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 @@ -2252,6 +2263,8 @@ public class WifiStateTracker extends 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 @@ -2275,8 +2288,16 @@ public class WifiStateTracker extends 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 @@ -2292,7 +2313,9 @@ public class WifiStateTracker extends 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 |