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