blob: 954bb44e8532abdfcb2f686e5636112357539ab3 [file] [log] [blame]
Dan Willemsen4980bf42017-02-14 14:17:12 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.provider;
18
19import android.annotation.SdkConstant;
20import android.annotation.SdkConstant.SdkConstantType;
chen xu85100482018-10-12 15:30:34 -070021import android.annotation.SystemApi;
Dan Willemsen4980bf42017-02-14 14:17:12 -080022import android.annotation.TestApi;
Mathew Inwoodba503112018-08-10 09:37:35 +010023import android.annotation.UnsupportedAppUsage;
Jordan Liub9b75ed2017-02-28 18:15:07 -080024import android.app.job.JobService;
Dan Willemsen4980bf42017-02-14 14:17:12 -080025import android.content.ComponentName;
26import android.content.ContentResolver;
27import android.content.ContentValues;
28import android.content.Context;
29import android.content.Intent;
Jordan Liub9b75ed2017-02-28 18:15:07 -080030import android.database.ContentObserver;
Cassie6d0a5712018-08-21 13:38:39 -070031import android.database.Cursor;
Dan Willemsen4980bf42017-02-14 14:17:12 -080032import android.database.sqlite.SqliteWrapper;
33import android.net.Uri;
Jordan Liub9b75ed2017-02-28 18:15:07 -080034import android.telephony.Rlog;
35import android.telephony.ServiceState;
Dan Willemsen4980bf42017-02-14 14:17:12 -080036import android.telephony.SmsMessage;
37import android.telephony.SubscriptionManager;
fionaxu58278be2018-01-29 14:08:12 -080038import android.telephony.TelephonyManager;
Dan Willemsen4980bf42017-02-14 14:17:12 -080039import android.text.TextUtils;
Dan Willemsen4980bf42017-02-14 14:17:12 -080040import android.util.Patterns;
41
42import com.android.internal.telephony.PhoneConstants;
43import com.android.internal.telephony.SmsApplication;
44
Dan Willemsen4980bf42017-02-14 14:17:12 -080045import java.util.HashSet;
46import java.util.Set;
47import java.util.regex.Matcher;
48import java.util.regex.Pattern;
49
50/**
51 * The Telephony provider contains data related to phone operation, specifically SMS and MMS
Jordan Liub9b75ed2017-02-28 18:15:07 -080052 * messages, access to the APN list, including the MMSC to use, and the service state.
Dan Willemsen4980bf42017-02-14 14:17:12 -080053 *
54 * <p class="note"><strong>Note:</strong> These APIs are not available on all Android-powered
55 * devices. If your app depends on telephony features such as for managing SMS messages, include
56 * a <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code <uses-feature>}
57 * </a> element in your manifest that declares the {@code "android.hardware.telephony"} hardware
58 * feature. Alternatively, you can check for telephony availability at runtime using either
59 * {@link android.content.pm.PackageManager#hasSystemFeature
60 * hasSystemFeature(PackageManager.FEATURE_TELEPHONY)} or {@link
61 * android.telephony.TelephonyManager#getPhoneType}.</p>
62 *
63 * <h3>Creating an SMS app</h3>
64 *
65 * <p>Only the default SMS app (selected by the user in system settings) is able to write to the
66 * SMS Provider (the tables defined within the {@code Telephony} class) and only the default SMS
67 * app receives the {@link android.provider.Telephony.Sms.Intents#SMS_DELIVER_ACTION} broadcast
68 * when the user receives an SMS or the {@link
69 * android.provider.Telephony.Sms.Intents#WAP_PUSH_DELIVER_ACTION} broadcast when the user
70 * receives an MMS.</p>
71 *
72 * <p>Any app that wants to behave as the user's default SMS app must handle the following intents:
73 * <ul>
74 * <li>In a broadcast receiver, include an intent filter for {@link Sms.Intents#SMS_DELIVER_ACTION}
75 * (<code>"android.provider.Telephony.SMS_DELIVER"</code>). The broadcast receiver must also
76 * require the {@link android.Manifest.permission#BROADCAST_SMS} permission.
77 * <p>This allows your app to directly receive incoming SMS messages.</p></li>
78 * <li>In a broadcast receiver, include an intent filter for {@link
79 * Sms.Intents#WAP_PUSH_DELIVER_ACTION}} ({@code "android.provider.Telephony.WAP_PUSH_DELIVER"})
80 * with the MIME type <code>"application/vnd.wap.mms-message"</code>.
81 * The broadcast receiver must also require the {@link
82 * android.Manifest.permission#BROADCAST_WAP_PUSH} permission.
83 * <p>This allows your app to directly receive incoming MMS messages.</p></li>
84 * <li>In your activity that delivers new messages, include an intent filter for
85 * {@link android.content.Intent#ACTION_SENDTO} (<code>"android.intent.action.SENDTO"
86 * </code>) with schemas, <code>sms:</code>, <code>smsto:</code>, <code>mms:</code>, and
87 * <code>mmsto:</code>.
88 * <p>This allows your app to receive intents from other apps that want to deliver a
89 * message.</p></li>
90 * <li>In a service, include an intent filter for {@link
91 * android.telephony.TelephonyManager#ACTION_RESPOND_VIA_MESSAGE}
92 * (<code>"android.intent.action.RESPOND_VIA_MESSAGE"</code>) with schemas,
93 * <code>sms:</code>, <code>smsto:</code>, <code>mms:</code>, and <code>mmsto:</code>.
94 * This service must also require the {@link
95 * android.Manifest.permission#SEND_RESPOND_VIA_MESSAGE} permission.
96 * <p>This allows users to respond to incoming phone calls with an immediate text message
97 * using your app.</p></li>
98 * </ul>
99 *
100 * <p>Other apps that are not selected as the default SMS app can only <em>read</em> the SMS
101 * Provider, but may also be notified when a new SMS arrives by listening for the {@link
102 * Sms.Intents#SMS_RECEIVED_ACTION}
103 * broadcast, which is a non-abortable broadcast that may be delivered to multiple apps. This
104 * broadcast is intended for apps that&mdash;while not selected as the default SMS app&mdash;need to
105 * read special incoming messages such as to perform phone number verification.</p>
106 *
107 * <p>For more information about building SMS apps, read the blog post, <a
108 * href="http://android-developers.blogspot.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html"
109 * >Getting Your SMS Apps Ready for KitKat</a>.</p>
110 *
111 */
112public final class Telephony {
113 private static final String TAG = "Telephony";
114
115 /**
116 * Not instantiable.
117 * @hide
118 */
119 private Telephony() {
120 }
121
122 /**
123 * Base columns for tables that contain text-based SMSs.
124 */
125 public interface TextBasedSmsColumns {
126
127 /** Message type: all messages. */
128 public static final int MESSAGE_TYPE_ALL = 0;
129
130 /** Message type: inbox. */
131 public static final int MESSAGE_TYPE_INBOX = 1;
132
133 /** Message type: sent messages. */
134 public static final int MESSAGE_TYPE_SENT = 2;
135
136 /** Message type: drafts. */
137 public static final int MESSAGE_TYPE_DRAFT = 3;
138
139 /** Message type: outbox. */
140 public static final int MESSAGE_TYPE_OUTBOX = 4;
141
142 /** Message type: failed outgoing message. */
143 public static final int MESSAGE_TYPE_FAILED = 5;
144
145 /** Message type: queued to send later. */
146 public static final int MESSAGE_TYPE_QUEUED = 6;
147
148 /**
149 * The type of message.
150 * <P>Type: INTEGER</P>
151 */
152 public static final String TYPE = "type";
153
154 /**
155 * The thread ID of the message.
156 * <P>Type: INTEGER</P>
157 */
158 public static final String THREAD_ID = "thread_id";
159
160 /**
161 * The address of the other party.
162 * <P>Type: TEXT</P>
163 */
164 public static final String ADDRESS = "address";
165
166 /**
167 * The date the message was received.
168 * <P>Type: INTEGER (long)</P>
169 */
170 public static final String DATE = "date";
171
172 /**
173 * The date the message was sent.
174 * <P>Type: INTEGER (long)</P>
175 */
176 public static final String DATE_SENT = "date_sent";
177
178 /**
179 * Has the message been read?
180 * <P>Type: INTEGER (boolean)</P>
181 */
182 public static final String READ = "read";
183
184 /**
185 * Has the message been seen by the user? The "seen" flag determines
186 * whether we need to show a notification.
187 * <P>Type: INTEGER (boolean)</P>
188 */
189 public static final String SEEN = "seen";
190
191 /**
192 * {@code TP-Status} value for the message, or -1 if no status has been received.
193 * <P>Type: INTEGER</P>
194 */
195 public static final String STATUS = "status";
196
197 /** TP-Status: no status received. */
198 public static final int STATUS_NONE = -1;
199 /** TP-Status: complete. */
200 public static final int STATUS_COMPLETE = 0;
201 /** TP-Status: pending. */
202 public static final int STATUS_PENDING = 32;
203 /** TP-Status: failed. */
204 public static final int STATUS_FAILED = 64;
205
206 /**
207 * The subject of the message, if present.
208 * <P>Type: TEXT</P>
209 */
210 public static final String SUBJECT = "subject";
211
212 /**
213 * The body of the message.
214 * <P>Type: TEXT</P>
215 */
216 public static final String BODY = "body";
217
218 /**
219 * The ID of the sender of the conversation, if present.
220 * <P>Type: INTEGER (reference to item in {@code content://contacts/people})</P>
221 */
222 public static final String PERSON = "person";
223
224 /**
225 * The protocol identifier code.
226 * <P>Type: INTEGER</P>
227 */
228 public static final String PROTOCOL = "protocol";
229
230 /**
231 * Is the {@code TP-Reply-Path} flag set?
232 * <P>Type: BOOLEAN</P>
233 */
234 public static final String REPLY_PATH_PRESENT = "reply_path_present";
235
236 /**
237 * The service center (SC) through which to send the message, if present.
238 * <P>Type: TEXT</P>
239 */
240 public static final String SERVICE_CENTER = "service_center";
241
242 /**
243 * Is the message locked?
244 * <P>Type: INTEGER (boolean)</P>
245 */
246 public static final String LOCKED = "locked";
247
248 /**
249 * The subscription to which the message belongs to. Its value will be
250 * < 0 if the sub id cannot be determined.
251 * <p>Type: INTEGER (long) </p>
252 */
253 public static final String SUBSCRIPTION_ID = "sub_id";
254
255 /**
256 * The MTU size of the mobile interface to which the APN connected
257 * @hide
258 */
259 public static final String MTU = "mtu";
260
261 /**
262 * Error code associated with sending or receiving this message
263 * <P>Type: INTEGER</P>
264 */
265 public static final String ERROR_CODE = "error_code";
266
267 /**
268 * The identity of the sender of a sent message. It is
269 * usually the package name of the app which sends the message.
270 * <p class="note"><strong>Note:</strong>
271 * This column is read-only. It is set by the provider and can not be changed by apps.
272 * <p>Type: TEXT</p>
273 */
274 public static final String CREATOR = "creator";
275 }
276
277 /**
278 * Contains all text-based SMS messages.
279 */
280 public static final class Sms implements BaseColumns, TextBasedSmsColumns {
281
282 /**
283 * Not instantiable.
284 * @hide
285 */
286 private Sms() {
287 }
288
289 /**
290 * Used to determine the currently configured default SMS package.
291 * @param context context of the requesting application
292 * @return package name for the default SMS package or null
293 */
294 public static String getDefaultSmsPackage(Context context) {
295 ComponentName component = SmsApplication.getDefaultSmsApplication(context, false);
296 if (component != null) {
297 return component.getPackageName();
298 }
299 return null;
300 }
301
302 /**
303 * Return cursor for table query.
304 * @hide
305 */
306 public static Cursor query(ContentResolver cr, String[] projection) {
307 return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
308 }
309
310 /**
311 * Return cursor for table query.
312 * @hide
313 */
Mathew Inwoodba503112018-08-10 09:37:35 +0100314 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800315 public static Cursor query(ContentResolver cr, String[] projection,
316 String where, String orderBy) {
317 return cr.query(CONTENT_URI, projection, where,
318 null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
319 }
320
321 /**
322 * The {@code content://} style URL for this table.
323 */
324 public static final Uri CONTENT_URI = Uri.parse("content://sms");
325
326 /**
327 * The default sort order for this table.
328 */
329 public static final String DEFAULT_SORT_ORDER = "date DESC";
330
331 /**
332 * Add an SMS to the given URI.
333 *
334 * @param resolver the content resolver to use
335 * @param uri the URI to add the message to
336 * @param address the address of the sender
337 * @param body the body of the message
338 * @param subject the pseudo-subject of the message
339 * @param date the timestamp for the message
340 * @param read true if the message has been read, false if not
341 * @param deliveryReport true if a delivery report was requested, false if not
342 * @return the URI for the new message
343 * @hide
344 */
Mathew Inwoodba503112018-08-10 09:37:35 +0100345 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800346 public static Uri addMessageToUri(ContentResolver resolver,
347 Uri uri, String address, String body, String subject,
348 Long date, boolean read, boolean deliveryReport) {
349 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
350 resolver, uri, address, body, subject, date, read, deliveryReport, -1L);
351 }
352
353 /**
354 * Add an SMS to the given URI.
355 *
356 * @param resolver the content resolver to use
357 * @param uri the URI to add the message to
358 * @param address the address of the sender
359 * @param body the body of the message
360 * @param subject the psuedo-subject of the message
361 * @param date the timestamp for the message
362 * @param read true if the message has been read, false if not
363 * @param deliveryReport true if a delivery report was requested, false if not
364 * @param subId the subscription which the message belongs to
365 * @return the URI for the new message
366 * @hide
367 */
Mathew Inwoodba503112018-08-10 09:37:35 +0100368 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800369 public static Uri addMessageToUri(int subId, ContentResolver resolver,
370 Uri uri, String address, String body, String subject,
371 Long date, boolean read, boolean deliveryReport) {
372 return addMessageToUri(subId, resolver, uri, address, body, subject,
373 date, read, deliveryReport, -1L);
374 }
375
376 /**
377 * Add an SMS to the given URI with the specified thread ID.
378 *
379 * @param resolver the content resolver to use
380 * @param uri the URI to add the message to
381 * @param address the address of the sender
382 * @param body the body of the message
383 * @param subject the pseudo-subject of the message
384 * @param date the timestamp for the message
385 * @param read true if the message has been read, false if not
386 * @param deliveryReport true if a delivery report was requested, false if not
387 * @param threadId the thread_id of the message
388 * @return the URI for the new message
389 * @hide
390 */
Mathew Inwoodba503112018-08-10 09:37:35 +0100391 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800392 public static Uri addMessageToUri(ContentResolver resolver,
393 Uri uri, String address, String body, String subject,
394 Long date, boolean read, boolean deliveryReport, long threadId) {
395 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
396 resolver, uri, address, body, subject,
397 date, read, deliveryReport, threadId);
398 }
399
400 /**
401 * Add an SMS to the given URI with thread_id specified.
402 *
403 * @param resolver the content resolver to use
404 * @param uri the URI to add the message to
405 * @param address the address of the sender
406 * @param body the body of the message
407 * @param subject the psuedo-subject of the message
408 * @param date the timestamp for the message
409 * @param read true if the message has been read, false if not
410 * @param deliveryReport true if a delivery report was requested, false if not
411 * @param threadId the thread_id of the message
412 * @param subId the subscription which the message belongs to
413 * @return the URI for the new message
414 * @hide
415 */
Mathew Inwoodba503112018-08-10 09:37:35 +0100416 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800417 public static Uri addMessageToUri(int subId, ContentResolver resolver,
418 Uri uri, String address, String body, String subject,
419 Long date, boolean read, boolean deliveryReport, long threadId) {
420 ContentValues values = new ContentValues(8);
421 Rlog.v(TAG,"Telephony addMessageToUri sub id: " + subId);
422
423 values.put(SUBSCRIPTION_ID, subId);
424 values.put(ADDRESS, address);
425 if (date != null) {
426 values.put(DATE, date);
427 }
428 values.put(READ, read ? Integer.valueOf(1) : Integer.valueOf(0));
429 values.put(SUBJECT, subject);
430 values.put(BODY, body);
431 if (deliveryReport) {
432 values.put(STATUS, STATUS_PENDING);
433 }
434 if (threadId != -1L) {
435 values.put(THREAD_ID, threadId);
436 }
437 return resolver.insert(uri, values);
438 }
439
440 /**
441 * Move a message to the given folder.
442 *
443 * @param context the context to use
444 * @param uri the message to move
445 * @param folder the folder to move to
446 * @return true if the operation succeeded
447 * @hide
448 */
Mathew Inwoodba503112018-08-10 09:37:35 +0100449 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800450 public static boolean moveMessageToFolder(Context context,
451 Uri uri, int folder, int error) {
452 if (uri == null) {
453 return false;
454 }
455
456 boolean markAsUnread = false;
457 boolean markAsRead = false;
458 switch(folder) {
459 case MESSAGE_TYPE_INBOX:
460 case MESSAGE_TYPE_DRAFT:
461 break;
462 case MESSAGE_TYPE_OUTBOX:
463 case MESSAGE_TYPE_SENT:
464 markAsRead = true;
465 break;
466 case MESSAGE_TYPE_FAILED:
467 case MESSAGE_TYPE_QUEUED:
468 markAsUnread = true;
469 break;
470 default:
471 return false;
472 }
473
474 ContentValues values = new ContentValues(3);
475
476 values.put(TYPE, folder);
477 if (markAsUnread) {
478 values.put(READ, 0);
479 } else if (markAsRead) {
480 values.put(READ, 1);
481 }
482 values.put(ERROR_CODE, error);
483
484 return 1 == SqliteWrapper.update(context, context.getContentResolver(),
485 uri, values, null, null);
486 }
487
488 /**
489 * Returns true iff the folder (message type) identifies an
490 * outgoing message.
491 * @hide
492 */
Mathew Inwoodba503112018-08-10 09:37:35 +0100493 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800494 public static boolean isOutgoingFolder(int messageType) {
495 return (messageType == MESSAGE_TYPE_FAILED)
496 || (messageType == MESSAGE_TYPE_OUTBOX)
497 || (messageType == MESSAGE_TYPE_SENT)
498 || (messageType == MESSAGE_TYPE_QUEUED);
499 }
500
501 /**
502 * Contains all text-based SMS messages in the SMS app inbox.
503 */
504 public static final class Inbox implements BaseColumns, TextBasedSmsColumns {
505
506 /**
507 * Not instantiable.
508 * @hide
509 */
510 private Inbox() {
511 }
512
513 /**
514 * The {@code content://} style URL for this table.
515 */
516 public static final Uri CONTENT_URI = Uri.parse("content://sms/inbox");
517
518 /**
519 * The default sort order for this table.
520 */
521 public static final String DEFAULT_SORT_ORDER = "date DESC";
522
523 /**
524 * Add an SMS to the Draft box.
525 *
526 * @param resolver the content resolver to use
527 * @param address the address of the sender
528 * @param body the body of the message
529 * @param subject the pseudo-subject of the message
530 * @param date the timestamp for the message
531 * @param read true if the message has been read, false if not
532 * @return the URI for the new message
533 * @hide
534 */
Mathew Inwoodba503112018-08-10 09:37:35 +0100535 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800536 public static Uri addMessage(ContentResolver resolver,
537 String address, String body, String subject, Long date,
538 boolean read) {
539 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
540 resolver, CONTENT_URI, address, body, subject, date, read, false);
541 }
542
543 /**
544 * Add an SMS to the Draft box.
545 *
546 * @param resolver the content resolver to use
547 * @param address the address of the sender
548 * @param body the body of the message
549 * @param subject the psuedo-subject of the message
550 * @param date the timestamp for the message
551 * @param read true if the message has been read, false if not
552 * @param subId the subscription which the message belongs to
553 * @return the URI for the new message
554 * @hide
555 */
Mathew Inwoodba503112018-08-10 09:37:35 +0100556 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800557 public static Uri addMessage(int subId, ContentResolver resolver,
558 String address, String body, String subject, Long date, boolean read) {
559 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
560 subject, date, read, false);
561 }
562 }
563
564 /**
565 * Contains all sent text-based SMS messages in the SMS app.
566 */
567 public static final class Sent implements BaseColumns, TextBasedSmsColumns {
568
569 /**
570 * Not instantiable.
571 * @hide
572 */
573 private Sent() {
574 }
575
576 /**
577 * The {@code content://} style URL for this table.
578 */
579 public static final Uri CONTENT_URI = Uri.parse("content://sms/sent");
580
581 /**
582 * The default sort order for this table.
583 */
584 public static final String DEFAULT_SORT_ORDER = "date DESC";
585
586 /**
587 * Add an SMS to the Draft box.
588 *
589 * @param resolver the content resolver to use
590 * @param address the address of the sender
591 * @param body the body of the message
592 * @param subject the pseudo-subject of the message
593 * @param date the timestamp for the message
594 * @return the URI for the new message
595 * @hide
596 */
Mathew Inwoodba503112018-08-10 09:37:35 +0100597 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800598 public static Uri addMessage(ContentResolver resolver,
599 String address, String body, String subject, Long date) {
600 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
601 resolver, CONTENT_URI, address, body, subject, date, true, false);
602 }
603
604 /**
605 * Add an SMS to the Draft box.
606 *
607 * @param resolver the content resolver to use
608 * @param address the address of the sender
609 * @param body the body of the message
610 * @param subject the psuedo-subject of the message
611 * @param date the timestamp for the message
612 * @param subId the subscription which the message belongs to
613 * @return the URI for the new message
614 * @hide
615 */
Mathew Inwoodba503112018-08-10 09:37:35 +0100616 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800617 public static Uri addMessage(int subId, ContentResolver resolver,
618 String address, String body, String subject, Long date) {
619 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
620 subject, date, true, false);
621 }
622 }
623
624 /**
625 * Contains all sent text-based SMS messages in the SMS app.
626 */
627 public static final class Draft implements BaseColumns, TextBasedSmsColumns {
628
629 /**
630 * Not instantiable.
631 * @hide
632 */
633 private Draft() {
634 }
635
636 /**
637 * The {@code content://} style URL for this table.
638 */
639 public static final Uri CONTENT_URI = Uri.parse("content://sms/draft");
640
641 /**
642 * @hide
643 */
Mathew Inwoodba503112018-08-10 09:37:35 +0100644 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800645 public static Uri addMessage(ContentResolver resolver,
646 String address, String body, String subject, Long date) {
647 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
648 resolver, CONTENT_URI, address, body, subject, date, true, false);
649 }
650
651 /**
652 * Add an SMS to the Draft box.
653 *
654 * @param resolver the content resolver to use
655 * @param address the address of the sender
656 * @param body the body of the message
657 * @param subject the psuedo-subject of the message
658 * @param date the timestamp for the message
659 * @param subId the subscription which the message belongs to
660 * @return the URI for the new message
661 * @hide
662 */
Mathew Inwoodba503112018-08-10 09:37:35 +0100663 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800664 public static Uri addMessage(int subId, ContentResolver resolver,
665 String address, String body, String subject, Long date) {
666 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
667 subject, date, true, false);
668 }
669
670 /**
671 * The default sort order for this table.
672 */
673 public static final String DEFAULT_SORT_ORDER = "date DESC";
674 }
675
676 /**
677 * Contains all pending outgoing text-based SMS messages.
678 */
679 public static final class Outbox implements BaseColumns, TextBasedSmsColumns {
680
681 /**
682 * Not instantiable.
683 * @hide
684 */
685 private Outbox() {
686 }
687
688 /**
689 * The {@code content://} style URL for this table.
690 */
691 public static final Uri CONTENT_URI = Uri.parse("content://sms/outbox");
692
693 /**
694 * The default sort order for this table.
695 */
696 public static final String DEFAULT_SORT_ORDER = "date DESC";
697
698 /**
699 * Add an SMS to the outbox.
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 pseudo-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 * @return the URI for the new message
708 * @hide
709 */
Mathew Inwoodba503112018-08-10 09:37:35 +0100710 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800711 public static Uri addMessage(ContentResolver resolver,
712 String address, String body, String subject, Long date,
713 boolean deliveryReport, long threadId) {
714 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
715 resolver, CONTENT_URI, address, body, subject, date,
716 true, deliveryReport, threadId);
717 }
718
719 /**
720 * Add an SMS to the Out box.
721 *
722 * @param resolver the content resolver to use
723 * @param address the address of the sender
724 * @param body the body of the message
725 * @param subject the psuedo-subject of the message
726 * @param date the timestamp for the message
727 * @param deliveryReport whether a delivery report was requested for the message
728 * @param subId the subscription which the message belongs to
729 * @return the URI for the new message
730 * @hide
731 */
732 public static Uri addMessage(int subId, ContentResolver resolver,
733 String address, String body, String subject, Long date,
734 boolean deliveryReport, long threadId) {
735 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
736 subject, date, true, deliveryReport, threadId);
737 }
738 }
739
740 /**
741 * Contains all sent text-based SMS messages in the SMS app.
742 */
743 public static final class Conversations
744 implements BaseColumns, TextBasedSmsColumns {
745
746 /**
747 * Not instantiable.
748 * @hide
749 */
750 private Conversations() {
751 }
752
753 /**
754 * The {@code content://} style URL for this table.
755 */
756 public static final Uri CONTENT_URI = Uri.parse("content://sms/conversations");
757
758 /**
759 * The default sort order for this table.
760 */
761 public static final String DEFAULT_SORT_ORDER = "date DESC";
762
763 /**
764 * The first 45 characters of the body of the message.
765 * <P>Type: TEXT</P>
766 */
767 public static final String SNIPPET = "snippet";
768
769 /**
770 * The number of messages in the conversation.
771 * <P>Type: INTEGER</P>
772 */
773 public static final String MESSAGE_COUNT = "msg_count";
774 }
775
776 /**
777 * Contains constants for SMS related Intents that are broadcast.
778 */
779 public static final class Intents {
780
781 /**
782 * Not instantiable.
783 * @hide
784 */
785 private Intents() {
786 }
787
788 /**
789 * Set by BroadcastReceiver to indicate that the message was handled
790 * successfully.
791 */
792 public static final int RESULT_SMS_HANDLED = 1;
793
794 /**
795 * Set by BroadcastReceiver to indicate a generic error while
796 * processing the message.
797 */
798 public static final int RESULT_SMS_GENERIC_ERROR = 2;
799
800 /**
801 * Set by BroadcastReceiver to indicate insufficient memory to store
802 * the message.
803 */
804 public static final int RESULT_SMS_OUT_OF_MEMORY = 3;
805
806 /**
807 * Set by BroadcastReceiver to indicate that the message, while
808 * possibly valid, is of a format or encoding that is not
809 * supported.
810 */
811 public static final int RESULT_SMS_UNSUPPORTED = 4;
812
813 /**
814 * Set by BroadcastReceiver to indicate a duplicate incoming message.
815 */
816 public static final int RESULT_SMS_DUPLICATED = 5;
817
818 /**
819 * Activity action: Ask the user to change the default
820 * SMS application. This will show a dialog that asks the
821 * user whether they want to replace the current default
822 * SMS application with the one specified in
823 * {@link #EXTRA_PACKAGE_NAME}.
824 */
825 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
826 public static final String ACTION_CHANGE_DEFAULT =
827 "android.provider.Telephony.ACTION_CHANGE_DEFAULT";
828
829 /**
830 * The PackageName string passed in as an
831 * extra for {@link #ACTION_CHANGE_DEFAULT}
832 *
833 * @see #ACTION_CHANGE_DEFAULT
834 */
835 public static final String EXTRA_PACKAGE_NAME = "package";
836
837 /**
838 * Broadcast Action: A new text-based SMS message has been received
839 * by the device. This intent will only be delivered to the default
840 * sms app. That app is responsible for writing the message and notifying
841 * the user. The intent will have the following extra values:</p>
842 *
843 * <ul>
844 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
845 * that make up the message.</li>
846 * <li><em>"format"</em> - A String describing the format of the PDUs. It can
847 * be either "3gpp" or "3gpp2".</li>
848 * <li><em>"subscription"</em> - An optional long value of the subscription id which
849 * received the message.</li>
850 * <li><em>"slot"</em> - An optional int value of the SIM slot containing the
851 * subscription.</li>
852 * <li><em>"phone"</em> - An optional int value of the phone id associated with the
853 * subscription.</li>
854 * <li><em>"errorCode"</em> - An optional int error code associated with receiving
855 * the message.</li>
856 * </ul>
857 *
858 * <p>The extra values can be extracted using
859 * {@link #getMessagesFromIntent(Intent)}.</p>
860 *
861 * <p>If a BroadcastReceiver encounters an error while processing
862 * this intent it should set the result code appropriately.</p>
863 *
864 * <p class="note"><strong>Note:</strong>
865 * The broadcast receiver that filters for this intent must declare
866 * {@link android.Manifest.permission#BROADCAST_SMS} as a required permission in
867 * the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code
868 * <receiver>}</a> tag.
869 *
870 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
871 */
872 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
873 public static final String SMS_DELIVER_ACTION =
874 "android.provider.Telephony.SMS_DELIVER";
875
876 /**
877 * Broadcast Action: A new text-based SMS message has been received
878 * by the device. This intent will be delivered to all registered
879 * receivers as a notification. These apps are not expected to write the
880 * message or notify the user. The intent will have the following extra
881 * values:</p>
882 *
883 * <ul>
884 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
885 * that make up the message.</li>
886 * </ul>
887 *
888 * <p>The extra values can be extracted using
889 * {@link #getMessagesFromIntent(Intent)}.</p>
890 *
891 * <p>If a BroadcastReceiver encounters an error while processing
892 * this intent it should set the result code appropriately.</p>
893 *
894 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
895 */
896 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
897 public static final String SMS_RECEIVED_ACTION =
898 "android.provider.Telephony.SMS_RECEIVED";
899
900 /**
901 * Broadcast Action: A new data based SMS message has been received
902 * by the device. This intent will be delivered to all registered
903 * receivers as a notification. The intent will have the following extra
904 * values:</p>
905 *
906 * <ul>
907 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
908 * that make up the message.</li>
909 * </ul>
910 *
911 * <p>The extra values can be extracted using
912 * {@link #getMessagesFromIntent(Intent)}.</p>
913 *
914 * <p>If a BroadcastReceiver encounters an error while processing
915 * this intent it should set the result code appropriately.</p>
916 *
917 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
918 */
919 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
920 public static final String DATA_SMS_RECEIVED_ACTION =
921 "android.intent.action.DATA_SMS_RECEIVED";
922
923 /**
924 * Broadcast Action: A new WAP PUSH message has been received by the
925 * device. This intent will only be delivered to the default
926 * sms app. That app is responsible for writing the message and notifying
927 * the user. The intent will have the following extra values:</p>
928 *
929 * <ul>
930 * <li><em>"transactionId"</em> - (Integer) The WAP transaction ID</li>
931 * <li><em>"pduType"</em> - (Integer) The WAP PDU type</li>
932 * <li><em>"header"</em> - (byte[]) The header of the message</li>
933 * <li><em>"data"</em> - (byte[]) The data payload of the message</li>
934 * <li><em>"contentTypeParameters" </em>
935 * -(HashMap&lt;String,String&gt;) Any parameters associated with the content type
936 * (decoded from the WSP Content-Type header)</li>
937 * <li><em>"subscription"</em> - An optional long value of the subscription id which
938 * received the message.</li>
939 * <li><em>"slot"</em> - An optional int value of the SIM slot containing the
940 * subscription.</li>
941 * <li><em>"phone"</em> - An optional int value of the phone id associated with the
942 * subscription.</li>
943 * </ul>
944 *
945 * <p>If a BroadcastReceiver encounters an error while processing
946 * this intent it should set the result code appropriately.</p>
947 *
948 * <p>The contentTypeParameters extra value is map of content parameters keyed by
949 * their names.</p>
950 *
951 * <p>If any unassigned well-known parameters are encountered, the key of the map will
952 * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter. If
953 * a parameter has No-Value the value in the map will be null.</p>
954 *
955 * <p>Requires {@link android.Manifest.permission#RECEIVE_MMS} or
956 * {@link android.Manifest.permission#RECEIVE_WAP_PUSH} (depending on WAP PUSH type) to
957 * receive.</p>
958 *
959 * <p class="note"><strong>Note:</strong>
960 * The broadcast receiver that filters for this intent must declare
961 * {@link android.Manifest.permission#BROADCAST_WAP_PUSH} as a required permission in
962 * the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code
963 * <receiver>}</a> tag.
964 */
965 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
966 public static final String WAP_PUSH_DELIVER_ACTION =
967 "android.provider.Telephony.WAP_PUSH_DELIVER";
968
969 /**
970 * Broadcast Action: A new WAP PUSH message has been received by the
971 * device. This intent will be delivered to all registered
972 * receivers as a notification. These apps are not expected to write the
973 * message or notify the user. The intent will have the following extra
974 * values:</p>
975 *
976 * <ul>
977 * <li><em>"transactionId"</em> - (Integer) The WAP transaction ID</li>
978 * <li><em>"pduType"</em> - (Integer) The WAP PDU type</li>
979 * <li><em>"header"</em> - (byte[]) The header of the message</li>
980 * <li><em>"data"</em> - (byte[]) The data payload of the message</li>
981 * <li><em>"contentTypeParameters"</em>
982 * - (HashMap&lt;String,String&gt;) Any parameters associated with the content type
983 * (decoded from the WSP Content-Type header)</li>
984 * </ul>
985 *
986 * <p>If a BroadcastReceiver encounters an error while processing
987 * this intent it should set the result code appropriately.</p>
988 *
989 * <p>The contentTypeParameters extra value is map of content parameters keyed by
990 * their names.</p>
991 *
992 * <p>If any unassigned well-known parameters are encountered, the key of the map will
993 * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter. If
994 * a parameter has No-Value the value in the map will be null.</p>
995 *
996 * <p>Requires {@link android.Manifest.permission#RECEIVE_MMS} or
997 * {@link android.Manifest.permission#RECEIVE_WAP_PUSH} (depending on WAP PUSH type) to
998 * receive.</p>
999 */
1000 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1001 public static final String WAP_PUSH_RECEIVED_ACTION =
1002 "android.provider.Telephony.WAP_PUSH_RECEIVED";
1003
1004 /**
1005 * Broadcast Action: A new Cell Broadcast message has been received
1006 * by the device. The intent will have the following extra
1007 * values:</p>
1008 *
1009 * <ul>
1010 * <li><em>"message"</em> - An SmsCbMessage object containing the broadcast message
1011 * data. This is not an emergency alert, so ETWS and CMAS data will be null.</li>
1012 * </ul>
1013 *
1014 * <p>The extra values can be extracted using
1015 * {@link #getMessagesFromIntent(Intent)}.</p>
1016 *
1017 * <p>If a BroadcastReceiver encounters an error while processing
1018 * this intent it should set the result code appropriately.</p>
1019 *
1020 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1021 */
1022 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1023 public static final String SMS_CB_RECEIVED_ACTION =
1024 "android.provider.Telephony.SMS_CB_RECEIVED";
1025
1026 /**
1027 * Action: A SMS based carrier provision intent. Used to identify default
1028 * carrier provisioning app on the device.
1029 * @hide
1030 */
1031 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1032 @TestApi
1033 public static final String SMS_CARRIER_PROVISION_ACTION =
1034 "android.provider.Telephony.SMS_CARRIER_PROVISION";
1035
1036 /**
1037 * Broadcast Action: A new Emergency Broadcast message has been received
1038 * by the device. The intent will have the following extra
1039 * values:</p>
1040 *
1041 * <ul>
1042 * <li><em>"message"</em> - An SmsCbMessage object containing the broadcast message
1043 * data, including ETWS or CMAS warning notification info if present.</li>
1044 * </ul>
1045 *
1046 * <p>The extra values can be extracted using
1047 * {@link #getMessagesFromIntent(Intent)}.</p>
1048 *
1049 * <p>If a BroadcastReceiver encounters an error while processing
1050 * this intent it should set the result code appropriately.</p>
1051 *
1052 * <p>Requires {@link android.Manifest.permission#RECEIVE_EMERGENCY_BROADCAST} to
1053 * receive.</p>
1054 * @removed
1055 */
1056 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1057 public static final String SMS_EMERGENCY_CB_RECEIVED_ACTION =
1058 "android.provider.Telephony.SMS_EMERGENCY_CB_RECEIVED";
1059
1060 /**
1061 * Broadcast Action: A new CDMA SMS has been received containing Service Category
1062 * Program Data (updates the list of enabled broadcast channels). The intent will
1063 * have the following extra values:</p>
1064 *
1065 * <ul>
1066 * <li><em>"operations"</em> - An array of CdmaSmsCbProgramData objects containing
1067 * the service category operations (add/delete/clear) to perform.</li>
1068 * </ul>
1069 *
1070 * <p>The extra values can be extracted using
1071 * {@link #getMessagesFromIntent(Intent)}.</p>
1072 *
1073 * <p>If a BroadcastReceiver encounters an error while processing
1074 * this intent it should set the result code appropriately.</p>
1075 *
1076 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1077 */
1078 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1079 public static final String SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION =
1080 "android.provider.Telephony.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED";
1081
1082 /**
1083 * Broadcast Action: The SIM storage for SMS messages is full. If
1084 * space is not freed, messages targeted for the SIM (class 2) may
1085 * not be saved.
1086 *
1087 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1088 */
1089 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1090 public static final String SIM_FULL_ACTION =
1091 "android.provider.Telephony.SIM_FULL";
1092
1093 /**
1094 * Broadcast Action: An incoming SMS has been rejected by the
1095 * telephony framework. This intent is sent in lieu of any
1096 * of the RECEIVED_ACTION intents. The intent will have the
1097 * following extra value:</p>
1098 *
1099 * <ul>
1100 * <li><em>"result"</em> - An int result code, e.g. {@link #RESULT_SMS_OUT_OF_MEMORY}
1101 * indicating the error returned to the network.</li>
1102 * </ul>
1103 *
1104 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1105 */
1106 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1107 public static final String SMS_REJECTED_ACTION =
1108 "android.provider.Telephony.SMS_REJECTED";
1109
1110 /**
1111 * Broadcast Action: An incoming MMS has been downloaded. The intent is sent to all
1112 * users, except for secondary users where SMS has been disabled and to managed
1113 * profiles.
1114 * @hide
1115 */
1116 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1117 public static final String MMS_DOWNLOADED_ACTION =
1118 "android.provider.Telephony.MMS_DOWNLOADED";
1119
1120 /**
Cassie5b97cf12018-02-22 09:58:33 -08001121 * Broadcast Action: A debug code has been entered in the dialer. This intent is
1122 * broadcast by the system and OEM telephony apps may need to receive these broadcasts.
1123 * These "secret codes" are used to activate developer menus by dialing certain codes.
1124 * And they are of the form {@code *#*#&lt;code&gt;#*#*}. The intent will have the data
1125 * URI: {@code android_secret_code://&lt;code&gt;}. It is possible that a manifest
1126 * receiver would be woken up even if it is not currently running.
1127 *
1128 * <p>Requires {@code android.Manifest.permission#CONTROL_INCALL_EXPERIENCE} to
1129 * send and receive.</p>
Cassie6d0a5712018-08-21 13:38:39 -07001130 * @deprecated it is no longer supported, use {@link
1131 * TelephonyManager#ACTION_SECRET_CODE} instead
Cassie866f4942018-01-19 17:23:36 -08001132 */
Cassie6d0a5712018-08-21 13:38:39 -07001133 @Deprecated
Cassie866f4942018-01-19 17:23:36 -08001134 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1135 public static final String SECRET_CODE_ACTION =
1136 "android.provider.Telephony.SECRET_CODE";
1137
1138 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08001139 * Broadcast action: When the default SMS package changes,
1140 * the previous default SMS package and the new default SMS
1141 * package are sent this broadcast to notify them of the change.
1142 * A boolean is specified in {@link #EXTRA_IS_DEFAULT_SMS_APP} to
1143 * indicate whether the package is the new default SMS package.
1144 */
1145 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1146 public static final String ACTION_DEFAULT_SMS_PACKAGE_CHANGED =
1147 "android.provider.action.DEFAULT_SMS_PACKAGE_CHANGED";
1148
1149 /**
1150 * The IsDefaultSmsApp boolean passed as an
1151 * extra for {@link #ACTION_DEFAULT_SMS_PACKAGE_CHANGED} to indicate whether the
1152 * SMS app is becoming the default SMS app or is no longer the default.
1153 *
1154 * @see #ACTION_DEFAULT_SMS_PACKAGE_CHANGED
1155 */
1156 public static final String EXTRA_IS_DEFAULT_SMS_APP =
1157 "android.provider.extra.IS_DEFAULT_SMS_APP";
1158
1159 /**
1160 * Broadcast action: When a change is made to the SmsProvider or
1161 * MmsProvider by a process other than the default SMS application,
1162 * this intent is broadcast to the default SMS application so it can
1163 * re-sync or update the change. The uri that was used to call the provider
1164 * can be retrieved from the intent with getData(). The actual affected uris
1165 * (which would depend on the selection specified) are not included.
1166 */
1167 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1168 public static final String ACTION_EXTERNAL_PROVIDER_CHANGE =
1169 "android.provider.action.EXTERNAL_PROVIDER_CHANGE";
1170
1171 /**
1172 * Read the PDUs out of an {@link #SMS_RECEIVED_ACTION} or a
1173 * {@link #DATA_SMS_RECEIVED_ACTION} intent.
1174 *
1175 * @param intent the intent to read from
1176 * @return an array of SmsMessages for the PDUs
1177 */
1178 public static SmsMessage[] getMessagesFromIntent(Intent intent) {
1179 Object[] messages;
1180 try {
1181 messages = (Object[]) intent.getSerializableExtra("pdus");
1182 }
1183 catch (ClassCastException e) {
1184 Rlog.e(TAG, "getMessagesFromIntent: " + e);
1185 return null;
1186 }
1187
1188 if (messages == null) {
1189 Rlog.e(TAG, "pdus does not exist in the intent");
1190 return null;
1191 }
1192
1193 String format = intent.getStringExtra("format");
1194 int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
1195 SubscriptionManager.getDefaultSmsSubscriptionId());
1196
1197 Rlog.v(TAG, " getMessagesFromIntent sub_id : " + subId);
1198
1199 int pduCount = messages.length;
1200 SmsMessage[] msgs = new SmsMessage[pduCount];
1201
1202 for (int i = 0; i < pduCount; i++) {
1203 byte[] pdu = (byte[]) messages[i];
1204 msgs[i] = SmsMessage.createFromPdu(pdu, format);
1205 if (msgs[i] != null) msgs[i].setSubId(subId);
1206 }
1207 return msgs;
1208 }
1209 }
1210 }
1211
1212 /**
pkanwar16b8a0d2017-06-07 10:59:41 -07001213 * Base column for the table that contain Carrier Public key.
1214 * @hide
1215 */
1216 public interface CarrierColumns extends BaseColumns {
1217
1218 public static final String MCC = "mcc";
1219 public static final String MNC = "mnc";
1220 public static final String KEY_TYPE = "key_type";
1221 public static final String MVNO_TYPE = "mvno_type";
1222 public static final String MVNO_MATCH_DATA = "mvno_match_data";
1223 public static final String PUBLIC_KEY = "public_key";
1224 public static final String KEY_IDENTIFIER = "key_identifier";
1225 public static final String EXPIRATION_TIME = "expiration_time";
1226 public static final String LAST_MODIFIED = "last_modified";
1227
1228 /**
1229 * The {@code content://} style URL for this table.
1230 * @hide
1231 */
1232 public static final Uri CONTENT_URI = Uri.parse("content://carrier_information/carrier");
1233 }
1234
1235 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08001236 * Base columns for tables that contain MMSs.
1237 */
1238 public interface BaseMmsColumns extends BaseColumns {
1239
1240 /** Message box: all messages. */
1241 public static final int MESSAGE_BOX_ALL = 0;
1242 /** Message box: inbox. */
1243 public static final int MESSAGE_BOX_INBOX = 1;
1244 /** Message box: sent messages. */
1245 public static final int MESSAGE_BOX_SENT = 2;
1246 /** Message box: drafts. */
1247 public static final int MESSAGE_BOX_DRAFTS = 3;
1248 /** Message box: outbox. */
1249 public static final int MESSAGE_BOX_OUTBOX = 4;
1250 /** Message box: failed. */
1251 public static final int MESSAGE_BOX_FAILED = 5;
1252
1253 /**
1254 * The thread ID of the message.
1255 * <P>Type: INTEGER (long)</P>
1256 */
1257 public static final String THREAD_ID = "thread_id";
1258
1259 /**
1260 * The date the message was received.
1261 * <P>Type: INTEGER (long)</P>
1262 */
1263 public static final String DATE = "date";
1264
1265 /**
1266 * The date the message was sent.
1267 * <P>Type: INTEGER (long)</P>
1268 */
1269 public static final String DATE_SENT = "date_sent";
1270
1271 /**
1272 * The box which the message belongs to, e.g. {@link #MESSAGE_BOX_INBOX}.
1273 * <P>Type: INTEGER</P>
1274 */
1275 public static final String MESSAGE_BOX = "msg_box";
1276
1277 /**
1278 * Has the message been read?
1279 * <P>Type: INTEGER (boolean)</P>
1280 */
1281 public static final String READ = "read";
1282
1283 /**
1284 * Has the message been seen by the user? The "seen" flag determines
1285 * whether we need to show a new message notification.
1286 * <P>Type: INTEGER (boolean)</P>
1287 */
1288 public static final String SEEN = "seen";
1289
1290 /**
1291 * Does the message have only a text part (can also have a subject) with
1292 * no picture, slideshow, sound, etc. parts?
1293 * <P>Type: INTEGER (boolean)</P>
1294 */
1295 public static final String TEXT_ONLY = "text_only";
1296
1297 /**
1298 * The {@code Message-ID} of the message.
1299 * <P>Type: TEXT</P>
1300 */
1301 public static final String MESSAGE_ID = "m_id";
1302
1303 /**
1304 * The subject of the message, if present.
1305 * <P>Type: TEXT</P>
1306 */
1307 public static final String SUBJECT = "sub";
1308
1309 /**
1310 * The character set of the subject, if present.
1311 * <P>Type: INTEGER</P>
1312 */
1313 public static final String SUBJECT_CHARSET = "sub_cs";
1314
1315 /**
1316 * The {@code Content-Type} of the message.
1317 * <P>Type: TEXT</P>
1318 */
1319 public static final String CONTENT_TYPE = "ct_t";
1320
1321 /**
1322 * The {@code Content-Location} of the message.
1323 * <P>Type: TEXT</P>
1324 */
1325 public static final String CONTENT_LOCATION = "ct_l";
1326
1327 /**
1328 * The expiry time of the message.
1329 * <P>Type: INTEGER (long)</P>
1330 */
1331 public static final String EXPIRY = "exp";
1332
1333 /**
1334 * The class of the message.
1335 * <P>Type: TEXT</P>
1336 */
1337 public static final String MESSAGE_CLASS = "m_cls";
1338
1339 /**
1340 * The type of the message defined by MMS spec.
1341 * <P>Type: INTEGER</P>
1342 */
1343 public static final String MESSAGE_TYPE = "m_type";
1344
1345 /**
1346 * The version of the specification that this message conforms to.
1347 * <P>Type: INTEGER</P>
1348 */
1349 public static final String MMS_VERSION = "v";
1350
1351 /**
1352 * The size of the message.
1353 * <P>Type: INTEGER</P>
1354 */
1355 public static final String MESSAGE_SIZE = "m_size";
1356
1357 /**
1358 * The priority of the message.
1359 * <P>Type: INTEGER</P>
1360 */
1361 public static final String PRIORITY = "pri";
1362
1363 /**
1364 * The {@code read-report} of the message.
1365 * <P>Type: INTEGER (boolean)</P>
1366 */
1367 public static final String READ_REPORT = "rr";
1368
1369 /**
1370 * Is read report allowed?
1371 * <P>Type: INTEGER (boolean)</P>
1372 */
1373 public static final String REPORT_ALLOWED = "rpt_a";
1374
1375 /**
1376 * The {@code response-status} of the message.
1377 * <P>Type: INTEGER</P>
1378 */
1379 public static final String RESPONSE_STATUS = "resp_st";
1380
1381 /**
1382 * The {@code status} of the message.
1383 * <P>Type: INTEGER</P>
1384 */
1385 public static final String STATUS = "st";
1386
1387 /**
1388 * The {@code transaction-id} of the message.
1389 * <P>Type: TEXT</P>
1390 */
1391 public static final String TRANSACTION_ID = "tr_id";
1392
1393 /**
1394 * The {@code retrieve-status} of the message.
1395 * <P>Type: INTEGER</P>
1396 */
1397 public static final String RETRIEVE_STATUS = "retr_st";
1398
1399 /**
1400 * The {@code retrieve-text} of the message.
1401 * <P>Type: TEXT</P>
1402 */
1403 public static final String RETRIEVE_TEXT = "retr_txt";
1404
1405 /**
1406 * The character set of the retrieve-text.
1407 * <P>Type: INTEGER</P>
1408 */
1409 public static final String RETRIEVE_TEXT_CHARSET = "retr_txt_cs";
1410
1411 /**
1412 * The {@code read-status} of the message.
1413 * <P>Type: INTEGER</P>
1414 */
1415 public static final String READ_STATUS = "read_status";
1416
1417 /**
1418 * The {@code content-class} of the message.
1419 * <P>Type: INTEGER</P>
1420 */
1421 public static final String CONTENT_CLASS = "ct_cls";
1422
1423 /**
1424 * The {@code delivery-report} of the message.
1425 * <P>Type: INTEGER</P>
1426 */
1427 public static final String DELIVERY_REPORT = "d_rpt";
1428
1429 /**
1430 * The {@code delivery-time-token} of the message.
1431 * <P>Type: INTEGER</P>
1432 * @deprecated this column is no longer supported.
1433 * @hide
1434 */
1435 @Deprecated
1436 public static final String DELIVERY_TIME_TOKEN = "d_tm_tok";
1437
1438 /**
1439 * The {@code delivery-time} of the message.
1440 * <P>Type: INTEGER</P>
1441 */
1442 public static final String DELIVERY_TIME = "d_tm";
1443
1444 /**
1445 * The {@code response-text} of the message.
1446 * <P>Type: TEXT</P>
1447 */
1448 public static final String RESPONSE_TEXT = "resp_txt";
1449
1450 /**
1451 * The {@code sender-visibility} of the message.
1452 * <P>Type: TEXT</P>
1453 * @deprecated this column is no longer supported.
1454 * @hide
1455 */
1456 @Deprecated
1457 public static final String SENDER_VISIBILITY = "s_vis";
1458
1459 /**
1460 * The {@code reply-charging} of the message.
1461 * <P>Type: INTEGER</P>
1462 * @deprecated this column is no longer supported.
1463 * @hide
1464 */
1465 @Deprecated
1466 public static final String REPLY_CHARGING = "r_chg";
1467
1468 /**
1469 * The {@code reply-charging-deadline-token} of the message.
1470 * <P>Type: INTEGER</P>
1471 * @deprecated this column is no longer supported.
1472 * @hide
1473 */
1474 @Deprecated
1475 public static final String REPLY_CHARGING_DEADLINE_TOKEN = "r_chg_dl_tok";
1476
1477 /**
1478 * The {@code reply-charging-deadline} of the message.
1479 * <P>Type: INTEGER</P>
1480 * @deprecated this column is no longer supported.
1481 * @hide
1482 */
1483 @Deprecated
1484 public static final String REPLY_CHARGING_DEADLINE = "r_chg_dl";
1485
1486 /**
1487 * The {@code reply-charging-id} of the message.
1488 * <P>Type: TEXT</P>
1489 * @deprecated this column is no longer supported.
1490 * @hide
1491 */
1492 @Deprecated
1493 public static final String REPLY_CHARGING_ID = "r_chg_id";
1494
1495 /**
1496 * The {@code reply-charging-size} of the message.
1497 * <P>Type: INTEGER</P>
1498 * @deprecated this column is no longer supported.
1499 * @hide
1500 */
1501 @Deprecated
1502 public static final String REPLY_CHARGING_SIZE = "r_chg_sz";
1503
1504 /**
1505 * The {@code previously-sent-by} of the message.
1506 * <P>Type: TEXT</P>
1507 * @deprecated this column is no longer supported.
1508 * @hide
1509 */
1510 @Deprecated
1511 public static final String PREVIOUSLY_SENT_BY = "p_s_by";
1512
1513 /**
1514 * The {@code previously-sent-date} of the message.
1515 * <P>Type: INTEGER</P>
1516 * @deprecated this column is no longer supported.
1517 * @hide
1518 */
1519 @Deprecated
1520 public static final String PREVIOUSLY_SENT_DATE = "p_s_d";
1521
1522 /**
1523 * The {@code store} of the message.
1524 * <P>Type: TEXT</P>
1525 * @deprecated this column is no longer supported.
1526 * @hide
1527 */
1528 @Deprecated
1529 public static final String STORE = "store";
1530
1531 /**
1532 * The {@code mm-state} of the message.
1533 * <P>Type: INTEGER</P>
1534 * @deprecated this column is no longer supported.
1535 * @hide
1536 */
1537 @Deprecated
1538 public static final String MM_STATE = "mm_st";
1539
1540 /**
1541 * The {@code mm-flags-token} of the message.
1542 * <P>Type: INTEGER</P>
1543 * @deprecated this column is no longer supported.
1544 * @hide
1545 */
1546 @Deprecated
1547 public static final String MM_FLAGS_TOKEN = "mm_flg_tok";
1548
1549 /**
1550 * The {@code mm-flags} of the message.
1551 * <P>Type: TEXT</P>
1552 * @deprecated this column is no longer supported.
1553 * @hide
1554 */
1555 @Deprecated
1556 public static final String MM_FLAGS = "mm_flg";
1557
1558 /**
1559 * The {@code store-status} of the message.
1560 * <P>Type: TEXT</P>
1561 * @deprecated this column is no longer supported.
1562 * @hide
1563 */
1564 @Deprecated
1565 public static final String STORE_STATUS = "store_st";
1566
1567 /**
1568 * The {@code store-status-text} of the message.
1569 * <P>Type: TEXT</P>
1570 * @deprecated this column is no longer supported.
1571 * @hide
1572 */
1573 @Deprecated
1574 public static final String STORE_STATUS_TEXT = "store_st_txt";
1575
1576 /**
1577 * The {@code stored} of the message.
1578 * <P>Type: TEXT</P>
1579 * @deprecated this column is no longer supported.
1580 * @hide
1581 */
1582 @Deprecated
1583 public static final String STORED = "stored";
1584
1585 /**
1586 * The {@code totals} of the message.
1587 * <P>Type: TEXT</P>
1588 * @deprecated this column is no longer supported.
1589 * @hide
1590 */
1591 @Deprecated
1592 public static final String TOTALS = "totals";
1593
1594 /**
1595 * The {@code mbox-totals} of the message.
1596 * <P>Type: TEXT</P>
1597 * @deprecated this column is no longer supported.
1598 * @hide
1599 */
1600 @Deprecated
1601 public static final String MBOX_TOTALS = "mb_t";
1602
1603 /**
1604 * The {@code mbox-totals-token} of the message.
1605 * <P>Type: INTEGER</P>
1606 * @deprecated this column is no longer supported.
1607 * @hide
1608 */
1609 @Deprecated
1610 public static final String MBOX_TOTALS_TOKEN = "mb_t_tok";
1611
1612 /**
1613 * The {@code quotas} of the message.
1614 * <P>Type: TEXT</P>
1615 * @deprecated this column is no longer supported.
1616 * @hide
1617 */
1618 @Deprecated
1619 public static final String QUOTAS = "qt";
1620
1621 /**
1622 * The {@code mbox-quotas} of the message.
1623 * <P>Type: TEXT</P>
1624 * @deprecated this column is no longer supported.
1625 * @hide
1626 */
1627 @Deprecated
1628 public static final String MBOX_QUOTAS = "mb_qt";
1629
1630 /**
1631 * The {@code mbox-quotas-token} of the message.
1632 * <P>Type: INTEGER</P>
1633 * @deprecated this column is no longer supported.
1634 * @hide
1635 */
1636 @Deprecated
1637 public static final String MBOX_QUOTAS_TOKEN = "mb_qt_tok";
1638
1639 /**
1640 * The {@code message-count} of the message.
1641 * <P>Type: INTEGER</P>
1642 * @deprecated this column is no longer supported.
1643 * @hide
1644 */
1645 @Deprecated
1646 public static final String MESSAGE_COUNT = "m_cnt";
1647
1648 /**
1649 * The {@code start} of the message.
1650 * <P>Type: INTEGER</P>
1651 * @deprecated this column is no longer supported.
1652 * @hide
1653 */
1654 @Deprecated
1655 public static final String START = "start";
1656
1657 /**
1658 * The {@code distribution-indicator} of the message.
1659 * <P>Type: TEXT</P>
1660 * @deprecated this column is no longer supported.
1661 * @hide
1662 */
1663 @Deprecated
1664 public static final String DISTRIBUTION_INDICATOR = "d_ind";
1665
1666 /**
1667 * The {@code element-descriptor} of the message.
1668 * <P>Type: TEXT</P>
1669 * @deprecated this column is no longer supported.
1670 * @hide
1671 */
1672 @Deprecated
1673 public static final String ELEMENT_DESCRIPTOR = "e_des";
1674
1675 /**
1676 * The {@code limit} of the message.
1677 * <P>Type: INTEGER</P>
1678 * @deprecated this column is no longer supported.
1679 * @hide
1680 */
1681 @Deprecated
1682 public static final String LIMIT = "limit";
1683
1684 /**
1685 * The {@code recommended-retrieval-mode} of the message.
1686 * <P>Type: INTEGER</P>
1687 * @deprecated this column is no longer supported.
1688 * @hide
1689 */
1690 @Deprecated
1691 public static final String RECOMMENDED_RETRIEVAL_MODE = "r_r_mod";
1692
1693 /**
1694 * The {@code recommended-retrieval-mode-text} of the message.
1695 * <P>Type: TEXT</P>
1696 * @deprecated this column is no longer supported.
1697 * @hide
1698 */
1699 @Deprecated
1700 public static final String RECOMMENDED_RETRIEVAL_MODE_TEXT = "r_r_mod_txt";
1701
1702 /**
1703 * The {@code status-text} of the message.
1704 * <P>Type: TEXT</P>
1705 * @deprecated this column is no longer supported.
1706 * @hide
1707 */
1708 @Deprecated
1709 public static final String STATUS_TEXT = "st_txt";
1710
1711 /**
1712 * The {@code applic-id} of the message.
1713 * <P>Type: TEXT</P>
1714 * @deprecated this column is no longer supported.
1715 * @hide
1716 */
1717 @Deprecated
1718 public static final String APPLIC_ID = "apl_id";
1719
1720 /**
1721 * The {@code reply-applic-id} of the message.
1722 * <P>Type: TEXT</P>
1723 * @deprecated this column is no longer supported.
1724 * @hide
1725 */
1726 @Deprecated
1727 public static final String REPLY_APPLIC_ID = "r_apl_id";
1728
1729 /**
1730 * The {@code aux-applic-id} of the message.
1731 * <P>Type: TEXT</P>
1732 * @deprecated this column is no longer supported.
1733 * @hide
1734 */
1735 @Deprecated
1736 public static final String AUX_APPLIC_ID = "aux_apl_id";
1737
1738 /**
1739 * The {@code drm-content} of the message.
1740 * <P>Type: TEXT</P>
1741 * @deprecated this column is no longer supported.
1742 * @hide
1743 */
1744 @Deprecated
1745 public static final String DRM_CONTENT = "drm_c";
1746
1747 /**
1748 * The {@code adaptation-allowed} of the message.
1749 * <P>Type: TEXT</P>
1750 * @deprecated this column is no longer supported.
1751 * @hide
1752 */
1753 @Deprecated
1754 public static final String ADAPTATION_ALLOWED = "adp_a";
1755
1756 /**
1757 * The {@code replace-id} of the message.
1758 * <P>Type: TEXT</P>
1759 * @deprecated this column is no longer supported.
1760 * @hide
1761 */
1762 @Deprecated
1763 public static final String REPLACE_ID = "repl_id";
1764
1765 /**
1766 * The {@code cancel-id} of the message.
1767 * <P>Type: TEXT</P>
1768 * @deprecated this column is no longer supported.
1769 * @hide
1770 */
1771 @Deprecated
1772 public static final String CANCEL_ID = "cl_id";
1773
1774 /**
1775 * The {@code cancel-status} of the message.
1776 * <P>Type: INTEGER</P>
1777 * @deprecated this column is no longer supported.
1778 * @hide
1779 */
1780 @Deprecated
1781 public static final String CANCEL_STATUS = "cl_st";
1782
1783 /**
1784 * Is the message locked?
1785 * <P>Type: INTEGER (boolean)</P>
1786 */
1787 public static final String LOCKED = "locked";
1788
1789 /**
1790 * The subscription to which the message belongs to. Its value will be
1791 * < 0 if the sub id cannot be determined.
1792 * <p>Type: INTEGER (long)</p>
1793 */
1794 public static final String SUBSCRIPTION_ID = "sub_id";
1795
1796 /**
1797 * The identity of the sender of a sent message. It is
1798 * usually the package name of the app which sends the message.
1799 * <p class="note"><strong>Note:</strong>
1800 * This column is read-only. It is set by the provider and can not be changed by apps.
1801 * <p>Type: TEXT</p>
1802 */
1803 public static final String CREATOR = "creator";
1804 }
1805
1806 /**
1807 * Columns for the "canonical_addresses" table used by MMS and SMS.
1808 */
1809 public interface CanonicalAddressesColumns extends BaseColumns {
1810 /**
1811 * An address used in MMS or SMS. Email addresses are
1812 * converted to lower case and are compared by string
1813 * equality. Other addresses are compared using
1814 * PHONE_NUMBERS_EQUAL.
1815 * <P>Type: TEXT</P>
1816 */
1817 public static final String ADDRESS = "address";
1818 }
1819
1820 /**
1821 * Columns for the "threads" table used by MMS and SMS.
1822 */
1823 public interface ThreadsColumns extends BaseColumns {
1824
1825 /**
1826 * The date at which the thread was created.
1827 * <P>Type: INTEGER (long)</P>
1828 */
1829 public static final String DATE = "date";
1830
1831 /**
1832 * A string encoding of the recipient IDs of the recipients of
1833 * the message, in numerical order and separated by spaces.
1834 * <P>Type: TEXT</P>
1835 */
1836 public static final String RECIPIENT_IDS = "recipient_ids";
1837
1838 /**
1839 * The message count of the thread.
1840 * <P>Type: INTEGER</P>
1841 */
1842 public static final String MESSAGE_COUNT = "message_count";
1843
1844 /**
1845 * Indicates whether all messages of the thread have been read.
1846 * <P>Type: INTEGER</P>
1847 */
1848 public static final String READ = "read";
1849
1850 /**
1851 * The snippet of the latest message in the thread.
1852 * <P>Type: TEXT</P>
1853 */
1854 public static final String SNIPPET = "snippet";
1855
1856 /**
1857 * The charset of the snippet.
1858 * <P>Type: INTEGER</P>
1859 */
1860 public static final String SNIPPET_CHARSET = "snippet_cs";
1861
1862 /**
1863 * Type of the thread, either {@link Threads#COMMON_THREAD} or
1864 * {@link Threads#BROADCAST_THREAD}.
1865 * <P>Type: INTEGER</P>
1866 */
1867 public static final String TYPE = "type";
1868
1869 /**
1870 * Indicates whether there is a transmission error in the thread.
1871 * <P>Type: INTEGER</P>
1872 */
1873 public static final String ERROR = "error";
1874
1875 /**
1876 * Indicates whether this thread contains any attachments.
1877 * <P>Type: INTEGER</P>
1878 */
1879 public static final String HAS_ATTACHMENT = "has_attachment";
1880
1881 /**
1882 * If the thread is archived
1883 * <P>Type: INTEGER (boolean)</P>
1884 */
1885 public static final String ARCHIVED = "archived";
1886 }
1887
1888 /**
1889 * Helper functions for the "threads" table used by MMS and SMS.
1890 */
1891 public static final class Threads implements ThreadsColumns {
1892
Mathew Inwoodba503112018-08-10 09:37:35 +01001893 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08001894 private static final String[] ID_PROJECTION = { BaseColumns._ID };
1895
1896 /**
1897 * Private {@code content://} style URL for this table. Used by
1898 * {@link #getOrCreateThreadId(android.content.Context, java.util.Set)}.
1899 */
Mathew Inwoodba503112018-08-10 09:37:35 +01001900 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08001901 private static final Uri THREAD_ID_CONTENT_URI = Uri.parse(
1902 "content://mms-sms/threadID");
1903
1904 /**
1905 * The {@code content://} style URL for this table, by conversation.
1906 */
1907 public static final Uri CONTENT_URI = Uri.withAppendedPath(
1908 MmsSms.CONTENT_URI, "conversations");
1909
1910 /**
1911 * The {@code content://} style URL for this table, for obsolete threads.
1912 */
1913 public static final Uri OBSOLETE_THREADS_URI = Uri.withAppendedPath(
1914 CONTENT_URI, "obsolete");
1915
1916 /** Thread type: common thread. */
1917 public static final int COMMON_THREAD = 0;
1918
1919 /** Thread type: broadcast thread. */
1920 public static final int BROADCAST_THREAD = 1;
1921
1922 /**
1923 * Not instantiable.
1924 * @hide
1925 */
1926 private Threads() {
1927 }
1928
1929 /**
1930 * This is a single-recipient version of {@code getOrCreateThreadId}.
1931 * It's convenient for use with SMS messages.
1932 * @param context the context object to use.
1933 * @param recipient the recipient to send to.
1934 */
1935 public static long getOrCreateThreadId(Context context, String recipient) {
1936 Set<String> recipients = new HashSet<String>();
1937
1938 recipients.add(recipient);
1939 return getOrCreateThreadId(context, recipients);
1940 }
1941
1942 /**
1943 * Given the recipients list and subject of an unsaved message,
1944 * return its thread ID. If the message starts a new thread,
1945 * allocate a new thread ID. Otherwise, use the appropriate
1946 * existing thread ID.
1947 *
1948 * <p>Find the thread ID of the same set of recipients (in any order,
1949 * without any additions). If one is found, return it. Otherwise,
1950 * return a unique thread ID.</p>
1951 */
1952 public static long getOrCreateThreadId(
1953 Context context, Set<String> recipients) {
1954 Uri.Builder uriBuilder = THREAD_ID_CONTENT_URI.buildUpon();
1955
1956 for (String recipient : recipients) {
1957 if (Mms.isEmailAddress(recipient)) {
1958 recipient = Mms.extractAddrSpec(recipient);
1959 }
1960
1961 uriBuilder.appendQueryParameter("recipient", recipient);
1962 }
1963
1964 Uri uri = uriBuilder.build();
1965 //if (DEBUG) Rlog.v(TAG, "getOrCreateThreadId uri: " + uri);
1966
1967 Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
1968 uri, ID_PROJECTION, null, null, null);
1969 if (cursor != null) {
1970 try {
1971 if (cursor.moveToFirst()) {
1972 return cursor.getLong(0);
1973 } else {
1974 Rlog.e(TAG, "getOrCreateThreadId returned no rows!");
1975 }
1976 } finally {
1977 cursor.close();
1978 }
1979 }
1980
1981 Rlog.e(TAG, "getOrCreateThreadId failed with " + recipients.size() + " recipients");
1982 throw new IllegalArgumentException("Unable to find or allocate a thread ID.");
1983 }
1984 }
1985
1986 /**
1987 * Contains all MMS messages.
1988 */
1989 public static final class Mms implements BaseMmsColumns {
1990
1991 /**
1992 * Not instantiable.
1993 * @hide
1994 */
1995 private Mms() {
1996 }
1997
1998 /**
1999 * The {@code content://} URI for this table.
2000 */
2001 public static final Uri CONTENT_URI = Uri.parse("content://mms");
2002
2003 /**
2004 * Content URI for getting MMS report requests.
2005 */
2006 public static final Uri REPORT_REQUEST_URI = Uri.withAppendedPath(
2007 CONTENT_URI, "report-request");
2008
2009 /**
2010 * Content URI for getting MMS report status.
2011 */
2012 public static final Uri REPORT_STATUS_URI = Uri.withAppendedPath(
2013 CONTENT_URI, "report-status");
2014
2015 /**
2016 * The default sort order for this table.
2017 */
2018 public static final String DEFAULT_SORT_ORDER = "date DESC";
2019
2020 /**
2021 * Regex pattern for names and email addresses.
2022 * <ul>
2023 * <li><em>mailbox</em> = {@code name-addr}</li>
2024 * <li><em>name-addr</em> = {@code [display-name] angle-addr}</li>
2025 * <li><em>angle-addr</em> = {@code [CFWS] "<" addr-spec ">" [CFWS]}</li>
2026 * </ul>
2027 * @hide
2028 */
Mathew Inwoodba503112018-08-10 09:37:35 +01002029 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002030 public static final Pattern NAME_ADDR_EMAIL_PATTERN =
2031 Pattern.compile("\\s*(\"[^\"]*\"|[^<>\"]+)\\s*<([^<>]+)>\\s*");
2032
2033 /**
2034 * Helper method to query this table.
2035 * @hide
2036 */
2037 public static Cursor query(
2038 ContentResolver cr, String[] projection) {
2039 return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
2040 }
2041
2042 /**
2043 * Helper method to query this table.
2044 * @hide
2045 */
2046 public static Cursor query(
2047 ContentResolver cr, String[] projection,
2048 String where, String orderBy) {
2049 return cr.query(CONTENT_URI, projection,
2050 where, null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
2051 }
2052
2053 /**
2054 * Helper method to extract email address from address string.
2055 * @hide
2056 */
Mathew Inwoodba503112018-08-10 09:37:35 +01002057 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002058 public static String extractAddrSpec(String address) {
2059 Matcher match = NAME_ADDR_EMAIL_PATTERN.matcher(address);
2060
2061 if (match.matches()) {
2062 return match.group(2);
2063 }
2064 return address;
2065 }
2066
2067 /**
2068 * Is the specified address an email address?
2069 *
2070 * @param address the input address to test
2071 * @return true if address is an email address; false otherwise.
2072 * @hide
2073 */
Mathew Inwoodba503112018-08-10 09:37:35 +01002074 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002075 public static boolean isEmailAddress(String address) {
2076 if (TextUtils.isEmpty(address)) {
2077 return false;
2078 }
2079
2080 String s = extractAddrSpec(address);
2081 Matcher match = Patterns.EMAIL_ADDRESS.matcher(s);
2082 return match.matches();
2083 }
2084
2085 /**
2086 * Is the specified number a phone number?
2087 *
2088 * @param number the input number to test
2089 * @return true if number is a phone number; false otherwise.
2090 * @hide
2091 */
Mathew Inwoodba503112018-08-10 09:37:35 +01002092 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002093 public static boolean isPhoneNumber(String number) {
2094 if (TextUtils.isEmpty(number)) {
2095 return false;
2096 }
2097
2098 Matcher match = Patterns.PHONE.matcher(number);
2099 return match.matches();
2100 }
2101
2102 /**
2103 * Contains all MMS messages in the MMS app inbox.
2104 */
2105 public static final class Inbox implements BaseMmsColumns {
2106
2107 /**
2108 * Not instantiable.
2109 * @hide
2110 */
2111 private Inbox() {
2112 }
2113
2114 /**
2115 * The {@code content://} style URL for this table.
2116 */
2117 public static final Uri
2118 CONTENT_URI = Uri.parse("content://mms/inbox");
2119
2120 /**
2121 * The default sort order for this table.
2122 */
2123 public static final String DEFAULT_SORT_ORDER = "date DESC";
2124 }
2125
2126 /**
2127 * Contains all MMS messages in the MMS app sent folder.
2128 */
2129 public static final class Sent implements BaseMmsColumns {
2130
2131 /**
2132 * Not instantiable.
2133 * @hide
2134 */
2135 private Sent() {
2136 }
2137
2138 /**
2139 * The {@code content://} style URL for this table.
2140 */
2141 public static final Uri
2142 CONTENT_URI = Uri.parse("content://mms/sent");
2143
2144 /**
2145 * The default sort order for this table.
2146 */
2147 public static final String DEFAULT_SORT_ORDER = "date DESC";
2148 }
2149
2150 /**
2151 * Contains all MMS messages in the MMS app drafts folder.
2152 */
2153 public static final class Draft implements BaseMmsColumns {
2154
2155 /**
2156 * Not instantiable.
2157 * @hide
2158 */
2159 private Draft() {
2160 }
2161
2162 /**
2163 * The {@code content://} style URL for this table.
2164 */
2165 public static final Uri
2166 CONTENT_URI = Uri.parse("content://mms/drafts");
2167
2168 /**
2169 * The default sort order for this table.
2170 */
2171 public static final String DEFAULT_SORT_ORDER = "date DESC";
2172 }
2173
2174 /**
2175 * Contains all MMS messages in the MMS app outbox.
2176 */
2177 public static final class Outbox implements BaseMmsColumns {
2178
2179 /**
2180 * Not instantiable.
2181 * @hide
2182 */
2183 private Outbox() {
2184 }
2185
2186 /**
2187 * The {@code content://} style URL for this table.
2188 */
2189 public static final Uri
2190 CONTENT_URI = Uri.parse("content://mms/outbox");
2191
2192 /**
2193 * The default sort order for this table.
2194 */
2195 public static final String DEFAULT_SORT_ORDER = "date DESC";
2196 }
2197
2198 /**
2199 * Contains address information for an MMS message.
2200 */
2201 public static final class Addr implements BaseColumns {
2202
2203 /**
2204 * Not instantiable.
2205 * @hide
2206 */
2207 private Addr() {
2208 }
2209
2210 /**
2211 * The ID of MM which this address entry belongs to.
2212 * <P>Type: INTEGER (long)</P>
2213 */
2214 public static final String MSG_ID = "msg_id";
2215
2216 /**
2217 * The ID of contact entry in Phone Book.
2218 * <P>Type: INTEGER (long)</P>
2219 */
2220 public static final String CONTACT_ID = "contact_id";
2221
2222 /**
2223 * The address text.
2224 * <P>Type: TEXT</P>
2225 */
2226 public static final String ADDRESS = "address";
2227
2228 /**
2229 * Type of address: must be one of {@code PduHeaders.BCC},
2230 * {@code PduHeaders.CC}, {@code PduHeaders.FROM}, {@code PduHeaders.TO}.
2231 * <P>Type: INTEGER</P>
2232 */
2233 public static final String TYPE = "type";
2234
2235 /**
2236 * Character set of this entry (MMS charset value).
2237 * <P>Type: INTEGER</P>
2238 */
2239 public static final String CHARSET = "charset";
2240 }
2241
2242 /**
2243 * Contains message parts.
2244 */
2245 public static final class Part implements BaseColumns {
2246
2247 /**
2248 * Not instantiable.
2249 * @hide
2250 */
2251 private Part() {
2252 }
2253
2254 /**
2255 * The identifier of the message which this part belongs to.
2256 * <P>Type: INTEGER</P>
2257 */
2258 public static final String MSG_ID = "mid";
2259
2260 /**
2261 * The order of the part.
2262 * <P>Type: INTEGER</P>
2263 */
2264 public static final String SEQ = "seq";
2265
2266 /**
2267 * The content type of the part.
2268 * <P>Type: TEXT</P>
2269 */
2270 public static final String CONTENT_TYPE = "ct";
2271
2272 /**
2273 * The name of the part.
2274 * <P>Type: TEXT</P>
2275 */
2276 public static final String NAME = "name";
2277
2278 /**
2279 * The charset of the part.
2280 * <P>Type: TEXT</P>
2281 */
2282 public static final String CHARSET = "chset";
2283
2284 /**
2285 * The file name of the part.
2286 * <P>Type: TEXT</P>
2287 */
2288 public static final String FILENAME = "fn";
2289
2290 /**
2291 * The content disposition of the part.
2292 * <P>Type: TEXT</P>
2293 */
2294 public static final String CONTENT_DISPOSITION = "cd";
2295
2296 /**
2297 * The content ID of the part.
2298 * <P>Type: INTEGER</P>
2299 */
2300 public static final String CONTENT_ID = "cid";
2301
2302 /**
2303 * The content location of the part.
2304 * <P>Type: INTEGER</P>
2305 */
2306 public static final String CONTENT_LOCATION = "cl";
2307
2308 /**
2309 * The start of content-type of the message.
2310 * <P>Type: INTEGER</P>
2311 */
2312 public static final String CT_START = "ctt_s";
2313
2314 /**
2315 * The type of content-type of the message.
2316 * <P>Type: TEXT</P>
2317 */
2318 public static final String CT_TYPE = "ctt_t";
2319
2320 /**
2321 * The location (on filesystem) of the binary data of the part.
2322 * <P>Type: INTEGER</P>
2323 */
2324 public static final String _DATA = "_data";
2325
2326 /**
2327 * The message text.
2328 * <P>Type: TEXT</P>
2329 */
2330 public static final String TEXT = "text";
2331 }
2332
2333 /**
2334 * Message send rate table.
2335 */
2336 public static final class Rate {
2337
2338 /**
2339 * Not instantiable.
2340 * @hide
2341 */
2342 private Rate() {
2343 }
2344
2345 /**
2346 * The {@code content://} style URL for this table.
2347 */
2348 public static final Uri CONTENT_URI = Uri.withAppendedPath(
2349 Mms.CONTENT_URI, "rate");
2350
2351 /**
2352 * When a message was successfully sent.
2353 * <P>Type: INTEGER (long)</P>
2354 */
2355 public static final String SENT_TIME = "sent_time";
2356 }
2357
2358 /**
2359 * Intents class.
2360 */
2361 public static final class Intents {
2362
2363 /**
2364 * Not instantiable.
2365 * @hide
2366 */
2367 private Intents() {
2368 }
2369
2370 /**
2371 * Indicates that the contents of specified URIs were changed.
2372 * The application which is showing or caching these contents
2373 * should be updated.
2374 */
2375 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2376 public static final String CONTENT_CHANGED_ACTION
2377 = "android.intent.action.CONTENT_CHANGED";
2378
2379 /**
2380 * An extra field which stores the URI of deleted contents.
2381 */
2382 public static final String DELETED_CONTENTS = "deleted_contents";
2383 }
2384 }
2385
2386 /**
2387 * Contains all MMS and SMS messages.
2388 */
2389 public static final class MmsSms implements BaseColumns {
2390
2391 /**
2392 * Not instantiable.
2393 * @hide
2394 */
2395 private MmsSms() {
2396 }
2397
2398 /**
2399 * The column to distinguish SMS and MMS messages in query results.
2400 */
2401 public static final String TYPE_DISCRIMINATOR_COLUMN =
2402 "transport_type";
2403
2404 /**
2405 * The {@code content://} style URL for this table.
2406 */
2407 public static final Uri CONTENT_URI = Uri.parse("content://mms-sms/");
2408
2409 /**
2410 * The {@code content://} style URL for this table, by conversation.
2411 */
2412 public static final Uri CONTENT_CONVERSATIONS_URI = Uri.parse(
2413 "content://mms-sms/conversations");
2414
2415 /**
2416 * The {@code content://} style URL for this table, by phone number.
2417 */
2418 public static final Uri CONTENT_FILTER_BYPHONE_URI = Uri.parse(
2419 "content://mms-sms/messages/byphone");
2420
2421 /**
2422 * The {@code content://} style URL for undelivered messages in this table.
2423 */
2424 public static final Uri CONTENT_UNDELIVERED_URI = Uri.parse(
2425 "content://mms-sms/undelivered");
2426
2427 /**
2428 * The {@code content://} style URL for draft messages in this table.
2429 */
2430 public static final Uri CONTENT_DRAFT_URI = Uri.parse(
2431 "content://mms-sms/draft");
2432
2433 /**
2434 * The {@code content://} style URL for locked messages in this table.
2435 */
2436 public static final Uri CONTENT_LOCKED_URI = Uri.parse(
2437 "content://mms-sms/locked");
2438
2439 /**
2440 * Pass in a query parameter called "pattern" which is the text to search for.
2441 * The sort order is fixed to be: {@code thread_id ASC, date DESC}.
2442 */
2443 public static final Uri SEARCH_URI = Uri.parse(
2444 "content://mms-sms/search");
2445
2446 // Constants for message protocol types.
2447
2448 /** SMS protocol type. */
2449 public static final int SMS_PROTO = 0;
2450
2451 /** MMS protocol type. */
2452 public static final int MMS_PROTO = 1;
2453
2454 // Constants for error types of pending messages.
2455
2456 /** Error type: no error. */
2457 public static final int NO_ERROR = 0;
2458
2459 /** Error type: generic transient error. */
2460 public static final int ERR_TYPE_GENERIC = 1;
2461
2462 /** Error type: SMS protocol transient error. */
2463 public static final int ERR_TYPE_SMS_PROTO_TRANSIENT = 2;
2464
2465 /** Error type: MMS protocol transient error. */
2466 public static final int ERR_TYPE_MMS_PROTO_TRANSIENT = 3;
2467
2468 /** Error type: transport failure. */
2469 public static final int ERR_TYPE_TRANSPORT_FAILURE = 4;
2470
2471 /** Error type: permanent error (along with all higher error values). */
2472 public static final int ERR_TYPE_GENERIC_PERMANENT = 10;
2473
2474 /** Error type: SMS protocol permanent error. */
2475 public static final int ERR_TYPE_SMS_PROTO_PERMANENT = 11;
2476
2477 /** Error type: MMS protocol permanent error. */
2478 public static final int ERR_TYPE_MMS_PROTO_PERMANENT = 12;
2479
2480 /**
2481 * Contains pending messages info.
2482 */
2483 public static final class PendingMessages implements BaseColumns {
2484
2485 /**
2486 * Not instantiable.
2487 * @hide
2488 */
2489 private PendingMessages() {
2490 }
2491
2492 public static final Uri CONTENT_URI = Uri.withAppendedPath(
2493 MmsSms.CONTENT_URI, "pending");
2494
2495 /**
2496 * The type of transport protocol (MMS or SMS).
2497 * <P>Type: INTEGER</P>
2498 */
2499 public static final String PROTO_TYPE = "proto_type";
2500
2501 /**
2502 * The ID of the message to be sent or downloaded.
2503 * <P>Type: INTEGER (long)</P>
2504 */
2505 public static final String MSG_ID = "msg_id";
2506
2507 /**
2508 * The type of the message to be sent or downloaded.
2509 * This field is only valid for MM. For SM, its value is always set to 0.
2510 * <P>Type: INTEGER</P>
2511 */
2512 public static final String MSG_TYPE = "msg_type";
2513
2514 /**
2515 * The type of the error code.
2516 * <P>Type: INTEGER</P>
2517 */
2518 public static final String ERROR_TYPE = "err_type";
2519
2520 /**
2521 * The error code of sending/retrieving process.
2522 * <P>Type: INTEGER</P>
2523 */
2524 public static final String ERROR_CODE = "err_code";
2525
2526 /**
2527 * How many times we tried to send or download the message.
2528 * <P>Type: INTEGER</P>
2529 */
2530 public static final String RETRY_INDEX = "retry_index";
2531
2532 /**
2533 * The time to do next retry.
2534 * <P>Type: INTEGER (long)</P>
2535 */
2536 public static final String DUE_TIME = "due_time";
2537
2538 /**
2539 * The time we last tried to send or download the message.
2540 * <P>Type: INTEGER (long)</P>
2541 */
2542 public static final String LAST_TRY = "last_try";
2543
2544 /**
2545 * The subscription to which the message belongs to. Its value will be
2546 * < 0 if the sub id cannot be determined.
2547 * <p>Type: INTEGER (long) </p>
2548 */
2549 public static final String SUBSCRIPTION_ID = "pending_sub_id";
2550 }
2551
2552 /**
2553 * Words table used by provider for full-text searches.
2554 * @hide
2555 */
2556 public static final class WordsTable {
2557
2558 /**
2559 * Not instantiable.
2560 * @hide
2561 */
2562 private WordsTable() {}
2563
2564 /**
2565 * Primary key.
2566 * <P>Type: INTEGER (long)</P>
2567 */
2568 public static final String ID = "_id";
2569
2570 /**
2571 * Source row ID.
2572 * <P>Type: INTEGER (long)</P>
2573 */
2574 public static final String SOURCE_ROW_ID = "source_id";
2575
2576 /**
2577 * Table ID (either 1 or 2).
2578 * <P>Type: INTEGER</P>
2579 */
2580 public static final String TABLE_ID = "table_to_use";
2581
2582 /**
2583 * The words to index.
2584 * <P>Type: TEXT</P>
2585 */
2586 public static final String INDEXED_TEXT = "index_text";
2587 }
2588 }
2589
2590 /**
2591 * Carriers class contains information about APNs, including MMSC information.
2592 */
2593 public static final class Carriers implements BaseColumns {
2594
2595 /**
2596 * Not instantiable.
2597 * @hide
2598 */
2599 private Carriers() {}
2600
2601 /**
2602 * The {@code content://} style URL for this table.
2603 */
2604 public static final Uri CONTENT_URI = Uri.parse("content://telephony/carriers");
2605
2606 /**
yuemingw4c0065f2018-01-16 19:48:10 +00002607 * The {@code content://} style URL to be called from DevicePolicyManagerService,
2608 * can manage DPC-owned APNs.
2609 * @hide
2610 */
2611 public static final Uri DPC_URI = Uri.parse("content://telephony/carriers/dpc");
2612
2613 /**
2614 * The {@code content://} style URL to be called from Telephony to query APNs.
2615 * When DPC-owned APNs are enforced, only DPC-owned APNs are returned, otherwise only
2616 * non-DPC-owned APNs are returned.
2617 * @hide
2618 */
2619 public static final Uri FILTERED_URI = Uri.parse("content://telephony/carriers/filtered");
2620
2621 /**
2622 * The {@code content://} style URL to be called from DevicePolicyManagerService
2623 * or Telephony to manage whether DPC-owned APNs are enforced.
2624 * @hide
2625 */
2626 public static final Uri ENFORCE_MANAGED_URI = Uri.parse(
2627 "content://telephony/carriers/enforce_managed");
2628
2629 /**
2630 * The column name for ENFORCE_MANAGED_URI, indicates whether DPC-owned APNs are enforced.
2631 * @hide
2632 */
2633 public static final String ENFORCE_KEY = "enforced";
2634
2635 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08002636 * The default sort order for this table.
2637 */
2638 public static final String DEFAULT_SORT_ORDER = "name ASC";
2639
2640 /**
2641 * Entry name.
2642 * <P>Type: TEXT</P>
2643 */
2644 public static final String NAME = "name";
2645
2646 /**
2647 * APN name.
2648 * <P>Type: TEXT</P>
2649 */
2650 public static final String APN = "apn";
2651
2652 /**
2653 * Proxy address.
2654 * <P>Type: TEXT</P>
2655 */
2656 public static final String PROXY = "proxy";
2657
2658 /**
2659 * Proxy port.
2660 * <P>Type: TEXT</P>
2661 */
2662 public static final String PORT = "port";
2663
2664 /**
2665 * MMS proxy address.
2666 * <P>Type: TEXT</P>
2667 */
2668 public static final String MMSPROXY = "mmsproxy";
2669
2670 /**
2671 * MMS proxy port.
2672 * <P>Type: TEXT</P>
2673 */
2674 public static final String MMSPORT = "mmsport";
2675
2676 /**
2677 * Server address.
2678 * <P>Type: TEXT</P>
2679 */
2680 public static final String SERVER = "server";
2681
2682 /**
2683 * APN username.
2684 * <P>Type: TEXT</P>
2685 */
2686 public static final String USER = "user";
2687
2688 /**
2689 * APN password.
2690 * <P>Type: TEXT</P>
2691 */
2692 public static final String PASSWORD = "password";
2693
2694 /**
2695 * MMSC URL.
2696 * <P>Type: TEXT</P>
2697 */
2698 public static final String MMSC = "mmsc";
2699
2700 /**
2701 * Mobile Country Code (MCC).
2702 * <P>Type: TEXT</P>
2703 */
2704 public static final String MCC = "mcc";
2705
2706 /**
2707 * Mobile Network Code (MNC).
2708 * <P>Type: TEXT</P>
2709 */
2710 public static final String MNC = "mnc";
2711
2712 /**
2713 * Numeric operator ID (as String). Usually {@code MCC + MNC}.
2714 * <P>Type: TEXT</P>
2715 */
2716 public static final String NUMERIC = "numeric";
2717
2718 /**
2719 * Authentication type.
2720 * <P>Type: INTEGER</P>
2721 */
2722 public static final String AUTH_TYPE = "authtype";
2723
2724 /**
2725 * Comma-delimited list of APN types.
2726 * <P>Type: TEXT</P>
2727 */
2728 public static final String TYPE = "type";
2729
2730 /**
2731 * The protocol to use to connect to this APN.
2732 *
2733 * One of the {@code PDP_type} values in TS 27.007 section 10.1.1.
2734 * For example: {@code IP}, {@code IPV6}, {@code IPV4V6}, or {@code PPP}.
2735 * <P>Type: TEXT</P>
2736 */
2737 public static final String PROTOCOL = "protocol";
2738
2739 /**
2740 * The protocol to use to connect to this APN when roaming.
2741 * The syntax is the same as protocol.
2742 * <P>Type: TEXT</P>
2743 */
2744 public static final String ROAMING_PROTOCOL = "roaming_protocol";
2745
2746 /**
2747 * Is this the current APN?
2748 * <P>Type: INTEGER (boolean)</P>
2749 */
2750 public static final String CURRENT = "current";
2751
2752 /**
2753 * Is this APN enabled?
2754 * <P>Type: INTEGER (boolean)</P>
2755 */
2756 public static final String CARRIER_ENABLED = "carrier_enabled";
2757
2758 /**
2759 * Radio Access Technology info.
2760 * To check what values are allowed, refer to {@link android.telephony.ServiceState}.
2761 * This should be spread to other technologies,
2762 * but is currently only used for LTE (14) and eHRPD (13).
2763 * <P>Type: INTEGER</P>
Cassiee1c88022018-02-22 08:51:03 -08002764 * @deprecated this column is no longer supported, use {@link #NETWORK_TYPE_BITMASK} instead
Dan Willemsen4980bf42017-02-14 14:17:12 -08002765 */
Cassied53df962017-12-05 13:34:33 -08002766 @Deprecated
Dan Willemsen4980bf42017-02-14 14:17:12 -08002767 public static final String BEARER = "bearer";
2768
2769 /**
2770 * Radio Access Technology bitmask.
2771 * To check what values can be contained, refer to {@link android.telephony.ServiceState}.
2772 * 0 indicates all techs otherwise first bit refers to RAT/bearer 1, second bit refers to
2773 * RAT/bearer 2 and so on.
2774 * Bitmask for a radio tech R is (1 << (R - 1))
2775 * <P>Type: INTEGER</P>
2776 * @hide
Cassiee1c88022018-02-22 08:51:03 -08002777 * @deprecated this column is no longer supported, use {@link #NETWORK_TYPE_BITMASK} instead
Dan Willemsen4980bf42017-02-14 14:17:12 -08002778 */
Cassied53df962017-12-05 13:34:33 -08002779 @Deprecated
Dan Willemsen4980bf42017-02-14 14:17:12 -08002780 public static final String BEARER_BITMASK = "bearer_bitmask";
2781
2782 /**
Cassied53df962017-12-05 13:34:33 -08002783 * Radio technology (network type) bitmask.
Cassiee1c88022018-02-22 08:51:03 -08002784 * To check what values can be contained, refer to the NETWORK_TYPE_ constants in
Cassied53df962017-12-05 13:34:33 -08002785 * {@link android.telephony.TelephonyManager}.
2786 * Bitmask for a radio tech R is (1 << (R - 1))
2787 * <P>Type: INTEGER</P>
2788 */
2789 public static final String NETWORK_TYPE_BITMASK = "network_type_bitmask";
2790
2791 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08002792 * MVNO type:
2793 * {@code SPN (Service Provider Name), IMSI, GID (Group Identifier Level 1)}.
2794 * <P>Type: TEXT</P>
2795 */
2796 public static final String MVNO_TYPE = "mvno_type";
2797
2798 /**
2799 * MVNO data.
2800 * Use the following examples.
2801 * <ul>
2802 * <li>SPN: A MOBILE, BEN NL, ...</li>
2803 * <li>IMSI: 302720x94, 2060188, ...</li>
2804 * <li>GID: 4E, 33, ...</li>
2805 * </ul>
2806 * <P>Type: TEXT</P>
2807 */
2808 public static final String MVNO_MATCH_DATA = "mvno_match_data";
2809
2810 /**
2811 * The subscription to which the APN belongs to
2812 * <p>Type: INTEGER (long) </p>
2813 */
2814 public static final String SUBSCRIPTION_ID = "sub_id";
2815
2816 /**
chen xu85100482018-10-12 15:30:34 -07002817 * The profile_id to which the APN saved in modem.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002818 * <p>Type: INTEGER</p>
2819 *@hide
2820 */
2821 public static final String PROFILE_ID = "profile_id";
2822
2823 /**
chen xu85100482018-10-12 15:30:34 -07002824 * If set to {@code true}, then the APN setting will persist to the modem.
2825 * <p>Type: INTEGER (boolean)</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08002826 *@hide
2827 */
chen xu85100482018-10-12 15:30:34 -07002828 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002829 public static final String MODEM_COGNITIVE = "modem_cognitive";
2830
2831 /**
chen xu85100482018-10-12 15:30:34 -07002832 * The max connections of this APN.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002833 * <p>Type: INTEGER</p>
2834 *@hide
2835 */
chen xu85100482018-10-12 15:30:34 -07002836 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002837 public static final String MAX_CONNS = "max_conns";
2838
2839 /**
chen xu85100482018-10-12 15:30:34 -07002840 * The wait time for retry of the APN.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002841 * <p>Type: INTEGER</p>
2842 *@hide
2843 */
chen xu85100482018-10-12 15:30:34 -07002844 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002845 public static final String WAIT_TIME = "wait_time";
2846
2847 /**
chen xu85100482018-10-12 15:30:34 -07002848 * The time to limit max connection for the APN.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002849 * <p>Type: INTEGER</p>
2850 *@hide
2851 */
chen xu85100482018-10-12 15:30:34 -07002852 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002853 public static final String MAX_CONNS_TIME = "max_conns_time";
2854
2855 /**
chen xu85100482018-10-12 15:30:34 -07002856 * The MTU(Maxinum transmit unit) size of the mobile interface to which the APN connected.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002857 * <p>Type: INTEGER </p>
2858 * @hide
2859 */
chen xu85100482018-10-12 15:30:34 -07002860 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002861 public static final String MTU = "mtu";
2862
2863 /**
chen xu85100482018-10-12 15:30:34 -07002864 * APN edit status. APN could be added/edited/deleted by a user or carrier.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002865 * <p>Type: INTEGER </p>
2866 * @hide
2867 */
chen xu85100482018-10-12 15:30:34 -07002868 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002869 public static final String EDITED = "edited";
2870
2871 /**
chen xu85100482018-10-12 15:30:34 -07002872 * {@code true} if this APN visible to the user, {@code false} otherwise.
2873 * <p>Type: INTEGER (boolean)</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08002874 * @hide
2875 */
chen xu85100482018-10-12 15:30:34 -07002876 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002877 public static final String USER_VISIBLE = "user_visible";
2878
2879 /**
chen xu85100482018-10-12 15:30:34 -07002880 * {@code true} if the user allowed to edit this APN, {@code false} otherwise.
2881 * <p>Type: INTEGER (boolean)</p>
Amit Mahajand4977942017-07-17 14:46:39 -07002882 * @hide
2883 */
chen xu85100482018-10-12 15:30:34 -07002884 @SystemApi
Amit Mahajand4977942017-07-17 14:46:39 -07002885 public static final String USER_EDITABLE = "user_editable";
2886
2887 /**
chen xu85100482018-10-12 15:30:34 -07002888 * {@link #EDITED APN edit status} indicates that this APN has not been edited or fails to
2889 * edit.
2890 * <p>Type: INTEGER </p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08002891 * @hide
2892 */
chen xu85100482018-10-12 15:30:34 -07002893 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002894 public static final int UNEDITED = 0;
chen xu85100482018-10-12 15:30:34 -07002895
Dan Willemsen4980bf42017-02-14 14:17:12 -08002896 /**
chen xu85100482018-10-12 15:30:34 -07002897 * {@link #EDITED APN edit status} indicates that this APN has been edited by users.
2898 * <p>Type: INTEGER </p>
2899 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08002900 */
chen xu85100482018-10-12 15:30:34 -07002901 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002902 public static final int USER_EDITED = 1;
chen xu85100482018-10-12 15:30:34 -07002903
Dan Willemsen4980bf42017-02-14 14:17:12 -08002904 /**
chen xu85100482018-10-12 15:30:34 -07002905 * {@link #EDITED APN edit status} indicates that this APN has been deleted by users.
2906 * <p>Type: INTEGER </p>
2907 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08002908 */
chen xu85100482018-10-12 15:30:34 -07002909 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002910 public static final int USER_DELETED = 2;
chen xu85100482018-10-12 15:30:34 -07002911
Dan Willemsen4980bf42017-02-14 14:17:12 -08002912 /**
chen xu85100482018-10-12 15:30:34 -07002913 * {@link #EDITED APN edit status} is an intermediate value used to indicate that an entry
2914 * deleted by the user is still present in the new APN database and therefore must remain
2915 * tagged as user deleted rather than completely removed from the database.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002916 * @hide
2917 */
2918 public static final int USER_DELETED_BUT_PRESENT_IN_XML = 3;
chen xu85100482018-10-12 15:30:34 -07002919
Dan Willemsen4980bf42017-02-14 14:17:12 -08002920 /**
chen xu85100482018-10-12 15:30:34 -07002921 * {@link #EDITED APN edit status} indicates that this APN has been edited by carriers.
2922 * <p>Type: INTEGER </p>
2923 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08002924 */
chen xu85100482018-10-12 15:30:34 -07002925 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08002926 public static final int CARRIER_EDITED = 4;
chen xu85100482018-10-12 15:30:34 -07002927
Dan Willemsen4980bf42017-02-14 14:17:12 -08002928 /**
chen xu85100482018-10-12 15:30:34 -07002929 * {@link #EDITED APN edit status} indicates that this APN has been deleted by carriers.
2930 * CARRIER_DELETED values are currently not used as there is no use case. If they are used,
Dan Willemsen4980bf42017-02-14 14:17:12 -08002931 * delete() will have to change accordingly. Currently it is hardcoded to USER_DELETED.
chen xu85100482018-10-12 15:30:34 -07002932 * <p>Type: INTEGER </p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08002933 * @hide
2934 */
2935 public static final int CARRIER_DELETED = 5;
chen xu85100482018-10-12 15:30:34 -07002936
Dan Willemsen4980bf42017-02-14 14:17:12 -08002937 /**
chen xu85100482018-10-12 15:30:34 -07002938 * {@link #EDITED APN edit status} is an intermediate value used to indicate that an entry
2939 * deleted by the carrier is still present in the new APN database and therefore must remain
2940 * tagged as user deleted rather than completely removed from the database.
2941 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08002942 */
2943 public static final int CARRIER_DELETED_BUT_PRESENT_IN_XML = 6;
yuemingwcf263eb2017-11-08 13:12:18 +00002944
2945 /**
2946 * The owner of the APN.
2947 * <p>Type: INTEGER</p>
2948 * @hide
2949 */
2950 public static final String OWNED_BY = "owned_by";
2951
2952 /**
2953 * Possible value for the OWNED_BY field.
2954 * APN is owned by DPC.
2955 * @hide
2956 */
2957 public static final int OWNED_BY_DPC = 0;
Jordan Liu40617152018-04-06 11:10:12 -07002958
yuemingwcf263eb2017-11-08 13:12:18 +00002959 /**
2960 * Possible value for the OWNED_BY field.
2961 * APN is owned by other sources.
2962 * @hide
2963 */
2964 public static final int OWNED_BY_OTHERS = 1;
Jordan Liu40617152018-04-06 11:10:12 -07002965
2966 /**
2967 * The APN set id. When the user manually selects an APN or the framework sets an APN as
2968 * preferred, all APNs with the same set id as the selected APN should be prioritized over
2969 * APNs in other sets.
chen xu85100482018-10-12 15:30:34 -07002970 * <p>Type: INTEGER</p>
Jordan Liu40617152018-04-06 11:10:12 -07002971 * @hide
2972 */
chen xu85100482018-10-12 15:30:34 -07002973 @SystemApi
Jordan Liu40617152018-04-06 11:10:12 -07002974 public static final String APN_SET_ID = "apn_set_id";
2975
2976 /**
chen xu85100482018-10-12 15:30:34 -07002977 * Possible value for the{@link #APN_SET_ID} field. By default APNs will not belong to a
2978 * set. If the user manually selects an APN with no set set, there is no need to prioritize
2979 * any specific APN set ids.
2980 * <p>Type: INTEGER</p>
Jordan Liu40617152018-04-06 11:10:12 -07002981 * @hide
2982 */
chen xu85100482018-10-12 15:30:34 -07002983 @SystemApi
Jordan Liu40617152018-04-06 11:10:12 -07002984 public static final int NO_SET_SET = 0;
2985
Dan Willemsen4980bf42017-02-14 14:17:12 -08002986 }
2987
2988 /**
2989 * Contains received SMS cell broadcast messages.
2990 * @hide
2991 */
2992 public static final class CellBroadcasts implements BaseColumns {
2993
2994 /**
2995 * Not instantiable.
2996 * @hide
2997 */
2998 private CellBroadcasts() {}
2999
3000 /**
3001 * The {@code content://} URI for this table.
3002 */
3003 public static final Uri CONTENT_URI = Uri.parse("content://cellbroadcasts");
3004
3005 /**
3006 * Message geographical scope.
3007 * <P>Type: INTEGER</P>
3008 */
3009 public static final String GEOGRAPHICAL_SCOPE = "geo_scope";
3010
3011 /**
3012 * Message serial number.
3013 * <P>Type: INTEGER</P>
3014 */
3015 public static final String SERIAL_NUMBER = "serial_number";
3016
3017 /**
3018 * PLMN of broadcast sender. {@code SERIAL_NUMBER + PLMN + LAC + CID} uniquely identifies
3019 * a broadcast for duplicate detection purposes.
3020 * <P>Type: TEXT</P>
3021 */
3022 public static final String PLMN = "plmn";
3023
3024 /**
3025 * Location Area (GSM) or Service Area (UMTS) of broadcast sender. Unused for CDMA.
3026 * Only included if Geographical Scope of message is not PLMN wide (01).
3027 * <P>Type: INTEGER</P>
3028 */
3029 public static final String LAC = "lac";
3030
3031 /**
3032 * Cell ID of message sender (GSM/UMTS). Unused for CDMA. Only included when the
3033 * Geographical Scope of message is cell wide (00 or 11).
3034 * <P>Type: INTEGER</P>
3035 */
3036 public static final String CID = "cid";
3037
3038 /**
3039 * Message code. <em>OBSOLETE: merged into SERIAL_NUMBER.</em>
3040 * <P>Type: INTEGER</P>
3041 */
3042 public static final String V1_MESSAGE_CODE = "message_code";
3043
3044 /**
3045 * Message identifier. <em>OBSOLETE: renamed to SERVICE_CATEGORY.</em>
3046 * <P>Type: INTEGER</P>
3047 */
3048 public static final String V1_MESSAGE_IDENTIFIER = "message_id";
3049
3050 /**
3051 * Service category (GSM/UMTS: message identifier; CDMA: service category).
3052 * <P>Type: INTEGER</P>
3053 */
3054 public static final String SERVICE_CATEGORY = "service_category";
3055
3056 /**
3057 * Message language code.
3058 * <P>Type: TEXT</P>
3059 */
3060 public static final String LANGUAGE_CODE = "language";
3061
3062 /**
3063 * Message body.
3064 * <P>Type: TEXT</P>
3065 */
3066 public static final String MESSAGE_BODY = "body";
3067
3068 /**
3069 * Message delivery time.
3070 * <P>Type: INTEGER (long)</P>
3071 */
3072 public static final String DELIVERY_TIME = "date";
3073
3074 /**
3075 * Has the message been viewed?
3076 * <P>Type: INTEGER (boolean)</P>
3077 */
3078 public static final String MESSAGE_READ = "read";
3079
3080 /**
3081 * Message format (3GPP or 3GPP2).
3082 * <P>Type: INTEGER</P>
3083 */
3084 public static final String MESSAGE_FORMAT = "format";
3085
3086 /**
3087 * Message priority (including emergency).
3088 * <P>Type: INTEGER</P>
3089 */
3090 public static final String MESSAGE_PRIORITY = "priority";
3091
3092 /**
3093 * ETWS warning type (ETWS alerts only).
3094 * <P>Type: INTEGER</P>
3095 */
3096 public static final String ETWS_WARNING_TYPE = "etws_warning_type";
3097
3098 /**
3099 * CMAS message class (CMAS alerts only).
3100 * <P>Type: INTEGER</P>
3101 */
3102 public static final String CMAS_MESSAGE_CLASS = "cmas_message_class";
3103
3104 /**
3105 * CMAS category (CMAS alerts only).
3106 * <P>Type: INTEGER</P>
3107 */
3108 public static final String CMAS_CATEGORY = "cmas_category";
3109
3110 /**
3111 * CMAS response type (CMAS alerts only).
3112 * <P>Type: INTEGER</P>
3113 */
3114 public static final String CMAS_RESPONSE_TYPE = "cmas_response_type";
3115
3116 /**
3117 * CMAS severity (CMAS alerts only).
3118 * <P>Type: INTEGER</P>
3119 */
3120 public static final String CMAS_SEVERITY = "cmas_severity";
3121
3122 /**
3123 * CMAS urgency (CMAS alerts only).
3124 * <P>Type: INTEGER</P>
3125 */
3126 public static final String CMAS_URGENCY = "cmas_urgency";
3127
3128 /**
3129 * CMAS certainty (CMAS alerts only).
3130 * <P>Type: INTEGER</P>
3131 */
3132 public static final String CMAS_CERTAINTY = "cmas_certainty";
3133
3134 /** The default sort order for this table. */
3135 public static final String DEFAULT_SORT_ORDER = DELIVERY_TIME + " DESC";
3136
3137 /**
3138 * Query columns for instantiating {@link android.telephony.CellBroadcastMessage} objects.
3139 */
3140 public static final String[] QUERY_COLUMNS = {
3141 _ID,
3142 GEOGRAPHICAL_SCOPE,
3143 PLMN,
3144 LAC,
3145 CID,
3146 SERIAL_NUMBER,
3147 SERVICE_CATEGORY,
3148 LANGUAGE_CODE,
3149 MESSAGE_BODY,
3150 DELIVERY_TIME,
3151 MESSAGE_READ,
3152 MESSAGE_FORMAT,
3153 MESSAGE_PRIORITY,
3154 ETWS_WARNING_TYPE,
3155 CMAS_MESSAGE_CLASS,
3156 CMAS_CATEGORY,
3157 CMAS_RESPONSE_TYPE,
3158 CMAS_SEVERITY,
3159 CMAS_URGENCY,
3160 CMAS_CERTAINTY
3161 };
3162 }
Jordan Liub9b75ed2017-02-28 18:15:07 -08003163
3164 /**
3165 * Constants for interfacing with the ServiceStateProvider and the different fields of the
3166 * {@link ServiceState} class accessible through the provider.
3167 */
3168 public static final class ServiceStateTable {
3169
3170 /**
3171 * Not instantiable.
3172 * @hide
3173 */
3174 private ServiceStateTable() {}
3175
3176 /**
3177 * The authority string for the ServiceStateProvider
3178 */
3179 public static final String AUTHORITY = "service-state";
3180
3181 /**
3182 * The {@code content://} style URL for the ServiceStateProvider
3183 */
3184 public static final Uri CONTENT_URI = Uri.parse("content://service-state/");
3185
3186 /**
3187 * Generates a content {@link Uri} used to receive updates on a specific field in the
3188 * ServiceState provider.
3189 * <p>
3190 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
3191 * {@link ServiceState} while your app is running. You can also use a {@link JobService} to
3192 * ensure your app is notified of changes to the {@link Uri} even when it is not running.
3193 * Note, however, that using a {@link JobService} does not guarantee timely delivery of
3194 * updates to the {@link Uri}.
3195 *
Jordan Liu0f332522017-04-19 14:25:29 -07003196 * @param subscriptionId the subscriptionId to receive updates on
Jordan Liub9b75ed2017-02-28 18:15:07 -08003197 * @param field the ServiceState field to receive updates on
3198 * @return the Uri used to observe {@link ServiceState} changes
3199 */
Jordan Liu0f332522017-04-19 14:25:29 -07003200 public static Uri getUriForSubscriptionIdAndField(int subscriptionId, String field) {
3201 return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId))
Jordan Liub9b75ed2017-02-28 18:15:07 -08003202 .appendEncodedPath(field).build();
3203 }
3204
3205 /**
3206 * Generates a content {@link Uri} used to receive updates on every field in the
3207 * ServiceState provider.
3208 * <p>
3209 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
3210 * {@link ServiceState} while your app is running. You can also use a {@link JobService} to
3211 * ensure your app is notified of changes to the {@link Uri} even when it is not running.
3212 * Note, however, that using a {@link JobService} does not guarantee timely delivery of
3213 * updates to the {@link Uri}.
3214 *
Jordan Liu0f332522017-04-19 14:25:29 -07003215 * @param subscriptionId the subscriptionId to receive updates on
Jordan Liub9b75ed2017-02-28 18:15:07 -08003216 * @return the Uri used to observe {@link ServiceState} changes
3217 */
Jordan Liu0f332522017-04-19 14:25:29 -07003218 public static Uri getUriForSubscriptionId(int subscriptionId) {
3219 return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId)).build();
Jordan Liub9b75ed2017-02-28 18:15:07 -08003220 }
3221
3222 /**
3223 * Used to insert a ServiceState into the ServiceStateProvider as a ContentValues instance.
3224 *
3225 * @param state the ServiceState to convert into ContentValues
3226 * @return the convertedContentValues instance
3227 * @hide
3228 */
3229 public static ContentValues getContentValuesForServiceState(ServiceState state) {
3230 ContentValues values = new ContentValues();
3231 values.put(VOICE_REG_STATE, state.getVoiceRegState());
3232 values.put(DATA_REG_STATE, state.getDataRegState());
3233 values.put(VOICE_ROAMING_TYPE, state.getVoiceRoamingType());
3234 values.put(DATA_ROAMING_TYPE, state.getDataRoamingType());
3235 values.put(VOICE_OPERATOR_ALPHA_LONG, state.getVoiceOperatorAlphaLong());
3236 values.put(VOICE_OPERATOR_ALPHA_SHORT, state.getVoiceOperatorAlphaShort());
3237 values.put(VOICE_OPERATOR_NUMERIC, state.getVoiceOperatorNumeric());
3238 values.put(DATA_OPERATOR_ALPHA_LONG, state.getDataOperatorAlphaLong());
3239 values.put(DATA_OPERATOR_ALPHA_SHORT, state.getDataOperatorAlphaShort());
3240 values.put(DATA_OPERATOR_NUMERIC, state.getDataOperatorNumeric());
3241 values.put(IS_MANUAL_NETWORK_SELECTION, state.getIsManualSelection());
3242 values.put(RIL_VOICE_RADIO_TECHNOLOGY, state.getRilVoiceRadioTechnology());
3243 values.put(RIL_DATA_RADIO_TECHNOLOGY, state.getRilDataRadioTechnology());
3244 values.put(CSS_INDICATOR, state.getCssIndicator());
Jack Yu2661fac2018-03-15 13:51:05 -07003245 values.put(NETWORK_ID, state.getCdmaNetworkId());
3246 values.put(SYSTEM_ID, state.getCdmaSystemId());
Jordan Liub9b75ed2017-02-28 18:15:07 -08003247 values.put(CDMA_ROAMING_INDICATOR, state.getCdmaRoamingIndicator());
3248 values.put(CDMA_DEFAULT_ROAMING_INDICATOR, state.getCdmaDefaultRoamingIndicator());
3249 values.put(CDMA_ERI_ICON_INDEX, state.getCdmaEriIconIndex());
3250 values.put(CDMA_ERI_ICON_MODE, state.getCdmaEriIconMode());
3251 values.put(IS_EMERGENCY_ONLY, state.isEmergencyOnly());
Jordan Liub9b75ed2017-02-28 18:15:07 -08003252 values.put(IS_USING_CARRIER_AGGREGATION, state.isUsingCarrierAggregation());
3253 return values;
3254 }
3255
3256 /**
3257 * An integer value indicating the current voice service state.
3258 * <p>
3259 * Valid values: {@link ServiceState#STATE_IN_SERVICE},
3260 * {@link ServiceState#STATE_OUT_OF_SERVICE}, {@link ServiceState#STATE_EMERGENCY_ONLY},
3261 * {@link ServiceState#STATE_POWER_OFF}.
3262 * <p>
3263 * This is the same as {@link ServiceState#getState()}.
3264 */
3265 public static final String VOICE_REG_STATE = "voice_reg_state";
3266
3267 /**
3268 * An integer value indicating the current data service state.
3269 * <p>
3270 * Valid values: {@link ServiceState#STATE_IN_SERVICE},
3271 * {@link ServiceState#STATE_OUT_OF_SERVICE}, {@link ServiceState#STATE_EMERGENCY_ONLY},
3272 * {@link ServiceState#STATE_POWER_OFF}.
3273 * <p>
3274 * This is the same as {@link ServiceState#getDataRegState()}.
3275 * @hide
3276 */
3277 public static final String DATA_REG_STATE = "data_reg_state";
3278
3279 /**
3280 * An integer value indicating the current voice roaming type.
3281 * <p>
3282 * This is the same as {@link ServiceState#getVoiceRoamingType()}.
3283 * @hide
3284 */
3285 public static final String VOICE_ROAMING_TYPE = "voice_roaming_type";
3286
3287 /**
3288 * An integer value indicating the current data roaming type.
3289 * <p>
3290 * This is the same as {@link ServiceState#getDataRoamingType()}.
3291 * @hide
3292 */
3293 public static final String DATA_ROAMING_TYPE = "data_roaming_type";
3294
3295 /**
3296 * The current registered voice network operator name in long alphanumeric format.
3297 * <p>
3298 * This is the same as {@link ServiceState#getVoiceOperatorAlphaLong()}.
3299 * @hide
3300 */
3301 public static final String VOICE_OPERATOR_ALPHA_LONG = "voice_operator_alpha_long";
3302
3303 /**
3304 * The current registered operator name in short alphanumeric format.
3305 * <p>
3306 * In GSM/UMTS, short format can be up to 8 characters long. The current registered voice
3307 * network operator name in long alphanumeric format.
3308 * <p>
3309 * This is the same as {@link ServiceState#getVoiceOperatorAlphaShort()}.
3310 * @hide
3311 */
3312 public static final String VOICE_OPERATOR_ALPHA_SHORT = "voice_operator_alpha_short";
3313
3314
3315 /**
3316 * The current registered operator numeric id.
3317 * <p>
3318 * In GSM/UMTS, numeric format is 3 digit country code plus 2 or 3 digit
3319 * network code.
3320 * <p>
3321 * This is the same as {@link ServiceState#getOperatorNumeric()}.
3322 */
3323 public static final String VOICE_OPERATOR_NUMERIC = "voice_operator_numeric";
3324
3325 /**
3326 * The current registered data network operator name in long alphanumeric format.
3327 * <p>
3328 * This is the same as {@link ServiceState#getDataOperatorAlphaLong()}.
3329 * @hide
3330 */
3331 public static final String DATA_OPERATOR_ALPHA_LONG = "data_operator_alpha_long";
3332
3333 /**
3334 * The current registered data network operator name in short alphanumeric format.
3335 * <p>
3336 * This is the same as {@link ServiceState#getDataOperatorAlphaShort()}.
3337 * @hide
3338 */
3339 public static final String DATA_OPERATOR_ALPHA_SHORT = "data_operator_alpha_short";
3340
3341 /**
3342 * The current registered data network operator numeric id.
3343 * <p>
3344 * This is the same as {@link ServiceState#getDataOperatorNumeric()}.
3345 * @hide
3346 */
3347 public static final String DATA_OPERATOR_NUMERIC = "data_operator_numeric";
3348
3349 /**
3350 * The current network selection mode.
3351 * <p>
3352 * This is the same as {@link ServiceState#getIsManualSelection()}.
3353 */
3354 public static final String IS_MANUAL_NETWORK_SELECTION = "is_manual_network_selection";
3355
3356 /**
3357 * This is the same as {@link ServiceState#getRilVoiceRadioTechnology()}.
3358 * @hide
3359 */
3360 public static final String RIL_VOICE_RADIO_TECHNOLOGY = "ril_voice_radio_technology";
3361
3362 /**
3363 * This is the same as {@link ServiceState#getRilDataRadioTechnology()}.
3364 * @hide
3365 */
3366 public static final String RIL_DATA_RADIO_TECHNOLOGY = "ril_data_radio_technology";
3367
3368 /**
3369 * This is the same as {@link ServiceState#getCssIndicator()}.
3370 * @hide
3371 */
3372 public static final String CSS_INDICATOR = "css_indicator";
3373
3374 /**
Jack Yu2661fac2018-03-15 13:51:05 -07003375 * This is the same as {@link ServiceState#getCdmaNetworkId()}.
Jordan Liub9b75ed2017-02-28 18:15:07 -08003376 * @hide
3377 */
3378 public static final String NETWORK_ID = "network_id";
3379
3380 /**
Jack Yu2661fac2018-03-15 13:51:05 -07003381 * This is the same as {@link ServiceState#getCdmaSystemId()}.
Jordan Liub9b75ed2017-02-28 18:15:07 -08003382 * @hide
3383 */
3384 public static final String SYSTEM_ID = "system_id";
3385
3386 /**
3387 * This is the same as {@link ServiceState#getCdmaRoamingIndicator()}.
3388 * @hide
3389 */
3390 public static final String CDMA_ROAMING_INDICATOR = "cdma_roaming_indicator";
3391
3392 /**
3393 * This is the same as {@link ServiceState#getCdmaDefaultRoamingIndicator()}.
3394 * @hide
3395 */
3396 public static final String CDMA_DEFAULT_ROAMING_INDICATOR =
3397 "cdma_default_roaming_indicator";
3398
3399 /**
3400 * This is the same as {@link ServiceState#getCdmaEriIconIndex()}.
3401 * @hide
3402 */
3403 public static final String CDMA_ERI_ICON_INDEX = "cdma_eri_icon_index";
3404
3405 /**
3406 * This is the same as {@link ServiceState#getCdmaEriIconMode()}.
3407 * @hide
3408 */
3409 public static final String CDMA_ERI_ICON_MODE = "cdma_eri_icon_mode";
3410
3411 /**
3412 * This is the same as {@link ServiceState#isEmergencyOnly()}.
3413 * @hide
3414 */
3415 public static final String IS_EMERGENCY_ONLY = "is_emergency_only";
3416
3417 /**
3418 * This is the same as {@link ServiceState#getDataRoamingFromRegistration()}.
3419 * @hide
3420 */
3421 public static final String IS_DATA_ROAMING_FROM_REGISTRATION =
3422 "is_data_roaming_from_registration";
3423
3424 /**
3425 * This is the same as {@link ServiceState#isUsingCarrierAggregation()}.
3426 * @hide
3427 */
3428 public static final String IS_USING_CARRIER_AGGREGATION = "is_using_carrier_aggregation";
3429 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07003430
3431 /**
fionaxu58278be2018-01-29 14:08:12 -08003432 * Contains carrier identification information for the current subscriptions.
3433 * @see SubscriptionManager#getActiveSubscriptionIdList()
fionaxu3d0ad1f2017-10-25 23:09:36 -07003434 */
fionaxu62bc7472018-02-28 11:18:45 -08003435 public static final class CarrierId implements BaseColumns {
fionaxu3d0ad1f2017-10-25 23:09:36 -07003436 /**
fionaxu58278be2018-01-29 14:08:12 -08003437 * Not instantiable.
3438 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07003439 */
fionaxu62bc7472018-02-28 11:18:45 -08003440 private CarrierId() {}
fionaxu3d0ad1f2017-10-25 23:09:36 -07003441
3442 /**
fionaxu58278be2018-01-29 14:08:12 -08003443 * The {@code content://} style URI for this provider.
fionaxu3d0ad1f2017-10-25 23:09:36 -07003444 */
fionaxu62bc7472018-02-28 11:18:45 -08003445 public static final Uri CONTENT_URI = Uri.parse("content://carrier_id");
fionaxu3d0ad1f2017-10-25 23:09:36 -07003446
3447 /**
fionaxu62bc7472018-02-28 11:18:45 -08003448 * The authority string for the CarrierId Provider
fionaxu58278be2018-01-29 14:08:12 -08003449 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07003450 */
fionaxu62bc7472018-02-28 11:18:45 -08003451 public static final String AUTHORITY = "carrier_id";
fionaxu58278be2018-01-29 14:08:12 -08003452
fionaxu3d0ad1f2017-10-25 23:09:36 -07003453
3454 /**
fionaxu58278be2018-01-29 14:08:12 -08003455 * Generates a content {@link Uri} used to receive updates on carrier identity change
3456 * on the given subscriptionId
3457 * <p>
3458 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
fionaxuc8d483e2018-03-07 21:52:05 -08003459 * carrier identity {@link TelephonyManager#getSimCarrierId()}
fionaxu58278be2018-01-29 14:08:12 -08003460 * while your app is running. You can also use a {@link JobService} to ensure your app
3461 * is notified of changes to the {@link Uri} even when it is not running.
3462 * Note, however, that using a {@link JobService} does not guarantee timely delivery of
3463 * updates to the {@link Uri}.
3464 *
3465 * @param subscriptionId the subscriptionId to receive updates on
3466 * @return the Uri used to observe carrier identity changes
fionaxu3d0ad1f2017-10-25 23:09:36 -07003467 */
fionaxu58278be2018-01-29 14:08:12 -08003468 public static Uri getUriForSubscriptionId(int subscriptionId) {
3469 return CONTENT_URI.buildUpon().appendEncodedPath(
3470 String.valueOf(subscriptionId)).build();
3471 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07003472
3473 /**
fionaxu58278be2018-01-29 14:08:12 -08003474 * A user facing carrier name.
fionaxuc8d483e2018-03-07 21:52:05 -08003475 * @see TelephonyManager#getSimCarrierIdName()
fionaxu3d0ad1f2017-10-25 23:09:36 -07003476 * <P>Type: TEXT </P>
3477 */
fionaxu62bc7472018-02-28 11:18:45 -08003478 public static final String CARRIER_NAME = "carrier_name";
fionaxu3d0ad1f2017-10-25 23:09:36 -07003479
3480 /**
3481 * A unique carrier id
fionaxuc8d483e2018-03-07 21:52:05 -08003482 * @see TelephonyManager#getSimCarrierId()
fionaxu3d0ad1f2017-10-25 23:09:36 -07003483 * <P>Type: INTEGER </P>
3484 */
fionaxu62bc7472018-02-28 11:18:45 -08003485 public static final String CARRIER_ID = "carrier_id";
fionaxu3d0ad1f2017-10-25 23:09:36 -07003486
3487 /**
fionaxu58278be2018-01-29 14:08:12 -08003488 * Contains mappings between matching rules with carrier id for all carriers.
3489 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07003490 */
fionaxu58278be2018-01-29 14:08:12 -08003491 public static final class All implements BaseColumns {
3492 /**
3493 * Numeric operator ID (as String). {@code MCC + MNC}
3494 * <P>Type: TEXT </P>
3495 */
3496 public static final String MCCMNC = "mccmnc";
3497
3498 /**
3499 * Group id level 1 (as String).
3500 * <P>Type: TEXT </P>
3501 */
3502 public static final String GID1 = "gid1";
3503
3504 /**
3505 * Group id level 2 (as String).
3506 * <P>Type: TEXT </P>
3507 */
3508 public static final String GID2 = "gid2";
3509
3510 /**
3511 * Public Land Mobile Network name.
3512 * <P>Type: TEXT </P>
3513 */
3514 public static final String PLMN = "plmn";
3515
3516 /**
3517 * Prefix xpattern of IMSI (International Mobile Subscriber Identity).
3518 * <P>Type: TEXT </P>
3519 */
3520 public static final String IMSI_PREFIX_XPATTERN = "imsi_prefix_xpattern";
3521
3522 /**
3523 * Service Provider Name.
3524 * <P>Type: TEXT </P>
3525 */
3526 public static final String SPN = "spn";
3527
3528 /**
3529 * Prefer APN name.
3530 * <P>Type: TEXT </P>
3531 */
3532 public static final String APN = "apn";
3533
3534 /**
3535 * Prefix of Integrated Circuit Card Identifier.
3536 * <P>Type: TEXT </P>
3537 */
3538 public static final String ICCID_PREFIX = "iccid_prefix";
3539
3540 /**
3541 * The {@code content://} URI for this table.
3542 */
fionaxu62bc7472018-02-28 11:18:45 -08003543 public static final Uri CONTENT_URI = Uri.parse("content://carrier_id/all");
fionaxu58278be2018-01-29 14:08:12 -08003544 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07003545 }
Dan Willemsen4980bf42017-02-14 14:17:12 -08003546}