aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/com/android/providers/contacts/LegacyContactImporter.java28
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);