blob: 087937d5ade2a658970fe191016d11f6a60956bb [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
Chen Xudd0c1c32019-10-21 22:47:27 -070019import android.Manifest;
chen xu5caa18c2018-11-28 00:21:50 -080020import android.annotation.IntDef;
chen xu81653862019-02-28 10:44:54 -080021import android.annotation.NonNull;
Jayachandran C349b9ba2018-10-30 15:09:06 -070022import android.annotation.RequiresPermission;
Dan Willemsen4980bf42017-02-14 14:17:12 -080023import android.annotation.SdkConstant;
24import android.annotation.SdkConstant.SdkConstantType;
chen xu85100482018-10-12 15:30:34 -070025import android.annotation.SystemApi;
Dan Willemsen4980bf42017-02-14 14:17:12 -080026import android.annotation.TestApi;
Mathew Inwood6750f2e2018-08-10 09:29:25 +010027import android.annotation.UnsupportedAppUsage;
Jordan Liub9b75ed2017-02-28 18:15:07 -080028import android.app.job.JobService;
Dan Willemsen4980bf42017-02-14 14:17:12 -080029import android.content.ComponentName;
30import android.content.ContentResolver;
31import android.content.ContentValues;
32import android.content.Context;
33import android.content.Intent;
Jordan Liub9b75ed2017-02-28 18:15:07 -080034import android.database.ContentObserver;
Aurimas Liutikas7f695332018-05-31 21:07:32 -070035import android.database.Cursor;
Dan Willemsen4980bf42017-02-14 14:17:12 -080036import android.database.sqlite.SqliteWrapper;
37import android.net.Uri;
Mathew Inwood8c854f82018-09-14 12:35:36 +010038import android.os.Build;
Jack Yu2e273b22019-04-02 10:49:35 -070039import android.os.Parcel;
Jordan Liub9b75ed2017-02-28 18:15:07 -080040import android.telephony.Rlog;
41import android.telephony.ServiceState;
Dan Willemsen4980bf42017-02-14 14:17:12 -080042import android.telephony.SmsMessage;
43import android.telephony.SubscriptionManager;
fionaxu58278be2018-01-29 14:08:12 -080044import android.telephony.TelephonyManager;
Dan Willemsen4980bf42017-02-14 14:17:12 -080045import android.text.TextUtils;
Dan Willemsen4980bf42017-02-14 14:17:12 -080046import android.util.Patterns;
47
48import com.android.internal.telephony.PhoneConstants;
49import com.android.internal.telephony.SmsApplication;
50
chen xu5caa18c2018-11-28 00:21:50 -080051import java.lang.annotation.Retention;
52import java.lang.annotation.RetentionPolicy;
Dan Willemsen4980bf42017-02-14 14:17:12 -080053import java.util.HashSet;
54import java.util.Set;
55import java.util.regex.Matcher;
56import java.util.regex.Pattern;
57
58/**
59 * The Telephony provider contains data related to phone operation, specifically SMS and MMS
Jordan Liub9b75ed2017-02-28 18:15:07 -080060 * messages, access to the APN list, including the MMSC to use, and the service state.
Dan Willemsen4980bf42017-02-14 14:17:12 -080061 *
62 * <p class="note"><strong>Note:</strong> These APIs are not available on all Android-powered
63 * devices. If your app depends on telephony features such as for managing SMS messages, include
64 * a <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code <uses-feature>}
65 * </a> element in your manifest that declares the {@code "android.hardware.telephony"} hardware
66 * feature. Alternatively, you can check for telephony availability at runtime using either
67 * {@link android.content.pm.PackageManager#hasSystemFeature
68 * hasSystemFeature(PackageManager.FEATURE_TELEPHONY)} or {@link
69 * android.telephony.TelephonyManager#getPhoneType}.</p>
70 *
71 * <h3>Creating an SMS app</h3>
72 *
73 * <p>Only the default SMS app (selected by the user in system settings) is able to write to the
74 * SMS Provider (the tables defined within the {@code Telephony} class) and only the default SMS
75 * app receives the {@link android.provider.Telephony.Sms.Intents#SMS_DELIVER_ACTION} broadcast
76 * when the user receives an SMS or the {@link
77 * android.provider.Telephony.Sms.Intents#WAP_PUSH_DELIVER_ACTION} broadcast when the user
78 * receives an MMS.</p>
79 *
80 * <p>Any app that wants to behave as the user's default SMS app must handle the following intents:
81 * <ul>
82 * <li>In a broadcast receiver, include an intent filter for {@link Sms.Intents#SMS_DELIVER_ACTION}
83 * (<code>"android.provider.Telephony.SMS_DELIVER"</code>). The broadcast receiver must also
84 * require the {@link android.Manifest.permission#BROADCAST_SMS} permission.
85 * <p>This allows your app to directly receive incoming SMS messages.</p></li>
86 * <li>In a broadcast receiver, include an intent filter for {@link
87 * Sms.Intents#WAP_PUSH_DELIVER_ACTION}} ({@code "android.provider.Telephony.WAP_PUSH_DELIVER"})
88 * with the MIME type <code>"application/vnd.wap.mms-message"</code>.
89 * The broadcast receiver must also require the {@link
90 * android.Manifest.permission#BROADCAST_WAP_PUSH} permission.
91 * <p>This allows your app to directly receive incoming MMS messages.</p></li>
92 * <li>In your activity that delivers new messages, include an intent filter for
93 * {@link android.content.Intent#ACTION_SENDTO} (<code>"android.intent.action.SENDTO"
94 * </code>) with schemas, <code>sms:</code>, <code>smsto:</code>, <code>mms:</code>, and
95 * <code>mmsto:</code>.
96 * <p>This allows your app to receive intents from other apps that want to deliver a
97 * message.</p></li>
98 * <li>In a service, include an intent filter for {@link
99 * android.telephony.TelephonyManager#ACTION_RESPOND_VIA_MESSAGE}
100 * (<code>"android.intent.action.RESPOND_VIA_MESSAGE"</code>) with schemas,
101 * <code>sms:</code>, <code>smsto:</code>, <code>mms:</code>, and <code>mmsto:</code>.
102 * This service must also require the {@link
103 * android.Manifest.permission#SEND_RESPOND_VIA_MESSAGE} permission.
104 * <p>This allows users to respond to incoming phone calls with an immediate text message
105 * using your app.</p></li>
106 * </ul>
107 *
108 * <p>Other apps that are not selected as the default SMS app can only <em>read</em> the SMS
109 * Provider, but may also be notified when a new SMS arrives by listening for the {@link
110 * Sms.Intents#SMS_RECEIVED_ACTION}
111 * broadcast, which is a non-abortable broadcast that may be delivered to multiple apps. This
112 * broadcast is intended for apps that&mdash;while not selected as the default SMS app&mdash;need to
113 * read special incoming messages such as to perform phone number verification.</p>
114 *
115 * <p>For more information about building SMS apps, read the blog post, <a
116 * href="http://android-developers.blogspot.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html"
117 * >Getting Your SMS Apps Ready for KitKat</a>.</p>
118 *
119 */
120public final class Telephony {
121 private static final String TAG = "Telephony";
122
123 /**
124 * Not instantiable.
125 * @hide
126 */
127 private Telephony() {
128 }
129
130 /**
131 * Base columns for tables that contain text-based SMSs.
132 */
133 public interface TextBasedSmsColumns {
134
135 /** Message type: all messages. */
136 public static final int MESSAGE_TYPE_ALL = 0;
137
138 /** Message type: inbox. */
139 public static final int MESSAGE_TYPE_INBOX = 1;
140
141 /** Message type: sent messages. */
142 public static final int MESSAGE_TYPE_SENT = 2;
143
144 /** Message type: drafts. */
145 public static final int MESSAGE_TYPE_DRAFT = 3;
146
147 /** Message type: outbox. */
148 public static final int MESSAGE_TYPE_OUTBOX = 4;
149
150 /** Message type: failed outgoing message. */
151 public static final int MESSAGE_TYPE_FAILED = 5;
152
153 /** Message type: queued to send later. */
154 public static final int MESSAGE_TYPE_QUEUED = 6;
155
156 /**
157 * The type of message.
158 * <P>Type: INTEGER</P>
159 */
160 public static final String TYPE = "type";
161
162 /**
163 * The thread ID of the message.
164 * <P>Type: INTEGER</P>
165 */
166 public static final String THREAD_ID = "thread_id";
167
168 /**
169 * The address of the other party.
170 * <P>Type: TEXT</P>
171 */
172 public static final String ADDRESS = "address";
173
174 /**
175 * The date the message was received.
176 * <P>Type: INTEGER (long)</P>
177 */
178 public static final String DATE = "date";
179
180 /**
181 * The date the message was sent.
182 * <P>Type: INTEGER (long)</P>
183 */
184 public static final String DATE_SENT = "date_sent";
185
186 /**
187 * Has the message been read?
188 * <P>Type: INTEGER (boolean)</P>
189 */
190 public static final String READ = "read";
191
192 /**
193 * Has the message been seen by the user? The "seen" flag determines
194 * whether we need to show a notification.
195 * <P>Type: INTEGER (boolean)</P>
196 */
197 public static final String SEEN = "seen";
198
199 /**
200 * {@code TP-Status} value for the message, or -1 if no status has been received.
201 * <P>Type: INTEGER</P>
202 */
203 public static final String STATUS = "status";
204
205 /** TP-Status: no status received. */
206 public static final int STATUS_NONE = -1;
207 /** TP-Status: complete. */
208 public static final int STATUS_COMPLETE = 0;
209 /** TP-Status: pending. */
210 public static final int STATUS_PENDING = 32;
211 /** TP-Status: failed. */
212 public static final int STATUS_FAILED = 64;
213
214 /**
215 * The subject of the message, if present.
216 * <P>Type: TEXT</P>
217 */
218 public static final String SUBJECT = "subject";
219
220 /**
221 * The body of the message.
222 * <P>Type: TEXT</P>
223 */
224 public static final String BODY = "body";
225
226 /**
227 * The ID of the sender of the conversation, if present.
228 * <P>Type: INTEGER (reference to item in {@code content://contacts/people})</P>
229 */
230 public static final String PERSON = "person";
231
232 /**
233 * The protocol identifier code.
234 * <P>Type: INTEGER</P>
235 */
236 public static final String PROTOCOL = "protocol";
237
238 /**
239 * Is the {@code TP-Reply-Path} flag set?
240 * <P>Type: BOOLEAN</P>
241 */
242 public static final String REPLY_PATH_PRESENT = "reply_path_present";
243
244 /**
245 * The service center (SC) through which to send the message, if present.
246 * <P>Type: TEXT</P>
247 */
248 public static final String SERVICE_CENTER = "service_center";
249
250 /**
251 * Is the message locked?
252 * <P>Type: INTEGER (boolean)</P>
253 */
254 public static final String LOCKED = "locked";
255
256 /**
257 * The subscription to which the message belongs to. Its value will be
258 * < 0 if the sub id cannot be determined.
259 * <p>Type: INTEGER (long) </p>
260 */
261 public static final String SUBSCRIPTION_ID = "sub_id";
262
263 /**
264 * The MTU size of the mobile interface to which the APN connected
265 * @hide
266 */
267 public static final String MTU = "mtu";
268
269 /**
270 * Error code associated with sending or receiving this message
271 * <P>Type: INTEGER</P>
272 */
273 public static final String ERROR_CODE = "error_code";
274
275 /**
276 * The identity of the sender of a sent message. It is
277 * usually the package name of the app which sends the message.
278 * <p class="note"><strong>Note:</strong>
279 * This column is read-only. It is set by the provider and can not be changed by apps.
280 * <p>Type: TEXT</p>
281 */
282 public static final String CREATOR = "creator";
283 }
284
285 /**
Vasu Nori84db0f52018-02-14 15:14:32 -0800286 * Columns in sms_changes table.
287 * @hide
288 */
289 public interface TextBasedSmsChangesColumns {
290 /**
291 * The {@code content://} style URL for this table.
292 * @hide
293 */
294 public static final Uri CONTENT_URI = Uri.parse("content://sms-changes");
295
296 /**
297 * Primary key.
298 * <P>Type: INTEGER (long)</P>
299 * @hide
300 */
301 public static final String ID = "_id";
302
303 /**
304 * Triggers on sms table create a row in this table for each update/delete.
305 * This column is the "_id" of the row from sms table that was updated/deleted.
306 * <P>Type: INTEGER (long)</P>
307 * @hide
308 */
309 public static final String ORIG_ROW_ID = "orig_rowid";
310
311 /**
312 * Triggers on sms table create a row in this table for each update/delete.
313 * This column is the "sub_id" of the row from sms table that was updated/deleted.
314 * @hide
315 * <P>Type: INTEGER (long)</P>
316 */
317 public static final String SUB_ID = "sub_id";
318
319 /**
320 * The type of operation that created this row.
321 * {@link #TYPE_UPDATE} = update op
322 * {@link #TYPE_DELETE} = delete op
323 * @hide
324 * <P>Type: INTEGER (long)</P>
325 */
326 public static final String TYPE = "type";
327
328 /**
329 * One of the possible values for the above column "type". Indicates it is an update op.
330 * @hide
331 */
332 public static final int TYPE_UPDATE = 0;
333
334 /**
335 * One of the possible values for the above column "type". Indicates it is a delete op.
336 * @hide
337 */
338 public static final int TYPE_DELETE = 1;
339
340 /**
341 * This column contains a non-null value only if the operation on sms table is an update op
342 * and the column "read" is changed by the update op.
343 * <P>Type: INTEGER (boolean)</P>
344 * @hide
345 */
346 public static final String NEW_READ_STATUS = "new_read_status";
347 }
348
349 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -0800350 * Contains all text-based SMS messages.
351 */
352 public static final class Sms implements BaseColumns, TextBasedSmsColumns {
353
354 /**
355 * Not instantiable.
356 * @hide
357 */
358 private Sms() {
359 }
360
361 /**
362 * Used to determine the currently configured default SMS package.
363 * @param context context of the requesting application
364 * @return package name for the default SMS package or null
365 */
366 public static String getDefaultSmsPackage(Context context) {
367 ComponentName component = SmsApplication.getDefaultSmsApplication(context, false);
368 if (component != null) {
369 return component.getPackageName();
370 }
371 return null;
372 }
373
374 /**
375 * Return cursor for table query.
376 * @hide
377 */
378 public static Cursor query(ContentResolver cr, String[] projection) {
379 return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
380 }
381
382 /**
383 * Return cursor for table query.
384 * @hide
385 */
Mathew Inwood8c854f82018-09-14 12:35:36 +0100386 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
Dan Willemsen4980bf42017-02-14 14:17:12 -0800387 public static Cursor query(ContentResolver cr, String[] projection,
388 String where, String orderBy) {
389 return cr.query(CONTENT_URI, projection, where,
390 null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
391 }
392
393 /**
394 * The {@code content://} style URL for this table.
395 */
396 public static final Uri CONTENT_URI = Uri.parse("content://sms");
397
398 /**
399 * The default sort order for this table.
400 */
401 public static final String DEFAULT_SORT_ORDER = "date DESC";
402
403 /**
404 * Add an SMS to the given URI.
405 *
406 * @param resolver the content resolver to use
407 * @param uri the URI to add the message to
408 * @param address the address of the sender
409 * @param body the body of the message
410 * @param subject the pseudo-subject of the message
411 * @param date the timestamp for the message
412 * @param read true if the message has been read, false if not
413 * @param deliveryReport true if a delivery report was requested, false if not
414 * @return the URI for the new message
415 * @hide
416 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100417 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800418 public static Uri addMessageToUri(ContentResolver resolver,
419 Uri uri, String address, String body, String subject,
420 Long date, boolean read, boolean deliveryReport) {
421 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
422 resolver, uri, address, body, subject, date, read, deliveryReport, -1L);
423 }
424
425 /**
426 * Add an SMS to the given URI.
427 *
428 * @param resolver the content resolver to use
429 * @param uri the URI to add the message to
430 * @param address the address of the sender
431 * @param body the body of the message
432 * @param subject the psuedo-subject of the message
433 * @param date the timestamp for the message
434 * @param read true if the message has been read, false if not
435 * @param deliveryReport true if a delivery report was requested, false if not
436 * @param subId the subscription which the message belongs to
437 * @return the URI for the new message
438 * @hide
439 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100440 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800441 public static Uri addMessageToUri(int subId, ContentResolver resolver,
442 Uri uri, String address, String body, String subject,
443 Long date, boolean read, boolean deliveryReport) {
444 return addMessageToUri(subId, resolver, uri, address, body, subject,
445 date, read, deliveryReport, -1L);
446 }
447
448 /**
449 * Add an SMS to the given URI with the specified thread ID.
450 *
451 * @param resolver the content resolver to use
452 * @param uri the URI to add the message to
453 * @param address the address of the sender
454 * @param body the body of the message
455 * @param subject the pseudo-subject of the message
456 * @param date the timestamp for the message
457 * @param read true if the message has been read, false if not
458 * @param deliveryReport true if a delivery report was requested, false if not
459 * @param threadId the thread_id of the message
460 * @return the URI for the new message
461 * @hide
462 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100463 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800464 public static Uri addMessageToUri(ContentResolver resolver,
465 Uri uri, String address, String body, String subject,
466 Long date, boolean read, boolean deliveryReport, long threadId) {
467 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
468 resolver, uri, address, body, subject,
469 date, read, deliveryReport, threadId);
470 }
471
472 /**
473 * Add an SMS to the given URI with thread_id specified.
474 *
475 * @param resolver the content resolver to use
476 * @param uri the URI to add the message to
477 * @param address the address of the sender
478 * @param body the body of the message
479 * @param subject the psuedo-subject of the message
480 * @param date the timestamp for the message
481 * @param read true if the message has been read, false if not
482 * @param deliveryReport true if a delivery report was requested, false if not
483 * @param threadId the thread_id of the message
484 * @param subId the subscription which the message belongs to
485 * @return the URI for the new message
486 * @hide
487 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100488 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800489 public static Uri addMessageToUri(int subId, ContentResolver resolver,
490 Uri uri, String address, String body, String subject,
491 Long date, boolean read, boolean deliveryReport, long threadId) {
492 ContentValues values = new ContentValues(8);
493 Rlog.v(TAG,"Telephony addMessageToUri sub id: " + subId);
494
495 values.put(SUBSCRIPTION_ID, subId);
496 values.put(ADDRESS, address);
497 if (date != null) {
498 values.put(DATE, date);
499 }
500 values.put(READ, read ? Integer.valueOf(1) : Integer.valueOf(0));
501 values.put(SUBJECT, subject);
502 values.put(BODY, body);
503 if (deliveryReport) {
504 values.put(STATUS, STATUS_PENDING);
505 }
506 if (threadId != -1L) {
507 values.put(THREAD_ID, threadId);
508 }
509 return resolver.insert(uri, values);
510 }
511
512 /**
513 * Move a message to the given folder.
514 *
515 * @param context the context to use
516 * @param uri the message to move
517 * @param folder the folder to move to
518 * @return true if the operation succeeded
519 * @hide
520 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100521 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800522 public static boolean moveMessageToFolder(Context context,
523 Uri uri, int folder, int error) {
524 if (uri == null) {
525 return false;
526 }
527
528 boolean markAsUnread = false;
529 boolean markAsRead = false;
530 switch(folder) {
531 case MESSAGE_TYPE_INBOX:
532 case MESSAGE_TYPE_DRAFT:
533 break;
534 case MESSAGE_TYPE_OUTBOX:
535 case MESSAGE_TYPE_SENT:
536 markAsRead = true;
537 break;
538 case MESSAGE_TYPE_FAILED:
539 case MESSAGE_TYPE_QUEUED:
540 markAsUnread = true;
541 break;
542 default:
543 return false;
544 }
545
546 ContentValues values = new ContentValues(3);
547
548 values.put(TYPE, folder);
549 if (markAsUnread) {
550 values.put(READ, 0);
551 } else if (markAsRead) {
552 values.put(READ, 1);
553 }
554 values.put(ERROR_CODE, error);
555
556 return 1 == SqliteWrapper.update(context, context.getContentResolver(),
557 uri, values, null, null);
558 }
559
560 /**
561 * Returns true iff the folder (message type) identifies an
562 * outgoing message.
563 * @hide
564 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100565 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800566 public static boolean isOutgoingFolder(int messageType) {
567 return (messageType == MESSAGE_TYPE_FAILED)
568 || (messageType == MESSAGE_TYPE_OUTBOX)
569 || (messageType == MESSAGE_TYPE_SENT)
570 || (messageType == MESSAGE_TYPE_QUEUED);
571 }
572
573 /**
574 * Contains all text-based SMS messages in the SMS app inbox.
575 */
576 public static final class Inbox implements BaseColumns, TextBasedSmsColumns {
577
578 /**
579 * Not instantiable.
580 * @hide
581 */
582 private Inbox() {
583 }
584
585 /**
586 * The {@code content://} style URL for this table.
587 */
588 public static final Uri CONTENT_URI = Uri.parse("content://sms/inbox");
589
590 /**
591 * The default sort order for this table.
592 */
593 public static final String DEFAULT_SORT_ORDER = "date DESC";
594
595 /**
596 * Add an SMS to the Draft box.
597 *
598 * @param resolver the content resolver to use
599 * @param address the address of the sender
600 * @param body the body of the message
601 * @param subject the pseudo-subject of the message
602 * @param date the timestamp for the message
603 * @param read true if the message has been read, false if not
604 * @return the URI for the new message
605 * @hide
606 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100607 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800608 public static Uri addMessage(ContentResolver resolver,
609 String address, String body, String subject, Long date,
610 boolean read) {
611 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
612 resolver, CONTENT_URI, address, body, subject, date, read, false);
613 }
614
615 /**
616 * Add an SMS to the Draft box.
617 *
618 * @param resolver the content resolver to use
619 * @param address the address of the sender
620 * @param body the body of the message
621 * @param subject the psuedo-subject of the message
622 * @param date the timestamp for the message
623 * @param read true if the message has been read, false if not
624 * @param subId the subscription which the message belongs to
625 * @return the URI for the new message
626 * @hide
627 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100628 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800629 public static Uri addMessage(int subId, ContentResolver resolver,
630 String address, String body, String subject, Long date, boolean read) {
631 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
632 subject, date, read, false);
633 }
634 }
635
636 /**
637 * Contains all sent text-based SMS messages in the SMS app.
638 */
639 public static final class Sent implements BaseColumns, TextBasedSmsColumns {
640
641 /**
642 * Not instantiable.
643 * @hide
644 */
645 private Sent() {
646 }
647
648 /**
649 * The {@code content://} style URL for this table.
650 */
651 public static final Uri CONTENT_URI = Uri.parse("content://sms/sent");
652
653 /**
654 * The default sort order for this table.
655 */
656 public static final String DEFAULT_SORT_ORDER = "date DESC";
657
658 /**
659 * Add an SMS to the Draft box.
660 *
661 * @param resolver the content resolver to use
662 * @param address the address of the sender
663 * @param body the body of the message
664 * @param subject the pseudo-subject of the message
665 * @param date the timestamp for the message
666 * @return the URI for the new message
667 * @hide
668 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100669 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800670 public static Uri addMessage(ContentResolver resolver,
671 String address, String body, String subject, Long date) {
672 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
673 resolver, CONTENT_URI, address, body, subject, date, true, false);
674 }
675
676 /**
677 * Add an SMS to the Draft box.
678 *
679 * @param resolver the content resolver to use
680 * @param address the address of the sender
681 * @param body the body of the message
682 * @param subject the psuedo-subject of the message
683 * @param date the timestamp for the message
684 * @param subId the subscription which the message belongs to
685 * @return the URI for the new message
686 * @hide
687 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100688 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800689 public static Uri addMessage(int subId, ContentResolver resolver,
690 String address, String body, String subject, Long date) {
691 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
692 subject, date, true, false);
693 }
694 }
695
696 /**
Leland Miller86272562019-08-08 10:16:31 -0700697 * Contains all draft text-based SMS messages in the SMS app.
Dan Willemsen4980bf42017-02-14 14:17:12 -0800698 */
699 public static final class Draft implements BaseColumns, TextBasedSmsColumns {
700
701 /**
702 * Not instantiable.
703 * @hide
704 */
705 private Draft() {
706 }
707
708 /**
709 * The {@code content://} style URL for this table.
710 */
711 public static final Uri CONTENT_URI = Uri.parse("content://sms/draft");
712
713 /**
714 * @hide
715 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100716 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800717 public static Uri addMessage(ContentResolver resolver,
718 String address, String body, String subject, Long date) {
719 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
720 resolver, CONTENT_URI, address, body, subject, date, true, false);
721 }
722
723 /**
724 * Add an SMS to the Draft box.
725 *
726 * @param resolver the content resolver to use
727 * @param address the address of the sender
728 * @param body the body of the message
729 * @param subject the psuedo-subject of the message
730 * @param date the timestamp for the message
731 * @param subId the subscription which the message belongs to
732 * @return the URI for the new message
733 * @hide
734 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100735 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800736 public static Uri addMessage(int subId, ContentResolver resolver,
737 String address, String body, String subject, Long date) {
738 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
739 subject, date, true, false);
740 }
741
742 /**
743 * The default sort order for this table.
744 */
745 public static final String DEFAULT_SORT_ORDER = "date DESC";
746 }
747
748 /**
749 * Contains all pending outgoing text-based SMS messages.
750 */
751 public static final class Outbox implements BaseColumns, TextBasedSmsColumns {
752
753 /**
754 * Not instantiable.
755 * @hide
756 */
757 private Outbox() {
758 }
759
760 /**
761 * The {@code content://} style URL for this table.
762 */
763 public static final Uri CONTENT_URI = Uri.parse("content://sms/outbox");
764
765 /**
766 * The default sort order for this table.
767 */
768 public static final String DEFAULT_SORT_ORDER = "date DESC";
769
770 /**
771 * Add an SMS to the outbox.
772 *
773 * @param resolver the content resolver to use
774 * @param address the address of the sender
775 * @param body the body of the message
776 * @param subject the pseudo-subject of the message
777 * @param date the timestamp for the message
778 * @param deliveryReport whether a delivery report was requested for the message
779 * @return the URI for the new message
780 * @hide
781 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100782 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -0800783 public static Uri addMessage(ContentResolver resolver,
784 String address, String body, String subject, Long date,
785 boolean deliveryReport, long threadId) {
786 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(),
787 resolver, CONTENT_URI, address, body, subject, date,
788 true, deliveryReport, threadId);
789 }
790
791 /**
792 * Add an SMS to the Out box.
793 *
794 * @param resolver the content resolver to use
795 * @param address the address of the sender
796 * @param body the body of the message
797 * @param subject the psuedo-subject of the message
798 * @param date the timestamp for the message
799 * @param deliveryReport whether a delivery report was requested for the message
800 * @param subId the subscription which the message belongs to
801 * @return the URI for the new message
802 * @hide
803 */
804 public static Uri addMessage(int subId, ContentResolver resolver,
805 String address, String body, String subject, Long date,
806 boolean deliveryReport, long threadId) {
807 return addMessageToUri(subId, resolver, CONTENT_URI, address, body,
808 subject, date, true, deliveryReport, threadId);
809 }
810 }
811
812 /**
Leland Miller86272562019-08-08 10:16:31 -0700813 * Contains a view of SMS conversations (also referred to as threads). This is similar to
814 * {@link Threads}, but only includes SMS messages and columns relevant to SMS
815 * conversations.
816 * <p>
817 * Note that this view ignores any information about MMS messages, it is a
818 * view of conversations as if MMS messages did not exist at all. This means that all
819 * relevant information, such as snippets and message count, will ignore any MMS messages
820 * that might be in the same thread through other views and present only data based on the
821 * SMS messages in that thread.
Dan Willemsen4980bf42017-02-14 14:17:12 -0800822 */
823 public static final class Conversations
824 implements BaseColumns, TextBasedSmsColumns {
825
826 /**
827 * Not instantiable.
828 * @hide
829 */
830 private Conversations() {
831 }
832
833 /**
834 * The {@code content://} style URL for this table.
835 */
836 public static final Uri CONTENT_URI = Uri.parse("content://sms/conversations");
837
838 /**
839 * The default sort order for this table.
840 */
841 public static final String DEFAULT_SORT_ORDER = "date DESC";
842
843 /**
Gowroji Sunil37ffaec2019-04-24 12:16:13 +0530844 * The first 45 characters of the body of the most recent message.
Dan Willemsen4980bf42017-02-14 14:17:12 -0800845 * <P>Type: TEXT</P>
846 */
847 public static final String SNIPPET = "snippet";
848
849 /**
850 * The number of messages in the conversation.
851 * <P>Type: INTEGER</P>
852 */
853 public static final String MESSAGE_COUNT = "msg_count";
854 }
855
856 /**
857 * Contains constants for SMS related Intents that are broadcast.
858 */
859 public static final class Intents {
860
861 /**
862 * Not instantiable.
863 * @hide
864 */
865 private Intents() {
866 }
867
868 /**
869 * Set by BroadcastReceiver to indicate that the message was handled
870 * successfully.
871 */
872 public static final int RESULT_SMS_HANDLED = 1;
873
874 /**
875 * Set by BroadcastReceiver to indicate a generic error while
876 * processing the message.
877 */
878 public static final int RESULT_SMS_GENERIC_ERROR = 2;
879
880 /**
881 * Set by BroadcastReceiver to indicate insufficient memory to store
882 * the message.
883 */
884 public static final int RESULT_SMS_OUT_OF_MEMORY = 3;
885
886 /**
887 * Set by BroadcastReceiver to indicate that the message, while
888 * possibly valid, is of a format or encoding that is not
889 * supported.
890 */
891 public static final int RESULT_SMS_UNSUPPORTED = 4;
892
893 /**
894 * Set by BroadcastReceiver to indicate a duplicate incoming message.
895 */
896 public static final int RESULT_SMS_DUPLICATED = 5;
897
898 /**
899 * Activity action: Ask the user to change the default
900 * SMS application. This will show a dialog that asks the
901 * user whether they want to replace the current default
902 * SMS application with the one specified in
903 * {@link #EXTRA_PACKAGE_NAME}.
Hai Zhang929085f2019-05-03 15:31:43 +0800904 * <p>
905 * This is no longer supported since Q, please use
906 * {@link android.app.role.RoleManager#createRequestRoleIntent(String)} with
907 * {@link android.app.role.RoleManager#ROLE_SMS} instead.
Dan Willemsen4980bf42017-02-14 14:17:12 -0800908 */
909 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
910 public static final String ACTION_CHANGE_DEFAULT =
911 "android.provider.Telephony.ACTION_CHANGE_DEFAULT";
912
913 /**
914 * The PackageName string passed in as an
915 * extra for {@link #ACTION_CHANGE_DEFAULT}
916 *
917 * @see #ACTION_CHANGE_DEFAULT
Hai Zhang929085f2019-05-03 15:31:43 +0800918 * <p>
919 * This is no longer supported since Q, please use
920 * {@link android.app.role.RoleManager#createRequestRoleIntent(String)} with
921 * {@link android.app.role.RoleManager#ROLE_SMS} instead.
Dan Willemsen4980bf42017-02-14 14:17:12 -0800922 */
923 public static final String EXTRA_PACKAGE_NAME = "package";
924
925 /**
926 * Broadcast Action: A new text-based SMS message has been received
927 * by the device. This intent will only be delivered to the default
928 * sms app. That app is responsible for writing the message and notifying
929 * the user. The intent will have the following extra values:</p>
930 *
931 * <ul>
932 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
933 * that make up the message.</li>
934 * <li><em>"format"</em> - A String describing the format of the PDUs. It can
935 * be either "3gpp" or "3gpp2".</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 * <li><em>"errorCode"</em> - An optional int error code associated with receiving
943 * the message.</li>
944 * </ul>
945 *
946 * <p>The extra values can be extracted using
947 * {@link #getMessagesFromIntent(Intent)}.</p>
948 *
949 * <p>If a BroadcastReceiver encounters an error while processing
950 * this intent it should set the result code appropriately.</p>
951 *
952 * <p class="note"><strong>Note:</strong>
953 * The broadcast receiver that filters for this intent must declare
954 * {@link android.Manifest.permission#BROADCAST_SMS} as a required permission in
955 * the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code
956 * <receiver>}</a> tag.
957 *
958 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
959 */
960 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
961 public static final String SMS_DELIVER_ACTION =
962 "android.provider.Telephony.SMS_DELIVER";
963
964 /**
965 * Broadcast Action: A new text-based SMS message has been received
966 * by the device. This intent will be delivered to all registered
967 * receivers as a notification. These apps are not expected to write the
968 * message or notify the user. The intent will have the following extra
969 * values:</p>
970 *
971 * <ul>
972 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
973 * that make up the message.</li>
974 * </ul>
975 *
976 * <p>The extra values can be extracted using
977 * {@link #getMessagesFromIntent(Intent)}.</p>
978 *
979 * <p>If a BroadcastReceiver encounters an error while processing
980 * this intent it should set the result code appropriately.</p>
981 *
982 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
983 */
984 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
985 public static final String SMS_RECEIVED_ACTION =
986 "android.provider.Telephony.SMS_RECEIVED";
987
988 /**
989 * Broadcast Action: A new data based SMS message has been received
990 * by the device. This intent will be delivered to all registered
991 * receivers as a notification. The intent will have the following extra
992 * values:</p>
993 *
994 * <ul>
995 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
996 * that make up the message.</li>
997 * </ul>
998 *
999 * <p>The extra values can be extracted using
1000 * {@link #getMessagesFromIntent(Intent)}.</p>
1001 *
1002 * <p>If a BroadcastReceiver encounters an error while processing
1003 * this intent it should set the result code appropriately.</p>
1004 *
1005 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1006 */
1007 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1008 public static final String DATA_SMS_RECEIVED_ACTION =
1009 "android.intent.action.DATA_SMS_RECEIVED";
1010
1011 /**
1012 * Broadcast Action: A new WAP PUSH message has been received by the
1013 * device. This intent will only be delivered to the default
1014 * sms app. That app is responsible for writing the message and notifying
1015 * the user. The intent will have the following extra values:</p>
1016 *
1017 * <ul>
1018 * <li><em>"transactionId"</em> - (Integer) The WAP transaction ID</li>
1019 * <li><em>"pduType"</em> - (Integer) The WAP PDU type</li>
1020 * <li><em>"header"</em> - (byte[]) The header of the message</li>
1021 * <li><em>"data"</em> - (byte[]) The data payload of the message</li>
1022 * <li><em>"contentTypeParameters" </em>
1023 * -(HashMap&lt;String,String&gt;) Any parameters associated with the content type
1024 * (decoded from the WSP Content-Type header)</li>
1025 * <li><em>"subscription"</em> - An optional long value of the subscription id which
1026 * received the message.</li>
1027 * <li><em>"slot"</em> - An optional int value of the SIM slot containing the
1028 * subscription.</li>
1029 * <li><em>"phone"</em> - An optional int value of the phone id associated with the
1030 * subscription.</li>
1031 * </ul>
1032 *
1033 * <p>If a BroadcastReceiver encounters an error while processing
1034 * this intent it should set the result code appropriately.</p>
1035 *
1036 * <p>The contentTypeParameters extra value is map of content parameters keyed by
1037 * their names.</p>
1038 *
1039 * <p>If any unassigned well-known parameters are encountered, the key of the map will
1040 * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter. If
1041 * a parameter has No-Value the value in the map will be null.</p>
1042 *
1043 * <p>Requires {@link android.Manifest.permission#RECEIVE_MMS} or
1044 * {@link android.Manifest.permission#RECEIVE_WAP_PUSH} (depending on WAP PUSH type) to
1045 * receive.</p>
1046 *
1047 * <p class="note"><strong>Note:</strong>
1048 * The broadcast receiver that filters for this intent must declare
1049 * {@link android.Manifest.permission#BROADCAST_WAP_PUSH} as a required permission in
1050 * the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code
1051 * <receiver>}</a> tag.
1052 */
1053 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1054 public static final String WAP_PUSH_DELIVER_ACTION =
1055 "android.provider.Telephony.WAP_PUSH_DELIVER";
1056
1057 /**
1058 * Broadcast Action: A new WAP PUSH message has been received by the
1059 * device. This intent will be delivered to all registered
1060 * receivers as a notification. These apps are not expected to write the
1061 * message or notify the user. The intent will have the following extra
1062 * values:</p>
1063 *
1064 * <ul>
1065 * <li><em>"transactionId"</em> - (Integer) The WAP transaction ID</li>
1066 * <li><em>"pduType"</em> - (Integer) The WAP PDU type</li>
1067 * <li><em>"header"</em> - (byte[]) The header of the message</li>
1068 * <li><em>"data"</em> - (byte[]) The data payload of the message</li>
1069 * <li><em>"contentTypeParameters"</em>
1070 * - (HashMap&lt;String,String&gt;) Any parameters associated with the content type
1071 * (decoded from the WSP Content-Type header)</li>
1072 * </ul>
1073 *
1074 * <p>If a BroadcastReceiver encounters an error while processing
1075 * this intent it should set the result code appropriately.</p>
1076 *
1077 * <p>The contentTypeParameters extra value is map of content parameters keyed by
1078 * their names.</p>
1079 *
1080 * <p>If any unassigned well-known parameters are encountered, the key of the map will
1081 * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter. If
1082 * a parameter has No-Value the value in the map will be null.</p>
1083 *
1084 * <p>Requires {@link android.Manifest.permission#RECEIVE_MMS} or
1085 * {@link android.Manifest.permission#RECEIVE_WAP_PUSH} (depending on WAP PUSH type) to
1086 * receive.</p>
1087 */
1088 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1089 public static final String WAP_PUSH_RECEIVED_ACTION =
1090 "android.provider.Telephony.WAP_PUSH_RECEIVED";
1091
1092 /**
1093 * Broadcast Action: A new Cell Broadcast message has been received
1094 * by the device. The intent will have the following extra
1095 * values:</p>
1096 *
1097 * <ul>
1098 * <li><em>"message"</em> - An SmsCbMessage object containing the broadcast message
1099 * data. This is not an emergency alert, so ETWS and CMAS data will be null.</li>
1100 * </ul>
1101 *
1102 * <p>The extra values can be extracted using
1103 * {@link #getMessagesFromIntent(Intent)}.</p>
1104 *
1105 * <p>If a BroadcastReceiver encounters an error while processing
1106 * this intent it should set the result code appropriately.</p>
1107 *
1108 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1109 */
1110 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1111 public static final String SMS_CB_RECEIVED_ACTION =
1112 "android.provider.Telephony.SMS_CB_RECEIVED";
1113
1114 /**
1115 * Action: A SMS based carrier provision intent. Used to identify default
1116 * carrier provisioning app on the device.
1117 * @hide
1118 */
1119 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1120 @TestApi
1121 public static final String SMS_CARRIER_PROVISION_ACTION =
1122 "android.provider.Telephony.SMS_CARRIER_PROVISION";
1123
1124 /**
1125 * Broadcast Action: A new Emergency Broadcast message has been received
1126 * by the device. The intent will have the following extra
1127 * values:</p>
1128 *
1129 * <ul>
Chen Xu39b95942019-11-06 20:30:58 -08001130 * <li><em>"message"</em> - An {@link android.telephony.SmsCbMessage} object
1131 * containing the broadcast message data, including ETWS or CMAS warning notification
1132 * info if present.</li>
Dan Willemsen4980bf42017-02-14 14:17:12 -08001133 * </ul>
1134 *
1135 * <p>The extra values can be extracted using
1136 * {@link #getMessagesFromIntent(Intent)}.</p>
1137 *
1138 * <p>If a BroadcastReceiver encounters an error while processing
1139 * this intent it should set the result code appropriately.</p>
1140 *
1141 * <p>Requires {@link android.Manifest.permission#RECEIVE_EMERGENCY_BROADCAST} to
1142 * receive.</p>
Chen Xu39b95942019-11-06 20:30:58 -08001143 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08001144 */
1145 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Chen Xu39b95942019-11-06 20:30:58 -08001146 @SystemApi
1147 public static final String ACTION_SMS_EMERGENCY_CB_RECEIVED =
1148 "android.provider.action.SMS_EMERGENCY_CB_RECEIVED";
Dan Willemsen4980bf42017-02-14 14:17:12 -08001149
1150 /**
1151 * Broadcast Action: A new CDMA SMS has been received containing Service Category
1152 * Program Data (updates the list of enabled broadcast channels). The intent will
1153 * have the following extra values:</p>
1154 *
1155 * <ul>
1156 * <li><em>"operations"</em> - An array of CdmaSmsCbProgramData objects containing
1157 * the service category operations (add/delete/clear) to perform.</li>
1158 * </ul>
1159 *
1160 * <p>The extra values can be extracted using
1161 * {@link #getMessagesFromIntent(Intent)}.</p>
1162 *
1163 * <p>If a BroadcastReceiver encounters an error while processing
1164 * this intent it should set the result code appropriately.</p>
1165 *
1166 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1167 */
1168 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1169 public static final String SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION =
1170 "android.provider.Telephony.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED";
1171
1172 /**
1173 * Broadcast Action: The SIM storage for SMS messages is full. If
1174 * space is not freed, messages targeted for the SIM (class 2) may
1175 * not be saved.
1176 *
1177 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1178 */
1179 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1180 public static final String SIM_FULL_ACTION =
1181 "android.provider.Telephony.SIM_FULL";
1182
1183 /**
1184 * Broadcast Action: An incoming SMS has been rejected by the
1185 * telephony framework. This intent is sent in lieu of any
1186 * of the RECEIVED_ACTION intents. The intent will have the
1187 * following extra value:</p>
1188 *
1189 * <ul>
1190 * <li><em>"result"</em> - An int result code, e.g. {@link #RESULT_SMS_OUT_OF_MEMORY}
1191 * indicating the error returned to the network.</li>
1192 * </ul>
1193 *
1194 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1195 */
1196 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1197 public static final String SMS_REJECTED_ACTION =
1198 "android.provider.Telephony.SMS_REJECTED";
1199
1200 /**
1201 * Broadcast Action: An incoming MMS has been downloaded. The intent is sent to all
1202 * users, except for secondary users where SMS has been disabled and to managed
1203 * profiles.
1204 * @hide
1205 */
1206 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1207 public static final String MMS_DOWNLOADED_ACTION =
1208 "android.provider.Telephony.MMS_DOWNLOADED";
1209
1210 /**
Cassie5b97cf12018-02-22 09:58:33 -08001211 * Broadcast Action: A debug code has been entered in the dialer. This intent is
1212 * broadcast by the system and OEM telephony apps may need to receive these broadcasts.
1213 * These "secret codes" are used to activate developer menus by dialing certain codes.
Alan Stokesa9b5b2a2019-02-28 16:45:47 +00001214 * And they are of the form {@code *#*#<code>#*#*}. The intent will have the data
1215 * URI: {@code android_secret_code://<code>}. It is possible that a manifest
Cassie5b97cf12018-02-22 09:58:33 -08001216 * receiver would be woken up even if it is not currently running.
1217 *
1218 * <p>Requires {@code android.Manifest.permission#CONTROL_INCALL_EXPERIENCE} to
1219 * send and receive.</p>
Cassie6d0a5712018-08-21 13:38:39 -07001220 * @deprecated it is no longer supported, use {@link
1221 * TelephonyManager#ACTION_SECRET_CODE} instead
Cassie866f4942018-01-19 17:23:36 -08001222 */
Cassie6d0a5712018-08-21 13:38:39 -07001223 @Deprecated
Cassie866f4942018-01-19 17:23:36 -08001224 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1225 public static final String SECRET_CODE_ACTION =
1226 "android.provider.Telephony.SECRET_CODE";
1227
1228 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08001229 * Broadcast action: When the default SMS package changes,
1230 * the previous default SMS package and the new default SMS
1231 * package are sent this broadcast to notify them of the change.
1232 * A boolean is specified in {@link #EXTRA_IS_DEFAULT_SMS_APP} to
1233 * indicate whether the package is the new default SMS package.
1234 */
1235 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1236 public static final String ACTION_DEFAULT_SMS_PACKAGE_CHANGED =
1237 "android.provider.action.DEFAULT_SMS_PACKAGE_CHANGED";
1238
1239 /**
1240 * The IsDefaultSmsApp boolean passed as an
1241 * extra for {@link #ACTION_DEFAULT_SMS_PACKAGE_CHANGED} to indicate whether the
1242 * SMS app is becoming the default SMS app or is no longer the default.
1243 *
1244 * @see #ACTION_DEFAULT_SMS_PACKAGE_CHANGED
1245 */
1246 public static final String EXTRA_IS_DEFAULT_SMS_APP =
1247 "android.provider.extra.IS_DEFAULT_SMS_APP";
1248
1249 /**
1250 * Broadcast action: When a change is made to the SmsProvider or
1251 * MmsProvider by a process other than the default SMS application,
1252 * this intent is broadcast to the default SMS application so it can
1253 * re-sync or update the change. The uri that was used to call the provider
1254 * can be retrieved from the intent with getData(). The actual affected uris
1255 * (which would depend on the selection specified) are not included.
1256 */
1257 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1258 public static final String ACTION_EXTERNAL_PROVIDER_CHANGE =
1259 "android.provider.action.EXTERNAL_PROVIDER_CHANGE";
1260
1261 /**
Makoto Onukia042aaa2018-09-18 16:14:12 -07001262 * Same as {@link #ACTION_DEFAULT_SMS_PACKAGE_CHANGED} but it's implicit (e.g. sent to
1263 * all apps) and requires
1264 * {@link android.Manifest.permission#MONITOR_DEFAULT_SMS_PACKAGE} to receive.
1265 *
1266 * @hide
1267 */
1268 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1269 public static final String ACTION_DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL =
1270 "android.provider.action.DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL";
1271
1272 /**
Amit Mahajan8c1c45a2018-10-22 10:43:34 -07001273 * Broadcast action: When SMS-MMS db is being created. If file-based encryption is
1274 * supported, this broadcast indicates creation of the db in credential-encrypted
1275 * storage. A boolean is specified in {@link #EXTRA_IS_INITIAL_CREATE} to indicate if
1276 * this is the initial create of the db. Requires
1277 * {@link android.Manifest.permission#READ_SMS} to receive.
1278 *
1279 * @see #EXTRA_IS_INITIAL_CREATE
1280 *
1281 * @hide
1282 */
1283 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1284 public static final String ACTION_SMS_MMS_DB_CREATED =
1285 "android.provider.action.SMS_MMS_DB_CREATED";
1286
1287 /**
1288 * Boolean flag passed as an extra with {@link #ACTION_SMS_MMS_DB_CREATED} to indicate
1289 * whether the DB creation is the initial creation on the device, that is it is after a
1290 * factory-data reset or a new device. Any subsequent creations of the DB (which
1291 * happens only in error scenarios) will have this flag set to false.
1292 *
1293 * @see #ACTION_SMS_MMS_DB_CREATED
1294 *
1295 * @hide
1296 */
1297 public static final String EXTRA_IS_INITIAL_CREATE =
1298 "android.provider.extra.IS_INITIAL_CREATE";
Jayachandran C349b9ba2018-10-30 15:09:06 -07001299
1300 /**
1301 * Broadcast intent action indicating that the telephony provider SMS MMS database is
1302 * corrupted. A boolean is specified in {@link #EXTRA_IS_CORRUPTED} to indicate if the
1303 * database is corrupted. Requires the
1304 * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE permission.
1305 *
1306 * @hide
1307 */
1308 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1309 @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
1310 public static final String ACTION_SMS_MMS_DB_LOST =
1311 "android.provider.action.SMS_MMS_DB_LOST";
1312
1313 /**
1314 * Boolean flag passed as an extra with {@link #ACTION_SMS_MMS_DB_LOST} to indicate
1315 * whether the DB got corrupted or not.
1316 *
1317 * @see #ACTION_SMS_MMS_DB_LOST
1318 *
1319 * @hide
1320 */
1321 public static final String EXTRA_IS_CORRUPTED =
1322 "android.provider.extra.IS_CORRUPTED";
1323
Amit Mahajan8c1c45a2018-10-22 10:43:34 -07001324 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08001325 * Read the PDUs out of an {@link #SMS_RECEIVED_ACTION} or a
1326 * {@link #DATA_SMS_RECEIVED_ACTION} intent.
1327 *
1328 * @param intent the intent to read from
1329 * @return an array of SmsMessages for the PDUs
1330 */
1331 public static SmsMessage[] getMessagesFromIntent(Intent intent) {
1332 Object[] messages;
1333 try {
1334 messages = (Object[]) intent.getSerializableExtra("pdus");
1335 }
1336 catch (ClassCastException e) {
1337 Rlog.e(TAG, "getMessagesFromIntent: " + e);
1338 return null;
1339 }
1340
1341 if (messages == null) {
1342 Rlog.e(TAG, "pdus does not exist in the intent");
1343 return null;
1344 }
1345
1346 String format = intent.getStringExtra("format");
1347 int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
1348 SubscriptionManager.getDefaultSmsSubscriptionId());
1349
1350 Rlog.v(TAG, " getMessagesFromIntent sub_id : " + subId);
1351
1352 int pduCount = messages.length;
1353 SmsMessage[] msgs = new SmsMessage[pduCount];
1354
1355 for (int i = 0; i < pduCount; i++) {
1356 byte[] pdu = (byte[]) messages[i];
1357 msgs[i] = SmsMessage.createFromPdu(pdu, format);
1358 if (msgs[i] != null) msgs[i].setSubId(subId);
1359 }
1360 return msgs;
1361 }
1362 }
1363 }
1364
1365 /**
pkanwar16b8a0d2017-06-07 10:59:41 -07001366 * Base column for the table that contain Carrier Public key.
1367 * @hide
1368 */
1369 public interface CarrierColumns extends BaseColumns {
1370
1371 public static final String MCC = "mcc";
1372 public static final String MNC = "mnc";
1373 public static final String KEY_TYPE = "key_type";
1374 public static final String MVNO_TYPE = "mvno_type";
1375 public static final String MVNO_MATCH_DATA = "mvno_match_data";
1376 public static final String PUBLIC_KEY = "public_key";
1377 public static final String KEY_IDENTIFIER = "key_identifier";
1378 public static final String EXPIRATION_TIME = "expiration_time";
1379 public static final String LAST_MODIFIED = "last_modified";
1380
1381 /**
1382 * The {@code content://} style URL for this table.
1383 * @hide
1384 */
1385 public static final Uri CONTENT_URI = Uri.parse("content://carrier_information/carrier");
1386 }
1387
1388 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08001389 * Base columns for tables that contain MMSs.
1390 */
1391 public interface BaseMmsColumns extends BaseColumns {
1392
1393 /** Message box: all messages. */
1394 public static final int MESSAGE_BOX_ALL = 0;
1395 /** Message box: inbox. */
1396 public static final int MESSAGE_BOX_INBOX = 1;
1397 /** Message box: sent messages. */
1398 public static final int MESSAGE_BOX_SENT = 2;
1399 /** Message box: drafts. */
1400 public static final int MESSAGE_BOX_DRAFTS = 3;
1401 /** Message box: outbox. */
1402 public static final int MESSAGE_BOX_OUTBOX = 4;
1403 /** Message box: failed. */
1404 public static final int MESSAGE_BOX_FAILED = 5;
1405
1406 /**
1407 * The thread ID of the message.
1408 * <P>Type: INTEGER (long)</P>
1409 */
1410 public static final String THREAD_ID = "thread_id";
1411
1412 /**
1413 * The date the message was received.
1414 * <P>Type: INTEGER (long)</P>
1415 */
1416 public static final String DATE = "date";
1417
1418 /**
1419 * The date the message was sent.
1420 * <P>Type: INTEGER (long)</P>
1421 */
1422 public static final String DATE_SENT = "date_sent";
1423
1424 /**
1425 * The box which the message belongs to, e.g. {@link #MESSAGE_BOX_INBOX}.
1426 * <P>Type: INTEGER</P>
1427 */
1428 public static final String MESSAGE_BOX = "msg_box";
1429
1430 /**
1431 * Has the message been read?
1432 * <P>Type: INTEGER (boolean)</P>
1433 */
1434 public static final String READ = "read";
1435
1436 /**
1437 * Has the message been seen by the user? The "seen" flag determines
1438 * whether we need to show a new message notification.
1439 * <P>Type: INTEGER (boolean)</P>
1440 */
1441 public static final String SEEN = "seen";
1442
1443 /**
1444 * Does the message have only a text part (can also have a subject) with
1445 * no picture, slideshow, sound, etc. parts?
1446 * <P>Type: INTEGER (boolean)</P>
1447 */
1448 public static final String TEXT_ONLY = "text_only";
1449
1450 /**
1451 * The {@code Message-ID} of the message.
1452 * <P>Type: TEXT</P>
1453 */
1454 public static final String MESSAGE_ID = "m_id";
1455
1456 /**
1457 * The subject of the message, if present.
1458 * <P>Type: TEXT</P>
1459 */
1460 public static final String SUBJECT = "sub";
1461
1462 /**
1463 * The character set of the subject, if present.
1464 * <P>Type: INTEGER</P>
1465 */
1466 public static final String SUBJECT_CHARSET = "sub_cs";
1467
1468 /**
1469 * The {@code Content-Type} of the message.
1470 * <P>Type: TEXT</P>
1471 */
1472 public static final String CONTENT_TYPE = "ct_t";
1473
1474 /**
1475 * The {@code Content-Location} of the message.
1476 * <P>Type: TEXT</P>
1477 */
1478 public static final String CONTENT_LOCATION = "ct_l";
1479
1480 /**
1481 * The expiry time of the message.
1482 * <P>Type: INTEGER (long)</P>
1483 */
1484 public static final String EXPIRY = "exp";
1485
1486 /**
1487 * The class of the message.
1488 * <P>Type: TEXT</P>
1489 */
1490 public static final String MESSAGE_CLASS = "m_cls";
1491
1492 /**
1493 * The type of the message defined by MMS spec.
1494 * <P>Type: INTEGER</P>
1495 */
1496 public static final String MESSAGE_TYPE = "m_type";
1497
1498 /**
1499 * The version of the specification that this message conforms to.
1500 * <P>Type: INTEGER</P>
1501 */
1502 public static final String MMS_VERSION = "v";
1503
1504 /**
1505 * The size of the message.
1506 * <P>Type: INTEGER</P>
1507 */
1508 public static final String MESSAGE_SIZE = "m_size";
1509
1510 /**
1511 * The priority of the message.
1512 * <P>Type: INTEGER</P>
1513 */
1514 public static final String PRIORITY = "pri";
1515
1516 /**
1517 * The {@code read-report} of the message.
1518 * <P>Type: INTEGER (boolean)</P>
1519 */
1520 public static final String READ_REPORT = "rr";
1521
1522 /**
1523 * Is read report allowed?
1524 * <P>Type: INTEGER (boolean)</P>
1525 */
1526 public static final String REPORT_ALLOWED = "rpt_a";
1527
1528 /**
1529 * The {@code response-status} of the message.
1530 * <P>Type: INTEGER</P>
1531 */
1532 public static final String RESPONSE_STATUS = "resp_st";
1533
1534 /**
1535 * The {@code status} of the message.
1536 * <P>Type: INTEGER</P>
1537 */
1538 public static final String STATUS = "st";
1539
1540 /**
1541 * The {@code transaction-id} of the message.
1542 * <P>Type: TEXT</P>
1543 */
1544 public static final String TRANSACTION_ID = "tr_id";
1545
1546 /**
1547 * The {@code retrieve-status} of the message.
1548 * <P>Type: INTEGER</P>
1549 */
1550 public static final String RETRIEVE_STATUS = "retr_st";
1551
1552 /**
1553 * The {@code retrieve-text} of the message.
1554 * <P>Type: TEXT</P>
1555 */
1556 public static final String RETRIEVE_TEXT = "retr_txt";
1557
1558 /**
1559 * The character set of the retrieve-text.
1560 * <P>Type: INTEGER</P>
1561 */
1562 public static final String RETRIEVE_TEXT_CHARSET = "retr_txt_cs";
1563
1564 /**
1565 * The {@code read-status} of the message.
1566 * <P>Type: INTEGER</P>
1567 */
1568 public static final String READ_STATUS = "read_status";
1569
1570 /**
1571 * The {@code content-class} of the message.
1572 * <P>Type: INTEGER</P>
1573 */
1574 public static final String CONTENT_CLASS = "ct_cls";
1575
1576 /**
1577 * The {@code delivery-report} of the message.
1578 * <P>Type: INTEGER</P>
1579 */
1580 public static final String DELIVERY_REPORT = "d_rpt";
1581
1582 /**
1583 * The {@code delivery-time-token} of the message.
1584 * <P>Type: INTEGER</P>
1585 * @deprecated this column is no longer supported.
1586 * @hide
1587 */
1588 @Deprecated
1589 public static final String DELIVERY_TIME_TOKEN = "d_tm_tok";
1590
1591 /**
1592 * The {@code delivery-time} of the message.
1593 * <P>Type: INTEGER</P>
1594 */
1595 public static final String DELIVERY_TIME = "d_tm";
1596
1597 /**
1598 * The {@code response-text} of the message.
1599 * <P>Type: TEXT</P>
1600 */
1601 public static final String RESPONSE_TEXT = "resp_txt";
1602
1603 /**
1604 * The {@code sender-visibility} of the message.
1605 * <P>Type: TEXT</P>
1606 * @deprecated this column is no longer supported.
1607 * @hide
1608 */
1609 @Deprecated
1610 public static final String SENDER_VISIBILITY = "s_vis";
1611
1612 /**
1613 * The {@code reply-charging} of the message.
1614 * <P>Type: INTEGER</P>
1615 * @deprecated this column is no longer supported.
1616 * @hide
1617 */
1618 @Deprecated
1619 public static final String REPLY_CHARGING = "r_chg";
1620
1621 /**
1622 * The {@code reply-charging-deadline-token} of the message.
1623 * <P>Type: INTEGER</P>
1624 * @deprecated this column is no longer supported.
1625 * @hide
1626 */
1627 @Deprecated
1628 public static final String REPLY_CHARGING_DEADLINE_TOKEN = "r_chg_dl_tok";
1629
1630 /**
1631 * The {@code reply-charging-deadline} of the message.
1632 * <P>Type: INTEGER</P>
1633 * @deprecated this column is no longer supported.
1634 * @hide
1635 */
1636 @Deprecated
1637 public static final String REPLY_CHARGING_DEADLINE = "r_chg_dl";
1638
1639 /**
1640 * The {@code reply-charging-id} of the message.
1641 * <P>Type: TEXT</P>
1642 * @deprecated this column is no longer supported.
1643 * @hide
1644 */
1645 @Deprecated
1646 public static final String REPLY_CHARGING_ID = "r_chg_id";
1647
1648 /**
1649 * The {@code reply-charging-size} of the message.
1650 * <P>Type: INTEGER</P>
1651 * @deprecated this column is no longer supported.
1652 * @hide
1653 */
1654 @Deprecated
1655 public static final String REPLY_CHARGING_SIZE = "r_chg_sz";
1656
1657 /**
1658 * The {@code previously-sent-by} of the message.
1659 * <P>Type: TEXT</P>
1660 * @deprecated this column is no longer supported.
1661 * @hide
1662 */
1663 @Deprecated
1664 public static final String PREVIOUSLY_SENT_BY = "p_s_by";
1665
1666 /**
1667 * The {@code previously-sent-date} of the message.
1668 * <P>Type: INTEGER</P>
1669 * @deprecated this column is no longer supported.
1670 * @hide
1671 */
1672 @Deprecated
1673 public static final String PREVIOUSLY_SENT_DATE = "p_s_d";
1674
1675 /**
1676 * The {@code store} of the message.
1677 * <P>Type: TEXT</P>
1678 * @deprecated this column is no longer supported.
1679 * @hide
1680 */
1681 @Deprecated
1682 public static final String STORE = "store";
1683
1684 /**
1685 * The {@code mm-state} of the message.
1686 * <P>Type: INTEGER</P>
1687 * @deprecated this column is no longer supported.
1688 * @hide
1689 */
1690 @Deprecated
1691 public static final String MM_STATE = "mm_st";
1692
1693 /**
1694 * The {@code mm-flags-token} of the message.
1695 * <P>Type: INTEGER</P>
1696 * @deprecated this column is no longer supported.
1697 * @hide
1698 */
1699 @Deprecated
1700 public static final String MM_FLAGS_TOKEN = "mm_flg_tok";
1701
1702 /**
1703 * The {@code mm-flags} of the message.
1704 * <P>Type: TEXT</P>
1705 * @deprecated this column is no longer supported.
1706 * @hide
1707 */
1708 @Deprecated
1709 public static final String MM_FLAGS = "mm_flg";
1710
1711 /**
1712 * The {@code store-status} of the message.
1713 * <P>Type: TEXT</P>
1714 * @deprecated this column is no longer supported.
1715 * @hide
1716 */
1717 @Deprecated
1718 public static final String STORE_STATUS = "store_st";
1719
1720 /**
1721 * The {@code store-status-text} of the message.
1722 * <P>Type: TEXT</P>
1723 * @deprecated this column is no longer supported.
1724 * @hide
1725 */
1726 @Deprecated
1727 public static final String STORE_STATUS_TEXT = "store_st_txt";
1728
1729 /**
1730 * The {@code stored} of the message.
1731 * <P>Type: TEXT</P>
1732 * @deprecated this column is no longer supported.
1733 * @hide
1734 */
1735 @Deprecated
1736 public static final String STORED = "stored";
1737
1738 /**
1739 * The {@code totals} of the message.
1740 * <P>Type: TEXT</P>
1741 * @deprecated this column is no longer supported.
1742 * @hide
1743 */
1744 @Deprecated
1745 public static final String TOTALS = "totals";
1746
1747 /**
1748 * The {@code mbox-totals} of the message.
1749 * <P>Type: TEXT</P>
1750 * @deprecated this column is no longer supported.
1751 * @hide
1752 */
1753 @Deprecated
1754 public static final String MBOX_TOTALS = "mb_t";
1755
1756 /**
1757 * The {@code mbox-totals-token} of the message.
1758 * <P>Type: INTEGER</P>
1759 * @deprecated this column is no longer supported.
1760 * @hide
1761 */
1762 @Deprecated
1763 public static final String MBOX_TOTALS_TOKEN = "mb_t_tok";
1764
1765 /**
1766 * The {@code quotas} of the message.
1767 * <P>Type: TEXT</P>
1768 * @deprecated this column is no longer supported.
1769 * @hide
1770 */
1771 @Deprecated
1772 public static final String QUOTAS = "qt";
1773
1774 /**
1775 * The {@code mbox-quotas} of the message.
1776 * <P>Type: TEXT</P>
1777 * @deprecated this column is no longer supported.
1778 * @hide
1779 */
1780 @Deprecated
1781 public static final String MBOX_QUOTAS = "mb_qt";
1782
1783 /**
1784 * The {@code mbox-quotas-token} of the message.
1785 * <P>Type: INTEGER</P>
1786 * @deprecated this column is no longer supported.
1787 * @hide
1788 */
1789 @Deprecated
1790 public static final String MBOX_QUOTAS_TOKEN = "mb_qt_tok";
1791
1792 /**
1793 * The {@code message-count} of the message.
1794 * <P>Type: INTEGER</P>
1795 * @deprecated this column is no longer supported.
1796 * @hide
1797 */
1798 @Deprecated
1799 public static final String MESSAGE_COUNT = "m_cnt";
1800
1801 /**
1802 * The {@code start} of the message.
1803 * <P>Type: INTEGER</P>
1804 * @deprecated this column is no longer supported.
1805 * @hide
1806 */
1807 @Deprecated
1808 public static final String START = "start";
1809
1810 /**
1811 * The {@code distribution-indicator} of the message.
1812 * <P>Type: TEXT</P>
1813 * @deprecated this column is no longer supported.
1814 * @hide
1815 */
1816 @Deprecated
1817 public static final String DISTRIBUTION_INDICATOR = "d_ind";
1818
1819 /**
1820 * The {@code element-descriptor} of the message.
1821 * <P>Type: TEXT</P>
1822 * @deprecated this column is no longer supported.
1823 * @hide
1824 */
1825 @Deprecated
1826 public static final String ELEMENT_DESCRIPTOR = "e_des";
1827
1828 /**
1829 * The {@code limit} of the message.
1830 * <P>Type: INTEGER</P>
1831 * @deprecated this column is no longer supported.
1832 * @hide
1833 */
1834 @Deprecated
1835 public static final String LIMIT = "limit";
1836
1837 /**
1838 * The {@code recommended-retrieval-mode} of the message.
1839 * <P>Type: INTEGER</P>
1840 * @deprecated this column is no longer supported.
1841 * @hide
1842 */
1843 @Deprecated
1844 public static final String RECOMMENDED_RETRIEVAL_MODE = "r_r_mod";
1845
1846 /**
1847 * The {@code recommended-retrieval-mode-text} of the message.
1848 * <P>Type: TEXT</P>
1849 * @deprecated this column is no longer supported.
1850 * @hide
1851 */
1852 @Deprecated
1853 public static final String RECOMMENDED_RETRIEVAL_MODE_TEXT = "r_r_mod_txt";
1854
1855 /**
1856 * The {@code status-text} of the message.
1857 * <P>Type: TEXT</P>
1858 * @deprecated this column is no longer supported.
1859 * @hide
1860 */
1861 @Deprecated
1862 public static final String STATUS_TEXT = "st_txt";
1863
1864 /**
1865 * The {@code applic-id} of the message.
1866 * <P>Type: TEXT</P>
1867 * @deprecated this column is no longer supported.
1868 * @hide
1869 */
1870 @Deprecated
1871 public static final String APPLIC_ID = "apl_id";
1872
1873 /**
1874 * The {@code reply-applic-id} of the message.
1875 * <P>Type: TEXT</P>
1876 * @deprecated this column is no longer supported.
1877 * @hide
1878 */
1879 @Deprecated
1880 public static final String REPLY_APPLIC_ID = "r_apl_id";
1881
1882 /**
1883 * The {@code aux-applic-id} of the message.
1884 * <P>Type: TEXT</P>
1885 * @deprecated this column is no longer supported.
1886 * @hide
1887 */
1888 @Deprecated
1889 public static final String AUX_APPLIC_ID = "aux_apl_id";
1890
1891 /**
1892 * The {@code drm-content} of the message.
1893 * <P>Type: TEXT</P>
1894 * @deprecated this column is no longer supported.
1895 * @hide
1896 */
1897 @Deprecated
1898 public static final String DRM_CONTENT = "drm_c";
1899
1900 /**
1901 * The {@code adaptation-allowed} of the message.
1902 * <P>Type: TEXT</P>
1903 * @deprecated this column is no longer supported.
1904 * @hide
1905 */
1906 @Deprecated
1907 public static final String ADAPTATION_ALLOWED = "adp_a";
1908
1909 /**
1910 * The {@code replace-id} of the message.
1911 * <P>Type: TEXT</P>
1912 * @deprecated this column is no longer supported.
1913 * @hide
1914 */
1915 @Deprecated
1916 public static final String REPLACE_ID = "repl_id";
1917
1918 /**
1919 * The {@code cancel-id} of the message.
1920 * <P>Type: TEXT</P>
1921 * @deprecated this column is no longer supported.
1922 * @hide
1923 */
1924 @Deprecated
1925 public static final String CANCEL_ID = "cl_id";
1926
1927 /**
1928 * The {@code cancel-status} of the message.
1929 * <P>Type: INTEGER</P>
1930 * @deprecated this column is no longer supported.
1931 * @hide
1932 */
1933 @Deprecated
1934 public static final String CANCEL_STATUS = "cl_st";
1935
1936 /**
1937 * Is the message locked?
1938 * <P>Type: INTEGER (boolean)</P>
1939 */
1940 public static final String LOCKED = "locked";
1941
1942 /**
1943 * The subscription to which the message belongs to. Its value will be
1944 * < 0 if the sub id cannot be determined.
1945 * <p>Type: INTEGER (long)</p>
1946 */
1947 public static final String SUBSCRIPTION_ID = "sub_id";
1948
1949 /**
1950 * The identity of the sender of a sent message. It is
1951 * usually the package name of the app which sends the message.
1952 * <p class="note"><strong>Note:</strong>
1953 * This column is read-only. It is set by the provider and can not be changed by apps.
1954 * <p>Type: TEXT</p>
1955 */
1956 public static final String CREATOR = "creator";
1957 }
1958
1959 /**
1960 * Columns for the "canonical_addresses" table used by MMS and SMS.
1961 */
1962 public interface CanonicalAddressesColumns extends BaseColumns {
1963 /**
1964 * An address used in MMS or SMS. Email addresses are
1965 * converted to lower case and are compared by string
1966 * equality. Other addresses are compared using
1967 * PHONE_NUMBERS_EQUAL.
1968 * <P>Type: TEXT</P>
1969 */
1970 public static final String ADDRESS = "address";
1971 }
1972
1973 /**
1974 * Columns for the "threads" table used by MMS and SMS.
1975 */
1976 public interface ThreadsColumns extends BaseColumns {
1977
1978 /**
1979 * The date at which the thread was created.
1980 * <P>Type: INTEGER (long)</P>
1981 */
1982 public static final String DATE = "date";
1983
1984 /**
1985 * A string encoding of the recipient IDs of the recipients of
1986 * the message, in numerical order and separated by spaces.
1987 * <P>Type: TEXT</P>
1988 */
1989 public static final String RECIPIENT_IDS = "recipient_ids";
1990
1991 /**
1992 * The message count of the thread.
1993 * <P>Type: INTEGER</P>
1994 */
1995 public static final String MESSAGE_COUNT = "message_count";
1996
1997 /**
1998 * Indicates whether all messages of the thread have been read.
1999 * <P>Type: INTEGER</P>
2000 */
2001 public static final String READ = "read";
2002
2003 /**
2004 * The snippet of the latest message in the thread.
2005 * <P>Type: TEXT</P>
2006 */
2007 public static final String SNIPPET = "snippet";
2008
2009 /**
2010 * The charset of the snippet.
2011 * <P>Type: INTEGER</P>
2012 */
2013 public static final String SNIPPET_CHARSET = "snippet_cs";
2014
2015 /**
2016 * Type of the thread, either {@link Threads#COMMON_THREAD} or
2017 * {@link Threads#BROADCAST_THREAD}.
2018 * <P>Type: INTEGER</P>
2019 */
2020 public static final String TYPE = "type";
2021
2022 /**
2023 * Indicates whether there is a transmission error in the thread.
2024 * <P>Type: INTEGER</P>
2025 */
2026 public static final String ERROR = "error";
2027
2028 /**
2029 * Indicates whether this thread contains any attachments.
2030 * <P>Type: INTEGER</P>
2031 */
2032 public static final String HAS_ATTACHMENT = "has_attachment";
2033
2034 /**
2035 * If the thread is archived
2036 * <P>Type: INTEGER (boolean)</P>
2037 */
2038 public static final String ARCHIVED = "archived";
2039 }
2040
2041 /**
2042 * Helper functions for the "threads" table used by MMS and SMS.
Leland Millerc445b2b2019-01-09 17:00:09 -08002043 *
2044 * Thread IDs are determined by the participants in a conversation and can be used to match
2045 * both SMS and MMS messages.
2046 *
2047 * To avoid issues where applications might cache a thread ID, the thread ID of a deleted thread
2048 * must not be reused to point at a new thread.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002049 */
2050 public static final class Threads implements ThreadsColumns {
2051
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002052 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002053 private static final String[] ID_PROJECTION = { BaseColumns._ID };
2054
2055 /**
2056 * Private {@code content://} style URL for this table. Used by
2057 * {@link #getOrCreateThreadId(android.content.Context, java.util.Set)}.
2058 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002059 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002060 private static final Uri THREAD_ID_CONTENT_URI = Uri.parse(
2061 "content://mms-sms/threadID");
2062
2063 /**
2064 * The {@code content://} style URL for this table, by conversation.
2065 */
2066 public static final Uri CONTENT_URI = Uri.withAppendedPath(
2067 MmsSms.CONTENT_URI, "conversations");
2068
2069 /**
2070 * The {@code content://} style URL for this table, for obsolete threads.
2071 */
2072 public static final Uri OBSOLETE_THREADS_URI = Uri.withAppendedPath(
2073 CONTENT_URI, "obsolete");
2074
2075 /** Thread type: common thread. */
2076 public static final int COMMON_THREAD = 0;
2077
2078 /** Thread type: broadcast thread. */
2079 public static final int BROADCAST_THREAD = 1;
2080
2081 /**
2082 * Not instantiable.
2083 * @hide
2084 */
2085 private Threads() {
2086 }
2087
2088 /**
2089 * This is a single-recipient version of {@code getOrCreateThreadId}.
2090 * It's convenient for use with SMS messages.
2091 * @param context the context object to use.
2092 * @param recipient the recipient to send to.
2093 */
2094 public static long getOrCreateThreadId(Context context, String recipient) {
2095 Set<String> recipients = new HashSet<String>();
2096
2097 recipients.add(recipient);
2098 return getOrCreateThreadId(context, recipients);
2099 }
2100
2101 /**
Leland Millerc445b2b2019-01-09 17:00:09 -08002102 * Given a set of recipients return its thread ID.
2103 * <p>
2104 * If a thread exists containing the provided participants, return its thread ID. Otherwise,
2105 * this will create a new thread containing the provided participants and return its ID.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002106 */
2107 public static long getOrCreateThreadId(
2108 Context context, Set<String> recipients) {
2109 Uri.Builder uriBuilder = THREAD_ID_CONTENT_URI.buildUpon();
2110
2111 for (String recipient : recipients) {
2112 if (Mms.isEmailAddress(recipient)) {
2113 recipient = Mms.extractAddrSpec(recipient);
2114 }
2115
2116 uriBuilder.appendQueryParameter("recipient", recipient);
2117 }
2118
2119 Uri uri = uriBuilder.build();
2120 //if (DEBUG) Rlog.v(TAG, "getOrCreateThreadId uri: " + uri);
2121
2122 Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
2123 uri, ID_PROJECTION, null, null, null);
2124 if (cursor != null) {
2125 try {
2126 if (cursor.moveToFirst()) {
2127 return cursor.getLong(0);
2128 } else {
2129 Rlog.e(TAG, "getOrCreateThreadId returned no rows!");
2130 }
2131 } finally {
2132 cursor.close();
2133 }
2134 }
2135
2136 Rlog.e(TAG, "getOrCreateThreadId failed with " + recipients.size() + " recipients");
2137 throw new IllegalArgumentException("Unable to find or allocate a thread ID.");
2138 }
2139 }
2140
2141 /**
Sahin Caliskanf00a8762019-01-24 14:32:12 -08002142 * Columns for the "rcs_*" tables used by {@link android.telephony.ims.RcsMessageStore} classes.
2143 *
2144 * @hide - not meant for public use
2145 */
2146 public interface RcsColumns {
Leland Millerbd7959d2019-02-13 10:31:31 -08002147 // TODO(sahinc): Turn this to true once the schema finalizes, so that people can update
2148 // their messaging databases. NOTE: move the switch/case update in MmsSmsDatabaseHelper to
2149 // the latest version of the database before turning this flag to true.
2150 boolean IS_RCS_TABLE_SCHEMA_CODE_COMPLETE = false;
2151
Sahin Caliskanf00a8762019-01-24 14:32:12 -08002152 /**
2153 * The authority for the content provider
2154 */
2155 String AUTHORITY = "rcs";
2156
2157 /**
2158 * The URI to start building upon to use {@link com.android.providers.telephony.RcsProvider}
2159 */
2160 Uri CONTENT_AND_AUTHORITY = Uri.parse("content://" + AUTHORITY);
2161
2162 /**
2163 * The value to be used whenever a transaction that expects an integer to be returned
2164 * failed.
2165 */
2166 int TRANSACTION_FAILED = Integer.MIN_VALUE;
2167
2168 /**
2169 * The value that denotes a timestamp was not set before (e.g. a message that is not
2170 * delivered yet will not have a DELIVERED_TIMESTAMP)
2171 */
2172 long TIMESTAMP_NOT_SET = 0;
2173
2174 /**
2175 * The table that {@link android.telephony.ims.RcsThread} gets persisted to
2176 */
2177 interface RcsThreadColumns {
2178 /**
2179 * The path that should be used for referring to
2180 * {@link android.telephony.ims.RcsThread}s in
2181 * {@link com.android.providers.telephony.RcsProvider} URIs.
2182 */
2183 String RCS_THREAD_URI_PART = "thread";
2184
2185 /**
2186 * The URI to query or modify {@link android.telephony.ims.RcsThread} via the content
2187 * provider.
2188 */
2189 Uri RCS_THREAD_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY, RCS_THREAD_URI_PART);
2190
2191 /**
2192 * The unique identifier of an {@link android.telephony.ims.RcsThread}
2193 */
2194 String RCS_THREAD_ID_COLUMN = "rcs_thread_id";
2195 }
2196
2197 /**
2198 * The table that {@link android.telephony.ims.Rcs1To1Thread} gets persisted to
2199 */
2200 interface Rcs1To1ThreadColumns extends RcsThreadColumns {
2201 /**
2202 * The path that should be used for referring to
2203 * {@link android.telephony.ims.Rcs1To1Thread}s in
2204 * {@link com.android.providers.telephony.RcsProvider} URIs.
2205 */
2206 String RCS_1_TO_1_THREAD_URI_PART = "p2p_thread";
2207
2208 /**
2209 * The URI to query or modify {@link android.telephony.ims.Rcs1To1Thread}s via the
Leland Millerdb2337f2019-02-20 07:53:49 -08002210 * content provider. Can also insert to this URI to create a new 1-to-1 thread. When
2211 * performing an insert, ensure that the provided content values contain the other
2212 * participant's ID under the key
2213 * {@link RcsParticipantColumns.RCS_PARTICIPANT_ID_COLUMN}
Sahin Caliskanf00a8762019-01-24 14:32:12 -08002214 */
2215 Uri RCS_1_TO_1_THREAD_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
2216 RCS_1_TO_1_THREAD_URI_PART);
2217
2218 /**
2219 * The SMS/MMS thread to fallback to in case of an RCS outage
2220 */
2221 String FALLBACK_THREAD_ID_COLUMN = "rcs_fallback_thread_id";
2222 }
2223
2224 /**
2225 * The table that {@link android.telephony.ims.RcsGroupThread} gets persisted to
2226 */
2227 interface RcsGroupThreadColumns extends RcsThreadColumns {
2228 /**
2229 * The path that should be used for referring to
2230 * {@link android.telephony.ims.RcsGroupThread}s in
2231 * {@link com.android.providers.telephony.RcsProvider} URIs.
2232 */
2233 String RCS_GROUP_THREAD_URI_PART = "group_thread";
2234
2235 /**
2236 * The URI to query or modify {@link android.telephony.ims.RcsGroupThread}s via the
2237 * content provider
2238 */
2239 Uri RCS_GROUP_THREAD_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
2240 RCS_GROUP_THREAD_URI_PART);
2241
2242 /**
2243 * The owner/admin of the {@link android.telephony.ims.RcsGroupThread}
2244 */
2245 String OWNER_PARTICIPANT_COLUMN = "owner_participant";
2246
2247 /**
2248 * The user visible name of the group
2249 */
2250 String GROUP_NAME_COLUMN = "group_name";
2251
2252 /**
2253 * The user visible icon of the group
2254 */
2255 String GROUP_ICON_COLUMN = "group_icon";
2256
2257 /**
2258 * The RCS conference URI for this group
2259 */
2260 String CONFERENCE_URI_COLUMN = "conference_uri";
2261 }
2262
2263 /**
2264 * The view that enables polling from all types of RCS threads at once
2265 */
2266 interface RcsUnifiedThreadColumns extends RcsThreadColumns, Rcs1To1ThreadColumns,
2267 RcsGroupThreadColumns {
2268 /**
2269 * The type of this {@link android.telephony.ims.RcsThread}
2270 */
2271 String THREAD_TYPE_COLUMN = "thread_type";
2272
2273 /**
2274 * Integer returned as a result from a database query that denotes the thread is 1 to 1
2275 */
2276 int THREAD_TYPE_1_TO_1 = 0;
2277
2278 /**
2279 * Integer returned as a result from a database query that denotes the thread is 1 to 1
2280 */
2281 int THREAD_TYPE_GROUP = 1;
2282 }
2283
2284 /**
2285 * The table that {@link android.telephony.ims.RcsParticipant} gets persisted to
2286 */
2287 interface RcsParticipantColumns {
2288 /**
2289 * The path that should be used for referring to
2290 * {@link android.telephony.ims.RcsParticipant}s in
2291 * {@link com.android.providers.telephony.RcsProvider} URIs.
2292 */
2293 String RCS_PARTICIPANT_URI_PART = "participant";
2294
2295 /**
2296 * The URI to query or modify {@link android.telephony.ims.RcsParticipant}s via the
2297 * content provider
2298 */
2299 Uri RCS_PARTICIPANT_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
2300 RCS_PARTICIPANT_URI_PART);
2301
2302 /**
2303 * The unique identifier of the entry in the database
2304 */
2305 String RCS_PARTICIPANT_ID_COLUMN = "rcs_participant_id";
2306
2307 /**
2308 * A foreign key on canonical_address table, also used by SMS/MMS
2309 */
2310 String CANONICAL_ADDRESS_ID_COLUMN = "canonical_address_id";
2311
2312 /**
2313 * The user visible RCS alias for this participant.
2314 */
2315 String RCS_ALIAS_COLUMN = "rcs_alias";
2316 }
2317
2318 /**
2319 * Additional constants to enable access to {@link android.telephony.ims.RcsParticipant}
2320 * related data
2321 */
2322 interface RcsParticipantHelpers extends RcsParticipantColumns {
2323 /**
2324 * The view that unifies "rcs_participant" and "canonical_addresses" tables for easy
2325 * access to participant address.
2326 */
2327 String RCS_PARTICIPANT_WITH_ADDRESS_VIEW = "rcs_participant_with_address_view";
2328
2329 /**
2330 * The view that unifies "rcs_participant", "canonical_addresses" and
2331 * "rcs_thread_participant" junction table to get full information on participants that
2332 * contribute to threads.
2333 */
2334 String RCS_PARTICIPANT_WITH_THREAD_VIEW = "rcs_participant_with_thread_view";
2335 }
2336
2337 /**
2338 * The table that {@link android.telephony.ims.RcsMessage} gets persisted to
2339 */
2340 interface RcsMessageColumns {
2341 /**
2342 * Denotes the type of this message (i.e.
2343 * {@link android.telephony.ims.RcsIncomingMessage} or
2344 * {@link android.telephony.ims.RcsOutgoingMessage}
2345 */
2346 String MESSAGE_TYPE_COLUMN = "rcs_message_type";
2347
2348 /**
2349 * The unique identifier for the message in the database - i.e. the primary key.
2350 */
2351 String MESSAGE_ID_COLUMN = "rcs_message_row_id";
2352
2353 /**
2354 * The globally unique RCS identifier for the message. Please see 4.4.5.2 - GSMA
2355 * RCC.53 (RCS Device API 1.6 Specification)
2356 */
2357 String GLOBAL_ID_COLUMN = "rcs_message_global_id";
2358
2359 /**
2360 * The subscription where this message was sent from/to.
2361 */
2362 String SUB_ID_COLUMN = "sub_id";
2363
2364 /**
2365 * The sending status of the message.
2366 * @see android.telephony.ims.RcsMessage.RcsMessageStatus
2367 */
2368 String STATUS_COLUMN = "status";
2369
2370 /**
2371 * The creation timestamp of the message.
2372 */
2373 String ORIGINATION_TIMESTAMP_COLUMN = "origination_timestamp";
2374
2375 /**
2376 * The text content of the message.
2377 */
2378 String MESSAGE_TEXT_COLUMN = "rcs_text";
2379
2380 /**
2381 * The latitude content of the message, if it contains a location.
2382 */
2383 String LATITUDE_COLUMN = "latitude";
2384
2385 /**
2386 * The longitude content of the message, if it contains a location.
2387 */
2388 String LONGITUDE_COLUMN = "longitude";
2389 }
2390
2391 /**
2392 * The table that additional information of {@link android.telephony.ims.RcsIncomingMessage}
2393 * gets persisted to.
2394 */
2395 interface RcsIncomingMessageColumns extends RcsMessageColumns {
2396 /**
2397 The path that should be used for referring to
2398 * {@link android.telephony.ims.RcsIncomingMessage}s in
2399 * {@link com.android.providers.telephony.RcsProvider} URIs.
2400 */
2401 String INCOMING_MESSAGE_URI_PART = "incoming_message";
2402
2403 /**
2404 * The URI to query incoming messages through
2405 * {@link com.android.providers.telephony.RcsProvider}
2406 */
2407 Uri INCOMING_MESSAGE_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
2408 INCOMING_MESSAGE_URI_PART);
2409
2410 /**
2411 * The ID of the {@link android.telephony.ims.RcsParticipant} that sent this message
2412 */
2413 String SENDER_PARTICIPANT_ID_COLUMN = "sender_participant";
2414
2415 /**
2416 * The timestamp of arrival for this message.
2417 */
2418 String ARRIVAL_TIMESTAMP_COLUMN = "arrival_timestamp";
2419
2420 /**
2421 * The time when the recipient has read this message.
2422 */
2423 String SEEN_TIMESTAMP_COLUMN = "seen_timestamp";
2424 }
2425
2426 /**
2427 * The table that additional information of {@link android.telephony.ims.RcsOutgoingMessage}
2428 * gets persisted to.
2429 */
2430 interface RcsOutgoingMessageColumns extends RcsMessageColumns {
2431 /**
2432 * The path that should be used for referring to
2433 * {@link android.telephony.ims.RcsOutgoingMessage}s in
2434 * {@link com.android.providers.telephony.RcsProvider} URIs.
2435 */
2436 String OUTGOING_MESSAGE_URI_PART = "outgoing_message";
2437
2438 /**
2439 * The URI to query or modify {@link android.telephony.ims.RcsOutgoingMessage}s via the
2440 * content provider
2441 */
2442 Uri OUTGOING_MESSAGE_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
2443 OUTGOING_MESSAGE_URI_PART);
2444 }
2445
2446 /**
2447 * The delivery information of an {@link android.telephony.ims.RcsOutgoingMessage}
2448 */
2449 interface RcsMessageDeliveryColumns extends RcsOutgoingMessageColumns {
2450 /**
2451 * The path that should be used for referring to
2452 * {@link android.telephony.ims.RcsOutgoingMessageDelivery}s in
2453 * {@link com.android.providers.telephony.RcsProvider} URIs.
2454 */
2455 String DELIVERY_URI_PART = "delivery";
2456
2457 /**
2458 * The timestamp of delivery of this message.
2459 */
2460 String DELIVERED_TIMESTAMP_COLUMN = "delivered_timestamp";
2461
2462 /**
2463 * The time when the recipient has read this message.
2464 */
2465 String SEEN_TIMESTAMP_COLUMN = "seen_timestamp";
2466 }
2467
2468 /**
2469 * The views that allow querying {@link android.telephony.ims.RcsIncomingMessage} and
2470 * {@link android.telephony.ims.RcsOutgoingMessage} at the same time.
2471 */
2472 interface RcsUnifiedMessageColumns extends RcsIncomingMessageColumns,
2473 RcsOutgoingMessageColumns {
2474 /**
2475 * The path that is used to query all {@link android.telephony.ims.RcsMessage} in
2476 * {@link com.android.providers.telephony.RcsProvider} URIs.
2477 */
2478 String UNIFIED_MESSAGE_URI_PART = "message";
2479
2480 /**
2481 * The URI to query all types of {@link android.telephony.ims.RcsMessage}s
2482 */
2483 Uri UNIFIED_MESSAGE_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
2484 UNIFIED_MESSAGE_URI_PART);
2485
2486 /**
2487 * The name of the view that unites rcs_message and rcs_incoming_message tables.
2488 */
2489 String UNIFIED_INCOMING_MESSAGE_VIEW = "unified_incoming_message_view";
2490
2491 /**
2492 * The name of the view that unites rcs_message and rcs_outgoing_message tables.
2493 */
2494 String UNIFIED_OUTGOING_MESSAGE_VIEW = "unified_outgoing_message_view";
2495
2496 /**
2497 * The column that shows from which table the message entry came from.
2498 */
2499 String MESSAGE_TYPE_COLUMN = "message_type";
2500
2501 /**
2502 * Integer returned as a result from a database query that denotes that the message is
2503 * an incoming message
2504 */
2505 int MESSAGE_TYPE_INCOMING = 1;
2506
2507 /**
2508 * Integer returned as a result from a database query that denotes that the message is
2509 * an outgoing message
2510 */
2511 int MESSAGE_TYPE_OUTGOING = 0;
2512 }
2513
2514 /**
2515 * The table that {@link android.telephony.ims.RcsFileTransferPart} gets persisted to.
2516 */
2517 interface RcsFileTransferColumns {
2518 /**
2519 * The path that should be used for referring to
2520 * {@link android.telephony.ims.RcsFileTransferPart}s in
2521 * {@link com.android.providers.telephony.RcsProvider} URIs.
2522 */
2523 String FILE_TRANSFER_URI_PART = "file_transfer";
2524
2525 /**
2526 * The URI to query or modify {@link android.telephony.ims.RcsFileTransferPart}s via the
2527 * content provider
2528 */
2529 Uri FILE_TRANSFER_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
2530 FILE_TRANSFER_URI_PART);
2531
2532 /**
2533 * The globally unique file transfer ID for this RCS file transfer.
2534 */
2535 String FILE_TRANSFER_ID_COLUMN = "rcs_file_transfer_id";
2536
2537 /**
2538 * The RCS session ID for this file transfer. The ID is implementation dependent but
2539 * should be unique.
2540 */
2541 String SESSION_ID_COLUMN = "session_id";
2542
2543 /**
2544 * The URI that points to the content of this file transfer
2545 */
2546 String CONTENT_URI_COLUMN = "content_uri";
2547
2548 /**
2549 * The file type of this file transfer in bytes. The validity of types is not enforced
2550 * in {@link android.telephony.ims.RcsMessageStore} APIs.
2551 */
2552 String CONTENT_TYPE_COLUMN = "content_type";
2553
2554 /**
2555 * The size of the file transfer in bytes.
2556 */
2557 String FILE_SIZE_COLUMN = "file_size";
2558
2559 /**
2560 * Number of bytes that was successfully transmitted for this file transfer
2561 */
2562 String SUCCESSFULLY_TRANSFERRED_BYTES = "transfer_offset";
2563
2564 /**
2565 * The status of this file transfer
2566 * @see android.telephony.ims.RcsFileTransferPart.RcsFileTransferStatus
2567 */
2568 String TRANSFER_STATUS_COLUMN = "transfer_status";
2569
2570 /**
2571 * The on-screen width of the file transfer, if it contains multi-media
2572 */
2573 String WIDTH_COLUMN = "width";
2574
2575 /**
2576 * The on-screen height of the file transfer, if it contains multi-media
2577 */
2578 String HEIGHT_COLUMN = "height";
2579
2580 /**
2581 * The duration of the content in milliseconds if this file transfer contains
2582 * multi-media
2583 */
2584 String DURATION_MILLIS_COLUMN = "duration";
2585
2586 /**
2587 * The URI to the preview of the content of this file transfer
2588 */
2589 String PREVIEW_URI_COLUMN = "preview_uri";
2590
2591 /**
2592 * The type of the preview of the content of this file transfer. The validity of types
2593 * is not enforced in {@link android.telephony.ims.RcsMessageStore} APIs.
2594 */
2595 String PREVIEW_TYPE_COLUMN = "preview_type";
2596 }
2597
2598 /**
2599 * The table that holds the information for
2600 * {@link android.telephony.ims.RcsGroupThreadEvent} and its subclasses.
2601 */
2602 interface RcsThreadEventColumns {
2603 /**
2604 * The string used in the {@link com.android.providers.telephony.RcsProvider} URI to
2605 * refer to participant joined events (example URI:
2606 * {@code content://rcs/group_thread/3/participant_joined_event})
2607 */
2608 String PARTICIPANT_JOINED_URI_PART = "participant_joined_event";
2609
2610 /**
2611 * The string used in the {@link com.android.providers.telephony.RcsProvider} URI to
2612 * refer to participant left events. (example URI:
2613 * {@code content://rcs/group_thread/3/participant_left_event/4})
2614 */
2615 String PARTICIPANT_LEFT_URI_PART = "participant_left_event";
2616
2617 /**
2618 * The string used in the {@link com.android.providers.telephony.RcsProvider} URI to
2619 * refer to name changed events. (example URI:
2620 * {@code content://rcs/group_thread/3/name_changed_event})
2621 */
2622 String NAME_CHANGED_URI_PART = "name_changed_event";
2623
2624 /**
2625 * The string used in the {@link com.android.providers.telephony.RcsProvider} URI to
2626 * refer to icon changed events. (example URI:
2627 * {@code content://rcs/group_thread/3/icon_changed_event})
2628 */
2629 String ICON_CHANGED_URI_PART = "icon_changed_event";
2630
2631 /**
2632 * The unique ID of this event in the database, i.e. the primary key
2633 */
2634 String EVENT_ID_COLUMN = "event_id";
2635
2636 /**
2637 * The type of this event
2638 *
2639 * @see RcsEventTypes
2640 */
2641 String EVENT_TYPE_COLUMN = "event_type";
2642
2643 /**
2644 * The timestamp in milliseconds of when this event happened
2645 */
2646 String TIMESTAMP_COLUMN = "origination_timestamp";
2647
2648 /**
2649 * The participant that generated this event
2650 */
2651 String SOURCE_PARTICIPANT_ID_COLUMN = "source_participant";
2652
2653 /**
2654 * The receiving participant of this event if this was an
2655 * {@link android.telephony.ims.RcsGroupThreadParticipantJoinedEvent} or
2656 * {@link android.telephony.ims.RcsGroupThreadParticipantLeftEvent}
2657 */
2658 String DESTINATION_PARTICIPANT_ID_COLUMN = "destination_participant";
2659
2660 /**
2661 * The URI for the new icon of the group thread if this was an
2662 * {@link android.telephony.ims.RcsGroupThreadIconChangedEvent}
2663 */
2664 String NEW_ICON_URI_COLUMN = "new_icon_uri";
2665
2666 /**
2667 * The URI for the new name of the group thread if this was an
2668 * {@link android.telephony.ims.RcsGroupThreadNameChangedEvent}
2669 */
2670 String NEW_NAME_COLUMN = "new_name";
2671 }
2672
2673 /**
2674 * The table that {@link android.telephony.ims.RcsParticipantAliasChangedEvent} gets
2675 * persisted to
2676 */
2677 interface RcsParticipantEventColumns {
2678 /**
2679 * The path that should be used for referring to
2680 * {@link android.telephony.ims.RcsParticipantAliasChangedEvent}s in
2681 * {@link com.android.providers.telephony.RcsProvider} URIs.
2682 */
2683 String ALIAS_CHANGE_EVENT_URI_PART = "alias_change_event";
2684
2685 /**
2686 * The new alias of the participant
2687 */
2688 String NEW_ALIAS_COLUMN = "new_alias";
2689 }
2690
2691 /**
2692 * These values are used in {@link com.android.providers.telephony.RcsProvider} to determine
2693 * what kind of event is present in the storage.
2694 */
2695 interface RcsEventTypes {
2696 /**
2697 * Integer constant that is stored in the
2698 * {@link com.android.providers.telephony.RcsProvider} database that denotes the event
2699 * is of type {@link android.telephony.ims.RcsParticipantAliasChangedEvent}
2700 */
2701 int PARTICIPANT_ALIAS_CHANGED_EVENT_TYPE = 1;
2702
2703 /**
2704 * Integer constant that is stored in the
2705 * {@link com.android.providers.telephony.RcsProvider} database that denotes the event
2706 * is of type {@link android.telephony.ims.RcsGroupThreadParticipantJoinedEvent}
2707 */
2708 int PARTICIPANT_JOINED_EVENT_TYPE = 2;
2709
2710 /**
2711 * Integer constant that is stored in the
2712 * {@link com.android.providers.telephony.RcsProvider} database that denotes the event
2713 * is of type {@link android.telephony.ims.RcsGroupThreadParticipantLeftEvent}
2714 */
2715 int PARTICIPANT_LEFT_EVENT_TYPE = 4;
2716
2717 /**
2718 * Integer constant that is stored in the
2719 * {@link com.android.providers.telephony.RcsProvider} database that denotes the event
2720 * is of type {@link android.telephony.ims.RcsGroupThreadIconChangedEvent}
2721 */
2722 int ICON_CHANGED_EVENT_TYPE = 8;
2723
2724 /**
2725 * Integer constant that is stored in the
2726 * {@link com.android.providers.telephony.RcsProvider} database that denotes the event
2727 * is of type {@link android.telephony.ims.RcsGroupThreadNameChangedEvent}
2728 */
2729 int NAME_CHANGED_EVENT_TYPE = 16;
2730 }
2731
2732 /**
2733 * The view that allows unified querying across all events
2734 */
2735 interface RcsUnifiedEventHelper extends RcsParticipantEventColumns, RcsThreadEventColumns {
2736 /**
2737 * The path that should be used for referring to
2738 * {@link android.telephony.ims.RcsEvent}s in
2739 * {@link com.android.providers.telephony.RcsProvider} URIs.
2740 */
2741 String RCS_EVENT_QUERY_URI_PATH = "event";
2742
2743 /**
2744 * The URI to query {@link android.telephony.ims.RcsEvent}s via the content provider.
2745 */
2746 Uri RCS_EVENT_QUERY_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
2747 RCS_EVENT_QUERY_URI_PATH);
2748 }
Leland Miller7b378ab2019-01-24 16:09:10 -08002749
2750 /**
2751 * Allows RCS specific canonical address handling.
2752 */
2753 interface RcsCanonicalAddressHelper {
2754 /**
2755 * Returns the canonical address ID for a canonical address, if now row exists, this
2756 * will add a row and return its ID. This helper works against the same table used by
2757 * the SMS and MMS threads, but is accessible only by the phone process for use by RCS
2758 * message storage.
2759 *
2760 * @throws IllegalArgumentException if unable to retrieve or create the canonical
2761 * address entry.
2762 */
2763 static long getOrCreateCanonicalAddressId(
2764 ContentResolver contentResolver, String canonicalAddress) {
2765
2766 Uri.Builder uriBuilder = CONTENT_AND_AUTHORITY.buildUpon();
2767 uriBuilder.appendPath("canonical-address");
2768 uriBuilder.appendQueryParameter("address", canonicalAddress);
2769 Uri uri = uriBuilder.build();
2770
2771 try (Cursor cursor = contentResolver.query(uri, null, null, null)) {
2772 if (cursor != null && cursor.moveToFirst()) {
2773 return cursor.getLong(cursor.getColumnIndex(CanonicalAddressesColumns._ID));
2774 } else {
2775 Rlog.e(TAG, "getOrCreateCanonicalAddressId returned no rows");
2776 }
2777 }
2778
2779 Rlog.e(TAG, "getOrCreateCanonicalAddressId failed");
2780 throw new IllegalArgumentException(
2781 "Unable to find or allocate a canonical address ID");
2782 }
2783 }
Sahin Caliskanf00a8762019-01-24 14:32:12 -08002784 }
2785
2786 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08002787 * Contains all MMS messages.
2788 */
2789 public static final class Mms implements BaseMmsColumns {
2790
2791 /**
2792 * Not instantiable.
2793 * @hide
2794 */
2795 private Mms() {
2796 }
2797
2798 /**
2799 * The {@code content://} URI for this table.
2800 */
2801 public static final Uri CONTENT_URI = Uri.parse("content://mms");
2802
2803 /**
2804 * Content URI for getting MMS report requests.
2805 */
2806 public static final Uri REPORT_REQUEST_URI = Uri.withAppendedPath(
2807 CONTENT_URI, "report-request");
2808
2809 /**
2810 * Content URI for getting MMS report status.
2811 */
2812 public static final Uri REPORT_STATUS_URI = Uri.withAppendedPath(
2813 CONTENT_URI, "report-status");
2814
2815 /**
2816 * The default sort order for this table.
2817 */
2818 public static final String DEFAULT_SORT_ORDER = "date DESC";
2819
2820 /**
2821 * Regex pattern for names and email addresses.
2822 * <ul>
2823 * <li><em>mailbox</em> = {@code name-addr}</li>
2824 * <li><em>name-addr</em> = {@code [display-name] angle-addr}</li>
2825 * <li><em>angle-addr</em> = {@code [CFWS] "<" addr-spec ">" [CFWS]}</li>
2826 * </ul>
2827 * @hide
2828 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002829 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002830 public static final Pattern NAME_ADDR_EMAIL_PATTERN =
2831 Pattern.compile("\\s*(\"[^\"]*\"|[^<>\"]+)\\s*<([^<>]+)>\\s*");
2832
2833 /**
2834 * Helper method to query this table.
2835 * @hide
2836 */
2837 public static Cursor query(
2838 ContentResolver cr, String[] projection) {
2839 return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
2840 }
2841
2842 /**
2843 * Helper method to query this table.
2844 * @hide
2845 */
2846 public static Cursor query(
2847 ContentResolver cr, String[] projection,
2848 String where, String orderBy) {
2849 return cr.query(CONTENT_URI, projection,
2850 where, null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
2851 }
2852
2853 /**
2854 * Helper method to extract email address from address string.
2855 * @hide
2856 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002857 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002858 public static String extractAddrSpec(String address) {
2859 Matcher match = NAME_ADDR_EMAIL_PATTERN.matcher(address);
2860
2861 if (match.matches()) {
2862 return match.group(2);
2863 }
2864 return address;
2865 }
2866
2867 /**
2868 * Is the specified address an email address?
2869 *
2870 * @param address the input address to test
2871 * @return true if address is an email address; false otherwise.
2872 * @hide
2873 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002874 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002875 public static boolean isEmailAddress(String address) {
2876 if (TextUtils.isEmpty(address)) {
2877 return false;
2878 }
2879
2880 String s = extractAddrSpec(address);
2881 Matcher match = Patterns.EMAIL_ADDRESS.matcher(s);
2882 return match.matches();
2883 }
2884
2885 /**
2886 * Is the specified number a phone number?
2887 *
2888 * @param number the input number to test
2889 * @return true if number is a phone number; false otherwise.
2890 * @hide
2891 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002892 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002893 public static boolean isPhoneNumber(String number) {
2894 if (TextUtils.isEmpty(number)) {
2895 return false;
2896 }
2897
2898 Matcher match = Patterns.PHONE.matcher(number);
2899 return match.matches();
2900 }
2901
2902 /**
2903 * Contains all MMS messages in the MMS app inbox.
2904 */
2905 public static final class Inbox implements BaseMmsColumns {
2906
2907 /**
2908 * Not instantiable.
2909 * @hide
2910 */
2911 private Inbox() {
2912 }
2913
2914 /**
2915 * The {@code content://} style URL for this table.
2916 */
2917 public static final Uri
2918 CONTENT_URI = Uri.parse("content://mms/inbox");
2919
2920 /**
2921 * The default sort order for this table.
2922 */
2923 public static final String DEFAULT_SORT_ORDER = "date DESC";
2924 }
2925
2926 /**
2927 * Contains all MMS messages in the MMS app sent folder.
2928 */
2929 public static final class Sent implements BaseMmsColumns {
2930
2931 /**
2932 * Not instantiable.
2933 * @hide
2934 */
2935 private Sent() {
2936 }
2937
2938 /**
2939 * The {@code content://} style URL for this table.
2940 */
2941 public static final Uri
2942 CONTENT_URI = Uri.parse("content://mms/sent");
2943
2944 /**
2945 * The default sort order for this table.
2946 */
2947 public static final String DEFAULT_SORT_ORDER = "date DESC";
2948 }
2949
2950 /**
2951 * Contains all MMS messages in the MMS app drafts folder.
2952 */
2953 public static final class Draft implements BaseMmsColumns {
2954
2955 /**
2956 * Not instantiable.
2957 * @hide
2958 */
2959 private Draft() {
2960 }
2961
2962 /**
2963 * The {@code content://} style URL for this table.
2964 */
2965 public static final Uri
2966 CONTENT_URI = Uri.parse("content://mms/drafts");
2967
2968 /**
2969 * The default sort order for this table.
2970 */
2971 public static final String DEFAULT_SORT_ORDER = "date DESC";
2972 }
2973
2974 /**
2975 * Contains all MMS messages in the MMS app outbox.
2976 */
2977 public static final class Outbox implements BaseMmsColumns {
2978
2979 /**
2980 * Not instantiable.
2981 * @hide
2982 */
2983 private Outbox() {
2984 }
2985
2986 /**
2987 * The {@code content://} style URL for this table.
2988 */
2989 public static final Uri
2990 CONTENT_URI = Uri.parse("content://mms/outbox");
2991
2992 /**
2993 * The default sort order for this table.
2994 */
2995 public static final String DEFAULT_SORT_ORDER = "date DESC";
2996 }
2997
2998 /**
2999 * Contains address information for an MMS message.
3000 */
3001 public static final class Addr implements BaseColumns {
3002
3003 /**
3004 * Not instantiable.
3005 * @hide
3006 */
3007 private Addr() {
3008 }
3009
3010 /**
3011 * The ID of MM which this address entry belongs to.
3012 * <P>Type: INTEGER (long)</P>
3013 */
3014 public static final String MSG_ID = "msg_id";
3015
3016 /**
3017 * The ID of contact entry in Phone Book.
3018 * <P>Type: INTEGER (long)</P>
3019 */
3020 public static final String CONTACT_ID = "contact_id";
3021
3022 /**
3023 * The address text.
3024 * <P>Type: TEXT</P>
3025 */
3026 public static final String ADDRESS = "address";
3027
3028 /**
3029 * Type of address: must be one of {@code PduHeaders.BCC},
3030 * {@code PduHeaders.CC}, {@code PduHeaders.FROM}, {@code PduHeaders.TO}.
3031 * <P>Type: INTEGER</P>
3032 */
3033 public static final String TYPE = "type";
3034
3035 /**
3036 * Character set of this entry (MMS charset value).
3037 * <P>Type: INTEGER</P>
3038 */
3039 public static final String CHARSET = "charset";
Nagarajaa15ee4d2019-07-09 14:54:33 +05303040
3041 /**
3042 * Generates a Addr {@link Uri} for message, used to perform Addr table operation
3043 * for mms.
3044 *
3045 * @param messageId the messageId used to generate Addr {@link Uri} dynamically
3046 * @return the addrUri used to perform Addr table operation for mms
3047 */
3048 @NonNull
3049 public static Uri getAddrUriForMessage(@NonNull String messageId) {
3050 Uri addrUri = Mms.CONTENT_URI.buildUpon()
3051 .appendPath(String.valueOf(messageId)).appendPath("addr").build();
3052 return addrUri;
3053 }
Dan Willemsen4980bf42017-02-14 14:17:12 -08003054 }
3055
3056 /**
3057 * Contains message parts.
Leland Miller6c753552019-01-22 17:28:55 -08003058 *
3059 * To avoid issues where applications might cache a part ID, the ID of a deleted part must
3060 * not be reused to point at a new part.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003061 */
3062 public static final class Part implements BaseColumns {
3063
3064 /**
3065 * Not instantiable.
3066 * @hide
3067 */
3068 private Part() {
3069 }
3070
3071 /**
Nagarajaa15ee4d2019-07-09 14:54:33 +05303072 * The name of part table.
3073 */
3074 private static final String TABLE_PART = "part";
3075
3076 /**
Leland Miller6c753552019-01-22 17:28:55 -08003077 * The {@code content://} style URL for this table. Can be appended with a part ID to
3078 * address individual parts.
3079 */
Leland Miller7a29ca62019-04-15 15:57:28 -07003080 @NonNull
Nagarajaa15ee4d2019-07-09 14:54:33 +05303081 public static final Uri CONTENT_URI = Uri.withAppendedPath(Mms.CONTENT_URI, TABLE_PART);
Leland Miller6c753552019-01-22 17:28:55 -08003082
3083 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08003084 * The identifier of the message which this part belongs to.
3085 * <P>Type: INTEGER</P>
3086 */
3087 public static final String MSG_ID = "mid";
3088
3089 /**
3090 * The order of the part.
3091 * <P>Type: INTEGER</P>
3092 */
3093 public static final String SEQ = "seq";
3094
3095 /**
3096 * The content type of the part.
3097 * <P>Type: TEXT</P>
3098 */
3099 public static final String CONTENT_TYPE = "ct";
3100
3101 /**
3102 * The name of the part.
3103 * <P>Type: TEXT</P>
3104 */
3105 public static final String NAME = "name";
3106
3107 /**
3108 * The charset of the part.
3109 * <P>Type: TEXT</P>
3110 */
3111 public static final String CHARSET = "chset";
3112
3113 /**
3114 * The file name of the part.
3115 * <P>Type: TEXT</P>
3116 */
3117 public static final String FILENAME = "fn";
3118
3119 /**
3120 * The content disposition of the part.
3121 * <P>Type: TEXT</P>
3122 */
3123 public static final String CONTENT_DISPOSITION = "cd";
3124
3125 /**
3126 * The content ID of the part.
3127 * <P>Type: INTEGER</P>
3128 */
3129 public static final String CONTENT_ID = "cid";
3130
3131 /**
3132 * The content location of the part.
3133 * <P>Type: INTEGER</P>
3134 */
3135 public static final String CONTENT_LOCATION = "cl";
3136
3137 /**
3138 * The start of content-type of the message.
3139 * <P>Type: INTEGER</P>
3140 */
3141 public static final String CT_START = "ctt_s";
3142
3143 /**
3144 * The type of content-type of the message.
3145 * <P>Type: TEXT</P>
3146 */
3147 public static final String CT_TYPE = "ctt_t";
3148
3149 /**
3150 * The location (on filesystem) of the binary data of the part.
3151 * <P>Type: INTEGER</P>
3152 */
3153 public static final String _DATA = "_data";
3154
3155 /**
3156 * The message text.
3157 * <P>Type: TEXT</P>
3158 */
3159 public static final String TEXT = "text";
Nagarajaa15ee4d2019-07-09 14:54:33 +05303160
3161 /**
3162 * Generates a Part {@link Uri} for message, used to perform Part table operation
3163 * for mms.
3164 *
3165 * @param messageId the messageId used to generate Part {@link Uri} dynamically
3166 * @return the partUri used to perform Part table operation for mms
3167 */
3168 @NonNull
3169 public static Uri getPartUriForMessage(@NonNull String messageId) {
3170 Uri partUri = Mms.CONTENT_URI.buildUpon()
3171 .appendPath(String.valueOf(messageId)).appendPath(
3172 TABLE_PART).build();
3173 return partUri;
3174 }
Dan Willemsen4980bf42017-02-14 14:17:12 -08003175 }
3176
3177 /**
3178 * Message send rate table.
3179 */
3180 public static final class Rate {
3181
3182 /**
3183 * Not instantiable.
3184 * @hide
3185 */
3186 private Rate() {
3187 }
3188
3189 /**
3190 * The {@code content://} style URL for this table.
3191 */
3192 public static final Uri CONTENT_URI = Uri.withAppendedPath(
3193 Mms.CONTENT_URI, "rate");
3194
3195 /**
3196 * When a message was successfully sent.
3197 * <P>Type: INTEGER (long)</P>
3198 */
3199 public static final String SENT_TIME = "sent_time";
3200 }
3201
3202 /**
3203 * Intents class.
3204 */
3205 public static final class Intents {
3206
3207 /**
3208 * Not instantiable.
3209 * @hide
3210 */
3211 private Intents() {
3212 }
3213
3214 /**
3215 * Indicates that the contents of specified URIs were changed.
3216 * The application which is showing or caching these contents
3217 * should be updated.
3218 */
3219 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3220 public static final String CONTENT_CHANGED_ACTION
3221 = "android.intent.action.CONTENT_CHANGED";
3222
3223 /**
3224 * An extra field which stores the URI of deleted contents.
3225 */
3226 public static final String DELETED_CONTENTS = "deleted_contents";
3227 }
3228 }
3229
3230 /**
3231 * Contains all MMS and SMS messages.
3232 */
3233 public static final class MmsSms implements BaseColumns {
3234
3235 /**
3236 * Not instantiable.
3237 * @hide
3238 */
3239 private MmsSms() {
3240 }
3241
3242 /**
3243 * The column to distinguish SMS and MMS messages in query results.
3244 */
3245 public static final String TYPE_DISCRIMINATOR_COLUMN =
3246 "transport_type";
3247
3248 /**
3249 * The {@code content://} style URL for this table.
3250 */
3251 public static final Uri CONTENT_URI = Uri.parse("content://mms-sms/");
3252
3253 /**
3254 * The {@code content://} style URL for this table, by conversation.
3255 */
3256 public static final Uri CONTENT_CONVERSATIONS_URI = Uri.parse(
3257 "content://mms-sms/conversations");
3258
3259 /**
3260 * The {@code content://} style URL for this table, by phone number.
3261 */
3262 public static final Uri CONTENT_FILTER_BYPHONE_URI = Uri.parse(
3263 "content://mms-sms/messages/byphone");
3264
3265 /**
3266 * The {@code content://} style URL for undelivered messages in this table.
3267 */
3268 public static final Uri CONTENT_UNDELIVERED_URI = Uri.parse(
3269 "content://mms-sms/undelivered");
3270
3271 /**
3272 * The {@code content://} style URL for draft messages in this table.
3273 */
3274 public static final Uri CONTENT_DRAFT_URI = Uri.parse(
3275 "content://mms-sms/draft");
3276
3277 /**
3278 * The {@code content://} style URL for locked messages in this table.
Nagarajaec816a02019-05-22 15:57:59 +05303279 * <P>This {@link Uri} is used to check at most one locked message found in the union of MMS
3280 * and SMS messages. Also this will return only _id column in response.</P>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003281 */
3282 public static final Uri CONTENT_LOCKED_URI = Uri.parse(
3283 "content://mms-sms/locked");
3284
3285 /**
3286 * Pass in a query parameter called "pattern" which is the text to search for.
3287 * The sort order is fixed to be: {@code thread_id ASC, date DESC}.
3288 */
3289 public static final Uri SEARCH_URI = Uri.parse(
3290 "content://mms-sms/search");
3291
3292 // Constants for message protocol types.
3293
3294 /** SMS protocol type. */
3295 public static final int SMS_PROTO = 0;
3296
3297 /** MMS protocol type. */
3298 public static final int MMS_PROTO = 1;
3299
3300 // Constants for error types of pending messages.
3301
3302 /** Error type: no error. */
3303 public static final int NO_ERROR = 0;
3304
3305 /** Error type: generic transient error. */
3306 public static final int ERR_TYPE_GENERIC = 1;
3307
3308 /** Error type: SMS protocol transient error. */
3309 public static final int ERR_TYPE_SMS_PROTO_TRANSIENT = 2;
3310
3311 /** Error type: MMS protocol transient error. */
3312 public static final int ERR_TYPE_MMS_PROTO_TRANSIENT = 3;
3313
3314 /** Error type: transport failure. */
3315 public static final int ERR_TYPE_TRANSPORT_FAILURE = 4;
3316
3317 /** Error type: permanent error (along with all higher error values). */
3318 public static final int ERR_TYPE_GENERIC_PERMANENT = 10;
3319
3320 /** Error type: SMS protocol permanent error. */
3321 public static final int ERR_TYPE_SMS_PROTO_PERMANENT = 11;
3322
3323 /** Error type: MMS protocol permanent error. */
3324 public static final int ERR_TYPE_MMS_PROTO_PERMANENT = 12;
3325
3326 /**
3327 * Contains pending messages info.
3328 */
3329 public static final class PendingMessages implements BaseColumns {
3330
3331 /**
3332 * Not instantiable.
3333 * @hide
3334 */
3335 private PendingMessages() {
3336 }
3337
3338 public static final Uri CONTENT_URI = Uri.withAppendedPath(
3339 MmsSms.CONTENT_URI, "pending");
3340
3341 /**
3342 * The type of transport protocol (MMS or SMS).
3343 * <P>Type: INTEGER</P>
3344 */
3345 public static final String PROTO_TYPE = "proto_type";
3346
3347 /**
3348 * The ID of the message to be sent or downloaded.
3349 * <P>Type: INTEGER (long)</P>
3350 */
3351 public static final String MSG_ID = "msg_id";
3352
3353 /**
3354 * The type of the message to be sent or downloaded.
3355 * This field is only valid for MM. For SM, its value is always set to 0.
3356 * <P>Type: INTEGER</P>
3357 */
3358 public static final String MSG_TYPE = "msg_type";
3359
3360 /**
3361 * The type of the error code.
3362 * <P>Type: INTEGER</P>
3363 */
3364 public static final String ERROR_TYPE = "err_type";
3365
3366 /**
3367 * The error code of sending/retrieving process.
3368 * <P>Type: INTEGER</P>
3369 */
3370 public static final String ERROR_CODE = "err_code";
3371
3372 /**
3373 * How many times we tried to send or download the message.
3374 * <P>Type: INTEGER</P>
3375 */
3376 public static final String RETRY_INDEX = "retry_index";
3377
3378 /**
3379 * The time to do next retry.
3380 * <P>Type: INTEGER (long)</P>
3381 */
3382 public static final String DUE_TIME = "due_time";
3383
3384 /**
3385 * The time we last tried to send or download the message.
3386 * <P>Type: INTEGER (long)</P>
3387 */
3388 public static final String LAST_TRY = "last_try";
3389
3390 /**
3391 * The subscription to which the message belongs to. Its value will be
3392 * < 0 if the sub id cannot be determined.
3393 * <p>Type: INTEGER (long) </p>
3394 */
3395 public static final String SUBSCRIPTION_ID = "pending_sub_id";
3396 }
3397
3398 /**
3399 * Words table used by provider for full-text searches.
3400 * @hide
3401 */
3402 public static final class WordsTable {
3403
3404 /**
3405 * Not instantiable.
3406 * @hide
3407 */
3408 private WordsTable() {}
3409
3410 /**
3411 * Primary key.
3412 * <P>Type: INTEGER (long)</P>
3413 */
3414 public static final String ID = "_id";
3415
3416 /**
3417 * Source row ID.
3418 * <P>Type: INTEGER (long)</P>
3419 */
3420 public static final String SOURCE_ROW_ID = "source_id";
3421
3422 /**
3423 * Table ID (either 1 or 2).
3424 * <P>Type: INTEGER</P>
3425 */
3426 public static final String TABLE_ID = "table_to_use";
3427
3428 /**
3429 * The words to index.
3430 * <P>Type: TEXT</P>
3431 */
3432 public static final String INDEXED_TEXT = "index_text";
3433 }
3434 }
3435
3436 /**
3437 * Carriers class contains information about APNs, including MMSC information.
3438 */
3439 public static final class Carriers implements BaseColumns {
3440
3441 /**
3442 * Not instantiable.
3443 * @hide
3444 */
3445 private Carriers() {}
3446
3447 /**
3448 * The {@code content://} style URL for this table.
calvinpan5e272372018-12-07 20:03:48 +08003449 * For MSIM, this will return APNs for the default subscription
3450 * {@link SubscriptionManager#getDefaultSubscriptionId()}. To specify subId for MSIM,
3451 * use {@link Uri#withAppendedPath(Uri, String)} to append with subscription id.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003452 */
calvinpanef7b99a2019-04-12 18:48:18 +08003453 @NonNull
Dan Willemsen4980bf42017-02-14 14:17:12 -08003454 public static final Uri CONTENT_URI = Uri.parse("content://telephony/carriers");
3455
3456 /**
calvinpan5e272372018-12-07 20:03:48 +08003457 * The {@code content://} style URL for this table. Used for APN query based on current
3458 * subscription. Instead of specifying carrier matching information in the selection,
3459 * this API will return all matching APNs from current subscription carrier and queries
3460 * will be applied on top of that. If there is no match for MVNO (Mobile Virtual Network
3461 * Operator) APNs, return APNs from its MNO (based on mccmnc) instead. For MSIM, this will
3462 * return APNs for the default subscription
3463 * {@link SubscriptionManager#getDefaultSubscriptionId()}. To specify subId for MSIM,
3464 * use {@link Uri#withAppendedPath(Uri, String)} to append with subscription id.
3465 */
calvinpanef7b99a2019-04-12 18:48:18 +08003466 @NonNull
calvinpan5e272372018-12-07 20:03:48 +08003467 public static final Uri SIM_APN_URI = Uri.parse(
3468 "content://telephony/carriers/sim_apn_list");
3469
3470 /**
yuemingw4c0065f2018-01-16 19:48:10 +00003471 * The {@code content://} style URL to be called from DevicePolicyManagerService,
3472 * can manage DPC-owned APNs.
3473 * @hide
3474 */
3475 public static final Uri DPC_URI = Uri.parse("content://telephony/carriers/dpc");
3476
3477 /**
3478 * The {@code content://} style URL to be called from Telephony to query APNs.
3479 * When DPC-owned APNs are enforced, only DPC-owned APNs are returned, otherwise only
calvinpan5e272372018-12-07 20:03:48 +08003480 * non-DPC-owned APNs are returned. For MSIM, this will return APNs for the default
3481 * subscription {@link SubscriptionManager#getDefaultSubscriptionId()}. To specify subId
3482 * for MSIM, use {@link Uri#withAppendedPath(Uri, String)} to append with subscription id.
yuemingw4c0065f2018-01-16 19:48:10 +00003483 * @hide
3484 */
3485 public static final Uri FILTERED_URI = Uri.parse("content://telephony/carriers/filtered");
3486
3487 /**
3488 * The {@code content://} style URL to be called from DevicePolicyManagerService
3489 * or Telephony to manage whether DPC-owned APNs are enforced.
3490 * @hide
3491 */
3492 public static final Uri ENFORCE_MANAGED_URI = Uri.parse(
3493 "content://telephony/carriers/enforce_managed");
3494
3495 /**
3496 * The column name for ENFORCE_MANAGED_URI, indicates whether DPC-owned APNs are enforced.
3497 * @hide
3498 */
3499 public static final String ENFORCE_KEY = "enforced";
3500
3501 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08003502 * The default sort order for this table.
3503 */
3504 public static final String DEFAULT_SORT_ORDER = "name ASC";
3505
3506 /**
3507 * Entry name.
3508 * <P>Type: TEXT</P>
3509 */
3510 public static final String NAME = "name";
3511
3512 /**
3513 * APN name.
3514 * <P>Type: TEXT</P>
3515 */
3516 public static final String APN = "apn";
3517
3518 /**
3519 * Proxy address.
3520 * <P>Type: TEXT</P>
3521 */
3522 public static final String PROXY = "proxy";
3523
3524 /**
3525 * Proxy port.
3526 * <P>Type: TEXT</P>
3527 */
3528 public static final String PORT = "port";
3529
3530 /**
3531 * MMS proxy address.
3532 * <P>Type: TEXT</P>
3533 */
3534 public static final String MMSPROXY = "mmsproxy";
3535
3536 /**
3537 * MMS proxy port.
3538 * <P>Type: TEXT</P>
3539 */
3540 public static final String MMSPORT = "mmsport";
3541
3542 /**
3543 * Server address.
3544 * <P>Type: TEXT</P>
3545 */
3546 public static final String SERVER = "server";
3547
3548 /**
3549 * APN username.
3550 * <P>Type: TEXT</P>
3551 */
3552 public static final String USER = "user";
3553
3554 /**
3555 * APN password.
3556 * <P>Type: TEXT</P>
3557 */
3558 public static final String PASSWORD = "password";
3559
3560 /**
3561 * MMSC URL.
3562 * <P>Type: TEXT</P>
3563 */
3564 public static final String MMSC = "mmsc";
3565
3566 /**
3567 * Mobile Country Code (MCC).
3568 * <P>Type: TEXT</P>
calvinpan5e272372018-12-07 20:03:48 +08003569 * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return
3570 * matching APNs based on current subscription carrier, thus no need to specify MCC and
3571 * other carrier matching information. In the future, Android will not support MCC for
3572 * APN query.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003573 */
3574 public static final String MCC = "mcc";
3575
3576 /**
3577 * Mobile Network Code (MNC).
3578 * <P>Type: TEXT</P>
calvinpan5e272372018-12-07 20:03:48 +08003579 * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return
3580 * matching APNs based on current subscription carrier, thus no need to specify MNC and
3581 * other carrier matching information. In the future, Android will not support MNC for
3582 * APN query.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003583 */
3584 public static final String MNC = "mnc";
3585
3586 /**
3587 * Numeric operator ID (as String). Usually {@code MCC + MNC}.
3588 * <P>Type: TEXT</P>
calvinpan5e272372018-12-07 20:03:48 +08003589 * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return
3590 * matching APNs based on current subscription carrier, thus no need to specify Numeric
3591 * and other carrier matching information. In the future, Android will not support Numeric
3592 * for APN query.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003593 */
3594 public static final String NUMERIC = "numeric";
3595
3596 /**
3597 * Authentication type.
3598 * <P>Type: INTEGER</P>
3599 */
3600 public static final String AUTH_TYPE = "authtype";
3601
3602 /**
3603 * Comma-delimited list of APN types.
3604 * <P>Type: TEXT</P>
3605 */
3606 public static final String TYPE = "type";
3607
3608 /**
3609 * The protocol to use to connect to this APN.
3610 *
3611 * One of the {@code PDP_type} values in TS 27.007 section 10.1.1.
3612 * For example: {@code IP}, {@code IPV6}, {@code IPV4V6}, or {@code PPP}.
3613 * <P>Type: TEXT</P>
3614 */
3615 public static final String PROTOCOL = "protocol";
3616
3617 /**
3618 * The protocol to use to connect to this APN when roaming.
3619 * The syntax is the same as protocol.
3620 * <P>Type: TEXT</P>
3621 */
3622 public static final String ROAMING_PROTOCOL = "roaming_protocol";
3623
3624 /**
3625 * Is this the current APN?
3626 * <P>Type: INTEGER (boolean)</P>
3627 */
3628 public static final String CURRENT = "current";
3629
3630 /**
3631 * Is this APN enabled?
3632 * <P>Type: INTEGER (boolean)</P>
3633 */
3634 public static final String CARRIER_ENABLED = "carrier_enabled";
3635
3636 /**
3637 * Radio Access Technology info.
3638 * To check what values are allowed, refer to {@link android.telephony.ServiceState}.
3639 * This should be spread to other technologies,
3640 * but is currently only used for LTE (14) and eHRPD (13).
3641 * <P>Type: INTEGER</P>
Cassiee1c88022018-02-22 08:51:03 -08003642 * @deprecated this column is no longer supported, use {@link #NETWORK_TYPE_BITMASK} instead
Dan Willemsen4980bf42017-02-14 14:17:12 -08003643 */
Cassied53df962017-12-05 13:34:33 -08003644 @Deprecated
Dan Willemsen4980bf42017-02-14 14:17:12 -08003645 public static final String BEARER = "bearer";
3646
3647 /**
3648 * Radio Access Technology bitmask.
3649 * To check what values can be contained, refer to {@link android.telephony.ServiceState}.
3650 * 0 indicates all techs otherwise first bit refers to RAT/bearer 1, second bit refers to
3651 * RAT/bearer 2 and so on.
3652 * Bitmask for a radio tech R is (1 << (R - 1))
3653 * <P>Type: INTEGER</P>
3654 * @hide
Cassiee1c88022018-02-22 08:51:03 -08003655 * @deprecated this column is no longer supported, use {@link #NETWORK_TYPE_BITMASK} instead
Dan Willemsen4980bf42017-02-14 14:17:12 -08003656 */
Cassied53df962017-12-05 13:34:33 -08003657 @Deprecated
Dan Willemsen4980bf42017-02-14 14:17:12 -08003658 public static final String BEARER_BITMASK = "bearer_bitmask";
3659
3660 /**
Cassied53df962017-12-05 13:34:33 -08003661 * Radio technology (network type) bitmask.
Cassiee1c88022018-02-22 08:51:03 -08003662 * To check what values can be contained, refer to the NETWORK_TYPE_ constants in
Cassied53df962017-12-05 13:34:33 -08003663 * {@link android.telephony.TelephonyManager}.
3664 * Bitmask for a radio tech R is (1 << (R - 1))
3665 * <P>Type: INTEGER</P>
3666 */
3667 public static final String NETWORK_TYPE_BITMASK = "network_type_bitmask";
3668
3669 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08003670 * MVNO type:
3671 * {@code SPN (Service Provider Name), IMSI, GID (Group Identifier Level 1)}.
3672 * <P>Type: TEXT</P>
calvinpan5e272372018-12-07 20:03:48 +08003673 * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return
3674 * matching APNs based on current subscription carrier, thus no need to specify MVNO_TYPE
3675 * and other carrier matching information. In the future, Android will not support MVNO_TYPE
3676 * for APN query.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003677 */
3678 public static final String MVNO_TYPE = "mvno_type";
3679
3680 /**
3681 * MVNO data.
3682 * Use the following examples.
3683 * <ul>
3684 * <li>SPN: A MOBILE, BEN NL, ...</li>
3685 * <li>IMSI: 302720x94, 2060188, ...</li>
3686 * <li>GID: 4E, 33, ...</li>
3687 * </ul>
3688 * <P>Type: TEXT</P>
calvinpan5e272372018-12-07 20:03:48 +08003689 * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return
3690 * matching APNs based on current subscription carrier, thus no need to specify
3691 * MVNO_MATCH_DATA and other carrier matching information. In the future, Android will not
3692 * support MVNO_MATCH_DATA for APN query.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003693 */
3694 public static final String MVNO_MATCH_DATA = "mvno_match_data";
3695
3696 /**
3697 * The subscription to which the APN belongs to
3698 * <p>Type: INTEGER (long) </p>
3699 */
3700 public static final String SUBSCRIPTION_ID = "sub_id";
3701
3702 /**
chen xu85100482018-10-12 15:30:34 -07003703 * The profile_id to which the APN saved in modem.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003704 * <p>Type: INTEGER</p>
3705 *@hide
3706 */
3707 public static final String PROFILE_ID = "profile_id";
3708
3709 /**
chen xu85100482018-10-12 15:30:34 -07003710 * If set to {@code true}, then the APN setting will persist to the modem.
3711 * <p>Type: INTEGER (boolean)</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003712 *@hide
3713 */
chen xu85100482018-10-12 15:30:34 -07003714 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003715 public static final String MODEM_PERSIST = "modem_cognitive";
Dan Willemsen4980bf42017-02-14 14:17:12 -08003716
3717 /**
chen xu5caa18c2018-11-28 00:21:50 -08003718 * The max number of connections of this APN.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003719 * <p>Type: INTEGER</p>
3720 *@hide
3721 */
chen xu85100482018-10-12 15:30:34 -07003722 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003723 public static final String MAX_CONNECTIONS = "max_conns";
Dan Willemsen4980bf42017-02-14 14:17:12 -08003724
3725 /**
chen xu5caa18c2018-11-28 00:21:50 -08003726 * The wait time for retrying the APN, in milliseconds.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003727 * <p>Type: INTEGER</p>
3728 *@hide
3729 */
chen xu85100482018-10-12 15:30:34 -07003730 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003731 public static final String WAIT_TIME_RETRY = "wait_time";
Dan Willemsen4980bf42017-02-14 14:17:12 -08003732
3733 /**
chen xu5caa18c2018-11-28 00:21:50 -08003734 * The max number of seconds this APN will support its maximum number of connections
3735 * as defined in {@link #MAX_CONNECTIONS}.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003736 * <p>Type: INTEGER</p>
3737 *@hide
3738 */
chen xu85100482018-10-12 15:30:34 -07003739 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003740 public static final String TIME_LIMIT_FOR_MAX_CONNECTIONS = "max_conns_time";
Dan Willemsen4980bf42017-02-14 14:17:12 -08003741
3742 /**
chen xu5caa18c2018-11-28 00:21:50 -08003743 * The MTU (maximum transmit unit) size of the mobile interface to which the APN is
3744 * connected, in bytes.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003745 * <p>Type: INTEGER </p>
3746 * @hide
3747 */
chen xu85100482018-10-12 15:30:34 -07003748 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08003749 public static final String MTU = "mtu";
3750
3751 /**
chen xu85100482018-10-12 15:30:34 -07003752 * APN edit status. APN could be added/edited/deleted by a user or carrier.
chen xu5caa18c2018-11-28 00:21:50 -08003753 * see all possible returned APN edit status.
3754 * <ul>
3755 * <li>{@link #UNEDITED}</li>
3756 * <li>{@link #USER_EDITED}</li>
3757 * <li>{@link #USER_DELETED}</li>
3758 * <li>{@link #CARRIER_EDITED}</li>
3759 * <li>{@link #CARRIER_DELETED}</li>
3760 * </ul>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003761 * <p>Type: INTEGER </p>
3762 * @hide
3763 */
chen xu85100482018-10-12 15:30:34 -07003764 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003765 public static final String EDITED_STATUS = "edited";
Dan Willemsen4980bf42017-02-14 14:17:12 -08003766
3767 /**
chen xu85100482018-10-12 15:30:34 -07003768 * {@code true} if this APN visible to the user, {@code false} otherwise.
3769 * <p>Type: INTEGER (boolean)</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003770 * @hide
3771 */
chen xu85100482018-10-12 15:30:34 -07003772 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08003773 public static final String USER_VISIBLE = "user_visible";
3774
3775 /**
chen xu85100482018-10-12 15:30:34 -07003776 * {@code true} if the user allowed to edit this APN, {@code false} otherwise.
3777 * <p>Type: INTEGER (boolean)</p>
Amit Mahajand4977942017-07-17 14:46:39 -07003778 * @hide
3779 */
chen xu85100482018-10-12 15:30:34 -07003780 @SystemApi
Amit Mahajand4977942017-07-17 14:46:39 -07003781 public static final String USER_EDITABLE = "user_editable";
3782
3783 /**
chen xu5caa18c2018-11-28 00:21:50 -08003784 * {@link #EDITED_STATUS APN edit status} indicates that this APN has not been edited or
3785 * fails to edit.
chen xu85100482018-10-12 15:30:34 -07003786 * <p>Type: INTEGER </p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003787 * @hide
3788 */
chen xu85100482018-10-12 15:30:34 -07003789 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003790 public static final @EditStatus int UNEDITED = 0;
chen xu85100482018-10-12 15:30:34 -07003791
Dan Willemsen4980bf42017-02-14 14:17:12 -08003792 /**
chen xu5caa18c2018-11-28 00:21:50 -08003793 * {@link #EDITED_STATUS APN edit status} indicates that this APN has been edited by users.
chen xu85100482018-10-12 15:30:34 -07003794 * <p>Type: INTEGER </p>
3795 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003796 */
chen xu85100482018-10-12 15:30:34 -07003797 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003798 public static final @EditStatus int USER_EDITED = 1;
chen xu85100482018-10-12 15:30:34 -07003799
Dan Willemsen4980bf42017-02-14 14:17:12 -08003800 /**
chen xu5caa18c2018-11-28 00:21:50 -08003801 * {@link #EDITED_STATUS APN edit status} indicates that this APN has been deleted by users.
chen xu85100482018-10-12 15:30:34 -07003802 * <p>Type: INTEGER </p>
3803 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003804 */
chen xu85100482018-10-12 15:30:34 -07003805 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003806 public static final @EditStatus int USER_DELETED = 2;
chen xu85100482018-10-12 15:30:34 -07003807
Dan Willemsen4980bf42017-02-14 14:17:12 -08003808 /**
chen xu5caa18c2018-11-28 00:21:50 -08003809 * {@link #EDITED_STATUS APN edit status} is an intermediate value used to indicate that an
3810 * entry deleted by the user is still present in the new APN database and therefore must
3811 * remain tagged as user deleted rather than completely removed from the database.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003812 * @hide
3813 */
3814 public static final int USER_DELETED_BUT_PRESENT_IN_XML = 3;
chen xu85100482018-10-12 15:30:34 -07003815
Dan Willemsen4980bf42017-02-14 14:17:12 -08003816 /**
chen xu5caa18c2018-11-28 00:21:50 -08003817 * {@link #EDITED_STATUS APN edit status} indicates that this APN has been edited by
3818 * carriers.
chen xu85100482018-10-12 15:30:34 -07003819 * <p>Type: INTEGER </p>
3820 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003821 */
chen xu85100482018-10-12 15:30:34 -07003822 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003823 public static final @EditStatus int CARRIER_EDITED = 4;
chen xu85100482018-10-12 15:30:34 -07003824
Dan Willemsen4980bf42017-02-14 14:17:12 -08003825 /**
chen xu5caa18c2018-11-28 00:21:50 -08003826 * {@link #EDITED_STATUS APN edit status} indicates that this APN has been deleted by
3827 * carriers. CARRIER_DELETED values are currently not used as there is no use case.
3828 * If they are used, delete() will have to change accordingly. Currently it is hardcoded to
3829 * USER_DELETED.
chen xu85100482018-10-12 15:30:34 -07003830 * <p>Type: INTEGER </p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003831 * @hide
3832 */
chen xu5caa18c2018-11-28 00:21:50 -08003833 public static final @EditStatus int CARRIER_DELETED = 5;
chen xu85100482018-10-12 15:30:34 -07003834
Dan Willemsen4980bf42017-02-14 14:17:12 -08003835 /**
chen xu5caa18c2018-11-28 00:21:50 -08003836 * {@link #EDITED_STATUS APN edit status} is an intermediate value used to indicate that an
3837 * entry deleted by the carrier is still present in the new APN database and therefore must
3838 * remain tagged as user deleted rather than completely removed from the database.
chen xu85100482018-10-12 15:30:34 -07003839 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003840 */
3841 public static final int CARRIER_DELETED_BUT_PRESENT_IN_XML = 6;
yuemingwcf263eb2017-11-08 13:12:18 +00003842
3843 /**
3844 * The owner of the APN.
3845 * <p>Type: INTEGER</p>
3846 * @hide
3847 */
3848 public static final String OWNED_BY = "owned_by";
3849
3850 /**
3851 * Possible value for the OWNED_BY field.
3852 * APN is owned by DPC.
3853 * @hide
3854 */
3855 public static final int OWNED_BY_DPC = 0;
Jordan Liu40617152018-04-06 11:10:12 -07003856
yuemingwcf263eb2017-11-08 13:12:18 +00003857 /**
3858 * Possible value for the OWNED_BY field.
3859 * APN is owned by other sources.
3860 * @hide
3861 */
3862 public static final int OWNED_BY_OTHERS = 1;
Jordan Liu40617152018-04-06 11:10:12 -07003863
3864 /**
3865 * The APN set id. When the user manually selects an APN or the framework sets an APN as
3866 * preferred, all APNs with the same set id as the selected APN should be prioritized over
3867 * APNs in other sets.
chen xu85100482018-10-12 15:30:34 -07003868 * <p>Type: INTEGER</p>
Jordan Liu40617152018-04-06 11:10:12 -07003869 * @hide
3870 */
chen xu85100482018-10-12 15:30:34 -07003871 @SystemApi
Jordan Liu40617152018-04-06 11:10:12 -07003872 public static final String APN_SET_ID = "apn_set_id";
3873
3874 /**
chen xu5caa18c2018-11-28 00:21:50 -08003875 * Possible value for the {@link #APN_SET_ID} field. By default APNs will not belong to a
3876 * set. If the user manually selects an APN without apn set id, there is no need to
3877 * prioritize any specific APN set ids.
chen xu85100482018-10-12 15:30:34 -07003878 * <p>Type: INTEGER</p>
Jordan Liu40617152018-04-06 11:10:12 -07003879 * @hide
3880 */
chen xu85100482018-10-12 15:30:34 -07003881 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003882 public static final int NO_APN_SET_ID = 0;
Jordan Liu40617152018-04-06 11:10:12 -07003883
calvinpanbeb6cb32018-10-19 15:11:22 +08003884 /**
3885 * A unique carrier id associated with this APN
3886 * {@see TelephonyManager#getSimCarrierId()}
3887 * <p>Type: STRING</p>
3888 */
3889 public static final String CARRIER_ID = "carrier_id";
3890
Yuuki Habuaaea4a52019-02-22 11:29:26 +09003891 /**
3892 * The skip 464xlat flag. Flag works as follows.
3893 * {@link #SKIP_464XLAT_DEFAULT}: the APN will skip only APN is IMS and no internet.
3894 * {@link #SKIP_464XLAT_DISABLE}: the APN will NOT skip 464xlat
3895 * {@link #SKIP_464XLAT_ENABLE}: the APN will skip 464xlat
3896 * <p>Type: INTEGER</p>
3897 *
3898 * @hide
3899 */
3900 public static final String SKIP_464XLAT = "skip_464xlat";
3901
3902 /**
3903 * Possible value for the {@link #SKIP_464XLAT} field.
3904 * <p>Type: INTEGER</p>
3905 *
3906 * @hide
3907 */
3908 public static final int SKIP_464XLAT_DEFAULT = -1;
3909
3910 /**
3911 * Possible value for the {@link #SKIP_464XLAT} field.
3912 * <p>Type: INTEGER</p>
3913 *
3914 * @hide
3915 */
3916 public static final int SKIP_464XLAT_DISABLE = 0;
3917
3918 /**
3919 * Possible value for the {@link #SKIP_464XLAT} field.
3920 * <p>Type: INTEGER</p>
3921 *
3922 * @hide
3923 */
3924 public static final int SKIP_464XLAT_ENABLE = 1;
3925
3926
chen xu5caa18c2018-11-28 00:21:50 -08003927 /** @hide */
3928 @IntDef({
3929 UNEDITED,
3930 USER_EDITED,
3931 USER_DELETED,
3932 CARRIER_DELETED,
3933 CARRIER_EDITED,
3934 })
3935 @Retention(RetentionPolicy.SOURCE)
3936 public @interface EditStatus {}
Yuuki Habuaaea4a52019-02-22 11:29:26 +09003937
3938 /** @hide */
3939 @IntDef({
3940 SKIP_464XLAT_DEFAULT,
3941 SKIP_464XLAT_DISABLE,
3942 SKIP_464XLAT_ENABLE,
3943 })
3944 @Retention(RetentionPolicy.SOURCE)
3945 public @interface Skip464XlatStatus {}
3946
Dan Willemsen4980bf42017-02-14 14:17:12 -08003947 }
3948
3949 /**
Chen Xudd0c1c32019-10-21 22:47:27 -07003950 * Contains received cell broadcast messages. More details are available in 3GPP TS 23.041.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003951 * @hide
3952 */
Jordan Liue4141f02019-08-16 14:07:03 -07003953 @SystemApi
Chen Xudd0c1c32019-10-21 22:47:27 -07003954 @TestApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08003955 public static final class CellBroadcasts implements BaseColumns {
3956
3957 /**
3958 * Not instantiable.
3959 * @hide
3960 */
3961 private CellBroadcasts() {}
3962
3963 /**
3964 * The {@code content://} URI for this table.
Chen Xudd0c1c32019-10-21 22:47:27 -07003965 * Only privileged framework components running on phone or network stack uid can
3966 * query or modify this table.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003967 */
Jordan Liue4141f02019-08-16 14:07:03 -07003968 @NonNull
Dan Willemsen4980bf42017-02-14 14:17:12 -08003969 public static final Uri CONTENT_URI = Uri.parse("content://cellbroadcasts");
3970
3971 /**
Chen Xudd0c1c32019-10-21 22:47:27 -07003972 * The {@code content://} URI for query cellbroadcast message history.
3973 * query results include following entries
3974 * <ul>
3975 * <li>{@link #_ID}</li>
3976 * <li>{@link #SLOT_INDEX}</li>
3977 * <li>{@link #GEOGRAPHICAL_SCOPE}</li>
3978 * <li>{@link #PLMN}</li>
3979 * <li>{@link #LAC}</li>
3980 * <li>{@link #CID}</li>
3981 * <li>{@link #SERIAL_NUMBER}</li>
3982 * <li>{@link #SERVICE_CATEGORY}</li>
3983 * <li>{@link #LANGUAGE_CODE}</li>
3984 * <li>{@link #MESSAGE_BODY}</li>
3985 * <li>{@link #DELIVERY_TIME}</li>
3986 * <li>{@link #MESSAGE_READ}</li>
3987 * <li>{@link #MESSAGE_FORMAT}</li>
3988 * <li>{@link #MESSAGE_PRIORITY}</li>
3989 * <li>{@link #ETWS_WARNING_TYPE}</li>
3990 * <li>{@link #CMAS_MESSAGE_CLASS}</li>
3991 * <li>{@link #CMAS_CATEGORY}</li>
3992 * <li>{@link #CMAS_RESPONSE_TYPE}</li>
3993 * <li>{@link #CMAS_SEVERITY}</li>
3994 * <li>{@link #CMAS_URGENCY}</li>
3995 * <li>{@link #CMAS_CERTAINTY}</li>
3996 * </ul>
3997 */
3998 @RequiresPermission(Manifest.permission.READ_CELL_BROADCASTS)
3999 @NonNull
4000 public static final Uri MESSAGE_HISTORY_URI = Uri.parse("content://cellbroadcasts/history");
4001
4002 /**
Chen Xua6379bc2019-10-03 16:48:56 -07004003 * The subscription which received this cell broadcast message.
4004 * @deprecated use {@link #SLOT_INDEX} instead.
Pengquan Meng9f677a02019-08-27 11:20:17 -07004005 * <P>Type: INTEGER</P>
4006 * @hide
4007 */
4008 public static final String SUB_ID = "sub_id";
4009
4010 /**
Chen Xua6379bc2019-10-03 16:48:56 -07004011 * The slot which received this cell broadcast message.
4012 * <P>Type: INTEGER</P>
Chen Xua6379bc2019-10-03 16:48:56 -07004013 */
4014 public static final String SLOT_INDEX = "slot_index";
4015
4016 /**
Jordan Liue4141f02019-08-16 14:07:03 -07004017 * Message geographical scope. Valid values are:
4018 * <ul>
4019 * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_CELL_WIDE}. meaning the
4020 * message is for the radio service cell</li>
4021 * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_CELL_WIDE_IMMEDIATE},
4022 * meaning the message is for the radio service cell and immediately displayed</li>
4023 * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_PLMN_WIDE}, meaning the
4024 * message is for the PLMN (i.e. MCC/MNC)</li>
4025 * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_LOCATION_AREA_WIDE},
4026 * meaning the message is for the location area (in GSM) or service area (in UMTS)</li>
4027 * </ul>
4028 *
4029 * <p>A message meant for a particular scope is automatically dismissed when the device
4030 * exits that scope.</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08004031 * <P>Type: INTEGER</P>
4032 */
4033 public static final String GEOGRAPHICAL_SCOPE = "geo_scope";
4034
4035 /**
4036 * Message serial number.
Jordan Liue4141f02019-08-16 14:07:03 -07004037 * <p>
4038 * A 16-bit integer which identifies a particular CBS (cell
4039 * broadcast short message service) message. The core network is responsible for
4040 * allocating this value, and the value may be managed cyclically (3GPP TS 23.041 section
4041 * 9.2.1) once the serial message has been incremented a sufficient number of times.
4042 * </p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08004043 * <P>Type: INTEGER</P>
4044 */
4045 public static final String SERIAL_NUMBER = "serial_number";
4046
4047 /**
Jordan Liue4141f02019-08-16 14:07:03 -07004048 * PLMN (i.e. MCC/MNC) of broadcast sender. {@code SERIAL_NUMBER + PLMN + LAC + CID}
4049 * uniquely identifies a broadcast for duplicate detection purposes.
Dan Willemsen4980bf42017-02-14 14:17:12 -08004050 * <P>Type: TEXT</P>
4051 */
4052 public static final String PLMN = "plmn";
4053
4054 /**
Jordan Liue4141f02019-08-16 14:07:03 -07004055 * Location area code (LAC).
4056 * <p>Code representing location area (GSM) or service area (UMTS) of broadcast sender.
4057 * Unused for CDMA. Only included if Geographical Scope of message is not PLMN wide (01).
4058 * This value is sent by the network based on the cell tower.
Dan Willemsen4980bf42017-02-14 14:17:12 -08004059 * <P>Type: INTEGER</P>
4060 */
4061 public static final String LAC = "lac";
4062
4063 /**
4064 * Cell ID of message sender (GSM/UMTS). Unused for CDMA. Only included when the
4065 * Geographical Scope of message is cell wide (00 or 11).
4066 * <P>Type: INTEGER</P>
4067 */
4068 public static final String CID = "cid";
4069
4070 /**
4071 * Message code. <em>OBSOLETE: merged into SERIAL_NUMBER.</em>
4072 * <P>Type: INTEGER</P>
Jordan Liue4141f02019-08-16 14:07:03 -07004073 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08004074 */
4075 public static final String V1_MESSAGE_CODE = "message_code";
4076
4077 /**
4078 * Message identifier. <em>OBSOLETE: renamed to SERVICE_CATEGORY.</em>
4079 * <P>Type: INTEGER</P>
Jordan Liue4141f02019-08-16 14:07:03 -07004080 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08004081 */
4082 public static final String V1_MESSAGE_IDENTIFIER = "message_id";
4083
4084 /**
Jordan Liue4141f02019-08-16 14:07:03 -07004085 * Service category which represents the general topic of the message.
4086 * <p>
4087 * For GSM/UMTS: message identifier (see 3GPP TS 23.041 section 9.4.1.2.2)
4088 * For CDMA: a 16-bit CDMA service category (see 3GPP2 C.R1001-D section 9.3)
4089 * </p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08004090 * <P>Type: INTEGER</P>
4091 */
4092 public static final String SERVICE_CATEGORY = "service_category";
4093
4094 /**
Jordan Liue4141f02019-08-16 14:07:03 -07004095 * Message language code. (See 3GPP TS 23.041 section 9.4.1.2.3 for details).
Dan Willemsen4980bf42017-02-14 14:17:12 -08004096 * <P>Type: TEXT</P>
4097 */
4098 public static final String LANGUAGE_CODE = "language";
4099
4100 /**
4101 * Message body.
4102 * <P>Type: TEXT</P>
4103 */
4104 public static final String MESSAGE_BODY = "body";
4105
4106 /**
4107 * Message delivery time.
Jordan Liue4141f02019-08-16 14:07:03 -07004108 * <p>This value is a system timestamp using {@link System#currentTimeMillis}</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08004109 * <P>Type: INTEGER (long)</P>
4110 */
4111 public static final String DELIVERY_TIME = "date";
4112
4113 /**
4114 * Has the message been viewed?
4115 * <P>Type: INTEGER (boolean)</P>
4116 */
4117 public static final String MESSAGE_READ = "read";
4118
4119 /**
Jordan Liue4141f02019-08-16 14:07:03 -07004120 * Message format ({@link android.telephony.SmsCbMessage#MESSAGE_FORMAT_3GPP} or
4121 * {@link android.telephony.SmsCbMessage#MESSAGE_FORMAT_3GPP2}).
Dan Willemsen4980bf42017-02-14 14:17:12 -08004122 * <P>Type: INTEGER</P>
4123 */
4124 public static final String MESSAGE_FORMAT = "format";
4125
4126 /**
Jordan Liue4141f02019-08-16 14:07:03 -07004127 * Message priority.
4128 * <p>This includes
4129 * <ul>
4130 * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_NORMAL}</li>
4131 * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_INTERACTIVE}</li>
4132 * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_URGENT}</li>
4133 * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_EMERGENCY}</li>
4134 * </p>
4135 * </ul>
Dan Willemsen4980bf42017-02-14 14:17:12 -08004136 * <P>Type: INTEGER</P>
4137 */
4138 public static final String MESSAGE_PRIORITY = "priority";
4139
4140 /**
Jordan Liue4141f02019-08-16 14:07:03 -07004141 * ETWS (Earthquake and Tsunami Warning System) warning type (ETWS alerts only).
4142 * <p>See {@link android.telephony.SmsCbEtwsInfo}</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08004143 * <P>Type: INTEGER</P>
4144 */
4145 public static final String ETWS_WARNING_TYPE = "etws_warning_type";
4146
4147 /**
Jordan Liue4141f02019-08-16 14:07:03 -07004148 * CMAS (Commercial Mobile Alert System) message class (CMAS alerts only).
4149 * <p>See {@link android.telephony.SmsCbCmasInfo}</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08004150 * <P>Type: INTEGER</P>
4151 */
4152 public static final String CMAS_MESSAGE_CLASS = "cmas_message_class";
4153
4154 /**
4155 * CMAS category (CMAS alerts only).
4156 * <P>Type: INTEGER</P>
4157 */
4158 public static final String CMAS_CATEGORY = "cmas_category";
4159
4160 /**
4161 * CMAS response type (CMAS alerts only).
4162 * <P>Type: INTEGER</P>
4163 */
4164 public static final String CMAS_RESPONSE_TYPE = "cmas_response_type";
4165
4166 /**
4167 * CMAS severity (CMAS alerts only).
4168 * <P>Type: INTEGER</P>
4169 */
4170 public static final String CMAS_SEVERITY = "cmas_severity";
4171
4172 /**
4173 * CMAS urgency (CMAS alerts only).
4174 * <P>Type: INTEGER</P>
4175 */
4176 public static final String CMAS_URGENCY = "cmas_urgency";
4177
4178 /**
4179 * CMAS certainty (CMAS alerts only).
4180 * <P>Type: INTEGER</P>
4181 */
4182 public static final String CMAS_CERTAINTY = "cmas_certainty";
4183
4184 /** The default sort order for this table. */
4185 public static final String DEFAULT_SORT_ORDER = DELIVERY_TIME + " DESC";
4186
4187 /**
Pengquan Mengc3427c02019-08-12 23:09:34 -07004188 * The timestamp in millisecond of when the device received the message.
4189 * <P>Type: BIGINT</P>
Pengquan Meng7032c1e2019-07-18 17:30:04 -07004190 */
4191 public static final String RECEIVED_TIME = "received_time";
4192
4193 /**
4194 * Indicates that whether the message has been broadcasted to the application.
4195 * <P>Type: BOOLEAN</P>
4196 */
4197 public static final String MESSAGE_BROADCASTED = "message_broadcasted";
4198
4199 /**
4200 * The Warning Area Coordinates Elements. This element is used for geo-fencing purpose.
4201 *
4202 * The geometry and its coordinates are separated vertical bar, the first item is the
4203 * geometry type and the remaining items are the parameter of this geometry.
4204 *
4205 * Only circle and polygon are supported. The coordinates are represented in Horizontal
4206 * coordinates format.
4207 *
4208 * Coordinate encoding:
4209 * "latitude, longitude"
4210 * where -90.00000 <= latitude <= 90.00000 and -180.00000 <= longitude <= 180.00000
4211 *
4212 * Polygon encoding:
4213 * "polygon|lat1,lng1|lat2,lng2|...|latn,lngn"
4214 * lat1,lng1 ... latn,lngn are the vertices coordinate of the polygon.
4215 *
4216 * Circle encoding:
4217 * "circle|lat,lng|radius".
4218 * lat,lng is the center of the circle. The unit of circle's radius is meter.
4219 *
4220 * Example:
4221 * "circle|0,0|100" mean a circle which center located at (0,0) and its radius is 100 meter.
4222 * "polygon|0,1.5|0,1|1,1|1,0" mean a polygon has vertices (0,1.5),(0,1),(1,1),(1,0).
4223 *
4224 * There could be more than one geometry store in this field, they are separated by a
4225 * semicolon.
4226 *
4227 * Example:
4228 * "circle|0,0|100;polygon|0,0|0,1.5|1,1|1,0;circle|100.123,100|200.123"
4229 *
4230 * <P>Type: TEXT</P>
4231 */
4232 public static final String GEOMETRIES = "geometries";
4233
4234 /**
Pengquan Meng9f677a02019-08-27 11:20:17 -07004235 * Geo-Fencing Maximum Wait Time in second. The range of the time is [0, 255]. A device
4236 * shall allow to determine its position meeting operator policy. If the device is unable to
4237 * determine its position meeting operator policy within the GeoFencing Maximum Wait Time,
4238 * it shall present the alert to the user and discontinue further positioning determination
4239 * for the alert.
4240 *
4241 * <P>Type: INTEGER</P>
Pengquan Meng9f677a02019-08-27 11:20:17 -07004242 */
4243 public static final String MAXIMUM_WAIT_TIME = "maximum_wait_time";
4244
4245 /**
Chen Xua6379bc2019-10-03 16:48:56 -07004246 * Query columns for instantiating com.android.cellbroadcastreceiver.CellBroadcastMessage.
Jordan Liue4141f02019-08-16 14:07:03 -07004247 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08004248 */
Jordan Liue4141f02019-08-16 14:07:03 -07004249 @NonNull
Dan Willemsen4980bf42017-02-14 14:17:12 -08004250 public static final String[] QUERY_COLUMNS = {
4251 _ID,
4252 GEOGRAPHICAL_SCOPE,
4253 PLMN,
4254 LAC,
4255 CID,
4256 SERIAL_NUMBER,
4257 SERVICE_CATEGORY,
4258 LANGUAGE_CODE,
4259 MESSAGE_BODY,
4260 DELIVERY_TIME,
4261 MESSAGE_READ,
4262 MESSAGE_FORMAT,
4263 MESSAGE_PRIORITY,
4264 ETWS_WARNING_TYPE,
4265 CMAS_MESSAGE_CLASS,
4266 CMAS_CATEGORY,
4267 CMAS_RESPONSE_TYPE,
4268 CMAS_SEVERITY,
4269 CMAS_URGENCY,
4270 CMAS_CERTAINTY
4271 };
Pengquan Mengc3427c02019-08-12 23:09:34 -07004272
4273 /**
4274 * Query columns for instantiating {@link android.telephony.SmsCbMessage} objects.
Jordan Liue4141f02019-08-16 14:07:03 -07004275 * @hide
Pengquan Mengc3427c02019-08-12 23:09:34 -07004276 */
4277 public static final String[] QUERY_COLUMNS_FWK = {
4278 _ID,
Chen Xua6379bc2019-10-03 16:48:56 -07004279 SLOT_INDEX,
Pengquan Mengc3427c02019-08-12 23:09:34 -07004280 GEOGRAPHICAL_SCOPE,
4281 PLMN,
4282 LAC,
4283 CID,
4284 SERIAL_NUMBER,
4285 SERVICE_CATEGORY,
4286 LANGUAGE_CODE,
4287 MESSAGE_BODY,
4288 MESSAGE_FORMAT,
4289 MESSAGE_PRIORITY,
4290 ETWS_WARNING_TYPE,
4291 CMAS_MESSAGE_CLASS,
4292 CMAS_CATEGORY,
4293 CMAS_RESPONSE_TYPE,
4294 CMAS_SEVERITY,
4295 CMAS_URGENCY,
4296 CMAS_CERTAINTY,
4297 RECEIVED_TIME,
4298 MESSAGE_BROADCASTED,
Pengquan Meng9f677a02019-08-27 11:20:17 -07004299 GEOMETRIES,
4300 MAXIMUM_WAIT_TIME
Pengquan Mengc3427c02019-08-12 23:09:34 -07004301 };
Dan Willemsen4980bf42017-02-14 14:17:12 -08004302 }
Jordan Liub9b75ed2017-02-28 18:15:07 -08004303
4304 /**
4305 * Constants for interfacing with the ServiceStateProvider and the different fields of the
4306 * {@link ServiceState} class accessible through the provider.
4307 */
4308 public static final class ServiceStateTable {
4309
4310 /**
4311 * Not instantiable.
4312 * @hide
4313 */
4314 private ServiceStateTable() {}
4315
4316 /**
4317 * The authority string for the ServiceStateProvider
4318 */
4319 public static final String AUTHORITY = "service-state";
4320
4321 /**
4322 * The {@code content://} style URL for the ServiceStateProvider
4323 */
4324 public static final Uri CONTENT_URI = Uri.parse("content://service-state/");
4325
4326 /**
4327 * Generates a content {@link Uri} used to receive updates on a specific field in the
4328 * ServiceState provider.
4329 * <p>
4330 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
4331 * {@link ServiceState} while your app is running. You can also use a {@link JobService} to
4332 * ensure your app is notified of changes to the {@link Uri} even when it is not running.
4333 * Note, however, that using a {@link JobService} does not guarantee timely delivery of
4334 * updates to the {@link Uri}.
4335 *
Jordan Liu0f332522017-04-19 14:25:29 -07004336 * @param subscriptionId the subscriptionId to receive updates on
Jordan Liub9b75ed2017-02-28 18:15:07 -08004337 * @param field the ServiceState field to receive updates on
4338 * @return the Uri used to observe {@link ServiceState} changes
4339 */
Jordan Liu0f332522017-04-19 14:25:29 -07004340 public static Uri getUriForSubscriptionIdAndField(int subscriptionId, String field) {
4341 return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId))
Jordan Liub9b75ed2017-02-28 18:15:07 -08004342 .appendEncodedPath(field).build();
4343 }
4344
4345 /**
4346 * Generates a content {@link Uri} used to receive updates on every field in the
4347 * ServiceState provider.
4348 * <p>
4349 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
4350 * {@link ServiceState} while your app is running. You can also use a {@link JobService} to
4351 * ensure your app is notified of changes to the {@link Uri} even when it is not running.
4352 * Note, however, that using a {@link JobService} does not guarantee timely delivery of
4353 * updates to the {@link Uri}.
4354 *
Jordan Liu0f332522017-04-19 14:25:29 -07004355 * @param subscriptionId the subscriptionId to receive updates on
Jordan Liub9b75ed2017-02-28 18:15:07 -08004356 * @return the Uri used to observe {@link ServiceState} changes
4357 */
Jordan Liu0f332522017-04-19 14:25:29 -07004358 public static Uri getUriForSubscriptionId(int subscriptionId) {
4359 return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId)).build();
Jordan Liub9b75ed2017-02-28 18:15:07 -08004360 }
4361
4362 /**
4363 * Used to insert a ServiceState into the ServiceStateProvider as a ContentValues instance.
4364 *
4365 * @param state the ServiceState to convert into ContentValues
4366 * @return the convertedContentValues instance
4367 * @hide
4368 */
4369 public static ContentValues getContentValuesForServiceState(ServiceState state) {
4370 ContentValues values = new ContentValues();
Jack Yu2e273b22019-04-02 10:49:35 -07004371 final Parcel p = Parcel.obtain();
4372 state.writeToParcel(p, 0);
4373 // Turn the parcel to byte array. Safe to do this because the content values were never
4374 // written into a persistent storage. ServiceStateProvider keeps values in the memory.
4375 values.put(SERVICE_STATE, p.marshall());
Jordan Liub9b75ed2017-02-28 18:15:07 -08004376 return values;
4377 }
4378
4379 /**
Jack Yu2e273b22019-04-02 10:49:35 -07004380 * The current service state.
4381 *
4382 * This is the entire {@link ServiceState} object in byte array.
4383 *
4384 * @hide
4385 */
4386 public static final String SERVICE_STATE = "service_state";
4387
4388 /**
Jordan Liub9b75ed2017-02-28 18:15:07 -08004389 * An integer value indicating the current voice service state.
4390 * <p>
4391 * Valid values: {@link ServiceState#STATE_IN_SERVICE},
4392 * {@link ServiceState#STATE_OUT_OF_SERVICE}, {@link ServiceState#STATE_EMERGENCY_ONLY},
4393 * {@link ServiceState#STATE_POWER_OFF}.
4394 * <p>
4395 * This is the same as {@link ServiceState#getState()}.
4396 */
4397 public static final String VOICE_REG_STATE = "voice_reg_state";
4398
4399 /**
4400 * An integer value indicating the current data service state.
4401 * <p>
4402 * Valid values: {@link ServiceState#STATE_IN_SERVICE},
4403 * {@link ServiceState#STATE_OUT_OF_SERVICE}, {@link ServiceState#STATE_EMERGENCY_ONLY},
4404 * {@link ServiceState#STATE_POWER_OFF}.
4405 * <p>
4406 * This is the same as {@link ServiceState#getDataRegState()}.
4407 * @hide
4408 */
4409 public static final String DATA_REG_STATE = "data_reg_state";
4410
4411 /**
4412 * An integer value indicating the current voice roaming type.
4413 * <p>
4414 * This is the same as {@link ServiceState#getVoiceRoamingType()}.
4415 * @hide
4416 */
4417 public static final String VOICE_ROAMING_TYPE = "voice_roaming_type";
4418
4419 /**
4420 * An integer value indicating the current data roaming type.
4421 * <p>
4422 * This is the same as {@link ServiceState#getDataRoamingType()}.
4423 * @hide
4424 */
4425 public static final String DATA_ROAMING_TYPE = "data_roaming_type";
4426
4427 /**
4428 * The current registered voice network operator name in long alphanumeric format.
4429 * <p>
4430 * This is the same as {@link ServiceState#getVoiceOperatorAlphaLong()}.
4431 * @hide
4432 */
4433 public static final String VOICE_OPERATOR_ALPHA_LONG = "voice_operator_alpha_long";
4434
4435 /**
4436 * The current registered operator name in short alphanumeric format.
4437 * <p>
4438 * In GSM/UMTS, short format can be up to 8 characters long. The current registered voice
4439 * network operator name in long alphanumeric format.
4440 * <p>
4441 * This is the same as {@link ServiceState#getVoiceOperatorAlphaShort()}.
4442 * @hide
4443 */
4444 public static final String VOICE_OPERATOR_ALPHA_SHORT = "voice_operator_alpha_short";
4445
4446
4447 /**
4448 * The current registered operator numeric id.
4449 * <p>
4450 * In GSM/UMTS, numeric format is 3 digit country code plus 2 or 3 digit
4451 * network code.
4452 * <p>
4453 * This is the same as {@link ServiceState#getOperatorNumeric()}.
4454 */
4455 public static final String VOICE_OPERATOR_NUMERIC = "voice_operator_numeric";
4456
4457 /**
4458 * The current registered data network operator name in long alphanumeric format.
4459 * <p>
4460 * This is the same as {@link ServiceState#getDataOperatorAlphaLong()}.
4461 * @hide
4462 */
4463 public static final String DATA_OPERATOR_ALPHA_LONG = "data_operator_alpha_long";
4464
4465 /**
4466 * The current registered data network operator name in short alphanumeric format.
4467 * <p>
4468 * This is the same as {@link ServiceState#getDataOperatorAlphaShort()}.
4469 * @hide
4470 */
4471 public static final String DATA_OPERATOR_ALPHA_SHORT = "data_operator_alpha_short";
4472
4473 /**
4474 * The current registered data network operator numeric id.
4475 * <p>
4476 * This is the same as {@link ServiceState#getDataOperatorNumeric()}.
4477 * @hide
4478 */
4479 public static final String DATA_OPERATOR_NUMERIC = "data_operator_numeric";
4480
4481 /**
4482 * The current network selection mode.
4483 * <p>
4484 * This is the same as {@link ServiceState#getIsManualSelection()}.
4485 */
4486 public static final String IS_MANUAL_NETWORK_SELECTION = "is_manual_network_selection";
4487
4488 /**
4489 * This is the same as {@link ServiceState#getRilVoiceRadioTechnology()}.
4490 * @hide
4491 */
4492 public static final String RIL_VOICE_RADIO_TECHNOLOGY = "ril_voice_radio_technology";
4493
4494 /**
4495 * This is the same as {@link ServiceState#getRilDataRadioTechnology()}.
4496 * @hide
4497 */
4498 public static final String RIL_DATA_RADIO_TECHNOLOGY = "ril_data_radio_technology";
4499
4500 /**
4501 * This is the same as {@link ServiceState#getCssIndicator()}.
4502 * @hide
4503 */
4504 public static final String CSS_INDICATOR = "css_indicator";
4505
4506 /**
Jack Yu2661fac2018-03-15 13:51:05 -07004507 * This is the same as {@link ServiceState#getCdmaNetworkId()}.
Jordan Liub9b75ed2017-02-28 18:15:07 -08004508 * @hide
4509 */
4510 public static final String NETWORK_ID = "network_id";
4511
4512 /**
Jack Yu2661fac2018-03-15 13:51:05 -07004513 * This is the same as {@link ServiceState#getCdmaSystemId()}.
Jordan Liub9b75ed2017-02-28 18:15:07 -08004514 * @hide
4515 */
4516 public static final String SYSTEM_ID = "system_id";
4517
4518 /**
4519 * This is the same as {@link ServiceState#getCdmaRoamingIndicator()}.
4520 * @hide
4521 */
4522 public static final String CDMA_ROAMING_INDICATOR = "cdma_roaming_indicator";
4523
4524 /**
4525 * This is the same as {@link ServiceState#getCdmaDefaultRoamingIndicator()}.
4526 * @hide
4527 */
4528 public static final String CDMA_DEFAULT_ROAMING_INDICATOR =
4529 "cdma_default_roaming_indicator";
4530
4531 /**
4532 * This is the same as {@link ServiceState#getCdmaEriIconIndex()}.
4533 * @hide
4534 */
4535 public static final String CDMA_ERI_ICON_INDEX = "cdma_eri_icon_index";
4536
4537 /**
4538 * This is the same as {@link ServiceState#getCdmaEriIconMode()}.
4539 * @hide
4540 */
4541 public static final String CDMA_ERI_ICON_MODE = "cdma_eri_icon_mode";
4542
4543 /**
4544 * This is the same as {@link ServiceState#isEmergencyOnly()}.
4545 * @hide
4546 */
4547 public static final String IS_EMERGENCY_ONLY = "is_emergency_only";
4548
4549 /**
4550 * This is the same as {@link ServiceState#getDataRoamingFromRegistration()}.
4551 * @hide
4552 */
4553 public static final String IS_DATA_ROAMING_FROM_REGISTRATION =
4554 "is_data_roaming_from_registration";
4555
4556 /**
4557 * This is the same as {@link ServiceState#isUsingCarrierAggregation()}.
4558 * @hide
4559 */
4560 public static final String IS_USING_CARRIER_AGGREGATION = "is_using_carrier_aggregation";
SongFerngWang3cbcf752019-03-21 23:14:20 +08004561
4562 /**
4563 * The current registered raw data network operator name in long alphanumeric format.
4564 * <p>
4565 * This is the same as {@link ServiceState#getOperatorAlphaLongRaw()}.
4566 * @hide
4567 */
4568 public static final String OPERATOR_ALPHA_LONG_RAW = "operator_alpha_long_raw";
4569
4570 /**
4571 * The current registered raw data network operator name in short alphanumeric format.
4572 * <p>
4573 * This is the same as {@link ServiceState#getOperatorAlphaShortRaw()}.
4574 * @hide
4575 */
4576 public static final String OPERATOR_ALPHA_SHORT_RAW = "operator_alpha_short_raw";
Jordan Liub9b75ed2017-02-28 18:15:07 -08004577 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07004578
4579 /**
fionaxu58278be2018-01-29 14:08:12 -08004580 * Contains carrier identification information for the current subscriptions.
fionaxu3d0ad1f2017-10-25 23:09:36 -07004581 */
fionaxu62bc7472018-02-28 11:18:45 -08004582 public static final class CarrierId implements BaseColumns {
fionaxu3d0ad1f2017-10-25 23:09:36 -07004583 /**
fionaxu58278be2018-01-29 14:08:12 -08004584 * Not instantiable.
4585 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07004586 */
fionaxu62bc7472018-02-28 11:18:45 -08004587 private CarrierId() {}
fionaxu3d0ad1f2017-10-25 23:09:36 -07004588
4589 /**
fionaxu58278be2018-01-29 14:08:12 -08004590 * The {@code content://} style URI for this provider.
fionaxu3d0ad1f2017-10-25 23:09:36 -07004591 */
fionaxu62bc7472018-02-28 11:18:45 -08004592 public static final Uri CONTENT_URI = Uri.parse("content://carrier_id");
fionaxu3d0ad1f2017-10-25 23:09:36 -07004593
4594 /**
fionaxu62bc7472018-02-28 11:18:45 -08004595 * The authority string for the CarrierId Provider
fionaxu58278be2018-01-29 14:08:12 -08004596 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07004597 */
fionaxu62bc7472018-02-28 11:18:45 -08004598 public static final String AUTHORITY = "carrier_id";
fionaxu58278be2018-01-29 14:08:12 -08004599
fionaxu3d0ad1f2017-10-25 23:09:36 -07004600
4601 /**
fionaxu58278be2018-01-29 14:08:12 -08004602 * Generates a content {@link Uri} used to receive updates on carrier identity change
4603 * on the given subscriptionId
4604 * <p>
4605 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
fionaxuc8d483e2018-03-07 21:52:05 -08004606 * carrier identity {@link TelephonyManager#getSimCarrierId()}
fionaxu58278be2018-01-29 14:08:12 -08004607 * while your app is running. You can also use a {@link JobService} to ensure your app
4608 * is notified of changes to the {@link Uri} even when it is not running.
4609 * Note, however, that using a {@link JobService} does not guarantee timely delivery of
4610 * updates to the {@link Uri}.
4611 *
4612 * @param subscriptionId the subscriptionId to receive updates on
4613 * @return the Uri used to observe carrier identity changes
fionaxu3d0ad1f2017-10-25 23:09:36 -07004614 */
fionaxu58278be2018-01-29 14:08:12 -08004615 public static Uri getUriForSubscriptionId(int subscriptionId) {
4616 return CONTENT_URI.buildUpon().appendEncodedPath(
4617 String.valueOf(subscriptionId)).build();
4618 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07004619
4620 /**
chen xu45f66212019-03-06 14:43:40 -08004621 * Generates a content {@link Uri} used to receive updates on specific carrier identity
chen xud47a0682018-12-06 15:34:05 -08004622 * change on the given subscriptionId returned by
chen xu45f66212019-03-06 14:43:40 -08004623 * {@link TelephonyManager#getSimSpecificCarrierId()}.
4624 * @see TelephonyManager#ACTION_SUBSCRIPTION_SPECIFIC_CARRIER_IDENTITY_CHANGED
chen xudd44d812018-11-02 17:49:57 -07004625 * <p>
4626 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
chen xu45f66212019-03-06 14:43:40 -08004627 * specific carrier identity {@link TelephonyManager#getSimSpecificCarrierId()}
chen xudd44d812018-11-02 17:49:57 -07004628 * while your app is running. You can also use a {@link JobService} to ensure your app
4629 * is notified of changes to the {@link Uri} even when it is not running.
4630 * Note, however, that using a {@link JobService} does not guarantee timely delivery of
4631 * updates to the {@link Uri}.
4632 *
4633 * @param subscriptionId the subscriptionId to receive updates on
chen xu45f66212019-03-06 14:43:40 -08004634 * @return the Uri used to observe specific carrier identity changes
chen xudd44d812018-11-02 17:49:57 -07004635 */
chen xu81653862019-02-28 10:44:54 -08004636 @NonNull
chen xu45f66212019-03-06 14:43:40 -08004637 public static Uri getSpecificCarrierIdUriForSubscriptionId(int subscriptionId) {
4638 return Uri.withAppendedPath(Uri.withAppendedPath(CONTENT_URI, "specific"),
chen xudd44d812018-11-02 17:49:57 -07004639 String.valueOf(subscriptionId));
4640 }
4641
4642 /**
fionaxu58278be2018-01-29 14:08:12 -08004643 * A user facing carrier name.
fionaxuc8d483e2018-03-07 21:52:05 -08004644 * @see TelephonyManager#getSimCarrierIdName()
fionaxu3d0ad1f2017-10-25 23:09:36 -07004645 * <P>Type: TEXT </P>
4646 */
fionaxu62bc7472018-02-28 11:18:45 -08004647 public static final String CARRIER_NAME = "carrier_name";
fionaxu3d0ad1f2017-10-25 23:09:36 -07004648
4649 /**
4650 * A unique carrier id
fionaxuc8d483e2018-03-07 21:52:05 -08004651 * @see TelephonyManager#getSimCarrierId()
fionaxu3d0ad1f2017-10-25 23:09:36 -07004652 * <P>Type: INTEGER </P>
4653 */
fionaxu62bc7472018-02-28 11:18:45 -08004654 public static final String CARRIER_ID = "carrier_id";
fionaxu3d0ad1f2017-10-25 23:09:36 -07004655
4656 /**
chen xudd44d812018-11-02 17:49:57 -07004657 * A fine-grained carrier id.
chen xu45f66212019-03-06 14:43:40 -08004658 * The specific carrier ID would be used for configuration purposes, but apps wishing to
4659 * know about the carrier itself should use the regular carrier ID returned by
4660 * {@link TelephonyManager#getSimCarrierId()}.
4661 *
4662 * @see TelephonyManager#getSimSpecificCarrierId()
chen xudd44d812018-11-02 17:49:57 -07004663 * This is not a database column, only used to notify content observers for
chen xu45f66212019-03-06 14:43:40 -08004664 * {@link #getSpecificCarrierIdUriForSubscriptionId(int)}
chen xudd44d812018-11-02 17:49:57 -07004665 */
chen xu45f66212019-03-06 14:43:40 -08004666 public static final String SPECIFIC_CARRIER_ID = "specific_carrier_id";
chen xudd44d812018-11-02 17:49:57 -07004667
4668 /**
chen xu45f66212019-03-06 14:43:40 -08004669 * A user facing carrier name for specific carrier id {@link #SPECIFIC_CARRIER_ID}.
4670 * @see TelephonyManager#getSimSpecificCarrierIdName()
chen xud47a0682018-12-06 15:34:05 -08004671 * This is not a database column, only used to notify content observers for
chen xu45f66212019-03-06 14:43:40 -08004672 * {@link #getSpecificCarrierIdUriForSubscriptionId(int)}
chen xud47a0682018-12-06 15:34:05 -08004673 */
chen xu45f66212019-03-06 14:43:40 -08004674 public static final String SPECIFIC_CARRIER_ID_NAME = "specific_carrier_id_name";
chen xud47a0682018-12-06 15:34:05 -08004675
4676 /**
chen xudd44d812018-11-02 17:49:57 -07004677 * A unique parent carrier id. The parent-child
4678 * relationship can be used to further differentiate a single carrier by different networks,
chen xu45f66212019-03-06 14:43:40 -08004679 * by prepaid v.s. postpaid. It's an optional field.
4680 * A carrier id with a valid parent_carrier_id is considered fine-grained specific carrier
4681 * ID, will not be returned as {@link #CARRIER_ID} but {@link #SPECIFIC_CARRIER_ID}.
chen xudd44d812018-11-02 17:49:57 -07004682 * <P>Type: INTEGER </P>
4683 * @hide
4684 */
4685 public static final String PARENT_CARRIER_ID = "parent_carrier_id";
4686
4687 /**
fionaxu58278be2018-01-29 14:08:12 -08004688 * Contains mappings between matching rules with carrier id for all carriers.
4689 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07004690 */
fionaxu58278be2018-01-29 14:08:12 -08004691 public static final class All implements BaseColumns {
4692 /**
4693 * Numeric operator ID (as String). {@code MCC + MNC}
4694 * <P>Type: TEXT </P>
4695 */
4696 public static final String MCCMNC = "mccmnc";
4697
4698 /**
4699 * Group id level 1 (as String).
4700 * <P>Type: TEXT </P>
4701 */
4702 public static final String GID1 = "gid1";
4703
4704 /**
4705 * Group id level 2 (as String).
4706 * <P>Type: TEXT </P>
4707 */
4708 public static final String GID2 = "gid2";
4709
4710 /**
4711 * Public Land Mobile Network name.
4712 * <P>Type: TEXT </P>
4713 */
4714 public static final String PLMN = "plmn";
4715
4716 /**
4717 * Prefix xpattern of IMSI (International Mobile Subscriber Identity).
4718 * <P>Type: TEXT </P>
4719 */
4720 public static final String IMSI_PREFIX_XPATTERN = "imsi_prefix_xpattern";
4721
4722 /**
4723 * Service Provider Name.
4724 * <P>Type: TEXT </P>
4725 */
4726 public static final String SPN = "spn";
4727
4728 /**
4729 * Prefer APN name.
4730 * <P>Type: TEXT </P>
4731 */
4732 public static final String APN = "apn";
4733
4734 /**
4735 * Prefix of Integrated Circuit Card Identifier.
4736 * <P>Type: TEXT </P>
4737 */
4738 public static final String ICCID_PREFIX = "iccid_prefix";
4739
4740 /**
fionaxuf9583572018-06-08 16:55:25 -07004741 * Certificate for carrier privilege access rules.
4742 * <P>Type: TEXT in hex string </P>
4743 */
4744 public static final String PRIVILEGE_ACCESS_RULE = "privilege_access_rule";
4745
4746 /**
fionaxu58278be2018-01-29 14:08:12 -08004747 * The {@code content://} URI for this table.
4748 */
fionaxu62bc7472018-02-28 11:18:45 -08004749 public static final Uri CONTENT_URI = Uri.parse("content://carrier_id/all");
fionaxu58278be2018-01-29 14:08:12 -08004750 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07004751 }
Dan Willemsen4980bf42017-02-14 14:17:12 -08004752}