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