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

Commit 3e86e2a8 authored by xshu's avatar xshu
Browse files

WifiConfiguration is captive portal never detected

Creates a new field in the WifiConfiguration to distinguish networks
that have never used captive portal.

Bug: 162801581
Test: atest android.net.wifi
Change-Id: I027b1b45890f5d158350ab40023772493d98f8fd
parent 60eec1c7
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -1625,6 +1625,14 @@ public class WifiConfiguration implements Parcelable {
         */
        private boolean mHasEverConnected;

        /**
         * Boolean indicating if captive portal has never been detected on this network.
         *
         * This should be true by default, for newly created WifiConfigurations until a captive
         * portal is detected.
         */
        private boolean mHasNeverDetectedCaptivePortal = true;

        /**
         * set whether this network is visible in latest Qualified Network Selection
         * @param seen value set to candidate
@@ -1714,6 +1722,19 @@ public class WifiConfiguration implements Parcelable {
            return mHasEverConnected;
        }

        /**
         * Set whether a captive portal has never been detected on this network.
         * @hide
         */
        public void setHasNeverDetectedCaptivePortal(boolean value) {
            mHasNeverDetectedCaptivePortal = value;
        }

        /** @hide */
        public boolean hasNeverDetectedCaptivePortal() {
            return mHasNeverDetectedCaptivePortal;
        }

        /** @hide */
        public NetworkSelectionStatus() {
            // previously stored configs will not have this parameter, so we default to false.
@@ -1989,6 +2010,7 @@ public class WifiConfiguration implements Parcelable {
            setCandidateScore(source.getCandidateScore());
            setConnectChoice(source.getConnectChoice());
            setHasEverConnected(source.hasEverConnected());
            setHasNeverDetectedCaptivePortal(source.hasNeverDetectedCaptivePortal());
        }

        /** @hide */
@@ -2008,6 +2030,7 @@ public class WifiConfiguration implements Parcelable {
                dest.writeInt(CONNECT_CHOICE_NOT_EXISTS);
            }
            dest.writeInt(hasEverConnected() ? 1 : 0);
            dest.writeInt(hasNeverDetectedCaptivePortal() ? 1 : 0);
        }

        /** @hide */
@@ -2026,6 +2049,7 @@ public class WifiConfiguration implements Parcelable {
                setConnectChoice(null);
            }
            setHasEverConnected(in.readInt() != 0);
            setHasNeverDetectedCaptivePortal(in.readInt() != 0);
        }
    }

@@ -2287,6 +2311,8 @@ public class WifiConfiguration implements Parcelable {
        }
        sbuf.append(" hasEverConnected: ")
                .append(mNetworkSelectionStatus.hasEverConnected()).append("\n");
        sbuf.append(" hasNeverDetectedCaptivePortal: ")
                .append(mNetworkSelectionStatus.hasNeverDetectedCaptivePortal()).append("\n");

        if (this.numAssociation > 0) {
            sbuf.append(" numAssociation ").append(this.numAssociation).append("\n");