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