summaryrefslogtreecommitdiffstats
path: root/wifi
diff options
context:
space:
mode:
authorEric Shienbrood <>2009-03-27 12:21:17 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-27 12:21:17 -0700
commit50108e9282031bbd3a22683061496285a806403e (patch)
treec2b9c68a2408b2adcf028a1e2f0d574f3dd87815 /wifi
parent499e098f0c529f761666150db12d1907aa0ae668 (diff)
downloadframeworks_base-50108e9282031bbd3a22683061496285a806403e.zip
frameworks_base-50108e9282031bbd3a22683061496285a806403e.tar.gz
frameworks_base-50108e9282031bbd3a22683061496285a806403e.tar.bz2
AI 143124: Fix bug #1731826, in which auto-connect to remembered networks does not
take place. This has the same underlying cause as bug #1739874, so this fixes that bug as well. The problem was that if the supplicant was in the DORMANT state at the time a scan-only Wi-Fi lock was released, the command to stop the Wi-Fi driver would never be issued. This had two main results: first, the driver would stay awake when the screen was blank and it was supposed to be sleeping, leading to excessive battery drain, and second, when the screen was turned back on, there would be no DRIVER-STARTED event generated (because the driver was already running). The DRIVER-STARTED event is the trigger for the framework to issue a RECONNECT command to the supplicant to cause it leave the DORMANT state and look for available remembered networks. To assist in tracking down this problem, and any such problems in the future, I added four counters to keep track of how many times full and scan-only Wi-Fi locks are acquired and released. The counter values are output in the dump() method of WifiService. While doing this, I noticed that because of missing "break" statements, the battery stats that keep track of how much time Wi-Fi locks are held were including the time for full locks in the time reported for scan-only locks. BUG=1731826,1739874 Automated import of CL 143124
Diffstat (limited to 'wifi')
-rw-r--r--wifi/java/android/net/wifi/WifiStateTracker.java40
1 files changed, 35 insertions, 5 deletions
diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java
index f7a9677..6ea35f5 100644
--- a/wifi/java/android/net/wifi/WifiStateTracker.java
+++ b/wifi/java/android/net/wifi/WifiStateTracker.java
@@ -245,6 +245,13 @@ public class WifiStateTracker extends NetworkStateTracker {
private static final int RUN_STATE_RUNNING = 2;
private static final int RUN_STATE_STOPPING = 3;
private static final int RUN_STATE_STOPPED = 4;
+
+ private static final String mRunStateNames[] = {
+ "Starting",
+ "Running",
+ "Stopping",
+ "Stopped"
+ };
private int mRunState;
private final IBatteryStats mBatteryStats;
@@ -836,7 +843,14 @@ public class WifiStateTracker extends NetworkStateTracker {
newDetailedState = DetailedState.FAILED;
}
handleDisconnectedState(newDetailedState);
- if (mRunState == RUN_STATE_RUNNING && !mIsScanOnly) {
+ /**
+ * If we were associated with a network (networkId != -1),
+ * assume we reached this state because of a failed attempt
+ * to acquire an IP address, and attempt another connection
+ * and IP address acquisition in RECONNECT_DELAY_MSECS
+ * milliseconds.
+ */
+ if (mRunState == RUN_STATE_RUNNING && !mIsScanOnly && networkId != -1) {
sendEmptyMessageDelayed(EVENT_DEFERRED_RECONNECT, RECONNECT_DELAY_MSECS);
} else if (mRunState == RUN_STATE_STOPPING) {
synchronized (this) {
@@ -1376,13 +1390,24 @@ public class WifiStateTracker extends NetworkStateTracker {
}
}
+ /**
+ * We want to stop the driver, but if we're connected to a network,
+ * we first want to disconnect, so that the supplicant is always in
+ * a known state (DISCONNECTED) when the driver is stopped.
+ * @return {@code true} if the operation succeeds, which means that the
+ * disconnect or stop command was initiated.
+ */
public synchronized boolean disconnectAndStop() {
if (mRunState != RUN_STATE_STOPPING && mRunState != RUN_STATE_STOPPED) {
// Take down any open network notifications
setNotificationVisible(false, 0, false, 0);
mRunState = RUN_STATE_STOPPING;
- return WifiNative.disconnectCommand();
+ if (mWifiInfo.getSupplicantState() == SupplicantState.DORMANT) {
+ return WifiNative.stopDriverCommand();
+ } else {
+ return WifiNative.disconnectCommand();
+ }
} else {
/*
* The "driver-stop" wake lock normally is released from the
@@ -1574,9 +1599,14 @@ public class WifiStateTracker extends NetworkStateTracker {
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
- sb.append("interface ").append(mInterfaceName).
- append(" runState=").append(mRunState).append(LS);
- sb.append(mWifiInfo).append(LS);
+ sb.append("interface ").append(mInterfaceName);
+ sb.append(" runState=");
+ if (mRunState >= 1 && mRunState <= mRunStateNames.length) {
+ sb.append(mRunStateNames[mRunState-1]);
+ } else {
+ sb.append(mRunState);
+ }
+ sb.append(LS).append(mWifiInfo).append(LS);
sb.append(mDhcpInfo).append(LS);
sb.append("haveIpAddress=").append(mHaveIPAddress).
append(", obtainingIpAddress=").append(mObtainingIPAddress).