Bug 633406 - Check for problems getting the cache directory on Android r=blassey, a=fennec-crash
authorWes Johnston <wjohnston@mozilla.com>
Fri, 11 Feb 2011 16:43:00 -0500
changeset 62453 edf89132ec20b0408562a9bf214eca8c78699775
parent 62452 645fce13f10acd57edf0d8210c8e3afe4f6a0adb
child 62454 0644a18eb249c04ea9f01963d7f7effdbff6bae3
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersblassey, fennec-crash
bugs633406
milestone2.0b12pre
Bug 633406 - Check for problems getting the cache directory on Android r=blassey, a=fennec-crash
embedding/android/GeckoAppShell.java
--- a/embedding/android/GeckoAppShell.java
+++ b/embedding/android/GeckoAppShell.java
@@ -105,20 +105,29 @@ class GeckoAppShell
 
     public static File getCacheDir() {
         if (sCacheFile == null)
             sCacheFile = GeckoApp.mAppContext.getCacheDir();
         return sCacheFile;
     }
 
     public static long getFreeSpace() {
-        if (sFreeSpace == -1) {
-            StatFs cacheStats = new StatFs(getCacheDir().getPath());
-            sFreeSpace = cacheStats.getFreeBlocks() * 
-                cacheStats.getBlockSize();
+        try {
+            if (sFreeSpace == -1) {
+                File cacheDir = getCacheDir();
+                if (cacheDir != null) {
+                    StatFs cacheStats = new StatFs(cacheDir.getPath());
+                    sFreeSpace = cacheStats.getFreeBlocks() * 
+                        cacheStats.getBlockSize();
+                } else {
+                    Log.i("GeckoAppShell", "Unable to get cache dir");
+                }
+            }
+        } catch (Exception e) {
+            Log.e("GeckoAppShell", "exception while stating cache dir: ", e);
         }
         return sFreeSpace;
     }
 
     static boolean moveFile(File inFile, File outFile)
     {
         Log.i("GeckoAppShell", "moving " + inFile + " to " + outFile);
         if (outFile.isDirectory())