Fix data update/delete URIs for profiles.

    If the contact update being performed is in the scope of a profile
    contact, the base URI for data operations must also be a profile
    URI.

    Bug 5249062
    Bug 5201592

Change-Id: I19197b338745cf8748339c650c958ba22f580620
diff --git a/src/com/android/contacts/model/EntityDelta.java b/src/com/android/contacts/model/EntityDelta.java
index a045eb4..8244e9c 100644
--- a/src/com/android/contacts/model/EntityDelta.java
+++ b/src/com/android/contacts/model/EntityDelta.java
@@ -414,7 +414,14 @@
                 // Ignore children if parent was deleted
                 if (isContactDelete) continue;
 
-                builder = child.buildDiff(Data.CONTENT_URI);
+                // Use the profile data URI if the contact is the profile.
+                if (mContactsQueryUri.equals(Profile.CONTENT_RAW_CONTACTS_URI)) {
+                    builder = child.buildDiff(Uri.withAppendedPath(Profile.CONTENT_URI,
+                            RawContacts.Data.CONTENT_DIRECTORY));
+                } else {
+                    builder = child.buildDiff(Data.CONTENT_URI);
+                }
+
                 if (child.isInsert()) {
                     if (isContactInsert) {
                         // Parent is brand new insert, so back-reference _id