mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 17:32:51 +08:00
[CB-3384] Use the ExposedJsApi to detect webCore thread instead of IceCreamCordovaWebViewClient.
Also removes a debug log statement.
This commit is contained in:
parent
71b19f591e
commit
88b289d815
@ -26,7 +26,6 @@ import android.database.Cursor;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.Base64InputStream;
|
|
||||||
|
|
||||||
import com.squareup.okhttp.OkHttpClient;
|
import com.squareup.okhttp.OkHttpClient;
|
||||||
|
|
||||||
@ -62,7 +61,7 @@ public class CordovaResourceApi {
|
|||||||
// Creating this is light-weight.
|
// Creating this is light-weight.
|
||||||
private static OkHttpClient httpClient = new OkHttpClient();
|
private static OkHttpClient httpClient = new OkHttpClient();
|
||||||
|
|
||||||
static Thread webCoreThread;
|
static Thread jsThread;
|
||||||
|
|
||||||
private final AssetManager assetManager;
|
private final AssetManager assetManager;
|
||||||
private final ContentResolver contentResolver;
|
private final ContentResolver contentResolver;
|
||||||
@ -294,7 +293,7 @@ public class CordovaResourceApi {
|
|||||||
if (curThread == Looper.getMainLooper().getThread()) {
|
if (curThread == Looper.getMainLooper().getThread()) {
|
||||||
throw new IllegalStateException("Do not perform IO operations on the UI thread. Use CordovaInterface.getThreadPool() instead.");
|
throw new IllegalStateException("Do not perform IO operations on the UI thread. Use CordovaInterface.getThreadPool() instead.");
|
||||||
}
|
}
|
||||||
if (curThread == webCoreThread) {
|
if (curThread == jsThread) {
|
||||||
throw new IllegalStateException("Tried to perform an IO operation on the WebCore thread. Use CordovaInterface.getThreadPool() instead.");
|
throw new IllegalStateException("Tried to perform an IO operation on the WebCore thread. Use CordovaInterface.getThreadPool() instead.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ package org.apache.cordova;
|
|||||||
|
|
||||||
import android.webkit.JavascriptInterface;
|
import android.webkit.JavascriptInterface;
|
||||||
import org.apache.cordova.PluginManager;
|
import org.apache.cordova.PluginManager;
|
||||||
import org.apache.cordova.PluginResult;
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,6 +47,9 @@ import org.json.JSONException;
|
|||||||
|
|
||||||
jsMessageQueue.setPaused(true);
|
jsMessageQueue.setPaused(true);
|
||||||
try {
|
try {
|
||||||
|
// Tell the resourceApi what thread the JS is running on.
|
||||||
|
CordovaResourceApi.jsThread = Thread.currentThread();
|
||||||
|
|
||||||
pluginManager.exec(service, action, callbackId, arguments);
|
pluginManager.exec(service, action, callbackId, arguments);
|
||||||
String ret = "";
|
String ret = "";
|
||||||
if (!NativeToJsMessageQueue.DISABLE_EXEC_CHAINING) {
|
if (!NativeToJsMessageQueue.DISABLE_EXEC_CHAINING) {
|
||||||
|
@ -27,7 +27,6 @@ import org.apache.cordova.LOG;
|
|||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.Log;
|
|
||||||
import android.webkit.WebResourceResponse;
|
import android.webkit.WebResourceResponse;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
|
||||||
@ -46,9 +45,6 @@ public class IceCreamCordovaWebViewClient extends CordovaWebViewClient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
|
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
|
||||||
// Tell the Thread-Checking resolve what thread the WebCore thread is.
|
|
||||||
CordovaResourceApi.webCoreThread = Thread.currentThread();
|
|
||||||
Log.e("WHAAAA", "FOOD " + CordovaResourceApi.webCoreThread);
|
|
||||||
try {
|
try {
|
||||||
// Check the against the white-list.
|
// Check the against the white-list.
|
||||||
if ((url.startsWith("http:") || url.startsWith("https:")) && !Config.isUrlWhiteListed(url)) {
|
if ((url.startsWith("http:") || url.startsWith("https:")) && !Config.isUrlWhiteListed(url)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user