summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYuli Huang <yuli@google.com>2011-09-28 01:21:15 +0800
committerYuli Huang <yuli@google.com>2011-09-28 01:21:15 +0800
commitfef5b9860f0a88fc673af2187938956ebd0ade75 (patch)
tree7e36a74279bc1627214d58891b29e8542690e165 /src
parentd8ad9c0d4fbc8bf0bb8bb2849ef537f60f278f8f (diff)
downloadandroid_packages_apps_Gallery2-fef5b9860f0a88fc673af2187938956ebd0ade75.tar.gz
android_packages_apps_Gallery2-fef5b9860f0a88fc673af2187938956ebd0ade75.tar.bz2
android_packages_apps_Gallery2-fef5b9860f0a88fc673af2187938956ebd0ade75.zip
Fix b/5287869 (and b/5369640).
Images from some app (MMS) may not have columns that PhotoEditor tries to query, for example: the orientation. Just ignore the absent columns. Change-Id: I1cda4e32241d9be7819453ede225388c7535c18c
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/photoeditor/BitmapUtils.java5
-rw-r--r--src/com/android/gallery3d/photoeditor/SaveCopyTask.java6
2 files changed, 8 insertions, 3 deletions
diff --git a/src/com/android/gallery3d/photoeditor/BitmapUtils.java b/src/com/android/gallery3d/photoeditor/BitmapUtils.java
index 5211a8379..ef01e4868 100644
--- a/src/com/android/gallery3d/photoeditor/BitmapUtils.java
+++ b/src/com/android/gallery3d/photoeditor/BitmapUtils.java
@@ -126,11 +126,14 @@ public class BitmapUtils {
private int getOrientation(Uri uri) {
int orientation = 0;
- Cursor cursor = context.getContentResolver().query(uri, IMAGE_PROJECTION, null, null, null);
+ Cursor cursor = null;
try {
+ cursor = context.getContentResolver().query(uri, IMAGE_PROJECTION, null, null, null);
if ((cursor != null) && cursor.moveToNext()) {
orientation = cursor.getInt(INDEX_ORIENTATION);
}
+ } catch (Exception e) {
+ // Ignore error for no orientation column; just use the default orientation value 0.
} finally {
if (cursor != null) {
cursor.close();
diff --git a/src/com/android/gallery3d/photoeditor/SaveCopyTask.java b/src/com/android/gallery3d/photoeditor/SaveCopyTask.java
index e43959e94..d46756335 100644
--- a/src/com/android/gallery3d/photoeditor/SaveCopyTask.java
+++ b/src/com/android/gallery3d/photoeditor/SaveCopyTask.java
@@ -118,14 +118,16 @@ public class SaveCopyTask extends AsyncTask<Bitmap, Void, Uri> {
double longitude = 0f;
ContentResolver contentResolver = context.getContentResolver();
- Cursor cursor = contentResolver.query(
- sourceUri, IMAGE_PROJECTION, null, null, null);
+ Cursor cursor = null;
try {
+ cursor = contentResolver.query(sourceUri, IMAGE_PROJECTION, null, null, null);
if ((cursor != null) && cursor.moveToNext()) {
dateTaken = cursor.getLong(INDEX_DATE_TAKEN);
latitude = cursor.getDouble(INDEX_LATITUDE);
longitude = cursor.getDouble(INDEX_LONGITUDE);
}
+ } catch (Exception e) {
+ // Ignore error for lacking property columns from the source.
} finally {
if (cursor != null) {
cursor.close();