Merge "Fix CaptivePortalLoginActivity probes to bypass Private DNS"
This commit is contained in:
@@ -320,6 +320,7 @@ public class CaptivePortalLoginActivity extends Activity {
|
|||||||
// TODO: reuse NetworkMonitor facilities for consistent captive portal detection.
|
// TODO: reuse NetworkMonitor facilities for consistent captive portal detection.
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
final Network network = ResolvUtil.makeNetworkWithPrivateDnsBypass(mNetwork);
|
||||||
// Give time for captive portal to open.
|
// Give time for captive portal to open.
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
@@ -328,7 +329,7 @@ public class CaptivePortalLoginActivity extends Activity {
|
|||||||
HttpURLConnection urlConnection = null;
|
HttpURLConnection urlConnection = null;
|
||||||
int httpResponseCode = 500;
|
int httpResponseCode = 500;
|
||||||
try {
|
try {
|
||||||
urlConnection = (HttpURLConnection) mNetwork.openConnection(mUrl);
|
urlConnection = (HttpURLConnection) network.openConnection(mUrl);
|
||||||
urlConnection.setInstanceFollowRedirects(false);
|
urlConnection.setInstanceFollowRedirects(false);
|
||||||
urlConnection.setConnectTimeout(SOCKET_TIMEOUT_MS);
|
urlConnection.setConnectTimeout(SOCKET_TIMEOUT_MS);
|
||||||
urlConnection.setReadTimeout(SOCKET_TIMEOUT_MS);
|
urlConnection.setReadTimeout(SOCKET_TIMEOUT_MS);
|
||||||
|
|||||||
@@ -62,4 +62,13 @@ public class ResolvUtil {
|
|||||||
final long netidForResolv = NETID_USE_LOCAL_NAMESERVERS | (long) network.netId;
|
final long netidForResolv = NETID_USE_LOCAL_NAMESERVERS | (long) network.netId;
|
||||||
return new Network((int) netidForResolv);
|
return new Network((int) netidForResolv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Network makeNetworkWithPrivateDnsBypass(Network network) {
|
||||||
|
return new Network(network) {
|
||||||
|
@Override
|
||||||
|
public InetAddress[] getAllByName(String host) throws UnknownHostException {
|
||||||
|
return blockingResolveAllLocally(network, host);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user