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

Commit 937c8eb0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Disallow WV APIs being used from different threads" into main

parents c9692cd2 2d9c4afc
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -121,8 +121,10 @@ public class WebView extends AbsoluteLayout
    // 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.
    // If `alwaysEnforceThreadChecking` flag is true, we will always throw an exception
    // irrespective of the value of this field.
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    private static volatile boolean sEnforceThreadChecking = false;
    private static volatile boolean sEnforceThreadChecking = Flags.alwaysEnforceThreadChecking();

    /**
     *  Transportation object for returning WebView across thread boundaries.
@@ -437,8 +439,10 @@ public class WebView extends AbsoluteLayout
            throw new RuntimeException(
                "WebView cannot be initialized on a thread that has no Looper.");
        }
        sEnforceThreadChecking = context.getApplicationInfo().targetSdkVersion >=
                Build.VERSION_CODES.JELLY_BEAN_MR2;
        if (!Flags.alwaysEnforceThreadChecking()) {
            sEnforceThreadChecking = context.getApplicationInfo().targetSdkVersion
                    >= Build.VERSION_CODES.JELLY_BEAN_MR2;
        }
        checkThread();

        ensureProviderCreated();
@@ -2661,7 +2665,7 @@ public class WebView extends AbsoluteLayout
            Log.w(LOGTAG, Log.getStackTraceString(throwable));
            StrictMode.onWebViewMethodCalledOnWrongThread(throwable);

            if (sEnforceThreadChecking) {
            if (Flags.alwaysEnforceThreadChecking() || sEnforceThreadChecking) {
                throw new RuntimeException(throwable);
            }
        }
+7 −0
Original line number Diff line number Diff line
@@ -42,3 +42,10 @@ flag {
    description: "New APIs required by File System Access"
    bug: "40101963"
}

flag {
    name: "always_enforce_thread_checking"
    namespace: "webview"
    description: "Always enforce that WebView APIs are called on the same thread"
    bug: "440569275"
}
 No newline at end of file