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