Don't display the "no Internet access" prompt on captive portals.
Bug: 20081183
Bug: 21066461
Change-Id: Idc71844a604f9ca655411c6916de256780ea4586
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 0961ffe..16b3dcf 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -1982,7 +1982,7 @@
if (msg.arg1 == 0) {
setProvNotificationVisibleIntent(false, msg.arg2, 0, null, null);
} else {
- NetworkAgentInfo nai = null;
+ final NetworkAgentInfo nai;
synchronized (mNetworkForNetId) {
nai = mNetworkForNetId.get(msg.arg2);
}
@@ -1990,6 +1990,7 @@
loge("EVENT_PROVISIONING_NOTIFICATION from unknown NetworkMonitor");
break;
}
+ nai.captivePortalDetected = true;
setProvNotificationVisibleIntent(true, msg.arg2, nai.networkInfo.getType(),
nai.networkInfo.getExtraInfo(), (PendingIntent)msg.obj);
}
@@ -2384,7 +2385,8 @@
// Only prompt if the network is unvalidated and was explicitly selected by the user, and if
// we haven't already been told to switch to it regardless of whether it validated or not.
- if (nai == null || nai.everValidated ||
+ // Also don't prompt on captive portals because we're already prompting the user to sign in.
+ if (nai == null || nai.everValidated || nai.captivePortalDetected ||
!nai.networkMisc.explicitlySelected || nai.networkMisc.acceptUnvalidated) {
return;
}
diff --git a/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java b/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java
index 8a7c902..eac748f 100644
--- a/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java
+++ b/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java
@@ -50,12 +50,11 @@
public final NetworkMisc networkMisc;
// Indicates if netd has been told to create this Network. Once created the appropriate routing
// rules are setup and routes are added so packets can begin flowing over the Network.
- // NOTE: This is a sticky bit; once set it is never cleared.
+ // This is a sticky bit; once set it is never cleared.
public boolean created;
// Set to true if this Network successfully passed validation or if it did not satisfy the
// default NetworkRequest in which case validation will not be attempted.
- // NOTE: This is a sticky bit; once set it is never cleared even if future validation attempts
- // fail.
+ // This is a sticky bit; once set it is never cleared even if future validation attempts fail.
public boolean everValidated;
// The result of the last validation attempt on this network (true if validated, false if not).
@@ -65,6 +64,10 @@
// TODO: Fix the network scoring code, remove this, and rename everValidated to validated.
public boolean lastValidated;
+ // Whether a captive portal was ever detected on this network.
+ // This is a sticky bit; once set it is never cleared.
+ public boolean captivePortalDetected;
+
// This represents the last score received from the NetworkAgent.
private int currentScore;
// Penalty applied to scores of Networks that have not been validated.
@@ -101,9 +104,6 @@
currentScore = score;
networkMonitor = new NetworkMonitor(context, handler, this, defaultRequest);
networkMisc = misc;
- created = false;
- everValidated = false;
- lastValidated = false;
}
public void addRequest(NetworkRequest networkRequest) {
@@ -166,6 +166,7 @@
"created{" + created + "} " +
"explicitlySelected{" + networkMisc.explicitlySelected + "} " +
"acceptUnvalidated{" + networkMisc.acceptUnvalidated + "} " +
+ "captivePortalDetected{" + captivePortalDetected + "} " +
"}";
}