• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 package android.provider;
18 
19 import android.Manifest;
20 import android.annotation.FlaggedApi;
21 import android.annotation.IntDef;
22 import android.annotation.NonNull;
23 import android.annotation.RequiresPermission;
24 import android.annotation.SdkConstant;
25 import android.annotation.SdkConstant.SdkConstantType;
26 import android.annotation.SystemApi;
27 import android.annotation.TestApi;
28 import android.compat.annotation.ChangeId;
29 import android.compat.annotation.EnabledAfter;
30 import android.compat.annotation.UnsupportedAppUsage;
31 import android.content.ComponentName;
32 import android.content.ContentResolver;
33 import android.content.ContentValues;
34 import android.content.Context;
35 import android.content.Intent;
36 import android.database.ContentObserver;
37 import android.database.Cursor;
38 import android.database.sqlite.SqliteWrapper;
39 import android.net.Uri;
40 import android.os.Build;
41 import android.os.Bundle;
42 import android.telephony.CarrierConfigManager;
43 import android.telephony.Rlog;
44 import android.telephony.ServiceState;
45 import android.telephony.SmsMessage;
46 import android.telephony.SubscriptionManager;
47 import android.telephony.TelephonyManager;
48 import android.telephony.UiccAccessRule;
49 import android.text.TextUtils;
50 import android.util.Patterns;
51 
52 import com.android.internal.telephony.SmsApplication;
53 import com.android.internal.telephony.flags.Flags;
54 
55 import java.lang.annotation.Retention;
56 import java.lang.annotation.RetentionPolicy;
57 import java.util.HashSet;
58 import java.util.List;
59 import java.util.Set;
60 import java.util.regex.Matcher;
61 import java.util.regex.Pattern;
62 
63 /**
64  * The Telephony provider contains data related to phone operation, specifically SMS and MMS
65  * messages, access to the APN list, including the MMSC to use, and the service state.
66  *
67  * <p class="note"><strong>Note:</strong> These APIs are not available on all Android-powered
68  * devices. If your app depends on telephony features such as for managing SMS messages, include
69  * a <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code <uses-feature>}
70  * </a> element in your manifest that declares the {@code "android.hardware.telephony"} hardware
71  * feature. Alternatively, you can check for telephony availability at runtime using either
72  * {@link android.content.pm.PackageManager#hasSystemFeature
73  * hasSystemFeature(PackageManager.FEATURE_TELEPHONY)} or {@link
74  * android.telephony.TelephonyManager#getPhoneType}.</p>
75  *
76  * <h3>Creating an SMS app</h3>
77  *
78  * <p>Only the default SMS app (selected by the user in system settings) is able to write to the
79  * SMS Provider (the tables defined within the {@code Telephony} class) and only the default SMS
80  * app receives the {@link android.provider.Telephony.Sms.Intents#SMS_DELIVER_ACTION} broadcast
81  * when the user receives an SMS or the {@link
82  * android.provider.Telephony.Sms.Intents#WAP_PUSH_DELIVER_ACTION} broadcast when the user
83  * receives an MMS.</p>
84  *
85  * <p>Any app that wants to behave as the user's default SMS app must handle the following intents:
86  * <ul>
87  * <li>In a broadcast receiver, include an intent filter for {@link Sms.Intents#SMS_DELIVER_ACTION}
88  * (<code>"android.provider.Telephony.SMS_DELIVER"</code>). The broadcast receiver must also
89  * require the {@link android.Manifest.permission#BROADCAST_SMS} permission.
90  * <p>This allows your app to directly receive incoming SMS messages.</p></li>
91  * <li>In a broadcast receiver, include an intent filter for {@link
92  * Sms.Intents#WAP_PUSH_DELIVER_ACTION}} ({@code "android.provider.Telephony.WAP_PUSH_DELIVER"})
93  * with the MIME type <code>"application/vnd.wap.mms-message"</code>.
94  * The broadcast receiver must also require the {@link
95  * android.Manifest.permission#BROADCAST_WAP_PUSH} permission.
96  * <p>This allows your app to directly receive incoming MMS messages.</p></li>
97  * <li>In your activity that delivers new messages, include an intent filter for
98  * {@link android.content.Intent#ACTION_SENDTO} (<code>"android.intent.action.SENDTO"
99  * </code>) with schemas, <code>sms:</code>, <code>smsto:</code>, <code>mms:</code>, and
100  * <code>mmsto:</code>.
101  * <p>This allows your app to receive intents from other apps that want to deliver a
102  * message.</p></li>
103  * <li>In a service, include an intent filter for {@link
104  * android.telephony.TelephonyManager#ACTION_RESPOND_VIA_MESSAGE}
105  * (<code>"android.intent.action.RESPOND_VIA_MESSAGE"</code>) with schemas,
106  * <code>sms:</code>, <code>smsto:</code>, <code>mms:</code>, and <code>mmsto:</code>.
107  * This service must also require the {@link
108  * android.Manifest.permission#SEND_RESPOND_VIA_MESSAGE} permission.
109  * <p>This allows users to respond to incoming phone calls with an immediate text message
110  * using your app.</p></li>
111  * </ul>
112  *
113  * <p>Other apps that are not selected as the default SMS app can only <em>read</em> the SMS
114  * Provider, but may also be notified when a new SMS arrives by listening for the {@link
115  * Sms.Intents#SMS_RECEIVED_ACTION}
116  * broadcast, which is a non-abortable broadcast that may be delivered to multiple apps. This
117  * broadcast is intended for apps that&mdash;while not selected as the default SMS app&mdash;need to
118  * read special incoming messages such as to perform phone number verification.</p>
119  *
120  * <p>For more information about building SMS apps, read the blog post, <a
121  * href="http://android-developers.blogspot.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html"
122  * >Getting Your SMS Apps Ready for KitKat</a>.</p>
123  *
124  */
125 public final class Telephony {
126     private static final String TAG = "Telephony";
127 
128     /**
129      * Not instantiable.
130      * @hide
131      */
Telephony()132     private Telephony() {
133     }
134 
135     /**
136      * Base columns for tables that contain text-based SMSs.
137      */
138     public interface TextBasedSmsColumns {
139 
140         /** Message type: all messages. */
141         public static final int MESSAGE_TYPE_ALL    = 0;
142 
143         /** Message type: inbox. */
144         public static final int MESSAGE_TYPE_INBOX  = 1;
145 
146         /** Message type: sent messages. */
147         public static final int MESSAGE_TYPE_SENT   = 2;
148 
149         /** Message type: drafts. */
150         public static final int MESSAGE_TYPE_DRAFT  = 3;
151 
152         /** Message type: outbox. */
153         public static final int MESSAGE_TYPE_OUTBOX = 4;
154 
155         /** Message type: failed outgoing message. */
156         public static final int MESSAGE_TYPE_FAILED = 5;
157 
158         /** Message type: queued to send later. */
159         public static final int MESSAGE_TYPE_QUEUED = 6;
160 
161         /**
162          * The type of message.
163          * <P>Type: INTEGER</P>
164          */
165         public static final String TYPE = "type";
166 
167         /**
168          * The thread ID of the message.
169          * <P>Type: INTEGER</P>
170          */
171         public static final String THREAD_ID = "thread_id";
172 
173         /**
174          * The address of the other party.
175          * <P>Type: TEXT</P>
176          */
177         public static final String ADDRESS = "address";
178 
179         /**
180          * The date the message was received.
181          * <P>Type: INTEGER (long)</P>
182          */
183         public static final String DATE = "date";
184 
185         /**
186          * The date the message was sent.
187          * <P>Type: INTEGER (long)</P>
188          */
189         public static final String DATE_SENT = "date_sent";
190 
191         /**
192          * Has the message been read?
193          * <P>Type: INTEGER (boolean)</P>
194          */
195         public static final String READ = "read";
196 
197         /**
198          * Has the message been seen by the user? The "seen" flag determines
199          * whether we need to show a notification.
200          * <P>Type: INTEGER (boolean)</P>
201          */
202         public static final String SEEN = "seen";
203 
204         /**
205          * {@code TP-Status} value for the message, or -1 if no status has been received.
206          * <P>Type: INTEGER</P>
207          */
208         public static final String STATUS = "status";
209 
210         /** TP-Status: no status received. */
211         public static final int STATUS_NONE = -1;
212         /** TP-Status: complete. */
213         public static final int STATUS_COMPLETE = 0;
214         /** TP-Status: pending. */
215         public static final int STATUS_PENDING = 32;
216         /** TP-Status: failed. */
217         public static final int STATUS_FAILED = 64;
218 
219         /**
220          * The subject of the message, if present.
221          * <P>Type: TEXT</P>
222          */
223         public static final String SUBJECT = "subject";
224 
225         /**
226          * The body of the message.
227          * <P>Type: TEXT</P>
228          */
229         public static final String BODY = "body";
230 
231         /**
232          * The ID of the sender of the conversation, if present.
233          * <P>Type: INTEGER (reference to item in {@code content://contacts/people})</P>
234          */
235         public static final String PERSON = "person";
236 
237         /**
238          * The protocol identifier code.
239          * <P>Type: INTEGER</P>
240          */
241         public static final String PROTOCOL = "protocol";
242 
243         /**
244          * Is the {@code TP-Reply-Path} flag set?
245          * <P>Type: BOOLEAN</P>
246          */
247         public static final String REPLY_PATH_PRESENT = "reply_path_present";
248 
249         /**
250          * The service center (SC) through which to send the message, if present.
251          * <P>Type: TEXT</P>
252          */
253         public static final String SERVICE_CENTER = "service_center";
254 
255         /**
256          * Is the message locked?
257          * <P>Type: INTEGER (boolean)</P>
258          */
259         public static final String LOCKED = "locked";
260 
261         /**
262          * The subscription to which the message belongs to. Its value will be
263          * < 0 if the sub id cannot be determined.
264          * <p>Type: INTEGER (long) </p>
265          */
266         public static final String SUBSCRIPTION_ID = "sub_id";
267 
268         /**
269          * The MTU size of the mobile interface to which the APN connected
270          * @hide
271          */
272         public static final String MTU = "mtu";
273 
274         /**
275          * Error code associated with sending or receiving this message
276          * <P>Type: INTEGER</P>
277          */
278         public static final String ERROR_CODE = "error_code";
279 
280         /**
281          * The identity of the sender of a sent message. It is
282          * usually the package name of the app which sends the message.
283          * <p class="note"><strong>Note:</strong>
284          * This column is read-only. It is set by the provider and can not be changed by apps.
285          * <p>Type: TEXT</p>
286          */
287         public static final String CREATOR = "creator";
288     }
289 
290     /**
291      * Columns in sms_changes table.
292      * @hide
293      */
294     public interface TextBasedSmsChangesColumns {
295         /**
296          * The {@code content://} style URL for this table.
297          * @hide
298          */
299         public static final Uri CONTENT_URI = Uri.parse("content://sms-changes");
300 
301         /**
302          * Primary key.
303          * <P>Type: INTEGER (long)</P>
304          * @hide
305          */
306         public static final String ID = "_id";
307 
308         /**
309          * Triggers on sms table create a row in this table for each update/delete.
310          * This column is the "_id" of the row from sms table that was updated/deleted.
311          * <P>Type: INTEGER (long)</P>
312          * @hide
313          */
314         public static final String ORIG_ROW_ID = "orig_rowid";
315 
316         /**
317          * Triggers on sms table create a row in this table for each update/delete.
318          * This column is the "sub_id" of the row from sms table that was updated/deleted.
319          * @hide
320          * <P>Type: INTEGER (long)</P>
321          */
322         public static final String SUB_ID = "sub_id";
323 
324         /**
325          * The type of operation that created this row.
326          *    {@link #TYPE_UPDATE} = update op
327          *    {@link #TYPE_DELETE} = delete op
328          * @hide
329          * <P>Type: INTEGER (long)</P>
330          */
331         public static final String TYPE = "type";
332 
333         /**
334          * One of the possible values for the above column "type". Indicates it is an update op.
335          * @hide
336          */
337         public static final int TYPE_UPDATE = 0;
338 
339         /**
340          * One of the possible values for the above column "type". Indicates it is a delete op.
341          * @hide
342          */
343         public static final int TYPE_DELETE = 1;
344 
345         /**
346          * This column contains a non-null value only if the operation on sms table is an update op
347          * and the column "read" is changed by the update op.
348          * <P>Type: INTEGER (boolean)</P>
349          * @hide
350          */
351         public static final String NEW_READ_STATUS = "new_read_status";
352     }
353 
354     /**
355      * Contains all text-based SMS messages.
356      */
357     public static final class Sms implements BaseColumns, TextBasedSmsColumns {
358 
359         /**
360          * Not instantiable.
361          * @hide
362          */
Sms()363         private Sms() {
364         }
365 
366         /**
367          * Used to determine the currently configured default SMS package.
368          * <p>
369          * As of Android 11 apps will need specific permission to query other packages. To use
370          * this method an app must include in their AndroidManifest:
371          * <pre>{@code
372          * <queries>
373          *   <intent>
374          *     <action android:name="android.provider.Telephony.SMS_DELIVER"/>
375          *   </intent>
376          * </queries>
377          * }</pre>
378          * Which will allow them to query packages which declare intent filters that include
379          * the {@link android.provider.Telephony.Sms.Intents#SMS_DELIVER_ACTION} intent.
380          * </p>
381          *
382          * @param context context of the requesting application
383          * @return package name for the default SMS package or null
384          */
getDefaultSmsPackage(Context context)385         public static String getDefaultSmsPackage(Context context) {
386             ComponentName component = SmsApplication.getDefaultSmsApplication(context, false);
387             if (component != null) {
388                 return component.getPackageName();
389             }
390             return null;
391         }
392 
393         /**
394          * Return cursor for table query.
395          * @hide
396          */
query(ContentResolver cr, String[] projection)397         public static Cursor query(ContentResolver cr, String[] projection) {
398             return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
399         }
400 
401         /**
402          * Return cursor for table query.
403          * @hide
404          */
405         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
query(ContentResolver cr, String[] projection, String where, String orderBy)406         public static Cursor query(ContentResolver cr, String[] projection,
407                 String where, String orderBy) {
408             return cr.query(CONTENT_URI, projection, where,
409                     null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
410         }
411 
412         /**
413          * The {@code content://} style URL for this table.
414          */
415         public static final Uri CONTENT_URI = Uri.parse("content://sms");
416 
417         /**
418          * The default sort order for this table.
419          */
420         public static final String DEFAULT_SORT_ORDER = "date DESC";
421 
422         /**
423          * Add an SMS to the given URI.
424          *
425          * @param resolver the content resolver to use
426          * @param uri the URI to add the message to
427          * @param address the address of the sender
428          * @param body the body of the message
429          * @param subject the pseudo-subject of the message
430          * @param date the timestamp for the message
431          * @param read true if the message has been read, false if not
432          * @param deliveryReport true if a delivery report was requested, false if not
433          * @return the URI for the new message
434          * @hide
435          */
436         @UnsupportedAppUsage
addMessageToUri(ContentResolver resolver, Uri uri, String address, String body, String subject, Long date, boolean read, boolean deliveryReport)437         public static Uri addMessageToUri(ContentResolver resolver,
438                 Uri uri, String address, String body, String subject,
439                 Long date, boolean read, boolean deliveryReport) {
440             return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
441                     resolver, uri, address, body, subject, date, read, deliveryReport, -1L);
442         }
443 
444         /**
445          * Add an SMS to the given URI.
446          *
447          * @param resolver the content resolver to use
448          * @param uri the URI to add the message to
449          * @param address the address of the sender
450          * @param body the body of the message
451          * @param subject the psuedo-subject of the message
452          * @param date the timestamp for the message
453          * @param read true if the message has been read, false if not
454          * @param deliveryReport true if a delivery report was requested, false if not
455          * @param subId the subscription which the message belongs to
456          * @return the URI for the new message
457          * @hide
458          */
459         @UnsupportedAppUsage
addMessageToUri(int subId, ContentResolver resolver, Uri uri, String address, String body, String subject, Long date, boolean read, boolean deliveryReport)460         public static Uri addMessageToUri(int subId, ContentResolver resolver,
461                 Uri uri, String address, String body, String subject,
462                 Long date, boolean read, boolean deliveryReport) {
463             return addMessageToUri(subId, resolver, uri, address, body, subject,
464                     date, read, deliveryReport, -1L);
465         }
466 
467         /**
468          * Add an SMS to the given URI with the specified thread ID.
469          *
470          * @param resolver the content resolver to use
471          * @param uri the URI to add the message to
472          * @param address the address of the sender
473          * @param body the body of the message
474          * @param subject the pseudo-subject of the message
475          * @param date the timestamp for the message
476          * @param read true if the message has been read, false if not
477          * @param deliveryReport true if a delivery report was requested, false if not
478          * @param threadId the thread_id of the message
479          * @return the URI for the new message
480          * @hide
481          */
482         @UnsupportedAppUsage
addMessageToUri(ContentResolver resolver, Uri uri, String address, String body, String subject, Long date, boolean read, boolean deliveryReport, long threadId)483         public static Uri addMessageToUri(ContentResolver resolver,
484                 Uri uri, String address, String body, String subject,
485                 Long date, boolean read, boolean deliveryReport, long threadId) {
486             return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
487                     resolver, uri, address, body, subject,
488                     date, read, deliveryReport, threadId);
489         }
490 
491         /**
492          * Add an SMS to the given URI with thread_id specified.
493          *
494          * @param resolver the content resolver to use
495          * @param uri the URI to add the message to
496          * @param address the address of the sender
497          * @param body the body of the message
498          * @param subject the psuedo-subject of the message
499          * @param date the timestamp for the message
500          * @param read true if the message has been read, false if not
501          * @param deliveryReport true if a delivery report was requested, false if not
502          * @param threadId the thread_id of the message
503          * @param subId the subscription which the message belongs to
504          * @return the URI for the new message
505          * @hide
506          */
507         @UnsupportedAppUsage
addMessageToUri(int subId, ContentResolver resolver, Uri uri, String address, String body, String subject, Long date, boolean read, boolean deliveryReport, long threadId)508         public static Uri addMessageToUri(int subId, ContentResolver resolver,
509                 Uri uri, String address, String body, String subject,
510                 Long date, boolean read, boolean deliveryReport, long threadId) {
511             ContentValues values = new ContentValues(8);
512             Rlog.v(TAG,"Telephony addMessageToUri sub id: " + subId);
513 
514             values.put(SUBSCRIPTION_ID, subId);
515             values.put(ADDRESS, address);
516             if (date != null) {
517                 values.put(DATE, date);
518             }
519             values.put(READ, read ? Integer.valueOf(1) : Integer.valueOf(0));
520             values.put(SUBJECT, subject);
521             values.put(BODY, body);
522             if (deliveryReport) {
523                 values.put(STATUS, STATUS_PENDING);
524             }
525             if (threadId != -1L) {
526                 values.put(THREAD_ID, threadId);
527             }
528             return resolver.insert(uri, values);
529         }
530 
531         /**
532          * Move a message to the given folder.
533          *
534          * @param context the context to use
535          * @param uri the message to move
536          * @param folder the folder to move to
537          * @return true if the operation succeeded
538          * @hide
539          */
540         @UnsupportedAppUsage
moveMessageToFolder(Context context, Uri uri, int folder, int error)541         public static boolean moveMessageToFolder(Context context,
542                 Uri uri, int folder, int error) {
543             if (uri == null) {
544                 return false;
545             }
546 
547             boolean markAsUnread = false;
548             boolean markAsRead = false;
549             switch(folder) {
550             case MESSAGE_TYPE_INBOX:
551             case MESSAGE_TYPE_DRAFT:
552                 break;
553             case MESSAGE_TYPE_OUTBOX:
554             case MESSAGE_TYPE_SENT:
555                 markAsRead = true;
556                 break;
557             case MESSAGE_TYPE_FAILED:
558             case MESSAGE_TYPE_QUEUED:
559                 markAsUnread = true;
560                 break;
561             default:
562                 return false;
563             }
564 
565             ContentValues values = new ContentValues(3);
566 
567             values.put(TYPE, folder);
568             if (markAsUnread) {
569                 values.put(READ, 0);
570             } else if (markAsRead) {
571                 values.put(READ, 1);
572             }
573             values.put(ERROR_CODE, error);
574 
575             return 1 == SqliteWrapper.update(context, context.getContentResolver(),
576                             uri, values, null, null);
577         }
578 
579         /**
580          * Returns true iff the folder (message type) identifies an
581          * outgoing message.
582          * @hide
583          */
584         @UnsupportedAppUsage
isOutgoingFolder(int messageType)585         public static boolean isOutgoingFolder(int messageType) {
586             return  (messageType == MESSAGE_TYPE_FAILED)
587                     || (messageType == MESSAGE_TYPE_OUTBOX)
588                     || (messageType == MESSAGE_TYPE_SENT)
589                     || (messageType == MESSAGE_TYPE_QUEUED);
590         }
591 
592         /**
593          * Contains all text-based SMS messages in the SMS app inbox.
594          */
595         public static final class Inbox implements BaseColumns, TextBasedSmsColumns {
596 
597             /**
598              * Not instantiable.
599              * @hide
600              */
Inbox()601             private Inbox() {
602             }
603 
604             /**
605              * The {@code content://} style URL for this table.
606              */
607             public static final Uri CONTENT_URI = Uri.parse("content://sms/inbox");
608 
609             /**
610              * The default sort order for this table.
611              */
612             public static final String DEFAULT_SORT_ORDER = "date DESC";
613 
614             /**
615              * Add an SMS to the Draft box.
616              *
617              * @param resolver the content resolver to use
618              * @param address the address of the sender
619              * @param body the body of the message
620              * @param subject the pseudo-subject of the message
621              * @param date the timestamp for the message
622              * @param read true if the message has been read, false if not
623              * @return the URI for the new message
624              * @hide
625              */
626             @UnsupportedAppUsage
addMessage(ContentResolver resolver, String address, String body, String subject, Long date, boolean read)627             public static Uri addMessage(ContentResolver resolver,
628                     String address, String body, String subject, Long date,
629                     boolean read) {
630                 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
631                         resolver, CONTENT_URI, address, body, subject, date, read, false);
632             }
633 
634             /**
635              * Add an SMS to the Draft box.
636              *
637              * @param resolver the content resolver to use
638              * @param address the address of the sender
639              * @param body the body of the message
640              * @param subject the psuedo-subject of the message
641              * @param date the timestamp for the message
642              * @param read true if the message has been read, false if not
643              * @param subId the subscription which the message belongs to
644              * @return the URI for the new message
645              * @hide
646              */
647             @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
addMessage(int subId, ContentResolver resolver, String address, String body, String subject, Long date, boolean read)648             public static Uri addMessage(int subId, ContentResolver resolver,
649                     String address, String body, String subject, Long date, boolean read) {
650                 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
651                         subject, date, read, false);
652             }
653         }
654 
655         /**
656          * Contains all sent text-based SMS messages in the SMS app.
657          */
658         public static final class Sent implements BaseColumns, TextBasedSmsColumns {
659 
660             /**
661              * Not instantiable.
662              * @hide
663              */
Sent()664             private Sent() {
665             }
666 
667             /**
668              * The {@code content://} style URL for this table.
669              */
670             public static final Uri CONTENT_URI = Uri.parse("content://sms/sent");
671 
672             /**
673              * The default sort order for this table.
674              */
675             public static final String DEFAULT_SORT_ORDER = "date DESC";
676 
677             /**
678              * Add an SMS to the Draft box.
679              *
680              * @param resolver the content resolver to use
681              * @param address the address of the sender
682              * @param body the body of the message
683              * @param subject the pseudo-subject of the message
684              * @param date the timestamp for the message
685              * @return the URI for the new message
686              * @hide
687              */
688             @UnsupportedAppUsage
addMessage(ContentResolver resolver, String address, String body, String subject, Long date)689             public static Uri addMessage(ContentResolver resolver,
690                     String address, String body, String subject, Long date) {
691                 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
692                         resolver, CONTENT_URI, address, body, subject, date, true, false);
693             }
694 
695             /**
696              * Add an SMS to the Draft box.
697              *
698              * @param resolver the content resolver to use
699              * @param address the address of the sender
700              * @param body the body of the message
701              * @param subject the psuedo-subject of the message
702              * @param date the timestamp for the message
703              * @param subId the subscription which the message belongs to
704              * @return the URI for the new message
705              * @hide
706              */
707             @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
addMessage(int subId, ContentResolver resolver, String address, String body, String subject, Long date)708             public static Uri addMessage(int subId, ContentResolver resolver,
709                     String address, String body, String subject, Long date) {
710                 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
711                         subject, date, true, false);
712             }
713         }
714 
715         /**
716          * Contains all draft text-based SMS messages in the SMS app.
717          */
718         public static final class Draft implements BaseColumns, TextBasedSmsColumns {
719 
720             /**
721              * Not instantiable.
722              * @hide
723              */
Draft()724             private Draft() {
725             }
726 
727             /**
728              * The {@code content://} style URL for this table.
729              */
730             public static final Uri CONTENT_URI = Uri.parse("content://sms/draft");
731 
732            /**
733             * @hide
734             */
735             @UnsupportedAppUsage
addMessage(ContentResolver resolver, String address, String body, String subject, Long date)736             public static Uri addMessage(ContentResolver resolver,
737                     String address, String body, String subject, Long date) {
738                 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
739                         resolver, CONTENT_URI, address, body, subject, date, true, false);
740             }
741 
742             /**
743              * Add an SMS to the Draft box.
744              *
745              * @param resolver the content resolver to use
746              * @param address the address of the sender
747              * @param body the body of the message
748              * @param subject the psuedo-subject of the message
749              * @param date the timestamp for the message
750              * @param subId the subscription which the message belongs to
751              * @return the URI for the new message
752              * @hide
753              */
754             @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
addMessage(int subId, ContentResolver resolver, String address, String body, String subject, Long date)755             public static Uri addMessage(int subId, ContentResolver resolver,
756                     String address, String body, String subject, Long date) {
757                 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
758                         subject, date, true, false);
759             }
760 
761             /**
762              * The default sort order for this table.
763              */
764             public static final String DEFAULT_SORT_ORDER = "date DESC";
765         }
766 
767         /**
768          * Contains all pending outgoing text-based SMS messages.
769          */
770         public static final class Outbox implements BaseColumns, TextBasedSmsColumns {
771 
772             /**
773              * Not instantiable.
774              * @hide
775              */
Outbox()776             private Outbox() {
777             }
778 
779             /**
780              * The {@code content://} style URL for this table.
781              */
782             public static final Uri CONTENT_URI = Uri.parse("content://sms/outbox");
783 
784             /**
785              * The default sort order for this table.
786              */
787             public static final String DEFAULT_SORT_ORDER = "date DESC";
788 
789             /**
790              * Add an SMS to the outbox.
791              *
792              * @param resolver the content resolver to use
793              * @param address the address of the sender
794              * @param body the body of the message
795              * @param subject the pseudo-subject of the message
796              * @param date the timestamp for the message
797              * @param deliveryReport whether a delivery report was requested for the message
798              * @return the URI for the new message
799              * @hide
800              */
801             @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
addMessage(ContentResolver resolver, String address, String body, String subject, Long date, boolean deliveryReport, long threadId)802             public static Uri addMessage(ContentResolver resolver,
803                     String address, String body, String subject, Long date,
804                     boolean deliveryReport, long threadId) {
805                 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
806                         resolver, CONTENT_URI, address, body, subject, date,
807                         true, deliveryReport, threadId);
808             }
809 
810             /**
811              * Add an SMS to the Out box.
812              *
813              * @param resolver the content resolver to use
814              * @param address the address of the sender
815              * @param body the body of the message
816              * @param subject the psuedo-subject of the message
817              * @param date the timestamp for the message
818              * @param deliveryReport whether a delivery report was requested for the message
819              * @param subId the subscription which the message belongs to
820              * @return the URI for the new message
821              * @hide
822              */
addMessage(int subId, ContentResolver resolver, String address, String body, String subject, Long date, boolean deliveryReport, long threadId)823             public static Uri addMessage(int subId, ContentResolver resolver,
824                     String address, String body, String subject, Long date,
825                     boolean deliveryReport, long threadId) {
826                 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
827                         subject, date, true, deliveryReport, threadId);
828             }
829         }
830 
831         /**
832          * Contains a view of SMS conversations (also referred to as threads). This is similar to
833          * {@link Threads}, but only includes SMS messages and columns relevant to SMS
834          * conversations.
835          * <p>
836          * Note that this view ignores any information about MMS messages, it is a
837          * view of conversations as if MMS messages did not exist at all. This means that all
838          * relevant information, such as snippets and message count, will ignore any MMS messages
839          * that might be in the same thread through other views and present only data based on the
840          * SMS messages in that thread.
841          */
842         public static final class Conversations
843                 implements BaseColumns, TextBasedSmsColumns {
844 
845             /**
846              * Not instantiable.
847              * @hide
848              */
Conversations()849             private Conversations() {
850             }
851 
852             /**
853              * The {@code content://} style URL for this table.
854              */
855             public static final Uri CONTENT_URI = Uri.parse("content://sms/conversations");
856 
857             /**
858              * The default sort order for this table.
859              */
860             public static final String DEFAULT_SORT_ORDER = "date DESC";
861 
862             /**
863              * The first 45 characters of the body of the most recent message.
864              * <P>Type: TEXT</P>
865              */
866             public static final String SNIPPET = "snippet";
867 
868             /**
869              * The number of messages in the conversation.
870              * <P>Type: INTEGER</P>
871              */
872             public static final String MESSAGE_COUNT = "msg_count";
873         }
874 
875         /**
876          * Contains constants for SMS related Intents that are broadcast.
877          */
878         public static final class Intents {
879 
880             /**
881              * Not instantiable.
882              * @hide
883              */
Intents()884             private Intents() {
885             }
886 
887             /**
888              * Set by BroadcastReceiver to indicate that the message was handled
889              * successfully.
890              */
891             public static final int RESULT_SMS_HANDLED = 1;
892 
893             /**
894              * Set by BroadcastReceiver to indicate a generic error while
895              * processing the message.
896              */
897             public static final int RESULT_SMS_GENERIC_ERROR = 2;
898 
899             /**
900              * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate
901              * insufficient memory to store the message.
902              */
903             public static final int RESULT_SMS_OUT_OF_MEMORY = 3;
904 
905             /**
906              * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate that
907              * the message, while possibly valid, is of a format or encoding that is not supported.
908              */
909             public static final int RESULT_SMS_UNSUPPORTED = 4;
910 
911             /**
912              * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate a
913              * duplicate incoming message.
914              */
915             public static final int RESULT_SMS_DUPLICATED = 5;
916 
917             /**
918              * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate a
919              * dispatch failure.
920              */
921             public static final int RESULT_SMS_DISPATCH_FAILURE = 6;
922 
923             /**
924              * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate a null
925              * PDU was received.
926              */
927             public static final int RESULT_SMS_NULL_PDU = 7;
928 
929             /**
930              * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate a null
931              * message was encountered.
932              */
933             public static final int RESULT_SMS_NULL_MESSAGE = 8;
934 
935             /**
936              * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate an sms
937              * was received while the phone was in encrypted state.
938              * <p>
939              * This result code is only used on devices that use Full Disk Encryption.  Support for
940              * Full Disk Encryption was entirely removed in API level 33, having been replaced by
941              * File Based Encryption.  Devices that use File Based Encryption never reject incoming
942              * SMS messages due to the encryption state.
943              */
944             public static final int RESULT_SMS_RECEIVED_WHILE_ENCRYPTED = 9;
945 
946             /**
947              * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate a
948              * telephony database error.
949              */
950             public static final int RESULT_SMS_DATABASE_ERROR = 10;
951 
952             /**
953              * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate an
954              * invalid uri.
955              */
956             public static final int RESULT_SMS_INVALID_URI = 11;
957 
958             /**
959              * Activity action: Ask the user to change the default
960              * SMS application. This will show a dialog that asks the
961              * user whether they want to replace the current default
962              * SMS application with the one specified in
963              * {@link #EXTRA_PACKAGE_NAME}.
964              * <p>
965              * This is no longer supported since Q, please use
966              * {@link android.app.role.RoleManager#createRequestRoleIntent(String)} with
967              * {@link android.app.role.RoleManager#ROLE_SMS} instead.
968              */
969             @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
970             public static final String ACTION_CHANGE_DEFAULT =
971                     "android.provider.Telephony.ACTION_CHANGE_DEFAULT";
972 
973             /**
974              * The PackageName string passed in as an
975              * extra for {@link #ACTION_CHANGE_DEFAULT}
976              *
977              * @see #ACTION_CHANGE_DEFAULT
978              * <p>
979              * This is no longer supported since Q, please use
980              * {@link android.app.role.RoleManager#createRequestRoleIntent(String)} with
981              * {@link android.app.role.RoleManager#ROLE_SMS} instead.
982              */
983             public static final String EXTRA_PACKAGE_NAME = "package";
984 
985             /**
986              * Broadcast Action: A new text-based SMS message has been received
987              * by the device. This intent will only be delivered to the default
988              * sms app. That app is responsible for writing the message and notifying
989              * the user. The intent will have the following extra values:</p>
990              *
991              * <ul>
992              *   <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
993              *   that make up the message.</li>
994              *   <li><em>"format"</em> - A String describing the format of the PDUs. It can
995              *   be either "3gpp" or "3gpp2".</li>
996              *   <li><em>"subscription"</em> - An optional long value of the subscription id which
997              *   received the message.</li>
998              *   <li><em>"slot"</em> - An optional int value of the SIM slot containing the
999              *   subscription.</li>
1000              *   <li><em>"phone"</em> - An optional int value of the phone id associated with the
1001              *   subscription.</li>
1002              *   <li><em>"errorCode"</em> - An optional int error code associated with receiving
1003              *   the message.</li>
1004              * </ul>
1005              *
1006              * <p>The extra values can be extracted using
1007              * {@link #getMessagesFromIntent(Intent)}.</p>
1008              *
1009              * <p>If a BroadcastReceiver encounters an error while processing
1010              * this intent it should set the result code appropriately.</p>
1011              *
1012              * <p class="note"><strong>Note:</strong>
1013              * The broadcast receiver that filters for this intent must declare
1014              * {@link android.Manifest.permission#BROADCAST_SMS} as a required permission in
1015              * the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code
1016              * <receiver>}</a> tag.
1017              *
1018              * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1019              */
1020             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1021             public static final String SMS_DELIVER_ACTION =
1022                     "android.provider.Telephony.SMS_DELIVER";
1023 
1024             /**
1025              * Broadcast Action: A new text-based SMS message has been received
1026              * by the device. This intent will be delivered to all registered
1027              * receivers as a notification. These apps are not expected to write the
1028              * message or notify the user. The intent will have the following extra
1029              * values:</p>
1030              *
1031              * <ul>
1032              *   <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
1033              *   that make up the message.</li>
1034              * </ul>
1035              *
1036              * <p>The extra values can be extracted using
1037              * {@link #getMessagesFromIntent(Intent)}.</p>
1038              *
1039              * <p>If a BroadcastReceiver encounters an error while processing
1040              * this intent it should set the result code appropriately.</p>
1041              *
1042              * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1043              */
1044             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1045             public static final String SMS_RECEIVED_ACTION =
1046                     "android.provider.Telephony.SMS_RECEIVED";
1047 
1048             /**
1049              * Broadcast Action: A new data based SMS message has been received
1050              * by the device. This intent will be delivered to all registered
1051              * receivers as a notification. The intent will have the following extra
1052              * values:</p>
1053              *
1054              * <ul>
1055              *   <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
1056              *   that make up the message.</li>
1057              * </ul>
1058              *
1059              * <p>The extra values can be extracted using
1060              * {@link #getMessagesFromIntent(Intent)}.</p>
1061              *
1062              * <p>If a BroadcastReceiver encounters an error while processing
1063              * this intent it should set the result code appropriately.</p>
1064              *
1065              * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1066              */
1067             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1068             public static final String DATA_SMS_RECEIVED_ACTION =
1069                     "android.intent.action.DATA_SMS_RECEIVED";
1070 
1071             /**
1072              * Broadcast Action: A new WAP PUSH message has been received by the
1073              * device. This intent will only be delivered to the default
1074              * sms app. That app is responsible for writing the message and notifying
1075              * the user. The intent will have the following extra values:</p>
1076              *
1077              * <ul>
1078              *   <li><em>"transactionId"</em> - (Integer) The WAP transaction ID</li>
1079              *   <li><em>"pduType"</em> - (Integer) The WAP PDU type</li>
1080              *   <li><em>"header"</em> - (byte[]) The header of the message</li>
1081              *   <li><em>"data"</em> - (byte[]) The data payload of the message</li>
1082              *   <li><em>"contentTypeParameters" </em>
1083              *   -(HashMap&lt;String,String&gt;) Any parameters associated with the content type
1084              *   (decoded from the WSP Content-Type header)</li>
1085              *   <li><em>"subscription"</em> - An optional long value of the subscription id which
1086              *   received the message.</li>
1087              *   <li><em>"slot"</em> - An optional int value of the SIM slot containing the
1088              *   subscription.</li>
1089              *   <li><em>"phone"</em> - An optional int value of the phone id associated with the
1090              *   subscription.</li>
1091              * </ul>
1092              *
1093              * <p>If a BroadcastReceiver encounters an error while processing
1094              * this intent it should set the result code appropriately.</p>
1095              *
1096              * <p>The contentTypeParameters extra value is map of content parameters keyed by
1097              * their names.</p>
1098              *
1099              * <p>If any unassigned well-known parameters are encountered, the key of the map will
1100              * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter.  If
1101              * a parameter has No-Value the value in the map will be null.</p>
1102              *
1103              * <p>Requires {@link android.Manifest.permission#RECEIVE_MMS} or
1104              * {@link android.Manifest.permission#RECEIVE_WAP_PUSH} (depending on WAP PUSH type) to
1105              * receive.</p>
1106              *
1107              * <p class="note"><strong>Note:</strong>
1108              * The broadcast receiver that filters for this intent must declare
1109              * {@link android.Manifest.permission#BROADCAST_WAP_PUSH} as a required permission in
1110              * the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code
1111              * <receiver>}</a> tag.
1112              */
1113             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1114             public static final String WAP_PUSH_DELIVER_ACTION =
1115                     "android.provider.Telephony.WAP_PUSH_DELIVER";
1116 
1117             /**
1118              * Broadcast Action: A new WAP PUSH message has been received by the
1119              * device. This intent will be delivered to all registered
1120              * receivers as a notification. These apps are not expected to write the
1121              * message or notify the user. The intent will have the following extra
1122              * values:</p>
1123              *
1124              * <ul>
1125              *   <li><em>"transactionId"</em> - (Integer) The WAP transaction ID</li>
1126              *   <li><em>"pduType"</em> - (Integer) The WAP PDU type</li>
1127              *   <li><em>"header"</em> - (byte[]) The header of the message</li>
1128              *   <li><em>"data"</em> - (byte[]) The data payload of the message</li>
1129              *   <li><em>"contentTypeParameters"</em>
1130              *   - (HashMap&lt;String,String&gt;) Any parameters associated with the content type
1131              *   (decoded from the WSP Content-Type header)</li>
1132              * </ul>
1133              *
1134              * <p>If a BroadcastReceiver encounters an error while processing
1135              * this intent it should set the result code appropriately.</p>
1136              *
1137              * <p>The contentTypeParameters extra value is map of content parameters keyed by
1138              * their names.</p>
1139              *
1140              * <p>If any unassigned well-known parameters are encountered, the key of the map will
1141              * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter.  If
1142              * a parameter has No-Value the value in the map will be null.</p>
1143              *
1144              * <p>Requires {@link android.Manifest.permission#RECEIVE_MMS} or
1145              * {@link android.Manifest.permission#RECEIVE_WAP_PUSH} (depending on WAP PUSH type) to
1146              * receive.</p>
1147              */
1148             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1149             public static final String WAP_PUSH_RECEIVED_ACTION =
1150                     "android.provider.Telephony.WAP_PUSH_RECEIVED";
1151 
1152             /**
1153              * Broadcast Action: A new Cell Broadcast message has been received
1154              * by the device. The intent will have the following extra
1155              * values:</p>
1156              *
1157              * <ul>
1158              *   <li><em>"message"</em> - An SmsCbMessage object containing the broadcast message
1159              *   data. This is not an emergency alert, so ETWS and CMAS data will be null.</li>
1160              * </ul>
1161              *
1162              * <p>The extra values can be extracted using
1163              * {@link #getMessagesFromIntent(Intent)}.</p>
1164              *
1165              * <p>If a BroadcastReceiver encounters an error while processing
1166              * this intent it should set the result code appropriately.</p>
1167              *
1168              * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1169              */
1170             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1171             public static final String SMS_CB_RECEIVED_ACTION =
1172                     "android.provider.Telephony.SMS_CB_RECEIVED";
1173 
1174             /**
1175              * Action: A SMS based carrier provision intent. Used to identify default
1176              * carrier provisioning app on the device.
1177              * @hide
1178              */
1179             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1180             @TestApi
1181             public static final String SMS_CARRIER_PROVISION_ACTION =
1182                     "android.provider.Telephony.SMS_CARRIER_PROVISION";
1183 
1184             /**
1185              * Broadcast Action: A new Emergency Broadcast message has been received
1186              * by the device. The intent will have the following extra
1187              * values:</p>
1188              *
1189              * <ul>
1190              *   <li><em>"message"</em> - An {@link android.telephony.SmsCbMessage} object
1191              *   containing the broadcast message data, including ETWS or CMAS warning notification
1192              *   info if present.</li>
1193              * </ul>
1194              *
1195              * <p>The extra values can be extracted using
1196              * {@link #getMessagesFromIntent(Intent)}.</p>
1197              *
1198              * <p>If a BroadcastReceiver encounters an error while processing
1199              * this intent it should set the result code appropriately.</p>
1200              *
1201              * <p>Requires {@link android.Manifest.permission#RECEIVE_EMERGENCY_BROADCAST} to
1202              * receive.</p>
1203              * @hide
1204              */
1205             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1206             @SystemApi
1207             public static final String ACTION_SMS_EMERGENCY_CB_RECEIVED =
1208                     "android.provider.action.SMS_EMERGENCY_CB_RECEIVED";
1209 
1210             /**
1211              * Broadcast Action: A new CDMA SMS has been received containing Service Category
1212              * Program Data (updates the list of enabled broadcast channels). The intent will
1213              * have the following extra values:</p>
1214              *
1215              * <ul>
1216              *   <li><em>"operations"</em> - An array of CdmaSmsCbProgramData objects containing
1217              *   the service category operations (add/delete/clear) to perform.</li>
1218              * </ul>
1219              *
1220              * <p>The extra values can be extracted using
1221              * {@link #getMessagesFromIntent(Intent)}.</p>
1222              *
1223              * <p>If a BroadcastReceiver encounters an error while processing
1224              * this intent it should set the result code appropriately.</p>
1225              *
1226              * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1227              */
1228             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1229             public static final String SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION =
1230                     "android.provider.Telephony.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED";
1231 
1232             /**
1233              * Broadcast Action: The SIM storage for SMS messages is full.  If
1234              * space is not freed, messages targeted for the SIM (class 2) may
1235              * not be saved.
1236              *
1237              * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1238              */
1239             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1240             public static final String SIM_FULL_ACTION =
1241                     "android.provider.Telephony.SIM_FULL";
1242 
1243             /**
1244              * Broadcast Action: An incoming SMS has been rejected by the
1245              * telephony framework.  This intent is sent in lieu of any
1246              * of the RECEIVED_ACTION intents.  The intent will have the
1247              * following extra value:</p>
1248              *
1249              * <ul>
1250              *   <li><em>"result"</em> - An int result code, e.g. {@link #RESULT_SMS_OUT_OF_MEMORY}
1251              *   indicating the error returned to the network.</li>
1252              * </ul>
1253              *
1254              * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1255              */
1256             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1257             public static final String SMS_REJECTED_ACTION =
1258                 "android.provider.Telephony.SMS_REJECTED";
1259 
1260             /**
1261              * Broadcast Action: An incoming MMS has been downloaded. The intent is sent to all
1262              * users, except for secondary users where SMS has been disabled and to managed
1263              * profiles.
1264              * @hide
1265              */
1266             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1267             public static final String MMS_DOWNLOADED_ACTION =
1268                 "android.provider.Telephony.MMS_DOWNLOADED";
1269 
1270             /**
1271              * Broadcast Action: A debug code has been entered in the dialer. This intent is
1272              * broadcast by the system and OEM telephony apps may need to receive these broadcasts.
1273              * These "secret codes" are used to activate developer menus by dialing certain codes.
1274              * And they are of the form {@code *#*#<code>#*#*}. The intent will have the data
1275              * URI: {@code android_secret_code://<code>}. It is possible that a manifest
1276              * receiver would be woken up even if it is not currently running.
1277              *
1278              * <p>Requires {@code android.Manifest.permission#CONTROL_INCALL_EXPERIENCE} to
1279              * send and receive.</p>
1280              * @deprecated it is no longer supported, use {@link
1281              * TelephonyManager#ACTION_SECRET_CODE} instead
1282              */
1283             @Deprecated
1284             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1285             public static final String SECRET_CODE_ACTION =
1286                     "android.provider.Telephony.SECRET_CODE";
1287 
1288             /**
1289              * Broadcast action: When the default SMS package changes,
1290              * the previous default SMS package and the new default SMS
1291              * package are sent this broadcast to notify them of the change.
1292              * A boolean is specified in {@link #EXTRA_IS_DEFAULT_SMS_APP} to
1293              * indicate whether the package is the new default SMS package.
1294             */
1295             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1296             public static final String ACTION_DEFAULT_SMS_PACKAGE_CHANGED =
1297                             "android.provider.action.DEFAULT_SMS_PACKAGE_CHANGED";
1298 
1299             /**
1300              * The IsDefaultSmsApp boolean passed as an
1301              * extra for {@link #ACTION_DEFAULT_SMS_PACKAGE_CHANGED} to indicate whether the
1302              * SMS app is becoming the default SMS app or is no longer the default.
1303              *
1304              * @see #ACTION_DEFAULT_SMS_PACKAGE_CHANGED
1305              */
1306             public static final String EXTRA_IS_DEFAULT_SMS_APP =
1307                     "android.provider.extra.IS_DEFAULT_SMS_APP";
1308 
1309             /**
1310              * Broadcast action: When a change is made to the SmsProvider or
1311              * MmsProvider by a process other than the default SMS application,
1312              * this intent is broadcast to the default SMS application so it can
1313              * re-sync or update the change. The uri that was used to call the provider
1314              * can be retrieved from the intent with getData(). The actual affected uris
1315              * (which would depend on the selection specified) are not included.
1316             */
1317             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1318             public static final String ACTION_EXTERNAL_PROVIDER_CHANGE =
1319                           "android.provider.action.EXTERNAL_PROVIDER_CHANGE";
1320 
1321             /**
1322              * Broadcast action: When SMS-MMS db is being created. If file-based encryption is
1323              * supported, this broadcast indicates creation of the db in credential-encrypted
1324              * storage. A boolean is specified in {@link #EXTRA_IS_INITIAL_CREATE} to indicate if
1325              * this is the initial create of the db.
1326              *
1327              * @see #EXTRA_IS_INITIAL_CREATE
1328              *
1329              * @hide
1330              */
1331             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1332             public static final String ACTION_SMS_MMS_DB_CREATED =
1333                     "android.provider.action.SMS_MMS_DB_CREATED";
1334 
1335             /**
1336              * Boolean flag passed as an extra with {@link #ACTION_SMS_MMS_DB_CREATED} to indicate
1337              * whether the DB creation is the initial creation on the device, that is it is after a
1338              * factory-data reset or a new device. Any subsequent creations of the DB (which
1339              * happens only in error scenarios) will have this flag set to false.
1340              *
1341              * @see #ACTION_SMS_MMS_DB_CREATED
1342              *
1343              * @hide
1344              */
1345             public static final String EXTRA_IS_INITIAL_CREATE =
1346                     "android.provider.extra.IS_INITIAL_CREATE";
1347 
1348             /**
1349              * Broadcast intent action indicating that the telephony provider SMS MMS database is
1350              * corrupted. A boolean is specified in {@link #EXTRA_IS_CORRUPTED} to indicate if the
1351              * database is corrupted. Requires the
1352              * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE permission.
1353              *
1354              * @hide
1355              */
1356             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1357             public static final String ACTION_SMS_MMS_DB_LOST =
1358                     "android.provider.action.SMS_MMS_DB_LOST";
1359 
1360             /**
1361              * Boolean flag passed as an extra with {@link #ACTION_SMS_MMS_DB_LOST} to indicate
1362              * whether the DB got corrupted or not.
1363              *
1364              * @see #ACTION_SMS_MMS_DB_LOST
1365              *
1366              * @hide
1367              */
1368             public static final String EXTRA_IS_CORRUPTED =
1369                     "android.provider.extra.IS_CORRUPTED";
1370 
1371             /**
1372              * Read the PDUs out of an {@link #SMS_RECEIVED_ACTION} or a
1373              * {@link #DATA_SMS_RECEIVED_ACTION} intent.
1374              *
1375              * @param intent the intent to read from
1376              * @return an array of SmsMessages for the PDUs
1377              */
getMessagesFromIntent(Intent intent)1378             public static SmsMessage[] getMessagesFromIntent(Intent intent) {
1379                 Object[] messages;
1380                 try {
1381                     messages = (Object[]) intent.getSerializableExtra("pdus");
1382                 } catch (ClassCastException e) {
1383                     Rlog.e(TAG, "getMessagesFromIntent: " + e);
1384                     return null;
1385                 }
1386 
1387                 if (messages == null) {
1388                     Rlog.e(TAG, "pdus does not exist in the intent");
1389                     return null;
1390                 }
1391 
1392                 String format = intent.getStringExtra("format");
1393                 int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
1394                         SubscriptionManager.INVALID_SUBSCRIPTION_ID);
1395                 if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
1396                     Rlog.v(TAG, "getMessagesFromIntent with valid subId : " + subId);
1397                 } else {
1398                     Rlog.v(TAG, "getMessagesFromIntent");
1399                 }
1400 
1401                 int pduCount = messages.length;
1402                 SmsMessage[] msgs = new SmsMessage[pduCount];
1403 
1404                 for (int i = 0; i < pduCount; i++) {
1405                     byte[] pdu = (byte[]) messages[i];
1406                     msgs[i] = SmsMessage.createFromPdu(pdu, format);
1407                 }
1408                 return msgs;
1409             }
1410         }
1411     }
1412 
1413     /**
1414      * Base column for the table that contain Carrier Public key.
1415      * @hide
1416      */
1417     public interface CarrierColumns extends BaseColumns {
1418 
1419         /**
1420          * Mobile Country Code (MCC).
1421          * <P> Type: TEXT </P>
1422          */
1423         public static final String MCC = "mcc";
1424 
1425         /**
1426          * Mobile Network Code (MNC).
1427          * <P> Type: TEXT </P>
1428          */
1429         public static final String MNC = "mnc";
1430 
1431         /**
1432          * KeyType whether the key is being used for WLAN or ePDG.
1433          * <P> Type: INTEGER </P>
1434          */
1435         public static final String KEY_TYPE = "key_type";
1436 
1437         /**
1438          * The carrier public key that is used for the IMSI encryption.
1439          * <P> Type: TEXT </P>
1440          */
1441         public static final String PUBLIC_KEY = "public_key";
1442 
1443         /**
1444          * The key identifier Attribute value pair that helps a server locate
1445          * the private key to decrypt the permanent identity.
1446          * <P> Type: TEXT </P>
1447          */
1448         public static final String KEY_IDENTIFIER = "key_identifier";
1449 
1450         /**
1451          * Date-Time in UTC when the key will expire.
1452          * <P> Type: INTEGER (long) </P>
1453          */
1454         public static final String EXPIRATION_TIME = "expiration_time";
1455 
1456         /**
1457          * Timestamp when this table was last modified, in milliseconds since
1458          * January 1, 1970 00:00:00.0 UTC.
1459          * <P> Type: INTEGER (long) </P>
1460          */
1461         public static final String LAST_MODIFIED = "last_modified";
1462 
1463         /**
1464          * Carrier ID of the operetor.
1465          * <P> Type: TEXT </P>
1466          */
1467         public static final String CARRIER_ID = "carrier_id";
1468         /**
1469          * The {@code content://} style URL for this table.
1470          */
1471         @NonNull
1472         public static final Uri CONTENT_URI = Uri.parse("content://carrier_information/carrier");
1473     }
1474 
1475     /**
1476      * Base columns for tables that contain MMSs.
1477      */
1478     public interface BaseMmsColumns extends BaseColumns {
1479 
1480         /** Message box: all messages. */
1481         public static final int MESSAGE_BOX_ALL    = 0;
1482         /** Message box: inbox. */
1483         public static final int MESSAGE_BOX_INBOX  = 1;
1484         /** Message box: sent messages. */
1485         public static final int MESSAGE_BOX_SENT   = 2;
1486         /** Message box: drafts. */
1487         public static final int MESSAGE_BOX_DRAFTS = 3;
1488         /** Message box: outbox. */
1489         public static final int MESSAGE_BOX_OUTBOX = 4;
1490         /** Message box: failed. */
1491         public static final int MESSAGE_BOX_FAILED = 5;
1492 
1493         /**
1494          * The thread ID of the message.
1495          * <P>Type: INTEGER (long)</P>
1496          */
1497         public static final String THREAD_ID = "thread_id";
1498 
1499         /**
1500          * The date the message was received.
1501          * <P>Type: INTEGER (long)</P>
1502          */
1503         public static final String DATE = "date";
1504 
1505         /**
1506          * The date the message was sent.
1507          * <P>Type: INTEGER (long)</P>
1508          */
1509         public static final String DATE_SENT = "date_sent";
1510 
1511         /**
1512          * The box which the message belongs to, e.g. {@link #MESSAGE_BOX_INBOX}.
1513          * <P>Type: INTEGER</P>
1514          */
1515         public static final String MESSAGE_BOX = "msg_box";
1516 
1517         /**
1518          * Has the message been read?
1519          * <P>Type: INTEGER (boolean)</P>
1520          */
1521         public static final String READ = "read";
1522 
1523         /**
1524          * Has the message been seen by the user? The "seen" flag determines
1525          * whether we need to show a new message notification.
1526          * <P>Type: INTEGER (boolean)</P>
1527          */
1528         public static final String SEEN = "seen";
1529 
1530         /**
1531          * Does the message have only a text part (can also have a subject) with
1532          * no picture, slideshow, sound, etc. parts?
1533          * <P>Type: INTEGER (boolean)</P>
1534          */
1535         public static final String TEXT_ONLY = "text_only";
1536 
1537         /**
1538          * The {@code Message-ID} of the message.
1539          * <P>Type: TEXT</P>
1540          */
1541         public static final String MESSAGE_ID = "m_id";
1542 
1543         /**
1544          * The subject of the message, if present.
1545          * <P>Type: TEXT</P>
1546          */
1547         public static final String SUBJECT = "sub";
1548 
1549         /**
1550          * The character set of the subject, if present.
1551          * <P>Type: INTEGER</P>
1552          */
1553         public static final String SUBJECT_CHARSET = "sub_cs";
1554 
1555         /**
1556          * The {@code Content-Type} of the message.
1557          * <P>Type: TEXT</P>
1558          */
1559         public static final String CONTENT_TYPE = "ct_t";
1560 
1561         /**
1562          * The {@code Content-Location} of the message.
1563          * <P>Type: TEXT</P>
1564          */
1565         public static final String CONTENT_LOCATION = "ct_l";
1566 
1567         /**
1568          * The expiry time of the message.
1569          * <P>Type: INTEGER (long)</P>
1570          */
1571         public static final String EXPIRY = "exp";
1572 
1573         /**
1574          * The class of the message.
1575          * <P>Type: TEXT</P>
1576          */
1577         public static final String MESSAGE_CLASS = "m_cls";
1578 
1579         /**
1580          * The type of the message defined by MMS spec.
1581          * <P>Type: INTEGER</P>
1582          */
1583         public static final String MESSAGE_TYPE = "m_type";
1584 
1585         /**
1586          * The version of the specification that this message conforms to.
1587          * <P>Type: INTEGER</P>
1588          */
1589         public static final String MMS_VERSION = "v";
1590 
1591         /**
1592          * The size of the message.
1593          * <P>Type: INTEGER</P>
1594          */
1595         public static final String MESSAGE_SIZE = "m_size";
1596 
1597         /**
1598          * The priority of the message.
1599          * <P>Type: INTEGER</P>
1600          */
1601         public static final String PRIORITY = "pri";
1602 
1603         /**
1604          * The {@code read-report} of the message.
1605          * <P>Type: INTEGER (boolean)</P>
1606          */
1607         public static final String READ_REPORT = "rr";
1608 
1609         /**
1610          * Is read report allowed?
1611          * <P>Type: INTEGER (boolean)</P>
1612          */
1613         public static final String REPORT_ALLOWED = "rpt_a";
1614 
1615         /**
1616          * The {@code response-status} of the message.
1617          * <P>Type: INTEGER</P>
1618          */
1619         public static final String RESPONSE_STATUS = "resp_st";
1620 
1621         /**
1622          * The {@code status} of the message.
1623          * <P>Type: INTEGER</P>
1624          */
1625         public static final String STATUS = "st";
1626 
1627         /**
1628          * The {@code transaction-id} of the message.
1629          * <P>Type: TEXT</P>
1630          */
1631         public static final String TRANSACTION_ID = "tr_id";
1632 
1633         /**
1634          * The {@code retrieve-status} of the message.
1635          * <P>Type: INTEGER</P>
1636          */
1637         public static final String RETRIEVE_STATUS = "retr_st";
1638 
1639         /**
1640          * The {@code retrieve-text} of the message.
1641          * <P>Type: TEXT</P>
1642          */
1643         public static final String RETRIEVE_TEXT = "retr_txt";
1644 
1645         /**
1646          * The character set of the retrieve-text.
1647          * <P>Type: INTEGER</P>
1648          */
1649         public static final String RETRIEVE_TEXT_CHARSET = "retr_txt_cs";
1650 
1651         /**
1652          * The {@code read-status} of the message.
1653          * <P>Type: INTEGER</P>
1654          */
1655         public static final String READ_STATUS = "read_status";
1656 
1657         /**
1658          * The {@code content-class} of the message.
1659          * <P>Type: INTEGER</P>
1660          */
1661         public static final String CONTENT_CLASS = "ct_cls";
1662 
1663         /**
1664          * The {@code delivery-report} of the message.
1665          * <P>Type: INTEGER</P>
1666          */
1667         public static final String DELIVERY_REPORT = "d_rpt";
1668 
1669         /**
1670          * The {@code delivery-time-token} of the message.
1671          * <P>Type: INTEGER</P>
1672          * @deprecated this column is no longer supported.
1673          * @hide
1674          */
1675         @Deprecated
1676         public static final String DELIVERY_TIME_TOKEN = "d_tm_tok";
1677 
1678         /**
1679          * The {@code delivery-time} of the message.
1680          * <P>Type: INTEGER</P>
1681          */
1682         public static final String DELIVERY_TIME = "d_tm";
1683 
1684         /**
1685          * The {@code response-text} of the message.
1686          * <P>Type: TEXT</P>
1687          */
1688         public static final String RESPONSE_TEXT = "resp_txt";
1689 
1690         /**
1691          * The {@code sender-visibility} of the message.
1692          * <P>Type: TEXT</P>
1693          * @deprecated this column is no longer supported.
1694          * @hide
1695          */
1696         @Deprecated
1697         public static final String SENDER_VISIBILITY = "s_vis";
1698 
1699         /**
1700          * The {@code reply-charging} of the message.
1701          * <P>Type: INTEGER</P>
1702          * @deprecated this column is no longer supported.
1703          * @hide
1704          */
1705         @Deprecated
1706         public static final String REPLY_CHARGING = "r_chg";
1707 
1708         /**
1709          * The {@code reply-charging-deadline-token} of the message.
1710          * <P>Type: INTEGER</P>
1711          * @deprecated this column is no longer supported.
1712          * @hide
1713          */
1714         @Deprecated
1715         public static final String REPLY_CHARGING_DEADLINE_TOKEN = "r_chg_dl_tok";
1716 
1717         /**
1718          * The {@code reply-charging-deadline} of the message.
1719          * <P>Type: INTEGER</P>
1720          * @deprecated this column is no longer supported.
1721          * @hide
1722          */
1723         @Deprecated
1724         public static final String REPLY_CHARGING_DEADLINE = "r_chg_dl";
1725 
1726         /**
1727          * The {@code reply-charging-id} of the message.
1728          * <P>Type: TEXT</P>
1729          * @deprecated this column is no longer supported.
1730          * @hide
1731          */
1732         @Deprecated
1733         public static final String REPLY_CHARGING_ID = "r_chg_id";
1734 
1735         /**
1736          * The {@code reply-charging-size} of the message.
1737          * <P>Type: INTEGER</P>
1738          * @deprecated this column is no longer supported.
1739          * @hide
1740          */
1741         @Deprecated
1742         public static final String REPLY_CHARGING_SIZE = "r_chg_sz";
1743 
1744         /**
1745          * The {@code previously-sent-by} of the message.
1746          * <P>Type: TEXT</P>
1747          * @deprecated this column is no longer supported.
1748          * @hide
1749          */
1750         @Deprecated
1751         public static final String PREVIOUSLY_SENT_BY = "p_s_by";
1752 
1753         /**
1754          * The {@code previously-sent-date} of the message.
1755          * <P>Type: INTEGER</P>
1756          * @deprecated this column is no longer supported.
1757          * @hide
1758          */
1759         @Deprecated
1760         public static final String PREVIOUSLY_SENT_DATE = "p_s_d";
1761 
1762         /**
1763          * The {@code store} of the message.
1764          * <P>Type: TEXT</P>
1765          * @deprecated this column is no longer supported.
1766          * @hide
1767          */
1768         @Deprecated
1769         public static final String STORE = "store";
1770 
1771         /**
1772          * The {@code mm-state} of the message.
1773          * <P>Type: INTEGER</P>
1774          * @deprecated this column is no longer supported.
1775          * @hide
1776          */
1777         @Deprecated
1778         public static final String MM_STATE = "mm_st";
1779 
1780         /**
1781          * The {@code mm-flags-token} of the message.
1782          * <P>Type: INTEGER</P>
1783          * @deprecated this column is no longer supported.
1784          * @hide
1785          */
1786         @Deprecated
1787         public static final String MM_FLAGS_TOKEN = "mm_flg_tok";
1788 
1789         /**
1790          * The {@code mm-flags} of the message.
1791          * <P>Type: TEXT</P>
1792          * @deprecated this column is no longer supported.
1793          * @hide
1794          */
1795         @Deprecated
1796         public static final String MM_FLAGS = "mm_flg";
1797 
1798         /**
1799          * The {@code store-status} of the message.
1800          * <P>Type: TEXT</P>
1801          * @deprecated this column is no longer supported.
1802          * @hide
1803          */
1804         @Deprecated
1805         public static final String STORE_STATUS = "store_st";
1806 
1807         /**
1808          * The {@code store-status-text} of the message.
1809          * <P>Type: TEXT</P>
1810          * @deprecated this column is no longer supported.
1811          * @hide
1812          */
1813         @Deprecated
1814         public static final String STORE_STATUS_TEXT = "store_st_txt";
1815 
1816         /**
1817          * The {@code stored} of the message.
1818          * <P>Type: TEXT</P>
1819          * @deprecated this column is no longer supported.
1820          * @hide
1821          */
1822         @Deprecated
1823         public static final String STORED = "stored";
1824 
1825         /**
1826          * The {@code totals} of the message.
1827          * <P>Type: TEXT</P>
1828          * @deprecated this column is no longer supported.
1829          * @hide
1830          */
1831         @Deprecated
1832         public static final String TOTALS = "totals";
1833 
1834         /**
1835          * The {@code mbox-totals} of the message.
1836          * <P>Type: TEXT</P>
1837          * @deprecated this column is no longer supported.
1838          * @hide
1839          */
1840         @Deprecated
1841         public static final String MBOX_TOTALS = "mb_t";
1842 
1843         /**
1844          * The {@code mbox-totals-token} of the message.
1845          * <P>Type: INTEGER</P>
1846          * @deprecated this column is no longer supported.
1847          * @hide
1848          */
1849         @Deprecated
1850         public static final String MBOX_TOTALS_TOKEN = "mb_t_tok";
1851 
1852         /**
1853          * The {@code quotas} of the message.
1854          * <P>Type: TEXT</P>
1855          * @deprecated this column is no longer supported.
1856          * @hide
1857          */
1858         @Deprecated
1859         public static final String QUOTAS = "qt";
1860 
1861         /**
1862          * The {@code mbox-quotas} of the message.
1863          * <P>Type: TEXT</P>
1864          * @deprecated this column is no longer supported.
1865          * @hide
1866          */
1867         @Deprecated
1868         public static final String MBOX_QUOTAS = "mb_qt";
1869 
1870         /**
1871          * The {@code mbox-quotas-token} of the message.
1872          * <P>Type: INTEGER</P>
1873          * @deprecated this column is no longer supported.
1874          * @hide
1875          */
1876         @Deprecated
1877         public static final String MBOX_QUOTAS_TOKEN = "mb_qt_tok";
1878 
1879         /**
1880          * The {@code message-count} of the message.
1881          * <P>Type: INTEGER</P>
1882          * @deprecated this column is no longer supported.
1883          * @hide
1884          */
1885         @Deprecated
1886         public static final String MESSAGE_COUNT = "m_cnt";
1887 
1888         /**
1889          * The {@code start} of the message.
1890          * <P>Type: INTEGER</P>
1891          * @deprecated this column is no longer supported.
1892          * @hide
1893          */
1894         @Deprecated
1895         public static final String START = "start";
1896 
1897         /**
1898          * The {@code distribution-indicator} of the message.
1899          * <P>Type: TEXT</P>
1900          * @deprecated this column is no longer supported.
1901          * @hide
1902          */
1903         @Deprecated
1904         public static final String DISTRIBUTION_INDICATOR = "d_ind";
1905 
1906         /**
1907          * The {@code element-descriptor} of the message.
1908          * <P>Type: TEXT</P>
1909          * @deprecated this column is no longer supported.
1910          * @hide
1911          */
1912         @Deprecated
1913         public static final String ELEMENT_DESCRIPTOR = "e_des";
1914 
1915         /**
1916          * The {@code limit} of the message.
1917          * <P>Type: INTEGER</P>
1918          * @deprecated this column is no longer supported.
1919          * @hide
1920          */
1921         @Deprecated
1922         public static final String LIMIT = "limit";
1923 
1924         /**
1925          * The {@code recommended-retrieval-mode} of the message.
1926          * <P>Type: INTEGER</P>
1927          * @deprecated this column is no longer supported.
1928          * @hide
1929          */
1930         @Deprecated
1931         public static final String RECOMMENDED_RETRIEVAL_MODE = "r_r_mod";
1932 
1933         /**
1934          * The {@code recommended-retrieval-mode-text} of the message.
1935          * <P>Type: TEXT</P>
1936          * @deprecated this column is no longer supported.
1937          * @hide
1938          */
1939         @Deprecated
1940         public static final String RECOMMENDED_RETRIEVAL_MODE_TEXT = "r_r_mod_txt";
1941 
1942         /**
1943          * The {@code status-text} of the message.
1944          * <P>Type: TEXT</P>
1945          * @deprecated this column is no longer supported.
1946          * @hide
1947          */
1948         @Deprecated
1949         public static final String STATUS_TEXT = "st_txt";
1950 
1951         /**
1952          * The {@code applic-id} of the message.
1953          * <P>Type: TEXT</P>
1954          * @deprecated this column is no longer supported.
1955          * @hide
1956          */
1957         @Deprecated
1958         public static final String APPLIC_ID = "apl_id";
1959 
1960         /**
1961          * The {@code reply-applic-id} of the message.
1962          * <P>Type: TEXT</P>
1963          * @deprecated this column is no longer supported.
1964          * @hide
1965          */
1966         @Deprecated
1967         public static final String REPLY_APPLIC_ID = "r_apl_id";
1968 
1969         /**
1970          * The {@code aux-applic-id} of the message.
1971          * <P>Type: TEXT</P>
1972          * @deprecated this column is no longer supported.
1973          * @hide
1974          */
1975         @Deprecated
1976         public static final String AUX_APPLIC_ID = "aux_apl_id";
1977 
1978         /**
1979          * The {@code drm-content} of the message.
1980          * <P>Type: TEXT</P>
1981          * @deprecated this column is no longer supported.
1982          * @hide
1983          */
1984         @Deprecated
1985         public static final String DRM_CONTENT = "drm_c";
1986 
1987         /**
1988          * The {@code adaptation-allowed} of the message.
1989          * <P>Type: TEXT</P>
1990          * @deprecated this column is no longer supported.
1991          * @hide
1992          */
1993         @Deprecated
1994         public static final String ADAPTATION_ALLOWED = "adp_a";
1995 
1996         /**
1997          * The {@code replace-id} of the message.
1998          * <P>Type: TEXT</P>
1999          * @deprecated this column is no longer supported.
2000          * @hide
2001          */
2002         @Deprecated
2003         public static final String REPLACE_ID = "repl_id";
2004 
2005         /**
2006          * The {@code cancel-id} of the message.
2007          * <P>Type: TEXT</P>
2008          * @deprecated this column is no longer supported.
2009          * @hide
2010          */
2011         @Deprecated
2012         public static final String CANCEL_ID = "cl_id";
2013 
2014         /**
2015          * The {@code cancel-status} of the message.
2016          * <P>Type: INTEGER</P>
2017          * @deprecated this column is no longer supported.
2018          * @hide
2019          */
2020         @Deprecated
2021         public static final String CANCEL_STATUS = "cl_st";
2022 
2023         /**
2024          * Is the message locked?
2025          * <P>Type: INTEGER (boolean)</P>
2026          */
2027         public static final String LOCKED = "locked";
2028 
2029         /**
2030          * The subscription to which the message belongs to. Its value will be
2031          * < 0 if the sub id cannot be determined.
2032          * <p>Type: INTEGER (long)</p>
2033          */
2034         public static final String SUBSCRIPTION_ID = "sub_id";
2035 
2036         /**
2037          * The identity of the sender of a sent message. It is
2038          * usually the package name of the app which sends the message.
2039          * <p class="note"><strong>Note:</strong>
2040          * This column is read-only. It is set by the provider and can not be changed by apps.
2041          * <p>Type: TEXT</p>
2042          */
2043         public static final String CREATOR = "creator";
2044     }
2045 
2046     /**
2047      * Columns for the "canonical_addresses" table used by MMS and SMS.
2048      */
2049     public interface CanonicalAddressesColumns extends BaseColumns {
2050         /**
2051          * An address used in MMS or SMS.  Email addresses are
2052          * converted to lower case and are compared by string
2053          * equality.  Other addresses are compared using
2054          * PHONE_NUMBERS_EQUAL.
2055          * <P>Type: TEXT</P>
2056          */
2057         public static final String ADDRESS = "address";
2058 
2059         /**
2060          * The subscription to which the message belongs to. Its value will be less than 0
2061          * if the sub id cannot be determined.
2062          * <p>Type: INTEGER (long) </p>
2063          * @hide
2064          */
2065         public static final String SUBSCRIPTION_ID = "sub_id";
2066     }
2067 
2068     /**
2069      * Columns for the "threads" table used by MMS and SMS.
2070      */
2071     public interface ThreadsColumns extends BaseColumns {
2072 
2073         /**
2074          * The date at which the thread was created.
2075          * <P>Type: INTEGER (long)</P>
2076          */
2077         public static final String DATE = "date";
2078 
2079         /**
2080          * A string encoding of the recipient IDs of the recipients of
2081          * the message, in numerical order and separated by spaces.
2082          * <P>Type: TEXT</P>
2083          */
2084         public static final String RECIPIENT_IDS = "recipient_ids";
2085 
2086         /**
2087          * The message count of the thread.
2088          * <P>Type: INTEGER</P>
2089          */
2090         public static final String MESSAGE_COUNT = "message_count";
2091 
2092         /**
2093          * Indicates whether all messages of the thread have been read.
2094          * <P>Type: INTEGER</P>
2095          */
2096         public static final String READ = "read";
2097 
2098         /**
2099          * The snippet of the latest message in the thread.
2100          * <P>Type: TEXT</P>
2101          */
2102         public static final String SNIPPET = "snippet";
2103 
2104         /**
2105          * The charset of the snippet.
2106          * <P>Type: INTEGER</P>
2107          */
2108         public static final String SNIPPET_CHARSET = "snippet_cs";
2109 
2110         /**
2111          * Type of the thread, either {@link Threads#COMMON_THREAD} or
2112          * {@link Threads#BROADCAST_THREAD}.
2113          * <P>Type: INTEGER</P>
2114          */
2115         public static final String TYPE = "type";
2116 
2117         /**
2118          * Indicates whether there is a transmission error in the thread.
2119          * <P>Type: INTEGER</P>
2120          */
2121         public static final String ERROR = "error";
2122 
2123         /**
2124          * Indicates whether this thread contains any attachments.
2125          * <P>Type: INTEGER</P>
2126          */
2127         public static final String HAS_ATTACHMENT = "has_attachment";
2128 
2129         /**
2130          * If the thread is archived
2131          * <P>Type: INTEGER (boolean)</P>
2132          */
2133         public static final String ARCHIVED = "archived";
2134 
2135         /**
2136          * The subscription to which the message belongs to. Its value will be less than 0
2137          * if the sub id cannot be determined.
2138          * <p>Type: INTEGER (long) </p>
2139          * @hide
2140          */
2141         public static final String SUBSCRIPTION_ID = "sub_id";
2142     }
2143 
2144     /**
2145      * Helper functions for the "threads" table used by MMS and SMS.
2146      *
2147      * Thread IDs are determined by the participants in a conversation and can be used to match
2148      * both SMS and MMS messages.
2149      *
2150      * To avoid issues where applications might cache a thread ID, the thread ID of a deleted thread
2151      * must not be reused to point at a new thread.
2152      */
2153     public static final class Threads implements ThreadsColumns {
2154 
2155         @UnsupportedAppUsage
2156         private static final String[] ID_PROJECTION = { BaseColumns._ID };
2157 
2158         /**
2159          * Private {@code content://} style URL for this table. Used by
2160          * {@link #getOrCreateThreadId(android.content.Context, java.util.Set)}.
2161          */
2162         @UnsupportedAppUsage
2163         private static final Uri THREAD_ID_CONTENT_URI = Uri.parse(
2164                 "content://mms-sms/threadID");
2165 
2166         /**
2167          * The {@code content://} style URL for this table, by conversation.
2168          */
2169         public static final Uri CONTENT_URI = Uri.withAppendedPath(
2170                 MmsSms.CONTENT_URI, "conversations");
2171 
2172         /**
2173          * The {@code content://} style URL for this table, for obsolete threads.
2174          */
2175         public static final Uri OBSOLETE_THREADS_URI = Uri.withAppendedPath(
2176                 CONTENT_URI, "obsolete");
2177 
2178         /** Thread type: common thread. */
2179         public static final int COMMON_THREAD    = 0;
2180 
2181         /** Thread type: broadcast thread. */
2182         public static final int BROADCAST_THREAD = 1;
2183 
2184         /**
2185          * Not instantiable.
2186          * @hide
2187          */
Threads()2188         private Threads() {
2189         }
2190 
2191         /**
2192          * This is a single-recipient version of {@code getOrCreateThreadId}.
2193          * It's convenient for use with SMS messages.
2194          * @param context the context object to use.
2195          * @param recipient the recipient to send to.
2196          */
getOrCreateThreadId(Context context, String recipient)2197         public static long getOrCreateThreadId(Context context, String recipient) {
2198             Set<String> recipients = new HashSet<String>();
2199 
2200             recipients.add(recipient);
2201             return getOrCreateThreadId(context, recipients);
2202         }
2203 
2204         /**
2205          * Given a set of recipients return its thread ID.
2206          * <p>
2207          * If a thread exists containing the provided participants, return its thread ID. Otherwise,
2208          * this will create a new thread containing the provided participants and return its ID.
2209          */
getOrCreateThreadId( Context context, Set<String> recipients)2210         public static long getOrCreateThreadId(
2211                 Context context, Set<String> recipients) {
2212             Uri.Builder uriBuilder = THREAD_ID_CONTENT_URI.buildUpon();
2213 
2214             for (String recipient : recipients) {
2215                 if (Mms.isEmailAddress(recipient)) {
2216                     recipient = Mms.extractAddrSpec(recipient);
2217                 }
2218 
2219                 uriBuilder.appendQueryParameter("recipient", recipient);
2220             }
2221 
2222             Uri uri = uriBuilder.build();
2223             //if (DEBUG) Rlog.v(TAG, "getOrCreateThreadId uri: " + uri);
2224 
2225             Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
2226                     uri, ID_PROJECTION, null, null, null);
2227             if (cursor != null) {
2228                 try {
2229                     if (cursor.moveToFirst()) {
2230                         return cursor.getLong(0);
2231                     } else {
2232                         Rlog.e(TAG, "getOrCreateThreadId returned no rows!");
2233                     }
2234                 } finally {
2235                     cursor.close();
2236                 }
2237             }
2238 
2239             Rlog.e(TAG, "getOrCreateThreadId failed with " + recipients.size() + " recipients");
2240             throw new IllegalArgumentException("Unable to find or allocate a thread ID.");
2241         }
2242     }
2243 
2244     /**
2245      * Contains all MMS messages.
2246      */
2247     public static final class Mms implements BaseMmsColumns {
2248 
2249         /**
2250          * Not instantiable.
2251          * @hide
2252          */
Mms()2253         private Mms() {
2254         }
2255 
2256         /**
2257          * The {@code content://} URI for this table.
2258          */
2259         public static final Uri CONTENT_URI = Uri.parse("content://mms");
2260 
2261         /**
2262          * Content URI for getting MMS report requests.
2263          */
2264         public static final Uri REPORT_REQUEST_URI = Uri.withAppendedPath(
2265                                             CONTENT_URI, "report-request");
2266 
2267         /**
2268          * Content URI for getting MMS report status.
2269          */
2270         public static final Uri REPORT_STATUS_URI = Uri.withAppendedPath(
2271                                             CONTENT_URI, "report-status");
2272 
2273         /**
2274          * The default sort order for this table.
2275          */
2276         public static final String DEFAULT_SORT_ORDER = "date DESC";
2277 
2278         /**
2279          * Regex pattern for names and email addresses.
2280          * <ul>
2281          *     <li><em>mailbox</em> = {@code name-addr}</li>
2282          *     <li><em>name-addr</em> = {@code [display-name] angle-addr}</li>
2283          *     <li><em>angle-addr</em> = {@code [CFWS] "<" addr-spec ">" [CFWS]}</li>
2284          * </ul>
2285          * @hide
2286          */
2287         @UnsupportedAppUsage
2288         public static final Pattern NAME_ADDR_EMAIL_PATTERN =
2289                 Pattern.compile("\\s*(\"[^\"]*\"|[^<>\"]+)\\s*<([^<>]+)>\\s*");
2290 
2291         /**
2292          * Helper method to query this table.
2293          * @hide
2294          */
query( ContentResolver cr, String[] projection)2295         public static Cursor query(
2296                 ContentResolver cr, String[] projection) {
2297             return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
2298         }
2299 
2300         /**
2301          * Helper method to query this table.
2302          * @hide
2303          */
query( ContentResolver cr, String[] projection, String where, String orderBy)2304         public static Cursor query(
2305                 ContentResolver cr, String[] projection,
2306                 String where, String orderBy) {
2307             return cr.query(CONTENT_URI, projection,
2308                     where, null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
2309         }
2310 
2311         /**
2312          * Helper method to extract email address from address string.
2313          * @hide
2314          */
2315         @UnsupportedAppUsage
extractAddrSpec(String address)2316         public static String extractAddrSpec(String address) {
2317             Matcher match = NAME_ADDR_EMAIL_PATTERN.matcher(address);
2318 
2319             if (match.matches()) {
2320                 return match.group(2);
2321             }
2322             return address;
2323         }
2324 
2325         /**
2326          * Is the specified address an email address?
2327          *
2328          * @param address the input address to test
2329          * @return true if address is an email address; false otherwise.
2330          * @hide
2331          */
2332         @UnsupportedAppUsage
isEmailAddress(String address)2333         public static boolean isEmailAddress(String address) {
2334             if (TextUtils.isEmpty(address)) {
2335                 return false;
2336             }
2337 
2338             String s = extractAddrSpec(address);
2339             Matcher match = Patterns.EMAIL_ADDRESS.matcher(s);
2340             return match.matches();
2341         }
2342 
2343         /**
2344          * Is the specified number a phone number?
2345          *
2346          * @param number the input number to test
2347          * @return true if number is a phone number; false otherwise.
2348          * @hide
2349          */
2350         @UnsupportedAppUsage
isPhoneNumber(String number)2351         public static boolean isPhoneNumber(String number) {
2352             if (TextUtils.isEmpty(number)) {
2353                 return false;
2354             }
2355 
2356             Matcher match = Patterns.PHONE.matcher(number);
2357             return match.matches();
2358         }
2359 
2360         /**
2361          * Contains all MMS messages in the MMS app inbox.
2362          */
2363         public static final class Inbox implements BaseMmsColumns {
2364 
2365             /**
2366              * Not instantiable.
2367              * @hide
2368              */
Inbox()2369             private Inbox() {
2370             }
2371 
2372             /**
2373              * The {@code content://} style URL for this table.
2374              */
2375             public static final Uri
2376                     CONTENT_URI = Uri.parse("content://mms/inbox");
2377 
2378             /**
2379              * The default sort order for this table.
2380              */
2381             public static final String DEFAULT_SORT_ORDER = "date DESC";
2382         }
2383 
2384         /**
2385          * Contains all MMS messages in the MMS app sent folder.
2386          */
2387         public static final class Sent implements BaseMmsColumns {
2388 
2389             /**
2390              * Not instantiable.
2391              * @hide
2392              */
Sent()2393             private Sent() {
2394             }
2395 
2396             /**
2397              * The {@code content://} style URL for this table.
2398              */
2399             public static final Uri
2400                     CONTENT_URI = Uri.parse("content://mms/sent");
2401 
2402             /**
2403              * The default sort order for this table.
2404              */
2405             public static final String DEFAULT_SORT_ORDER = "date DESC";
2406         }
2407 
2408         /**
2409          * Contains all MMS messages in the MMS app drafts folder.
2410          */
2411         public static final class Draft implements BaseMmsColumns {
2412 
2413             /**
2414              * Not instantiable.
2415              * @hide
2416              */
Draft()2417             private Draft() {
2418             }
2419 
2420             /**
2421              * The {@code content://} style URL for this table.
2422              */
2423             public static final Uri
2424                     CONTENT_URI = Uri.parse("content://mms/drafts");
2425 
2426             /**
2427              * The default sort order for this table.
2428              */
2429             public static final String DEFAULT_SORT_ORDER = "date DESC";
2430         }
2431 
2432         /**
2433          * Contains all MMS messages in the MMS app outbox.
2434          */
2435         public static final class Outbox implements BaseMmsColumns {
2436 
2437             /**
2438              * Not instantiable.
2439              * @hide
2440              */
Outbox()2441             private Outbox() {
2442             }
2443 
2444             /**
2445              * The {@code content://} style URL for this table.
2446              */
2447             public static final Uri
2448                     CONTENT_URI = Uri.parse("content://mms/outbox");
2449 
2450             /**
2451              * The default sort order for this table.
2452              */
2453             public static final String DEFAULT_SORT_ORDER = "date DESC";
2454         }
2455 
2456         /**
2457          * Contains address information for an MMS message.
2458          */
2459         public static final class Addr implements BaseColumns {
2460 
2461             /**
2462              * Not instantiable.
2463              * @hide
2464              */
Addr()2465             private Addr() {
2466             }
2467 
2468             /**
2469              * The ID of MM which this address entry belongs to.
2470              * <P>Type: INTEGER (long)</P>
2471              */
2472             public static final String MSG_ID = "msg_id";
2473 
2474             /**
2475              * The ID of contact entry in Phone Book.
2476              * <P>Type: INTEGER (long)</P>
2477              */
2478             public static final String CONTACT_ID = "contact_id";
2479 
2480             /**
2481              * The address text.
2482              * <P>Type: TEXT</P>
2483              */
2484             public static final String ADDRESS = "address";
2485 
2486             /**
2487              * Type of address: must be one of {@code PduHeaders.BCC},
2488              * {@code PduHeaders.CC}, {@code PduHeaders.FROM}, {@code PduHeaders.TO}.
2489              * <P>Type: INTEGER</P>
2490              */
2491             public static final String TYPE = "type";
2492 
2493             /**
2494              * Character set of this entry (MMS charset value).
2495              * <P>Type: INTEGER</P>
2496              */
2497             public static final String CHARSET = "charset";
2498 
2499             /**
2500              * The subscription to which the message belongs to. Its value will be less than 0
2501              * if the sub id cannot be determined.
2502              * <p>Type: INTEGER (long) </p>
2503              * @hide
2504              */
2505             public static final String SUBSCRIPTION_ID = "sub_id";
2506 
2507             /**
2508              * Generates a Addr {@link Uri} for message, used to perform Addr table operation
2509              * for mms.
2510              *
2511              * @param messageId the messageId used to generate Addr {@link Uri} dynamically
2512              * @return the addrUri used to perform Addr table operation for mms
2513              */
2514             @NonNull
getAddrUriForMessage(@onNull String messageId)2515             public static Uri getAddrUriForMessage(@NonNull String messageId) {
2516                 Uri addrUri = Mms.CONTENT_URI.buildUpon()
2517                         .appendPath(String.valueOf(messageId)).appendPath("addr").build();
2518                 return addrUri;
2519             }
2520         }
2521 
2522         /**
2523          * Contains message parts.
2524          *
2525          * To avoid issues where applications might cache a part ID, the ID of a deleted part must
2526          * not be reused to point at a new part.
2527          */
2528         public static final class Part implements BaseColumns {
2529 
2530             /**
2531              * Not instantiable.
2532              * @hide
2533              */
Part()2534             private Part() {
2535             }
2536 
2537             /**
2538              * The name of part table.
2539              */
2540             private static final String TABLE_PART = "part";
2541 
2542             /**
2543              * The {@code content://} style URL for this table. Can be appended with a part ID to
2544              * address individual parts.
2545              */
2546             @NonNull
2547             public static final Uri CONTENT_URI = Uri.withAppendedPath(Mms.CONTENT_URI, TABLE_PART);
2548 
2549             /**
2550              * The identifier of the message which this part belongs to.
2551              * <P>Type: INTEGER</P>
2552              */
2553             public static final String MSG_ID = "mid";
2554 
2555             /**
2556              * The order of the part.
2557              * <P>Type: INTEGER</P>
2558              */
2559             public static final String SEQ = "seq";
2560 
2561             /**
2562              * The content type of the part.
2563              * <P>Type: TEXT</P>
2564              */
2565             public static final String CONTENT_TYPE = "ct";
2566 
2567             /**
2568              * The name of the part.
2569              * <P>Type: TEXT</P>
2570              */
2571             public static final String NAME = "name";
2572 
2573             /**
2574              * The charset of the part.
2575              * <P>Type: TEXT</P>
2576              */
2577             public static final String CHARSET = "chset";
2578 
2579             /**
2580              * The file name of the part.
2581              * <P>Type: TEXT</P>
2582              */
2583             public static final String FILENAME = "fn";
2584 
2585             /**
2586              * The content disposition of the part.
2587              * <P>Type: TEXT</P>
2588              */
2589             public static final String CONTENT_DISPOSITION = "cd";
2590 
2591             /**
2592              * The content ID of the part.
2593              * <P>Type: INTEGER</P>
2594              */
2595             public static final String CONTENT_ID = "cid";
2596 
2597             /**
2598              * The content location of the part.
2599              * <P>Type: INTEGER</P>
2600              */
2601             public static final String CONTENT_LOCATION = "cl";
2602 
2603             /**
2604              * The start of content-type of the message.
2605              * <P>Type: INTEGER</P>
2606              */
2607             public static final String CT_START = "ctt_s";
2608 
2609             /**
2610              * The type of content-type of the message.
2611              * <P>Type: TEXT</P>
2612              */
2613             public static final String CT_TYPE = "ctt_t";
2614 
2615             /**
2616              * The location (on filesystem) of the binary data of the part.
2617              * <P>Type: INTEGER</P>
2618              */
2619             public static final String _DATA = "_data";
2620 
2621             /**
2622              * The message text.
2623              * <P>Type: TEXT</P>
2624              */
2625             public static final String TEXT = "text";
2626 
2627             /**
2628              * The subscription to which the message belongs to. Its value will be less than 0
2629              * if the sub id cannot be determined.
2630              * <p>Type: INTEGER (long) </p>
2631              * @hide
2632              */
2633             public static final String SUBSCRIPTION_ID = "sub_id";
2634 
2635             /**
2636              * Generates a Part {@link Uri} for message, used to perform Part table operation
2637              * for mms.
2638              *
2639              * @param messageId the messageId used to generate Part {@link Uri} dynamically
2640              * @return the partUri used to perform Part table operation for mms
2641              */
2642             @NonNull
getPartUriForMessage(@onNull String messageId)2643             public static Uri getPartUriForMessage(@NonNull String messageId) {
2644                 Uri partUri = Mms.CONTENT_URI.buildUpon()
2645                         .appendPath(String.valueOf(messageId)).appendPath(
2646                                 TABLE_PART).build();
2647                 return partUri;
2648             }
2649         }
2650 
2651         /**
2652          * Message send rate table.
2653          */
2654         public static final class Rate {
2655 
2656             /**
2657              * Not instantiable.
2658              * @hide
2659              */
Rate()2660             private Rate() {
2661             }
2662 
2663             /**
2664              * The {@code content://} style URL for this table.
2665              */
2666             public static final Uri CONTENT_URI = Uri.withAppendedPath(
2667                     Mms.CONTENT_URI, "rate");
2668 
2669             /**
2670              * When a message was successfully sent.
2671              * <P>Type: INTEGER (long)</P>
2672              */
2673             public static final String SENT_TIME = "sent_time";
2674 
2675             /**
2676              * The subscription to which the message belongs to. Its value will be less than 0
2677              * if the sub id cannot be determined.
2678              * <p>Type: INTEGER (long) </p>
2679              * @hide
2680              */
2681             public static final String SUBSCRIPTION_ID = "sub_id";
2682         }
2683 
2684         /**
2685          * Intents class.
2686          */
2687         public static final class Intents {
2688 
2689             /**
2690              * Not instantiable.
2691              * @hide
2692              */
Intents()2693             private Intents() {
2694             }
2695 
2696             /**
2697              * Indicates that the contents of specified URIs were changed.
2698              * The application which is showing or caching these contents
2699              * should be updated.
2700              */
2701             @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2702             public static final String CONTENT_CHANGED_ACTION
2703                     = "android.intent.action.CONTENT_CHANGED";
2704 
2705             /**
2706              * An extra field which stores the URI of deleted contents.
2707              */
2708             public static final String DELETED_CONTENTS = "deleted_contents";
2709         }
2710     }
2711 
2712     /**
2713      * Contains all MMS and SMS messages.
2714      */
2715     public static final class MmsSms implements BaseColumns {
2716 
2717         /**
2718          * Not instantiable.
2719          * @hide
2720          */
MmsSms()2721         private MmsSms() {
2722         }
2723 
2724         /**
2725          * The column to distinguish SMS and MMS messages in query results.
2726          */
2727         public static final String TYPE_DISCRIMINATOR_COLUMN =
2728                 "transport_type";
2729 
2730         /**
2731          * The {@code content://} style URL for this table.
2732          */
2733         public static final Uri CONTENT_URI = Uri.parse("content://mms-sms/");
2734 
2735         /**
2736          * The {@code content://} style URL for this table, by conversation.
2737          */
2738         public static final Uri CONTENT_CONVERSATIONS_URI = Uri.parse(
2739                 "content://mms-sms/conversations");
2740 
2741         /**
2742          * The {@code content://} style URL for this table, by phone number.
2743          */
2744         public static final Uri CONTENT_FILTER_BYPHONE_URI = Uri.parse(
2745                 "content://mms-sms/messages/byphone");
2746 
2747         /**
2748          * The {@code content://} style URL for undelivered messages in this table.
2749          */
2750         public static final Uri CONTENT_UNDELIVERED_URI = Uri.parse(
2751                 "content://mms-sms/undelivered");
2752 
2753         /**
2754          * The {@code content://} style URL for draft messages in this table.
2755          */
2756         public static final Uri CONTENT_DRAFT_URI = Uri.parse(
2757                 "content://mms-sms/draft");
2758 
2759         /**
2760          * The {@code content://} style URL for locked messages in this table.
2761          * <P>This {@link Uri} is used to check at most one locked message found in the union of MMS
2762          * and SMS messages. Also this will return only _id column in response.</P>
2763          */
2764         public static final Uri CONTENT_LOCKED_URI = Uri.parse(
2765                 "content://mms-sms/locked");
2766 
2767         /**
2768          * Pass in a query parameter called "pattern" which is the text to search for.
2769          * The sort order is fixed to be: {@code thread_id ASC, date DESC}.
2770          */
2771         public static final Uri SEARCH_URI = Uri.parse(
2772                 "content://mms-sms/search");
2773 
2774         // Constants for message protocol types.
2775 
2776         /** SMS protocol type. */
2777         public static final int SMS_PROTO = 0;
2778 
2779         /** MMS protocol type. */
2780         public static final int MMS_PROTO = 1;
2781 
2782         // Constants for error types of pending messages.
2783 
2784         /** Error type: no error. */
2785         public static final int NO_ERROR                      = 0;
2786 
2787         /** Error type: generic transient error. */
2788         public static final int ERR_TYPE_GENERIC              = 1;
2789 
2790         /** Error type: SMS protocol transient error. */
2791         public static final int ERR_TYPE_SMS_PROTO_TRANSIENT  = 2;
2792 
2793         /** Error type: MMS protocol transient error. */
2794         public static final int ERR_TYPE_MMS_PROTO_TRANSIENT  = 3;
2795 
2796         /** Error type: transport failure. */
2797         public static final int ERR_TYPE_TRANSPORT_FAILURE    = 4;
2798 
2799         /** Error type: permanent error (along with all higher error values). */
2800         public static final int ERR_TYPE_GENERIC_PERMANENT    = 10;
2801 
2802         /** Error type: SMS protocol permanent error. */
2803         public static final int ERR_TYPE_SMS_PROTO_PERMANENT  = 11;
2804 
2805         /** Error type: MMS protocol permanent error. */
2806         public static final int ERR_TYPE_MMS_PROTO_PERMANENT  = 12;
2807 
2808         /**
2809          * Contains pending messages info.
2810          */
2811         public static final class PendingMessages implements BaseColumns {
2812 
2813             /**
2814              * Not instantiable.
2815              * @hide
2816              */
PendingMessages()2817             private PendingMessages() {
2818             }
2819 
2820             public static final Uri CONTENT_URI = Uri.withAppendedPath(
2821                     MmsSms.CONTENT_URI, "pending");
2822 
2823             /**
2824              * The type of transport protocol (MMS or SMS).
2825              * <P>Type: INTEGER</P>
2826              */
2827             public static final String PROTO_TYPE = "proto_type";
2828 
2829             /**
2830              * The ID of the message to be sent or downloaded.
2831              * <P>Type: INTEGER (long)</P>
2832              */
2833             public static final String MSG_ID = "msg_id";
2834 
2835             /**
2836              * The type of the message to be sent or downloaded.
2837              * This field is only valid for MM. For SM, its value is always set to 0.
2838              * <P>Type: INTEGER</P>
2839              */
2840             public static final String MSG_TYPE = "msg_type";
2841 
2842             /**
2843              * The type of the error code.
2844              * <P>Type: INTEGER</P>
2845              */
2846             public static final String ERROR_TYPE = "err_type";
2847 
2848             /**
2849              * The error code of sending/retrieving process.
2850              * <P>Type: INTEGER</P>
2851              */
2852             public static final String ERROR_CODE = "err_code";
2853 
2854             /**
2855              * How many times we tried to send or download the message.
2856              * <P>Type: INTEGER</P>
2857              */
2858             public static final String RETRY_INDEX = "retry_index";
2859 
2860             /**
2861              * The time to do next retry.
2862              * <P>Type: INTEGER (long)</P>
2863              */
2864             public static final String DUE_TIME = "due_time";
2865 
2866             /**
2867              * The time we last tried to send or download the message.
2868              * <P>Type: INTEGER (long)</P>
2869              */
2870             public static final String LAST_TRY = "last_try";
2871 
2872             /**
2873              * The subscription to which the message belongs to. Its value will be
2874              * < 0 if the sub id cannot be determined.
2875              * <p>Type: INTEGER (long) </p>
2876              */
2877             public static final String SUBSCRIPTION_ID = "pending_sub_id";
2878         }
2879 
2880         /**
2881          * Words table used by provider for full-text searches.
2882          * @hide
2883          */
2884         public static final class WordsTable {
2885 
2886             /**
2887              * Not instantiable.
2888              * @hide
2889              */
WordsTable()2890             private WordsTable() {}
2891 
2892             /**
2893              * Primary key.
2894              * <P>Type: INTEGER (long)</P>
2895              */
2896             public static final String ID = "_id";
2897 
2898             /**
2899              * Source row ID.
2900              * <P>Type: INTEGER (long)</P>
2901              */
2902             public static final String SOURCE_ROW_ID = "source_id";
2903 
2904             /**
2905              * Table ID (either 1 or 2).
2906              * <P>Type: INTEGER</P>
2907              */
2908             public static final String TABLE_ID = "table_to_use";
2909 
2910             /**
2911              * The words to index.
2912              * <P>Type: TEXT</P>
2913              */
2914             public static final String INDEXED_TEXT = "index_text";
2915 
2916             /**
2917              * The subscription to which the message belongs to. Its value will be less than 0
2918              * if the sub id cannot be determined.
2919              * <p>Type: INTEGER (long) </p>
2920              * @hide
2921              */
2922             public static final String SUBSCRIPTION_ID = "sub_id";
2923         }
2924     }
2925 
2926     /**
2927      * Carriers class contains information about APNs, including MMSC information.
2928      */
2929     public static final class Carriers implements BaseColumns {
2930 
2931         /**
2932          * Not instantiable.
2933          * @hide
2934          */
Carriers()2935         private Carriers() {}
2936 
2937         /**
2938          * The {@code content://} style URL for this table.
2939          * For MSIM, this will return APNs for the default subscription
2940          * {@link SubscriptionManager#getDefaultSubscriptionId()}. To specify subId for MSIM,
2941          * use {@link Uri#withAppendedPath(Uri, String)} to append with subscription id.
2942          */
2943         @NonNull
2944         public static final Uri CONTENT_URI = Uri.parse("content://telephony/carriers");
2945 
2946         /**
2947          * The {@code content://} style URL for this table. Used for APN query based on current
2948          * subscription. Instead of specifying carrier matching information in the selection,
2949          * this API will return all matching APNs from current subscription carrier and queries
2950          * will be applied on top of that. If there is no match for MVNO (Mobile Virtual Network
2951          * Operator) APNs, return APNs from its MNO (based on mccmnc) instead. For MSIM, this will
2952          * return APNs for the default subscription
2953          * {@link SubscriptionManager#getDefaultSubscriptionId()}. To specify subId for MSIM,
2954          * use {@link Uri#withAppendedPath(Uri, String)} to append with subscription id.
2955          */
2956         @NonNull
2957         public static final Uri SIM_APN_URI = Uri.parse(
2958                 "content://telephony/carriers/sim_apn_list");
2959 
2960         /**
2961          * The {@code content://} style URL to be called from DevicePolicyManagerService,
2962          * can manage DPC-owned APNs.
2963          * @hide
2964          */
2965         public static final @NonNull Uri DPC_URI = Uri.parse("content://telephony/carriers/dpc");
2966 
2967         /**
2968          * The {@code content://} style URL to be called from Telephony to query APNs.
2969          * When DPC-owned APNs are enforced, only DPC-owned APNs are returned, otherwise only
2970          * non-DPC-owned APNs are returned. For MSIM, this will return APNs for the default
2971          * subscription {@link SubscriptionManager#getDefaultSubscriptionId()}. To specify subId
2972          * for MSIM, use {@link Uri#withAppendedPath(Uri, String)} to append with subscription id.
2973          * @hide
2974          */
2975         public static final Uri FILTERED_URI = Uri.parse("content://telephony/carriers/filtered");
2976 
2977         /**
2978          * The {@code content://} style URL to be called from DevicePolicyManagerService
2979          * or Telephony to manage whether DPC-owned APNs are enforced.
2980          * @hide
2981          */
2982         public static final Uri ENFORCE_MANAGED_URI = Uri.parse(
2983                 "content://telephony/carriers/enforce_managed");
2984 
2985         /**
2986          * The {@code content://} style URL for the perferred APN used for internet.
2987          *
2988          * @hide
2989          */
2990         public static final Uri PREFERRED_APN_URI = Uri.parse(
2991                 "content://telephony/carriers/preferapn/subId");
2992 
2993         /**
2994          * The {@code content://} style URL for the perferred APN set id.
2995          *
2996          * @hide
2997          */
2998         public static final Uri PREFERRED_APN_SET_URI = Uri.parse(
2999                 "content://telephony/carriers/preferapnset/subId");
3000 
3001         /**
3002          * The id of preferred APN.
3003          *
3004          * @see #PREFERRED_APN_URI
3005          * @hide
3006          */
3007         public static final String APN_ID = "apn_id";
3008 
3009         /**
3010          * The column name for ENFORCE_MANAGED_URI, indicates whether DPC-owned APNs are enforced.
3011          * @hide
3012          */
3013         public static final String ENFORCE_KEY = "enforced";
3014 
3015         /**
3016          * The default sort order for this table.
3017          */
3018         public static final String DEFAULT_SORT_ORDER = "name ASC";
3019 
3020         /**
3021          * Entry name.
3022          * <P>Type: TEXT</P>
3023          */
3024         public static final String NAME = "name";
3025 
3026         /**
3027          * APN name.
3028          * <P>Type: TEXT</P>
3029          */
3030         public static final String APN = "apn";
3031 
3032         /**
3033          * Proxy address.
3034          * <P>Type: TEXT</P>
3035          */
3036         public static final String PROXY = "proxy";
3037 
3038         /**
3039          * Proxy port.
3040          * <P>Type: TEXT</P>
3041          */
3042         public static final String PORT = "port";
3043 
3044         /**
3045          * MMS proxy address.
3046          * <P>Type: TEXT</P>
3047          */
3048         public static final String MMSPROXY = "mmsproxy";
3049 
3050         /**
3051          * MMS proxy port.
3052          * <P>Type: TEXT</P>
3053          */
3054         public static final String MMSPORT = "mmsport";
3055 
3056         /**
3057          * Server address.
3058          * <P>Type: TEXT</P>
3059          */
3060         public static final String SERVER = "server";
3061 
3062         /**
3063          * APN username.
3064          * <P>Type: TEXT</P>
3065          */
3066         public static final String USER = "user";
3067 
3068         /**
3069          * APN password.
3070          * <P>Type: TEXT</P>
3071          */
3072         public static final String PASSWORD = "password";
3073 
3074         /**
3075          * MMSC URL.
3076          * <P>Type: TEXT</P>
3077          */
3078         public static final String MMSC = "mmsc";
3079 
3080         /**
3081          * Mobile Country Code (MCC).
3082          * <P>Type: TEXT</P>
3083          * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return
3084          * matching APNs based on current subscription carrier, thus no need to specify MCC and
3085          * other carrier matching information. In the future, Android will not support MCC for
3086          * APN query.
3087          */
3088         public static final String MCC = "mcc";
3089 
3090         /**
3091          * Mobile Network Code (MNC).
3092          * <P>Type: TEXT</P>
3093          * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return
3094          * matching APNs based on current subscription carrier, thus no need to specify MNC and
3095          * other carrier matching information. In the future, Android will not support MNC for
3096          * APN query.
3097          */
3098         public static final String MNC = "mnc";
3099 
3100         /**
3101          * Numeric operator ID (as String). Usually {@code MCC + MNC}.
3102          * <P>Type: TEXT</P>
3103          * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return
3104          * matching APNs based on current subscription carrier, thus no need to specify Numeric
3105          * and other carrier matching information. In the future, Android will not support Numeric
3106          * for APN query.
3107          */
3108         public static final String NUMERIC = "numeric";
3109 
3110         /**
3111          * Authentication type.
3112          * <P>Type:  INTEGER</P>
3113          */
3114         public static final String AUTH_TYPE = "authtype";
3115 
3116         /**
3117          * Comma-delimited list of APN types.
3118          * <P>Type: TEXT</P>
3119          */
3120         public static final String TYPE = "type";
3121 
3122         /**
3123          * The protocol to use to connect to this APN.
3124          *
3125          * One of the {@code PDP_type} values in TS 27.007 section 10.1.1.
3126          * For example: {@code IP}, {@code IPV6}, {@code IPV4V6}, or {@code PPP}.
3127          * <P>Type: TEXT</P>
3128          */
3129         public static final String PROTOCOL = "protocol";
3130 
3131         /**
3132          * The protocol to use to connect to this APN when roaming.
3133          * The syntax is the same as protocol.
3134          * <P>Type: TEXT</P>
3135          */
3136         public static final String ROAMING_PROTOCOL = "roaming_protocol";
3137 
3138         /**
3139          * Is this the current APN?
3140          * <P>Type: INTEGER (boolean)</P>
3141          */
3142         public static final String CURRENT = "current";
3143 
3144         /**
3145          * Is this APN enabled?
3146          * <P>Type: INTEGER (boolean)</P>
3147          */
3148         public static final String CARRIER_ENABLED = "carrier_enabled";
3149 
3150         /**
3151          * Radio Access Technology info.
3152          * To check what values are allowed, refer to {@link android.telephony.ServiceState}.
3153          * This should be spread to other technologies,
3154          * but is currently only used for LTE (14) and eHRPD (13).
3155          * <P>Type: INTEGER</P>
3156          * @deprecated this column is no longer supported, use {@link #NETWORK_TYPE_BITMASK} instead
3157          */
3158         @Deprecated
3159         public static final String BEARER = "bearer";
3160 
3161         /**
3162          * Radio Access Technology bitmask.
3163          * To check what values can be contained, refer to {@link android.telephony.ServiceState}.
3164          * 0 indicates all techs otherwise first bit refers to RAT/bearer 1, second bit refers to
3165          * RAT/bearer 2 and so on.
3166          * Bitmask for a radio tech R is (1 << (R - 1))
3167          * <P>Type: INTEGER</P>
3168          * @hide
3169          * @deprecated this column is no longer supported, use {@link #NETWORK_TYPE_BITMASK} instead
3170          */
3171         @Deprecated
3172         public static final String BEARER_BITMASK = "bearer_bitmask";
3173 
3174         /**
3175          * Radio technology (network type) bitmask.
3176          * To check what values can be contained, refer to the NETWORK_TYPE_ constants in
3177          * {@link android.telephony.TelephonyManager}.
3178          * Bitmask for a radio tech R is (1 << (R - 1))
3179          * <P>Type: INTEGER</P>
3180          */
3181         public static final String NETWORK_TYPE_BITMASK = "network_type_bitmask";
3182 
3183         /**
3184          * Lingering radio technology (network type) bitmask.
3185          * To check what values can be contained, refer to the NETWORK_TYPE_ constants in
3186          * {@link android.telephony.TelephonyManager}.
3187          * Bitmask for a radio tech R is (1 << (R - 1))
3188          * <P>Type: INTEGER (long)</P>
3189          * @hide
3190          */
3191         public static final String LINGERING_NETWORK_TYPE_BITMASK =
3192                 "lingering_network_type_bitmask";
3193 
3194         /**
3195          * Sets whether the PDU session brought up by this APN should always be on.
3196          * See 3GPP TS 23.501 section 5.6.13
3197          * <P>Type: INTEGER</P>
3198          */
3199         @FlaggedApi(Flags.FLAG_APN_SETTING_FIELD_SUPPORT_FLAG)
3200         public static final String ALWAYS_ON = "always_on";
3201 
3202         /**
3203          * The infrastructure bitmask which the APN can be used on. For example, some APNs can only
3204          * be used when the device is on cellular, on satellite, or both. The default value is
3205          * 3 (INFRASTRUCTURE_CELLULAR | INFRASTRUCTURE_SATELLITE).
3206          *
3207          * <P>Type: INTEGER</P>
3208          * @hide
3209          */
3210         public static final String INFRASTRUCTURE_BITMASK = "infrastructure_bitmask";
3211 
3212         /**
3213          * Indicating if the APN is used for eSIM bootsrap provisioning. The default value is 0 (Not
3214          * used for eSIM bootstrap provisioning).
3215          *
3216          * <P>Type: INTEGER</P>
3217          * @hide
3218          */
3219         public static final String ESIM_BOOTSTRAP_PROVISIONING = "esim_bootstrap_provisioning";
3220 
3221         /**
3222          * MVNO type:
3223          * {@code SPN (Service Provider Name), IMSI, GID (Group Identifier Level 1)}.
3224          * <P>Type: TEXT</P>
3225          * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return
3226          * matching APNs based on current subscription carrier, thus no need to specify MVNO_TYPE
3227          * and other carrier matching information. In the future, Android will not support MVNO_TYPE
3228          * for APN query.
3229          */
3230         public static final String MVNO_TYPE = "mvno_type";
3231 
3232         /**
3233          * MVNO data.
3234          * Use the following examples.
3235          * <ul>
3236          *     <li>SPN: A MOBILE, BEN NL, ...</li>
3237          *     <li>IMSI: 302720x94, 2060188, ...</li>
3238          *     <li>GID: 4E, 33, ...</li>
3239          * </ul>
3240          * <P>Type: TEXT</P>
3241          * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return
3242          * matching APNs based on current subscription carrier, thus no need to specify
3243          * MVNO_MATCH_DATA and other carrier matching information. In the future, Android will not
3244          * support MVNO_MATCH_DATA for APN query.
3245          */
3246         public static final String MVNO_MATCH_DATA = "mvno_match_data";
3247 
3248         /**
3249          * The subscription to which the APN belongs to
3250          * <p>Type: INTEGER (long) </p>
3251          */
3252         public static final String SUBSCRIPTION_ID = "sub_id";
3253 
3254         /**
3255          * The profile_id to which the APN saved in modem.
3256          * <p>Type: INTEGER</p>
3257          *@hide
3258          */
3259         public static final String PROFILE_ID = "profile_id";
3260 
3261         /**
3262          * If set to {@code true}, then the APN setting will persist to the modem.
3263          * <p>Type: INTEGER (boolean)</p>
3264          *@hide
3265          */
3266         @SystemApi
3267         public static final String MODEM_PERSIST = "modem_cognitive";
3268 
3269         /**
3270          * The max number of connections of this APN.
3271          * <p>Type: INTEGER</p>
3272          *@hide
3273          */
3274         @SystemApi
3275         public static final String MAX_CONNECTIONS = "max_conns";
3276 
3277         /**
3278          * The wait time for retrying the APN, in milliseconds.
3279          * <p>Type: INTEGER</p>
3280          *@hide
3281          */
3282         @SystemApi
3283         public static final String WAIT_TIME_RETRY = "wait_time";
3284 
3285         /**
3286          * The max number of seconds this APN will support its maximum number of connections
3287          * as defined in {@link #MAX_CONNECTIONS}.
3288          * <p>Type: INTEGER</p>
3289          *@hide
3290          */
3291         @SystemApi
3292         public static final String TIME_LIMIT_FOR_MAX_CONNECTIONS = "max_conns_time";
3293 
3294         /**
3295          * The MTU (maximum transmit unit) size of the mobile interface to which the APN is
3296          * connected, in bytes.
3297          * <p>Type: INTEGER </p>
3298          * @hide
3299          * @deprecated use {@link #MTU_V4} or {@link #MTU_V6} instead
3300          */
3301         @SystemApi
3302         @Deprecated
3303         public static final String MTU = "mtu";
3304 
3305         /**
3306          * The MTU (maximum transmit unit) size of the mobile interface for IPv4 to which the APN is
3307          * connected, in bytes.
3308          * <p>Type: INTEGER </p>
3309          */
3310         @FlaggedApi(Flags.FLAG_APN_SETTING_FIELD_SUPPORT_FLAG)
3311         public static final String MTU_V4 = "mtu_v4";
3312 
3313         /**
3314          * The MTU (maximum transmit unit) size of the mobile interface for IPv6 to which the APN is
3315          * connected, in bytes.
3316          * <p>Type: INTEGER </p>
3317          */
3318         @FlaggedApi(Flags.FLAG_APN_SETTING_FIELD_SUPPORT_FLAG)
3319         public static final String MTU_V6 = "mtu_v6";
3320 
3321         /**
3322          * APN edit status. APN could be added/edited/deleted by a user or carrier.
3323          * see all possible returned APN edit status.
3324          * <ul>
3325          *     <li>{@link #UNEDITED}</li>
3326          *     <li>{@link #USER_EDITED}</li>
3327          *     <li>{@link #USER_DELETED}</li>
3328          *     <li>{@link #CARRIER_EDITED}</li>
3329          *     <li>{@link #CARRIER_DELETED}</li>
3330          * </ul>
3331          * <p>Type: INTEGER </p>
3332          * @hide
3333          */
3334         @SystemApi
3335         public static final String EDITED_STATUS = "edited";
3336 
3337         /**
3338          * {@code true} if this APN visible to the user, {@code false} otherwise.
3339          * <p>Type: INTEGER (boolean)</p>
3340          */
3341         @FlaggedApi(Flags.FLAG_APN_SETTING_FIELD_SUPPORT_FLAG)
3342         public static final String USER_VISIBLE = "user_visible";
3343 
3344         /**
3345          * {@code true} if the user allowed to edit this APN, {@code false} otherwise.
3346          * <p>Type: INTEGER (boolean)</p>
3347          */
3348         @FlaggedApi(Flags.FLAG_APN_SETTING_FIELD_SUPPORT_FLAG)
3349         public static final String USER_EDITABLE = "user_editable";
3350 
3351         /**
3352          * Integer value denoting an invalid APN id
3353          * @hide
3354          */
3355         public static final int INVALID_APN_ID = -1;
3356 
3357         /**
3358          * {@link #EDITED_STATUS APN edit status} indicates that this APN has not been edited or
3359          * fails to edit.
3360          * <p>Type: INTEGER </p>
3361          * @hide
3362          */
3363         @SystemApi
3364         public static final @EditStatus int UNEDITED = 0;
3365 
3366         /**
3367          * {@link #EDITED_STATUS APN edit status} indicates that this APN has been edited by users.
3368          * <p>Type: INTEGER </p>
3369          * @hide
3370          */
3371         @SystemApi
3372         public static final @EditStatus int USER_EDITED = 1;
3373 
3374         /**
3375          * {@link #EDITED_STATUS APN edit status} indicates that this APN has been deleted by users.
3376          * <p>Type: INTEGER </p>
3377          * @hide
3378          */
3379         @SystemApi
3380         public static final @EditStatus int USER_DELETED = 2;
3381 
3382         /**
3383          * {@link #EDITED_STATUS APN edit status} is an intermediate value used to indicate that an
3384          * entry deleted by the user is still present in the new APN database and therefore must
3385          * remain tagged as user deleted rather than completely removed from the database.
3386          * @hide
3387          */
3388         public static final int USER_DELETED_BUT_PRESENT_IN_XML = 3;
3389 
3390         /**
3391          * {@link #EDITED_STATUS APN edit status} indicates that this APN has been edited by
3392          * carriers.
3393          * <p>Type: INTEGER </p>
3394          * @hide
3395          */
3396         @SystemApi
3397         public static final @EditStatus int CARRIER_EDITED = 4;
3398 
3399         /**
3400          * {@link #EDITED_STATUS APN edit status} indicates that this APN has been deleted by
3401          * carriers. CARRIER_DELETED values are currently not used as there is no use case.
3402          * If they are used, delete() will have to change accordingly. Currently it is hardcoded to
3403          * USER_DELETED.
3404          * <p>Type: INTEGER </p>
3405          * @hide
3406          */
3407         public static final @EditStatus int CARRIER_DELETED = 5;
3408 
3409         /**
3410          * {@link #EDITED_STATUS APN edit status} is an intermediate value used to indicate that an
3411          * entry deleted by the carrier is still present in the new APN database and therefore must
3412          * remain tagged as user deleted rather than completely removed from the database.
3413          * @hide
3414          */
3415         public static final int CARRIER_DELETED_BUT_PRESENT_IN_XML = 6;
3416 
3417         /**
3418          * The owner of the APN.
3419          * <p>Type: INTEGER</p>
3420          * @hide
3421          */
3422         public static final String OWNED_BY = "owned_by";
3423 
3424         /**
3425          * Possible value for the OWNED_BY field.
3426          * APN is owned by DPC.
3427          * @hide
3428          */
3429         public static final int OWNED_BY_DPC = 0;
3430 
3431         /**
3432          * Possible value for the OWNED_BY field.
3433          * APN is owned by other sources.
3434          * @hide
3435          */
3436         public static final int OWNED_BY_OTHERS = 1;
3437 
3438         /**
3439          * The APN set id. When the user manually selects an APN or the framework sets an APN as
3440          * preferred, the device can only use APNs with the same set id as the selected APN.
3441          * <p>Type: INTEGER</p>
3442          * @hide
3443          */
3444         @SystemApi
3445         public static final String APN_SET_ID = "apn_set_id";
3446 
3447         /**
3448          * Possible value for the {@link #APN_SET_ID} field. By default APNs are added to set 0.
3449          * <p>Type: INTEGER</p>
3450          * @hide
3451          */
3452         @SystemApi
3453         public static final int NO_APN_SET_ID = 0;
3454 
3455         /**
3456          * Possible value for the {@link #APN_SET_ID} field.
3457          * APNs with MATCH_ALL_APN_SET_ID will be used regardless of any set ids of
3458          * the selected APN.
3459          * <p>Type: INTEGER</p>
3460          * @hide
3461          */
3462         @SystemApi
3463         public static final int MATCH_ALL_APN_SET_ID = -1;
3464 
3465         /**
3466          * A unique carrier id associated with this APN {@link TelephonyManager#getSimCarrierId()}
3467          * In case of matching carrier information, this should be used by default instead of
3468          * those fields of {@link #MCC}, {@link #MNC}, {@link #NUMERIC}, {@link #MVNO_TYPE},
3469          * {@link #MVNO_MATCH_DATA}, etc.
3470          * <p>Type: STRING</p>
3471          */
3472         public static final String CARRIER_ID = "carrier_id";
3473 
3474         /**
3475          * The skip 464xlat flag. Flag works as follows.
3476          * {@link #SKIP_464XLAT_DEFAULT}: the APN will skip only APN is IMS and no internet.
3477          * {@link #SKIP_464XLAT_DISABLE}: the APN will NOT skip 464xlat
3478          * {@link #SKIP_464XLAT_ENABLE}: the APN will skip 464xlat
3479          * <p>Type: INTEGER</p>
3480          *
3481          * @hide
3482          */
3483         public static final String SKIP_464XLAT = "skip_464xlat";
3484 
3485         /**
3486          * Possible value for the {@link #SKIP_464XLAT} field.
3487          * <p>Type: INTEGER</p>
3488          *
3489          * @hide
3490          */
3491         public static final int SKIP_464XLAT_DEFAULT = -1;
3492 
3493         /**
3494          * Possible value for the {@link #SKIP_464XLAT} field.
3495          * <p>Type: INTEGER</p>
3496          *
3497          * @hide
3498          */
3499         public static final int SKIP_464XLAT_DISABLE = 0;
3500 
3501         /**
3502          * Possible value for the {@link #SKIP_464XLAT} field.
3503          * <p>Type: INTEGER</p>
3504          *
3505          * @hide
3506          */
3507         public static final int SKIP_464XLAT_ENABLE = 1;
3508 
3509 
3510         /** @hide */
3511         @IntDef({
3512                 UNEDITED,
3513                 USER_EDITED,
3514                 USER_DELETED,
3515                 CARRIER_DELETED,
3516                 CARRIER_EDITED,
3517         })
3518         @Retention(RetentionPolicy.SOURCE)
3519         public @interface EditStatus {}
3520 
3521         /**
3522          * Compat framework change ID for the APN db read permission change.
3523          *
3524          * In API level 30 and beyond, accessing the APN database will require the
3525          * {@link android.Manifest.permission#WRITE_APN_SETTINGS} permission. This change ID tracks
3526          * apps that are affected because they don't hold this permission.
3527          * @hide
3528          */
3529         @ChangeId
3530         @EnabledAfter(targetSdkVersion = android.os.Build.VERSION_CODES.Q)
3531         public static final long APN_READING_PERMISSION_CHANGE_ID = 124107808L;
3532     }
3533 
3534     /**
3535      * Contains received cell broadcast messages. More details are available in 3GPP TS 23.041.
3536      * @hide
3537      */
3538     @SystemApi
3539     public static final class CellBroadcasts implements BaseColumns {
3540 
3541         /**
3542          * Not instantiable.
3543          * @hide
3544          */
CellBroadcasts()3545         private CellBroadcasts() {}
3546 
3547         /**
3548          * The {@code content://} URI for this table.
3549          * Only privileged framework components running on phone or network stack uid can
3550          * query or modify this table.
3551          */
3552         @NonNull
3553         public static final Uri CONTENT_URI = Uri.parse("content://cellbroadcasts");
3554 
3555         /**
3556          * The {@code content://} URI for query cellbroadcast message history.
3557          * query results include following entries
3558          * <ul>
3559          *     <li>{@link #_ID}</li>
3560          *     <li>{@link #SLOT_INDEX}</li>
3561          *     <li>{@link #GEOGRAPHICAL_SCOPE}</li>
3562          *     <li>{@link #PLMN}</li>
3563          *     <li>{@link #LAC}</li>
3564          *     <li>{@link #CID}</li>
3565          *     <li>{@link #SERIAL_NUMBER}</li>
3566          *     <li>{@link #SERVICE_CATEGORY}</li>
3567          *     <li>{@link #LANGUAGE_CODE}</li>
3568          *     <li>{@link #MESSAGE_BODY}</li>
3569          *     <li>{@link #DELIVERY_TIME}</li>
3570          *     <li>{@link #MESSAGE_READ}</li>
3571          *     <li>{@link #MESSAGE_FORMAT}</li>
3572          *     <li>{@link #MESSAGE_PRIORITY}</li>
3573          *     <li>{@link #ETWS_WARNING_TYPE}</li>
3574          *     <li>{@link #CMAS_MESSAGE_CLASS}</li>
3575          *     <li>{@link #CMAS_CATEGORY}</li>
3576          *     <li>{@link #CMAS_RESPONSE_TYPE}</li>
3577          *     <li>{@link #CMAS_SEVERITY}</li>
3578          *     <li>{@link #CMAS_URGENCY}</li>
3579          *     <li>{@link #CMAS_CERTAINTY}</li>
3580          * </ul>
3581          */
3582         @RequiresPermission(Manifest.permission.READ_CELL_BROADCASTS)
3583         @NonNull
3584         public static final Uri MESSAGE_HISTORY_URI = Uri.parse("content://cellbroadcasts/history");
3585 
3586         /**
3587          * The authority for the legacy cellbroadcast provider.
3588          * This is used for OEM data migration. OEMs want to migrate message history or
3589          * sharepreference data to mainlined cellbroadcastreceiver app, should have a
3590          * contentprovider with authority: cellbroadcast-legacy. Mainlined cellbroadcastreceiver
3591          * will interact with this URI to retrieve data and persists to mainlined cellbroadcast app.
3592          *
3593          * @hide
3594          */
3595         @SystemApi
3596         public static final @NonNull String AUTHORITY_LEGACY = "cellbroadcast-legacy";
3597 
3598         /**
3599          * A content:// style uri to the authority for the legacy cellbroadcast provider.
3600          * @hide
3601          */
3602         @SystemApi
3603         public static final @NonNull Uri AUTHORITY_LEGACY_URI =
3604                 Uri.parse("content://cellbroadcast-legacy");
3605 
3606         /**
3607          * Method name to {@link android.content.ContentProvider#call(String, String, Bundle)
3608          * for {@link #AUTHORITY_LEGACY}. Used to query cellbroadcast {@link Preference},
3609          * containing following supported entries
3610          * <ul>
3611          *     <li>{@link #ENABLE_AREA_UPDATE_INFO_PREF}</li>
3612          *     <li>{@link #ENABLE_TEST_ALERT_PREF}</li>
3613          *     <li>{@link #ENABLE_STATE_LOCAL_TEST_PREF}</li>
3614          *     <li>{@link #ENABLE_PUBLIC_SAFETY_PREF}</li>
3615          *     <li>{@link #ENABLE_CMAS_AMBER_PREF}</li>
3616          *     <li>{@link #ENABLE_CMAS_SEVERE_THREAT_PREF}</li>
3617          *     <li>{@link #ENABLE_CMAS_EXTREME_THREAT_PREF}</li>
3618          *     <li>{@link #ENABLE_CMAS_PRESIDENTIAL_PREF}</li>
3619          *     <li>{@link #ENABLE_ALERT_VIBRATION_PREF}</li>
3620          *     <li>{@link #ENABLE_EMERGENCY_PERF}</li>
3621          *     <li>{@link #ENABLE_CMAS_IN_SECOND_LANGUAGE_PREF}</li>
3622          * </ul>
3623          * @hide
3624          */
3625         @SystemApi
3626         public static final @NonNull String CALL_METHOD_GET_PREFERENCE = "get_preference";
3627 
3628         /**
3629          * Arg name to {@link android.content.ContentProvider#call(String, String, Bundle)}
3630          * for {@link #AUTHORITY_LEGACY}.
3631          * Contains all supported shared preferences for cellbroadcast.
3632          *
3633          * @hide
3634          */
3635         @SystemApi
3636         public static final class Preference {
3637             /**
3638              * Not Instantiatable.
3639              * @hide
3640              */
Preference()3641             private Preference() {}
3642 
3643             /** Preference to enable area update info alert */
3644             public static final @NonNull String ENABLE_AREA_UPDATE_INFO_PREF =
3645                     "enable_area_update_info_alerts";
3646 
3647             /** Preference to enable test alert */
3648             public static final @NonNull String ENABLE_TEST_ALERT_PREF =
3649                     "enable_test_alerts";
3650 
3651             /** Preference to enable state local test alert */
3652             public static final @NonNull String ENABLE_STATE_LOCAL_TEST_PREF
3653                     = "enable_state_local_test_alerts";
3654 
3655             /** Preference to enable public safety alert */
3656             public static final @NonNull String ENABLE_PUBLIC_SAFETY_PREF
3657                     = "enable_public_safety_messages";
3658 
3659             /** Preference to enable amber alert */
3660             public static final @NonNull String ENABLE_CMAS_AMBER_PREF
3661                     = "enable_cmas_amber_alerts";
3662 
3663             /** Preference to enable severe threat alert */
3664             public static final @NonNull String ENABLE_CMAS_SEVERE_THREAT_PREF
3665                     = "enable_cmas_severe_threat_alerts";
3666 
3667             /** Preference to enable extreme threat alert */
3668             public static final @NonNull String ENABLE_CMAS_EXTREME_THREAT_PREF =
3669                     "enable_cmas_extreme_threat_alerts";
3670 
3671             /** Preference to enable presidential alert */
3672             public static final @NonNull String ENABLE_CMAS_PRESIDENTIAL_PREF =
3673                     "enable_cmas_presidential_alerts";
3674 
3675             /** Preference to enable alert vibration */
3676             public static final @NonNull String ENABLE_ALERT_VIBRATION_PREF =
3677                     "enable_alert_vibrate";
3678 
3679             /** Preference to enable emergency alert */
3680             public static final @NonNull String ENABLE_EMERGENCY_PERF =
3681                     "enable_emergency_alerts";
3682 
3683             /** Preference to enable receive alerts in second language */
3684             public static final @NonNull String ENABLE_CMAS_IN_SECOND_LANGUAGE_PREF =
3685                     "receive_cmas_in_second_language";
3686         }
3687 
3688         /**
3689          * The subscription which received this cell broadcast message.
3690          * <P>Type: INTEGER</P>
3691          */
3692         public static final String SUBSCRIPTION_ID = "sub_id";
3693 
3694         /**
3695          * The slot which received this cell broadcast message.
3696          * <P>Type: INTEGER</P>
3697          */
3698         public static final String SLOT_INDEX = "slot_index";
3699 
3700         /**
3701          * Message geographical scope. Valid values are:
3702          * <ul>
3703          * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_CELL_WIDE}. meaning the
3704          * message is for the radio service cell</li>
3705          * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_CELL_WIDE_IMMEDIATE},
3706          * meaning the message is for the radio service cell and immediately displayed</li>
3707          * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_PLMN_WIDE}, meaning the
3708          * message is for the PLMN (i.e. MCC/MNC)</li>
3709          * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_LOCATION_AREA_WIDE},
3710          * meaning the message is for the location area (in GSM) or service area (in UMTS)</li>
3711          * </ul>
3712          *
3713          * <p>A message meant for a particular scope is automatically dismissed when the device
3714          * exits that scope.</p>
3715          * <P>Type: INTEGER</P>
3716          */
3717         public static final String GEOGRAPHICAL_SCOPE = "geo_scope";
3718 
3719         /**
3720          * Message serial number.
3721          * <p>
3722          * A 16-bit integer which identifies a particular CBS (cell
3723          * broadcast short message service) message. The core network is responsible for
3724          * allocating this value, and the value may be managed cyclically (3GPP TS 23.041 section
3725          * 9.2.1) once the serial message has been incremented a sufficient number of times.
3726          * </p>
3727          * <P>Type: INTEGER</P>
3728          */
3729         public static final String SERIAL_NUMBER = "serial_number";
3730 
3731         /**
3732          * PLMN (i.e. MCC/MNC) of broadcast sender. {@code SERIAL_NUMBER + PLMN + LAC + CID}
3733          * uniquely identifies a broadcast for duplicate detection purposes.
3734          * <P>Type: TEXT</P>
3735          */
3736         public static final String PLMN = "plmn";
3737 
3738         /**
3739          * Location area code (LAC).
3740          * <p>Code representing location area (GSM) or service area (UMTS) of broadcast sender.
3741          * Unused for CDMA. Only included if Geographical Scope of message is not PLMN wide (01).
3742          * This value is sent by the network based on the cell tower.
3743          * <P>Type: INTEGER</P>
3744          */
3745         public static final String LAC = "lac";
3746 
3747         /**
3748          * Cell ID of message sender (GSM/UMTS). Unused for CDMA. Only included when the
3749          * Geographical Scope of message is cell wide (00 or 11).
3750          * <P>Type: INTEGER</P>
3751          */
3752         public static final String CID = "cid";
3753 
3754         /**
3755          * Service category which represents the general topic of the message.
3756          * <p>
3757          * For GSM/UMTS: message identifier (see 3GPP TS 23.041 section 9.4.1.2.2)
3758          * For CDMA: a 16-bit CDMA service category (see 3GPP2 C.R1001-D section 9.3)
3759          * </p>
3760          * <P>Type: INTEGER</P>
3761          */
3762         public static final String SERVICE_CATEGORY = "service_category";
3763 
3764         /**
3765          * Message language code. (See 3GPP TS 23.041 section 9.4.1.2.3 for details).
3766          * <P>Type: TEXT</P>
3767          */
3768         public static final String LANGUAGE_CODE = "language";
3769 
3770         /**
3771          * Dats coding scheme of the message.
3772          * <p>
3773          * The data coding scheme (dcs) value defined in 3GPP TS 23.038 section 4
3774          * </p>
3775          * <P>Type: INTEGER</P>
3776          */
3777         public static final String DATA_CODING_SCHEME = "dcs";
3778 
3779         /**
3780          * Message body.
3781          * <P>Type: TEXT</P>
3782          */
3783         public static final String MESSAGE_BODY = "body";
3784 
3785         /**
3786          * Message delivery time.
3787          * <p>This value is a system timestamp using {@link System#currentTimeMillis}</p>
3788          * <P>Type: INTEGER (long)</P>
3789          */
3790         public static final String DELIVERY_TIME = "date";
3791 
3792         /**
3793          * Has the message been viewed?
3794          * <P>Type: INTEGER (boolean)</P>
3795          */
3796         public static final String MESSAGE_READ = "read";
3797 
3798         /**
3799          * Message format ({@link android.telephony.SmsCbMessage#MESSAGE_FORMAT_3GPP} or
3800          * {@link android.telephony.SmsCbMessage#MESSAGE_FORMAT_3GPP2}).
3801          * <P>Type: INTEGER</P>
3802          */
3803         public static final String MESSAGE_FORMAT = "format";
3804 
3805         /**
3806          * Message priority.
3807          * <p>This includes
3808          * <ul>
3809          * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_NORMAL}</li>
3810          * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_INTERACTIVE}</li>
3811          * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_URGENT}</li>
3812          * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_EMERGENCY}</li>
3813          * </p>
3814          * </ul>
3815          * <P>Type: INTEGER</P>
3816          */
3817         public static final String MESSAGE_PRIORITY = "priority";
3818 
3819         /**
3820          * ETWS (Earthquake and Tsunami Warning System) warning type (ETWS alerts only).
3821          * <p>See {@link android.telephony.SmsCbEtwsInfo}</p>
3822          * <P>Type: INTEGER</P>
3823          */
3824         public static final String ETWS_WARNING_TYPE = "etws_warning_type";
3825 
3826         /**
3827          * ETWS (Earthquake and Tsunami Warning System, Japan only) primary message or not. The
3828          * primary message is sent as soon as the emergency occurs. It does not provide any
3829          * information except the emergency type (e.g. earthquake, tsunami). The ETWS secondary
3830          * message is sent afterwards and provides the details of the emergency.
3831          *
3832          * <p>See {@link android.telephony.SmsCbEtwsInfo}</p>
3833          * <P>Type: BOOLEAN</P>
3834          */
3835         public static final String ETWS_IS_PRIMARY = "etws_is_primary";
3836 
3837         /**
3838          * CMAS (Commercial Mobile Alert System) message class (CMAS alerts only).
3839          * <p>See {@link android.telephony.SmsCbCmasInfo}</p>
3840          * <P>Type: INTEGER</P>
3841          */
3842         public static final String CMAS_MESSAGE_CLASS = "cmas_message_class";
3843 
3844         /**
3845          * CMAS category (CMAS alerts only).
3846          * <P>Type: INTEGER</P>
3847          */
3848         public static final String CMAS_CATEGORY = "cmas_category";
3849 
3850         /**
3851          * CMAS response type (CMAS alerts only).
3852          * <P>Type: INTEGER</P>
3853          */
3854         public static final String CMAS_RESPONSE_TYPE = "cmas_response_type";
3855 
3856         /**
3857          * CMAS severity (CMAS alerts only).
3858          * <P>Type: INTEGER</P>
3859          */
3860         public static final String CMAS_SEVERITY = "cmas_severity";
3861 
3862         /**
3863          * CMAS urgency (CMAS alerts only).
3864          * <P>Type: INTEGER</P>
3865          */
3866         public static final String CMAS_URGENCY = "cmas_urgency";
3867 
3868         /**
3869          * CMAS certainty (CMAS alerts only).
3870          * <P>Type: INTEGER</P>
3871          */
3872         public static final String CMAS_CERTAINTY = "cmas_certainty";
3873 
3874         /** The default sort order for this table. */
3875         public static final String DEFAULT_SORT_ORDER = DELIVERY_TIME + " DESC";
3876 
3877         /**
3878          * The timestamp in millisecond, reported by {@link System#currentTimeMillis()}, when the
3879          * device received the message.
3880          * <P>Type: BIGINT</P>
3881          */
3882         public static final String RECEIVED_TIME = "received_time";
3883 
3884         /**
3885          * The timestamp in millisecond, reported by {@link System#currentTimeMillis()}, when
3886          * location was checked last time. Note this is only applicable to geo-targeting message.
3887          * For non geo-targeting message. the field will be set to -1.
3888          * <P>Type: BIGINT</P>
3889          */
3890         public static final String LOCATION_CHECK_TIME = "location_check_time";
3891         /**
3892          * Indicates that whether the message has been broadcasted to the application.
3893          * <P>Type: BOOLEAN</P>
3894          */
3895         // TODO: deprecate this in S.
3896         public static final String MESSAGE_BROADCASTED = "message_broadcasted";
3897 
3898         /**
3899          * Indicates that whether the message has been displayed to the user.
3900          * <P>Type: BOOLEAN</P>
3901          */
3902         public static final String MESSAGE_DISPLAYED = "message_displayed";
3903 
3904         /**
3905          * The Warning Area Coordinates Elements. This element is used for geo-fencing purpose.
3906          *
3907          * The geometry and its coordinates are separated vertical bar, the first item is the
3908          * geometry type and the remaining items are the parameter of this geometry.
3909          *
3910          * Only circle and polygon are supported. The coordinates are represented in Horizontal
3911          * coordinates format.
3912          *
3913          * Coordinate encoding:
3914          * "latitude, longitude"
3915          * where -90.00000 <= latitude <= 90.00000 and -180.00000 <= longitude <= 180.00000
3916          *
3917          * Polygon encoding:
3918          * "polygon|lat1,lng1|lat2,lng2|...|latn,lngn"
3919          * lat1,lng1 ... latn,lngn are the vertices coordinate of the polygon.
3920          *
3921          * Circle encoding:
3922          * "circle|lat,lng|radius".
3923          * lat,lng is the center of the circle. The unit of circle's radius is meter.
3924          *
3925          * Example:
3926          * "circle|0,0|100" mean a circle which center located at (0,0) and its radius is 100 meter.
3927          * "polygon|0,1.5|0,1|1,1|1,0" mean a polygon has vertices (0,1.5),(0,1),(1,1),(1,0).
3928          *
3929          * There could be more than one geometry store in this field, they are separated by a
3930          * semicolon.
3931          *
3932          * Example:
3933          * "circle|0,0|100;polygon|0,0|0,1.5|1,1|1,0;circle|100.123,100|200.123"
3934          *
3935          * <P>Type: TEXT</P>
3936          */
3937         public static final String GEOMETRIES = "geometries";
3938 
3939         /**
3940          * Geo-Fencing Maximum Wait Time in second. The range of the time is [0, 255]. A device
3941          * shall allow to determine its position meeting operator policy. If the device is unable to
3942          * determine its position meeting operator policy within the GeoFencing Maximum Wait Time,
3943          * it shall present the alert to the user and discontinue further positioning determination
3944          * for the alert.
3945          *
3946          * <P>Type: INTEGER</P>
3947          */
3948         public static final String MAXIMUM_WAIT_TIME = "maximum_wait_time";
3949 
3950         /**
3951          * Query columns for instantiating com.android.cellbroadcastreceiver.CellBroadcastMessage.
3952          * @hide
3953          */
3954         @NonNull
3955         public static final String[] QUERY_COLUMNS = {
3956                 _ID,
3957                 GEOGRAPHICAL_SCOPE,
3958                 PLMN,
3959                 LAC,
3960                 CID,
3961                 SERIAL_NUMBER,
3962                 SERVICE_CATEGORY,
3963                 LANGUAGE_CODE,
3964                 MESSAGE_BODY,
3965                 DELIVERY_TIME,
3966                 MESSAGE_READ,
3967                 MESSAGE_FORMAT,
3968                 MESSAGE_PRIORITY,
3969                 ETWS_WARNING_TYPE,
3970                 CMAS_MESSAGE_CLASS,
3971                 CMAS_CATEGORY,
3972                 CMAS_RESPONSE_TYPE,
3973                 CMAS_SEVERITY,
3974                 CMAS_URGENCY,
3975                 CMAS_CERTAINTY
3976         };
3977     }
3978 
3979     /**
3980      * Constants for interfacing with the ServiceStateProvider and the different fields of the
3981      * {@link ServiceState} class accessible through the provider.
3982      */
3983     public static final class ServiceStateTable {
3984 
3985         /**
3986          * Not instantiable.
3987          * @hide
3988          */
ServiceStateTable()3989         private ServiceStateTable() {}
3990 
3991         /**
3992          * The authority string for the ServiceStateProvider
3993          */
3994         public static final String AUTHORITY = "service-state";
3995 
3996         /**
3997          * The {@code content://} style URL for the ServiceStateProvider
3998          */
3999         public static final Uri CONTENT_URI = Uri.parse("content://service-state/");
4000 
4001         /**
4002          * Generates a content {@link Uri} used to receive updates on a specific field in the
4003          * ServiceState provider.
4004          * <p>
4005          * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
4006          * {@link ServiceState} while your app is running.
4007          * You can also use a {@link android.app.job.JobService} to
4008          * ensure your app is notified of changes to the {@link Uri} even when it is not running.
4009          * Note, however, that using a {@link android.app.job.JobService}
4010          * does not guarantee timely delivery of
4011          * updates to the {@link Uri}.
4012          *
4013          * @param subscriptionId the subscriptionId to receive updates on
4014          * @param field the ServiceState field to receive updates on
4015          * @return the Uri used to observe {@link ServiceState} changes
4016          */
getUriForSubscriptionIdAndField(int subscriptionId, String field)4017         public static Uri getUriForSubscriptionIdAndField(int subscriptionId, String field) {
4018             return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId))
4019                     .appendEncodedPath(field).build();
4020         }
4021 
4022         /**
4023          * Generates a content {@link Uri} used to receive updates on every field in the
4024          * ServiceState provider.
4025          * <p>
4026          * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
4027          * {@link ServiceState} while your app is running.  You can also use a
4028          * {@link android.app.job.JobService} to
4029          * ensure your app is notified of changes to the {@link Uri} even when it is not running.
4030          * Note, however, that using a {@link android.app.job.JobService}
4031          * does not guarantee timely delivery of
4032          * updates to the {@link Uri}.
4033          *
4034          * @param subscriptionId the subscriptionId to receive updates on
4035          * @return the Uri used to observe {@link ServiceState} changes
4036          */
getUriForSubscriptionId(int subscriptionId)4037         public static Uri getUriForSubscriptionId(int subscriptionId) {
4038             return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId)).build();
4039         }
4040 
4041         /**
4042          * An integer value indicating the current voice service state.
4043          * <p>
4044          * Valid values: {@link ServiceState#STATE_IN_SERVICE},
4045          * {@link ServiceState#STATE_OUT_OF_SERVICE}, {@link ServiceState#STATE_EMERGENCY_ONLY},
4046          * {@link ServiceState#STATE_POWER_OFF}.
4047          * <p>
4048          * This is the same as {@link ServiceState#getState()}.
4049          */
4050         public static final String VOICE_REG_STATE = "voice_reg_state";
4051 
4052         /**
4053          * An integer value indicating the current data service state.
4054          * <p>
4055          * Valid values: {@link ServiceState#STATE_IN_SERVICE},
4056          * {@link ServiceState#STATE_OUT_OF_SERVICE}, {@link ServiceState#STATE_EMERGENCY_ONLY},
4057          * {@link ServiceState#STATE_POWER_OFF}.
4058          */
4059         public static final String DATA_REG_STATE = "data_reg_state";
4060 
4061         /**
4062          * The current registered operator numeric id.
4063          * <p>
4064          * In GSM/UMTS, numeric format is 3 digit country code plus 2 or 3 digit
4065          * network code.
4066          * <p>
4067          * This is the same as {@link ServiceState#getOperatorNumeric()}.
4068          */
4069         public static final String VOICE_OPERATOR_NUMERIC = "voice_operator_numeric";
4070 
4071         /**
4072          * The current network selection mode.
4073          * <p>
4074          * This is the same as {@link ServiceState#getIsManualSelection()}.
4075          */
4076         public static final String IS_MANUAL_NETWORK_SELECTION = "is_manual_network_selection";
4077 
4078         /**
4079          * The current data network type.
4080          * <p>
4081          * This is the same as {@link TelephonyManager#getDataNetworkType()}.
4082          */
4083         public static final String DATA_NETWORK_TYPE = "data_network_type";
4084 
4085         /**
4086          * An integer value indicating the current duplex mode if the radio technology is LTE,
4087          * LTE-CA or NR.
4088          * <p>
4089          * Valid values: {@link ServiceState#DUPLEX_MODE_UNKNOWN},
4090          * {@link ServiceState#DUPLEX_MODE_FDD}, {@link ServiceState#DUPLEX_MODE_TDD}.
4091          * <p>
4092          * This is the same as {@link ServiceState#getDuplexMode()}.
4093          */
4094         public static final String DUPLEX_MODE = "duplex_mode";
4095     }
4096 
4097     /**
4098      * Contains carrier identification information for the current subscriptions.
4099      */
4100     public static final class CarrierId implements BaseColumns {
4101         /**
4102          * Not instantiable.
4103          * @hide
4104          */
CarrierId()4105         private CarrierId() {}
4106 
4107         /**
4108          * The {@code content://} style URI for this provider.
4109          */
4110         public static final Uri CONTENT_URI = Uri.parse("content://carrier_id");
4111 
4112         /**
4113          * The authority string for the CarrierId Provider
4114          * @hide
4115          */
4116         public static final String AUTHORITY = "carrier_id";
4117 
4118 
4119         /**
4120          * Generates a content {@link Uri} used to receive updates on carrier identity change
4121          * on the given subscriptionId
4122          * <p>
4123          * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
4124          * carrier identity {@link TelephonyManager#getSimCarrierId()}
4125          * while your app is running. You can also use a {@link android.app.job.JobService}
4126          * to ensure your app
4127          * is notified of changes to the {@link Uri} even when it is not running.
4128          * Note, however, that using a {@link android.app.job.JobService} does not guarantee
4129          * timely delivery of updates to the {@link Uri}.
4130          *
4131          * @param subscriptionId the subscriptionId to receive updates on
4132          * @return the Uri used to observe carrier identity changes
4133          */
getUriForSubscriptionId(int subscriptionId)4134         public static Uri getUriForSubscriptionId(int subscriptionId) {
4135             return CONTENT_URI.buildUpon().appendEncodedPath(
4136                     String.valueOf(subscriptionId)).build();
4137         }
4138 
4139         /**
4140          * Generates a content {@link Uri} used to receive updates on specific carrier identity
4141          * change on the given subscriptionId returned by
4142          * {@link TelephonyManager#getSimSpecificCarrierId()}.
4143          * @see TelephonyManager#ACTION_SUBSCRIPTION_SPECIFIC_CARRIER_IDENTITY_CHANGED
4144          * <p>
4145          * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
4146          * specific carrier identity {@link TelephonyManager#getSimSpecificCarrierId()}
4147          * while your app is running. You can also use a {@link android.app.job.JobService}
4148          * to ensure your app
4149          * is notified of changes to the {@link Uri} even when it is not running.
4150          * Note, however, that using a {@link android.app.job.JobService} does not guarantee timely
4151          * delivery of updates to the {@link Uri}.
4152          *
4153          * @param subscriptionId the subscriptionId to receive updates on
4154          * @return the Uri used to observe specific carrier identity changes
4155          */
4156         @NonNull
getSpecificCarrierIdUriForSubscriptionId(int subscriptionId)4157         public static Uri getSpecificCarrierIdUriForSubscriptionId(int subscriptionId) {
4158             return Uri.withAppendedPath(Uri.withAppendedPath(CONTENT_URI, "specific"),
4159                     String.valueOf(subscriptionId));
4160         }
4161 
4162         /**
4163          * A user facing carrier name.
4164          * @see TelephonyManager#getSimCarrierIdName()
4165          * <P>Type: TEXT </P>
4166          */
4167         public static final String CARRIER_NAME = "carrier_name";
4168 
4169         /**
4170          * A unique carrier id
4171          * @see TelephonyManager#getSimCarrierId()
4172          * <P>Type: INTEGER </P>
4173          */
4174         public static final String CARRIER_ID = "carrier_id";
4175 
4176         /**
4177          * A fine-grained carrier id.
4178          * The specific carrier ID would be used for configuration purposes, but apps wishing to
4179          * know about the carrier itself should use the regular carrier ID returned by
4180          * {@link TelephonyManager#getSimCarrierId()}.
4181          *
4182          * @see TelephonyManager#getSimSpecificCarrierId()
4183          * This is not a database column, only used to notify content observers for
4184          * {@link #getSpecificCarrierIdUriForSubscriptionId(int)}
4185          */
4186         public static final String SPECIFIC_CARRIER_ID = "specific_carrier_id";
4187 
4188         /**
4189          * A user facing carrier name for specific carrier id {@link #SPECIFIC_CARRIER_ID}.
4190          * @see TelephonyManager#getSimSpecificCarrierIdName()
4191          * This is not a database column, only used to notify content observers for
4192          * {@link #getSpecificCarrierIdUriForSubscriptionId(int)}
4193          */
4194         public static final String SPECIFIC_CARRIER_ID_NAME = "specific_carrier_id_name";
4195 
4196         /**
4197          * A unique parent carrier id. The parent-child
4198          * relationship can be used to further differentiate a single carrier by different networks,
4199          * by prepaid v.s. postpaid. It's an optional field.
4200          * A carrier id with a valid parent_carrier_id is considered fine-grained specific carrier
4201          * ID, will not be returned as {@link #CARRIER_ID} but {@link #SPECIFIC_CARRIER_ID}.
4202          * <P>Type: INTEGER </P>
4203          * @hide
4204          */
4205         public static final String PARENT_CARRIER_ID = "parent_carrier_id";
4206 
4207         /**
4208          * Contains mappings between matching rules with carrier id for all carriers.
4209          * @hide
4210          */
4211         public static final class All implements BaseColumns {
4212 
4213             /**
4214              * Not instantiable.
4215              * @hide
4216              */
All()4217             private All() {
4218             }
4219 
4220             /**
4221              * Numeric operator ID (as String). {@code MCC + MNC}
4222              * <P>Type: TEXT </P>
4223              */
4224             public static final String MCCMNC = "mccmnc";
4225 
4226             /**
4227              * Group id level 1 (as String).
4228              * <P>Type: TEXT </P>
4229              */
4230             public static final String GID1 = "gid1";
4231 
4232             /**
4233              * Group id level 2 (as String).
4234              * <P>Type: TEXT </P>
4235              */
4236             public static final String GID2 = "gid2";
4237 
4238             /**
4239              * Public Land Mobile Network name.
4240              * <P>Type: TEXT </P>
4241              */
4242             public static final String PLMN = "plmn";
4243 
4244             /**
4245              * Prefix xpattern of IMSI (International Mobile Subscriber Identity).
4246              * <P>Type: TEXT </P>
4247              */
4248             public static final String IMSI_PREFIX_XPATTERN = "imsi_prefix_xpattern";
4249 
4250             /**
4251              * Service Provider Name.
4252              * <P>Type: TEXT </P>
4253              */
4254             public static final String SPN = "spn";
4255 
4256             /**
4257              * Prefer APN name.
4258              * <P>Type: TEXT </P>
4259              */
4260             public static final String APN = "apn";
4261 
4262             /**
4263              * Prefix of Integrated Circuit Card Identifier.
4264              * <P>Type: TEXT </P>
4265              */
4266             public static final String ICCID_PREFIX = "iccid_prefix";
4267 
4268             /**
4269              * Certificate for carrier privilege access rules.
4270              * <P>Type: TEXT in hex string </P>
4271              */
4272             public static final String PRIVILEGE_ACCESS_RULE = "privilege_access_rule";
4273 
4274             /**
4275              * The {@code content://} URI for this table.
4276              */
4277             @NonNull
4278             public static final Uri CONTENT_URI = Uri.parse("content://carrier_id/all");
4279         }
4280     }
4281 
4282     /**
4283      * Contains SIM Information
4284      * @hide
4285      */
4286     public static final class SimInfo {
4287         /**
4288          * Not instantiable.
4289          * @hide
4290          */
SimInfo()4291         private SimInfo() {}
4292 
4293         /**
4294          * The {@code content://} style URI for this provider.
4295          * @hide
4296          */
4297         @NonNull
4298         public static final Uri CONTENT_URI = Uri.parse("content://telephony/siminfo");
4299 
4300         /**
4301          * TelephonyProvider unique key column name is the subscription id.
4302          * <P>Type: TEXT (String)</P>
4303          *
4304          * @hide
4305          */
4306         public static final String COLUMN_UNIQUE_KEY_SUBSCRIPTION_ID = "_id";
4307 
4308         /**
4309          * TelephonyProvider column name for a unique identifier for the subscription within the
4310          * specific subscription type. For example, it contains SIM ICC Identifier subscriptions
4311          * on Local SIMs. and Mac-address for Remote-SIM Subscriptions for Bluetooth devices.
4312          * <P>Type: TEXT (String)</P>
4313          *
4314          * @hide
4315          */
4316         public static final String COLUMN_ICC_ID = "icc_id";
4317 
4318         /**
4319          * TelephonyProvider column name for user SIM_SlOT_INDEX
4320          * <P>Type: INTEGER (int)</P>
4321          *
4322          * @hide
4323          */
4324         public static final String COLUMN_SIM_SLOT_INDEX = "sim_id";
4325 
4326         /**
4327          * SIM is not inserted
4328          * @hide
4329          */
4330         public static final int SIM_NOT_INSERTED = -1;
4331 
4332         /**
4333          * TelephonyProvider column name Subscription-type.
4334          * <P>Type: INTEGER (int)</P> {@link #SUBSCRIPTION_TYPE_LOCAL_SIM} for Local-SIM
4335          * Subscriptions, {@link #SUBSCRIPTION_TYPE_REMOTE_SIM} for Remote-SIM Subscriptions.
4336          * Default value is 0.
4337          *
4338          * @hide
4339          */
4340         public static final String COLUMN_SUBSCRIPTION_TYPE = "subscription_type";
4341 
4342         /**
4343          * This constant is to designate a subscription as a Local-SIM Subscription.
4344          * <p> A Local-SIM can be a physical SIM inserted into a sim-slot in the device, or eSIM on
4345          * the device.
4346          * </p>
4347          *
4348          * @hide
4349          */
4350         public static final int SUBSCRIPTION_TYPE_LOCAL_SIM = 0;
4351 
4352         /**
4353          * This constant is to designate a subscription as a Remote-SIM Subscription.
4354          * <p>
4355          * A Remote-SIM subscription is for a SIM on a phone connected to this device via some
4356          * connectivity mechanism, for example bluetooth. Similar to Local SIM, this subscription
4357          * can be used for SMS, Voice and data by proxying data through the connected device.
4358          * Certain data of the SIM, such as IMEI, are not accessible for Remote SIMs.
4359          * </p>
4360          *
4361          * <p>
4362          * A Remote-SIM is available only as long the phone stays connected to this device.
4363          * When the phone disconnects, Remote-SIM subscription is removed from this device and is
4364          * no longer known. All data associated with the subscription, such as stored SMS, call
4365          * logs, contacts etc, are removed from this device.
4366          * </p>
4367          *
4368          * <p>
4369          * If the phone re-connects to this device, a new Remote-SIM subscription is created for
4370          * the phone. The Subscription Id associated with the new subscription is different from
4371          * the Subscription Id of the previous Remote-SIM subscription created (and removed) for the
4372          * phone; i.e., new Remote-SIM subscription treats the reconnected phone as a Remote-SIM
4373          * that was never seen before.
4374          * </p>
4375          *
4376          * @hide
4377          */
4378         public static final int SUBSCRIPTION_TYPE_REMOTE_SIM = 1;
4379 
4380         /**
4381          * TelephonyProvider column name data_enabled_override_rules.
4382          * It's a list of rules for overriding data enabled settings. The syntax is
4383          * For example, "mms=nonDefault" indicates enabling data for mms in non-default
4384          * subscription.
4385          * "default=nonDefault&inVoiceCall" indicates enabling data for internet in non-default
4386          * subscription and while is in voice call.
4387          *
4388          * Default value is empty string.
4389          * @deprecated This column is no longer supported. Use
4390          * {@link #COLUMN_ENABLED_MOBILE_DATA_POLICIES} instead.
4391          * @hide
4392          */
4393         @Deprecated
4394         public static final String COLUMN_DATA_ENABLED_OVERRIDE_RULES =
4395                 "data_enabled_override_rules";
4396 
4397         /**
4398          * TelephonyProvider column name enabled_mobile_data_policies.
4399          * A list of mobile data policies, each of which represented by an integer and joint by ",".
4400          *
4401          * Default value is empty string.
4402          * @hide
4403          */
4404         public static final String COLUMN_ENABLED_MOBILE_DATA_POLICIES =
4405                 "enabled_mobile_data_policies";
4406 
4407         /**
4408          * TelephonyProvider column name for user displayed name.
4409          * <P>Type: TEXT (String)</P>
4410          *
4411          * @hide
4412          */
4413         public static final String COLUMN_DISPLAY_NAME = "display_name";
4414 
4415         /**
4416          * TelephonyProvider column name for the service provider name for the SIM.
4417          * <P>Type: TEXT (String)</P>
4418          *
4419          * @hide
4420          */
4421         public static final String COLUMN_CARRIER_NAME = "carrier_name";
4422 
4423         /**
4424          * TelephonyProvider column name for source of the user displayed name.
4425          * <P>Type: INT (int)</P> with one of the NAME_SOURCE_XXXX values below
4426          *
4427          * @hide
4428          */
4429         public static final String COLUMN_NAME_SOURCE = "name_source";
4430 
4431         /**
4432          * The name source is unknown.
4433          * @hide
4434          */
4435         public static final int NAME_SOURCE_UNKNOWN = -1;
4436 
4437         /** The name_source is from the carrier id. {@hide} */
4438         public static final int NAME_SOURCE_CARRIER_ID = 0;
4439 
4440         /**
4441          * The name_source is from SIM EF_SPN.
4442          * @hide
4443          */
4444         public static final int NAME_SOURCE_SIM_SPN = 1;
4445 
4446         /**
4447          * The name_source is from user input
4448          * @hide
4449          */
4450         public static final int NAME_SOURCE_USER_INPUT = 2;
4451 
4452         /**
4453          * The name_source is carrier (carrier app, carrier config, etc.)
4454          * @hide
4455          */
4456         public static final int NAME_SOURCE_CARRIER = 3;
4457 
4458         /**
4459          * The name_source is from SIM EF_PNN.
4460          * @hide
4461          */
4462         public static final int NAME_SOURCE_SIM_PNN = 4;
4463 
4464         /**
4465          * TelephonyProvider column name for the color of a SIM.
4466          * <P>Type: INTEGER (int)</P>
4467          *
4468          * @hide
4469          */
4470         public static final String COLUMN_COLOR = "color";
4471 
4472         /** The default color of a SIM {@hide} */
4473         public static final int COLOR_DEFAULT = 0;
4474 
4475         /**
4476          * TelephonyProvider column name for the phone number of a SIM.
4477          * <P>Type: TEXT (String)</P>
4478          *
4479          * @hide
4480          */
4481         public static final String COLUMN_NUMBER = "number";
4482 
4483         /**
4484          * TelephonyProvider column name for the number display format of a SIM.
4485          * <P>Type: INTEGER (int)</P>
4486          *
4487          * @hide
4488          */
4489         public static final String COLUMN_DISPLAY_NUMBER_FORMAT = "display_number_format";
4490 
4491         /**
4492          * TelephonyProvider column name for the default display format of a SIM
4493          * @hide
4494          */
4495         public static final int DISPLAY_NUMBER_DEFAULT = 1;
4496 
4497         /**
4498          * TelephonyProvider column name for whether data roaming is enabled.
4499          * <P>Type: INTEGER (int)</P>
4500          *
4501          * @hide
4502          */
4503         public static final String COLUMN_DATA_ROAMING = "data_roaming";
4504 
4505         /** Indicates that data roaming is enabled for a subscription {@hide} */
4506         public static final int DATA_ROAMING_ENABLE = 1;
4507 
4508         /** Indicates that data roaming is disabled for a subscription {@hide} */
4509         public static final int DATA_ROAMING_DISABLE = 0;
4510 
4511         /**
4512          * TelephonyProvider column name for subscription carrier id.
4513          * @see TelephonyManager#getSimCarrierId()
4514          * <p>Type: INTEGER (int) </p>
4515          *
4516          * @hide
4517          */
4518         public static final String COLUMN_CARRIER_ID = "carrier_id";
4519 
4520         /**
4521          * A comma-separated list of EHPLMNs associated with the subscription
4522          * <P>Type: TEXT (String)</P>
4523          *
4524          * @hide
4525          */
4526         public static final String COLUMN_EHPLMNS = "ehplmns";
4527 
4528         /**
4529          * A comma-separated list of HPLMNs associated with the subscription
4530          * <P>Type: TEXT (String)</P>
4531          *
4532          * @hide
4533          */
4534         public static final String COLUMN_HPLMNS = "hplmns";
4535 
4536         /**
4537          * TelephonyProvider column name for the MCC associated with a SIM, stored as a string.
4538          * <P>Type: TEXT (String)</P>
4539          *
4540          * @hide
4541          */
4542         public static final String COLUMN_MCC_STRING = "mcc_string";
4543 
4544         /**
4545          * TelephonyProvider column name for the MNC associated with a SIM, stored as a string.
4546          * <P>Type: TEXT (String)</P>
4547          *
4548          * @hide
4549          */
4550         public static final String COLUMN_MNC_STRING = "mnc_string";
4551 
4552         /**
4553          * TelephonyProvider column name for the MCC associated with a SIM.
4554          * <P>Type: INTEGER (int)</P>
4555          *
4556          * @hide
4557          */
4558         public static final String COLUMN_MCC = "mcc";
4559 
4560         /**
4561          * TelephonyProvider column name for the MNC associated with a SIM.
4562          * <P>Type: INTEGER (int)</P>
4563          *
4564          * @hide
4565          */
4566         public static final String COLUMN_MNC = "mnc";
4567 
4568         /**
4569          * TelephonyProvider column name for the iso country code associated with a SIM.
4570          * <P>Type: TEXT (String)</P>
4571          *
4572          * @hide
4573          */
4574         public static final String COLUMN_ISO_COUNTRY_CODE = "iso_country_code";
4575 
4576         /**
4577          * TelephonyProvider column name for the sim provisioning status associated with a SIM.
4578          * <P>Type: INTEGER (int)</P>
4579          *
4580          * @hide
4581          */
4582         public static final String COLUMN_SIM_PROVISIONING_STATUS = "sim_provisioning_status";
4583 
4584         /** The sim is provisioned {@hide} */
4585         public static final int SIM_PROVISIONED = 0;
4586 
4587         /**
4588          * TelephonyProvider column name for whether a subscription is embedded (that is, present on
4589          * an eSIM).
4590          * <p>Type: INTEGER (int), 1 for embedded or 0 for non-embedded.
4591          *
4592          * @hide
4593          */
4594         public static final String COLUMN_IS_EMBEDDED = "is_embedded";
4595 
4596         /**
4597          * TelephonyProvider column name for SIM card identifier. For UICC card it is the ICCID of
4598          * the current enabled profile on the card, while for eUICC card it is the EID of the card.
4599          * <P>Type: TEXT (String)</P>
4600          *
4601          * @hide
4602          */
4603         public static final String COLUMN_CARD_ID = "card_id";
4604 
4605         /**
4606          * TelephonyProvider column name for the encoded {@link UiccAccessRule}s from
4607          * {@link UiccAccessRule#encodeRules}. Only present if {@link #COLUMN_IS_EMBEDDED} is 1.
4608          * <p>TYPE: BLOB
4609          *
4610          * @hide
4611          */
4612         public static final String COLUMN_ACCESS_RULES = "access_rules";
4613 
4614         /**
4615          * TelephonyProvider column name for the encoded {@link UiccAccessRule}s from
4616          * {@link UiccAccessRule#encodeRules} but for the rules that come from CarrierConfigs.
4617          * Only present if there are access rules in CarrierConfigs
4618          * <p>TYPE: BLOB
4619          *
4620          * @hide
4621          */
4622         public static final String COLUMN_ACCESS_RULES_FROM_CARRIER_CONFIGS =
4623                 "access_rules_from_carrier_configs";
4624 
4625         /**
4626          * TelephonyProvider column name identifying whether an embedded subscription is on a
4627          * removable card. Such subscriptions are marked inaccessible as soon as the current card
4628          * is removed. Otherwise, they will remain accessible unless explicitly deleted. Only
4629          * present if {@link #COLUMN_IS_EMBEDDED} is 1.
4630          * <p>TYPE: INTEGER (int), 1 for removable or 0 for non-removable.
4631          *
4632          * @hide
4633          */
4634         public static final String COLUMN_IS_REMOVABLE = "is_removable";
4635 
4636         /** TelephonyProvider column name for extreme threat in CB settings {@hide} */
4637         public static final String COLUMN_CB_EXTREME_THREAT_ALERT =
4638                 "enable_cmas_extreme_threat_alerts";
4639 
4640         /** TelephonyProvider column name for severe threat in CB settings {@hide} */
4641         public static final String COLUMN_CB_SEVERE_THREAT_ALERT =
4642                 "enable_cmas_severe_threat_alerts";
4643 
4644         /** TelephonyProvider column name for amber alert in CB settings {@hide} */
4645         public static final String COLUMN_CB_AMBER_ALERT = "enable_cmas_amber_alerts";
4646 
4647         /** TelephonyProvider column name for emergency alert in CB settings {@hide} */
4648         public static final String COLUMN_CB_EMERGENCY_ALERT = "enable_emergency_alerts";
4649 
4650         /** TelephonyProvider column name for alert sound duration in CB settings {@hide} */
4651         public static final String COLUMN_CB_ALERT_SOUND_DURATION = "alert_sound_duration";
4652 
4653         /** TelephonyProvider column name for alert reminder interval in CB settings {@hide} */
4654         public static final String COLUMN_CB_ALERT_REMINDER_INTERVAL = "alert_reminder_interval";
4655 
4656         /** TelephonyProvider column name for enabling vibrate in CB settings {@hide} */
4657         public static final String COLUMN_CB_ALERT_VIBRATE = "enable_alert_vibrate";
4658 
4659         /** TelephonyProvider column name for enabling alert speech in CB settings {@hide} */
4660         public static final String COLUMN_CB_ALERT_SPEECH = "enable_alert_speech";
4661 
4662         /** TelephonyProvider column name for ETWS test alert in CB settings {@hide} */
4663         public static final String COLUMN_CB_ETWS_TEST_ALERT = "enable_etws_test_alerts";
4664 
4665         /** TelephonyProvider column name for enable channel50 alert in CB settings {@hide} */
4666         public static final String COLUMN_CB_CHANNEL_50_ALERT = "enable_channel_50_alerts";
4667 
4668         /** TelephonyProvider column name for CMAS test alert in CB settings {@hide} */
4669         public static final String COLUMN_CB_CMAS_TEST_ALERT = "enable_cmas_test_alerts";
4670 
4671         /** TelephonyProvider column name for Opt out dialog in CB settings {@hide} */
4672         public static final String COLUMN_CB_OPT_OUT_DIALOG = "show_cmas_opt_out_dialog";
4673 
4674         /**
4675          * TelephonyProvider column name for enable Volte.
4676          *
4677          * If this setting is not initialized (set to -1)  then we use the Carrier Config value
4678          * {@link CarrierConfigManager#KEY_ENHANCED_4G_LTE_ON_BY_DEFAULT_BOOL}.
4679          *
4680          * @hide
4681          */
4682         public static final String COLUMN_ENHANCED_4G_MODE_ENABLED = "volte_vt_enabled";
4683 
4684         /** TelephonyProvider column name for enable VT (Video Telephony over IMS) {@hide} */
4685         public static final String COLUMN_VT_IMS_ENABLED = "vt_ims_enabled";
4686 
4687         /** TelephonyProvider column name for enable Wifi calling {@hide} */
4688         public static final String COLUMN_WFC_IMS_ENABLED = "wfc_ims_enabled";
4689 
4690         /** TelephonyProvider column name for Wifi calling mode {@hide} */
4691         public static final String COLUMN_WFC_IMS_MODE = "wfc_ims_mode";
4692 
4693         /** TelephonyProvider column name for Wifi calling mode in roaming {@hide} */
4694         public static final String COLUMN_WFC_IMS_ROAMING_MODE = "wfc_ims_roaming_mode";
4695 
4696         /** TelephonyProvider column name for enable Wifi calling in roaming {@hide} */
4697         public static final String COLUMN_WFC_IMS_ROAMING_ENABLED = "wfc_ims_roaming_enabled";
4698 
4699         /**
4700          * TelephonyProvider column name for determining if the user has enabled IMS RCS User
4701          * Capability Exchange (UCE) for this subscription.
4702          *
4703          * @hide
4704          */
4705         public static final String COLUMN_IMS_RCS_UCE_ENABLED = "ims_rcs_uce_enabled";
4706 
4707         /**
4708          * TelephonyProvider column name for determining if the user has enabled cross SIM calling
4709          * for this subscription.
4710          *
4711          * @hide
4712          */
4713         public static final String COLUMN_CROSS_SIM_CALLING_ENABLED = "cross_sim_calling_enabled";
4714 
4715         /**
4716          * TelephonyProvider column name for whether a subscription is opportunistic, that is,
4717          * whether the network it connects to is limited in functionality or coverage.
4718          * For example, CBRS.
4719          * <p>Type: INTEGER (int), 1 for opportunistic or 0 for non-opportunistic.
4720          *
4721          * @hide
4722          */
4723         public static final String COLUMN_IS_OPPORTUNISTIC = "is_opportunistic";
4724 
4725         /**
4726          * TelephonyProvider column name for group ID. Subscriptions with same group ID
4727          * are considered bundled together, and should behave as a single subscription at
4728          * certain scenarios.
4729          *
4730          * @hide
4731          */
4732         public static final String COLUMN_GROUP_UUID = "group_uuid";
4733 
4734         /**
4735          * TelephonyProvider column name for group owner. It's the package name who created
4736          * the subscription group.
4737          *
4738          * @hide
4739          */
4740         public static final String COLUMN_GROUP_OWNER = "group_owner";
4741 
4742         /**
4743          * TelephonyProvider column name for whether a subscription is metered or not, that is,
4744          * whether the network it connects to charges for subscription or not. For example, paid
4745          * CBRS or unpaid.
4746          *
4747          * @hide
4748          */
4749         public static final String COLUMN_IS_METERED = "is_metered";
4750 
4751         /**
4752          * TelephonyProvider column name for the profile class of a subscription
4753          * Only present if {@link #COLUMN_IS_EMBEDDED} is 1.
4754          * <P>Type: INTEGER (int)</P>
4755          *
4756          * @hide
4757          */
4758         public static final String COLUMN_PROFILE_CLASS = "profile_class";
4759 
4760         /**
4761          * TelephonyProvider column name for the port index of the active UICC port.
4762          * <P>Type: INTEGER (int)</P>
4763          * @hide
4764          */
4765         public static final String COLUMN_PORT_INDEX = "port_index";
4766 
4767         /**
4768          * A testing profile can be pre-loaded or downloaded onto
4769          * the eUICC and provides connectivity to test equipment
4770          * for the purpose of testing the device and the eUICC. It
4771          * is not intended to store any operator credentials.
4772          *
4773          * @hide
4774          */
4775         public static final int PROFILE_CLASS_TESTING = 0;
4776 
4777         /**
4778          * A provisioning profile is pre-loaded onto the eUICC and
4779          * provides connectivity to a mobile network solely for the
4780          * purpose of provisioning profiles.
4781          *
4782          * @hide
4783          */
4784         public static final int PROFILE_CLASS_PROVISIONING = 1;
4785 
4786         /**
4787          * An operational profile can be pre-loaded or downloaded
4788          * onto the eUICC and provides services provided by the
4789          * operator.
4790          *
4791          * @hide
4792          */
4793         public static final int PROFILE_CLASS_OPERATIONAL = 2;
4794 
4795         /**
4796          * The profile class is unset. This occurs when profile class
4797          * info is not available. The subscription either has no profile
4798          * metadata or the profile metadata did not encode profile class.
4799          *
4800          * @hide
4801          */
4802         public static final int PROFILE_CLASS_UNSET = -1;
4803 
4804         /**
4805          * IMSI (International Mobile Subscriber Identity).
4806          * <P>Type: TEXT </P>
4807          *
4808          * @hide
4809          */
4810         public static final String COLUMN_IMSI = "imsi";
4811 
4812         /**
4813          * Whether uicc applications is set to be enabled or disabled. By default it's enabled.
4814          * @hide
4815          */
4816         public static final String COLUMN_UICC_APPLICATIONS_ENABLED = "uicc_applications_enabled";
4817 
4818         /**
4819          * TelephonyProvider column name for allowed network types. Indicate which network types
4820          * are allowed. Default is -1.
4821          * <P>Type: BIGINT (long) </P>
4822          *
4823          * @hide
4824          */
4825         public static final String COLUMN_ALLOWED_NETWORK_TYPES = "allowed_network_types";
4826 
4827         /**
4828          * TelephonyProvider column name for allowed network types with all of reasons. Indicate
4829          * which network types are allowed for
4830          * {@link TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_USER},
4831          * {@link TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_POWER},
4832          * {@link TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_CARRIER},
4833          * {@link TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G}.
4834          * <P>Type: TEXT </P>
4835          *
4836          * @hide
4837          */
4838         public static final String COLUMN_ALLOWED_NETWORK_TYPES_FOR_REASONS =
4839                 "allowed_network_types_for_reasons";
4840 
4841         /**
4842          * TelephonyProvider column name for RCS configuration.
4843          * <p>TYPE: BLOB
4844          *
4845          * @hide
4846          */
4847         public static final String COLUMN_RCS_CONFIG = "rcs_config";
4848 
4849         /**
4850          * TelephonyProvider column name for device to device sharing status.
4851          *
4852          * @hide
4853          */
4854         public static final String COLUMN_D2D_STATUS_SHARING = "d2d_sharing_status";
4855 
4856         /**
4857          * TelephonyProvider column name for VoIMS provisioning. Default is 0.
4858          * <P>Type: INTEGER </P>
4859          *
4860          * @hide
4861          */
4862         public static final String COLUMN_VOIMS_OPT_IN_STATUS = "voims_opt_in_status";
4863 
4864         /**
4865          * TelephonyProvider column name for information selected contacts that allow device to
4866          * device sharing.
4867          *
4868          * @hide
4869          */
4870         public static final String COLUMN_D2D_STATUS_SHARING_SELECTED_CONTACTS =
4871                 "d2d_sharing_contacts";
4872 
4873         /**
4874         * TelephonyProvider column name for NR Advanced calling
4875         * Determines if the user has enabled VoNR settings for this subscription.
4876         *
4877         * @hide
4878         */
4879         public static final String COLUMN_NR_ADVANCED_CALLING_ENABLED =
4880                 "nr_advanced_calling_enabled";
4881 
4882         /**
4883          * TelephonyProvider column name for the phone number from source CARRIER
4884          *
4885          * @hide
4886          */
4887         public static final String COLUMN_PHONE_NUMBER_SOURCE_CARRIER =
4888                 "phone_number_source_carrier";
4889 
4890         /**
4891          * TelephonyProvider column name for the phone number from source IMS
4892          *
4893          * @hide
4894          */
4895         public static final String COLUMN_PHONE_NUMBER_SOURCE_IMS =
4896                 "phone_number_source_ims";
4897 
4898         /**
4899          * TelephonyProvider column name for last used TP - message Reference
4900          *
4901          * @hide
4902          */
4903         public static final String COLUMN_TP_MESSAGE_REF = "tp_message_ref";
4904 
4905         /**
4906          * TelephonyProvider column name for the device's preferred usage setting.
4907          *
4908          * @hide
4909          */
4910         public static final String COLUMN_USAGE_SETTING = "usage_setting";
4911 
4912         /**
4913          * TelephonyProvider column name for user handle associated with this sim.
4914          *
4915          * @hide
4916          */
4917         public static final String COLUMN_USER_HANDLE = "user_handle";
4918 
4919         /**
4920          * TelephonyProvider column name for satellite enabled.
4921          * By default, it's disabled.
4922          *
4923          * @hide
4924          */
4925         public static final String COLUMN_SATELLITE_ENABLED = "satellite_enabled";
4926 
4927         /**
4928          * TelephonyProvider column name for satellite attach enabled for carrier. The value of this
4929          * column is set based on user settings.
4930          * By default, it's enabled.
4931          *
4932          * @hide
4933          */
4934         public static final String COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER =
4935                 "satellite_attach_enabled_for_carrier";
4936 
4937         /**
4938          * TelephonyProvider column name to identify eSIM profile of a non-terrestrial network.
4939          * By default, it's disabled.
4940          *
4941          * @hide
4942          */
4943         public static final String COLUMN_IS_NTN = "is_ntn";
4944 
4945         /**
4946          * TelephonyProvider column name for transferred status
4947          *
4948          * @hide
4949          */
4950         public static final String COLUMN_TRANSFER_STATUS = "transfer_status";
4951 
4952         /**
4953          * TelephonyProvider column name to indicate the service capability bitmasks.
4954          *
4955          * @hide
4956          */
4957         public static final String COLUMN_SERVICE_CAPABILITIES = "service_capabilities";
4958 
4959         /**
4960          * TelephonyProvider column name for satellite entitlement status. The value of this column
4961          * is set based on entitlement query result for satellite configuration.
4962          * By default, it's disabled.
4963          *
4964          * @hide
4965          */
4966         public static final String COLUMN_SATELLITE_ENTITLEMENT_STATUS =
4967                 "satellite_entitlement_status";
4968 
4969         /**
4970          * TelephonyProvider column name for satellite entitlement plmns. The value of this
4971          * column is set based on entitlement query result for satellite configuration.
4972          * By default, it's empty.
4973          *
4974          * @hide
4975          */
4976         public static final String COLUMN_SATELLITE_ENTITLEMENT_PLMNS =
4977                 "satellite_entitlement_plmns";
4978 
4979         /** All columns in {@link SimInfo} table. */
4980         private static final List<String> ALL_COLUMNS = List.of(
4981                 COLUMN_UNIQUE_KEY_SUBSCRIPTION_ID,
4982                 COLUMN_ICC_ID,
4983                 COLUMN_SIM_SLOT_INDEX,
4984                 COLUMN_DISPLAY_NAME,
4985                 COLUMN_CARRIER_NAME,
4986                 COLUMN_NAME_SOURCE,
4987                 COLUMN_COLOR,
4988                 COLUMN_NUMBER,
4989                 COLUMN_DISPLAY_NUMBER_FORMAT,
4990                 COLUMN_DATA_ROAMING,
4991                 COLUMN_MCC,
4992                 COLUMN_MNC,
4993                 COLUMN_MCC_STRING,
4994                 COLUMN_MNC_STRING,
4995                 COLUMN_EHPLMNS,
4996                 COLUMN_HPLMNS,
4997                 COLUMN_SIM_PROVISIONING_STATUS,
4998                 COLUMN_IS_EMBEDDED,
4999                 COLUMN_CARD_ID,
5000                 COLUMN_ACCESS_RULES,
5001                 COLUMN_ACCESS_RULES_FROM_CARRIER_CONFIGS,
5002                 COLUMN_IS_REMOVABLE,
5003                 COLUMN_CB_EXTREME_THREAT_ALERT,
5004                 COLUMN_CB_SEVERE_THREAT_ALERT,
5005                 COLUMN_CB_AMBER_ALERT,
5006                 COLUMN_CB_EMERGENCY_ALERT,
5007                 COLUMN_CB_ALERT_SOUND_DURATION,
5008                 COLUMN_CB_ALERT_REMINDER_INTERVAL,
5009                 COLUMN_CB_ALERT_VIBRATE,
5010                 COLUMN_CB_ALERT_SPEECH,
5011                 COLUMN_CB_ETWS_TEST_ALERT,
5012                 COLUMN_CB_CHANNEL_50_ALERT,
5013                 COLUMN_CB_CMAS_TEST_ALERT,
5014                 COLUMN_CB_OPT_OUT_DIALOG,
5015                 COLUMN_ENHANCED_4G_MODE_ENABLED,
5016                 COLUMN_VT_IMS_ENABLED,
5017                 COLUMN_WFC_IMS_ENABLED,
5018                 COLUMN_WFC_IMS_MODE,
5019                 COLUMN_WFC_IMS_ROAMING_MODE,
5020                 COLUMN_WFC_IMS_ROAMING_ENABLED,
5021                 COLUMN_IS_OPPORTUNISTIC,
5022                 COLUMN_GROUP_UUID,
5023                 COLUMN_IS_METERED,
5024                 COLUMN_ISO_COUNTRY_CODE,
5025                 COLUMN_CARRIER_ID,
5026                 COLUMN_PROFILE_CLASS,
5027                 COLUMN_SUBSCRIPTION_TYPE,
5028                 COLUMN_GROUP_OWNER,
5029                 COLUMN_DATA_ENABLED_OVERRIDE_RULES,
5030                 COLUMN_ENABLED_MOBILE_DATA_POLICIES,
5031                 COLUMN_IMSI,
5032                 COLUMN_UICC_APPLICATIONS_ENABLED,
5033                 COLUMN_ALLOWED_NETWORK_TYPES,
5034                 COLUMN_IMS_RCS_UCE_ENABLED,
5035                 COLUMN_CROSS_SIM_CALLING_ENABLED,
5036                 COLUMN_RCS_CONFIG,
5037                 COLUMN_ALLOWED_NETWORK_TYPES_FOR_REASONS,
5038                 COLUMN_D2D_STATUS_SHARING,
5039                 COLUMN_VOIMS_OPT_IN_STATUS,
5040                 COLUMN_D2D_STATUS_SHARING_SELECTED_CONTACTS,
5041                 COLUMN_NR_ADVANCED_CALLING_ENABLED,
5042                 COLUMN_PHONE_NUMBER_SOURCE_CARRIER,
5043                 COLUMN_PHONE_NUMBER_SOURCE_IMS,
5044                 COLUMN_PORT_INDEX,
5045                 COLUMN_USAGE_SETTING,
5046                 COLUMN_TP_MESSAGE_REF,
5047                 COLUMN_USER_HANDLE,
5048                 COLUMN_SATELLITE_ENABLED,
5049                 COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
5050                 COLUMN_IS_NTN,
5051                 COLUMN_SERVICE_CAPABILITIES,
5052                 COLUMN_TRANSFER_STATUS,
5053                 COLUMN_SATELLITE_ENTITLEMENT_STATUS,
5054                 COLUMN_SATELLITE_ENTITLEMENT_PLMNS
5055         );
5056 
5057         /**
5058          * @return All columns in {@link SimInfo} table.
5059          *
5060          * @hide
5061          */
5062         @NonNull
getAllColumns()5063         public static List<String> getAllColumns() {
5064             return ALL_COLUMNS;
5065         }
5066     }
5067 
5068     /**
5069      * Stores incoming satellite datagrams.
5070      * @hide
5071      */
5072     public static final class SatelliteDatagrams {
5073         /**
5074          * Not instantiable.
5075          * @hide
5076          */
SatelliteDatagrams()5077         private SatelliteDatagrams() {}
5078 
5079         /**
5080          * Provider name for Satellite Datagrams table.
5081          */
5082         public static final String PROVIDER_NAME = "satellite";
5083 
5084         /**
5085          * Table name for Satellite Datagrams table.
5086          */
5087         public static final String TABLE_NAME = "incoming_datagrams";
5088 
5089         /**
5090          * URL for satellite incoming datagrams table.
5091          */
5092         private static final String URL = "content://" + PROVIDER_NAME + "/" + TABLE_NAME;
5093 
5094         /**
5095          * The {@code content://} style URI for this provider.
5096          * @hide
5097          */
5098         public static final Uri CONTENT_URI = Uri.parse(URL);
5099 
5100         /**
5101          * SatelliteProvider unique key column name is the datagram id.
5102          * <P>Type: INTEGER (int)</P>
5103          * @hide
5104          */
5105         public static final String COLUMN_UNIQUE_KEY_DATAGRAM_ID = "datagram_id";
5106 
5107         /**
5108          * SatelliteProvider column name for storing datagram.
5109          * <p>TYPE: BLOB
5110          * @hide
5111          */
5112         public static final String COLUMN_DATAGRAM = "datagram";
5113 
5114         /** All columns in {@link SatelliteDatagrams} table. */
5115         private static final List<String> ALL_COLUMNS = List.of(
5116                 COLUMN_UNIQUE_KEY_DATAGRAM_ID,
5117                 COLUMN_DATAGRAM
5118         );
5119 
5120         /**
5121          * @return All columns in {@link SatelliteDatagrams} table.
5122          * @hide
5123          */
5124         @NonNull
getAllColumns()5125         public static List<String> getAllColumns() {
5126             return ALL_COLUMNS;
5127         }
5128     }
5129 }
5130