From fc47442b31761e64e188c51c3dd2a782ecbd9c62 Mon Sep 17 00:00:00 2001 From: Hugo Benichi Date: Wed, 17 May 2017 10:30:40 +0900 Subject: [PATCH] Captive portals: reinspect http result after fallback probe 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 Change-Id: I07ea23a2b5f694c5ada9633169af98409efedff1 --- .../android/server/connectivity/NetworkMonitor.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/NetworkMonitor.java b/services/core/java/com/android/server/connectivity/NetworkMonitor.java index 4dcf4251abadd..b41bceca3b4c1 100644 --- a/services/core/java/com/android/server/connectivity/NetworkMonitor.java +++ b/services/core/java/com/android/server/connectivity/NetworkMonitor.java @@ -967,14 +967,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) {