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 */ 16 17package android.provider; 18 19import android.Manifest; 20import android.annotation.SdkConstant; 21import android.annotation.SdkConstant.SdkConstantType; 22import android.content.Intent; 23import android.database.ContentObserver; 24import android.net.Uri; 25import android.provider.CallLog.Calls; 26 27/** 28 * The contract between the voicemail provider and applications. Contains 29 * definitions for the supported URIs and columns. 30 * 31 * <P>The content providers exposes two tables through this interface: 32 * <ul> 33 * <li> Voicemails table: This stores the actual voicemail records. The 34 * columns and URIs for accessing this table are defined by the 35 * {@link Voicemails} class. 36 * </li> 37 * <li> Status table: This provides a way for the voicemail source application 38 * to convey its current state to the system. The columns and URIS for 39 * accessing this table are defined by the {@link Status} class. 40 * </li> 41 * </ul> 42 * 43 * <P> The minimum permission needed to access this content provider is 44 * {@link Manifest.permission#ADD_VOICEMAIL} 45 * 46 * <P>Voicemails are inserted by what is called as a "voicemail source" 47 * application, which is responsible for syncing voicemail data between a remote 48 * server and the local voicemail content provider. "voicemail source" 49 * application should always set the {@link #PARAM_KEY_SOURCE_PACKAGE} in the 50 * URI to identify its package. 51 * 52 * <P>In addition to the {@link ContentObserver} notifications the voicemail 53 * provider also generates broadcast intents to notify change for applications 54 * that are not active and therefore cannot listen to ContentObserver 55 * notifications. Broadcast intents with following actions are generated: 56 * <ul> 57 * <li> {@link #ACTION_NEW_VOICEMAIL} is generated for each new voicemail 58 * inserted. 59 * </li> 60 * <li> {@link Intent#ACTION_PROVIDER_CHANGED} is generated for any change 61 * made into the database, including new voicemail. 62 * </li> 63 * </ul> 64 */ 65public class VoicemailContract { 66 /** Not instantiable. */ 67 private VoicemailContract() { 68 } 69 70 /** The authority used by the voicemail provider. */ 71 public static final String AUTHORITY = "com.android.voicemail"; 72 /** 73 * Parameter key used in the URI to specify the voicemail source package name. 74 * <p> This field must be set in all requests that originate from a voicemail source. 75 */ 76 public static final String PARAM_KEY_SOURCE_PACKAGE = "source_package"; 77 78 /** Broadcast intent when a new voicemail record is inserted. */ 79 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 80 public static final String ACTION_NEW_VOICEMAIL = "android.intent.action.NEW_VOICEMAIL"; 81 82 /** 83 * Broadcast intent to request a voicemail source to fetch voicemail content of a specific 84 * voicemail from the remote server. The voicemail to fetch is specified by the data uri 85 * of the intent. 86 * <p> 87 * All voicemail sources are expected to handle this event. After storing the content 88 * the application should also set {@link Voicemails#HAS_CONTENT} to 1; 89 */ 90 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 91 public static final String ACTION_FETCH_VOICEMAIL = "android.intent.action.FETCH_VOICEMAIL"; 92 93 /** 94 * Extra included in {@link Intent#ACTION_PROVIDER_CHANGED} broadcast intents to indicate if the 95 * receiving package made this change. 96 */ 97 public static final String EXTRA_SELF_CHANGE = "com.android.voicemail.extra.SELF_CHANGE"; 98 99 /** 100 * Name of the source package field, which must be same across all voicemail related tables. 101 * This is an internal field. 102 * @hide 103 */ 104 public static final String SOURCE_PACKAGE_FIELD = "source_package"; 105 106 /** Defines fields exposed through the /voicemail path of this content provider. */ 107 public static final class Voicemails implements BaseColumns, OpenableColumns { 108 /** Not instantiable. */ 109 private Voicemails() { 110 } 111 112 /** URI to insert/retrieve voicemails. */ 113 public static final Uri CONTENT_URI = 114 Uri.parse("content://" + AUTHORITY + "/voicemail"); 115 116 /** The MIME type for a collection of voicemails. */ 117 public static final String DIR_TYPE = "vnd.android.cursor.dir/voicemails"; 118 119 /** The MIME type for a single voicemail. */ 120 public static final String ITEM_TYPE = "vnd.android.cursor.item/voicemail"; 121 122 /** 123 * Phone number of the voicemail sender. 124 * <P>Type: TEXT</P> 125 */ 126 public static final String NUMBER = Calls.NUMBER; 127 /** 128 * The date the voicemail was sent, in milliseconds since the epoch 129 * <P>Type: INTEGER (long)</P> 130 */ 131 public static final String DATE = Calls.DATE; 132 /** 133 * The duration of the voicemail in seconds. 134 * <P>Type: INTEGER (long)</P> 135 */ 136 public static final String DURATION = Calls.DURATION; 137 /** 138 * Whether this item has been read or otherwise consumed by the user. 139 * <P>Type: INTEGER (boolean)</P> 140 */ 141 public static final String IS_READ = Calls.IS_READ; 142 /** 143 * The mail box state of the voicemail. This field is currently not used by the system. 144 * <P> Possible values: {@link #STATE_INBOX}, {@link #STATE_DELETED}, 145 * {@link #STATE_UNDELETED}. 146 * <P>Type: INTEGER</P> 147 * @hide 148 */ 149 public static final String STATE = "state"; 150 /** 151 * Value of {@link #STATE} when the voicemail is in inbox. 152 * @hide 153 */ 154 public static int STATE_INBOX = 0; 155 /** 156 * Value of {@link #STATE} when the voicemail has been marked as deleted. 157 * @hide 158 */ 159 public static int STATE_DELETED = 1; 160 /** 161 * Value of {@link #STATE} when the voicemail has marked as undeleted. 162 * @hide 163 */ 164 public static int STATE_UNDELETED = 2; 165 /** 166 * Package name of the source application that inserted the voicemail. 167 * <P>Type: TEXT</P> 168 */ 169 public static final String SOURCE_PACKAGE = SOURCE_PACKAGE_FIELD; 170 /** 171 * Application-specific data available to the source application that 172 * inserted the voicemail. This is typically used to store the source 173 * specific message id to identify this voicemail on the remote 174 * voicemail server. 175 * <P>Type: TEXT</P> 176 * <P> Note that this is NOT the voicemail media content data. 177 */ 178 public static final String SOURCE_DATA = "source_data"; 179 /** 180 * Whether the media content for this voicemail is available for 181 * consumption. 182 * <P>Type: INTEGER (boolean)</P> 183 */ 184 public static final String HAS_CONTENT = "has_content"; 185 /** 186 * MIME type of the media content for the voicemail. 187 * <P>Type: TEXT</P> 188 */ 189 public static final String MIME_TYPE = "mime_type"; 190 /** 191 * Path to the media content file. Internal only field. 192 * @hide 193 */ 194 public static final String _DATA = "_data"; 195 196 /** 197 * A convenience method to build voicemail URI specific to a source package by appending 198 * {@link VoicemailContract#PARAM_KEY_SOURCE_PACKAGE} param to the base URI. 199 */ 200 public static Uri buildSourceUri(String packageName) { 201 return Voicemails.CONTENT_URI.buildUpon() 202 .appendQueryParameter(PARAM_KEY_SOURCE_PACKAGE, packageName).build(); 203 } 204 } 205 206 /** Defines fields exposed through the /status path of this content provider. */ 207 public static final class Status implements BaseColumns { 208 /** URI to insert/retrieve status of voicemail source. */ 209 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/status"); 210 /** The MIME type for a collection of voicemail source statuses. */ 211 public static final String DIR_TYPE = "vnd.android.cursor.dir/voicemail.source.status"; 212 /** The MIME type for a single voicemail source status entry. */ 213 public static final String ITEM_TYPE = "vnd.android.cursor.item/voicemail.source.status"; 214 215 /** Not instantiable. */ 216 private Status() { 217 } 218 /** 219 * The package name of the voicemail source. There can only be a one entry per source. 220 * <P>Type: TEXT</P> 221 */ 222 public static final String SOURCE_PACKAGE = SOURCE_PACKAGE_FIELD; 223 /** 224 * The URI to call to invoke source specific voicemail settings screen. On a user request 225 * to setup voicemail an intent with action VIEW with this URI will be fired by the system. 226 * <P>Type: TEXT</P> 227 */ 228 public static final String SETTINGS_URI = "settings_uri"; 229 /** 230 * The URI to call when the user requests to directly access the voicemail from the remote 231 * server. In case of an IVR voicemail system this is typically set to the the voicemail 232 * number specified using a tel:/ URI. 233 * <P>Type: TEXT</P> 234 */ 235 public static final String VOICEMAIL_ACCESS_URI = "voicemail_access_uri"; 236 /** 237 * The configuration state of the voicemail source. 238 * <P> Possible values: 239 * {@link #CONFIGURATION_STATE_OK}, 240 * {@link #CONFIGURATION_STATE_NOT_CONFIGURED}, 241 * {@link #CONFIGURATION_STATE_CAN_BE_CONFIGURED} 242 * <P>Type: INTEGER</P> 243 */ 244 public static final String CONFIGURATION_STATE = "configuration_state"; 245 /** Value of {@link #CONFIGURATION_STATE} to indicate an all OK configuration status. */ 246 public static final int CONFIGURATION_STATE_OK = 0; 247 /** 248 * Value of {@link #CONFIGURATION_STATE} to indicate the visual voicemail is not 249 * yet configured on this device. 250 */ 251 public static final int CONFIGURATION_STATE_NOT_CONFIGURED = 1; 252 /** 253 * Value of {@link #CONFIGURATION_STATE} to indicate the visual voicemail is not 254 * yet configured on this device but can be configured by the user. 255 * <p> This state must be used when the source has verified that the current user can be 256 * upgraded to visual voicemail and would like to show a set up invitation message. 257 */ 258 public static final int CONFIGURATION_STATE_CAN_BE_CONFIGURED = 2; 259 /** 260 * The data channel state of the voicemail source. This the channel through which the source 261 * pulls voicemail data from a remote server. 262 * <P> Possible values: 263 * {@link #DATA_CHANNEL_STATE_OK}, 264 * {@link #DATA_CHANNEL_STATE_NO_CONNECTION} 265 * </P> 266 * <P>Type: INTEGER</P> 267 */ 268 public static final String DATA_CHANNEL_STATE = "data_channel_state"; 269 /** 270 * Value of {@link #DATA_CHANNEL_STATE} to indicate that data channel is working fine. 271 */ 272 public static final int DATA_CHANNEL_STATE_OK = 0; 273 /** 274 * Value of {@link #DATA_CHANNEL_STATE} to indicate that data channel connection is not 275 * working. 276 */ 277 public static final int DATA_CHANNEL_STATE_NO_CONNECTION = 1; 278 /** 279 * The notification channel state of the voicemail source. This is the channel through which 280 * the source gets notified of new voicemails on the remote server. 281 * <P> Possible values: 282 * {@link #NOTIFICATION_CHANNEL_STATE_OK}, 283 * {@link #NOTIFICATION_CHANNEL_STATE_NO_CONNECTION}, 284 * {@link #NOTIFICATION_CHANNEL_STATE_MESSAGE_WAITING} 285 * </P> 286 * <P>Type: INTEGER</P> 287 */ 288 public static final String NOTIFICATION_CHANNEL_STATE = "notification_channel_state"; 289 /** 290 * Value of {@link #NOTIFICATION_CHANNEL_STATE} to indicate that the notification channel is 291 * working fine. 292 */ 293 public static final int NOTIFICATION_CHANNEL_STATE_OK = 0; 294 /** 295 * Value of {@link #NOTIFICATION_CHANNEL_STATE} to indicate that the notification channel 296 * connection is not working. 297 */ 298 public static final int NOTIFICATION_CHANNEL_STATE_NO_CONNECTION = 1; 299 /** 300 * Value of {@link #NOTIFICATION_CHANNEL_STATE} to indicate that there are messages waiting 301 * on the server but the details are not known. 302 * <p> Use this state when the notification can only tell that there are pending messages on 303 * the server but no details of the sender/time etc are known. 304 */ 305 public static final int NOTIFICATION_CHANNEL_STATE_MESSAGE_WAITING = 2; 306 307 /** 308 * A convenience method to build status URI specific to a source package by appending 309 * {@link VoicemailContract#PARAM_KEY_SOURCE_PACKAGE} param to the base URI. 310 */ 311 public static Uri buildSourceUri(String packageName) { 312 return Status.CONTENT_URI.buildUpon() 313 .appendQueryParameter(PARAM_KEY_SOURCE_PACKAGE, packageName).build(); 314 } 315 } 316} 317