ContactsProvider2: Renaming Aggregates to Contacts
diff --git a/src/com/android/providers/contacts/ContactAggregator.java b/src/com/android/providers/contacts/ContactAggregator.java
index 0568dd7..637601c 100644
--- a/src/com/android/providers/contacts/ContactAggregator.java
+++ b/src/com/android/providers/contacts/ContactAggregator.java
@@ -17,13 +17,13 @@
 package com.android.providers.contacts;
 
 import com.android.providers.contacts.ContactMatcher.MatchScore;
-import com.android.providers.contacts.OpenHelper.AggregatesColumns;
 import com.android.providers.contacts.OpenHelper.AggregationExceptionColumns;
 import com.android.providers.contacts.OpenHelper.Clauses;
-import com.android.providers.contacts.OpenHelper.RawContactsColumns;
+import com.android.providers.contacts.OpenHelper.ContactsColumns;
 import com.android.providers.contacts.OpenHelper.MimetypesColumns;
 import com.android.providers.contacts.OpenHelper.NameLookupColumns;
 import com.android.providers.contacts.OpenHelper.NameLookupType;
+import com.android.providers.contacts.OpenHelper.RawContactsColumns;
 import com.android.providers.contacts.OpenHelper.Tables;
 
 import android.content.ContentValues;
@@ -32,12 +32,11 @@
 import android.database.DatabaseUtils;
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteQueryBuilder;
-import android.database.sqlite.SQLiteStatement;
-import android.provider.ContactsContract.Aggregates;
 import android.provider.ContactsContract.AggregationExceptions;
 import android.provider.ContactsContract.CommonDataKinds;
-import android.provider.ContactsContract.RawContacts;
+import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.Data;
+import android.provider.ContactsContract.RawContacts;
 import android.provider.ContactsContract.CommonDataKinds.Email;
 import android.provider.ContactsContract.CommonDataKinds.Nickname;
 import android.provider.ContactsContract.CommonDataKinds.Phone;
@@ -84,32 +83,32 @@
     private static final int COL_DATA2 = 2;
 
     private static final String[] DATA_JOIN_MIMETYPE_AND_CONTACT_COLUMNS = new String[] {
-            Data.DATA1, Data.DATA2, RawContacts.AGGREGATE_ID
+            Data.DATA1, Data.DATA2, RawContacts.CONTACT_ID
     };
 
     private static final int COL_DATA_CONTACT_DATA1 = 0;
     private static final int COL_DATA_CONTACT_DATA2 = 1;
-    private static final int COL_DATA_CONTACT_AGGREGATE_ID = 2;
+    private static final int COL_DATA_CONTACT_CONTACT_ID = 2;
 
     private static final String[] NAME_LOOKUP_COLUMNS = new String[] {
-            RawContacts.AGGREGATE_ID, NameLookupColumns.NORMALIZED_NAME, NameLookupColumns.NAME_TYPE
+            RawContacts.CONTACT_ID, NameLookupColumns.NORMALIZED_NAME, NameLookupColumns.NAME_TYPE
     };
 
-    private static final int COL_NAME_LOOKUP_AGGREGATE_ID = 0;
+    private static final int COL_NAME_LOOKUP_CONTACT_ID = 0;
     private static final int COL_NORMALIZED_NAME = 1;
     private static final int COL_NAME_TYPE = 2;
 
     private static final String[] AGGREGATE_EXCEPTION_JOIN_CONTACT_TWICE_COLUMNS = new String[]{
             AggregationExceptions.TYPE,
             AggregationExceptionColumns.RAW_CONTACT_ID1,
-            "raw_contacts1." + RawContacts.AGGREGATE_ID,
-            "raw_contacts2." + RawContacts.AGGREGATE_ID
+            "raw_contacts1." + RawContacts.CONTACT_ID,
+            "raw_contacts2." + RawContacts.CONTACT_ID
     };
 
     private static final int COL_TYPE = 0;
-    private static final int COL_CONTACT_ID1 = 1;
-    private static final int COL_AGGREGATE_ID1 = 2;
-    private static final int COL_AGGREGATE_ID2 = 3;
+    private static final int COL_RAW_CONTACT_ID1 = 1;
+    private static final int COL_CONTACT_ID1 = 2;
+    private static final int COL_CONTACT_ID2 = 3;
 
     private static final String[] CONTACT_ID_COLUMN = new String[] { RawContacts._ID };
 
@@ -127,8 +126,8 @@
     private static final int COL_TIMES_CONTACTED = 3;
     private static final int COL_STARRED = 4;
 
-    private static final String[] AGGREGATE_ID_COLUMNS = new String[]{ RawContacts.AGGREGATE_ID };
-    private static final int COL_AGGREGATE_ID = 0;
+    private static final String[] CONTACT_ID_COLUMNS = new String[]{ RawContacts.CONTACT_ID };
+    private static final int COL_CONTACT_ID = 0;
 
     private static final int MODE_INSERT_LOOKUP_DATA = 0;
     private static final int MODE_AGGREGATION = 1;
