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

Commit ee8feae5 authored by Paul Jensen's avatar Paul Jensen Committed by Android (Google) Code Review
Browse files

Merge "Show broken lock image when SSL errors are encountered in...

Merge "Show broken lock image when SSL errors are encountered in CaptivePortalLogin." into lmp-mr1-dev
parents 296aa925 fc8022f8
Loading
Loading
Loading
Loading
+7.68 KiB
Loading image diff...
+15 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
import android.net.Proxy;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Bundle;
import android.provider.Settings;
import android.provider.Settings.Global;
@@ -37,6 +38,7 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.webkit.SslErrorHandler;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
@@ -251,6 +253,19 @@ public class CaptivePortalLoginActivity extends Activity {
            }
            testForCaptivePortal();
        }

        // A web page consisting of a large broken lock icon to indicate SSL failure.
        final static String SSL_ERROR_HTML = "<!DOCTYPE html><html><head><style>" +
                "html { width:100%; height:100%; " +
                "       background:url(locked_page.png) center center no-repeat; }" +
                "</style></head><body></body></html>";

        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
            Log.w(TAG, "SSL error; displaying broken lock icon.");
            view.loadDataWithBaseURL("file:///android_asset/", SSL_ERROR_HTML, "text/HTML",
                    "UTF-8", null);
        }
    }

    private class MyWebChromeClient extends WebChromeClient {