aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZheng Fu <zhengfu@google.com>2015-06-09 16:52:34 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-09 16:52:35 +0000
commit039259f7a3fa9cb11e891c878728b6cc0bc80f25 (patch)
tree2ef513b0c5d399ac745fb55f4b5af07798bbe286
parent6c3380a5e5d5ce112f4ea5991b1f7136d51e5ce7 (diff)
parenta87f9f49c7f773d9ad0926de5017463d72938dab (diff)
downloadContactsProvider-039259f7a3fa9cb11e891c878728b6cc0bc80f25.tar.gz
Merge "Roll out new aggregator to limited dogfooders." into mnc-dev
-rw-r--r--src/com/android/providers/contacts/ContactsProvider2.java11
-rw-r--r--tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java8
2 files changed, 18 insertions, 1 deletions
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index 72512b70..c881c658 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -276,7 +276,11 @@ public class ContactsProvider2 extends AbstractContactsProvider
private static final String PREF_LOCALE = "locale";
- private static final int PROPERTY_AGGREGATION_ALGORITHM_VERSION = 4;
+ private static int PROPERTY_AGGREGATION_ALGORITHM_VERSION;
+
+ private static final int AGGREGATION_ALGORITHM_OLD_VERSION = 4;
+
+ private static final int AGGREGATION_ALGORITHM_NEW_VERSION = 5;
private static final String AGGREGATE_CONTACTS = "sync.contacts.aggregate";
@@ -1602,6 +1606,11 @@ public class ContactsProvider2 extends AbstractContactsProvider
int value = android.provider.Settings.Global.getInt(context.getContentResolver(),
Global.NEW_CONTACT_AGGREGATOR, 0);
+
+ // Turn on aggregation algorithm updating process if new aggregator is enabled.
+ PROPERTY_AGGREGATION_ALGORITHM_VERSION = (value == 0)
+ ? AGGREGATION_ALGORITHM_OLD_VERSION
+ : AGGREGATION_ALGORITHM_NEW_VERSION;
mContactAggregator = (value == 0)
? new ContactAggregator(this, mContactsHelper,
createPhotoPriorityResolver(context), mNameSplitter, mCommonNicknameCache)
diff --git a/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java b/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java
index 58a7a6e0..3b59cdb8 100644
--- a/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java
+++ b/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java
@@ -37,6 +37,7 @@ import android.test.MoreAsserts;
import android.test.suitebuilder.annotation.MediumTest;
import com.android.providers.contacts.BaseContactsProvider2Test;
+import com.android.providers.contacts.ContactsProvider2;
import com.android.providers.contacts.TestUtils;
import com.android.providers.contacts.tests.R;
import com.android.providers.contacts.testutil.DataUtil;
@@ -67,6 +68,13 @@ public class ContactAggregatorTest extends BaseContactsProvider2Test {
AggregationExceptions.RAW_CONTACT_ID2
};
+ protected void setUp() throws Exception {
+ super.setUp();
+ final ContactsProvider2 cp = (ContactsProvider2) getProvider();
+ // Make sure to use ContactAggregator.java class
+ cp.setNewAggregatorForTest(false);
+ }
+
public void testCrudAggregationExceptions() throws Exception {
long rawContactId1 = RawContactUtil.createRawContactWithName(mResolver, "zz", "top");
long rawContactId2 = RawContactUtil.createRawContactWithName(mResolver, "aa", "bottom");