• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package android.provider;
18 
19 import android.annotation.SdkConstant;
20 import android.annotation.SdkConstant.SdkConstantType;
21 import android.content.ComponentName;
22 import android.content.ContentResolver;
23 import android.content.ContentValues;
24 import android.content.Context;
25 import android.content.Intent;
26 import android.database.ContentObserver;
27 import android.net.Uri;
28 import android.provider.CallLog.Calls;
29 import android.telecom.PhoneAccount;
30 import android.telecom.PhoneAccountHandle;
31 import android.telecom.Voicemail;
32 
33 import java.util.List;
34 
35 /**
36  * The contract between the voicemail provider and applications. Contains
37  * definitions for the supported URIs and columns.
38  *
39  * <P>The content providers exposes two tables through this interface:
40  * <ul>
41  *   <li> Voicemails table: This stores the actual voicemail records. The
42  *   columns and URIs for accessing this table are defined by the
43  *   {@link Voicemails} class.
44  *   </li>
45  *   <li> Status table: This provides a way for the voicemail source application
46  *   to convey its current state to the system. The columns and URIS for
47  *   accessing this table are defined by the {@link Status} class.
48  *   </li>
49  * </ul>
50  *
51  * <P> The minimum permission needed to access this content provider is
52  * {@link android.Manifest.permission#ADD_VOICEMAIL} or carrier privileges (see
53  * {@link android.telephony.TelephonyManager#hasCarrierPrivileges}).
54  *
55  * <P>Voicemails are inserted by what is called as a "voicemail source"
56  * application, which is responsible for syncing voicemail data between a remote
57  * server and the local voicemail content provider. "voicemail source"
58  * application should always set the {@link #PARAM_KEY_SOURCE_PACKAGE} in the
59  * URI to identify its package.
60  *
61  * <P>In addition to the {@link ContentObserver} notifications the voicemail
62  * provider also generates broadcast intents to notify change for applications
63  * that are not active and therefore cannot listen to ContentObserver
64  * notifications. Broadcast intents with following actions are generated:
65  * <ul>
66  *   <li> {@link #ACTION_NEW_VOICEMAIL} is generated for each new voicemail
67  *   inserted.
68  *   </li>
69  *   <li> {@link Intent#ACTION_PROVIDER_CHANGED} is generated for any change
70  *    made into the database, including new voicemail.
71  *   </li>
72  * </ul>
73  */
74 public class VoicemailContract {
75     /** Not instantiable. */
VoicemailContract()76     private VoicemailContract() {
77     }
78 
79     /** The authority used by the voicemail provider. */
80     public static final String AUTHORITY = "com.android.voicemail";
81     /**
82      * Parameter key used in the URI to specify the voicemail source package name.
83      * <p> This field must be set in all requests that originate from a voicemail source.
84      */
85     public static final String PARAM_KEY_SOURCE_PACKAGE = "source_package";
86 
87     /** Broadcast intent when a new voicemail record is inserted. */
88     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
89     public static final String ACTION_NEW_VOICEMAIL = "android.intent.action.NEW_VOICEMAIL";
90 
91     /**
92      * Broadcast intent to request a voicemail source to fetch voicemail content of a specific
93      * voicemail from the remote server. The voicemail to fetch is specified by the data uri
94      * of the intent.
95      * <p>
96      * All voicemail sources are expected to handle this event. After storing the content
97      * the application should also set {@link Voicemails#HAS_CONTENT} to 1;
98      */
99     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
100     public static final String ACTION_FETCH_VOICEMAIL = "android.intent.action.FETCH_VOICEMAIL";
101 
102     /**
103      * Broadcast intent to request all voicemail sources to perform a sync with the remote server.
104      */
105     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
106     public static final String ACTION_SYNC_VOICEMAIL = "android.provider.action.SYNC_VOICEMAIL";
107 
108     /**
109      * Broadcast intent to inform a new visual voicemail SMS has been received. This intent will
110      * only be delivered to the telephony service.
111      *
112      * @see #EXTRA_VOICEMAIL_SMS
113      * @see #EXTRA_TARGET_PACKAGE
114      *
115      * @hide */
116     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
117     public static final String ACTION_VOICEMAIL_SMS_RECEIVED =
118             "com.android.internal.provider.action.VOICEMAIL_SMS_RECEIVED";
119 
120     /**
121      * Extra in {@link #ACTION_VOICEMAIL_SMS_RECEIVED} indicating the content of the SMS.
122      *
123      * @hide
124      */
125     public static final String EXTRA_VOICEMAIL_SMS = "android.provider.extra.VOICEMAIL_SMS";
126 
127     /**
128      * Extra in {@link #ACTION_VOICEMAIL_SMS_RECEIVED} indicating the target package to bind {@link
129      * android.telephony.VisualVoicemailService}.
130      *
131      * <p>This extra should be set to android.telephony.VisualVoicemailSmsFilterSettings#packageName
132      * while performing filtering. Since the default dialer might change between the filter sending
133      * it and telephony binding to the service, this ensures the service will not receive SMS
134      * filtered by the previous app.
135      *
136      * @hide
137      */
138     public static final String EXTRA_TARGET_PACKAGE = "android.provider.extra.TARGET_PACAKGE";
139 
140     /**
141      * Extra included in {@link Intent#ACTION_PROVIDER_CHANGED} broadcast intents to indicate if the
142      * receiving package made this change.
143      */
144     public static final String EXTRA_SELF_CHANGE = "com.android.voicemail.extra.SELF_CHANGE";
145 
146     /**
147      * Extra included in {@link #ACTION_SYNC_VOICEMAIL} broadcast intents to indicate which {@link
148      * PhoneAccountHandle} to sync.
149      */
150     public static final String EXTRA_PHONE_ACCOUNT_HANDLE =
151             "android.provider.extra.PHONE_ACCOUNT_HANDLE";
152 
153     /**
154      * Name of the source package field, which must be same across all voicemail related tables.
155      * This is an internal field.
156      * @hide
157      */
158     public static final String SOURCE_PACKAGE_FIELD = "source_package";
159 
160     /** Defines fields exposed through the /voicemail path of this content provider. */
161     public static final class Voicemails implements BaseColumns, OpenableColumns {
162         /** Not instantiable. */
Voicemails()163         private Voicemails() {
164         }
165 
166         /** URI to insert/retrieve voicemails. */
167         public static final Uri CONTENT_URI =
168             Uri.parse("content://" + AUTHORITY + "/voicemail");
169 
170         /** The MIME type for a collection of voicemails. */
171         public static final String DIR_TYPE = "vnd.android.cursor.dir/voicemails";
172 
173         /** The MIME type for a single voicemail. */
174         public static final String ITEM_TYPE = "vnd.android.cursor.item/voicemail";
175 
176         /**
177          * Phone number of the voicemail sender.
178          * <P>Type: TEXT</P>
179          */
180         public static final String NUMBER = Calls.NUMBER;
181         /**
182          * The date the voicemail was sent, in milliseconds since the epoch
183          * <P>Type: INTEGER (long)</P>
184          */
185         public static final String DATE = Calls.DATE;
186         /**
187          * The duration of the voicemail in seconds.
188          * <P>Type: INTEGER (long)</P>
189          */
190         public static final String DURATION = Calls.DURATION;
191         /**
192          * Whether or not the voicemail has been acknowledged (notification sent to the user).
193          * <P>Type: INTEGER (boolean)</P>
194          */
195         public static final String NEW = Calls.NEW;
196         /**
197          * Whether this item has been read or otherwise consumed by the user.
198          * <P>Type: INTEGER (boolean)</P>
199          */
200         public static final String IS_READ = Calls.IS_READ;
201         /**
202          * The mail box state of the voicemail. This field is currently not used by the system.
203          * <P> Possible values: {@link #STATE_INBOX}, {@link #STATE_DELETED},
204          * {@link #STATE_UNDELETED}.
205          * <P>Type: INTEGER</P>
206          * @hide
207          */
208         public static final String STATE = "state";
209         /**
210          * Value of {@link #STATE} when the voicemail is in inbox.
211          * @hide
212          */
213         public static int STATE_INBOX = 0;
214         /**
215          * Value of {@link #STATE} when the voicemail has been marked as deleted.
216          * @hide
217          */
218         public static int STATE_DELETED = 1;
219         /**
220          * Value of {@link #STATE} when the voicemail has marked as undeleted.
221          * @hide
222          */
223         public static int STATE_UNDELETED = 2;
224         /**
225          * Package name of the source application that inserted the voicemail.
226          * <P>Type: TEXT</P>
227          */
228         public static final String SOURCE_PACKAGE = SOURCE_PACKAGE_FIELD;
229         /**
230          * Application-specific data available to the source application that
231          * inserted the voicemail. This is typically used to store the source
232          * specific message id to identify this voicemail on the remote
233          * voicemail server.
234          * <P>Type: TEXT</P>
235          * <P> Note that this is NOT the voicemail media content data.
236          */
237         public static final String SOURCE_DATA = "source_data";
238         /**
239          * Whether the media content for this voicemail is available for
240          * consumption.
241          * <P>Type: INTEGER (boolean)</P>
242          */
243         public static final String HAS_CONTENT = "has_content";
244         /**
245          * MIME type of the media content for the voicemail.
246          * <P>Type: TEXT</P>
247          */
248         public static final String MIME_TYPE = "mime_type";
249         /**
250          * The transcription of the voicemail entry. This will only be populated if the voicemail
251          * entry has a valid transcription.
252          * <P>Type: TEXT</P>
253          */
254         public static final String TRANSCRIPTION = "transcription";
255         /**
256          * The state of the voicemail transcription.
257          * <P> Possible values: {@link #TRANSCRIPTION_NOT_STARTED},
258          * {@link #TRANSCRIPTION_IN_PROGRESS}, {@link #TRANSCRIPTION_FAILED},
259          * {@link #TRANSCRIPTION_AVAILABLE}.
260          * <P>Type: INTEGER</P>
261          * @hide
262          */
263         public static final String TRANSCRIPTION_STATE = "transcription_state";
264         /**
265          * Value of {@link #TRANSCRIPTION_STATE} when the voicemail transcription has not yet
266          * been attempted.
267          * @hide
268          */
269         public static final int TRANSCRIPTION_NOT_STARTED = 0;
270         /**
271          * Value of {@link #TRANSCRIPTION_STATE} when the voicemail transcription has begun
272          * but is not yet complete.
273          * @hide
274          */
275         public static final int TRANSCRIPTION_IN_PROGRESS = 1;
276         /**
277          * Value of {@link #TRANSCRIPTION_STATE} when the voicemail transcription has
278          * been attempted and failed.
279          * @hide
280          */
281         public static final int TRANSCRIPTION_FAILED = 2;
282         /**
283          * Value of {@link #TRANSCRIPTION_STATE} when the voicemail transcription has
284          * completed and the result has been stored in the {@link #TRANSCRIPTION} column.
285          * @hide
286          */
287         public static final int TRANSCRIPTION_AVAILABLE = 3;
288         /**
289          * Path to the media content file. Internal only field.
290          * @hide
291          */
292         public static final String _DATA = "_data";
293 
294         // Note: PHONE_ACCOUNT_* constant values are "subscription_*" due to a historic naming
295         // that was encoded into call log databases.
296 
297         /**
298          * The {@link ComponentName} of the {@link PhoneAccount} in string form. The
299          * {@link PhoneAccount} of the voicemail is used to differentiate voicemails from different
300          * sources.
301          * <P>Type: TEXT</P>
302          */
303         public static final String PHONE_ACCOUNT_COMPONENT_NAME = "subscription_component_name";
304 
305         /**
306          * The identifier of a {@link PhoneAccount} that is unique to a specified
307          * {@link ComponentName}. The {@link PhoneAccount} of the voicemail is used to differentiate
308          * voicemails from different sources.
309          * <P>Type: TEXT</P>
310          */
311         public static final String PHONE_ACCOUNT_ID = "subscription_id";
312 
313         /**
314          * Flag used to indicate that local, unsynced changes are present.
315          * Currently, this is used to indicate that the voicemail was read or deleted.
316          * The value will be 1 if dirty is true, 0 if false.
317          *
318          * <p>When a caller updates a voicemail row (either with {@link ContentResolver#update} or
319          * {@link ContentResolver#applyBatch}), and if the {@link ContentValues} doesn't contain
320          * this column, the voicemail provider implicitly sets it to 0 if the calling package is
321          * the {@link #SOURCE_PACKAGE} or to 1 otherwise. To prevent this behavior, explicitly set
322          * {@link #DIRTY_RETAIN} to DIRTY in the {@link ContentValues}.
323          *
324          * <P>Type: INTEGER (boolean)</P>
325          *
326          * @see #DIRTY_RETAIN
327          */
328         public static final String DIRTY = "dirty";
329 
330         /**
331          * Value of {@link #DIRTY} when updating to indicate that the value should not be updated
332          * during this operation.
333          */
334         public static final int DIRTY_RETAIN = -1;
335 
336         /**
337          * Flag used to indicate that the voicemail was deleted but not synced to the server.
338          * A deleted row should be ignored.
339          * The value will be 1 if deleted is true, 0 if false.
340          * <P>Type: INTEGER (boolean)</P>
341          */
342         public static final String DELETED = "deleted";
343 
344         /**
345          * The date the row is last inserted, updated, or marked as deleted, in milliseconds
346          * since the epoch. Read only.
347          * <P>Type: INTEGER (long)</P>
348          */
349         public static final String LAST_MODIFIED = "last_modified";
350 
351         /**
352          * Flag to indicate the voicemail was backed up. The value will be 1 if backed up, 0 if
353          * not.
354          *
355          * <P>Type: INTEGER (boolean)</P>
356          */
357         public static final String BACKED_UP = "backed_up";
358 
359         /**
360          * Flag to indicate the voicemail was restored from a backup. The value will be 1 if
361          * restored, 0 if not.
362          *
363          * <P>Type: INTEGER (boolean)</P>
364          */
365         public static final String RESTORED = "restored";
366 
367         /**
368          * Flag to indicate the voicemail was marked as archived. Archived voicemail should not be
369          * deleted even if it no longer exist on the server. The value will be 1 if archived true, 0
370          * if not.
371          *
372          * <P>Type: INTEGER (boolean)</P>
373          */
374         public static final String ARCHIVED = "archived";
375 
376         /**
377          * Flag to indicate the voicemail is a OMTP voicemail handled by the {@link
378          * android.telephony.VisualVoicemailService}. The UI should only show OMTP voicemails from
379          * the current visual voicemail package. For example, the selection could be
380          * {@code WHERE (IS_OMTP_VOICEMAIL == 0) OR ( IS_OMTP_VOICEMAIL == 1 AND SOURCE_PACKAGE ==
381          * "current.vvm.package")}
382          *
383          * <P>Type: INTEGER (boolean)</P>
384          *
385          * @see android.telephony.TelephonyManager#getVisualVoicemailPackageName
386          */
387         public static final String IS_OMTP_VOICEMAIL = "is_omtp_voicemail";
388 
389         /**
390          * A convenience method to build voicemail URI specific to a source package by appending
391          * {@link VoicemailContract#PARAM_KEY_SOURCE_PACKAGE} param to the base URI.
392          */
buildSourceUri(String packageName)393         public static Uri buildSourceUri(String packageName) {
394             return Voicemails.CONTENT_URI.buildUpon()
395                     .appendQueryParameter(PARAM_KEY_SOURCE_PACKAGE, packageName)
396                     .build();
397         }
398 
399         /**
400          * Inserts a new voicemail into the voicemail content provider.
401          *
402          * @param context The context of the app doing the inserting
403          * @param voicemail Data to be inserted
404          * @return {@link Uri} of the newly inserted {@link Voicemail}
405          *
406          * @hide
407          */
insert(Context context, Voicemail voicemail)408         public static Uri insert(Context context, Voicemail voicemail) {
409             ContentResolver contentResolver = context.getContentResolver();
410             ContentValues contentValues = getContentValues(voicemail);
411             return contentResolver.insert(buildSourceUri(context.getPackageName()), contentValues);
412         }
413 
414         /**
415          * Inserts a list of voicemails into the voicemail content provider.
416          *
417          * @param context The context of the app doing the inserting
418          * @param voicemails Data to be inserted
419          * @return the number of voicemails inserted
420          *
421          * @hide
422          */
insert(Context context, List<Voicemail> voicemails)423         public static int insert(Context context, List<Voicemail> voicemails) {
424             ContentResolver contentResolver = context.getContentResolver();
425             int count = voicemails.size();
426             for (int i = 0; i < count; i++) {
427                 ContentValues contentValues = getContentValues(voicemails.get(i));
428                 contentResolver.insert(buildSourceUri(context.getPackageName()), contentValues);
429             }
430             return count;
431         }
432 
433         /**
434          * Clears all voicemails accessible to this voicemail content provider for the calling
435          * package. By default, a package only has permission to delete voicemails it inserted.
436          *
437          * @return the number of voicemails deleted
438          *
439          * @hide
440          */
deleteAll(Context context)441         public static int deleteAll(Context context) {
442             return context.getContentResolver().delete(
443                     buildSourceUri(context.getPackageName()), "", new String[0]);
444         }
445 
446         /**
447          * Maps structured {@link Voicemail} to {@link ContentValues} in content provider.
448          */
getContentValues(Voicemail voicemail)449         private static ContentValues getContentValues(Voicemail voicemail) {
450             ContentValues contentValues = new ContentValues();
451             contentValues.put(Voicemails.DATE, String.valueOf(voicemail.getTimestampMillis()));
452             contentValues.put(Voicemails.NUMBER, voicemail.getNumber());
453             contentValues.put(Voicemails.DURATION, String.valueOf(voicemail.getDuration()));
454             contentValues.put(Voicemails.SOURCE_PACKAGE, voicemail.getSourcePackage());
455             contentValues.put(Voicemails.SOURCE_DATA, voicemail.getSourceData());
456             contentValues.put(Voicemails.IS_READ, voicemail.isRead() ? 1 : 0);
457 
458             PhoneAccountHandle phoneAccount = voicemail.getPhoneAccount();
459             if (phoneAccount != null) {
460                 contentValues.put(Voicemails.PHONE_ACCOUNT_COMPONENT_NAME,
461                         phoneAccount.getComponentName().flattenToString());
462                 contentValues.put(Voicemails.PHONE_ACCOUNT_ID, phoneAccount.getId());
463             }
464 
465             if (voicemail.getTranscription() != null) {
466                 contentValues.put(Voicemails.TRANSCRIPTION, voicemail.getTranscription());
467             }
468 
469             return contentValues;
470         }
471     }
472 
473     /** Defines fields exposed through the /status path of this content provider. */
474     public static final class Status implements BaseColumns {
475         /** URI to insert/retrieve status of voicemail source. */
476         public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/status");
477         /** The MIME type for a collection of voicemail source statuses. */
478         public static final String DIR_TYPE = "vnd.android.cursor.dir/voicemail.source.status";
479         /** The MIME type for a single voicemail source status entry. */
480         public static final String ITEM_TYPE = "vnd.android.cursor.item/voicemail.source.status";
481 
482         /** Not instantiable. */
Status()483         private Status() {
484         }
485         /**
486          * The package name of the voicemail source. There can only be a one entry per account
487          * per source.
488          * <P>Type: TEXT</P>
489          */
490         public static final String SOURCE_PACKAGE = SOURCE_PACKAGE_FIELD;
491 
492         /**
493          * The type of the source, which determines how to interpret source-specific states.
494          * Typically this will be set to the same string as
495          * {@link android.telephony.CarrierConfigManager#KEY_VVM_TYPE_STRING}. For example,
496          * "vvm_type_omtp".
497          *
498          * <P>Type: TEXT</P>
499          *
500          * @see #CONFIGURATION_STATE
501          * @see #DATA_CHANNEL_STATE
502          * @see #NOTIFICATION_CHANNEL_STATE
503          */
504         public static final String SOURCE_TYPE = "source_type";
505 
506         // Note: Multiple entries may exist for a single source if they are differentiated by the
507         // PHONE_ACCOUNT_* fields.
508 
509         /**
510          * The {@link ComponentName} of the {@link PhoneAccount} in string form. The
511          * {@link PhoneAccount} differentiates voicemail sources from the same package.
512          * <P>Type: TEXT</P>
513          */
514         public static final String PHONE_ACCOUNT_COMPONENT_NAME = "phone_account_component_name";
515 
516         /**
517          * The identifier of a {@link PhoneAccount} that is unique to a specified component. The
518          * {@link PhoneAccount} differentiates voicemail sources from the same package.
519          * <P>Type: TEXT</P>
520          */
521         public static final String PHONE_ACCOUNT_ID = "phone_account_id";
522 
523         /**
524          * The URI to call to invoke source specific voicemail settings screen. On a user request
525          * to setup voicemail an intent with action VIEW with this URI will be fired by the system.
526          * <P>Type: TEXT</P>
527          */
528         public static final String SETTINGS_URI = "settings_uri";
529         /**
530          * The URI to call when the user requests to directly access the voicemail from the remote
531          * server. In case of an IVR voicemail system this is typically set to the the voicemail
532          * number specified using a tel:/ URI.
533          * <P>Type: TEXT</P>
534          */
535         public static final String VOICEMAIL_ACCESS_URI = "voicemail_access_uri";
536         /**
537          * The configuration state of the voicemail source.
538          *
539          * <P>Negative values are reserved to the source for source-specific states, see
540          * {@link #SOURCE_TYPE}
541          *
542          * <P> Possible values:
543          * {@link #CONFIGURATION_STATE_OK},
544          * {@link #CONFIGURATION_STATE_NOT_CONFIGURED},
545          * {@link #CONFIGURATION_STATE_CAN_BE_CONFIGURED}
546          * {@link #CONFIGURATION_STATE_CONFIGURING}
547          * {@link #CONFIGURATION_STATE_FAILED}
548          * {@link #CONFIGURATION_STATE_DISABLED}
549          * <P>Type: INTEGER</P>
550          */
551         public static final String CONFIGURATION_STATE = "configuration_state";
552 
553         /** Value of {@link #CONFIGURATION_STATE} to indicate an all OK configuration status. */
554         public static final int CONFIGURATION_STATE_OK = 0;
555         /**
556          * Value of {@link #CONFIGURATION_STATE} to indicate the visual voicemail is not
557          * yet configured on this device.
558          */
559         public static final int CONFIGURATION_STATE_NOT_CONFIGURED = 1;
560         /**
561          * Value of {@link #CONFIGURATION_STATE} to indicate the visual voicemail is not
562          * yet configured on this device but can be configured by the user.
563          * <p> This state must be used when the source has verified that the current user can be
564          * upgraded to visual voicemail and would like to show a set up invitation message.
565          */
566         public static final int CONFIGURATION_STATE_CAN_BE_CONFIGURED = 2;
567         /**
568          * Value of {@link #CONFIGURATION_STATE} to indicate that visual voicemail still is being
569          * configured.
570          */
571         public static final int CONFIGURATION_STATE_CONFIGURING = 3;
572         /**
573          * Value of {@link #CONFIGURATION_STATE} to indicate that visual voicemail has failed to
574          * be configured.
575          */
576         public static final int CONFIGURATION_STATE_FAILED = 4;
577         /**
578          * Value of {@link #CONFIGURATION_STATE} to indicate that visual voicemail is disabled by
579          * the user.
580          */
581         public static final int CONFIGURATION_STATE_DISABLED = 5;
582         /**
583          * The data channel state of the voicemail source. This the channel through which the source
584          * pulls voicemail data from a remote server.
585          *
586          * <P>Negative values are reserved to the source for source-specific states, see
587          * {@link #SOURCE_TYPE}
588          *
589          * <P> Possible values:
590          * {@link #DATA_CHANNEL_STATE_OK},
591          * {@link #DATA_CHANNEL_STATE_NO_CONNECTION}
592          * </P>
593          * <P>Type: INTEGER</P>
594          */
595         public static final String DATA_CHANNEL_STATE = "data_channel_state";
596 
597         /**
598          *  Value of {@link #DATA_CHANNEL_STATE} to indicate that data channel is working fine.
599          */
600         public static final int DATA_CHANNEL_STATE_OK = 0;
601         /**
602          *  Value of {@link #DATA_CHANNEL_STATE} to indicate that data channel failed to find a
603          *  suitable network to connect to the server.
604          */
605         public static final int DATA_CHANNEL_STATE_NO_CONNECTION = 1;
606         /**
607          *  Value of {@link #DATA_CHANNEL_STATE} to indicate that data channel failed to find a
608          *  suitable network to connect to the server, and the carrier requires using cellular
609          *  data network to connect to the server.
610          */
611         public static final int DATA_CHANNEL_STATE_NO_CONNECTION_CELLULAR_REQUIRED = 2;
612         /**
613          *  Value of {@link #DATA_CHANNEL_STATE} to indicate that data channel received incorrect
614          *  settings or credentials to connect to the server
615          */
616         public static final int DATA_CHANNEL_STATE_BAD_CONFIGURATION = 3;
617         /**
618          *  Value of {@link #DATA_CHANNEL_STATE} to indicate that a error has occurred in the data
619          *  channel while communicating with the server
620          */
621         public static final int DATA_CHANNEL_STATE_COMMUNICATION_ERROR = 4;
622         /**
623          *  Value of {@link #DATA_CHANNEL_STATE} to indicate that the server reported an internal
624          *  error to the data channel.
625          */
626         public static final int DATA_CHANNEL_STATE_SERVER_ERROR = 5;
627         /**
628          *  Value of {@link #DATA_CHANNEL_STATE} to indicate that while there is a suitable network,
629          *  the data channel is unable to establish a connection with the server.
630          */
631         public static final int DATA_CHANNEL_STATE_SERVER_CONNECTION_ERROR = 6;
632 
633         /**
634          * The notification channel state of the voicemail source. This is the channel through which
635          * the source gets notified of new voicemails on the remote server.
636          *
637          * <P>Negative values are reserved to the source for source-specific states, see
638          * {@link #SOURCE_TYPE}
639          *
640          * <P> Possible values:
641          * {@link #NOTIFICATION_CHANNEL_STATE_OK},
642          * {@link #NOTIFICATION_CHANNEL_STATE_NO_CONNECTION},
643          * {@link #NOTIFICATION_CHANNEL_STATE_MESSAGE_WAITING}
644          * </P>
645          * <P>Type: INTEGER</P>
646          */
647         public static final String NOTIFICATION_CHANNEL_STATE = "notification_channel_state";
648 
649         /**
650          * Value of {@link #NOTIFICATION_CHANNEL_STATE} to indicate that the notification channel is
651          * working fine.
652          */
653         public static final int NOTIFICATION_CHANNEL_STATE_OK = 0;
654         /**
655          * Value of {@link #NOTIFICATION_CHANNEL_STATE} to indicate that the notification channel
656          * connection is not working.
657          */
658         public static final int NOTIFICATION_CHANNEL_STATE_NO_CONNECTION = 1;
659         /**
660          * Value of {@link #NOTIFICATION_CHANNEL_STATE} to indicate that there are messages waiting
661          * on the server but the details are not known.
662          * <p> Use this state when the notification can only tell that there are pending messages on
663          * the server but no details of the sender/time etc are known.
664          */
665         public static final int NOTIFICATION_CHANNEL_STATE_MESSAGE_WAITING = 2;
666 
667         /**
668          * Amount of resource that is used by existing voicemail in the visual voicemail inbox,
669          * or {@link #QUOTA_UNAVAILABLE} if the quota has never been updated before. This value is
670          * used to inform the client the situation on the remote server. Unit is not specified.
671          * <P>Type: INTEGER</P>
672          */
673         public static final String QUOTA_OCCUPIED = "quota_occupied";
674 
675         /**
676          * Total resource in the visual voicemail inbox that can be used, or
677          * {@link #QUOTA_UNAVAILABLE} if server either has unlimited quota or does not provide quota
678          * information. This value is used to inform the client the situation on the remote server.
679          * Unit is not specified.
680          * <P>Type: INTEGER</P>
681          */
682         public static final String QUOTA_TOTAL = "quota_total";
683 
684         /**
685          * Value for {@link #QUOTA_OCCUPIED} and {@link #QUOTA_TOTAL} to indicate that no
686          * information is available.
687          */
688         public static final int QUOTA_UNAVAILABLE = -1;
689 
690         /**
691          * A convenience method to build status URI specific to a source package by appending
692          * {@link VoicemailContract#PARAM_KEY_SOURCE_PACKAGE} param to the base URI.
693          */
buildSourceUri(String packageName)694         public static Uri buildSourceUri(String packageName) {
695             return Status.CONTENT_URI.buildUpon()
696                     .appendQueryParameter(PARAM_KEY_SOURCE_PACKAGE, packageName).build();
697         }
698     }
699 }
700