diff options
author | Daisuke Miyakawa <dmiyakawa@google.com> | 2010-09-26 12:15:40 -0700 |
---|---|---|
committer | Daisuke Miyakawa <dmiyakawa@google.com> | 2010-09-26 12:21:33 -0700 |
commit | e0998604df4ddfcd5c87ea097dcc0950a9518ed1 (patch) | |
tree | e15ac4bc349c2ab91bde539c81450a8d0b83db76 /core/java/android/pim | |
parent | d45a33554ca6c18ed81e45320998b9e4f4680379 (diff) | |
download | frameworks_base-e0998604df4ddfcd5c87ea097dcc0950a9518ed1.zip frameworks_base-e0998604df4ddfcd5c87ea097dcc0950a9518ed1.tar.gz frameworks_base-e0998604df4ddfcd5c87ea097dcc0950a9518ed1.tar.bz2 |
Add necessary logic removed during backport
Makes importer import contcats into an appropriate group.
Without this logic, all imported contacts are stored in
"Other Groups".
This logic is removed in my previous submit, while
it shouldn't be.
Bug: 3036599
Change-Id: Ic1dc7253d807fbde4352afe2082984c3b7227267
Diffstat (limited to 'core/java/android/pim')
-rw-r--r-- | core/java/android/pim/vcard/VCardEntry.java | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/core/java/android/pim/vcard/VCardEntry.java b/core/java/android/pim/vcard/VCardEntry.java index 94f7c5f..02e1674 100644 --- a/core/java/android/pim/vcard/VCardEntry.java +++ b/core/java/android/pim/vcard/VCardEntry.java @@ -20,12 +20,10 @@ import android.content.ContentProviderOperation; import android.content.ContentProviderResult; import android.content.ContentResolver; import android.content.OperationApplicationException; +import android.database.Cursor; import android.net.Uri; import android.os.RemoteException; import android.provider.ContactsContract; -import android.provider.ContactsContract.Contacts; -import android.provider.ContactsContract.Data; -import android.provider.ContactsContract.RawContacts; import android.provider.ContactsContract.CommonDataKinds.Email; import android.provider.ContactsContract.CommonDataKinds.Event; import android.provider.ContactsContract.CommonDataKinds.GroupMembership; @@ -38,6 +36,10 @@ import android.provider.ContactsContract.CommonDataKinds.Photo; import android.provider.ContactsContract.CommonDataKinds.StructuredName; import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; import android.provider.ContactsContract.CommonDataKinds.Website; +import android.provider.ContactsContract.Contacts; +import android.provider.ContactsContract.Data; +import android.provider.ContactsContract.Groups; +import android.provider.ContactsContract.RawContacts; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.util.Log; @@ -59,6 +61,9 @@ public class VCardEntry { private final static int DEFAULT_ORGANIZATION_TYPE = Organization.TYPE_WORK; + private static final String ACCOUNT_TYPE_GOOGLE = "com.google"; + private static final String GOOGLE_MY_CONTACTS_GROUP = "System Group: My Contacts"; + private static final Map<String, Integer> sImMap = new HashMap<String, Integer>(); static { @@ -1111,6 +1116,23 @@ public class VCardEntry { if (mAccount != null) { builder.withValue(RawContacts.ACCOUNT_NAME, mAccount.name); builder.withValue(RawContacts.ACCOUNT_TYPE, mAccount.type); + + // Assume that caller side creates this group if it does not exist. + if (ACCOUNT_TYPE_GOOGLE.equals(mAccount.type)) { + final Cursor cursor = resolver.query(Groups.CONTENT_URI, new String[] { + Groups.SOURCE_ID }, + Groups.TITLE + "=?", new String[] { + GOOGLE_MY_CONTACTS_GROUP }, null); + try { + if (cursor != null && cursor.moveToFirst()) { + myGroupsId = cursor.getString(0); + } + } finally { + if (cursor != null) { + cursor.close(); + } + } + } } else { builder.withValue(RawContacts.ACCOUNT_NAME, null); builder.withValue(RawContacts.ACCOUNT_TYPE, null); |