From 989edfde740b0dfddddba9782cced333624484dd Mon Sep 17 00:00:00 2001 From: Dmitri Plotnikov Date: Tue, 16 Feb 2010 14:40:46 -0800 Subject: Fixing the use of entities in VCardExporter. Bug: 2377678 Change-Id: I05768fd2ce28406b1fc32005343fa1eeaaecdd24 --- core/java/android/pim/vcard/VCardComposer.java | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'core') diff --git a/core/java/android/pim/vcard/VCardComposer.java b/core/java/android/pim/vcard/VCardComposer.java index 5e978f6..2eb25954 100644 --- a/core/java/android/pim/vcard/VCardComposer.java +++ b/core/java/android/pim/vcard/VCardComposer.java @@ -31,6 +31,7 @@ import android.provider.CallLog.Calls; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Data; import android.provider.ContactsContract.RawContacts; +import android.provider.ContactsContract.RawContactsEntity; import android.provider.ContactsContract.CommonDataKinds.Email; import android.provider.ContactsContract.CommonDataKinds.Event; import android.provider.ContactsContract.CommonDataKinds.Im; @@ -498,17 +499,18 @@ public class VCardComposer { Method getEntityIteratorMethod) throws VCardException { final Map> contentValuesListMap = new HashMap>(); - // The resolver may return the entity iterator with no data. It is possiible. + // The resolver may return the entity iterator with no data. It is possible. // e.g. If all the data in the contact of the given contact id are not exportable ones, // they are hidden from the view of this method, though contact id itself exists. EntityIterator entityIterator = null; try { + final Uri uri = RawContactsEntity.CONTENT_URI.buildUpon() + .appendQueryParameter(Data.FOR_EXPORT_ONLY, "1") + .build(); + final String selection = Data.CONTACT_ID + "=?"; + final String[] selectionArgs = new String[] {contactId}; if (getEntityIteratorMethod != null) { - final Uri uri = RawContacts.CONTENT_URI.buildUpon() - .appendQueryParameter(Data.FOR_EXPORT_ONLY, "1") - .build(); - final String selection = Data.CONTACT_ID + "=?"; - final String[] selectionArgs = new String[] {contactId}; + // Please note that this branch is executed by some tests only try { entityIterator = (EntityIterator)getEntityIteratorMethod.invoke(null, mContentResolver, uri, selection, selectionArgs, null); @@ -528,13 +530,8 @@ public class VCardComposer { e.getCause().getMessage()); } } else { - final Uri uri = RawContacts.CONTENT_URI.buildUpon() - .appendEncodedPath(contactId) - .appendEncodedPath(RawContacts.Entity.CONTENT_DIRECTORY) - .appendQueryParameter(Data.FOR_EXPORT_ONLY, "1") - .build(); entityIterator = RawContacts.newEntityIterator(mContentResolver.query( - uri, null, null, null, null)); + uri, null, selection, selectionArgs, null)); } if (entityIterator == null) { -- cgit v1.1