diff options
author | Dmitri Plotnikov <dplotnikov@google.com> | 2010-04-05 18:41:43 -0700 |
---|---|---|
committer | Dmitri Plotnikov <dplotnikov@google.com> | 2010-04-05 18:41:43 -0700 |
commit | 35ebc8d4a0a96b8fbe155e0c2ee6e72a994e6e8c (patch) | |
tree | a991c4fd612ed8fb6afa200b9d8eba039bd0c936 | |
parent | 2aa932da79a22b69d55e862966941afe4377532e (diff) | |
download | ContactsProvider-35ebc8d4a0a96b8fbe155e0c2ee6e72a994e6e8c.tar.gz |
Fixing handling of null sync ID in legacy import. Part II
There was an issue with the original "fix". I actually ran
tests against Master and thus did not notice the breakage.
Bug: 2498528
Change-Id: Ic3d288a5d1d39f1ff9a9bb5a3a048c813f665fbc
-rw-r--r-- | src/com/android/providers/contacts/LegacyContactImporter.java | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/com/android/providers/contacts/LegacyContactImporter.java b/src/com/android/providers/contacts/LegacyContactImporter.java index 30751ba8..2634d44e 100644 --- a/src/com/android/providers/contacts/LegacyContactImporter.java +++ b/src/com/android/providers/contacts/LegacyContactImporter.java @@ -297,11 +297,10 @@ public class LegacyContactImporter { insert.bindLong(GroupsInsert.GROUP_VISIBLE, 1); String account = c.getString(GroupsQuery._SYNC_ACCOUNT); - String syncId = c.getString(GroupsQuery._SYNC_ID); - if (!TextUtils.isEmpty(account) && !TextUtils.isEmpty(syncId)) { + if (!TextUtils.isEmpty(account)) { bindString(insert, GroupsInsert.ACCOUNT_NAME, account); bindString(insert, GroupsInsert.ACCOUNT_TYPE, DEFAULT_ACCOUNT_TYPE); - bindString(insert, GroupsInsert.SOURCE_ID, syncId); + bindString(insert, GroupsInsert.SOURCE_ID, c.getString(GroupsQuery._SYNC_ID)); } else { insert.bindNull(GroupsInsert.ACCOUNT_NAME); insert.bindNull(GroupsInsert.ACCOUNT_TYPE); @@ -559,11 +558,10 @@ public class LegacyContactImporter { insert.bindLong(RawContactsInsert.CONTACT_IN_VISIBLE_GROUP, 1); String account = c.getString(PeopleQuery._SYNC_ACCOUNT); - String syncId = c.getString(PeopleQuery._SYNC_ID); - if (!TextUtils.isEmpty(account) && !TextUtils.isEmpty(syncId)) { + if (!TextUtils.isEmpty(account)) { bindString(insert, RawContactsInsert.ACCOUNT_NAME, account); bindString(insert, RawContactsInsert.ACCOUNT_TYPE, DEFAULT_ACCOUNT_TYPE); - bindString(insert, RawContactsInsert.SOURCE_ID, syncId); + bindString(insert, RawContactsInsert.SOURCE_ID, c.getString(PeopleQuery._SYNC_ID)); } else { insert.bindNull(RawContactsInsert.ACCOUNT_NAME); insert.bindNull(RawContactsInsert.ACCOUNT_TYPE); @@ -1075,9 +1073,8 @@ public class LegacyContactImporter { insert.bindBlob(PhotoInsert.PHOTO, c.getBlob(PhotosQuery.DATA)); String account = c.getString(PhotosQuery._SYNC_ACCOUNT); - String syncId = c.getString(PhotosQuery._SYNC_ID); - if (!TextUtils.isEmpty(account) && !TextUtils.isEmpty(syncId)) { - insert.bindString(PhotoInsert.SYNC1, syncId); + if (!TextUtils.isEmpty(account)) { + bindString(insert, PhotoInsert.SYNC1, c.getString(PhotosQuery._SYNC_ID)); } else { insert.bindNull(PhotoInsert.SYNC1); } @@ -1133,8 +1130,9 @@ public class LegacyContactImporter { long groupId = 0; if (c.isNull(GroupMembershipQuery.GROUP_ID)) { String account = c.getString(GroupMembershipQuery.GROUP_SYNC_ACCOUNT); - String syncId = c.getString(GroupMembershipQuery.GROUP_SYNC_ID); - if (!TextUtils.isEmpty(account) && !TextUtils.isEmpty(syncId)) { + if (!TextUtils.isEmpty(account)) { + String syncId = c.getString(GroupMembershipQuery.GROUP_SYNC_ID); + Cursor cursor = mTargetDb.query(Tables.GROUPS, new String[]{Groups._ID}, Groups.SOURCE_ID + "=?", new String[]{syncId}, null, null, null); @@ -1274,14 +1272,14 @@ public class LegacyContactImporter { private void insertDeletedPerson(Cursor c, SQLiteStatement insert) { String account = c.getString(DeletedPeopleQuery._SYNC_ACCOUNT); - String syncId = c.getString(DeletedPeopleQuery._SYNC_ID); - if (TextUtils.isEmpty(account) || TextUtils.isEmpty(syncId)) { + if (account == null) { return; } insert.bindString(DeletedRawContactInsert.ACCOUNT_NAME, account); insert.bindString(DeletedRawContactInsert.ACCOUNT_TYPE, DEFAULT_ACCOUNT_TYPE); - insert.bindString(DeletedRawContactInsert.SOURCE_ID, syncId); + bindString(insert, DeletedRawContactInsert.SOURCE_ID, + c.getString(DeletedPeopleQuery._SYNC_ID)); insert.bindLong(DeletedRawContactInsert.DELETED, 1); insert.bindLong(DeletedRawContactInsert.AGGREGATION_MODE, RawContacts.AGGREGATION_MODE_DISABLED); |