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