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