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

Commit 01673699 authored by Gustav Sennton's avatar Gustav Sennton
Browse files

Add an API to fetch the WebView thread.

Some WebView APIs contain checks ensuring apps only use WebView APIs
from one single thread. The WebView Support Library should perform
similar thread checks. To do so we publish an API to get the WebView
thread, so that the support library knows which thread to check against.

Test: Ran the corresponding CTS tests.
Bug: 38220806
Change-Id: Ibab878e211d9594df6d39f99ce130e28fac7f019
parent 6ba8bc8a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -50280,6 +50280,7 @@ package android.webkit {
    method public android.graphics.Bitmap getFavicon();
    method public android.webkit.WebView.HitTestResult getHitTestResult();
    method public deprecated java.lang.String[] getHttpAuthUsernamePassword(java.lang.String, java.lang.String);
    method public android.os.Looper getLooper();
    method public java.lang.String getOriginalUrl();
    method public int getProgress();
    method public boolean getRendererPriorityWaivedWhenNotVisible();
+12 −0
Original line number Diff line number Diff line
@@ -663,6 +663,10 @@ public class WebView extends AbsoluteLayout
        if (context == null) {
            throw new IllegalArgumentException("Invalid context argument");
        }
        if (mWebViewThread == null) {
            throw new RuntimeException(
                "WebView cannot be initialized on a thread that has no Looper.");
        }
        sEnforceThreadChecking = context.getApplicationInfo().targetSdkVersion >=
                Build.VERSION_CODES.JELLY_BEAN_MR2;
        checkThread();
@@ -2422,6 +2426,14 @@ public class WebView extends AbsoluteLayout
        return getFactory().getWebViewClassLoader();
    }

    /**
     * Returns the {@link Looper} corresponding to the thread on which WebView calls must be made.
     */
    @NonNull
    public Looper getLooper() {
        return mWebViewThread;
    }

    //-------------------------------------------------------------------------
    // Interface for WebView providers
    //-------------------------------------------------------------------------