diff options
| author | Gustav Sennton <gsennton@google.com> | 2018-01-19 12:11:25 +0000 |
|---|---|---|
| committer | Gustav Sennton <gsennton@google.com> | 2018-01-24 14:39:45 +0000 |
| commit | 0167369990eefda2166221cf88cd0eba25d6eb1f (patch) | |
| tree | 6ccd2b82b673a66ba35222a02d3fbf9c428858dc /core/java/android/webkit/WebView.java | |
| parent | 6ba8bc8a476662fd74feb4a07d65ecf236d7e622 (diff) | |
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
Diffstat (limited to 'core/java/android/webkit/WebView.java')
| -rw-r--r-- | core/java/android/webkit/WebView.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 00860a42a546..2c51ee940039 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -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 //------------------------------------------------------------------------- |
