From a5123ab95a30f2bc88cc94825a6d6c8e4d84d9e5 Mon Sep 17 00:00:00 2001 From: Wes Johnston Date: Fri, 11 Feb 2011 16:43:00 -0500 Subject: [PATCH] Bug 633406 - Check for problems getting the cache directory on Android r=blassey, a=fennec-crash --- embedding/android/GeckoAppShell.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/embedding/android/GeckoAppShell.java b/embedding/android/GeckoAppShell.java index 1097576ddaa..9e7a2de7c90 100644 --- a/embedding/android/GeckoAppShell.java +++ b/embedding/android/GeckoAppShell.java @@ -110,10 +110,19 @@ class GeckoAppShell } 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; }