VoicemailContract.java revision 73f0a3a6bde168524a5f3c7ac31ba372174940e7
1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16package android.provider; 17 18import android.content.Intent; 19import android.database.ContentObserver; 20import android.net.Uri; 21import android.provider.CallLog.Calls; 22 23/** 24 * The contract between the voicemail provider and applications. Contains 25 * definitions for the supported URIs and columns. 26 * 27 * <P>Voicemails are inserted by what is called as a "voicemail source" 28 * application, which is responsible for syncing voicemail data between a remote 29 * server and the local voicemail content provider. "voicemail source" 30 * application should use the source specific {@link #CONTENT_URI_SOURCE} URI 31 * to insert and retrieve voicemails. 32 * 33 * <P>In addition to the {@link ContentObserver} notifications the voicemail 34 * provider also generates broadcast intents to notify change for applications 35 * that are not active and therefore cannot listen to ContentObserver 36 * notifications. Broadcast intents with following actions are generated: 37 * <ul> 38 * <li> {@link #ACTION_NEW_VOICEMAIL} is generated for each new voicemail 39 * inserted. 40 * </li> 41 * <li> {@link Intent#ACTION_PROVIDER_CHANGED} is generated for any change 42 * made into the database, including new voicemail. 43 * </li> 44 * </ul> 45 * @hide 46 */ 47// TODO: unhide when the API is approved by android-api-council 48public class VoicemailContract { 49 /** Not instantiable. */ 50 private VoicemailContract() { 51 } 52 53 /** The authority used by the voicemail provider. */ 54 public static final String AUTHORITY = "com.android.voicemail"; 55 /** URI to insert/retrieve all voicemails. */ 56 public static final Uri CONTENT_URI = 57 Uri.parse("content://" + AUTHORITY + "/voicemail"); 58 /** URI to insert/retrieve voicemails by a given voicemail source. */ 59 public static final Uri CONTENT_URI_SOURCE = 60 Uri.parse("content://" + AUTHORITY + "/voicemail/source/"); 61 /** URI to insert/retrieve status of voicemail source. */ 62 public static final Uri STATUS_CONTENT_URI = 63 Uri.parse("content://" + AUTHORITY + "/status"); 64 /** 65 * Parameter key used in the URI to specify the voicemail source package name. 66 * <p> This field must be set in all requests that originate from a voicemail source. 67 */ 68 public static final String PARAM_KEY_SOURCE_PACKAGE = "source_package"; 69 70 // TODO: Move ACTION_NEW_VOICEMAIL to the Intent class. 71 /** Broadcast intent when a new voicemail record is inserted. */ 72 public static final String ACTION_NEW_VOICEMAIL = "android.intent.action.NEW_VOICEMAIL"; 73 /** 74 * Extra included in {@value Intent#ACTION_PROVIDER_CHANGED} and 75 * {@value #ACTION_NEW_VOICEMAIL} broadcast intents to indicate if the receiving 76 * package made this change. 77 */ 78 public static final String EXTRA_SELF_CHANGE = "com.android.voicemail.extra.SELF_CHANGE"; 79 80 /** The mime type for a collection of voicemails. */ 81 public static final String DIR_TYPE = "vnd.android.cursor.dir/voicemails"; 82 83 /** 84 * A convenience method to build voicemail URI specific to a source package. Appends URI param 85 * {@link #PARAM_KEY_SOURCE_PACKAGE} to the base voicemail content URI. 86 */ 87 public static Uri buildSourceVoicemailUri(String packageName) { 88 return CONTENT_URI.buildUpon() 89 .appendQueryParameter(PARAM_KEY_SOURCE_PACKAGE, packageName).build(); 90 } 91 92 /** 93 * A convenience method to build status URI specific to a source package. Appends URI param 94 * {@link #PARAM_KEY_SOURCE_PACKAGE} to the base status content URI. 95 */ 96 public static Uri buildSourceStatusUri(String packageName) { 97 return STATUS_CONTENT_URI.buildUpon() 98 .appendQueryParameter(PARAM_KEY_SOURCE_PACKAGE, packageName).build(); 99 } 100 101 /** Defines fields exposed through the /voicemail path of this content provider. */ 102 public static final class Voicemails implements BaseColumns { 103 /** Not instantiable. */ 104 private Voicemails() { 105 } 106 107 /** 108 * Phone number of the voicemail sender. 109 * <P>Type: TEXT</P> 110 */ 111 public static final String NUMBER = Calls.NUMBER; 112 /** 113 * The date the voicemail was sent, in milliseconds since the epoch 114 * <P>Type: INTEGER (long)</P> 115 */ 116 public static final String DATE = Calls.DATE; 117 /** 118 * The duration of the voicemail in seconds. 119 * <P>Type: INTEGER (long)</P> 120 */ 121 public static final String DURATION = Calls.DURATION; 122 /** 123 * Whether this is a new voicemail (i.e. has not been heard). 124 * <P>Type: INTEGER (boolean)</P> 125 */ 126 public static final String NEW = Calls.NEW; 127 /** 128 * The mail box state of the voicemail. 129 * <P> Possible values: {@link #STATE_INBOX}, {@link #STATE_DELETED}, 130 * {@link #STATE_UNDELETED}. 131 * <P>Type: INTEGER</P> 132 */ 133 public static final String STATE = "state"; 134 /** Value of {@link #STATE} when the voicemail is in inbox. */ 135 public static int STATE_INBOX = 0; 136 /** Value of {@link #STATE} when the voicemail has been marked as deleted. */ 137 public static int STATE_DELETED = 1; 138 /** Value of {@link #STATE} when the voicemail has marked as undeleted. */ 139 public static int STATE_UNDELETED = 2; 140 /** 141 * Package name of the source application that inserted the voicemail. 142 * <P>Type: TEXT</P> 143 */ 144 public static final String SOURCE_PACKAGE = "source_package"; 145 /** 146 * Application-specific data available to the source application that 147 * inserted the voicemail. This is typically used to store the source 148 * specific message id to identify this voicemail on the remote 149 * voicemail server. 150 * <P>Type: TEXT</P> 151 * <P> Note that this is NOT the voicemail media content data. 152 */ 153 public static final String SOURCE_DATA = "source_data"; 154 /** 155 * Whether the media content for this voicemail is available for 156 * consumption. 157 * <P>Type: INTEGER (boolean)</P> 158 */ 159 public static final String HAS_CONTENT = "has_content"; 160 /** 161 * MIME type of the media content for the voicemail. 162 * <P>Type: TEXT</P> 163 */ 164 public static final String MIME_TYPE = "mime_type"; 165 /** 166 * Path to the media content file. Internal only field. 167 * @hide 168 */ 169 public static final String _DATA = "_data"; 170 } 171 172 /** Defines fields exposed through the /status path of this content provider. */ 173 public static final class Status implements BaseColumns { 174 /** Not instantiable. */ 175 private Status() { 176 } 177 /** 178 * The package name of the voicemail source. There can only be a one entry per source. 179 * <P>Type: TEXT</P> 180 */ 181 public static final String SOURCE_PACKAGE = "source_package"; 182 /** 183 * The URI to call to invoke source specific voicemail settings screen. On a user request 184 * to setup voicemail an intent with action VIEW with this URI will be fired by the system. 185 * <P>Type: TEXT</P> 186 */ 187 public static final String SETTINGS_URI = "settings_uri"; 188 /** 189 * The URI to call when the user requests to directly access the voicemail from the remote 190 * server. In case of an IVR voicemail system this is typically set to the the voicemail 191 * number specified using a tel:/ URI. 192 * <P>Type: TEXT</P> 193 */ 194 public static final String VOICEMAIL_ACCESS_URI = "voicemail_access_uri"; 195 /** 196 * The configuration state of the voicemail source. 197 * <P> Possible values: 198 * {@link #CONFIGURATION_STATE_OK}, 199 * {@link #CONFIGURATION_STATE_NOT_CONFIGURED}, 200 * {@link #CONFIGURATION_STATE_CAN_BE_CONFIGURED} 201 * <P>Type: INTEGER</P> 202 */ 203 public static final String CONFIGURATION_STATE = "configuration_state"; 204 public static final int CONFIGURATION_STATE_OK = 0; 205 public static final int CONFIGURATION_STATE_NOT_CONFIGURED = 1; 206 /** 207 * This state must be used when the source has verified that the current user can be 208 * upgraded to visual voicemail and would like to show a set up invitation message. 209 */ 210 public static final int CONFIGURATION_STATE_CAN_BE_CONFIGURED = 2; 211 /** 212 * The data channel state of the voicemail source. This the channel through which the source 213 * pulls voicemail data from a remote server. 214 * <P> Possible values: 215 * {@link #DATA_CHANNEL_STATE_OK}, 216 * {@link #DATA_CHANNEL_STATE_NO_CONNECTION} 217 * </P> 218 * <P>Type: INTEGER</P> 219 */ 220 public static final String DATA_CHANNEL_STATE = "data_channel_state"; 221 public static final int DATA_CHANNEL_STATE_OK = 0; 222 public static final int DATA_CHANNEL_STATE_NO_CONNECTION = 1; 223 /** 224 * The notification channel state of the voicemail source. This is the channel through which 225 * the source gets notified of new voicemails on the remote server. 226 * <P> Possible values: 227 * {@link #NOTIFICATION_CHANNEL_STATE_OK}, 228 * {@link #NOTIFICATION_CHANNEL_STATE_NO_CONNECTION}, 229 * {@link #NOTIFICATION_CHANNEL_STATE_MESSAGE_WAITING} 230 * </P> 231 * <P>Type: INTEGER</P> 232 */ 233 public static final String NOTIFICATION_CHANNEL_STATE = "notification_channel_state"; 234 public static final int NOTIFICATION_CHANNEL_STATE_OK = 0; 235 public static final int NOTIFICATION_CHANNEL_STATE_NO_CONNECTION = 1; 236 /** 237 * Use this state when the notification can only tell that there are pending messages on 238 * the server but no details of the sender/time etc are known. 239 */ 240 public static final int NOTIFICATION_CHANNEL_STATE_MESSAGE_WAITING = 2; 241 242 } 243} 244