OSDN Git Service

Change network validation probe default configs
authorHugo Benichi <hugobenichi@google.com>
Tue, 27 Sep 2016 04:16:19 +0000 (13:16 +0900)
committerHugo Benichi <hugobenichi@google.com>
Wed, 28 Sep 2016 23:35:19 +0000 (08:35 +0900)
This patch changes the default configuration values for captive
portal detection.

Now by default:
  - the HTTPS probe tries to connect to www.google.com/generate_204
    instead of connectivitycheck.gstatic.com/generate_204
  - the fallback probe is used and tries to connect to
    google.com/gen_204
  - the request header User-Agent field is set to appears similar to
    a Chrome request.

Bug: 29367974
Change-Id: Ic965e2693e154e96bf0f7e4c1b9a2f704b9c3452

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

index 13f3174..6eb89fa 100644 (file)
@@ -82,13 +82,16 @@ public class NetworkMonitor extends StateMachine {
     private static final String TAG = NetworkMonitor.class.getSimpleName();
     private static final boolean DBG = false;
 
-    // Default urls for captive portal detection probes
-    private static final String DEFAULT_HTTPS_URL     =
-            "https://connectivitycheck.gstatic.com/generate_204";
+    // Default configuration values for captive portal detection probes.
+    // TODO: append a random length parameter to the default HTTPS url.
+    // TODO: randomize browser version ids in the default User-Agent String.
+    private static final String DEFAULT_HTTPS_URL     = "https://www.google.com/generate_204";
     private static final String DEFAULT_HTTP_URL      =
             "http://connectivitycheck.gstatic.com/generate_204";
-    private static final String DEFAULT_FALLBACK_URL  = null;
-    private static final String DEFAULT_USER_AGENT    = null;
+    private static final String DEFAULT_FALLBACK_URL  = "http://www.google.com/gen_204";
+    private static final String DEFAULT_USER_AGENT    = "Mozilla/5.0 (X11; Linux x86_64) "
+                                                      + "AppleWebKit/537.36 (KHTML, like Gecko) "
+                                                      + "Chrome/52.0.2743.82 Safari/537.36";
 
     private static final int SOCKET_TIMEOUT_MS = 10000;
     private static final int PROBE_TIMEOUT_MS  = 3000;