incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From macdo...@apache.org
Subject android commit: Guard against null pointer exception in ES File Explorer being used to get a picture
Date Wed, 26 Sep 2012 19:53:05 GMT
Updated Branches:
  refs/heads/master 54caa6e43 -> 1b4096b01


Guard against null pointer exception in ES File Explorer being used to get a picture


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

Branch: refs/heads/master
Commit: 1b4096b01db41de633aeadd3e2fae43111722d97
Parents: 54caa6e
Author: Simon MacDonald <simon.macdonald@gmail.com>
Authored: Wed Sep 26 15:52:37 2012 -0400
Committer: Simon MacDonald <simon.macdonald@gmail.com>
Committed: Wed Sep 26 15:52:37 2012 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/FileUtils.java |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/1b4096b0/framework/src/org/apache/cordova/FileUtils.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileUtils.java b/framework/src/org/apache/cordova/FileUtils.java
index 1c8f084..cbeff98 100755
--- a/framework/src/org/apache/cordova/FileUtils.java
+++ b/framework/src/org/apache/cordova/FileUtils.java
@@ -1048,10 +1048,16 @@ public class FileUtils extends Plugin {
      */
     @SuppressWarnings("deprecation")
     protected static String getRealPathFromURI(Uri contentUri, CordovaInterface cordova)
{
-        String[] proj = { _DATA };
-        Cursor cursor = cordova.getActivity().managedQuery(contentUri, proj, null, null,
null);
-        int column_index = cursor.getColumnIndexOrThrow(_DATA);
-        cursor.moveToFirst();
-        return cursor.getString(column_index);
+        String uri = contentUri.toString();
+        if (uri.startsWith("content:")) {
+            String[] proj = { _DATA };
+            Cursor cursor = cordova.getActivity().managedQuery(contentUri, proj, null, null,
null);
+            int column_index = cursor.getColumnIndexOrThrow(_DATA);
+            cursor.moveToFirst();
+            return cursor.getString(column_index);
+        } else {
+            return uri;
+        }
+        
     }
 }


Mime
View raw message