You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2014/06/16 23:28:37 UTC

[1/3] git commit: CB-6940: context.getExternal* methods return null if sdcard isn't in mounted state, causing exceptions that prevent startup from reaching readystate

Repository: cordova-plugin-file
Updated Branches:
  refs/heads/master 239654900 -> cbcd0f461


CB-6940: context.getExternal* methods return null if sdcard isn't in mounted state, causing exceptions that prevent startup from reaching readystate

Signed-off-by: Joe Bowser <bo...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/76f869ed
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/76f869ed
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/76f869ed

Branch: refs/heads/master
Commit: 76f869ed8cd48bd1eafa1aa7a2d83a8607f4cb9a
Parents: 2396549
Author: dzeims <dz...@users.noreply.github.com>
Authored: Mon Jun 16 14:24:23 2014 -0400
Committer: Joe Bowser <bo...@apache.org>
Committed: Mon Jun 16 12:43:08 2014 -0700

----------------------------------------------------------------------
 src/android/FileUtils.java | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/76f869ed/src/android/FileUtils.java
----------------------------------------------------------------------
diff --git a/src/android/FileUtils.java b/src/android/FileUtils.java
index 3f1c817..270855a 100644
--- a/src/android/FileUtils.java
+++ b/src/android/FileUtils.java
@@ -129,11 +129,11 @@ public class FileUtils extends CordovaPlugin {
         HashMap<String, String> availableFileSystems = new HashMap<String,String>();
 
         availableFileSystems.put("files", context.getFilesDir().getAbsolutePath());
-        availableFileSystems.put("files-external", context.getExternalFilesDir(null).getAbsolutePath());
+        try { availableFileSystems.put("files-external", context.getExternalFilesDir(null).getAbsolutePath()); } catch(Exception e) {}
         availableFileSystems.put("documents", new File(context.getFilesDir(), "Documents").getAbsolutePath());
-        availableFileSystems.put("sdcard", Environment.getExternalStorageDirectory().getAbsolutePath());
+        try { availableFileSystems.put("sdcard", Environment.getExternalStorageDirectory().getAbsolutePath()); } catch(Exception e) {}
         availableFileSystems.put("cache", context.getCacheDir().getAbsolutePath());
-        availableFileSystems.put("cache-external", context.getExternalCacheDir().getAbsolutePath());
+        try { availableFileSystems.put("cache-external", context.getExternalCacheDir().getAbsolutePath()); } catch(Exception e) {}
         availableFileSystems.put("root", "/");
 
         return availableFileSystems;
@@ -863,10 +863,10 @@ public class FileUtils extends CordovaPlugin {
         ret.put("applicationStorageDirectory", toDirUrl(context.getFilesDir().getParentFile()));
         ret.put("dataDirectory", toDirUrl(context.getFilesDir()));
         ret.put("cacheDirectory", toDirUrl(context.getCacheDir()));
-        ret.put("externalApplicationStorageDirectory", toDirUrl(context.getExternalFilesDir(null).getParentFile()));
-        ret.put("externalDataDirectory", toDirUrl(context.getExternalFilesDir(null)));
-        ret.put("externalCacheDirectory", toDirUrl(context.getExternalCacheDir()));
-        ret.put("externalRootDirectory", toDirUrl(Environment.getExternalStorageDirectory()));
+        try { ret.put("externalApplicationStorageDirectory", toDirUrl(context.getExternalFilesDir(null).getParentFile())); } catch(Exception e) {}
+        try { ret.put("externalDataDirectory", toDirUrl(context.getExternalFilesDir(null))); } catch(Exception e) {}
+        try { ret.put("externalCacheDirectory", toDirUrl(context.getExternalCacheDir())); } catch(Exception e) {}
+        try { ret.put("externalRootDirectory", toDirUrl(Environment.getExternalStorageDirectory())); } catch(Exception e) {}
         return ret;
     }
 


[2/3] git commit: CB-6940: Android: cleanup try/catch exception handling

Posted by bo...@apache.org.
CB-6940: Android: cleanup try/catch exception handling

Signed-off-by: Joe Bowser <bo...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/44fe0406
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/44fe0406
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/44fe0406

Branch: refs/heads/master
Commit: 44fe0406a7a99b643bd8c85c84ea4523b0345c84
Parents: 76f869e
Author: dzeims <dz...@users.noreply.github.com>
Authored: Mon Jun 16 14:42:27 2014 -0400
Committer: Joe Bowser <bo...@apache.org>
Committed: Mon Jun 16 12:43:21 2014 -0700

----------------------------------------------------------------------
 src/android/FileUtils.java | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/44fe0406/src/android/FileUtils.java
----------------------------------------------------------------------
diff --git a/src/android/FileUtils.java b/src/android/FileUtils.java
index 270855a..db8f4d4 100644
--- a/src/android/FileUtils.java
+++ b/src/android/FileUtils.java
@@ -129,12 +129,19 @@ public class FileUtils extends CordovaPlugin {
         HashMap<String, String> availableFileSystems = new HashMap<String,String>();
 
         availableFileSystems.put("files", context.getFilesDir().getAbsolutePath());
-        try { availableFileSystems.put("files-external", context.getExternalFilesDir(null).getAbsolutePath()); } catch(Exception e) {}
         availableFileSystems.put("documents", new File(context.getFilesDir(), "Documents").getAbsolutePath());
-        try { availableFileSystems.put("sdcard", Environment.getExternalStorageDirectory().getAbsolutePath()); } catch(Exception e) {}
         availableFileSystems.put("cache", context.getCacheDir().getAbsolutePath());
-        try { availableFileSystems.put("cache-external", context.getExternalCacheDir().getAbsolutePath()); } catch(Exception e) {}
         availableFileSystems.put("root", "/");
+        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+          try {
+            availableFileSystems.put("files-external", context.getExternalFilesDir(null).getAbsolutePath());
+            availableFileSystems.put("sdcard", Environment.getExternalStorageDirectory().getAbsolutePath());
+            availableFileSystems.put("cache-external", context.getExternalCacheDir().getAbsolutePath());
+          }
+          catch(IOException e) {
+            /* If external storage is unavailable, context.getExternal* returns null */
+          }
+        }
 
         return availableFileSystems;
     }
