OSDN Git Service

Captive portals: reinspect http result after fallback probe
authorHugo Benichi <hugobenichi@google.com>
Wed, 17 May 2017 01:30:40 +0000 (10:30 +0900)
committerHugo Benichi <hugobenichi@google.com>
Thu, 18 May 2017 02:53:10 +0000 (11:53 +0900)
When DNS queries that precede the http and https probe take a long time
to complete, it is possible that the fallback probe fires earlier than
either the http and https probes.

This causes the detection logic to ignore the result of the http probe,
which may cause the system to miss captive portals advertising
themselves on the url used by the http probe but not on the url used by
the fallback probe.

This patch fixes that issue by forcing the detection to wait on the
result of the http probe if the fallback probe does not find a portal.

Bug: 38259299
Bug: 36532213
Test: manually tested with nearby captive portal networks
Merged-In: I07ea23a2b5f694c5ada9633169af98409efedff1
Change-Id: Ie016cad52719d07167acf026f738d31000c78cd2

(cherry picked from commit fc47442b31761e64e188c51c3dd2a782ecbd9c62)

services/core/java/com/android/server/connectivity/NetworkMonitor.java

index 96f6f2d..11296ab 100644 (file)
@@ -960,14 +960,18 @@ public class NetworkMonitor extends StateMachine {
                 return result;
             }
         }
-        // Otherwise wait until https probe completes and use its result.
+        // Otherwise wait until http and https probes completes and use their results.
         try {
+            httpProbe.join();
+            if (httpProbe.result().isPortal()) {
+                return httpProbe.result();
+            }
             httpsProbe.join();
+            return httpsProbe.result();
         } catch (InterruptedException e) {
-            validationLog("Error: https probe wait interrupted!");
+            validationLog("Error: http or https probe wait interrupted!");
             return CaptivePortalProbeResult.FAILED;
         }
-        return httpsProbe.result();
     }
 
     private URL makeURL(String url) {