Merge "Fix 5489985: Handle the exception when the external volume has not been added to MediaProvider." into ics-mr1
diff --git a/src/com/android/camera/Storage.java b/src/com/android/camera/Storage.java
index 564c088..38a6d48 100644
--- a/src/com/android/camera/Storage.java
+++ b/src/com/android/camera/Storage.java
@@ -84,10 +84,16 @@
values.put(ImageColumns.LONGITUDE, location.getLongitude());
}
- Uri uri = resolver.insert(Images.Media.EXTERNAL_CONTENT_URI, values);
- if (uri == null) {
- Log.e(TAG, "Failed to write MediaStore");
- return null;
+ Uri uri = null;
+ try {
+ uri = resolver.insert(Images.Media.EXTERNAL_CONTENT_URI, values);
+ } catch (Throwable th) {
+ // This can happen when the external volume is already mounted, but
+ // MediaScanner has not notify MediaProvider to add that volume.
+ // The picture is still safe and MediaScanner will find it and
+ // insert it into MediaProvider. The only problem is that the user
+ // cannot click the thumbnail to review the picture.
+ Log.e(TAG, "Failed to write MediaStore" + th);
}
return uri;
}