@@ -863,10 +870,17 @@ public class FileUtils extends CordovaPlugin {
         ret.put("applicationStorageDirectory", toDirUrl(context.getFilesDir().getParentFile()));
         ret.put("dataDirectory", toDirUrl(context.getFilesDir()));
         ret.put("cacheDirectory", toDirUrl(context.getCacheDir()));
-        try { ret.put("externalApplicationStorageDirectory", toDirUrl(context.getExternalFilesDir(null).getParentFile())); } catch(Exception e) {}
-        try { ret.put("externalDataDirectory", toDirUrl(context.getExternalFilesDir(null))); } catch(Exception e) {}
-        try { ret.put("externalCacheDirectory", toDirUrl(context.getExternalCacheDir())); } catch(Exception e) {}
-        try { ret.put("externalRootDirectory", toDirUrl(Environment.getExternalStorageDirectory())); } catch(Exception e) {}
+        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+          try {
+            ret.put("externalApplicationStorageDirectory", toDirUrl(context.getExternalFilesDir(null).getParentFile()));
+            ret.put("externalDataDirectory", toDirUrl(context.getExternalFilesDir(null)));
+            ret.put("externalCacheDirectory", toDirUrl(context.getExternalCacheDir()));
+            ret.put("externalRootDirectory", toDirUrl(Environment.getExternalStorageDirectory()));
+          }
+          catch(IOException e) {
+            /* If external storage is unavailable, context.getExternal* returns null */
+          }
+        }
         return ret;
     }
 


[3/3] git commit: CB-6940: Fixing up commit from dzeims

Posted by bo...@apache.org.
CB-6940: Fixing up commit from dzeims


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

Branch: refs/heads/master
Commit: cbcd0f461d676df876e4be19e20a4c80b0e2d6de
Parents: 44fe040
Author: Joe Bowser <bo...@apache.org>
Authored: Mon Jun 16 14:28:10 2014 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Mon Jun 16 14:28:10 2014 -0700

----------------------------------------------------------------------
 src/android/FileUtils.java | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/cbcd0f46/src/android/FileUtils.java
----------------------------------------------------------------------
diff --git a/src/android/FileUtils.java b/src/android/FileUtils.java
index db8f4d4..d1d0f81 100644
--- a/src/android/FileUtils.java
+++ b/src/android/FileUtils.java
@@ -138,8 +138,8 @@ public class FileUtils extends CordovaPlugin {
             availableFileSystems.put("sdcard", Environment.getExternalStorageDirectory().getAbsolutePath());
             availableFileSystems.put("cache-external", context.getExternalCacheDir().getAbsolutePath());
           }
-          catch(IOException e) {
-            /* If external storage is unavailable, context.getExternal* returns null */
+          catch(NullPointerException e) {
+              Log.d(LOG_TAG, "External storage unavailable, check to see if USB Mass Storage Mode is on");
           }
         }
 
@@ -877,8 +877,9 @@ public class FileUtils extends CordovaPlugin {
             ret.put("externalCacheDirectory", toDirUrl(context.getExternalCacheDir()));
             ret.put("externalRootDirectory", toDirUrl(Environment.getExternalStorageDirectory()));
           }
-          catch(IOException e) {
+          catch(NullPointerException e) {
             /* If external storage is unavailable, context.getExternal* returns null */
+              Log.d(LOG_TAG, "Unable to access these paths, most liklely due to USB storage");
           }
         }
         return ret;