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 <[email protected]> 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 <[email protected]> Authored: Mon Jun 16 14:24:23 2014 -0400 Committer: Joe Bowser <[email protected]> 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; }
