blob: d7024cfb7e2ffa43953ae51ca3e5e49029c4a5c8 [file] [log] [blame]
Dan Willemsen4980bf42017-02-14 14:17:12 -08001/*
2 * Copyright (C) 2006 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
Jayachandran C349b9ba2018-10-30 15:09:06 -070019import android.annotation.RequiresPermission;
Dan Willemsen4980bf42017-02-14 14:17:12 -080020import android.annotation.SdkConstant;
21import android.annotation.SdkConstant.SdkConstantType;
chen xu85100482018-10-12 15:30:34 -070022import android.annotation.SystemApi;
Dan Willemsen4980bf42017-02-14 14:17:12 -080023import android.annotation.TestApi;
Mathew Inwood6750f2e2018-08-10 09:29:25 +010024import android.annotation.UnsupportedAppUsage;
Jordan Liub9b75ed2017-02-28 18:15:07 -080025import android.app.job.JobService;
Dan Willemsen4980bf42017-02-14 14:17:12 -080026import android.content.ComponentName;
27import android.content.ContentResolver;
28import android.content.ContentValues;
29import android.content.Context;
30import android.content.Intent;
Jordan Liub9b75ed2017-02-28 18:15:07 -080031import android.database.ContentObserver;
Aurimas Liutikas7f695332018-05-31 21:07:32 -070032import android.database.Cursor;
Dan Willemsen4980bf42017-02-14 14:17:12 -080033import android.database.sqlite.SqliteWrapper;
34import android.net.Uri;
Mathew Inwood8c854f82018-09-14 12:35:36 +010035import android.os.Build;
Jordan Liub9b75ed2017-02-28 18:15:07 -080036import android.telephony.Rlog;
37import android.telephony.ServiceState;
Dan Willemsen4980bf42017-02-14 14:17:12 -080038import android.telephony.SmsMessage;
39import android.telephony.SubscriptionManager;
fionaxu58278be2018-01-29 14:08:12 -080040import android.telephony.TelephonyManager;
Dan Willemsen4980bf42017-02-14 14:17:12 -080041import android.text.TextUtils;
Dan Willemsen4980bf42017-02-14 14:17:12 -080042import android.util.Patterns;
43
44import com.android.internal.telephony.PhoneConstants;
45import com.android.internal.telephony.SmsApplication;
46
Dan Willemsen4980bf42017-02-14 14:17:12 -080047import java.util.HashSet;
48import java.util.Set;
49import java.util.regex.Matcher;
50import java.util.regex.Pattern;
51
52/**
53 * The Telephony provider contains data related to phone operation, specifically SMS and MMS
Jordan Liub9b75ed2017-02-28 18:15:07 -080054 * messages, access to the APN list, including the MMSC to use, and the service state.
Dan Willemsen4980bf42017-02-14 14:17:12 -080055 *
56 * <p class="note"><strong>Note:</strong> These APIs are not available on all Android-powered
57 * devices. If your app depends on telephony features such as for managing SMS messages, include
58 * a <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code <uses-feature>}
59 * </a> element in your manifest that declares the {@code "android.hardware.telephony"} hardware
60 * feature. Alternatively, you can check for telephony availability at runtime using either
61 * {@link android.content.pm.PackageManager#hasSystemFeature
62 * hasSystemFeature(PackageManager.FEATURE_TELEPHONY)} or {@link
63 * android.telephony.TelephonyManager#getPhoneType}.</p>
64 *
65 * <h3>Creating an SMS app</h3>
66 *
67 * <p>Only the default SMS app (selected by the user in system settings) is able to write to the
68 * SMS Provider (the tables defined within the {@code Telephony} class) and only the default SMS
69 * app receives the {@link android.provider.Telephony.Sms.Intents#SMS_DELIVER_ACTION} broadcast
70 * when the user receives an SMS or the {@link
71 * android.provider.Telephony.Sms.Intents#WAP_PUSH_DELIVER_ACTION} broadcast when the user
72 * receives an MMS.</p>
73 *
74 * <p>Any app that wants to behave as the user's default SMS app must handle the following intents:
75 * <ul>
76 * <li>In a broadcast receiver, include an intent filter for {@link Sms.Intents#SMS_DELIVER_ACTION}
77 * (<code>"android.provider.Telephony.SMS_DELIVER"</code>). The broadcast receiver must also
78 * require the {@link android.Manifest.permission#BROADCAST_SMS} permission.
79 * <p>This allows your app to directly receive incoming SMS messages.</p></li>
80 * <li>In a broadcast receiver, include an intent filter for {@link
81 * Sms.Intents#WAP_PUSH_DELIVER_ACTION}} ({@code "android.provider.Telephony.WAP_PUSH_DELIVER"})
82 * with the MIME type <code>"application/vnd.wap.mms-message"</code>.
83 * The broadcast receiver must also require the {@link
84 * android.Manifest.permission#BROADCAST_WAP_PUSH} permission.
85 * <p>This allows your app to directly receive incoming MMS messages.</p></li>
86 * <li>In your activity that delivers new messages, include an intent filter for
87 * {@link android.content.Intent#ACTION_SENDTO} (<code>"android.intent.action.SENDTO"
88 * </code>) with schemas, <code>sms:</code>, <code>smsto:</code>, <code>mms:</code>, and
89 * <code>mmsto:</code>.
90 * <p>This allows your app to receive intents from other apps that want to deliver a
91 * message.</p></li>
92 * <li>In a service, include an intent filter for {@link
93 * android.telephony.TelephonyManager#ACTION_RESPOND_VIA_MESSAGE}
94 * (<code>"android.intent.action.RESPOND_VIA_MESSAGE"</code>) with schemas,
95 * <code>sms:</code>, <code>smsto:</code>, <code>mms:</code>, and <code>mmsto:</code>.
96 * This service must also require the {@link
97 * android.Manifest.permission#SEND_RESPOND_VIA_MESSAGE} permission.
98 * <p>This allows users to respond to incoming phone calls with an immediate text message
99 * using your app.</p></li>
100 * </ul>
101 *
102 * <p>Other apps that are not selected as the default SMS app can only <em>read</em> the SMS
103 * Provider, but may also be notified when a new SMS arrives by listening for the {@link
104 * Sms.Intents#SMS_RECEIVED_ACTION}
105 * broadcast, which is a non-abortable broadcast that may be delivered to multiple apps. This
106 * broadcast is intended for apps that&mdash;while not selected as the default SMS app&mdash;need to
107 * read special incoming messages such as to perform phone number verification.</p>
108 *
109 * <p>For more information about building SMS apps, read the blog post, <a
110 * href="http://android-developers.blogspot.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html"
111 * >Getting Your SMS Apps Ready for KitKat</a>.</p>
112 *
113 */
114public final class Telephony {
115 private static final String TAG = "Telephony";
116
117 /**
118 * Not instantiable.
119 * @hide
120 */
121 private Telephony() {
122 }
123
124 /**
125 * Base columns for tables that contain text-based SMSs.
126 */
127 public interface TextBasedSmsColumns {
128
129 /** Message type: all messages. */
130 public static final int MESSAGE_TYPE_ALL = 0;
131
132 /** Message type: inbox. */
133 public static final int MESSAGE_TYPE_INBOX = 1;
134
135 /** Message type: sent messages. */
136 public static final int MESSAGE_TYPE_SENT = 2;
137
138 /** Message type: drafts. */
139 public static final int MESSAGE_TYPE_DRAFT = 3;
140
141 /** Message type: outbox. */
142 public static final int MESSAGE_TYPE_OUTBOX = 4;
143
144 /** Message type: failed outgoing message. */
145 public static final int MESSAGE_TYPE_FAILED = 5;
146
147 /** Message type: queued to send later. */
148 public static final int MESSAGE_TYPE_QUEUED = 6;
149
150 /**
151 * The type of message.
152 * <P>Type: INTEGER</P>
153 */
154 public static final String TYPE = "type";
155
156 /**
157 * The thread ID of the message.
158 * <P>Type: INTEGER</P>
159 */
160 public static final String THREAD_ID = "thread_id";
161
162 /**
163 * The address of the other party.
164 * <P>Type: TEXT</P>
165 */
166 public static final String ADDRESS = "address";
167
168 /**
169 * The date the message was received.
170 * <P>Type: INTEGER (long)</P>
171 */
172 public static final String DATE = "date";
173
174 /**
175 * The date the message was sent.
176 * <P>Type: INTEGER (long)</P>
177 */
178 public static final String DATE_SENT = "date_sent";
179
180 /**
181 * Has the message been read?
182 * <P>Type: INTEGER (boolean)</P>
183 */
184 public static final String READ = "read";
185
186 /**
187 * Has the message been seen by the user? The "seen" flag determines
188 * whether we need to show a notification.
189 * <P>Type: INTEGER (boolean)</P>
190 */
191 public static final String SEEN = "seen";
192
193 /**
194 * {@code TP-Status} value for the message, or -1 if no status has been received.
195 * <P>Type: INTEGER</P>
196 */
197 public static final String STATUS = "status";
198
199 /** TP-Status: no status received. */
200 public static final int STATUS_NONE = -1;
201 /** TP-Status: complete. */
202 public static final int STATUS_COMPLETE = 0;
203 /** TP-Status: pending. */
204 public static final int STATUS_PENDING = 32;
205 /** TP-Status: failed. */
206 public static final int STATUS_FAILED = 64;
207
208 /**
209 * The subject of the message, if present.
210 * <P>Type: TEXT</P>
211 */
212 public static final String SUBJECT = "subject";
213
214 /**
215 * The body of the message.
216 * <P>Type: TEXT</P>
217 */
218 public static final String BODY = "body";
219
220 /**
221 * The ID of the sender of the conversation, if present.
222 * <P>Type: INTEGER (reference to item in {@code content://contacts/people})</P>
223 */
224 public static final String PERSON = "person";
225
226 /**
227 * The protocol identifier code.
228 * <P>Type: INTEGER</P>
229 */
230 public static final String PROTOCOL = "protocol";
231
232 /**
233 * Is the {@code TP-Reply-Path} flag set?
234 * <P>Type: BOOLEAN</P>
235 */
236 public static final String REPLY_PATH_PRESENT = "reply_path_present";
237
238 /**
239 * The service center (SC) through which to send the message, if present.
240 * <P>Type: TEXT</P>
241 */
242 public static final String SERVICE_CENTER = "service_center";
243
244 /**
245 * Is the message locked?
246 * <P>Type: INTEGER (boolean)</P>
247 */
248 public static final String LOCKED = "locked";
249
250 /**
251 * The subscription to which the message belongs to. Its value will be
252 * < 0 if the sub id cannot be determined.
253 * <p>Type: INTEGER (long) </p>
254 */
255 public static final String SUBSCRIPTION_ID = "sub_id";
256
257 /**
258 * The MTU size of the mobile interface to which the APN connected
259 * @hide
260 */
261 public static final String MTU = "mtu";
262
263 /**
264 * Error code associated with sending or receiving this message
265 * <P>Type: INTEGER</P>
266 */
267 public static final String ERROR_CODE = "error_code";
268
269 /**
270 * The identity of the sender of a sent message. It is
271 * usually the package name of the app which sends the message.
272 * <p class="note"><strong>Note:</strong>
273 * This column is read-only. It is set by the provider and can not be changed by apps.
274 * <p>Type: TEXT</p>
275 */
276 public static final String CREATOR = "creator";
277 }
278
279 /**
Vasu Nori84db0f52018-02-14 15:14:32 -0800280 * Columns in sms_changes table.
281 * @hide
282 */
283 public interface TextBasedSmsChangesColumns {
284 /**
285 * The {@code content://} style URL for this table.
286 * @hide
287 */
288 public static final Uri CONTENT_URI = Uri.parse("content://sms-changes");
289
290 /**
291 * Primary key.
292 * <P>Type: INTEGER (long)</P>
293 * @hide
294 */
295 public static final String ID = "_id";
296
297 /**
298 * Triggers on sms table create a row in this table for each update/delete.
299 * This column is the "_id" of the row from sms table that was updated/deleted.
300 * <P>Type: INTEGER (long)</P>
301 * @hide
302 */
303 public static final String ORIG_ROW_ID = "orig_rowid";
304
305 /**
306 * Triggers on sms table create a row in this table for each update/delete.
307 * This column is the "sub_id" of the row from sms table that was updated/deleted.
308 * @hide
309 * <P>Type: INTEGER (long)</P>
310 */
311 public static final String SUB_ID = "sub_id";
312
313 /**
314 * The type of operation that created this row.
315 * {@link #TYPE_UPDATE} = update op
316 * {@link #TYPE_DELETE} = delete op
317 * @hide
318 * <P>Type: INTEGER (long)</P>
319 */
320 public static final String TYPE = "type";
321
322 /**
323 * One of the possible values for the above column "type". Indicates it is an update op.
324 * @hide
325 */
326 public static final int TYPE_UPDATE = 0;
327
328 /**
329 * One of the possible values for the above column "type". Indicates it is a delete op.
330 * @hide
331 */
332 public static final int TYPE_DELETE = 1;
333
334 /**
335 * This column contains a non-null value only if the operation on sms table is an update op
336 * and the column "read" is changed by the update op.
337 * <P>Type: INTEGER (boolean)</P>
338 * @hide
339 */
340 public static final String NEW_READ_STATUS = "new_read_status";
341 }
342
343 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -0800344 * Contains all text-based SMS messages.
345 */
346 public static final class Sms implements BaseColumns, TextBasedSmsColumns {
347
348 /**
349 * Not instantiable.
350 * @hide
351 */
352 private Sms() {
353 }
354
355 /**
356 * Used to determine the currently configured default SMS package.
357 * @param context context of the requesting application
358 * @return package name for the default SMS package or null
359 */
360 public static String getDefaultSmsPackage(Context context) {
361 ComponentName component = SmsApplication.getDefaultSmsApplication(context, false);
362 if (component != null) {
363 return component.getPackageName();
364 }
365 return null;
366 }
367
368 /**
369 * Return cursor for table query.
370 * @hide
371 */
372 public static Cursor query(ContentResolver cr, String[] projection) {
373 return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
374 }
375
376 /**
377 * Return cursor for table query.
378 * @hide
379 */
Mathew Inwood8c854f82018-09-14 12:35:36 +0100380 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
Dan Willemsen4980bf42017-02-14 14:17:12 -0800381 public static Cursor query(ContentResolver cr, String[] projection,
382 String where, String orderBy) {
383 return cr.query(CONTENT_URI, projection, where,
384 null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
385 }
386
387 /**
388 * The {@code content://} style URL for this table.
389 */
390 public static final Uri CONTENT_URI = Uri.parse("content://sms");
391
392 /**
393 * The default sort order for this table.
394 */
395 public static final String DEFAULT_SORT_ORDER = "date DESC";
396
397 /**
398 * Add an SMS to the given URI.
399 *
400 * @param resolver the content resolver to use
401 * @param uri the URI to add the message to
402 * @param address the address of the sender
403 * @param body the body of the message
404 * @param subject the pseudo-subject of the message
405 * @param date the timestamp for the message
406 * @param read true if the message has been read, false if not
407 * @param deliveryReport true if a delivery report was requested, false if not
408 * @return the URI for the new message
409 * @hide
410 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100411 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800412 public static Uri addMessageToUri(ContentResolver resolver,
413 Uri uri, String address, String body, String subject,
414 Long date, boolean read, boolean deliveryReport) {
415 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
416 resolver, uri, address, body, subject, date, read, deliveryReport, -1L);
417 }
418
419 /**
420 * Add an SMS to the given URI.
421 *
422 * @param resolver the content resolver to use
423 * @param uri the URI to add the message to
424 * @param address the address of the sender
425 * @param body the body of the message
426 * @param subject the psuedo-subject of the message
427 * @param date the timestamp for the message
428 * @param read true if the message has been read, false if not
429 * @param deliveryReport true if a delivery report was requested, false if not
430 * @param subId the subscription which the message belongs to
431 * @return the URI for the new message
432 * @hide
433 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100434 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800435 public static Uri addMessageToUri(int subId, ContentResolver resolver,
436 Uri uri, String address, String body, String subject,
437 Long date, boolean read, boolean deliveryReport) {
438 return addMessageToUri(subId, resolver, uri, address, body, subject,
439 date, read, deliveryReport, -1L);
440 }
441
442 /**
443 * Add an SMS to the given URI with the specified thread ID.
444 *
445 * @param resolver the content resolver to use
446 * @param uri the URI to add the message to
447 * @param address the address of the sender
448 * @param body the body of the message
449 * @param subject the pseudo-subject of the message
450 * @param date the timestamp for the message
451 * @param read true if the message has been read, false if not
452 * @param deliveryReport true if a delivery report was requested, false if not
453 * @param threadId the thread_id of the message
454 * @return the URI for the new message
455 * @hide
456 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100457 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800458 public static Uri addMessageToUri(ContentResolver resolver,
459 Uri uri, String address, String body, String subject,
460 Long date, boolean read, boolean deliveryReport, long threadId) {
461 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
462 resolver, uri, address, body, subject,
463 date, read, deliveryReport, threadId);
464 }
465
466 /**
467 * Add an SMS to the given URI with thread_id specified.
468 *
469 * @param resolver the content resolver to use
470 * @param uri the URI to add the message to
471 * @param address the address of the sender
472 * @param body the body of the message
473 * @param subject the psuedo-subject of the message
474 * @param date the timestamp for the message
475 * @param read true if the message has been read, false if not
476 * @param deliveryReport true if a delivery report was requested, false if not
477 * @param threadId the thread_id of the message
478 * @param subId the subscription which the message belongs to
479 * @return the URI for the new message
480 * @hide
481 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100482 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800483 public static Uri addMessageToUri(int subId, ContentResolver resolver,
484 Uri uri, String address, String body, String subject,
485 Long date, boolean read, boolean deliveryReport, long threadId) {
486 ContentValues values = new ContentValues(8);
487 Rlog.v(TAG,"Telephony addMessageToUri sub id: " + subId);
488
489 values.put(SUBSCRIPTION_ID, subId);
490 values.put(ADDRESS, address);
491 if (date != null) {
492 values.put(DATE, date);
493 }
494 values.put(READ, read ? Integer.valueOf(1) : Integer.valueOf(0));
495 values.put(SUBJECT, subject);
496 values.put(BODY, body);
497 if (deliveryReport) {
498 values.put(STATUS, STATUS_PENDING);
499 }
500 if (threadId != -1L) {
501 values.put(THREAD_ID, threadId);
502 }
503 return resolver.insert(uri, values);
504 }
505
506 /**
507 * Move a message to the given folder.
508 *
509 * @param context the context to use
510 * @param uri the message to move
511 * @param folder the folder to move to
512 * @return true if the operation succeeded
513 * @hide
514 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100515 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800516 public static boolean moveMessageToFolder(Context context,
517 Uri uri, int folder, int error) {
518 if (uri == null) {
519 return false;
520 }
521
522 boolean markAsUnread = false;
523 boolean markAsRead = false;
524 switch(folder) {
525 case MESSAGE_TYPE_INBOX:
526 case MESSAGE_TYPE_DRAFT:
527 break;
528 case MESSAGE_TYPE_OUTBOX:
529 case MESSAGE_TYPE_SENT:
530 markAsRead = true;
531 break;
532 case MESSAGE_TYPE_FAILED:
533 case MESSAGE_TYPE_QUEUED:
534 markAsUnread = true;
535 break;
536 default:
537 return false;
538 }
539
540 ContentValues values = new ContentValues(3);
541
542 values.put(TYPE, folder);
543 if (markAsUnread) {
544 values.put(READ, 0);
545 } else if (markAsRead) {
546 values.put(READ, 1);
547 }
548 values.put(ERROR_CODE, error);
549
550 return 1 == SqliteWrapper.update(context, context.getContentResolver(),
551 uri, values, null, null);
552 }
553
554 /**
555 * Returns true iff the folder (message type) identifies an
556 * outgoing message.
557 * @hide
558 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100559 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800560 public static boolean isOutgoingFolder(int messageType) {
561 return (messageType == MESSAGE_TYPE_FAILED)
562 || (messageType == MESSAGE_TYPE_OUTBOX)
563 || (messageType == MESSAGE_TYPE_SENT)
564 || (messageType == MESSAGE_TYPE_QUEUED);
565 }
566
567 /**
568 * Contains all text-based SMS messages in the SMS app inbox.
569 */
570 public static final class Inbox implements BaseColumns, TextBasedSmsColumns {
571
572 /**
573 * Not instantiable.
574 * @hide
575 */
576 private Inbox() {
577 }
578
579 /**
580 * The {@code content://} style URL for this table.
581 */
582 public static final Uri CONTENT_URI = Uri.parse("content://sms/inbox");
583
584 /**
585 * The default sort order for this table.
586 */
587 public static final String DEFAULT_SORT_ORDER = "date DESC";
588
589 /**
590 * Add an SMS to the Draft box.
591 *
592 * @param resolver the content resolver to use
593 * @param address the address of the sender
594 * @param body the body of the message
595 * @param subject the pseudo-subject of the message
596 * @param date the timestamp for the message
597 * @param read true if the message has been read, false if not
598 * @return the URI for the new message
599 * @hide
600 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100601 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800602 public static Uri addMessage(ContentResolver resolver,
603 String address, String body, String subject, Long date,
604 boolean read) {
605 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
606 resolver, CONTENT_URI, address, body, subject, date, read, false);
607 }
608
609 /**
610 * Add an SMS to the Draft box.
611 *
612 * @param resolver the content resolver to use
613 * @param address the address of the sender
614 * @param body the body of the message
615 * @param subject the psuedo-subject of the message
616 * @param date the timestamp for the message
617 * @param read true if the message has been read, false if not
618 * @param subId the subscription which the message belongs to
619 * @return the URI for the new message
620 * @hide
621 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100622 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800623 public static Uri addMessage(int subId, ContentResolver resolver,
624 String address, String body, String subject, Long date, boolean read) {
625 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
626 subject, date, read, false);
627 }
628 }
629
630 /**
631 * Contains all sent text-based SMS messages in the SMS app.
632 */
633 public static final class Sent implements BaseColumns, TextBasedSmsColumns {
634
635 /**
636 * Not instantiable.
637 * @hide
638 */
639 private Sent() {
640 }
641
642 /**
643 * The {@code content://} style URL for this table.
644 */
645 public static final Uri CONTENT_URI = Uri.parse("content://sms/sent");
646
647 /**
648 * The default sort order for this table.
649 */
650 public static final String DEFAULT_SORT_ORDER = "date DESC";
651
652 /**
653 * Add an SMS to the Draft box.
654 *
655 * @param resolver the content resolver to use
656 * @param address the address of the sender
657 * @param body the body of the message
658 * @param subject the pseudo-subject of the message
659 * @param date the timestamp for the message
660 * @return the URI for the new message
661 * @hide
662 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100663 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800664 public static Uri addMessage(ContentResolver resolver,
665 String address, String body, String subject, Long date) {
666 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
667 resolver, CONTENT_URI, address, body, subject, date, true, false);
668 }
669
670 /**
671 * Add an SMS to the Draft box.
672 *
673 * @param resolver the content resolver to use
674 * @param address the address of the sender
675 * @param body the body of the message
676 * @param subject the psuedo-subject of the message
677 * @param date the timestamp for the message
678 * @param subId the subscription which the message belongs to
679 * @return the URI for the new message
680 * @hide
681 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100682 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800683 public static Uri addMessage(int subId, ContentResolver resolver,
684 String address, String body, String subject, Long date) {
685 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
686 subject, date, true, false);
687 }
688 }
689
690 /**
691 * Contains all sent text-based SMS messages in the SMS app.
692 */
693 public static final class Draft implements BaseColumns, TextBasedSmsColumns {
694
695 /**
696 * Not instantiable.
697 * @hide
698 */
699 private Draft() {
700 }
701
702 /**
703 * The {@code content://} style URL for this table.
704 */
705 public static final Uri CONTENT_URI = Uri.parse("content://sms/draft");
706
707 /**
708 * @hide
709 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100710 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800711 public static Uri addMessage(ContentResolver resolver,
712 String address, String body, String subject, Long date) {
713 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
714 resolver, CONTENT_URI, address, body, subject, date, true, false);
715 }
716
717 /**
718 * Add an SMS to the Draft box.
719 *
720 * @param resolver the content resolver to use
721 * @param address the address of the sender
722 * @param body the body of the message
723 * @param subject the psuedo-subject of the message
724 * @param date the timestamp for the message
725 * @param subId the subscription which the message belongs to
726 * @return the URI for the new message
727 * @hide
728 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100729 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800730 public static Uri addMessage(int subId, ContentResolver resolver,
731 String address, String body, String subject, Long date) {
732 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
733 subject, date, true, false);
734 }
735
736 /**
737 * The default sort order for this table.
738 */
739 public static final String DEFAULT_SORT_ORDER = "date DESC";
740 }
741
742 /**
743 * Contains all pending outgoing text-based SMS messages.
744 */
745 public static final class Outbox implements BaseColumns, TextBasedSmsColumns {
746
747 /**
748 * Not instantiable.
749 * @hide
750 */
751 private Outbox() {
752 }
753
754 /**
755 * The {@code content://} style URL for this table.
756 */
757 public static final Uri CONTENT_URI = Uri.parse("content://sms/outbox");
758
759 /**
760 * The default sort order for this table.
761 */
762 public static final String DEFAULT_SORT_ORDER = "date DESC";
763
764 /**
765 * Add an SMS to the outbox.
766 *
767 * @param resolver the content resolver to use
768 * @param address the address of the sender
769 * @param body the body of the message
770 * @param subject the pseudo-subject of the message
771 * @param date the timestamp for the message
772 * @param deliveryReport whether a delivery report was requested for the message
773 * @return the URI for the new message
774 * @hide
775 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100776 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800777 public static Uri addMessage(ContentResolver resolver,
778 String address, String body, String subject, Long date,
779 boolean deliveryReport, long threadId) {
780 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
781 resolver, CONTENT_URI, address, body, subject, date,
782 true, deliveryReport, threadId);
783 }
784
785 /**
786 * Add an SMS to the Out box.
787 *
788 * @param resolver the content resolver to use
789 * @param address the address of the sender
790 * @param body the body of the message
791 * @param subject the psuedo-subject of the message
792 * @param date the timestamp for the message
793 * @param deliveryReport whether a delivery report was requested for the message
794 * @param subId the subscription which the message belongs to
795 * @return the URI for the new message
796 * @hide
797 */
798 public static Uri addMessage(int subId, ContentResolver resolver,
799 String address, String body, String subject, Long date,
800 boolean deliveryReport, long threadId) {
801 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
802 subject, date, true, deliveryReport, threadId);
803 }
804 }
805
806 /**
807 * Contains all sent text-based SMS messages in the SMS app.
808 */
809 public static final class Conversations
810 implements BaseColumns, TextBasedSmsColumns {
811
812 /**
813 * Not instantiable.
814 * @hide
815 */
816 private Conversations() {
817 }
818
819 /**
820 * The {@code content://} style URL for this table.
821 */
822 public static final Uri CONTENT_URI = Uri.parse("content://sms/conversations");
823
824 /**
825 * The default sort order for this table.
826 */
827 public static final String DEFAULT_SORT_ORDER = "date DESC";
828
829 /**
830 * The first 45 characters of the body of the message.
831 * <P>Type: TEXT</P>
832 */
833 public static final String SNIPPET = "snippet";
834
835 /**
836 * The number of messages in the conversation.
837 * <P>Type: INTEGER</P>
838 */
839 public static final String MESSAGE_COUNT = "msg_count";
840 }
841
842 /**
843 * Contains constants for SMS related Intents that are broadcast.
844 */
845 public static final class Intents {
846
847 /**
848 * Not instantiable.
849 * @hide
850 */
851 private Intents() {
852 }
853
854 /**
855 * Set by BroadcastReceiver to indicate that the message was handled
856 * successfully.
857 */
858 public static final int RESULT_SMS_HANDLED = 1;
859
860 /**
861 * Set by BroadcastReceiver to indicate a generic error while
862 * processing the message.
863 */
864 public static final int RESULT_SMS_GENERIC_ERROR = 2;
865
866 /**
867 * Set by BroadcastReceiver to indicate insufficient memory to store
868 * the message.
869 */
870 public static final int RESULT_SMS_OUT_OF_MEMORY = 3;
871
872 /**
873 * Set by BroadcastReceiver to indicate that the message, while
874 * possibly valid, is of a format or encoding that is not
875 * supported.
876 */
877 public static final int RESULT_SMS_UNSUPPORTED = 4;
878
879 /**
880 * Set by BroadcastReceiver to indicate a duplicate incoming message.
881 */
882 public static final int RESULT_SMS_DUPLICATED = 5;
883
884 /**
885 * Activity action: Ask the user to change the default
886 * SMS application. This will show a dialog that asks the
887 * user whether they want to replace the current default
888 * SMS application with the one specified in
889 * {@link #EXTRA_PACKAGE_NAME}.
890 */
891 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
892 public static final String ACTION_CHANGE_DEFAULT =
893 "android.provider.Telephony.ACTION_CHANGE_DEFAULT";
894
895 /**
896 * The PackageName string passed in as an
897 * extra for {@link #ACTION_CHANGE_DEFAULT}
898 *
899 * @see #ACTION_CHANGE_DEFAULT
900 */
901 public static final String EXTRA_PACKAGE_NAME = "package";
902
903 /**
904 * Broadcast Action: A new text-based SMS message has been received
905 * by the device. This intent will only be delivered to the default
906 * sms app. That app is responsible for writing the message and notifying
907 * the user. The intent will have the following extra values:</p>
908 *
909 * <ul>
910 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
911 * that make up the message.</li>
912 * <li><em>"format"</em> - A String describing the format of the PDUs. It can
913 * be either "3gpp" or "3gpp2".</li>
914 * <li><em>"subscription"</em> - An optional long value of the subscription id which
915 * received the message.</li>
916 * <li><em>"slot"</em> - An optional int value of the SIM slot containing the
917 * subscription.</li>
918 * <li><em>"phone"</em> - An optional int value of the phone id associated with the
919 * subscription.</li>
920 * <li><em>"errorCode"</em> - An optional int error code associated with receiving
921 * the message.</li>
922 * </ul>
923 *
924 * <p>The extra values can be extracted using
925 * {@link #getMessagesFromIntent(Intent)}.</p>
926 *
927 * <p>If a BroadcastReceiver encounters an error while processing
928 * this intent it should set the result code appropriately.</p>
929 *
930 * <p class="note"><strong>Note:</strong>
931 * The broadcast receiver that filters for this intent must declare
932 * {@link android.Manifest.permission#BROADCAST_SMS} as a required permission in
933 * the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code
934 * <receiver>}</a> tag.
935 *
936 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
937 */
938 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
939 public static final String SMS_DELIVER_ACTION =
940 "android.provider.Telephony.SMS_DELIVER";
941
942 /**
943 * Broadcast Action: A new text-based SMS message has been received
944 * by the device. This intent will be delivered to all registered
945 * receivers as a notification. These apps are not expected to write the
946 * message or notify the user. The intent will have the following extra
947 * values:</p>
948 *
949 * <ul>
950 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
951 * that make up the message.</li>
952 * </ul>
953 *
954 * <p>The extra values can be extracted using
955 * {@link #getMessagesFromIntent(Intent)}.</p>
956 *
957 * <p>If a BroadcastReceiver encounters an error while processing
958 * this intent it should set the result code appropriately.</p>
959 *
960 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
961 */
962 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
963 public static final String SMS_RECEIVED_ACTION =
964 "android.provider.Telephony.SMS_RECEIVED";
965
966 /**
967 * Broadcast Action: A new data based SMS message has been received
968 * by the device. This intent will be delivered to all registered
969 * receivers as a notification. The intent will have the following extra
970 * values:</p>
971 *
972 * <ul>
973 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
974 * that make up the message.</li>
975 * </ul>
976 *
977 * <p>The extra values can be extracted using
978 * {@link #getMessagesFromIntent(Intent)}.</p>
979 *
980 * <p>If a BroadcastReceiver encounters an error while processing
981 * this intent it should set the result code appropriately.</p>
982 *
983 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
984 */
985 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
986 public static final String DATA_SMS_RECEIVED_ACTION =
987 "android.intent.action.DATA_SMS_RECEIVED";
988
989 /**
990 * Broadcast Action: A new WAP PUSH message has been received by the
991 * device. This intent will only be delivered to the default
992 * sms app. That app is responsible for writing the message and notifying
993 * the user. The intent will have the following extra values:</p>
994 *
995 * <ul>
996 * <li><em>"transactionId"</em> - (Integer) The WAP transaction ID</li>
997 * <li><em>"pduType"</em> - (Integer) The WAP PDU type</li>
998 * <li><em>"header"</em> - (byte[]) The header of the message</li>
999 * <li><em>"data"</em> - (byte[]) The data payload of the message</li>
1000 * <li><em>"contentTypeParameters" </em>
1001 * -(HashMap&lt;String,String&gt;) Any parameters associated with the content type
1002 * (decoded from the WSP Content-Type header)</li>
1003 * <li><em>"subscription"</em> - An optional long value of the subscription id which
1004 * received the message.</li>
1005 * <li><em>"slot"</em> - An optional int value of the SIM slot containing the
1006 * subscription.</li>
1007 * <li><em>"phone"</em> - An optional int value of the phone id associated with the
1008 * subscription.</li>
1009 * </ul>
1010 *
1011 * <p>If a BroadcastReceiver encounters an error while processing
1012 * this intent it should set the result code appropriately.</p>
1013 *
1014 * <p>The contentTypeParameters extra value is map of content parameters keyed by
1015 * their names.</p>
1016 *
1017 * <p>If any unassigned well-known parameters are encountered, the key of the map will
1018 * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter. If
1019 * a parameter has No-Value the value in the map will be null.</p>
1020 *
1021 * <p>Requires {@link android.Manifest.permission#RECEIVE_MMS} or
1022 * {@link android.Manifest.permission#RECEIVE_WAP_PUSH} (depending on WAP PUSH type) to
1023 * receive.</p>
1024 *
1025 * <p class="note"><strong>Note:</strong>
1026 * The broadcast receiver that filters for this intent must declare
1027 * {@link android.Manifest.permission#BROADCAST_WAP_PUSH} as a required permission in
1028 * the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code
1029 * <receiver>}</a> tag.
1030 */
1031 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1032 public static final String WAP_PUSH_DELIVER_ACTION =
1033 "android.provider.Telephony.WAP_PUSH_DELIVER";
1034
1035 /**
1036 * Broadcast Action: A new WAP PUSH message has been received by the
1037 * device. This intent will be delivered to all registered
1038 * receivers as a notification. These apps are not expected to write the
1039 * message or notify the user. The intent will have the following extra
1040 * values:</p>
1041 *
1042 * <ul>
1043 * <li><em>"transactionId"</em> - (Integer) The WAP transaction ID</li>
1044 * <li><em>"pduType"</em> - (Integer) The WAP PDU type</li>
1045 * <li><em>"header"</em> - (byte[]) The header of the message</li>
1046 * <li><em>"data"</em> - (byte[]) The data payload of the message</li>
1047 * <li><em>"contentTypeParameters"</em>
1048 * - (HashMap&lt;String,String&gt;) Any parameters associated with the content type
1049 * (decoded from the WSP Content-Type header)</li>
1050 * </ul>
1051 *
1052 * <p>If a BroadcastReceiver encounters an error while processing
1053 * this intent it should set the result code appropriately.</p>
1054 *
1055 * <p>The contentTypeParameters extra value is map of content parameters keyed by
1056 * their names.</p>
1057 *
1058 * <p>If any unassigned well-known parameters are encountered, the key of the map will
1059 * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter. If
1060 * a parameter has No-Value the value in the map will be null.</p>
1061 *
1062 * <p>Requires {@link android.Manifest.permission#RECEIVE_MMS} or
1063 * {@link android.Manifest.permission#RECEIVE_WAP_PUSH} (depending on WAP PUSH type) to
1064 * receive.</p>
1065 */
1066 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1067 public static final String WAP_PUSH_RECEIVED_ACTION =
1068 "android.provider.Telephony.WAP_PUSH_RECEIVED";
1069
1070 /**
1071 * Broadcast Action: A new Cell Broadcast message has been received
1072 * by the device. The intent will have the following extra
1073 * values:</p>
1074 *
1075 * <ul>
1076 * <li><em>"message"</em> - An SmsCbMessage object containing the broadcast message
1077 * data. This is not an emergency alert, so ETWS and CMAS data will be null.</li>
1078 * </ul>
1079 *
1080 * <p>The extra values can be extracted using
1081 * {@link #getMessagesFromIntent(Intent)}.</p>
1082 *
1083 * <p>If a BroadcastReceiver encounters an error while processing
1084 * this intent it should set the result code appropriately.</p>
1085 *
1086 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1087 */
1088 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1089 public static final String SMS_CB_RECEIVED_ACTION =
1090 "android.provider.Telephony.SMS_CB_RECEIVED";
1091
1092 /**
1093 * Action: A SMS based carrier provision intent. Used to identify default
1094 * carrier provisioning app on the device.
1095 * @hide
1096 */
1097 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1098 @TestApi
1099 public static final String SMS_CARRIER_PROVISION_ACTION =
1100 "android.provider.Telephony.SMS_CARRIER_PROVISION";
1101
1102 /**
1103 * Broadcast Action: A new Emergency Broadcast message has been received
1104 * by the device. The intent will have the following extra
1105 * values:</p>
1106 *
1107 * <ul>
1108 * <li><em>"message"</em> - An SmsCbMessage object containing the broadcast message
1109 * data, including ETWS or CMAS warning notification info if present.</li>
1110 * </ul>
1111 *
1112 * <p>The extra values can be extracted using
1113 * {@link #getMessagesFromIntent(Intent)}.</p>
1114 *
1115 * <p>If a BroadcastReceiver encounters an error while processing
1116 * this intent it should set the result code appropriately.</p>
1117 *
1118 * <p>Requires {@link android.Manifest.permission#RECEIVE_EMERGENCY_BROADCAST} to
1119 * receive.</p>
1120 * @removed
1121 */
1122 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1123 public static final String SMS_EMERGENCY_CB_RECEIVED_ACTION =
1124 "android.provider.Telephony.SMS_EMERGENCY_CB_RECEIVED";
1125
1126 /**
1127 * Broadcast Action: A new CDMA SMS has been received containing Service Category
1128 * Program Data (updates the list of enabled broadcast channels). The intent will
1129 * have the following extra values:</p>
1130 *
1131 * <ul>
1132 * <li><em>"operations"</em> - An array of CdmaSmsCbProgramData objects containing
1133 * the service category operations (add/delete/clear) to perform.</li>
1134 * </ul>
1135 *
1136 * <p>The extra values can be extracted using
1137 * {@link #getMessagesFromIntent(Intent)}.</p>
1138 *
1139 * <p>If a BroadcastReceiver encounters an error while processing
1140 * this intent it should set the result code appropriately.</p>
1141 *
1142 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1143 */
1144 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1145 public static final String SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION =
1146 "android.provider.Telephony.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED";
1147
1148 /**
1149 * Broadcast Action: The SIM storage for SMS messages is full. If
1150 * space is not freed, messages targeted for the SIM (class 2) may
1151 * not be saved.
1152 *
1153 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1154 */
1155 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1156 public static final String SIM_FULL_ACTION =
1157 "android.provider.Telephony.SIM_FULL";
1158
1159 /**
1160 * Broadcast Action: An incoming SMS has been rejected by the
1161 * telephony framework. This intent is sent in lieu of any
1162 * of the RECEIVED_ACTION intents. The intent will have the
1163 * following extra value:</p>
1164 *
1165 * <ul>
1166 * <li><em>"result"</em> - An int result code, e.g. {@link #RESULT_SMS_OUT_OF_MEMORY}
1167 * indicating the error returned to the network.</li>
1168 * </ul>
1169 *
1170 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1171 */
1172 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1173 public static final String SMS_REJECTED_ACTION =
1174 "android.provider.Telephony.SMS_REJECTED";
1175
1176 /**
1177 * Broadcast Action: An incoming MMS has been downloaded. The intent is sent to all
1178 * users, except for secondary users where SMS has been disabled and to managed
1179 * profiles.
1180 * @hide
1181 */
1182 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1183 public static final String MMS_DOWNLOADED_ACTION =
1184 "android.provider.Telephony.MMS_DOWNLOADED";
1185
1186 /**
Cassie5b97cf12018-02-22 09:58:33 -08001187 * Broadcast Action: A debug code has been entered in the dialer. This intent is
1188 * broadcast by the system and OEM telephony apps may need to receive these broadcasts.
1189 * These "secret codes" are used to activate developer menus by dialing certain codes.
1190 * And they are of the form {@code *#*#&lt;code&gt;#*#*}. The intent will have the data
1191 * URI: {@code android_secret_code://&lt;code&gt;}. It is possible that a manifest
1192 * receiver would be woken up even if it is not currently running.
1193 *
1194 * <p>Requires {@code android.Manifest.permission#CONTROL_INCALL_EXPERIENCE} to
1195 * send and receive.</p>
Cassie6d0a5712018-08-21 13:38:39 -07001196 * @deprecated it is no longer supported, use {@link
1197 * TelephonyManager#ACTION_SECRET_CODE} instead
Cassie866f4942018-01-19 17:23:36 -08001198 */
Cassie6d0a5712018-08-21 13:38:39 -07001199 @Deprecated
Cassie866f4942018-01-19 17:23:36 -08001200 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1201 public static final String SECRET_CODE_ACTION =
1202 "android.provider.Telephony.SECRET_CODE";
1203
1204 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08001205 * Broadcast action: When the default SMS package changes,
1206 * the previous default SMS package and the new default SMS
1207 * package are sent this broadcast to notify them of the change.
1208 * A boolean is specified in {@link #EXTRA_IS_DEFAULT_SMS_APP} to
1209 * indicate whether the package is the new default SMS package.
1210 */
1211 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1212 public static final String ACTION_DEFAULT_SMS_PACKAGE_CHANGED =
1213 "android.provider.action.DEFAULT_SMS_PACKAGE_CHANGED";
1214
1215 /**
1216 * The IsDefaultSmsApp boolean passed as an
1217 * extra for {@link #ACTION_DEFAULT_SMS_PACKAGE_CHANGED} to indicate whether the
1218 * SMS app is becoming the default SMS app or is no longer the default.
1219 *
1220 * @see #ACTION_DEFAULT_SMS_PACKAGE_CHANGED
1221 */
1222 public static final String EXTRA_IS_DEFAULT_SMS_APP =
1223 "android.provider.extra.IS_DEFAULT_SMS_APP";
1224
1225 /**
1226 * Broadcast action: When a change is made to the SmsProvider or
1227 * MmsProvider by a process other than the default SMS application,
1228 * this intent is broadcast to the default SMS application so it can
1229 * re-sync or update the change. The uri that was used to call the provider
1230 * can be retrieved from the intent with getData(). The actual affected uris
1231 * (which would depend on the selection specified) are not included.
1232 */
1233 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1234 public static final String ACTION_EXTERNAL_PROVIDER_CHANGE =
1235 "android.provider.action.EXTERNAL_PROVIDER_CHANGE";
1236
1237 /**
Makoto Onukia042aaa2018-09-18 16:14:12 -07001238 * Same as {@link #ACTION_DEFAULT_SMS_PACKAGE_CHANGED} but it's implicit (e.g. sent to
1239 * all apps) and requires
1240 * {@link android.Manifest.permission#MONITOR_DEFAULT_SMS_PACKAGE} to receive.
1241 *
1242 * @hide
1243 */
1244 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1245 public static final String ACTION_DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL =
1246 "android.provider.action.DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL";
1247
1248 /**
Amit Mahajan8c1c45a2018-10-22 10:43:34 -07001249 * Broadcast action: When SMS-MMS db is being created. If file-based encryption is
1250 * supported, this broadcast indicates creation of the db in credential-encrypted
1251 * storage. A boolean is specified in {@link #EXTRA_IS_INITIAL_CREATE} to indicate if
1252 * this is the initial create of the db. Requires
1253 * {@link android.Manifest.permission#READ_SMS} to receive.
1254 *
1255 * @see #EXTRA_IS_INITIAL_CREATE
1256 *
1257 * @hide
1258 */
1259 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1260 public static final String ACTION_SMS_MMS_DB_CREATED =
1261 "android.provider.action.SMS_MMS_DB_CREATED";
1262
1263 /**
1264 * Boolean flag passed as an extra with {@link #ACTION_SMS_MMS_DB_CREATED} to indicate
1265 * whether the DB creation is the initial creation on the device, that is it is after a
1266 * factory-data reset or a new device. Any subsequent creations of the DB (which
1267 * happens only in error scenarios) will have this flag set to false.
1268 *
1269 * @see #ACTION_SMS_MMS_DB_CREATED
1270 *
1271 * @hide
1272 */
1273 public static final String EXTRA_IS_INITIAL_CREATE =
1274 "android.provider.extra.IS_INITIAL_CREATE";
Jayachandran C349b9ba2018-10-30 15:09:06 -07001275
1276 /**
1277 * Broadcast intent action indicating that the telephony provider SMS MMS database is
1278 * corrupted. A boolean is specified in {@link #EXTRA_IS_CORRUPTED} to indicate if the
1279 * database is corrupted. Requires the
1280 * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE permission.
1281 *
1282 * @hide
1283 */
1284 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1285 @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
1286 public static final String ACTION_SMS_MMS_DB_LOST =
1287 "android.provider.action.SMS_MMS_DB_LOST";
1288
1289 /**
1290 * Boolean flag passed as an extra with {@link #ACTION_SMS_MMS_DB_LOST} to indicate
1291 * whether the DB got corrupted or not.
1292 *
1293 * @see #ACTION_SMS_MMS_DB_LOST
1294 *
1295 * @hide
1296 */
1297 public static final String EXTRA_IS_CORRUPTED =
1298 "android.provider.extra.IS_CORRUPTED";
1299
Amit Mahajan8c1c45a2018-10-22 10:43:34 -07001300 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08001301 * Read the PDUs out of an {@link #SMS_RECEIVED_ACTION} or a
1302 * {@link #DATA_SMS_RECEIVED_ACTION} intent.
1303 *
1304 * @param intent the intent to read from
1305 * @return an array of SmsMessages for the PDUs
1306 */
1307 public static SmsMessage[] getMessagesFromIntent(Intent intent) {
1308 Object[] messages;
1309 try {
1310 messages = (Object[]) intent.getSerializableExtra("pdus");
1311 }
1312 catch (ClassCastException e) {
1313 Rlog.e(TAG, "getMessagesFromIntent: " + e);
1314 return null;
1315 }
1316
1317 if (messages == null) {
1318 Rlog.e(TAG, "pdus does not exist in the intent");
1319 return null;
1320 }
1321
1322 String format = intent.getStringExtra("format");
1323 int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
1324 SubscriptionManager.getDefaultSmsSubscriptionId());
1325
1326 Rlog.v(TAG, " getMessagesFromIntent sub_id : " + subId);
1327
1328 int pduCount = messages.length;
1329 SmsMessage[] msgs = new SmsMessage[pduCount];
1330
1331 for (int i = 0; i < pduCount; i++) {
1332 byte[] pdu = (byte[]) messages[i];
1333 msgs[i] = SmsMessage.createFromPdu(pdu, format);
1334 if (msgs[i] != null) msgs[i].setSubId(subId);
1335 }
1336 return msgs;
1337 }
1338 }
1339 }
1340
1341 /**
pkanwar16b8a0d2017-06-07 10:59:41 -07001342 * Base column for the table that contain Carrier Public key.
1343 * @hide
1344 */
1345 public interface CarrierColumns extends BaseColumns {
1346
1347 public static final String MCC = "mcc";
1348 public static final String MNC = "mnc";
1349 public static final String KEY_TYPE = "key_type";
1350 public static final String MVNO_TYPE = "mvno_type";
1351 public static final String MVNO_MATCH_DATA = "mvno_match_data";
1352 public static final String PUBLIC_KEY = "public_key";
1353 public static final String KEY_IDENTIFIER = "key_identifier";
1354 public static final String EXPIRATION_TIME = "expiration_time";
1355 public static final String LAST_MODIFIED = "last_modified";
1356
1357 /**
1358 * The {@code content://} style URL for this table.
1359 * @hide
1360 */
1361 public static final Uri CONTENT_URI = Uri.parse("content://carrier_information/carrier");
1362 }
1363
1364 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08001365 * Base columns for tables that contain MMSs.
1366 */
1367 public interface BaseMmsColumns extends BaseColumns {
1368
1369 /** Message box: all messages. */
1370 public static final int MESSAGE_BOX_ALL = 0;
1371 /** Message box: inbox. */
1372 public static final int MESSAGE_BOX_INBOX = 1;
1373 /** Message box: sent messages. */
1374 public static final int MESSAGE_BOX_SENT = 2;
1375 /** Message box: drafts. */
1376 public static final int MESSAGE_BOX_DRAFTS = 3;
1377 /** Message box: outbox. */
1378 public static final int MESSAGE_BOX_OUTBOX = 4;
1379 /** Message box: failed. */
1380 public static final int MESSAGE_BOX_FAILED = 5;
1381
1382 /**
1383 * The thread ID of the message.
1384 * <P>Type: INTEGER (long)</P>
1385 */
1386 public static final String THREAD_ID = "thread_id";
1387
1388 /**
1389 * The date the message was received.
1390 * <P>Type: INTEGER (long)</P>
1391 */
1392 public static final String DATE = "date";
1393
1394 /**
1395 * The date the message was sent.
1396 * <P>Type: INTEGER (long)</P>
1397 */
1398 public static final String DATE_SENT = "date_sent";
1399
1400 /**
1401 * The box which the message belongs to, e.g. {@link #MESSAGE_BOX_INBOX}.
1402 * <P>Type: INTEGER</P>
1403 */
1404 public static final String MESSAGE_BOX = "msg_box";
1405
1406 /**
1407 * Has the message been read?
1408 * <P>Type: INTEGER (boolean)</P>
1409 */
1410 public static final String READ = "read";
1411
1412 /**
1413 * Has the message been seen by the user? The "seen" flag determines
1414 * whether we need to show a new message notification.
1415 * <P>Type: INTEGER (boolean)</P>
1416 */
1417 public static final String SEEN = "seen";
1418
1419 /**
1420 * Does the message have only a text part (can also have a subject) with
1421 * no picture, slideshow, sound, etc. parts?
1422 * <P>Type: INTEGER (boolean)</P>
1423 */
1424 public static final String TEXT_ONLY = "text_only";
1425
1426 /**
1427 * The {@code Message-ID} of the message.
1428 * <P>Type: TEXT</P>
1429 */
1430 public static final String MESSAGE_ID = "m_id";
1431
1432 /**
1433 * The subject of the message, if present.
1434 * <P>Type: TEXT</P>
1435 */
1436 public static final String SUBJECT = "sub";
1437
1438 /**
1439 * The character set of the subject, if present.
1440 * <P>Type: INTEGER</P>
1441 */
1442 public static final String SUBJECT_CHARSET = "sub_cs";
1443
1444 /**
1445 * The {@code Content-Type} of the message.
1446 * <P>Type: TEXT</P>
1447 */
1448 public static final String CONTENT_TYPE = "ct_t";
1449
1450 /**
1451 * The {@code Content-Location} of the message.
1452 * <P>Type: TEXT</P>
1453 */
1454 public static final String CONTENT_LOCATION = "ct_l";
1455
1456 /**
1457 * The expiry time of the message.
1458 * <P>Type: INTEGER (long)</P>
1459 */
1460 public static final String EXPIRY = "exp";
1461
1462 /**
1463 * The class of the message.
1464 * <P>Type: TEXT</P>
1465 */
1466 public static final String MESSAGE_CLASS = "m_cls";
1467
1468 /**
1469 * The type of the message defined by MMS spec.
1470 * <P>Type: INTEGER</P>
1471 */
1472 public static final String MESSAGE_TYPE = "m_type";
1473
1474 /**
1475 * The version of the specification that this message conforms to.
1476 * <P>Type: INTEGER</P>
1477 */
1478 public static final String MMS_VERSION = "v";
1479
1480 /**
1481 * The size of the message.
1482 * <P>Type: INTEGER</P>
1483 */
1484 public static final String MESSAGE_SIZE = "m_size";
1485
1486 /**
1487 * The priority of the message.
1488 * <P>Type: INTEGER</P>
1489 */
1490 public static final String PRIORITY = "pri";
1491
1492 /**
1493 * The {@code read-report} of the message.
1494 * <P>Type: INTEGER (boolean)</P>
1495 */
1496 public static final String READ_REPORT = "rr";
1497
1498 /**
1499 * Is read report allowed?
1500 * <P>Type: INTEGER (boolean)</P>
1501 */
1502 public static final String REPORT_ALLOWED = "rpt_a";
1503
1504 /**
1505 * The {@code response-status} of the message.
1506 * <P>Type: INTEGER</P>
1507 */
1508 public static final String RESPONSE_STATUS = "resp_st";
1509
1510 /**
1511 * The {@code status} of the message.
1512 * <P>Type: INTEGER</P>
1513 */
1514 public static final String STATUS = "st";
1515
1516 /**
1517 * The {@code transaction-id} of the message.
1518 * <P>Type: TEXT</P>
1519 */
1520 public static final String TRANSACTION_ID = "tr_id";
1521
1522 /**
1523 * The {@code retrieve-status} of the message.
1524 * <P>Type: INTEGER</P>
1525 */
1526 public static final String RETRIEVE_STATUS = "retr_st";
1527
1528 /**
1529 * The {@code retrieve-text} of the message.
1530 * <P>Type: TEXT</P>
1531 */
1532 public static final String RETRIEVE_TEXT = "retr_txt";
1533
1534 /**
1535 * The character set of the retrieve-text.
1536 * <P>Type: INTEGER</P>
1537 */
1538 public static final String RETRIEVE_TEXT_CHARSET = "retr_txt_cs";
1539
1540 /**
1541 * The {@code read-status} of the message.
1542 * <P>Type: INTEGER</P>
1543 */
1544 public static final String READ_STATUS = "read_status";
1545
1546 /**
1547 * The {@code content-class} of the message.
1548 * <P>Type: INTEGER</P>
1549 */
1550 public static final String CONTENT_CLASS = "ct_cls";
1551
1552 /**
1553 * The {@code delivery-report} of the message.
1554 * <P>Type: INTEGER</P>
1555 */
1556 public static final String DELIVERY_REPORT = "d_rpt";
1557
1558 /**
1559 * The {@code delivery-time-token} of the message.
1560 * <P>Type: INTEGER</P>
1561 * @deprecated this column is no longer supported.
1562 * @hide
1563 */
1564 @Deprecated
1565 public static final String DELIVERY_TIME_TOKEN = "d_tm_tok";
1566
1567 /**
1568 * The {@code delivery-time} of the message.
1569 * <P>Type: INTEGER</P>
1570 */
1571 public static final String DELIVERY_TIME = "d_tm";
1572
1573 /**
1574 * The {@code response-text} of the message.
1575 * <P>Type: TEXT</P>
1576 */
1577 public static final String RESPONSE_TEXT = "resp_txt";
1578
1579 /**
1580 * The {@code sender-visibility} of the message.
1581 * <P>Type: TEXT</P>
1582 * @deprecated this column is no longer supported.
1583 * @hide
1584 */
1585 @Deprecated
1586 public static final String SENDER_VISIBILITY = "s_vis";
1587
1588 /**
1589 * The {@code reply-charging} of the message.
1590 * <P>Type: INTEGER</P>
1591 * @deprecated this column is no longer supported.
1592 * @hide
1593 */
1594 @Deprecated
1595 public static final String REPLY_CHARGING = "r_chg";
1596
1597 /**
1598 * The {@code reply-charging-deadline-token} of the message.
1599 * <P>Type: INTEGER</P>
1600 * @deprecated this column is no longer supported.
1601 * @hide
1602 */
1603 @Deprecated
1604 public static final String REPLY_CHARGING_DEADLINE_TOKEN = "r_chg_dl_tok";
1605
1606 /**
1607 * The {@code reply-charging-deadline} of the message.
1608 * <P>Type: INTEGER</P>
1609 * @deprecated this column is no longer supported.
1610 * @hide
1611 */
1612 @Deprecated
1613 public static final String REPLY_CHARGING_DEADLINE = "r_chg_dl";
1614
1615 /**
1616 * The {@code reply-charging-id} of the message.
1617 * <P>Type: TEXT</P>
1618 * @deprecated this column is no longer supported.
1619 * @hide
1620 */
1621 @Deprecated
1622 public static final String REPLY_CHARGING_ID = "r_chg_id";
1623
1624 /**
1625 * The {@code reply-charging-size} of the message.
1626 * <P>Type: INTEGER</P>
1627 * @deprecated this column is no longer supported.
1628 * @hide
1629 */
1630 @Deprecated
1631 public static final String REPLY_CHARGING_SIZE = "r_chg_sz";
1632
1633 /**
1634 * The {@code previously-sent-by} of the message.
1635 * <P>Type: TEXT</P>
1636 * @deprecated this column is no longer supported.
1637 * @hide
1638 */
1639 @Deprecated
1640 public static final String PREVIOUSLY_SENT_BY = "p_s_by";
1641
1642 /**
1643 * The {@code previously-sent-date} of the message.
1644 * <P>Type: INTEGER</P>
1645 * @deprecated this column is no longer supported.
1646 * @hide
1647 */
1648 @Deprecated
1649 public static final String PREVIOUSLY_SENT_DATE = "p_s_d";
1650
1651 /**
1652 * The {@code store} of the message.
1653 * <P>Type: TEXT</P>
1654 * @deprecated this column is no longer supported.
1655 * @hide
1656 */
1657 @Deprecated
1658 public static final String STORE = "store";
1659
1660 /**
1661 * The {@code mm-state} of the message.
1662 * <P>Type: INTEGER</P>
1663 * @deprecated this column is no longer supported.
1664 * @hide
1665 */
1666 @Deprecated
1667 public static final String MM_STATE = "mm_st";
1668
1669 /**
1670 * The {@code mm-flags-token} of the message.
1671 * <P>Type: INTEGER</P>
1672 * @deprecated this column is no longer supported.
1673 * @hide
1674 */
1675 @Deprecated
1676 public static final String MM_FLAGS_TOKEN = "mm_flg_tok";
1677
1678 /**
1679 * The {@code mm-flags} of the message.
1680 * <P>Type: TEXT</P>
1681 * @deprecated this column is no longer supported.
1682 * @hide
1683 */
1684 @Deprecated
1685 public static final String MM_FLAGS = "mm_flg";
1686
1687 /**
1688 * The {@code store-status} of the message.
1689 * <P>Type: TEXT</P>
1690 * @deprecated this column is no longer supported.
1691 * @hide
1692 */
1693 @Deprecated
1694 public static final String STORE_STATUS = "store_st";
1695
1696 /**
1697 * The {@code store-status-text} of the message.
1698 * <P>Type: TEXT</P>
1699 * @deprecated this column is no longer supported.
1700 * @hide
1701 */
1702 @Deprecated
1703 public static final String STORE_STATUS_TEXT = "store_st_txt";
1704
1705 /**
1706 * The {@code stored} of the message.
1707 * <P>Type: TEXT</P>
1708 * @deprecated this column is no longer supported.
1709 * @hide
1710 */
1711 @Deprecated
1712 public static final String STORED = "stored";
1713
1714 /**
1715 * The {@code totals} of the message.
1716 * <P>Type: TEXT</P>
1717 * @deprecated this column is no longer supported.
1718 * @hide
1719 */
1720 @Deprecated
1721 public static final String TOTALS = "totals";
1722
1723 /**
1724 * The {@code mbox-totals} of the message.
1725 * <P>Type: TEXT</P>
1726 * @deprecated this column is no longer supported.
1727 * @hide
1728 */
1729 @Deprecated
1730 public static final String MBOX_TOTALS = "mb_t";
1731
1732 /**
1733 * The {@code mbox-totals-token} of the message.
1734 * <P>Type: INTEGER</P>
1735 * @deprecated this column is no longer supported.
1736 * @hide
1737 */
1738 @Deprecated
1739 public static final String MBOX_TOTALS_TOKEN = "mb_t_tok";
1740
1741 /**
1742 * The {@code quotas} of the message.
1743 * <P>Type: TEXT</P>
1744 * @deprecated this column is no longer supported.
1745 * @hide
1746 */
1747 @Deprecated
1748 public static final String QUOTAS = "qt";
1749
1750 /**
1751 * The {@code mbox-quotas} of the message.
1752 * <P>Type: TEXT</P>
1753 * @deprecated this column is no longer supported.
1754 * @hide
1755 */
1756 @Deprecated
1757 public static final String MBOX_QUOTAS = "mb_qt";
1758
1759 /**
1760 * The {@code mbox-quotas-token} of the message.
1761 * <P>Type: INTEGER</P>
1762 * @deprecated this column is no longer supported.
1763 * @hide
1764 */
1765 @Deprecated
1766 public static final String MBOX_QUOTAS_TOKEN = "mb_qt_tok";
1767
1768 /**
1769 * The {@code message-count} of the message.
1770 * <P>Type: INTEGER</P>
1771 * @deprecated this column is no longer supported.
1772 * @hide
1773 */
1774 @Deprecated
1775 public static final String MESSAGE_COUNT = "m_cnt";
1776
1777 /**
1778 * The {@code start} of the message.
1779 * <P>Type: INTEGER</P>
1780 * @deprecated this column is no longer supported.
1781 * @hide
1782 */
1783 @Deprecated
1784 public static final String START = "start";
1785
1786 /**
1787 * The {@code distribution-indicator} of the message.
1788 * <P>Type: TEXT</P>
1789 * @deprecated this column is no longer supported.
1790 * @hide
1791 */
1792 @Deprecated
1793 public static final String DISTRIBUTION_INDICATOR = "d_ind";
1794
1795 /**
1796 * The {@code element-descriptor} of the message.
1797 * <P>Type: TEXT</P>
1798 * @deprecated this column is no longer supported.
1799 * @hide
1800 */
1801 @Deprecated
1802 public static final String ELEMENT_DESCRIPTOR = "e_des";
1803
1804 /**
1805 * The {@code limit} of the message.
1806 * <P>Type: INTEGER</P>
1807 * @deprecated this column is no longer supported.
1808 * @hide
1809 */
1810 @Deprecated
1811 public static final String LIMIT = "limit";
1812
1813 /**
1814 * The {@code recommended-retrieval-mode} of the message.
1815 * <P>Type: INTEGER</P>
1816 * @deprecated this column is no longer supported.
1817 * @hide
1818 */
1819 @Deprecated
1820 public static final String RECOMMENDED_RETRIEVAL_MODE = "r_r_mod";
1821
1822 /**
1823 * The {@code recommended-retrieval-mode-text} of the message.
1824 * <P>Type: TEXT</P>
1825 * @deprecated this column is no longer supported.
1826 * @hide
1827 */
1828 @Deprecated
1829 public static final String RECOMMENDED_RETRIEVAL_MODE_TEXT = "r_r_mod_txt";
1830
1831 /**
1832 * The {@code status-text} of the message.
1833 * <P>Type: TEXT</P>
1834 * @deprecated this column is no longer supported.
1835 * @hide
1836 */
1837 @Deprecated
1838 public static final String STATUS_TEXT = "st_txt";
1839
1840 /**
1841 * The {@code applic-id} of the message.
1842 * <P>Type: TEXT</P>
1843 * @deprecated this column is no longer supported.
1844 * @hide
1845 */
1846 @Deprecated
1847 public static final String APPLIC_ID = "apl_id";
1848
1849 /**
1850 * The {@code reply-applic-id} of the message.
1851 * <P>Type: TEXT</P>
1852 * @deprecated this column is no longer supported.
1853 * @hide
1854 */
1855 @Deprecated
1856 public static final String REPLY_APPLIC_ID = "r_apl_id";
1857
1858 /**
1859 * The {@code aux-applic-id} of the message.
1860 * <P>Type: TEXT</P>
1861 * @deprecated this column is no longer supported.
1862 * @hide
1863 */
1864 @Deprecated
1865 public static final String AUX_APPLIC_ID = "aux_apl_id";
1866
1867 /**
1868 * The {@code drm-content} of the message.
1869 * <P>Type: TEXT</P>
1870 * @deprecated this column is no longer supported.
1871 * @hide
1872 */
1873 @Deprecated
1874 public static final String DRM_CONTENT = "drm_c";
1875
1876 /**
1877 * The {@code adaptation-allowed} of the message.
1878 * <P>Type: TEXT</P>
1879 * @deprecated this column is no longer supported.
1880 * @hide
1881 */
1882 @Deprecated
1883 public static final String ADAPTATION_ALLOWED = "adp_a";
1884
1885 /**
1886 * The {@code replace-id} of the message.
1887 * <P>Type: TEXT</P>
1888 * @deprecated this column is no longer supported.
1889 * @hide
1890 */
1891 @Deprecated
1892 public static final String REPLACE_ID = "repl_id";
1893
1894 /**
1895 * The {@code cancel-id} of the message.
1896 * <P>Type: TEXT</P>
1897 * @deprecated this column is no longer supported.
1898 * @hide
1899 */
1900 @Deprecated
1901 public static final String CANCEL_ID = "cl_id";
1902
1903 /**
1904 * The {@code cancel-status} of the message.
1905 * <P>Type: INTEGER</P>
1906 * @deprecated this column is no longer supported.
1907 * @hide
1908 */
1909 @Deprecated
1910 public static final String CANCEL_STATUS = "cl_st";
1911
1912 /**
1913 * Is the message locked?
1914 * <P>Type: INTEGER (boolean)</P>
1915 */
1916 public static final String LOCKED = "locked";
1917
1918 /**
1919 * The subscription to which the message belongs to. Its value will be
1920 * < 0 if the sub id cannot be determined.
1921 * <p>Type: INTEGER (long)</p>
1922 */
1923 public static final String SUBSCRIPTION_ID = "sub_id";
1924
1925 /**
1926 * The identity of the sender of a sent message. It is
1927 * usually the package name of the app which sends the message.
1928 * <p class="note"><strong>Note:</strong>
1929 * This column is read-only. It is set by the provider and can not be changed by apps.
1930 * <p>Type: TEXT</p>
1931 */
1932 public static final String CREATOR = "creator";
1933 }
1934
1935 /**
1936 * Columns for the "canonical_addresses" table used by MMS and SMS.
1937 */
1938 public interface CanonicalAddressesColumns extends BaseColumns {
1939 /**
1940 * An address used in MMS or SMS. Email addresses are
1941 * converted to lower case and are compared by string
1942 * equality. Other addresses are compared using
1943 * PHONE_NUMBERS_EQUAL.
1944 * <P>Type: TEXT</P>
1945 */
1946 public static final String ADDRESS = "address";
1947 }
1948
1949 /**
1950 * Columns for the "threads" table used by MMS and SMS.
1951 */
1952 public interface ThreadsColumns extends BaseColumns {
1953
1954 /**
1955 * The date at which the thread was created.
1956 * <P>Type: INTEGER (long)</P>
1957 */
1958 public static final String DATE = "date";
1959
1960 /**
1961 * A string encoding of the recipient IDs of the recipients of
1962 * the message, in numerical order and separated by spaces.
1963 * <P>Type: TEXT</P>
1964 */
1965 public static final String RECIPIENT_IDS = "recipient_ids";
1966
1967 /**
1968 * The message count of the thread.
1969 * <P>Type: INTEGER</P>
1970 */
1971 public static final String MESSAGE_COUNT = "message_count";
1972
1973 /**
1974 * Indicates whether all messages of the thread have been read.
1975 * <P>Type: INTEGER</P>
1976 */
1977 public static final String READ = "read";
1978
1979 /**
1980 * The snippet of the latest message in the thread.
1981 * <P>Type: TEXT</P>
1982 */
1983 public static final String SNIPPET = "snippet";
1984
1985 /**
1986 * The charset of the snippet.
1987 * <P>Type: INTEGER</P>
1988 */
1989 public static final String SNIPPET_CHARSET = "snippet_cs";
1990
1991 /**
1992 * Type of the thread, either {@link Threads#COMMON_THREAD} or
1993 * {@link Threads#BROADCAST_THREAD}.
1994 * <P>Type: INTEGER</P>
1995 */
1996 public static final String TYPE = "type";
1997
1998 /**
1999 * Indicates whether there is a transmission error in the thread.
2000 * <P>Type: INTEGER</P>
2001 */
2002 public static final String ERROR = "error";
2003
2004 /**
2005 * Indicates whether this thread contains any attachments.
2006 * <P>Type: INTEGER</P>
2007 */
2008 public static final String HAS_ATTACHMENT = "has_attachment";
2009
2010 /**
2011 * If the thread is archived
2012 * <P>Type: INTEGER (boolean)</P>
2013 */
2014 public static final String ARCHIVED = "archived";
2015 }
2016
2017 /**
2018 * Helper functions for the "threads" table used by MMS and SMS.
2019 */
2020 public static final class Threads implements ThreadsColumns {
2021
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002022 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002023 private static final String[] ID_PROJECTION = { BaseColumns._ID };
2024
2025 /**
2026 * Private {@code content://} style URL for this table. Used by
2027 * {@link #getOrCreateThreadId(android.content.Context, java.util.Set)}.
2028 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002029 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002030 private static final Uri THREAD_ID_CONTENT_URI = Uri.parse(
2031 "content://mms-sms/threadID");
2032
2033 /**
2034 * The {@code content://} style URL for this table, by conversation.
2035 */
2036 public static final Uri CONTENT_URI = Uri.withAppendedPath(
2037 MmsSms.CONTENT_URI, "conversations");
2038
2039 /**
2040 * The {@code content://} style URL for this table, for obsolete threads.
2041 */
2042 public static final Uri OBSOLETE_THREADS_URI = Uri.withAppendedPath(
2043 CONTENT_URI, "obsolete");
2044
2045 /** Thread type: common thread. */
2046 public static final int COMMON_THREAD = 0;
2047
2048 /** Thread type: broadcast thread. */
2049 public static final int BROADCAST_THREAD = 1;
2050
2051 /**
2052 * Not instantiable.
2053 * @hide
2054 */
2055 private Threads() {
2056 }
2057
2058 /**
2059 * This is a single-recipient version of {@code getOrCreateThreadId}.
2060 * It's convenient for use with SMS messages.
2061 * @param context the context object to use.
2062 * @param recipient the recipient to send to.
2063 */
2064 public static long getOrCreateThreadId(Context context, String recipient) {
2065 Set<String> recipients = new HashSet<String>();
2066
2067 recipients.add(recipient);
2068 return getOrCreateThreadId(context, recipients);
2069 }
2070
2071 /**
2072 * Given the recipients list and subject of an unsaved message,
2073 * return its thread ID. If the message starts a new thread,
2074 * allocate a new thread ID. Otherwise, use the appropriate
2075 * existing thread ID.
2076 *
2077 * <p>Find the thread ID of the same set of recipients (in any order,
2078 * without any additions). If one is found, return it. Otherwise,
2079 * return a unique thread ID.</p>
2080 */
2081 public static long getOrCreateThreadId(
2082 Context context, Set<String> recipients) {
2083 Uri.Builder uriBuilder = THREAD_ID_CONTENT_URI.buildUpon();
2084
2085 for (String recipient : recipients) {
2086 if (Mms.isEmailAddress(recipient)) {
2087 recipient = Mms.extractAddrSpec(recipient);
2088 }
2089
2090 uriBuilder.appendQueryParameter("recipient", recipient);
2091 }
2092
2093 Uri uri = uriBuilder.build();
2094 //if (DEBUG) Rlog.v(TAG, "getOrCreateThreadId uri: " + uri);
2095
2096 Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
2097 uri, ID_PROJECTION, null, null, null);
2098 if (cursor != null) {
2099 try {
2100 if (cursor.moveToFirst()) {
2101 return cursor.getLong(0);
2102 } else {
2103 Rlog.e(TAG, "getOrCreateThreadId returned no rows!");
2104 }
2105 } finally {
2106 cursor.close();
2107 }
2108 }
2109
2110 Rlog.e(TAG, "getOrCreateThreadId failed with " + recipients.size() + " recipients");
2111 throw new IllegalArgumentException("Unable to find or allocate a thread ID.");
2112 }
2113 }
2114
2115 /**
2116 * Contains all MMS messages.
2117 */
2118 public static final class Mms implements BaseMmsColumns {
2119
2120 /**
2121 * Not instantiable.
2122 * @hide
2123 */
2124 private Mms() {
2125 }
2126
2127 /**
2128 * The {@code content://} URI for this table.
2129 */
2130 public static final Uri CONTENT_URI = Uri.parse("content://mms");
2131
2132 /**
2133 * Content URI for getting MMS report requests.
2134 */
2135 public static final Uri REPORT_REQUEST_URI = Uri.withAppendedPath(
2136 CONTENT_URI, "report-request");
2137
2138 /**
2139 * Content URI for getting MMS report status.
2140 */
2141 public static final Uri REPORT_STATUS_URI = Uri.withAppendedPath(
2142 CONTENT_URI, "report-status");
2143
2144 /**
2145 * The default sort order for this table.
2146 */
2147 public static final String DEFAULT_SORT_ORDER = "date DESC";
2148
2149 /**
2150 * Regex pattern for names and email addresses.
2151 * <ul>
2152 * <li><em>mailbox</em> = {@code name-addr}</li>
2153 * <li><em>name-addr</em> = {@code [display-name] angle-addr}</li>
2154 * <li><em>angle-addr</em> = {@code [CFWS] "<" addr-spec ">" [CFWS]}</li>
2155 * </ul>
2156 * @hide
2157 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002158 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002159 public static final Pattern NAME_ADDR_EMAIL_PATTERN =
2160 Pattern.compile("\\s*(\"[^\"]*\"|[^<>\"]+)\\s*<([^<>]+)>\\s*");
2161
2162 /**
2163 * Helper method to query this table.
2164 * @hide
2165 */
2166 public static Cursor query(
2167 ContentResolver cr, String[] projection) {
2168 return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
2169 }
2170
2171 /**
2172 * Helper method to query this table.
2173 * @hide
2174 */
2175 public static Cursor query(
2176 ContentResolver cr, String[] projection,
2177 String where, String orderBy) {
2178 return cr.query(CONTENT_URI, projection,
2179 where, null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
2180 }
2181
2182 /**
2183 * Helper method to extract email address from address string.
2184 * @hide
2185 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002186 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002187 public static String extractAddrSpec(String address) {
2188 Matcher match = NAME_ADDR_EMAIL_PATTERN.matcher(address);
2189
2190 if (match.matches()) {
2191 return match.group(2);
2192 }
2193 return address;
2194 }
2195
2196 /**
2197 * Is the specified address an email address?
2198 *
2199 * @param address the input address to test
2200 * @return true if address is an email address; false otherwise.
2201 * @hide
2202 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002203 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002204 public static boolean isEmailAddress(String address) {
2205 if (TextUtils.isEmpty(address)) {
2206 return false;
2207 }
2208
2209 String s = extractAddrSpec(address);
2210 Matcher match = Patterns.EMAIL_ADDRESS.matcher(s);
2211 return match.matches();
2212 }
2213
2214 /**
2215 * Is the specified number a phone number?
2216 *
2217 * @param number the input number to test
2218 * @return true if number is a phone number; false otherwise.
2219 * @hide
2220 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002221 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002222 public static boolean isPhoneNumber(String number) {
2223 if (TextUtils.isEmpty(number)) {
2224 return false;
2225 }
2226
2227 Matcher match = Patterns.PHONE.matcher(number);
2228 return match.matches();
2229 }
2230
2231 /**
2232 * Contains all MMS messages in the MMS app inbox.
2233 */
2234 public static final class Inbox implements BaseMmsColumns {
2235
2236 /**
2237 * Not instantiable.
2238 * @hide
2239 */
2240 private Inbox() {
2241 }
2242
2243 /**
2244 * The {@code content://} style URL for this table.
2245 */
2246 public static final Uri
2247 CONTENT_URI = Uri.parse("content://mms/inbox");
2248
2249 /**
2250 * The default sort order for this table.
2251 */
2252 public static final String DEFAULT_SORT_ORDER = "date DESC";
2253 }
2254
2255 /**
2256 * Contains all MMS messages in the MMS app sent folder.
2257 */
2258 public static final class Sent implements BaseMmsColumns {
2259
2260 /**
2261 * Not instantiable.
2262 * @hide
2263 */
2264 private Sent() {
2265 }
2266
2267 /**
2268 * The {@code content://} style URL for this table.
2269 */
2270 public static final Uri
2271 CONTENT_URI = Uri.parse("content://mms/sent");
2272
2273 /**
2274 * The default sort order for this table.
2275 */
2276 public static final String DEFAULT_SORT_ORDER = "date DESC";
2277 }
2278
2279 /**
2280 * Contains all MMS messages in the MMS app drafts folder.
2281 */
2282 public static final class Draft implements BaseMmsColumns {
2283
2284 /**
2285 * Not instantiable.
2286 * @hide
2287 */
2288 private Draft() {
2289 }
2290
2291 /**
2292 * The {@code content://} style URL for this table.
2293 */
2294 public static final Uri
2295 CONTENT_URI = Uri.parse("content://mms/drafts");
2296
2297 /**
2298 * The default sort order for this table.
2299 */
2300 public static final String DEFAULT_SORT_ORDER = "date DESC";
2301 }
2302
2303 /**
2304 * Contains all MMS messages in the MMS app outbox.
2305 */
2306 public static final class Outbox implements BaseMmsColumns {
2307
2308 /**
2309 * Not instantiable.
2310 * @hide
2311 */
2312 private Outbox() {
2313 }
2314
2315 /**
2316 * The {@code content://} style URL for this table.
2317 */
2318 public static final Uri
2319 CONTENT_URI = Uri.parse("content://mms/outbox");
2320
2321 /**
2322 * The default sort order for this table.
2323 */
2324 public static final String DEFAULT_SORT_ORDER = "date DESC";
2325 }
2326
2327 /**
2328 * Contains address information for an MMS message.
2329 */
2330 public static final class Addr implements BaseColumns {
2331
2332 /**
2333 * Not instantiable.
2334 * @hide
2335 */
2336 private Addr() {
2337 }
2338
2339 /**
2340 * The ID of MM which this address entry belongs to.
2341 * <P>Type: INTEGER (long)</P>
2342 */
2343 public static final String MSG_ID = "msg_id";
2344
2345 /**
2346 * The ID of contact entry in Phone Book.
2347 * <P>Type: INTEGER (long)</P>
2348 */
2349 public static final String CONTACT_ID = "contact_id";
2350
2351 /**
2352 * The address text.
2353 * <P>Type: TEXT</P>
2354 */
2355 public static final String ADDRESS = "address";
2356
2357 /**
2358 * Type of address: must be one of {@code PduHeaders.BCC},
2359 * {@code PduHeaders.CC}, {@code PduHeaders.FROM}, {@code PduHeaders.TO}.
2360 * <P>Type: INTEGER</P>
2361 */
2362 public static final String TYPE = "type";
2363
2364 /**
2365 * Character set of this entry (MMS charset value).
2366 * <P>Type: INTEGER</P>
2367 */
2368 public static final String CHARSET = "charset";
2369 }
2370
2371 /**
2372 * Contains message parts.
2373 */
2374 public static final class Part implements BaseColumns {
2375
2376 /**
2377 * Not instantiable.
2378 * @hide
2379 */
2380 private Part() {
2381 }
2382
2383 /**
2384 * The identifier of the message which this part belongs to.
2385 * <P>Type: INTEGER</P>
2386 */
2387 public static final String MSG_ID = "mid";
2388
2389 /**
2390 * The order of the part.
2391 * <P>Type: INTEGER</P>
2392 */
2393 public static final String SEQ = "seq";
2394
2395 /**
2396 * The content type of the part.
2397 * <P>Type: TEXT</P>
2398 */
2399 public static final String CONTENT_TYPE = "ct";
2400
2401 /**
2402 * The name of the part.
2403 * <P>Type: TEXT</P>
2404 */
2405 public static final String NAME = "name";
2406
2407 /**
2408 * The charset of the part.
2409 * <P>Type: TEXT</P>
2410 */
2411 public static final String CHARSET = "chset";
2412
2413 /**
2414 * The file name of the part.
2415 * <P>Type: TEXT</P>
2416 */
2417 public static final String FILENAME = "fn";
2418
2419 /**
2420 * The content disposition of the part.
2421 * <P>Type: TEXT</P>
2422 */
2423 public static final String CONTENT_DISPOSITION = "cd";
2424
2425 /**
2426 * The content ID of the part.
2427 * <P>Type: INTEGER</P>
2428 */
2429 public static final String CONTENT_ID = "cid";
2430
2431 /**
2432 * The content location of the part.
2433 * <P>Type: INTEGER</P>
2434 */
2435 public static final String CONTENT_LOCATION = "cl";
2436
2437 /**
2438 * The start of content-type of the message.
2439 * <P>Type: INTEGER</P>
2440 */
2441 public static final String CT_START = "ctt_s";
2442
2443 /**
2444 * The type of content-type of the message.
2445 * <P>Type: TEXT</P>
2446 */
2447 public static final String CT_TYPE = "ctt_t";
2448
2449 /**
2450 * The location (on filesystem) of the binary data of the part.
2451 * <P>Type: INTEGER</P>
2452 */
2453 public static final String _DATA = "_data";
2454
2455 /**
2456 * The message text.
2457 * <P>Type: TEXT</P>
2458 */
2459 public static final String TEXT = "text";
2460 }
2461
2462 /**
2463 * Message send rate table.
2464 */
2465 public static final class Rate {
2466
2467 /**
2468 * Not instantiable.
2469 * @hide
2470 */
2471 private Rate() {
2472 }
2473
2474 /**
2475 * The {@code content://} style URL for this table.
2476 */
2477 public static final Uri CONTENT_URI = Uri.withAppendedPath(
2478 Mms.CONTENT_URI, "rate");
2479
2480 /**
2481 * When a message was successfully sent.
2482 * <P>Type: INTEGER (long)</P>
2483 */
2484 public static final String SENT_TIME = "sent_time";
2485 }
2486
2487 /**
2488 * Intents class.
2489 */
2490 public static final class Intents {
2491
2492 /**
2493 * Not instantiable.
2494 * @hide
2495 */
2496 private Intents() {
2497 }
2498
2499 /**
2500 * Indicates that the contents of specified URIs were changed.
2501 * The application which is showing or caching these contents
2502 * should be updated.
2503 */
2504 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2505 public static final String CONTENT_CHANGED_ACTION
2506 = "android.intent.action.CONTENT_CHANGED";
2507
2508 /**
2509 * An extra field which stores the URI of deleted contents.
2510 */
2511 public static final String DELETED_CONTENTS = "deleted_contents";
2512 }
2513 }
2514
2515 /**
2516 * Contains all MMS and SMS messages.
2517 */
2518 public static final class MmsSms implements BaseColumns {
2519
2520 /**
2521 * Not instantiable.
2522 * @hide
2523 */
2524 private MmsSms() {
2525 }
2526
2527 /**
2528 * The column to distinguish SMS and MMS messages in query results.
2529 */
2530 public static final String TYPE_DISCRIMINATOR_COLUMN =
2531 "transport_type";
2532
2533 /**
2534 * The {@code content://} style URL for this table.
2535 */
2536 public static final Uri CONTENT_URI = Uri.parse("content://mms-sms/");
2537
2538 /**
2539 * The {@code content://} style URL for this table, by conversation.
2540 */
2541 public static final Uri CONTENT_CONVERSATIONS_URI = Uri.parse(
2542 "content://mms-sms/conversations");
2543
2544 /**
2545 * The {@code content://} style URL for this table, by phone number.
2546 */
2547 public static final Uri CONTENT_FILTER_BYPHONE_URI = Uri.parse(
2548 "content://mms-sms/messages/byphone");
2549
2550 /**
2551 * The {@code content://} style URL for undelivered messages in this table.
2552 */
2553 public static final Uri CONTENT_UNDELIVERED_URI = Uri.parse(
2554 "content://mms-sms/undelivered");
2555
2556 /**
2557 * The {@code content://} style URL for draft messages in this table.
2558 */
2559 public static final Uri CONTENT_DRAFT_URI = Uri.parse(
2560 "content://mms-sms/draft");
2561
2562 /**
2563 * The {@code content://} style URL for locked messages in this table.
2564 */
2565 public static final Uri CONTENT_LOCKED_URI = Uri.parse(
2566 "content://mms-sms/locked");
2567
2568 /**
2569 * Pass in a query parameter called "pattern" which is the text to search for.
2570 * The sort order is fixed to be: {@code thread_id ASC, date DESC}.
2571 */
2572 public static final Uri SEARCH_URI = Uri.parse(
2573 "content://mms-sms/search");
2574
2575 // Constants for message protocol types.
2576
2577 /** SMS protocol type. */
2578 public static final int SMS_PROTO = 0;
2579
2580 /** MMS protocol type. */
2581 public static final int MMS_PROTO = 1;
2582
2583 // Constants for error types of pending messages.
2584
2585 /** Error type: no error. */
2586 public static final int NO_ERROR = 0;
2587
2588 /** Error type: generic transient error. */
2589 public static final int ERR_TYPE_GENERIC = 1;
2590
2591 /** Error type: SMS protocol transient error. */
2592 public static final int ERR_TYPE_SMS_PROTO_TRANSIENT = 2;
2593
2594 /** Error type: MMS protocol transient error. */
2595 public static final int ERR_TYPE_MMS_PROTO_TRANSIENT = 3;
2596
2597 /** Error type: transport failure. */
2598 public static final int ERR_TYPE_TRANSPORT_FAILURE = 4;
2599
2600 /** Error type: permanent error (along with all higher error values). */
2601 public static final int ERR_TYPE_GENERIC_PERMANENT = 10;
2602
2603 /** Error type: SMS protocol permanent error. */
2604 public static final int ERR_TYPE_SMS_PROTO_PERMANENT = 11;
2605
2606 /** Error type: MMS protocol permanent error. */
2607 public static final int ERR_TYPE_MMS_PROTO_PERMANENT = 12;
2608
2609 /**
2610 * Contains pending messages info.
2611 */
2612 public static final class PendingMessages implements BaseColumns {
2613
2614 /**
2615 * Not instantiable.
2616 * @hide
2617 */
2618 private PendingMessages() {
2619 }
2620
2621 public static final Uri CONTENT_URI = Uri.withAppendedPath(
2622 MmsSms.CONTENT_URI, "pending");
2623
2624 /**
2625 * The type of transport protocol (MMS or SMS).
2626 * <P>Type: INTEGER</P>
2627 */
2628 public static final String PROTO_TYPE = "proto_type";
2629
2630 /**
2631 * The ID of the message to be sent or downloaded.
2632 * <P>Type: INTEGER (long)</P>
2633 */
2634 public static final String MSG_ID = "msg_id";
2635
2636 /**
2637 * The type of the message to be sent or downloaded.
2638 * This field is only valid for MM. For SM, its value is always set to 0.
2639 * <P>Type: INTEGER</P>
2640 */
2641 public static final String MSG_TYPE = "msg_type";
2642
2643 /**
2644 * The type of the error code.
2645 * <P>Type: INTEGER</P>
2646 */
2647 public static final String ERROR_TYPE = "err_type";
2648
2649 /**
2650 * The error code of sending/retrieving process.
2651 * <P>Type: INTEGER</P>
2652 */
2653 public static final String ERROR_CODE = "err_code";
2654
2655 /**
2656 * How many times we tried to send or download the message.
2657 * <P>Type: INTEGER</P>
2658 */
2659 public static final String RETRY_INDEX = "retry_index";
2660
2661 /**
2662 * The time to do next retry.
2663 * <P>Type: INTEGER (long)</P>
2664 */
2665 public static final String DUE_TIME = "due_time";
2666
2667 /**
2668 * The time we last tried to send or download the message.
2669 * <P>Type: INTEGER (long)</P>
2670 */
2671 public static final String LAST_TRY = "last_try";
2672
2673 /**
2674 * The subscription to which the message belongs to. Its value will be
2675 * < 0 if the sub id cannot be determined.
2676 * <p>Type: INTEGER (long) </p>
2677 */
2678 public static final String SUBSCRIPTION_ID = "pending_sub_id";
2679 }
2680
2681 /**
2682 * Words table used by provider for full-text searches.
2683 * @hide
2684 */
2685 public static final class WordsTable {
2686
2687 /**
2688 * Not instantiable.
2689 * @hide
2690 */
2691 private WordsTable() {}
2692
2693 /**
2694 * Primary key.
2695 * <P>Type: INTEGER (long)</P>
2696 */
2697 public static final String ID = "_id";
2698
2699 /**
2700 * Source row ID.
2701 * <P>Type: INTEGER (long)</P>
2702 */
2703 public static final String SOURCE_ROW_ID = "source_id";
2704
2705 /**
2706 * Table ID (either 1 or 2).
2707 * <P>Type: INTEGER</P>
2708 */
2709 public static final String TABLE_ID = "table_to_use";
2710
2711 /**
2712 * The words to index.
2713 * <P>Type: TEXT</P>
2714 */
2715 public static final String INDEXED_TEXT = "index_text";
2716 }
2717 }
2718
2719 /**
2720 * Carriers class contains information about APNs, including MMSC information.
2721 */
2722 public static final class Carriers implements BaseColumns {
2723
2724 /**
2725 * Not instantiable.
2726 * @hide
2727 */
2728 private Carriers() {}
2729
2730 /**
2731 * The {@code content://} style URL for this table.
2732 */
2733 public static final Uri CONTENT_URI = Uri.parse("content://telephony/carriers");
2734
2735 /**
yuemingw4c0065f2018-01-16 19:48:10 +00002736 * The {@code content://} style URL to be called from DevicePolicyManagerService,
2737 * can manage DPC-owned APNs.
2738 * @hide
2739 */
2740 public static final Uri DPC_URI = Uri.parse("content://telephony/carriers/dpc");
2741
2742 /**
2743 * The {@code content://} style URL to be called from Telephony to query APNs.
2744 * When DPC-owned APNs are enforced, only DPC-owned APNs are returned, otherwise only
2745 * non-DPC-owned APNs are returned.
2746 * @hide
2747 */
2748 public static final Uri FILTERED_URI = Uri.parse("content://telephony/carriers/filtered");
2749
2750 /**
2751 * The {@code content://} style URL to be called from DevicePolicyManagerService
2752 * or Telephony to manage whether DPC-owned APNs are enforced.
2753 * @hide
2754 */
2755 public static final Uri ENFORCE_MANAGED_URI = Uri.parse(
2756 "content://telephony/carriers/enforce_managed");
2757
2758 /**
2759 * The column name for ENFORCE_MANAGED_URI, indicates whether DPC-owned APNs are enforced.
2760 * @hide
2761 */
2762 public static final String ENFORCE_KEY = "enforced";
2763
2764 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08002765 * The default sort order for this table.
2766 */
2767 public static final String DEFAULT_SORT_ORDER = "name ASC";
2768
2769 /**
2770 * Entry name.
2771 * <P>Type: TEXT</P>
2772 */
2773 public static final String NAME = "name";
2774
2775 /**
2776 * APN name.
2777 * <P>Type: TEXT</P>
2778 */
2779 public static final String APN = "apn";
2780
2781 /**
2782 * Proxy address.
2783 * <P>Type: TEXT</P>
2784 */
2785 public static final String PROXY = "proxy";
2786
2787 /**
2788 * Proxy port.
2789 * <P>Type: TEXT</P>
2790 */
2791 public static final String PORT = "port";
2792
2793 /**
2794 * MMS proxy address.
2795 * <P>Type: TEXT</P>
2796 */
2797 public static final String MMSPROXY = "mmsproxy";
2798
2799 /**
2800 * MMS proxy port.
2801 * <P>Type: TEXT</P>
2802 */
2803 public static final String MMSPORT = "mmsport";
2804
2805 /**
2806 * Server address.
2807 * <P>Type: TEXT</P>
2808 */
2809 public static final String SERVER = "server";
2810
2811 /**
2812 * APN username.
2813 * <P>Type: TEXT</P>
2814 */
2815 public static final String USER = "user";
2816
2817 /**
2818 * APN password.
2819 * <P>Type: TEXT</P>
2820 */
2821 public static final String PASSWORD = "password";
2822
2823 /**
2824 * MMSC URL.
2825 * <P>Type: TEXT</P>
2826 */
2827 public static final String MMSC = "mmsc";
2828
2829 /**
2830 * Mobile Country Code (MCC).
2831 * <P>Type: TEXT</P>
2832 */
2833 public static final String MCC = "mcc";
2834
2835 /**
2836 * Mobile Network Code (MNC).
2837 * <P>Type: TEXT</P>
2838 */
2839 public static final String MNC = "mnc";
2840
2841 /**
2842 * Numeric operator ID (as String). Usually {@code MCC + MNC}.
2843 * <P>Type: TEXT</P>
2844 */
2845 public static final String NUMERIC = "numeric";
2846
2847 /**
2848 * Authentication type.
2849 * <P>Type: INTEGER</P>
2850 */
2851 public static final String AUTH_TYPE = "authtype";
2852
2853 /**
2854 * Comma-delimited list of APN types.
2855 * <P>Type: TEXT</P>
2856 */
2857 public static final String TYPE = "type";
2858
2859 /**
2860 * The protocol to use to connect to this APN.
2861 *
2862 * One of the {@code PDP_type} values in TS 27.007 section 10.1.1.
2863 * For example: {@code IP}, {@code IPV6}, {@code IPV4V6}, or {@code PPP}.
2864 * <P>Type: TEXT</P>
2865 */
2866 public static final String PROTOCOL = "protocol";
2867
2868 /**
2869 * The protocol to use to connect to this APN when roaming.
2870 * The syntax is the same as protocol.
2871 * <P>Type: TEXT</P>
2872 */
2873 public static final String ROAMING_PROTOCOL = "roaming_protocol";
2874
2875 /**
2876 * Is this the current APN?
2877 * <P>Type: INTEGER (boolean)</P>
2878 */
2879 public static final String CURRENT = "current";
2880
2881 /**
2882 * Is this APN enabled?
2883 * <P>Type: INTEGER (boolean)</P>
2884 */
2885 public static final String CARRIER_ENABLED = "carrier_enabled";
2886
2887 /**
2888 * Radio Access Technology info.
2889 * To check what values are allowed, refer to {@link android.telephony.ServiceState}.
2890 * This should be spread to other technologies,
2891 * but is currently only used for LTE (14) and eHRPD (13).
2892 * <P>Type: INTEGER</P>
Cassiee1c88022018-02-22 08:51:03 -08002893 * @deprecated this column is no longer supported, use {@link #NETWORK_TYPE_BITMASK} instead
Dan Willemsen4980bf42017-02-14 14:17:12 -08002894 */
Cassied53df962017-12-05 13:34:33 -08002895 @Deprecated
Dan Willemsen4980bf42017-02-14 14:17:12 -08002896 public static final String BEARER = "bearer";
2897
2898 /**
2899 * Radio Access Technology bitmask.
2900 * To check what values can be contained, refer to {@link android.telephony.ServiceState}.
2901 * 0 indicates all techs otherwise first bit refers to RAT/bearer 1, second bit refers to
2902 * RAT/bearer 2 and so on.
2903 * Bitmask for a radio tech R is (1 << (R - 1))
2904 * <P>Type: INTEGER</P>
2905 * @hide
Cassiee1c88022018-02-22 08:51:03 -08002906 * @deprecated this column is no longer supported, use {@link #NETWORK_TYPE_BITMASK} instead
Dan Willemsen4980bf42017-02-14 14:17:12 -08002907 */
Cassied53df962017-12-05 13:34:33 -08002908 @Deprecated
Dan Willemsen4980bf42017-02-14 14:17:12 -08002909 public static final String BEARER_BITMASK = "bearer_bitmask";
2910
2911 /**
Cassied53df962017-12-05 13:34:33 -08002912 * Radio technology (network type) bitmask.
Cassiee1c88022018-02-22 08:51:03 -08002913 * To check what values can be contained, refer to the NETWORK_TYPE_ constants in
Cassied53df962017-12-05 13:34:33 -08002914 * {@link android.telephony.TelephonyManager}.
2915 * Bitmask for a radio tech R is (1 << (R - 1))
2916 * <P>Type: INTEGER</P>
2917 */
2918 public static final String NETWORK_TYPE_BITMASK = "network_type_bitmask";
2919
2920 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08002921 * MVNO type:
2922 * {@code SPN (Service Provider Name), IMSI, GID (Group Identifier Level 1)}.
2923 * <P>Type: TEXT</P>
2924 */
2925 public static final String MVNO_TYPE = "mvno_type";
2926
2927 /**
2928 * MVNO data.
2929 * Use the following examples.
2930 * <ul>
2931 * <li>SPN: A MOBILE, BEN NL, ...</li>
2932 * <li>IMSI: 302720x94, 2060188, ...</li>
2933 * <li>GID: 4E, 33, ...</li>
2934 * </ul>
2935 * <P>Type: TEXT</P>
2936 */
2937 public static final String MVNO_MATCH_DATA = "mvno_match_data";
2938
2939 /**
2940 * The subscription to which the APN belongs to
2941 * <p>Type: INTEGER (long) </p>
2942 */
2943 public static final String SUBSCRIPTION_ID = "sub_id";
2944
2945 /**
chen xu85100482018-10-12 15:30:34 -07002946 * The profile_id to which the APN saved in modem.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002947 * <p>Type: INTEGER</p>
2948 *@hide
2949 */
2950 public static final String PROFILE_ID = "profile_id";
2951
2952 /**
chen xu85100482018-10-12 15:30:34 -07002953 * If set to {@code true}, then the APN setting will persist to the modem.
2954 * <p>Type: INTEGER (boolean)</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08002955 *@hide
2956 */
chen xu85100482018-10-12 15:30:34 -07002957 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002958 public static final String MODEM_COGNITIVE = "modem_cognitive";
2959
2960 /**
chen xu85100482018-10-12 15:30:34 -07002961 * The max connections of this APN.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002962 * <p>Type: INTEGER</p>
2963 *@hide
2964 */
chen xu85100482018-10-12 15:30:34 -07002965 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002966 public static final String MAX_CONNS = "max_conns";
2967
2968 /**
chen xu85100482018-10-12 15:30:34 -07002969 * The wait time for retry of the APN.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002970 * <p>Type: INTEGER</p>
2971 *@hide
2972 */
chen xu85100482018-10-12 15:30:34 -07002973 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002974 public static final String WAIT_TIME = "wait_time";
2975
2976 /**
chen xu85100482018-10-12 15:30:34 -07002977 * The time to limit max connection for the APN.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002978 * <p>Type: INTEGER</p>
2979 *@hide
2980 */
chen xu85100482018-10-12 15:30:34 -07002981 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002982 public static final String MAX_CONNS_TIME = "max_conns_time";
2983
2984 /**
chen xu85100482018-10-12 15:30:34 -07002985 * The MTU(Maxinum transmit unit) size of the mobile interface to which the APN connected.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002986 * <p>Type: INTEGER </p>
2987 * @hide
2988 */
chen xu85100482018-10-12 15:30:34 -07002989 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002990 public static final String MTU = "mtu";
2991
2992 /**
chen xu85100482018-10-12 15:30:34 -07002993 * APN edit status. APN could be added/edited/deleted by a user or carrier.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002994 * <p>Type: INTEGER </p>
2995 * @hide
2996 */
chen xu85100482018-10-12 15:30:34 -07002997 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002998 public static final String EDITED = "edited";
2999
3000 /**
chen xu85100482018-10-12 15:30:34 -07003001 * {@code true} if this APN visible to the user, {@code false} otherwise.
3002 * <p>Type: INTEGER (boolean)</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003003 * @hide
3004 */
chen xu85100482018-10-12 15:30:34 -07003005 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08003006 public static final String USER_VISIBLE = "user_visible";
3007
3008 /**
chen xu85100482018-10-12 15:30:34 -07003009 * {@code true} if the user allowed to edit this APN, {@code false} otherwise.
3010 * <p>Type: INTEGER (boolean)</p>
Amit Mahajand4977942017-07-17 14:46:39 -07003011 * @hide
3012 */
chen xu85100482018-10-12 15:30:34 -07003013 @SystemApi
Amit Mahajand4977942017-07-17 14:46:39 -07003014 public static final String USER_EDITABLE = "user_editable";
3015
3016 /**
chen xu85100482018-10-12 15:30:34 -07003017 * {@link #EDITED APN edit status} indicates that this APN has not been edited or fails to
3018 * edit.
3019 * <p>Type: INTEGER </p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003020 * @hide
3021 */
chen xu85100482018-10-12 15:30:34 -07003022 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08003023 public static final int UNEDITED = 0;
chen xu85100482018-10-12 15:30:34 -07003024
Dan Willemsen4980bf42017-02-14 14:17:12 -08003025 /**
chen xu85100482018-10-12 15:30:34 -07003026 * {@link #EDITED APN edit status} indicates that this APN has been edited by users.
3027 * <p>Type: INTEGER </p>
3028 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003029 */
chen xu85100482018-10-12 15:30:34 -07003030 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08003031 public static final int USER_EDITED = 1;
chen xu85100482018-10-12 15:30:34 -07003032
Dan Willemsen4980bf42017-02-14 14:17:12 -08003033 /**
chen xu85100482018-10-12 15:30:34 -07003034 * {@link #EDITED APN edit status} indicates that this APN has been deleted by users.
3035 * <p>Type: INTEGER </p>
3036 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003037 */
chen xu85100482018-10-12 15:30:34 -07003038 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08003039 public static final int USER_DELETED = 2;
chen xu85100482018-10-12 15:30:34 -07003040
Dan Willemsen4980bf42017-02-14 14:17:12 -08003041 /**
chen xu85100482018-10-12 15:30:34 -07003042 * {@link #EDITED APN edit status} is an intermediate value used to indicate that an entry
3043 * deleted by the user is still present in the new APN database and therefore must remain
3044 * tagged as user deleted rather than completely removed from the database.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003045 * @hide
3046 */
3047 public static final int USER_DELETED_BUT_PRESENT_IN_XML = 3;
chen xu85100482018-10-12 15:30:34 -07003048
Dan Willemsen4980bf42017-02-14 14:17:12 -08003049 /**
chen xu85100482018-10-12 15:30:34 -07003050 * {@link #EDITED APN edit status} indicates that this APN has been edited by carriers.
3051 * <p>Type: INTEGER </p>
3052 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003053 */
chen xu85100482018-10-12 15:30:34 -07003054 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08003055 public static final int CARRIER_EDITED = 4;
chen xu85100482018-10-12 15:30:34 -07003056
Dan Willemsen4980bf42017-02-14 14:17:12 -08003057 /**
chen xu85100482018-10-12 15:30:34 -07003058 * {@link #EDITED APN edit status} indicates that this APN has been deleted by carriers.
3059 * CARRIER_DELETED values are currently not used as there is no use case. If they are used,
Dan Willemsen4980bf42017-02-14 14:17:12 -08003060 * delete() will have to change accordingly. Currently it is hardcoded to USER_DELETED.
chen xu85100482018-10-12 15:30:34 -07003061 * <p>Type: INTEGER </p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003062 * @hide
3063 */
3064 public static final int CARRIER_DELETED = 5;
chen xu85100482018-10-12 15:30:34 -07003065
Dan Willemsen4980bf42017-02-14 14:17:12 -08003066 /**
chen xu85100482018-10-12 15:30:34 -07003067 * {@link #EDITED APN edit status} is an intermediate value used to indicate that an entry
3068 * deleted by the carrier is still present in the new APN database and therefore must remain
3069 * tagged as user deleted rather than completely removed from the database.
3070 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003071 */
3072 public static final int CARRIER_DELETED_BUT_PRESENT_IN_XML = 6;
yuemingwcf263eb2017-11-08 13:12:18 +00003073
3074 /**
3075 * The owner of the APN.
3076 * <p>Type: INTEGER</p>
3077 * @hide
3078 */
3079 public static final String OWNED_BY = "owned_by";
3080
3081 /**
3082 * Possible value for the OWNED_BY field.
3083 * APN is owned by DPC.
3084 * @hide
3085 */
3086 public static final int OWNED_BY_DPC = 0;
Jordan Liu40617152018-04-06 11:10:12 -07003087
yuemingwcf263eb2017-11-08 13:12:18 +00003088 /**
3089 * Possible value for the OWNED_BY field.
3090 * APN is owned by other sources.
3091 * @hide
3092 */
3093 public static final int OWNED_BY_OTHERS = 1;
Jordan Liu40617152018-04-06 11:10:12 -07003094
3095 /**
3096 * The APN set id. When the user manually selects an APN or the framework sets an APN as
3097 * preferred, all APNs with the same set id as the selected APN should be prioritized over
3098 * APNs in other sets.
chen xu85100482018-10-12 15:30:34 -07003099 * <p>Type: INTEGER</p>
Jordan Liu40617152018-04-06 11:10:12 -07003100 * @hide
3101 */
chen xu85100482018-10-12 15:30:34 -07003102 @SystemApi
Jordan Liu40617152018-04-06 11:10:12 -07003103 public static final String APN_SET_ID = "apn_set_id";
3104
3105 /**
chen xu85100482018-10-12 15:30:34 -07003106 * Possible value for the{@link #APN_SET_ID} field. By default APNs will not belong to a
3107 * set. If the user manually selects an APN with no set set, there is no need to prioritize
3108 * any specific APN set ids.
3109 * <p>Type: INTEGER</p>
Jordan Liu40617152018-04-06 11:10:12 -07003110 * @hide
3111 */
chen xu85100482018-10-12 15:30:34 -07003112 @SystemApi
Jordan Liu40617152018-04-06 11:10:12 -07003113 public static final int NO_SET_SET = 0;
3114
calvinpanbeb6cb32018-10-19 15:11:22 +08003115 /**
3116 * A unique carrier id associated with this APN
3117 * {@see TelephonyManager#getSimCarrierId()}
3118 * <p>Type: STRING</p>
3119 */
3120 public static final String CARRIER_ID = "carrier_id";
3121
Dan Willemsen4980bf42017-02-14 14:17:12 -08003122 }
3123
3124 /**
3125 * Contains received SMS cell broadcast messages.
3126 * @hide
3127 */
3128 public static final class CellBroadcasts implements BaseColumns {
3129
3130 /**
3131 * Not instantiable.
3132 * @hide
3133 */
3134 private CellBroadcasts() {}
3135
3136 /**
3137 * The {@code content://} URI for this table.
3138 */
3139 public static final Uri CONTENT_URI = Uri.parse("content://cellbroadcasts");
3140
3141 /**
3142 * Message geographical scope.
3143 * <P>Type: INTEGER</P>
3144 */
3145 public static final String GEOGRAPHICAL_SCOPE = "geo_scope";
3146
3147 /**
3148 * Message serial number.
3149 * <P>Type: INTEGER</P>
3150 */
3151 public static final String SERIAL_NUMBER = "serial_number";
3152
3153 /**
3154 * PLMN of broadcast sender. {@code SERIAL_NUMBER + PLMN + LAC + CID} uniquely identifies
3155 * a broadcast for duplicate detection purposes.
3156 * <P>Type: TEXT</P>
3157 */
3158 public static final String PLMN = "plmn";
3159
3160 /**
3161 * Location Area (GSM) or Service Area (UMTS) of broadcast sender. Unused for CDMA.
3162 * Only included if Geographical Scope of message is not PLMN wide (01).
3163 * <P>Type: INTEGER</P>
3164 */
3165 public static final String LAC = "lac";
3166
3167 /**
3168 * Cell ID of message sender (GSM/UMTS). Unused for CDMA. Only included when the
3169 * Geographical Scope of message is cell wide (00 or 11).
3170 * <P>Type: INTEGER</P>
3171 */
3172 public static final String CID = "cid";
3173
3174 /**
3175 * Message code. <em>OBSOLETE: merged into SERIAL_NUMBER.</em>
3176 * <P>Type: INTEGER</P>
3177 */
3178 public static final String V1_MESSAGE_CODE = "message_code";
3179
3180 /**
3181 * Message identifier. <em>OBSOLETE: renamed to SERVICE_CATEGORY.</em>
3182 * <P>Type: INTEGER</P>
3183 */
3184 public static final String V1_MESSAGE_IDENTIFIER = "message_id";
3185
3186 /**
3187 * Service category (GSM/UMTS: message identifier; CDMA: service category).
3188 * <P>Type: INTEGER</P>
3189 */
3190 public static final String SERVICE_CATEGORY = "service_category";
3191
3192 /**
3193 * Message language code.
3194 * <P>Type: TEXT</P>
3195 */
3196 public static final String LANGUAGE_CODE = "language";
3197
3198 /**
3199 * Message body.
3200 * <P>Type: TEXT</P>
3201 */
3202 public static final String MESSAGE_BODY = "body";
3203
3204 /**
3205 * Message delivery time.
3206 * <P>Type: INTEGER (long)</P>
3207 */
3208 public static final String DELIVERY_TIME = "date";
3209
3210 /**
3211 * Has the message been viewed?
3212 * <P>Type: INTEGER (boolean)</P>
3213 */
3214 public static final String MESSAGE_READ = "read";
3215
3216 /**
3217 * Message format (3GPP or 3GPP2).
3218 * <P>Type: INTEGER</P>
3219 */
3220 public static final String MESSAGE_FORMAT = "format";
3221
3222 /**
3223 * Message priority (including emergency).
3224 * <P>Type: INTEGER</P>
3225 */
3226 public static final String MESSAGE_PRIORITY = "priority";
3227
3228 /**
3229 * ETWS warning type (ETWS alerts only).
3230 * <P>Type: INTEGER</P>
3231 */
3232 public static final String ETWS_WARNING_TYPE = "etws_warning_type";
3233
3234 /**
3235 * CMAS message class (CMAS alerts only).
3236 * <P>Type: INTEGER</P>
3237 */
3238 public static final String CMAS_MESSAGE_CLASS = "cmas_message_class";
3239
3240 /**
3241 * CMAS category (CMAS alerts only).
3242 * <P>Type: INTEGER</P>
3243 */
3244 public static final String CMAS_CATEGORY = "cmas_category";
3245
3246 /**
3247 * CMAS response type (CMAS alerts only).
3248 * <P>Type: INTEGER</P>
3249 */
3250 public static final String CMAS_RESPONSE_TYPE = "cmas_response_type";
3251
3252 /**
3253 * CMAS severity (CMAS alerts only).
3254 * <P>Type: INTEGER</P>
3255 */
3256 public static final String CMAS_SEVERITY = "cmas_severity";
3257
3258 /**
3259 * CMAS urgency (CMAS alerts only).
3260 * <P>Type: INTEGER</P>
3261 */
3262 public static final String CMAS_URGENCY = "cmas_urgency";
3263
3264 /**
3265 * CMAS certainty (CMAS alerts only).
3266 * <P>Type: INTEGER</P>
3267 */
3268 public static final String CMAS_CERTAINTY = "cmas_certainty";
3269
3270 /** The default sort order for this table. */
3271 public static final String DEFAULT_SORT_ORDER = DELIVERY_TIME + " DESC";
3272
3273 /**
3274 * Query columns for instantiating {@link android.telephony.CellBroadcastMessage} objects.
3275 */
3276 public static final String[] QUERY_COLUMNS = {
3277 _ID,
3278 GEOGRAPHICAL_SCOPE,
3279 PLMN,
3280 LAC,
3281 CID,
3282 SERIAL_NUMBER,
3283 SERVICE_CATEGORY,
3284 LANGUAGE_CODE,
3285 MESSAGE_BODY,
3286 DELIVERY_TIME,
3287 MESSAGE_READ,
3288 MESSAGE_FORMAT,
3289 MESSAGE_PRIORITY,
3290 ETWS_WARNING_TYPE,
3291 CMAS_MESSAGE_CLASS,
3292 CMAS_CATEGORY,
3293 CMAS_RESPONSE_TYPE,
3294 CMAS_SEVERITY,
3295 CMAS_URGENCY,
3296 CMAS_CERTAINTY
3297 };
3298 }
Jordan Liub9b75ed2017-02-28 18:15:07 -08003299
3300 /**
3301 * Constants for interfacing with the ServiceStateProvider and the different fields of the
3302 * {@link ServiceState} class accessible through the provider.
3303 */
3304 public static final class ServiceStateTable {
3305
3306 /**
3307 * Not instantiable.
3308 * @hide
3309 */
3310 private ServiceStateTable() {}
3311
3312 /**
3313 * The authority string for the ServiceStateProvider
3314 */
3315 public static final String AUTHORITY = "service-state";
3316
3317 /**
3318 * The {@code content://} style URL for the ServiceStateProvider
3319 */
3320 public static final Uri CONTENT_URI = Uri.parse("content://service-state/");
3321
3322 /**
3323 * Generates a content {@link Uri} used to receive updates on a specific field in the
3324 * ServiceState provider.
3325 * <p>
3326 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
3327 * {@link ServiceState} while your app is running. You can also use a {@link JobService} to
3328 * ensure your app is notified of changes to the {@link Uri} even when it is not running.
3329 * Note, however, that using a {@link JobService} does not guarantee timely delivery of
3330 * updates to the {@link Uri}.
3331 *
Jordan Liu0f332522017-04-19 14:25:29 -07003332 * @param subscriptionId the subscriptionId to receive updates on
Jordan Liub9b75ed2017-02-28 18:15:07 -08003333 * @param field the ServiceState field to receive updates on
3334 * @return the Uri used to observe {@link ServiceState} changes
3335 */
Jordan Liu0f332522017-04-19 14:25:29 -07003336 public static Uri getUriForSubscriptionIdAndField(int subscriptionId, String field) {
3337 return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId))
Jordan Liub9b75ed2017-02-28 18:15:07 -08003338 .appendEncodedPath(field).build();
3339 }
3340
3341 /**
3342 * Generates a content {@link Uri} used to receive updates on every field in the
3343 * ServiceState provider.
3344 * <p>
3345 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
3346 * {@link ServiceState} while your app is running. You can also use a {@link JobService} to
3347 * ensure your app is notified of changes to the {@link Uri} even when it is not running.
3348 * Note, however, that using a {@link JobService} does not guarantee timely delivery of
3349 * updates to the {@link Uri}.
3350 *
Jordan Liu0f332522017-04-19 14:25:29 -07003351 * @param subscriptionId the subscriptionId to receive updates on
Jordan Liub9b75ed2017-02-28 18:15:07 -08003352 * @return the Uri used to observe {@link ServiceState} changes
3353 */
Jordan Liu0f332522017-04-19 14:25:29 -07003354 public static Uri getUriForSubscriptionId(int subscriptionId) {
3355 return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId)).build();
Jordan Liub9b75ed2017-02-28 18:15:07 -08003356 }
3357
3358 /**
3359 * Used to insert a ServiceState into the ServiceStateProvider as a ContentValues instance.
3360 *
3361 * @param state the ServiceState to convert into ContentValues
3362 * @return the convertedContentValues instance
3363 * @hide
3364 */
3365 public static ContentValues getContentValuesForServiceState(ServiceState state) {
3366 ContentValues values = new ContentValues();
3367 values.put(VOICE_REG_STATE, state.getVoiceRegState());
3368 values.put(DATA_REG_STATE, state.getDataRegState());
3369 values.put(VOICE_ROAMING_TYPE, state.getVoiceRoamingType());
3370 values.put(DATA_ROAMING_TYPE, state.getDataRoamingType());
3371 values.put(VOICE_OPERATOR_ALPHA_LONG, state.getVoiceOperatorAlphaLong());
3372 values.put(VOICE_OPERATOR_ALPHA_SHORT, state.getVoiceOperatorAlphaShort());
3373 values.put(VOICE_OPERATOR_NUMERIC, state.getVoiceOperatorNumeric());
3374 values.put(DATA_OPERATOR_ALPHA_LONG, state.getDataOperatorAlphaLong());
3375 values.put(DATA_OPERATOR_ALPHA_SHORT, state.getDataOperatorAlphaShort());
3376 values.put(DATA_OPERATOR_NUMERIC, state.getDataOperatorNumeric());
3377 values.put(IS_MANUAL_NETWORK_SELECTION, state.getIsManualSelection());
3378 values.put(RIL_VOICE_RADIO_TECHNOLOGY, state.getRilVoiceRadioTechnology());
3379 values.put(RIL_DATA_RADIO_TECHNOLOGY, state.getRilDataRadioTechnology());
3380 values.put(CSS_INDICATOR, state.getCssIndicator());
Jack Yu2661fac2018-03-15 13:51:05 -07003381 values.put(NETWORK_ID, state.getCdmaNetworkId());
3382 values.put(SYSTEM_ID, state.getCdmaSystemId());
Jordan Liub9b75ed2017-02-28 18:15:07 -08003383 values.put(CDMA_ROAMING_INDICATOR, state.getCdmaRoamingIndicator());
3384 values.put(CDMA_DEFAULT_ROAMING_INDICATOR, state.getCdmaDefaultRoamingIndicator());
3385 values.put(CDMA_ERI_ICON_INDEX, state.getCdmaEriIconIndex());
3386 values.put(CDMA_ERI_ICON_MODE, state.getCdmaEriIconMode());
3387 values.put(IS_EMERGENCY_ONLY, state.isEmergencyOnly());
Jordan Liub9b75ed2017-02-28 18:15:07 -08003388 values.put(IS_USING_CARRIER_AGGREGATION, state.isUsingCarrierAggregation());
3389 return values;
3390 }
3391
3392 /**
3393 * An integer value indicating the current voice service state.
3394 * <p>
3395 * Valid values: {@link ServiceState#STATE_IN_SERVICE},
3396 * {@link ServiceState#STATE_OUT_OF_SERVICE}, {@link ServiceState#STATE_EMERGENCY_ONLY},
3397 * {@link ServiceState#STATE_POWER_OFF}.
3398 * <p>
3399 * This is the same as {@link ServiceState#getState()}.
3400 */
3401 public static final String VOICE_REG_STATE = "voice_reg_state";
3402
3403 /**
3404 * An integer value indicating the current data service state.
3405 * <p>
3406 * Valid values: {@link ServiceState#STATE_IN_SERVICE},
3407 * {@link ServiceState#STATE_OUT_OF_SERVICE}, {@link ServiceState#STATE_EMERGENCY_ONLY},
3408 * {@link ServiceState#STATE_POWER_OFF}.
3409 * <p>
3410 * This is the same as {@link ServiceState#getDataRegState()}.
3411 * @hide
3412 */
3413 public static final String DATA_REG_STATE = "data_reg_state";
3414
3415 /**
3416 * An integer value indicating the current voice roaming type.
3417 * <p>
3418 * This is the same as {@link ServiceState#getVoiceRoamingType()}.
3419 * @hide
3420 */
3421 public static final String VOICE_ROAMING_TYPE = "voice_roaming_type";
3422
3423 /**
3424 * An integer value indicating the current data roaming type.
3425 * <p>
3426 * This is the same as {@link ServiceState#getDataRoamingType()}.
3427 * @hide
3428 */
3429 public static final String DATA_ROAMING_TYPE = "data_roaming_type";
3430
3431 /**
3432 * The current registered voice network operator name in long alphanumeric format.
3433 * <p>
3434 * This is the same as {@link ServiceState#getVoiceOperatorAlphaLong()}.
3435 * @hide
3436 */
3437 public static final String VOICE_OPERATOR_ALPHA_LONG = "voice_operator_alpha_long";
3438
3439 /**
3440 * The current registered operator name in short alphanumeric format.
3441 * <p>
3442 * In GSM/UMTS, short format can be up to 8 characters long. The current registered voice
3443 * network operator name in long alphanumeric format.
3444 * <p>
3445 * This is the same as {@link ServiceState#getVoiceOperatorAlphaShort()}.
3446 * @hide
3447 */
3448 public static final String VOICE_OPERATOR_ALPHA_SHORT = "voice_operator_alpha_short";
3449
3450
3451 /**
3452 * The current registered operator numeric id.
3453 * <p>
3454 * In GSM/UMTS, numeric format is 3 digit country code plus 2 or 3 digit
3455 * network code.
3456 * <p>
3457 * This is the same as {@link ServiceState#getOperatorNumeric()}.
3458 */
3459 public static final String VOICE_OPERATOR_NUMERIC = "voice_operator_numeric";
3460
3461 /**
3462 * The current registered data network operator name in long alphanumeric format.
3463 * <p>
3464 * This is the same as {@link ServiceState#getDataOperatorAlphaLong()}.
3465 * @hide
3466 */
3467 public static final String DATA_OPERATOR_ALPHA_LONG = "data_operator_alpha_long";
3468
3469 /**
3470 * The current registered data network operator name in short alphanumeric format.
3471 * <p>
3472 * This is the same as {@link ServiceState#getDataOperatorAlphaShort()}.
3473 * @hide
3474 */
3475 public static final String DATA_OPERATOR_ALPHA_SHORT = "data_operator_alpha_short";
3476
3477 /**
3478 * The current registered data network operator numeric id.
3479 * <p>
3480 * This is the same as {@link ServiceState#getDataOperatorNumeric()}.
3481 * @hide
3482 */
3483 public static final String DATA_OPERATOR_NUMERIC = "data_operator_numeric";
3484
3485 /**
3486 * The current network selection mode.
3487 * <p>
3488 * This is the same as {@link ServiceState#getIsManualSelection()}.
3489 */
3490 public static final String IS_MANUAL_NETWORK_SELECTION = "is_manual_network_selection";
3491
3492 /**
3493 * This is the same as {@link ServiceState#getRilVoiceRadioTechnology()}.
3494 * @hide
3495 */
3496 public static final String RIL_VOICE_RADIO_TECHNOLOGY = "ril_voice_radio_technology";
3497
3498 /**
3499 * This is the same as {@link ServiceState#getRilDataRadioTechnology()}.
3500 * @hide
3501 */
3502 public static final String RIL_DATA_RADIO_TECHNOLOGY = "ril_data_radio_technology";
3503
3504 /**
3505 * This is the same as {@link ServiceState#getCssIndicator()}.
3506 * @hide
3507 */
3508 public static final String CSS_INDICATOR = "css_indicator";
3509
3510 /**
Jack Yu2661fac2018-03-15 13:51:05 -07003511 * This is the same as {@link ServiceState#getCdmaNetworkId()}.
Jordan Liub9b75ed2017-02-28 18:15:07 -08003512 * @hide
3513 */
3514 public static final String NETWORK_ID = "network_id";
3515
3516 /**
Jack Yu2661fac2018-03-15 13:51:05 -07003517 * This is the same as {@link ServiceState#getCdmaSystemId()}.
Jordan Liub9b75ed2017-02-28 18:15:07 -08003518 * @hide
3519 */
3520 public static final String SYSTEM_ID = "system_id";
3521
3522 /**
3523 * This is the same as {@link ServiceState#getCdmaRoamingIndicator()}.
3524 * @hide
3525 */
3526 public static final String CDMA_ROAMING_INDICATOR = "cdma_roaming_indicator";
3527
3528 /**
3529 * This is the same as {@link ServiceState#getCdmaDefaultRoamingIndicator()}.
3530 * @hide
3531 */
3532 public static final String CDMA_DEFAULT_ROAMING_INDICATOR =
3533 "cdma_default_roaming_indicator";
3534
3535 /**
3536 * This is the same as {@link ServiceState#getCdmaEriIconIndex()}.
3537 * @hide
3538 */
3539 public static final String CDMA_ERI_ICON_INDEX = "cdma_eri_icon_index";
3540
3541 /**
3542 * This is the same as {@link ServiceState#getCdmaEriIconMode()}.
3543 * @hide
3544 */
3545 public static final String CDMA_ERI_ICON_MODE = "cdma_eri_icon_mode";
3546
3547 /**
3548 * This is the same as {@link ServiceState#isEmergencyOnly()}.
3549 * @hide
3550 */
3551 public static final String IS_EMERGENCY_ONLY = "is_emergency_only";
3552
3553 /**
3554 * This is the same as {@link ServiceState#getDataRoamingFromRegistration()}.
3555 * @hide
3556 */
3557 public static final String IS_DATA_ROAMING_FROM_REGISTRATION =
3558 "is_data_roaming_from_registration";
3559
3560 /**
3561 * This is the same as {@link ServiceState#isUsingCarrierAggregation()}.
3562 * @hide
3563 */
3564 public static final String IS_USING_CARRIER_AGGREGATION = "is_using_carrier_aggregation";
3565 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07003566
3567 /**
fionaxu58278be2018-01-29 14:08:12 -08003568 * Contains carrier identification information for the current subscriptions.
fionaxu3d0ad1f2017-10-25 23:09:36 -07003569 */
fionaxu62bc7472018-02-28 11:18:45 -08003570 public static final class CarrierId implements BaseColumns {
fionaxu3d0ad1f2017-10-25 23:09:36 -07003571 /**
fionaxu58278be2018-01-29 14:08:12 -08003572 * Not instantiable.
3573 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07003574 */
fionaxu62bc7472018-02-28 11:18:45 -08003575 private CarrierId() {}
fionaxu3d0ad1f2017-10-25 23:09:36 -07003576
3577 /**
fionaxu58278be2018-01-29 14:08:12 -08003578 * The {@code content://} style URI for this provider.
fionaxu3d0ad1f2017-10-25 23:09:36 -07003579 */
fionaxu62bc7472018-02-28 11:18:45 -08003580 public static final Uri CONTENT_URI = Uri.parse("content://carrier_id");
fionaxu3d0ad1f2017-10-25 23:09:36 -07003581
3582 /**
fionaxu62bc7472018-02-28 11:18:45 -08003583 * The authority string for the CarrierId Provider
fionaxu58278be2018-01-29 14:08:12 -08003584 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07003585 */
fionaxu62bc7472018-02-28 11:18:45 -08003586 public static final String AUTHORITY = "carrier_id";
fionaxu58278be2018-01-29 14:08:12 -08003587
fionaxu3d0ad1f2017-10-25 23:09:36 -07003588
3589 /**
fionaxu58278be2018-01-29 14:08:12 -08003590 * Generates a content {@link Uri} used to receive updates on carrier identity change
3591 * on the given subscriptionId
3592 * <p>
3593 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
fionaxuc8d483e2018-03-07 21:52:05 -08003594 * carrier identity {@link TelephonyManager#getSimCarrierId()}
fionaxu58278be2018-01-29 14:08:12 -08003595 * while your app is running. You can also use a {@link JobService} to ensure your app
3596 * is notified of changes to the {@link Uri} even when it is not running.
3597 * Note, however, that using a {@link JobService} does not guarantee timely delivery of
3598 * updates to the {@link Uri}.
3599 *
3600 * @param subscriptionId the subscriptionId to receive updates on
3601 * @return the Uri used to observe carrier identity changes
fionaxu3d0ad1f2017-10-25 23:09:36 -07003602 */
fionaxu58278be2018-01-29 14:08:12 -08003603 public static Uri getUriForSubscriptionId(int subscriptionId) {
3604 return CONTENT_URI.buildUpon().appendEncodedPath(
3605 String.valueOf(subscriptionId)).build();
3606 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07003607
3608 /**
fionaxu58278be2018-01-29 14:08:12 -08003609 * A user facing carrier name.
fionaxuc8d483e2018-03-07 21:52:05 -08003610 * @see TelephonyManager#getSimCarrierIdName()
fionaxu3d0ad1f2017-10-25 23:09:36 -07003611 * <P>Type: TEXT </P>
3612 */
fionaxu62bc7472018-02-28 11:18:45 -08003613 public static final String CARRIER_NAME = "carrier_name";
fionaxu3d0ad1f2017-10-25 23:09:36 -07003614
3615 /**
3616 * A unique carrier id
fionaxuc8d483e2018-03-07 21:52:05 -08003617 * @see TelephonyManager#getSimCarrierId()
fionaxu3d0ad1f2017-10-25 23:09:36 -07003618 * <P>Type: INTEGER </P>
3619 */
fionaxu62bc7472018-02-28 11:18:45 -08003620 public static final String CARRIER_ID = "carrier_id";
fionaxu3d0ad1f2017-10-25 23:09:36 -07003621
3622 /**
chen xu2e801e02018-10-16 11:55:26 -07003623 * A unique mno carrier id. mno carrier shares the same {@link All#MCCMNC} as carrier id
3624 * and can be solely identified by {@link All#MCCMNC} only. If there is no such mno
3625 * carrier, then mno carrier id equals to {@link #CARRIER_ID carrier id}.
3626 *
3627 * <p>mno carrier id can be used as fallback id. When the exact carrier id configurations
3628 * are not found, usually fall back to its mno carrier id.
3629 * <P>Type: INTEGER </P>
3630 * @hide
3631 */
3632 public static final String MNO_CARRIER_ID = "mno_carrier_id";
3633
3634 /**
fionaxu58278be2018-01-29 14:08:12 -08003635 * Contains mappings between matching rules with carrier id for all carriers.
3636 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07003637 */
fionaxu58278be2018-01-29 14:08:12 -08003638 public static final class All implements BaseColumns {
3639 /**
3640 * Numeric operator ID (as String). {@code MCC + MNC}
3641 * <P>Type: TEXT </P>
3642 */
3643 public static final String MCCMNC = "mccmnc";
3644
3645 /**
3646 * Group id level 1 (as String).
3647 * <P>Type: TEXT </P>
3648 */
3649 public static final String GID1 = "gid1";
3650
3651 /**
3652 * Group id level 2 (as String).
3653 * <P>Type: TEXT </P>
3654 */
3655 public static final String GID2 = "gid2";
3656
3657 /**
3658 * Public Land Mobile Network name.
3659 * <P>Type: TEXT </P>
3660 */
3661 public static final String PLMN = "plmn";
3662
3663 /**
3664 * Prefix xpattern of IMSI (International Mobile Subscriber Identity).
3665 * <P>Type: TEXT </P>
3666 */
3667 public static final String IMSI_PREFIX_XPATTERN = "imsi_prefix_xpattern";
3668
3669 /**
3670 * Service Provider Name.
3671 * <P>Type: TEXT </P>
3672 */
3673 public static final String SPN = "spn";
3674
3675 /**
3676 * Prefer APN name.
3677 * <P>Type: TEXT </P>
3678 */
3679 public static final String APN = "apn";
3680
3681 /**
3682 * Prefix of Integrated Circuit Card Identifier.
3683 * <P>Type: TEXT </P>
3684 */
3685 public static final String ICCID_PREFIX = "iccid_prefix";
3686
3687 /**
fionaxuf9583572018-06-08 16:55:25 -07003688 * Certificate for carrier privilege access rules.
3689 * <P>Type: TEXT in hex string </P>
3690 */
3691 public static final String PRIVILEGE_ACCESS_RULE = "privilege_access_rule";
3692
3693 /**
fionaxu58278be2018-01-29 14:08:12 -08003694 * The {@code content://} URI for this table.
3695 */
fionaxu62bc7472018-02-28 11:18:45 -08003696 public static final Uri CONTENT_URI = Uri.parse("content://carrier_id/all");
fionaxu58278be2018-01-29 14:08:12 -08003697 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07003698 }
Dan Willemsen4980bf42017-02-14 14:17:12 -08003699}