Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1c1629da authored by Dmitri Plotnikov's avatar Dmitri Plotnikov
Browse files

Protecting access to the new Contacts API with a try/catch block.

parent 41b379da
Loading
Loading
Loading
Loading
+22 −12
Original line number Diff line number Diff line
@@ -312,8 +312,12 @@ public final class ContactsContract {
         * @param contactUri the contact whose photo should be used
         */
        public static Uri getPhotoUri(ContentResolver cr, Uri contactUri) {

            // TODO remove try/catch block as soon as eclair-dev is merged in eclair
            try {
                long photoId = -1;
            Cursor cursor = cr.query(contactUri, new String[]{Contacts.PHOTO_ID}, null, null, null);
                Cursor cursor = cr.query(contactUri, new String[] {Contacts.PHOTO_ID},
                        null, null, null);
                try {
                    if (!cursor.moveToNext()) {
                        return null;
@@ -329,6 +333,9 @@ public final class ContactsContract {
                }

                return ContentUris.withAppendedId(ContactsContract.Data.CONTENT_URI, photoId);
            } catch (Exception e) {
                return null;
            }
        }

        /**
@@ -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 {