Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 98e17973 authored by Narayan Kamath's avatar Narayan Kamath
Browse files

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
parent 805f7a1d
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -142,11 +142,6 @@ public class BluetoothTetheringDataTracker extends BaseNetworkStateTracker {
        return true;
    }

    @Override
    public void captivePortalCheckComplete() {
        // not implemented
    }

    @Override
    public void captivePortalCheckCompleted(boolean isCaptivePortal) {
        // not implemented
+2 −7
Original line number Diff line number Diff line
@@ -20,10 +20,10 @@ import android.content.Context;
import android.os.Handler;
import android.os.Messenger;

import com.android.internal.util.Preconditions;

import java.util.concurrent.atomic.AtomicBoolean;

import com.android.internal.util.Preconditions;

/**
 * Interface to control and observe state of a specific network, hiding
 * network-specific details from {@link ConnectivityManager}. Surfaces events
@@ -107,11 +107,6 @@ public abstract class BaseNetworkStateTracker implements NetworkStateTracker {
        return null;
    }

    @Override
    public void captivePortalCheckComplete() {
        // not implemented
    }

    @Override
    public void captivePortalCheckCompleted(boolean isCaptivePortal) {
        // not implemented
+11 −43
Original line number Diff line number Diff line
@@ -84,13 +84,12 @@ public class CaptivePortalTracker extends StateMachine {
    private String mServer;
    private String mUrl;
    private boolean mIsCaptivePortalCheckEnabled = false;
    private IConnectivityManager mConnService;
    private TelephonyManager mTelephonyManager;
    private WifiManager mWifiManager;
    private Context mContext;
    private final IConnectivityManager mConnService;
    private final TelephonyManager mTelephonyManager;
    private final WifiManager mWifiManager;
    private final Context mContext;
    private NetworkInfo mNetworkInfo;

    private static final int CMD_DETECT_PORTAL          = 0;
    private static final int CMD_CONNECTIVITY_CHANGE    = 1;
    private static final int CMD_DELAYED_CAPTIVE_CHECK  = 2;

@@ -98,14 +97,15 @@ public class CaptivePortalTracker extends StateMachine {
    private static final int DELAYED_CHECK_INTERVAL_MS = 10000;
    private int mDelayedCheckToken = 0;

    private State mDefaultState = new DefaultState();
    private State mNoActiveNetworkState = new NoActiveNetworkState();
    private State mActiveNetworkState = new ActiveNetworkState();
    private State mDelayedCaptiveCheckState = new DelayedCaptiveCheckState();
    private final State mDefaultState = new DefaultState();
    private final State mNoActiveNetworkState = new NoActiveNetworkState();
    private final State mActiveNetworkState = new ActiveNetworkState();
    private final State mDelayedCaptiveCheckState = new DelayedCaptiveCheckState();

    private static final String SETUP_WIZARD_PACKAGE = "com.google.android.setupwizard";
    private boolean mDeviceProvisioned = false;
    private ProvisioningObserver mProvisioningObserver;
    @SuppressWarnings("unused")
    private final ProvisioningObserver mProvisioningObserver;

    private CaptivePortalTracker(Context context, IConnectivityManager cs) {
        super(TAG);
@@ -174,29 +174,11 @@ public class CaptivePortalTracker extends StateMachine {
        return captivePortal;
    }

    public void detectCaptivePortal(NetworkInfo info) {
        sendMessage(obtainMessage(CMD_DETECT_PORTAL, info));
    }

    private class DefaultState extends State {

        @Override
        public boolean processMessage(Message message) {
            if (DBG) log(getName() + message.toString());
            switch (message.what) {
                case CMD_DETECT_PORTAL:
                    NetworkInfo info = (NetworkInfo) message.obj;
                    // Checking on a secondary connection is not supported
                    // yet
                    notifyPortalCheckComplete(info);
                    break;
                case CMD_CONNECTIVITY_CHANGE:
                case CMD_DELAYED_CAPTIVE_CHECK:
                    break;
                default:
            loge("Ignoring " + message);
                    break;
            }
            return HANDLED;
        }
    }
@@ -316,19 +298,6 @@ public class CaptivePortalTracker extends StateMachine {
        }
    }

    private void notifyPortalCheckComplete(NetworkInfo info) {
        if (info == null) {
            loge("notifyPortalCheckComplete on null");
            return;
        }
        try {
            if (DBG) log("notifyPortalCheckComplete: ni=" + info);
            mConnService.captivePortalCheckComplete(info);
        } catch(RemoteException e) {
            e.printStackTrace();
        }
    }

    private void notifyPortalCheckCompleted(NetworkInfo info, boolean isCaptivePortal) {
        if (info == null) {
            loge("notifyPortalCheckComplete on null");
@@ -464,7 +433,6 @@ public class CaptivePortalTracker extends StateMachine {
                latencyBroadcast.putExtra(EXTRA_NETWORK_TYPE, mTelephonyManager.getNetworkType());
                List<CellInfo> info = mTelephonyManager.getAllCellInfo();
                if (info == null) return;
                StringBuffer uniqueCellId = new StringBuffer();
                int numRegisteredCellInfo = 0;
                for (CellInfo cellInfo : info) {
                    if (cellInfo.isRegistered()) {
+0 −18
Original line number Diff line number Diff line
@@ -1328,24 +1328,6 @@ public class ConnectivityManager {
        }
    }

    /**
     * Signal that the captive portal check on the indicated network
     * is complete and we can turn the network on for general use.
     *
     * @param info the {@link NetworkInfo} object for the networkType
     *        in question.
     *
     * <p>This method requires the call to hold the permission
     * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}.
     * {@hide}
     */
    public void captivePortalCheckComplete(NetworkInfo info) {
        try {
            mService.captivePortalCheckComplete(info);
        } catch (RemoteException e) {
        }
    }

    /**
     * Signal that the captive portal check on the indicated network
     * is complete and whether its a captive portal or not.
+0 −5
Original line number Diff line number Diff line
@@ -116,11 +116,6 @@ public class DummyDataStateTracker extends BaseNetworkStateTracker {
        return true;
    }

    @Override
    public void captivePortalCheckComplete() {
        // not implemented
    }

    @Override
    public void captivePortalCheckCompleted(boolean isCaptivePortal) {
        // not implemented
Loading