Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 778ade90 authored by Hugo Benichi's avatar Hugo Benichi Committed by Gerrit Code Review
Browse files

Merge "DO NOT MERGE Instrument captive portal login activity"

parents b6dde12e 0c913bac
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -47,6 +47,9 @@ import android.webkit.WebViewClient;
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 @@ public class CaptivePortalLoginActivity extends Activity {

    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 @@ public class CaptivePortalLoginActivity extends Activity {
    @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 @@ public class CaptivePortalLoginActivity extends Activity {
            mCm.unregisterNetworkCallback(mNetworkCallback);
            mNetworkCallback = null;
        }
        logMetricsEvent(result.metricsEvent);
        switch (result) {
            case DISMISSED:
                mCaptivePortal.reportCaptivePortalDismissed();
@@ -381,6 +395,7 @@ public class CaptivePortalLoginActivity extends Activity {

        @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 @@ public class CaptivePortalLoginActivity extends Activity {
        }
        return url.getHost();
    }

    private void logMetricsEvent(int event) {
        MetricsLogger.action(this, event, getPackageName());
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -2278,6 +2278,11 @@ message MetricsEvent {
    // 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
  }