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;
         }