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