diff options
author | Dave Santoro <dsantoro@google.com> | 2011-08-04 12:34:21 -0700 |
---|---|---|
committer | Dave Santoro <dsantoro@google.com> | 2011-08-04 12:34:21 -0700 |
commit | 3593682b8d9213fde576a0cff54458ad50563980 (patch) | |
tree | facf3d11d5394beb3d83cdaddb30a2dd9c64c7fb /src | |
parent | 8049e12f9a9a6dd19155fdce2352d437ca27a14c (diff) | |
download | packages_providers_ContactsProvider-3593682b8d9213fde576a0cff54458ad50563980.zip packages_providers_ContactsProvider-3593682b8d9213fde576a0cff54458ad50563980.tar.gz packages_providers_ContactsProvider-3593682b8d9213fde576a0cff54458ad50563980.tar.bz2 |
Fix data set handling for groups.
Bug 5121818
Change-Id: I5bd0c6b0678aed2b708057774d7041b822bf3ed9
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/providers/contacts/ContactsProvider2.java | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java index 20b577c..32a7a07 100644 --- a/src/com/android/providers/contacts/ContactsProvider2.java +++ b/src/com/android/providers/contacts/ContactsProvider2.java @@ -2262,14 +2262,14 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun * @param values {@link ContentValues} to read and possibly update. */ private AccountWithDataSet resolveAccountWithDataSet(Uri uri, ContentValues values) { - final Account account = resolveAccount(uri, mValues); + final Account account = resolveAccount(uri, values); AccountWithDataSet accountWithDataSet = null; if (account != null) { String dataSet = getQueryParameter(uri, RawContacts.DATA_SET); if (dataSet == null) { - dataSet = mValues.getAsString(RawContacts.DATA_SET); + dataSet = values.getAsString(RawContacts.DATA_SET); } else { - mValues.put(RawContacts.DATA_SET, dataSet); + values.put(RawContacts.DATA_SET, dataSet); } accountWithDataSet = new AccountWithDataSet(account.name, account.type, dataSet); } @@ -2796,11 +2796,7 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun mValues.clear(); mValues.putAll(values); - final Account account = resolveAccount(uri, mValues); - String dataSet = null; - if (account != null && mValues.containsKey(Groups.DATA_SET)) { - dataSet = mValues.getAsString(Groups.DATA_SET); - } + final AccountWithDataSet accountWithDataSet = resolveAccountWithDataSet(uri, mValues); // Replace package with internal mapping final String packageName = mValues.getAsString(Groups.RES_PACKAGE); @@ -2823,20 +2819,28 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun // add all starred raw contacts to this group String selection; String[] selectionArgs; - if (account == null) { + if (accountWithDataSet == null) { selection = RawContacts.ACCOUNT_NAME + " IS NULL AND " + RawContacts.ACCOUNT_TYPE + " IS NULL AND " + RawContacts.DATA_SET + " IS NULL"; selectionArgs = null; - } else if (dataSet == null) { + } else if (accountWithDataSet.getDataSet() == null) { selection = RawContacts.ACCOUNT_NAME + "=? AND " - + RawContacts.ACCOUNT_TYPE + "=?"; - selectionArgs = new String[]{account.name, account.type}; + + RawContacts.ACCOUNT_TYPE + "=? AND " + + RawContacts.DATA_SET + " IS NULL"; + selectionArgs = new String[] { + accountWithDataSet.getAccountName(), + accountWithDataSet.getAccountType() + }; } else { selection = RawContacts.ACCOUNT_NAME + "=? AND " + RawContacts.ACCOUNT_TYPE + "=? AND " + RawContacts.DATA_SET + "=?"; - selectionArgs = new String[]{account.name, account.type, dataSet}; + selectionArgs = new String[] { + accountWithDataSet.getAccountName(), + accountWithDataSet.getAccountType(), + accountWithDataSet.getDataSet() + }; } Cursor c = mDb.query(Tables.RAW_CONTACTS, new String[]{RawContacts._ID, RawContacts.STARRED}, |