summaryrefslogtreecommitdiffstats
path: root/wifi/java
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2010-10-12 16:34:07 -0700
committerIrfan Sheriff <isheriff@google.com>2010-10-12 16:47:51 -0700
commit68825ac32deb00991e18b5b40b455b68e9d78324 (patch)
tree04b4967f13494649957cace48177d858c0a8617a /wifi/java
parentc949b9c3ffe5ed9e2112a15224a86c55651fedfd (diff)
downloadframeworks_base-68825ac32deb00991e18b5b40b455b68e9d78324.zip
frameworks_base-68825ac32deb00991e18b5b40b455b68e9d78324.tar.gz
frameworks_base-68825ac32deb00991e18b5b40b455b68e9d78324.tar.bz2
state machine fixes
- When supplicant dies, restart it - When wifimonitor fails to connect in time, restart supplicant - fix dhcp counter reset - defer all load/unload actions when waiting for supplicant control connection - we dont need to disconnect & reconnect at start with the faster monitor connection and handling of failures Bug: 2973023 Bug: 3090725 Change-Id: I5c834ddd08e6300e2b29da0941a24633825b4d3b
Diffstat (limited to 'wifi/java')
-rw-r--r--wifi/java/android/net/wifi/WifiStateMachine.java67
1 files changed, 23 insertions, 44 deletions
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index efd0e0a..7dd1909 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -45,8 +45,6 @@ import android.net.NetworkUtils;
import android.net.ConnectivityManager;
import android.net.NetworkInfo.DetailedState;
import android.net.LinkProperties;
-import android.net.ProxyProperties;
-import android.net.wifi.WifiConfiguration.Status;
import android.os.Binder;
import android.os.Message;
import android.os.Parcelable;
@@ -60,7 +58,6 @@ import android.os.ServiceManager;
import android.os.Process;
import android.os.WorkSource;
import android.provider.Settings;
-import android.text.TextUtils;
import android.util.EventLog;
import android.util.Log;
import android.util.Slog;
@@ -70,26 +67,18 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadset;
import android.bluetooth.BluetoothProfile;
-import android.content.ContentResolver;
import android.content.Intent;
import android.content.Context;
-import android.database.ContentObserver;
import com.android.internal.app.IBatteryStats;
import com.android.internal.util.HierarchicalState;
import com.android.internal.util.HierarchicalStateMachine;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.net.UnknownHostException;
+
import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
@@ -1511,8 +1500,8 @@ public class WifiStateMachine extends HierarchicalStateMachine {
}
/**
- * Send the tracker a notification that a connection to the supplicant
- * daemon has been established.
+ * Send the tracker a notification that connection to the supplicant
+ * daemon is lost
*/
void notifySupplicantLost() {
sendMessage(SUP_DISCONNECTION_EVENT);
@@ -1944,16 +1933,18 @@ public class WifiStateMachine extends HierarchicalStateMachine {
sendSupplicantConnectionChangedBroadcast(true);
transitionTo(mDriverSupReadyState);
break;
- case CMD_STOP_SUPPLICANT:
- Log.d(TAG, "Stop supplicant received");
+ case SUP_DISCONNECTION_EVENT:
+ Log.e(TAG, "Failed to setup control channel, restart supplicant");
WifiNative.stopSupplicant();
transitionTo(mDriverLoadedState);
+ sendMessageAtFrontOfQueue(CMD_START_SUPPLICANT);
break;
- /* Fail soft ap when waiting for supplicant start */
+ case CMD_LOAD_DRIVER:
+ case CMD_UNLOAD_DRIVER:
+ case CMD_START_SUPPLICANT:
+ case CMD_STOP_SUPPLICANT:
case CMD_START_AP:
- Log.d(TAG, "Failed to start soft AP with a running supplicant");
- setWifiApState(WIFI_AP_STATE_FAILED);
- break;
+ case CMD_STOP_AP:
case CMD_START_DRIVER:
case CMD_STOP_DRIVER:
case CMD_SET_SCAN_MODE:
@@ -1966,10 +1957,6 @@ public class WifiStateMachine extends HierarchicalStateMachine {
case CMD_STOP_PACKET_FILTERING:
deferMessage(message);
break;
- case CMD_STOP_AP:
- case CMD_START_SUPPLICANT:
- case CMD_UNLOAD_DRIVER:
- break;
default:
return NOT_HANDLED;
}
@@ -1993,23 +1980,24 @@ public class WifiStateMachine extends HierarchicalStateMachine {
WifiConfiguration config;
switch(message.what) {
case CMD_STOP_SUPPLICANT: /* Supplicant stopped by user */
+ EventLog.writeEvent(EVENTLOG_WIFI_EVENT_HANDLED, message.what);
Log.d(TAG, "Stop supplicant received");
+ WifiNative.closeSupplicantConnection();
WifiNative.stopSupplicant();
- //$FALL-THROUGH$
+ handleNetworkDisconnect();
+ sendSupplicantConnectionChangedBroadcast(false);
+ mSupplicantStateTracker.resetSupplicantState();
+ transitionTo(mDriverLoadedState);
+ break;
case SUP_DISCONNECTION_EVENT: /* Supplicant died */
EventLog.writeEvent(EVENTLOG_WIFI_EVENT_HANDLED, message.what);
+ Log.e(TAG, "Supplicant died, restarting");
WifiNative.closeSupplicantConnection();
handleNetworkDisconnect();
sendSupplicantConnectionChangedBroadcast(false);
mSupplicantStateTracker.resetSupplicantState();
transitionTo(mDriverLoadedState);
-
- /* When supplicant dies, unload driver and enter failed state */
- //TODO: consider bringing up supplicant again
- if (message.what == SUP_DISCONNECTION_EVENT) {
- Log.d(TAG, "Supplicant died, unloading driver");
- sendMessage(obtainMessage(CMD_UNLOAD_DRIVER, WIFI_STATE_UNKNOWN, 0));
- }
+ sendMessageAtFrontOfQueue(CMD_START_SUPPLICANT); /* restart */
break;
case CMD_START_DRIVER:
EventLog.writeEvent(EVENTLOG_WIFI_EVENT_HANDLED, message.what);
@@ -2171,15 +2159,6 @@ public class WifiStateMachine extends HierarchicalStateMachine {
transitionTo(mScanModeState);
} else {
WifiNative.setScanResultHandlingCommand(CONNECT_MODE);
- /* If supplicant has already connected, before we could finish establishing
- * the control channel connection, we miss all the supplicant events.
- * Disconnect and reconnect when driver has started to ensure we receive
- * all supplicant events.
- *
- * TODO: This is a bit unclean, ideally the supplicant should never
- * connect until told to do so by the framework
- */
- WifiNative.disconnectCommand();
WifiNative.reconnectCommand();
transitionTo(mConnectModeState);
}
@@ -2564,7 +2543,6 @@ public class WifiStateMachine extends HierarchicalStateMachine {
switch(message.what) {
case CMD_IP_CONFIG_SUCCESS:
- mReconnectCount = 0;
mLastSignalLevel = -1; // force update of signal strength
synchronized (mDhcpInfo) {
mWifiInfo.setIpAddress(mDhcpInfo.ipAddress);
@@ -2585,9 +2563,10 @@ public class WifiStateMachine extends HierarchicalStateMachine {
* to a given network, disable the network
*/
if (++mReconnectCount > getMaxDhcpRetries()) {
- Log.e(TAG, "Failed " +
- mReconnectCount + " times, Disabling " + mLastNetworkId);
+ Log.e(TAG, "Failed " +
+ mReconnectCount + " times, Disabling " + mLastNetworkId);
WifiConfigStore.disableNetwork(mLastNetworkId);
+ mReconnectCount = 0;
}
/* DHCP times out after about 30 seconds, we do a