From 3e86e2a844d8ec7a32e9a1b668372222bb326cea Mon Sep 17 00:00:00 2001 From: xshu Date: Mon, 12 Oct 2020 19:01:54 -0700 Subject: [PATCH] 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 --- .../android/net/wifi/WifiConfiguration.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java index 7c2556d8cffd4..fd4e1ddac3a2a 100644 --- a/wifi/java/android/net/wifi/WifiConfiguration.java +++ b/wifi/java/android/net/wifi/WifiConfiguration.java @@ -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");