From c8dd93d4c8b3f673c0eb739e8622de4d906b3204 Mon Sep 17 00:00:00 2001 From: Renat Aksitov Date: Sun, 1 May 2016 16:31:28 -0700 Subject: [PATCH] Voice Messaging Intent API. Adding missing items about MIME type and account type to the "integration with the Contacts Provider" section. Bug 28295510 Change-Id: I890458e62a714519be70e930fd53315c141ba354 --- api/current.txt | 2 + api/system-current.txt | 2 + api/test-current.txt | 2 + .../android/provider/ContactsContract.java | 58 +++++++++++++++---- 4 files changed, 52 insertions(+), 12 deletions(-) diff --git a/api/current.txt b/api/current.txt index 5e4b2d4eb958e..8a7677a2c7646 100644 --- a/api/current.txt +++ b/api/current.txt @@ -31692,6 +31692,8 @@ package android.provider { field public static final java.lang.String EXTRA_RECIPIENT_CONTACT_NAME = "android.provider.extra.RECIPIENT_CONTACT_NAME"; field public static final java.lang.String EXTRA_RECIPIENT_CONTACT_URI = "android.provider.extra.RECIPIENT_CONTACT_URI"; field public static final java.lang.String INVITE_CONTACT = "com.android.contacts.action.INVITE_CONTACT"; + field public static final java.lang.String METADATA_ACCOUNT_TYPE = "android.provider.account_type"; + field public static final java.lang.String METADATA_MIMETYPE = "android.provider.mimetype"; field public static final java.lang.String SEARCH_SUGGESTION_CLICKED = "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; field public static final java.lang.String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; field public static final java.lang.String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; diff --git a/api/system-current.txt b/api/system-current.txt index bde3a8cd7bb19..6b3d09f7dcdb4 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -34260,6 +34260,8 @@ package android.provider { field public static final java.lang.String EXTRA_RECIPIENT_CONTACT_NAME = "android.provider.extra.RECIPIENT_CONTACT_NAME"; field public static final java.lang.String EXTRA_RECIPIENT_CONTACT_URI = "android.provider.extra.RECIPIENT_CONTACT_URI"; field public static final java.lang.String INVITE_CONTACT = "com.android.contacts.action.INVITE_CONTACT"; + field public static final java.lang.String METADATA_ACCOUNT_TYPE = "android.provider.account_type"; + field public static final java.lang.String METADATA_MIMETYPE = "android.provider.mimetype"; field public static final java.lang.String SEARCH_SUGGESTION_CLICKED = "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; field public static final java.lang.String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; field public static final java.lang.String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; diff --git a/api/test-current.txt b/api/test-current.txt index 91415066a3dfd..fbf67ecd151d7 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -31764,6 +31764,8 @@ package android.provider { field public static final java.lang.String EXTRA_RECIPIENT_CONTACT_NAME = "android.provider.extra.RECIPIENT_CONTACT_NAME"; field public static final java.lang.String EXTRA_RECIPIENT_CONTACT_URI = "android.provider.extra.RECIPIENT_CONTACT_URI"; field public static final java.lang.String INVITE_CONTACT = "com.android.contacts.action.INVITE_CONTACT"; + field public static final java.lang.String METADATA_ACCOUNT_TYPE = "android.provider.account_type"; + field public static final java.lang.String METADATA_MIMETYPE = "android.provider.mimetype"; field public static final java.lang.String SEARCH_SUGGESTION_CLICKED = "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; field public static final java.lang.String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; field public static final java.lang.String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java index 3658df9a84434..8658d137c7bba 100644 --- a/core/java/android/provider/ContactsContract.java +++ b/core/java/android/provider/ContactsContract.java @@ -8759,21 +8759,34 @@ public final class ContactsContract { * android.service.voice.VoiceInteractionSession#startVoiceActivity}. *

* When the action was not initiated by Voice Assistant or when the receiving activity does - * not support {@link android.content.Intent#CATEGORY_VOICE}, the activity should confirm + * not support {@link android.content.Intent#CATEGORY_VOICE}, the activity must confirm * with the user before sending the message (because in this case it is unknown which app * sent the intent, it could be malicious). *

* To allow the Voice Assistant to help users with contacts disambiguation, the messaging - * app may choose to integrate with the Contacts Provider. The following convention should - * be met when creating Data table for such integration: + * app may choose to integrate with the Contacts Provider. You will need to specify a new + * MIME type in order to store your app’s unique contact IDs and optional human readable + * labels in the Data table. The Voice Assistant needs to know this MIME type and {@link + * RawContacts#ACCOUNT_TYPE} that you are using in order to provide the smooth contact + * disambiguation user experience. The following convention should be met when performing + * such integration: *

+ * If the app chooses not to integrate with the Contacts Provider (in particular, when + * either METADATA_ACCOUNT_TYPE or METADATA_MIMETYPE field is missing), Voice Assistant + * will use existing phone number entries as contact ID's for such app. *

* Input: {@link android.content.Intent#getType} is the MIME type of the data being sent. * The intent sender will always put the concrete mime type in the intent type, like @@ -8814,6 +8830,8 @@ public final class ContactsContract { * @see #EXTRA_RECIPIENT_CONTACT_URI * @see #EXTRA_RECIPIENT_CONTACT_CHAT_ID * @see #EXTRA_RECIPIENT_CONTACT_NAME + * @see #METADATA_ACCOUNT_TYPE + * @see #METADATA_MIMETYPE */ public static final String ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS = "android.provider.action.VOICE_SEND_MESSAGE_TO_CONTACTS"; @@ -8845,8 +8863,10 @@ public final class ContactsContract { * recipient is absent, it will be set to null. *

* The value of the elements comes from the {@link DataColumns#DATA1} column in Contacts - * Provider, and should be the unambiguous contact endpoint. This value is app-specific, it - * could be a phone number or some proprietary ID. + * Provider with {@link DataColumns#MIMETYPE} from {@link #METADATA_MIMETYPE} (if both + * {@link #METADATA_ACCOUNT_TYPE} and {@link #METADATA_MIMETYPE} are specified by the app; + * otherwise, the value will be a phone number), and should be the unambiguous contact + * endpoint. This value is app-specific, it could be some proprietary ID or a phone number. */ public static final String EXTRA_RECIPIENT_CONTACT_CHAT_ID = "android.provider.extra.RECIPIENT_CONTACT_CHAT_ID"; @@ -8866,6 +8886,20 @@ public final class ContactsContract { public static final String EXTRA_RECIPIENT_CONTACT_NAME = "android.provider.extra.RECIPIENT_CONTACT_NAME"; + /** + * A string associated with an {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} activity + * describing {@link RawContacts#ACCOUNT_TYPE} for the corresponding Contacts Provider + * implementation. + */ + public static final String METADATA_ACCOUNT_TYPE = "android.provider.account_type"; + + /** + * A string associated with an {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} activity + * describing {@link DataColumns#MIMETYPE} for the corresponding Contacts Provider + * implementation. + */ + public static final String METADATA_MIMETYPE = "android.provider.mimetype"; + /** * Starts an Activity that lets the user select the multiple phones from a * list of phone numbers which come from the contacts or