Introducing the notion of "verified name" on a raw contact.

This flag can be set by a sync adapter if it is certain that the
name is correct (a social network sync adapter would be a good example
of this).  It can also be explicitly set by the user in the Contact
Edit UI.

Bug: 2164422
Change-Id: Id46e04c28eeb0dc386adfc6ad8988dda50824e2b
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 5819b59..16746d4 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -1102,6 +1102,33 @@
          * <P>Type: INTEGER</P>
          */
         public static final String DELETED = "deleted";
+
+        /**
+         * The "name_verified" flag: "1" means that the name fields on this raw
+         * contact can be trusted and therefore should be used for the entire
+         * aggregated contact.
+         * <p>
+         * If an aggregated contact contains more than one raw contact with a
+         * verified name, one of those verified names is chosen at random.
+         * If an aggregated contact contains no verified names, the
+         * name is chosen randomly from the constituent raw contacts.
+         * </p>
+         * <p>
+         * Updating this flag from "0" to "1" automatically resets it to "0" on
+         * all other raw contacts in the same aggregated contact.
+         * </p>
+         * <p>
+         * Sync adapters should only specify a value for this column when
+         * inserting a raw contact and leave it out when doing an update.
+         * </p>
+         * <p>
+         * The default value is "0"
+         * </p>
+         * <p>Type: INTEGER</p>
+         *
+         * @hide
+         */
+        public static final String NAME_VERIFIED = "name_verified";
     }
 
     /**
@@ -1673,6 +1700,7 @@
                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID);
                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED);
                 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, IS_RESTRICTED);
+                DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, NAME_VERIFIED);
                 android.content.Entity contact = new android.content.Entity(cv);
 
                 // read data rows until the contact id changes