DO NOT MERGE Instrument captive portal login activity
Also add CAPTIVE_PORTAL_LOGIN_ACTIVITY_SSL_ERROR constants to
metrics_constants.proto for counting ssl error pages shown by the
captive portal login activity.
Bug: 36203355
Bug: 34901696
Bug: 36532213
Test: manually tested with captive portal testing setup while watching
event logs: adb logcat -b events | grep captiveportallogin
06-08 16:25:20.279 21558 21558 I sysui_action: [1004,com.android.captiveportallogin]
06-08 17:01:04.052 21558 21558 I sysui_action: [1007,com.android.captiveportallogin]
Merged-In: Ia05853506d424ad4cb2c11770ae7718fbef3f01c
(cherry picked from commit c61dc92fc0619d101c4b789f6305012701cc47a0)
(cherry picked with DO NOT MERGE because oc-dev-plus-aosp already
contains a version of this commit compatible with proto2).
Change-Id: I55ea3c61842f16bf6a98e812fb6dc940f96f895c
diff --git a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
index d13f37a..71d9fc8 100644
--- a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
+++ b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
@@ -47,6 +47,9 @@
import android.widget.ProgressBar;
import android.widget.TextView;
+import com.android.internal.logging.MetricsLogger;
+import com.android.internal.logging.MetricsProto.MetricsEvent;
+
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
@@ -63,7 +66,14 @@
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 String mUserAgent;
@@ -77,6 +87,9 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
+ logMetricsEvent(MetricsEvent.ACTION_CAPTIVE_PORTAL_LOGIN_ACTIVITY);
+
mCm = ConnectivityManager.from(this);
mNetwork = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_NETWORK);
mCaptivePortal = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL);
@@ -173,6 +186,7 @@
mCm.unregisterNetworkCallback(mNetworkCallback);
mNetworkCallback = null;
}
+ logMetricsEvent(result.metricsEvent);
switch (result) {
case DISMISSED:
mCaptivePortal.reportCaptivePortalDismissed();
@@ -381,6 +395,7 @@
@Override
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: " +
// Only show host to avoid leaking private info.
Uri.parse(error.getUrl()).getHost() + " certificate: " +
@@ -492,4 +507,8 @@
}
return url.getHost();
}
+
+ private void logMetricsEvent(int event) {
+ MetricsLogger.action(this, event, getPackageName());
+ }
}
diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto
index 8bc7520..58f1cd8 100644
--- a/proto/src/metrics_constants.proto
+++ b/proto/src/metrics_constants.proto
@@ -2278,6 +2278,11 @@
// OS: O DR
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.
// END OF AOSP CONSTANTS
}