From 88b289d8156b24d0d89e0bd1fd07d68958014dae Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Tue, 16 Jul 2013 09:32:29 -0400 Subject: [PATCH] [CB-3384] Use the ExposedJsApi to detect webCore thread instead of IceCreamCordovaWebViewClient. Also removes a debug log statement. --- framework/src/org/apache/cordova/CordovaResourceApi.java | 5 ++--- framework/src/org/apache/cordova/ExposedJsApi.java | 4 +++- .../src/org/apache/cordova/IceCreamCordovaWebViewClient.java | 4 ---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/framework/src/org/apache/cordova/CordovaResourceApi.java b/framework/src/org/apache/cordova/CordovaResourceApi.java index b891b51a..ebf88016 100644 --- a/framework/src/org/apache/cordova/CordovaResourceApi.java +++ b/framework/src/org/apache/cordova/CordovaResourceApi.java @@ -26,7 +26,6 @@ import android.database.Cursor; import android.net.Uri; import android.os.Looper; import android.util.Base64; -import android.util.Base64InputStream; import com.squareup.okhttp.OkHttpClient; @@ -62,7 +61,7 @@ public class CordovaResourceApi { // Creating this is light-weight. private static OkHttpClient httpClient = new OkHttpClient(); - static Thread webCoreThread; + static Thread jsThread; private final AssetManager assetManager; private final ContentResolver contentResolver; @@ -294,7 +293,7 @@ public class CordovaResourceApi { if (curThread == Looper.getMainLooper().getThread()) { 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."); } } diff --git a/framework/src/org/apache/cordova/ExposedJsApi.java b/framework/src/org/apache/cordova/ExposedJsApi.java index 7434c2ec..23defcb8 100755 --- a/framework/src/org/apache/cordova/ExposedJsApi.java +++ b/framework/src/org/apache/cordova/ExposedJsApi.java @@ -20,7 +20,6 @@ package org.apache.cordova; import android.webkit.JavascriptInterface; import org.apache.cordova.PluginManager; -import org.apache.cordova.PluginResult; import org.json.JSONException; /** @@ -48,6 +47,9 @@ import org.json.JSONException; jsMessageQueue.setPaused(true); try { + // Tell the resourceApi what thread the JS is running on. + CordovaResourceApi.jsThread = Thread.currentThread(); + pluginManager.exec(service, action, callbackId, arguments); String ret = ""; if (!NativeToJsMessageQueue.DISABLE_EXEC_CHAINING) { diff --git a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java index d1e632de..519a8ff2 100644 --- a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java +++ b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java @@ -27,7 +27,6 @@ import org.apache.cordova.LOG; import android.annotation.TargetApi; import android.net.Uri; import android.os.Build; -import android.util.Log; import android.webkit.WebResourceResponse; import android.webkit.WebView; @@ -46,9 +45,6 @@ public class IceCreamCordovaWebViewClient extends CordovaWebViewClient { @Override 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 { // Check the against the white-list. if ((url.startsWith("http:") || url.startsWith("https:")) && !Config.isUrlWhiteListed(url)) {