diff --git a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java index 57e155a04bd70..3601a0aa57461 100644 --- a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java +++ b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java @@ -58,6 +58,7 @@ import java.util.Random; public class CaptivePortalLoginActivity extends Activity { private static final String TAG = CaptivePortalLoginActivity.class.getSimpleName(); private static final boolean DBG = true; + private static final boolean VDBG = false; private static final int SOCKET_TIMEOUT_MS = 10000; @@ -311,6 +312,7 @@ public class CaptivePortalLoginActivity extends Activity { private class MyWebViewClient extends WebViewClient { private static final String INTERNAL_ASSETS = "file:///android_asset/"; + private final String mBrowserBailOutToken = Long.toString(new Random().nextLong()); // How many Android device-independent-pixels per scaled-pixel // dp/sp = (px/sp) / (px/dp) = (1/sp) / (1/dp) @@ -363,12 +365,6 @@ public class CaptivePortalLoginActivity extends Activity { testForCaptivePortal(); } - // Convert Android device-independent-pixels (dp) to HTML size. - private String dp(int dp) { - // HTML px's are scaled just like dp's, so just add "px" suffix. - return Integer.toString(dp) + "px"; - } - // Convert Android scaled-pixels (sp) to HTML size. private String sp(int sp) { // Convert sp to dp's. @@ -376,25 +372,11 @@ public class CaptivePortalLoginActivity extends Activity { // Apply a scale factor to make things look right. dp *= 1.3; // Convert dp's to HTML size. - return dp((int)dp); + // HTML px's are scaled just like dp's, so just add "px" suffix. + return Integer.toString((int)dp) + "px"; } // A web page consisting of a large broken lock icon to indicate SSL failure. - private final String SSL_ERROR_HTML = "


" + - "

%s
" + - "
%s
" + - "%s"; @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { @@ -402,10 +384,63 @@ public class CaptivePortalLoginActivity extends Activity { // Only show host to avoid leaking private info. Uri.parse(error.getUrl()).getHost() + " certificate: " + error.getCertificate() + "); displaying SSL warning."); - final String html = String.format(SSL_ERROR_HTML, getString(R.string.ssl_error_warning), - getString(R.string.ssl_error_example), mBrowserBailOutToken, - getString(R.string.ssl_error_continue)); - view.loadDataWithBaseURL(INTERNAL_ASSETS, html, "text/HTML", "UTF-8", null); + final String sslErrorPage = makeSslErrorPage(); + if (VDBG) { + Log.d(TAG, sslErrorPage); + } + view.loadDataWithBaseURL(INTERNAL_ASSETS, sslErrorPage, "text/HTML", "UTF-8", null); + } + + private String makeSslErrorPage() { + final String warningMsg = getString(R.string.ssl_error_warning); + final String exampleMsg = getString(R.string.ssl_error_example); + final String continueMsg = getString(R.string.ssl_error_continue); + return String.join("\n", + "", + "", + " ", + " ", + "", + "", + "


", + "

" + warningMsg + "
", + "
" + exampleMsg + "
", + " " + continueMsg + "", + "", + ""); } @Override