Merge "Instrument captive portal login activity" into stage-aosp-master
This commit is contained in:
@@ -47,6 +47,9 @@ import android.webkit.WebViewClient;
|
|||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.android.internal.logging.MetricsLogger;
|
||||||
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
@@ -64,7 +67,14 @@ public class CaptivePortalLoginActivity extends Activity {
|
|||||||
|
|
||||||
private static final int SOCKET_TIMEOUT_MS = 10000;
|
private static final int SOCKET_TIMEOUT_MS = 10000;
|
||||||
|
|
||||||
private enum Result { DISMISSED, UNWANTED, WANTED_AS_IS };
|
private enum Result {
|
||||||
|
DISMISSED(MetricsEvent.ACTION_CAPTIVE_PORTAL_LOGIN_RESULT_DISMISSED),
|
||||||
|
UNWANTED(MetricsEvent.ACTION_CAPTIVE_PORTAL_LOGIN_RESULT_UNWANTED),
|
||||||
|
WANTED_AS_IS(MetricsEvent.ACTION_CAPTIVE_PORTAL_LOGIN_RESULT_WANTED_AS_IS);
|
||||||
|
|
||||||
|
final int metricsEvent;
|
||||||
|
Result(int metricsEvent) { this.metricsEvent = metricsEvent; }
|
||||||
|
};
|
||||||
|
|
||||||
private URL mUrl;
|
private URL mUrl;
|
||||||
private String mUserAgent;
|
private String mUserAgent;
|
||||||
@@ -80,6 +90,9 @@ public class CaptivePortalLoginActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
logMetricsEvent(MetricsEvent.ACTION_CAPTIVE_PORTAL_LOGIN_ACTIVITY);
|
||||||
|
|
||||||
mCm = ConnectivityManager.from(this);
|
mCm = ConnectivityManager.from(this);
|
||||||
mNetwork = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_NETWORK);
|
mNetwork = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_NETWORK);
|
||||||
mCaptivePortal = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL);
|
mCaptivePortal = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL);
|
||||||
@@ -176,6 +189,7 @@ public class CaptivePortalLoginActivity extends Activity {
|
|||||||
if (DBG) {
|
if (DBG) {
|
||||||
Log.d(TAG, String.format("Result %s for %s", result.name(), mUrl.toString()));
|
Log.d(TAG, String.format("Result %s for %s", result.name(), mUrl.toString()));
|
||||||
}
|
}
|
||||||
|
logMetricsEvent(result.metricsEvent);
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case DISMISSED:
|
case DISMISSED:
|
||||||
mCaptivePortal.reportCaptivePortalDismissed();
|
mCaptivePortal.reportCaptivePortalDismissed();
|
||||||
@@ -387,6 +401,7 @@ public class CaptivePortalLoginActivity extends Activity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
|
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
|
||||||
|
logMetricsEvent(MetricsEvent.CAPTIVE_PORTAL_LOGIN_ACTIVITY_SSL_ERROR);
|
||||||
Log.w(TAG, "SSL error (error: " + error.getPrimaryError() + " host: " +
|
Log.w(TAG, "SSL error (error: " + error.getPrimaryError() + " host: " +
|
||||||
// Only show host to avoid leaking private info.
|
// Only show host to avoid leaking private info.
|
||||||
Uri.parse(error.getUrl()).getHost() + " certificate: " +
|
Uri.parse(error.getUrl()).getHost() + " certificate: " +
|
||||||
@@ -498,4 +513,8 @@ public class CaptivePortalLoginActivity extends Activity {
|
|||||||
}
|
}
|
||||||
return url.getHost();
|
return url.getHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void logMetricsEvent(int event) {
|
||||||
|
MetricsLogger.action(this, event, getPackageName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3999,6 +3999,11 @@ message MetricsEvent {
|
|||||||
// OS: O DR
|
// OS: O DR
|
||||||
ACTION_WIFI_SIGNIN = 1008;
|
ACTION_WIFI_SIGNIN = 1008;
|
||||||
|
|
||||||
|
// CaptivePortalLoginActivity displays SSL error page
|
||||||
|
// CATEGORY: GLOBAL_SYSTEM_UI
|
||||||
|
// OS: O DR
|
||||||
|
CAPTIVE_PORTAL_LOGIN_ACTIVITY_SSL_ERROR = 1013;
|
||||||
|
|
||||||
// Add new aosp constants above this line.
|
// Add new aosp constants above this line.
|
||||||
// END OF AOSP CONSTANTS
|
// END OF AOSP CONSTANTS
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user