You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/07/18 07:39:55 UTC

[1/2] android commit: [CB-3384] Fix thread assertion when plugins remap URIs

Updated Branches:
  refs/heads/3.0.x 488492813 -> d91ac45d8
  refs/heads/master 8202ab83f -> b915aafb5


[CB-3384] Fix thread assertion when plugins remap URIs


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/b915aafb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/b915aafb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/b915aafb

Branch: refs/heads/master
Commit: b915aafb5be31912129b04c7e70b9c0a9908ee9c
Parents: 8202ab8
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Jul 18 01:38:47 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Jul 18 01:38:47 2013 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaResourceApi.java | 17 ++++++++++++++++-
 .../cordova/IceCreamCordovaWebViewClient.java      |  2 +-
 2 files changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b915aafb/framework/src/org/apache/cordova/CordovaResourceApi.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaResourceApi.java b/framework/src/org/apache/cordova/CordovaResourceApi.java
index ebf8801..cb85744 100644
--- a/framework/src/org/apache/cordova/CordovaResourceApi.java
+++ b/framework/src/org/apache/cordova/CordovaResourceApi.java
@@ -156,9 +156,24 @@ public class CordovaResourceApi {
      * @throws Throws an InvalidArgumentException for relative URIs. Relative URIs should be
      *     resolved before being passed into this function.
      * @throws Throws an IOException if the URI cannot be opened.
+     * @throws Throws an IllegalStateException if called on a foreground thread.
      */
     public OpenForReadResult openForRead(Uri uri) throws IOException {
-        assertBackgroundThread();
+        return openForRead(uri, false);
+    }
+
+    /**
+     * Opens a stream to the givne URI, also providing the MIME type & length.
+     * @return Never returns null.
+     * @throws Throws an InvalidArgumentException for relative URIs. Relative URIs should be
+     *     resolved before being passed into this function.
+     * @throws Throws an IOException if the URI cannot be opened.
+     * @throws Throws an IllegalStateException if called on a foreground thread and skipThreadCheck is false.
+     */
+    public OpenForReadResult openForRead(Uri uri, boolean skipThreadCheck) throws IOException {
+        if (!skipThreadCheck) {
+            assertBackgroundThread();
+        }
         switch (getUriType(uri)) {
             case URI_TYPE_FILE: {
                 FileInputStream inputStream = new FileInputStream(uri.getPath());

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b915aafb/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
index 519a8ff..f1fcbf0 100644
--- a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
@@ -59,7 +59,7 @@ public class IceCreamCordovaWebViewClient extends CordovaWebViewClient {
             Uri remappedUri = resourceApi.remapUri(origUri);
             
             if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri)) {
-                OpenForReadResult result = resourceApi.openForRead(remappedUri);
+                OpenForReadResult result = resourceApi.openForRead(remappedUri, true);
                 return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream);
             }
             // If we don't need to special-case the request, let the browser load it.


[2/2] android commit: [CB-3384] Fix thread assertion when plugins remap URIs (cherry picked from commit b915aafb5be31912129b04c7e70b9c0a9908ee9c)

Posted by ag...@apache.org.
[CB-3384] Fix thread assertion when plugins remap URIs
(cherry picked from commit b915aafb5be31912129b04c7e70b9c0a9908ee9c)


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/d91ac45d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/d91ac45d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/d91ac45d

Branch: refs/heads/3.0.x
Commit: d91ac45d8821c7729fa9d06d12c2e204a1ce25fd
Parents: 4884928
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Jul 18 01:38:47 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Jul 18 01:39:48 2013 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaResourceApi.java | 17 ++++++++++++++++-
 .../cordova/IceCreamCordovaWebViewClient.java      |  2 +-
 2 files changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/d91ac45d/framework/src/org/apache/cordova/CordovaResourceApi.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaResourceApi.java b/framework/src/org/apache/cordova/CordovaResourceApi.java
index ebf8801..cb85744 100644
--- a/framework/src/org/apache/cordova/CordovaResourceApi.java
+++ b/framework/src/org/apache/cordova/CordovaResourceApi.java
@@ -156,9 +156,24 @@ public class CordovaResourceApi {
      * @throws Throws an InvalidArgumentException for relative URIs. Relative URIs should be
      *     resolved before being passed into this function.
      * @throws Throws an IOException if the URI cannot be opened.
+     * @throws Throws an IllegalStateException if called on a foreground thread.
      */
     public OpenForReadResult openForRead(Uri uri) throws IOException {
-        assertBackgroundThread();
+        return openForRead(uri, false);
+    }
+
+    /**
+     * Opens a stream to the givne URI, also providing the MIME type & length.
+     * @return Never returns null.
+     * @throws Throws an InvalidArgumentException for relative URIs. Relative URIs should be
+     *     resolved before being passed into this function.
+     * @throws Throws an IOException if the URI cannot be opened.
+     * @throws Throws an IllegalStateException if called on a foreground thread and skipThreadCheck is false.
+     */
+    public OpenForReadResult openForRead(Uri uri, boolean skipThreadCheck) throws IOException {
+        if (!skipThreadCheck) {
+            assertBackgroundThread();
+        }
         switch (getUriType(uri)) {
             case URI_TYPE_FILE: {
                 FileInputStream inputStream = new FileInputStream(uri.getPath());

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/d91ac45d/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
index 519a8ff..f1fcbf0 100644
--- a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
@@ -59,7 +59,7 @@ public class IceCreamCordovaWebViewClient extends CordovaWebViewClient {
             Uri remappedUri = resourceApi.remapUri(origUri);
             
             if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri)) {
-                OpenForReadResult result = resourceApi.openForRead(remappedUri);
+                OpenForReadResult result = resourceApi.openForRead(remappedUri, true);
                 return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream);
             }
             // If we don't need to special-case the request, let the browser load it.