blob: 6c9c01cb0d673ce5dc333ce4dbbb38cb281c9860 [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 /**
Amit Mahajan8c1c45a2018-10-22 10:43:34 -07001248 * Broadcast action: When SMS-MMS db is being created. If file-based encryption is
1249 * supported, this broadcast indicates creation of the db in credential-encrypted
1250 * storage. A boolean is specified in {@link #EXTRA_IS_INITIAL_CREATE} to indicate if
1251 * this is the initial create of the db. Requires
1252 * {@link android.Manifest.permission#READ_SMS} to receive.
1253 *
1254 * @see #EXTRA_IS_INITIAL_CREATE
1255 *
1256 * @hide
1257 */
1258 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1259 public static final String ACTION_SMS_MMS_DB_CREATED =
1260 "android.provider.action.SMS_MMS_DB_CREATED";
1261
1262 /**
1263 * Boolean flag passed as an extra with {@link #ACTION_SMS_MMS_DB_CREATED} to indicate
1264 * whether the DB creation is the initial creation on the device, that is it is after a
1265 * factory-data reset or a new device. Any subsequent creations of the DB (which
1266 * happens only in error scenarios) will have this flag set to false.
1267 *
1268 * @see #ACTION_SMS_MMS_DB_CREATED
1269 *
1270 * @hide
1271 */
1272 public static final String EXTRA_IS_INITIAL_CREATE =
1273 "android.provider.extra.IS_INITIAL_CREATE";
1274 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08001275 * Read the PDUs out of an {@link #SMS_RECEIVED_ACTION} or a
1276 * {@link #DATA_SMS_RECEIVED_ACTION} intent.
1277 *
1278 * @param intent the intent to read from
1279 * @return an array of SmsMessages for the PDUs
1280 */
1281 public static SmsMessage[] getMessagesFromIntent(Intent intent) {
1282 Object[] messages;
1283 try {
1284 messages = (Object[]) intent.getSerializableExtra("pdus");
1285 }
1286 catch (ClassCastException e) {
1287 Rlog.e(TAG, "getMessagesFromIntent: " + e);
1288 return null;
1289 }
1290
1291 if (messages == null) {
1292 Rlog.e(TAG, "pdus does not exist in the intent");
1293 return null;
1294 }
1295
1296 String format = intent.getStringExtra("format");
1297 int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
1298 SubscriptionManager.getDefaultSmsSubscriptionId());
1299
1300 Rlog.v(TAG, " getMessagesFromIntent sub_id : " + subId);
1301
1302 int pduCount = messages.length;
1303 SmsMessage[] msgs = new SmsMessage[pduCount];
1304
1305 for (int i = 0; i < pduCount; i++) {
1306 byte[] pdu = (byte[]) messages[i];
1307 msgs[i] = SmsMessage.createFromPdu(pdu, format);
1308 if (msgs[i] != null) msgs[i].setSubId(subId);
1309 }
1310 return msgs;
1311 }
1312 }
1313 }
1314
1315 /**
pkanwar16b8a0d2017-06-07 10:59:41 -07001316 * Base column for the table that contain Carrier Public key.
1317 * @hide
1318 */
1319 public interface CarrierColumns extends BaseColumns {
1320
1321 public static final String MCC = "mcc";
1322 public static final String MNC = "mnc";
1323 public static final String KEY_TYPE = "key_type";
1324 public static final String MVNO_TYPE = "mvno_type";
1325 public static final String MVNO_MATCH_DATA = "mvno_match_data";
1326 public static final String PUBLIC_KEY = "public_key";
1327 public static final String KEY_IDENTIFIER = "key_identifier";
1328 public static final String EXPIRATION_TIME = "expiration_time";
1329 public static final String LAST_MODIFIED = "last_modified";
1330
1331 /**
1332 * The {@code content://} style URL for this table.
1333 * @hide
1334 */
1335 public static final Uri CONTENT_URI = Uri.parse("content://carrier_information/carrier");
1336 }
1337
1338 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08001339 * Base columns for tables that contain MMSs.
1340 */
1341 public interface BaseMmsColumns extends BaseColumns {
1342
1343 /** Message box: all messages. */
1344 public static final int MESSAGE_BOX_ALL = 0;
1345 /** Message box: inbox. */
1346 public static final int MESSAGE_BOX_INBOX = 1;
1347 /** Message box: sent messages. */
1348 public static final int MESSAGE_BOX_SENT = 2;
1349 /** Message box: drafts. */
1350 public static final int MESSAGE_BOX_DRAFTS = 3;
1351 /** Message box: outbox. */
1352 public static final int MESSAGE_BOX_OUTBOX = 4;
1353 /** Message box: failed. */
1354 public static final int MESSAGE_BOX_FAILED = 5;
1355
1356 /**
1357 * The thread ID of the message.
1358 * <P>Type: INTEGER (long)</P>
1359 */
1360 public static final String THREAD_ID = "thread_id";
1361
1362 /**
1363 * The date the message was received.
1364 * <P>Type: INTEGER (long)</P>
1365 */
1366 public static final String DATE = "date";
1367
1368 /**
1369 * The date the message was sent.
1370 * <P>Type: INTEGER (long)</P>
1371 */
1372 public static final String DATE_SENT = "date_sent";
1373
1374 /**
1375 * The box which the message belongs to, e.g. {@link #MESSAGE_BOX_INBOX}.
1376 * <P>Type: INTEGER</P>
1377 */
1378 public static final String MESSAGE_BOX = "msg_box";
1379
1380 /**
1381 * Has the message been read?
1382 * <P>Type: INTEGER (boolean)</P>
1383 */
1384 public static final String READ = "read";
1385
1386 /**
1387 * Has the message been seen by the user? The "seen" flag determines
1388 * whether we need to show a new message notification.
1389 * <P>Type: INTEGER (boolean)</P>
1390 */
1391 public static final String SEEN = "seen";
1392
1393 /**
1394 * Does the message have only a text part (can also have a subject) with
1395 * no picture, slideshow, sound, etc. parts?
1396 * <P>Type: INTEGER (boolean)</P>
1397 */
1398 public static final String TEXT_ONLY = "text_only";
1399
1400 /**
1401 * The {@code Message-ID} of the message.
1402 * <P>Type: TEXT</P>
1403 */
1404 public static final String MESSAGE_ID = "m_id";
1405
1406 /**
1407 * The subject of the message, if present.
1408 * <P>Type: TEXT</P>
1409 */
1410 public static final String SUBJECT = "sub";
1411
1412 /**
1413 * The character set of the subject, if present.
1414 * <P>Type: INTEGER</P>
1415 */
1416 public static final String SUBJECT_CHARSET = "sub_cs";
1417
1418 /**
1419 * The {@code Content-Type} of the message.
1420 * <P>Type: TEXT</P>
1421 */
1422 public static final String CONTENT_TYPE = "ct_t";
1423
1424 /**
1425 * The {@code Content-Location} of the message.
1426 * <P>Type: TEXT</P>
1427 */
1428 public static final String CONTENT_LOCATION = "ct_l";
1429
1430 /**
1431 * The expiry time of the message.
1432 * <P>Type: INTEGER (long)</P>
1433 */
1434 public static final String EXPIRY = "exp";
1435
1436 /**
1437 * The class of the message.
1438 * <P>Type: TEXT</P>
1439 */
1440 public static final String MESSAGE_CLASS = "m_cls";
1441
1442 /**
1443 * The type of the message defined by MMS spec.
1444 * <P>Type: INTEGER</P>
1445 */
1446 public static final String MESSAGE_TYPE = "m_type";
1447
1448 /**
1449 * The version of the specification that this message conforms to.
1450 * <P>Type: INTEGER</P>
1451 */
1452 public static final String MMS_VERSION = "v";
1453
1454 /**
1455 * The size of the message.
1456 * <P>Type: INTEGER</P>
1457 */
1458 public static final String MESSAGE_SIZE = "m_size";
1459
1460 /**
1461 * The priority of the message.
1462 * <P>Type: INTEGER</P>
1463 */
1464 public static final String PRIORITY = "pri";
1465
1466 /**
1467 * The {@code read-report} of the message.
1468 * <P>Type: INTEGER (boolean)</P>
1469 */
1470 public static final String READ_REPORT = "rr";
1471
1472 /**
1473 * Is read report allowed?
1474 * <P>Type: INTEGER (boolean)</P>
1475 */
1476 public static final String REPORT_ALLOWED = "rpt_a";
1477
1478 /**
1479 * The {@code response-status} of the message.
1480 * <P>Type: INTEGER</P>
1481 */
1482 public static final String RESPONSE_STATUS = "resp_st";
1483
1484 /**
1485 * The {@code status} of the message.
1486 * <P>Type: INTEGER</P>
1487 */
1488 public static final String STATUS = "st";
1489
1490 /**
1491 * The {@code transaction-id} of the message.
1492 * <P>Type: TEXT</P>
1493 */
1494 public static final String TRANSACTION_ID = "tr_id";
1495
1496 /**
1497 * The {@code retrieve-status} of the message.
1498 * <P>Type: INTEGER</P>
1499 */
1500 public static final String RETRIEVE_STATUS = "retr_st";
1501
1502 /**
1503 * The {@code retrieve-text} of the message.
1504 * <P>Type: TEXT</P>
1505 */
1506 public static final String RETRIEVE_TEXT = "retr_txt";
1507
1508 /**
1509 * The character set of the retrieve-text.
1510 * <P>Type: INTEGER</P>
1511 */
1512 public static final String RETRIEVE_TEXT_CHARSET = "retr_txt_cs";
1513
1514 /**
1515 * The {@code read-status} of the message.
1516 * <P>Type: INTEGER</P>
1517 */
1518 public static final String READ_STATUS = "read_status";
1519
1520 /**
1521 * The {@code content-class} of the message.
1522 * <P>Type: INTEGER</P>
1523 */
1524 public static final String CONTENT_CLASS = "ct_cls";
1525
1526 /**
1527 * The {@code delivery-report} of the message.
1528 * <P>Type: INTEGER</P>
1529 */
1530 public static final String DELIVERY_REPORT = "d_rpt";
1531
1532 /**
1533 * The {@code delivery-time-token} of the message.
1534 * <P>Type: INTEGER</P>
1535 * @deprecated this column is no longer supported.
1536 * @hide
1537 */
1538 @Deprecated
1539 public static final String DELIVERY_TIME_TOKEN = "d_tm_tok";
1540
1541 /**
1542 * The {@code delivery-time} of the message.
1543 * <P>Type: INTEGER</P>
1544 */
1545 public static final String DELIVERY_TIME = "d_tm";
1546
1547 /**
1548 * The {@code response-text} of the message.
1549 * <P>Type: TEXT</P>
1550 */
1551 public static final String RESPONSE_TEXT = "resp_txt";
1552
1553 /**
1554 * The {@code sender-visibility} of the message.
1555 * <P>Type: TEXT</P>
1556 * @deprecated this column is no longer supported.
1557 * @hide
1558 */
1559 @Deprecated
1560 public static final String SENDER_VISIBILITY = "s_vis";
1561
1562 /**
1563 * The {@code reply-charging} of the message.
1564 * <P>Type: INTEGER</P>
1565 * @deprecated this column is no longer supported.
1566 * @hide
1567 */
1568 @Deprecated
1569 public static final String REPLY_CHARGING = "r_chg";
1570
1571 /**
1572 * The {@code reply-charging-deadline-token} 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_DEADLINE_TOKEN = "r_chg_dl_tok";
1579
1580 /**
1581 * The {@code reply-charging-deadline} of the message.
1582 * <P>Type: INTEGER</P>
1583 * @deprecated this column is no longer supported.
1584 * @hide
1585 */
1586 @Deprecated
1587 public static final String REPLY_CHARGING_DEADLINE = "r_chg_dl";
1588
1589 /**
1590 * The {@code reply-charging-id} of the message.
1591 * <P>Type: TEXT</P>
1592 * @deprecated this column is no longer supported.
1593 * @hide
1594 */
1595 @Deprecated
1596 public static final String REPLY_CHARGING_ID = "r_chg_id";
1597
1598 /**
1599 * The {@code reply-charging-size} of the message.
1600 * <P>Type: INTEGER</P>
1601 * @deprecated this column is no longer supported.
1602 * @hide
1603 */
1604 @Deprecated
1605 public static final String REPLY_CHARGING_SIZE = "r_chg_sz";
1606
1607 /**
1608 * The {@code previously-sent-by} of the message.
1609 * <P>Type: TEXT</P>
1610 * @deprecated this column is no longer supported.
1611 * @hide
1612 */
1613 @Deprecated
1614 public static final String PREVIOUSLY_SENT_BY = "p_s_by";
1615
1616 /**
1617 * The {@code previously-sent-date} 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 PREVIOUSLY_SENT_DATE = "p_s_d";
1624
1625 /**
1626 * The {@code store} 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 STORE = "store";
1633
1634 /**
1635 * The {@code mm-state} of the message.
1636 * <P>Type: INTEGER</P>
1637 * @deprecated this column is no longer supported.
1638 * @hide
1639 */
1640 @Deprecated
1641 public static final String MM_STATE = "mm_st";
1642
1643 /**
1644 * The {@code mm-flags-token} of the message.
1645 * <P>Type: INTEGER</P>
1646 * @deprecated this column is no longer supported.
1647 * @hide
1648 */
1649 @Deprecated
1650 public static final String MM_FLAGS_TOKEN = "mm_flg_tok";
1651
1652 /**
1653 * The {@code mm-flags} 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 MM_FLAGS = "mm_flg";
1660
1661 /**
1662 * The {@code store-status} 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 STORE_STATUS = "store_st";
1669
1670 /**
1671 * The {@code store-status-text} 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 STORE_STATUS_TEXT = "store_st_txt";
1678
1679 /**
1680 * The {@code stored} of the message.
1681 * <P>Type: TEXT</P>
1682 * @deprecated this column is no longer supported.
1683 * @hide
1684 */
1685 @Deprecated
1686 public static final String STORED = "stored";
1687
1688 /**
1689 * The {@code totals} 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 TOTALS = "totals";
1696
1697 /**
1698 * The {@code mbox-totals} 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_TOTALS = "mb_t";
1705
1706 /**
1707 * The {@code mbox-totals-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_TOTALS_TOKEN = "mb_t_tok";
1714
1715 /**
1716 * The {@code quotas} of the message.
1717 * <P>Type: TEXT</P>
1718 * @deprecated this column is no longer supported.
1719 * @hide
1720 */
1721 @Deprecated
1722 public static final String QUOTAS = "qt";
1723
1724 /**
1725 * The {@code mbox-quotas} of the message.
1726 * <P>Type: TEXT</P>
1727 * @deprecated this column is no longer supported.
1728 * @hide
1729 */
1730 @Deprecated
1731 public static final String MBOX_QUOTAS = "mb_qt";
1732
1733 /**
1734 * The {@code mbox-quotas-token} of the message.
1735 * <P>Type: INTEGER</P>
1736 * @deprecated this column is no longer supported.
1737 * @hide
1738 */
1739 @Deprecated
1740 public static final String MBOX_QUOTAS_TOKEN = "mb_qt_tok";
1741
1742 /**
1743 * The {@code message-count} of the message.
1744 * <P>Type: INTEGER</P>
1745 * @deprecated this column is no longer supported.
1746 * @hide
1747 */
1748 @Deprecated
1749 public static final String MESSAGE_COUNT = "m_cnt";
1750
1751 /**
1752 * The {@code start} 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 START = "start";
1759
1760 /**
1761 * The {@code distribution-indicator} of the message.
1762 * <P>Type: TEXT</P>
1763 * @deprecated this column is no longer supported.
1764 * @hide
1765 */
1766 @Deprecated
1767 public static final String DISTRIBUTION_INDICATOR = "d_ind";
1768
1769 /**
1770 * The {@code element-descriptor} 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 ELEMENT_DESCRIPTOR = "e_des";
1777
1778 /**
1779 * The {@code limit} of the message.
1780 * <P>Type: INTEGER</P>
1781 * @deprecated this column is no longer supported.
1782 * @hide
1783 */
1784 @Deprecated
1785 public static final String LIMIT = "limit";
1786
1787 /**
1788 * The {@code recommended-retrieval-mode} of the message.
1789 * <P>Type: INTEGER</P>
1790 * @deprecated this column is no longer supported.
1791 * @hide
1792 */
1793 @Deprecated
1794 public static final String RECOMMENDED_RETRIEVAL_MODE = "r_r_mod";
1795
1796 /**
1797 * The {@code recommended-retrieval-mode-text} 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 RECOMMENDED_RETRIEVAL_MODE_TEXT = "r_r_mod_txt";
1804
1805 /**
1806 * The {@code status-text} 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 STATUS_TEXT = "st_txt";
1813
1814 /**
1815 * The {@code applic-id} 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 APPLIC_ID = "apl_id";
1822
1823 /**
1824 * The {@code reply-applic-id} 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 REPLY_APPLIC_ID = "r_apl_id";
1831
1832 /**
1833 * The {@code aux-applic-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 AUX_APPLIC_ID = "aux_apl_id";
1840
1841 /**
1842 * The {@code drm-content} 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 DRM_CONTENT = "drm_c";
1849
1850 /**
1851 * The {@code adaptation-allowed} of the message.
1852 * <P>Type: TEXT</P>
1853 * @deprecated this column is no longer supported.
1854 * @hide
1855 */
1856 @Deprecated
1857 public static final String ADAPTATION_ALLOWED = "adp_a";
1858
1859 /**
1860 * The {@code replace-id} of the message.
1861 * <P>Type: TEXT</P>
1862 * @deprecated this column is no longer supported.
1863 * @hide
1864 */
1865 @Deprecated
1866 public static final String REPLACE_ID = "repl_id";
1867
1868 /**
1869 * The {@code cancel-id} of the message.
1870 * <P>Type: TEXT</P>
1871 * @deprecated this column is no longer supported.
1872 * @hide
1873 */
1874 @Deprecated
1875 public static final String CANCEL_ID = "cl_id";
1876
1877 /**
1878 * The {@code cancel-status} of the message.
1879 * <P>Type: INTEGER</P>
1880 * @deprecated this column is no longer supported.
1881 * @hide
1882 */
1883 @Deprecated
1884 public static final String CANCEL_STATUS = "cl_st";
1885
1886 /**
1887 * Is the message locked?
1888 * <P>Type: INTEGER (boolean)</P>
1889 */
1890 public static final String LOCKED = "locked";
1891
1892 /**
1893 * The subscription to which the message belongs to. Its value will be
1894 * < 0 if the sub id cannot be determined.
1895 * <p>Type: INTEGER (long)</p>
1896 */
1897 public static final String SUBSCRIPTION_ID = "sub_id";
1898
1899 /**
1900 * The identity of the sender of a sent message. It is
1901 * usually the package name of the app which sends the message.
1902 * <p class="note"><strong>Note:</strong>
1903 * This column is read-only. It is set by the provider and can not be changed by apps.
1904 * <p>Type: TEXT</p>
1905 */
1906 public static final String CREATOR = "creator";
1907 }
1908
1909 /**
1910 * Columns for the "canonical_addresses" table used by MMS and SMS.
1911 */
1912 public interface CanonicalAddressesColumns extends BaseColumns {
1913 /**
1914 * An address used in MMS or SMS. Email addresses are
1915 * converted to lower case and are compared by string
1916 * equality. Other addresses are compared using
1917 * PHONE_NUMBERS_EQUAL.
1918 * <P>Type: TEXT</P>
1919 */
1920 public static final String ADDRESS = "address";
1921 }
1922
1923 /**
1924 * Columns for the "threads" table used by MMS and SMS.
1925 */
1926 public interface ThreadsColumns extends BaseColumns {
1927
1928 /**
1929 * The date at which the thread was created.
1930 * <P>Type: INTEGER (long)</P>
1931 */
1932 public static final String DATE = "date";
1933
1934 /**
1935 * A string encoding of the recipient IDs of the recipients of
1936 * the message, in numerical order and separated by spaces.
1937 * <P>Type: TEXT</P>
1938 */
1939 public static final String RECIPIENT_IDS = "recipient_ids";
1940
1941 /**
1942 * The message count of the thread.
1943 * <P>Type: INTEGER</P>
1944 */
1945 public static final String MESSAGE_COUNT = "message_count";
1946
1947 /**
1948 * Indicates whether all messages of the thread have been read.
1949 * <P>Type: INTEGER</P>
1950 */
1951 public static final String READ = "read";
1952
1953 /**
1954 * The snippet of the latest message in the thread.
1955 * <P>Type: TEXT</P>
1956 */
1957 public static final String SNIPPET = "snippet";
1958
1959 /**
1960 * The charset of the snippet.
1961 * <P>Type: INTEGER</P>
1962 */
1963 public static final String SNIPPET_CHARSET = "snippet_cs";
1964
1965 /**
1966 * Type of the thread, either {@link Threads#COMMON_THREAD} or
1967 * {@link Threads#BROADCAST_THREAD}.
1968 * <P>Type: INTEGER</P>
1969 */
1970 public static final String TYPE = "type";
1971
1972 /**
1973 * Indicates whether there is a transmission error in the thread.
1974 * <P>Type: INTEGER</P>
1975 */
1976 public static final String ERROR = "error";
1977
1978 /**
1979 * Indicates whether this thread contains any attachments.
1980 * <P>Type: INTEGER</P>
1981 */
1982 public static final String HAS_ATTACHMENT = "has_attachment";
1983
1984 /**
1985 * If the thread is archived
1986 * <P>Type: INTEGER (boolean)</P>
1987 */
1988 public static final String ARCHIVED = "archived";
1989 }
1990
1991 /**
1992 * Helper functions for the "threads" table used by MMS and SMS.
1993 */
1994 public static final class Threads implements ThreadsColumns {
1995
Mathew Inwood6750f2e2018-08-10 09:29:25 +01001996 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08001997 private static final String[] ID_PROJECTION = { BaseColumns._ID };
1998
1999 /**
2000 * Private {@code content://} style URL for this table. Used by
2001 * {@link #getOrCreateThreadId(android.content.Context, java.util.Set)}.
2002 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002003 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002004 private static final Uri THREAD_ID_CONTENT_URI = Uri.parse(
2005 "content://mms-sms/threadID");
2006
2007 /**
2008 * The {@code content://} style URL for this table, by conversation.
2009 */
2010 public static final Uri CONTENT_URI = Uri.withAppendedPath(
2011 MmsSms.CONTENT_URI, "conversations");
2012
2013 /**
2014 * The {@code content://} style URL for this table, for obsolete threads.
2015 */
2016 public static final Uri OBSOLETE_THREADS_URI = Uri.withAppendedPath(
2017 CONTENT_URI, "obsolete");
2018
2019 /** Thread type: common thread. */
2020 public static final int COMMON_THREAD = 0;
2021
2022 /** Thread type: broadcast thread. */
2023 public static final int BROADCAST_THREAD = 1;
2024
2025 /**
2026 * Not instantiable.
2027 * @hide
2028 */
2029 private Threads() {
2030 }
2031
2032 /**
2033 * This is a single-recipient version of {@code getOrCreateThreadId}.
2034 * It's convenient for use with SMS messages.
2035 * @param context the context object to use.
2036 * @param recipient the recipient to send to.
2037 */
2038 public static long getOrCreateThreadId(Context context, String recipient) {
2039 Set<String> recipients = new HashSet<String>();
2040
2041 recipients.add(recipient);
2042 return getOrCreateThreadId(context, recipients);
2043 }
2044
2045 /**
2046 * Given the recipients list and subject of an unsaved message,
2047 * return its thread ID. If the message starts a new thread,
2048 * allocate a new thread ID. Otherwise, use the appropriate
2049 * existing thread ID.
2050 *
2051 * <p>Find the thread ID of the same set of recipients (in any order,
2052 * without any additions). If one is found, return it. Otherwise,
2053 * return a unique thread ID.</p>
2054 */
2055 public static long getOrCreateThreadId(
2056 Context context, Set<String> recipients) {
2057 Uri.Builder uriBuilder = THREAD_ID_CONTENT_URI.buildUpon();
2058
2059 for (String recipient : recipients) {
2060 if (Mms.isEmailAddress(recipient)) {
2061 recipient = Mms.extractAddrSpec(recipient);
2062 }
2063
2064 uriBuilder.appendQueryParameter("recipient", recipient);
2065 }
2066
2067 Uri uri = uriBuilder.build();
2068 //if (DEBUG) Rlog.v(TAG, "getOrCreateThreadId uri: " + uri);
2069
2070 Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
2071 uri, ID_PROJECTION, null, null, null);
2072 if (cursor != null) {
2073 try {
2074 if (cursor.moveToFirst()) {
2075 return cursor.getLong(0);
2076 } else {
2077 Rlog.e(TAG, "getOrCreateThreadId returned no rows!");
2078 }
2079 } finally {
2080 cursor.close();
2081 }
2082 }
2083
2084 Rlog.e(TAG, "getOrCreateThreadId failed with " + recipients.size() + " recipients");
2085 throw new IllegalArgumentException("Unable to find or allocate a thread ID.");
2086 }
2087 }
2088
2089 /**
2090 * Contains all MMS messages.
2091 */
2092 public static final class Mms implements BaseMmsColumns {
2093
2094 /**
2095 * Not instantiable.
2096 * @hide
2097 */
2098 private Mms() {
2099 }
2100
2101 /**
2102 * The {@code content://} URI for this table.
2103 */
2104 public static final Uri CONTENT_URI = Uri.parse("content://mms");
2105
2106 /**
2107 * Content URI for getting MMS report requests.
2108 */
2109 public static final Uri REPORT_REQUEST_URI = Uri.withAppendedPath(
2110 CONTENT_URI, "report-request");
2111
2112 /**
2113 * Content URI for getting MMS report status.
2114 */
2115 public static final Uri REPORT_STATUS_URI = Uri.withAppendedPath(
2116 CONTENT_URI, "report-status");
2117
2118 /**
2119 * The default sort order for this table.
2120 */
2121 public static final String DEFAULT_SORT_ORDER = "date DESC";
2122
2123 /**
2124 * Regex pattern for names and email addresses.
2125 * <ul>
2126 * <li><em>mailbox</em> = {@code name-addr}</li>
2127 * <li><em>name-addr</em> = {@code [display-name] angle-addr}</li>
2128 * <li><em>angle-addr</em> = {@code [CFWS] "<" addr-spec ">" [CFWS]}</li>
2129 * </ul>
2130 * @hide
2131 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002132 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002133 public static final Pattern NAME_ADDR_EMAIL_PATTERN =
2134 Pattern.compile("\\s*(\"[^\"]*\"|[^<>\"]+)\\s*<([^<>]+)>\\s*");
2135
2136 /**
2137 * Helper method to query this table.
2138 * @hide
2139 */
2140 public static Cursor query(
2141 ContentResolver cr, String[] projection) {
2142 return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
2143 }
2144
2145 /**
2146 * Helper method to query this table.
2147 * @hide
2148 */
2149 public static Cursor query(
2150 ContentResolver cr, String[] projection,
2151 String where, String orderBy) {
2152 return cr.query(CONTENT_URI, projection,
2153 where, null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
2154 }
2155
2156 /**
2157 * Helper method to extract email address from address string.
2158 * @hide
2159 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002160 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002161 public static String extractAddrSpec(String address) {
2162 Matcher match = NAME_ADDR_EMAIL_PATTERN.matcher(address);
2163
2164 if (match.matches()) {
2165 return match.group(2);
2166 }
2167 return address;
2168 }
2169
2170 /**
2171 * Is the specified address an email address?
2172 *
2173 * @param address the input address to test
2174 * @return true if address is an email address; false otherwise.
2175 * @hide
2176 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002177 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002178 public static boolean isEmailAddress(String address) {
2179 if (TextUtils.isEmpty(address)) {
2180 return false;
2181 }
2182
2183 String s = extractAddrSpec(address);
2184 Matcher match = Patterns.EMAIL_ADDRESS.matcher(s);
2185 return match.matches();
2186 }
2187
2188 /**
2189 * Is the specified number a phone number?
2190 *
2191 * @param number the input number to test
2192 * @return true if number is a phone number; false otherwise.
2193 * @hide
2194 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002195 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002196 public static boolean isPhoneNumber(String number) {
2197 if (TextUtils.isEmpty(number)) {
2198 return false;
2199 }
2200
2201 Matcher match = Patterns.PHONE.matcher(number);
2202 return match.matches();
2203 }
2204
2205 /**
2206 * Contains all MMS messages in the MMS app inbox.
2207 */
2208 public static final class Inbox implements BaseMmsColumns {
2209
2210 /**
2211 * Not instantiable.
2212 * @hide
2213 */
2214 private Inbox() {
2215 }
2216
2217 /**
2218 * The {@code content://} style URL for this table.
2219 */
2220 public static final Uri
2221 CONTENT_URI = Uri.parse("content://mms/inbox");
2222
2223 /**
2224 * The default sort order for this table.
2225 */
2226 public static final String DEFAULT_SORT_ORDER = "date DESC";
2227 }
2228
2229 /**
2230 * Contains all MMS messages in the MMS app sent folder.
2231 */
2232 public static final class Sent implements BaseMmsColumns {
2233
2234 /**
2235 * Not instantiable.
2236 * @hide
2237 */
2238 private Sent() {
2239 }
2240
2241 /**
2242 * The {@code content://} style URL for this table.
2243 */
2244 public static final Uri
2245 CONTENT_URI = Uri.parse("content://mms/sent");
2246
2247 /**
2248 * The default sort order for this table.
2249 */
2250 public static final String DEFAULT_SORT_ORDER = "date DESC";
2251 }
2252
2253 /**
2254 * Contains all MMS messages in the MMS app drafts folder.
2255 */
2256 public static final class Draft implements BaseMmsColumns {
2257
2258 /**
2259 * Not instantiable.
2260 * @hide
2261 */
2262 private Draft() {
2263 }
2264
2265 /**
2266 * The {@code content://} style URL for this table.
2267 */
2268 public static final Uri
2269 CONTENT_URI = Uri.parse("content://mms/drafts");
2270
2271 /**
2272 * The default sort order for this table.
2273 */
2274 public static final String DEFAULT_SORT_ORDER = "date DESC";
2275 }
2276
2277 /**
2278 * Contains all MMS messages in the MMS app outbox.
2279 */
2280 public static final class Outbox implements BaseMmsColumns {
2281
2282 /**
2283 * Not instantiable.
2284 * @hide
2285 */
2286 private Outbox() {
2287 }
2288
2289 /**
2290 * The {@code content://} style URL for this table.
2291 */
2292 public static final Uri
2293 CONTENT_URI = Uri.parse("content://mms/outbox");
2294
2295 /**
2296 * The default sort order for this table.
2297 */
2298 public static final String DEFAULT_SORT_ORDER = "date DESC";
2299 }
2300
2301 /**
2302 * Contains address information for an MMS message.
2303 */
2304 public static final class Addr implements BaseColumns {
2305
2306 /**
2307 * Not instantiable.
2308 * @hide
2309 */
2310 private Addr() {
2311 }
2312
2313 /**
2314 * The ID of MM which this address entry belongs to.
2315 * <P>Type: INTEGER (long)</P>
2316 */
2317 public static final String MSG_ID = "msg_id";
2318
2319 /**
2320 * The ID of contact entry in Phone Book.
2321 * <P>Type: INTEGER (long)</P>
2322 */
2323 public static final String CONTACT_ID = "contact_id";
2324
2325 /**
2326 * The address text.
2327 * <P>Type: TEXT</P>
2328 */
2329 public static final String ADDRESS = "address";
2330
2331 /**
2332 * Type of address: must be one of {@code PduHeaders.BCC},
2333 * {@code PduHeaders.CC}, {@code PduHeaders.FROM}, {@code PduHeaders.TO}.
2334 * <P>Type: INTEGER</P>
2335 */
2336 public static final String TYPE = "type";
2337
2338 /**
2339 * Character set of this entry (MMS charset value).
2340 * <P>Type: INTEGER</P>
2341 */
2342 public static final String CHARSET = "charset";
2343 }
2344
2345 /**
2346 * Contains message parts.
2347 */
2348 public static final class Part implements BaseColumns {
2349
2350 /**
2351 * Not instantiable.
2352 * @hide
2353 */
2354 private Part() {
2355 }
2356
2357 /**
2358 * The identifier of the message which this part belongs to.
2359 * <P>Type: INTEGER</P>
2360 */
2361 public static final String MSG_ID = "mid";
2362
2363 /**
2364 * The order of the part.
2365 * <P>Type: INTEGER</P>
2366 */
2367 public static final String SEQ = "seq";
2368
2369 /**
2370 * The content type of the part.
2371 * <P>Type: TEXT</P>
2372 */
2373 public static final String CONTENT_TYPE = "ct";
2374
2375 /**
2376 * The name of the part.
2377 * <P>Type: TEXT</P>
2378 */
2379 public static final String NAME = "name";
2380
2381 /**
2382 * The charset of the part.
2383 * <P>Type: TEXT</P>
2384 */
2385 public static final String CHARSET = "chset";
2386
2387 /**
2388 * The file name of the part.
2389 * <P>Type: TEXT</P>
2390 */
2391 public static final String FILENAME = "fn";
2392
2393 /**
2394 * The content disposition of the part.
2395 * <P>Type: TEXT</P>
2396 */
2397 public static final String CONTENT_DISPOSITION = "cd";
2398
2399 /**
2400 * The content ID of the part.
2401 * <P>Type: INTEGER</P>
2402 */
2403 public static final String CONTENT_ID = "cid";
2404
2405 /**
2406 * The content location of the part.
2407 * <P>Type: INTEGER</P>
2408 */
2409 public static final String CONTENT_LOCATION = "cl";
2410
2411 /**
2412 * The start of content-type of the message.
2413 * <P>Type: INTEGER</P>
2414 */
2415 public static final String CT_START = "ctt_s";
2416
2417 /**
2418 * The type of content-type of the message.
2419 * <P>Type: TEXT</P>
2420 */
2421 public static final String CT_TYPE = "ctt_t";
2422
2423 /**
2424 * The location (on filesystem) of the binary data of the part.
2425 * <P>Type: INTEGER</P>
2426 */
2427 public static final String _DATA = "_data";
2428
2429 /**
2430 * The message text.
2431 * <P>Type: TEXT</P>
2432 */
2433 public static final String TEXT = "text";
2434 }
2435
2436 /**
2437 * Message send rate table.
2438 */
2439 public static final class Rate {
2440
2441 /**
2442 * Not instantiable.
2443 * @hide
2444 */
2445 private Rate() {
2446 }
2447
2448 /**
2449 * The {@code content://} style URL for this table.
2450 */
2451 public static final Uri CONTENT_URI = Uri.withAppendedPath(
2452 Mms.CONTENT_URI, "rate");
2453
2454 /**
2455 * When a message was successfully sent.
2456 * <P>Type: INTEGER (long)</P>
2457 */
2458 public static final String SENT_TIME = "sent_time";
2459 }
2460
2461 /**
2462 * Intents class.
2463 */
2464 public static final class Intents {
2465
2466 /**
2467 * Not instantiable.
2468 * @hide
2469 */
2470 private Intents() {
2471 }
2472
2473 /**
2474 * Indicates that the contents of specified URIs were changed.
2475 * The application which is showing or caching these contents
2476 * should be updated.
2477 */
2478 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2479 public static final String CONTENT_CHANGED_ACTION
2480 = "android.intent.action.CONTENT_CHANGED";
2481
2482 /**
2483 * An extra field which stores the URI of deleted contents.
2484 */
2485 public static final String DELETED_CONTENTS = "deleted_contents";
2486 }
2487 }
2488
2489 /**
2490 * Contains all MMS and SMS messages.
2491 */
2492 public static final class MmsSms implements BaseColumns {
2493
2494 /**
2495 * Not instantiable.
2496 * @hide
2497 */
2498 private MmsSms() {
2499 }
2500
2501 /**
2502 * The column to distinguish SMS and MMS messages in query results.
2503 */
2504 public static final String TYPE_DISCRIMINATOR_COLUMN =
2505 "transport_type";
2506
2507 /**
2508 * The {@code content://} style URL for this table.
2509 */
2510 public static final Uri CONTENT_URI = Uri.parse("content://mms-sms/");
2511
2512 /**
2513 * The {@code content://} style URL for this table, by conversation.
2514 */
2515 public static final Uri CONTENT_CONVERSATIONS_URI = Uri.parse(
2516 "content://mms-sms/conversations");
2517
2518 /**
2519 * The {@code content://} style URL for this table, by phone number.
2520 */
2521 public static final Uri CONTENT_FILTER_BYPHONE_URI = Uri.parse(
2522 "content://mms-sms/messages/byphone");
2523
2524 /**
2525 * The {@code content://} style URL for undelivered messages in this table.
2526 */
2527 public static final Uri CONTENT_UNDELIVERED_URI = Uri.parse(
2528 "content://mms-sms/undelivered");
2529
2530 /**
2531 * The {@code content://} style URL for draft messages in this table.
2532 */
2533 public static final Uri CONTENT_DRAFT_URI = Uri.parse(
2534 "content://mms-sms/draft");
2535
2536 /**
2537 * The {@code content://} style URL for locked messages in this table.
2538 */
2539 public static final Uri CONTENT_LOCKED_URI = Uri.parse(
2540 "content://mms-sms/locked");
2541
2542 /**
2543 * Pass in a query parameter called "pattern" which is the text to search for.
2544 * The sort order is fixed to be: {@code thread_id ASC, date DESC}.
2545 */
2546 public static final Uri SEARCH_URI = Uri.parse(
2547 "content://mms-sms/search");
2548
2549 // Constants for message protocol types.
2550
2551 /** SMS protocol type. */
2552 public static final int SMS_PROTO = 0;
2553
2554 /** MMS protocol type. */
2555 public static final int MMS_PROTO = 1;
2556
2557 // Constants for error types of pending messages.
2558
2559 /** Error type: no error. */
2560 public static final int NO_ERROR = 0;
2561
2562 /** Error type: generic transient error. */
2563 public static final int ERR_TYPE_GENERIC = 1;
2564
2565 /** Error type: SMS protocol transient error. */
2566 public static final int ERR_TYPE_SMS_PROTO_TRANSIENT = 2;
2567
2568 /** Error type: MMS protocol transient error. */
2569 public static final int ERR_TYPE_MMS_PROTO_TRANSIENT = 3;
2570
2571 /** Error type: transport failure. */
2572 public static final int ERR_TYPE_TRANSPORT_FAILURE = 4;
2573
2574 /** Error type: permanent error (along with all higher error values). */
2575 public static final int ERR_TYPE_GENERIC_PERMANENT = 10;
2576
2577 /** Error type: SMS protocol permanent error. */
2578 public static final int ERR_TYPE_SMS_PROTO_PERMANENT = 11;
2579
2580 /** Error type: MMS protocol permanent error. */
2581 public static final int ERR_TYPE_MMS_PROTO_PERMANENT = 12;
2582
2583 /**
2584 * Contains pending messages info.
2585 */
2586 public static final class PendingMessages implements BaseColumns {
2587
2588 /**
2589 * Not instantiable.
2590 * @hide
2591 */
2592 private PendingMessages() {
2593 }
2594
2595 public static final Uri CONTENT_URI = Uri.withAppendedPath(
2596 MmsSms.CONTENT_URI, "pending");
2597
2598 /**
2599 * The type of transport protocol (MMS or SMS).
2600 * <P>Type: INTEGER</P>
2601 */
2602 public static final String PROTO_TYPE = "proto_type";
2603
2604 /**
2605 * The ID of the message to be sent or downloaded.
2606 * <P>Type: INTEGER (long)</P>
2607 */
2608 public static final String MSG_ID = "msg_id";
2609
2610 /**
2611 * The type of the message to be sent or downloaded.
2612 * This field is only valid for MM. For SM, its value is always set to 0.
2613 * <P>Type: INTEGER</P>
2614 */
2615 public static final String MSG_TYPE = "msg_type";
2616
2617 /**
2618 * The type of the error code.
2619 * <P>Type: INTEGER</P>
2620 */
2621 public static final String ERROR_TYPE = "err_type";
2622
2623 /**
2624 * The error code of sending/retrieving process.
2625 * <P>Type: INTEGER</P>
2626 */
2627 public static final String ERROR_CODE = "err_code";
2628
2629 /**
2630 * How many times we tried to send or download the message.
2631 * <P>Type: INTEGER</P>
2632 */
2633 public static final String RETRY_INDEX = "retry_index";
2634
2635 /**
2636 * The time to do next retry.
2637 * <P>Type: INTEGER (long)</P>
2638 */
2639 public static final String DUE_TIME = "due_time";
2640
2641 /**
2642 * The time we last tried to send or download the message.
2643 * <P>Type: INTEGER (long)</P>
2644 */
2645 public static final String LAST_TRY = "last_try";
2646
2647 /**
2648 * The subscription to which the message belongs to. Its value will be
2649 * < 0 if the sub id cannot be determined.
2650 * <p>Type: INTEGER (long) </p>
2651 */
2652 public static final String SUBSCRIPTION_ID = "pending_sub_id";
2653 }
2654
2655 /**
2656 * Words table used by provider for full-text searches.
2657 * @hide
2658 */
2659 public static final class WordsTable {
2660
2661 /**
2662 * Not instantiable.
2663 * @hide
2664 */
2665 private WordsTable() {}
2666
2667 /**
2668 * Primary key.
2669 * <P>Type: INTEGER (long)</P>
2670 */
2671 public static final String ID = "_id";
2672
2673 /**
2674 * Source row ID.
2675 * <P>Type: INTEGER (long)</P>
2676 */
2677 public static final String SOURCE_ROW_ID = "source_id";
2678
2679 /**
2680 * Table ID (either 1 or 2).
2681 * <P>Type: INTEGER</P>
2682 */
2683 public static final String TABLE_ID = "table_to_use";
2684
2685 /**
2686 * The words to index.
2687 * <P>Type: TEXT</P>
2688 */
2689 public static final String INDEXED_TEXT = "index_text";
2690 }
2691 }
2692
2693 /**
2694 * Carriers class contains information about APNs, including MMSC information.
2695 */
2696 public static final class Carriers implements BaseColumns {
2697
2698 /**
2699 * Not instantiable.
2700 * @hide
2701 */
2702 private Carriers() {}
2703
2704 /**
2705 * The {@code content://} style URL for this table.
2706 */
2707 public static final Uri CONTENT_URI = Uri.parse("content://telephony/carriers");
2708
2709 /**
yuemingw4c0065f2018-01-16 19:48:10 +00002710 * The {@code content://} style URL to be called from DevicePolicyManagerService,
2711 * can manage DPC-owned APNs.
2712 * @hide
2713 */
2714 public static final Uri DPC_URI = Uri.parse("content://telephony/carriers/dpc");
2715
2716 /**
2717 * The {@code content://} style URL to be called from Telephony to query APNs.
2718 * When DPC-owned APNs are enforced, only DPC-owned APNs are returned, otherwise only
2719 * non-DPC-owned APNs are returned.
2720 * @hide
2721 */
2722 public static final Uri FILTERED_URI = Uri.parse("content://telephony/carriers/filtered");
2723
2724 /**
2725 * The {@code content://} style URL to be called from DevicePolicyManagerService
2726 * or Telephony to manage whether DPC-owned APNs are enforced.
2727 * @hide
2728 */
2729 public static final Uri ENFORCE_MANAGED_URI = Uri.parse(
2730 "content://telephony/carriers/enforce_managed");
2731
2732 /**
2733 * The column name for ENFORCE_MANAGED_URI, indicates whether DPC-owned APNs are enforced.
2734 * @hide
2735 */
2736 public static final String ENFORCE_KEY = "enforced";
2737
2738 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08002739 * The default sort order for this table.
2740 */
2741 public static final String DEFAULT_SORT_ORDER = "name ASC";
2742
2743 /**
2744 * Entry name.
2745 * <P>Type: TEXT</P>
2746 */
2747 public static final String NAME = "name";
2748
2749 /**
2750 * APN name.
2751 * <P>Type: TEXT</P>
2752 */
2753 public static final String APN = "apn";
2754
2755 /**
2756 * Proxy address.
2757 * <P>Type: TEXT</P>
2758 */
2759 public static final String PROXY = "proxy";
2760
2761 /**
2762 * Proxy port.
2763 * <P>Type: TEXT</P>
2764 */
2765 public static final String PORT = "port";
2766
2767 /**
2768 * MMS proxy address.
2769 * <P>Type: TEXT</P>
2770 */
2771 public static final String MMSPROXY = "mmsproxy";
2772
2773 /**
2774 * MMS proxy port.
2775 * <P>Type: TEXT</P>
2776 */
2777 public static final String MMSPORT = "mmsport";
2778
2779 /**
2780 * Server address.
2781 * <P>Type: TEXT</P>
2782 */
2783 public static final String SERVER = "server";
2784
2785 /**
2786 * APN username.
2787 * <P>Type: TEXT</P>
2788 */
2789 public static final String USER = "user";
2790
2791 /**
2792 * APN password.
2793 * <P>Type: TEXT</P>
2794 */
2795 public static final String PASSWORD = "password";
2796
2797 /**
2798 * MMSC URL.
2799 * <P>Type: TEXT</P>
2800 */
2801 public static final String MMSC = "mmsc";
2802
2803 /**
2804 * Mobile Country Code (MCC).
2805 * <P>Type: TEXT</P>
2806 */
2807 public static final String MCC = "mcc";
2808
2809 /**
2810 * Mobile Network Code (MNC).
2811 * <P>Type: TEXT</P>
2812 */
2813 public static final String MNC = "mnc";
2814
2815 /**
2816 * Numeric operator ID (as String). Usually {@code MCC + MNC}.
2817 * <P>Type: TEXT</P>
2818 */
2819 public static final String NUMERIC = "numeric";
2820
2821 /**
2822 * Authentication type.
2823 * <P>Type: INTEGER</P>
2824 */
2825 public static final String AUTH_TYPE = "authtype";
2826
2827 /**
2828 * Comma-delimited list of APN types.
2829 * <P>Type: TEXT</P>
2830 */
2831 public static final String TYPE = "type";
2832
2833 /**
2834 * The protocol to use to connect to this APN.
2835 *
2836 * One of the {@code PDP_type} values in TS 27.007 section 10.1.1.
2837 * For example: {@code IP}, {@code IPV6}, {@code IPV4V6}, or {@code PPP}.
2838 * <P>Type: TEXT</P>
2839 */
2840 public static final String PROTOCOL = "protocol";
2841
2842 /**
2843 * The protocol to use to connect to this APN when roaming.
2844 * The syntax is the same as protocol.
2845 * <P>Type: TEXT</P>
2846 */
2847 public static final String ROAMING_PROTOCOL = "roaming_protocol";
2848
2849 /**
2850 * Is this the current APN?
2851 * <P>Type: INTEGER (boolean)</P>
2852 */
2853 public static final String CURRENT = "current";
2854
2855 /**
2856 * Is this APN enabled?
2857 * <P>Type: INTEGER (boolean)</P>
2858 */
2859 public static final String CARRIER_ENABLED = "carrier_enabled";
2860
2861 /**
2862 * Radio Access Technology info.
2863 * To check what values are allowed, refer to {@link android.telephony.ServiceState}.
2864 * This should be spread to other technologies,
2865 * but is currently only used for LTE (14) and eHRPD (13).
2866 * <P>Type: INTEGER</P>
Cassiee1c88022018-02-22 08:51:03 -08002867 * @deprecated this column is no longer supported, use {@link #NETWORK_TYPE_BITMASK} instead
Dan Willemsen4980bf42017-02-14 14:17:12 -08002868 */
Cassied53df962017-12-05 13:34:33 -08002869 @Deprecated
Dan Willemsen4980bf42017-02-14 14:17:12 -08002870 public static final String BEARER = "bearer";
2871
2872 /**
2873 * Radio Access Technology bitmask.
2874 * To check what values can be contained, refer to {@link android.telephony.ServiceState}.
2875 * 0 indicates all techs otherwise first bit refers to RAT/bearer 1, second bit refers to
2876 * RAT/bearer 2 and so on.
2877 * Bitmask for a radio tech R is (1 << (R - 1))
2878 * <P>Type: INTEGER</P>
2879 * @hide
Cassiee1c88022018-02-22 08:51:03 -08002880 * @deprecated this column is no longer supported, use {@link #NETWORK_TYPE_BITMASK} instead
Dan Willemsen4980bf42017-02-14 14:17:12 -08002881 */
Cassied53df962017-12-05 13:34:33 -08002882 @Deprecated
Dan Willemsen4980bf42017-02-14 14:17:12 -08002883 public static final String BEARER_BITMASK = "bearer_bitmask";
2884
2885 /**
Cassied53df962017-12-05 13:34:33 -08002886 * Radio technology (network type) bitmask.
Cassiee1c88022018-02-22 08:51:03 -08002887 * To check what values can be contained, refer to the NETWORK_TYPE_ constants in
Cassied53df962017-12-05 13:34:33 -08002888 * {@link android.telephony.TelephonyManager}.
2889 * Bitmask for a radio tech R is (1 << (R - 1))
2890 * <P>Type: INTEGER</P>
2891 */
2892 public static final String NETWORK_TYPE_BITMASK = "network_type_bitmask";
2893
2894 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08002895 * MVNO type:
2896 * {@code SPN (Service Provider Name), IMSI, GID (Group Identifier Level 1)}.
2897 * <P>Type: TEXT</P>
2898 */
2899 public static final String MVNO_TYPE = "mvno_type";
2900
2901 /**
2902 * MVNO data.
2903 * Use the following examples.
2904 * <ul>
2905 * <li>SPN: A MOBILE, BEN NL, ...</li>
2906 * <li>IMSI: 302720x94, 2060188, ...</li>
2907 * <li>GID: 4E, 33, ...</li>
2908 * </ul>
2909 * <P>Type: TEXT</P>
2910 */
2911 public static final String MVNO_MATCH_DATA = "mvno_match_data";
2912
2913 /**
2914 * The subscription to which the APN belongs to
2915 * <p>Type: INTEGER (long) </p>
2916 */
2917 public static final String SUBSCRIPTION_ID = "sub_id";
2918
2919 /**
chen xu85100482018-10-12 15:30:34 -07002920 * The profile_id to which the APN saved in modem.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002921 * <p>Type: INTEGER</p>
2922 *@hide
2923 */
2924 public static final String PROFILE_ID = "profile_id";
2925
2926 /**
chen xu85100482018-10-12 15:30:34 -07002927 * If set to {@code true}, then the APN setting will persist to the modem.
2928 * <p>Type: INTEGER (boolean)</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08002929 *@hide
2930 */
chen xu85100482018-10-12 15:30:34 -07002931 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002932 public static final String MODEM_COGNITIVE = "modem_cognitive";
2933
2934 /**
chen xu85100482018-10-12 15:30:34 -07002935 * The max connections of this APN.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002936 * <p>Type: INTEGER</p>
2937 *@hide
2938 */
chen xu85100482018-10-12 15:30:34 -07002939 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002940 public static final String MAX_CONNS = "max_conns";
2941
2942 /**
chen xu85100482018-10-12 15:30:34 -07002943 * The wait time for retry of the APN.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002944 * <p>Type: INTEGER</p>
2945 *@hide
2946 */
chen xu85100482018-10-12 15:30:34 -07002947 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002948 public static final String WAIT_TIME = "wait_time";
2949
2950 /**
chen xu85100482018-10-12 15:30:34 -07002951 * The time to limit max connection for the APN.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002952 * <p>Type: INTEGER</p>
2953 *@hide
2954 */
chen xu85100482018-10-12 15:30:34 -07002955 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002956 public static final String MAX_CONNS_TIME = "max_conns_time";
2957
2958 /**
chen xu85100482018-10-12 15:30:34 -07002959 * The MTU(Maxinum transmit unit) size of the mobile interface to which the APN connected.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002960 * <p>Type: INTEGER </p>
2961 * @hide
2962 */
chen xu85100482018-10-12 15:30:34 -07002963 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002964 public static final String MTU = "mtu";
2965
2966 /**
chen xu85100482018-10-12 15:30:34 -07002967 * APN edit status. APN could be added/edited/deleted by a user or carrier.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002968 * <p>Type: INTEGER </p>
2969 * @hide
2970 */
chen xu85100482018-10-12 15:30:34 -07002971 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002972 public static final String EDITED = "edited";
2973
2974 /**
chen xu85100482018-10-12 15:30:34 -07002975 * {@code true} if this APN visible to the user, {@code false} otherwise.
2976 * <p>Type: INTEGER (boolean)</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08002977 * @hide
2978 */
chen xu85100482018-10-12 15:30:34 -07002979 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002980 public static final String USER_VISIBLE = "user_visible";
2981
2982 /**
chen xu85100482018-10-12 15:30:34 -07002983 * {@code true} if the user allowed to edit this APN, {@code false} otherwise.
2984 * <p>Type: INTEGER (boolean)</p>
Amit Mahajand4977942017-07-17 14:46:39 -07002985 * @hide
2986 */
chen xu85100482018-10-12 15:30:34 -07002987 @SystemApi
Amit Mahajand4977942017-07-17 14:46:39 -07002988 public static final String USER_EDITABLE = "user_editable";
2989
2990 /**
chen xu85100482018-10-12 15:30:34 -07002991 * {@link #EDITED APN edit status} indicates that this APN has not been edited or fails to
2992 * edit.
2993 * <p>Type: INTEGER </p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08002994 * @hide
2995 */
chen xu85100482018-10-12 15:30:34 -07002996 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002997 public static final int UNEDITED = 0;
chen xu85100482018-10-12 15:30:34 -07002998
Dan Willemsen4980bf42017-02-14 14:17:12 -08002999 /**
chen xu85100482018-10-12 15:30:34 -07003000 * {@link #EDITED APN edit status} indicates that this APN has been edited by users.
3001 * <p>Type: INTEGER </p>
3002 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003003 */
chen xu85100482018-10-12 15:30:34 -07003004 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08003005 public static final int USER_EDITED = 1;
chen xu85100482018-10-12 15:30:34 -07003006
Dan Willemsen4980bf42017-02-14 14:17:12 -08003007 /**
chen xu85100482018-10-12 15:30:34 -07003008 * {@link #EDITED APN edit status} indicates that this APN has been deleted by users.
3009 * <p>Type: INTEGER </p>
3010 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003011 */
chen xu85100482018-10-12 15:30:34 -07003012 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08003013 public static final int USER_DELETED = 2;
chen xu85100482018-10-12 15:30:34 -07003014
Dan Willemsen4980bf42017-02-14 14:17:12 -08003015 /**
chen xu85100482018-10-12 15:30:34 -07003016 * {@link #EDITED APN edit status} is an intermediate value used to indicate that an entry
3017 * deleted by the user is still present in the new APN database and therefore must remain
3018 * tagged as user deleted rather than completely removed from the database.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003019 * @hide
3020 */
3021 public static final int USER_DELETED_BUT_PRESENT_IN_XML = 3;
chen xu85100482018-10-12 15:30:34 -07003022
Dan Willemsen4980bf42017-02-14 14:17:12 -08003023 /**
chen xu85100482018-10-12 15:30:34 -07003024 * {@link #EDITED APN edit status} indicates that this APN has been edited by carriers.
3025 * <p>Type: INTEGER </p>
3026 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003027 */
chen xu85100482018-10-12 15:30:34 -07003028 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08003029 public static final int CARRIER_EDITED = 4;
chen xu85100482018-10-12 15:30:34 -07003030
Dan Willemsen4980bf42017-02-14 14:17:12 -08003031 /**
chen xu85100482018-10-12 15:30:34 -07003032 * {@link #EDITED APN edit status} indicates that this APN has been deleted by carriers.
3033 * CARRIER_DELETED values are currently not used as there is no use case. If they are used,
Dan Willemsen4980bf42017-02-14 14:17:12 -08003034 * delete() will have to change accordingly. Currently it is hardcoded to USER_DELETED.
chen xu85100482018-10-12 15:30:34 -07003035 * <p>Type: INTEGER </p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003036 * @hide
3037 */
3038 public static final int CARRIER_DELETED = 5;
chen xu85100482018-10-12 15:30:34 -07003039
Dan Willemsen4980bf42017-02-14 14:17:12 -08003040 /**
chen xu85100482018-10-12 15:30:34 -07003041 * {@link #EDITED APN edit status} is an intermediate value used to indicate that an entry
3042 * deleted by the carrier is still present in the new APN database and therefore must remain
3043 * tagged as user deleted rather than completely removed from the database.
3044 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003045 */
3046 public static final int CARRIER_DELETED_BUT_PRESENT_IN_XML = 6;
yuemingwcf263eb2017-11-08 13:12:18 +00003047
3048 /**
3049 * The owner of the APN.
3050 * <p>Type: INTEGER</p>
3051 * @hide
3052 */
3053 public static final String OWNED_BY = "owned_by";
3054
3055 /**
3056 * Possible value for the OWNED_BY field.
3057 * APN is owned by DPC.
3058 * @hide
3059 */
3060 public static final int OWNED_BY_DPC = 0;
Jordan Liu40617152018-04-06 11:10:12 -07003061
yuemingwcf263eb2017-11-08 13:12:18 +00003062 /**
3063 * Possible value for the OWNED_BY field.
3064 * APN is owned by other sources.
3065 * @hide
3066 */
3067 public static final int OWNED_BY_OTHERS = 1;
Jordan Liu40617152018-04-06 11:10:12 -07003068
3069 /**
3070 * The APN set id. When the user manually selects an APN or the framework sets an APN as
3071 * preferred, all APNs with the same set id as the selected APN should be prioritized over
3072 * APNs in other sets.
chen xu85100482018-10-12 15:30:34 -07003073 * <p>Type: INTEGER</p>
Jordan Liu40617152018-04-06 11:10:12 -07003074 * @hide
3075 */
chen xu85100482018-10-12 15:30:34 -07003076 @SystemApi
Jordan Liu40617152018-04-06 11:10:12 -07003077 public static final String APN_SET_ID = "apn_set_id";
3078
3079 /**
chen xu85100482018-10-12 15:30:34 -07003080 * Possible value for the{@link #APN_SET_ID} field. By default APNs will not belong to a
3081 * set. If the user manually selects an APN with no set set, there is no need to prioritize
3082 * any specific APN set ids.
3083 * <p>Type: INTEGER</p>
Jordan Liu40617152018-04-06 11:10:12 -07003084 * @hide
3085 */
chen xu85100482018-10-12 15:30:34 -07003086 @SystemApi
Jordan Liu40617152018-04-06 11:10:12 -07003087 public static final int NO_SET_SET = 0;
3088
Dan Willemsen4980bf42017-02-14 14:17:12 -08003089 }
3090
3091 /**
3092 * Contains received SMS cell broadcast messages.
3093 * @hide
3094 */
3095 public static final class CellBroadcasts implements BaseColumns {
3096
3097 /**
3098 * Not instantiable.
3099 * @hide
3100 */
3101 private CellBroadcasts() {}
3102
3103 /**
3104 * The {@code content://} URI for this table.
3105 */
3106 public static final Uri CONTENT_URI = Uri.parse("content://cellbroadcasts");
3107
3108 /**
3109 * Message geographical scope.
3110 * <P>Type: INTEGER</P>
3111 */
3112 public static final String GEOGRAPHICAL_SCOPE = "geo_scope";
3113
3114 /**
3115 * Message serial number.
3116 * <P>Type: INTEGER</P>
3117 */
3118 public static final String SERIAL_NUMBER = "serial_number";
3119
3120 /**
3121 * PLMN of broadcast sender. {@code SERIAL_NUMBER + PLMN + LAC + CID} uniquely identifies
3122 * a broadcast for duplicate detection purposes.
3123 * <P>Type: TEXT</P>
3124 */
3125 public static final String PLMN = "plmn";
3126
3127 /**
3128 * Location Area (GSM) or Service Area (UMTS) of broadcast sender. Unused for CDMA.
3129 * Only included if Geographical Scope of message is not PLMN wide (01).
3130 * <P>Type: INTEGER</P>
3131 */
3132 public static final String LAC = "lac";
3133
3134 /**
3135 * Cell ID of message sender (GSM/UMTS). Unused for CDMA. Only included when the
3136 * Geographical Scope of message is cell wide (00 or 11).
3137 * <P>Type: INTEGER</P>
3138 */
3139 public static final String CID = "cid";
3140
3141 /**
3142 * Message code. <em>OBSOLETE: merged into SERIAL_NUMBER.</em>
3143 * <P>Type: INTEGER</P>
3144 */
3145 public static final String V1_MESSAGE_CODE = "message_code";
3146
3147 /**
3148 * Message identifier. <em>OBSOLETE: renamed to SERVICE_CATEGORY.</em>
3149 * <P>Type: INTEGER</P>
3150 */
3151 public static final String V1_MESSAGE_IDENTIFIER = "message_id";
3152
3153 /**
3154 * Service category (GSM/UMTS: message identifier; CDMA: service category).
3155 * <P>Type: INTEGER</P>
3156 */
3157 public static final String SERVICE_CATEGORY = "service_category";
3158
3159 /**
3160 * Message language code.
3161 * <P>Type: TEXT</P>
3162 */
3163 public static final String LANGUAGE_CODE = "language";
3164
3165 /**
3166 * Message body.
3167 * <P>Type: TEXT</P>
3168 */
3169 public static final String MESSAGE_BODY = "body";
3170
3171 /**
3172 * Message delivery time.
3173 * <P>Type: INTEGER (long)</P>
3174 */
3175 public static final String DELIVERY_TIME = "date";
3176
3177 /**
3178 * Has the message been viewed?
3179 * <P>Type: INTEGER (boolean)</P>
3180 */
3181 public static final String MESSAGE_READ = "read";
3182
3183 /**
3184 * Message format (3GPP or 3GPP2).
3185 * <P>Type: INTEGER</P>
3186 */
3187 public static final String MESSAGE_FORMAT = "format";
3188
3189 /**
3190 * Message priority (including emergency).
3191 * <P>Type: INTEGER</P>
3192 */
3193 public static final String MESSAGE_PRIORITY = "priority";
3194
3195 /**
3196 * ETWS warning type (ETWS alerts only).
3197 * <P>Type: INTEGER</P>
3198 */
3199 public static final String ETWS_WARNING_TYPE = "etws_warning_type";
3200
3201 /**
3202 * CMAS message class (CMAS alerts only).
3203 * <P>Type: INTEGER</P>
3204 */
3205 public static final String CMAS_MESSAGE_CLASS = "cmas_message_class";
3206
3207 /**
3208 * CMAS category (CMAS alerts only).
3209 * <P>Type: INTEGER</P>
3210 */
3211 public static final String CMAS_CATEGORY = "cmas_category";
3212
3213 /**
3214 * CMAS response type (CMAS alerts only).
3215 * <P>Type: INTEGER</P>
3216 */
3217 public static final String CMAS_RESPONSE_TYPE = "cmas_response_type";
3218
3219 /**
3220 * CMAS severity (CMAS alerts only).
3221 * <P>Type: INTEGER</P>
3222 */
3223 public static final String CMAS_SEVERITY = "cmas_severity";
3224
3225 /**
3226 * CMAS urgency (CMAS alerts only).
3227 * <P>Type: INTEGER</P>
3228 */
3229 public static final String CMAS_URGENCY = "cmas_urgency";
3230
3231 /**
3232 * CMAS certainty (CMAS alerts only).
3233 * <P>Type: INTEGER</P>
3234 */
3235 public static final String CMAS_CERTAINTY = "cmas_certainty";
3236
3237 /** The default sort order for this table. */
3238 public static final String DEFAULT_SORT_ORDER = DELIVERY_TIME + " DESC";
3239
3240 /**
3241 * Query columns for instantiating {@link android.telephony.CellBroadcastMessage} objects.
3242 */
3243 public static final String[] QUERY_COLUMNS = {
3244 _ID,
3245 GEOGRAPHICAL_SCOPE,
3246 PLMN,
3247 LAC,
3248 CID,
3249 SERIAL_NUMBER,
3250 SERVICE_CATEGORY,
3251 LANGUAGE_CODE,
3252 MESSAGE_BODY,
3253 DELIVERY_TIME,
3254 MESSAGE_READ,
3255 MESSAGE_FORMAT,
3256 MESSAGE_PRIORITY,
3257 ETWS_WARNING_TYPE,
3258 CMAS_MESSAGE_CLASS,
3259 CMAS_CATEGORY,
3260 CMAS_RESPONSE_TYPE,
3261 CMAS_SEVERITY,
3262 CMAS_URGENCY,
3263 CMAS_CERTAINTY
3264 };
3265 }
Jordan Liub9b75ed2017-02-28 18:15:07 -08003266
3267 /**
3268 * Constants for interfacing with the ServiceStateProvider and the different fields of the
3269 * {@link ServiceState} class accessible through the provider.
3270 */
3271 public static final class ServiceStateTable {
3272
3273 /**
3274 * Not instantiable.
3275 * @hide
3276 */
3277 private ServiceStateTable() {}
3278
3279 /**
3280 * The authority string for the ServiceStateProvider
3281 */
3282 public static final String AUTHORITY = "service-state";
3283
3284 /**
3285 * The {@code content://} style URL for the ServiceStateProvider
3286 */
3287 public static final Uri CONTENT_URI = Uri.parse("content://service-state/");
3288
3289 /**
3290 * Generates a content {@link Uri} used to receive updates on a specific field in the
3291 * ServiceState provider.
3292 * <p>
3293 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
3294 * {@link ServiceState} while your app is running. You can also use a {@link JobService} to
3295 * ensure your app is notified of changes to the {@link Uri} even when it is not running.
3296 * Note, however, that using a {@link JobService} does not guarantee timely delivery of
3297 * updates to the {@link Uri}.
3298 *
Jordan Liu0f332522017-04-19 14:25:29 -07003299 * @param subscriptionId the subscriptionId to receive updates on
Jordan Liub9b75ed2017-02-28 18:15:07 -08003300 * @param field the ServiceState field to receive updates on
3301 * @return the Uri used to observe {@link ServiceState} changes
3302 */
Jordan Liu0f332522017-04-19 14:25:29 -07003303 public static Uri getUriForSubscriptionIdAndField(int subscriptionId, String field) {
3304 return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId))
Jordan Liub9b75ed2017-02-28 18:15:07 -08003305 .appendEncodedPath(field).build();
3306 }
3307
3308 /**
3309 * Generates a content {@link Uri} used to receive updates on every field in the
3310 * ServiceState provider.
3311 * <p>
3312 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
3313 * {@link ServiceState} while your app is running. You can also use a {@link JobService} to
3314 * ensure your app is notified of changes to the {@link Uri} even when it is not running.
3315 * Note, however, that using a {@link JobService} does not guarantee timely delivery of
3316 * updates to the {@link Uri}.
3317 *
Jordan Liu0f332522017-04-19 14:25:29 -07003318 * @param subscriptionId the subscriptionId to receive updates on
Jordan Liub9b75ed2017-02-28 18:15:07 -08003319 * @return the Uri used to observe {@link ServiceState} changes
3320 */
Jordan Liu0f332522017-04-19 14:25:29 -07003321 public static Uri getUriForSubscriptionId(int subscriptionId) {
3322 return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId)).build();
Jordan Liub9b75ed2017-02-28 18:15:07 -08003323 }
3324
3325 /**
3326 * Used to insert a ServiceState into the ServiceStateProvider as a ContentValues instance.
3327 *
3328 * @param state the ServiceState to convert into ContentValues
3329 * @return the convertedContentValues instance
3330 * @hide
3331 */
3332 public static ContentValues getContentValuesForServiceState(ServiceState state) {
3333 ContentValues values = new ContentValues();
3334 values.put(VOICE_REG_STATE, state.getVoiceRegState());
3335 values.put(DATA_REG_STATE, state.getDataRegState());
3336 values.put(VOICE_ROAMING_TYPE, state.getVoiceRoamingType());
3337 values.put(DATA_ROAMING_TYPE, state.getDataRoamingType());
3338 values.put(VOICE_OPERATOR_ALPHA_LONG, state.getVoiceOperatorAlphaLong());
3339 values.put(VOICE_OPERATOR_ALPHA_SHORT, state.getVoiceOperatorAlphaShort());
3340 values.put(VOICE_OPERATOR_NUMERIC, state.getVoiceOperatorNumeric());
3341 values.put(DATA_OPERATOR_ALPHA_LONG, state.getDataOperatorAlphaLong());
3342 values.put(DATA_OPERATOR_ALPHA_SHORT, state.getDataOperatorAlphaShort());
3343 values.put(DATA_OPERATOR_NUMERIC, state.getDataOperatorNumeric());
3344 values.put(IS_MANUAL_NETWORK_SELECTION, state.getIsManualSelection());
3345 values.put(RIL_VOICE_RADIO_TECHNOLOGY, state.getRilVoiceRadioTechnology());
3346 values.put(RIL_DATA_RADIO_TECHNOLOGY, state.getRilDataRadioTechnology());
3347 values.put(CSS_INDICATOR, state.getCssIndicator());
Jack Yu2661fac2018-03-15 13:51:05 -07003348 values.put(NETWORK_ID, state.getCdmaNetworkId());
3349 values.put(SYSTEM_ID, state.getCdmaSystemId());
Jordan Liub9b75ed2017-02-28 18:15:07 -08003350 values.put(CDMA_ROAMING_INDICATOR, state.getCdmaRoamingIndicator());
3351 values.put(CDMA_DEFAULT_ROAMING_INDICATOR, state.getCdmaDefaultRoamingIndicator());
3352 values.put(CDMA_ERI_ICON_INDEX, state.getCdmaEriIconIndex());
3353 values.put(CDMA_ERI_ICON_MODE, state.getCdmaEriIconMode());
3354 values.put(IS_EMERGENCY_ONLY, state.isEmergencyOnly());
Jordan Liub9b75ed2017-02-28 18:15:07 -08003355 values.put(IS_USING_CARRIER_AGGREGATION, state.isUsingCarrierAggregation());
3356 return values;
3357 }
3358
3359 /**
3360 * An integer value indicating the current voice service state.
3361 * <p>
3362 * Valid values: {@link ServiceState#STATE_IN_SERVICE},
3363 * {@link ServiceState#STATE_OUT_OF_SERVICE}, {@link ServiceState#STATE_EMERGENCY_ONLY},
3364 * {@link ServiceState#STATE_POWER_OFF}.
3365 * <p>
3366 * This is the same as {@link ServiceState#getState()}.
3367 */
3368 public static final String VOICE_REG_STATE = "voice_reg_state";
3369
3370 /**
3371 * An integer value indicating the current data service state.
3372 * <p>
3373 * Valid values: {@link ServiceState#STATE_IN_SERVICE},
3374 * {@link ServiceState#STATE_OUT_OF_SERVICE}, {@link ServiceState#STATE_EMERGENCY_ONLY},
3375 * {@link ServiceState#STATE_POWER_OFF}.
3376 * <p>
3377 * This is the same as {@link ServiceState#getDataRegState()}.
3378 * @hide
3379 */
3380 public static final String DATA_REG_STATE = "data_reg_state";
3381
3382 /**
3383 * An integer value indicating the current voice roaming type.
3384 * <p>
3385 * This is the same as {@link ServiceState#getVoiceRoamingType()}.
3386 * @hide
3387 */
3388 public static final String VOICE_ROAMING_TYPE = "voice_roaming_type";
3389
3390 /**
3391 * An integer value indicating the current data roaming type.
3392 * <p>
3393 * This is the same as {@link ServiceState#getDataRoamingType()}.
3394 * @hide
3395 */
3396 public static final String DATA_ROAMING_TYPE = "data_roaming_type";
3397
3398 /**
3399 * The current registered voice network operator name in long alphanumeric format.
3400 * <p>
3401 * This is the same as {@link ServiceState#getVoiceOperatorAlphaLong()}.
3402 * @hide
3403 */
3404 public static final String VOICE_OPERATOR_ALPHA_LONG = "voice_operator_alpha_long";
3405
3406 /**
3407 * The current registered operator name in short alphanumeric format.
3408 * <p>
3409 * In GSM/UMTS, short format can be up to 8 characters long. The current registered voice
3410 * network operator name in long alphanumeric format.
3411 * <p>
3412 * This is the same as {@link ServiceState#getVoiceOperatorAlphaShort()}.
3413 * @hide
3414 */
3415 public static final String VOICE_OPERATOR_ALPHA_SHORT = "voice_operator_alpha_short";
3416
3417
3418 /**
3419 * The current registered operator numeric id.
3420 * <p>
3421 * In GSM/UMTS, numeric format is 3 digit country code plus 2 or 3 digit
3422 * network code.
3423 * <p>
3424 * This is the same as {@link ServiceState#getOperatorNumeric()}.
3425 */
3426 public static final String VOICE_OPERATOR_NUMERIC = "voice_operator_numeric";
3427
3428 /**
3429 * The current registered data network operator name in long alphanumeric format.
3430 * <p>
3431 * This is the same as {@link ServiceState#getDataOperatorAlphaLong()}.
3432 * @hide
3433 */
3434 public static final String DATA_OPERATOR_ALPHA_LONG = "data_operator_alpha_long";
3435
3436 /**
3437 * The current registered data network operator name in short alphanumeric format.
3438 * <p>
3439 * This is the same as {@link ServiceState#getDataOperatorAlphaShort()}.
3440 * @hide
3441 */
3442 public static final String DATA_OPERATOR_ALPHA_SHORT = "data_operator_alpha_short";
3443
3444 /**
3445 * The current registered data network operator numeric id.
3446 * <p>
3447 * This is the same as {@link ServiceState#getDataOperatorNumeric()}.
3448 * @hide
3449 */
3450 public static final String DATA_OPERATOR_NUMERIC = "data_operator_numeric";
3451
3452 /**
3453 * The current network selection mode.
3454 * <p>
3455 * This is the same as {@link ServiceState#getIsManualSelection()}.
3456 */
3457 public static final String IS_MANUAL_NETWORK_SELECTION = "is_manual_network_selection";
3458
3459 /**
3460 * This is the same as {@link ServiceState#getRilVoiceRadioTechnology()}.
3461 * @hide
3462 */
3463 public static final String RIL_VOICE_RADIO_TECHNOLOGY = "ril_voice_radio_technology";
3464
3465 /**
3466 * This is the same as {@link ServiceState#getRilDataRadioTechnology()}.
3467 * @hide
3468 */
3469 public static final String RIL_DATA_RADIO_TECHNOLOGY = "ril_data_radio_technology";
3470
3471 /**
3472 * This is the same as {@link ServiceState#getCssIndicator()}.
3473 * @hide
3474 */
3475 public static final String CSS_INDICATOR = "css_indicator";
3476
3477 /**
Jack Yu2661fac2018-03-15 13:51:05 -07003478 * This is the same as {@link ServiceState#getCdmaNetworkId()}.
Jordan Liub9b75ed2017-02-28 18:15:07 -08003479 * @hide
3480 */
3481 public static final String NETWORK_ID = "network_id";
3482
3483 /**
Jack Yu2661fac2018-03-15 13:51:05 -07003484 * This is the same as {@link ServiceState#getCdmaSystemId()}.
Jordan Liub9b75ed2017-02-28 18:15:07 -08003485 * @hide
3486 */
3487 public static final String SYSTEM_ID = "system_id";
3488
3489 /**
3490 * This is the same as {@link ServiceState#getCdmaRoamingIndicator()}.
3491 * @hide
3492 */
3493 public static final String CDMA_ROAMING_INDICATOR = "cdma_roaming_indicator";
3494
3495 /**
3496 * This is the same as {@link ServiceState#getCdmaDefaultRoamingIndicator()}.
3497 * @hide
3498 */
3499 public static final String CDMA_DEFAULT_ROAMING_INDICATOR =
3500 "cdma_default_roaming_indicator";
3501
3502 /**
3503 * This is the same as {@link ServiceState#getCdmaEriIconIndex()}.
3504 * @hide
3505 */
3506 public static final String CDMA_ERI_ICON_INDEX = "cdma_eri_icon_index";
3507
3508 /**
3509 * This is the same as {@link ServiceState#getCdmaEriIconMode()}.
3510 * @hide
3511 */
3512 public static final String CDMA_ERI_ICON_MODE = "cdma_eri_icon_mode";
3513
3514 /**
3515 * This is the same as {@link ServiceState#isEmergencyOnly()}.
3516 * @hide
3517 */
3518 public static final String IS_EMERGENCY_ONLY = "is_emergency_only";
3519
3520 /**
3521 * This is the same as {@link ServiceState#getDataRoamingFromRegistration()}.
3522 * @hide
3523 */
3524 public static final String IS_DATA_ROAMING_FROM_REGISTRATION =
3525 "is_data_roaming_from_registration";
3526
3527 /**
3528 * This is the same as {@link ServiceState#isUsingCarrierAggregation()}.
3529 * @hide
3530 */
3531 public static final String IS_USING_CARRIER_AGGREGATION = "is_using_carrier_aggregation";
3532 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07003533
3534 /**
fionaxu58278be2018-01-29 14:08:12 -08003535 * Contains carrier identification information for the current subscriptions.
fionaxu3d0ad1f2017-10-25 23:09:36 -07003536 */
fionaxu62bc7472018-02-28 11:18:45 -08003537 public static final class CarrierId implements BaseColumns {
fionaxu3d0ad1f2017-10-25 23:09:36 -07003538 /**
fionaxu58278be2018-01-29 14:08:12 -08003539 * Not instantiable.
3540 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07003541 */
fionaxu62bc7472018-02-28 11:18:45 -08003542 private CarrierId() {}
fionaxu3d0ad1f2017-10-25 23:09:36 -07003543
3544 /**
fionaxu58278be2018-01-29 14:08:12 -08003545 * The {@code content://} style URI for this provider.
fionaxu3d0ad1f2017-10-25 23:09:36 -07003546 */
fionaxu62bc7472018-02-28 11:18:45 -08003547 public static final Uri CONTENT_URI = Uri.parse("content://carrier_id");
fionaxu3d0ad1f2017-10-25 23:09:36 -07003548
3549 /**
fionaxu62bc7472018-02-28 11:18:45 -08003550 * The authority string for the CarrierId Provider
fionaxu58278be2018-01-29 14:08:12 -08003551 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07003552 */
fionaxu62bc7472018-02-28 11:18:45 -08003553 public static final String AUTHORITY = "carrier_id";
fionaxu58278be2018-01-29 14:08:12 -08003554
fionaxu3d0ad1f2017-10-25 23:09:36 -07003555
3556 /**
fionaxu58278be2018-01-29 14:08:12 -08003557 * Generates a content {@link Uri} used to receive updates on carrier identity change
3558 * on the given subscriptionId
3559 * <p>
3560 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
fionaxuc8d483e2018-03-07 21:52:05 -08003561 * carrier identity {@link TelephonyManager#getSimCarrierId()}
fionaxu58278be2018-01-29 14:08:12 -08003562 * while your app is running. You can also use a {@link JobService} to ensure your app
3563 * is notified of changes to the {@link Uri} even when it is not running.
3564 * Note, however, that using a {@link JobService} does not guarantee timely delivery of
3565 * updates to the {@link Uri}.
3566 *
3567 * @param subscriptionId the subscriptionId to receive updates on
3568 * @return the Uri used to observe carrier identity changes
fionaxu3d0ad1f2017-10-25 23:09:36 -07003569 */
fionaxu58278be2018-01-29 14:08:12 -08003570 public static Uri getUriForSubscriptionId(int subscriptionId) {
3571 return CONTENT_URI.buildUpon().appendEncodedPath(
3572 String.valueOf(subscriptionId)).build();
3573 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07003574
3575 /**
fionaxu58278be2018-01-29 14:08:12 -08003576 * A user facing carrier name.
fionaxuc8d483e2018-03-07 21:52:05 -08003577 * @see TelephonyManager#getSimCarrierIdName()
fionaxu3d0ad1f2017-10-25 23:09:36 -07003578 * <P>Type: TEXT </P>
3579 */
fionaxu62bc7472018-02-28 11:18:45 -08003580 public static final String CARRIER_NAME = "carrier_name";
fionaxu3d0ad1f2017-10-25 23:09:36 -07003581
3582 /**
3583 * A unique carrier id
fionaxuc8d483e2018-03-07 21:52:05 -08003584 * @see TelephonyManager#getSimCarrierId()
fionaxu3d0ad1f2017-10-25 23:09:36 -07003585 * <P>Type: INTEGER </P>
3586 */
fionaxu62bc7472018-02-28 11:18:45 -08003587 public static final String CARRIER_ID = "carrier_id";
fionaxu3d0ad1f2017-10-25 23:09:36 -07003588
3589 /**
chen xu2e801e02018-10-16 11:55:26 -07003590 * A unique mno carrier id. mno carrier shares the same {@link All#MCCMNC} as carrier id
3591 * and can be solely identified by {@link All#MCCMNC} only. If there is no such mno
3592 * carrier, then mno carrier id equals to {@link #CARRIER_ID carrier id}.
3593 *
3594 * <p>mno carrier id can be used as fallback id. When the exact carrier id configurations
3595 * are not found, usually fall back to its mno carrier id.
3596 * <P>Type: INTEGER </P>
3597 * @hide
3598 */
3599 public static final String MNO_CARRIER_ID = "mno_carrier_id";
3600
3601 /**
fionaxu58278be2018-01-29 14:08:12 -08003602 * Contains mappings between matching rules with carrier id for all carriers.
3603 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07003604 */
fionaxu58278be2018-01-29 14:08:12 -08003605 public static final class All implements BaseColumns {
3606 /**
3607 * Numeric operator ID (as String). {@code MCC + MNC}
3608 * <P>Type: TEXT </P>
3609 */
3610 public static final String MCCMNC = "mccmnc";
3611
3612 /**
3613 * Group id level 1 (as String).
3614 * <P>Type: TEXT </P>
3615 */
3616 public static final String GID1 = "gid1";
3617
3618 /**
3619 * Group id level 2 (as String).
3620 * <P>Type: TEXT </P>
3621 */
3622 public static final String GID2 = "gid2";
3623
3624 /**
3625 * Public Land Mobile Network name.
3626 * <P>Type: TEXT </P>
3627 */
3628 public static final String PLMN = "plmn";
3629
3630 /**
3631 * Prefix xpattern of IMSI (International Mobile Subscriber Identity).
3632 * <P>Type: TEXT </P>
3633 */
3634 public static final String IMSI_PREFIX_XPATTERN = "imsi_prefix_xpattern";
3635
3636 /**
3637 * Service Provider Name.
3638 * <P>Type: TEXT </P>
3639 */
3640 public static final String SPN = "spn";
3641
3642 /**
3643 * Prefer APN name.
3644 * <P>Type: TEXT </P>
3645 */
3646 public static final String APN = "apn";
3647
3648 /**
3649 * Prefix of Integrated Circuit Card Identifier.
3650 * <P>Type: TEXT </P>
3651 */
3652 public static final String ICCID_PREFIX = "iccid_prefix";
3653
3654 /**
fionaxuf9583572018-06-08 16:55:25 -07003655 * Certificate for carrier privilege access rules.
3656 * <P>Type: TEXT in hex string </P>
3657 */
3658 public static final String PRIVILEGE_ACCESS_RULE = "privilege_access_rule";
3659
3660 /**
fionaxu58278be2018-01-29 14:08:12 -08003661 * The {@code content://} URI for this table.
3662 */
fionaxu62bc7472018-02-28 11:18:45 -08003663 public static final Uri CONTENT_URI = Uri.parse("content://carrier_id/all");
fionaxu58278be2018-01-29 14:08:12 -08003664 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07003665 }
Dan Willemsen4980bf42017-02-14 14:17:12 -08003666}