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

Commit 83b00258 authored by Kristian Monsen's avatar Kristian Monsen Committed by Android (Google) Code Review
Browse files

Merge "Fix for bug 8577776 Throw exception if app calls WebView used on wrong...

Merge "Fix for bug 8577776 Throw exception if app calls WebView used on wrong thread" into jb-mr2-dev
parents bf26c9cf b5cd8c0a
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.graphics.Picture;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.http.SslCertificate;
import android.os.Build;
import android.os.Bundle;
import android.os.Looper;
import android.os.Message;
@@ -241,6 +242,11 @@ public class WebView extends AbsoluteLayout

    private static final String LOGTAG = "webview_proxy";

    // Throwing an exception for incorrect thread usage if the
    // build target is JB MR2 or newer. Defaults to false, and is
    // set in the WebView constructor.
    private static Boolean sEnforceThreadChecking = false;

    /**
     *  Transportation object for returning WebView across thread boundaries.
     */
@@ -483,6 +489,8 @@ public class WebView extends AbsoluteLayout
        if (context == null) {
            throw new IllegalArgumentException("Invalid context argument");
        }
        sEnforceThreadChecking = context.getApplicationInfo().targetSdkVersion >=
                Build.VERSION_CODES.JELLY_BEAN_MR2;
        checkThread();

        ensureProviderCreated();
@@ -1915,6 +1923,10 @@ public class WebView extends AbsoluteLayout
                    "Future versions of WebView may not support use on other threads.");
            Log.w(LOGTAG, Log.getStackTraceString(throwable));
            StrictMode.onWebViewMethodCalledOnWrongThread(throwable);

            if (sEnforceThreadChecking) {
                throw new RuntimeException(throwable);
            }
        }
    }