@@ -202,7 +201,7 @@
 
     /**
      * Schedules aggregation pass after a short delay.  This method should be called every time
-     * the {@link RawContacts#AGGREGATE_ID} field is reset on any record.
+     * the {@link RawContacts#CONTACT_ID} field is reset on any record.
      */
     public void schedule() {
         mScheduler.schedule();
@@ -236,7 +235,7 @@
 
         final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
         final Cursor c = db.query(Tables.RAW_CONTACTS, new String[]{RawContacts._ID},
-                RawContacts.AGGREGATE_ID + " IS NULL AND "
+                RawContacts.CONTACT_ID + " IS NULL AND "
                         + RawContacts.AGGREGATION_MODE + "=" + RawContacts.AGGREGATION_MODE_DEFAULT,
                 null, null, null, null);
 
@@ -308,12 +307,12 @@
     public int markContactForAggregation(long rawContactId) {
         final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
 
-        long aggregateId = mOpenHelper.getAggregateId(rawContactId);
-        if (aggregateId != 0) {
+        long contactId = mOpenHelper.getContactId(rawContactId);
+        if (contactId != 0) {
 
-            // Clear out the aggregate ID field on the contact
+            // Clear out the contact ID field on the contact
             ContentValues values = new ContentValues();
-            values.putNull(RawContacts.AGGREGATE_ID);
+            values.putNull(RawContacts.CONTACT_ID);
             int updated = db.update(Tables.RAW_CONTACTS, values,
                     RawContacts._ID + "=" + rawContactId + " AND " + RawContacts.AGGREGATION_MODE + "="
                             + RawContacts.AGGREGATION_MODE_DEFAULT, null);
@@ -325,56 +324,56 @@
             db.execSQL("DELETE FROM " + Tables.NAME_LOOKUP + " WHERE "
                     + NameLookupColumns.RAW_CONTACT_ID + "=" + rawContactId);
 
-            // Delete the aggregate itself if it no longer has constituent contacts
-            db.execSQL("DELETE FROM " + Tables.AGGREGATES + " WHERE " + Aggregates._ID + "="
-                    + aggregateId + " AND " + Aggregates._ID + " NOT IN (SELECT "
-                    + RawContacts.AGGREGATE_ID + " FROM " + Tables.RAW_CONTACTS + ");");
+            // Delete the aggregate contact itself if it no longer has constituent raw contacts
+            db.execSQL("DELETE FROM " + Tables.CONTACTS + " WHERE " + Contacts._ID + "="
+                    + contactId + " AND " + Contacts._ID + " NOT IN (SELECT "
+                    + RawContacts.CONTACT_ID + " FROM " + Tables.RAW_CONTACTS + ");");
             return RawContacts.AGGREGATION_MODE_DEFAULT;
         }
         return RawContacts.AGGREGATION_MODE_DISABLED;
     }
 
-    public void updateAggregateData(long aggregateId) {
+    public void updateAggregateData(long contactId) {
         final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
         final ContentValues values = new ContentValues();
-        updateAggregateData(db, aggregateId, values);
+        updateAggregateData(db, contactId, values);
     }
 
     /**
-     * Given a specific contact, finds all matching aggregates and chooses the aggregate
-     * with the highest match score.  If no such aggregate is found, creates a new aggregate.
+     * Given a specific raw contact, finds all matching aggregate contacts and chooses the one
+     * with the highest match score.  If no such contact is found, creates a new contact.
      */
     /* package */ synchronized void aggregateContact(SQLiteDatabase db, long rawContactId,
             MatchCandidateList candidates, ContactMatcher matcher, ContentValues values) {
         candidates.clear();
         matcher.clear();
 
-        long aggregateId = pickBestMatchBasedOnExceptions(db, rawContactId, matcher);
-        if (aggregateId == -1) {
-            aggregateId = pickBestMatchBasedOnData(db, rawContactId, candidates, matcher);
+        long contactId = pickBestMatchBasedOnExceptions(db, rawContactId, matcher);
+        if (contactId == -1) {
+            contactId = pickBestMatchBasedOnData(db, rawContactId, candidates, matcher);
         }
 
         boolean newAgg = false;
 
-        if (aggregateId == -1) {
+        if (contactId == -1) {
             newAgg = true;
-            ContentValues aggregateValues = new ContentValues();
-            aggregateValues.put(Aggregates.DISPLAY_NAME, "");
-            aggregateId = db.insert(Tables.AGGREGATES, Aggregates.DISPLAY_NAME, aggregateValues);
+            ContentValues contactValues = new ContentValues();
+            contactValues.put(Contacts.DISPLAY_NAME, "");
+            contactId = db.insert(Tables.CONTACTS, Contacts.DISPLAY_NAME, contactValues);
         }
 
         updateContactAggregationData(db, rawContactId, candidates, values);
-        mOpenHelper.setAggregateId(rawContactId, aggregateId);
+        mOpenHelper.setContactId(rawContactId, contactId);
 
-        updateAggregateData(db, aggregateId, values);
-        updatePrimaries(db, aggregateId, rawContactId, newAgg);
-        mOpenHelper.updateAggregateVisible(aggregateId);
+        updateAggregateData(db, contactId, values);
+        updatePrimaries(db, contactId, rawContactId, newAgg);
+        mOpenHelper.updateContactVisible(contactId);
 
     }
 
     /**
      * Computes match scores based on exceptions entered by the user: always match and never match.
-     * Returns the aggregate with the always match exception if any.
+     * Returns the aggregate contact with the always match exception if any.
      */
     private long pickBestMatchBasedOnExceptions(SQLiteDatabase db, long rawContactId,
             ContactMatcher matcher) {
@@ -387,22 +386,22 @@
         try {
             while (c.moveToNext()) {
                 int type = c.getInt(COL_TYPE);
-                long contactId1 = c.getLong(COL_CONTACT_ID1);
-                long aggregateId = -1;
-                if (rawContactId == contactId1) {
-                    if (!c.isNull(COL_AGGREGATE_ID2)) {
-                        aggregateId = c.getLong(COL_AGGREGATE_ID2);
+                long rawContactId1 = c.getLong(COL_RAW_CONTACT_ID1);
+                long contactId = -1;
+                if (rawContactId == rawContactId1) {
+                    if (!c.isNull(COL_CONTACT_ID2)) {
+                        contactId = c.getLong(COL_CONTACT_ID2);
                     }
                 } else {
-                    if (!c.isNull(COL_AGGREGATE_ID1)) {
-                        aggregateId = c.getLong(COL_AGGREGATE_ID1);
+                    if (!c.isNull(COL_CONTACT_ID1)) {
+                        contactId = c.getLong(COL_CONTACT_ID1);
                     }
                 }
-                if (aggregateId != -1) {
+                if (contactId != -1) {
                     if (type == AggregationExceptions.TYPE_KEEP_IN) {
-                        return aggregateId;
+                        return contactId;
                     } else {
-                        matcher.keepOut(aggregateId);
+                        matcher.keepOut(contactId);
                     }
                 }
             }
@@ -414,7 +413,7 @@
     }
 
     /**
-     * Picks the best matching aggregate based on matches between data elements.  It considers
+     * Picks the best matching contact based on matches between data elements.  It considers
      * name match to be primary and phone, email etc matches to be secondary.  A good primary
      * match triggers aggregation, while a good secondary match only triggers aggregation in
      * the absence of a strong primary mismatch.
@@ -443,25 +442,25 @@
     }
 
     /**
-     * Picks the best matching aggregate based on secondary data matches.  The method loads
-     * structured names for all candidate aggregates and recomputes match scores using approximate
+     * Picks the best matching contact based on secondary data matches.  The method loads
+     * structured names for all candidate contacts and recomputes match scores using approximate
      * matching.
      */
     private long pickBestMatchBasedOnSecondaryData(SQLiteDatabase db,
             MatchCandidateList candidates, ContactMatcher matcher) {
-        List<Long> secondaryAggregateIds = matcher.prepareSecondaryMatchCandidates(
+        List<Long> secondaryContactIds = matcher.prepareSecondaryMatchCandidates(
                 ContactMatcher.SCORE_THRESHOLD_PRIMARY);
-        if (secondaryAggregateIds == null) {
+        if (secondaryContactIds == null) {
             return -1;
         }
 
         StringBuilder selection = new StringBuilder();
-        selection.append(RawContacts.AGGREGATE_ID).append(" IN (");
-        for (int i = 0; i < secondaryAggregateIds.size(); i++) {
+        selection.append(RawContacts.CONTACT_ID).append(" IN (");
+        for (int i = 0; i < secondaryContactIds.size(); i++) {
             if (i != 0) {
                 selection.append(',');
             }
-            selection.append(secondaryAggregateIds.get(i));
+            selection.append(secondaryContactIds.get(i));
         }
         selection.append(") AND ")
                 .append(MimetypesColumns.MIMETYPE)
@@ -478,7 +477,7 @@
             while (c.moveToNext()) {
                 String givenName = c.getString(COL_DATA_CONTACT_DATA1);
                 String familyName = c.getString(COL_DATA_CONTACT_DATA2);
-                long aggregateId = c.getLong(COL_DATA_CONTACT_AGGREGATE_ID);
+                long contactId = c.getLong(COL_DATA_CONTACT_CONTACT_ID);
 
                 nameCandidates.clear();
                 addMatchCandidatesStructuredName(givenName, familyName, MODE_INSERT_LOOKUP_DATA,
@@ -495,7 +494,7 @@
                     if (NameLookupType.isBasedOnStructuredName(candidate.mLookupType)) {
                         for (int j = 0; j < nameCandidates.mCount; j++) {
                             NameMatchCandidate nameCandidate = nameCandidates.mList.get(j);
-                            matcher.matchName(aggregateId,
+                            matcher.matchName(contactId,
                                     nameCandidate.mLookupType, nameCandidate.mName,
                                     candidate.mLookupType, candidate.mName, true);
                         }
@@ -510,7 +509,7 @@
     }
 
     /**
-     * Computes scores for aggregates that have matching data rows.
+     * Computes scores for contacts that have matching data rows.
      */
     private void updateMatchScoresBasedOnDataMatches(SQLiteDatabase db, long rawContactId,
             int mode, MatchCandidateList candidates, ContactMatcher matcher) {
@@ -556,8 +555,7 @@
             MatchCandidateList candidates) {
         if (TextUtils.isEmpty(givenName)) {
 
-            // If neither the first nor last name are specified, we won't
-            // aggregate
+            // If neither the first nor last name are specified, we won't aggregate
             if (TextUtils.isEmpty(familyName)) {
                 return;
             }
@@ -688,7 +686,7 @@
         // Yank the last comma
         selection.setLength(selection.length() - 1);
         selection.append(") AND ");
-        selection.append(RawContacts.AGGREGATE_ID);
+        selection.append(RawContacts.CONTACT_ID);
         selection.append(" NOT NULL");
 
         matchAllCandidates(db, selection.toString(), candidates, matcher, false);
@@ -708,7 +706,7 @@
                 if (!firstLetters.contains(firstLetter)) {
                     firstLetters.add(firstLetter);
                     final String selection = "(" + NameLookupColumns.NORMALIZED_NAME + " GLOB '"
-                            + firstLetter + "*') AND " + RawContacts.AGGREGATE_ID + " NOT NULL";
+                            + firstLetter + "*') AND " + RawContacts.CONTACT_ID + " NOT NULL";
                     matchAllCandidates(db, selection, candidates, matcher, true);
                 }
             }
@@ -726,14 +724,14 @@
 
         try {
             while (c.moveToNext()) {
-                Long aggregateId = c.getLong(COL_NAME_LOOKUP_AGGREGATE_ID);
+                Long contactId = c.getLong(COL_NAME_LOOKUP_CONTACT_ID);
                 String name = c.getString(COL_NORMALIZED_NAME);
                 int nameType = c.getInt(COL_NAME_TYPE);
 
                 // Determine which candidate produced this match
                 for (int i = 0; i < candidates.mCount; i++) {
                     NameMatchCandidate candidate = candidates.mList.get(i);
-                    matcher.matchName(aggregateId, candidate.mLookupType, candidate.mName,
+                    matcher.matchName(contactId, candidate.mLookupType, candidate.mName,
                             nameType, name, approximate);
                 }
             }
@@ -745,12 +743,12 @@
     private void lookupPhoneMatches(SQLiteDatabase db, String phoneNumber, ContactMatcher matcher) {
         SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
         OpenHelper.buildPhoneLookupQuery(qb, phoneNumber);
-        Cursor c = qb.query(db, AGGREGATE_ID_COLUMNS,
-                RawContacts.AGGREGATE_ID + " NOT NULL", null, null, null, null);
+        Cursor c = qb.query(db, CONTACT_ID_COLUMNS,
+                RawContacts.CONTACT_ID + " NOT NULL", null, null, null, null);
         try {
             while (c.moveToNext()) {
-                long aggregateId = c.getLong(COL_AGGREGATE_ID);
-                matcher.updateScoreWithPhoneNumberMatch(aggregateId);
+                long contactId = c.getLong(COL_CONTACT_ID);
+                matcher.updateScoreWithPhoneNumberMatch(contactId);
             }
         } finally {
             c.close();
@@ -761,13 +759,13 @@
      * Finds exact email matches and updates their match scores.
      */
     private void lookupEmailMatches(SQLiteDatabase db, String address, ContactMatcher matcher) {
-        Cursor c = db.query(Tables.DATA_JOIN_MIMETYPE_RAW_CONTACTS, AGGREGATE_ID_COLUMNS,
-                Clauses.WHERE_EMAIL_MATCHES + " AND " + RawContacts.AGGREGATE_ID + " NOT NULL",
+        Cursor c = db.query(Tables.DATA_JOIN_MIMETYPE_RAW_CONTACTS, CONTACT_ID_COLUMNS,
+                Clauses.WHERE_EMAIL_MATCHES + " AND " + RawContacts.CONTACT_ID + " NOT NULL",
                 new String[]{address}, null, null, null);
         try {
             while (c.moveToNext()) {
-                long aggregateId = c.getLong(COL_AGGREGATE_ID);
-                matcher.updateScoreWithEmailMatch(aggregateId);
+                long contactId = c.getLong(COL_CONTACT_ID);
+                matcher.updateScoreWithEmailMatch(contactId);
             }
         } finally {
             c.close();
@@ -779,15 +777,15 @@
      */
     private void lookupNicknameMatches(SQLiteDatabase db, String nickname, ContactMatcher matcher) {
         String normalized = NameNormalizer.normalize(nickname);
-        Cursor c = db.query(true, Tables.NAME_LOOKUP_JOIN_RAW_CONTACTS, AGGREGATE_ID_COLUMNS,
+        Cursor c = db.query(true, Tables.NAME_LOOKUP_JOIN_RAW_CONTACTS, CONTACT_ID_COLUMNS,
                 NameLookupColumns.NAME_TYPE + "=" + NameLookupType.NICKNAME + " AND "
                         + NameLookupColumns.NORMALIZED_NAME + "='" + normalized + "' AND "
-                        + RawContacts.AGGREGATE_ID + " NOT NULL",
+                        + RawContacts.CONTACT_ID + " NOT NULL",
                 null, null, null, null, null);
         try {
             while (c.moveToNext()) {
-                long aggregateId = c.getLong(COL_AGGREGATE_ID);
-                matcher.updateScoreWithNicknameMatch(aggregateId);
+                long contactId = c.getLong(COL_CONTACT_ID);
+                matcher.updateScoreWithNicknameMatch(contactId);
             }
         } finally {
             c.close();
@@ -835,19 +833,19 @@
     /**
      * Updates aggregate-level data from constituent contacts.
      */
-    private void updateAggregateData(final SQLiteDatabase db, long aggregateId,
+    private void updateAggregateData(final SQLiteDatabase db, long contactId,
             final ContentValues values) {
-        updateDisplayName(db, aggregateId, values);
-        updateSendToVoicemailAndRingtone(db, aggregateId);
-        updatePhotoId(db, aggregateId, values);
+        updateDisplayName(db, contactId, values);
+        updateSendToVoicemailAndRingtone(db, contactId);
+        updatePhotoId(db, contactId, values);
     }
 
     /**
-     * Updates the aggregate record's {@link Aggregates#DISPLAY_NAME} field. If none of the
-     * constituent contacts has a suitable name, leaves the aggregate record unchanged.
+     * Updates the contact record's {@link Contacts#DISPLAY_NAME} field. If none of the
+     * constituent raw contacts has a suitable name, leaves the aggregate contact record unchanged.
      */
-    private void updateDisplayName(SQLiteDatabase db, long aggregateId, ContentValues values) {
-        String displayName = getBestDisplayName(db, aggregateId);
+    private void updateDisplayName(SQLiteDatabase db, long contactId, ContentValues values) {
+        String displayName = getBestDisplayName(db, contactId);
 
         // If don't have anything to base the display name on, let's just leave what was in
         // that field hoping that there was something there before and it is still valid.
@@ -856,24 +854,24 @@
         }
 
         values.clear();
-        values.put(Aggregates.DISPLAY_NAME, displayName);
-        db.update(Tables.AGGREGATES, values, Aggregates._ID + "=" + aggregateId, null);
+        values.put(Contacts.DISPLAY_NAME, displayName);
+        db.update(Tables.CONTACTS, values, Contacts._ID + "=" + contactId, null);
     }
 
-    private void updatePhotoId(SQLiteDatabase db, long aggregateId, ContentValues values) {
-        int photoId = choosePhotoId(db, aggregateId);
+    private void updatePhotoId(SQLiteDatabase db, long contactId, ContentValues values) {
+        int photoId = choosePhotoId(db, contactId);
 
         if (photoId == -1) {
             return;
         }
 
         values.clear();
-        values.put(Aggregates.PHOTO_ID, photoId);
-        db.update(Tables.AGGREGATES, values, Aggregates._ID + "=" + aggregateId, null);
+        values.put(Contacts.PHOTO_ID, photoId);
+        db.update(Tables.CONTACTS, values, Contacts._ID + "=" + contactId, null);
     }
 
     /**
-     * Updates the various {@link AggregatesColumns} primary values based on the
+     * Updates the various {@link ContactsColumns} primary values based on the
      * newly joined {@link RawContacts} entry. If some aggregate primary values are
      * unassigned, primary values from this contact will be promoted as the new
      * super-primaries.
@@ -888,8 +886,8 @@
 
         // Read currently recorded aggregate primary values
         try {
-            cursor = db.query(Tables.AGGREGATES, Projections.PROJ_AGGREGATE_PRIMARIES,
-                    Aggregates._ID + "=" + aggId, null, null, null, null);
+            cursor = db.query(Tables.CONTACTS, Projections.PROJ_CONTACT_PRIMARIES,
+                    Contacts._ID + "=" + aggId, null, null, null, null);
             if (cursor.moveToNext()) {
                 hasOptimalPhone = (cursor.getLong(Projections.COL_OPTIMAL_PRIMARY_PHONE_ID) != 0);
                 hasFallbackPhone = (cursor.getLong(Projections.COL_FALLBACK_PRIMARY_PHONE_ID) != 0);
@@ -934,24 +932,24 @@
 
         final ContentValues values = new ContentValues();
 
-        // If a new aggregate, and single child is restricted, then mark
-        // aggregate as being protected by package. Otherwise set as null if
-        // multiple under aggregate or not restricted.
-        values.put(AggregatesColumns.SINGLE_IS_RESTRICTED, (newAgg && candidateIsRestricted) ? 1
+        // If a new contact, and single child is restricted, then mark
+        // contact as being protected by package. Otherwise set as null if
+        // multiple under contact or not restricted.
+        values.put(ContactsColumns.SINGLE_IS_RESTRICTED, (newAgg && candidateIsRestricted) ? 1
                 : 0);
 
         // If newly joined contact has a primary phone number, consider
         // promoting it up into aggregate as super-primary.
         if (candidatePhone != 0) {
             if (!hasOptimalPhone) {
-                values.put(AggregatesColumns.OPTIMAL_PRIMARY_PHONE_ID, candidatePhone);
-                values.put(AggregatesColumns.OPTIMAL_PRIMARY_PHONE_IS_RESTRICTED,
+                values.put(ContactsColumns.OPTIMAL_PRIMARY_PHONE_ID, candidatePhone);
+                values.put(ContactsColumns.OPTIMAL_PRIMARY_PHONE_IS_RESTRICTED,
                         candidateIsRestricted ? 1 : 0);
             }
 
             // Also promote to unrestricted value, if none provided yet.
             if (!hasFallbackPhone && !candidateIsRestricted) {
-                values.put(AggregatesColumns.FALLBACK_PRIMARY_PHONE_ID, candidatePhone);
+                values.put(ContactsColumns.FALLBACK_PRIMARY_PHONE_ID, candidatePhone);
             }
         }
 
@@ -959,34 +957,34 @@
         // into aggregate as super-primary.
         if (candidateEmail != 0) {
             if (!hasOptimalEmail) {
-                values.put(AggregatesColumns.OPTIMAL_PRIMARY_EMAIL_ID, candidateEmail);
-                values.put(AggregatesColumns.OPTIMAL_PRIMARY_EMAIL_IS_RESTRICTED,
+                values.put(ContactsColumns.OPTIMAL_PRIMARY_EMAIL_ID, candidateEmail);
+                values.put(ContactsColumns.OPTIMAL_PRIMARY_EMAIL_IS_RESTRICTED,
                         candidateIsRestricted ? 1 : 0);
             }
 
             // Also promote to unrestricted value, if none provided yet.
             if (!hasFallbackEmail && !candidateIsRestricted) {
-                values.put(AggregatesColumns.FALLBACK_PRIMARY_EMAIL_ID, candidateEmail);
+                values.put(ContactsColumns.FALLBACK_PRIMARY_EMAIL_ID, candidateEmail);
             }
         }
 
-        // Only write updated aggregate values if we made changes.
+        // Only write updated contact values if we made changes.
         if (values.size() > 0) {
             Log.d(TAG, "some sort of promotion is going on: " + values.toString());
-            db.update(Tables.AGGREGATES, values, Aggregates._ID + "=" + aggId, null);
+            db.update(Tables.CONTACTS, values, Contacts._ID + "=" + aggId, null);
         }
 
     }
 
     /**
-     * Computes display name for the given aggregate.  Chooses a longer name over a shorter name
+     * Computes display name for the given contact.  Chooses a longer name over a shorter name
      * and a mixed-case name over an all lowercase or uppercase name.
      */
-    private String getBestDisplayName(SQLiteDatabase db, long aggregateId) {
+    private String getBestDisplayName(SQLiteDatabase db, long contactId) {
         String bestDisplayName = null;
 
         final Cursor c = db.query(Tables.RAW_CONTACTS, new String[] {RawContactsColumns.DISPLAY_NAME},
-                RawContacts.AGGREGATE_ID + "=" + aggregateId, null, null, null, null);
+                RawContacts.CONTACT_ID + "=" + contactId, null, null, null, null);
 
         try {
             while (c.moveToNext()) {
@@ -1008,17 +1006,17 @@
     }
 
     /**
-     * Iterates over the photos associated with aggregate defined by aggregateId, and chooses one
-     * to be associated with the aggregate. Initially this just chooses the first photo in a list
+     * Iterates over the photos associated with contact defined by contactId, and chooses one
+     * to be associated with the contact. Initially this just chooses the first photo in a list
      * sorted by account name.
      */
-    private int choosePhotoId(SQLiteDatabase db, long aggregateId) {
+    private int choosePhotoId(SQLiteDatabase db, long contactId) {
         int chosenPhotoId = -1;
         String chosenAccount = null;
 
-        final Cursor c = db.query(Tables.DATA_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_AGGREGATES,
+        final Cursor c = db.query(Tables.DATA_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_CONTACTS,
                 new String[] {"data._id AS _id", RawContacts.ACCOUNT_NAME},
-                DatabaseUtils.concatenateWhere(RawContacts.AGGREGATE_ID + "=" + aggregateId,
+                DatabaseUtils.concatenateWhere(RawContacts.CONTACT_ID + "=" + contactId,
                         Data.MIMETYPE + "='" + Photo.CONTENT_ITEM_TYPE + "'"),
                 null, null, null, null);
 
@@ -1043,19 +1041,19 @@
     }
 
     /**
-     * Updates the aggregate's send-to-voicemail and custom-ringtone options based on
+     * Updates the contact's send-to-voicemail and custom-ringtone options based on
      * constituent contacts' options.
      */
-    private void updateSendToVoicemailAndRingtone(SQLiteDatabase db, long aggregateId) {
+    private void updateSendToVoicemailAndRingtone(SQLiteDatabase db, long contactId) {
         int totalContactCount = 0;
-        int aggregateSendToVoicemail = 0;
-        String aggregateCustomRingtone = null;
-        long aggregateLastTimeContacted = 0;
-        int aggregateTimesContacted = 0;
-        boolean aggregateStarred = false;
+        int contactSendToVoicemail = 0;
+        String contactCustomRingtone = null;
+        long contactLastTimeContacted = 0;
+        int contactTimesContacted = 0;
+        boolean contactStarred = false;
 
         final Cursor c = db.query(Tables.RAW_CONTACTS, CONTACT_OPTIONS_COLUMNS,
-                RawContacts.AGGREGATE_ID + "=" + aggregateId, null, null, null, null);
+                RawContacts.CONTACT_ID + "=" + contactId, null, null, null, null);
 
         try {
             while (c.moveToNext()) {
@@ -1063,44 +1061,44 @@
                 if (!c.isNull(COL_SEND_TO_VOICEMAIL)) {
                     boolean sendToVoicemail = (c.getInt(COL_SEND_TO_VOICEMAIL) != 0);
                     if (sendToVoicemail) {
-                        aggregateSendToVoicemail++;
+                        contactSendToVoicemail++;
                     }
                 }
 
-                if (aggregateCustomRingtone == null && !c.isNull(COL_CUSTOM_RINGTONE)) {
-                    aggregateCustomRingtone = c.getString(COL_CUSTOM_RINGTONE);
+                if (contactCustomRingtone == null && !c.isNull(COL_CUSTOM_RINGTONE)) {
+                    contactCustomRingtone = c.getString(COL_CUSTOM_RINGTONE);
                 }
 
                 long lastTimeContacted = c.getLong(COL_LAST_TIME_CONTACTED);
-                if (lastTimeContacted > aggregateLastTimeContacted) {
-                    aggregateLastTimeContacted = lastTimeContacted;
+                if (lastTimeContacted > contactLastTimeContacted) {
+                    contactLastTimeContacted = lastTimeContacted;
                 }
 
                 int timesContacted = c.getInt(COL_TIMES_CONTACTED);
-                if (timesContacted > aggregateTimesContacted) {
-                    aggregateTimesContacted = timesContacted;
+                if (timesContacted > contactTimesContacted) {
+                    contactTimesContacted = timesContacted;
                 }
 
-                aggregateStarred |= (c.getInt(COL_STARRED) != 0);
+                contactStarred |= (c.getInt(COL_STARRED) != 0);
             }
         } finally {
             c.close();
         }
 
         ContentValues values = new ContentValues(2);
-        values.put(Aggregates.SEND_TO_VOICEMAIL, totalContactCount == aggregateSendToVoicemail);
-        values.put(Aggregates.CUSTOM_RINGTONE, aggregateCustomRingtone);
-        values.put(Aggregates.LAST_TIME_CONTACTED, aggregateLastTimeContacted);
-        values.put(Aggregates.TIMES_CONTACTED, aggregateTimesContacted);
-        values.put(Aggregates.STARRED, aggregateStarred);
+        values.put(Contacts.SEND_TO_VOICEMAIL, totalContactCount == contactSendToVoicemail);
+        values.put(Contacts.CUSTOM_RINGTONE, contactCustomRingtone);
+        values.put(Contacts.LAST_TIME_CONTACTED, contactLastTimeContacted);
+        values.put(Contacts.TIMES_CONTACTED, contactTimesContacted);
+        values.put(Contacts.STARRED, contactStarred);
 
-        db.update(Tables.AGGREGATES, values, Aggregates._ID + "=" + aggregateId, null);
+        db.update(Tables.CONTACTS, values, Contacts._ID + "=" + contactId, null);
     }
 
     /**
-     * Finds matching aggregates and returns a cursor on those.
+     * Finds matching contacts and returns a cursor on those.
      */
-    public Cursor queryAggregationSuggestions(long aggregateId, String[] projection,
+    public Cursor queryAggregationSuggestions(long contactId, String[] projection,
             HashMap<String, String> projectionMap, int maxSuggestions) {
         final SQLiteDatabase db = mOpenHelper.getReadableDatabase();
 
@@ -1110,8 +1108,8 @@
         // aggregation, but not kill it.
         db.beginTransaction();
         try {
-            List<MatchScore> bestMatches = findMatchingAggregates(db, aggregateId, maxSuggestions);
-            c = queryMatchingAggregates(db, aggregateId, projection, projectionMap, bestMatches);
+            List<MatchScore> bestMatches = findMatchingContacts(db, contactId, maxSuggestions);
+            c = queryMatchingContacts(db, contactId, projection, projectionMap, bestMatches);
             db.setTransactionSuccessful();
         } finally {
             db.endTransaction();
@@ -1120,63 +1118,63 @@
     }
 
     /**
-     * Loads aggregates with specified IDs and returns them in the order of IDs in the
+     * Loads contacts with specified IDs and returns them in the order of IDs in the
      * supplied list.
      */
-    private Cursor queryMatchingAggregates(final SQLiteDatabase db, long aggregateId,
+    private Cursor queryMatchingContacts(final SQLiteDatabase db, long contactId,
             String[] projection, HashMap<String, String> projectionMap,
             List<MatchScore> bestMatches) {
 
         StringBuilder selection = new StringBuilder();
-        selection.append(Aggregates._ID);
+        selection.append(Contacts._ID);
         selection.append(" IN (");
         for (int i = 0; i < bestMatches.size(); i++) {
             MatchScore matchScore = bestMatches.get(i);
             if (i != 0) {
                 selection.append(",");
             }
-            selection.append(matchScore.getAggregateId());
+            selection.append(matchScore.getContactId());
         }
         selection.append(")");
 
         final SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
-        qb.setTables(Tables.AGGREGATES);
+        qb.setTables(Tables.CONTACTS);
         qb.setProjectionMap(projectionMap);
 
         final Cursor cursor = qb.query(db, projection, selection.toString(), null, null, null,
-                Aggregates._ID);
+                Contacts._ID);
 
-        ArrayList<Long> sortedAggregateIds = new ArrayList<Long>(bestMatches.size());
+        ArrayList<Long> sortedContactIds = new ArrayList<Long>(bestMatches.size());
         for (MatchScore matchScore : bestMatches) {
-            sortedAggregateIds.add(matchScore.getAggregateId());
+            sortedContactIds.add(matchScore.getContactId());
         }
 
-        Collections.sort(sortedAggregateIds);
+        Collections.sort(sortedContactIds);
 
         int[] positionMap = new int[bestMatches.size()];
         for (int i = 0; i < positionMap.length; i++) {
-            long id = bestMatches.get(i).getAggregateId();
-            positionMap[i] = sortedAggregateIds.indexOf(id);
+            long id = bestMatches.get(i).getContactId();
+            positionMap[i] = sortedContactIds.indexOf(id);
         }
 
         return new ReorderingCursorWrapper(cursor, positionMap);
     }
 
     /**
-     * Finds aggregates with data matches and returns a list of {@link MatchScore}'s in the
+     * Finds contacts with data matches and returns a list of {@link MatchScore}'s in the
      * descending order of match score.
      */
-    private List<MatchScore> findMatchingAggregates(final SQLiteDatabase db,
-            long aggregateId, int maxSuggestions) {
+    private List<MatchScore> findMatchingContacts(final SQLiteDatabase db,
+            long contactId, int maxSuggestions) {
 
         MatchCandidateList candidates = new MatchCandidateList();
         ContactMatcher matcher = new ContactMatcher();
 
-        // Don't aggregate an aggregate with itself
-        matcher.keepOut(aggregateId);
+        // Don't aggregate a contact with itself
+        matcher.keepOut(contactId);
 
         final Cursor c = db.query(Tables.RAW_CONTACTS, CONTACT_ID_COLUMN,
-                RawContacts.AGGREGATE_ID + "=" + aggregateId, null, null, null, null);
+                RawContacts.CONTACT_ID + "=" + contactId, null, null, null, null);
         try {
             while (c.moveToNext()) {
                 long rawContactId = c.getLong(0);
@@ -1199,12 +1197,12 @@
      * Various database projections used internally.
      */
     private interface Projections {
-        static final String[] PROJ_AGGREGATE_PRIMARIES = new String[] {
-                AggregatesColumns.OPTIMAL_PRIMARY_PHONE_ID,
-                AggregatesColumns.FALLBACK_PRIMARY_PHONE_ID,
-                AggregatesColumns.OPTIMAL_PRIMARY_EMAIL_ID,
-                AggregatesColumns.FALLBACK_PRIMARY_EMAIL_ID,
-                AggregatesColumns.SINGLE_IS_RESTRICTED,
+        static final String[] PROJ_CONTACT_PRIMARIES = new String[] {
+                ContactsColumns.OPTIMAL_PRIMARY_PHONE_ID,
+                ContactsColumns.FALLBACK_PRIMARY_PHONE_ID,
+                ContactsColumns.OPTIMAL_PRIMARY_EMAIL_ID,
+                ContactsColumns.FALLBACK_PRIMARY_EMAIL_ID,
+                ContactsColumns.SINGLE_IS_RESTRICTED,
         };
 
         static final int COL_OPTIMAL_PRIMARY_PHONE_ID = 0;
diff --git a/src/com/android/providers/contacts/ContactMatcher.java b/src/com/android/providers/contacts/ContactMatcher.java
index d4b3349..6ab98dd 100644
--- a/src/com/android/providers/contacts/ContactMatcher.java
+++ b/src/com/android/providers/contacts/ContactMatcher.java
@@ -208,23 +208,23 @@
     }
 
     /**
-     * Captures the max score and match count for a specific aggregate.  Used in an
-     * aggregateId - MatchScore map.
+     * Captures the max score and match count for a specific contact.  Used in an
+     * contactId - MatchScore map.
      */
     public static class MatchScore implements Comparable<MatchScore> {
-        private long mAggregateId;
+        private long mContactId;
         private boolean mKeepIn;
         private boolean mKeepOut;
         private int mPrimaryScore;
         private int mSecondaryScore;
         private int mMatchCount;
 
-        public MatchScore(long aggregateId) {
-            this.mAggregateId = aggregateId;
+        public MatchScore(long contactId) {
+            this.mContactId = contactId;
         }
 
-        public void reset(long aggregateId) {
-            this.mAggregateId = aggregateId;
+        public void reset(long contactId) {
+            this.mContactId = contactId;
             mKeepIn = false;
             mKeepOut = false;
             mPrimaryScore = 0;
@@ -232,8 +232,8 @@
             mMatchCount = 0;
         }
 
-        public long getAggregateId() {
-            return mAggregateId;
+        public long getContactId() {
+            return mContactId;
         }
 
         public void updatePrimaryScore(int score) {
@@ -269,7 +269,7 @@
 
             int score = (mPrimaryScore > mSecondaryScore ? mPrimaryScore : mSecondaryScore);
 
-            // Ensure that of two aggregates with the same match score the one with more matching
+            // Ensure that of two contacts with the same match score the one with more matching
             // data elements wins.
             return score * SCORE_SCALE + mMatchCount;
         }
@@ -283,7 +283,7 @@
 
         @Override
         public String toString() {
-            return mAggregateId + ": " + mPrimaryScore + "/" + mSecondaryScore + "(" + mMatchCount
+            return mContactId + ": " + mPrimaryScore + "/" + mSecondaryScore + "(" + mMatchCount
                     + ")";
         }
     }
@@ -295,30 +295,30 @@
     private final JaroWinklerDistance mJaroWinklerDistance =
             new JaroWinklerDistance(MAX_MATCHED_NAME_LENGTH);
 
-    private MatchScore getMatchingScore(long aggregateId) {
-        MatchScore matchingScore = mScores.get(aggregateId);
+    private MatchScore getMatchingScore(long contactId) {
+        MatchScore matchingScore = mScores.get(contactId);
         if (matchingScore == null) {
             if (mScoreList.size() > mScoreCount) {
                 matchingScore = mScoreList.get(mScoreCount);
-                matchingScore.reset(aggregateId);
+                matchingScore.reset(contactId);
             } else {
-                matchingScore = new MatchScore(aggregateId);
+                matchingScore = new MatchScore(contactId);
                 mScoreList.add(matchingScore);
             }
             mScoreCount++;
-            mScores.put(aggregateId, matchingScore);
+            mScores.put(contactId, matchingScore);
         }
         return matchingScore;
     }
 
     /**
      * Checks if there is a match and updates the overall score for the
-     * specified aggregate for a discovered match. The new score is determined
+     * specified contact for a discovered match. The new score is determined
      * by the prior score, by the type of name we were looking for, the type
      * of name we found and, if the match is approximate, the distance between the candidate and
      * actual name.
      */
-    public void matchName(long aggregateId, int candidateNameType, String candidateName,
+    public void matchName(long contactId, int candidateNameType, String candidateName,
             int nameType, String name, boolean approximate) {
         int maxScore = getMaxScore(candidateNameType, nameType);
         if (maxScore == 0) {
@@ -326,7 +326,7 @@
         }
 
         if (candidateName.equals(name)) {
-            updatePrimaryScore(aggregateId, maxScore);
+            updatePrimaryScore(contactId, maxScore);
             return;
         }
 
@@ -351,35 +351,35 @@
             score = 0;
         }
 
-        updatePrimaryScore(aggregateId, score);
+        updatePrimaryScore(contactId, score);
     }
 
-    public void updateScoreWithPhoneNumberMatch(long aggregateId) {
-        updateSecondaryScore(aggregateId, PHONE_MATCH_SCORE);
+    public void updateScoreWithPhoneNumberMatch(long contactId) {
+        updateSecondaryScore(contactId, PHONE_MATCH_SCORE);
     }
 
-    public void updateScoreWithEmailMatch(long aggregateId) {
-        updateSecondaryScore(aggregateId, EMAIL_MATCH_SCORE);
+    public void updateScoreWithEmailMatch(long contactId) {
+        updateSecondaryScore(contactId, EMAIL_MATCH_SCORE);
     }
 
-    public void updateScoreWithNicknameMatch(long aggregateId) {
-        updateSecondaryScore(aggregateId, NICKNAME_MATCH_SCORE);
+    public void updateScoreWithNicknameMatch(long contactId) {
+        updateSecondaryScore(contactId, NICKNAME_MATCH_SCORE);
     }
 
-    private void updatePrimaryScore(long aggregateId, int score) {
-        getMatchingScore(aggregateId).updatePrimaryScore(score);
+    private void updatePrimaryScore(long contactId, int score) {
+        getMatchingScore(contactId).updatePrimaryScore(score);
     }
 
-    private void updateSecondaryScore(long aggregateId, int score) {
-        getMatchingScore(aggregateId).updateSecondaryScore(score);
+    private void updateSecondaryScore(long contactId, int score) {
+        getMatchingScore(contactId).updateSecondaryScore(score);
     }
 
-    public void keepIn(long aggregateId) {
-        getMatchingScore(aggregateId).keepIn();
+    public void keepIn(long contactId) {
+        getMatchingScore(contactId).keepIn();
     }
 
-    public void keepOut(long aggregateId) {
-        getMatchingScore(aggregateId).keepOut();
+    public void keepOut(long contactId) {
+        getMatchingScore(contactId).keepOut();
     }
 
     public void clear() {
@@ -388,14 +388,14 @@
     }
 
     /**
-     * Returns a list of IDs for aggregates that are matched on secondary data elements
+     * Returns a list of IDs for contacts that are matched on secondary data elements
      * (phone number, email address, nickname). We still need to obtain the approximate
-     * primary score for those aggregates to determine if any of them should be aggregated.
+     * primary score for those contacts to determine if any of them should be contactd.
      * <p>
      * May return null.
      */
     public List<Long> prepareSecondaryMatchCandidates(int threshold) {
-        ArrayList<Long> aggregateIds = null;
+        ArrayList<Long> contactIds = null;
 
         for (int i = 0; i < mScoreCount; i++) {
             MatchScore score = mScoreList.get(i);
@@ -405,27 +405,27 @@
 
             int s = score.mSecondaryScore;
             if (s >= threshold) {
-                if (aggregateIds == null) {
-                    aggregateIds = new ArrayList<Long>();
+                if (contactIds == null) {
+                    contactIds = new ArrayList<Long>();
                 }
-                aggregateIds.add(score.mAggregateId);
+                contactIds.add(score.mContactId);
                 score.mPrimaryScore = NO_DATA_SCORE;
             }
         }
-        return aggregateIds;
+        return contactIds;
     }
 
     /**
-     * Returns the aggregateId with the best match score over the specified threshold or -1
-     * if no such aggregate is found.
+     * Returns the contactId with the best match score over the specified threshold or -1
+     * if no such contact is found.
      */
     public long pickBestMatch(int threshold) {
-        long aggregateId = -1;
+        long contactId = -1;
         int maxScore = 0;
         for (int i = 0; i < mScoreCount; i++) {
             MatchScore score = mScoreList.get(i);
             if (score.mKeepIn) {
-                return score.mAggregateId;
+                return score.mContactId;
             }
 
             if (score.mKeepOut) {
@@ -438,11 +438,11 @@
             }
 
             if (s >= threshold && s > maxScore) {
-                aggregateId = score.mAggregateId;
+                contactId = score.mContactId;
                 maxScore = s;
             }
         }
-        return aggregateId;
+        return contactId;
     }
 
     /**
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index bfc065e..7c4dfd4 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -17,16 +17,16 @@
 package com.android.providers.contacts;
 
 import com.android.internal.content.SyncStateContentProviderHelper;
-import com.android.providers.contacts.OpenHelper.AggregatesColumns;
 import com.android.providers.contacts.OpenHelper.AggregationExceptionColumns;
 import com.android.providers.contacts.OpenHelper.Clauses;
-import com.android.providers.contacts.OpenHelper.RawContactsColumns;
+import com.android.providers.contacts.OpenHelper.ContactsColumns;
 import com.android.providers.contacts.OpenHelper.DataColumns;
 import com.android.providers.contacts.OpenHelper.GroupsColumns;
 import com.android.providers.contacts.OpenHelper.MimetypesColumns;
-import com.android.providers.contacts.OpenHelper.PhoneColumns;
 import com.android.providers.contacts.OpenHelper.PackagesColumns;
+import com.android.providers.contacts.OpenHelper.PhoneColumns;
 import com.android.providers.contacts.OpenHelper.PhoneLookupColumns;
+import com.android.providers.contacts.OpenHelper.RawContactsColumns;
 import com.android.providers.contacts.OpenHelper.Tables;
 import com.google.android.collect.Lists;
 
@@ -54,14 +54,13 @@
 import android.provider.BaseColumns;
 import android.provider.ContactsContract;
 import android.provider.Contacts.ContactMethods;
-import android.provider.ContactsContract.Aggregates;
 import android.provider.ContactsContract.AggregationExceptions;
 import android.provider.ContactsContract.CommonDataKinds;
-import android.provider.ContactsContract.RawContacts;
+import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.Data;
 import android.provider.ContactsContract.Groups;
 import android.provider.ContactsContract.Presence;
-import android.provider.ContactsContract.Aggregates.AggregationSuggestions;
+import android.provider.ContactsContract.RawContacts;
 import android.provider.ContactsContract.CommonDataKinds.BaseTypes;
 import android.provider.ContactsContract.CommonDataKinds.Email;
 import android.provider.ContactsContract.CommonDataKinds.GroupMembership;
@@ -71,9 +70,9 @@
 import android.provider.ContactsContract.CommonDataKinds.Phone;
 import android.provider.ContactsContract.CommonDataKinds.StructuredName;
 import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
+import android.provider.ContactsContract.Contacts.AggregationSuggestions;
 import android.telephony.PhoneNumberUtils;
 import android.text.TextUtils;
-import android.util.Log;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -94,22 +93,22 @@
 
     private static final UriMatcher sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
 
-    private static final String STREQUENT_ORDER_BY = Aggregates.STARRED + " DESC, "
-            + Aggregates.TIMES_CONTACTED + " DESC, "
-            + Aggregates.DISPLAY_NAME + " ASC";
+    private static final String STREQUENT_ORDER_BY = Contacts.STARRED + " DESC, "
+            + Contacts.TIMES_CONTACTED + " DESC, "
+            + Contacts.DISPLAY_NAME + " ASC";
     private static final String STREQUENT_LIMIT =
-            "(SELECT COUNT(1) FROM " + Tables.AGGREGATES + " WHERE "
-            + Aggregates.STARRED + "=1) + 25";
+            "(SELECT COUNT(1) FROM " + Tables.CONTACTS + " WHERE "
+            + Contacts.STARRED + "=1) + 25";
 
-    private static final int AGGREGATES = 1000;
-    private static final int AGGREGATES_ID = 1001;
-    private static final int AGGREGATES_DATA = 1002;
-    private static final int AGGREGATES_SUMMARY = 1003;
-    private static final int AGGREGATES_SUMMARY_ID = 1004;
-    private static final int AGGREGATES_SUMMARY_FILTER = 1005;
-    private static final int AGGREGATES_SUMMARY_STREQUENT = 1006;
-    private static final int AGGREGATES_SUMMARY_STREQUENT_FILTER = 1007;
-    private static final int AGGREGATES_SUMMARY_GROUP = 1008;
+    private static final int CONTACTS = 1000;
+    private static final int CONTACTS_ID = 1001;
+    private static final int CONTACTS_DATA = 1002;
+    private static final int CONTACTS_SUMMARY = 1003;
+    private static final int CONTACTS_SUMMARY_ID = 1004;
+    private static final int CONTACTS_SUMMARY_FILTER = 1005;
+    private static final int CONTACTS_SUMMARY_STREQUENT = 1006;
+    private static final int CONTACTS_SUMMARY_STREQUENT_FILTER = 1007;
+    private static final int CONTACTS_SUMMARY_GROUP = 1008;
 
     private static final int RAW_CONTACTS = 2002;
     private static final int RAW_CONTACTS_ID = 2003;
@@ -152,43 +151,43 @@
         public static final int ACCOUNT_TYPE = 2;
     }
 
-    private interface DataContactsQuery {
+    private interface DataRawContactsQuery {
         public static final String TABLE = Tables.DATA_JOIN_MIMETYPE_RAW_CONTACTS;
 
         public static final String[] PROJECTION = new String[] {
             RawContactsColumns.CONCRETE_ID,
             DataColumns.CONCRETE_ID,
-            RawContacts.AGGREGATE_ID,
+            RawContacts.CONTACT_ID,
             RawContacts.IS_RESTRICTED,
             Data.MIMETYPE,
         };
 
         public static final int RAW_CONTACT_ID = 0;
         public static final int DATA_ID = 1;
-        public static final int AGGREGATE_ID = 2;
+        public static final int CONTACT_ID = 2;
         public static final int IS_RESTRICTED = 3;
         public static final int MIMETYPE = 4;
     }
 
-    private interface DataAggregatesQuery {
-        public static final String TABLE = Tables.DATA_JOIN_MIMETYPES_RAW_CONTACTS_AGGREGATES;
+    private interface DataContactsQuery {
+        public static final String TABLE = Tables.DATA_JOIN_MIMETYPES_RAW_CONTACTS_CONTACTS;
 
         public static final String[] PROJECTION = new String[] {
             RawContactsColumns.CONCRETE_ID,
             DataColumns.CONCRETE_ID,
-            AggregatesColumns.CONCRETE_ID,
+            ContactsColumns.CONCRETE_ID,
             MimetypesColumns.CONCRETE_ID,
             Phone.NUMBER,
             Email.DATA,
-            AggregatesColumns.OPTIMAL_PRIMARY_PHONE_ID,
-            AggregatesColumns.FALLBACK_PRIMARY_PHONE_ID,
-            AggregatesColumns.OPTIMAL_PRIMARY_EMAIL_ID,
-            AggregatesColumns.FALLBACK_PRIMARY_EMAIL_ID,
+            ContactsColumns.OPTIMAL_PRIMARY_PHONE_ID,
+            ContactsColumns.FALLBACK_PRIMARY_PHONE_ID,
+            ContactsColumns.OPTIMAL_PRIMARY_EMAIL_ID,
+            ContactsColumns.FALLBACK_PRIMARY_EMAIL_ID,
         };
 
-        public static final int CONTACT_ID = 0;
+        public static final int RAW_CONTACT_ID = 0;
         public static final int DATA_ID = 1;
-        public static final int AGGREGATE_ID = 2;
+        public static final int CONTACT_ID = 2;
         public static final int MIMETYPE_ID = 3;
         public static final int PHONE_NUMBER = 4;
         public static final int EMAIL_DATA = 5;
@@ -287,15 +286,15 @@
     }
 
     /** Contains just the contacts columns */
-    private static final HashMap<String, String> sAggregatesProjectionMap;
-    /** Contains the aggregate columns along with primary phone */
-    private static final HashMap<String, String> sAggregatesSummaryProjectionMap;
-    /** Contains the data, contacts, and aggregate columns, for joined tables. */
-    private static final HashMap<String, String> sDataContactsAggregateProjectionMap;
-    /** Contains the data, contacts, group sourceid and aggregate columns, for joined tables. */
-    private static final HashMap<String, String> sDataContactsGroupsAggregateProjectionMap;
-    /** Contains just the contacts columns */
     private static final HashMap<String, String> sContactsProjectionMap;
+    /** Contains the contact columns along with primary phone */
+    private static final HashMap<String, String> sContactsSummaryProjectionMap;
+    /** Contains the data, contacts, and contact columns, for joined tables. */
+    private static final HashMap<String, String> sDataContactsContactProjectionMap;
+    /** Contains the data, contacts, group sourceid and contact columns, for joined tables. */
+    private static final HashMap<String, String> sDataContactsGroupsContactProjectionMap;
+    /** Contains just the contacts columns */
+    private static final HashMap<String, String> sRawContactsProjectionMap;
     /** Contains just the data columns */
     private static final HashMap<String, String> sDataGroupsProjectionMap;
     /** Contains the data and contacts columns, for joined tables */
@@ -312,12 +311,12 @@
     private static final HashMap<String, String> sPresenceProjectionMap;
 
     /** Sql select statement that returns the contact id associated with a data record. */
-    private static final String sNestedContactIdSelect;
+    private static final String sNestedRawContactIdSelect;
     /** Sql select statement that returns the mimetype id associated with a data record. */
     private static final String sNestedMimetypeSelect;
-    /** Sql select statement that returns the aggregate id associated with a contact record. */
-    private static final String sNestedAggregateIdSelect;
-    /** Sql select statement that returns a list of contact ids associated with an aggregate record. */
+    /** Sql select statement that returns the contact id associated with a contact record. */
+    private static final String sNestedContactIdSelect;
+    /** Sql select statement that returns a list of contact ids associated with an contact record. */
     private static final String sNestedContactIdListSelect;
     /** Sql where statement used to match all the data records that need to be updated when a new
      * "primary" is selected.*/
@@ -326,12 +325,12 @@
      * "super primary" is selected.*/
     private static final String sSetSuperPrimaryWhere;
     /** Sql where statement for filtering on groups. */
-    private static final String sAggregatesInGroupSelect;
+    private static final String sContactsInGroupSelect;
     /** Precompiled sql statement for setting a data record to the primary. */
     private SQLiteStatement mSetPrimaryStatement;
     /** Precompiled sql statement for setting a data record to the super primary. */
     private SQLiteStatement mSetSuperPrimaryStatement;
-    /** Precompiled sql statement for incrementing times contacted for an aggregate */
+    /** Precompiled sql statement for incrementing times contacted for an contact */
     private SQLiteStatement mLastTimeContactedUpdate;
     /** Precompiled sql statement for updating a contact display name */
     private SQLiteStatement mContactDisplayNameUpdate;
@@ -342,20 +341,20 @@
     static {
         // Contacts URI matching table
         final UriMatcher matcher = sUriMatcher;
-        matcher.addURI(ContactsContract.AUTHORITY, "aggregates", AGGREGATES);
-        matcher.addURI(ContactsContract.AUTHORITY, "aggregates/#", AGGREGATES_ID);
-        matcher.addURI(ContactsContract.AUTHORITY, "aggregates/#/data", AGGREGATES_DATA);
-        matcher.addURI(ContactsContract.AUTHORITY, "aggregates_summary", AGGREGATES_SUMMARY);
-        matcher.addURI(ContactsContract.AUTHORITY, "aggregates_summary/#", AGGREGATES_SUMMARY_ID);
-        matcher.addURI(ContactsContract.AUTHORITY, "aggregates_summary/filter/*",
-                AGGREGATES_SUMMARY_FILTER);
-        matcher.addURI(ContactsContract.AUTHORITY, "aggregates_summary/strequent/",
-                AGGREGATES_SUMMARY_STREQUENT);
-        matcher.addURI(ContactsContract.AUTHORITY, "aggregates_summary/strequent/filter/*",
-                AGGREGATES_SUMMARY_STREQUENT_FILTER);
-        matcher.addURI(ContactsContract.AUTHORITY, "aggregates_summary/group/*",
-                AGGREGATES_SUMMARY_GROUP);
-        matcher.addURI(ContactsContract.AUTHORITY, "aggregates/#/suggestions",
+        matcher.addURI(ContactsContract.AUTHORITY, "contacts", CONTACTS);
+        matcher.addURI(ContactsContract.AUTHORITY, "contacts/#", CONTACTS_ID);
+        matcher.addURI(ContactsContract.AUTHORITY, "contacts/#/data", CONTACTS_DATA);
+        matcher.addURI(ContactsContract.AUTHORITY, "contacts_summary", CONTACTS_SUMMARY);
+        matcher.addURI(ContactsContract.AUTHORITY, "contacts_summary/#", CONTACTS_SUMMARY_ID);
+        matcher.addURI(ContactsContract.AUTHORITY, "contacts_summary/filter/*",
+                CONTACTS_SUMMARY_FILTER);
+        matcher.addURI(ContactsContract.AUTHORITY, "contacts_summary/strequent/",
+                CONTACTS_SUMMARY_STREQUENT);
+        matcher.addURI(ContactsContract.AUTHORITY, "contacts_summary/strequent/filter/*",
+                CONTACTS_SUMMARY_STREQUENT_FILTER);
+        matcher.addURI(ContactsContract.AUTHORITY, "contacts_summary/group/*",
+                CONTACTS_SUMMARY_GROUP);
+        matcher.addURI(ContactsContract.AUTHORITY, "contacts/#/suggestions",
                 AGGREGATION_SUGGESTIONS);
         matcher.addURI(ContactsContract.AUTHORITY, "raw_contacts", RAW_CONTACTS);
         matcher.addURI(ContactsContract.AUTHORITY, "raw_contacts/#", RAW_CONTACTS_ID);
@@ -386,46 +385,46 @@
 
         HashMap<String, String> columns;
 
-        // Aggregates projection map
+        // Contacts projection map
         columns = new HashMap<String, String>();
-        columns.put(Aggregates._ID, "aggregates._id AS _id");
-        columns.put(Aggregates.DISPLAY_NAME, AggregatesColumns.CONCRETE_DISPLAY_NAME + " AS "
-                + Aggregates.DISPLAY_NAME);
-        columns.put(Aggregates.LAST_TIME_CONTACTED, AggregatesColumns.CONCRETE_LAST_TIME_CONTACTED
-                + " AS " + Aggregates.LAST_TIME_CONTACTED);
-        columns.put(Aggregates.TIMES_CONTACTED, AggregatesColumns.CONCRETE_TIMES_CONTACTED + " AS "
-                + Aggregates.TIMES_CONTACTED);
-        columns.put(Aggregates.STARRED, AggregatesColumns.CONCRETE_STARRED + " AS "
-                + Aggregates.STARRED);
-        columns.put(Aggregates.IN_VISIBLE_GROUP, Aggregates.IN_VISIBLE_GROUP);
-        columns.put(Aggregates.PHOTO_ID, Aggregates.PHOTO_ID);
-        columns.put(Aggregates.PRIMARY_PHONE_ID, Aggregates.PRIMARY_PHONE_ID);
-        columns.put(Aggregates.PRIMARY_EMAIL_ID, Aggregates.PRIMARY_EMAIL_ID);
-        columns.put(Aggregates.CUSTOM_RINGTONE, AggregatesColumns.CONCRETE_CUSTOM_RINGTONE + " AS "
-                + Aggregates.CUSTOM_RINGTONE);
-        columns.put(Aggregates.SEND_TO_VOICEMAIL, AggregatesColumns.CONCRETE_SEND_TO_VOICEMAIL
-                + " AS " + Aggregates.SEND_TO_VOICEMAIL);
-        columns.put(AggregatesColumns.FALLBACK_PRIMARY_PHONE_ID,
-                AggregatesColumns.FALLBACK_PRIMARY_PHONE_ID);
-        columns.put(AggregatesColumns.FALLBACK_PRIMARY_EMAIL_ID,
-                AggregatesColumns.FALLBACK_PRIMARY_EMAIL_ID);
-        sAggregatesProjectionMap = columns;
+        columns.put(Contacts._ID, "contacts._id AS _id");
+        columns.put(Contacts.DISPLAY_NAME, ContactsColumns.CONCRETE_DISPLAY_NAME + " AS "
+                + Contacts.DISPLAY_NAME);
+        columns.put(Contacts.LAST_TIME_CONTACTED, ContactsColumns.CONCRETE_LAST_TIME_CONTACTED
+                + " AS " + Contacts.LAST_TIME_CONTACTED);
+        columns.put(Contacts.TIMES_CONTACTED, ContactsColumns.CONCRETE_TIMES_CONTACTED + " AS "
+                + Contacts.TIMES_CONTACTED);
+        columns.put(Contacts.STARRED, ContactsColumns.CONCRETE_STARRED + " AS "
+                + Contacts.STARRED);
+        columns.put(Contacts.IN_VISIBLE_GROUP, Contacts.IN_VISIBLE_GROUP);
+        columns.put(Contacts.PHOTO_ID, Contacts.PHOTO_ID);
+        columns.put(Contacts.PRIMARY_PHONE_ID, Contacts.PRIMARY_PHONE_ID);
+        columns.put(Contacts.PRIMARY_EMAIL_ID, Contacts.PRIMARY_EMAIL_ID);
+        columns.put(Contacts.CUSTOM_RINGTONE, ContactsColumns.CONCRETE_CUSTOM_RINGTONE + " AS "
+                + Contacts.CUSTOM_RINGTONE);
+        columns.put(Contacts.SEND_TO_VOICEMAIL, ContactsColumns.CONCRETE_SEND_TO_VOICEMAIL
+                + " AS " + Contacts.SEND_TO_VOICEMAIL);
+        columns.put(ContactsColumns.FALLBACK_PRIMARY_PHONE_ID,
+                ContactsColumns.FALLBACK_PRIMARY_PHONE_ID);
+        columns.put(ContactsColumns.FALLBACK_PRIMARY_EMAIL_ID,
+                ContactsColumns.FALLBACK_PRIMARY_EMAIL_ID);
+        sContactsProjectionMap = columns;
 
         columns = new HashMap<String, String>();
-        columns.putAll(sAggregatesProjectionMap);
+        columns.putAll(sContactsProjectionMap);
 
-        // Aggregates primaries projection map. The overall presence status is
+        // Contacts primaries projection map. The overall presence status is
         // the most-present value, as indicated by the largest value.
-        columns.put(Aggregates.PRESENCE_STATUS, "MAX(" + Presence.PRESENCE_STATUS + ")");
-        columns.put(Aggregates.PRIMARY_PHONE_TYPE, CommonDataKinds.Phone.TYPE);
-        columns.put(Aggregates.PRIMARY_PHONE_LABEL, CommonDataKinds.Phone.LABEL);
-        columns.put(Aggregates.PRIMARY_PHONE_NUMBER, CommonDataKinds.Phone.NUMBER);
-        sAggregatesSummaryProjectionMap = columns;
+        columns.put(Contacts.PRESENCE_STATUS, "MAX(" + Presence.PRESENCE_STATUS + ")");
+        columns.put(Contacts.PRIMARY_PHONE_TYPE, CommonDataKinds.Phone.TYPE);
+        columns.put(Contacts.PRIMARY_PHONE_LABEL, CommonDataKinds.Phone.LABEL);
+        columns.put(Contacts.PRIMARY_PHONE_NUMBER, CommonDataKinds.Phone.NUMBER);
+        sContactsSummaryProjectionMap = columns;
 
         // RawContacts projection map
         columns = new HashMap<String, String>();
         columns.put(RawContacts._ID, Tables.RAW_CONTACTS + "." + RawContacts._ID + " AS _id");
-        columns.put(RawContacts.AGGREGATE_ID, RawContacts.AGGREGATE_ID);
+        columns.put(RawContacts.CONTACT_ID, RawContacts.CONTACT_ID);
         columns.put(RawContacts.ACCOUNT_NAME,
                 OpenHelper.RawContactsColumns.CONCRETE_ACCOUNT_NAME
                         + " AS " + RawContacts.ACCOUNT_NAME);
@@ -444,7 +443,7 @@
         columns.put(RawContacts.DELETED,
                 OpenHelper.RawContactsColumns.CONCRETE_DELETED
                         + " AS " + RawContacts.DELETED);
-        sContactsProjectionMap = columns;
+        sRawContactsProjectionMap = columns;
 
         // Data projection map
         columns = new HashMap<String, String>();
@@ -480,9 +479,9 @@
 
         // Data, groups and contacts projection map for joins. _id comes from the data table
         columns = new HashMap<String, String>();
-        columns.putAll(sContactsProjectionMap);
+        columns.putAll(sRawContactsProjectionMap);
         columns.putAll(sDataGroupsProjectionMap); // _id will be replaced with the one from data
-        columns.put(Data.RAW_CONTACT_ID, DataColumns.CONCRETE_CONTACT_ID);
+        columns.put(Data.RAW_CONTACT_ID, DataColumns.CONCRETE_RAW_CONTACT_ID);
         sDataContactsGroupsProjectionMap = columns;
 
         // Data and contacts projection map for joins. _id comes from the data table
@@ -493,17 +492,17 @@
 
         // Data and contacts projection map for joins. _id comes from the data table
         columns = new HashMap<String, String>();
-        columns.putAll(sAggregatesProjectionMap);
-        columns.putAll(sContactsProjectionMap); //
+        columns.putAll(sContactsProjectionMap);
+        columns.putAll(sRawContactsProjectionMap); //
         columns.putAll(sDataGroupsProjectionMap); // _id will be replaced with the one from data
-        columns.put(Data.RAW_CONTACT_ID, DataColumns.CONCRETE_CONTACT_ID);
-        sDataContactsGroupsAggregateProjectionMap = columns;
+        columns.put(Data.RAW_CONTACT_ID, DataColumns.CONCRETE_RAW_CONTACT_ID);
+        sDataContactsGroupsContactProjectionMap = columns;
 
         // Data and contacts projection map for joins. _id comes from the data table
         columns = new HashMap<String, String>();
-        columns.putAll(sDataContactsGroupsAggregateProjectionMap);
+        columns.putAll(sDataContactsGroupsContactProjectionMap);
         columns.remove(GroupMembership.GROUP_SOURCE_ID);
-        sDataContactsAggregateProjectionMap = columns;
+        sDataContactsContactProjectionMap = columns;
 
         // Groups projection map
         columns = new HashMap<String, String>();
@@ -523,14 +522,14 @@
         columns = new HashMap<String, String>();
         columns.putAll(sGroupsProjectionMap);
 
-        columns.put(Groups.SUMMARY_COUNT, "(SELECT COUNT(DISTINCT " + AggregatesColumns.CONCRETE_ID
-                + ") FROM " + Tables.DATA_JOIN_MIMETYPES_RAW_CONTACTS_AGGREGATES + " WHERE "
+        columns.put(Groups.SUMMARY_COUNT, "(SELECT COUNT(DISTINCT " + ContactsColumns.CONCRETE_ID
+                + ") FROM " + Tables.DATA_JOIN_MIMETYPES_RAW_CONTACTS_CONTACTS + " WHERE "
                 + Clauses.MIMETYPE_IS_GROUP_MEMBERSHIP + " AND " + Clauses.BELONGS_TO_GROUP
                 + ") AS " + Groups.SUMMARY_COUNT);
 
         columns.put(Groups.SUMMARY_WITH_PHONES, "(SELECT COUNT(DISTINCT "
-                + AggregatesColumns.CONCRETE_ID + ") FROM "
-                + Tables.DATA_JOIN_MIMETYPES_RAW_CONTACTS_AGGREGATES + " WHERE "
+                + ContactsColumns.CONCRETE_ID + ") FROM "
+                + Tables.DATA_JOIN_MIMETYPES_RAW_CONTACTS_CONTACTS + " WHERE "
                 + Clauses.MIMETYPE_IS_GROUP_MEMBERSHIP + " AND " + Clauses.BELONGS_TO_GROUP
                 + " AND " + Clauses.HAS_PRIMARY_PHONE + ") AS " + Groups.SUMMARY_WITH_PHONES);
 
@@ -540,9 +539,9 @@
         columns = new HashMap<String, String>();
         columns.put(AggregationExceptionColumns._ID, Tables.AGGREGATION_EXCEPTIONS + "._id AS _id");
         columns.put(AggregationExceptions.TYPE, AggregationExceptions.TYPE);
-        columns.put(AggregationExceptions.AGGREGATE_ID,
-                "raw_contacts1." + RawContacts.AGGREGATE_ID
-                + " AS " + AggregationExceptions.AGGREGATE_ID);
+        columns.put(AggregationExceptions.CONTACT_ID,
+                "raw_contacts1." + RawContacts.CONTACT_ID
+                + " AS " + AggregationExceptions.CONTACT_ID);
         columns.put(AggregationExceptions.RAW_CONTACT_ID, AggregationExceptionColumns.RAW_CONTACT_ID2);
         sAggregationExceptionsProjectionMap = columns;
 
@@ -558,20 +557,20 @@
         columns.put(Presence.PRESENCE_CUSTOM_STATUS, Presence.PRESENCE_CUSTOM_STATUS);
         sPresenceProjectionMap = columns;
 
-        sNestedContactIdSelect = "SELECT " + Data.RAW_CONTACT_ID + " FROM " + Tables.DATA + " WHERE "
+        sNestedRawContactIdSelect = "SELECT " + Data.RAW_CONTACT_ID + " FROM " + Tables.DATA + " WHERE "
                 + Data._ID + "=?";
         sNestedMimetypeSelect = "SELECT " + DataColumns.MIMETYPE_ID + " FROM " + Tables.DATA
                 + " WHERE " + Data._ID + "=?";
-        sNestedAggregateIdSelect = "SELECT " + RawContacts.AGGREGATE_ID + " FROM " + Tables.RAW_CONTACTS
-                + " WHERE " + RawContacts._ID + "=(" + sNestedContactIdSelect + ")";
+        sNestedContactIdSelect = "SELECT " + RawContacts.CONTACT_ID + " FROM " + Tables.RAW_CONTACTS
+                + " WHERE " + RawContacts._ID + "=(" + sNestedRawContactIdSelect + ")";
         sNestedContactIdListSelect = "SELECT " + RawContacts._ID + " FROM " + Tables.RAW_CONTACTS
-                + " WHERE " + RawContacts.AGGREGATE_ID + "=(" + sNestedAggregateIdSelect + ")";
-        sSetPrimaryWhere = Data.RAW_CONTACT_ID + "=(" + sNestedContactIdSelect + ") AND "
+                + " WHERE " + RawContacts.CONTACT_ID + "=(" + sNestedContactIdSelect + ")";
+        sSetPrimaryWhere = Data.RAW_CONTACT_ID + "=(" + sNestedRawContactIdSelect + ") AND "
                 + DataColumns.MIMETYPE_ID + "=(" + sNestedMimetypeSelect + ")";
         sSetSuperPrimaryWhere = Data.RAW_CONTACT_ID + " IN (" + sNestedContactIdListSelect + ") AND "
                 + DataColumns.MIMETYPE_ID + "=(" + sNestedMimetypeSelect + ")";
-        sAggregatesInGroupSelect = AggregatesColumns.CONCRETE_ID + " IN (SELECT "
-                + RawContacts.AGGREGATE_ID + " FROM " + Tables.RAW_CONTACTS + " WHERE ("
+        sContactsInGroupSelect = ContactsColumns.CONCRETE_ID + " IN (SELECT "
+                + RawContacts.CONTACT_ID + " FROM " + Tables.RAW_CONTACTS + " WHERE ("
                 + RawContactsColumns.CONCRETE_ID + " IN (SELECT " + Tables.DATA + "."
                 + Data.RAW_CONTACT_ID + " FROM " + Tables.DATA_JOIN_MIMETYPES + " WHERE ("
                 + Data.MIMETYPE + "='" + GroupMembership.CONTENT_ITEM_TYPE + "' AND "
@@ -953,7 +952,7 @@
                 + "=(_id=?) WHERE " + sSetSuperPrimaryWhere);
         mLastTimeContactedUpdate = db.compileStatement("UPDATE " + Tables.RAW_CONTACTS + " SET "
                 + RawContacts.TIMES_CONTACTED + "=" + RawContacts.TIMES_CONTACTED + "+1,"
-                + RawContacts.LAST_TIME_CONTACTED + "=? WHERE " + RawContacts.AGGREGATE_ID + "=?");
+                + RawContacts.LAST_TIME_CONTACTED + "=? WHERE " + RawContacts.CONTACT_ID + "=?");
 
         mContactDisplayNameUpdate = db.compileStatement("UPDATE " + Tables.RAW_CONTACTS + " SET "
                 + RawContactsColumns.DISPLAY_NAME + "=? WHERE " + RawContacts._ID + "=?");
@@ -1035,14 +1034,14 @@
                 id = mOpenHelper.getSyncState().insert(mOpenHelper.getWritableDatabase(), values);
                 break;
 
-            case AGGREGATES: {
-                insertAggregate(values);
+            case CONTACTS: {
+                insertContact(values);
                 break;
             }
 
             case RAW_CONTACTS: {
                 final Account account = readAccountFromQueryParams(uri);
-                id = insertContact(values, account);
+                id = insertRawContact(values, account);
                 break;
             }
 
@@ -1107,12 +1106,12 @@
     }
 
     /**
-     * Inserts an item in the aggregates table
+     * Inserts an item in the contacts table
      *
      * @param values the values for the new row
      * @return the row ID of the newly created row
      */
-    private long insertAggregate(ContentValues values) {
+    private long insertContact(ContentValues values) {
         throw new UnsupportedOperationException("Aggregates are created automatically");
     }
 
@@ -1123,7 +1122,7 @@
      * @param account the account this contact should be associated with. may be null.
      * @return the row ID of the newly created row
      */
-    private long insertContact(ContentValues values, Account account) {
+    private long insertRawContact(ContentValues values, Account account) {
         /*
          * The contact record is inserted in the contacts table, but it needs to
          * be processed by the aggregator before it will be returned by the
@@ -1132,12 +1131,12 @@
         final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
 
         ContentValues overriddenValues = new ContentValues(values);
-        overriddenValues.putNull(RawContacts.AGGREGATE_ID);
+        overriddenValues.putNull(RawContacts.CONTACT_ID);
         if (!resolveAccount(overriddenValues, account)) {
             return -1;
         }
 
-        long rawContactId = db.insert(Tables.RAW_CONTACTS, RawContacts.AGGREGATE_ID,
+        long rawContactId = db.insert(Tables.RAW_CONTACTS, RawContacts.CONTACT_ID,
                 overriddenValues);
 
         int aggregationMode = RawContacts.AGGREGATION_MODE_DEFAULT;
@@ -1351,7 +1350,7 @@
     }
 
     /**
-     * Delete the given {@link Data} row, fixing up any {@link Aggregates}
+     * Delete the given {@link Data} row, fixing up any {@link Contacts}
      * primaries that reference it.
      */
     private int deleteData(long dataId) {
@@ -1370,19 +1369,19 @@
 
         Cursor cursor = null;
         try {
-            cursor = db.query(DataAggregatesQuery.TABLE, DataAggregatesQuery.PROJECTION,
+            cursor = db.query(DataContactsQuery.TABLE, DataContactsQuery.PROJECTION,
                     DataColumns.CONCRETE_ID + "=" + dataId, null, null, null, null);
             if (cursor.moveToFirst()) {
-                aggId = cursor.getLong(DataAggregatesQuery.AGGREGATE_ID);
-                mimeId = cursor.getLong(DataAggregatesQuery.MIMETYPE_ID);
+                aggId = cursor.getLong(DataContactsQuery.CONTACT_ID);
+                mimeId = cursor.getLong(DataContactsQuery.MIMETYPE_ID);
                 if (mimeId == mimePhone) {
-                    dataRaw = cursor.getString(DataAggregatesQuery.PHONE_NUMBER);
-                    fixOptimal = (cursor.getLong(DataAggregatesQuery.OPTIMAL_PHONE_ID) == dataId);
-                    fixFallback = (cursor.getLong(DataAggregatesQuery.FALLBACK_PHONE_ID) == dataId);
+                    dataRaw = cursor.getString(DataContactsQuery.PHONE_NUMBER);
+                    fixOptimal = (cursor.getLong(DataContactsQuery.OPTIMAL_PHONE_ID) == dataId);
+                    fixFallback = (cursor.getLong(DataContactsQuery.FALLBACK_PHONE_ID) == dataId);
                 } else if (mimeId == mimeEmail) {
-                    dataRaw = cursor.getString(DataAggregatesQuery.EMAIL_DATA);
-                    fixOptimal = (cursor.getLong(DataAggregatesQuery.OPTIMAL_EMAIL_ID) == dataId);
-                    fixFallback = (cursor.getLong(DataAggregatesQuery.FALLBACK_EMAIL_ID) == dataId);
+                    dataRaw = cursor.getString(DataContactsQuery.EMAIL_DATA);
+                    fixOptimal = (cursor.getLong(DataContactsQuery.OPTIMAL_EMAIL_ID) == dataId);
+                    fixFallback = (cursor.getLong(DataContactsQuery.FALLBACK_EMAIL_ID) == dataId);
                 }
             }
         } finally {
@@ -1425,19 +1424,19 @@
             final int COL_IS_RESTRICTED = 1;
             final int COL_SCORE = 2;
 
-            cursor = db.query(Tables.DATA_JOIN_MIMETYPES_RAW_CONTACTS_AGGREGATES, PROJ_PRIMARY,
-                    AggregatesColumns.CONCRETE_ID + "=" + aggId + " AND " + DataColumns.MIMETYPE_ID
+            cursor = db.query(Tables.DATA_JOIN_MIMETYPES_RAW_CONTACTS_CONTACTS, PROJ_PRIMARY,
+                    ContactsColumns.CONCRETE_ID + "=" + aggId + " AND " + DataColumns.MIMETYPE_ID
                             + "=" + mimeId, null, null, null, SCORE);
 
             if (fixOptimal) {
                 String colId = null;
                 String colIsRestricted = null;
                 if (mimeId == mimePhone) {
-                    colId = AggregatesColumns.OPTIMAL_PRIMARY_PHONE_ID;
-                    colIsRestricted = AggregatesColumns.OPTIMAL_PRIMARY_PHONE_IS_RESTRICTED;
+                    colId = ContactsColumns.OPTIMAL_PRIMARY_PHONE_ID;
+                    colIsRestricted = ContactsColumns.OPTIMAL_PRIMARY_PHONE_IS_RESTRICTED;
                 } else if (mimeId == mimeEmail) {
-                    colId = AggregatesColumns.OPTIMAL_PRIMARY_EMAIL_ID;
-                    colIsRestricted = AggregatesColumns.OPTIMAL_PRIMARY_EMAIL_IS_RESTRICTED;
+                    colId = ContactsColumns.OPTIMAL_PRIMARY_EMAIL_ID;
+                    colIsRestricted = ContactsColumns.OPTIMAL_PRIMARY_EMAIL_IS_RESTRICTED;
                 }
 
                 // Start by replacing with null, since fixOptimal told us that
@@ -1463,9 +1462,9 @@
             if (fixFallback) {
                 String colId = null;
                 if (mimeId == mimePhone) {
-                    colId = AggregatesColumns.FALLBACK_PRIMARY_PHONE_ID;
+                    colId = ContactsColumns.FALLBACK_PRIMARY_PHONE_ID;
                 } else if (mimeId == mimeEmail) {
-                    colId = AggregatesColumns.FALLBACK_PRIMARY_EMAIL_ID;
+                    colId = ContactsColumns.FALLBACK_PRIMARY_EMAIL_ID;
                 }
 
                 // Start by replacing with null, since fixFallback told us that
@@ -1484,9 +1483,9 @@
                 }
             }
 
-            // Push through any aggregate updates we have
+            // Push through any contact updates we have
             if (values.size() > 0) {
-                db.update(Tables.AGGREGATES, values, AggregatesColumns.CONCRETE_ID + "=" + aggId,
+                db.update(Tables.CONTACTS, values, ContactsColumns.CONCRETE_ID + "=" + aggId,
                         null);
             }
         }
@@ -1546,7 +1545,7 @@
         }
 
         if (values.containsKey(Presence.RAW_CONTACT_ID)) {
-            selection.append(" AND " + DataColumns.CONCRETE_CONTACT_ID + "=")
+            selection.append(" AND " + DataColumns.CONCRETE_RAW_CONTACT_ID + "=")
                     .append(values.getAsLong(Presence.RAW_CONTACT_ID));
         }
 
@@ -1588,16 +1587,16 @@
             case SYNCSTATE:
                 return mOpenHelper.getSyncState().delete(db, selection, selectionArgs);
 
-            case AGGREGATES_ID: {
-                long aggregateId = ContentUris.parseId(uri);
+            case CONTACTS_ID: {
+                long contactId = ContentUris.parseId(uri);
 
-                // Remove references to the aggregate first
+                // Remove references to the contact first
                 ContentValues values = new ContentValues();
-                values.putNull(RawContacts.AGGREGATE_ID);
+                values.putNull(RawContacts.CONTACT_ID);
                 db.update(Tables.RAW_CONTACTS, values,
-                        RawContacts.AGGREGATE_ID + "=" + aggregateId, null);
+                        RawContacts.CONTACT_ID + "=" + contactId, null);
 
-                return db.delete(Tables.AGGREGATES, BaseColumns._ID + "=" + aggregateId, null);
+                return db.delete(Tables.CONTACTS, BaseColumns._ID + "=" + contactId, null);
             }
 
             case RAW_CONTACTS_ID: {
@@ -1678,14 +1677,14 @@
             case SYNCSTATE:
                 return mOpenHelper.getSyncState().update(db, values, selection, selectionArgs);
 
-            // TODO(emillar): We will want to disallow editing the aggregates table at some point.
-            case AGGREGATES: {
-                count = db.update(Tables.AGGREGATES, values, selection, selectionArgs);
+            // TODO(emillar): We will want to disallow editing the contacts table at some point.
+            case CONTACTS: {
+                count = db.update(Tables.CONTACTS, values, selection, selectionArgs);
                 break;
             }
 
-            case AGGREGATES_ID: {
-                count = updateAggregateData(db, ContentUris.parseId(uri), values);
+            case CONTACTS_ID: {
+                count = updateContactData(db, ContentUris.parseId(uri), values);
                 break;
             }
 
@@ -1722,7 +1721,7 @@
                         + (selection == null ? "" : " AND " + selection);
                 count = db.update(Tables.GROUPS, values, selectionWithId, selectionArgs);
 
-                // If changing visibility, then update aggregates
+                // If changing visibility, then update contacts
                 if (values.containsKey(Groups.GROUP_VISIBLE)) {
                     mOpenHelper.updateAllVisible();
                 }
@@ -1830,20 +1829,20 @@
         return 0;
     }
 
-    private int updateAggregateData(SQLiteDatabase db, long aggregateId, ContentValues values) {
+    private int updateContactData(SQLiteDatabase db, long contactId, ContentValues values) {
 
         // First update all constituent contacts
         ContentValues optionValues = new ContentValues(5);
         OpenHelper.copyStringValue(optionValues, RawContacts.CUSTOM_RINGTONE,
-                values, Aggregates.CUSTOM_RINGTONE);
+                values, Contacts.CUSTOM_RINGTONE);
         OpenHelper.copyLongValue(optionValues, RawContacts.SEND_TO_VOICEMAIL,
-                values, Aggregates.SEND_TO_VOICEMAIL);
+                values, Contacts.SEND_TO_VOICEMAIL);
         OpenHelper.copyLongValue(optionValues, RawContacts.LAST_TIME_CONTACTED,
-                values, Aggregates.LAST_TIME_CONTACTED);
+                values, Contacts.LAST_TIME_CONTACTED);
         OpenHelper.copyLongValue(optionValues, RawContacts.TIMES_CONTACTED,
-                values, Aggregates.TIMES_CONTACTED);
+                values, Contacts.TIMES_CONTACTED);
         OpenHelper.copyLongValue(optionValues, RawContacts.STARRED,
-                values, Aggregates.STARRED);
+                values, Contacts.STARRED);
 
         // Nothing to update - just return
         if (optionValues.size() == 0) {
@@ -1851,13 +1850,13 @@
         }
 
         db.update(Tables.RAW_CONTACTS, optionValues,
-                RawContacts.AGGREGATE_ID + "=" + aggregateId, null);
-        return db.update(Tables.AGGREGATES, values, Aggregates._ID + "=" + aggregateId, null);
+                RawContacts.CONTACT_ID + "=" + contactId, null);
+        return db.update(Tables.CONTACTS, values, Contacts._ID + "=" + contactId, null);
     }
 
-    public void updateContactTime(long aggregateId, long lastTimeContacted) {
+    public void updateContactTime(long contactId, long lastTimeContacted) {
         mLastTimeContactedUpdate.bindLong(1, lastTimeContacted);
-        mLastTimeContactedUpdate.bindLong(2, aggregateId);
+        mLastTimeContactedUpdate.bindLong(2, contactId);
         mLastTimeContactedUpdate.execute();
     }
 
@@ -1881,13 +1880,13 @@
 
     private int updateAggregationException(SQLiteDatabase db, ContentValues values) {
         int exceptionType = values.getAsInteger(AggregationExceptions.TYPE);
-        long aggregateId = values.getAsInteger(AggregationExceptions.AGGREGATE_ID);
+        long contactId = values.getAsInteger(AggregationExceptions.CONTACT_ID);
         long rawContactId = values.getAsInteger(AggregationExceptions.RAW_CONTACT_ID);
 
-        // First, we build a list of contactID-contactID pairs for the given aggregate and contact.
+        // First, we build a list of contactID-contactID pairs for the given contact and contact.
         ArrayList<RawContactPair> pairs = new ArrayList<RawContactPair>();
-        Cursor c = db.query(ContactsQuery.TABLE, ContactsQuery.PROJECTION, RawContacts.AGGREGATE_ID
-                + "=" + aggregateId, null, null, null, null);
+        Cursor c = db.query(ContactsQuery.TABLE, ContactsQuery.PROJECTION, RawContacts.CONTACT_ID
+                + "=" + contactId, null, null, null, null);
         try {
             while (c.moveToNext()) {
                 long aggregatedContactId = c.getLong(ContactsQuery.RAW_CONTACT_ID);
@@ -1922,7 +1921,7 @@
             mContactAggregator.aggregateContact(db, rawContactId);
             if (exceptionType == AggregationExceptions.TYPE_AUTOMATIC
                     || exceptionType == AggregationExceptions.TYPE_KEEP_OUT) {
-                mContactAggregator.updateAggregateData(aggregateId);
+                mContactAggregator.updateAggregateData(contactId);
             }
         }
 
@@ -1969,7 +1968,7 @@
         SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
         String groupBy = null;
         String limit = null;
-        String aggregateIdColName = Tables.AGGREGATES + "." + Aggregates._ID;
+        String contactIdColName = Tables.CONTACTS + "." + Contacts._ID;
 
         // TODO: Consider writing a test case for RestrictionExceptions when you
         // write a new query() block to make sure it protects restricted data.
@@ -1979,90 +1978,90 @@
                 return mOpenHelper.getSyncState().query(db, projection, selection,  selectionArgs,
                         sortOrder);
 
-            case AGGREGATES: {
-                qb.setTables(Tables.AGGREGATES);
+            case CONTACTS: {
+                qb.setTables(Tables.CONTACTS);
                 applyAggregateRestrictionExceptions(qb);
-                applyAggregatePrimaryRestrictionExceptions(sAggregatesProjectionMap);
-                qb.setProjectionMap(sAggregatesProjectionMap);
+                applyAggregatePrimaryRestrictionExceptions(sContactsProjectionMap);
+                qb.setProjectionMap(sContactsProjectionMap);
                 break;
             }
 
-            case AGGREGATES_ID: {
+            case CONTACTS_ID: {
                 long aggId = ContentUris.parseId(uri);
-                qb.setTables(Tables.AGGREGATES);
-                qb.appendWhere(AggregatesColumns.CONCRETE_ID + "=" + aggId + " AND ");
+                qb.setTables(Tables.CONTACTS);
+                qb.appendWhere(ContactsColumns.CONCRETE_ID + "=" + aggId + " AND ");
                 applyAggregateRestrictionExceptions(qb);
-                applyAggregatePrimaryRestrictionExceptions(sAggregatesProjectionMap);
-                qb.setProjectionMap(sAggregatesProjectionMap);
+                applyAggregatePrimaryRestrictionExceptions(sContactsProjectionMap);
+                qb.setProjectionMap(sContactsProjectionMap);
                 break;
             }
 
-            case AGGREGATES_SUMMARY: {
+            case CONTACTS_SUMMARY: {
                 // TODO: join into social status tables
-                qb.setTables(Tables.AGGREGATES_JOIN_PRESENCE_PRIMARY_PHONE);
+                qb.setTables(Tables.CONTACTS_JOIN_PRESENCE_PRIMARY_PHONE);
                 applyAggregateRestrictionExceptions(qb);
-                applyAggregatePrimaryRestrictionExceptions(sAggregatesSummaryProjectionMap);
-                projection = assertContained(projection, Aggregates.PRIMARY_PHONE_ID);
-                qb.setProjectionMap(sAggregatesSummaryProjectionMap);
-                groupBy = aggregateIdColName;
+                applyAggregatePrimaryRestrictionExceptions(sContactsSummaryProjectionMap);
+                projection = assertContained(projection, Contacts.PRIMARY_PHONE_ID);
+                qb.setProjectionMap(sContactsSummaryProjectionMap);
+                groupBy = contactIdColName;
                 break;
             }
 
-            case AGGREGATES_SUMMARY_ID: {
+            case CONTACTS_SUMMARY_ID: {
                 // TODO: join into social status tables
                 long aggId = ContentUris.parseId(uri);
-                qb.setTables(Tables.AGGREGATES_JOIN_PRESENCE_PRIMARY_PHONE);
-                qb.appendWhere(AggregatesColumns.CONCRETE_ID + "=" + aggId + " AND ");
+                qb.setTables(Tables.CONTACTS_JOIN_PRESENCE_PRIMARY_PHONE);
+                qb.appendWhere(ContactsColumns.CONCRETE_ID + "=" + aggId + " AND ");
                 applyAggregateRestrictionExceptions(qb);
-                applyAggregatePrimaryRestrictionExceptions(sAggregatesSummaryProjectionMap);
-                projection = assertContained(projection, Aggregates.PRIMARY_PHONE_ID);
-                qb.setProjectionMap(sAggregatesSummaryProjectionMap);
-                groupBy = aggregateIdColName;
+                applyAggregatePrimaryRestrictionExceptions(sContactsSummaryProjectionMap);
+                projection = assertContained(projection, Contacts.PRIMARY_PHONE_ID);
+                qb.setProjectionMap(sContactsSummaryProjectionMap);
+                groupBy = contactIdColName;
                 break;
             }
 
-            case AGGREGATES_SUMMARY_FILTER: {
+            case CONTACTS_SUMMARY_FILTER: {
                 // TODO: filter query based on callingUid
-                qb.setTables(Tables.AGGREGATES_JOIN_PRESENCE_PRIMARY_PHONE);
-                qb.setProjectionMap(sAggregatesSummaryProjectionMap);
+                qb.setTables(Tables.CONTACTS_JOIN_PRESENCE_PRIMARY_PHONE);
+                qb.setProjectionMap(sContactsSummaryProjectionMap);
                 if (uri.getPathSegments().size() > 2) {
-                    qb.appendWhere(buildAggregateLookupWhereClause(uri.getLastPathSegment()));
+                    qb.appendWhere(buildContactLookupWhereClause(uri.getLastPathSegment()));
                 }
-                groupBy = aggregateIdColName;
+                groupBy = contactIdColName;
                 break;
             }
 
-            case AGGREGATES_SUMMARY_STREQUENT_FILTER:
-            case AGGREGATES_SUMMARY_STREQUENT: {
+            case CONTACTS_SUMMARY_STREQUENT_FILTER:
+            case CONTACTS_SUMMARY_STREQUENT: {
                 // Build the first query for starred
-                qb.setTables(Tables.AGGREGATES_JOIN_PRESENCE_PRIMARY_PHONE);
-                qb.setProjectionMap(sAggregatesSummaryProjectionMap);
-                if (match == AGGREGATES_SUMMARY_STREQUENT_FILTER
+                qb.setTables(Tables.CONTACTS_JOIN_PRESENCE_PRIMARY_PHONE);
+                qb.setProjectionMap(sContactsSummaryProjectionMap);
+                if (match == CONTACTS_SUMMARY_STREQUENT_FILTER
                         && uri.getPathSegments().size() > 3) {
-                    qb.appendWhere(buildAggregateLookupWhereClause(uri.getLastPathSegment()));
+                    qb.appendWhere(buildContactLookupWhereClause(uri.getLastPathSegment()));
                 }
-                final String starredQuery = qb.buildQuery(projection, Aggregates.STARRED + "=1",
-                        null, aggregateIdColName, null, null,
+                final String starredQuery = qb.buildQuery(projection, Contacts.STARRED + "=1",
+                        null, contactIdColName, null, null,
                         null /* limit */);
 
                 // Build the second query for frequent
                 qb = new SQLiteQueryBuilder();
-                qb.setTables(Tables.AGGREGATES_JOIN_PRESENCE_PRIMARY_PHONE);
-                qb.setProjectionMap(sAggregatesSummaryProjectionMap);
-                if (match == AGGREGATES_SUMMARY_STREQUENT_FILTER
+                qb.setTables(Tables.CONTACTS_JOIN_PRESENCE_PRIMARY_PHONE);
+                qb.setProjectionMap(sContactsSummaryProjectionMap);
+                if (match == CONTACTS_SUMMARY_STREQUENT_FILTER
                         && uri.getPathSegments().size() > 3) {
-                    qb.appendWhere(buildAggregateLookupWhereClause(uri.getLastPathSegment()));
+                    qb.appendWhere(buildContactLookupWhereClause(uri.getLastPathSegment()));
                 }
                 final String frequentQuery = qb.buildQuery(projection,
-                        Aggregates.TIMES_CONTACTED + " > 0 AND (" + Aggregates.STARRED
-                        + " = 0 OR " + Aggregates.STARRED + " IS NULL)",
-                        null, aggregateIdColName, null, null, null);
+                        Contacts.TIMES_CONTACTED + " > 0 AND (" + Contacts.STARRED
+                        + " = 0 OR " + Contacts.STARRED + " IS NULL)",
+                        null, contactIdColName, null, null, null);
 
                 // Put them together
                 final String query = qb.buildUnionQuery(new String[] {starredQuery, frequentQuery},
                         STREQUENT_ORDER_BY, STREQUENT_LIMIT);
                 Cursor c = db.rawQueryWithFactory(null, query, null,
-                        Tables.AGGREGATES_JOIN_PRESENCE_PRIMARY_PHONE);
+                        Tables.CONTACTS_JOIN_PRESENCE_PRIMARY_PHONE);
 
                 if ((c != null) && !isTemporary()) {
                     c.setNotificationUri(getContext().getContentResolver(),
@@ -2071,57 +2070,57 @@
                 return c;
             }
 
-            case AGGREGATES_SUMMARY_GROUP: {
-                qb.setTables(Tables.AGGREGATES_JOIN_PRESENCE_PRIMARY_PHONE);
+            case CONTACTS_SUMMARY_GROUP: {
+                qb.setTables(Tables.CONTACTS_JOIN_PRESENCE_PRIMARY_PHONE);
                 applyAggregateRestrictionExceptions(qb);
-                applyAggregatePrimaryRestrictionExceptions(sAggregatesSummaryProjectionMap);
-                projection = assertContained(projection, Aggregates.PRIMARY_PHONE_ID);
-                qb.setProjectionMap(sAggregatesSummaryProjectionMap);
+                applyAggregatePrimaryRestrictionExceptions(sContactsSummaryProjectionMap);
+                projection = assertContained(projection, Contacts.PRIMARY_PHONE_ID);
+                qb.setProjectionMap(sContactsSummaryProjectionMap);
                 if (uri.getPathSegments().size() > 2) {
-                    qb.appendWhere(" AND " + sAggregatesInGroupSelect);
+                    qb.appendWhere(" AND " + sContactsInGroupSelect);
                     selectionArgs = appendGroupArg(selectionArgs, uri.getLastPathSegment());
                 }
-                groupBy = aggregateIdColName;
+                groupBy = contactIdColName;
                 break;
             }
 
-            case AGGREGATES_DATA: {
+            case CONTACTS_DATA: {
                 long aggId = Long.parseLong(uri.getPathSegments().get(1));
-                qb.setTables(Tables.DATA_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_AGGREGATES_GROUPS);
-                qb.setProjectionMap(sDataContactsGroupsAggregateProjectionMap);
-                qb.appendWhere(RawContacts.AGGREGATE_ID + "=" + aggId + " AND ");
+                qb.setTables(Tables.DATA_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_CONTACTS_GROUPS);
+                qb.setProjectionMap(sDataContactsGroupsContactProjectionMap);
+                qb.appendWhere(RawContacts.CONTACT_ID + "=" + aggId + " AND ");
                 applyDataRestrictionExceptions(qb);
                 break;
             }
 
             case PHONES_FILTER: {
-                qb.setTables(Tables.DATA_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_AGGREGATES);
-                qb.setProjectionMap(sDataContactsAggregateProjectionMap);
+                qb.setTables(Tables.DATA_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_CONTACTS);
+                qb.setProjectionMap(sDataContactsContactProjectionMap);
                 qb.appendWhere(Data.MIMETYPE + " = '" + Phone.CONTENT_ITEM_TYPE + "'");
                 if (uri.getPathSegments().size() > 2) {
-                    qb.appendWhere(" AND " + buildAggregateLookupWhereClause(
+                    qb.appendWhere(" AND " + buildContactLookupWhereClause(
                             uri.getLastPathSegment()));
                 }
                 break;
             }
 
             case PHONES: {
-                qb.setTables(Tables.DATA_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_AGGREGATES);
-                qb.setProjectionMap(sDataContactsAggregateProjectionMap);
+                qb.setTables(Tables.DATA_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_CONTACTS);
+                qb.setProjectionMap(sDataContactsContactProjectionMap);
                 qb.appendWhere(Data.MIMETYPE + " = \"" + Phone.CONTENT_ITEM_TYPE + "\"");
                 break;
             }
 
             case POSTALS: {
-                qb.setTables(Tables.DATA_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_AGGREGATES);
-                qb.setProjectionMap(sDataContactsAggregateProjectionMap);
+                qb.setTables(Tables.DATA_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_CONTACTS);
+                qb.setProjectionMap(sDataContactsContactProjectionMap);
                 qb.appendWhere(Data.MIMETYPE + " = \"" + StructuredPostal.CONTENT_ITEM_TYPE + "\"");
                 break;
             }
 
             case RAW_CONTACTS: {
                 qb.setTables(Tables.RAW_CONTACTS);
-                qb.setProjectionMap(sContactsProjectionMap);
+                qb.setProjectionMap(sRawContactsProjectionMap);
                 applyContactsRestrictionExceptions(qb);
                 break;
             }
@@ -2129,7 +2128,7 @@
             case RAW_CONTACTS_ID: {
                 long rawContactId = ContentUris.parseId(uri);
                 qb.setTables(Tables.RAW_CONTACTS);
-                qb.setProjectionMap(sContactsProjectionMap);
+                qb.setProjectionMap(sRawContactsProjectionMap);
                 qb.appendWhere(RawContactsColumns.CONCRETE_ID + "=" + rawContactId + " AND ");
                 applyContactsRestrictionExceptions(qb);
                 break;
@@ -2146,7 +2145,7 @@
 
             case CONTACTS_FILTER_EMAIL: {
                 // TODO: filter query based on callingUid
-                qb.setTables(Tables.DATA_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_AGGREGATES);
+                qb.setTables(Tables.DATA_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_CONTACTS);
                 qb.setProjectionMap(sDataContactsProjectionMap);
                 qb.appendWhere(Data.MIMETYPE + "='" + CommonDataKinds.Email.CONTENT_ITEM_TYPE + "'");
                 qb.appendWhere(" AND " + CommonDataKinds.Email.DATA + "=");
@@ -2206,7 +2205,7 @@
             }
 
             case GROUPS_SUMMARY: {
-                qb.setTables(Tables.GROUPS_JOIN_PACKAGES_DATA_RAW_CONTACTS_AGGREGATES);
+                qb.setTables(Tables.GROUPS_JOIN_PACKAGES_DATA_RAW_CONTACTS_CONTACTS);
                 qb.setProjectionMap(sGroupsSummaryProjectionMap);
                 groupBy = GroupsColumns.CONCRETE_ID;
                 break;
@@ -2219,7 +2218,7 @@
             }
 
             case AGGREGATION_SUGGESTIONS: {
-                long aggregateId = Long.parseLong(uri.getPathSegments().get(1));
+                long contactId = Long.parseLong(uri.getPathSegments().get(1));
                 final String maxSuggestionsParam =
                         uri.getQueryParameter(AggregationSuggestions.MAX_SUGGESTIONS);
 
@@ -2230,8 +2229,8 @@
                     maxSuggestions = DEFAULT_MAX_SUGGESTIONS;
                 }
 
-                return mContactAggregator.queryAggregationSuggestions(aggregateId, projection,
-                        sAggregatesProjectionMap, maxSuggestions);
+                return mContactAggregator.queryAggregationSuggestions(contactId, projection,
+                        sContactsProjectionMap, maxSuggestions);
             }
 
             case PRESENCE: {
@@ -2289,21 +2288,21 @@
     }
 
     /**
-     * Restrict selection of {@link Aggregates} to only public ones, or those
+     * Restrict selection of {@link Contacts} to only public ones, or those
      * the caller has been granted an exception to.
      */
     private void applyAggregateRestrictionExceptions(SQLiteQueryBuilder qb) {
         if (hasRestrictedAccess()) {
             qb.appendWhere("1");
         } else {
-            qb.appendWhere(AggregatesColumns.SINGLE_IS_RESTRICTED + "=0");
+            qb.appendWhere(ContactsColumns.SINGLE_IS_RESTRICTED + "=0");
         }
     }
 
     /**
      * Find any exceptions that have been granted to the calling process, and
-     * add projections to correctly select {@link Aggregates#PRIMARY_PHONE_ID}
-     * and {@link Aggregates#PRIMARY_EMAIL_ID}.
+     * add projections to correctly select {@link Contacts#PRIMARY_PHONE_ID}
+     * and {@link Contacts#PRIMARY_EMAIL_ID}.
      */
     private void applyAggregatePrimaryRestrictionExceptions(HashMap<String, String> projection) {
         String projectionPhone;
@@ -2311,23 +2310,23 @@
 
         if (hasRestrictedAccess()) {
             // With restricted access, always give optimal values
-            projectionPhone = AggregatesColumns.OPTIMAL_PRIMARY_PHONE_ID + " AS "
-                    + Aggregates.PRIMARY_PHONE_ID;
-            projectionEmail = AggregatesColumns.OPTIMAL_PRIMARY_EMAIL_ID + " AS "
-                    + Aggregates.PRIMARY_EMAIL_ID;
+            projectionPhone = ContactsColumns.OPTIMAL_PRIMARY_PHONE_ID + " AS "
+                    + Contacts.PRIMARY_PHONE_ID;
+            projectionEmail = ContactsColumns.OPTIMAL_PRIMARY_EMAIL_ID + " AS "
+                    + Contacts.PRIMARY_EMAIL_ID;
         } else {
             // With general access, always give fallback values
-            projectionPhone = AggregatesColumns.FALLBACK_PRIMARY_PHONE_ID + " AS "
-                    + Aggregates.PRIMARY_PHONE_ID;
-            projectionEmail = AggregatesColumns.FALLBACK_PRIMARY_EMAIL_ID + " AS "
-                    + Aggregates.PRIMARY_EMAIL_ID;
+            projectionPhone = ContactsColumns.FALLBACK_PRIMARY_PHONE_ID + " AS "
+                    + Contacts.PRIMARY_PHONE_ID;
+            projectionEmail = ContactsColumns.FALLBACK_PRIMARY_EMAIL_ID + " AS "
+                    + Contacts.PRIMARY_EMAIL_ID;
         }
 
-        projection.remove(Aggregates.PRIMARY_PHONE_ID);
-        projection.put(Aggregates.PRIMARY_PHONE_ID, projectionPhone);
+        projection.remove(Contacts.PRIMARY_PHONE_ID);
+        projection.put(Contacts.PRIMARY_PHONE_ID, projectionPhone);
 
-        projection.remove(Aggregates.PRIMARY_EMAIL_ID);
-        projection.put(Aggregates.PRIMARY_EMAIL_ID, projectionEmail);
+        projection.remove(Contacts.PRIMARY_EMAIL_ID);
+        projection.put(Contacts.PRIMARY_EMAIL_ID, projectionEmail);
     }
 
     /**
@@ -2561,8 +2560,8 @@
     public String getType(Uri uri) {
         final int match = sUriMatcher.match(uri);
         switch (match) {
-            case AGGREGATES: return Aggregates.CONTENT_TYPE;
-            case AGGREGATES_ID: return Aggregates.CONTENT_ITEM_TYPE;
+            case CONTACTS: return Contacts.CONTENT_TYPE;
+            case CONTACTS_ID: return Contacts.CONTENT_ITEM_TYPE;
             case RAW_CONTACTS: return RawContacts.CONTENT_TYPE;
             case RAW_CONTACTS_ID: return RawContacts.CONTENT_ITEM_TYPE;
             case DATA_ID:
@@ -2571,7 +2570,7 @@
                 return mOpenHelper.getDataMimeType(dataId);
             case AGGREGATION_EXCEPTIONS: return AggregationExceptions.CONTENT_TYPE;
             case AGGREGATION_EXCEPTION_ID: return AggregationExceptions.CONTENT_ITEM_TYPE;
-            case AGGREGATION_SUGGESTIONS: return Aggregates.CONTENT_TYPE;
+            case AGGREGATION_SUGGESTIONS: return Contacts.CONTENT_TYPE;
         }
         throw new UnsupportedOperationException("Unknown uri: " + uri);
     }
@@ -2635,12 +2634,12 @@
 
         Cursor cursor = null;
         try {
-            cursor = db.query(DataContactsQuery.TABLE, DataContactsQuery.PROJECTION,
+            cursor = db.query(DataRawContactsQuery.TABLE, DataRawContactsQuery.PROJECTION,
                     DataColumns.CONCRETE_ID + "=" + dataId, null, null, null, null);
             if (cursor.moveToFirst()) {
-                aggId = cursor.getLong(DataContactsQuery.AGGREGATE_ID);
-                isRestricted = (cursor.getInt(DataContactsQuery.IS_RESTRICTED) == 1);
-                mimeType = cursor.getString(DataContactsQuery.MIMETYPE);
+                aggId = cursor.getLong(DataRawContactsQuery.CONTACT_ID);
+                isRestricted = (cursor.getInt(DataRawContactsQuery.IS_RESTRICTED) == 1);
+                mimeType = cursor.getString(DataRawContactsQuery.MIMETYPE);
             }
         } finally {
             if (cursor != null) {
@@ -2660,33 +2659,33 @@
         // Record this value as the new primary for the parent aggregate
         final ContentValues values = new ContentValues();
         if (isPhone) {
-            values.put(AggregatesColumns.OPTIMAL_PRIMARY_PHONE_ID, dataId);
-            values.put(AggregatesColumns.OPTIMAL_PRIMARY_PHONE_IS_RESTRICTED, isRestricted);
+            values.put(ContactsColumns.OPTIMAL_PRIMARY_PHONE_ID, dataId);
+            values.put(ContactsColumns.OPTIMAL_PRIMARY_PHONE_IS_RESTRICTED, isRestricted);
         } else if (isEmail) {
-            values.put(AggregatesColumns.OPTIMAL_PRIMARY_EMAIL_ID, dataId);
-            values.put(AggregatesColumns.OPTIMAL_PRIMARY_EMAIL_IS_RESTRICTED, isRestricted);
+            values.put(ContactsColumns.OPTIMAL_PRIMARY_EMAIL_ID, dataId);
+            values.put(ContactsColumns.OPTIMAL_PRIMARY_EMAIL_IS_RESTRICTED, isRestricted);
         }
 
         // If this data is unrestricted, then also set as fallback
         if (!isRestricted && isPhone) {
-            values.put(AggregatesColumns.FALLBACK_PRIMARY_PHONE_ID, dataId);
+            values.put(ContactsColumns.FALLBACK_PRIMARY_PHONE_ID, dataId);
         } else if (!isRestricted && isEmail) {
-            values.put(AggregatesColumns.FALLBACK_PRIMARY_EMAIL_ID, dataId);
+            values.put(ContactsColumns.FALLBACK_PRIMARY_EMAIL_ID, dataId);
         }
 
-        // Push update into aggregates table, if needed
+        // Push update into contacts table, if needed
         if (values.size() > 0) {
-            db.update(Tables.AGGREGATES, values, Aggregates._ID + "=" + aggId, null);
+            db.update(Tables.CONTACTS, values, Contacts._ID + "=" + aggId, null);
         }
     }
 
-    private String buildAggregateLookupWhereClause(String filterParam) {
+    private String buildContactLookupWhereClause(String filterParam) {
         StringBuilder filter = new StringBuilder();
-        filter.append(Tables.AGGREGATES);
+        filter.append(Tables.CONTACTS);
         filter.append(".");
-        filter.append(Aggregates._ID);
+        filter.append(Contacts._ID);
         filter.append(" IN (SELECT ");
-        filter.append(RawContacts.AGGREGATE_ID);
+        filter.append(RawContacts.CONTACT_ID);
         filter.append(" FROM ");
         filter.append(Tables.RAW_CONTACTS);
         filter.append(" WHERE ");
diff --git a/src/com/android/providers/contacts/LegacyApiSupport.java b/src/com/android/providers/contacts/LegacyApiSupport.java
index f736116..c9d7113 100644
--- a/src/com/android/providers/contacts/LegacyApiSupport.java
+++ b/src/com/android/providers/contacts/LegacyApiSupport.java
@@ -428,7 +428,7 @@
     private final ContactsProvider2 mContactsProvider;
     private final NameSplitter mPhoneticNameSplitter;
 
-    /** Precompiled sql statement for incrementing times contacted for an aggregate */
+    /** Precompiled sql statement for incrementing times contacted for a contact */
     private final SQLiteStatement mLastTimeContactedUpdate;
 
     private final ContentValues mValues = new ContentValues();
@@ -522,7 +522,7 @@
         db.execSQL("CREATE VIEW " + LegacyTables.CONTACT_METHODS + " AS SELECT " +
                 DataColumns.CONCRETE_ID
                         + " AS " + ContactMethods._ID + ", " +
-                DataColumns.CONCRETE_CONTACT_ID
+                DataColumns.CONCRETE_RAW_CONTACT_ID
                         + " AS " + ContactMethods.PERSON_ID + ", " +
                 CONTACT_METHOD_KIND_SQL
                         + " AS " + ContactMethods.KIND + ", " +
@@ -565,7 +565,7 @@
         db.execSQL("CREATE VIEW " + LegacyTables.PHONES + " AS SELECT " +
                 DataColumns.CONCRETE_ID
                         + " AS " + android.provider.Contacts.Phones._ID + ", " +
-                DataColumns.CONCRETE_CONTACT_ID
+                DataColumns.CONCRETE_RAW_CONTACT_ID
                         + " AS " + android.provider.Contacts.Phones.PERSON_ID + ", " +
                 DataColumns.CONCRETE_IS_PRIMARY
                         + " AS " + android.provider.Contacts.Phones.ISPRIMARY + ", " +
@@ -606,7 +606,7 @@
         db.execSQL("CREATE VIEW " + LegacyTables.EXTENSIONS + " AS SELECT " +
                 DataColumns.CONCRETE_ID
                         + " AS " + android.provider.Contacts.Extensions._ID + ", " +
-                DataColumns.CONCRETE_CONTACT_ID
+                DataColumns.CONCRETE_RAW_CONTACT_ID
                         + " AS " + android.provider.Contacts.Extensions.PERSON_ID + ", " +
                 ExtensionsColumns.NAME
                         + " AS " + android.provider.Contacts.Extensions.NAME + ", " +
@@ -632,7 +632,7 @@
         db.execSQL("CREATE VIEW " + LegacyTables.GROUP_MEMBERSHIP + " AS SELECT " +
                 DataColumns.CONCRETE_ID
                         + " AS " + android.provider.Contacts.GroupMembership._ID + ", " +
-                DataColumns.CONCRETE_CONTACT_ID
+                DataColumns.CONCRETE_RAW_CONTACT_ID
                         + " AS " + android.provider.Contacts.GroupMembership.PERSON_ID + ", " +
                 GroupMembership.GROUP_ROW_ID
                         + " AS " + android.provider.Contacts.GroupMembership.GROUP_ID + ", " +
@@ -653,7 +653,7 @@
         db.execSQL("CREATE VIEW " + LegacyTables.PHOTOS + " AS SELECT " +
                 DataColumns.CONCRETE_ID
                         + " AS " + android.provider.Contacts.Photos._ID + ", " +
-                DataColumns.CONCRETE_CONTACT_ID
+                DataColumns.CONCRETE_RAW_CONTACT_ID
                         + " AS " + android.provider.Contacts.Photos.PERSON_ID + ", " +
                 Tables.DATA + "." + Photo.PHOTO
                         + " AS " + android.provider.Contacts.Photos.DATA + ", " +
@@ -994,9 +994,9 @@
         }
 
         long rawContactId = Long.parseLong(uri.getPathSegments().get(1));
-        long aggregateId = mOpenHelper.getAggregateId(rawContactId);
-        if (aggregateId != 0) {
-            mContactsProvider.updateContactTime(aggregateId, lastTimeContacted);
+        long contactId = mOpenHelper.getContactId(rawContactId);
+        if (contactId != 0) {
+            mContactsProvider.updateContactTime(contactId, lastTimeContacted);
         } else {
             mLastTimeContactedUpdate.bindLong(1, lastTimeContacted);
             mLastTimeContactedUpdate.bindLong(2, rawContactId);
diff --git a/src/com/android/providers/contacts/OpenHelper.java b/src/com/android/providers/contacts/OpenHelper.java
index aa90f52..f7ce82c 100644
--- a/src/com/android/providers/contacts/OpenHelper.java
+++ b/src/com/android/providers/contacts/OpenHelper.java
@@ -32,12 +32,12 @@
 import android.database.sqlite.SQLiteQueryBuilder;
 import android.database.sqlite.SQLiteStatement;
 import android.provider.BaseColumns;
-import android.provider.ContactsContract.Aggregates;
 import android.provider.ContactsContract.AggregationExceptions;
-import android.provider.ContactsContract.RawContacts;
+import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.Data;
 import android.provider.ContactsContract.Groups;
 import android.provider.ContactsContract.Presence;
+import android.provider.ContactsContract.RawContacts;
 import android.provider.ContactsContract.CommonDataKinds.Email;
 import android.provider.ContactsContract.CommonDataKinds.GroupMembership;
 import android.provider.ContactsContract.CommonDataKinds.Im;
@@ -57,7 +57,7 @@
 /* package */ class OpenHelper extends SQLiteOpenHelper {
     private static final String TAG = "OpenHelper";
 
-    private static final int DATABASE_VERSION = 52;
+    private static final int DATABASE_VERSION = 54;
     private static final String DATABASE_NAME = "contacts2.db";
     private static final String DATABASE_PRESENCE = "presence_db";
 
@@ -67,7 +67,7 @@
 
     public interface Tables {
         public static final String ACCOUNTS = "accounts";
-        public static final String AGGREGATES = "aggregates";
+        public static final String CONTACTS = "contacts";
         public static final String RAW_CONTACTS = "raw_contacts";
         public static final String PACKAGES = "packages";
         public static final String MIMETYPES = "mimetypes";
@@ -79,8 +79,8 @@
         public static final String PRESENCE = "presence";
         public static final String NICKNAME_LOOKUP = "nickname_lookup";
 
-        public static final String AGGREGATES_JOIN_PRESENCE_PRIMARY_PHONE = "aggregates "
-                + "LEFT OUTER JOIN raw_contacts ON (aggregates._id = raw_contacts.aggregate_id) "
+        public static final String CONTACTS_JOIN_PRESENCE_PRIMARY_PHONE = "contacts "
+                + "LEFT OUTER JOIN raw_contacts ON (contacts._id = raw_contacts.contact_id) "
                 + "LEFT OUTER JOIN presence ON (raw_contacts._id = presence.raw_contact_id) "
                 + "LEFT OUTER JOIN data ON (primary_phone_id = data._id)";
 
@@ -101,18 +101,18 @@
                 + "LEFT OUTER JOIN mimetypes ON (data.mimetype_id = mimetypes._id) "
                 + "LEFT OUTER JOIN raw_contacts ON (data.raw_contact_id = raw_contacts._id)";
 
-        public static final String DATA_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_AGGREGATES = "data "
+        public static final String DATA_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_CONTACTS = "data "
                 + "LEFT OUTER JOIN packages ON (data.package_id = packages._id) "
                 + "LEFT OUTER JOIN mimetypes ON (data.mimetype_id = mimetypes._id) "
                 + "LEFT OUTER JOIN raw_contacts ON (data.raw_contact_id = raw_contacts._id) "
-                + "LEFT OUTER JOIN aggregates ON (raw_contacts.aggregate_id = aggregates._id)";
+                + "LEFT OUTER JOIN contacts ON (raw_contacts.contact_id = contacts._id)";
 
-        public static final String DATA_JOIN_MIMETYPES_RAW_CONTACTS_AGGREGATES = "data "
+        public static final String DATA_JOIN_MIMETYPES_RAW_CONTACTS_CONTACTS = "data "
                 + "LEFT OUTER JOIN mimetypes ON (data.mimetype_id = mimetypes._id) "
                 + "LEFT OUTER JOIN raw_contacts ON (data.raw_contact_id = raw_contacts._id) "
-                + "LEFT OUTER JOIN aggregates ON (raw_contacts.aggregate_id = aggregates._id)";
+                + "LEFT OUTER JOIN contacts ON (raw_contacts.contact_id = contacts._id)";
 
-        public static final String DATA_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_AGGREGATES_GROUPS =
+        public static final String DATA_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_CONTACTS_GROUPS =
                 "data "
                 + "LEFT OUTER JOIN packages ON (data.package_id = packages._id) "
                 + "LEFT OUTER JOIN mimetypes ON (data.mimetype_id = mimetypes._id) "
@@ -120,7 +120,7 @@
                 + "  ON (mimetypes.mimetype='" + GroupMembership.CONTENT_ITEM_TYPE + "' "
                 + "      AND groups._id = data." + GroupMembership.GROUP_ROW_ID + ") "
                 + "LEFT OUTER JOIN raw_contacts ON (data.raw_contact_id = raw_contacts._id) "
-                + "LEFT OUTER JOIN aggregates ON (raw_contacts.aggregate_id = aggregates._id)";
+                + "LEFT OUTER JOIN contacts ON (raw_contacts.contact_id = contacts._id)";
 
         public static final String DATA_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_GROUPS = "data "
                 + "LEFT OUTER JOIN packages ON (data.package_id = packages._id) "
@@ -133,25 +133,25 @@
         public static final String GROUPS_JOIN_PACKAGES = "groups "
                 + "LEFT OUTER JOIN packages ON (groups.package_id = packages._id)";
 
-        public static final String GROUPS_JOIN_PACKAGES_DATA_RAW_CONTACTS_AGGREGATES = "groups "
+        public static final String GROUPS_JOIN_PACKAGES_DATA_RAW_CONTACTS_CONTACTS = "groups "
                 + "LEFT OUTER JOIN packages ON (groups.package_id = packages._id) "
                 + "LEFT OUTER JOIN data "
                 + "  ON (groups._id = data." + GroupMembership.GROUP_ROW_ID + ") "
                 + "LEFT OUTER JOIN raw_contacts ON (data.raw_contact_id = raw_contacts._id) "
-                + "LEFT OUTER JOIN aggregates ON (raw_contacts.aggregate_id = aggregates._id)";
+                + "LEFT OUTER JOIN contacts ON (raw_contacts.contact_id = contacts._id)";
 
         public static final String ACTIVITIES = "activities";
 
         public static final String ACTIVITIES_JOIN_MIMETYPES = "activities "
                 + "LEFT OUTER JOIN mimetypes ON (activities.mimetype_id = mimetypes._id)";
 
-        public static final String ACTIVITIES_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_AGGREGATES =
+        public static final String ACTIVITIES_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_CONTACTS =
                 "activities "
                 + "LEFT OUTER JOIN packages ON (activities.package_id = packages._id) "
                 + "LEFT OUTER JOIN mimetypes ON (activities.mimetype_id = mimetypes._id) "
                 + "LEFT OUTER JOIN raw_contacts ON (activities.author_contact_id = " +
                 		"raw_contacts._id) "
-                + "LEFT OUTER JOIN aggregates ON (raw_contacts.aggregate_id = aggregates._id)";
+                + "LEFT OUTER JOIN contacts ON (raw_contacts.contact_id = contacts._id)";
 
         public static final String NAME_LOOKUP_JOIN_RAW_CONTACTS = "name_lookup "
                 + "INNER JOIN raw_contacts ON (name_lookup.raw_contact_id = raw_contacts._id)";
@@ -182,14 +182,14 @@
                 + GroupsColumns.CONCRETE_ID;
 
         public static final String HAS_PRIMARY_PHONE = "("
-                + AggregatesColumns.OPTIMAL_PRIMARY_PHONE_ID + " IS NOT NULL OR "
-                + AggregatesColumns.FALLBACK_PRIMARY_PHONE_ID + " IS NOT NULL)";
+                + ContactsColumns.OPTIMAL_PRIMARY_PHONE_ID + " IS NOT NULL OR "
+                + ContactsColumns.FALLBACK_PRIMARY_PHONE_ID + " IS NOT NULL)";
 
         // TODO: add in check against package_visible
         public static final String IN_VISIBLE_GROUP = "SELECT MIN(COUNT(" + DataColumns.CONCRETE_ID
                 + "),1) FROM " + Tables.DATA_JOIN_RAW_CONTACTS_GROUPS + " WHERE "
-                + DataColumns.MIMETYPE_ID + "=? AND " + RawContacts.AGGREGATE_ID + "="
-                + AggregatesColumns.CONCRETE_ID + " AND " + Groups.GROUP_VISIBLE + "=1";
+                + DataColumns.MIMETYPE_ID + "=? AND " + RawContacts.CONTACT_ID + "="
+                + ContactsColumns.CONCRETE_ID + " AND " + Groups.GROUP_VISIBLE + "=1";
 
         public static final String GROUP_HAS_ACCOUNT_AND_SOURCE_ID =
                 Groups.SOURCE_ID + "=? AND "
@@ -197,7 +197,7 @@
                         + Groups.ACCOUNT_TYPE + "=?";
     }
 
-    public interface AggregatesColumns {
+    public interface ContactsColumns {
         public static final String OPTIMAL_PRIMARY_PHONE_ID = "optimal_phone_id";
         public static final String OPTIMAL_PRIMARY_PHONE_IS_RESTRICTED =
                 "optimal_phone_is_restricted";
@@ -210,19 +210,19 @@
 
         public static final String SINGLE_IS_RESTRICTED = "single_is_restricted";
 
-        public static final String CONCRETE_ID = Tables.AGGREGATES + "." + BaseColumns._ID;
-        public static final String CONCRETE_DISPLAY_NAME = Tables.AGGREGATES + "."
-                + Aggregates.DISPLAY_NAME;
+        public static final String CONCRETE_ID = Tables.CONTACTS + "." + BaseColumns._ID;
+        public static final String CONCRETE_DISPLAY_NAME = Tables.CONTACTS + "."
+                + Contacts.DISPLAY_NAME;
 
-        public static final String CONCRETE_TIMES_CONTACTED = Tables.AGGREGATES + "."
-                + Aggregates.TIMES_CONTACTED;
-        public static final String CONCRETE_LAST_TIME_CONTACTED = Tables.AGGREGATES + "."
-                + Aggregates.LAST_TIME_CONTACTED;
-        public static final String CONCRETE_STARRED = Tables.AGGREGATES + "." + Aggregates.STARRED;
-        public static final String CONCRETE_CUSTOM_RINGTONE = Tables.AGGREGATES + "."
-                + Aggregates.CUSTOM_RINGTONE;
-        public static final String CONCRETE_SEND_TO_VOICEMAIL = Tables.AGGREGATES + "."
-                + Aggregates.SEND_TO_VOICEMAIL;
+        public static final String CONCRETE_TIMES_CONTACTED = Tables.CONTACTS + "."
+                + Contacts.TIMES_CONTACTED;
+        public static final String CONCRETE_LAST_TIME_CONTACTED = Tables.CONTACTS + "."
+                + Contacts.LAST_TIME_CONTACTED;
+        public static final String CONCRETE_STARRED = Tables.CONTACTS + "." + Contacts.STARRED;
+        public static final String CONCRETE_CUSTOM_RINGTONE = Tables.CONTACTS + "."
+                + Contacts.CUSTOM_RINGTONE;
+        public static final String CONCRETE_SEND_TO_VOICEMAIL = Tables.CONTACTS + "."
+                + Contacts.SEND_TO_VOICEMAIL;
     }
 
     public interface RawContactsColumns {
@@ -248,7 +248,8 @@
         public static final String MIMETYPE_ID = "mimetype_id";
 
         public static final String CONCRETE_ID = Tables.DATA + "." + BaseColumns._ID;
-        public static final String CONCRETE_CONTACT_ID = Tables.DATA + "." + Data.RAW_CONTACT_ID;
+        public static final String CONCRETE_RAW_CONTACT_ID = Tables.DATA + "."
+                + Data.RAW_CONTACT_ID;
         public static final String CONCRETE_GROUP_ID = Tables.DATA + "."
                 + GroupMembership.GROUP_ROW_ID;
 
@@ -374,9 +375,9 @@
     /** Compiled statements for querying and inserting mappings */
     private SQLiteStatement mMimetypeQuery;
     private SQLiteStatement mPackageQuery;
-    private SQLiteStatement mAggregateIdQuery;
+    private SQLiteStatement mContactIdQuery;
     private SQLiteStatement mAggregationModeQuery;
-    private SQLiteStatement mAggregateIdUpdate;
+    private SQLiteStatement mContactIdUpdate;
     private SQLiteStatement mMimetypeInsert;
     private SQLiteStatement mPackageInsert;
     private SQLiteStatement mNameLookupInsert;
@@ -388,7 +389,7 @@
     private final SyncStateContentProviderHelper mSyncState;
     private HashMap<String, String[]> mNicknameClusterCache;
 
-    /** Compiled statements for updating {@link Aggregates#IN_VISIBLE_GROUP}. */
+    /** Compiled statements for updating {@link Contacts#IN_VISIBLE_GROUP}. */
     private SQLiteStatement mVisibleAllUpdate;
     private SQLiteStatement mVisibleSpecificUpdate;
 
@@ -432,10 +433,10 @@
                 + Tables.MIMETYPES + " WHERE " + MimetypesColumns.MIMETYPE + "=?");
         mPackageQuery = db.compileStatement("SELECT " + PackagesColumns._ID + " FROM "
                 + Tables.PACKAGES + " WHERE " + PackagesColumns.PACKAGE + "=?");
-        mAggregateIdQuery = db.compileStatement("SELECT " + RawContacts.AGGREGATE_ID + " FROM "
+        mContactIdQuery = db.compileStatement("SELECT " + RawContacts.CONTACT_ID + " FROM "
                 + Tables.RAW_CONTACTS + " WHERE " + RawContacts._ID + "=?");
-        mAggregateIdUpdate = db.compileStatement("UPDATE " + Tables.RAW_CONTACTS + " SET "
-                + RawContacts.AGGREGATE_ID + "=?" + " WHERE " + RawContacts._ID + "=?");
+        mContactIdUpdate = db.compileStatement("UPDATE " + Tables.RAW_CONTACTS + " SET "
+                + RawContacts.CONTACT_ID + "=?" + " WHERE " + RawContacts._ID + "=?");
         mAggregationModeQuery = db.compileStatement("SELECT " + RawContacts.AGGREGATION_MODE
                 + " FROM " + Tables.RAW_CONTACTS + " WHERE " + RawContacts._ID + "=?");
         mMimetypeInsert = db.compileStatement("INSERT INTO " + Tables.MIMETYPES + "("
@@ -452,12 +453,12 @@
                 + NameLookupColumns.RAW_CONTACT_ID + "," + NameLookupColumns.NAME_TYPE + ","
                 + NameLookupColumns.NORMALIZED_NAME + ") VALUES (?,?,?)");
 
-        final String visibleUpdate = "UPDATE " + Tables.AGGREGATES + " SET "
-                + Aggregates.IN_VISIBLE_GROUP + "= (" + Clauses.IN_VISIBLE_GROUP + ")";
+        final String visibleUpdate = "UPDATE " + Tables.CONTACTS + " SET "
+                + Contacts.IN_VISIBLE_GROUP + "= (" + Clauses.IN_VISIBLE_GROUP + ")";
 
         mVisibleAllUpdate = db.compileStatement(visibleUpdate);
         mVisibleSpecificUpdate = db.compileStatement(visibleUpdate + " WHERE "
-                + AggregatesColumns.CONCRETE_ID + "=?");
+                + ContactsColumns.CONCRETE_ID + "=?");
 
         // Make sure we have an in-memory presence table
         final String tableName = DATABASE_PRESENCE + "." + Tables.PRESENCE;
@@ -488,23 +489,23 @@
         mSyncState.createDatabase(db);
 
         // One row per group of contacts corresponding to the same person
-        db.execSQL("CREATE TABLE " + Tables.AGGREGATES + " (" +
+        db.execSQL("CREATE TABLE " + Tables.CONTACTS + " (" +
                 BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
-                Aggregates.DISPLAY_NAME + " TEXT," +
-                Aggregates.PHOTO_ID + " INTEGER REFERENCES data(_id)," +
-                Aggregates.CUSTOM_RINGTONE + " TEXT," +
-                Aggregates.SEND_TO_VOICEMAIL + " INTEGER NOT NULL DEFAULT 0," +
-                Aggregates.TIMES_CONTACTED + " INTEGER NOT NULL DEFAULT 0," +
-                Aggregates.LAST_TIME_CONTACTED + " INTEGER," +
-                Aggregates.STARRED + " INTEGER NOT NULL DEFAULT 0," +
-                Aggregates.IN_VISIBLE_GROUP + " INTEGER NOT NULL DEFAULT 1," +
-                AggregatesColumns.OPTIMAL_PRIMARY_PHONE_ID + " INTEGER REFERENCES data(_id)," +
-                AggregatesColumns.OPTIMAL_PRIMARY_PHONE_IS_RESTRICTED + " INTEGER DEFAULT 0," +
-                AggregatesColumns.FALLBACK_PRIMARY_PHONE_ID + " INTEGER REFERENCES data(_id)," +
-                AggregatesColumns.OPTIMAL_PRIMARY_EMAIL_ID + " INTEGER REFERENCES data(_id)," +
-                AggregatesColumns.OPTIMAL_PRIMARY_EMAIL_IS_RESTRICTED + " INTEGER DEFAULT 0," +
-                AggregatesColumns.FALLBACK_PRIMARY_EMAIL_ID + " INTEGER REFERENCES data(_id)," +
-                AggregatesColumns.SINGLE_IS_RESTRICTED + " INTEGER REFERENCES package(_id)" +
+                Contacts.DISPLAY_NAME + " TEXT," +
+                Contacts.PHOTO_ID + " INTEGER REFERENCES data(_id)," +
+                Contacts.CUSTOM_RINGTONE + " TEXT," +
+                Contacts.SEND_TO_VOICEMAIL + " INTEGER NOT NULL DEFAULT 0," +
+                Contacts.TIMES_CONTACTED + " INTEGER NOT NULL DEFAULT 0," +
+                Contacts.LAST_TIME_CONTACTED + " INTEGER," +
+                Contacts.STARRED + " INTEGER NOT NULL DEFAULT 0," +
+                Contacts.IN_VISIBLE_GROUP + " INTEGER NOT NULL DEFAULT 1," +
+                ContactsColumns.OPTIMAL_PRIMARY_PHONE_ID + " INTEGER REFERENCES data(_id)," +
+                ContactsColumns.OPTIMAL_PRIMARY_PHONE_IS_RESTRICTED + " INTEGER DEFAULT 0," +
+                ContactsColumns.FALLBACK_PRIMARY_PHONE_ID + " INTEGER REFERENCES data(_id)," +
+                ContactsColumns.OPTIMAL_PRIMARY_EMAIL_ID + " INTEGER REFERENCES data(_id)," +
+                ContactsColumns.OPTIMAL_PRIMARY_EMAIL_IS_RESTRICTED + " INTEGER DEFAULT 0," +
+                ContactsColumns.FALLBACK_PRIMARY_EMAIL_ID + " INTEGER REFERENCES data(_id)," +
+                ContactsColumns.SINGLE_IS_RESTRICTED + " INTEGER REFERENCES package(_id)" +
         ");");
 
         // Contacts table
@@ -517,7 +518,7 @@
                 RawContacts.VERSION + " INTEGER NOT NULL DEFAULT 1," +
                 RawContacts.DIRTY + " INTEGER NOT NULL DEFAULT 1," +
                 RawContacts.DELETED + " INTEGER NOT NULL DEFAULT 0," +
-                RawContacts.AGGREGATE_ID + " INTEGER," +
+                RawContacts.CONTACT_ID + " INTEGER," +
                 RawContacts.AGGREGATION_MODE + " INTEGER NOT NULL DEFAULT " +
                         RawContacts.AGGREGATION_MODE_DEFAULT + "," +
                 RawContacts.CUSTOM_RINGTONE + " TEXT," +
@@ -737,7 +738,7 @@
                 + ", data will be lost!");
 
         db.execSQL("DROP TABLE IF EXISTS " + Tables.ACCOUNTS + ";");
-        db.execSQL("DROP TABLE IF EXISTS " + Tables.AGGREGATES + ";");
+        db.execSQL("DROP TABLE IF EXISTS " + Tables.CONTACTS + ";");
         db.execSQL("DROP TABLE IF EXISTS " + Tables.RAW_CONTACTS + ";");
         db.execSQL("DROP TABLE IF EXISTS " + Tables.PACKAGES + ";");
         db.execSQL("DROP TABLE IF EXISTS " + Tables.MIMETYPES + ";");
@@ -768,7 +769,7 @@
      */
     public void wipeData() {
         SQLiteDatabase db = getWritableDatabase();
-        db.execSQL("DELETE FROM " + Tables.AGGREGATES + ";");
+        db.execSQL("DELETE FROM " + Tables.CONTACTS + ";");
         db.execSQL("DELETE FROM " + Tables.RAW_CONTACTS + ";");
         db.execSQL("DELETE FROM " + Tables.DATA + ";");
         db.execSQL("DELETE FROM " + Tables.PHONE_LOOKUP + ";");
@@ -891,7 +892,7 @@
     }
 
     /**
-     * Update {@link Aggregates#IN_VISIBLE_GROUP} for all aggregates.
+     * Update {@link Contacts#IN_VISIBLE_GROUP} for all contacts.
      */
     public void updateAllVisible() {
         final long groupMembershipMimetypeId = getMimeTypeId(GroupMembership.CONTENT_ITEM_TYPE);
@@ -900,9 +901,9 @@
     }
 
     /**
-     * Update {@link Aggregates#IN_VISIBLE_GROUP} for a specific aggregate.
+     * Update {@link Contacts#IN_VISIBLE_GROUP} for a specific contact.
      */
-    public void updateAggregateVisible(long aggId) {
+    public void updateContactVisible(long aggId) {
         final long groupMembershipMimetypeId = getMimeTypeId(GroupMembership.CONTENT_ITEM_TYPE);
         mVisibleSpecificUpdate.bindLong(1, groupMembershipMimetypeId);
         mVisibleSpecificUpdate.bindLong(2, aggId);
@@ -910,23 +911,23 @@
     }
 
     /**
-     * Updates the aggregate ID for the specified contact.
+     * Updates the contact ID for the specified contact.
      */
-    public void setAggregateId(long rawContactId, long aggregateId) {
+    public void setContactId(long rawContactId, long contactId) {
         getWritableDatabase();
-        DatabaseUtils.bindObjectToProgram(mAggregateIdUpdate, 1, aggregateId);
-        DatabaseUtils.bindObjectToProgram(mAggregateIdUpdate, 2, rawContactId);
-        mAggregateIdUpdate.execute();
+        DatabaseUtils.bindObjectToProgram(mContactIdUpdate, 1, contactId);
+        DatabaseUtils.bindObjectToProgram(mContactIdUpdate, 2, rawContactId);
+        mContactIdUpdate.execute();
     }
 
     /**
-     * Returns aggregate ID for the given contact or zero if it is NULL.
+     * Returns contact ID for the given contact or zero if it is NULL.
      */
-    public long getAggregateId(long rawContactId) {
+    public long getContactId(long rawContactId) {
         getReadableDatabase();
         try {
-            DatabaseUtils.bindObjectToProgram(mAggregateIdQuery, 1, rawContactId);
-            return mAggregateIdQuery.simpleQueryForLong();
+            DatabaseUtils.bindObjectToProgram(mContactIdQuery, 1, rawContactId);
+            return mContactIdQuery.simpleQueryForLong();
         } catch (SQLiteDoneException e) {
             // No valid mapping found, so return -1
             return 0;
diff --git a/src/com/android/providers/contacts/SocialProvider.java b/src/com/android/providers/contacts/SocialProvider.java
index a590c87..a5ea0c9 100644
--- a/src/com/android/providers/contacts/SocialProvider.java
+++ b/src/com/android/providers/contacts/SocialProvider.java
@@ -30,7 +30,7 @@
 import android.database.sqlite.SQLiteQueryBuilder;
 import android.provider.BaseColumns;
 import android.provider.ContactsContract;
-import android.provider.ContactsContract.Aggregates;
+import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.RawContacts;
 import android.provider.SocialContract;
 import android.provider.SocialContract.Activities;
@@ -54,20 +54,20 @@
     private static final int ACTIVITIES_ID = 1001;
     private static final int ACTIVITIES_AUTHORED_BY = 1002;
 
-    private static final int AGGREGATE_STATUS_ID = 3000;
+    private static final int CONTACT_STATUS_ID = 3000;
 
     private static final String DEFAULT_SORT_ORDER = Activities.THREAD_PUBLISHED + " DESC, "
             + Activities.PUBLISHED + " ASC";
 
     /** Contains just the contacts columns */
-    private static final HashMap<String, String> sAggregatesProjectionMap;
-    /** Contains just the contacts columns */
     private static final HashMap<String, String> sContactsProjectionMap;
+    /** Contains just the contacts columns */
+    private static final HashMap<String, String> sRawContactsProjectionMap;
     /** Contains just the activities columns */
     private static final HashMap<String, String> sActivitiesProjectionMap;
 
-    /** Contains the activities, contacts, and aggregates columns, for joined tables */
-    private static final HashMap<String, String> sActivitiesAggregatesProjectionMap;
+    /** Contains the activities, raw contacts, and contacts columns, for joined tables */
+    private static final HashMap<String, String> sActivitiesContactsProjectionMap;
 
     static {
         // Contacts URI matching table
@@ -77,20 +77,20 @@
         matcher.addURI(SocialContract.AUTHORITY, "activities/#", ACTIVITIES_ID);
         matcher.addURI(SocialContract.AUTHORITY, "activities/authored_by/#", ACTIVITIES_AUTHORED_BY);
 
-        matcher.addURI(SocialContract.AUTHORITY, "aggregate_status/#", AGGREGATE_STATUS_ID);
+        matcher.addURI(SocialContract.AUTHORITY, "contact_status/#", CONTACT_STATUS_ID);
 
         HashMap<String, String> columns;
 
-        // Aggregates projection map
+        // Contacts projection map
         columns = new HashMap<String, String>();
-        columns.put(Aggregates.DISPLAY_NAME, Aggregates.DISPLAY_NAME);
-        sAggregatesProjectionMap = columns;
+        columns.put(Contacts.DISPLAY_NAME, Contacts.DISPLAY_NAME);
+        sContactsProjectionMap = columns;
 
         // Contacts projection map
         columns = new HashMap<String, String>();
         columns.put(RawContacts._ID, Tables.RAW_CONTACTS + "." + RawContacts._ID + " AS _id");
-        columns.put(RawContacts.AGGREGATE_ID, RawContacts.AGGREGATE_ID);
-        sContactsProjectionMap = columns;
+        columns.put(RawContacts.CONTACT_ID, RawContacts.CONTACT_ID);
+        sRawContactsProjectionMap = columns;
 
         // Activities projection map
         columns = new HashMap<String, String>();
@@ -110,12 +110,12 @@
         columns.put(Activities.THUMBNAIL, Activities.THUMBNAIL);
         sActivitiesProjectionMap = columns;
 
-        // Activities, contacts, and aggregates projection map for joins
+        // Activities, raw contacts, and contacts projection map for joins
         columns = new HashMap<String, String>();
-        columns.putAll(sAggregatesProjectionMap);
         columns.putAll(sContactsProjectionMap);
+        columns.putAll(sRawContactsProjectionMap);
         columns.putAll(sActivitiesProjectionMap); // Final _id will be from Activities
-        sActivitiesAggregatesProjectionMap = columns;
+        sActivitiesContactsProjectionMap = columns;
 
     }
 
@@ -330,38 +330,38 @@
         final int match = sUriMatcher.match(uri);
         switch (match) {
             case ACTIVITIES: {
-                qb.setTables(Tables.ACTIVITIES_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_AGGREGATES);
-                qb.setProjectionMap(sActivitiesAggregatesProjectionMap);
+                qb.setTables(Tables.ACTIVITIES_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_CONTACTS);
+                qb.setProjectionMap(sActivitiesContactsProjectionMap);
                 break;
             }
 
             case ACTIVITIES_ID: {
                 // TODO: enforce that caller has read access to this data
                 long activityId = ContentUris.parseId(uri);
-                qb.setTables(Tables.ACTIVITIES_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_AGGREGATES);
-                qb.setProjectionMap(sActivitiesAggregatesProjectionMap);
+                qb.setTables(Tables.ACTIVITIES_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_CONTACTS);
+                qb.setProjectionMap(sActivitiesContactsProjectionMap);
                 qb.appendWhere(Activities._ID + "=" + activityId);
                 break;
             }
 
             case ACTIVITIES_AUTHORED_BY: {
                 long contactId = ContentUris.parseId(uri);
-                qb.setTables(Tables.ACTIVITIES_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_AGGREGATES);
-                qb.setProjectionMap(sActivitiesAggregatesProjectionMap);
+                qb.setTables(Tables.ACTIVITIES_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_CONTACTS);
+                qb.setProjectionMap(sActivitiesContactsProjectionMap);
                 qb.appendWhere(Activities.AUTHOR_CONTACT_ID + "=" + contactId);
                 break;
             }
 
-            case AGGREGATE_STATUS_ID: {
+            case CONTACT_STATUS_ID: {
                 long aggId = ContentUris.parseId(uri);
-                qb.setTables(Tables.ACTIVITIES_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_AGGREGATES);
-                qb.setProjectionMap(sActivitiesAggregatesProjectionMap);
+                qb.setTables(Tables.ACTIVITIES_JOIN_PACKAGES_MIMETYPES_RAW_CONTACTS_CONTACTS);
+                qb.setProjectionMap(sActivitiesContactsProjectionMap);
 
-                // Latest status of an aggregate is any top-level status
+                // Latest status of a contact is any top-level status
                 // authored by one of its children contacts.
                 qb.appendWhere(Activities.IN_REPLY_TO + " IS NULL AND ");
                 qb.appendWhere(Activities.AUTHOR_CONTACT_ID + " IN (SELECT " + BaseColumns._ID
-                        + " FROM " + Tables.RAW_CONTACTS + " WHERE " + RawContacts.AGGREGATE_ID + "="
+                        + " FROM " + Tables.RAW_CONTACTS + " WHERE " + RawContacts.CONTACT_ID + "="
                         + aggId + ")");
                 sortOrder = Activities.PUBLISHED + " DESC";
                 limit = "1";
@@ -396,8 +396,8 @@
                 final SQLiteDatabase db = mOpenHelper.getReadableDatabase();
                 long activityId = ContentUris.parseId(uri);
                 return mOpenHelper.getActivityMimeType(activityId);
-            case AGGREGATE_STATUS_ID:
-                return Aggregates.CONTENT_ITEM_TYPE;
+            case CONTACT_STATUS_ID:
+                return Contacts.CONTENT_ITEM_TYPE;
         }
         throw new UnsupportedOperationException("Unknown uri: " + uri);
     }
diff --git a/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java b/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java
index 81b5bf6..0cb504a 100644
--- a/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java
+++ b/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java
@@ -26,7 +26,7 @@
 import android.database.Cursor;
 import android.net.Uri;
 import android.provider.ContactsContract;
-import android.provider.ContactsContract.Aggregates;
+import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.AggregationExceptions;
 import android.provider.ContactsContract.RawContacts;
 import android.provider.ContactsContract.Data;
@@ -96,13 +96,13 @@
                 .build();
     }
 
-    protected long createContact() {
+    protected long createRawContact() {
         ContentValues values = new ContentValues();
         Uri contactUri = mResolver.insert(RawContacts.CONTENT_URI, values);
         return ContentUris.parseId(contactUri);
     }
 
-    protected long createContact(Account account) {
+    protected long createRawContact(Account account) {
         ContentValues values = new ContentValues();
         final Uri uri = maybeAddAccountQueryParameters(RawContacts.CONTENT_URI, account);
         Uri contactUri = mResolver.insert(uri, values);
@@ -231,76 +231,77 @@
                 RawContacts.CONTENT_URI, rawContactId), values, null, null);
     }
 
-    protected void setAggregationException(int type, long aggregateId, long rawContactId) {
+    protected void setAggregationException(int type, long contactId, long rawContactId) {
         ContentValues values = new ContentValues();
-        values.put(AggregationExceptions.AGGREGATE_ID, aggregateId);
+        values.put(AggregationExceptions.CONTACT_ID, contactId);
         values.put(AggregationExceptions.RAW_CONTACT_ID, rawContactId);
         values.put(AggregationExceptions.TYPE, type);
         mResolver.update(AggregationExceptions.CONTENT_URI, values, null, null);
     }
 
-    protected Cursor queryContact(long rawContactId) {
+    protected Cursor queryRawContact(long rawContactId) {
         return mResolver.query(ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), null,
                 null, null, null);
     }
 
-    protected Cursor queryAggregate(long aggregateId) {
-        return mResolver.query(ContentUris.withAppendedId(Aggregates.CONTENT_URI, aggregateId),
+    protected Cursor queryContact(long contactId) {
+        return mResolver.query(ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId),
                 null, null, null, null);
     }
 
-    protected Cursor queryAggregateSummary(long aggregateId, String[] projection) {
-        return mResolver.query(ContentUris.withAppendedId(Aggregates.CONTENT_SUMMARY_URI,
-                aggregateId), projection, null, null, null);
+    protected Cursor queryContactSummary(long contactId, String[] projection) {
+        return mResolver.query(ContentUris.withAppendedId(Contacts.CONTENT_SUMMARY_URI,
+                contactId), projection, null, null, null);
     }
 
-    protected Cursor queryAggregateSummary() {
-        return mResolver.query(Aggregates.CONTENT_SUMMARY_URI, null, null, null, null);
+    protected Cursor queryContactSummary() {
+        return mResolver.query(Contacts.CONTENT_SUMMARY_URI, null, null, null, null);
     }
 
-    protected long queryAggregateId(long rawContactId) {
-        Cursor c = queryContact(rawContactId);
+    protected long queryContactId(long rawContactId) {
+        Cursor c = queryRawContact(rawContactId);
         assertTrue(c.moveToFirst());
-        long aggregateId = c.getLong(c.getColumnIndex(RawContacts.AGGREGATE_ID));
+        long contactId = c.getLong(c.getColumnIndex(RawContacts.CONTACT_ID));
         c.close();
-        return aggregateId;
+        return contactId;
     }
 
-    protected long queryPhotoId(long aggregateId) {
-        Cursor c = queryAggregate(aggregateId);
+    protected long queryPhotoId(long contactId) {
+        Cursor c = queryContact(contactId);
         assertTrue(c.moveToFirst());
-        long photoId = c.getInt(c.getColumnIndex(Aggregates.PHOTO_ID));
+        long photoId = c.getInt(c.getColumnIndex(Contacts.PHOTO_ID));
         c.close();
         return photoId;
     }
 
-    protected String queryDisplayName(long aggregateId) {
-        Cursor c = queryAggregate(aggregateId);
+    protected String queryDisplayName(long contactId) {
+        Cursor c = queryContact(contactId);
         assertTrue(c.moveToFirst());
-        String displayName = c.getString(c.getColumnIndex(Aggregates.DISPLAY_NAME));
+        String displayName = c.getString(c.getColumnIndex(Contacts.DISPLAY_NAME));
         c.close();
         return displayName;
     }
 
-    protected void assertAggregated(long contactId1, long contactId2) {
-        long aggregateId1 = queryAggregateId(contactId1);
-        long aggregateId2 = queryAggregateId(contactId2);
-        assertTrue(aggregateId1 == aggregateId2);
+    protected void assertAggregated(long rawContactId1, long rawContactId2) {
+        long contactId1 = queryContactId(rawContactId1);
+        long contactId2 = queryContactId(rawContactId2);
+        assertTrue(contactId1 == contactId2);
     }
 
-    protected void assertAggregated(long contactId1, long contactId2, String expectedDisplayName) {
-        long aggregateId1 = queryAggregateId(contactId1);
-        long aggregateId2 = queryAggregateId(contactId2);
-        assertTrue(aggregateId1 == aggregateId2);
+    protected void assertAggregated(long rawContactId1, long rawContactId2,
+            String expectedDisplayName) {
+        long contactId1 = queryContactId(rawContactId1);
+        long contactId2 = queryContactId(rawContactId2);
+        assertTrue(contactId1 == contactId2);
 
-        String displayName = queryDisplayName(aggregateId1);
+        String displayName = queryDisplayName(contactId1);
         assertEquals(expectedDisplayName, displayName);
     }
 
-    protected void assertNotAggregated(long contactId1, long contactId2) {
-        long aggregateId1 = queryAggregateId(contactId1);
-        long aggregateId2 = queryAggregateId(contactId2);
-        assertTrue(aggregateId1 != aggregateId2);
+    protected void assertNotAggregated(long rawContactId1, long rawContactId2) {
+        long contactId1 = queryContactId(rawContactId1);
+        long contactId2 = queryContactId(rawContactId2);
+        assertTrue(contactId1 != contactId2);
     }
 
     protected void assertStructuredName(long rawContactId, String prefix, String givenName,
diff --git a/tests/src/com/android/providers/contacts/ContactAggregatorTest.java b/tests/src/com/android/providers/contacts/ContactAggregatorTest.java
index efb95e7..06dc197 100644
--- a/tests/src/com/android/providers/contacts/ContactAggregatorTest.java
+++ b/tests/src/com/android/providers/contacts/ContactAggregatorTest.java
@@ -18,7 +18,7 @@
 import android.content.ContentUris;
 import android.database.Cursor;
 import android.net.Uri;
-import android.provider.ContactsContract.Aggregates;
+import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.AggregationExceptions;
 import android.test.suitebuilder.annotation.LargeTest;
 
@@ -36,519 +36,519 @@
 
     private static final String[] AGGREGATION_EXCEPTION_PROJECTION = new String[] {
             AggregationExceptions.TYPE,
-            AggregationExceptions.AGGREGATE_ID,
+            AggregationExceptions.CONTACT_ID,
             AggregationExceptions.RAW_CONTACT_ID
     };
 
     public void testCrudAggregationExceptions() throws Exception {
-        long contactId1 = createContact();
-        long aggregateId = queryAggregateId(contactId1);
-        long contactId2 = createContact();
+        long rawContactId1 = createRawContact();
+        long contactId = queryContactId(rawContactId1);
+        long rawContactId2 = createRawContact();
 
-        setAggregationException(AggregationExceptions.TYPE_KEEP_IN, aggregateId, contactId2);
+        setAggregationException(AggregationExceptions.TYPE_KEEP_IN, contactId, rawContactId2);
 
         // Refetch the row we have just inserted
         Cursor c = mResolver.query(AggregationExceptions.CONTENT_URI,
-                AGGREGATION_EXCEPTION_PROJECTION, AggregationExceptions.AGGREGATE_ID + "="
-                        + aggregateId, null, null);
+                AGGREGATION_EXCEPTION_PROJECTION, AggregationExceptions.CONTACT_ID + "="
+                        + contactId, null, null);
 
         assertTrue(c.moveToFirst());
         assertEquals(AggregationExceptions.TYPE_KEEP_IN, c.getInt(0));
-        assertEquals(aggregateId, c.getLong(1));
-        assertEquals(contactId2, c.getLong(2));
+        assertEquals(contactId, c.getLong(1));
+        assertEquals(rawContactId2, c.getLong(2));
         assertFalse(c.moveToNext());
         c.close();
 
         // Change from TYPE_KEEP_IN to TYPE_KEEP_OUT
-        setAggregationException(AggregationExceptions.TYPE_KEEP_OUT, aggregateId, contactId2);
+        setAggregationException(AggregationExceptions.TYPE_KEEP_OUT, contactId, rawContactId2);
 
         c = mResolver.query(AggregationExceptions.CONTENT_URI,
-                AGGREGATION_EXCEPTION_PROJECTION, AggregationExceptions.AGGREGATE_ID + "="
-                        + aggregateId, null, null);
+                AGGREGATION_EXCEPTION_PROJECTION, AggregationExceptions.CONTACT_ID + "="
+                        + contactId, null, null);
 
         assertTrue(c.moveToFirst());
         assertEquals(AggregationExceptions.TYPE_KEEP_OUT, c.getInt(0));
-        assertEquals(aggregateId, c.getLong(1));
-        assertEquals(contactId2, c.getLong(2));
+        assertEquals(contactId, c.getLong(1));
+        assertEquals(rawContactId2, c.getLong(2));
         assertFalse(c.moveToNext());
         c.close();
 
         // Delete the rule
-        setAggregationException(AggregationExceptions.TYPE_AUTOMATIC, aggregateId, contactId2);
+        setAggregationException(AggregationExceptions.TYPE_AUTOMATIC, contactId, rawContactId2);
 
         // Verify that the row is gone
         c = mResolver.query(AggregationExceptions.CONTENT_URI,
-                AGGREGATION_EXCEPTION_PROJECTION, AggregationExceptions.AGGREGATE_ID + "="
-                        + aggregateId, null, null);
+                AGGREGATION_EXCEPTION_PROJECTION, AggregationExceptions.CONTACT_ID + "="
+                        + contactId, null, null);
         assertFalse(c.moveToFirst());
         c.close();
     }
 
     public void testAggregationCreatesNewAggregate() {
-        long rawContactId = createContact();
+        long rawContactId = createRawContact();
 
         Uri resultUri = insertStructuredName(rawContactId, "Johna", "Smitha");
 
         // Parse the URI and confirm that it contains an ID
         assertTrue(ContentUris.parseId(resultUri) != 0);
 
-        long aggregateId = queryAggregateId(rawContactId);
-        assertTrue(aggregateId != 0);
+        long contactId = queryContactId(rawContactId);
+        assertTrue(contactId != 0);
 
-        String displayName = queryDisplayName(aggregateId);
+        String displayName = queryDisplayName(contactId);
         assertEquals("Johna Smitha", displayName);
     }
 
     public void testAggregationOfExactFullNameMatch() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Johnb", "Smithb");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Johnb", "Smithb");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Johnb", "Smithb");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Johnb", "Smithb");
 
-        assertAggregated(contactId1, contactId2, "Johnb Smithb");
+        assertAggregated(rawContactId1, rawContactId2, "Johnb Smithb");
     }
 
     public void testAggregationOfCaseInsensitiveFullNameMatch() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Johnc", "Smithc");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Johnc", "Smithc");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Johnc", "smithc");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Johnc", "smithc");
 
-        assertAggregated(contactId1, contactId2, "Johnc Smithc");
+        assertAggregated(rawContactId1, rawContactId2, "Johnc Smithc");
     }
 
     public void testAggregationOfLastNameMatch() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, null, "Johnd");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, null, "Johnd");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, null, "johnd");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, null, "johnd");
 
-        assertAggregated(contactId1, contactId2, "Johnd");
+        assertAggregated(rawContactId1, rawContactId2, "Johnd");
     }
 
     public void testNonAggregationOfFirstNameMatch() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Johne", "Smithe");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Johne", "Smithe");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Johne", null);
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Johne", null);
 
-        assertNotAggregated(contactId1, contactId2);
+        assertNotAggregated(rawContactId1, rawContactId2);
     }
 
     // TODO: should this be allowed to match?
     public void testNonAggregationOfLastNameMatch() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Johnf", "Smithf");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Johnf", "Smithf");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, null, "Smithf");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, null, "Smithf");
 
-        assertNotAggregated(contactId1, contactId2);
+        assertNotAggregated(rawContactId1, rawContactId2);
     }
 
     public void testAggregationOfConcatenatedFullNameMatch() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Johng", "Smithg");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Johng", "Smithg");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "johngsmithg", null);
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "johngsmithg", null);
 
-        assertAggregated(contactId1, contactId2, "Johng Smithg");
+        assertAggregated(rawContactId1, rawContactId2, "Johng Smithg");
     }
 
     public void testAggregationOfNormalizedFullNameMatch() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "H\u00e9l\u00e8ne", "Bj\u00f8rn");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "H\u00e9l\u00e8ne", "Bj\u00f8rn");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "helene bjorn", null);
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "helene bjorn", null);
 
-        assertAggregated(contactId1, contactId2, "H\u00e9l\u00e8ne Bj\u00f8rn");
+        assertAggregated(rawContactId1, rawContactId2, "H\u00e9l\u00e8ne Bj\u00f8rn");
     }
 
     public void testAggregationBasedOnPhoneNumberNoNameData() {
-        long contactId1 = createContact();
-        insertPhoneNumber(contactId1, "(888)555-1231");
+        long rawContactId1 = createRawContact();
+        insertPhoneNumber(rawContactId1, "(888)555-1231");
 
-        long contactId2 = createContact();
-        insertPhoneNumber(contactId2, "1(888)555-1231");
+        long rawContactId2 = createRawContact();
+        insertPhoneNumber(rawContactId2, "1(888)555-1231");
 
-        assertAggregated(contactId1, contactId2);
+        assertAggregated(rawContactId1, rawContactId2);
     }
 
     public void testAggregationBasedOnPhoneNumberWhenTargetAggregateHasNoName() {
-        long contactId1 = createContact();
-        insertPhoneNumber(contactId1, "(888)555-1232");
+        long rawContactId1 = createRawContact();
+        insertPhoneNumber(rawContactId1, "(888)555-1232");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Johnl", "Smithl");
-        insertPhoneNumber(contactId2, "1(888)555-1232");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Johnl", "Smithl");
+        insertPhoneNumber(rawContactId2, "1(888)555-1232");
 
-        assertAggregated(contactId1, contactId2);
+        assertAggregated(rawContactId1, rawContactId2);
     }
 
     public void testAggregationBasedOnPhoneNumberWhenNewContactHasNoName() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Johnm", "Smithm");
-        insertPhoneNumber(contactId1, "(888)555-1233");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Johnm", "Smithm");
+        insertPhoneNumber(rawContactId1, "(888)555-1233");
 
-        long contactId2 = createContact();
-        insertPhoneNumber(contactId2, "1(888)555-1233");
+        long rawContactId2 = createRawContact();
+        insertPhoneNumber(rawContactId2, "1(888)555-1233");
 
-        assertAggregated(contactId1, contactId2);
+        assertAggregated(rawContactId1, rawContactId2);
     }
 
     public void testAggregationBasedOnPhoneNumberWithSimilarNames() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Ogre", "Hunter");
-        insertPhoneNumber(contactId1, "(888)555-1234");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Ogre", "Hunter");
+        insertPhoneNumber(rawContactId1, "(888)555-1234");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Opra", "Humper");
-        insertPhoneNumber(contactId2, "1(888)555-1234");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Opra", "Humper");
+        insertPhoneNumber(rawContactId2, "1(888)555-1234");
 
-        assertAggregated(contactId1, contactId2);
+        assertAggregated(rawContactId1, rawContactId2);
     }
 
     public void testAggregationBasedOnPhoneNumberWithDifferentNames() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Baby", "Bear");
-        insertPhoneNumber(contactId1, "(888)555-1235");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Baby", "Bear");
+        insertPhoneNumber(rawContactId1, "(888)555-1235");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Blind", "Mouse");
-        insertPhoneNumber(contactId2, "1(888)555-1235");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Blind", "Mouse");
+        insertPhoneNumber(rawContactId2, "1(888)555-1235");
 
-        assertNotAggregated(contactId1, contactId2);
+        assertNotAggregated(rawContactId1, rawContactId2);
     }
 
     public void testAggregationBasedOnEmailNoNameData() {
-        long contactId1 = createContact();
-        insertEmail(contactId1, "lightning@android.com");
+        long rawContactId1 = createRawContact();
+        insertEmail(rawContactId1, "lightning@android.com");
 
-        long contactId2 = createContact();
-        insertEmail(contactId2, "lightning@android.com");
+        long rawContactId2 = createRawContact();
+        insertEmail(rawContactId2, "lightning@android.com");
 
-        assertAggregated(contactId1, contactId2);
+        assertAggregated(rawContactId1, rawContactId2);
     }
 
     public void testAggregationBasedOnEmailWhenTargetAggregateHasNoName() {
-        long contactId1 = createContact();
-        insertEmail(contactId1, "mcqueen@android.com");
+        long rawContactId1 = createRawContact();
+        insertEmail(rawContactId1, "mcqueen@android.com");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Lightning", "McQueen");
-        insertEmail(contactId2, "mcqueen@android.com");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Lightning", "McQueen");
+        insertEmail(rawContactId2, "mcqueen@android.com");
 
-        assertAggregated(contactId1, contactId2);
+        assertAggregated(rawContactId1, rawContactId2);
     }
 
     public void testAggregationBasedOnEmailWhenNewContactHasNoName() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Doc", "Hudson");
-        insertEmail(contactId1, "doc@android.com");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Doc", "Hudson");
+        insertEmail(rawContactId1, "doc@android.com");
 
-        long contactId2 = createContact();
-        insertEmail(contactId2, "doc@android.com");
+        long rawContactId2 = createRawContact();
+        insertEmail(rawContactId2, "doc@android.com");
 
-        assertAggregated(contactId1, contactId2);
+        assertAggregated(rawContactId1, rawContactId2);
     }
 
     public void testAggregationBasedOnEmailWithSimilarNames() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Sally", "Carrera");
-        insertEmail(contactId1, "sally@android.com");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Sally", "Carrera");
+        insertEmail(rawContactId1, "sally@android.com");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Sallie", "Carerra");
-        insertEmail(contactId2, "sally@android.com");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Sallie", "Carerra");
+        insertEmail(rawContactId2, "sally@android.com");
 
-        assertAggregated(contactId1, contactId2);
+        assertAggregated(rawContactId1, rawContactId2);
     }
 
     public void testAggregationBasedOnEmailWithDifferentNames() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Chick", "Hicks");
-        insertEmail(contactId1, "hicky@android.com");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Chick", "Hicks");
+        insertEmail(rawContactId1, "hicky@android.com");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Luigi", "Guido");
-        insertEmail(contactId2, "hicky@android.com");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Luigi", "Guido");
+        insertEmail(rawContactId2, "hicky@android.com");
 
-        assertNotAggregated(contactId1, contactId2);
+        assertNotAggregated(rawContactId1, rawContactId2);
     }
 
     public void testAggregationByCommonNicknameWithLastName() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Bill", "Gore");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Bill", "Gore");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "William", "Gore");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "William", "Gore");
 
-        assertAggregated(contactId1, contactId2, "William Gore");
+        assertAggregated(rawContactId1, rawContactId2, "William Gore");
     }
 
     public void testAggregationByCommonNicknameOnly() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Lawrence", null);
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Lawrence", null);
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Larry", null);
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Larry", null);
 
-        assertAggregated(contactId1, contactId2, "Lawrence");
+        assertAggregated(rawContactId1, rawContactId2, "Lawrence");
     }
 
     public void testAggregationByNicknameNoStructuredName() {
-        long contactId1 = createContact();
-        insertNickname(contactId1, "Frozone");
+        long rawContactId1 = createRawContact();
+        insertNickname(rawContactId1, "Frozone");
 
-        long contactId2 = createContact();
-        insertNickname(contactId2, "Frozone");
+        long rawContactId2 = createRawContact();
+        insertNickname(rawContactId2, "Frozone");
 
-        assertAggregated(contactId1, contactId2);
+        assertAggregated(rawContactId1, rawContactId2);
     }
 
     public void testAggregationByNicknameWithSimilarNames() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Buddy", "Pine");
-        insertNickname(contactId1, "Syndrome");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Buddy", "Pine");
+        insertNickname(rawContactId1, "Syndrome");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Body", "Pane");
-        insertNickname(contactId2, "Syndrome");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Body", "Pane");
+        insertNickname(rawContactId2, "Syndrome");
 
-        assertAggregated(contactId1, contactId2);
+        assertAggregated(rawContactId1, rawContactId2);
     }
 
     public void testAggregationByNicknameWithDifferentNames() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Helen", "Parr");
-        insertNickname(contactId1, "Elastigirl");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Helen", "Parr");
+        insertNickname(rawContactId1, "Elastigirl");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Shawn", "Johnson");
-        insertNickname(contactId2, "Elastigirl");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Shawn", "Johnson");
+        insertNickname(rawContactId2, "Elastigirl");
 
-        assertNotAggregated(contactId1, contactId2);
+        assertNotAggregated(rawContactId1, rawContactId2);
     }
 
     public void testAggregationExceptionKeepIn() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Johnk", "Smithk");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Johnk", "Smithk");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Johnkx", "Smithkx");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Johnkx", "Smithkx");
 
-        long aggregateId1 = queryAggregateId(contactId1);
-        long aggregateId2 = queryAggregateId(contactId2);
+        long contactId1 = queryContactId(rawContactId1);
+        long contactId2 = queryContactId(rawContactId2);
 
         setAggregationException(AggregationExceptions.TYPE_KEEP_IN,
-                queryAggregateId(contactId1), contactId2);
+                queryContactId(rawContactId1), rawContactId2);
 
-        assertAggregated(contactId1, contactId2, "Johnkx Smithkx");
+        assertAggregated(rawContactId1, rawContactId2, "Johnkx Smithkx");
 
         // Assert that the empty aggregate got removed
-        long newAggregateId1 = queryAggregateId(contactId1);
-        if (aggregateId1 != newAggregateId1) {
-            Cursor cursor = queryAggregate(aggregateId1);
+        long newContactId1 = queryContactId(rawContactId1);
+        if (contactId1 != newContactId1) {
+            Cursor cursor = queryContact(contactId1);
             assertFalse(cursor.moveToFirst());
             cursor.close();
         } else {
-            Cursor cursor = queryAggregate(aggregateId2);
+            Cursor cursor = queryContact(contactId2);
             assertFalse(cursor.moveToFirst());
             cursor.close();
         }
     }
 
     public void testAggregationExceptionKeepOut() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Johnh", "Smithh");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Johnh", "Smithh");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Johnh", "Smithh");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Johnh", "Smithh");
 
         setAggregationException(AggregationExceptions.TYPE_KEEP_OUT,
-                queryAggregateId(contactId1), contactId2);
+                queryContactId(rawContactId1), rawContactId2);
 
-        assertNotAggregated(contactId1, contactId2);
+        assertNotAggregated(rawContactId1, rawContactId2);
     }
 
     public void testAggregationExceptionKeepOutCheckUpdatesDisplayName() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Johni", "Smithi");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Johni", "Smithi");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Johnj", "Smithj");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Johnj", "Smithj");
 
         setAggregationException(AggregationExceptions.TYPE_KEEP_IN,
-                queryAggregateId(contactId1), contactId2);
+                queryContactId(rawContactId1), rawContactId2);
 
-        assertAggregated(contactId1, contactId2, "Johnj Smithj");
+        assertAggregated(rawContactId1, rawContactId2, "Johnj Smithj");
 
         setAggregationException(AggregationExceptions.TYPE_KEEP_OUT,
-                queryAggregateId(contactId1), contactId2);
+                queryContactId(rawContactId1), rawContactId2);
 
-        assertNotAggregated(contactId1, contactId2);
+        assertNotAggregated(rawContactId1, rawContactId2);
 
-        String displayName1 = queryDisplayName(queryAggregateId(contactId1));
+        String displayName1 = queryDisplayName(queryContactId(rawContactId1));
         assertEquals("Johni Smithi", displayName1);
 
-        String displayName2 = queryDisplayName(queryAggregateId(contactId2));
+        String displayName2 = queryDisplayName(queryContactId(rawContactId2));
         assertEquals("Johnj Smithj", displayName2);
     }
 
     public void testAggregationSuggestionsBasedOnName() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Duane", null);
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Duane", null);
 
         // Exact name match
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Duane", null);
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Duane", null);
         setAggregationException(AggregationExceptions.TYPE_KEEP_OUT,
-                queryAggregateId(contactId1), contactId2);
+                queryContactId(rawContactId1), rawContactId2);
 
         // Edit distance == 0.84
-        long contactId3 = createContact();
-        insertStructuredName(contactId3, "Dwayne", null);
+        long rawContactId3 = createRawContact();
+        insertStructuredName(rawContactId3, "Dwayne", null);
 
         // Edit distance == 0.6
-        long contactId4 = createContact();
-        insertStructuredName(contactId4, "Donny", null);
+        long rawContactId4 = createRawContact();
+        insertStructuredName(rawContactId4, "Donny", null);
 
-        long aggregateId1 = queryAggregateId(contactId1);
-        long aggregateId2 = queryAggregateId(contactId2);
-        long aggregateId3 = queryAggregateId(contactId3);
+        long contactId1 = queryContactId(rawContactId1);
+        long contactId2 = queryContactId(rawContactId2);
+        long contactId3 = queryContactId(rawContactId3);
 
-        assertSuggestions(aggregateId1, aggregateId2, aggregateId3);
+        assertSuggestions(contactId1, contactId2, contactId3);
     }
 
     public void testAggregationSuggestionsBasedOnPhoneNumber() {
 
         // Create two contacts that would not be aggregated because of name mismatch
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Lord", "Farquaad");
-        insertPhoneNumber(contactId1, "(888)555-1236");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Lord", "Farquaad");
+        insertPhoneNumber(rawContactId1, "(888)555-1236");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Talking", "Donkey");
-        insertPhoneNumber(contactId2, "1(888)555-1236");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Talking", "Donkey");
+        insertPhoneNumber(rawContactId2, "1(888)555-1236");
 
-        long aggregateId1 = queryAggregateId(contactId1);
-        long aggregateId2 = queryAggregateId(contactId2);
-        assertTrue(aggregateId1 != aggregateId2);
+        long contactId1 = queryContactId(rawContactId1);
+        long contactId2 = queryContactId(rawContactId2);
+        assertTrue(contactId1 != contactId2);
 
-        assertSuggestions(aggregateId1, aggregateId2);
+        assertSuggestions(contactId1, contactId2);
     }
 
     public void testAggregationSuggestionsBasedOnEmailAddress() {
 
         // Create two contacts that would not be aggregated because of name mismatch
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Carl", "Fredricksen");
-        insertEmail(contactId1, "up@android.com");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Carl", "Fredricksen");
+        insertEmail(rawContactId1, "up@android.com");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Charles", "Muntz");
-        insertEmail(contactId2, "up@android.com");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Charles", "Muntz");
+        insertEmail(rawContactId2, "up@android.com");
 
-        long aggregateId1 = queryAggregateId(contactId1);
-        long aggregateId2 = queryAggregateId(contactId2);
-        assertTrue(aggregateId1 != aggregateId2);
+        long contactId1 = queryContactId(rawContactId1);
+        long contactId2 = queryContactId(rawContactId2);
+        assertTrue(contactId1 != contactId2);
 
-        assertSuggestions(aggregateId1, aggregateId2);
+        assertSuggestions(contactId1, contactId2);
     }
 
     public void testAggregationSuggestionsBasedOnEmailAddressApproximateMatch() {
 
         // Create two contacts that would not be aggregated because of name mismatch
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Bob", null);
-        insertEmail(contactId1, "incredible2004@android.com");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Bob", null);
+        insertEmail(rawContactId1, "incredible2004@android.com");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Lucius", "Best");
-        insertEmail(contactId2, "incrediball@androidd.com");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Lucius", "Best");
+        insertEmail(rawContactId2, "incrediball@androidd.com");
 
-        long aggregateId1 = queryAggregateId(contactId1);
-        long aggregateId2 = queryAggregateId(contactId2);
-        assertTrue(aggregateId1 != aggregateId2);
+        long contactId1 = queryContactId(rawContactId1);
+        long contactId2 = queryContactId(rawContactId2);
+        assertTrue(contactId1 != contactId2);
 
-        assertSuggestions(aggregateId1, aggregateId2);
+        assertSuggestions(contactId1, contactId2);
     }
 
     public void testAggregationSuggestionsBasedOnNickname() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Peter", "Parker");
-        insertNickname(contactId1, "Spider-Man");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Peter", "Parker");
+        insertNickname(rawContactId1, "Spider-Man");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Manny", "Spider");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Manny", "Spider");
 
-        long aggregateId1 = queryAggregateId(contactId1);
-        setAggregationException(AggregationExceptions.TYPE_KEEP_OUT, aggregateId1, contactId2);
+        long contactId1 = queryContactId(rawContactId1);
+        setAggregationException(AggregationExceptions.TYPE_KEEP_OUT, contactId1, rawContactId2);
 
-        long aggregateId2 = queryAggregateId(contactId2);
-        assertSuggestions(aggregateId1, aggregateId2);
+        long contactId2 = queryContactId(rawContactId2);
+        assertSuggestions(contactId1, contactId2);
     }
 
     public void testAggregationSuggestionsBasedOnNicknameMatchingName() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Clark", "Kent");
-        insertNickname(contactId1, "Superman");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Clark", "Kent");
+        insertNickname(rawContactId1, "Superman");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Roy", "Williams");
-        insertNickname(contactId2, "superman");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Roy", "Williams");
+        insertNickname(rawContactId2, "superman");
 
-        long aggregateId1 = queryAggregateId(contactId1);
-        setAggregationException(AggregationExceptions.TYPE_KEEP_OUT, aggregateId1, contactId2);
+        long contactId1 = queryContactId(rawContactId1);
+        setAggregationException(AggregationExceptions.TYPE_KEEP_OUT, contactId1, rawContactId2);
 
-        long aggregateId2 = queryAggregateId(contactId2);
-        assertSuggestions(aggregateId1, aggregateId2);
+        long contactId2 = queryContactId(rawContactId2);
+        assertSuggestions(contactId1, contactId2);
     }
 
     public void testAggregationSuggestionsBasedOnCommonNickname() {
-        long contactId1 = createContact();
-        insertStructuredName(contactId1, "Dick", "Cherry");
+        long rawContactId1 = createRawContact();
+        insertStructuredName(rawContactId1, "Dick", "Cherry");
 
-        long contactId2 = createContact();
-        insertStructuredName(contactId2, "Richard", "Cherry");
+        long rawContactId2 = createRawContact();
+        insertStructuredName(rawContactId2, "Richard", "Cherry");
 
-        long aggregateId1 = queryAggregateId(contactId1);
-        setAggregationException(AggregationExceptions.TYPE_KEEP_OUT, aggregateId1, contactId2);
+        long contactId1 = queryContactId(rawContactId1);
+        setAggregationException(AggregationExceptions.TYPE_KEEP_OUT, contactId1, rawContactId2);
 
-        long aggregateId2 = queryAggregateId(contactId2);
-        assertSuggestions(aggregateId1, aggregateId2);
+        long contactId2 = queryContactId(rawContactId2);
+        assertSuggestions(contactId1, contactId2);
     }
 
     public void testChoosePhoto() {
-        long contactId1 = createContact();
-        setContactAccountName(contactId1, "donut");
-        long donutId = ContentUris.parseId(insertPhoto(contactId1));
-        long aggregateId = queryAggregateId(contactId1);
+        long rawContactId1 = createRawContact();
+        setContactAccountName(rawContactId1, "donut");
+        long donutId = ContentUris.parseId(insertPhoto(rawContactId1));
+        long contactId = queryContactId(rawContactId1);
 
-        long contactId2 = createContact();
-        setAggregationException(AggregationExceptions.TYPE_KEEP_IN, aggregateId, contactId2);
-        setContactAccountName(contactId2, "cupcake");
-        long cupcakeId = ContentUris.parseId(insertPhoto(contactId2));
+        long rawContactId2 = createRawContact();
+        setAggregationException(AggregationExceptions.TYPE_KEEP_IN, contactId, rawContactId2);
+        setContactAccountName(rawContactId2, "cupcake");
+        long cupcakeId = ContentUris.parseId(insertPhoto(rawContactId2));
 
-        long contactId3 = createContact();
-        setAggregationException(AggregationExceptions.TYPE_KEEP_IN, aggregateId, contactId3);
-        setContactAccountName(contactId3, "flan");
-        long flanId = ContentUris.parseId(insertPhoto(contactId3));
+        long rawContactId3 = createRawContact();
+        setAggregationException(AggregationExceptions.TYPE_KEEP_IN, contactId, rawContactId3);
+        setContactAccountName(rawContactId3, "flan");
+        long flanId = ContentUris.parseId(insertPhoto(rawContactId3));
 
-        assertEquals(cupcakeId, queryPhotoId(queryAggregateId(contactId2)));
+        assertEquals(cupcakeId, queryPhotoId(queryContactId(rawContactId2)));
     }
 
-    private void assertSuggestions(long aggregateId, long... suggestions) {
-        final Uri aggregateUri = ContentUris.withAppendedId(Aggregates.CONTENT_URI, aggregateId);
+    private void assertSuggestions(long contactId, long... suggestions) {
+        final Uri aggregateUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
         Uri uri = Uri.withAppendedPath(aggregateUri,
-                Aggregates.AggregationSuggestions.CONTENT_DIRECTORY);
-        final Cursor cursor = mResolver.query(uri, new String[] { Aggregates._ID },
+                Contacts.AggregationSuggestions.CONTENT_DIRECTORY);
+        final Cursor cursor = mResolver.query(uri, new String[] { Contacts._ID },
                 null, null, null);
 
         assertEquals(suggestions.length, cursor.getCount());
diff --git a/tests/src/com/android/providers/contacts/ContactsActor.java b/tests/src/com/android/providers/contacts/ContactsActor.java
index f18661c..969df7a 100644
--- a/tests/src/com/android/providers/contacts/ContactsActor.java
+++ b/tests/src/com/android/providers/contacts/ContactsActor.java
@@ -29,7 +29,7 @@
 import android.provider.BaseColumns;
 import android.provider.ContactsContract;
 import android.provider.Contacts.Phones;
-import android.provider.ContactsContract.Aggregates;
+import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.CommonDataKinds;
 import android.provider.ContactsContract.RawContacts;
 import android.provider.ContactsContract.Data;
@@ -206,22 +206,22 @@
         throw new UnsupportedOperationException("RestrictionExceptions are hard-coded");
     }
 
-    public long getAggregateForContact(long contactId) {
-        Uri contactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, contactId);
-        final Cursor cursor = resolver.query(contactUri, Projections.PROJ_CONTACTS, null,
+    public long getContactForRawContact(long rawContactId) {
+        Uri contactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId);
+        final Cursor cursor = resolver.query(contactUri, Projections.PROJ_RAW_CONTACTS, null,
                 null, null);
         if (!cursor.moveToFirst()) {
             cursor.close();
             throw new RuntimeException("Contact didn't have an aggregate");
         }
-        final long aggId = cursor.getLong(Projections.COL_CONTACTS_AGGREGATE);
+        final long aggId = cursor.getLong(Projections.COL_CONTACTS_ID);
         cursor.close();
         return aggId;
     }
 
-    public int getDataCountForAggregate(long aggId) {
-        Uri contactUri = Uri.withAppendedPath(ContentUris.withAppendedId(Aggregates.CONTENT_URI,
-                aggId), Aggregates.Data.CONTENT_DIRECTORY);
+    public int getDataCountForContact(long contactId) {
+        Uri contactUri = Uri.withAppendedPath(ContentUris.withAppendedId(Contacts.CONTENT_URI,
+                contactId), Contacts.Data.CONTENT_DIRECTORY);
         final Cursor cursor = resolver.query(contactUri, Projections.PROJ_ID, null, null,
                 null);
         final int count = cursor.getCount();
@@ -237,13 +237,13 @@
         resolver.update(updateUri, values, null, null);
     }
 
-    public long getPrimaryPhoneId(long aggId) {
-        Uri aggUri = ContentUris.withAppendedId(Aggregates.CONTENT_URI, aggId);
-        final Cursor cursor = resolver.query(aggUri, Projections.PROJ_AGGREGATES, null,
+    public long getPrimaryPhoneId(long contactId) {
+        Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
+        final Cursor cursor = resolver.query(contactUri, Projections.PROJ_CONTACTS, null,
                 null, null);
         long primaryPhoneId = -1;
         if (cursor.moveToFirst()) {
-            primaryPhoneId = cursor.getLong(Projections.COL_AGGREGATES_PRIMARY_PHONE_ID);
+            primaryPhoneId = cursor.getLong(Projections.COL_CONTACTS_PRIMARY_PHONE_ID);
         }
         cursor.close();
         return primaryPhoneId;
@@ -278,17 +278,17 @@
 
         static final int COL_ID = 0;
 
+        static final String[] PROJ_RAW_CONTACTS = new String[] {
+                RawContacts.CONTACT_ID
+        };
+
+        static final int COL_CONTACTS_ID = 0;
+
         static final String[] PROJ_CONTACTS = new String[] {
-                RawContacts.AGGREGATE_ID
+                Contacts.PRIMARY_PHONE_ID
         };
 
-        static final int COL_CONTACTS_AGGREGATE = 0;
-
-        static final String[] PROJ_AGGREGATES = new String[] {
-                Aggregates.PRIMARY_PHONE_ID
-        };
-
-        static final int COL_AGGREGATES_PRIMARY_PHONE_ID = 0;
+        static final int COL_CONTACTS_PRIMARY_PHONE_ID = 0;
 
     }
 }
diff --git a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
index 9726a01..ec253c3 100644
--- a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
+++ b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
@@ -24,7 +24,7 @@
 import android.database.Cursor;
 import android.net.Uri;
 import android.os.RemoteException;
-import android.provider.ContactsContract.Aggregates;
+import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.AggregationExceptions;
 import android.provider.ContactsContract.Data;
 import android.provider.ContactsContract.Presence;
@@ -50,7 +50,7 @@
 public class ContactsProvider2Test extends BaseContactsProvider2Test {
 
     public void testDisplayNameParsingWhenPartsUnspecified() {
-        long rawContactId = createContact();
+        long rawContactId = createRawContact();
         ContentValues values = new ContentValues();
         values.put(StructuredName.DISPLAY_NAME, "Mr.John Kevin von Smith, Jr.");
         insertStructuredName(rawContactId, values);
@@ -59,7 +59,7 @@
     }
 
     public void testDisplayNameParsingWhenPartsSpecified() {
-        long rawContactId = createContact();
+        long rawContactId = createRawContact();
         ContentValues values = new ContentValues();
         values.put(StructuredName.DISPLAY_NAME, "Mr.John Kevin von Smith, Jr.");
         values.put(StructuredName.FAMILY_NAME, "Johnson");
@@ -69,87 +69,87 @@
     }
 
     public void testSendToVoicemailDefault() {
-        long rawContactId = createContact();
-        long aggregateId = queryAggregateId(rawContactId);
+        long rawContactId = createRawContact();
+        long contactId = queryContactId(rawContactId);
 
-        Cursor c = queryAggregate(aggregateId);
+        Cursor c = queryContact(contactId);
         assertTrue(c.moveToNext());
-        int sendToVoicemail = c.getInt(c.getColumnIndex(Aggregates.SEND_TO_VOICEMAIL));
+        int sendToVoicemail = c.getInt(c.getColumnIndex(Contacts.SEND_TO_VOICEMAIL));
         assertEquals(0, sendToVoicemail);
         c.close();
     }
 
     public void testSetSendToVoicemailAndRingtone() {
-        long rawContactId = createContact();
-        long aggregateId = queryAggregateId(rawContactId);
+        long rawContactId = createRawContact();
+        long contactId = queryContactId(rawContactId);
 
-        updateSendToVoicemailAndRingtone(aggregateId, true, "foo");
-        assertSendToVoicemailAndRingtone(aggregateId, true, "foo");
+        updateSendToVoicemailAndRingtone(contactId, true, "foo");
+        assertSendToVoicemailAndRingtone(contactId, true, "foo");
     }
 
     public void testSendToVoicemailAndRingtoneAfterAggregation() {
-        long contactId1 = createContact();
-        long aggregateId1 = queryAggregateId(contactId1);
-        updateSendToVoicemailAndRingtone(aggregateId1, true, "foo");
+        long rawContactId1 = createRawContact();
+        long contactId1 = queryContactId(rawContactId1);
+        updateSendToVoicemailAndRingtone(contactId1, true, "foo");
 
-        long contactId2 = createContact();
-        long aggregateId2 = queryAggregateId(contactId2);
-        updateSendToVoicemailAndRingtone(aggregateId2, true, "bar");
+        long rawContactId2 = createRawContact();
+        long contactId2 = queryContactId(rawContactId2);
+        updateSendToVoicemailAndRingtone(contactId2, true, "bar");
 
         // Aggregate them
-        setAggregationException(AggregationExceptions.TYPE_KEEP_IN, aggregateId1, contactId2);
+        setAggregationException(AggregationExceptions.TYPE_KEEP_IN, contactId1, rawContactId2);
 
-        // Both contacts had "send to VM", the aggregate now has the same value
-        assertSendToVoicemailAndRingtone(aggregateId1, true, "foo,bar"); // Either foo or bar
+        // Both contacts had "send to VM", the contact now has the same value
+        assertSendToVoicemailAndRingtone(contactId1, true, "foo,bar"); // Either foo or bar
     }
 
     public void testDoNotSendToVoicemailAfterAggregation() {
-        long contactId1 = createContact();
-        long aggregateId1 = queryAggregateId(contactId1);
-        updateSendToVoicemailAndRingtone(aggregateId1, true, null);
+        long rawContactId1 = createRawContact();
+        long contactId1 = queryContactId(rawContactId1);
+        updateSendToVoicemailAndRingtone(contactId1, true, null);
 
-        long contactId2 = createContact();
-        long aggregateId2 = queryAggregateId(contactId2);
-        updateSendToVoicemailAndRingtone(aggregateId2, false, null);
+        long rawContactId2 = createRawContact();
+        long contactId2 = queryContactId(rawContactId2);
+        updateSendToVoicemailAndRingtone(contactId2, false, null);
 
         // Aggregate them
-        setAggregationException(AggregationExceptions.TYPE_KEEP_IN, aggregateId1, contactId2);
+        setAggregationException(AggregationExceptions.TYPE_KEEP_IN, contactId1, rawContactId2);
 
         // Since one of the contacts had "don't send to VM" that setting wins for the aggregate
-        assertSendToVoicemailAndRingtone(aggregateId1, false, null);
+        assertSendToVoicemailAndRingtone(contactId1, false, null);
     }
 
     public void testSetSendToVoicemailAndRingtonePreservedAfterJoinAndSplit() {
-        long contactId1 = createContact();
-        long aggregateId1 = queryAggregateId(contactId1);
-        updateSendToVoicemailAndRingtone(aggregateId1, true, "foo");
+        long rawContactId1 = createRawContact();
+        long contactId1 = queryContactId(rawContactId1);
+        updateSendToVoicemailAndRingtone(contactId1, true, "foo");
 
-        long contactId2 = createContact();
-        long aggregateId2 = queryAggregateId(contactId2);
-        updateSendToVoicemailAndRingtone(aggregateId2, false, "bar");
+        long rawContactId2 = createRawContact();
+        long contactId2 = queryContactId(rawContactId2);
+        updateSendToVoicemailAndRingtone(contactId2, false, "bar");
 
         // Aggregate them
-        setAggregationException(AggregationExceptions.TYPE_KEEP_IN, aggregateId1, contactId2);
+        setAggregationException(AggregationExceptions.TYPE_KEEP_IN, contactId1, rawContactId2);
 
         // Split them
-        setAggregationException(AggregationExceptions.TYPE_KEEP_OUT, aggregateId1, contactId2);
+        setAggregationException(AggregationExceptions.TYPE_KEEP_OUT, contactId1, rawContactId2);
 
-        assertSendToVoicemailAndRingtone(aggregateId1, true, "foo");
-        assertSendToVoicemailAndRingtone(queryAggregateId(contactId2), false, "bar");
+        assertSendToVoicemailAndRingtone(contactId1, true, "foo");
+        assertSendToVoicemailAndRingtone(queryContactId(rawContactId2), false, "bar");
     }
 
-    public void testSinglePresenceRowPerAggregate() {
+    public void testSinglePresenceRowPerContact() {
         int protocol1 = Im.PROTOCOL_GOOGLE_TALK;
         String handle1 = "test@gmail.com";
 
-        long contactId1 = createContact();
-        insertImHandle(contactId1, protocol1, handle1);
+        long rawContactId1 = createRawContact();
+        insertImHandle(rawContactId1, protocol1, handle1);
 
         insertPresence(protocol1, handle1, Presence.AVAILABLE);
         insertPresence(protocol1, handle1, Presence.AWAY);
         insertPresence(protocol1, handle1, Presence.INVISIBLE);
 
-        Cursor c = queryAggregateSummary(queryAggregateId(contactId1),
+        Cursor c = queryContactSummary(queryContactId(rawContactId1),
                 new String[] {Presence.PRESENCE_STATUS});
         assertEquals(c.getCount(), 1);
 
@@ -158,26 +158,26 @@
 
     }
 
-    private void updateSendToVoicemailAndRingtone(long aggregateId, boolean sendToVoicemail,
+    private void updateSendToVoicemailAndRingtone(long contactId, boolean sendToVoicemail,
             String ringtone) {
         ContentValues values = new ContentValues();
-        values.put(Aggregates.SEND_TO_VOICEMAIL, sendToVoicemail);
+        values.put(Contacts.SEND_TO_VOICEMAIL, sendToVoicemail);
         if (ringtone != null) {
-            values.put(Aggregates.CUSTOM_RINGTONE, ringtone);
+            values.put(Contacts.CUSTOM_RINGTONE, ringtone);
         }
 
-        final Uri uri = ContentUris.withAppendedId(Aggregates.CONTENT_URI, aggregateId);
+        final Uri uri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
         int count = mResolver.update(uri, values, null, null);
         assertEquals(1, count);
     }
 
-    private void assertSendToVoicemailAndRingtone(long aggregateId, boolean expectedSendToVoicemail,
+    private void assertSendToVoicemailAndRingtone(long contactId, boolean expectedSendToVoicemail,
             String expectedRingtone) {
-        Cursor c = queryAggregate(aggregateId);
+        Cursor c = queryContact(contactId);
         assertTrue(c.moveToNext());
-        int sendToVoicemail = c.getInt(c.getColumnIndex(Aggregates.SEND_TO_VOICEMAIL));
+        int sendToVoicemail = c.getInt(c.getColumnIndex(Contacts.SEND_TO_VOICEMAIL));
         assertEquals(expectedSendToVoicemail ? 1 : 0, sendToVoicemail);
-        String ringtone = c.getString(c.getColumnIndex(Aggregates.CUSTOM_RINGTONE));
+        String ringtone = c.getString(c.getColumnIndex(Contacts.CUSTOM_RINGTONE));
         if (expectedRingtone == null) {
             assertNull(ringtone);
         } else {
@@ -187,30 +187,30 @@
     }
 
     public void testGroupCreationAfterMembershipInsert() {
-        long contactId1 = createContact(mAccount);
-        Uri groupMembershipUri = insertGroupMembership(contactId1, "gsid1");
+        long rawContactId1 = createRawContact(mAccount);
+        Uri groupMembershipUri = insertGroupMembership(rawContactId1, "gsid1");
 
         long groupId = assertSingleGroup(NO_LONG, mAccount, "gsid1", null);
         assertSingleGroupMembership(ContentUris.parseId(groupMembershipUri),
-                contactId1, groupId, "gsid1");
+                rawContactId1, groupId, "gsid1");
     }
 
     public void testGroupReuseAfterMembershipInsert() {
-        long contactId1 = createContact(mAccount);
+        long rawContactId1 = createRawContact(mAccount);
         long groupId1 = createGroup(mAccount, "gsid1", "title1");
-        Uri groupMembershipUri = insertGroupMembership(contactId1, "gsid1");
+        Uri groupMembershipUri = insertGroupMembership(rawContactId1, "gsid1");
 
         assertSingleGroup(groupId1, mAccount, "gsid1", "title1");
         assertSingleGroupMembership(ContentUris.parseId(groupMembershipUri),
-                contactId1, groupId1, "gsid1");
+                rawContactId1, groupId1, "gsid1");
     }
 
     public void testGroupInsertFailureOnGroupIdConflict() {
-        long contactId1 = createContact(mAccount);
+        long rawContactId1 = createRawContact(mAccount);
         long groupId1 = createGroup(mAccount, "gsid1", "title1");
 
         ContentValues values = new ContentValues();
-        values.put(GroupMembership.RAW_CONTACT_ID, contactId1);
+        values.put(GroupMembership.RAW_CONTACT_ID, rawContactId1);
         values.put(GroupMembership.MIMETYPE, GroupMembership.CONTENT_ITEM_TYPE);
         values.put(GroupMembership.GROUP_SOURCE_ID, "gsid1");
         values.put(GroupMembership.GROUP_ROW_ID, groupId1);
@@ -229,23 +229,23 @@
         long groupId1 = createGroup(mAccount, "gsid1", "title1");
         long groupId2 = createGroup(mAccount, "gsid2", "title2");
 
-        long c0 = id = createContact(mAccount);
+        long c0 = id = createRawContact(mAccount);
         Uri id_0_0 = insertGroupMembership(id, "gsid1");
         Uri id_0_1 = insertEmail(id, "c0@email.com");
         Uri id_0_2 = insertPhoneNumber(id, "5551212c0");
 
-        long c1 = id = createContact(mAccount);
+        long c1 = id = createRawContact(mAccount);
         Uri id_1_0 = insertGroupMembership(id, "gsid1");
         Uri id_1_1 = insertGroupMembership(id, "gsid2");
         Uri id_1_2 = insertEmail(id, "c1@email.com");
         Uri id_1_3 = insertPhoneNumber(id, "5551212c1");
 
-        long c2 = id = createContact(mAccount);
+        long c2 = id = createRawContact(mAccount);
         Uri id_2_0 = insertGroupMembership(id, "gsid1");
         Uri id_2_1 = insertEmail(id, "c2@email.com");
         Uri id_2_2 = insertPhoneNumber(id, "5551212c2");
 
-        long c3 = id = createContact(mAccount);
+        long c3 = id = createRawContact(mAccount);
         Uri id_3_0 = insertGroupMembership(id, groupId2);
         Uri id_3_1 = insertEmail(id, "c3@email.com");
         Uri id_3_2 = insertPhoneNumber(id, "5551212c3");
@@ -307,7 +307,7 @@
     }
 
     public void testDataCreateUpdateDeleteByMimeType() throws Exception {
-        long rawContactId = createContact();
+        long rawContactId = createRawContact();
 
         ContentValues values = new ContentValues();
         values.put(Data.RAW_CONTACT_ID, rawContactId);
@@ -368,7 +368,7 @@
     }
 
     public void testRawContactDeletion() {
-        long rawContactId = createContact();
+        long rawContactId = createRawContact();
         Uri uri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId);
 
         insertImHandle(rawContactId, Im.PROTOCOL_GOOGLE_TALK, "deleteme@android.com");
@@ -394,15 +394,15 @@
 
     public void testContactDirtySetOnChange() {
         Uri uri = ContentUris.withAppendedId(ContactsContract.RawContacts.CONTENT_URI,
-                createContact(mAccount));
+                createRawContact(mAccount));
         assertDirty(uri, true);
         clearDirty(uri);
         assertDirty(uri, false);
     }
 
     public void testContactDirtyAndVersion() {
-        final long contactId = createContact(mAccount);
-        Uri uri = ContentUris.withAppendedId(ContactsContract.RawContacts.CONTENT_URI, contactId);
+        final long rawContactId = createRawContact(mAccount);
+        Uri uri = ContentUris.withAppendedId(ContactsContract.RawContacts.CONTENT_URI, rawContactId);
         assertDirty(uri, true);
         long version = getVersion(uri);
 
@@ -428,7 +428,7 @@
         ++version;
         assertEquals(version, getVersion(uri));
 
-        Uri emailUri = insertEmail(contactId, "goo@woo.com");
+        Uri emailUri = insertEmail(rawContactId, "goo@woo.com");
         assertDirty(uri, true);
         ++version;
         version = getVersion(uri);
@@ -453,7 +453,7 @@
 
     public void testContactVersionUpdates() {
         Uri uri = ContentUris.withAppendedId(ContactsContract.RawContacts.CONTENT_URI,
-                createContact(mAccount));
+                createRawContact(mAccount));
         long version = getVersion(uri);
         ContentValues values = new ContentValues();
         values.put(ContactsContract.RawContacts.SEND_TO_VOICEMAIL, 1);
diff --git a/tests/src/com/android/providers/contacts/GroupsTest.java b/tests/src/com/android/providers/contacts/GroupsTest.java
index b759a49..38715b5 100644
--- a/tests/src/com/android/providers/contacts/GroupsTest.java
+++ b/tests/src/com/android/providers/contacts/GroupsTest.java
@@ -73,8 +73,8 @@
 
         // Make sure that Charlie was aggregated
         {
-            long aggCharlie = mActor.getAggregateForContact(contactCharlie);
-            long aggCharlieDupe = mActor.getAggregateForContact(contactCharlieDupe);
+            long aggCharlie = mActor.getContactForRawContact(contactCharlie);
+            long aggCharlieDupe = mActor.getContactForRawContact(contactCharlieDupe);
             assertTrue("Didn't aggregate two contacts with identical names",
                     (aggCharlie == aggCharlieDupe));
         }
diff --git a/tests/src/com/android/providers/contacts/RestrictionExceptionsTest.java b/tests/src/com/android/providers/contacts/RestrictionExceptionsTest.java
index e841d90..1263fe7 100644
--- a/tests/src/com/android/providers/contacts/RestrictionExceptionsTest.java
+++ b/tests/src/com/android/providers/contacts/RestrictionExceptionsTest.java
@@ -27,7 +27,7 @@
 import android.net.Uri;
 import android.provider.BaseColumns;
 import android.provider.ContactsContract;
-import android.provider.ContactsContract.Aggregates;
+import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.RawContacts;
 import android.provider.ContactsContract.Data;
 import android.test.AndroidTestCase;
@@ -91,13 +91,13 @@
         // Grey creates an unprotected contact
         long greyContact = mGrey.createContact(false);
         long greyData = mGrey.createPhone(greyContact, PHONE_GREY);
-        long greyAgg = mGrey.getAggregateForContact(greyContact);
+        long greyAgg = mGrey.getContactForRawContact(greyContact);
 
         // Assert that both Grey and Blue can read contact
         assertTrue("Owner of unrestricted contact unable to read",
-                (mGrey.getDataCountForAggregate(greyAgg) == 1));
+                (mGrey.getDataCountForContact(greyAgg) == 1));
         assertTrue("Non-owner of unrestricted contact unable to read",
-                (mBlue.getDataCountForAggregate(greyAgg) == 1));
+                (mBlue.getDataCountForContact(greyAgg) == 1));
 
         // Red grants protected access to itself
         mRed.updateException(PACKAGE_RED, PACKAGE_RED, true);
@@ -105,15 +105,15 @@
         // Red creates a protected contact
         long redContact = mRed.createContact(true);
         long redData = mRed.createPhone(redContact, PHONE_RED);
-        long redAgg = mRed.getAggregateForContact(redContact);
+        long redAgg = mRed.getContactForRawContact(redContact);
 
         // Assert that only Red can read contact
         assertTrue("Owner of restricted contact unable to read",
-                (mRed.getDataCountForAggregate(redAgg) == 1));
+                (mRed.getDataCountForContact(redAgg) == 1));
         assertTrue("Non-owner of restricted contact able to read",
-                (mBlue.getDataCountForAggregate(redAgg) == 0));
+                (mBlue.getDataCountForContact(redAgg) == 0));
         assertTrue("Non-owner of restricted contact able to read",
-                (mGreen.getDataCountForAggregate(redAgg) == 0));
+                (mGreen.getDataCountForContact(redAgg) == 0));
 
         try {
             // Blue tries to grant an exception for Red data, which should throw
@@ -129,28 +129,28 @@
 
         // Both Blue and Red can read Red contact, but still not Green
         assertTrue("Owner of restricted contact unable to read",
-                (mRed.getDataCountForAggregate(redAgg) == 1));
+                (mRed.getDataCountForContact(redAgg) == 1));
         assertTrue("Non-owner with restriction exception unable to read",
-                (mBlue.getDataCountForAggregate(redAgg) == 1));
+                (mBlue.getDataCountForContact(redAgg) == 1));
         assertTrue("Non-owner of restricted contact able to read",
-                (mGreen.getDataCountForAggregate(redAgg) == 0));
+                (mGreen.getDataCountForContact(redAgg) == 0));
 
         // Red revokes exception to Blue
         mRed.updateException(PACKAGE_RED, PACKAGE_BLUE, false);
 
         // Assert that only Red can read contact
         assertTrue("Owner of restricted contact unable to read",
-                (mRed.getDataCountForAggregate(redAgg) == 1));
+                (mRed.getDataCountForContact(redAgg) == 1));
         assertTrue("Non-owner of restricted contact able to read",
-                (mBlue.getDataCountForAggregate(redAgg) == 0));
+                (mBlue.getDataCountForContact(redAgg) == 0));
         assertTrue("Non-owner of restricted contact able to read",
-                (mGreen.getDataCountForAggregate(redAgg) == 0));
+                (mGreen.getDataCountForContact(redAgg) == 0));
 
     }
 
     /**
      * Create an aggregate that has multiple contacts with various levels of
-     * protected data, and ensure that {@link Aggregates#CONTENT_SUMMARY_URI}
+     * protected data, and ensure that {@link Contacts#CONTENT_SUMMARY_URI}
      * details don't expose {@link Contacts#IS_RESTRICTED} data.
      */
     public void __testAggregateSummary() {
@@ -179,8 +179,8 @@
         // Make sure both aggregates were joined
         long singleAgg;
         {
-            long redAgg = mRed.getAggregateForContact(redContact);
-            long blueAgg = mBlue.getAggregateForContact(blueContact);
+            long redAgg = mRed.getContactForRawContact(redContact);
+            long blueAgg = mBlue.getContactForRawContact(blueContact);
             assertTrue("Two contacts with identical name not aggregated correctly",
                     (redAgg == blueAgg));
             singleAgg = redAgg;
@@ -208,9 +208,9 @@
 
         // Make sure all three aggregates were joined
         {
-            long redAgg = mRed.getAggregateForContact(redContact);
-            long blueAgg = mBlue.getAggregateForContact(blueContact);
-            long greyAgg = mGrey.getAggregateForContact(greyContact);
+            long redAgg = mRed.getContactForRawContact(redContact);
+            long blueAgg = mBlue.getContactForRawContact(blueContact);
+            long greyAgg = mGrey.getContactForRawContact(greyContact);
             assertTrue("Three contacts with identical name not aggregated correctly",
                     (redAgg == blueAgg) && (blueAgg == greyAgg));
             singleAgg = redAgg;
@@ -244,11 +244,11 @@
         // Green creates a protected contact
         long greenContact = mGreen.createContact(true);
         long greenData = mGreen.createPhone(greenContact, PHONE_GREEN);
-        long greenAgg = mGreen.getAggregateForContact(greenContact);
+        long greenAgg = mGreen.getContactForRawContact(greenContact);
 
         // AGGREGATES
         cursor = mRed.resolver
-                .query(Aggregates.CONTENT_URI, Projections.PROJ_ID, null, null, null);
+                .query(Contacts.CONTENT_URI, Projections.PROJ_ID, null, null, null);
         while (cursor.moveToNext()) {
             assertTrue("Discovered restricted contact",
                     (cursor.getLong(Projections.COL_ID) != greenAgg));
@@ -256,20 +256,20 @@
         cursor.close();
 
         // AGGREGATES_ID
-        cursor = mRed.resolver.query(ContentUris.withAppendedId(Aggregates.CONTENT_URI, greenAgg),
+        cursor = mRed.resolver.query(ContentUris.withAppendedId(Contacts.CONTENT_URI, greenAgg),
                 Projections.PROJ_ID, null, null, null);
         assertTrue("Discovered restricted contact", (cursor.getCount() == 0));
         cursor.close();
 
         // AGGREGATES_DATA
         cursor = mRed.resolver.query(Uri.withAppendedPath(ContentUris.withAppendedId(
-                Aggregates.CONTENT_URI, greenAgg), Aggregates.Data.CONTENT_DIRECTORY),
+                Contacts.CONTENT_URI, greenAgg), Contacts.Data.CONTENT_DIRECTORY),
                 Projections.PROJ_ID, null, null, null);
         assertTrue("Discovered restricted contact", (cursor.getCount() == 0));
         cursor.close();
 
         // AGGREGATES_SUMMARY
-        cursor = mRed.resolver.query(Aggregates.CONTENT_SUMMARY_URI, Projections.PROJ_ID, null,
+        cursor = mRed.resolver.query(Contacts.CONTENT_SUMMARY_URI, Projections.PROJ_ID, null,
                 null, null);
         while (cursor.moveToNext()) {
             assertTrue("Discovered restricted contact",
@@ -278,7 +278,7 @@
         cursor.close();
 
         // AGGREGATES_SUMMARY_ID
-        cursor = mRed.resolver.query(ContentUris.withAppendedId(Aggregates.CONTENT_SUMMARY_URI,
+        cursor = mRed.resolver.query(ContentUris.withAppendedId(Contacts.CONTENT_SUMMARY_URI,
                 greenAgg), Projections.PROJ_ID, null, null, null);
         assertTrue("Discovered restricted contact", (cursor.getCount() == 0));
         cursor.close();