Show better message to users if camera fails to access sdcard.
Also print the exception if sdcard access fails.
bug:2713104
Change-Id: I35a553ee75a49398582b587755d097b02b144015
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 337aa8f..1bfe813 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -38,15 +38,18 @@
<!-- alert to the user to wait for some operation to complete -->
<string name="wait">Please wait\u2026</string>
- <!-- alert to the user to that an SD card must be installed before using the camera -->
+ <!-- alert to the user that an SD card must be installed before using the camera -->
<string name="no_storage">Please insert an SD card before using the camera.</string>
- <!-- alert to the user to that the SD card is too full to complete the operation -->
+ <!-- alert to the user that the SD card is too full to complete the operation -->
<string name="not_enough_space">Your SD card is full.</string>
- <!-- alert to the user to that the SD card is being disk-checked -->
+ <!-- alert to the user that the SD card is being disk-checked -->
<string name="preparing_sd">Preparing SD card\u2026</string>
+ <!-- alert to the user that the camera fails to read or write the SD card. -->
+ <string name="access_sd_fail">Fail to access SD card.</string>
+
<!-- Settings stuff -->
<!-- Menu items: -->
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 052d16c..1f18dd6 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -1208,6 +1208,8 @@
} else {
noStorageText = getString(R.string.no_storage);
}
+ } else if (remaining == MenuHelper.CANNOT_STAT_ERROR) {
+ noStorageText = getString(R.string.access_sd_fail);
} else if (remaining < 1) {
noStorageText = getString(R.string.not_enough_space);
}
diff --git a/src/com/android/camera/MenuHelper.java b/src/com/android/camera/MenuHelper.java
index 1c8f0fa..e07f4f0 100644
--- a/src/com/android/camera/MenuHelper.java
+++ b/src/com/android/camera/MenuHelper.java
@@ -201,6 +201,7 @@
// if we can't stat the filesystem then we don't know how many
// pictures are remaining. it might be zero but just leave it
// blank since we really don't know.
+ Log.e(TAG, "Fail to access sdcard", ex);
return CANNOT_STAT_ERROR;
}
}
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 958f19e..5ee144a 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -108,6 +108,7 @@
private static final int STORAGE_STATUS_OK = 0;
private static final int STORAGE_STATUS_LOW = 1;
private static final int STORAGE_STATUS_NONE = 2;
+ private static final int STORAGE_STATUS_FAIL = 3;
private static final boolean SWITCH_CAMERA = true;
private static final boolean SWITCH_VIDEO = false;
@@ -496,6 +497,10 @@
break;
case STORAGE_STATUS_LOW:
errorMessage = getString(R.string.spaceIsLow_content);
+ break;
+ case STORAGE_STATUS_FAIL:
+ errorMessage = getString(R.string.access_sd_fail);
+ break;
}
if (errorMessage != null) {
if (mStorageHint == null) {
@@ -514,6 +519,8 @@
long remaining = mayHaveSd ? getAvailableStorage() : NO_STORAGE_ERROR;
if (remaining == NO_STORAGE_ERROR) {
return STORAGE_STATUS_NONE;
+ } else if (remaining == CANNOT_STAT_ERROR) {
+ return STORAGE_STATUS_FAIL;
}
return remaining < LOW_STORAGE_THRESHOLD
? STORAGE_STATUS_LOW
@@ -848,10 +855,11 @@
return (long) stat.getAvailableBlocks()
* (long) stat.getBlockSize();
}
- } catch (RuntimeException ex) {
+ } catch (Exception ex) {
// if we can't stat the filesystem then we don't know how many
// free bytes exist. It might be zero but just leave it
// blank since we really don't know.
+ Log.e(TAG, "Fail to access sdcard", ex);
return CANNOT_STAT_ERROR;
}
}