blob: 6a396ce3309361bb062bb7e42b711691200c63b2 [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 xu5caa18c2018-11-28 00:21:50 -080019import android.annotation.IntDef;
Jayachandran C349b9ba2018-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 Inwood6750f2e2018-08-10 09:29:25 +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;
Aurimas Liutikas7f695332018-05-31 21:07:32 -070033import android.database.Cursor;
Dan Willemsen4980bf42017-02-14 14:17:12 -080034import android.database.sqlite.SqliteWrapper;
35import android.net.Uri;
Mathew Inwood8c854f82018-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 xu5caa18c2018-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 /**
Vasu Nori84db0f52018-02-14 15:14:32 -0800283 * Columns in sms_changes table.
284 * @hide
285 */
286 public interface TextBasedSmsChangesColumns {
287 /**
288 * The {@code content://} style URL for this table.
289 * @hide
290 */
291 public static final Uri CONTENT_URI = Uri.parse("content://sms-changes");
292
293 /**
294 * Primary key.
295 * <P>Type: INTEGER (long)</P>
296 * @hide
297 */
298 public static final String ID = "_id";
299
300 /**
301 * Triggers on sms table create a row in this table for each update/delete.
302 * This column is the "_id" of the row from sms table that was updated/deleted.
303 * <P>Type: INTEGER (long)</P>
304 * @hide
305 */
306 public static final String ORIG_ROW_ID = "orig_rowid";
307
308 /**
309 * Triggers on sms table create a row in this table for each update/delete.
310 * This column is the "sub_id" of the row from sms table that was updated/deleted.
311 * @hide
312 * <P>Type: INTEGER (long)</P>
313 */
314 public static final String SUB_ID = "sub_id";
315
316 /**
317 * The type of operation that created this row.
318 * {@link #TYPE_UPDATE} = update op
319 * {@link #TYPE_DELETE} = delete op
320 * @hide
321 * <P>Type: INTEGER (long)</P>
322 */
323 public static final String TYPE = "type";
324
325 /**
326 * One of the possible values for the above column "type". Indicates it is an update op.
327 * @hide
328 */
329 public static final int TYPE_UPDATE = 0;
330
331 /**
332 * One of the possible values for the above column "type". Indicates it is a delete op.
333 * @hide
334 */
335 public static final int TYPE_DELETE = 1;
336
337 /**
338 * This column contains a non-null value only if the operation on sms table is an update op
339 * and the column "read" is changed by the update op.
340 * <P>Type: INTEGER (boolean)</P>
341 * @hide
342 */
343 public static final String NEW_READ_STATUS = "new_read_status";
344 }
345
346 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -0800347 * Contains all text-based SMS messages.
348 */
349 public static final class Sms implements BaseColumns, TextBasedSmsColumns {
350
351 /**
352 * Not instantiable.
353 * @hide
354 */
355 private Sms() {
356 }
357
358 /**
359 * Used to determine the currently configured default SMS package.
360 * @param context context of the requesting application
361 * @return package name for the default SMS package or null
362 */
363 public static String getDefaultSmsPackage(Context context) {
364 ComponentName component = SmsApplication.getDefaultSmsApplication(context, false);
365 if (component != null) {
366 return component.getPackageName();
367 }
368 return null;
369 }
370
371 /**
372 * Return cursor for table query.
373 * @hide
374 */
375 public static Cursor query(ContentResolver cr, String[] projection) {
376 return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
377 }
378
379 /**
380 * Return cursor for table query.
381 * @hide
382 */
Mathew Inwood8c854f82018-09-14 12:35:36 +0100383 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
Dan Willemsen4980bf42017-02-14 14:17:12 -0800384 public static Cursor query(ContentResolver cr, String[] projection,
385 String where, String orderBy) {
386 return cr.query(CONTENT_URI, projection, where,
387 null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
388 }
389
390 /**
391 * The {@code content://} style URL for this table.
392 */
393 public static final Uri CONTENT_URI = Uri.parse("content://sms");
394
395 /**
396 * The default sort order for this table.
397 */
398 public static final String DEFAULT_SORT_ORDER = "date DESC";
399
400 /**
401 * Add an SMS to the given URI.
402 *
403 * @param resolver the content resolver to use
404 * @param uri the URI to add the message to
405 * @param address the address of the sender
406 * @param body the body of the message
407 * @param subject the pseudo-subject of the message
408 * @param date the timestamp for the message
409 * @param read true if the message has been read, false if not
410 * @param deliveryReport true if a delivery report was requested, false if not
411 * @return the URI for the new message
412 * @hide
413 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100414 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800415 public static Uri addMessageToUri(ContentResolver resolver,
416 Uri uri, String address, String body, String subject,
417 Long date, boolean read, boolean deliveryReport) {
418 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
419 resolver, uri, address, body, subject, date, read, deliveryReport, -1L);
420 }
421
422 /**
423 * Add an SMS to the given URI.
424 *
425 * @param resolver the content resolver to use
426 * @param uri the URI to add the message to
427 * @param address the address of the sender
428 * @param body the body of the message
429 * @param subject the psuedo-subject of the message
430 * @param date the timestamp for the message
431 * @param read true if the message has been read, false if not
432 * @param deliveryReport true if a delivery report was requested, false if not
433 * @param subId the subscription which the message belongs to
434 * @return the URI for the new message
435 * @hide
436 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100437 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800438 public static Uri addMessageToUri(int subId, ContentResolver resolver,
439 Uri uri, String address, String body, String subject,
440 Long date, boolean read, boolean deliveryReport) {
441 return addMessageToUri(subId, resolver, uri, address, body, subject,
442 date, read, deliveryReport, -1L);
443 }
444
445 /**
446 * Add an SMS to the given URI with the specified thread ID.
447 *
448 * @param resolver the content resolver to use
449 * @param uri the URI to add the message to
450 * @param address the address of the sender
451 * @param body the body of the message
452 * @param subject the pseudo-subject of the message
453 * @param date the timestamp for the message
454 * @param read true if the message has been read, false if not
455 * @param deliveryReport true if a delivery report was requested, false if not
456 * @param threadId the thread_id of the message
457 * @return the URI for the new message
458 * @hide
459 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100460 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800461 public static Uri addMessageToUri(ContentResolver resolver,
462 Uri uri, String address, String body, String subject,
463 Long date, boolean read, boolean deliveryReport, long threadId) {
464 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
465 resolver, uri, address, body, subject,
466 date, read, deliveryReport, threadId);
467 }
468
469 /**
470 * Add an SMS to the given URI with thread_id specified.
471 *
472 * @param resolver the content resolver to use
473 * @param uri the URI to add the message to
474 * @param address the address of the sender
475 * @param body the body of the message
476 * @param subject the psuedo-subject of the message
477 * @param date the timestamp for the message
478 * @param read true if the message has been read, false if not
479 * @param deliveryReport true if a delivery report was requested, false if not
480 * @param threadId the thread_id of the message
481 * @param subId the subscription which the message belongs to
482 * @return the URI for the new message
483 * @hide
484 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100485 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800486 public static Uri addMessageToUri(int subId, ContentResolver resolver,
487 Uri uri, String address, String body, String subject,
488 Long date, boolean read, boolean deliveryReport, long threadId) {
489 ContentValues values = new ContentValues(8);
490 Rlog.v(TAG,"Telephony addMessageToUri sub id: " + subId);
491
492 values.put(SUBSCRIPTION_ID, subId);
493 values.put(ADDRESS, address);
494 if (date != null) {
495 values.put(DATE, date);
496 }
497 values.put(READ, read ? Integer.valueOf(1) : Integer.valueOf(0));
498 values.put(SUBJECT, subject);
499 values.put(BODY, body);
500 if (deliveryReport) {
501 values.put(STATUS, STATUS_PENDING);
502 }
503 if (threadId != -1L) {
504 values.put(THREAD_ID, threadId);
505 }
506 return resolver.insert(uri, values);
507 }
508
509 /**
510 * Move a message to the given folder.
511 *
512 * @param context the context to use
513 * @param uri the message to move
514 * @param folder the folder to move to
515 * @return true if the operation succeeded
516 * @hide
517 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100518 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800519 public static boolean moveMessageToFolder(Context context,
520 Uri uri, int folder, int error) {
521 if (uri == null) {
522 return false;
523 }
524
525 boolean markAsUnread = false;
526 boolean markAsRead = false;
527 switch(folder) {
528 case MESSAGE_TYPE_INBOX:
529 case MESSAGE_TYPE_DRAFT:
530 break;
531 case MESSAGE_TYPE_OUTBOX:
532 case MESSAGE_TYPE_SENT:
533 markAsRead = true;
534 break;
535 case MESSAGE_TYPE_FAILED:
536 case MESSAGE_TYPE_QUEUED:
537 markAsUnread = true;
538 break;
539 default:
540 return false;
541 }
542
543 ContentValues values = new ContentValues(3);
544
545 values.put(TYPE, folder);
546 if (markAsUnread) {
547 values.put(READ, 0);
548 } else if (markAsRead) {
549 values.put(READ, 1);
550 }
551 values.put(ERROR_CODE, error);
552
553 return 1 == SqliteWrapper.update(context, context.getContentResolver(),
554 uri, values, null, null);
555 }
556
557 /**
558 * Returns true iff the folder (message type) identifies an
559 * outgoing message.
560 * @hide
561 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100562 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800563 public static boolean isOutgoingFolder(int messageType) {
564 return (messageType == MESSAGE_TYPE_FAILED)
565 || (messageType == MESSAGE_TYPE_OUTBOX)
566 || (messageType == MESSAGE_TYPE_SENT)
567 || (messageType == MESSAGE_TYPE_QUEUED);
568 }
569
570 /**
571 * Contains all text-based SMS messages in the SMS app inbox.
572 */
573 public static final class Inbox implements BaseColumns, TextBasedSmsColumns {
574
575 /**
576 * Not instantiable.
577 * @hide
578 */
579 private Inbox() {
580 }
581
582 /**
583 * The {@code content://} style URL for this table.
584 */
585 public static final Uri CONTENT_URI = Uri.parse("content://sms/inbox");
586
587 /**
588 * The default sort order for this table.
589 */
590 public static final String DEFAULT_SORT_ORDER = "date DESC";
591
592 /**
593 * Add an SMS to the Draft box.
594 *
595 * @param resolver the content resolver to use
596 * @param address the address of the sender
597 * @param body the body of the message
598 * @param subject the pseudo-subject of the message
599 * @param date the timestamp for the message
600 * @param read true if the message has been read, false if not
601 * @return the URI for the new message
602 * @hide
603 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100604 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800605 public static Uri addMessage(ContentResolver resolver,
606 String address, String body, String subject, Long date,
607 boolean read) {
608 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
609 resolver, CONTENT_URI, address, body, subject, date, read, false);
610 }
611
612 /**
613 * Add an SMS to the Draft box.
614 *
615 * @param resolver the content resolver to use
616 * @param address the address of the sender
617 * @param body the body of the message
618 * @param subject the psuedo-subject of the message
619 * @param date the timestamp for the message
620 * @param read true if the message has been read, false if not
621 * @param subId the subscription which the message belongs to
622 * @return the URI for the new message
623 * @hide
624 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100625 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800626 public static Uri addMessage(int subId, ContentResolver resolver,
627 String address, String body, String subject, Long date, boolean read) {
628 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
629 subject, date, read, false);
630 }
631 }
632
633 /**
634 * Contains all sent text-based SMS messages in the SMS app.
635 */
636 public static final class Sent implements BaseColumns, TextBasedSmsColumns {
637
638 /**
639 * Not instantiable.
640 * @hide
641 */
642 private Sent() {
643 }
644
645 /**
646 * The {@code content://} style URL for this table.
647 */
648 public static final Uri CONTENT_URI = Uri.parse("content://sms/sent");
649
650 /**
651 * The default sort order for this table.
652 */
653 public static final String DEFAULT_SORT_ORDER = "date DESC";
654
655 /**
656 * Add an SMS to the Draft box.
657 *
658 * @param resolver the content resolver to use
659 * @param address the address of the sender
660 * @param body the body of the message
661 * @param subject the pseudo-subject of the message
662 * @param date the timestamp for the message
663 * @return the URI for the new message
664 * @hide
665 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100666 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800667 public static Uri addMessage(ContentResolver resolver,
668 String address, String body, String subject, Long date) {
669 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
670 resolver, CONTENT_URI, address, body, subject, date, true, false);
671 }
672
673 /**
674 * Add an SMS to the Draft box.
675 *
676 * @param resolver the content resolver to use
677 * @param address the address of the sender
678 * @param body the body of the message
679 * @param subject the psuedo-subject of the message
680 * @param date the timestamp for the message
681 * @param subId the subscription which the message belongs to
682 * @return the URI for the new message
683 * @hide
684 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100685 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800686 public static Uri addMessage(int subId, ContentResolver resolver,
687 String address, String body, String subject, Long date) {
688 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
689 subject, date, true, false);
690 }
691 }
692
693 /**
694 * Contains all sent text-based SMS messages in the SMS app.
695 */
696 public static final class Draft implements BaseColumns, TextBasedSmsColumns {
697
698 /**
699 * Not instantiable.
700 * @hide
701 */
702 private Draft() {
703 }
704
705 /**
706 * The {@code content://} style URL for this table.
707 */
708 public static final Uri CONTENT_URI = Uri.parse("content://sms/draft");
709
710 /**
711 * @hide
712 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100713 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800714 public static Uri addMessage(ContentResolver resolver,
715 String address, String body, String subject, Long date) {
716 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
717 resolver, CONTENT_URI, address, body, subject, date, true, false);
718 }
719
720 /**
721 * Add an SMS to the Draft box.
722 *
723 * @param resolver the content resolver to use
724 * @param address the address of the sender
725 * @param body the body of the message
726 * @param subject the psuedo-subject of the message
727 * @param date the timestamp for the message
728 * @param subId the subscription which the message belongs to
729 * @return the URI for the new message
730 * @hide
731 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100732 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800733 public static Uri addMessage(int subId, ContentResolver resolver,
734 String address, String body, String subject, Long date) {
735 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
736 subject, date, true, false);
737 }
738
739 /**
740 * The default sort order for this table.
741 */
742 public static final String DEFAULT_SORT_ORDER = "date DESC";
743 }
744
745 /**
746 * Contains all pending outgoing text-based SMS messages.
747 */
748 public static final class Outbox implements BaseColumns, TextBasedSmsColumns {
749
750 /**
751 * Not instantiable.
752 * @hide
753 */
754 private Outbox() {
755 }
756
757 /**
758 * The {@code content://} style URL for this table.
759 */
760 public static final Uri CONTENT_URI = Uri.parse("content://sms/outbox");
761
762 /**
763 * The default sort order for this table.
764 */
765 public static final String DEFAULT_SORT_ORDER = "date DESC";
766
767 /**
768 * Add an SMS to the outbox.
769 *
770 * @param resolver the content resolver to use
771 * @param address the address of the sender
772 * @param body the body of the message
773 * @param subject the pseudo-subject of the message
774 * @param date the timestamp for the message
775 * @param deliveryReport whether a delivery report was requested for the message
776 * @return the URI for the new message
777 * @hide
778 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100779 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800780 public static Uri addMessage(ContentResolver resolver,
781 String address, String body, String subject, Long date,
782 boolean deliveryReport, long threadId) {
783 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
784 resolver, CONTENT_URI, address, body, subject, date,
785 true, deliveryReport, threadId);
786 }
787
788 /**
789 * Add an SMS to the Out box.
790 *
791 * @param resolver the content resolver to use
792 * @param address the address of the sender
793 * @param body the body of the message
794 * @param subject the psuedo-subject of the message
795 * @param date the timestamp for the message
796 * @param deliveryReport whether a delivery report was requested for the message
797 * @param subId the subscription which the message belongs to
798 * @return the URI for the new message
799 * @hide
800 */
801 public static Uri addMessage(int subId, ContentResolver resolver,
802 String address, String body, String subject, Long date,
803 boolean deliveryReport, long threadId) {
804 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
805 subject, date, true, deliveryReport, threadId);
806 }
807 }
808
809 /**
810 * Contains all sent text-based SMS messages in the SMS app.
811 */
812 public static final class Conversations
813 implements BaseColumns, TextBasedSmsColumns {
814
815 /**
816 * Not instantiable.
817 * @hide
818 */
819 private Conversations() {
820 }
821
822 /**
823 * The {@code content://} style URL for this table.
824 */
825 public static final Uri CONTENT_URI = Uri.parse("content://sms/conversations");
826
827 /**
828 * The default sort order for this table.
829 */
830 public static final String DEFAULT_SORT_ORDER = "date DESC";
831
832 /**
833 * The first 45 characters of the body of the message.
834 * <P>Type: TEXT</P>
835 */
836 public static final String SNIPPET = "snippet";
837
838 /**
839 * The number of messages in the conversation.
840 * <P>Type: INTEGER</P>
841 */
842 public static final String MESSAGE_COUNT = "msg_count";
843 }
844
845 /**
846 * Contains constants for SMS related Intents that are broadcast.
847 */
848 public static final class Intents {
849
850 /**
851 * Not instantiable.
852 * @hide
853 */
854 private Intents() {
855 }
856
857 /**
858 * Set by BroadcastReceiver to indicate that the message was handled
859 * successfully.
860 */
861 public static final int RESULT_SMS_HANDLED = 1;
862
863 /**
864 * Set by BroadcastReceiver to indicate a generic error while
865 * processing the message.
866 */
867 public static final int RESULT_SMS_GENERIC_ERROR = 2;
868
869 /**
870 * Set by BroadcastReceiver to indicate insufficient memory to store
871 * the message.
872 */
873 public static final int RESULT_SMS_OUT_OF_MEMORY = 3;
874
875 /**
876 * Set by BroadcastReceiver to indicate that the message, while
877 * possibly valid, is of a format or encoding that is not
878 * supported.
879 */
880 public static final int RESULT_SMS_UNSUPPORTED = 4;
881
882 /**
883 * Set by BroadcastReceiver to indicate a duplicate incoming message.
884 */
885 public static final int RESULT_SMS_DUPLICATED = 5;
886
887 /**
888 * Activity action: Ask the user to change the default
889 * SMS application. This will show a dialog that asks the
890 * user whether they want to replace the current default
891 * SMS application with the one specified in
892 * {@link #EXTRA_PACKAGE_NAME}.
893 */
894 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
895 public static final String ACTION_CHANGE_DEFAULT =
896 "android.provider.Telephony.ACTION_CHANGE_DEFAULT";
897
898 /**
899 * The PackageName string passed in as an
900 * extra for {@link #ACTION_CHANGE_DEFAULT}
901 *
902 * @see #ACTION_CHANGE_DEFAULT
903 */
904 public static final String EXTRA_PACKAGE_NAME = "package";
905
906 /**
907 * Broadcast Action: A new text-based SMS message has been received
908 * by the device. This intent will only be delivered to the default
909 * sms app. That app is responsible for writing the message and notifying
910 * the user. The intent will have the following extra values:</p>
911 *
912 * <ul>
913 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
914 * that make up the message.</li>
915 * <li><em>"format"</em> - A String describing the format of the PDUs. It can
916 * be either "3gpp" or "3gpp2".</li>
917 * <li><em>"subscription"</em> - An optional long value of the subscription id which
918 * received the message.</li>
919 * <li><em>"slot"</em> - An optional int value of the SIM slot containing the
920 * subscription.</li>
921 * <li><em>"phone"</em> - An optional int value of the phone id associated with the
922 * subscription.</li>
923 * <li><em>"errorCode"</em> - An optional int error code associated with receiving
924 * the message.</li>
925 * </ul>
926 *
927 * <p>The extra values can be extracted using
928 * {@link #getMessagesFromIntent(Intent)}.</p>
929 *
930 * <p>If a BroadcastReceiver encounters an error while processing
931 * this intent it should set the result code appropriately.</p>
932 *
933 * <p class="note"><strong>Note:</strong>
934 * The broadcast receiver that filters for this intent must declare
935 * {@link android.Manifest.permission#BROADCAST_SMS} as a required permission in
936 * the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code
937 * <receiver>}</a> tag.
938 *
939 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
940 */
941 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
942 public static final String SMS_DELIVER_ACTION =
943 "android.provider.Telephony.SMS_DELIVER";
944
945 /**
946 * Broadcast Action: A new text-based SMS message has been received
947 * by the device. This intent will be delivered to all registered
948 * receivers as a notification. These apps are not expected to write the
949 * message or notify the user. The intent will have the following extra
950 * values:</p>
951 *
952 * <ul>
953 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
954 * that make up the message.</li>
955 * </ul>
956 *
957 * <p>The extra values can be extracted using
958 * {@link #getMessagesFromIntent(Intent)}.</p>
959 *
960 * <p>If a BroadcastReceiver encounters an error while processing
961 * this intent it should set the result code appropriately.</p>
962 *
963 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
964 */
965 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
966 public static final String SMS_RECEIVED_ACTION =
967 "android.provider.Telephony.SMS_RECEIVED";
968
969 /**
970 * Broadcast Action: A new data based SMS message has been received
971 * by the device. This intent will be delivered to all registered
972 * receivers as a notification. The intent will have the following extra
973 * values:</p>
974 *
975 * <ul>
976 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
977 * that make up the message.</li>
978 * </ul>
979 *
980 * <p>The extra values can be extracted using
981 * {@link #getMessagesFromIntent(Intent)}.</p>
982 *
983 * <p>If a BroadcastReceiver encounters an error while processing
984 * this intent it should set the result code appropriately.</p>
985 *
986 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
987 */
988 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
989 public static final String DATA_SMS_RECEIVED_ACTION =
990 "android.intent.action.DATA_SMS_RECEIVED";
991
992 /**
993 * Broadcast Action: A new WAP PUSH message has been received by the
994 * device. This intent will only be delivered to the default
995 * sms app. That app is responsible for writing the message and notifying
996 * the user. The intent will have the following extra values:</p>
997 *
998 * <ul>
999 * <li><em>"transactionId"</em> - (Integer) The WAP transaction ID</li>
1000 * <li><em>"pduType"</em> - (Integer) The WAP PDU type</li>
1001 * <li><em>"header"</em> - (byte[]) The header of the message</li>
1002 * <li><em>"data"</em> - (byte[]) The data payload of the message</li>
1003 * <li><em>"contentTypeParameters" </em>
1004 * -(HashMap&lt;String,String&gt;) Any parameters associated with the content type
1005 * (decoded from the WSP Content-Type header)</li>
1006 * <li><em>"subscription"</em> - An optional long value of the subscription id which
1007 * received the message.</li>
1008 * <li><em>"slot"</em> - An optional int value of the SIM slot containing the
1009 * subscription.</li>
1010 * <li><em>"phone"</em> - An optional int value of the phone id associated with the
1011 * subscription.</li>
1012 * </ul>
1013 *
1014 * <p>If a BroadcastReceiver encounters an error while processing
1015 * this intent it should set the result code appropriately.</p>
1016 *
1017 * <p>The contentTypeParameters extra value is map of content parameters keyed by
1018 * their names.</p>
1019 *
1020 * <p>If any unassigned well-known parameters are encountered, the key of the map will
1021 * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter. If
1022 * a parameter has No-Value the value in the map will be null.</p>
1023 *
1024 * <p>Requires {@link android.Manifest.permission#RECEIVE_MMS} or
1025 * {@link android.Manifest.permission#RECEIVE_WAP_PUSH} (depending on WAP PUSH type) to
1026 * receive.</p>
1027 *
1028 * <p class="note"><strong>Note:</strong>
1029 * The broadcast receiver that filters for this intent must declare
1030 * {@link android.Manifest.permission#BROADCAST_WAP_PUSH} as a required permission in
1031 * the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code
1032 * <receiver>}</a> tag.
1033 */
1034 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1035 public static final String WAP_PUSH_DELIVER_ACTION =
1036 "android.provider.Telephony.WAP_PUSH_DELIVER";
1037
1038 /**
1039 * Broadcast Action: A new WAP PUSH message has been received by the
1040 * device. This intent will be delivered to all registered
1041 * receivers as a notification. These apps are not expected to write the
1042 * message or notify the user. The intent will have the following extra
1043 * values:</p>
1044 *
1045 * <ul>
1046 * <li><em>"transactionId"</em> - (Integer) The WAP transaction ID</li>
1047 * <li><em>"pduType"</em> - (Integer) The WAP PDU type</li>
1048 * <li><em>"header"</em> - (byte[]) The header of the message</li>
1049 * <li><em>"data"</em> - (byte[]) The data payload of the message</li>
1050 * <li><em>"contentTypeParameters"</em>
1051 * - (HashMap&lt;String,String&gt;) Any parameters associated with the content type
1052 * (decoded from the WSP Content-Type header)</li>
1053 * </ul>
1054 *
1055 * <p>If a BroadcastReceiver encounters an error while processing
1056 * this intent it should set the result code appropriately.</p>
1057 *
1058 * <p>The contentTypeParameters extra value is map of content parameters keyed by
1059 * their names.</p>
1060 *
1061 * <p>If any unassigned well-known parameters are encountered, the key of the map will
1062 * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter. If
1063 * a parameter has No-Value the value in the map will be null.</p>
1064 *
1065 * <p>Requires {@link android.Manifest.permission#RECEIVE_MMS} or
1066 * {@link android.Manifest.permission#RECEIVE_WAP_PUSH} (depending on WAP PUSH type) to
1067 * receive.</p>
1068 */
1069 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1070 public static final String WAP_PUSH_RECEIVED_ACTION =
1071 "android.provider.Telephony.WAP_PUSH_RECEIVED";
1072
1073 /**
1074 * Broadcast Action: A new Cell Broadcast message has been received
1075 * by the device. The intent will have the following extra
1076 * values:</p>
1077 *
1078 * <ul>
1079 * <li><em>"message"</em> - An SmsCbMessage object containing the broadcast message
1080 * data. This is not an emergency alert, so ETWS and CMAS data will be null.</li>
1081 * </ul>
1082 *
1083 * <p>The extra values can be extracted using
1084 * {@link #getMessagesFromIntent(Intent)}.</p>
1085 *
1086 * <p>If a BroadcastReceiver encounters an error while processing
1087 * this intent it should set the result code appropriately.</p>
1088 *
1089 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1090 */
1091 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1092 public static final String SMS_CB_RECEIVED_ACTION =
1093 "android.provider.Telephony.SMS_CB_RECEIVED";
1094
1095 /**
1096 * Action: A SMS based carrier provision intent. Used to identify default
1097 * carrier provisioning app on the device.
1098 * @hide
1099 */
1100 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1101 @TestApi
1102 public static final String SMS_CARRIER_PROVISION_ACTION =
1103 "android.provider.Telephony.SMS_CARRIER_PROVISION";
1104
1105 /**
1106 * Broadcast Action: A new Emergency Broadcast message has been received
1107 * by the device. The intent will have the following extra
1108 * values:</p>
1109 *
1110 * <ul>
1111 * <li><em>"message"</em> - An SmsCbMessage object containing the broadcast message
1112 * data, including ETWS or CMAS warning notification info if present.</li>
1113 * </ul>
1114 *
1115 * <p>The extra values can be extracted using
1116 * {@link #getMessagesFromIntent(Intent)}.</p>
1117 *
1118 * <p>If a BroadcastReceiver encounters an error while processing
1119 * this intent it should set the result code appropriately.</p>
1120 *
1121 * <p>Requires {@link android.Manifest.permission#RECEIVE_EMERGENCY_BROADCAST} to
1122 * receive.</p>
1123 * @removed
1124 */
1125 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1126 public static final String SMS_EMERGENCY_CB_RECEIVED_ACTION =
1127 "android.provider.Telephony.SMS_EMERGENCY_CB_RECEIVED";
1128
1129 /**
1130 * Broadcast Action: A new CDMA SMS has been received containing Service Category
1131 * Program Data (updates the list of enabled broadcast channels). The intent will
1132 * have the following extra values:</p>
1133 *
1134 * <ul>
1135 * <li><em>"operations"</em> - An array of CdmaSmsCbProgramData objects containing
1136 * the service category operations (add/delete/clear) to perform.</li>
1137 * </ul>
1138 *
1139 * <p>The extra values can be extracted using
1140 * {@link #getMessagesFromIntent(Intent)}.</p>
1141 *
1142 * <p>If a BroadcastReceiver encounters an error while processing
1143 * this intent it should set the result code appropriately.</p>
1144 *
1145 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1146 */
1147 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1148 public static final String SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION =
1149 "android.provider.Telephony.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED";
1150
1151 /**
1152 * Broadcast Action: The SIM storage for SMS messages is full. If
1153 * space is not freed, messages targeted for the SIM (class 2) may
1154 * not be saved.
1155 *
1156 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1157 */
1158 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1159 public static final String SIM_FULL_ACTION =
1160 "android.provider.Telephony.SIM_FULL";
1161
1162 /**
1163 * Broadcast Action: An incoming SMS has been rejected by the
1164 * telephony framework. This intent is sent in lieu of any
1165 * of the RECEIVED_ACTION intents. The intent will have the
1166 * following extra value:</p>
1167 *
1168 * <ul>
1169 * <li><em>"result"</em> - An int result code, e.g. {@link #RESULT_SMS_OUT_OF_MEMORY}
1170 * indicating the error returned to the network.</li>
1171 * </ul>
1172 *
1173 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1174 */
1175 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1176 public static final String SMS_REJECTED_ACTION =
1177 "android.provider.Telephony.SMS_REJECTED";
1178
1179 /**
1180 * Broadcast Action: An incoming MMS has been downloaded. The intent is sent to all
1181 * users, except for secondary users where SMS has been disabled and to managed
1182 * profiles.
1183 * @hide
1184 */
1185 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1186 public static final String MMS_DOWNLOADED_ACTION =
1187 "android.provider.Telephony.MMS_DOWNLOADED";
1188
1189 /**
Cassie5b97cf12018-02-22 09:58:33 -08001190 * Broadcast Action: A debug code has been entered in the dialer. This intent is
1191 * broadcast by the system and OEM telephony apps may need to receive these broadcasts.
1192 * These "secret codes" are used to activate developer menus by dialing certain codes.
1193 * And they are of the form {@code *#*#&lt;code&gt;#*#*}. The intent will have the data
1194 * URI: {@code android_secret_code://&lt;code&gt;}. It is possible that a manifest
1195 * receiver would be woken up even if it is not currently running.
1196 *
1197 * <p>Requires {@code android.Manifest.permission#CONTROL_INCALL_EXPERIENCE} to
1198 * send and receive.</p>
Cassie6d0a5712018-08-21 13:38:39 -07001199 * @deprecated it is no longer supported, use {@link
1200 * TelephonyManager#ACTION_SECRET_CODE} instead
Cassie866f4942018-01-19 17:23:36 -08001201 */
Cassie6d0a5712018-08-21 13:38:39 -07001202 @Deprecated
Cassie866f4942018-01-19 17:23:36 -08001203 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1204 public static final String SECRET_CODE_ACTION =
1205 "android.provider.Telephony.SECRET_CODE";
1206
1207 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08001208 * Broadcast action: When the default SMS package changes,
1209 * the previous default SMS package and the new default SMS
1210 * package are sent this broadcast to notify them of the change.
1211 * A boolean is specified in {@link #EXTRA_IS_DEFAULT_SMS_APP} to
1212 * indicate whether the package is the new default SMS package.
1213 */
1214 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1215 public static final String ACTION_DEFAULT_SMS_PACKAGE_CHANGED =
1216 "android.provider.action.DEFAULT_SMS_PACKAGE_CHANGED";
1217
1218 /**
1219 * The IsDefaultSmsApp boolean passed as an
1220 * extra for {@link #ACTION_DEFAULT_SMS_PACKAGE_CHANGED} to indicate whether the
1221 * SMS app is becoming the default SMS app or is no longer the default.
1222 *
1223 * @see #ACTION_DEFAULT_SMS_PACKAGE_CHANGED
1224 */
1225 public static final String EXTRA_IS_DEFAULT_SMS_APP =
1226 "android.provider.extra.IS_DEFAULT_SMS_APP";
1227
1228 /**
1229 * Broadcast action: When a change is made to the SmsProvider or
1230 * MmsProvider by a process other than the default SMS application,
1231 * this intent is broadcast to the default SMS application so it can
1232 * re-sync or update the change. The uri that was used to call the provider
1233 * can be retrieved from the intent with getData(). The actual affected uris
1234 * (which would depend on the selection specified) are not included.
1235 */
1236 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1237 public static final String ACTION_EXTERNAL_PROVIDER_CHANGE =
1238 "android.provider.action.EXTERNAL_PROVIDER_CHANGE";
1239
1240 /**
Makoto Onukia042aaa2018-09-18 16:14:12 -07001241 * Same as {@link #ACTION_DEFAULT_SMS_PACKAGE_CHANGED} but it's implicit (e.g. sent to
1242 * all apps) and requires
1243 * {@link android.Manifest.permission#MONITOR_DEFAULT_SMS_PACKAGE} to receive.
1244 *
1245 * @hide
1246 */
1247 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1248 public static final String ACTION_DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL =
1249 "android.provider.action.DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL";
1250
1251 /**
Amit Mahajan8c1c45a2018-10-22 10:43:34 -07001252 * Broadcast action: When SMS-MMS db is being created. If file-based encryption is
1253 * supported, this broadcast indicates creation of the db in credential-encrypted
1254 * storage. A boolean is specified in {@link #EXTRA_IS_INITIAL_CREATE} to indicate if
1255 * this is the initial create of the db. Requires
1256 * {@link android.Manifest.permission#READ_SMS} to receive.
1257 *
1258 * @see #EXTRA_IS_INITIAL_CREATE
1259 *
1260 * @hide
1261 */
1262 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1263 public static final String ACTION_SMS_MMS_DB_CREATED =
1264 "android.provider.action.SMS_MMS_DB_CREATED";
1265
1266 /**
1267 * Boolean flag passed as an extra with {@link #ACTION_SMS_MMS_DB_CREATED} to indicate
1268 * whether the DB creation is the initial creation on the device, that is it is after a
1269 * factory-data reset or a new device. Any subsequent creations of the DB (which
1270 * happens only in error scenarios) will have this flag set to false.
1271 *
1272 * @see #ACTION_SMS_MMS_DB_CREATED
1273 *
1274 * @hide
1275 */
1276 public static final String EXTRA_IS_INITIAL_CREATE =
1277 "android.provider.extra.IS_INITIAL_CREATE";
Jayachandran C349b9ba2018-10-30 15:09:06 -07001278
1279 /**
1280 * Broadcast intent action indicating that the telephony provider SMS MMS database is
1281 * corrupted. A boolean is specified in {@link #EXTRA_IS_CORRUPTED} to indicate if the
1282 * database is corrupted. Requires the
1283 * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE permission.
1284 *
1285 * @hide
1286 */
1287 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1288 @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
1289 public static final String ACTION_SMS_MMS_DB_LOST =
1290 "android.provider.action.SMS_MMS_DB_LOST";
1291
1292 /**
1293 * Boolean flag passed as an extra with {@link #ACTION_SMS_MMS_DB_LOST} to indicate
1294 * whether the DB got corrupted or not.
1295 *
1296 * @see #ACTION_SMS_MMS_DB_LOST
1297 *
1298 * @hide
1299 */
1300 public static final String EXTRA_IS_CORRUPTED =
1301 "android.provider.extra.IS_CORRUPTED";
1302
Amit Mahajan8c1c45a2018-10-22 10:43:34 -07001303 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08001304 * Read the PDUs out of an {@link #SMS_RECEIVED_ACTION} or a
1305 * {@link #DATA_SMS_RECEIVED_ACTION} intent.
1306 *
1307 * @param intent the intent to read from
1308 * @return an array of SmsMessages for the PDUs
1309 */
1310 public static SmsMessage[] getMessagesFromIntent(Intent intent) {
1311 Object[] messages;
1312 try {
1313 messages = (Object[]) intent.getSerializableExtra("pdus");
1314 }
1315 catch (ClassCastException e) {
1316 Rlog.e(TAG, "getMessagesFromIntent: " + e);
1317 return null;
1318 }
1319
1320 if (messages == null) {
1321 Rlog.e(TAG, "pdus does not exist in the intent");
1322 return null;
1323 }
1324
1325 String format = intent.getStringExtra("format");
1326 int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
1327 SubscriptionManager.getDefaultSmsSubscriptionId());
1328
1329 Rlog.v(TAG, " getMessagesFromIntent sub_id : " + subId);
1330
1331 int pduCount = messages.length;
1332 SmsMessage[] msgs = new SmsMessage[pduCount];
1333
1334 for (int i = 0; i < pduCount; i++) {
1335 byte[] pdu = (byte[]) messages[i];
1336 msgs[i] = SmsMessage.createFromPdu(pdu, format);
1337 if (msgs[i] != null) msgs[i].setSubId(subId);
1338 }
1339 return msgs;
1340 }
1341 }
1342 }
1343
1344 /**
pkanwar16b8a0d2017-06-07 10:59:41 -07001345 * Base column for the table that contain Carrier Public key.
1346 * @hide
1347 */
1348 public interface CarrierColumns extends BaseColumns {
1349
1350 public static final String MCC = "mcc";
1351 public static final String MNC = "mnc";
1352 public static final String KEY_TYPE = "key_type";
1353 public static final String MVNO_TYPE = "mvno_type";
1354 public static final String MVNO_MATCH_DATA = "mvno_match_data";
1355 public static final String PUBLIC_KEY = "public_key";
1356 public static final String KEY_IDENTIFIER = "key_identifier";
1357 public static final String EXPIRATION_TIME = "expiration_time";
1358 public static final String LAST_MODIFIED = "last_modified";
1359
1360 /**
1361 * The {@code content://} style URL for this table.
1362 * @hide
1363 */
1364 public static final Uri CONTENT_URI = Uri.parse("content://carrier_information/carrier");
1365 }
1366
1367 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08001368 * Base columns for tables that contain MMSs.
1369 */
1370 public interface BaseMmsColumns extends BaseColumns {
1371
1372 /** Message box: all messages. */
1373 public static final int MESSAGE_BOX_ALL = 0;
1374 /** Message box: inbox. */
1375 public static final int MESSAGE_BOX_INBOX = 1;
1376 /** Message box: sent messages. */
1377 public static final int MESSAGE_BOX_SENT = 2;
1378 /** Message box: drafts. */
1379 public static final int MESSAGE_BOX_DRAFTS = 3;
1380 /** Message box: outbox. */
1381 public static final int MESSAGE_BOX_OUTBOX = 4;
1382 /** Message box: failed. */
1383 public static final int MESSAGE_BOX_FAILED = 5;
1384
1385 /**
1386 * The thread ID of the message.
1387 * <P>Type: INTEGER (long)</P>
1388 */
1389 public static final String THREAD_ID = "thread_id";
1390
1391 /**
1392 * The date the message was received.
1393 * <P>Type: INTEGER (long)</P>
1394 */
1395 public static final String DATE = "date";
1396
1397 /**
1398 * The date the message was sent.
1399 * <P>Type: INTEGER (long)</P>
1400 */
1401 public static final String DATE_SENT = "date_sent";
1402
1403 /**
1404 * The box which the message belongs to, e.g. {@link #MESSAGE_BOX_INBOX}.
1405 * <P>Type: INTEGER</P>
1406 */
1407 public static final String MESSAGE_BOX = "msg_box";
1408
1409 /**
1410 * Has the message been read?
1411 * <P>Type: INTEGER (boolean)</P>
1412 */
1413 public static final String READ = "read";
1414
1415 /**
1416 * Has the message been seen by the user? The "seen" flag determines
1417 * whether we need to show a new message notification.
1418 * <P>Type: INTEGER (boolean)</P>
1419 */
1420 public static final String SEEN = "seen";
1421
1422 /**
1423 * Does the message have only a text part (can also have a subject) with
1424 * no picture, slideshow, sound, etc. parts?
1425 * <P>Type: INTEGER (boolean)</P>
1426 */
1427 public static final String TEXT_ONLY = "text_only";
1428
1429 /**
1430 * The {@code Message-ID} of the message.
1431 * <P>Type: TEXT</P>
1432 */
1433 public static final String MESSAGE_ID = "m_id";
1434
1435 /**
1436 * The subject of the message, if present.
1437 * <P>Type: TEXT</P>
1438 */
1439 public static final String SUBJECT = "sub";
1440
1441 /**
1442 * The character set of the subject, if present.
1443 * <P>Type: INTEGER</P>
1444 */
1445 public static final String SUBJECT_CHARSET = "sub_cs";
1446
1447 /**
1448 * The {@code Content-Type} of the message.
1449 * <P>Type: TEXT</P>
1450 */
1451 public static final String CONTENT_TYPE = "ct_t";
1452
1453 /**
1454 * The {@code Content-Location} of the message.
1455 * <P>Type: TEXT</P>
1456 */
1457 public static final String CONTENT_LOCATION = "ct_l";
1458
1459 /**
1460 * The expiry time of the message.
1461 * <P>Type: INTEGER (long)</P>
1462 */
1463 public static final String EXPIRY = "exp";
1464
1465 /**
1466 * The class of the message.
1467 * <P>Type: TEXT</P>
1468 */
1469 public static final String MESSAGE_CLASS = "m_cls";
1470
1471 /**
1472 * The type of the message defined by MMS spec.
1473 * <P>Type: INTEGER</P>
1474 */
1475 public static final String MESSAGE_TYPE = "m_type";
1476
1477 /**
1478 * The version of the specification that this message conforms to.
1479 * <P>Type: INTEGER</P>
1480 */
1481 public static final String MMS_VERSION = "v";
1482
1483 /**
1484 * The size of the message.
1485 * <P>Type: INTEGER</P>
1486 */
1487 public static final String MESSAGE_SIZE = "m_size";
1488
1489 /**
1490 * The priority of the message.
1491 * <P>Type: INTEGER</P>
1492 */
1493 public static final String PRIORITY = "pri";
1494
1495 /**
1496 * The {@code read-report} of the message.
1497 * <P>Type: INTEGER (boolean)</P>
1498 */
1499 public static final String READ_REPORT = "rr";
1500
1501 /**
1502 * Is read report allowed?
1503 * <P>Type: INTEGER (boolean)</P>
1504 */
1505 public static final String REPORT_ALLOWED = "rpt_a";
1506
1507 /**
1508 * The {@code response-status} of the message.
1509 * <P>Type: INTEGER</P>
1510 */
1511 public static final String RESPONSE_STATUS = "resp_st";
1512
1513 /**
1514 * The {@code status} of the message.
1515 * <P>Type: INTEGER</P>
1516 */
1517 public static final String STATUS = "st";
1518
1519 /**
1520 * The {@code transaction-id} of the message.
1521 * <P>Type: TEXT</P>
1522 */
1523 public static final String TRANSACTION_ID = "tr_id";
1524
1525 /**
1526 * The {@code retrieve-status} of the message.
1527 * <P>Type: INTEGER</P>
1528 */
1529 public static final String RETRIEVE_STATUS = "retr_st";
1530
1531 /**
1532 * The {@code retrieve-text} of the message.
1533 * <P>Type: TEXT</P>
1534 */
1535 public static final String RETRIEVE_TEXT = "retr_txt";
1536
1537 /**
1538 * The character set of the retrieve-text.
1539 * <P>Type: INTEGER</P>
1540 */
1541 public static final String RETRIEVE_TEXT_CHARSET = "retr_txt_cs";
1542
1543 /**
1544 * The {@code read-status} of the message.
1545 * <P>Type: INTEGER</P>
1546 */
1547 public static final String READ_STATUS = "read_status";
1548
1549 /**
1550 * The {@code content-class} of the message.
1551 * <P>Type: INTEGER</P>
1552 */
1553 public static final String CONTENT_CLASS = "ct_cls";
1554
1555 /**
1556 * The {@code delivery-report} of the message.
1557 * <P>Type: INTEGER</P>
1558 */
1559 public static final String DELIVERY_REPORT = "d_rpt";
1560
1561 /**
1562 * The {@code delivery-time-token} of the message.
1563 * <P>Type: INTEGER</P>
1564 * @deprecated this column is no longer supported.
1565 * @hide
1566 */
1567 @Deprecated
1568 public static final String DELIVERY_TIME_TOKEN = "d_tm_tok";
1569
1570 /**
1571 * The {@code delivery-time} of the message.
1572 * <P>Type: INTEGER</P>
1573 */
1574 public static final String DELIVERY_TIME = "d_tm";
1575
1576 /**
1577 * The {@code response-text} of the message.
1578 * <P>Type: TEXT</P>
1579 */
1580 public static final String RESPONSE_TEXT = "resp_txt";
1581
1582 /**
1583 * The {@code sender-visibility} of the message.
1584 * <P>Type: TEXT</P>
1585 * @deprecated this column is no longer supported.
1586 * @hide
1587 */
1588 @Deprecated
1589 public static final String SENDER_VISIBILITY = "s_vis";
1590
1591 /**
1592 * The {@code reply-charging} of the message.
1593 * <P>Type: INTEGER</P>
1594 * @deprecated this column is no longer supported.
1595 * @hide
1596 */
1597 @Deprecated
1598 public static final String REPLY_CHARGING = "r_chg";
1599
1600 /**
1601 * The {@code reply-charging-deadline-token} of the message.
1602 * <P>Type: INTEGER</P>
1603 * @deprecated this column is no longer supported.
1604 * @hide
1605 */
1606 @Deprecated
1607 public static final String REPLY_CHARGING_DEADLINE_TOKEN = "r_chg_dl_tok";
1608
1609 /**
1610 * The {@code reply-charging-deadline} of the message.
1611 * <P>Type: INTEGER</P>
1612 * @deprecated this column is no longer supported.
1613 * @hide
1614 */
1615 @Deprecated
1616 public static final String REPLY_CHARGING_DEADLINE = "r_chg_dl";
1617
1618 /**
1619 * The {@code reply-charging-id} of the message.
1620 * <P>Type: TEXT</P>
1621 * @deprecated this column is no longer supported.
1622 * @hide
1623 */
1624 @Deprecated
1625 public static final String REPLY_CHARGING_ID = "r_chg_id";
1626
1627 /**
1628 * The {@code reply-charging-size} of the message.
1629 * <P>Type: INTEGER</P>
1630 * @deprecated this column is no longer supported.
1631 * @hide
1632 */
1633 @Deprecated
1634 public static final String REPLY_CHARGING_SIZE = "r_chg_sz";
1635
1636 /**
1637 * The {@code previously-sent-by} of the message.
1638 * <P>Type: TEXT</P>
1639 * @deprecated this column is no longer supported.
1640 * @hide
1641 */
1642 @Deprecated
1643 public static final String PREVIOUSLY_SENT_BY = "p_s_by";
1644
1645 /**
1646 * The {@code previously-sent-date} of the message.
1647 * <P>Type: INTEGER</P>
1648 * @deprecated this column is no longer supported.
1649 * @hide
1650 */
1651 @Deprecated
1652 public static final String PREVIOUSLY_SENT_DATE = "p_s_d";
1653
1654 /**
1655 * The {@code store} of the message.
1656 * <P>Type: TEXT</P>
1657 * @deprecated this column is no longer supported.
1658 * @hide
1659 */
1660 @Deprecated
1661 public static final String STORE = "store";
1662
1663 /**
1664 * The {@code mm-state} of the message.
1665 * <P>Type: INTEGER</P>
1666 * @deprecated this column is no longer supported.
1667 * @hide
1668 */
1669 @Deprecated
1670 public static final String MM_STATE = "mm_st";
1671
1672 /**
1673 * The {@code mm-flags-token} of the message.
1674 * <P>Type: INTEGER</P>
1675 * @deprecated this column is no longer supported.
1676 * @hide
1677 */
1678 @Deprecated
1679 public static final String MM_FLAGS_TOKEN = "mm_flg_tok";
1680
1681 /**
1682 * The {@code mm-flags} of the message.
1683 * <P>Type: TEXT</P>
1684 * @deprecated this column is no longer supported.
1685 * @hide
1686 */
1687 @Deprecated
1688 public static final String MM_FLAGS = "mm_flg";
1689
1690 /**
1691 * The {@code store-status} of the message.
1692 * <P>Type: TEXT</P>
1693 * @deprecated this column is no longer supported.
1694 * @hide
1695 */
1696 @Deprecated
1697 public static final String STORE_STATUS = "store_st";
1698
1699 /**
1700 * The {@code store-status-text} of the message.
1701 * <P>Type: TEXT</P>
1702 * @deprecated this column is no longer supported.
1703 * @hide
1704 */
1705 @Deprecated
1706 public static final String STORE_STATUS_TEXT = "store_st_txt";
1707
1708 /**
1709 * The {@code stored} of the message.
1710 * <P>Type: TEXT</P>
1711 * @deprecated this column is no longer supported.
1712 * @hide
1713 */
1714 @Deprecated
1715 public static final String STORED = "stored";
1716
1717 /**
1718 * The {@code totals} of the message.
1719 * <P>Type: TEXT</P>
1720 * @deprecated this column is no longer supported.
1721 * @hide
1722 */
1723 @Deprecated
1724 public static final String TOTALS = "totals";
1725
1726 /**
1727 * The {@code mbox-totals} of the message.
1728 * <P>Type: TEXT</P>
1729 * @deprecated this column is no longer supported.
1730 * @hide
1731 */
1732 @Deprecated
1733 public static final String MBOX_TOTALS = "mb_t";
1734
1735 /**
1736 * The {@code mbox-totals-token} of the message.
1737 * <P>Type: INTEGER</P>
1738 * @deprecated this column is no longer supported.
1739 * @hide
1740 */
1741 @Deprecated
1742 public static final String MBOX_TOTALS_TOKEN = "mb_t_tok";
1743
1744 /**
1745 * The {@code quotas} of the message.
1746 * <P>Type: TEXT</P>
1747 * @deprecated this column is no longer supported.
1748 * @hide
1749 */
1750 @Deprecated
1751 public static final String QUOTAS = "qt";
1752
1753 /**
1754 * The {@code mbox-quotas} of the message.
1755 * <P>Type: TEXT</P>
1756 * @deprecated this column is no longer supported.
1757 * @hide
1758 */
1759 @Deprecated
1760 public static final String MBOX_QUOTAS = "mb_qt";
1761
1762 /**
1763 * The {@code mbox-quotas-token} of the message.
1764 * <P>Type: INTEGER</P>
1765 * @deprecated this column is no longer supported.
1766 * @hide
1767 */
1768 @Deprecated
1769 public static final String MBOX_QUOTAS_TOKEN = "mb_qt_tok";
1770
1771 /**
1772 * The {@code message-count} of the message.
1773 * <P>Type: INTEGER</P>
1774 * @deprecated this column is no longer supported.
1775 * @hide
1776 */
1777 @Deprecated
1778 public static final String MESSAGE_COUNT = "m_cnt";
1779
1780 /**
1781 * The {@code start} of the message.
1782 * <P>Type: INTEGER</P>
1783 * @deprecated this column is no longer supported.
1784 * @hide
1785 */
1786 @Deprecated
1787 public static final String START = "start";
1788
1789 /**
1790 * The {@code distribution-indicator} of the message.
1791 * <P>Type: TEXT</P>
1792 * @deprecated this column is no longer supported.
1793 * @hide
1794 */
1795 @Deprecated
1796 public static final String DISTRIBUTION_INDICATOR = "d_ind";
1797
1798 /**
1799 * The {@code element-descriptor} of the message.
1800 * <P>Type: TEXT</P>
1801 * @deprecated this column is no longer supported.
1802 * @hide
1803 */
1804 @Deprecated
1805 public static final String ELEMENT_DESCRIPTOR = "e_des";
1806
1807 /**
1808 * The {@code limit} of the message.
1809 * <P>Type: INTEGER</P>
1810 * @deprecated this column is no longer supported.
1811 * @hide
1812 */
1813 @Deprecated
1814 public static final String LIMIT = "limit";
1815
1816 /**
1817 * The {@code recommended-retrieval-mode} of the message.
1818 * <P>Type: INTEGER</P>
1819 * @deprecated this column is no longer supported.
1820 * @hide
1821 */
1822 @Deprecated
1823 public static final String RECOMMENDED_RETRIEVAL_MODE = "r_r_mod";
1824
1825 /**
1826 * The {@code recommended-retrieval-mode-text} of the message.
1827 * <P>Type: TEXT</P>
1828 * @deprecated this column is no longer supported.
1829 * @hide
1830 */
1831 @Deprecated
1832 public static final String RECOMMENDED_RETRIEVAL_MODE_TEXT = "r_r_mod_txt";
1833
1834 /**
1835 * The {@code status-text} of the message.
1836 * <P>Type: TEXT</P>
1837 * @deprecated this column is no longer supported.
1838 * @hide
1839 */
1840 @Deprecated
1841 public static final String STATUS_TEXT = "st_txt";
1842
1843 /**
1844 * The {@code applic-id} of the message.
1845 * <P>Type: TEXT</P>
1846 * @deprecated this column is no longer supported.
1847 * @hide
1848 */
1849 @Deprecated
1850 public static final String APPLIC_ID = "apl_id";
1851
1852 /**
1853 * The {@code reply-applic-id} of the message.
1854 * <P>Type: TEXT</P>
1855 * @deprecated this column is no longer supported.
1856 * @hide
1857 */
1858 @Deprecated
1859 public static final String REPLY_APPLIC_ID = "r_apl_id";
1860
1861 /**
1862 * The {@code aux-applic-id} of the message.
1863 * <P>Type: TEXT</P>
1864 * @deprecated this column is no longer supported.
1865 * @hide
1866 */
1867 @Deprecated
1868 public static final String AUX_APPLIC_ID = "aux_apl_id";
1869
1870 /**
1871 * The {@code drm-content} of the message.
1872 * <P>Type: TEXT</P>
1873 * @deprecated this column is no longer supported.
1874 * @hide
1875 */
1876 @Deprecated
1877 public static final String DRM_CONTENT = "drm_c";
1878
1879 /**
1880 * The {@code adaptation-allowed} of the message.
1881 * <P>Type: TEXT</P>
1882 * @deprecated this column is no longer supported.
1883 * @hide
1884 */
1885 @Deprecated
1886 public static final String ADAPTATION_ALLOWED = "adp_a";
1887
1888 /**
1889 * The {@code replace-id} of the message.
1890 * <P>Type: TEXT</P>
1891 * @deprecated this column is no longer supported.
1892 * @hide
1893 */
1894 @Deprecated
1895 public static final String REPLACE_ID = "repl_id";
1896
1897 /**
1898 * The {@code cancel-id} of the message.
1899 * <P>Type: TEXT</P>
1900 * @deprecated this column is no longer supported.
1901 * @hide
1902 */
1903 @Deprecated
1904 public static final String CANCEL_ID = "cl_id";
1905
1906 /**
1907 * The {@code cancel-status} of the message.
1908 * <P>Type: INTEGER</P>
1909 * @deprecated this column is no longer supported.
1910 * @hide
1911 */
1912 @Deprecated
1913 public static final String CANCEL_STATUS = "cl_st";
1914
1915 /**
1916 * Is the message locked?
1917 * <P>Type: INTEGER (boolean)</P>
1918 */
1919 public static final String LOCKED = "locked";
1920
1921 /**
1922 * The subscription to which the message belongs to. Its value will be
1923 * < 0 if the sub id cannot be determined.
1924 * <p>Type: INTEGER (long)</p>
1925 */
1926 public static final String SUBSCRIPTION_ID = "sub_id";
1927
1928 /**
1929 * The identity of the sender of a sent message. It is
1930 * usually the package name of the app which sends the message.
1931 * <p class="note"><strong>Note:</strong>
1932 * This column is read-only. It is set by the provider and can not be changed by apps.
1933 * <p>Type: TEXT</p>
1934 */
1935 public static final String CREATOR = "creator";
1936 }
1937
1938 /**
1939 * Columns for the "canonical_addresses" table used by MMS and SMS.
1940 */
1941 public interface CanonicalAddressesColumns extends BaseColumns {
1942 /**
1943 * An address used in MMS or SMS. Email addresses are
1944 * converted to lower case and are compared by string
1945 * equality. Other addresses are compared using
1946 * PHONE_NUMBERS_EQUAL.
1947 * <P>Type: TEXT</P>
1948 */
1949 public static final String ADDRESS = "address";
1950 }
1951
1952 /**
1953 * Columns for the "threads" table used by MMS and SMS.
1954 */
1955 public interface ThreadsColumns extends BaseColumns {
1956
1957 /**
1958 * The date at which the thread was created.
1959 * <P>Type: INTEGER (long)</P>
1960 */
1961 public static final String DATE = "date";
1962
1963 /**
1964 * A string encoding of the recipient IDs of the recipients of
1965 * the message, in numerical order and separated by spaces.
1966 * <P>Type: TEXT</P>
1967 */
1968 public static final String RECIPIENT_IDS = "recipient_ids";
1969
1970 /**
1971 * The message count of the thread.
1972 * <P>Type: INTEGER</P>
1973 */
1974 public static final String MESSAGE_COUNT = "message_count";
1975
1976 /**
1977 * Indicates whether all messages of the thread have been read.
1978 * <P>Type: INTEGER</P>
1979 */
1980 public static final String READ = "read";
1981
1982 /**
1983 * The snippet of the latest message in the thread.
1984 * <P>Type: TEXT</P>
1985 */
1986 public static final String SNIPPET = "snippet";
1987
1988 /**
1989 * The charset of the snippet.
1990 * <P>Type: INTEGER</P>
1991 */
1992 public static final String SNIPPET_CHARSET = "snippet_cs";
1993
1994 /**
1995 * Type of the thread, either {@link Threads#COMMON_THREAD} or
1996 * {@link Threads#BROADCAST_THREAD}.
1997 * <P>Type: INTEGER</P>
1998 */
1999 public static final String TYPE = "type";
2000
2001 /**
2002 * Indicates whether there is a transmission error in the thread.
2003 * <P>Type: INTEGER</P>
2004 */
2005 public static final String ERROR = "error";
2006
2007 /**
2008 * Indicates whether this thread contains any attachments.
2009 * <P>Type: INTEGER</P>
2010 */
2011 public static final String HAS_ATTACHMENT = "has_attachment";
2012
2013 /**
2014 * If the thread is archived
2015 * <P>Type: INTEGER (boolean)</P>
2016 */
2017 public static final String ARCHIVED = "archived";
2018 }
2019
2020 /**
2021 * Helper functions for the "threads" table used by MMS and SMS.
2022 */
2023 public static final class Threads implements ThreadsColumns {
2024
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002025 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002026 private static final String[] ID_PROJECTION = { BaseColumns._ID };
2027
2028 /**
2029 * Private {@code content://} style URL for this table. Used by
2030 * {@link #getOrCreateThreadId(android.content.Context, java.util.Set)}.
2031 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002032 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002033 private static final Uri THREAD_ID_CONTENT_URI = Uri.parse(
2034 "content://mms-sms/threadID");
2035
2036 /**
2037 * The {@code content://} style URL for this table, by conversation.
2038 */
2039 public static final Uri CONTENT_URI = Uri.withAppendedPath(
2040 MmsSms.CONTENT_URI, "conversations");
2041
2042 /**
2043 * The {@code content://} style URL for this table, for obsolete threads.
2044 */
2045 public static final Uri OBSOLETE_THREADS_URI = Uri.withAppendedPath(
2046 CONTENT_URI, "obsolete");
2047
2048 /** Thread type: common thread. */
2049 public static final int COMMON_THREAD = 0;
2050
2051 /** Thread type: broadcast thread. */
2052 public static final int BROADCAST_THREAD = 1;
2053
2054 /**
2055 * Not instantiable.
2056 * @hide
2057 */
2058 private Threads() {
2059 }
2060
2061 /**
2062 * This is a single-recipient version of {@code getOrCreateThreadId}.
2063 * It's convenient for use with SMS messages.
2064 * @param context the context object to use.
2065 * @param recipient the recipient to send to.
2066 */
2067 public static long getOrCreateThreadId(Context context, String recipient) {
2068 Set<String> recipients = new HashSet<String>();
2069
2070 recipients.add(recipient);
2071 return getOrCreateThreadId(context, recipients);
2072 }
2073
2074 /**
2075 * Given the recipients list and subject of an unsaved message,
2076 * return its thread ID. If the message starts a new thread,
2077 * allocate a new thread ID. Otherwise, use the appropriate
2078 * existing thread ID.
2079 *
2080 * <p>Find the thread ID of the same set of recipients (in any order,
2081 * without any additions). If one is found, return it. Otherwise,
2082 * return a unique thread ID.</p>
2083 */
2084 public static long getOrCreateThreadId(
2085 Context context, Set<String> recipients) {
2086 Uri.Builder uriBuilder = THREAD_ID_CONTENT_URI.buildUpon();
2087
2088 for (String recipient : recipients) {
2089 if (Mms.isEmailAddress(recipient)) {
2090 recipient = Mms.extractAddrSpec(recipient);
2091 }
2092
2093 uriBuilder.appendQueryParameter("recipient", recipient);
2094 }
2095
2096 Uri uri = uriBuilder.build();
2097 //if (DEBUG) Rlog.v(TAG, "getOrCreateThreadId uri: " + uri);
2098
2099 Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
2100 uri, ID_PROJECTION, null, null, null);
2101 if (cursor != null) {
2102 try {
2103 if (cursor.moveToFirst()) {
2104 return cursor.getLong(0);
2105 } else {
2106 Rlog.e(TAG, "getOrCreateThreadId returned no rows!");
2107 }
2108 } finally {
2109 cursor.close();
2110 }
2111 }
2112
2113 Rlog.e(TAG, "getOrCreateThreadId failed with " + recipients.size() + " recipients");
2114 throw new IllegalArgumentException("Unable to find or allocate a thread ID.");
2115 }
2116 }
2117
2118 /**
2119 * Contains all MMS messages.
2120 */
2121 public static final class Mms implements BaseMmsColumns {
2122
2123 /**
2124 * Not instantiable.
2125 * @hide
2126 */
2127 private Mms() {
2128 }
2129
2130 /**
2131 * The {@code content://} URI for this table.
2132 */
2133 public static final Uri CONTENT_URI = Uri.parse("content://mms");
2134
2135 /**
2136 * Content URI for getting MMS report requests.
2137 */
2138 public static final Uri REPORT_REQUEST_URI = Uri.withAppendedPath(
2139 CONTENT_URI, "report-request");
2140
2141 /**
2142 * Content URI for getting MMS report status.
2143 */
2144 public static final Uri REPORT_STATUS_URI = Uri.withAppendedPath(
2145 CONTENT_URI, "report-status");
2146
2147 /**
2148 * The default sort order for this table.
2149 */
2150 public static final String DEFAULT_SORT_ORDER = "date DESC";
2151
2152 /**
2153 * Regex pattern for names and email addresses.
2154 * <ul>
2155 * <li><em>mailbox</em> = {@code name-addr}</li>
2156 * <li><em>name-addr</em> = {@code [display-name] angle-addr}</li>
2157 * <li><em>angle-addr</em> = {@code [CFWS] "<" addr-spec ">" [CFWS]}</li>
2158 * </ul>
2159 * @hide
2160 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002161 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002162 public static final Pattern NAME_ADDR_EMAIL_PATTERN =
2163 Pattern.compile("\\s*(\"[^\"]*\"|[^<>\"]+)\\s*<([^<>]+)>\\s*");
2164
2165 /**
2166 * Helper method to query this table.
2167 * @hide
2168 */
2169 public static Cursor query(
2170 ContentResolver cr, String[] projection) {
2171 return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
2172 }
2173
2174 /**
2175 * Helper method to query this table.
2176 * @hide
2177 */
2178 public static Cursor query(
2179 ContentResolver cr, String[] projection,
2180 String where, String orderBy) {
2181 return cr.query(CONTENT_URI, projection,
2182 where, null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
2183 }
2184
2185 /**
2186 * Helper method to extract email address from address string.
2187 * @hide
2188 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002189 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002190 public static String extractAddrSpec(String address) {
2191 Matcher match = NAME_ADDR_EMAIL_PATTERN.matcher(address);
2192
2193 if (match.matches()) {
2194 return match.group(2);
2195 }
2196 return address;
2197 }
2198
2199 /**
2200 * Is the specified address an email address?
2201 *
2202 * @param address the input address to test
2203 * @return true if address is an email address; false otherwise.
2204 * @hide
2205 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002206 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002207 public static boolean isEmailAddress(String address) {
2208 if (TextUtils.isEmpty(address)) {
2209 return false;
2210 }
2211
2212 String s = extractAddrSpec(address);
2213 Matcher match = Patterns.EMAIL_ADDRESS.matcher(s);
2214 return match.matches();
2215 }
2216
2217 /**
2218 * Is the specified number a phone number?
2219 *
2220 * @param number the input number to test
2221 * @return true if number is a phone number; false otherwise.
2222 * @hide
2223 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002224 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002225 public static boolean isPhoneNumber(String number) {
2226 if (TextUtils.isEmpty(number)) {
2227 return false;
2228 }
2229
2230 Matcher match = Patterns.PHONE.matcher(number);
2231 return match.matches();
2232 }
2233
2234 /**
2235 * Contains all MMS messages in the MMS app inbox.
2236 */
2237 public static final class Inbox implements BaseMmsColumns {
2238
2239 /**
2240 * Not instantiable.
2241 * @hide
2242 */
2243 private Inbox() {
2244 }
2245
2246 /**
2247 * The {@code content://} style URL for this table.
2248 */
2249 public static final Uri
2250 CONTENT_URI = Uri.parse("content://mms/inbox");
2251
2252 /**
2253 * The default sort order for this table.
2254 */
2255 public static final String DEFAULT_SORT_ORDER = "date DESC";
2256 }
2257
2258 /**
2259 * Contains all MMS messages in the MMS app sent folder.
2260 */
2261 public static final class Sent implements BaseMmsColumns {
2262
2263 /**
2264 * Not instantiable.
2265 * @hide
2266 */
2267 private Sent() {
2268 }
2269
2270 /**
2271 * The {@code content://} style URL for this table.
2272 */
2273 public static final Uri
2274 CONTENT_URI = Uri.parse("content://mms/sent");
2275
2276 /**
2277 * The default sort order for this table.
2278 */
2279 public static final String DEFAULT_SORT_ORDER = "date DESC";
2280 }
2281
2282 /**
2283 * Contains all MMS messages in the MMS app drafts folder.
2284 */
2285 public static final class Draft implements BaseMmsColumns {
2286
2287 /**
2288 * Not instantiable.
2289 * @hide
2290 */
2291 private Draft() {
2292 }
2293
2294 /**
2295 * The {@code content://} style URL for this table.
2296 */
2297 public static final Uri
2298 CONTENT_URI = Uri.parse("content://mms/drafts");
2299
2300 /**
2301 * The default sort order for this table.
2302 */
2303 public static final String DEFAULT_SORT_ORDER = "date DESC";
2304 }
2305
2306 /**
2307 * Contains all MMS messages in the MMS app outbox.
2308 */
2309 public static final class Outbox implements BaseMmsColumns {
2310
2311 /**
2312 * Not instantiable.
2313 * @hide
2314 */
2315 private Outbox() {
2316 }
2317
2318 /**
2319 * The {@code content://} style URL for this table.
2320 */
2321 public static final Uri
2322 CONTENT_URI = Uri.parse("content://mms/outbox");
2323
2324 /**
2325 * The default sort order for this table.
2326 */
2327 public static final String DEFAULT_SORT_ORDER = "date DESC";
2328 }
2329
2330 /**
2331 * Contains address information for an MMS message.
2332 */
2333 public static final class Addr implements BaseColumns {
2334
2335 /**
2336 * Not instantiable.
2337 * @hide
2338 */
2339 private Addr() {
2340 }
2341
2342 /**
2343 * The ID of MM which this address entry belongs to.
2344 * <P>Type: INTEGER (long)</P>
2345 */
2346 public static final String MSG_ID = "msg_id";
2347
2348 /**
2349 * The ID of contact entry in Phone Book.
2350 * <P>Type: INTEGER (long)</P>
2351 */
2352 public static final String CONTACT_ID = "contact_id";
2353
2354 /**
2355 * The address text.
2356 * <P>Type: TEXT</P>
2357 */
2358 public static final String ADDRESS = "address";
2359
2360 /**
2361 * Type of address: must be one of {@code PduHeaders.BCC},
2362 * {@code PduHeaders.CC}, {@code PduHeaders.FROM}, {@code PduHeaders.TO}.
2363 * <P>Type: INTEGER</P>
2364 */
2365 public static final String TYPE = "type";
2366
2367 /**
2368 * Character set of this entry (MMS charset value).
2369 * <P>Type: INTEGER</P>
2370 */
2371 public static final String CHARSET = "charset";
2372 }
2373
2374 /**
2375 * Contains message parts.
2376 */
2377 public static final class Part implements BaseColumns {
2378
2379 /**
2380 * Not instantiable.
2381 * @hide
2382 */
2383 private Part() {
2384 }
2385
2386 /**
2387 * The identifier of the message which this part belongs to.
2388 * <P>Type: INTEGER</P>
2389 */
2390 public static final String MSG_ID = "mid";
2391
2392 /**
2393 * The order of the part.
2394 * <P>Type: INTEGER</P>
2395 */
2396 public static final String SEQ = "seq";
2397
2398 /**
2399 * The content type of the part.
2400 * <P>Type: TEXT</P>
2401 */
2402 public static final String CONTENT_TYPE = "ct";
2403
2404 /**
2405 * The name of the part.
2406 * <P>Type: TEXT</P>
2407 */
2408 public static final String NAME = "name";
2409
2410 /**
2411 * The charset of the part.
2412 * <P>Type: TEXT</P>
2413 */
2414 public static final String CHARSET = "chset";
2415
2416 /**
2417 * The file name of the part.
2418 * <P>Type: TEXT</P>
2419 */
2420 public static final String FILENAME = "fn";
2421
2422 /**
2423 * The content disposition of the part.
2424 * <P>Type: TEXT</P>
2425 */
2426 public static final String CONTENT_DISPOSITION = "cd";
2427
2428 /**
2429 * The content ID of the part.
2430 * <P>Type: INTEGER</P>
2431 */
2432 public static final String CONTENT_ID = "cid";
2433
2434 /**
2435 * The content location of the part.
2436 * <P>Type: INTEGER</P>
2437 */
2438 public static final String CONTENT_LOCATION = "cl";
2439
2440 /**
2441 * The start of content-type of the message.
2442 * <P>Type: INTEGER</P>
2443 */
2444 public static final String CT_START = "ctt_s";
2445
2446 /**
2447 * The type of content-type of the message.
2448 * <P>Type: TEXT</P>
2449 */
2450 public static final String CT_TYPE = "ctt_t";
2451
2452 /**
2453 * The location (on filesystem) of the binary data of the part.
2454 * <P>Type: INTEGER</P>
2455 */
2456 public static final String _DATA = "_data";
2457
2458 /**
2459 * The message text.
2460 * <P>Type: TEXT</P>
2461 */
2462 public static final String TEXT = "text";
2463 }
2464
2465 /**
2466 * Message send rate table.
2467 */
2468 public static final class Rate {
2469
2470 /**
2471 * Not instantiable.
2472 * @hide
2473 */
2474 private Rate() {
2475 }
2476
2477 /**
2478 * The {@code content://} style URL for this table.
2479 */
2480 public static final Uri CONTENT_URI = Uri.withAppendedPath(
2481 Mms.CONTENT_URI, "rate");
2482
2483 /**
2484 * When a message was successfully sent.
2485 * <P>Type: INTEGER (long)</P>
2486 */
2487 public static final String SENT_TIME = "sent_time";
2488 }
2489
2490 /**
2491 * Intents class.
2492 */
2493 public static final class Intents {
2494
2495 /**
2496 * Not instantiable.
2497 * @hide
2498 */
2499 private Intents() {
2500 }
2501
2502 /**
2503 * Indicates that the contents of specified URIs were changed.
2504 * The application which is showing or caching these contents
2505 * should be updated.
2506 */
2507 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2508 public static final String CONTENT_CHANGED_ACTION
2509 = "android.intent.action.CONTENT_CHANGED";
2510
2511 /**
2512 * An extra field which stores the URI of deleted contents.
2513 */
2514 public static final String DELETED_CONTENTS = "deleted_contents";
2515 }
2516 }
2517
2518 /**
2519 * Contains all MMS and SMS messages.
2520 */
2521 public static final class MmsSms implements BaseColumns {
2522
2523 /**
2524 * Not instantiable.
2525 * @hide
2526 */
2527 private MmsSms() {
2528 }
2529
2530 /**
2531 * The column to distinguish SMS and MMS messages in query results.
2532 */
2533 public static final String TYPE_DISCRIMINATOR_COLUMN =
2534 "transport_type";
2535
2536 /**
2537 * The {@code content://} style URL for this table.
2538 */
2539 public static final Uri CONTENT_URI = Uri.parse("content://mms-sms/");
2540
2541 /**
2542 * The {@code content://} style URL for this table, by conversation.
2543 */
2544 public static final Uri CONTENT_CONVERSATIONS_URI = Uri.parse(
2545 "content://mms-sms/conversations");
2546
2547 /**
2548 * The {@code content://} style URL for this table, by phone number.
2549 */
2550 public static final Uri CONTENT_FILTER_BYPHONE_URI = Uri.parse(
2551 "content://mms-sms/messages/byphone");
2552
2553 /**
2554 * The {@code content://} style URL for undelivered messages in this table.
2555 */
2556 public static final Uri CONTENT_UNDELIVERED_URI = Uri.parse(
2557 "content://mms-sms/undelivered");
2558
2559 /**
2560 * The {@code content://} style URL for draft messages in this table.
2561 */
2562 public static final Uri CONTENT_DRAFT_URI = Uri.parse(
2563 "content://mms-sms/draft");
2564
2565 /**
2566 * The {@code content://} style URL for locked messages in this table.
2567 */
2568 public static final Uri CONTENT_LOCKED_URI = Uri.parse(
2569 "content://mms-sms/locked");
2570
2571 /**
2572 * Pass in a query parameter called "pattern" which is the text to search for.
2573 * The sort order is fixed to be: {@code thread_id ASC, date DESC}.
2574 */
2575 public static final Uri SEARCH_URI = Uri.parse(
2576 "content://mms-sms/search");
2577
2578 // Constants for message protocol types.
2579
2580 /** SMS protocol type. */
2581 public static final int SMS_PROTO = 0;
2582
2583 /** MMS protocol type. */
2584 public static final int MMS_PROTO = 1;
2585
2586 // Constants for error types of pending messages.
2587
2588 /** Error type: no error. */
2589 public static final int NO_ERROR = 0;
2590
2591 /** Error type: generic transient error. */
2592 public static final int ERR_TYPE_GENERIC = 1;
2593
2594 /** Error type: SMS protocol transient error. */
2595 public static final int ERR_TYPE_SMS_PROTO_TRANSIENT = 2;
2596
2597 /** Error type: MMS protocol transient error. */
2598 public static final int ERR_TYPE_MMS_PROTO_TRANSIENT = 3;
2599
2600 /** Error type: transport failure. */
2601 public static final int ERR_TYPE_TRANSPORT_FAILURE = 4;
2602
2603 /** Error type: permanent error (along with all higher error values). */
2604 public static final int ERR_TYPE_GENERIC_PERMANENT = 10;
2605
2606 /** Error type: SMS protocol permanent error. */
2607 public static final int ERR_TYPE_SMS_PROTO_PERMANENT = 11;
2608
2609 /** Error type: MMS protocol permanent error. */
2610 public static final int ERR_TYPE_MMS_PROTO_PERMANENT = 12;
2611
2612 /**
2613 * Contains pending messages info.
2614 */
2615 public static final class PendingMessages implements BaseColumns {
2616
2617 /**
2618 * Not instantiable.
2619 * @hide
2620 */
2621 private PendingMessages() {
2622 }
2623
2624 public static final Uri CONTENT_URI = Uri.withAppendedPath(
2625 MmsSms.CONTENT_URI, "pending");
2626
2627 /**
2628 * The type of transport protocol (MMS or SMS).
2629 * <P>Type: INTEGER</P>
2630 */
2631 public static final String PROTO_TYPE = "proto_type";
2632
2633 /**
2634 * The ID of the message to be sent or downloaded.
2635 * <P>Type: INTEGER (long)</P>
2636 */
2637 public static final String MSG_ID = "msg_id";
2638
2639 /**
2640 * The type of the message to be sent or downloaded.
2641 * This field is only valid for MM. For SM, its value is always set to 0.
2642 * <P>Type: INTEGER</P>
2643 */
2644 public static final String MSG_TYPE = "msg_type";
2645
2646 /**
2647 * The type of the error code.
2648 * <P>Type: INTEGER</P>
2649 */
2650 public static final String ERROR_TYPE = "err_type";
2651
2652 /**
2653 * The error code of sending/retrieving process.
2654 * <P>Type: INTEGER</P>
2655 */
2656 public static final String ERROR_CODE = "err_code";
2657
2658 /**
2659 * How many times we tried to send or download the message.
2660 * <P>Type: INTEGER</P>
2661 */
2662 public static final String RETRY_INDEX = "retry_index";
2663
2664 /**
2665 * The time to do next retry.
2666 * <P>Type: INTEGER (long)</P>
2667 */
2668 public static final String DUE_TIME = "due_time";
2669
2670 /**
2671 * The time we last tried to send or download the message.
2672 * <P>Type: INTEGER (long)</P>
2673 */
2674 public static final String LAST_TRY = "last_try";
2675
2676 /**
2677 * The subscription to which the message belongs to. Its value will be
2678 * < 0 if the sub id cannot be determined.
2679 * <p>Type: INTEGER (long) </p>
2680 */
2681 public static final String SUBSCRIPTION_ID = "pending_sub_id";
2682 }
2683
2684 /**
2685 * Words table used by provider for full-text searches.
2686 * @hide
2687 */
2688 public static final class WordsTable {
2689
2690 /**
2691 * Not instantiable.
2692 * @hide
2693 */
2694 private WordsTable() {}
2695
2696 /**
2697 * Primary key.
2698 * <P>Type: INTEGER (long)</P>
2699 */
2700 public static final String ID = "_id";
2701
2702 /**
2703 * Source row ID.
2704 * <P>Type: INTEGER (long)</P>
2705 */
2706 public static final String SOURCE_ROW_ID = "source_id";
2707
2708 /**
2709 * Table ID (either 1 or 2).
2710 * <P>Type: INTEGER</P>
2711 */
2712 public static final String TABLE_ID = "table_to_use";
2713
2714 /**
2715 * The words to index.
2716 * <P>Type: TEXT</P>
2717 */
2718 public static final String INDEXED_TEXT = "index_text";
2719 }
2720 }
2721
2722 /**
2723 * Carriers class contains information about APNs, including MMSC information.
2724 */
2725 public static final class Carriers implements BaseColumns {
2726
2727 /**
2728 * Not instantiable.
2729 * @hide
2730 */
2731 private Carriers() {}
2732
2733 /**
2734 * The {@code content://} style URL for this table.
2735 */
2736 public static final Uri CONTENT_URI = Uri.parse("content://telephony/carriers");
2737
2738 /**
yuemingw4c0065f2018-01-16 19:48:10 +00002739 * The {@code content://} style URL to be called from DevicePolicyManagerService,
2740 * can manage DPC-owned APNs.
2741 * @hide
2742 */
2743 public static final Uri DPC_URI = Uri.parse("content://telephony/carriers/dpc");
2744
2745 /**
2746 * The {@code content://} style URL to be called from Telephony to query APNs.
2747 * When DPC-owned APNs are enforced, only DPC-owned APNs are returned, otherwise only
2748 * non-DPC-owned APNs are returned.
2749 * @hide
2750 */
2751 public static final Uri FILTERED_URI = Uri.parse("content://telephony/carriers/filtered");
2752
2753 /**
2754 * The {@code content://} style URL to be called from DevicePolicyManagerService
2755 * or Telephony to manage whether DPC-owned APNs are enforced.
2756 * @hide
2757 */
2758 public static final Uri ENFORCE_MANAGED_URI = Uri.parse(
2759 "content://telephony/carriers/enforce_managed");
2760
2761 /**
calvinpand3b26112018-10-31 19:09:27 +08002762 * The {@code content://} style URL to be called from Telephony to query current APNs.
2763 * @hide
2764 */
2765 public static final Uri SIM_APN_LIST = Uri.parse(
2766 "content://telephony/carriers/sim_apn_list");
2767
2768 /**
yuemingw4c0065f2018-01-16 19:48:10 +00002769 * The column name for ENFORCE_MANAGED_URI, indicates whether DPC-owned APNs are enforced.
2770 * @hide
2771 */
2772 public static final String ENFORCE_KEY = "enforced";
2773
2774 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08002775 * The default sort order for this table.
2776 */
2777 public static final String DEFAULT_SORT_ORDER = "name ASC";
2778
2779 /**
2780 * Entry name.
2781 * <P>Type: TEXT</P>
2782 */
2783 public static final String NAME = "name";
2784
2785 /**
2786 * APN name.
2787 * <P>Type: TEXT</P>
2788 */
2789 public static final String APN = "apn";
2790
2791 /**
2792 * Proxy address.
2793 * <P>Type: TEXT</P>
2794 */
2795 public static final String PROXY = "proxy";
2796
2797 /**
2798 * Proxy port.
2799 * <P>Type: TEXT</P>
2800 */
2801 public static final String PORT = "port";
2802
2803 /**
2804 * MMS proxy address.
2805 * <P>Type: TEXT</P>
2806 */
2807 public static final String MMSPROXY = "mmsproxy";
2808
2809 /**
2810 * MMS proxy port.
2811 * <P>Type: TEXT</P>
2812 */
2813 public static final String MMSPORT = "mmsport";
2814
2815 /**
2816 * Server address.
2817 * <P>Type: TEXT</P>
2818 */
2819 public static final String SERVER = "server";
2820
2821 /**
2822 * APN username.
2823 * <P>Type: TEXT</P>
2824 */
2825 public static final String USER = "user";
2826
2827 /**
2828 * APN password.
2829 * <P>Type: TEXT</P>
2830 */
2831 public static final String PASSWORD = "password";
2832
2833 /**
2834 * MMSC URL.
2835 * <P>Type: TEXT</P>
2836 */
2837 public static final String MMSC = "mmsc";
2838
2839 /**
2840 * Mobile Country Code (MCC).
2841 * <P>Type: TEXT</P>
2842 */
2843 public static final String MCC = "mcc";
2844
2845 /**
2846 * Mobile Network Code (MNC).
2847 * <P>Type: TEXT</P>
2848 */
2849 public static final String MNC = "mnc";
2850
2851 /**
2852 * Numeric operator ID (as String). Usually {@code MCC + MNC}.
2853 * <P>Type: TEXT</P>
2854 */
2855 public static final String NUMERIC = "numeric";
2856
2857 /**
2858 * Authentication type.
2859 * <P>Type: INTEGER</P>
2860 */
2861 public static final String AUTH_TYPE = "authtype";
2862
2863 /**
2864 * Comma-delimited list of APN types.
2865 * <P>Type: TEXT</P>
2866 */
2867 public static final String TYPE = "type";
2868
2869 /**
2870 * The protocol to use to connect to this APN.
2871 *
2872 * One of the {@code PDP_type} values in TS 27.007 section 10.1.1.
2873 * For example: {@code IP}, {@code IPV6}, {@code IPV4V6}, or {@code PPP}.
2874 * <P>Type: TEXT</P>
2875 */
2876 public static final String PROTOCOL = "protocol";
2877
2878 /**
2879 * The protocol to use to connect to this APN when roaming.
2880 * The syntax is the same as protocol.
2881 * <P>Type: TEXT</P>
2882 */
2883 public static final String ROAMING_PROTOCOL = "roaming_protocol";
2884
2885 /**
2886 * Is this the current APN?
2887 * <P>Type: INTEGER (boolean)</P>
2888 */
2889 public static final String CURRENT = "current";
2890
2891 /**
2892 * Is this APN enabled?
2893 * <P>Type: INTEGER (boolean)</P>
2894 */
2895 public static final String CARRIER_ENABLED = "carrier_enabled";
2896
2897 /**
2898 * Radio Access Technology info.
2899 * To check what values are allowed, refer to {@link android.telephony.ServiceState}.
2900 * This should be spread to other technologies,
2901 * but is currently only used for LTE (14) and eHRPD (13).
2902 * <P>Type: INTEGER</P>
Cassiee1c88022018-02-22 08:51:03 -08002903 * @deprecated this column is no longer supported, use {@link #NETWORK_TYPE_BITMASK} instead
Dan Willemsen4980bf42017-02-14 14:17:12 -08002904 */
Cassied53df962017-12-05 13:34:33 -08002905 @Deprecated
Dan Willemsen4980bf42017-02-14 14:17:12 -08002906 public static final String BEARER = "bearer";
2907
2908 /**
2909 * Radio Access Technology bitmask.
2910 * To check what values can be contained, refer to {@link android.telephony.ServiceState}.
2911 * 0 indicates all techs otherwise first bit refers to RAT/bearer 1, second bit refers to
2912 * RAT/bearer 2 and so on.
2913 * Bitmask for a radio tech R is (1 << (R - 1))
2914 * <P>Type: INTEGER</P>
2915 * @hide
Cassiee1c88022018-02-22 08:51:03 -08002916 * @deprecated this column is no longer supported, use {@link #NETWORK_TYPE_BITMASK} instead
Dan Willemsen4980bf42017-02-14 14:17:12 -08002917 */
Cassied53df962017-12-05 13:34:33 -08002918 @Deprecated
Dan Willemsen4980bf42017-02-14 14:17:12 -08002919 public static final String BEARER_BITMASK = "bearer_bitmask";
2920
2921 /**
Cassied53df962017-12-05 13:34:33 -08002922 * Radio technology (network type) bitmask.
Cassiee1c88022018-02-22 08:51:03 -08002923 * To check what values can be contained, refer to the NETWORK_TYPE_ constants in
Cassied53df962017-12-05 13:34:33 -08002924 * {@link android.telephony.TelephonyManager}.
2925 * Bitmask for a radio tech R is (1 << (R - 1))
2926 * <P>Type: INTEGER</P>
2927 */
2928 public static final String NETWORK_TYPE_BITMASK = "network_type_bitmask";
2929
2930 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08002931 * MVNO type:
2932 * {@code SPN (Service Provider Name), IMSI, GID (Group Identifier Level 1)}.
2933 * <P>Type: TEXT</P>
2934 */
2935 public static final String MVNO_TYPE = "mvno_type";
2936
2937 /**
2938 * MVNO data.
2939 * Use the following examples.
2940 * <ul>
2941 * <li>SPN: A MOBILE, BEN NL, ...</li>
2942 * <li>IMSI: 302720x94, 2060188, ...</li>
2943 * <li>GID: 4E, 33, ...</li>
2944 * </ul>
2945 * <P>Type: TEXT</P>
2946 */
2947 public static final String MVNO_MATCH_DATA = "mvno_match_data";
2948
2949 /**
2950 * The subscription to which the APN belongs to
2951 * <p>Type: INTEGER (long) </p>
2952 */
2953 public static final String SUBSCRIPTION_ID = "sub_id";
2954
2955 /**
chen xu85100482018-10-12 15:30:34 -07002956 * The profile_id to which the APN saved in modem.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002957 * <p>Type: INTEGER</p>
2958 *@hide
2959 */
2960 public static final String PROFILE_ID = "profile_id";
2961
2962 /**
chen xu85100482018-10-12 15:30:34 -07002963 * If set to {@code true}, then the APN setting will persist to the modem.
2964 * <p>Type: INTEGER (boolean)</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08002965 *@hide
2966 */
chen xu85100482018-10-12 15:30:34 -07002967 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08002968 public static final String MODEM_PERSIST = "modem_cognitive";
Dan Willemsen4980bf42017-02-14 14:17:12 -08002969
2970 /**
chen xu5caa18c2018-11-28 00:21:50 -08002971 * The max number of connections of this APN.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002972 * <p>Type: INTEGER</p>
2973 *@hide
2974 */
chen xu85100482018-10-12 15:30:34 -07002975 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08002976 public static final String MAX_CONNECTIONS = "max_conns";
Dan Willemsen4980bf42017-02-14 14:17:12 -08002977
2978 /**
chen xu5caa18c2018-11-28 00:21:50 -08002979 * The wait time for retrying the APN, in milliseconds.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002980 * <p>Type: INTEGER</p>
2981 *@hide
2982 */
chen xu85100482018-10-12 15:30:34 -07002983 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08002984 public static final String WAIT_TIME_RETRY = "wait_time";
Dan Willemsen4980bf42017-02-14 14:17:12 -08002985
2986 /**
chen xu5caa18c2018-11-28 00:21:50 -08002987 * The max number of seconds this APN will support its maximum number of connections
2988 * as defined in {@link #MAX_CONNECTIONS}.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002989 * <p>Type: INTEGER</p>
2990 *@hide
2991 */
chen xu85100482018-10-12 15:30:34 -07002992 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08002993 public static final String TIME_LIMIT_FOR_MAX_CONNECTIONS = "max_conns_time";
Dan Willemsen4980bf42017-02-14 14:17:12 -08002994
2995 /**
chen xu5caa18c2018-11-28 00:21:50 -08002996 * The MTU (maximum transmit unit) size of the mobile interface to which the APN is
2997 * connected, in bytes.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002998 * <p>Type: INTEGER </p>
2999 * @hide
3000 */
chen xu85100482018-10-12 15:30:34 -07003001 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08003002 public static final String MTU = "mtu";
3003
3004 /**
chen xu85100482018-10-12 15:30:34 -07003005 * APN edit status. APN could be added/edited/deleted by a user or carrier.
chen xu5caa18c2018-11-28 00:21:50 -08003006 * see all possible returned APN edit status.
3007 * <ul>
3008 * <li>{@link #UNEDITED}</li>
3009 * <li>{@link #USER_EDITED}</li>
3010 * <li>{@link #USER_DELETED}</li>
3011 * <li>{@link #CARRIER_EDITED}</li>
3012 * <li>{@link #CARRIER_DELETED}</li>
3013 * </ul>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003014 * <p>Type: INTEGER </p>
3015 * @hide
3016 */
chen xu85100482018-10-12 15:30:34 -07003017 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003018 public static final String EDITED_STATUS = "edited";
Dan Willemsen4980bf42017-02-14 14:17:12 -08003019
3020 /**
chen xu85100482018-10-12 15:30:34 -07003021 * {@code true} if this APN visible to the user, {@code false} otherwise.
3022 * <p>Type: INTEGER (boolean)</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003023 * @hide
3024 */
chen xu85100482018-10-12 15:30:34 -07003025 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08003026 public static final String USER_VISIBLE = "user_visible";
3027
3028 /**
chen xu85100482018-10-12 15:30:34 -07003029 * {@code true} if the user allowed to edit this APN, {@code false} otherwise.
3030 * <p>Type: INTEGER (boolean)</p>
Amit Mahajand4977942017-07-17 14:46:39 -07003031 * @hide
3032 */
chen xu85100482018-10-12 15:30:34 -07003033 @SystemApi
Amit Mahajand4977942017-07-17 14:46:39 -07003034 public static final String USER_EDITABLE = "user_editable";
3035
3036 /**
chen xu5caa18c2018-11-28 00:21:50 -08003037 * {@link #EDITED_STATUS APN edit status} indicates that this APN has not been edited or
3038 * fails to edit.
chen xu85100482018-10-12 15:30:34 -07003039 * <p>Type: INTEGER </p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003040 * @hide
3041 */
chen xu85100482018-10-12 15:30:34 -07003042 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003043 public static final @EditStatus int UNEDITED = 0;
chen xu85100482018-10-12 15:30:34 -07003044
Dan Willemsen4980bf42017-02-14 14:17:12 -08003045 /**
chen xu5caa18c2018-11-28 00:21:50 -08003046 * {@link #EDITED_STATUS APN edit status} indicates that this APN has been edited by users.
chen xu85100482018-10-12 15:30:34 -07003047 * <p>Type: INTEGER </p>
3048 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003049 */
chen xu85100482018-10-12 15:30:34 -07003050 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003051 public static final @EditStatus int USER_EDITED = 1;
chen xu85100482018-10-12 15:30:34 -07003052
Dan Willemsen4980bf42017-02-14 14:17:12 -08003053 /**
chen xu5caa18c2018-11-28 00:21:50 -08003054 * {@link #EDITED_STATUS APN edit status} indicates that this APN has been deleted by users.
chen xu85100482018-10-12 15:30:34 -07003055 * <p>Type: INTEGER </p>
3056 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003057 */
chen xu85100482018-10-12 15:30:34 -07003058 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003059 public static final @EditStatus int USER_DELETED = 2;
chen xu85100482018-10-12 15:30:34 -07003060
Dan Willemsen4980bf42017-02-14 14:17:12 -08003061 /**
chen xu5caa18c2018-11-28 00:21:50 -08003062 * {@link #EDITED_STATUS APN edit status} is an intermediate value used to indicate that an
3063 * entry deleted by the user is still present in the new APN database and therefore must
3064 * remain tagged as user deleted rather than completely removed from the database.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003065 * @hide
3066 */
3067 public static final int USER_DELETED_BUT_PRESENT_IN_XML = 3;
chen xu85100482018-10-12 15:30:34 -07003068
Dan Willemsen4980bf42017-02-14 14:17:12 -08003069 /**
chen xu5caa18c2018-11-28 00:21:50 -08003070 * {@link #EDITED_STATUS APN edit status} indicates that this APN has been edited by
3071 * carriers.
chen xu85100482018-10-12 15:30:34 -07003072 * <p>Type: INTEGER </p>
3073 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003074 */
chen xu85100482018-10-12 15:30:34 -07003075 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003076 public static final @EditStatus int CARRIER_EDITED = 4;
chen xu85100482018-10-12 15:30:34 -07003077
Dan Willemsen4980bf42017-02-14 14:17:12 -08003078 /**
chen xu5caa18c2018-11-28 00:21:50 -08003079 * {@link #EDITED_STATUS APN edit status} indicates that this APN has been deleted by
3080 * carriers. CARRIER_DELETED values are currently not used as there is no use case.
3081 * If they are used, delete() will have to change accordingly. Currently it is hardcoded to
3082 * USER_DELETED.
chen xu85100482018-10-12 15:30:34 -07003083 * <p>Type: INTEGER </p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003084 * @hide
3085 */
chen xu5caa18c2018-11-28 00:21:50 -08003086 public static final @EditStatus int CARRIER_DELETED = 5;
chen xu85100482018-10-12 15:30:34 -07003087
Dan Willemsen4980bf42017-02-14 14:17:12 -08003088 /**
chen xu5caa18c2018-11-28 00:21:50 -08003089 * {@link #EDITED_STATUS APN edit status} is an intermediate value used to indicate that an
3090 * entry deleted by the carrier is still present in the new APN database and therefore must
3091 * remain tagged as user deleted rather than completely removed from the database.
chen xu85100482018-10-12 15:30:34 -07003092 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003093 */
3094 public static final int CARRIER_DELETED_BUT_PRESENT_IN_XML = 6;
yuemingwcf263eb2017-11-08 13:12:18 +00003095
3096 /**
3097 * The owner of the APN.
3098 * <p>Type: INTEGER</p>
3099 * @hide
3100 */
3101 public static final String OWNED_BY = "owned_by";
3102
3103 /**
3104 * Possible value for the OWNED_BY field.
3105 * APN is owned by DPC.
3106 * @hide
3107 */
3108 public static final int OWNED_BY_DPC = 0;
Jordan Liu40617152018-04-06 11:10:12 -07003109
yuemingwcf263eb2017-11-08 13:12:18 +00003110 /**
3111 * Possible value for the OWNED_BY field.
3112 * APN is owned by other sources.
3113 * @hide
3114 */
3115 public static final int OWNED_BY_OTHERS = 1;
Jordan Liu40617152018-04-06 11:10:12 -07003116
3117 /**
3118 * The APN set id. When the user manually selects an APN or the framework sets an APN as
3119 * preferred, all APNs with the same set id as the selected APN should be prioritized over
3120 * APNs in other sets.
chen xu85100482018-10-12 15:30:34 -07003121 * <p>Type: INTEGER</p>
Jordan Liu40617152018-04-06 11:10:12 -07003122 * @hide
3123 */
chen xu85100482018-10-12 15:30:34 -07003124 @SystemApi
Jordan Liu40617152018-04-06 11:10:12 -07003125 public static final String APN_SET_ID = "apn_set_id";
3126
3127 /**
chen xu5caa18c2018-11-28 00:21:50 -08003128 * Possible value for the {@link #APN_SET_ID} field. By default APNs will not belong to a
3129 * set. If the user manually selects an APN without apn set id, there is no need to
3130 * prioritize any specific APN set ids.
chen xu85100482018-10-12 15:30:34 -07003131 * <p>Type: INTEGER</p>
Jordan Liu40617152018-04-06 11:10:12 -07003132 * @hide
3133 */
chen xu85100482018-10-12 15:30:34 -07003134 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003135 public static final int NO_APN_SET_ID = 0;
Jordan Liu40617152018-04-06 11:10:12 -07003136
calvinpanbeb6cb32018-10-19 15:11:22 +08003137 /**
3138 * A unique carrier id associated with this APN
3139 * {@see TelephonyManager#getSimCarrierId()}
3140 * <p>Type: STRING</p>
3141 */
3142 public static final String CARRIER_ID = "carrier_id";
3143
chen xu5caa18c2018-11-28 00:21:50 -08003144 /** @hide */
3145 @IntDef({
3146 UNEDITED,
3147 USER_EDITED,
3148 USER_DELETED,
3149 CARRIER_DELETED,
3150 CARRIER_EDITED,
3151 })
3152 @Retention(RetentionPolicy.SOURCE)
3153 public @interface EditStatus {}
3154
Dan Willemsen4980bf42017-02-14 14:17:12 -08003155 }
3156
3157 /**
3158 * Contains received SMS cell broadcast messages.
3159 * @hide
3160 */
3161 public static final class CellBroadcasts implements BaseColumns {
3162
3163 /**
3164 * Not instantiable.
3165 * @hide
3166 */
3167 private CellBroadcasts() {}
3168
3169 /**
3170 * The {@code content://} URI for this table.
3171 */
3172 public static final Uri CONTENT_URI = Uri.parse("content://cellbroadcasts");
3173
3174 /**
3175 * Message geographical scope.
3176 * <P>Type: INTEGER</P>
3177 */
3178 public static final String GEOGRAPHICAL_SCOPE = "geo_scope";
3179
3180 /**
3181 * Message serial number.
3182 * <P>Type: INTEGER</P>
3183 */
3184 public static final String SERIAL_NUMBER = "serial_number";
3185
3186 /**
3187 * PLMN of broadcast sender. {@code SERIAL_NUMBER + PLMN + LAC + CID} uniquely identifies
3188 * a broadcast for duplicate detection purposes.
3189 * <P>Type: TEXT</P>
3190 */
3191 public static final String PLMN = "plmn";
3192
3193 /**
3194 * Location Area (GSM) or Service Area (UMTS) of broadcast sender. Unused for CDMA.
3195 * Only included if Geographical Scope of message is not PLMN wide (01).
3196 * <P>Type: INTEGER</P>
3197 */
3198 public static final String LAC = "lac";
3199
3200 /**
3201 * Cell ID of message sender (GSM/UMTS). Unused for CDMA. Only included when the
3202 * Geographical Scope of message is cell wide (00 or 11).
3203 * <P>Type: INTEGER</P>
3204 */
3205 public static final String CID = "cid";
3206
3207 /**
3208 * Message code. <em>OBSOLETE: merged into SERIAL_NUMBER.</em>
3209 * <P>Type: INTEGER</P>
3210 */
3211 public static final String V1_MESSAGE_CODE = "message_code";
3212
3213 /**
3214 * Message identifier. <em>OBSOLETE: renamed to SERVICE_CATEGORY.</em>
3215 * <P>Type: INTEGER</P>
3216 */
3217 public static final String V1_MESSAGE_IDENTIFIER = "message_id";
3218
3219 /**
3220 * Service category (GSM/UMTS: message identifier; CDMA: service category).
3221 * <P>Type: INTEGER</P>
3222 */
3223 public static final String SERVICE_CATEGORY = "service_category";
3224
3225 /**
3226 * Message language code.
3227 * <P>Type: TEXT</P>
3228 */
3229 public static final String LANGUAGE_CODE = "language";
3230
3231 /**
3232 * Message body.
3233 * <P>Type: TEXT</P>
3234 */
3235 public static final String MESSAGE_BODY = "body";
3236
3237 /**
3238 * Message delivery time.
3239 * <P>Type: INTEGER (long)</P>
3240 */
3241 public static final String DELIVERY_TIME = "date";
3242
3243 /**
3244 * Has the message been viewed?
3245 * <P>Type: INTEGER (boolean)</P>
3246 */
3247 public static final String MESSAGE_READ = "read";
3248
3249 /**
3250 * Message format (3GPP or 3GPP2).
3251 * <P>Type: INTEGER</P>
3252 */
3253 public static final String MESSAGE_FORMAT = "format";
3254
3255 /**
3256 * Message priority (including emergency).
3257 * <P>Type: INTEGER</P>
3258 */
3259 public static final String MESSAGE_PRIORITY = "priority";
3260
3261 /**
3262 * ETWS warning type (ETWS alerts only).
3263 * <P>Type: INTEGER</P>
3264 */
3265 public static final String ETWS_WARNING_TYPE = "etws_warning_type";
3266
3267 /**
3268 * CMAS message class (CMAS alerts only).
3269 * <P>Type: INTEGER</P>
3270 */
3271 public static final String CMAS_MESSAGE_CLASS = "cmas_message_class";
3272
3273 /**
3274 * CMAS category (CMAS alerts only).
3275 * <P>Type: INTEGER</P>
3276 */
3277 public static final String CMAS_CATEGORY = "cmas_category";
3278
3279 /**
3280 * CMAS response type (CMAS alerts only).
3281 * <P>Type: INTEGER</P>
3282 */
3283 public static final String CMAS_RESPONSE_TYPE = "cmas_response_type";
3284
3285 /**
3286 * CMAS severity (CMAS alerts only).
3287 * <P>Type: INTEGER</P>
3288 */
3289 public static final String CMAS_SEVERITY = "cmas_severity";
3290
3291 /**
3292 * CMAS urgency (CMAS alerts only).
3293 * <P>Type: INTEGER</P>
3294 */
3295 public static final String CMAS_URGENCY = "cmas_urgency";
3296
3297 /**
3298 * CMAS certainty (CMAS alerts only).
3299 * <P>Type: INTEGER</P>
3300 */
3301 public static final String CMAS_CERTAINTY = "cmas_certainty";
3302
3303 /** The default sort order for this table. */
3304 public static final String DEFAULT_SORT_ORDER = DELIVERY_TIME + " DESC";
3305
3306 /**
3307 * Query columns for instantiating {@link android.telephony.CellBroadcastMessage} objects.
3308 */
3309 public static final String[] QUERY_COLUMNS = {
3310 _ID,
3311 GEOGRAPHICAL_SCOPE,
3312 PLMN,
3313 LAC,
3314 CID,
3315 SERIAL_NUMBER,
3316 SERVICE_CATEGORY,
3317 LANGUAGE_CODE,
3318 MESSAGE_BODY,
3319 DELIVERY_TIME,
3320 MESSAGE_READ,
3321 MESSAGE_FORMAT,
3322 MESSAGE_PRIORITY,
3323 ETWS_WARNING_TYPE,
3324 CMAS_MESSAGE_CLASS,
3325 CMAS_CATEGORY,
3326 CMAS_RESPONSE_TYPE,
3327 CMAS_SEVERITY,
3328 CMAS_URGENCY,
3329 CMAS_CERTAINTY
3330 };
3331 }
Jordan Liub9b75ed2017-02-28 18:15:07 -08003332
3333 /**
3334 * Constants for interfacing with the ServiceStateProvider and the different fields of the
3335 * {@link ServiceState} class accessible through the provider.
3336 */
3337 public static final class ServiceStateTable {
3338
3339 /**
3340 * Not instantiable.
3341 * @hide
3342 */
3343 private ServiceStateTable() {}
3344
3345 /**
3346 * The authority string for the ServiceStateProvider
3347 */
3348 public static final String AUTHORITY = "service-state";
3349
3350 /**
3351 * The {@code content://} style URL for the ServiceStateProvider
3352 */
3353 public static final Uri CONTENT_URI = Uri.parse("content://service-state/");
3354
3355 /**
3356 * Generates a content {@link Uri} used to receive updates on a specific field in the
3357 * ServiceState provider.
3358 * <p>
3359 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
3360 * {@link ServiceState} while your app is running. You can also use a {@link JobService} to
3361 * ensure your app is notified of changes to the {@link Uri} even when it is not running.
3362 * Note, however, that using a {@link JobService} does not guarantee timely delivery of
3363 * updates to the {@link Uri}.
3364 *
Jordan Liu0f332522017-04-19 14:25:29 -07003365 * @param subscriptionId the subscriptionId to receive updates on
Jordan Liub9b75ed2017-02-28 18:15:07 -08003366 * @param field the ServiceState field to receive updates on
3367 * @return the Uri used to observe {@link ServiceState} changes
3368 */
Jordan Liu0f332522017-04-19 14:25:29 -07003369 public static Uri getUriForSubscriptionIdAndField(int subscriptionId, String field) {
3370 return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId))
Jordan Liub9b75ed2017-02-28 18:15:07 -08003371 .appendEncodedPath(field).build();
3372 }
3373
3374 /**
3375 * Generates a content {@link Uri} used to receive updates on every field in the
3376 * ServiceState provider.
3377 * <p>
3378 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
3379 * {@link ServiceState} while your app is running. You can also use a {@link JobService} to
3380 * ensure your app is notified of changes to the {@link Uri} even when it is not running.
3381 * Note, however, that using a {@link JobService} does not guarantee timely delivery of
3382 * updates to the {@link Uri}.
3383 *
Jordan Liu0f332522017-04-19 14:25:29 -07003384 * @param subscriptionId the subscriptionId to receive updates on
Jordan Liub9b75ed2017-02-28 18:15:07 -08003385 * @return the Uri used to observe {@link ServiceState} changes
3386 */
Jordan Liu0f332522017-04-19 14:25:29 -07003387 public static Uri getUriForSubscriptionId(int subscriptionId) {
3388 return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId)).build();
Jordan Liub9b75ed2017-02-28 18:15:07 -08003389 }
3390
3391 /**
3392 * Used to insert a ServiceState into the ServiceStateProvider as a ContentValues instance.
3393 *
3394 * @param state the ServiceState to convert into ContentValues
3395 * @return the convertedContentValues instance
3396 * @hide
3397 */
3398 public static ContentValues getContentValuesForServiceState(ServiceState state) {
3399 ContentValues values = new ContentValues();
3400 values.put(VOICE_REG_STATE, state.getVoiceRegState());
3401 values.put(DATA_REG_STATE, state.getDataRegState());
3402 values.put(VOICE_ROAMING_TYPE, state.getVoiceRoamingType());
3403 values.put(DATA_ROAMING_TYPE, state.getDataRoamingType());
3404 values.put(VOICE_OPERATOR_ALPHA_LONG, state.getVoiceOperatorAlphaLong());
3405 values.put(VOICE_OPERATOR_ALPHA_SHORT, state.getVoiceOperatorAlphaShort());
3406 values.put(VOICE_OPERATOR_NUMERIC, state.getVoiceOperatorNumeric());
3407 values.put(DATA_OPERATOR_ALPHA_LONG, state.getDataOperatorAlphaLong());
3408 values.put(DATA_OPERATOR_ALPHA_SHORT, state.getDataOperatorAlphaShort());
3409 values.put(DATA_OPERATOR_NUMERIC, state.getDataOperatorNumeric());
3410 values.put(IS_MANUAL_NETWORK_SELECTION, state.getIsManualSelection());
3411 values.put(RIL_VOICE_RADIO_TECHNOLOGY, state.getRilVoiceRadioTechnology());
3412 values.put(RIL_DATA_RADIO_TECHNOLOGY, state.getRilDataRadioTechnology());
3413 values.put(CSS_INDICATOR, state.getCssIndicator());
Jack Yu2661fac2018-03-15 13:51:05 -07003414 values.put(NETWORK_ID, state.getCdmaNetworkId());
3415 values.put(SYSTEM_ID, state.getCdmaSystemId());
Jordan Liub9b75ed2017-02-28 18:15:07 -08003416 values.put(CDMA_ROAMING_INDICATOR, state.getCdmaRoamingIndicator());
3417 values.put(CDMA_DEFAULT_ROAMING_INDICATOR, state.getCdmaDefaultRoamingIndicator());
3418 values.put(CDMA_ERI_ICON_INDEX, state.getCdmaEriIconIndex());
3419 values.put(CDMA_ERI_ICON_MODE, state.getCdmaEriIconMode());
3420 values.put(IS_EMERGENCY_ONLY, state.isEmergencyOnly());
Jordan Liub9b75ed2017-02-28 18:15:07 -08003421 values.put(IS_USING_CARRIER_AGGREGATION, state.isUsingCarrierAggregation());
3422 return values;
3423 }
3424
3425 /**
3426 * An integer value indicating the current voice service state.
3427 * <p>
3428 * Valid values: {@link ServiceState#STATE_IN_SERVICE},
3429 * {@link ServiceState#STATE_OUT_OF_SERVICE}, {@link ServiceState#STATE_EMERGENCY_ONLY},
3430 * {@link ServiceState#STATE_POWER_OFF}.
3431 * <p>
3432 * This is the same as {@link ServiceState#getState()}.
3433 */
3434 public static final String VOICE_REG_STATE = "voice_reg_state";
3435
3436 /**
3437 * An integer value indicating the current data service state.
3438 * <p>
3439 * Valid values: {@link ServiceState#STATE_IN_SERVICE},
3440 * {@link ServiceState#STATE_OUT_OF_SERVICE}, {@link ServiceState#STATE_EMERGENCY_ONLY},
3441 * {@link ServiceState#STATE_POWER_OFF}.
3442 * <p>
3443 * This is the same as {@link ServiceState#getDataRegState()}.
3444 * @hide
3445 */
3446 public static final String DATA_REG_STATE = "data_reg_state";
3447
3448 /**
3449 * An integer value indicating the current voice roaming type.
3450 * <p>
3451 * This is the same as {@link ServiceState#getVoiceRoamingType()}.
3452 * @hide
3453 */
3454 public static final String VOICE_ROAMING_TYPE = "voice_roaming_type";
3455
3456 /**
3457 * An integer value indicating the current data roaming type.
3458 * <p>
3459 * This is the same as {@link ServiceState#getDataRoamingType()}.
3460 * @hide
3461 */
3462 public static final String DATA_ROAMING_TYPE = "data_roaming_type";
3463
3464 /**
3465 * The current registered voice network operator name in long alphanumeric format.
3466 * <p>
3467 * This is the same as {@link ServiceState#getVoiceOperatorAlphaLong()}.
3468 * @hide
3469 */
3470 public static final String VOICE_OPERATOR_ALPHA_LONG = "voice_operator_alpha_long";
3471
3472 /**
3473 * The current registered operator name in short alphanumeric format.
3474 * <p>
3475 * In GSM/UMTS, short format can be up to 8 characters long. The current registered voice
3476 * network operator name in long alphanumeric format.
3477 * <p>
3478 * This is the same as {@link ServiceState#getVoiceOperatorAlphaShort()}.
3479 * @hide
3480 */
3481 public static final String VOICE_OPERATOR_ALPHA_SHORT = "voice_operator_alpha_short";
3482
3483
3484 /**
3485 * The current registered operator numeric id.
3486 * <p>
3487 * In GSM/UMTS, numeric format is 3 digit country code plus 2 or 3 digit
3488 * network code.
3489 * <p>
3490 * This is the same as {@link ServiceState#getOperatorNumeric()}.
3491 */
3492 public static final String VOICE_OPERATOR_NUMERIC = "voice_operator_numeric";
3493
3494 /**
3495 * The current registered data network operator name in long alphanumeric format.
3496 * <p>
3497 * This is the same as {@link ServiceState#getDataOperatorAlphaLong()}.
3498 * @hide
3499 */
3500 public static final String DATA_OPERATOR_ALPHA_LONG = "data_operator_alpha_long";
3501
3502 /**
3503 * The current registered data network operator name in short alphanumeric format.
3504 * <p>
3505 * This is the same as {@link ServiceState#getDataOperatorAlphaShort()}.
3506 * @hide
3507 */
3508 public static final String DATA_OPERATOR_ALPHA_SHORT = "data_operator_alpha_short";
3509
3510 /**
3511 * The current registered data network operator numeric id.
3512 * <p>
3513 * This is the same as {@link ServiceState#getDataOperatorNumeric()}.
3514 * @hide
3515 */
3516 public static final String DATA_OPERATOR_NUMERIC = "data_operator_numeric";
3517
3518 /**
3519 * The current network selection mode.
3520 * <p>
3521 * This is the same as {@link ServiceState#getIsManualSelection()}.
3522 */
3523 public static final String IS_MANUAL_NETWORK_SELECTION = "is_manual_network_selection";
3524
3525 /**
3526 * This is the same as {@link ServiceState#getRilVoiceRadioTechnology()}.
3527 * @hide
3528 */
3529 public static final String RIL_VOICE_RADIO_TECHNOLOGY = "ril_voice_radio_technology";
3530
3531 /**
3532 * This is the same as {@link ServiceState#getRilDataRadioTechnology()}.
3533 * @hide
3534 */
3535 public static final String RIL_DATA_RADIO_TECHNOLOGY = "ril_data_radio_technology";
3536
3537 /**
3538 * This is the same as {@link ServiceState#getCssIndicator()}.
3539 * @hide
3540 */
3541 public static final String CSS_INDICATOR = "css_indicator";
3542
3543 /**
Jack Yu2661fac2018-03-15 13:51:05 -07003544 * This is the same as {@link ServiceState#getCdmaNetworkId()}.
Jordan Liub9b75ed2017-02-28 18:15:07 -08003545 * @hide
3546 */
3547 public static final String NETWORK_ID = "network_id";
3548
3549 /**
Jack Yu2661fac2018-03-15 13:51:05 -07003550 * This is the same as {@link ServiceState#getCdmaSystemId()}.
Jordan Liub9b75ed2017-02-28 18:15:07 -08003551 * @hide
3552 */
3553 public static final String SYSTEM_ID = "system_id";
3554
3555 /**
3556 * This is the same as {@link ServiceState#getCdmaRoamingIndicator()}.
3557 * @hide
3558 */
3559 public static final String CDMA_ROAMING_INDICATOR = "cdma_roaming_indicator";
3560
3561 /**
3562 * This is the same as {@link ServiceState#getCdmaDefaultRoamingIndicator()}.
3563 * @hide
3564 */
3565 public static final String CDMA_DEFAULT_ROAMING_INDICATOR =
3566 "cdma_default_roaming_indicator";
3567
3568 /**
3569 * This is the same as {@link ServiceState#getCdmaEriIconIndex()}.
3570 * @hide
3571 */
3572 public static final String CDMA_ERI_ICON_INDEX = "cdma_eri_icon_index";
3573
3574 /**
3575 * This is the same as {@link ServiceState#getCdmaEriIconMode()}.
3576 * @hide
3577 */
3578 public static final String CDMA_ERI_ICON_MODE = "cdma_eri_icon_mode";
3579
3580 /**
3581 * This is the same as {@link ServiceState#isEmergencyOnly()}.
3582 * @hide
3583 */
3584 public static final String IS_EMERGENCY_ONLY = "is_emergency_only";
3585
3586 /**
3587 * This is the same as {@link ServiceState#getDataRoamingFromRegistration()}.
3588 * @hide
3589 */
3590 public static final String IS_DATA_ROAMING_FROM_REGISTRATION =
3591 "is_data_roaming_from_registration";
3592
3593 /**
3594 * This is the same as {@link ServiceState#isUsingCarrierAggregation()}.
3595 * @hide
3596 */
3597 public static final String IS_USING_CARRIER_AGGREGATION = "is_using_carrier_aggregation";
3598 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07003599
3600 /**
fionaxu58278be2018-01-29 14:08:12 -08003601 * Contains carrier identification information for the current subscriptions.
fionaxu3d0ad1f2017-10-25 23:09:36 -07003602 */
fionaxu62bc7472018-02-28 11:18:45 -08003603 public static final class CarrierId implements BaseColumns {
fionaxu3d0ad1f2017-10-25 23:09:36 -07003604 /**
fionaxu58278be2018-01-29 14:08:12 -08003605 * Not instantiable.
3606 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07003607 */
fionaxu62bc7472018-02-28 11:18:45 -08003608 private CarrierId() {}
fionaxu3d0ad1f2017-10-25 23:09:36 -07003609
3610 /**
fionaxu58278be2018-01-29 14:08:12 -08003611 * The {@code content://} style URI for this provider.
fionaxu3d0ad1f2017-10-25 23:09:36 -07003612 */
fionaxu62bc7472018-02-28 11:18:45 -08003613 public static final Uri CONTENT_URI = Uri.parse("content://carrier_id");
fionaxu3d0ad1f2017-10-25 23:09:36 -07003614
3615 /**
fionaxu62bc7472018-02-28 11:18:45 -08003616 * The authority string for the CarrierId Provider
fionaxu58278be2018-01-29 14:08:12 -08003617 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07003618 */
fionaxu62bc7472018-02-28 11:18:45 -08003619 public static final String AUTHORITY = "carrier_id";
fionaxu58278be2018-01-29 14:08:12 -08003620
fionaxu3d0ad1f2017-10-25 23:09:36 -07003621
3622 /**
fionaxu58278be2018-01-29 14:08:12 -08003623 * Generates a content {@link Uri} used to receive updates on carrier identity change
3624 * on the given subscriptionId
3625 * <p>
3626 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
fionaxuc8d483e2018-03-07 21:52:05 -08003627 * carrier identity {@link TelephonyManager#getSimCarrierId()}
fionaxu58278be2018-01-29 14:08:12 -08003628 * while your app is running. You can also use a {@link JobService} to ensure your app
3629 * is notified of changes to the {@link Uri} even when it is not running.
3630 * Note, however, that using a {@link JobService} does not guarantee timely delivery of
3631 * updates to the {@link Uri}.
3632 *
3633 * @param subscriptionId the subscriptionId to receive updates on
3634 * @return the Uri used to observe carrier identity changes
fionaxu3d0ad1f2017-10-25 23:09:36 -07003635 */
fionaxu58278be2018-01-29 14:08:12 -08003636 public static Uri getUriForSubscriptionId(int subscriptionId) {
3637 return CONTENT_URI.buildUpon().appendEncodedPath(
3638 String.valueOf(subscriptionId)).build();
3639 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07003640
3641 /**
chen xudd44d812018-11-02 17:49:57 -07003642 * Generates a content {@link Uri} used to receive updates on precise carrier identity
3643 * change on the given subscriptionId
3644 * {@link TelephonyManager#ACTION_SUBSCRIPTION_PRECISE_CARRIER_IDENTITY_CHANGED}.
3645 * <p>
3646 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
3647 * precise carrier identity {@link TelephonyManager#getSimPreciseCarrierId()}
3648 * while your app is running. You can also use a {@link JobService} to ensure your app
3649 * is notified of changes to the {@link Uri} even when it is not running.
3650 * Note, however, that using a {@link JobService} does not guarantee timely delivery of
3651 * updates to the {@link Uri}.
3652 *
3653 * @param subscriptionId the subscriptionId to receive updates on
3654 * @return the Uri used to observe precise carrier identity changes
3655 * @hide
3656 */
3657 public static Uri getPreciseCarrierIdUriForSubscriptionId(int subscriptionId) {
3658 return Uri.withAppendedPath(Uri.withAppendedPath(CONTENT_URI, "precise"),
3659 String.valueOf(subscriptionId));
3660 }
3661
3662 /**
fionaxu58278be2018-01-29 14:08:12 -08003663 * A user facing carrier name.
fionaxuc8d483e2018-03-07 21:52:05 -08003664 * @see TelephonyManager#getSimCarrierIdName()
fionaxu3d0ad1f2017-10-25 23:09:36 -07003665 * <P>Type: TEXT </P>
3666 */
fionaxu62bc7472018-02-28 11:18:45 -08003667 public static final String CARRIER_NAME = "carrier_name";
fionaxu3d0ad1f2017-10-25 23:09:36 -07003668
3669 /**
3670 * A unique carrier id
fionaxuc8d483e2018-03-07 21:52:05 -08003671 * @see TelephonyManager#getSimCarrierId()
fionaxu3d0ad1f2017-10-25 23:09:36 -07003672 * <P>Type: INTEGER </P>
3673 */
fionaxu62bc7472018-02-28 11:18:45 -08003674 public static final String CARRIER_ID = "carrier_id";
fionaxu3d0ad1f2017-10-25 23:09:36 -07003675
3676 /**
chen xudd44d812018-11-02 17:49:57 -07003677 * A user facing carrier name for precise carrier id.
3678 * @see TelephonyManager#getSimPreciseCarrierIdName()
3679 * This is not a database column, only used to notify content observers for
3680 * {@link #getPreciseCarrierIdUriForSubscriptionId(int)}
3681 * @hide
3682 */
3683 public static final String PRECISE_CARRIER_ID_NAME = "precise_carrier_id_name";
3684
3685 /**
3686 * A fine-grained carrier id.
3687 * @see TelephonyManager#getSimPreciseCarrierId()
3688 * This is not a database column, only used to notify content observers for
3689 * {@link #getPreciseCarrierIdUriForSubscriptionId(int)}
3690 * @hide
3691 */
3692 public static final String PRECISE_CARRIER_ID = "precise_carrier_id";
3693
3694 /**
3695 * A unique parent carrier id. The parent-child
3696 * relationship can be used to further differentiate a single carrier by different networks,
3697 * by prepaid v.s. postpaid or even by 4G v.s. 3G plan. It's an optional field.
3698 * A carrier id with a valid parent_carrier_id is considered fine-grained carrier id, will
3699 * not be returned as {@link #CARRIER_ID} but {@link #PRECISE_CARRIER_ID}.
3700 * <P>Type: INTEGER </P>
3701 * @hide
3702 */
3703 public static final String PARENT_CARRIER_ID = "parent_carrier_id";
3704
3705 /**
chen xu2e801e02018-10-16 11:55:26 -07003706 * A unique mno carrier id. mno carrier shares the same {@link All#MCCMNC} as carrier id
3707 * and can be solely identified by {@link All#MCCMNC} only. If there is no such mno
3708 * carrier, then mno carrier id equals to {@link #CARRIER_ID carrier id}.
3709 *
3710 * <p>mno carrier id can be used as fallback id. When the exact carrier id configurations
3711 * are not found, usually fall back to its mno carrier id.
3712 * <P>Type: INTEGER </P>
3713 * @hide
3714 */
3715 public static final String MNO_CARRIER_ID = "mno_carrier_id";
3716
3717 /**
fionaxu58278be2018-01-29 14:08:12 -08003718 * Contains mappings between matching rules with carrier id for all carriers.
3719 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07003720 */
fionaxu58278be2018-01-29 14:08:12 -08003721 public static final class All implements BaseColumns {
3722 /**
3723 * Numeric operator ID (as String). {@code MCC + MNC}
3724 * <P>Type: TEXT </P>
3725 */
3726 public static final String MCCMNC = "mccmnc";
3727
3728 /**
3729 * Group id level 1 (as String).
3730 * <P>Type: TEXT </P>
3731 */
3732 public static final String GID1 = "gid1";
3733
3734 /**
3735 * Group id level 2 (as String).
3736 * <P>Type: TEXT </P>
3737 */
3738 public static final String GID2 = "gid2";
3739
3740 /**
3741 * Public Land Mobile Network name.
3742 * <P>Type: TEXT </P>
3743 */
3744 public static final String PLMN = "plmn";
3745
3746 /**
3747 * Prefix xpattern of IMSI (International Mobile Subscriber Identity).
3748 * <P>Type: TEXT </P>
3749 */
3750 public static final String IMSI_PREFIX_XPATTERN = "imsi_prefix_xpattern";
3751
3752 /**
3753 * Service Provider Name.
3754 * <P>Type: TEXT </P>
3755 */
3756 public static final String SPN = "spn";
3757
3758 /**
3759 * Prefer APN name.
3760 * <P>Type: TEXT </P>
3761 */
3762 public static final String APN = "apn";
3763
3764 /**
3765 * Prefix of Integrated Circuit Card Identifier.
3766 * <P>Type: TEXT </P>
3767 */
3768 public static final String ICCID_PREFIX = "iccid_prefix";
3769
3770 /**
fionaxuf9583572018-06-08 16:55:25 -07003771 * Certificate for carrier privilege access rules.
3772 * <P>Type: TEXT in hex string </P>
3773 */
3774 public static final String PRIVILEGE_ACCESS_RULE = "privilege_access_rule";
3775
3776 /**
fionaxu58278be2018-01-29 14:08:12 -08003777 * The {@code content://} URI for this table.
3778 */
fionaxu62bc7472018-02-28 11:18:45 -08003779 public static final Uri CONTENT_URI = Uri.parse("content://carrier_id/all");
fionaxu58278be2018-01-29 14:08:12 -08003780 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07003781 }
Dan Willemsen4980bf42017-02-14 14:17:12 -08003782}