Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 20f14386 authored by Tingting Wang's avatar Tingting Wang
Browse files

Add MetadataSync table to ContactsContract.

Sync adapter will modify MetadataSync table to cache the metadata_sync
data from server before it is merged into other CP2 tables.

BUG 20055193

Change-Id: I19d31fc19204444432212cc14c9650d41e075648
parent 34ea2cc2
Loading
Loading
Loading
Loading
+143 −1
Original line number Diff line number Diff line
@@ -2201,7 +2201,6 @@ public final class ContactsContract {
        public static final long DAYS_KEPT_MILLISECONDS = 1000L * 60L * 60L * 24L * (long)DAYS_KEPT;
    }


    protected interface RawContactsColumns {
        /**
         * A reference to the {@link ContactsContract.Contacts#_ID} that this
@@ -8921,4 +8920,147 @@ public final class ContactsContract {
            public static final String EXTRA_DATA_SET = "android.provider.extra.DATA_SET";
        }
    }

    /**
     * @hide
     */
    protected interface MetadataSyncColumns {

        /**
         * The raw contact backup id.
         * A reference to the {@link ContactsContract.RawContacts#BACKUP_ID} that save the
         * persistent unique id for each raw contact within its source system.
         *
         * @hide
         */
        public static final String RAW_CONTACT_BACKUP_ID = "raw_contact_backup_id";

        /**
         * The account type to which the raw_contact of this item is associated. See
         * {@link RawContacts#ACCOUNT_TYPE}
         *
         * @hide
         */
        public static final String ACCOUNT_TYPE = "account_type";

        /**
         * The account name to which the raw_contact of this item is associated. See
         * {@link RawContacts#ACCOUNT_NAME}
         *
         * @hide
         */
        public static final String ACCOUNT_NAME = "account_name";

        /**
         * The data set within the account that the raw_contact of this row belongs to. This allows
         * multiple sync adapters for the same account type to distinguish between
         * each others' data.
         * {@link RawContacts#DATA_SET}
         *
         * @hide
         */
        public static final String DATA_SET = "data_set";

        /**
         * A text column contains the Json string got from People API. The Json string contains
         * all the metadata related to the raw contact, i.e., all the data fields and
         * aggregation exceptions.
         *
         * Here is an example of the Json string got from the actual schema.
         * <pre>
         *     {
         *       "unique_contact_id": {
         *         "account_type": "CUSTOM_ACCOUNT",
         *         "custom_account_type": "facebook",
         *         "account_name": "android-test",
         *         "contact_id": "1111111",
         *         "data_set": "FOCUS"
         *       },
         *       "contact_prefs": {
         *         "send_to_voicemail": true,
         *         "starred": false,
         *         "pinned": 2
         *       },
         *       "aggregation_data": [
         *         {
         *           "type": "TOGETHER",
         *           "contact_ids": [
         *             {
         *               "account_type": "GOOGLE_ACCOUNT",
         *               "account_name": "android-test2",
         *               "contact_id": "2222222",
         *               "data_set": "GOOGLE_PLUS"
         *             },
         *             {
         *               "account_type": "GOOGLE_ACCOUNT",
         *               "account_name": "android-test3",
         *               "contact_id": "3333333",
         *               "data_set": "CUSTOM",
         *               "custom_data_set": "custom type"
         *             }
         *           ]
         *         }
         *       ],
         *       "field_data": [
         *         {
         *           "field_data_id": "1001",
         *           "field_data_prefs": {
         *             "is_primary": true,
         *             "is_super_primary": true
         *           },
         *           "usage_stats": [
         *             {
         *               "usage_type": "CALL",
         *               "last_time_used": 10000001,
         *               "usage_count": 10
         *             }
         *           ]
         *         }
         *       ]
         *     }
         * </pre>
         *
         * @hide
         */
        public static final String DATA = "data";

        /**
         * The "deleted" flag: "0" by default, "1" if the row has been marked
         * for deletion. When {@link android.content.ContentResolver#delete} is
         * called on a raw contact, updating MetadataSync table to set the flag of the raw contact
         * as "1", then metadata sync adapter deletes the raw contact metadata on the server.
         * <P>Type: INTEGER</P>
         *
         * @hide
         */
        public static final String DELETED = "deleted";
    }

    /**
     * Constants for the metadata sync table. This table is used to cache the metadata_sync data
     * from server before it is merged into other CP2 tables.
     *
     * @hide
     */
    public static final class MetadataSync implements BaseColumns, MetadataSyncColumns {

        /** The authority for the contacts metadata */
        public static final String METADATA_AUTHORITY = "com.android.contacts.metadata";

        /** A content:// style uri to the authority for the contacts metadata */
        public static final Uri METADATA_AUTHORITY_URI = Uri.parse(
                "content://" + METADATA_AUTHORITY);

        /**
         * This utility class cannot be instantiated
         */
        private MetadataSync() {
        }

        /**
         * The content:// style URI for this table.
         */
        public static final Uri CONTENT_URI = Uri.withAppendedPath(METADATA_AUTHORITY_URI,
                "metadata_sync");
    }
}