From 98e1797367ca8cd8b8476f6befdb55f81cd13e19 Mon Sep 17 00:00:00 2001 From: Narayan Kamath Date: Thu, 29 Aug 2013 13:40:43 +0100 Subject: Remove captive portal code that has no effect. Note that this CL does not change any behaviour. At the center of this change is CaptivePortalTracker#detectCaptivePortal(), which does nothing except call back into ConnectivityService. Removing it allows us to simplify code in ConnectivityService. It also allows us to remove ConnectivityService#captivePortalCheckComplete which was only ever called in response to this method. While this does not change any behaviour, it preserves existing bad behaviour, i.e, that the CAPTIVE_PORTAL_CHECK NetworkInfo state does not correspond to actual captive portal detection. We transition into that state and immediately (and unconditionally) out of it and into CONNECTED. Change-Id: Ib3797f956d2db5e3cacaaa53e899d81aa8e958af --- wifi/java/android/net/wifi/IWifiManager.aidl | 2 - wifi/java/android/net/wifi/WifiManager.java | 7 ---- wifi/java/android/net/wifi/WifiStateMachine.java | 51 +++++++----------------- wifi/java/android/net/wifi/WifiStateTracker.java | 8 ---- 4 files changed, 15 insertions(+), 53 deletions(-) (limited to 'wifi/java/android/net') diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl index 5a1928c..bfcc208 100644 --- a/wifi/java/android/net/wifi/IWifiManager.aidl +++ b/wifi/java/android/net/wifi/IWifiManager.aidl @@ -111,8 +111,6 @@ interface IWifiManager String getConfigFile(); - void captivePortalCheckComplete(); - void enableTdls(String remoteIPAddress, boolean enable); void enableTdlsWithMacAddress(String remoteMacAddress, boolean enable); diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 7fc8bef..1fa7e85 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -2157,13 +2157,6 @@ public class WifiManager { } } - /** @hide */ - public void captivePortalCheckComplete() { - try { - mService.captivePortalCheckComplete(); - } catch (RemoteException e) {} - } - protected void finalize() throws Throwable { try { synchronized (sThreadRefLock) { diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 4bc3dda..f877c48 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -56,13 +56,11 @@ import android.net.wifi.WpsResult.Status; import android.net.wifi.p2p.WifiP2pManager; import android.net.wifi.p2p.WifiP2pService; import android.os.BatteryStats; -import android.os.Binder; import android.os.IBinder; import android.os.INetworkManagementService; import android.os.Message; import android.os.Messenger; import android.os.PowerManager; -import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; @@ -70,7 +68,6 @@ import android.os.SystemProperties; import android.os.UserHandle; import android.os.WorkSource; import android.provider.Settings; -import android.util.Log; import android.util.LruCache; import android.text.TextUtils; @@ -86,7 +83,6 @@ import com.android.server.net.BaseNetworkObserver; import java.io.FileDescriptor; import java.io.PrintWriter; import java.net.InetAddress; -import java.net.Inet6Address; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -303,8 +299,6 @@ public class WifiStateMachine extends StateMachine { static final int CMD_DELAYED_STOP_DRIVER = BASE + 18; /* A delayed message sent to start driver when it fail to come up */ static final int CMD_DRIVER_START_TIMED_OUT = BASE + 19; - /* Ready to switch to network as default */ - static final int CMD_CAPTIVE_CHECK_COMPLETE = BASE + 20; /* Start the soft access point */ static final int CMD_START_AP = BASE + 21; @@ -536,8 +530,6 @@ public class WifiStateMachine extends StateMachine { private State mObtainingIpState = new ObtainingIpState(); /* Waiting for link quality verification to be complete */ private State mVerifyingLinkState = new VerifyingLinkState(); - /* Waiting for captive portal check to be complete */ - private State mCaptivePortalCheckState = new CaptivePortalCheckState(); /* Connected with IP addr */ private State mConnectedState = new ConnectedState(); /* disconnect issued, waiting for network disconnect confirmation */ @@ -774,7 +766,6 @@ public class WifiStateMachine extends StateMachine { addState(mL2ConnectedState, mConnectModeState); addState(mObtainingIpState, mL2ConnectedState); addState(mVerifyingLinkState, mL2ConnectedState); - addState(mCaptivePortalCheckState, mL2ConnectedState); addState(mConnectedState, mL2ConnectedState); addState(mDisconnectingState, mConnectModeState); addState(mDisconnectedState, mConnectModeState); @@ -1277,10 +1268,6 @@ public class WifiStateMachine extends StateMachine { } } - public void captivePortalCheckComplete() { - sendMessage(CMD_CAPTIVE_CHECK_COMPLETE); - } - /** * TODO: doc */ @@ -2459,7 +2446,6 @@ public class WifiStateMachine extends StateMachine { case CMD_STOP_DRIVER: case CMD_DELAYED_STOP_DRIVER: case CMD_DRIVER_START_TIMED_OUT: - case CMD_CAPTIVE_CHECK_COMPLETE: case CMD_START_AP: case CMD_START_AP_SUCCESS: case CMD_START_AP_FAILURE: @@ -3731,29 +3717,17 @@ public class WifiStateMachine extends StateMachine { break; case WifiWatchdogStateMachine.GOOD_LINK_DETECTED: log(getName() + " GOOD_LINK_DETECTED: transition to captive portal check"); - transitionTo(mCaptivePortalCheckState); - break; - default: - if (DBG) log(getName() + " what=" + message.what + " NOT_HANDLED"); - return NOT_HANDLED; - } - return HANDLED; - } - } + // Send out a broadcast with the CAPTIVE_PORTAL_CHECK to preserve + // existing behaviour. The captive portal check really happens after we + // transition into DetailedState.CONNECTED. + setNetworkDetailedState(DetailedState.CAPTIVE_PORTAL_CHECK); + mWifiConfigStore.updateStatus(mLastNetworkId, + DetailedState.CAPTIVE_PORTAL_CHECK); + sendNetworkStateChangeBroadcast(mLastBssid); - class CaptivePortalCheckState extends State { - @Override - public void enter() { - log(getName() + " enter"); - setNetworkDetailedState(DetailedState.CAPTIVE_PORTAL_CHECK); - mWifiConfigStore.updateStatus(mLastNetworkId, DetailedState.CAPTIVE_PORTAL_CHECK); - sendNetworkStateChangeBroadcast(mLastBssid); - } - @Override - public boolean processMessage(Message message) { - switch (message.what) { - case CMD_CAPTIVE_CHECK_COMPLETE: - log(getName() + " CMD_CAPTIVE_CHECK_COMPLETE"); + // NOTE: This might look like an odd place to enable IPV6 but this is in + // response to transitioning into GOOD_LINK_DETECTED. Similarly, we disable + // ipv6 when we transition into POOR_LINK_DETECTED in mConnectedState. try { mNwService.enableIpv6(mInterfaceName); } catch (RemoteException re) { @@ -3761,12 +3735,16 @@ public class WifiStateMachine extends StateMachine { } catch (IllegalStateException e) { loge("Failed to enable IPv6: " + e); } + + log(getName() + " GOOD_LINK_DETECTED: transition to CONNECTED"); setNetworkDetailedState(DetailedState.CONNECTED); mWifiConfigStore.updateStatus(mLastNetworkId, DetailedState.CONNECTED); sendNetworkStateChangeBroadcast(mLastBssid); transitionTo(mConnectedState); + break; default: + if (DBG) log(getName() + " what=" + message.what + " NOT_HANDLED"); return NOT_HANDLED; } return HANDLED; @@ -3798,6 +3776,7 @@ public class WifiStateMachine extends StateMachine { } return HANDLED; } + @Override public void exit() { /* Request a CS wakelock during transition to mobile */ diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java index 615c893..7ded171 100644 --- a/wifi/java/android/net/wifi/WifiStateTracker.java +++ b/wifi/java/android/net/wifi/WifiStateTracker.java @@ -115,14 +115,6 @@ public class WifiStateTracker extends BaseNetworkStateTracker { return true; } - /** - * Captive check is complete, switch to network - */ - @Override - public void captivePortalCheckComplete() { - mWifiManager.captivePortalCheckComplete(); - } - @Override public void captivePortalCheckCompleted(boolean isCaptivePortal) { // not implemented -- cgit v1.1