Don't show aggregation suggestion for new me contacts

Bug 23353464

Change-Id: Ifb63c73b59153ff7bdc26b3f4f471d3521bed0b2
diff --git a/src/com/android/contacts/editor/CompactContactEditorFragment.java b/src/com/android/contacts/editor/CompactContactEditorFragment.java
index 656c5ae..3a062cf 100644
--- a/src/com/android/contacts/editor/CompactContactEditorFragment.java
+++ b/src/com/android/contacts/editor/CompactContactEditorFragment.java
@@ -363,8 +363,8 @@
 
         // Prepare an Intent to start the expanded editor
         final Intent intent = isInsert
-                ? EditorIntents.createInsertContactIntent(
-                        mState, getDisplayName(), getPhoneticName(), mUpdatedPhotos)
+                ? EditorIntents.createInsertContactIntent(mState, getDisplayName(),
+                        getPhoneticName(), mUpdatedPhotos, mNewLocalProfile)
                 : EditorIntents.createEditContactIntent(mLookupUri, getMaterialPalette(),
                         mPhotoId, mNameId);
         ImplicitIntentsUtil.startActivityInApp(getActivity(), intent);
diff --git a/src/com/android/contacts/editor/ContactEditorBaseFragment.java b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
index 18b1381..c030509 100644
--- a/src/com/android/contacts/editor/ContactEditorBaseFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
@@ -964,7 +964,7 @@
             // If we're coming back from the fully expanded editor and this is an insert, just
             // pass any values entered by the user back to the compact editor without doing a save
             final Intent resultIntent = EditorIntents.createCompactInsertContactIntent(
-                    mState, getDisplayName(), getPhoneticName(), mUpdatedPhotos);
+                    mState, getDisplayName(), getPhoneticName(), mUpdatedPhotos, mNewLocalProfile);
             resultIntent.putExtra(INTENT_EXTRA_SAVE_BACK_PRESSED, backPressed);
             mListener.onSaveFinished(resultIntent);
             return true;
@@ -1117,7 +1117,7 @@
                 mListener.onCustomCreateContactActivityRequested(account, mIntentExtras);
             }
         } else {
-            setStateForNewContact(account, accountType);
+            setStateForNewContact(account, accountType, isEditingUserProfile());
         }
     }
 
@@ -1194,9 +1194,10 @@
     /**
      * Prepare {@link #mState} for a newly created phone-local contact.
      */
-    private void setStateForNewContact(AccountWithDataSet account, AccountType accountType) {
-        setStateForNewContact(account, accountType,
-                /* oldState =*/ null, /* oldAccountType =*/ null);
+    private void setStateForNewContact(AccountWithDataSet account, AccountType accountType,
+            boolean isUserProfile) {
+        setStateForNewContact(account, accountType, /* oldState =*/ null,
+                /* oldAccountType =*/ null, isUserProfile);
     }
 
     /**
@@ -1204,9 +1205,10 @@
      * specified by oldState and oldAccountType.
      */
     protected void setStateForNewContact(AccountWithDataSet account, AccountType accountType,
-            RawContactDelta oldState, AccountType oldAccountType) {
+            RawContactDelta oldState, AccountType oldAccountType, boolean isUserProfile) {
         mStatus = Status.EDITING;
         mState.add(createNewRawContactDelta(account, accountType, oldState, oldAccountType));
+        mIsUserProfile = isUserProfile;
         mNewContactDataReady = true;
         bindEditors();
     }
@@ -1442,7 +1444,8 @@
                             mContext, contactLookupUri, mLookupUri);
                     final Intent resultIntent = isInsert(getActivity().getIntent())
                             ? EditorIntents.createCompactInsertContactIntent(
-                                    mState, getDisplayName(), getPhoneticName(), updatedPhotos)
+                                    mState, getDisplayName(), getPhoneticName(), updatedPhotos,
+                                    mNewLocalProfile)
                             : EditorIntents.createCompactEditContactIntent(
                                     lookupUri, getMaterialPalette(), updatedPhotos, photoId,
                                     nameId);
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index 4da17fa..b29ad30 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -166,9 +166,11 @@
             mExistingContactDataReady = false;
             mNewContactDataReady = false;
             mState = new RawContactDeltaList();
-            setStateForNewContact(newAccount, newAccountType, oldState, oldAccountType);
+            setStateForNewContact(newAccount, newAccountType, oldState, oldAccountType,
+                    isEditingUserProfile());
             if (mIsEdit) {
-                setStateForExistingContact(mReadOnlyDisplayName, mIsUserProfile, mRawContacts);
+                setStateForExistingContact(mReadOnlyDisplayName, isEditingUserProfile(),
+                        mRawContacts);
             }
         }
     }
@@ -300,7 +302,7 @@
 
                 rawContactEditor.setAutoAddToDefaultGroup(mAutoAddToDefaultGroup);
 
-                if (isAggregationSuggestionRawContactId(rawContactId)) {
+                if (!isEditingUserProfile() && isAggregationSuggestionRawContactId(rawContactId)) {
                     acquireAggregationSuggestions(activity,
                             rawContactEditor.getNameEditor().getRawContactId(),
                             rawContactEditor.getNameEditor().getValues());
diff --git a/src/com/android/contacts/editor/EditorIntents.java b/src/com/android/contacts/editor/EditorIntents.java
index a3c29fc..68ce76f 100644
--- a/src/com/android/contacts/editor/EditorIntents.java
+++ b/src/com/android/contacts/editor/EditorIntents.java
@@ -58,7 +58,8 @@
      */
     public static Intent createCompactInsertContactIntent() {
         return createCompactInsertContactIntent(/* rawContactDeltaList =*/ null,
-                /* displayName =*/ null, /* phoneticName =*/ null, /* updatedPhotos =*/ null);
+                /* displayName =*/ null, /* phoneticName =*/ null, /* updatedPhotos =*/ null,
+                /* isNewLocalProfile =*/ false);
     }
 
     /**
@@ -66,8 +67,10 @@
      * the field values specified by rawContactDeltaList pre-populate in the form.
      */
     public static Intent createCompactInsertContactIntent(RawContactDeltaList rawContactDeltaList,
-            String displayName, String phoneticName, Bundle updatedPhotos) {
+            String displayName, String phoneticName, Bundle updatedPhotos,
+            boolean isNewLocalProfile) {
         final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
+        intent.putExtra(ContactEditorFragment.INTENT_EXTRA_NEW_LOCAL_PROFILE, isNewLocalProfile);
         if (rawContactDeltaList != null || displayName != null || phoneticName != null) {
             putRawContactDeltaValues(intent, rawContactDeltaList, displayName, phoneticName);
         }
@@ -112,9 +115,11 @@
      * existing contact.
      */
     public static Intent createInsertContactIntent(RawContactDeltaList rawContactDeltaList,
-            String displayName, String phoneticName, Bundle updatedPhotos) {
+            String displayName, String phoneticName, Bundle updatedPhotos,
+            boolean isNewLocalProfile) {
         final Intent intent = new Intent(ContactEditorBaseActivity.ACTION_INSERT,
                 Contacts.CONTENT_URI);
+        intent.putExtra(ContactEditorFragment.INTENT_EXTRA_NEW_LOCAL_PROFILE, isNewLocalProfile);
         addContactIntentFlags(intent);
         putRawContactDeltaValues(intent, rawContactDeltaList, displayName, phoneticName);
         putUpdatedPhotos(intent, updatedPhotos);