OSDN Git Service

fix cellular captive portal reevaluation url
authorfionaxu <fionaxu@google.com>
Mon, 10 Jul 2017 16:34:07 +0000 (09:34 -0700)
committerChen Xu <fionaxu@google.com>
Thu, 7 Sep 2017 18:49:55 +0000 (18:49 +0000)
we apply redirection link as the url everywhere for cellular captive portal.
this url should only be used when load the portal page at the first place (when users
click on the notification) and shouldn't be used as the re-evaluation url
as it wont return the expected response code.
instead we should use special URL (generate_204) from connectivity
service which will return 204 if redirection is gone.

Test: manual test with cold and hot TMO SIM
Bug: 62532802
Change-Id: I56bb03a58447c5c46758e692ff357d540ea4cd7b

packages/CarrierDefaultApp/src/com/android/carrierdefaultapp/CaptivePortalLoginActivity.java

index c1f03fd..ae8fc80 100644 (file)
@@ -226,7 +226,8 @@ public class CaptivePortalLoginActivity extends Activity {
                 int httpResponseCode = 500;
                 int oldTag = TrafficStats.getAndSetThreadStatsTag(TrafficStats.TAG_SYSTEM_PROBE);
                 try {
-                    urlConnection = (HttpURLConnection) mNetwork.openConnection(mUrl);
+                    urlConnection = (HttpURLConnection) mNetwork.openConnection(
+                            new URL(mCm.getCaptivePortalServerUrl()));
                     urlConnection.setInstanceFollowRedirects(false);
                     urlConnection.setConnectTimeout(SOCKET_TIMEOUT_MS);
                     urlConnection.setReadTimeout(SOCKET_TIMEOUT_MS);
@@ -234,6 +235,7 @@ public class CaptivePortalLoginActivity extends Activity {
                     urlConnection.getInputStream();
                     httpResponseCode = urlConnection.getResponseCode();
                 } catch (IOException e) {
+                    loge(e.getMessage());
                 } finally {
                     if (urlConnection != null) urlConnection.disconnect();
                     TrafficStats.setThreadStatsTag(oldTag);