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