am a28c18fc: Merge "Fix DHCP handling at disconnect/reconnect" into jb-mr1-dev

* commit 'a28c18fc618e4bf58da6417166b1ee249dc16ea9':
  Fix DHCP handling at disconnect/reconnect
This commit is contained in:
Irfan Sheriff
2012-08-29 15:57:58 -07:00
committed by Android Git Automerger
3 changed files with 21 additions and 9 deletions

View File

@@ -92,10 +92,12 @@ public class DhcpStateMachine extends StateMachine {
/* Notification from DHCP state machine post DHCP discovery/renewal. Indicates /* Notification from DHCP state machine post DHCP discovery/renewal. Indicates
* success/failure */ * success/failure */
public static final int CMD_POST_DHCP_ACTION = BASE + 5; public static final int CMD_POST_DHCP_ACTION = BASE + 5;
/* Notification from DHCP state machine before quitting */
public static final int CMD_ON_QUIT = BASE + 6;
/* Command from controller to indicate DHCP discovery/renewal can continue /* Command from controller to indicate DHCP discovery/renewal can continue
* after pre DHCP action is complete */ * after pre DHCP action is complete */
public static final int CMD_PRE_DHCP_ACTION_COMPLETE = BASE + 6; public static final int CMD_PRE_DHCP_ACTION_COMPLETE = BASE + 7;
/* Message.arg1 arguments to CMD_POST_DHCP notification */ /* Message.arg1 arguments to CMD_POST_DHCP notification */
public static final int DHCP_SUCCESS = 1; public static final int DHCP_SUCCESS = 1;
@@ -172,6 +174,10 @@ public class DhcpStateMachine extends StateMachine {
quit(); quit();
} }
protected void onQuitting() {
mController.sendMessage(CMD_ON_QUIT);
}
class DefaultState extends State { class DefaultState extends State {
@Override @Override
public void exit() { public void exit() {

View File

@@ -240,7 +240,7 @@ public class WifiService extends IWifiManager.Stub {
switch (msg.what) { switch (msg.what) {
case AsyncChannel.CMD_CHANNEL_HALF_CONNECTED: { case AsyncChannel.CMD_CHANNEL_HALF_CONNECTED: {
if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) { if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
Slog.d(TAG, "New client listening to asynchronous messages"); if (DBG) Slog.d(TAG, "New client listening to asynchronous messages");
mClients.add((AsyncChannel) msg.obj); mClients.add((AsyncChannel) msg.obj);
} else { } else {
Slog.e(TAG, "Client connection failure, error=" + msg.arg1); Slog.e(TAG, "Client connection failure, error=" + msg.arg1);
@@ -249,9 +249,9 @@ public class WifiService extends IWifiManager.Stub {
} }
case AsyncChannel.CMD_CHANNEL_DISCONNECTED: { case AsyncChannel.CMD_CHANNEL_DISCONNECTED: {
if (msg.arg1 == AsyncChannel.STATUS_SEND_UNSUCCESSFUL) { if (msg.arg1 == AsyncChannel.STATUS_SEND_UNSUCCESSFUL) {
Slog.d(TAG, "Send failed, client connection lost"); if (DBG) Slog.d(TAG, "Send failed, client connection lost");
} else { } else {
Slog.d(TAG, "Client connection lost with reason: " + msg.arg1); if (DBG) Slog.d(TAG, "Client connection lost with reason: " + msg.arg1);
} }
mClients.remove((AsyncChannel) msg.obj); mClients.remove((AsyncChannel) msg.obj);
break; break;

View File

@@ -1672,10 +1672,7 @@ public class WifiStateMachine extends StateMachine {
/* In case we were in middle of DHCP operation /* In case we were in middle of DHCP operation
restore back powermode */ restore back powermode */
handlePostDhcpSetup(); handlePostDhcpSetup();
mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_STOP_DHCP); mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_STOP_DHCP);
mDhcpStateMachine.doQuit();
mDhcpStateMachine = null;
} }
try { try {
@@ -1928,6 +1925,9 @@ public class WifiStateMachine extends StateMachine {
case CMD_CLEAR_SUSPEND_OPTIMIZATIONS: case CMD_CLEAR_SUSPEND_OPTIMIZATIONS:
case CMD_NO_NETWORKS_PERIODIC_SCAN: case CMD_NO_NETWORKS_PERIODIC_SCAN:
break; break;
case DhcpStateMachine.CMD_ON_QUIT:
mDhcpStateMachine = null;
break;
case CMD_SET_SUSPEND_OPTIMIZATIONS: case CMD_SET_SUSPEND_OPTIMIZATIONS:
mSuspendWakeLock.release(); mSuspendWakeLock.release();
break; break;
@@ -2498,6 +2498,9 @@ public class WifiStateMachine extends StateMachine {
/* Send any reset commands to supplicant before shutting it down */ /* Send any reset commands to supplicant before shutting it down */
handleNetworkDisconnect(); handleNetworkDisconnect();
if (mDhcpStateMachine != null) {
mDhcpStateMachine.doQuit();
}
if (DBG) log("stopping supplicant"); if (DBG) log("stopping supplicant");
if (!mWifiNative.stopSupplicant()) { if (!mWifiNative.stopSupplicant()) {
@@ -3197,8 +3200,11 @@ public class WifiStateMachine extends StateMachine {
if (!mWifiConfigStore.isUsingStaticIp(mLastNetworkId)) { if (!mWifiConfigStore.isUsingStaticIp(mLastNetworkId)) {
//start DHCP //start DHCP
mDhcpStateMachine = DhcpStateMachine.makeDhcpStateMachine( if (mDhcpStateMachine == null) {
mContext, WifiStateMachine.this, mInterfaceName); mDhcpStateMachine = DhcpStateMachine.makeDhcpStateMachine(
mContext, WifiStateMachine.this, mInterfaceName);
}
mDhcpStateMachine.registerForPreDhcpNotification(); mDhcpStateMachine.registerForPreDhcpNotification();
mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_START_DHCP); mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_START_DHCP);
} else { } else {