Merge change 21367 into eclair
* changes:
Simplified and fixed aggregation on structured name.
diff --git a/src/com/android/providers/contacts/LegacyContactImporter.java b/src/com/android/providers/contacts/LegacyContactImporter.java
index 7d06a7d..bdead14 100644
--- a/src/com/android/providers/contacts/LegacyContactImporter.java
+++ b/src/com/android/providers/contacts/LegacyContactImporter.java
@@ -55,10 +55,6 @@
public static final String DEFAULT_ACCOUNT_TYPE = "com.google.GAIA";
private static final String DATABASE_NAME = "contacts.db";
- private static final String CONTACTS_FEED_URL = "http://www.google.com/m8/feeds/contacts/";
- private static final String GROUPS_FEED_URL = "http://www.google.com/m8/feeds/groups/";
- private static final String PHOTO_FEED_URL = "http://www.google.com/m8/feeds/photos/media/";
-
private static final int INSERT_BATCH_SIZE = 200;
private final Context mContext;
@@ -233,11 +229,9 @@
String account = c.getString(GroupsQuery._SYNC_ACCOUNT);
if (!TextUtils.isEmpty(account)) {
- String syncId = c.getString(GroupsQuery._SYNC_ID);
- String sourceId = buildGroupSourceId(account, syncId);
bindString(insert, GroupsInsert.ACCOUNT_NAME, account);
bindString(insert, GroupsInsert.ACCOUNT_TYPE, DEFAULT_ACCOUNT_TYPE);
- bindString(insert, GroupsInsert.SOURCE_ID, sourceId);
+ bindString(insert, GroupsInsert.SOURCE_ID, c.getString(GroupsQuery._SYNC_ID));
} else {
insert.bindNull(GroupsInsert.ACCOUNT_NAME);
insert.bindNull(GroupsInsert.ACCOUNT_TYPE);
@@ -246,14 +240,6 @@
insert(insert);
}
- private String buildGroupSourceId(String account, String syncId) {
- if (account == null || syncId == null) {
- return null;
- }
-
- return GROUPS_FEED_URL + account + "/base/" + syncId;
- }
-
private interface PeopleQuery {
String TABLE = "people";
@@ -455,11 +441,9 @@
String account = c.getString(PeopleQuery._SYNC_ACCOUNT);
if (!TextUtils.isEmpty(account)) {
- String syncId = c.getString(PeopleQuery._SYNC_ID);
- String sourceId = buildRawContactSourceId(account, syncId);
bindString(insert, RawContactsInsert.ACCOUNT_NAME, account);
bindString(insert, RawContactsInsert.ACCOUNT_TYPE, DEFAULT_ACCOUNT_TYPE);
- bindString(insert, RawContactsInsert.SOURCE_ID, sourceId);
+ bindString(insert, RawContactsInsert.SOURCE_ID, c.getString(PeopleQuery._SYNC_ID));
} else {
insert.bindNull(RawContactsInsert.ACCOUNT_NAME);
insert.bindNull(RawContactsInsert.ACCOUNT_TYPE);
@@ -512,14 +496,6 @@
insert(insert);
}
- private String buildRawContactSourceId(String account, String syncId) {
- if (account == null || syncId == null) {
- return null;
- }
-
- return CONTACTS_FEED_URL + account + "/base/" + syncId;
- }
-
private interface OrganizationsQuery {
String TABLE = "organizations";
@@ -863,9 +839,7 @@
String account = c.getString(PhotosQuery._SYNC_ACCOUNT);
if (!TextUtils.isEmpty(account)) {
- String syncId = c.getString(PhotosQuery._SYNC_ID);
- String sourceId = buildPhotoSourceId(account, syncId);
- insert.bindString(PhotoInsert.SYNC1, sourceId);
+ insert.bindString(PhotoInsert.SYNC1, c.getString(PhotosQuery._SYNC_ID));
} else {
insert.bindNull(PhotoInsert.SYNC1);
}
@@ -873,14 +847,6 @@
insert(insert);
}
- private String buildPhotoSourceId(String account, String syncId) {
- if (account == null || syncId == null) {
- return null;
- }
-
- return PHOTO_FEED_URL + account + "/" + syncId;
- }
-
private interface GroupMembershipQuery {
String TABLE = "groupmembership";
@@ -927,10 +893,9 @@
String account = c.getString(GroupMembershipQuery.GROUP_SYNC_ACCOUNT);
if (!TextUtils.isEmpty(account)) {
String syncId = c.getString(GroupMembershipQuery.GROUP_SYNC_ID);
- String sourceId = buildGroupSourceId(account, syncId);
Cursor cursor = mContactsProvider.query(Groups.CONTENT_URI,
- new String[]{Groups._ID}, Groups.SOURCE_ID + "=?", new String[]{sourceId},
+ new String[]{Groups._ID}, Groups.SOURCE_ID + "=?", new String[]{syncId},
null);
try {
if (cursor.moveToFirst()) {
@@ -945,7 +910,7 @@
values.put(Groups.ACCOUNT_NAME, account);
values.put(Groups.ACCOUNT_TYPE, DEFAULT_ACCOUNT_TYPE);
values.put(Groups.GROUP_VISIBLE, true);
- values.put(Groups.SOURCE_ID, sourceId);
+ values.put(Groups.SOURCE_ID, syncId);
Uri groupUri = mContactsProvider.insert(Groups.CONTENT_URI, values);
groupId = ContentUris.parseId(groupUri);
}
@@ -1057,12 +1022,10 @@
return;
}
- String syncId = c.getString(DeletedPeopleQuery._SYNC_ID);
- String sourceId = buildRawContactSourceId(account, syncId);
-
insert.bindString(DeletedRawContactInsert.ACCOUNT_NAME, account);
insert.bindString(DeletedRawContactInsert.ACCOUNT_TYPE, DEFAULT_ACCOUNT_TYPE);
- insert.bindString(DeletedRawContactInsert.SOURCE_ID, sourceId);
+ insert.bindString(DeletedRawContactInsert.SOURCE_ID,
+ c.getString(DeletedPeopleQuery._SYNC_ID));
insert.bindLong(DeletedRawContactInsert.DELETED, 1);
insert.bindLong(DeletedRawContactInsert.AGGREGATION_MODE,
RawContacts.AGGREGATION_MODE_DISABLED);
diff --git a/tests/assets/expected_data.txt b/tests/assets/expected_data.txt
index cdd6c1e..7f70292 100644
--- a/tests/assets/expected_data.txt
+++ b/tests/assets/expected_data.txt
@@ -538,7 +538,7 @@
538 is_primary=0
539 is_super_primary=0
540 data_version=0
-541 data_sync1=http://www.google.com/m8/feeds/photos/media/android.contacts.test.eclair@gmail.com/3d09f37e0f0dbc6f
+541 data_sync1=3d09f37e0f0dbc6f
542 data_sync2=null
543 data_sync3=null
544 data_sync4=null
@@ -555,7 +555,7 @@
555 is_primary=0
556 is_super_primary=0
557 data_version=0
-558 data_sync1=http://www.google.com/m8/feeds/photos/media/android.contacts.test.eclair@gmail.com/5c9ae978b346ac9
+558 data_sync1=5c9ae978b346ac9
559 data_sync2=null
560 data_sync3=null
561 data_sync4=null
diff --git a/tests/assets/expected_groups.txt b/tests/assets/expected_groups.txt
index 5ff878f..4d813af 100644
--- a/tests/assets/expected_groups.txt
+++ b/tests/assets/expected_groups.txt
@@ -6,7 +6,7 @@
6 group_visible=1
7 notes=System Group: My Contacts
8 res_package=null
-9 sourceid=http://www.google.com/m8/feeds/groups/android.contacts.test.eclair@gmail.com/base/6
+9 sourceid=6
10 system_id=Contacts
11 title=System Group: My Contacts
12 version=1
@@ -23,7 +23,7 @@
23 group_visible=1
24 notes=Eclair Contacts
25 res_package=null
-26 sourceid=http://www.google.com/m8/feeds/groups/android.contacts.test.eclair@gmail.com/base/20a186238cf27aaa
+26 sourceid=20a186238cf27aaa
27 system_id=null
28 title=Eclair Contacts
29 version=1
@@ -40,7 +40,7 @@
40 group_visible=1
41 notes=Starred in Android
42 res_package=null
-43 sourceid=http://www.google.com/m8/feeds/groups/android.contacts.test.eclair@gmail.com/base/2fcbf74c8be345dc
+43 sourceid=2fcbf74c8be345dc
44 system_id=null
45 title=Starred in Android
46 version=1
@@ -57,7 +57,7 @@
57 group_visible=1
58 notes=null
59 res_package=null
-60 sourceid=http://www.google.com/m8/feeds/groups/android.contacts.test.eclair@gmail.com/base/55555555555
+60 sourceid=55555555555
61 system_id=null
62 title=null
63 version=1
diff --git a/tests/assets/expected_raw_contacts.txt b/tests/assets/expected_raw_contacts.txt
index 21c9a6a..65928e5 100644
--- a/tests/assets/expected_raw_contacts.txt
+++ b/tests/assets/expected_raw_contacts.txt
@@ -17,7 +17,7 @@
17 account_type=com.google.GAIA
18 deleted=0
19 dirty=1
-20 sourceid=http://www.google.com/m8/feeds/contacts/android.contacts.test.eclair@gmail.com/base/3d09f37e0f0dbc6f
+20 sourceid=3d09f37e0f0dbc6f
21 version=25
22 sync1=1249441106583000
23 sync2=null
@@ -30,7 +30,7 @@
30 account_type=com.google.GAIA
31 deleted=0
32 dirty=1
-33 sourceid=http://www.google.com/m8/feeds/contacts/android.contacts.test.eclair@gmail.com/base/5c9ae978b346ac9
+33 sourceid=5c9ae978b346ac9
34 version=12
35 sync1=1249441067558000
36 sync2=null
@@ -56,7 +56,7 @@
56 account_type=com.google.GAIA
57 deleted=1
58 dirty=0
-59 sourceid=http://www.google.com/m8/feeds/contacts/android.contacts.test.eclair@gmail.com/base/20d08a710c3df43d
+59 sourceid=20d08a710c3df43d
60 version=1
61 sync1=null
62 sync2=null