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