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