Telephony.java revision 4e71df52b26f87087327819c53570f60262a9c6a
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
17package android.provider;
18
19import android.annotation.SdkConstant;
20import android.annotation.SdkConstant.SdkConstantType;
21import android.content.ComponentName;
22import android.content.ContentResolver;
23import android.content.ContentValues;
24import android.content.Context;
25import android.content.Intent;
26import android.database.Cursor;
27import android.database.sqlite.SqliteWrapper;
28import android.net.Uri;
29import android.telephony.SmsMessage;
30import android.telephony.SubscriptionManager;
31import android.text.TextUtils;
32import android.telephony.Rlog;
33import android.util.Patterns;
34
35import com.android.internal.telephony.PhoneConstants;
36import com.android.internal.telephony.SmsApplication;
37
38
39import java.util.HashSet;
40import java.util.Set;
41import java.util.regex.Matcher;
42import java.util.regex.Pattern;
43
44/**
45 * The Telephony provider contains data related to phone operation, specifically SMS and MMS
46 * messages and access to the APN list, including the MMSC to use.
47 *
48 * <p class="note"><strong>Note:</strong> These APIs are not available on all Android-powered
49 * devices. If your app depends on telephony features such as for managing SMS messages, include
50 * a <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature>}
51 * </a> element in your manifest that declares the {@code "android.hardware.telephony"} hardware
52 * feature. Alternatively, you can check for telephony availability at runtime using either
53 * {@link android.content.pm.PackageManager#hasSystemFeature
54 * hasSystemFeature(PackageManager.FEATURE_TELEPHONY)} or {@link
55 * android.telephony.TelephonyManager#getPhoneType}.</p>
56 *
57 * <h3>Creating an SMS app</h3>
58 *
59 * <p>Only the default SMS app (selected by the user in system settings) is able to write to the
60 * SMS Provider (the tables defined within the {@code Telephony} class) and only the default SMS
61 * app receives the {@link android.provider.Telephony.Sms.Intents#SMS_DELIVER_ACTION} broadcast
62 * when the user receives an SMS or the {@link
63 * android.provider.Telephony.Sms.Intents#WAP_PUSH_DELIVER_ACTION} broadcast when the user
64 * receives an MMS.</p>
65 *
66 * <p>Any app that wants to behave as the user's default SMS app must handle the following intents:
67 * <ul>
68 * <li>In a broadcast receiver, include an intent filter for {@link Sms.Intents#SMS_DELIVER_ACTION}
69 * (<code>"android.provider.Telephony.SMS_DELIVER"</code>). The broadcast receiver must also
70 * require the {@link android.Manifest.permission#BROADCAST_SMS} permission.
71 * <p>This allows your app to directly receive incoming SMS messages.</p></li>
72 * <li>In a broadcast receiver, include an intent filter for {@link
73 * Sms.Intents#WAP_PUSH_DELIVER_ACTION}} ({@code "android.provider.Telephony.WAP_PUSH_DELIVER"})
74 * with the MIME type <code>"application/vnd.wap.mms-message"</code>.
75 * The broadcast receiver must also require the {@link
76 * android.Manifest.permission#BROADCAST_WAP_PUSH} permission.
77 * <p>This allows your app to directly receive incoming MMS messages.</p></li>
78 * <li>In your activity that delivers new messages, include an intent filter for
79 * {@link android.content.Intent#ACTION_SENDTO} (<code>"android.intent.action.SENDTO"
80 * </code>) with schemas, <code>sms:</code>, <code>smsto:</code>, <code>mms:</code>, and
81 * <code>mmsto:</code>.
82 * <p>This allows your app to receive intents from other apps that want to deliver a
83 * message.</p></li>
84 * <li>In a service, include an intent filter for {@link
85 * android.telephony.TelephonyManager#ACTION_RESPOND_VIA_MESSAGE}
86 * (<code>"android.intent.action.RESPOND_VIA_MESSAGE"</code>) with schemas,
87 * <code>sms:</code>, <code>smsto:</code>, <code>mms:</code>, and <code>mmsto:</code>.
88 * This service must also require the {@link
89 * android.Manifest.permission#SEND_RESPOND_VIA_MESSAGE} permission.
90 * <p>This allows users to respond to incoming phone calls with an immediate text message
91 * using your app.</p></li>
92 * </ul>
93 *
94 * <p>Other apps that are not selected as the default SMS app can only <em>read</em> the SMS
95 * Provider, but may also be notified when a new SMS arrives by listening for the {@link
96 * Sms.Intents#SMS_RECEIVED_ACTION}
97 * broadcast, which is a non-abortable broadcast that may be delivered to multiple apps. This
98 * broadcast is intended for apps that&mdash;while not selected as the default SMS app&mdash;need to
99 * read special incoming messages such as to perform phone number verification.</p>
100 *
101 * <p>For more information about building SMS apps, read the blog post, <a
102 * href="http://android-developers.blogspot.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html"
103 * >Getting Your SMS Apps Ready for KitKat</a>.</p>
104 *
105 */
106public final class Telephony {
107    private static final String TAG = "Telephony";
108
109    /**
110     * Not instantiable.
111     * @hide
112     */
113    private Telephony() {
114    }
115
116    /**
117     * Base columns for tables that contain text-based SMSs.
118     */
119    public interface TextBasedSmsColumns {
120
121        /** Message type: all messages. */
122        public static final int MESSAGE_TYPE_ALL    = 0;
123
124        /** Message type: inbox. */
125        public static final int MESSAGE_TYPE_INBOX  = 1;
126
127        /** Message type: sent messages. */
128        public static final int MESSAGE_TYPE_SENT   = 2;
129
130        /** Message type: drafts. */
131        public static final int MESSAGE_TYPE_DRAFT  = 3;
132
133        /** Message type: outbox. */
134        public static final int MESSAGE_TYPE_OUTBOX = 4;
135
136        /** Message type: failed outgoing message. */
137        public static final int MESSAGE_TYPE_FAILED = 5;
138
139        /** Message type: queued to send later. */
140        public static final int MESSAGE_TYPE_QUEUED = 6;
141
142        /**
143         * The type of message.
144         * <P>Type: INTEGER</P>
145         */
146        public static final String TYPE = "type";
147
148        /**
149         * The thread ID of the message.
150         * <P>Type: INTEGER</P>
151         */
152        public static final String THREAD_ID = "thread_id";
153
154        /**
155         * The address of the other party.
156         * <P>Type: TEXT</P>
157         */
158        public static final String ADDRESS = "address";
159
160        /**
161         * The date the message was received.
162         * <P>Type: INTEGER (long)</P>
163         */
164        public static final String DATE = "date";
165
166        /**
167         * The date the message was sent.
168         * <P>Type: INTEGER (long)</P>
169         */
170        public static final String DATE_SENT = "date_sent";
171
172        /**
173         * Has the message been read?
174         * <P>Type: INTEGER (boolean)</P>
175         */
176        public static final String READ = "read";
177
178        /**
179         * Has the message been seen by the user? The "seen" flag determines
180         * whether we need to show a notification.
181         * <P>Type: INTEGER (boolean)</P>
182         */
183        public static final String SEEN = "seen";
184
185        /**
186         * {@code TP-Status} value for the message, or -1 if no status has been received.
187         * <P>Type: INTEGER</P>
188         */
189        public static final String STATUS = "status";
190
191        /** TP-Status: no status received. */
192        public static final int STATUS_NONE = -1;
193        /** TP-Status: complete. */
194        public static final int STATUS_COMPLETE = 0;
195        /** TP-Status: pending. */
196        public static final int STATUS_PENDING = 32;
197        /** TP-Status: failed. */
198        public static final int STATUS_FAILED = 64;
199
200        /**
201         * The subject of the message, if present.
202         * <P>Type: TEXT</P>
203         */
204        public static final String SUBJECT = "subject";
205
206        /**
207         * The body of the message.
208         * <P>Type: TEXT</P>
209         */
210        public static final String BODY = "body";
211
212        /**
213         * The ID of the sender of the conversation, if present.
214         * <P>Type: INTEGER (reference to item in {@code content://contacts/people})</P>
215         */
216        public static final String PERSON = "person";
217
218        /**
219         * The protocol identifier code.
220         * <P>Type: INTEGER</P>
221         */
222        public static final String PROTOCOL = "protocol";
223
224        /**
225         * Is the {@code TP-Reply-Path} flag set?
226         * <P>Type: BOOLEAN</P>
227         */
228        public static final String REPLY_PATH_PRESENT = "reply_path_present";
229
230        /**
231         * The service center (SC) through which to send the message, if present.
232         * <P>Type: TEXT</P>
233         */
234        public static final String SERVICE_CENTER = "service_center";
235
236        /**
237         * Is the message locked?
238         * <P>Type: INTEGER (boolean)</P>
239         */
240        public static final String LOCKED = "locked";
241
242        /**
243         * The sub_id to which the message belongs to. Its value will be
244         * {@link android.telephony.SubscriptionManager#INVALID_SUB_ID} if the sub id cannot be
245         * determined.
246         * <p>Type: INTEGER (long) </p>
247         */
248        public static final String SUB_ID = "sub_id";
249
250        /**
251         * The MTU size of the mobile interface to which the APN connected
252         * @hide
253         */
254        public static final String MTU = "mtu";
255
256        /**
257         * Error code associated with sending or receiving this message
258         * <P>Type: INTEGER</P>
259         */
260        public static final String ERROR_CODE = "error_code";
261
262        /**
263         * The identity of the sender of a sent message. It is
264         * usually the package name of the app which sends the message.
265         * <p>Type: TEXT</p>
266         */
267        public static final String CREATOR = "creator";
268    }
269
270    /**
271     * Contains all text-based SMS messages.
272     */
273    public static final class Sms implements BaseColumns, TextBasedSmsColumns {
274
275        /**
276         * Not instantiable.
277         * @hide
278         */
279        private Sms() {
280        }
281
282        /**
283         * Used to determine the currently configured default SMS package.
284         * @param context context of the requesting application
285         * @return package name for the default SMS package or null
286         */
287        public static String getDefaultSmsPackage(Context context) {
288            ComponentName component = SmsApplication.getDefaultSmsApplication(context, false);
289            if (component != null) {
290                return component.getPackageName();
291            }
292            return null;
293        }
294
295        /**
296         * Return cursor for table query.
297         * @hide
298         */
299        public static Cursor query(ContentResolver cr, String[] projection) {
300            return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
301        }
302
303        /**
304         * Return cursor for table query.
305         * @hide
306         */
307        public static Cursor query(ContentResolver cr, String[] projection,
308                String where, String orderBy) {
309            return cr.query(CONTENT_URI, projection, where,
310                    null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
311        }
312
313        /**
314         * The {@code content://} style URL for this table.
315         */
316        public static final Uri CONTENT_URI = Uri.parse("content://sms");
317
318        /**
319         * The default sort order for this table.
320         */
321        public static final String DEFAULT_SORT_ORDER = "date DESC";
322
323        /**
324         * Add an SMS to the given URI.
325         *
326         * @param resolver the content resolver to use
327         * @param uri the URI to add the message to
328         * @param address the address of the sender
329         * @param body the body of the message
330         * @param subject the pseudo-subject of the message
331         * @param date the timestamp for the message
332         * @param read true if the message has been read, false if not
333         * @param deliveryReport true if a delivery report was requested, false if not
334         * @return the URI for the new message
335         * @hide
336         */
337        public static Uri addMessageToUri(ContentResolver resolver,
338                Uri uri, String address, String body, String subject,
339                Long date, boolean read, boolean deliveryReport) {
340            return addMessageToUri(SubscriptionManager.getDefaultSmsSubId(),
341                    resolver, uri, address, body, subject, date, read, deliveryReport, -1L);
342        }
343
344        /**
345         * Add an SMS to the given URI.
346         *
347         * @param resolver the content resolver to use
348         * @param uri the URI to add the message to
349         * @param address the address of the sender
350         * @param body the body of the message
351         * @param subject the psuedo-subject of the message
352         * @param date the timestamp for the message
353         * @param read true if the message has been read, false if not
354         * @param deliveryReport true if a delivery report was requested, false if not
355         * @param subId the sub_id which the message belongs to
356         * @return the URI for the new message
357         * @hide
358         */
359        public static Uri addMessageToUri(long subId, ContentResolver resolver,
360                Uri uri, String address, String body, String subject,
361                Long date, boolean read, boolean deliveryReport) {
362            return addMessageToUri(subId, resolver, uri, address, body, subject,
363                    date, read, deliveryReport, -1L);
364        }
365
366        /**
367         * Add an SMS to the given URI with the specified thread ID.
368         *
369         * @param resolver the content resolver to use
370         * @param uri the URI to add the message to
371         * @param address the address of the sender
372         * @param body the body of the message
373         * @param subject the pseudo-subject of the message
374         * @param date the timestamp for the message
375         * @param read true if the message has been read, false if not
376         * @param deliveryReport true if a delivery report was requested, false if not
377         * @param threadId the thread_id of the message
378         * @return the URI for the new message
379         * @hide
380         */
381        public static Uri addMessageToUri(ContentResolver resolver,
382                Uri uri, String address, String body, String subject,
383                Long date, boolean read, boolean deliveryReport, long threadId) {
384            return addMessageToUri(SubscriptionManager.getDefaultSmsSubId(),
385                    resolver, uri, address, body, subject,
386                    date, read, deliveryReport, threadId);
387        }
388
389        /**
390         * Add an SMS to the given URI with thread_id specified.
391         *
392         * @param resolver the content resolver to use
393         * @param uri the URI to add the message to
394         * @param address the address of the sender
395         * @param body the body of the message
396         * @param subject the psuedo-subject of the message
397         * @param date the timestamp for the message
398         * @param read true if the message has been read, false if not
399         * @param deliveryReport true if a delivery report was requested, false if not
400         * @param threadId the thread_id of the message
401         * @param subId the sub_id which the message belongs to
402         * @return the URI for the new message
403         * @hide
404         */
405        public static Uri addMessageToUri(long subId, ContentResolver resolver,
406                Uri uri, String address, String body, String subject,
407                Long date, boolean read, boolean deliveryReport, long threadId) {
408            ContentValues values = new ContentValues(8);
409            Rlog.v(TAG,"Telephony addMessageToUri sub id: " + subId);
410
411            values.put(SUB_ID, subId);
412            values.put(ADDRESS, address);
413            if (date != null) {
414                values.put(DATE, date);
415            }
416            values.put(READ, read ? Integer.valueOf(1) : Integer.valueOf(0));
417            values.put(SUBJECT, subject);
418            values.put(BODY, body);
419            if (deliveryReport) {
420                values.put(STATUS, STATUS_PENDING);
421            }
422            if (threadId != -1L) {
423                values.put(THREAD_ID, threadId);
424            }
425            return resolver.insert(uri, values);
426        }
427
428        /**
429         * Move a message to the given folder.
430         *
431         * @param context the context to use
432         * @param uri the message to move
433         * @param folder the folder to move to
434         * @return true if the operation succeeded
435         * @hide
436         */
437        public static boolean moveMessageToFolder(Context context,
438                Uri uri, int folder, int error) {
439            if (uri == null) {
440                return false;
441            }
442
443            boolean markAsUnread = false;
444            boolean markAsRead = false;
445            switch(folder) {
446            case MESSAGE_TYPE_INBOX:
447            case MESSAGE_TYPE_DRAFT:
448                break;
449            case MESSAGE_TYPE_OUTBOX:
450            case MESSAGE_TYPE_SENT:
451                markAsRead = true;
452                break;
453            case MESSAGE_TYPE_FAILED:
454            case MESSAGE_TYPE_QUEUED:
455                markAsUnread = true;
456                break;
457            default:
458                return false;
459            }
460
461            ContentValues values = new ContentValues(3);
462
463            values.put(TYPE, folder);
464            if (markAsUnread) {
465                values.put(READ, 0);
466            } else if (markAsRead) {
467                values.put(READ, 1);
468            }
469            values.put(ERROR_CODE, error);
470
471            return 1 == SqliteWrapper.update(context, context.getContentResolver(),
472                            uri, values, null, null);
473        }
474
475        /**
476         * Returns true iff the folder (message type) identifies an
477         * outgoing message.
478         * @hide
479         */
480        public static boolean isOutgoingFolder(int messageType) {
481            return  (messageType == MESSAGE_TYPE_FAILED)
482                    || (messageType == MESSAGE_TYPE_OUTBOX)
483                    || (messageType == MESSAGE_TYPE_SENT)
484                    || (messageType == MESSAGE_TYPE_QUEUED);
485        }
486
487        /**
488         * Contains all text-based SMS messages in the SMS app inbox.
489         */
490        public static final class Inbox implements BaseColumns, TextBasedSmsColumns {
491
492            /**
493             * Not instantiable.
494             * @hide
495             */
496            private Inbox() {
497            }
498
499            /**
500             * The {@code content://} style URL for this table.
501             */
502            public static final Uri CONTENT_URI = Uri.parse("content://sms/inbox");
503
504            /**
505             * The default sort order for this table.
506             */
507            public static final String DEFAULT_SORT_ORDER = "date DESC";
508
509            /**
510             * Add an SMS to the Draft box.
511             *
512             * @param resolver the content resolver to use
513             * @param address the address of the sender
514             * @param body the body of the message
515             * @param subject the pseudo-subject of the message
516             * @param date the timestamp for the message
517             * @param read true if the message has been read, false if not
518             * @return the URI for the new message
519             * @hide
520             */
521            public static Uri addMessage(ContentResolver resolver,
522                    String address, String body, String subject, Long date,
523                    boolean read) {
524                return addMessageToUri(SubscriptionManager.getDefaultSmsSubId(),
525                        resolver, CONTENT_URI, address, body, subject, date, read, false);
526            }
527
528            /**
529             * Add an SMS to the Draft box.
530             *
531             * @param resolver the content resolver to use
532             * @param address the address of the sender
533             * @param body the body of the message
534             * @param subject the psuedo-subject of the message
535             * @param date the timestamp for the message
536             * @param read true if the message has been read, false if not
537             * @param subId the sub_id which the message belongs to
538             * @return the URI for the new message
539             * @hide
540             */
541            public static Uri addMessage(long subId, ContentResolver resolver,
542                    String address, String body, String subject, Long date, boolean read) {
543                return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
544                        subject, date, read, false);
545            }
546        }
547
548        /**
549         * Contains all sent text-based SMS messages in the SMS app.
550         */
551        public static final class Sent implements BaseColumns, TextBasedSmsColumns {
552
553            /**
554             * Not instantiable.
555             * @hide
556             */
557            private Sent() {
558            }
559
560            /**
561             * The {@code content://} style URL for this table.
562             */
563            public static final Uri CONTENT_URI = Uri.parse("content://sms/sent");
564
565            /**
566             * The default sort order for this table.
567             */
568            public static final String DEFAULT_SORT_ORDER = "date DESC";
569
570            /**
571             * Add an SMS to the Draft box.
572             *
573             * @param resolver the content resolver to use
574             * @param address the address of the sender
575             * @param body the body of the message
576             * @param subject the pseudo-subject of the message
577             * @param date the timestamp for the message
578             * @return the URI for the new message
579             * @hide
580             */
581            public static Uri addMessage(ContentResolver resolver,
582                    String address, String body, String subject, Long date) {
583                return addMessageToUri(SubscriptionManager.getDefaultSmsSubId(),
584                        resolver, CONTENT_URI, address, body, subject, date, true, false);
585            }
586
587            /**
588             * Add an SMS to the Draft box.
589             *
590             * @param resolver the content resolver to use
591             * @param address the address of the sender
592             * @param body the body of the message
593             * @param subject the psuedo-subject of the message
594             * @param date the timestamp for the message
595             * @param subId the sub_id which the message belongs to
596             * @return the URI for the new message
597             * @hide
598             */
599            public static Uri addMessage(long subId, ContentResolver resolver,
600                    String address, String body, String subject, Long date) {
601                return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
602                        subject, date, true, false);
603            }
604        }
605
606        /**
607         * Contains all sent text-based SMS messages in the SMS app.
608         */
609        public static final class Draft implements BaseColumns, TextBasedSmsColumns {
610
611            /**
612             * Not instantiable.
613             * @hide
614             */
615            private Draft() {
616            }
617
618            /**
619             * The {@code content://} style URL for this table.
620             */
621            public static final Uri CONTENT_URI = Uri.parse("content://sms/draft");
622
623           /**
624            * @hide
625            */
626            public static Uri addMessage(ContentResolver resolver,
627                    String address, String body, String subject, Long date) {
628                return addMessageToUri(SubscriptionManager.getDefaultSmsSubId(),
629                        resolver, CONTENT_URI, address, body, subject, date, true, false);
630            }
631
632            /**
633             * Add an SMS to the Draft box.
634             *
635             * @param resolver the content resolver to use
636             * @param address the address of the sender
637             * @param body the body of the message
638             * @param subject the psuedo-subject of the message
639             * @param date the timestamp for the message
640             * @param subId the sub_id which the message belongs to
641             * @return the URI for the new message
642             * @hide
643             */
644            public static Uri addMessage(long subId, ContentResolver resolver,
645                    String address, String body, String subject, Long date) {
646                return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
647                        subject, date, true, false);
648            }
649
650            /**
651             * The default sort order for this table.
652             */
653            public static final String DEFAULT_SORT_ORDER = "date DESC";
654        }
655
656        /**
657         * Contains all pending outgoing text-based SMS messages.
658         */
659        public static final class Outbox implements BaseColumns, TextBasedSmsColumns {
660
661            /**
662             * Not instantiable.
663             * @hide
664             */
665            private Outbox() {
666            }
667
668            /**
669             * The {@code content://} style URL for this table.
670             */
671            public static final Uri CONTENT_URI = Uri.parse("content://sms/outbox");
672
673            /**
674             * The default sort order for this table.
675             */
676            public static final String DEFAULT_SORT_ORDER = "date DESC";
677
678            /**
679             * Add an SMS to the outbox.
680             *
681             * @param resolver the content resolver to use
682             * @param address the address of the sender
683             * @param body the body of the message
684             * @param subject the pseudo-subject of the message
685             * @param date the timestamp for the message
686             * @param deliveryReport whether a delivery report was requested for the message
687             * @return the URI for the new message
688             * @hide
689             */
690            public static Uri addMessage(ContentResolver resolver,
691                    String address, String body, String subject, Long date,
692                    boolean deliveryReport, long threadId) {
693                return addMessageToUri(SubscriptionManager.getDefaultSmsSubId(),
694                        resolver, CONTENT_URI, address, body, subject, date,
695                        true, deliveryReport, threadId);
696            }
697
698            /**
699             * Add an SMS to the Out box.
700             *
701             * @param resolver the content resolver to use
702             * @param address the address of the sender
703             * @param body the body of the message
704             * @param subject the psuedo-subject of the message
705             * @param date the timestamp for the message
706             * @param deliveryReport whether a delivery report was requested for the message
707             * @param subId the sub_id which the message belongs to
708             * @return the URI for the new message
709             * @hide
710             */
711            public static Uri addMessage(long subId, ContentResolver resolver,
712                    String address, String body, String subject, Long date,
713                    boolean deliveryReport, long threadId) {
714                return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
715                        subject, date, true, deliveryReport, threadId);
716            }
717        }
718
719        /**
720         * Contains all sent text-based SMS messages in the SMS app.
721         */
722        public static final class Conversations
723                implements BaseColumns, TextBasedSmsColumns {
724
725            /**
726             * Not instantiable.
727             * @hide
728             */
729            private Conversations() {
730            }
731
732            /**
733             * The {@code content://} style URL for this table.
734             */
735            public static final Uri CONTENT_URI = Uri.parse("content://sms/conversations");
736
737            /**
738             * The default sort order for this table.
739             */
740            public static final String DEFAULT_SORT_ORDER = "date DESC";
741
742            /**
743             * The first 45 characters of the body of the message.
744             * <P>Type: TEXT</P>
745             */
746            public static final String SNIPPET = "snippet";
747
748            /**
749             * The number of messages in the conversation.
750             * <P>Type: INTEGER</P>
751             */
752            public static final String MESSAGE_COUNT = "msg_count";
753        }
754
755        /**
756         * Contains constants for SMS related Intents that are broadcast.
757         */
758        public static final class Intents {
759
760            /**
761             * Not instantiable.
762             * @hide
763             */
764            private Intents() {
765            }
766
767            /**
768             * Set by BroadcastReceiver to indicate that the message was handled
769             * successfully.
770             */
771            public static final int RESULT_SMS_HANDLED = 1;
772
773            /**
774             * Set by BroadcastReceiver to indicate a generic error while
775             * processing the message.
776             */
777            public static final int RESULT_SMS_GENERIC_ERROR = 2;
778
779            /**
780             * Set by BroadcastReceiver to indicate insufficient memory to store
781             * the message.
782             */
783            public static final int RESULT_SMS_OUT_OF_MEMORY = 3;
784
785            /**
786             * Set by BroadcastReceiver to indicate that the message, while
787             * possibly valid, is of a format or encoding that is not
788             * supported.
789             */
790            public static final int RESULT_SMS_UNSUPPORTED = 4;
791
792            /**
793             * Set by BroadcastReceiver to indicate a duplicate incoming message.
794             */
795            public static final int RESULT_SMS_DUPLICATED = 5;
796
797            /**
798             * Activity action: Ask the user to change the default
799             * SMS application. This will show a dialog that asks the
800             * user whether they want to replace the current default
801             * SMS application with the one specified in
802             * {@link #EXTRA_PACKAGE_NAME}.
803             */
804            @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
805            public static final String ACTION_CHANGE_DEFAULT =
806                    "android.provider.Telephony.ACTION_CHANGE_DEFAULT";
807
808            /**
809             * The PackageName string passed in as an
810             * extra for {@link #ACTION_CHANGE_DEFAULT}
811             *
812             * @see #ACTION_CHANGE_DEFAULT
813             */
814            public static final String EXTRA_PACKAGE_NAME = "package";
815
816            /**
817             * Broadcast Action: A new text-based SMS message has been received
818             * by the device. This intent will only be delivered to the default
819             * sms app. That app is responsible for writing the message and notifying
820             * the user. The intent will have the following extra values:</p>
821             *
822             * <ul>
823             *   <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
824             *   that make up the message.</li>
825             * </ul>
826             *
827             * <p>The extra values can be extracted using
828             * {@link #getMessagesFromIntent(Intent)}.</p>
829             *
830             * <p>If a BroadcastReceiver encounters an error while processing
831             * this intent it should set the result code appropriately.</p>
832             *
833             * <p class="note"><strong>Note:</strong>
834             * The broadcast receiver that filters for this intent must declare
835             * {@link android.Manifest.permission#BROADCAST_SMS} as a required permission in
836             * the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code
837             * &lt;receiver>}</a> tag.
838             */
839            @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
840            public static final String SMS_DELIVER_ACTION =
841                    "android.provider.Telephony.SMS_DELIVER";
842
843            /**
844             * Broadcast Action: A new text-based SMS message has been received
845             * by the device. This intent will only be delivered to a
846             * carrier app which is responsible for filtering the message.
847             * If the carrier app wants to drop a message, it should set the result
848             * code to {@link android.app.Activity#RESULT_CANCELED}. The carrier app can
849             * also modify the SMS PDU by setting the "pdus" value in result extras.</p>
850             *
851             * The intent will have the following extra values:</p>
852             *
853             * <ul>
854             *   <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
855             *   that make up the message.</li>
856             *   <li><em>"format"</em> - A String describing the format of the PDUs. It can
857             *   be either "3gpp" or "3gpp2".</li>
858             *   <li><em>"destport"</em> - An int describing the destination port of a data
859             *   SMS. It will be -1 for text SMS.</li>
860             * </ul>
861             *
862             * <p>The extra values can be extracted using
863             * {@link #getMessagesFromIntent(Intent)}.</p>
864             *
865             * <p class="note"><strong>Note:</strong>
866             * The broadcast receiver that filters for this intent must be a carrier privileged app.
867             * It must also declare {@link android.Manifest.permission#BROADCAST_SMS} as a required
868             * permission in the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">
869             * {@code &lt;receiver>}</a> tag.
870             */
871            @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
872            public static final String SMS_FILTER_ACTION =
873                    "android.provider.Telephony.SMS_FILTER";
874
875            /**
876             * Broadcast Action: A new text-based SMS message has been received
877             * by the device. This intent will be delivered to all registered
878             * receivers as a notification. These apps are not expected to write the
879             * message or notify the user. The intent will have the following extra
880             * values:</p>
881             *
882             * <ul>
883             *   <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
884             *   that make up the message.</li>
885             * </ul>
886             *
887             * <p>The extra values can be extracted using
888             * {@link #getMessagesFromIntent(Intent)}.</p>
889             *
890             * <p>If a BroadcastReceiver encounters an error while processing
891             * this intent it should set the result code appropriately.</p>
892             */
893            @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
894            public static final String SMS_RECEIVED_ACTION =
895                    "android.provider.Telephony.SMS_RECEIVED";
896
897            /**
898             * Broadcast Action: A new data based SMS message has been received
899             * by the device. This intent will be delivered to all registered
900             * receivers as a notification. The intent will have the following extra
901             * values:</p>
902             *
903             * <ul>
904             *   <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
905             *   that make up the message.</li>
906             * </ul>
907             *
908             * <p>The extra values can be extracted using
909             * {@link #getMessagesFromIntent(Intent)}.</p>
910             *
911             * <p>If a BroadcastReceiver encounters an error while processing
912             * this intent it should set the result code appropriately.</p>
913             */
914            @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
915            public static final String DATA_SMS_RECEIVED_ACTION =
916                    "android.intent.action.DATA_SMS_RECEIVED";
917
918            /**
919             * Broadcast Action: A new WAP PUSH message has been received by the
920             * device. This intent will only be delivered to the default
921             * sms app. That app is responsible for writing the message and notifying
922             * the user. The intent will have the following extra values:</p>
923             *
924             * <ul>
925             *   <li><em>"transactionId"</em> - (Integer) The WAP transaction ID</li>
926             *   <li><em>"pduType"</em> - (Integer) The WAP PDU type</li>
927             *   <li><em>"header"</em> - (byte[]) The header of the message</li>
928             *   <li><em>"data"</em> - (byte[]) The data payload of the message</li>
929             *   <li><em>"contentTypeParameters" </em>
930             *   -(HashMap&lt;String,String&gt;) Any parameters associated with the content type
931             *   (decoded from the WSP Content-Type header)</li>
932             * </ul>
933             *
934             * <p>If a BroadcastReceiver encounters an error while processing
935             * this intent it should set the result code appropriately.</p>
936             *
937             * <p>The contentTypeParameters extra value is map of content parameters keyed by
938             * their names.</p>
939             *
940             * <p>If any unassigned well-known parameters are encountered, the key of the map will
941             * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter.  If
942             * a parameter has No-Value the value in the map will be null.</p>
943             *
944             * <p class="note"><strong>Note:</strong>
945             * The broadcast receiver that filters for this intent must declare
946             * {@link android.Manifest.permission#BROADCAST_WAP_PUSH} as a required permission in
947             * the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code
948             * &lt;receiver>}</a> tag.
949             */
950            @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
951            public static final String WAP_PUSH_DELIVER_ACTION =
952                    "android.provider.Telephony.WAP_PUSH_DELIVER";
953
954            /**
955             * Broadcast Action: A new WAP PUSH message has been received by the
956             * device. This intent will be delivered to all registered
957             * receivers as a notification. These apps are not expected to write the
958             * message or notify the user. The intent will have the following extra
959             * values:</p>
960             *
961             * <ul>
962             *   <li><em>"transactionId"</em> - (Integer) The WAP transaction ID</li>
963             *   <li><em>"pduType"</em> - (Integer) The WAP PDU type</li>
964             *   <li><em>"header"</em> - (byte[]) The header of the message</li>
965             *   <li><em>"data"</em> - (byte[]) The data payload of the message</li>
966             *   <li><em>"contentTypeParameters"</em>
967             *   - (HashMap&lt;String,String&gt;) Any parameters associated with the content type
968             *   (decoded from the WSP Content-Type header)</li>
969             * </ul>
970             *
971             * <p>If a BroadcastReceiver encounters an error while processing
972             * this intent it should set the result code appropriately.</p>
973             *
974             * <p>The contentTypeParameters extra value is map of content parameters keyed by
975             * their names.</p>
976             *
977             * <p>If any unassigned well-known parameters are encountered, the key of the map will
978             * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter.  If
979             * a parameter has No-Value the value in the map will be null.</p>
980             */
981            @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
982            public static final String WAP_PUSH_RECEIVED_ACTION =
983                    "android.provider.Telephony.WAP_PUSH_RECEIVED";
984
985            /**
986             * Broadcast Action: A new Cell Broadcast message has been received
987             * by the device. The intent will have the following extra
988             * values:</p>
989             *
990             * <ul>
991             *   <li><em>"message"</em> - An SmsCbMessage object containing the broadcast message
992             *   data. This is not an emergency alert, so ETWS and CMAS data will be null.</li>
993             * </ul>
994             *
995             * <p>The extra values can be extracted using
996             * {@link #getMessagesFromIntent(Intent)}.</p>
997             *
998             * <p>If a BroadcastReceiver encounters an error while processing
999             * this intent it should set the result code appropriately.</p>
1000             */
1001            @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1002            public static final String SMS_CB_RECEIVED_ACTION =
1003                    "android.provider.Telephony.SMS_CB_RECEIVED";
1004
1005            /**
1006             * Broadcast Action: A new Emergency Broadcast message has been received
1007             * by the device. The intent will have the following extra
1008             * values:</p>
1009             *
1010             * <ul>
1011             *   <li><em>"message"</em> - An SmsCbMessage object containing the broadcast message
1012             *   data, including ETWS or CMAS warning notification info if present.</li>
1013             * </ul>
1014             *
1015             * <p>The extra values can be extracted using
1016             * {@link #getMessagesFromIntent(Intent)}.</p>
1017             *
1018             * <p>If a BroadcastReceiver encounters an error while processing
1019             * this intent it should set the result code appropriately.</p>
1020             */
1021            @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1022            public static final String SMS_EMERGENCY_CB_RECEIVED_ACTION =
1023                    "android.provider.Telephony.SMS_EMERGENCY_CB_RECEIVED";
1024
1025            /**
1026             * Broadcast Action: A new CDMA SMS has been received containing Service Category
1027             * Program Data (updates the list of enabled broadcast channels). The intent will
1028             * have the following extra values:</p>
1029             *
1030             * <ul>
1031             *   <li><em>"operations"</em> - An array of CdmaSmsCbProgramData objects containing
1032             *   the service category operations (add/delete/clear) to perform.</li>
1033             * </ul>
1034             *
1035             * <p>The extra values can be extracted using
1036             * {@link #getMessagesFromIntent(Intent)}.</p>
1037             *
1038             * <p>If a BroadcastReceiver encounters an error while processing
1039             * this intent it should set the result code appropriately.</p>
1040             */
1041            @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1042            public static final String SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION =
1043                    "android.provider.Telephony.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED";
1044
1045            /**
1046             * Broadcast Action: The SIM storage for SMS messages is full.  If
1047             * space is not freed, messages targeted for the SIM (class 2) may
1048             * not be saved.
1049             */
1050            @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1051            public static final String SIM_FULL_ACTION =
1052                    "android.provider.Telephony.SIM_FULL";
1053
1054            /**
1055             * Broadcast Action: An incoming SMS has been rejected by the
1056             * telephony framework.  This intent is sent in lieu of any
1057             * of the RECEIVED_ACTION intents.  The intent will have the
1058             * following extra value:</p>
1059             *
1060             * <ul>
1061             *   <li><em>"result"</em> - An int result code, e.g. {@link #RESULT_SMS_OUT_OF_MEMORY}
1062             *   indicating the error returned to the network.</li>
1063             * </ul>
1064             */
1065            @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1066            public static final String SMS_REJECTED_ACTION =
1067                "android.provider.Telephony.SMS_REJECTED";
1068
1069            /**
1070             * Broadcast Action: A new SMS PDU needs to be sent from
1071             * the device. This intent will only be delivered to a
1072             * carrier app. That app is responsible for sending the PDU.
1073             * The intent will have the following extra values:</p>
1074             *
1075             * <ul>
1076             *   <li><em>"pdu"</em> - (byte[]) The PDU to send.</li>
1077             *   <li><em>"smsc"</em> - (byte[]) The service center address (for GSM PDU only).</li>
1078             *   <li><em>"format"</em> - (String) The format of the PDU. Either 3gpp or 3gpp2. </li>
1079             *   <li><em>"concat.refNumber"</em> - (int) If the SMS is part of a multi-part SMS, the
1080             *   ref number used in the SMS header.</li>
1081             *   <li><em>"concat.seqNumber"</em> - (int) If the SMS is part of a multi-part SMS, the
1082             *   sequence number of this SMS.</li>
1083             *   <li><em>"concat.msgCount"</em> - (int) If the SMS is part of a multi-part SMS, the
1084             *   total number of SMSes in the multi-part SMS.</li>
1085             * </ul>
1086             *
1087             * <p>If a BroadcastReceiver is trying to send the message,
1088             *  it should set the result code to {@link android.app.Activity#RESULT_OK} and set
1089             *  the following in the result extra values:</p>
1090             *
1091             * <ul>
1092             *   <li><em>"messageref"</em> - (int) The new message reference number which will be
1093             *   later used in the updateSmsSendStatus call.</li>
1094             * </ul>
1095             *
1096             * <p>If a BroadcastReceiver cannot send the message, it should not set the result
1097             *  code and the platform will send it via the normal pathway.
1098             * </p>
1099             *
1100             * <p class="note"><strong>Note:</strong>
1101             * The broadcast receiver that filters for this intent must be a carrier privileged app.
1102             * It must also declare {@link android.Manifest.permission#BROADCAST_SMS} as a required
1103             * permission in the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">
1104             * {@code &lt;receiver>}</a> tag.
1105             */
1106            @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1107            public static final String SMS_SEND_ACTION =
1108                "android.provider.Telephony.SMS_SEND";
1109
1110            /**
1111             * Read the PDUs out of an {@link #SMS_RECEIVED_ACTION} or a
1112             * {@link #DATA_SMS_RECEIVED_ACTION} intent.
1113             *
1114             * @param intent the intent to read from
1115             * @return an array of SmsMessages for the PDUs
1116             */
1117            public static SmsMessage[] getMessagesFromIntent(Intent intent) {
1118                Object[] messages = (Object[]) intent.getSerializableExtra("pdus");
1119                String format = intent.getStringExtra("format");
1120                long subId = intent.getLongExtra(PhoneConstants.SUBSCRIPTION_KEY,
1121                        SubscriptionManager.getDefaultSmsSubId());
1122
1123                Rlog.v(TAG, " getMessagesFromIntent sub_id : " + subId);
1124
1125                int pduCount = messages.length;
1126                SmsMessage[] msgs = new SmsMessage[pduCount];
1127
1128                for (int i = 0; i < pduCount; i++) {
1129                    byte[] pdu = (byte[]) messages[i];
1130                    msgs[i] = SmsMessage.createFromPdu(pdu, format);
1131                    msgs[i].setSubId(subId);
1132                }
1133                return msgs;
1134            }
1135        }
1136    }
1137
1138    /**
1139     * Base columns for tables that contain MMSs.
1140     */
1141    public interface BaseMmsColumns extends BaseColumns {
1142
1143        /** Message box: all messages. */
1144        public static final int MESSAGE_BOX_ALL    = 0;
1145        /** Message box: inbox. */
1146        public static final int MESSAGE_BOX_INBOX  = 1;
1147        /** Message box: sent messages. */
1148        public static final int MESSAGE_BOX_SENT   = 2;
1149        /** Message box: drafts. */
1150        public static final int MESSAGE_BOX_DRAFTS = 3;
1151        /** Message box: outbox. */
1152        public static final int MESSAGE_BOX_OUTBOX = 4;
1153        /** Message box: failed. */
1154        public static final int MESSAGE_BOX_FAILED = 5;
1155
1156        /**
1157         * The thread ID of the message.
1158         * <P>Type: INTEGER (long)</P>
1159         */
1160        public static final String THREAD_ID = "thread_id";
1161
1162        /**
1163         * The date the message was received.
1164         * <P>Type: INTEGER (long)</P>
1165         */
1166        public static final String DATE = "date";
1167
1168        /**
1169         * The date the message was sent.
1170         * <P>Type: INTEGER (long)</P>
1171         */
1172        public static final String DATE_SENT = "date_sent";
1173
1174        /**
1175         * The box which the message belongs to, e.g. {@link #MESSAGE_BOX_INBOX}.
1176         * <P>Type: INTEGER</P>
1177         */
1178        public static final String MESSAGE_BOX = "msg_box";
1179
1180        /**
1181         * Has the message been read?
1182         * <P>Type: INTEGER (boolean)</P>
1183         */
1184        public static final String READ = "read";
1185
1186        /**
1187         * Has the message been seen by the user? The "seen" flag determines
1188         * whether we need to show a new message notification.
1189         * <P>Type: INTEGER (boolean)</P>
1190         */
1191        public static final String SEEN = "seen";
1192
1193        /**
1194         * Does the message have only a text part (can also have a subject) with
1195         * no picture, slideshow, sound, etc. parts?
1196         * <P>Type: INTEGER (boolean)</P>
1197         */
1198        public static final String TEXT_ONLY = "text_only";
1199
1200        /**
1201         * The {@code Message-ID} of the message.
1202         * <P>Type: TEXT</P>
1203         */
1204        public static final String MESSAGE_ID = "m_id";
1205
1206        /**
1207         * The subject of the message, if present.
1208         * <P>Type: TEXT</P>
1209         */
1210        public static final String SUBJECT = "sub";
1211
1212        /**
1213         * The character set of the subject, if present.
1214         * <P>Type: INTEGER</P>
1215         */
1216        public static final String SUBJECT_CHARSET = "sub_cs";
1217
1218        /**
1219         * The {@code Content-Type} of the message.
1220         * <P>Type: TEXT</P>
1221         */
1222        public static final String CONTENT_TYPE = "ct_t";
1223
1224        /**
1225         * The {@code Content-Location} of the message.
1226         * <P>Type: TEXT</P>
1227         */
1228        public static final String CONTENT_LOCATION = "ct_l";
1229
1230        /**
1231         * The expiry time of the message.
1232         * <P>Type: INTEGER (long)</P>
1233         */
1234        public static final String EXPIRY = "exp";
1235
1236        /**
1237         * The class of the message.
1238         * <P>Type: TEXT</P>
1239         */
1240        public static final String MESSAGE_CLASS = "m_cls";
1241
1242        /**
1243         * The type of the message defined by MMS spec.
1244         * <P>Type: INTEGER</P>
1245         */
1246        public static final String MESSAGE_TYPE = "m_type";
1247
1248        /**
1249         * The version of the specification that this message conforms to.
1250         * <P>Type: INTEGER</P>
1251         */
1252        public static final String MMS_VERSION = "v";
1253
1254        /**
1255         * The size of the message.
1256         * <P>Type: INTEGER</P>
1257         */
1258        public static final String MESSAGE_SIZE = "m_size";
1259
1260        /**
1261         * The priority of the message.
1262         * <P>Type: INTEGER</P>
1263         */
1264        public static final String PRIORITY = "pri";
1265
1266        /**
1267         * The {@code read-report} of the message.
1268         * <P>Type: INTEGER (boolean)</P>
1269         */
1270        public static final String READ_REPORT = "rr";
1271
1272        /**
1273         * Is read report allowed?
1274         * <P>Type: INTEGER (boolean)</P>
1275         */
1276        public static final String REPORT_ALLOWED = "rpt_a";
1277
1278        /**
1279         * The {@code response-status} of the message.
1280         * <P>Type: INTEGER</P>
1281         */
1282        public static final String RESPONSE_STATUS = "resp_st";
1283
1284        /**
1285         * The {@code status} of the message.
1286         * <P>Type: INTEGER</P>
1287         */
1288        public static final String STATUS = "st";
1289
1290        /**
1291         * The {@code transaction-id} of the message.
1292         * <P>Type: TEXT</P>
1293         */
1294        public static final String TRANSACTION_ID = "tr_id";
1295
1296        /**
1297         * The {@code retrieve-status} of the message.
1298         * <P>Type: INTEGER</P>
1299         */
1300        public static final String RETRIEVE_STATUS = "retr_st";
1301
1302        /**
1303         * The {@code retrieve-text} of the message.
1304         * <P>Type: TEXT</P>
1305         */
1306        public static final String RETRIEVE_TEXT = "retr_txt";
1307
1308        /**
1309         * The character set of the retrieve-text.
1310         * <P>Type: INTEGER</P>
1311         */
1312        public static final String RETRIEVE_TEXT_CHARSET = "retr_txt_cs";
1313
1314        /**
1315         * The {@code read-status} of the message.
1316         * <P>Type: INTEGER</P>
1317         */
1318        public static final String READ_STATUS = "read_status";
1319
1320        /**
1321         * The {@code content-class} of the message.
1322         * <P>Type: INTEGER</P>
1323         */
1324        public static final String CONTENT_CLASS = "ct_cls";
1325
1326        /**
1327         * The {@code delivery-report} of the message.
1328         * <P>Type: INTEGER</P>
1329         */
1330        public static final String DELIVERY_REPORT = "d_rpt";
1331
1332        /**
1333         * The {@code delivery-time-token} of the message.
1334         * <P>Type: INTEGER</P>
1335         * @deprecated this column is no longer supported.
1336         * @hide
1337         */
1338        @Deprecated
1339        public static final String DELIVERY_TIME_TOKEN = "d_tm_tok";
1340
1341        /**
1342         * The {@code delivery-time} of the message.
1343         * <P>Type: INTEGER</P>
1344         */
1345        public static final String DELIVERY_TIME = "d_tm";
1346
1347        /**
1348         * The {@code response-text} of the message.
1349         * <P>Type: TEXT</P>
1350         */
1351        public static final String RESPONSE_TEXT = "resp_txt";
1352
1353        /**
1354         * The {@code sender-visibility} of the message.
1355         * <P>Type: TEXT</P>
1356         * @deprecated this column is no longer supported.
1357         * @hide
1358         */
1359        @Deprecated
1360        public static final String SENDER_VISIBILITY = "s_vis";
1361
1362        /**
1363         * The {@code reply-charging} of the message.
1364         * <P>Type: INTEGER</P>
1365         * @deprecated this column is no longer supported.
1366         * @hide
1367         */
1368        @Deprecated
1369        public static final String REPLY_CHARGING = "r_chg";
1370
1371        /**
1372         * The {@code reply-charging-deadline-token} of the message.
1373         * <P>Type: INTEGER</P>
1374         * @deprecated this column is no longer supported.
1375         * @hide
1376         */
1377        @Deprecated
1378        public static final String REPLY_CHARGING_DEADLINE_TOKEN = "r_chg_dl_tok";
1379
1380        /**
1381         * The {@code reply-charging-deadline} of the message.
1382         * <P>Type: INTEGER</P>
1383         * @deprecated this column is no longer supported.
1384         * @hide
1385         */
1386        @Deprecated
1387        public static final String REPLY_CHARGING_DEADLINE = "r_chg_dl";
1388
1389        /**
1390         * The {@code reply-charging-id} of the message.
1391         * <P>Type: TEXT</P>
1392         * @deprecated this column is no longer supported.
1393         * @hide
1394         */
1395        @Deprecated
1396        public static final String REPLY_CHARGING_ID = "r_chg_id";
1397
1398        /**
1399         * The {@code reply-charging-size} of the message.
1400         * <P>Type: INTEGER</P>
1401         * @deprecated this column is no longer supported.
1402         * @hide
1403         */
1404        @Deprecated
1405        public static final String REPLY_CHARGING_SIZE = "r_chg_sz";
1406
1407        /**
1408         * The {@code previously-sent-by} of the message.
1409         * <P>Type: TEXT</P>
1410         * @deprecated this column is no longer supported.
1411         * @hide
1412         */
1413        @Deprecated
1414        public static final String PREVIOUSLY_SENT_BY = "p_s_by";
1415
1416        /**
1417         * The {@code previously-sent-date} of the message.
1418         * <P>Type: INTEGER</P>
1419         * @deprecated this column is no longer supported.
1420         * @hide
1421         */
1422        @Deprecated
1423        public static final String PREVIOUSLY_SENT_DATE = "p_s_d";
1424
1425        /**
1426         * The {@code store} of the message.
1427         * <P>Type: TEXT</P>
1428         * @deprecated this column is no longer supported.
1429         * @hide
1430         */
1431        @Deprecated
1432        public static final String STORE = "store";
1433
1434        /**
1435         * The {@code mm-state} of the message.
1436         * <P>Type: INTEGER</P>
1437         * @deprecated this column is no longer supported.
1438         * @hide
1439         */
1440        @Deprecated
1441        public static final String MM_STATE = "mm_st";
1442
1443        /**
1444         * The {@code mm-flags-token} of the message.
1445         * <P>Type: INTEGER</P>
1446         * @deprecated this column is no longer supported.
1447         * @hide
1448         */
1449        @Deprecated
1450        public static final String MM_FLAGS_TOKEN = "mm_flg_tok";
1451
1452        /**
1453         * The {@code mm-flags} of the message.
1454         * <P>Type: TEXT</P>
1455         * @deprecated this column is no longer supported.
1456         * @hide
1457         */
1458        @Deprecated
1459        public static final String MM_FLAGS = "mm_flg";
1460
1461        /**
1462         * The {@code store-status} of the message.
1463         * <P>Type: TEXT</P>
1464         * @deprecated this column is no longer supported.
1465         * @hide
1466         */
1467        @Deprecated
1468        public static final String STORE_STATUS = "store_st";
1469
1470        /**
1471         * The {@code store-status-text} of the message.
1472         * <P>Type: TEXT</P>
1473         * @deprecated this column is no longer supported.
1474         * @hide
1475         */
1476        @Deprecated
1477        public static final String STORE_STATUS_TEXT = "store_st_txt";
1478
1479        /**
1480         * The {@code stored} of the message.
1481         * <P>Type: TEXT</P>
1482         * @deprecated this column is no longer supported.
1483         * @hide
1484         */
1485        @Deprecated
1486        public static final String STORED = "stored";
1487
1488        /**
1489         * The {@code totals} of the message.
1490         * <P>Type: TEXT</P>
1491         * @deprecated this column is no longer supported.
1492         * @hide
1493         */
1494        @Deprecated
1495        public static final String TOTALS = "totals";
1496
1497        /**
1498         * The {@code mbox-totals} of the message.
1499         * <P>Type: TEXT</P>
1500         * @deprecated this column is no longer supported.
1501         * @hide
1502         */
1503        @Deprecated
1504        public static final String MBOX_TOTALS = "mb_t";
1505
1506        /**
1507         * The {@code mbox-totals-token} of the message.
1508         * <P>Type: INTEGER</P>
1509         * @deprecated this column is no longer supported.
1510         * @hide
1511         */
1512        @Deprecated
1513        public static final String MBOX_TOTALS_TOKEN = "mb_t_tok";
1514
1515        /**
1516         * The {@code quotas} of the message.
1517         * <P>Type: TEXT</P>
1518         * @deprecated this column is no longer supported.
1519         * @hide
1520         */
1521        @Deprecated
1522        public static final String QUOTAS = "qt";
1523
1524        /**
1525         * The {@code mbox-quotas} of the message.
1526         * <P>Type: TEXT</P>
1527         * @deprecated this column is no longer supported.
1528         * @hide
1529         */
1530        @Deprecated
1531        public static final String MBOX_QUOTAS = "mb_qt";
1532
1533        /**
1534         * The {@code mbox-quotas-token} of the message.
1535         * <P>Type: INTEGER</P>
1536         * @deprecated this column is no longer supported.
1537         * @hide
1538         */
1539        @Deprecated
1540        public static final String MBOX_QUOTAS_TOKEN = "mb_qt_tok";
1541
1542        /**
1543         * The {@code message-count} of the message.
1544         * <P>Type: INTEGER</P>
1545         * @deprecated this column is no longer supported.
1546         * @hide
1547         */
1548        @Deprecated
1549        public static final String MESSAGE_COUNT = "m_cnt";
1550
1551        /**
1552         * The {@code start} of the message.
1553         * <P>Type: INTEGER</P>
1554         * @deprecated this column is no longer supported.
1555         * @hide
1556         */
1557        @Deprecated
1558        public static final String START = "start";
1559
1560        /**
1561         * The {@code distribution-indicator} of the message.
1562         * <P>Type: TEXT</P>
1563         * @deprecated this column is no longer supported.
1564         * @hide
1565         */
1566        @Deprecated
1567        public static final String DISTRIBUTION_INDICATOR = "d_ind";
1568
1569        /**
1570         * The {@code element-descriptor} of the message.
1571         * <P>Type: TEXT</P>
1572         * @deprecated this column is no longer supported.
1573         * @hide
1574         */
1575        @Deprecated
1576        public static final String ELEMENT_DESCRIPTOR = "e_des";
1577
1578        /**
1579         * The {@code limit} of the message.
1580         * <P>Type: INTEGER</P>
1581         * @deprecated this column is no longer supported.
1582         * @hide
1583         */
1584        @Deprecated
1585        public static final String LIMIT = "limit";
1586
1587        /**
1588         * The {@code recommended-retrieval-mode} of the message.
1589         * <P>Type: INTEGER</P>
1590         * @deprecated this column is no longer supported.
1591         * @hide
1592         */
1593        @Deprecated
1594        public static final String RECOMMENDED_RETRIEVAL_MODE = "r_r_mod";
1595
1596        /**
1597         * The {@code recommended-retrieval-mode-text} of the message.
1598         * <P>Type: TEXT</P>
1599         * @deprecated this column is no longer supported.
1600         * @hide
1601         */
1602        @Deprecated
1603        public static final String RECOMMENDED_RETRIEVAL_MODE_TEXT = "r_r_mod_txt";
1604
1605        /**
1606         * The {@code status-text} of the message.
1607         * <P>Type: TEXT</P>
1608         * @deprecated this column is no longer supported.
1609         * @hide
1610         */
1611        @Deprecated
1612        public static final String STATUS_TEXT = "st_txt";
1613
1614        /**
1615         * The {@code applic-id} of the message.
1616         * <P>Type: TEXT</P>
1617         * @deprecated this column is no longer supported.
1618         * @hide
1619         */
1620        @Deprecated
1621        public static final String APPLIC_ID = "apl_id";
1622
1623        /**
1624         * The {@code reply-applic-id} of the message.
1625         * <P>Type: TEXT</P>
1626         * @deprecated this column is no longer supported.
1627         * @hide
1628         */
1629        @Deprecated
1630        public static final String REPLY_APPLIC_ID = "r_apl_id";
1631
1632        /**
1633         * The {@code aux-applic-id} of the message.
1634         * <P>Type: TEXT</P>
1635         * @deprecated this column is no longer supported.
1636         * @hide
1637         */
1638        @Deprecated
1639        public static final String AUX_APPLIC_ID = "aux_apl_id";
1640
1641        /**
1642         * The {@code drm-content} of the message.
1643         * <P>Type: TEXT</P>
1644         * @deprecated this column is no longer supported.
1645         * @hide
1646         */
1647        @Deprecated
1648        public static final String DRM_CONTENT = "drm_c";
1649
1650        /**
1651         * The {@code adaptation-allowed} of the message.
1652         * <P>Type: TEXT</P>
1653         * @deprecated this column is no longer supported.
1654         * @hide
1655         */
1656        @Deprecated
1657        public static final String ADAPTATION_ALLOWED = "adp_a";
1658
1659        /**
1660         * The {@code replace-id} of the message.
1661         * <P>Type: TEXT</P>
1662         * @deprecated this column is no longer supported.
1663         * @hide
1664         */
1665        @Deprecated
1666        public static final String REPLACE_ID = "repl_id";
1667
1668        /**
1669         * The {@code cancel-id} of the message.
1670         * <P>Type: TEXT</P>
1671         * @deprecated this column is no longer supported.
1672         * @hide
1673         */
1674        @Deprecated
1675        public static final String CANCEL_ID = "cl_id";
1676
1677        /**
1678         * The {@code cancel-status} of the message.
1679         * <P>Type: INTEGER</P>
1680         * @deprecated this column is no longer supported.
1681         * @hide
1682         */
1683        @Deprecated
1684        public static final String CANCEL_STATUS = "cl_st";
1685
1686        /**
1687         * Is the message locked?
1688         * <P>Type: INTEGER (boolean)</P>
1689         */
1690        public static final String LOCKED = "locked";
1691
1692        /**
1693         * The sub_id to which the message belongs to. Its value will be
1694         * {@link android.telephony.SubscriptionManager#INVALID_SUB_ID} if the sub id cannot be
1695         * determined.
1696         * <p>Type: INTEGER (long)</p>
1697         */
1698        public static final String SUB_ID = "sub_id";
1699
1700        /**
1701         * The identity of the sender of a sent message. It is
1702         * usually the package name of the app which sends the message.
1703         * <p>Type: TEXT</p>
1704         */
1705        public static final String CREATOR = "creator";
1706    }
1707
1708    /**
1709     * Columns for the "canonical_addresses" table used by MMS and SMS.
1710     */
1711    public interface CanonicalAddressesColumns extends BaseColumns {
1712        /**
1713         * An address used in MMS or SMS.  Email addresses are
1714         * converted to lower case and are compared by string
1715         * equality.  Other addresses are compared using
1716         * PHONE_NUMBERS_EQUAL.
1717         * <P>Type: TEXT</P>
1718         */
1719        public static final String ADDRESS = "address";
1720    }
1721
1722    /**
1723     * Columns for the "threads" table used by MMS and SMS.
1724     */
1725    public interface ThreadsColumns extends BaseColumns {
1726
1727        /**
1728         * The date at which the thread was created.
1729         * <P>Type: INTEGER (long)</P>
1730         */
1731        public static final String DATE = "date";
1732
1733        /**
1734         * A string encoding of the recipient IDs of the recipients of
1735         * the message, in numerical order and separated by spaces.
1736         * <P>Type: TEXT</P>
1737         */
1738        public static final String RECIPIENT_IDS = "recipient_ids";
1739
1740        /**
1741         * The message count of the thread.
1742         * <P>Type: INTEGER</P>
1743         */
1744        public static final String MESSAGE_COUNT = "message_count";
1745
1746        /**
1747         * Indicates whether all messages of the thread have been read.
1748         * <P>Type: INTEGER</P>
1749         */
1750        public static final String READ = "read";
1751
1752        /**
1753         * The snippet of the latest message in the thread.
1754         * <P>Type: TEXT</P>
1755         */
1756        public static final String SNIPPET = "snippet";
1757
1758        /**
1759         * The charset of the snippet.
1760         * <P>Type: INTEGER</P>
1761         */
1762        public static final String SNIPPET_CHARSET = "snippet_cs";
1763
1764        /**
1765         * Type of the thread, either {@link Threads#COMMON_THREAD} or
1766         * {@link Threads#BROADCAST_THREAD}.
1767         * <P>Type: INTEGER</P>
1768         */
1769        public static final String TYPE = "type";
1770
1771        /**
1772         * Indicates whether there is a transmission error in the thread.
1773         * <P>Type: INTEGER</P>
1774         */
1775        public static final String ERROR = "error";
1776
1777        /**
1778         * Indicates whether this thread contains any attachments.
1779         * <P>Type: INTEGER</P>
1780         */
1781        public static final String HAS_ATTACHMENT = "has_attachment";
1782
1783        /**
1784         * If the thread is archived
1785         * <P>Type: INTEGER (boolean)</P>
1786         */
1787        public static final String ARCHIVED = "archived";
1788    }
1789
1790    /**
1791     * Helper functions for the "threads" table used by MMS and SMS.
1792     */
1793    public static final class Threads implements ThreadsColumns {
1794
1795        private static final String[] ID_PROJECTION = { BaseColumns._ID };
1796
1797        /**
1798         * Private {@code content://} style URL for this table. Used by
1799         * {@link #getOrCreateThreadId(android.content.Context, java.util.Set)}.
1800         */
1801        private static final Uri THREAD_ID_CONTENT_URI = Uri.parse(
1802                "content://mms-sms/threadID");
1803
1804        /**
1805         * The {@code content://} style URL for this table, by conversation.
1806         */
1807        public static final Uri CONTENT_URI = Uri.withAppendedPath(
1808                MmsSms.CONTENT_URI, "conversations");
1809
1810        /**
1811         * The {@code content://} style URL for this table, for obsolete threads.
1812         */
1813        public static final Uri OBSOLETE_THREADS_URI = Uri.withAppendedPath(
1814                CONTENT_URI, "obsolete");
1815
1816        /** Thread type: common thread. */
1817        public static final int COMMON_THREAD    = 0;
1818
1819        /** Thread type: broadcast thread. */
1820        public static final int BROADCAST_THREAD = 1;
1821
1822        /**
1823         * Not instantiable.
1824         * @hide
1825         */
1826        private Threads() {
1827        }
1828
1829        /**
1830         * This is a single-recipient version of {@code getOrCreateThreadId}.
1831         * It's convenient for use with SMS messages.
1832         * @param context the context object to use.
1833         * @param recipient the recipient to send to.
1834         * @hide
1835         */
1836        public static long getOrCreateThreadId(Context context, String recipient) {
1837            Set<String> recipients = new HashSet<String>();
1838
1839            recipients.add(recipient);
1840            return getOrCreateThreadId(context, recipients);
1841        }
1842
1843        /**
1844         * Given the recipients list and subject of an unsaved message,
1845         * return its thread ID.  If the message starts a new thread,
1846         * allocate a new thread ID.  Otherwise, use the appropriate
1847         * existing thread ID.
1848         *
1849         * <p>Find the thread ID of the same set of recipients (in any order,
1850         * without any additions). If one is found, return it. Otherwise,
1851         * return a unique thread ID.</p>
1852         * @hide
1853         */
1854        public static long getOrCreateThreadId(
1855                Context context, Set<String> recipients) {
1856            Uri.Builder uriBuilder = THREAD_ID_CONTENT_URI.buildUpon();
1857
1858            for (String recipient : recipients) {
1859                if (Mms.isEmailAddress(recipient)) {
1860                    recipient = Mms.extractAddrSpec(recipient);
1861                }
1862
1863                uriBuilder.appendQueryParameter("recipient", recipient);
1864            }
1865
1866            Uri uri = uriBuilder.build();
1867            //if (DEBUG) Rlog.v(TAG, "getOrCreateThreadId uri: " + uri);
1868
1869            Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
1870                    uri, ID_PROJECTION, null, null, null);
1871            if (cursor != null) {
1872                try {
1873                    if (cursor.moveToFirst()) {
1874                        return cursor.getLong(0);
1875                    } else {
1876                        Rlog.e(TAG, "getOrCreateThreadId returned no rows!");
1877                    }
1878                } finally {
1879                    cursor.close();
1880                }
1881            }
1882
1883            Rlog.e(TAG, "getOrCreateThreadId failed with uri " + uri.toString());
1884            throw new IllegalArgumentException("Unable to find or allocate a thread ID.");
1885        }
1886    }
1887
1888    /**
1889     * Contains all MMS messages.
1890     */
1891    public static final class Mms implements BaseMmsColumns {
1892
1893        /**
1894         * Not instantiable.
1895         * @hide
1896         */
1897        private Mms() {
1898        }
1899
1900        /**
1901         * The {@code content://} URI for this table.
1902         */
1903        public static final Uri CONTENT_URI = Uri.parse("content://mms");
1904
1905        /**
1906         * Content URI for getting MMS report requests.
1907         */
1908        public static final Uri REPORT_REQUEST_URI = Uri.withAppendedPath(
1909                                            CONTENT_URI, "report-request");
1910
1911        /**
1912         * Content URI for getting MMS report status.
1913         */
1914        public static final Uri REPORT_STATUS_URI = Uri.withAppendedPath(
1915                                            CONTENT_URI, "report-status");
1916
1917        /**
1918         * The default sort order for this table.
1919         */
1920        public static final String DEFAULT_SORT_ORDER = "date DESC";
1921
1922        /**
1923         * Regex pattern for names and email addresses.
1924         * <ul>
1925         *     <li><em>mailbox</em> = {@code name-addr}</li>
1926         *     <li><em>name-addr</em> = {@code [display-name] angle-addr}</li>
1927         *     <li><em>angle-addr</em> = {@code [CFWS] "<" addr-spec ">" [CFWS]}</li>
1928         * </ul>
1929         * @hide
1930         */
1931        public static final Pattern NAME_ADDR_EMAIL_PATTERN =
1932                Pattern.compile("\\s*(\"[^\"]*\"|[^<>\"]+)\\s*<([^<>]+)>\\s*");
1933
1934        /**
1935         * Helper method to query this table.
1936         * @hide
1937         */
1938        public static Cursor query(
1939                ContentResolver cr, String[] projection) {
1940            return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
1941        }
1942
1943        /**
1944         * Helper method to query this table.
1945         * @hide
1946         */
1947        public static Cursor query(
1948                ContentResolver cr, String[] projection,
1949                String where, String orderBy) {
1950            return cr.query(CONTENT_URI, projection,
1951                    where, null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
1952        }
1953
1954        /**
1955         * Helper method to extract email address from address string.
1956         * @hide
1957         */
1958        public static String extractAddrSpec(String address) {
1959            Matcher match = NAME_ADDR_EMAIL_PATTERN.matcher(address);
1960
1961            if (match.matches()) {
1962                return match.group(2);
1963            }
1964            return address;
1965        }
1966
1967        /**
1968         * Is the specified address an email address?
1969         *
1970         * @param address the input address to test
1971         * @return true if address is an email address; false otherwise.
1972         * @hide
1973         */
1974        public static boolean isEmailAddress(String address) {
1975            if (TextUtils.isEmpty(address)) {
1976                return false;
1977            }
1978
1979            String s = extractAddrSpec(address);
1980            Matcher match = Patterns.EMAIL_ADDRESS.matcher(s);
1981            return match.matches();
1982        }
1983
1984        /**
1985         * Is the specified number a phone number?
1986         *
1987         * @param number the input number to test
1988         * @return true if number is a phone number; false otherwise.
1989         * @hide
1990         */
1991        public static boolean isPhoneNumber(String number) {
1992            if (TextUtils.isEmpty(number)) {
1993                return false;
1994            }
1995
1996            Matcher match = Patterns.PHONE.matcher(number);
1997            return match.matches();
1998        }
1999
2000        /**
2001         * Contains all MMS messages in the MMS app inbox.
2002         */
2003        public static final class Inbox implements BaseMmsColumns {
2004
2005            /**
2006             * Not instantiable.
2007             * @hide
2008             */
2009            private Inbox() {
2010            }
2011
2012            /**
2013             * The {@code content://} style URL for this table.
2014             */
2015            public static final Uri
2016                    CONTENT_URI = Uri.parse("content://mms/inbox");
2017
2018            /**
2019             * The default sort order for this table.
2020             */
2021            public static final String DEFAULT_SORT_ORDER = "date DESC";
2022        }
2023
2024        /**
2025         * Contains all MMS messages in the MMS app sent folder.
2026         */
2027        public static final class Sent implements BaseMmsColumns {
2028
2029            /**
2030             * Not instantiable.
2031             * @hide
2032             */
2033            private Sent() {
2034            }
2035
2036            /**
2037             * The {@code content://} style URL for this table.
2038             */
2039            public static final Uri
2040                    CONTENT_URI = Uri.parse("content://mms/sent");
2041
2042            /**
2043             * The default sort order for this table.
2044             */
2045            public static final String DEFAULT_SORT_ORDER = "date DESC";
2046        }
2047
2048        /**
2049         * Contains all MMS messages in the MMS app drafts folder.
2050         */
2051        public static final class Draft implements BaseMmsColumns {
2052
2053            /**
2054             * Not instantiable.
2055             * @hide
2056             */
2057            private Draft() {
2058            }
2059
2060            /**
2061             * The {@code content://} style URL for this table.
2062             */
2063            public static final Uri
2064                    CONTENT_URI = Uri.parse("content://mms/drafts");
2065
2066            /**
2067             * The default sort order for this table.
2068             */
2069            public static final String DEFAULT_SORT_ORDER = "date DESC";
2070        }
2071
2072        /**
2073         * Contains all MMS messages in the MMS app outbox.
2074         */
2075        public static final class Outbox implements BaseMmsColumns {
2076
2077            /**
2078             * Not instantiable.
2079             * @hide
2080             */
2081            private Outbox() {
2082            }
2083
2084            /**
2085             * The {@code content://} style URL for this table.
2086             */
2087            public static final Uri
2088                    CONTENT_URI = Uri.parse("content://mms/outbox");
2089
2090            /**
2091             * The default sort order for this table.
2092             */
2093            public static final String DEFAULT_SORT_ORDER = "date DESC";
2094        }
2095
2096        /**
2097         * Contains address information for an MMS message.
2098         */
2099        public static final class Addr implements BaseColumns {
2100
2101            /**
2102             * Not instantiable.
2103             * @hide
2104             */
2105            private Addr() {
2106            }
2107
2108            /**
2109             * The ID of MM which this address entry belongs to.
2110             * <P>Type: INTEGER (long)</P>
2111             */
2112            public static final String MSG_ID = "msg_id";
2113
2114            /**
2115             * The ID of contact entry in Phone Book.
2116             * <P>Type: INTEGER (long)</P>
2117             */
2118            public static final String CONTACT_ID = "contact_id";
2119
2120            /**
2121             * The address text.
2122             * <P>Type: TEXT</P>
2123             */
2124            public static final String ADDRESS = "address";
2125
2126            /**
2127             * Type of address: must be one of {@code PduHeaders.BCC},
2128             * {@code PduHeaders.CC}, {@code PduHeaders.FROM}, {@code PduHeaders.TO}.
2129             * <P>Type: INTEGER</P>
2130             */
2131            public static final String TYPE = "type";
2132
2133            /**
2134             * Character set of this entry (MMS charset value).
2135             * <P>Type: INTEGER</P>
2136             */
2137            public static final String CHARSET = "charset";
2138        }
2139
2140        /**
2141         * Contains message parts.
2142         */
2143        public static final class Part implements BaseColumns {
2144
2145            /**
2146             * Not instantiable.
2147             * @hide
2148             */
2149            private Part() {
2150            }
2151
2152            /**
2153             * The identifier of the message which this part belongs to.
2154             * <P>Type: INTEGER</P>
2155             */
2156            public static final String MSG_ID = "mid";
2157
2158            /**
2159             * The order of the part.
2160             * <P>Type: INTEGER</P>
2161             */
2162            public static final String SEQ = "seq";
2163
2164            /**
2165             * The content type of the part.
2166             * <P>Type: TEXT</P>
2167             */
2168            public static final String CONTENT_TYPE = "ct";
2169
2170            /**
2171             * The name of the part.
2172             * <P>Type: TEXT</P>
2173             */
2174            public static final String NAME = "name";
2175
2176            /**
2177             * The charset of the part.
2178             * <P>Type: TEXT</P>
2179             */
2180            public static final String CHARSET = "chset";
2181
2182            /**
2183             * The file name of the part.
2184             * <P>Type: TEXT</P>
2185             */
2186            public static final String FILENAME = "fn";
2187
2188            /**
2189             * The content disposition of the part.
2190             * <P>Type: TEXT</P>
2191             */
2192            public static final String CONTENT_DISPOSITION = "cd";
2193
2194            /**
2195             * The content ID of the part.
2196             * <P>Type: INTEGER</P>
2197             */
2198            public static final String CONTENT_ID = "cid";
2199
2200            /**
2201             * The content location of the part.
2202             * <P>Type: INTEGER</P>
2203             */
2204            public static final String CONTENT_LOCATION = "cl";
2205
2206            /**
2207             * The start of content-type of the message.
2208             * <P>Type: INTEGER</P>
2209             */
2210            public static final String CT_START = "ctt_s";
2211
2212            /**
2213             * The type of content-type of the message.
2214             * <P>Type: TEXT</P>
2215             */
2216            public static final String CT_TYPE = "ctt_t";
2217
2218            /**
2219             * The location (on filesystem) of the binary data of the part.
2220             * <P>Type: INTEGER</P>
2221             */
2222            public static final String _DATA = "_data";
2223
2224            /**
2225             * The message text.
2226             * <P>Type: TEXT</P>
2227             */
2228            public static final String TEXT = "text";
2229        }
2230
2231        /**
2232         * Message send rate table.
2233         */
2234        public static final class Rate {
2235
2236            /**
2237             * Not instantiable.
2238             * @hide
2239             */
2240            private Rate() {
2241            }
2242
2243            /**
2244             * The {@code content://} style URL for this table.
2245             */
2246            public static final Uri CONTENT_URI = Uri.withAppendedPath(
2247                    Mms.CONTENT_URI, "rate");
2248
2249            /**
2250             * When a message was successfully sent.
2251             * <P>Type: INTEGER (long)</P>
2252             */
2253            public static final String SENT_TIME = "sent_time";
2254        }
2255
2256        /**
2257         * Intents class.
2258         */
2259        public static final class Intents {
2260
2261            /**
2262             * Not instantiable.
2263             * @hide
2264             */
2265            private Intents() {
2266            }
2267
2268            /**
2269             * Indicates that the contents of specified URIs were changed.
2270             * The application which is showing or caching these contents
2271             * should be updated.
2272             */
2273            @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2274            public static final String CONTENT_CHANGED_ACTION
2275                    = "android.intent.action.CONTENT_CHANGED";
2276
2277            /**
2278             * Broadcast Action: A new MMS PDU needs to be sent from
2279             * the device. This intent will only be delivered to a
2280             * carrier app. That app is responsible for sending the PDU.
2281             * The intent will have the following extra values:</p>
2282             *
2283             * <ul>
2284             *   <li><em>{@link #EXTRA_MMS_CONTENT_URI}</em> - (Uri) The content provider of the
2285             *     PDU to send.</li>
2286             *   <li><em>{@link #EXTRA_MMS_LOCATION_URL}</em> - (String) The optional url to send
2287             *     this MMS PDU. If this is not specified, PDU should be sent to the default MMSC
2288             *     url.</li>
2289             * </ul>
2290             *
2291             * <p>If a BroadcastReceiver is trying to send the message,
2292             *  it should set the result code to {@link android.app.Activity#RESULT_OK} and set
2293             *  the following in the result extra values:</p>
2294             *
2295             * <ul>
2296             *   <li><em>"messageref"</em> - (int) The new message reference number which will be
2297             *   later used in the updateMmsSendStatus call.</li>
2298             * </ul>
2299             *
2300             * <p>If a BroadcastReceiver cannot send the message, it should not set the result
2301             *  code and the platform will send it via the normal pathway.
2302             * </p>
2303             *
2304             * <p class="note"><strong>Note:</strong>
2305             * The broadcast receiver that filters for this intent must be a carrier privileged app.
2306             * It must also declare {@link android.Manifest.permission#BROADCAST_WAP_PUSH} as a required
2307             * permission in the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">
2308             * {@code &lt;receiver>}</a> tag.
2309             */
2310            @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2311            public static final String MMS_SEND_ACTION =
2312                    "android.provider.Telephony.MMS_SEND";
2313
2314            /**
2315             * Broadcast Action: A new MMS needs to be downloaded.
2316             * This intent will only be delivered to a
2317             * carrier app. That app is responsible for downloading the message at the URL.
2318             * The intent will have the following extra values:</p>
2319             *
2320             * <ul>
2321             *   <li><em>{@link #EXTRA_MMS_CONTENT_URI}</em> - (Uri) The content provider of the
2322             *     PDU to be downloaded.</li>
2323             *   <li><em>{@link #EXTRA_MMS_LOCATION_URL}</em> - (String) The message URL to be
2324             *     downloaded.</li>
2325             * </ul>
2326             *
2327             * <p>If a BroadcastReceiver is trying to download the message,
2328             *  it should set the result code to {@link android.app.Activity#RESULT_OK} and set
2329             *  the following in the result extra values:</p>
2330             *
2331             * <ul>
2332             *   <li><em>"messageref"</em> - (int) The new message reference number which will be
2333             *   later used in the updateMmsDownloadStatus call.</li>
2334             * </ul>
2335             *
2336             * <p>If a BroadcastReceiver cannot download the message, it should not set the result
2337             *  code and the platform will download it via the normal pathway.
2338             * </p>
2339             *
2340             * <p class="note"><strong>Note:</strong>
2341             * The broadcast receiver that filters for this intent must be a carrier privileged app.
2342             * It must also declare {@link android.Manifest.permission#BROADCAST_WAP_PUSH} as a required
2343             * permission in the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">
2344             * {@code &lt;receiver>}</a> tag.
2345             */
2346            @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2347            public static final String MMS_DOWNLOAD_ACTION =
2348                    "android.provider.Telephony.MMS_DOWNLOAD";
2349
2350            /**
2351             * An extra field which stores the URI of deleted contents.
2352             */
2353            public static final String DELETED_CONTENTS = "deleted_contents";
2354
2355            /**
2356             * The content provider of the PDU to be sent/downloaded passed as an extra for
2357             * {@link #MMS_DOWNLOAD_ACTION} and {@link #MMS_SEND_ACTION}.
2358             */
2359            public static final String EXTRA_MMS_CONTENT_URI =
2360                    "android.provider.Telephony.extra.MMS_CONTENT_URI";
2361
2362            /**
2363             * The message URL to be downloaded passed as an extra for {@link #MMS_DOWNLOAD_ACTION}.
2364             * It is also the URL to send an MMS to passed as an extra for
2365             * {@link #MMS_SEND_ACTION}.
2366             */
2367            public static final String EXTRA_MMS_LOCATION_URL =
2368                    "android.provider.Telephony.extra.MMS_LOCATION_URL";
2369        }
2370    }
2371
2372    /**
2373     * Contains all MMS and SMS messages.
2374     */
2375    public static final class MmsSms implements BaseColumns {
2376
2377        /**
2378         * Not instantiable.
2379         * @hide
2380         */
2381        private MmsSms() {
2382        }
2383
2384        /**
2385         * The column to distinguish SMS and MMS messages in query results.
2386         */
2387        public static final String TYPE_DISCRIMINATOR_COLUMN =
2388                "transport_type";
2389
2390        /**
2391         * The {@code content://} style URL for this table.
2392         */
2393        public static final Uri CONTENT_URI = Uri.parse("content://mms-sms/");
2394
2395        /**
2396         * The {@code content://} style URL for this table, by conversation.
2397         */
2398        public static final Uri CONTENT_CONVERSATIONS_URI = Uri.parse(
2399                "content://mms-sms/conversations");
2400
2401        /**
2402         * The {@code content://} style URL for this table, by phone number.
2403         */
2404        public static final Uri CONTENT_FILTER_BYPHONE_URI = Uri.parse(
2405                "content://mms-sms/messages/byphone");
2406
2407        /**
2408         * The {@code content://} style URL for undelivered messages in this table.
2409         */
2410        public static final Uri CONTENT_UNDELIVERED_URI = Uri.parse(
2411                "content://mms-sms/undelivered");
2412
2413        /**
2414         * The {@code content://} style URL for draft messages in this table.
2415         */
2416        public static final Uri CONTENT_DRAFT_URI = Uri.parse(
2417                "content://mms-sms/draft");
2418
2419        /**
2420         * The {@code content://} style URL for locked messages in this table.
2421         */
2422        public static final Uri CONTENT_LOCKED_URI = Uri.parse(
2423                "content://mms-sms/locked");
2424
2425        /**
2426         * Pass in a query parameter called "pattern" which is the text to search for.
2427         * The sort order is fixed to be: {@code thread_id ASC, date DESC}.
2428         */
2429        public static final Uri SEARCH_URI = Uri.parse(
2430                "content://mms-sms/search");
2431
2432        // Constants for message protocol types.
2433
2434        /** SMS protocol type. */
2435        public static final int SMS_PROTO = 0;
2436
2437        /** MMS protocol type. */
2438        public static final int MMS_PROTO = 1;
2439
2440        // Constants for error types of pending messages.
2441
2442        /** Error type: no error. */
2443        public static final int NO_ERROR                      = 0;
2444
2445        /** Error type: generic transient error. */
2446        public static final int ERR_TYPE_GENERIC              = 1;
2447
2448        /** Error type: SMS protocol transient error. */
2449        public static final int ERR_TYPE_SMS_PROTO_TRANSIENT  = 2;
2450
2451        /** Error type: MMS protocol transient error. */
2452        public static final int ERR_TYPE_MMS_PROTO_TRANSIENT  = 3;
2453
2454        /** Error type: transport failure. */
2455        public static final int ERR_TYPE_TRANSPORT_FAILURE    = 4;
2456
2457        /** Error type: permanent error (along with all higher error values). */
2458        public static final int ERR_TYPE_GENERIC_PERMANENT    = 10;
2459
2460        /** Error type: SMS protocol permanent error. */
2461        public static final int ERR_TYPE_SMS_PROTO_PERMANENT  = 11;
2462
2463        /** Error type: MMS protocol permanent error. */
2464        public static final int ERR_TYPE_MMS_PROTO_PERMANENT  = 12;
2465
2466        /**
2467         * Contains pending messages info.
2468         */
2469        public static final class PendingMessages implements BaseColumns {
2470
2471            /**
2472             * Not instantiable.
2473             * @hide
2474             */
2475            private PendingMessages() {
2476            }
2477
2478            public static final Uri CONTENT_URI = Uri.withAppendedPath(
2479                    MmsSms.CONTENT_URI, "pending");
2480
2481            /**
2482             * The type of transport protocol (MMS or SMS).
2483             * <P>Type: INTEGER</P>
2484             */
2485            public static final String PROTO_TYPE = "proto_type";
2486
2487            /**
2488             * The ID of the message to be sent or downloaded.
2489             * <P>Type: INTEGER (long)</P>
2490             */
2491            public static final String MSG_ID = "msg_id";
2492
2493            /**
2494             * The type of the message to be sent or downloaded.
2495             * This field is only valid for MM. For SM, its value is always set to 0.
2496             * <P>Type: INTEGER</P>
2497             */
2498            public static final String MSG_TYPE = "msg_type";
2499
2500            /**
2501             * The type of the error code.
2502             * <P>Type: INTEGER</P>
2503             */
2504            public static final String ERROR_TYPE = "err_type";
2505
2506            /**
2507             * The error code of sending/retrieving process.
2508             * <P>Type: INTEGER</P>
2509             */
2510            public static final String ERROR_CODE = "err_code";
2511
2512            /**
2513             * How many times we tried to send or download the message.
2514             * <P>Type: INTEGER</P>
2515             */
2516            public static final String RETRY_INDEX = "retry_index";
2517
2518            /**
2519             * The time to do next retry.
2520             * <P>Type: INTEGER (long)</P>
2521             */
2522            public static final String DUE_TIME = "due_time";
2523
2524            /**
2525             * The time we last tried to send or download the message.
2526             * <P>Type: INTEGER (long)</P>
2527             */
2528            public static final String LAST_TRY = "last_try";
2529
2530            /**
2531             * The sub_id to which the message belongs to. Its value will be
2532             * {@link android.telephony.SubscriptionManager#INVALID_SUB_ID} if the sub id cannot be
2533             * determined.
2534             * <p>Type: INTEGER (long) </p>
2535             */
2536            public static final String SUB_ID = "pending_sub_id";
2537        }
2538
2539        /**
2540         * Words table used by provider for full-text searches.
2541         * @hide
2542         */
2543        public static final class WordsTable {
2544
2545            /**
2546             * Not instantiable.
2547             * @hide
2548             */
2549            private WordsTable() {}
2550
2551            /**
2552             * Primary key.
2553             * <P>Type: INTEGER (long)</P>
2554             */
2555            public static final String ID = "_id";
2556
2557            /**
2558             * Source row ID.
2559             * <P>Type: INTEGER (long)</P>
2560             */
2561            public static final String SOURCE_ROW_ID = "source_id";
2562
2563            /**
2564             * Table ID (either 1 or 2).
2565             * <P>Type: INTEGER</P>
2566             */
2567            public static final String TABLE_ID = "table_to_use";
2568
2569            /**
2570             * The words to index.
2571             * <P>Type: TEXT</P>
2572             */
2573            public static final String INDEXED_TEXT = "index_text";
2574        }
2575    }
2576
2577    /**
2578     * Carriers class contains information about APNs, including MMSC information.
2579     */
2580    public static final class Carriers implements BaseColumns {
2581
2582        /**
2583         * Not instantiable.
2584         * @hide
2585         */
2586        private Carriers() {}
2587
2588        /**
2589         * The {@code content://} style URL for this table.
2590         */
2591        public static final Uri CONTENT_URI = Uri.parse("content://telephony/carriers");
2592
2593        /**
2594         * The default sort order for this table.
2595         */
2596        public static final String DEFAULT_SORT_ORDER = "name ASC";
2597
2598        /**
2599         * Entry name.
2600         * <P>Type: TEXT</P>
2601         */
2602        public static final String NAME = "name";
2603
2604        /**
2605         * APN name.
2606         * <P>Type: TEXT</P>
2607         */
2608        public static final String APN = "apn";
2609
2610        /**
2611         * Proxy address.
2612         * <P>Type: TEXT</P>
2613         */
2614        public static final String PROXY = "proxy";
2615
2616        /**
2617         * Proxy port.
2618         * <P>Type: TEXT</P>
2619         */
2620        public static final String PORT = "port";
2621
2622        /**
2623         * MMS proxy address.
2624         * <P>Type: TEXT</P>
2625         */
2626        public static final String MMSPROXY = "mmsproxy";
2627
2628        /**
2629         * MMS proxy port.
2630         * <P>Type: TEXT</P>
2631         */
2632        public static final String MMSPORT = "mmsport";
2633
2634        /**
2635         * Server address.
2636         * <P>Type: TEXT</P>
2637         */
2638        public static final String SERVER = "server";
2639
2640        /**
2641         * APN username.
2642         * <P>Type: TEXT</P>
2643         */
2644        public static final String USER = "user";
2645
2646        /**
2647         * APN password.
2648         * <P>Type: TEXT</P>
2649         */
2650        public static final String PASSWORD = "password";
2651
2652        /**
2653         * MMSC URL.
2654         * <P>Type: TEXT</P>
2655         */
2656        public static final String MMSC = "mmsc";
2657
2658        /**
2659         * Mobile Country Code (MCC).
2660         * <P>Type: TEXT</P>
2661         */
2662        public static final String MCC = "mcc";
2663
2664        /**
2665         * Mobile Network Code (MNC).
2666         * <P>Type: TEXT</P>
2667         */
2668        public static final String MNC = "mnc";
2669
2670        /**
2671         * Numeric operator ID (as String). Usually {@code MCC + MNC}.
2672         * <P>Type: TEXT</P>
2673         */
2674        public static final String NUMERIC = "numeric";
2675
2676        /**
2677         * Authentication type.
2678         * <P>Type:  INTEGER</P>
2679         */
2680        public static final String AUTH_TYPE = "authtype";
2681
2682        /**
2683         * Comma-delimited list of APN types.
2684         * <P>Type: TEXT</P>
2685         */
2686        public static final String TYPE = "type";
2687
2688        /**
2689         * The protocol to use to connect to this APN.
2690         *
2691         * One of the {@code PDP_type} values in TS 27.007 section 10.1.1.
2692         * For example: {@code IP}, {@code IPV6}, {@code IPV4V6}, or {@code PPP}.
2693         * <P>Type: TEXT</P>
2694         */
2695        public static final String PROTOCOL = "protocol";
2696
2697        /**
2698         * The protocol to use to connect to this APN when roaming.
2699         * The syntax is the same as protocol.
2700         * <P>Type: TEXT</P>
2701         */
2702        public static final String ROAMING_PROTOCOL = "roaming_protocol";
2703
2704        /**
2705         * Is this the current APN?
2706         * <P>Type: INTEGER (boolean)</P>
2707         */
2708        public static final String CURRENT = "current";
2709
2710        /**
2711         * Is this APN enabled?
2712         * <P>Type: INTEGER (boolean)</P>
2713         */
2714        public static final String CARRIER_ENABLED = "carrier_enabled";
2715
2716        /**
2717         * Radio Access Technology info.
2718         * To check what values are allowed, refer to {@link android.telephony.ServiceState}.
2719         * This should be spread to other technologies,
2720         * but is currently only used for LTE (14) and eHRPD (13).
2721         * <P>Type: INTEGER</P>
2722         */
2723        public static final String BEARER = "bearer";
2724
2725        /**
2726         * MVNO type:
2727         * {@code SPN (Service Provider Name), IMSI, GID (Group Identifier Level 1)}.
2728         * <P>Type: TEXT</P>
2729         */
2730        public static final String MVNO_TYPE = "mvno_type";
2731
2732        /**
2733         * MVNO data.
2734         * Use the following examples.
2735         * <ul>
2736         *     <li>SPN: A MOBILE, BEN NL, ...</li>
2737         *     <li>IMSI: 302720x94, 2060188, ...</li>
2738         *     <li>GID: 4E, 33, ...</li>
2739         * </ul>
2740         * <P>Type: TEXT</P>
2741         */
2742        public static final String MVNO_MATCH_DATA = "mvno_match_data";
2743
2744        /**
2745         * The sub_id to which the APN belongs to
2746         * <p>Type: INTEGER (long) </p>
2747         */
2748        public static final String SUB_ID = "sub_id";
2749
2750        /**
2751         * The profile_id to which the APN saved in modem
2752         * <p>Type: INTEGER</p>
2753         *@hide
2754         */
2755        public static final String PROFILE_ID = "profile_id";
2756
2757        /**
2758         * Is the apn setting to be set in modem
2759         * <P>Type: INTEGER (boolean)</P>
2760         *@hide
2761         */
2762        public static final String MODEM_COGNITIVE = "modem_cognitive";
2763
2764        /**
2765         * The max connections of this apn
2766         * <p>Type: INTEGER</p>
2767         *@hide
2768         */
2769        public static final String MAX_CONNS = "max_conns";
2770
2771        /**
2772         * The wait time for retry of the apn
2773         * <p>Type: INTEGER</p>
2774         *@hide
2775         */
2776        public static final String WAIT_TIME = "wait_time";
2777
2778        /**
2779         * The time to limit max connection for the apn
2780         * <p>Type: INTEGER</p>
2781         *@hide
2782         */
2783        public static final String MAX_CONNS_TIME = "max_conns_time";
2784
2785        /**
2786         * The MTU size of the mobile interface to  which the APN connected
2787         * <p>Type: INTEGER </p>
2788         * @hide
2789         */
2790        public static final String MTU = "mtu";
2791    }
2792
2793    /**
2794     * Contains received SMS cell broadcast messages.
2795     * @hide
2796     */
2797    public static final class CellBroadcasts implements BaseColumns {
2798
2799        /**
2800         * Not instantiable.
2801         * @hide
2802         */
2803        private CellBroadcasts() {}
2804
2805        /**
2806         * The {@code content://} URI for this table.
2807         */
2808        public static final Uri CONTENT_URI = Uri.parse("content://cellbroadcasts");
2809
2810        /**
2811         * Message geographical scope.
2812         * <P>Type: INTEGER</P>
2813         */
2814        public static final String GEOGRAPHICAL_SCOPE = "geo_scope";
2815
2816        /**
2817         * Message serial number.
2818         * <P>Type: INTEGER</P>
2819         */
2820        public static final String SERIAL_NUMBER = "serial_number";
2821
2822        /**
2823         * PLMN of broadcast sender. {@code SERIAL_NUMBER + PLMN + LAC + CID} uniquely identifies
2824         * a broadcast for duplicate detection purposes.
2825         * <P>Type: TEXT</P>
2826         */
2827        public static final String PLMN = "plmn";
2828
2829        /**
2830         * Location Area (GSM) or Service Area (UMTS) of broadcast sender. Unused for CDMA.
2831         * Only included if Geographical Scope of message is not PLMN wide (01).
2832         * <P>Type: INTEGER</P>
2833         */
2834        public static final String LAC = "lac";
2835
2836        /**
2837         * Cell ID of message sender (GSM/UMTS). Unused for CDMA. Only included when the
2838         * Geographical Scope of message is cell wide (00 or 11).
2839         * <P>Type: INTEGER</P>
2840         */
2841        public static final String CID = "cid";
2842
2843        /**
2844         * Message code. <em>OBSOLETE: merged into SERIAL_NUMBER.</em>
2845         * <P>Type: INTEGER</P>
2846         */
2847        public static final String V1_MESSAGE_CODE = "message_code";
2848
2849        /**
2850         * Message identifier. <em>OBSOLETE: renamed to SERVICE_CATEGORY.</em>
2851         * <P>Type: INTEGER</P>
2852         */
2853        public static final String V1_MESSAGE_IDENTIFIER = "message_id";
2854
2855        /**
2856         * Service category (GSM/UMTS: message identifier; CDMA: service category).
2857         * <P>Type: INTEGER</P>
2858         */
2859        public static final String SERVICE_CATEGORY = "service_category";
2860
2861        /**
2862         * Message language code.
2863         * <P>Type: TEXT</P>
2864         */
2865        public static final String LANGUAGE_CODE = "language";
2866
2867        /**
2868         * Message body.
2869         * <P>Type: TEXT</P>
2870         */
2871        public static final String MESSAGE_BODY = "body";
2872
2873        /**
2874         * Message delivery time.
2875         * <P>Type: INTEGER (long)</P>
2876         */
2877        public static final String DELIVERY_TIME = "date";
2878
2879        /**
2880         * Has the message been viewed?
2881         * <P>Type: INTEGER (boolean)</P>
2882         */
2883        public static final String MESSAGE_READ = "read";
2884
2885        /**
2886         * Message format (3GPP or 3GPP2).
2887         * <P>Type: INTEGER</P>
2888         */
2889        public static final String MESSAGE_FORMAT = "format";
2890
2891        /**
2892         * Message priority (including emergency).
2893         * <P>Type: INTEGER</P>
2894         */
2895        public static final String MESSAGE_PRIORITY = "priority";
2896
2897        /**
2898         * ETWS warning type (ETWS alerts only).
2899         * <P>Type: INTEGER</P>
2900         */
2901        public static final String ETWS_WARNING_TYPE = "etws_warning_type";
2902
2903        /**
2904         * CMAS message class (CMAS alerts only).
2905         * <P>Type: INTEGER</P>
2906         */
2907        public static final String CMAS_MESSAGE_CLASS = "cmas_message_class";
2908
2909        /**
2910         * CMAS category (CMAS alerts only).
2911         * <P>Type: INTEGER</P>
2912         */
2913        public static final String CMAS_CATEGORY = "cmas_category";
2914
2915        /**
2916         * CMAS response type (CMAS alerts only).
2917         * <P>Type: INTEGER</P>
2918         */
2919        public static final String CMAS_RESPONSE_TYPE = "cmas_response_type";
2920
2921        /**
2922         * CMAS severity (CMAS alerts only).
2923         * <P>Type: INTEGER</P>
2924         */
2925        public static final String CMAS_SEVERITY = "cmas_severity";
2926
2927        /**
2928         * CMAS urgency (CMAS alerts only).
2929         * <P>Type: INTEGER</P>
2930         */
2931        public static final String CMAS_URGENCY = "cmas_urgency";
2932
2933        /**
2934         * CMAS certainty (CMAS alerts only).
2935         * <P>Type: INTEGER</P>
2936         */
2937        public static final String CMAS_CERTAINTY = "cmas_certainty";
2938
2939        /** The default sort order for this table. */
2940        public static final String DEFAULT_SORT_ORDER = DELIVERY_TIME + " DESC";
2941
2942        /**
2943         * Query columns for instantiating {@link android.telephony.CellBroadcastMessage} objects.
2944         */
2945        public static final String[] QUERY_COLUMNS = {
2946                _ID,
2947                GEOGRAPHICAL_SCOPE,
2948                PLMN,
2949                LAC,
2950                CID,
2951                SERIAL_NUMBER,
2952                SERVICE_CATEGORY,
2953                LANGUAGE_CODE,
2954                MESSAGE_BODY,
2955                DELIVERY_TIME,
2956                MESSAGE_READ,
2957                MESSAGE_FORMAT,
2958                MESSAGE_PRIORITY,
2959                ETWS_WARNING_TYPE,
2960                CMAS_MESSAGE_CLASS,
2961                CMAS_CATEGORY,
2962                CMAS_RESPONSE_TYPE,
2963                CMAS_SEVERITY,
2964                CMAS_URGENCY,
2965                CMAS_CERTAINTY
2966        };
2967    }
2968}
2969