diff options
author | Dmitri Plotnikov <dplotnikov@google.com> | 2010-04-05 14:18:45 -0700 |
---|---|---|
committer | Dmitri Plotnikov <dplotnikov@google.com> | 2010-04-05 14:18:59 -0700 |
commit | 2aa932da79a22b69d55e862966941afe4377532e (patch) | |
tree | 91213ee416e25643301243b797e1192a1ea8f6d3 | |
parent | c64e0fb0655d8e81c22db555b55c953b5b787b01 (diff) | |
download | ContactsProvider-2aa932da79a22b69d55e862966941afe4377532e.tar.gz |
Fixing handling of null sync ID in legacy import.
Bug: 2498528
Change-Id: I0c0f84ab39258ce068a8013cb0e704e8cdf23e80
-rw-r--r-- | src/com/android/providers/contacts/LegacyContactImporter.java | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/com/android/providers/contacts/LegacyContactImporter.java b/src/com/android/providers/contacts/LegacyContactImporter.java index 00982151..30751ba8 100644 --- a/src/com/android/providers/contacts/LegacyContactImporter.java +++ b/src/com/android/providers/contacts/LegacyContactImporter.java @@ -97,7 +97,7 @@ public class LegacyContactImporter { private long mPhotoMimetypeId; private long mGroupMembershipMimetypeId; - private long mEstimatedStorageRequirement; + private long mEstimatedStorageRequirement = DATABASE_MIN_SIZE; public LegacyContactImporter(Context context, ContactsProvider2 contactsProvider) { mContext = context; @@ -297,10 +297,11 @@ public class LegacyContactImporter { insert.bindLong(GroupsInsert.GROUP_VISIBLE, 1); String account = c.getString(GroupsQuery._SYNC_ACCOUNT); - if (!TextUtils.isEmpty(account)) { + String syncId = c.getString(GroupsQuery._SYNC_ID); + if (!TextUtils.isEmpty(account) && !TextUtils.isEmpty(syncId)) { bindString(insert, GroupsInsert.ACCOUNT_NAME, account); bindString(insert, GroupsInsert.ACCOUNT_TYPE, DEFAULT_ACCOUNT_TYPE); - bindString(insert, GroupsInsert.SOURCE_ID, c.getString(GroupsQuery._SYNC_ID)); + bindString(insert, GroupsInsert.SOURCE_ID, syncId); } else { insert.bindNull(GroupsInsert.ACCOUNT_NAME); insert.bindNull(GroupsInsert.ACCOUNT_TYPE); @@ -558,10 +559,11 @@ public class LegacyContactImporter { insert.bindLong(RawContactsInsert.CONTACT_IN_VISIBLE_GROUP, 1); String account = c.getString(PeopleQuery._SYNC_ACCOUNT); - if (!TextUtils.isEmpty(account)) { + String syncId = c.getString(PeopleQuery._SYNC_ID); + if (!TextUtils.isEmpty(account) && !TextUtils.isEmpty(syncId)) { bindString(insert, RawContactsInsert.ACCOUNT_NAME, account); bindString(insert, RawContactsInsert.ACCOUNT_TYPE, DEFAULT_ACCOUNT_TYPE); - bindString(insert, RawContactsInsert.SOURCE_ID, c.getString(PeopleQuery._SYNC_ID)); + bindString(insert, RawContactsInsert.SOURCE_ID, syncId); } else { insert.bindNull(RawContactsInsert.ACCOUNT_NAME); insert.bindNull(RawContactsInsert.ACCOUNT_TYPE); @@ -1073,8 +1075,9 @@ public class LegacyContactImporter { insert.bindBlob(PhotoInsert.PHOTO, c.getBlob(PhotosQuery.DATA)); String account = c.getString(PhotosQuery._SYNC_ACCOUNT); - if (!TextUtils.isEmpty(account)) { - insert.bindString(PhotoInsert.SYNC1, c.getString(PhotosQuery._SYNC_ID)); + String syncId = c.getString(PhotosQuery._SYNC_ID); + if (!TextUtils.isEmpty(account) && !TextUtils.isEmpty(syncId)) { + insert.bindString(PhotoInsert.SYNC1, syncId); } else { insert.bindNull(PhotoInsert.SYNC1); } @@ -1130,9 +1133,8 @@ public class LegacyContactImporter { long groupId = 0; if (c.isNull(GroupMembershipQuery.GROUP_ID)) { String account = c.getString(GroupMembershipQuery.GROUP_SYNC_ACCOUNT); - if (!TextUtils.isEmpty(account)) { - String syncId = c.getString(GroupMembershipQuery.GROUP_SYNC_ID); - + String syncId = c.getString(GroupMembershipQuery.GROUP_SYNC_ID); + if (!TextUtils.isEmpty(account) && !TextUtils.isEmpty(syncId)) { Cursor cursor = mTargetDb.query(Tables.GROUPS, new String[]{Groups._ID}, Groups.SOURCE_ID + "=?", new String[]{syncId}, null, null, null); @@ -1272,14 +1274,14 @@ public class LegacyContactImporter { private void insertDeletedPerson(Cursor c, SQLiteStatement insert) { String account = c.getString(DeletedPeopleQuery._SYNC_ACCOUNT); - if (account == null) { + String syncId = c.getString(DeletedPeopleQuery._SYNC_ID); + if (TextUtils.isEmpty(account) || TextUtils.isEmpty(syncId)) { return; } insert.bindString(DeletedRawContactInsert.ACCOUNT_NAME, account); insert.bindString(DeletedRawContactInsert.ACCOUNT_TYPE, DEFAULT_ACCOUNT_TYPE); - insert.bindString(DeletedRawContactInsert.SOURCE_ID, - c.getString(DeletedPeopleQuery._SYNC_ID)); + insert.bindString(DeletedRawContactInsert.SOURCE_ID, syncId); insert.bindLong(DeletedRawContactInsert.DELETED, 1); insert.bindLong(DeletedRawContactInsert.AGGREGATION_MODE, RawContacts.AGGREGATION_MODE_DISABLED); |