CaptivePortalLoginActivity correctly gets UserAgent
Change I33cbcdab9809c712d998da6d925bdd4e3093f8ff added to the intent passed from NetworkMonitor to the CaptivePortalLoginActivity an extra argument to set the UserAgent header of probes done by the CaptivePortalLoginActivity. However that extra String argument is not correctly retrieved from the Intent and instead a null pointer is returned by getParcelableExtra(). Consequently the UserAgent header field is never set. This patch fixes this bug and replace getParcelableExtra() with getStringExtra(). It also adds logging of the request header and response header for every network probes sent by CaptivePortalLoginActivity. Bug: 35937367, 32369183 Test: manually tested Change-Id: If5c463023474ffb0401f3cda5875ccd9fc6f79f9
This commit is contained in:
@@ -77,8 +77,8 @@ public class CaptivePortalLoginActivity extends Activity {
|
||||
mCm = ConnectivityManager.from(this);
|
||||
mNetwork = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_NETWORK);
|
||||
mCaptivePortal = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL);
|
||||
mUserAgent = getIntent().getParcelableExtra(
|
||||
ConnectivityManager.EXTRA_CAPTIVE_PORTAL_USER_AGENT);
|
||||
mUserAgent =
|
||||
getIntent().getStringExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL_USER_AGENT);
|
||||
mUrl = getUrl();
|
||||
if (mUrl == null) {
|
||||
// getUrl() failed to parse the url provided in the intent: bail out in a way that
|
||||
@@ -274,8 +274,17 @@ public class CaptivePortalLoginActivity extends Activity {
|
||||
if (mUserAgent != null) {
|
||||
urlConnection.setRequestProperty("User-Agent", mUserAgent);
|
||||
}
|
||||
// cannot read request header after connection
|
||||
String requestHeader = urlConnection.getRequestProperties().toString();
|
||||
|
||||
urlConnection.getInputStream();
|
||||
httpResponseCode = urlConnection.getResponseCode();
|
||||
if (DBG) {
|
||||
Log.d(TAG, "probe at " + mUrl +
|
||||
" ret=" + httpResponseCode +
|
||||
" request=" + requestHeader +
|
||||
" headers=" + urlConnection.getHeaderFields());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} finally {
|
||||
if (urlConnection != null) urlConnection.disconnect();
|
||||
|
||||
@@ -789,6 +789,8 @@ public class NetworkMonitor extends StateMachine {
|
||||
if (userAgent != null) {
|
||||
urlConnection.setRequestProperty("User-Agent", userAgent);
|
||||
}
|
||||
// cannot read request header after connection
|
||||
String requestHeader = urlConnection.getRequestProperties().toString();
|
||||
|
||||
// Time how long it takes to get a response to our request
|
||||
long requestTimestamp = SystemClock.elapsedRealtime();
|
||||
@@ -802,6 +804,7 @@ public class NetworkMonitor extends StateMachine {
|
||||
validationLog(ValidationProbeEvent.getProbeName(probeType) + " " + url +
|
||||
" time=" + (responseTimestamp - requestTimestamp) + "ms" +
|
||||
" ret=" + httpResponseCode +
|
||||
" request=" + requestHeader +
|
||||
" headers=" + urlConnection.getHeaderFields());
|
||||
// NOTE: We may want to consider an "HTTP/1.0 204" response to be a captive
|
||||
// portal. The only example of this seen so far was a captive portal. For
|
||||
|
||||
Reference in New Issue
Block a user