summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorMichael Plass <mplass@google.com>2019-08-28 17:38:44 -0700
committerMichael Plass <mplass@google.com>2019-09-12 20:44:48 +0000
commit58457bff724192c55f8348571cd4f2ddc3ff53db (patch)
treeb48647dcda0172b2b5703a5a79f2172244a92f28 /service
parent00490aa849a315fbbc653872b29b59a638adbd24 (diff)
Allow wifi CONNECT_NETWORK in ObtainingIpState
The user should be able to pick a new network in the situation that it is taking a long time to get an IP configuration. Also cleaned up a nearby obsolete TODO. Bug: 133459384 Bug: 36576642 Test: atest FrameworksWifiTests Test: atest com.android.server.wifi.ClientModeImplTest#connectWhileObtainingIp Test: manual, using an AP with its DHCP server turned off Change-Id: Icfbad84cad39b9f7026c541487eae4c922644865
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java30
1 files changed, 25 insertions, 5 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index de96527ca..4559cf0b1 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -4387,8 +4387,6 @@ public class ClientModeImpl extends StateMachine {
// We switched from DHCP to static or from static to DHCP, or the
// static IP address has changed.
log("Reconfiguring IP on connection");
- // TODO(b/36576642): clear addresses and disable IPv6
- // to simplify obtainingIpState.
transitionTo(mObtainingIpState);
}
}
@@ -5280,9 +5278,7 @@ public class ClientModeImpl extends StateMachine {
// Stop IpClient in case we're switching from DHCP to static
// configuration or vice versa.
//
- // TODO: Only ever enter this state the first time we connect to a
- // network, never on switching between static configuration and
- // DHCP. When we transition from static configuration to DHCP in
+ // When we transition from static configuration to DHCP in
// particular, we must tell ConnectivityService that we're
// disconnected, because DHCP might take a long time during which
// connectivity APIs such as getActiveNetworkInfo should not return
@@ -5329,6 +5325,25 @@ public class ClientModeImpl extends StateMachine {
case CMD_START_ROAM:
mMessageHandlingStatus = MESSAGE_HANDLING_STATUS_DISCARD;
break;
+ case WifiManager.CONNECT_NETWORK:
+ // TODO(b/117601161) do all connect-network processing in one place
+ // Do not disconnect if we try to connect to the same network
+ int netId = message.arg1;
+ if (mWifiInfo.getNetworkId() == netId) {
+ handleStatus = NOT_HANDLED;
+ break;
+ }
+ // Defer the message so it is handled after the state change
+ mMessageHandlingStatus = MESSAGE_HANDLING_STATUS_DEFERRED;
+ deferMessage(message);
+ mWifiScoreCard.noteConnectionAttempt(mWifiInfo);
+ reportConnectionAttemptEnd(
+ WifiMetrics.ConnectionEvent.FAILURE_NEW_CONNECTION_ATTEMPT,
+ WifiMetricsProto.ConnectionEvent.HLF_NONE,
+ WifiMetricsProto.ConnectionEvent.FAILURE_REASON_UNKNOWN);
+ mWifiNative.disconnect(mInterfaceName);
+ transitionTo(mDisconnectingState);
+ break;
case WifiManager.SAVE_NETWORK:
mMessageHandlingStatus = MESSAGE_HANDLING_STATUS_DEFERRED;
deferMessage(message);
@@ -5792,6 +5807,10 @@ public class ClientModeImpl extends StateMachine {
boolean handleStatus = HANDLED;
switch (message.what) {
+ case WifiManager.CONNECT_NETWORK:
+ mMessageHandlingStatus = MESSAGE_HANDLING_STATUS_DEFERRED;
+ deferMessage(message);
+ break;
case CMD_DISCONNECT:
if (mVerboseLoggingEnabled) {
log("Ignore CMD_DISCONNECT when already disconnecting.");
@@ -5810,6 +5829,7 @@ public class ClientModeImpl extends StateMachine {
* we have missed the network disconnection, transition to mDisconnectedState
* and handle the rest of the events there
*/
+ mMessageHandlingStatus = MESSAGE_HANDLING_STATUS_DEFERRED;
deferMessage(message);
handleNetworkDisconnect();
transitionTo(mDisconnectedState);