summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/provider/ContactsContract.java34
1 files changed, 22 insertions, 12 deletions
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 5932040..18b666c 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -312,23 +312,30 @@ public final class ContactsContract {
* @param contactUri the contact whose photo should be used
*/
public static Uri getPhotoUri(ContentResolver cr, Uri contactUri) {
- long photoId = -1;
- Cursor cursor = cr.query(contactUri, new String[]{Contacts.PHOTO_ID}, null, null, null);
+
+ // TODO remove try/catch block as soon as eclair-dev is merged in eclair
try {
- if (!cursor.moveToNext()) {
- return null;
- }
+ long photoId = -1;
+ Cursor cursor = cr.query(contactUri, new String[] {Contacts.PHOTO_ID},
+ null, null, null);
+ try {
+ if (!cursor.moveToNext()) {
+ return null;
+ }
- if (cursor.isNull(0)) {
- return null;
+ if (cursor.isNull(0)) {
+ return null;
+ }
+
+ photoId = cursor.getLong(0);
+ } finally {
+ cursor.close();
}
- photoId = cursor.getLong(0);
- } finally {
- cursor.close();
+ return ContentUris.withAppendedId(ContactsContract.Data.CONTENT_URI, photoId);
+ } catch (Exception e) {
+ return null;
}
-
- return ContentUris.withAppendedId(ContactsContract.Data.CONTENT_URI, photoId);
}
/**
@@ -339,6 +346,9 @@ public final class ContactsContract {
*/
public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) {
Uri photoUri = getPhotoUri(cr, contactUri);
+ if (photoUri == null) {
+ return null;
+ }
Cursor cursor = cr.query(photoUri,
new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null);
try {