blob: 2aa346cf94ccb578e286f8f52ed9eb600f4be997 [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 Xua32c7fc2019-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;
Hall Liu45a351e2019-11-21 16:35:37 -080028import android.compat.annotation.ChangeId;
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;
Chen Xuad2f91f2019-12-30 00:29:01 -080039import android.os.Bundle;
Jack Yu2e273b22019-04-02 10:49:35 -070040import android.os.Parcel;
Jordan Liub9b75ed2017-02-28 18:15:07 -080041import android.telephony.Rlog;
42import android.telephony.ServiceState;
Dan Willemsen4980bf42017-02-14 14:17:12 -080043import android.telephony.SmsMessage;
44import android.telephony.SubscriptionManager;
fionaxu58278be2018-01-29 14:08:12 -080045import android.telephony.TelephonyManager;
Dan Willemsen4980bf42017-02-14 14:17:12 -080046import android.text.TextUtils;
Dan Willemsen4980bf42017-02-14 14:17:12 -080047import android.util.Patterns;
48
Dan Willemsen4980bf42017-02-14 14:17:12 -080049import 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 /**
Tom Taylorccc1c3e2019-10-30 10:08:50 -0700881 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate
882 * insufficient memory to store the message.
Dan Willemsen4980bf42017-02-14 14:17:12 -0800883 */
884 public static final int RESULT_SMS_OUT_OF_MEMORY = 3;
885
886 /**
Tom Taylorccc1c3e2019-10-30 10:08:50 -0700887 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate that
888 * the message, while possibly valid, is of a format or encoding that is not supported.
Dan Willemsen4980bf42017-02-14 14:17:12 -0800889 */
890 public static final int RESULT_SMS_UNSUPPORTED = 4;
891
892 /**
Tom Taylorccc1c3e2019-10-30 10:08:50 -0700893 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate a
894 * duplicate incoming message.
Dan Willemsen4980bf42017-02-14 14:17:12 -0800895 */
896 public static final int RESULT_SMS_DUPLICATED = 5;
897
898 /**
Tom Taylorccc1c3e2019-10-30 10:08:50 -0700899 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate a
900 * dispatch failure.
901 */
902 public static final int RESULT_SMS_DISPATCH_FAILURE = 6;
903
904 /**
905 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate a null
906 * PDU was received.
907 */
908 public static final int RESULT_SMS_NULL_PDU = 7;
909
910 /**
911 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate a null
912 * message was encountered.
913 */
914 public static final int RESULT_SMS_NULL_MESSAGE = 8;
915
916 /**
917 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate an sms
918 * was received while the phone was in encrypted state.
919 */
920 public static final int RESULT_SMS_RECEIVED_WHILE_ENCRYPTED = 9;
921
922 /**
923 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate a
924 * telephony database error.
925 */
926 public static final int RESULT_SMS_DATABASE_ERROR = 10;
927
928 /**
929 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate an
930 * invalid uri.
931 */
932 public static final int RESULT_SMS_INVALID_URI = 11;
933
934 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -0800935 * Activity action: Ask the user to change the default
936 * SMS application. This will show a dialog that asks the
937 * user whether they want to replace the current default
938 * SMS application with the one specified in
939 * {@link #EXTRA_PACKAGE_NAME}.
Hai Zhang929085f2019-05-03 15:31:43 +0800940 * <p>
941 * This is no longer supported since Q, please use
942 * {@link android.app.role.RoleManager#createRequestRoleIntent(String)} with
943 * {@link android.app.role.RoleManager#ROLE_SMS} instead.
Dan Willemsen4980bf42017-02-14 14:17:12 -0800944 */
945 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
946 public static final String ACTION_CHANGE_DEFAULT =
947 "android.provider.Telephony.ACTION_CHANGE_DEFAULT";
948
949 /**
950 * The PackageName string passed in as an
951 * extra for {@link #ACTION_CHANGE_DEFAULT}
952 *
953 * @see #ACTION_CHANGE_DEFAULT
Hai Zhang929085f2019-05-03 15:31:43 +0800954 * <p>
955 * This is no longer supported since Q, please use
956 * {@link android.app.role.RoleManager#createRequestRoleIntent(String)} with
957 * {@link android.app.role.RoleManager#ROLE_SMS} instead.
Dan Willemsen4980bf42017-02-14 14:17:12 -0800958 */
959 public static final String EXTRA_PACKAGE_NAME = "package";
960
961 /**
962 * Broadcast Action: A new text-based SMS message has been received
963 * by the device. This intent will only be delivered to the default
964 * sms app. That app is responsible for writing the message and notifying
965 * the user. The intent will have the following extra values:</p>
966 *
967 * <ul>
968 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
969 * that make up the message.</li>
970 * <li><em>"format"</em> - A String describing the format of the PDUs. It can
971 * be either "3gpp" or "3gpp2".</li>
972 * <li><em>"subscription"</em> - An optional long value of the subscription id which
973 * received the message.</li>
974 * <li><em>"slot"</em> - An optional int value of the SIM slot containing the
975 * subscription.</li>
976 * <li><em>"phone"</em> - An optional int value of the phone id associated with the
977 * subscription.</li>
978 * <li><em>"errorCode"</em> - An optional int error code associated with receiving
979 * the message.</li>
980 * </ul>
981 *
982 * <p>The extra values can be extracted using
983 * {@link #getMessagesFromIntent(Intent)}.</p>
984 *
985 * <p>If a BroadcastReceiver encounters an error while processing
986 * this intent it should set the result code appropriately.</p>
987 *
988 * <p class="note"><strong>Note:</strong>
989 * The broadcast receiver that filters for this intent must declare
990 * {@link android.Manifest.permission#BROADCAST_SMS} as a required permission in
991 * the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code
992 * <receiver>}</a> tag.
993 *
994 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
995 */
996 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
997 public static final String SMS_DELIVER_ACTION =
998 "android.provider.Telephony.SMS_DELIVER";
999
1000 /**
1001 * Broadcast Action: A new text-based SMS message has been received
1002 * by the device. This intent will be delivered to all registered
1003 * receivers as a notification. These apps are not expected to write the
1004 * message or notify the user. The intent will have the following extra
1005 * values:</p>
1006 *
1007 * <ul>
1008 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
1009 * that make up the message.</li>
1010 * </ul>
1011 *
1012 * <p>The extra values can be extracted using
1013 * {@link #getMessagesFromIntent(Intent)}.</p>
1014 *
1015 * <p>If a BroadcastReceiver encounters an error while processing
1016 * this intent it should set the result code appropriately.</p>
1017 *
1018 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1019 */
1020 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1021 public static final String SMS_RECEIVED_ACTION =
1022 "android.provider.Telephony.SMS_RECEIVED";
1023
1024 /**
1025 * Broadcast Action: A new data based SMS message has been received
1026 * by the device. This intent will be delivered to all registered
1027 * receivers as a notification. The intent will have the following extra
1028 * values:</p>
1029 *
1030 * <ul>
1031 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
1032 * that make up the message.</li>
1033 * </ul>
1034 *
1035 * <p>The extra values can be extracted using
1036 * {@link #getMessagesFromIntent(Intent)}.</p>
1037 *
1038 * <p>If a BroadcastReceiver encounters an error while processing
1039 * this intent it should set the result code appropriately.</p>
1040 *
1041 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1042 */
1043 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1044 public static final String DATA_SMS_RECEIVED_ACTION =
1045 "android.intent.action.DATA_SMS_RECEIVED";
1046
1047 /**
1048 * Broadcast Action: A new WAP PUSH message has been received by the
1049 * device. This intent will only be delivered to the default
1050 * sms app. That app is responsible for writing the message and notifying
1051 * the user. The intent will have the following extra values:</p>
1052 *
1053 * <ul>
1054 * <li><em>"transactionId"</em> - (Integer) The WAP transaction ID</li>
1055 * <li><em>"pduType"</em> - (Integer) The WAP PDU type</li>
1056 * <li><em>"header"</em> - (byte[]) The header of the message</li>
1057 * <li><em>"data"</em> - (byte[]) The data payload of the message</li>
1058 * <li><em>"contentTypeParameters" </em>
1059 * -(HashMap&lt;String,String&gt;) Any parameters associated with the content type
1060 * (decoded from the WSP Content-Type header)</li>
1061 * <li><em>"subscription"</em> - An optional long value of the subscription id which
1062 * received the message.</li>
1063 * <li><em>"slot"</em> - An optional int value of the SIM slot containing the
1064 * subscription.</li>
1065 * <li><em>"phone"</em> - An optional int value of the phone id associated with the
1066 * subscription.</li>
1067 * </ul>
1068 *
1069 * <p>If a BroadcastReceiver encounters an error while processing
1070 * this intent it should set the result code appropriately.</p>
1071 *
1072 * <p>The contentTypeParameters extra value is map of content parameters keyed by
1073 * their names.</p>
1074 *
1075 * <p>If any unassigned well-known parameters are encountered, the key of the map will
1076 * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter. If
1077 * a parameter has No-Value the value in the map will be null.</p>
1078 *
1079 * <p>Requires {@link android.Manifest.permission#RECEIVE_MMS} or
1080 * {@link android.Manifest.permission#RECEIVE_WAP_PUSH} (depending on WAP PUSH type) to
1081 * receive.</p>
1082 *
1083 * <p class="note"><strong>Note:</strong>
1084 * The broadcast receiver that filters for this intent must declare
1085 * {@link android.Manifest.permission#BROADCAST_WAP_PUSH} as a required permission in
1086 * the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code
1087 * <receiver>}</a> tag.
1088 */
1089 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1090 public static final String WAP_PUSH_DELIVER_ACTION =
1091 "android.provider.Telephony.WAP_PUSH_DELIVER";
1092
1093 /**
1094 * Broadcast Action: A new WAP PUSH message has been received by the
1095 * device. This intent will be delivered to all registered
1096 * receivers as a notification. These apps are not expected to write the
1097 * message or notify the user. The intent will have the following extra
1098 * values:</p>
1099 *
1100 * <ul>
1101 * <li><em>"transactionId"</em> - (Integer) The WAP transaction ID</li>
1102 * <li><em>"pduType"</em> - (Integer) The WAP PDU type</li>
1103 * <li><em>"header"</em> - (byte[]) The header of the message</li>
1104 * <li><em>"data"</em> - (byte[]) The data payload of the message</li>
1105 * <li><em>"contentTypeParameters"</em>
1106 * - (HashMap&lt;String,String&gt;) Any parameters associated with the content type
1107 * (decoded from the WSP Content-Type header)</li>
1108 * </ul>
1109 *
1110 * <p>If a BroadcastReceiver encounters an error while processing
1111 * this intent it should set the result code appropriately.</p>
1112 *
1113 * <p>The contentTypeParameters extra value is map of content parameters keyed by
1114 * their names.</p>
1115 *
1116 * <p>If any unassigned well-known parameters are encountered, the key of the map will
1117 * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter. If
1118 * a parameter has No-Value the value in the map will be null.</p>
1119 *
1120 * <p>Requires {@link android.Manifest.permission#RECEIVE_MMS} or
1121 * {@link android.Manifest.permission#RECEIVE_WAP_PUSH} (depending on WAP PUSH type) to
1122 * receive.</p>
1123 */
1124 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1125 public static final String WAP_PUSH_RECEIVED_ACTION =
1126 "android.provider.Telephony.WAP_PUSH_RECEIVED";
1127
1128 /**
1129 * Broadcast Action: A new Cell Broadcast message has been received
1130 * by the device. The intent will have the following extra
1131 * values:</p>
1132 *
1133 * <ul>
1134 * <li><em>"message"</em> - An SmsCbMessage object containing the broadcast message
1135 * data. This is not an emergency alert, so ETWS and CMAS data will be null.</li>
1136 * </ul>
1137 *
1138 * <p>The extra values can be extracted using
1139 * {@link #getMessagesFromIntent(Intent)}.</p>
1140 *
1141 * <p>If a BroadcastReceiver encounters an error while processing
1142 * this intent it should set the result code appropriately.</p>
1143 *
1144 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1145 */
1146 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1147 public static final String SMS_CB_RECEIVED_ACTION =
1148 "android.provider.Telephony.SMS_CB_RECEIVED";
1149
1150 /**
1151 * Action: A SMS based carrier provision intent. Used to identify default
1152 * carrier provisioning app on the device.
1153 * @hide
1154 */
1155 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1156 @TestApi
1157 public static final String SMS_CARRIER_PROVISION_ACTION =
1158 "android.provider.Telephony.SMS_CARRIER_PROVISION";
1159
1160 /**
1161 * Broadcast Action: A new Emergency Broadcast message has been received
1162 * by the device. The intent will have the following extra
1163 * values:</p>
1164 *
1165 * <ul>
Chen Xu9c1260c2019-11-06 20:30:58 -08001166 * <li><em>"message"</em> - An {@link android.telephony.SmsCbMessage} object
1167 * containing the broadcast message data, including ETWS or CMAS warning notification
1168 * info if present.</li>
Dan Willemsen4980bf42017-02-14 14:17:12 -08001169 * </ul>
1170 *
1171 * <p>The extra values can be extracted using
1172 * {@link #getMessagesFromIntent(Intent)}.</p>
1173 *
1174 * <p>If a BroadcastReceiver encounters an error while processing
1175 * this intent it should set the result code appropriately.</p>
1176 *
1177 * <p>Requires {@link android.Manifest.permission#RECEIVE_EMERGENCY_BROADCAST} to
1178 * receive.</p>
Chen Xu9c1260c2019-11-06 20:30:58 -08001179 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08001180 */
1181 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Chen Xu9c1260c2019-11-06 20:30:58 -08001182 @SystemApi
1183 public static final String ACTION_SMS_EMERGENCY_CB_RECEIVED =
1184 "android.provider.action.SMS_EMERGENCY_CB_RECEIVED";
Dan Willemsen4980bf42017-02-14 14:17:12 -08001185
1186 /**
1187 * Broadcast Action: A new CDMA SMS has been received containing Service Category
1188 * Program Data (updates the list of enabled broadcast channels). The intent will
1189 * have the following extra values:</p>
1190 *
1191 * <ul>
1192 * <li><em>"operations"</em> - An array of CdmaSmsCbProgramData objects containing
1193 * the service category operations (add/delete/clear) to perform.</li>
1194 * </ul>
1195 *
1196 * <p>The extra values can be extracted using
1197 * {@link #getMessagesFromIntent(Intent)}.</p>
1198 *
1199 * <p>If a BroadcastReceiver encounters an error while processing
1200 * this intent it should set the result code appropriately.</p>
1201 *
1202 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1203 */
1204 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1205 public static final String SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION =
1206 "android.provider.Telephony.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED";
1207
1208 /**
1209 * Broadcast Action: The SIM storage for SMS messages is full. If
1210 * space is not freed, messages targeted for the SIM (class 2) may
1211 * not be saved.
1212 *
1213 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1214 */
1215 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1216 public static final String SIM_FULL_ACTION =
1217 "android.provider.Telephony.SIM_FULL";
1218
1219 /**
1220 * Broadcast Action: An incoming SMS has been rejected by the
1221 * telephony framework. This intent is sent in lieu of any
1222 * of the RECEIVED_ACTION intents. The intent will have the
1223 * following extra value:</p>
1224 *
1225 * <ul>
1226 * <li><em>"result"</em> - An int result code, e.g. {@link #RESULT_SMS_OUT_OF_MEMORY}
1227 * indicating the error returned to the network.</li>
1228 * </ul>
1229 *
1230 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p>
1231 */
1232 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1233 public static final String SMS_REJECTED_ACTION =
1234 "android.provider.Telephony.SMS_REJECTED";
1235
1236 /**
1237 * Broadcast Action: An incoming MMS has been downloaded. The intent is sent to all
1238 * users, except for secondary users where SMS has been disabled and to managed
1239 * profiles.
1240 * @hide
1241 */
1242 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1243 public static final String MMS_DOWNLOADED_ACTION =
1244 "android.provider.Telephony.MMS_DOWNLOADED";
1245
1246 /**
Cassie5b97cf12018-02-22 09:58:33 -08001247 * Broadcast Action: A debug code has been entered in the dialer. This intent is
1248 * broadcast by the system and OEM telephony apps may need to receive these broadcasts.
1249 * These "secret codes" are used to activate developer menus by dialing certain codes.
Alan Stokesa9b5b2a2019-02-28 16:45:47 +00001250 * And they are of the form {@code *#*#<code>#*#*}. The intent will have the data
1251 * URI: {@code android_secret_code://<code>}. It is possible that a manifest
Cassie5b97cf12018-02-22 09:58:33 -08001252 * receiver would be woken up even if it is not currently running.
1253 *
1254 * <p>Requires {@code android.Manifest.permission#CONTROL_INCALL_EXPERIENCE} to
1255 * send and receive.</p>
Cassie6d0a5712018-08-21 13:38:39 -07001256 * @deprecated it is no longer supported, use {@link
1257 * TelephonyManager#ACTION_SECRET_CODE} instead
Cassie866f4942018-01-19 17:23:36 -08001258 */
Cassie6d0a5712018-08-21 13:38:39 -07001259 @Deprecated
Cassie866f4942018-01-19 17:23:36 -08001260 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1261 public static final String SECRET_CODE_ACTION =
1262 "android.provider.Telephony.SECRET_CODE";
1263
1264 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08001265 * Broadcast action: When the default SMS package changes,
1266 * the previous default SMS package and the new default SMS
1267 * package are sent this broadcast to notify them of the change.
1268 * A boolean is specified in {@link #EXTRA_IS_DEFAULT_SMS_APP} to
1269 * indicate whether the package is the new default SMS package.
1270 */
1271 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1272 public static final String ACTION_DEFAULT_SMS_PACKAGE_CHANGED =
1273 "android.provider.action.DEFAULT_SMS_PACKAGE_CHANGED";
1274
1275 /**
1276 * The IsDefaultSmsApp boolean passed as an
1277 * extra for {@link #ACTION_DEFAULT_SMS_PACKAGE_CHANGED} to indicate whether the
1278 * SMS app is becoming the default SMS app or is no longer the default.
1279 *
1280 * @see #ACTION_DEFAULT_SMS_PACKAGE_CHANGED
1281 */
1282 public static final String EXTRA_IS_DEFAULT_SMS_APP =
1283 "android.provider.extra.IS_DEFAULT_SMS_APP";
1284
1285 /**
1286 * Broadcast action: When a change is made to the SmsProvider or
1287 * MmsProvider by a process other than the default SMS application,
1288 * this intent is broadcast to the default SMS application so it can
1289 * re-sync or update the change. The uri that was used to call the provider
1290 * can be retrieved from the intent with getData(). The actual affected uris
1291 * (which would depend on the selection specified) are not included.
1292 */
1293 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1294 public static final String ACTION_EXTERNAL_PROVIDER_CHANGE =
1295 "android.provider.action.EXTERNAL_PROVIDER_CHANGE";
1296
1297 /**
Makoto Onukia042aaa2018-09-18 16:14:12 -07001298 * Same as {@link #ACTION_DEFAULT_SMS_PACKAGE_CHANGED} but it's implicit (e.g. sent to
1299 * all apps) and requires
1300 * {@link android.Manifest.permission#MONITOR_DEFAULT_SMS_PACKAGE} to receive.
1301 *
1302 * @hide
1303 */
1304 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1305 public static final String ACTION_DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL =
1306 "android.provider.action.DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL";
1307
1308 /**
Amit Mahajan8c1c45a2018-10-22 10:43:34 -07001309 * Broadcast action: When SMS-MMS db is being created. If file-based encryption is
1310 * supported, this broadcast indicates creation of the db in credential-encrypted
1311 * storage. A boolean is specified in {@link #EXTRA_IS_INITIAL_CREATE} to indicate if
Jayachandran C1637e442019-12-12 18:51:56 -08001312 * this is the initial create of the db.
Amit Mahajan8c1c45a2018-10-22 10:43:34 -07001313 *
1314 * @see #EXTRA_IS_INITIAL_CREATE
1315 *
1316 * @hide
1317 */
1318 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1319 public static final String ACTION_SMS_MMS_DB_CREATED =
1320 "android.provider.action.SMS_MMS_DB_CREATED";
1321
1322 /**
1323 * Boolean flag passed as an extra with {@link #ACTION_SMS_MMS_DB_CREATED} to indicate
1324 * whether the DB creation is the initial creation on the device, that is it is after a
1325 * factory-data reset or a new device. Any subsequent creations of the DB (which
1326 * happens only in error scenarios) will have this flag set to false.
1327 *
1328 * @see #ACTION_SMS_MMS_DB_CREATED
1329 *
1330 * @hide
1331 */
1332 public static final String EXTRA_IS_INITIAL_CREATE =
1333 "android.provider.extra.IS_INITIAL_CREATE";
Jayachandran C349b9ba2018-10-30 15:09:06 -07001334
1335 /**
1336 * Broadcast intent action indicating that the telephony provider SMS MMS database is
1337 * corrupted. A boolean is specified in {@link #EXTRA_IS_CORRUPTED} to indicate if the
1338 * database is corrupted. Requires the
1339 * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE permission.
1340 *
1341 * @hide
1342 */
1343 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1344 @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
1345 public static final String ACTION_SMS_MMS_DB_LOST =
1346 "android.provider.action.SMS_MMS_DB_LOST";
1347
1348 /**
1349 * Boolean flag passed as an extra with {@link #ACTION_SMS_MMS_DB_LOST} to indicate
1350 * whether the DB got corrupted or not.
1351 *
1352 * @see #ACTION_SMS_MMS_DB_LOST
1353 *
1354 * @hide
1355 */
1356 public static final String EXTRA_IS_CORRUPTED =
1357 "android.provider.extra.IS_CORRUPTED";
1358
Amit Mahajan8c1c45a2018-10-22 10:43:34 -07001359 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08001360 * Read the PDUs out of an {@link #SMS_RECEIVED_ACTION} or a
1361 * {@link #DATA_SMS_RECEIVED_ACTION} intent.
1362 *
1363 * @param intent the intent to read from
1364 * @return an array of SmsMessages for the PDUs
1365 */
1366 public static SmsMessage[] getMessagesFromIntent(Intent intent) {
1367 Object[] messages;
1368 try {
1369 messages = (Object[]) intent.getSerializableExtra("pdus");
1370 }
1371 catch (ClassCastException e) {
1372 Rlog.e(TAG, "getMessagesFromIntent: " + e);
1373 return null;
1374 }
1375
1376 if (messages == null) {
1377 Rlog.e(TAG, "pdus does not exist in the intent");
1378 return null;
1379 }
1380
1381 String format = intent.getStringExtra("format");
Meng Wang646dcbd2019-12-05 12:12:20 -08001382 int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
Dan Willemsen4980bf42017-02-14 14:17:12 -08001383 SubscriptionManager.getDefaultSmsSubscriptionId());
1384
1385 Rlog.v(TAG, " getMessagesFromIntent sub_id : " + subId);
1386
1387 int pduCount = messages.length;
1388 SmsMessage[] msgs = new SmsMessage[pduCount];
1389
1390 for (int i = 0; i < pduCount; i++) {
1391 byte[] pdu = (byte[]) messages[i];
1392 msgs[i] = SmsMessage.createFromPdu(pdu, format);
Dan Willemsen4980bf42017-02-14 14:17:12 -08001393 }
1394 return msgs;
1395 }
1396 }
1397 }
1398
1399 /**
pkanwar16b8a0d2017-06-07 10:59:41 -07001400 * Base column for the table that contain Carrier Public key.
1401 * @hide
1402 */
zoey chenb27edd72019-11-01 15:09:11 +08001403 @SystemApi
pkanwar16b8a0d2017-06-07 10:59:41 -07001404 public interface CarrierColumns extends BaseColumns {
1405
zoey chenb27edd72019-11-01 15:09:11 +08001406 /**
1407 * Mobile Country Code (MCC).
1408 * <P> Type: TEXT </P>
1409 */
pkanwar16b8a0d2017-06-07 10:59:41 -07001410 public static final String MCC = "mcc";
zoey chenb27edd72019-11-01 15:09:11 +08001411
1412 /**
1413 * Mobile Network Code (MNC).
1414 * <P> Type: TEXT </P>
1415 */
pkanwar16b8a0d2017-06-07 10:59:41 -07001416 public static final String MNC = "mnc";
zoey chenb27edd72019-11-01 15:09:11 +08001417
1418 /**
1419 * KeyType whether the key is being used for WLAN or ePDG.
1420 * <P> Type: INTEGER </P>
1421 */
pkanwar16b8a0d2017-06-07 10:59:41 -07001422 public static final String KEY_TYPE = "key_type";
zoey chenb27edd72019-11-01 15:09:11 +08001423
1424 /**
1425 * MVNO type:
1426 * {@code SPN (Service Provider Name), IMSI, GID (Group Identifier Level 1)}.
1427 * <P> Type: TEXT </P>
1428 */
pkanwar16b8a0d2017-06-07 10:59:41 -07001429 public static final String MVNO_TYPE = "mvno_type";
zoey chenb27edd72019-11-01 15:09:11 +08001430
1431 /**
1432 * MVNO data.
1433 * Use the following examples.
1434 * <ul>
1435 * <li>SPN: A MOBILE, BEN NL, ...</li>
1436 * <li>IMSI: 302720x94, 2060188, ...</li>
1437 * <li>GID: 4E, 33, ...</li>
1438 * </ul>
1439 * <P> Type: TEXT </P>
1440 */
pkanwar16b8a0d2017-06-07 10:59:41 -07001441 public static final String MVNO_MATCH_DATA = "mvno_match_data";
zoey chenb27edd72019-11-01 15:09:11 +08001442
1443 /**
1444 * The carrier public key that is used for the IMSI encryption.
1445 * <P> Type: TEXT </P>
1446 */
pkanwar16b8a0d2017-06-07 10:59:41 -07001447 public static final String PUBLIC_KEY = "public_key";
zoey chenb27edd72019-11-01 15:09:11 +08001448
1449 /**
1450 * The key identifier Attribute value pair that helps a server locate
1451 * the private key to decrypt the permanent identity.
1452 * <P> Type: TEXT </P>
1453 */
pkanwar16b8a0d2017-06-07 10:59:41 -07001454 public static final String KEY_IDENTIFIER = "key_identifier";
zoey chenb27edd72019-11-01 15:09:11 +08001455
1456 /**
1457 * Date-Time in UTC when the key will expire.
1458 * <P> Type: INTEGER (long) </P>
1459 */
pkanwar16b8a0d2017-06-07 10:59:41 -07001460 public static final String EXPIRATION_TIME = "expiration_time";
zoey chenb27edd72019-11-01 15:09:11 +08001461
1462 /**
1463 * Timestamp when this table was last modified, in milliseconds since
1464 * January 1, 1970 00:00:00.0 UTC.
1465 * <P> Type: INTEGER (long) </P>
1466 */
pkanwar16b8a0d2017-06-07 10:59:41 -07001467 public static final String LAST_MODIFIED = "last_modified";
1468
1469 /**
1470 * The {@code content://} style URL for this table.
pkanwar16b8a0d2017-06-07 10:59:41 -07001471 */
zoey chenb27edd72019-11-01 15:09:11 +08001472 @NonNull
pkanwar16b8a0d2017-06-07 10:59:41 -07001473 public static final Uri CONTENT_URI = Uri.parse("content://carrier_information/carrier");
1474 }
1475
1476 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08001477 * Base columns for tables that contain MMSs.
1478 */
1479 public interface BaseMmsColumns extends BaseColumns {
1480
1481 /** Message box: all messages. */
1482 public static final int MESSAGE_BOX_ALL = 0;
1483 /** Message box: inbox. */
1484 public static final int MESSAGE_BOX_INBOX = 1;
1485 /** Message box: sent messages. */
1486 public static final int MESSAGE_BOX_SENT = 2;
1487 /** Message box: drafts. */
1488 public static final int MESSAGE_BOX_DRAFTS = 3;
1489 /** Message box: outbox. */
1490 public static final int MESSAGE_BOX_OUTBOX = 4;
1491 /** Message box: failed. */
1492 public static final int MESSAGE_BOX_FAILED = 5;
1493
1494 /**
1495 * The thread ID of the message.
1496 * <P>Type: INTEGER (long)</P>
1497 */
1498 public static final String THREAD_ID = "thread_id";
1499
1500 /**
1501 * The date the message was received.
1502 * <P>Type: INTEGER (long)</P>
1503 */
1504 public static final String DATE = "date";
1505
1506 /**
1507 * The date the message was sent.
1508 * <P>Type: INTEGER (long)</P>
1509 */
1510 public static final String DATE_SENT = "date_sent";
1511
1512 /**
1513 * The box which the message belongs to, e.g. {@link #MESSAGE_BOX_INBOX}.
1514 * <P>Type: INTEGER</P>
1515 */
1516 public static final String MESSAGE_BOX = "msg_box";
1517
1518 /**
1519 * Has the message been read?
1520 * <P>Type: INTEGER (boolean)</P>
1521 */
1522 public static final String READ = "read";
1523
1524 /**
1525 * Has the message been seen by the user? The "seen" flag determines
1526 * whether we need to show a new message notification.
1527 * <P>Type: INTEGER (boolean)</P>
1528 */
1529 public static final String SEEN = "seen";
1530
1531 /**
1532 * Does the message have only a text part (can also have a subject) with
1533 * no picture, slideshow, sound, etc. parts?
1534 * <P>Type: INTEGER (boolean)</P>
1535 */
1536 public static final String TEXT_ONLY = "text_only";
1537
1538 /**
1539 * The {@code Message-ID} of the message.
1540 * <P>Type: TEXT</P>
1541 */
1542 public static final String MESSAGE_ID = "m_id";
1543
1544 /**
1545 * The subject of the message, if present.
1546 * <P>Type: TEXT</P>
1547 */
1548 public static final String SUBJECT = "sub";
1549
1550 /**
1551 * The character set of the subject, if present.
1552 * <P>Type: INTEGER</P>
1553 */
1554 public static final String SUBJECT_CHARSET = "sub_cs";
1555
1556 /**
1557 * The {@code Content-Type} of the message.
1558 * <P>Type: TEXT</P>
1559 */
1560 public static final String CONTENT_TYPE = "ct_t";
1561
1562 /**
1563 * The {@code Content-Location} of the message.
1564 * <P>Type: TEXT</P>
1565 */
1566 public static final String CONTENT_LOCATION = "ct_l";
1567
1568 /**
1569 * The expiry time of the message.
1570 * <P>Type: INTEGER (long)</P>
1571 */
1572 public static final String EXPIRY = "exp";
1573
1574 /**
1575 * The class of the message.
1576 * <P>Type: TEXT</P>
1577 */
1578 public static final String MESSAGE_CLASS = "m_cls";
1579
1580 /**
1581 * The type of the message defined by MMS spec.
1582 * <P>Type: INTEGER</P>
1583 */
1584 public static final String MESSAGE_TYPE = "m_type";
1585
1586 /**
1587 * The version of the specification that this message conforms to.
1588 * <P>Type: INTEGER</P>
1589 */
1590 public static final String MMS_VERSION = "v";
1591
1592 /**
1593 * The size of the message.
1594 * <P>Type: INTEGER</P>
1595 */
1596 public static final String MESSAGE_SIZE = "m_size";
1597
1598 /**
1599 * The priority of the message.
1600 * <P>Type: INTEGER</P>
1601 */
1602 public static final String PRIORITY = "pri";
1603
1604 /**
1605 * The {@code read-report} of the message.
1606 * <P>Type: INTEGER (boolean)</P>
1607 */
1608 public static final String READ_REPORT = "rr";
1609
1610 /**
1611 * Is read report allowed?
1612 * <P>Type: INTEGER (boolean)</P>
1613 */
1614 public static final String REPORT_ALLOWED = "rpt_a";
1615
1616 /**
1617 * The {@code response-status} of the message.
1618 * <P>Type: INTEGER</P>
1619 */
1620 public static final String RESPONSE_STATUS = "resp_st";
1621
1622 /**
1623 * The {@code status} of the message.
1624 * <P>Type: INTEGER</P>
1625 */
1626 public static final String STATUS = "st";
1627
1628 /**
1629 * The {@code transaction-id} of the message.
1630 * <P>Type: TEXT</P>
1631 */
1632 public static final String TRANSACTION_ID = "tr_id";
1633
1634 /**
1635 * The {@code retrieve-status} of the message.
1636 * <P>Type: INTEGER</P>
1637 */
1638 public static final String RETRIEVE_STATUS = "retr_st";
1639
1640 /**
1641 * The {@code retrieve-text} of the message.
1642 * <P>Type: TEXT</P>
1643 */
1644 public static final String RETRIEVE_TEXT = "retr_txt";
1645
1646 /**
1647 * The character set of the retrieve-text.
1648 * <P>Type: INTEGER</P>
1649 */
1650 public static final String RETRIEVE_TEXT_CHARSET = "retr_txt_cs";
1651
1652 /**
1653 * The {@code read-status} of the message.
1654 * <P>Type: INTEGER</P>
1655 */
1656 public static final String READ_STATUS = "read_status";
1657
1658 /**
1659 * The {@code content-class} of the message.
1660 * <P>Type: INTEGER</P>
1661 */
1662 public static final String CONTENT_CLASS = "ct_cls";
1663
1664 /**
1665 * The {@code delivery-report} of the message.
1666 * <P>Type: INTEGER</P>
1667 */
1668 public static final String DELIVERY_REPORT = "d_rpt";
1669
1670 /**
1671 * The {@code delivery-time-token} of the message.
1672 * <P>Type: INTEGER</P>
1673 * @deprecated this column is no longer supported.
1674 * @hide
1675 */
1676 @Deprecated
1677 public static final String DELIVERY_TIME_TOKEN = "d_tm_tok";
1678
1679 /**
1680 * The {@code delivery-time} of the message.
1681 * <P>Type: INTEGER</P>
1682 */
1683 public static final String DELIVERY_TIME = "d_tm";
1684
1685 /**
1686 * The {@code response-text} of the message.
1687 * <P>Type: TEXT</P>
1688 */
1689 public static final String RESPONSE_TEXT = "resp_txt";
1690
1691 /**
1692 * The {@code sender-visibility} of the message.
1693 * <P>Type: TEXT</P>
1694 * @deprecated this column is no longer supported.
1695 * @hide
1696 */
1697 @Deprecated
1698 public static final String SENDER_VISIBILITY = "s_vis";
1699
1700 /**
1701 * The {@code reply-charging} of the message.
1702 * <P>Type: INTEGER</P>
1703 * @deprecated this column is no longer supported.
1704 * @hide
1705 */
1706 @Deprecated
1707 public static final String REPLY_CHARGING = "r_chg";
1708
1709 /**
1710 * The {@code reply-charging-deadline-token} of the message.
1711 * <P>Type: INTEGER</P>
1712 * @deprecated this column is no longer supported.
1713 * @hide
1714 */
1715 @Deprecated
1716 public static final String REPLY_CHARGING_DEADLINE_TOKEN = "r_chg_dl_tok";
1717
1718 /**
1719 * The {@code reply-charging-deadline} of the message.
1720 * <P>Type: INTEGER</P>
1721 * @deprecated this column is no longer supported.
1722 * @hide
1723 */
1724 @Deprecated
1725 public static final String REPLY_CHARGING_DEADLINE = "r_chg_dl";
1726
1727 /**
1728 * The {@code reply-charging-id} of the message.
1729 * <P>Type: TEXT</P>
1730 * @deprecated this column is no longer supported.
1731 * @hide
1732 */
1733 @Deprecated
1734 public static final String REPLY_CHARGING_ID = "r_chg_id";
1735
1736 /**
1737 * The {@code reply-charging-size} of the message.
1738 * <P>Type: INTEGER</P>
1739 * @deprecated this column is no longer supported.
1740 * @hide
1741 */
1742 @Deprecated
1743 public static final String REPLY_CHARGING_SIZE = "r_chg_sz";
1744
1745 /**
1746 * The {@code previously-sent-by} of the message.
1747 * <P>Type: TEXT</P>
1748 * @deprecated this column is no longer supported.
1749 * @hide
1750 */
1751 @Deprecated
1752 public static final String PREVIOUSLY_SENT_BY = "p_s_by";
1753
1754 /**
1755 * The {@code previously-sent-date} of the message.
1756 * <P>Type: INTEGER</P>
1757 * @deprecated this column is no longer supported.
1758 * @hide
1759 */
1760 @Deprecated
1761 public static final String PREVIOUSLY_SENT_DATE = "p_s_d";
1762
1763 /**
1764 * The {@code store} of the message.
1765 * <P>Type: TEXT</P>
1766 * @deprecated this column is no longer supported.
1767 * @hide
1768 */
1769 @Deprecated
1770 public static final String STORE = "store";
1771
1772 /**
1773 * The {@code mm-state} of the message.
1774 * <P>Type: INTEGER</P>
1775 * @deprecated this column is no longer supported.
1776 * @hide
1777 */
1778 @Deprecated
1779 public static final String MM_STATE = "mm_st";
1780
1781 /**
1782 * The {@code mm-flags-token} of the message.
1783 * <P>Type: INTEGER</P>
1784 * @deprecated this column is no longer supported.
1785 * @hide
1786 */
1787 @Deprecated
1788 public static final String MM_FLAGS_TOKEN = "mm_flg_tok";
1789
1790 /**
1791 * The {@code mm-flags} of the message.
1792 * <P>Type: TEXT</P>
1793 * @deprecated this column is no longer supported.
1794 * @hide
1795 */
1796 @Deprecated
1797 public static final String MM_FLAGS = "mm_flg";
1798
1799 /**
1800 * The {@code store-status} of the message.
1801 * <P>Type: TEXT</P>
1802 * @deprecated this column is no longer supported.
1803 * @hide
1804 */
1805 @Deprecated
1806 public static final String STORE_STATUS = "store_st";
1807
1808 /**
1809 * The {@code store-status-text} of the message.
1810 * <P>Type: TEXT</P>
1811 * @deprecated this column is no longer supported.
1812 * @hide
1813 */
1814 @Deprecated
1815 public static final String STORE_STATUS_TEXT = "store_st_txt";
1816
1817 /**
1818 * The {@code stored} of the message.
1819 * <P>Type: TEXT</P>
1820 * @deprecated this column is no longer supported.
1821 * @hide
1822 */
1823 @Deprecated
1824 public static final String STORED = "stored";
1825
1826 /**
1827 * The {@code totals} of the message.
1828 * <P>Type: TEXT</P>
1829 * @deprecated this column is no longer supported.
1830 * @hide
1831 */
1832 @Deprecated
1833 public static final String TOTALS = "totals";
1834
1835 /**
1836 * The {@code mbox-totals} of the message.
1837 * <P>Type: TEXT</P>
1838 * @deprecated this column is no longer supported.
1839 * @hide
1840 */
1841 @Deprecated
1842 public static final String MBOX_TOTALS = "mb_t";
1843
1844 /**
1845 * The {@code mbox-totals-token} of the message.
1846 * <P>Type: INTEGER</P>
1847 * @deprecated this column is no longer supported.
1848 * @hide
1849 */
1850 @Deprecated
1851 public static final String MBOX_TOTALS_TOKEN = "mb_t_tok";
1852
1853 /**
1854 * The {@code quotas} of the message.
1855 * <P>Type: TEXT</P>
1856 * @deprecated this column is no longer supported.
1857 * @hide
1858 */
1859 @Deprecated
1860 public static final String QUOTAS = "qt";
1861
1862 /**
1863 * The {@code mbox-quotas} of the message.
1864 * <P>Type: TEXT</P>
1865 * @deprecated this column is no longer supported.
1866 * @hide
1867 */
1868 @Deprecated
1869 public static final String MBOX_QUOTAS = "mb_qt";
1870
1871 /**
1872 * The {@code mbox-quotas-token} of the message.
1873 * <P>Type: INTEGER</P>
1874 * @deprecated this column is no longer supported.
1875 * @hide
1876 */
1877 @Deprecated
1878 public static final String MBOX_QUOTAS_TOKEN = "mb_qt_tok";
1879
1880 /**
1881 * The {@code message-count} of the message.
1882 * <P>Type: INTEGER</P>
1883 * @deprecated this column is no longer supported.
1884 * @hide
1885 */
1886 @Deprecated
1887 public static final String MESSAGE_COUNT = "m_cnt";
1888
1889 /**
1890 * The {@code start} of the message.
1891 * <P>Type: INTEGER</P>
1892 * @deprecated this column is no longer supported.
1893 * @hide
1894 */
1895 @Deprecated
1896 public static final String START = "start";
1897
1898 /**
1899 * The {@code distribution-indicator} of the message.
1900 * <P>Type: TEXT</P>
1901 * @deprecated this column is no longer supported.
1902 * @hide
1903 */
1904 @Deprecated
1905 public static final String DISTRIBUTION_INDICATOR = "d_ind";
1906
1907 /**
1908 * The {@code element-descriptor} of the message.
1909 * <P>Type: TEXT</P>
1910 * @deprecated this column is no longer supported.
1911 * @hide
1912 */
1913 @Deprecated
1914 public static final String ELEMENT_DESCRIPTOR = "e_des";
1915
1916 /**
1917 * The {@code limit} of the message.
1918 * <P>Type: INTEGER</P>
1919 * @deprecated this column is no longer supported.
1920 * @hide
1921 */
1922 @Deprecated
1923 public static final String LIMIT = "limit";
1924
1925 /**
1926 * The {@code recommended-retrieval-mode} of the message.
1927 * <P>Type: INTEGER</P>
1928 * @deprecated this column is no longer supported.
1929 * @hide
1930 */
1931 @Deprecated
1932 public static final String RECOMMENDED_RETRIEVAL_MODE = "r_r_mod";
1933
1934 /**
1935 * The {@code recommended-retrieval-mode-text} of the message.
1936 * <P>Type: TEXT</P>
1937 * @deprecated this column is no longer supported.
1938 * @hide
1939 */
1940 @Deprecated
1941 public static final String RECOMMENDED_RETRIEVAL_MODE_TEXT = "r_r_mod_txt";
1942
1943 /**
1944 * The {@code status-text} of the message.
1945 * <P>Type: TEXT</P>
1946 * @deprecated this column is no longer supported.
1947 * @hide
1948 */
1949 @Deprecated
1950 public static final String STATUS_TEXT = "st_txt";
1951
1952 /**
1953 * The {@code applic-id} of the message.
1954 * <P>Type: TEXT</P>
1955 * @deprecated this column is no longer supported.
1956 * @hide
1957 */
1958 @Deprecated
1959 public static final String APPLIC_ID = "apl_id";
1960
1961 /**
1962 * The {@code reply-applic-id} of the message.
1963 * <P>Type: TEXT</P>
1964 * @deprecated this column is no longer supported.
1965 * @hide
1966 */
1967 @Deprecated
1968 public static final String REPLY_APPLIC_ID = "r_apl_id";
1969
1970 /**
1971 * The {@code aux-applic-id} of the message.
1972 * <P>Type: TEXT</P>
1973 * @deprecated this column is no longer supported.
1974 * @hide
1975 */
1976 @Deprecated
1977 public static final String AUX_APPLIC_ID = "aux_apl_id";
1978
1979 /**
1980 * The {@code drm-content} of the message.
1981 * <P>Type: TEXT</P>
1982 * @deprecated this column is no longer supported.
1983 * @hide
1984 */
1985 @Deprecated
1986 public static final String DRM_CONTENT = "drm_c";
1987
1988 /**
1989 * The {@code adaptation-allowed} of the message.
1990 * <P>Type: TEXT</P>
1991 * @deprecated this column is no longer supported.
1992 * @hide
1993 */
1994 @Deprecated
1995 public static final String ADAPTATION_ALLOWED = "adp_a";
1996
1997 /**
1998 * The {@code replace-id} of the message.
1999 * <P>Type: TEXT</P>
2000 * @deprecated this column is no longer supported.
2001 * @hide
2002 */
2003 @Deprecated
2004 public static final String REPLACE_ID = "repl_id";
2005
2006 /**
2007 * The {@code cancel-id} of the message.
2008 * <P>Type: TEXT</P>
2009 * @deprecated this column is no longer supported.
2010 * @hide
2011 */
2012 @Deprecated
2013 public static final String CANCEL_ID = "cl_id";
2014
2015 /**
2016 * The {@code cancel-status} of the message.
2017 * <P>Type: INTEGER</P>
2018 * @deprecated this column is no longer supported.
2019 * @hide
2020 */
2021 @Deprecated
2022 public static final String CANCEL_STATUS = "cl_st";
2023
2024 /**
2025 * Is the message locked?
2026 * <P>Type: INTEGER (boolean)</P>
2027 */
2028 public static final String LOCKED = "locked";
2029
2030 /**
2031 * The subscription to which the message belongs to. Its value will be
2032 * < 0 if the sub id cannot be determined.
2033 * <p>Type: INTEGER (long)</p>
2034 */
2035 public static final String SUBSCRIPTION_ID = "sub_id";
2036
2037 /**
2038 * The identity of the sender of a sent message. It is
2039 * usually the package name of the app which sends the message.
2040 * <p class="note"><strong>Note:</strong>
2041 * This column is read-only. It is set by the provider and can not be changed by apps.
2042 * <p>Type: TEXT</p>
2043 */
2044 public static final String CREATOR = "creator";
2045 }
2046
2047 /**
2048 * Columns for the "canonical_addresses" table used by MMS and SMS.
2049 */
2050 public interface CanonicalAddressesColumns extends BaseColumns {
2051 /**
2052 * An address used in MMS or SMS. Email addresses are
2053 * converted to lower case and are compared by string
2054 * equality. Other addresses are compared using
2055 * PHONE_NUMBERS_EQUAL.
2056 * <P>Type: TEXT</P>
2057 */
2058 public static final String ADDRESS = "address";
2059 }
2060
2061 /**
2062 * Columns for the "threads" table used by MMS and SMS.
2063 */
2064 public interface ThreadsColumns extends BaseColumns {
2065
2066 /**
2067 * The date at which the thread was created.
2068 * <P>Type: INTEGER (long)</P>
2069 */
2070 public static final String DATE = "date";
2071
2072 /**
2073 * A string encoding of the recipient IDs of the recipients of
2074 * the message, in numerical order and separated by spaces.
2075 * <P>Type: TEXT</P>
2076 */
2077 public static final String RECIPIENT_IDS = "recipient_ids";
2078
2079 /**
2080 * The message count of the thread.
2081 * <P>Type: INTEGER</P>
2082 */
2083 public static final String MESSAGE_COUNT = "message_count";
2084
2085 /**
2086 * Indicates whether all messages of the thread have been read.
2087 * <P>Type: INTEGER</P>
2088 */
2089 public static final String READ = "read";
2090
2091 /**
2092 * The snippet of the latest message in the thread.
2093 * <P>Type: TEXT</P>
2094 */
2095 public static final String SNIPPET = "snippet";
2096
2097 /**
2098 * The charset of the snippet.
2099 * <P>Type: INTEGER</P>
2100 */
2101 public static final String SNIPPET_CHARSET = "snippet_cs";
2102
2103 /**
2104 * Type of the thread, either {@link Threads#COMMON_THREAD} or
2105 * {@link Threads#BROADCAST_THREAD}.
2106 * <P>Type: INTEGER</P>
2107 */
2108 public static final String TYPE = "type";
2109
2110 /**
2111 * Indicates whether there is a transmission error in the thread.
2112 * <P>Type: INTEGER</P>
2113 */
2114 public static final String ERROR = "error";
2115
2116 /**
2117 * Indicates whether this thread contains any attachments.
2118 * <P>Type: INTEGER</P>
2119 */
2120 public static final String HAS_ATTACHMENT = "has_attachment";
2121
2122 /**
2123 * If the thread is archived
2124 * <P>Type: INTEGER (boolean)</P>
2125 */
2126 public static final String ARCHIVED = "archived";
2127 }
2128
2129 /**
2130 * Helper functions for the "threads" table used by MMS and SMS.
Leland Millerc445b2b2019-01-09 17:00:09 -08002131 *
2132 * Thread IDs are determined by the participants in a conversation and can be used to match
2133 * both SMS and MMS messages.
2134 *
2135 * To avoid issues where applications might cache a thread ID, the thread ID of a deleted thread
2136 * must not be reused to point at a new thread.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002137 */
2138 public static final class Threads implements ThreadsColumns {
2139
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002140 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002141 private static final String[] ID_PROJECTION = { BaseColumns._ID };
2142
2143 /**
2144 * Private {@code content://} style URL for this table. Used by
2145 * {@link #getOrCreateThreadId(android.content.Context, java.util.Set)}.
2146 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002147 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002148 private static final Uri THREAD_ID_CONTENT_URI = Uri.parse(
2149 "content://mms-sms/threadID");
2150
2151 /**
2152 * The {@code content://} style URL for this table, by conversation.
2153 */
2154 public static final Uri CONTENT_URI = Uri.withAppendedPath(
2155 MmsSms.CONTENT_URI, "conversations");
2156
2157 /**
2158 * The {@code content://} style URL for this table, for obsolete threads.
2159 */
2160 public static final Uri OBSOLETE_THREADS_URI = Uri.withAppendedPath(
2161 CONTENT_URI, "obsolete");
2162
2163 /** Thread type: common thread. */
2164 public static final int COMMON_THREAD = 0;
2165
2166 /** Thread type: broadcast thread. */
2167 public static final int BROADCAST_THREAD = 1;
2168
2169 /**
2170 * Not instantiable.
2171 * @hide
2172 */
2173 private Threads() {
2174 }
2175
2176 /**
2177 * This is a single-recipient version of {@code getOrCreateThreadId}.
2178 * It's convenient for use with SMS messages.
2179 * @param context the context object to use.
2180 * @param recipient the recipient to send to.
2181 */
2182 public static long getOrCreateThreadId(Context context, String recipient) {
2183 Set<String> recipients = new HashSet<String>();
2184
2185 recipients.add(recipient);
2186 return getOrCreateThreadId(context, recipients);
2187 }
2188
2189 /**
Leland Millerc445b2b2019-01-09 17:00:09 -08002190 * Given a set of recipients return its thread ID.
2191 * <p>
2192 * If a thread exists containing the provided participants, return its thread ID. Otherwise,
2193 * this will create a new thread containing the provided participants and return its ID.
Dan Willemsen4980bf42017-02-14 14:17:12 -08002194 */
2195 public static long getOrCreateThreadId(
2196 Context context, Set<String> recipients) {
2197 Uri.Builder uriBuilder = THREAD_ID_CONTENT_URI.buildUpon();
2198
2199 for (String recipient : recipients) {
2200 if (Mms.isEmailAddress(recipient)) {
2201 recipient = Mms.extractAddrSpec(recipient);
2202 }
2203
2204 uriBuilder.appendQueryParameter("recipient", recipient);
2205 }
2206
2207 Uri uri = uriBuilder.build();
2208 //if (DEBUG) Rlog.v(TAG, "getOrCreateThreadId uri: " + uri);
2209
2210 Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
2211 uri, ID_PROJECTION, null, null, null);
2212 if (cursor != null) {
2213 try {
2214 if (cursor.moveToFirst()) {
2215 return cursor.getLong(0);
2216 } else {
2217 Rlog.e(TAG, "getOrCreateThreadId returned no rows!");
2218 }
2219 } finally {
2220 cursor.close();
2221 }
2222 }
2223
2224 Rlog.e(TAG, "getOrCreateThreadId failed with " + recipients.size() + " recipients");
2225 throw new IllegalArgumentException("Unable to find or allocate a thread ID.");
2226 }
2227 }
2228
2229 /**
Sahin Caliskanf00a8762019-01-24 14:32:12 -08002230 * Columns for the "rcs_*" tables used by {@link android.telephony.ims.RcsMessageStore} classes.
2231 *
2232 * @hide - not meant for public use
2233 */
2234 public interface RcsColumns {
Leland Millerbd7959d2019-02-13 10:31:31 -08002235 // TODO(sahinc): Turn this to true once the schema finalizes, so that people can update
2236 // their messaging databases. NOTE: move the switch/case update in MmsSmsDatabaseHelper to
2237 // the latest version of the database before turning this flag to true.
2238 boolean IS_RCS_TABLE_SCHEMA_CODE_COMPLETE = false;
2239
Sahin Caliskanf00a8762019-01-24 14:32:12 -08002240 /**
2241 * The authority for the content provider
2242 */
2243 String AUTHORITY = "rcs";
2244
2245 /**
2246 * The URI to start building upon to use {@link com.android.providers.telephony.RcsProvider}
2247 */
2248 Uri CONTENT_AND_AUTHORITY = Uri.parse("content://" + AUTHORITY);
2249
2250 /**
2251 * The value to be used whenever a transaction that expects an integer to be returned
2252 * failed.
2253 */
2254 int TRANSACTION_FAILED = Integer.MIN_VALUE;
2255
2256 /**
2257 * The value that denotes a timestamp was not set before (e.g. a message that is not
2258 * delivered yet will not have a DELIVERED_TIMESTAMP)
2259 */
2260 long TIMESTAMP_NOT_SET = 0;
2261
2262 /**
2263 * The table that {@link android.telephony.ims.RcsThread} gets persisted to
2264 */
2265 interface RcsThreadColumns {
2266 /**
2267 * The path that should be used for referring to
2268 * {@link android.telephony.ims.RcsThread}s in
2269 * {@link com.android.providers.telephony.RcsProvider} URIs.
2270 */
2271 String RCS_THREAD_URI_PART = "thread";
2272
2273 /**
2274 * The URI to query or modify {@link android.telephony.ims.RcsThread} via the content
2275 * provider.
2276 */
2277 Uri RCS_THREAD_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY, RCS_THREAD_URI_PART);
2278
2279 /**
2280 * The unique identifier of an {@link android.telephony.ims.RcsThread}
2281 */
2282 String RCS_THREAD_ID_COLUMN = "rcs_thread_id";
2283 }
2284
2285 /**
2286 * The table that {@link android.telephony.ims.Rcs1To1Thread} gets persisted to
2287 */
2288 interface Rcs1To1ThreadColumns extends RcsThreadColumns {
2289 /**
2290 * The path that should be used for referring to
2291 * {@link android.telephony.ims.Rcs1To1Thread}s in
2292 * {@link com.android.providers.telephony.RcsProvider} URIs.
2293 */
2294 String RCS_1_TO_1_THREAD_URI_PART = "p2p_thread";
2295
2296 /**
2297 * The URI to query or modify {@link android.telephony.ims.Rcs1To1Thread}s via the
Leland Millerdb2337f2019-02-20 07:53:49 -08002298 * content provider. Can also insert to this URI to create a new 1-to-1 thread. When
2299 * performing an insert, ensure that the provided content values contain the other
2300 * participant's ID under the key
2301 * {@link RcsParticipantColumns.RCS_PARTICIPANT_ID_COLUMN}
Sahin Caliskanf00a8762019-01-24 14:32:12 -08002302 */
2303 Uri RCS_1_TO_1_THREAD_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
2304 RCS_1_TO_1_THREAD_URI_PART);
2305
2306 /**
2307 * The SMS/MMS thread to fallback to in case of an RCS outage
2308 */
2309 String FALLBACK_THREAD_ID_COLUMN = "rcs_fallback_thread_id";
2310 }
2311
2312 /**
2313 * The table that {@link android.telephony.ims.RcsGroupThread} gets persisted to
2314 */
2315 interface RcsGroupThreadColumns extends RcsThreadColumns {
2316 /**
2317 * The path that should be used for referring to
2318 * {@link android.telephony.ims.RcsGroupThread}s in
2319 * {@link com.android.providers.telephony.RcsProvider} URIs.
2320 */
2321 String RCS_GROUP_THREAD_URI_PART = "group_thread";
2322
2323 /**
2324 * The URI to query or modify {@link android.telephony.ims.RcsGroupThread}s via the
2325 * content provider
2326 */
2327 Uri RCS_GROUP_THREAD_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
2328 RCS_GROUP_THREAD_URI_PART);
2329
2330 /**
2331 * The owner/admin of the {@link android.telephony.ims.RcsGroupThread}
2332 */
2333 String OWNER_PARTICIPANT_COLUMN = "owner_participant";
2334
2335 /**
2336 * The user visible name of the group
2337 */
2338 String GROUP_NAME_COLUMN = "group_name";
2339
2340 /**
2341 * The user visible icon of the group
2342 */
2343 String GROUP_ICON_COLUMN = "group_icon";
2344
2345 /**
2346 * The RCS conference URI for this group
2347 */
2348 String CONFERENCE_URI_COLUMN = "conference_uri";
2349 }
2350
2351 /**
2352 * The view that enables polling from all types of RCS threads at once
2353 */
2354 interface RcsUnifiedThreadColumns extends RcsThreadColumns, Rcs1To1ThreadColumns,
2355 RcsGroupThreadColumns {
2356 /**
2357 * The type of this {@link android.telephony.ims.RcsThread}
2358 */
2359 String THREAD_TYPE_COLUMN = "thread_type";
2360
2361 /**
2362 * Integer returned as a result from a database query that denotes the thread is 1 to 1
2363 */
2364 int THREAD_TYPE_1_TO_1 = 0;
2365
2366 /**
2367 * Integer returned as a result from a database query that denotes the thread is 1 to 1
2368 */
2369 int THREAD_TYPE_GROUP = 1;
2370 }
2371
2372 /**
2373 * The table that {@link android.telephony.ims.RcsParticipant} gets persisted to
2374 */
2375 interface RcsParticipantColumns {
2376 /**
2377 * The path that should be used for referring to
2378 * {@link android.telephony.ims.RcsParticipant}s in
2379 * {@link com.android.providers.telephony.RcsProvider} URIs.
2380 */
2381 String RCS_PARTICIPANT_URI_PART = "participant";
2382
2383 /**
2384 * The URI to query or modify {@link android.telephony.ims.RcsParticipant}s via the
2385 * content provider
2386 */
2387 Uri RCS_PARTICIPANT_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
2388 RCS_PARTICIPANT_URI_PART);
2389
2390 /**
2391 * The unique identifier of the entry in the database
2392 */
2393 String RCS_PARTICIPANT_ID_COLUMN = "rcs_participant_id";
2394
2395 /**
2396 * A foreign key on canonical_address table, also used by SMS/MMS
2397 */
2398 String CANONICAL_ADDRESS_ID_COLUMN = "canonical_address_id";
2399
2400 /**
2401 * The user visible RCS alias for this participant.
2402 */
2403 String RCS_ALIAS_COLUMN = "rcs_alias";
2404 }
2405
2406 /**
2407 * Additional constants to enable access to {@link android.telephony.ims.RcsParticipant}
2408 * related data
2409 */
2410 interface RcsParticipantHelpers extends RcsParticipantColumns {
2411 /**
2412 * The view that unifies "rcs_participant" and "canonical_addresses" tables for easy
2413 * access to participant address.
2414 */
2415 String RCS_PARTICIPANT_WITH_ADDRESS_VIEW = "rcs_participant_with_address_view";
2416
2417 /**
2418 * The view that unifies "rcs_participant", "canonical_addresses" and
2419 * "rcs_thread_participant" junction table to get full information on participants that
2420 * contribute to threads.
2421 */
2422 String RCS_PARTICIPANT_WITH_THREAD_VIEW = "rcs_participant_with_thread_view";
2423 }
2424
2425 /**
2426 * The table that {@link android.telephony.ims.RcsMessage} gets persisted to
2427 */
2428 interface RcsMessageColumns {
2429 /**
2430 * Denotes the type of this message (i.e.
2431 * {@link android.telephony.ims.RcsIncomingMessage} or
2432 * {@link android.telephony.ims.RcsOutgoingMessage}
2433 */
2434 String MESSAGE_TYPE_COLUMN = "rcs_message_type";
2435
2436 /**
2437 * The unique identifier for the message in the database - i.e. the primary key.
2438 */
2439 String MESSAGE_ID_COLUMN = "rcs_message_row_id";
2440
2441 /**
2442 * The globally unique RCS identifier for the message. Please see 4.4.5.2 - GSMA
2443 * RCC.53 (RCS Device API 1.6 Specification)
2444 */
2445 String GLOBAL_ID_COLUMN = "rcs_message_global_id";
2446
2447 /**
2448 * The subscription where this message was sent from/to.
2449 */
2450 String SUB_ID_COLUMN = "sub_id";
2451
2452 /**
2453 * The sending status of the message.
2454 * @see android.telephony.ims.RcsMessage.RcsMessageStatus
2455 */
2456 String STATUS_COLUMN = "status";
2457
2458 /**
2459 * The creation timestamp of the message.
2460 */
2461 String ORIGINATION_TIMESTAMP_COLUMN = "origination_timestamp";
2462
2463 /**
2464 * The text content of the message.
2465 */
2466 String MESSAGE_TEXT_COLUMN = "rcs_text";
2467
2468 /**
2469 * The latitude content of the message, if it contains a location.
2470 */
2471 String LATITUDE_COLUMN = "latitude";
2472
2473 /**
2474 * The longitude content of the message, if it contains a location.
2475 */
2476 String LONGITUDE_COLUMN = "longitude";
2477 }
2478
2479 /**
2480 * The table that additional information of {@link android.telephony.ims.RcsIncomingMessage}
2481 * gets persisted to.
2482 */
2483 interface RcsIncomingMessageColumns extends RcsMessageColumns {
2484 /**
2485 The path that should be used for referring to
2486 * {@link android.telephony.ims.RcsIncomingMessage}s in
2487 * {@link com.android.providers.telephony.RcsProvider} URIs.
2488 */
2489 String INCOMING_MESSAGE_URI_PART = "incoming_message";
2490
2491 /**
2492 * The URI to query incoming messages through
2493 * {@link com.android.providers.telephony.RcsProvider}
2494 */
2495 Uri INCOMING_MESSAGE_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
2496 INCOMING_MESSAGE_URI_PART);
2497
2498 /**
2499 * The ID of the {@link android.telephony.ims.RcsParticipant} that sent this message
2500 */
2501 String SENDER_PARTICIPANT_ID_COLUMN = "sender_participant";
2502
2503 /**
2504 * The timestamp of arrival for this message.
2505 */
2506 String ARRIVAL_TIMESTAMP_COLUMN = "arrival_timestamp";
2507
2508 /**
2509 * The time when the recipient has read this message.
2510 */
2511 String SEEN_TIMESTAMP_COLUMN = "seen_timestamp";
2512 }
2513
2514 /**
2515 * The table that additional information of {@link android.telephony.ims.RcsOutgoingMessage}
2516 * gets persisted to.
2517 */
2518 interface RcsOutgoingMessageColumns extends RcsMessageColumns {
2519 /**
2520 * The path that should be used for referring to
2521 * {@link android.telephony.ims.RcsOutgoingMessage}s in
2522 * {@link com.android.providers.telephony.RcsProvider} URIs.
2523 */
2524 String OUTGOING_MESSAGE_URI_PART = "outgoing_message";
2525
2526 /**
2527 * The URI to query or modify {@link android.telephony.ims.RcsOutgoingMessage}s via the
2528 * content provider
2529 */
2530 Uri OUTGOING_MESSAGE_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
2531 OUTGOING_MESSAGE_URI_PART);
2532 }
2533
2534 /**
2535 * The delivery information of an {@link android.telephony.ims.RcsOutgoingMessage}
2536 */
2537 interface RcsMessageDeliveryColumns extends RcsOutgoingMessageColumns {
2538 /**
2539 * The path that should be used for referring to
2540 * {@link android.telephony.ims.RcsOutgoingMessageDelivery}s in
2541 * {@link com.android.providers.telephony.RcsProvider} URIs.
2542 */
2543 String DELIVERY_URI_PART = "delivery";
2544
2545 /**
2546 * The timestamp of delivery of this message.
2547 */
2548 String DELIVERED_TIMESTAMP_COLUMN = "delivered_timestamp";
2549
2550 /**
2551 * The time when the recipient has read this message.
2552 */
2553 String SEEN_TIMESTAMP_COLUMN = "seen_timestamp";
2554 }
2555
2556 /**
2557 * The views that allow querying {@link android.telephony.ims.RcsIncomingMessage} and
2558 * {@link android.telephony.ims.RcsOutgoingMessage} at the same time.
2559 */
2560 interface RcsUnifiedMessageColumns extends RcsIncomingMessageColumns,
2561 RcsOutgoingMessageColumns {
2562 /**
2563 * The path that is used to query all {@link android.telephony.ims.RcsMessage} in
2564 * {@link com.android.providers.telephony.RcsProvider} URIs.
2565 */
2566 String UNIFIED_MESSAGE_URI_PART = "message";
2567
2568 /**
2569 * The URI to query all types of {@link android.telephony.ims.RcsMessage}s
2570 */
2571 Uri UNIFIED_MESSAGE_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
2572 UNIFIED_MESSAGE_URI_PART);
2573
2574 /**
2575 * The name of the view that unites rcs_message and rcs_incoming_message tables.
2576 */
2577 String UNIFIED_INCOMING_MESSAGE_VIEW = "unified_incoming_message_view";
2578
2579 /**
2580 * The name of the view that unites rcs_message and rcs_outgoing_message tables.
2581 */
2582 String UNIFIED_OUTGOING_MESSAGE_VIEW = "unified_outgoing_message_view";
2583
2584 /**
2585 * The column that shows from which table the message entry came from.
2586 */
2587 String MESSAGE_TYPE_COLUMN = "message_type";
2588
2589 /**
2590 * Integer returned as a result from a database query that denotes that the message is
2591 * an incoming message
2592 */
2593 int MESSAGE_TYPE_INCOMING = 1;
2594
2595 /**
2596 * Integer returned as a result from a database query that denotes that the message is
2597 * an outgoing message
2598 */
2599 int MESSAGE_TYPE_OUTGOING = 0;
2600 }
2601
2602 /**
2603 * The table that {@link android.telephony.ims.RcsFileTransferPart} gets persisted to.
2604 */
2605 interface RcsFileTransferColumns {
2606 /**
2607 * The path that should be used for referring to
2608 * {@link android.telephony.ims.RcsFileTransferPart}s in
2609 * {@link com.android.providers.telephony.RcsProvider} URIs.
2610 */
2611 String FILE_TRANSFER_URI_PART = "file_transfer";
2612
2613 /**
2614 * The URI to query or modify {@link android.telephony.ims.RcsFileTransferPart}s via the
2615 * content provider
2616 */
2617 Uri FILE_TRANSFER_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
2618 FILE_TRANSFER_URI_PART);
2619
2620 /**
2621 * The globally unique file transfer ID for this RCS file transfer.
2622 */
2623 String FILE_TRANSFER_ID_COLUMN = "rcs_file_transfer_id";
2624
2625 /**
2626 * The RCS session ID for this file transfer. The ID is implementation dependent but
2627 * should be unique.
2628 */
2629 String SESSION_ID_COLUMN = "session_id";
2630
2631 /**
2632 * The URI that points to the content of this file transfer
2633 */
2634 String CONTENT_URI_COLUMN = "content_uri";
2635
2636 /**
2637 * The file type of this file transfer in bytes. The validity of types is not enforced
2638 * in {@link android.telephony.ims.RcsMessageStore} APIs.
2639 */
2640 String CONTENT_TYPE_COLUMN = "content_type";
2641
2642 /**
2643 * The size of the file transfer in bytes.
2644 */
2645 String FILE_SIZE_COLUMN = "file_size";
2646
2647 /**
2648 * Number of bytes that was successfully transmitted for this file transfer
2649 */
2650 String SUCCESSFULLY_TRANSFERRED_BYTES = "transfer_offset";
2651
2652 /**
2653 * The status of this file transfer
2654 * @see android.telephony.ims.RcsFileTransferPart.RcsFileTransferStatus
2655 */
2656 String TRANSFER_STATUS_COLUMN = "transfer_status";
2657
2658 /**
2659 * The on-screen width of the file transfer, if it contains multi-media
2660 */
2661 String WIDTH_COLUMN = "width";
2662
2663 /**
2664 * The on-screen height of the file transfer, if it contains multi-media
2665 */
2666 String HEIGHT_COLUMN = "height";
2667
2668 /**
2669 * The duration of the content in milliseconds if this file transfer contains
2670 * multi-media
2671 */
2672 String DURATION_MILLIS_COLUMN = "duration";
2673
2674 /**
2675 * The URI to the preview of the content of this file transfer
2676 */
2677 String PREVIEW_URI_COLUMN = "preview_uri";
2678
2679 /**
2680 * The type of the preview of the content of this file transfer. The validity of types
2681 * is not enforced in {@link android.telephony.ims.RcsMessageStore} APIs.
2682 */
2683 String PREVIEW_TYPE_COLUMN = "preview_type";
2684 }
2685
2686 /**
2687 * The table that holds the information for
2688 * {@link android.telephony.ims.RcsGroupThreadEvent} and its subclasses.
2689 */
2690 interface RcsThreadEventColumns {
2691 /**
2692 * The string used in the {@link com.android.providers.telephony.RcsProvider} URI to
2693 * refer to participant joined events (example URI:
2694 * {@code content://rcs/group_thread/3/participant_joined_event})
2695 */
2696 String PARTICIPANT_JOINED_URI_PART = "participant_joined_event";
2697
2698 /**
2699 * The string used in the {@link com.android.providers.telephony.RcsProvider} URI to
2700 * refer to participant left events. (example URI:
2701 * {@code content://rcs/group_thread/3/participant_left_event/4})
2702 */
2703 String PARTICIPANT_LEFT_URI_PART = "participant_left_event";
2704
2705 /**
2706 * The string used in the {@link com.android.providers.telephony.RcsProvider} URI to
2707 * refer to name changed events. (example URI:
2708 * {@code content://rcs/group_thread/3/name_changed_event})
2709 */
2710 String NAME_CHANGED_URI_PART = "name_changed_event";
2711
2712 /**
2713 * The string used in the {@link com.android.providers.telephony.RcsProvider} URI to
2714 * refer to icon changed events. (example URI:
2715 * {@code content://rcs/group_thread/3/icon_changed_event})
2716 */
2717 String ICON_CHANGED_URI_PART = "icon_changed_event";
2718
2719 /**
2720 * The unique ID of this event in the database, i.e. the primary key
2721 */
2722 String EVENT_ID_COLUMN = "event_id";
2723
2724 /**
2725 * The type of this event
2726 *
2727 * @see RcsEventTypes
2728 */
2729 String EVENT_TYPE_COLUMN = "event_type";
2730
2731 /**
2732 * The timestamp in milliseconds of when this event happened
2733 */
2734 String TIMESTAMP_COLUMN = "origination_timestamp";
2735
2736 /**
2737 * The participant that generated this event
2738 */
2739 String SOURCE_PARTICIPANT_ID_COLUMN = "source_participant";
2740
2741 /**
2742 * The receiving participant of this event if this was an
2743 * {@link android.telephony.ims.RcsGroupThreadParticipantJoinedEvent} or
2744 * {@link android.telephony.ims.RcsGroupThreadParticipantLeftEvent}
2745 */
2746 String DESTINATION_PARTICIPANT_ID_COLUMN = "destination_participant";
2747
2748 /**
2749 * The URI for the new icon of the group thread if this was an
2750 * {@link android.telephony.ims.RcsGroupThreadIconChangedEvent}
2751 */
2752 String NEW_ICON_URI_COLUMN = "new_icon_uri";
2753
2754 /**
2755 * The URI for the new name of the group thread if this was an
2756 * {@link android.telephony.ims.RcsGroupThreadNameChangedEvent}
2757 */
2758 String NEW_NAME_COLUMN = "new_name";
2759 }
2760
2761 /**
2762 * The table that {@link android.telephony.ims.RcsParticipantAliasChangedEvent} gets
2763 * persisted to
2764 */
2765 interface RcsParticipantEventColumns {
2766 /**
2767 * The path that should be used for referring to
2768 * {@link android.telephony.ims.RcsParticipantAliasChangedEvent}s in
2769 * {@link com.android.providers.telephony.RcsProvider} URIs.
2770 */
2771 String ALIAS_CHANGE_EVENT_URI_PART = "alias_change_event";
2772
2773 /**
2774 * The new alias of the participant
2775 */
2776 String NEW_ALIAS_COLUMN = "new_alias";
2777 }
2778
2779 /**
2780 * These values are used in {@link com.android.providers.telephony.RcsProvider} to determine
2781 * what kind of event is present in the storage.
2782 */
2783 interface RcsEventTypes {
2784 /**
2785 * Integer constant that is stored in the
2786 * {@link com.android.providers.telephony.RcsProvider} database that denotes the event
2787 * is of type {@link android.telephony.ims.RcsParticipantAliasChangedEvent}
2788 */
2789 int PARTICIPANT_ALIAS_CHANGED_EVENT_TYPE = 1;
2790
2791 /**
2792 * Integer constant that is stored in the
2793 * {@link com.android.providers.telephony.RcsProvider} database that denotes the event
2794 * is of type {@link android.telephony.ims.RcsGroupThreadParticipantJoinedEvent}
2795 */
2796 int PARTICIPANT_JOINED_EVENT_TYPE = 2;
2797
2798 /**
2799 * Integer constant that is stored in the
2800 * {@link com.android.providers.telephony.RcsProvider} database that denotes the event
2801 * is of type {@link android.telephony.ims.RcsGroupThreadParticipantLeftEvent}
2802 */
2803 int PARTICIPANT_LEFT_EVENT_TYPE = 4;
2804
2805 /**
2806 * Integer constant that is stored in the
2807 * {@link com.android.providers.telephony.RcsProvider} database that denotes the event
2808 * is of type {@link android.telephony.ims.RcsGroupThreadIconChangedEvent}
2809 */
2810 int ICON_CHANGED_EVENT_TYPE = 8;
2811
2812 /**
2813 * Integer constant that is stored in the
2814 * {@link com.android.providers.telephony.RcsProvider} database that denotes the event
2815 * is of type {@link android.telephony.ims.RcsGroupThreadNameChangedEvent}
2816 */
2817 int NAME_CHANGED_EVENT_TYPE = 16;
2818 }
2819
2820 /**
2821 * The view that allows unified querying across all events
2822 */
2823 interface RcsUnifiedEventHelper extends RcsParticipantEventColumns, RcsThreadEventColumns {
2824 /**
2825 * The path that should be used for referring to
2826 * {@link android.telephony.ims.RcsEvent}s in
2827 * {@link com.android.providers.telephony.RcsProvider} URIs.
2828 */
2829 String RCS_EVENT_QUERY_URI_PATH = "event";
2830
2831 /**
2832 * The URI to query {@link android.telephony.ims.RcsEvent}s via the content provider.
2833 */
2834 Uri RCS_EVENT_QUERY_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
2835 RCS_EVENT_QUERY_URI_PATH);
2836 }
Leland Miller7b378ab2019-01-24 16:09:10 -08002837
2838 /**
2839 * Allows RCS specific canonical address handling.
2840 */
2841 interface RcsCanonicalAddressHelper {
2842 /**
2843 * Returns the canonical address ID for a canonical address, if now row exists, this
2844 * will add a row and return its ID. This helper works against the same table used by
2845 * the SMS and MMS threads, but is accessible only by the phone process for use by RCS
2846 * message storage.
2847 *
2848 * @throws IllegalArgumentException if unable to retrieve or create the canonical
2849 * address entry.
2850 */
2851 static long getOrCreateCanonicalAddressId(
2852 ContentResolver contentResolver, String canonicalAddress) {
2853
2854 Uri.Builder uriBuilder = CONTENT_AND_AUTHORITY.buildUpon();
2855 uriBuilder.appendPath("canonical-address");
2856 uriBuilder.appendQueryParameter("address", canonicalAddress);
2857 Uri uri = uriBuilder.build();
2858
2859 try (Cursor cursor = contentResolver.query(uri, null, null, null)) {
2860 if (cursor != null && cursor.moveToFirst()) {
2861 return cursor.getLong(cursor.getColumnIndex(CanonicalAddressesColumns._ID));
2862 } else {
2863 Rlog.e(TAG, "getOrCreateCanonicalAddressId returned no rows");
2864 }
2865 }
2866
2867 Rlog.e(TAG, "getOrCreateCanonicalAddressId failed");
2868 throw new IllegalArgumentException(
2869 "Unable to find or allocate a canonical address ID");
2870 }
2871 }
Sahin Caliskanf00a8762019-01-24 14:32:12 -08002872 }
2873
2874 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08002875 * Contains all MMS messages.
2876 */
2877 public static final class Mms implements BaseMmsColumns {
2878
2879 /**
2880 * Not instantiable.
2881 * @hide
2882 */
2883 private Mms() {
2884 }
2885
2886 /**
2887 * The {@code content://} URI for this table.
2888 */
2889 public static final Uri CONTENT_URI = Uri.parse("content://mms");
2890
2891 /**
2892 * Content URI for getting MMS report requests.
2893 */
2894 public static final Uri REPORT_REQUEST_URI = Uri.withAppendedPath(
2895 CONTENT_URI, "report-request");
2896
2897 /**
2898 * Content URI for getting MMS report status.
2899 */
2900 public static final Uri REPORT_STATUS_URI = Uri.withAppendedPath(
2901 CONTENT_URI, "report-status");
2902
2903 /**
2904 * The default sort order for this table.
2905 */
2906 public static final String DEFAULT_SORT_ORDER = "date DESC";
2907
2908 /**
2909 * Regex pattern for names and email addresses.
2910 * <ul>
2911 * <li><em>mailbox</em> = {@code name-addr}</li>
2912 * <li><em>name-addr</em> = {@code [display-name] angle-addr}</li>
2913 * <li><em>angle-addr</em> = {@code [CFWS] "<" addr-spec ">" [CFWS]}</li>
2914 * </ul>
2915 * @hide
2916 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002917 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002918 public static final Pattern NAME_ADDR_EMAIL_PATTERN =
2919 Pattern.compile("\\s*(\"[^\"]*\"|[^<>\"]+)\\s*<([^<>]+)>\\s*");
2920
2921 /**
2922 * Helper method to query this table.
2923 * @hide
2924 */
2925 public static Cursor query(
2926 ContentResolver cr, String[] projection) {
2927 return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
2928 }
2929
2930 /**
2931 * Helper method to query this table.
2932 * @hide
2933 */
2934 public static Cursor query(
2935 ContentResolver cr, String[] projection,
2936 String where, String orderBy) {
2937 return cr.query(CONTENT_URI, projection,
2938 where, null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
2939 }
2940
2941 /**
2942 * Helper method to extract email address from address string.
2943 * @hide
2944 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002945 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002946 public static String extractAddrSpec(String address) {
2947 Matcher match = NAME_ADDR_EMAIL_PATTERN.matcher(address);
2948
2949 if (match.matches()) {
2950 return match.group(2);
2951 }
2952 return address;
2953 }
2954
2955 /**
2956 * Is the specified address an email address?
2957 *
2958 * @param address the input address to test
2959 * @return true if address is an email address; false otherwise.
2960 * @hide
2961 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002962 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002963 public static boolean isEmailAddress(String address) {
2964 if (TextUtils.isEmpty(address)) {
2965 return false;
2966 }
2967
2968 String s = extractAddrSpec(address);
2969 Matcher match = Patterns.EMAIL_ADDRESS.matcher(s);
2970 return match.matches();
2971 }
2972
2973 /**
2974 * Is the specified number a phone number?
2975 *
2976 * @param number the input number to test
2977 * @return true if number is a phone number; false otherwise.
2978 * @hide
2979 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002980 @UnsupportedAppUsage
Dan Willemsen4980bf42017-02-14 14:17:12 -08002981 public static boolean isPhoneNumber(String number) {
2982 if (TextUtils.isEmpty(number)) {
2983 return false;
2984 }
2985
2986 Matcher match = Patterns.PHONE.matcher(number);
2987 return match.matches();
2988 }
2989
2990 /**
2991 * Contains all MMS messages in the MMS app inbox.
2992 */
2993 public static final class Inbox implements BaseMmsColumns {
2994
2995 /**
2996 * Not instantiable.
2997 * @hide
2998 */
2999 private Inbox() {
3000 }
3001
3002 /**
3003 * The {@code content://} style URL for this table.
3004 */
3005 public static final Uri
3006 CONTENT_URI = Uri.parse("content://mms/inbox");
3007
3008 /**
3009 * The default sort order for this table.
3010 */
3011 public static final String DEFAULT_SORT_ORDER = "date DESC";
3012 }
3013
3014 /**
3015 * Contains all MMS messages in the MMS app sent folder.
3016 */
3017 public static final class Sent implements BaseMmsColumns {
3018
3019 /**
3020 * Not instantiable.
3021 * @hide
3022 */
3023 private Sent() {
3024 }
3025
3026 /**
3027 * The {@code content://} style URL for this table.
3028 */
3029 public static final Uri
3030 CONTENT_URI = Uri.parse("content://mms/sent");
3031
3032 /**
3033 * The default sort order for this table.
3034 */
3035 public static final String DEFAULT_SORT_ORDER = "date DESC";
3036 }
3037
3038 /**
3039 * Contains all MMS messages in the MMS app drafts folder.
3040 */
3041 public static final class Draft implements BaseMmsColumns {
3042
3043 /**
3044 * Not instantiable.
3045 * @hide
3046 */
3047 private Draft() {
3048 }
3049
3050 /**
3051 * The {@code content://} style URL for this table.
3052 */
3053 public static final Uri
3054 CONTENT_URI = Uri.parse("content://mms/drafts");
3055
3056 /**
3057 * The default sort order for this table.
3058 */
3059 public static final String DEFAULT_SORT_ORDER = "date DESC";
3060 }
3061
3062 /**
3063 * Contains all MMS messages in the MMS app outbox.
3064 */
3065 public static final class Outbox implements BaseMmsColumns {
3066
3067 /**
3068 * Not instantiable.
3069 * @hide
3070 */
3071 private Outbox() {
3072 }
3073
3074 /**
3075 * The {@code content://} style URL for this table.
3076 */
3077 public static final Uri
3078 CONTENT_URI = Uri.parse("content://mms/outbox");
3079
3080 /**
3081 * The default sort order for this table.
3082 */
3083 public static final String DEFAULT_SORT_ORDER = "date DESC";
3084 }
3085
3086 /**
3087 * Contains address information for an MMS message.
3088 */
3089 public static final class Addr implements BaseColumns {
3090
3091 /**
3092 * Not instantiable.
3093 * @hide
3094 */
3095 private Addr() {
3096 }
3097
3098 /**
3099 * The ID of MM which this address entry belongs to.
3100 * <P>Type: INTEGER (long)</P>
3101 */
3102 public static final String MSG_ID = "msg_id";
3103
3104 /**
3105 * The ID of contact entry in Phone Book.
3106 * <P>Type: INTEGER (long)</P>
3107 */
3108 public static final String CONTACT_ID = "contact_id";
3109
3110 /**
3111 * The address text.
3112 * <P>Type: TEXT</P>
3113 */
3114 public static final String ADDRESS = "address";
3115
3116 /**
3117 * Type of address: must be one of {@code PduHeaders.BCC},
3118 * {@code PduHeaders.CC}, {@code PduHeaders.FROM}, {@code PduHeaders.TO}.
3119 * <P>Type: INTEGER</P>
3120 */
3121 public static final String TYPE = "type";
3122
3123 /**
3124 * Character set of this entry (MMS charset value).
3125 * <P>Type: INTEGER</P>
3126 */
3127 public static final String CHARSET = "charset";
Nagarajaa15ee4d2019-07-09 14:54:33 +05303128
3129 /**
3130 * Generates a Addr {@link Uri} for message, used to perform Addr table operation
3131 * for mms.
3132 *
3133 * @param messageId the messageId used to generate Addr {@link Uri} dynamically
3134 * @return the addrUri used to perform Addr table operation for mms
3135 */
3136 @NonNull
3137 public static Uri getAddrUriForMessage(@NonNull String messageId) {
3138 Uri addrUri = Mms.CONTENT_URI.buildUpon()
3139 .appendPath(String.valueOf(messageId)).appendPath("addr").build();
3140 return addrUri;
3141 }
Dan Willemsen4980bf42017-02-14 14:17:12 -08003142 }
3143
3144 /**
3145 * Contains message parts.
Leland Miller6c753552019-01-22 17:28:55 -08003146 *
3147 * To avoid issues where applications might cache a part ID, the ID of a deleted part must
3148 * not be reused to point at a new part.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003149 */
3150 public static final class Part implements BaseColumns {
3151
3152 /**
3153 * Not instantiable.
3154 * @hide
3155 */
3156 private Part() {
3157 }
3158
3159 /**
Nagarajaa15ee4d2019-07-09 14:54:33 +05303160 * The name of part table.
3161 */
3162 private static final String TABLE_PART = "part";
3163
3164 /**
Leland Miller6c753552019-01-22 17:28:55 -08003165 * The {@code content://} style URL for this table. Can be appended with a part ID to
3166 * address individual parts.
3167 */
Leland Miller7a29ca62019-04-15 15:57:28 -07003168 @NonNull
Nagarajaa15ee4d2019-07-09 14:54:33 +05303169 public static final Uri CONTENT_URI = Uri.withAppendedPath(Mms.CONTENT_URI, TABLE_PART);
Leland Miller6c753552019-01-22 17:28:55 -08003170
3171 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08003172 * The identifier of the message which this part belongs to.
3173 * <P>Type: INTEGER</P>
3174 */
3175 public static final String MSG_ID = "mid";
3176
3177 /**
3178 * The order of the part.
3179 * <P>Type: INTEGER</P>
3180 */
3181 public static final String SEQ = "seq";
3182
3183 /**
3184 * The content type of the part.
3185 * <P>Type: TEXT</P>
3186 */
3187 public static final String CONTENT_TYPE = "ct";
3188
3189 /**
3190 * The name of the part.
3191 * <P>Type: TEXT</P>
3192 */
3193 public static final String NAME = "name";
3194
3195 /**
3196 * The charset of the part.
3197 * <P>Type: TEXT</P>
3198 */
3199 public static final String CHARSET = "chset";
3200
3201 /**
3202 * The file name of the part.
3203 * <P>Type: TEXT</P>
3204 */
3205 public static final String FILENAME = "fn";
3206
3207 /**
3208 * The content disposition of the part.
3209 * <P>Type: TEXT</P>
3210 */
3211 public static final String CONTENT_DISPOSITION = "cd";
3212
3213 /**
3214 * The content ID of the part.
3215 * <P>Type: INTEGER</P>
3216 */
3217 public static final String CONTENT_ID = "cid";
3218
3219 /**
3220 * The content location of the part.
3221 * <P>Type: INTEGER</P>
3222 */
3223 public static final String CONTENT_LOCATION = "cl";
3224
3225 /**
3226 * The start of content-type of the message.
3227 * <P>Type: INTEGER</P>
3228 */
3229 public static final String CT_START = "ctt_s";
3230
3231 /**
3232 * The type of content-type of the message.
3233 * <P>Type: TEXT</P>
3234 */
3235 public static final String CT_TYPE = "ctt_t";
3236
3237 /**
3238 * The location (on filesystem) of the binary data of the part.
3239 * <P>Type: INTEGER</P>
3240 */
3241 public static final String _DATA = "_data";
3242
3243 /**
3244 * The message text.
3245 * <P>Type: TEXT</P>
3246 */
3247 public static final String TEXT = "text";
Nagarajaa15ee4d2019-07-09 14:54:33 +05303248
3249 /**
3250 * Generates a Part {@link Uri} for message, used to perform Part table operation
3251 * for mms.
3252 *
3253 * @param messageId the messageId used to generate Part {@link Uri} dynamically
3254 * @return the partUri used to perform Part table operation for mms
3255 */
3256 @NonNull
3257 public static Uri getPartUriForMessage(@NonNull String messageId) {
3258 Uri partUri = Mms.CONTENT_URI.buildUpon()
3259 .appendPath(String.valueOf(messageId)).appendPath(
3260 TABLE_PART).build();
3261 return partUri;
3262 }
Dan Willemsen4980bf42017-02-14 14:17:12 -08003263 }
3264
3265 /**
3266 * Message send rate table.
3267 */
3268 public static final class Rate {
3269
3270 /**
3271 * Not instantiable.
3272 * @hide
3273 */
3274 private Rate() {
3275 }
3276
3277 /**
3278 * The {@code content://} style URL for this table.
3279 */
3280 public static final Uri CONTENT_URI = Uri.withAppendedPath(
3281 Mms.CONTENT_URI, "rate");
3282
3283 /**
3284 * When a message was successfully sent.
3285 * <P>Type: INTEGER (long)</P>
3286 */
3287 public static final String SENT_TIME = "sent_time";
3288 }
3289
3290 /**
3291 * Intents class.
3292 */
3293 public static final class Intents {
3294
3295 /**
3296 * Not instantiable.
3297 * @hide
3298 */
3299 private Intents() {
3300 }
3301
3302 /**
3303 * Indicates that the contents of specified URIs were changed.
3304 * The application which is showing or caching these contents
3305 * should be updated.
3306 */
3307 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3308 public static final String CONTENT_CHANGED_ACTION
3309 = "android.intent.action.CONTENT_CHANGED";
3310
3311 /**
3312 * An extra field which stores the URI of deleted contents.
3313 */
3314 public static final String DELETED_CONTENTS = "deleted_contents";
3315 }
3316 }
3317
3318 /**
3319 * Contains all MMS and SMS messages.
3320 */
3321 public static final class MmsSms implements BaseColumns {
3322
3323 /**
3324 * Not instantiable.
3325 * @hide
3326 */
3327 private MmsSms() {
3328 }
3329
3330 /**
3331 * The column to distinguish SMS and MMS messages in query results.
3332 */
3333 public static final String TYPE_DISCRIMINATOR_COLUMN =
3334 "transport_type";
3335
3336 /**
3337 * The {@code content://} style URL for this table.
3338 */
3339 public static final Uri CONTENT_URI = Uri.parse("content://mms-sms/");
3340
3341 /**
3342 * The {@code content://} style URL for this table, by conversation.
3343 */
3344 public static final Uri CONTENT_CONVERSATIONS_URI = Uri.parse(
3345 "content://mms-sms/conversations");
3346
3347 /**
3348 * The {@code content://} style URL for this table, by phone number.
3349 */
3350 public static final Uri CONTENT_FILTER_BYPHONE_URI = Uri.parse(
3351 "content://mms-sms/messages/byphone");
3352
3353 /**
3354 * The {@code content://} style URL for undelivered messages in this table.
3355 */
3356 public static final Uri CONTENT_UNDELIVERED_URI = Uri.parse(
3357 "content://mms-sms/undelivered");
3358
3359 /**
3360 * The {@code content://} style URL for draft messages in this table.
3361 */
3362 public static final Uri CONTENT_DRAFT_URI = Uri.parse(
3363 "content://mms-sms/draft");
3364
3365 /**
3366 * The {@code content://} style URL for locked messages in this table.
Nagarajaec816a02019-05-22 15:57:59 +05303367 * <P>This {@link Uri} is used to check at most one locked message found in the union of MMS
3368 * and SMS messages. Also this will return only _id column in response.</P>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003369 */
3370 public static final Uri CONTENT_LOCKED_URI = Uri.parse(
3371 "content://mms-sms/locked");
3372
3373 /**
3374 * Pass in a query parameter called "pattern" which is the text to search for.
3375 * The sort order is fixed to be: {@code thread_id ASC, date DESC}.
3376 */
3377 public static final Uri SEARCH_URI = Uri.parse(
3378 "content://mms-sms/search");
3379
3380 // Constants for message protocol types.
3381
3382 /** SMS protocol type. */
3383 public static final int SMS_PROTO = 0;
3384
3385 /** MMS protocol type. */
3386 public static final int MMS_PROTO = 1;
3387
3388 // Constants for error types of pending messages.
3389
3390 /** Error type: no error. */
3391 public static final int NO_ERROR = 0;
3392
3393 /** Error type: generic transient error. */
3394 public static final int ERR_TYPE_GENERIC = 1;
3395
3396 /** Error type: SMS protocol transient error. */
3397 public static final int ERR_TYPE_SMS_PROTO_TRANSIENT = 2;
3398
3399 /** Error type: MMS protocol transient error. */
3400 public static final int ERR_TYPE_MMS_PROTO_TRANSIENT = 3;
3401
3402 /** Error type: transport failure. */
3403 public static final int ERR_TYPE_TRANSPORT_FAILURE = 4;
3404
3405 /** Error type: permanent error (along with all higher error values). */
3406 public static final int ERR_TYPE_GENERIC_PERMANENT = 10;
3407
3408 /** Error type: SMS protocol permanent error. */
3409 public static final int ERR_TYPE_SMS_PROTO_PERMANENT = 11;
3410
3411 /** Error type: MMS protocol permanent error. */
3412 public static final int ERR_TYPE_MMS_PROTO_PERMANENT = 12;
3413
3414 /**
3415 * Contains pending messages info.
3416 */
3417 public static final class PendingMessages implements BaseColumns {
3418
3419 /**
3420 * Not instantiable.
3421 * @hide
3422 */
3423 private PendingMessages() {
3424 }
3425
3426 public static final Uri CONTENT_URI = Uri.withAppendedPath(
3427 MmsSms.CONTENT_URI, "pending");
3428
3429 /**
3430 * The type of transport protocol (MMS or SMS).
3431 * <P>Type: INTEGER</P>
3432 */
3433 public static final String PROTO_TYPE = "proto_type";
3434
3435 /**
3436 * The ID of the message to be sent or downloaded.
3437 * <P>Type: INTEGER (long)</P>
3438 */
3439 public static final String MSG_ID = "msg_id";
3440
3441 /**
3442 * The type of the message to be sent or downloaded.
3443 * This field is only valid for MM. For SM, its value is always set to 0.
3444 * <P>Type: INTEGER</P>
3445 */
3446 public static final String MSG_TYPE = "msg_type";
3447
3448 /**
3449 * The type of the error code.
3450 * <P>Type: INTEGER</P>
3451 */
3452 public static final String ERROR_TYPE = "err_type";
3453
3454 /**
3455 * The error code of sending/retrieving process.
3456 * <P>Type: INTEGER</P>
3457 */
3458 public static final String ERROR_CODE = "err_code";
3459
3460 /**
3461 * How many times we tried to send or download the message.
3462 * <P>Type: INTEGER</P>
3463 */
3464 public static final String RETRY_INDEX = "retry_index";
3465
3466 /**
3467 * The time to do next retry.
3468 * <P>Type: INTEGER (long)</P>
3469 */
3470 public static final String DUE_TIME = "due_time";
3471
3472 /**
3473 * The time we last tried to send or download the message.
3474 * <P>Type: INTEGER (long)</P>
3475 */
3476 public static final String LAST_TRY = "last_try";
3477
3478 /**
3479 * The subscription to which the message belongs to. Its value will be
3480 * < 0 if the sub id cannot be determined.
3481 * <p>Type: INTEGER (long) </p>
3482 */
3483 public static final String SUBSCRIPTION_ID = "pending_sub_id";
3484 }
3485
3486 /**
3487 * Words table used by provider for full-text searches.
3488 * @hide
3489 */
3490 public static final class WordsTable {
3491
3492 /**
3493 * Not instantiable.
3494 * @hide
3495 */
3496 private WordsTable() {}
3497
3498 /**
3499 * Primary key.
3500 * <P>Type: INTEGER (long)</P>
3501 */
3502 public static final String ID = "_id";
3503
3504 /**
3505 * Source row ID.
3506 * <P>Type: INTEGER (long)</P>
3507 */
3508 public static final String SOURCE_ROW_ID = "source_id";
3509
3510 /**
3511 * Table ID (either 1 or 2).
3512 * <P>Type: INTEGER</P>
3513 */
3514 public static final String TABLE_ID = "table_to_use";
3515
3516 /**
3517 * The words to index.
3518 * <P>Type: TEXT</P>
3519 */
3520 public static final String INDEXED_TEXT = "index_text";
3521 }
3522 }
3523
3524 /**
3525 * Carriers class contains information about APNs, including MMSC information.
3526 */
3527 public static final class Carriers implements BaseColumns {
3528
3529 /**
3530 * Not instantiable.
3531 * @hide
3532 */
3533 private Carriers() {}
3534
3535 /**
3536 * The {@code content://} style URL for this table.
calvinpan5e272372018-12-07 20:03:48 +08003537 * For MSIM, this will return APNs for the default subscription
3538 * {@link SubscriptionManager#getDefaultSubscriptionId()}. To specify subId for MSIM,
3539 * use {@link Uri#withAppendedPath(Uri, String)} to append with subscription id.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003540 */
calvinpanef7b99a2019-04-12 18:48:18 +08003541 @NonNull
Dan Willemsen4980bf42017-02-14 14:17:12 -08003542 public static final Uri CONTENT_URI = Uri.parse("content://telephony/carriers");
3543
3544 /**
calvinpan5e272372018-12-07 20:03:48 +08003545 * The {@code content://} style URL for this table. Used for APN query based on current
3546 * subscription. Instead of specifying carrier matching information in the selection,
3547 * this API will return all matching APNs from current subscription carrier and queries
3548 * will be applied on top of that. If there is no match for MVNO (Mobile Virtual Network
3549 * Operator) APNs, return APNs from its MNO (based on mccmnc) instead. For MSIM, this will
3550 * return APNs for the default subscription
3551 * {@link SubscriptionManager#getDefaultSubscriptionId()}. To specify subId for MSIM,
3552 * use {@link Uri#withAppendedPath(Uri, String)} to append with subscription id.
3553 */
calvinpanef7b99a2019-04-12 18:48:18 +08003554 @NonNull
calvinpan5e272372018-12-07 20:03:48 +08003555 public static final Uri SIM_APN_URI = Uri.parse(
3556 "content://telephony/carriers/sim_apn_list");
3557
3558 /**
yuemingw4c0065f2018-01-16 19:48:10 +00003559 * The {@code content://} style URL to be called from DevicePolicyManagerService,
3560 * can manage DPC-owned APNs.
3561 * @hide
3562 */
Hall Liuefc4962e2019-12-27 14:21:58 -08003563 @SystemApi
3564 public static final @NonNull Uri DPC_URI = Uri.parse("content://telephony/carriers/dpc");
yuemingw4c0065f2018-01-16 19:48:10 +00003565
3566 /**
3567 * The {@code content://} style URL to be called from Telephony to query APNs.
3568 * When DPC-owned APNs are enforced, only DPC-owned APNs are returned, otherwise only
calvinpan5e272372018-12-07 20:03:48 +08003569 * non-DPC-owned APNs are returned. For MSIM, this will return APNs for the default
3570 * subscription {@link SubscriptionManager#getDefaultSubscriptionId()}. To specify subId
3571 * for MSIM, use {@link Uri#withAppendedPath(Uri, String)} to append with subscription id.
yuemingw4c0065f2018-01-16 19:48:10 +00003572 * @hide
3573 */
3574 public static final Uri FILTERED_URI = Uri.parse("content://telephony/carriers/filtered");
3575
3576 /**
3577 * The {@code content://} style URL to be called from DevicePolicyManagerService
3578 * or Telephony to manage whether DPC-owned APNs are enforced.
3579 * @hide
3580 */
3581 public static final Uri ENFORCE_MANAGED_URI = Uri.parse(
3582 "content://telephony/carriers/enforce_managed");
3583
3584 /**
3585 * The column name for ENFORCE_MANAGED_URI, indicates whether DPC-owned APNs are enforced.
3586 * @hide
3587 */
3588 public static final String ENFORCE_KEY = "enforced";
3589
3590 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08003591 * The default sort order for this table.
3592 */
3593 public static final String DEFAULT_SORT_ORDER = "name ASC";
3594
3595 /**
3596 * Entry name.
3597 * <P>Type: TEXT</P>
3598 */
3599 public static final String NAME = "name";
3600
3601 /**
3602 * APN name.
3603 * <P>Type: TEXT</P>
3604 */
3605 public static final String APN = "apn";
3606
3607 /**
3608 * Proxy address.
3609 * <P>Type: TEXT</P>
3610 */
3611 public static final String PROXY = "proxy";
3612
3613 /**
3614 * Proxy port.
3615 * <P>Type: TEXT</P>
3616 */
3617 public static final String PORT = "port";
3618
3619 /**
3620 * MMS proxy address.
3621 * <P>Type: TEXT</P>
3622 */
3623 public static final String MMSPROXY = "mmsproxy";
3624
3625 /**
3626 * MMS proxy port.
3627 * <P>Type: TEXT</P>
3628 */
3629 public static final String MMSPORT = "mmsport";
3630
3631 /**
3632 * Server address.
3633 * <P>Type: TEXT</P>
3634 */
3635 public static final String SERVER = "server";
3636
3637 /**
3638 * APN username.
3639 * <P>Type: TEXT</P>
3640 */
3641 public static final String USER = "user";
3642
3643 /**
3644 * APN password.
3645 * <P>Type: TEXT</P>
3646 */
3647 public static final String PASSWORD = "password";
3648
3649 /**
3650 * MMSC URL.
3651 * <P>Type: TEXT</P>
3652 */
3653 public static final String MMSC = "mmsc";
3654
3655 /**
3656 * Mobile Country Code (MCC).
3657 * <P>Type: TEXT</P>
calvinpan5e272372018-12-07 20:03:48 +08003658 * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return
3659 * matching APNs based on current subscription carrier, thus no need to specify MCC and
3660 * other carrier matching information. In the future, Android will not support MCC for
3661 * APN query.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003662 */
3663 public static final String MCC = "mcc";
3664
3665 /**
3666 * Mobile Network Code (MNC).
3667 * <P>Type: TEXT</P>
calvinpan5e272372018-12-07 20:03:48 +08003668 * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return
3669 * matching APNs based on current subscription carrier, thus no need to specify MNC and
3670 * other carrier matching information. In the future, Android will not support MNC for
3671 * APN query.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003672 */
3673 public static final String MNC = "mnc";
3674
3675 /**
3676 * Numeric operator ID (as String). Usually {@code MCC + MNC}.
3677 * <P>Type: TEXT</P>
calvinpan5e272372018-12-07 20:03:48 +08003678 * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return
3679 * matching APNs based on current subscription carrier, thus no need to specify Numeric
3680 * and other carrier matching information. In the future, Android will not support Numeric
3681 * for APN query.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003682 */
3683 public static final String NUMERIC = "numeric";
3684
3685 /**
3686 * Authentication type.
3687 * <P>Type: INTEGER</P>
3688 */
3689 public static final String AUTH_TYPE = "authtype";
3690
3691 /**
3692 * Comma-delimited list of APN types.
3693 * <P>Type: TEXT</P>
3694 */
3695 public static final String TYPE = "type";
3696
3697 /**
3698 * The protocol to use to connect to this APN.
3699 *
3700 * One of the {@code PDP_type} values in TS 27.007 section 10.1.1.
3701 * For example: {@code IP}, {@code IPV6}, {@code IPV4V6}, or {@code PPP}.
3702 * <P>Type: TEXT</P>
3703 */
3704 public static final String PROTOCOL = "protocol";
3705
3706 /**
3707 * The protocol to use to connect to this APN when roaming.
3708 * The syntax is the same as protocol.
3709 * <P>Type: TEXT</P>
3710 */
3711 public static final String ROAMING_PROTOCOL = "roaming_protocol";
3712
3713 /**
3714 * Is this the current APN?
3715 * <P>Type: INTEGER (boolean)</P>
3716 */
3717 public static final String CURRENT = "current";
3718
3719 /**
3720 * Is this APN enabled?
3721 * <P>Type: INTEGER (boolean)</P>
3722 */
3723 public static final String CARRIER_ENABLED = "carrier_enabled";
3724
3725 /**
3726 * Radio Access Technology info.
3727 * To check what values are allowed, refer to {@link android.telephony.ServiceState}.
3728 * This should be spread to other technologies,
3729 * but is currently only used for LTE (14) and eHRPD (13).
3730 * <P>Type: INTEGER</P>
Cassiee1c88022018-02-22 08:51:03 -08003731 * @deprecated this column is no longer supported, use {@link #NETWORK_TYPE_BITMASK} instead
Dan Willemsen4980bf42017-02-14 14:17:12 -08003732 */
Cassied53df962017-12-05 13:34:33 -08003733 @Deprecated
Dan Willemsen4980bf42017-02-14 14:17:12 -08003734 public static final String BEARER = "bearer";
3735
3736 /**
3737 * Radio Access Technology bitmask.
3738 * To check what values can be contained, refer to {@link android.telephony.ServiceState}.
3739 * 0 indicates all techs otherwise first bit refers to RAT/bearer 1, second bit refers to
3740 * RAT/bearer 2 and so on.
3741 * Bitmask for a radio tech R is (1 << (R - 1))
3742 * <P>Type: INTEGER</P>
3743 * @hide
Cassiee1c88022018-02-22 08:51:03 -08003744 * @deprecated this column is no longer supported, use {@link #NETWORK_TYPE_BITMASK} instead
Dan Willemsen4980bf42017-02-14 14:17:12 -08003745 */
Cassied53df962017-12-05 13:34:33 -08003746 @Deprecated
Dan Willemsen4980bf42017-02-14 14:17:12 -08003747 public static final String BEARER_BITMASK = "bearer_bitmask";
3748
3749 /**
Cassied53df962017-12-05 13:34:33 -08003750 * Radio technology (network type) bitmask.
Cassiee1c88022018-02-22 08:51:03 -08003751 * To check what values can be contained, refer to the NETWORK_TYPE_ constants in
Cassied53df962017-12-05 13:34:33 -08003752 * {@link android.telephony.TelephonyManager}.
3753 * Bitmask for a radio tech R is (1 << (R - 1))
3754 * <P>Type: INTEGER</P>
3755 */
3756 public static final String NETWORK_TYPE_BITMASK = "network_type_bitmask";
3757
3758 /**
Dan Willemsen4980bf42017-02-14 14:17:12 -08003759 * MVNO type:
3760 * {@code SPN (Service Provider Name), IMSI, GID (Group Identifier Level 1)}.
3761 * <P>Type: TEXT</P>
calvinpan5e272372018-12-07 20:03:48 +08003762 * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return
3763 * matching APNs based on current subscription carrier, thus no need to specify MVNO_TYPE
3764 * and other carrier matching information. In the future, Android will not support MVNO_TYPE
3765 * for APN query.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003766 */
3767 public static final String MVNO_TYPE = "mvno_type";
3768
3769 /**
3770 * MVNO data.
3771 * Use the following examples.
3772 * <ul>
3773 * <li>SPN: A MOBILE, BEN NL, ...</li>
3774 * <li>IMSI: 302720x94, 2060188, ...</li>
3775 * <li>GID: 4E, 33, ...</li>
3776 * </ul>
3777 * <P>Type: TEXT</P>
calvinpan5e272372018-12-07 20:03:48 +08003778 * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return
3779 * matching APNs based on current subscription carrier, thus no need to specify
3780 * MVNO_MATCH_DATA and other carrier matching information. In the future, Android will not
3781 * support MVNO_MATCH_DATA for APN query.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003782 */
3783 public static final String MVNO_MATCH_DATA = "mvno_match_data";
3784
3785 /**
3786 * The subscription to which the APN belongs to
3787 * <p>Type: INTEGER (long) </p>
3788 */
3789 public static final String SUBSCRIPTION_ID = "sub_id";
3790
3791 /**
chen xu85100482018-10-12 15:30:34 -07003792 * The profile_id to which the APN saved in modem.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003793 * <p>Type: INTEGER</p>
3794 *@hide
3795 */
3796 public static final String PROFILE_ID = "profile_id";
3797
3798 /**
chen xu85100482018-10-12 15:30:34 -07003799 * If set to {@code true}, then the APN setting will persist to the modem.
3800 * <p>Type: INTEGER (boolean)</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003801 *@hide
3802 */
chen xu85100482018-10-12 15:30:34 -07003803 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003804 public static final String MODEM_PERSIST = "modem_cognitive";
Dan Willemsen4980bf42017-02-14 14:17:12 -08003805
3806 /**
chen xu5caa18c2018-11-28 00:21:50 -08003807 * The max number of connections of this APN.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003808 * <p>Type: INTEGER</p>
3809 *@hide
3810 */
chen xu85100482018-10-12 15:30:34 -07003811 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003812 public static final String MAX_CONNECTIONS = "max_conns";
Dan Willemsen4980bf42017-02-14 14:17:12 -08003813
3814 /**
chen xu5caa18c2018-11-28 00:21:50 -08003815 * The wait time for retrying the APN, in milliseconds.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003816 * <p>Type: INTEGER</p>
3817 *@hide
3818 */
chen xu85100482018-10-12 15:30:34 -07003819 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003820 public static final String WAIT_TIME_RETRY = "wait_time";
Dan Willemsen4980bf42017-02-14 14:17:12 -08003821
3822 /**
chen xu5caa18c2018-11-28 00:21:50 -08003823 * The max number of seconds this APN will support its maximum number of connections
3824 * as defined in {@link #MAX_CONNECTIONS}.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003825 * <p>Type: INTEGER</p>
3826 *@hide
3827 */
chen xu85100482018-10-12 15:30:34 -07003828 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003829 public static final String TIME_LIMIT_FOR_MAX_CONNECTIONS = "max_conns_time";
Dan Willemsen4980bf42017-02-14 14:17:12 -08003830
3831 /**
chen xu5caa18c2018-11-28 00:21:50 -08003832 * The MTU (maximum transmit unit) size of the mobile interface to which the APN is
3833 * connected, in bytes.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003834 * <p>Type: INTEGER </p>
3835 * @hide
3836 */
chen xu85100482018-10-12 15:30:34 -07003837 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08003838 public static final String MTU = "mtu";
3839
3840 /**
chen xu85100482018-10-12 15:30:34 -07003841 * APN edit status. APN could be added/edited/deleted by a user or carrier.
chen xu5caa18c2018-11-28 00:21:50 -08003842 * see all possible returned APN edit status.
3843 * <ul>
3844 * <li>{@link #UNEDITED}</li>
3845 * <li>{@link #USER_EDITED}</li>
3846 * <li>{@link #USER_DELETED}</li>
3847 * <li>{@link #CARRIER_EDITED}</li>
3848 * <li>{@link #CARRIER_DELETED}</li>
3849 * </ul>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003850 * <p>Type: INTEGER </p>
3851 * @hide
3852 */
chen xu85100482018-10-12 15:30:34 -07003853 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003854 public static final String EDITED_STATUS = "edited";
Dan Willemsen4980bf42017-02-14 14:17:12 -08003855
3856 /**
chen xu85100482018-10-12 15:30:34 -07003857 * {@code true} if this APN visible to the user, {@code false} otherwise.
3858 * <p>Type: INTEGER (boolean)</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003859 * @hide
3860 */
chen xu85100482018-10-12 15:30:34 -07003861 @SystemApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08003862 public static final String USER_VISIBLE = "user_visible";
3863
3864 /**
chen xu85100482018-10-12 15:30:34 -07003865 * {@code true} if the user allowed to edit this APN, {@code false} otherwise.
3866 * <p>Type: INTEGER (boolean)</p>
Amit Mahajand4977942017-07-17 14:46:39 -07003867 * @hide
3868 */
chen xu85100482018-10-12 15:30:34 -07003869 @SystemApi
Amit Mahajand4977942017-07-17 14:46:39 -07003870 public static final String USER_EDITABLE = "user_editable";
3871
3872 /**
Hall Liuefc4962e2019-12-27 14:21:58 -08003873 * Integer value denoting an invalid APN id
3874 * @hide
3875 */
3876 @SystemApi
3877 public static final int INVALID_APN_ID = -1;
3878
3879 /**
chen xu5caa18c2018-11-28 00:21:50 -08003880 * {@link #EDITED_STATUS APN edit status} indicates that this APN has not been edited or
3881 * fails to edit.
chen xu85100482018-10-12 15:30:34 -07003882 * <p>Type: INTEGER </p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003883 * @hide
3884 */
chen xu85100482018-10-12 15:30:34 -07003885 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003886 public static final @EditStatus int UNEDITED = 0;
chen xu85100482018-10-12 15:30:34 -07003887
Dan Willemsen4980bf42017-02-14 14:17:12 -08003888 /**
chen xu5caa18c2018-11-28 00:21:50 -08003889 * {@link #EDITED_STATUS APN edit status} indicates that this APN has been edited by users.
chen xu85100482018-10-12 15:30:34 -07003890 * <p>Type: INTEGER </p>
3891 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003892 */
chen xu85100482018-10-12 15:30:34 -07003893 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003894 public static final @EditStatus int USER_EDITED = 1;
chen xu85100482018-10-12 15:30:34 -07003895
Dan Willemsen4980bf42017-02-14 14:17:12 -08003896 /**
chen xu5caa18c2018-11-28 00:21:50 -08003897 * {@link #EDITED_STATUS APN edit status} indicates that this APN has been deleted by users.
chen xu85100482018-10-12 15:30:34 -07003898 * <p>Type: INTEGER </p>
3899 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003900 */
chen xu85100482018-10-12 15:30:34 -07003901 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003902 public static final @EditStatus int USER_DELETED = 2;
chen xu85100482018-10-12 15:30:34 -07003903
Dan Willemsen4980bf42017-02-14 14:17:12 -08003904 /**
chen xu5caa18c2018-11-28 00:21:50 -08003905 * {@link #EDITED_STATUS APN edit status} is an intermediate value used to indicate that an
3906 * entry deleted by the user is still present in the new APN database and therefore must
3907 * remain tagged as user deleted rather than completely removed from the database.
Dan Willemsen4980bf42017-02-14 14:17:12 -08003908 * @hide
3909 */
3910 public static final int USER_DELETED_BUT_PRESENT_IN_XML = 3;
chen xu85100482018-10-12 15:30:34 -07003911
Dan Willemsen4980bf42017-02-14 14:17:12 -08003912 /**
chen xu5caa18c2018-11-28 00:21:50 -08003913 * {@link #EDITED_STATUS APN edit status} indicates that this APN has been edited by
3914 * carriers.
chen xu85100482018-10-12 15:30:34 -07003915 * <p>Type: INTEGER </p>
3916 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003917 */
chen xu85100482018-10-12 15:30:34 -07003918 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003919 public static final @EditStatus int CARRIER_EDITED = 4;
chen xu85100482018-10-12 15:30:34 -07003920
Dan Willemsen4980bf42017-02-14 14:17:12 -08003921 /**
chen xu5caa18c2018-11-28 00:21:50 -08003922 * {@link #EDITED_STATUS APN edit status} indicates that this APN has been deleted by
3923 * carriers. CARRIER_DELETED values are currently not used as there is no use case.
3924 * If they are used, delete() will have to change accordingly. Currently it is hardcoded to
3925 * USER_DELETED.
chen xu85100482018-10-12 15:30:34 -07003926 * <p>Type: INTEGER </p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08003927 * @hide
3928 */
chen xu5caa18c2018-11-28 00:21:50 -08003929 public static final @EditStatus int CARRIER_DELETED = 5;
chen xu85100482018-10-12 15:30:34 -07003930
Dan Willemsen4980bf42017-02-14 14:17:12 -08003931 /**
chen xu5caa18c2018-11-28 00:21:50 -08003932 * {@link #EDITED_STATUS APN edit status} is an intermediate value used to indicate that an
3933 * entry deleted by the carrier is still present in the new APN database and therefore must
3934 * remain tagged as user deleted rather than completely removed from the database.
chen xu85100482018-10-12 15:30:34 -07003935 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08003936 */
3937 public static final int CARRIER_DELETED_BUT_PRESENT_IN_XML = 6;
yuemingwcf263eb2017-11-08 13:12:18 +00003938
3939 /**
3940 * The owner of the APN.
3941 * <p>Type: INTEGER</p>
3942 * @hide
3943 */
3944 public static final String OWNED_BY = "owned_by";
3945
3946 /**
3947 * Possible value for the OWNED_BY field.
3948 * APN is owned by DPC.
3949 * @hide
3950 */
3951 public static final int OWNED_BY_DPC = 0;
Jordan Liu40617152018-04-06 11:10:12 -07003952
yuemingwcf263eb2017-11-08 13:12:18 +00003953 /**
3954 * Possible value for the OWNED_BY field.
3955 * APN is owned by other sources.
3956 * @hide
3957 */
3958 public static final int OWNED_BY_OTHERS = 1;
Jordan Liu40617152018-04-06 11:10:12 -07003959
3960 /**
3961 * The APN set id. When the user manually selects an APN or the framework sets an APN as
3962 * preferred, all APNs with the same set id as the selected APN should be prioritized over
3963 * APNs in other sets.
chen xu85100482018-10-12 15:30:34 -07003964 * <p>Type: INTEGER</p>
Jordan Liu40617152018-04-06 11:10:12 -07003965 * @hide
3966 */
chen xu85100482018-10-12 15:30:34 -07003967 @SystemApi
Jordan Liu40617152018-04-06 11:10:12 -07003968 public static final String APN_SET_ID = "apn_set_id";
3969
3970 /**
chen xu5caa18c2018-11-28 00:21:50 -08003971 * Possible value for the {@link #APN_SET_ID} field. By default APNs will not belong to a
3972 * set. If the user manually selects an APN without apn set id, there is no need to
3973 * prioritize any specific APN set ids.
chen xu85100482018-10-12 15:30:34 -07003974 * <p>Type: INTEGER</p>
Jordan Liu40617152018-04-06 11:10:12 -07003975 * @hide
3976 */
chen xu85100482018-10-12 15:30:34 -07003977 @SystemApi
chen xu5caa18c2018-11-28 00:21:50 -08003978 public static final int NO_APN_SET_ID = 0;
Jordan Liu40617152018-04-06 11:10:12 -07003979
calvinpanbeb6cb32018-10-19 15:11:22 +08003980 /**
3981 * A unique carrier id associated with this APN
3982 * {@see TelephonyManager#getSimCarrierId()}
3983 * <p>Type: STRING</p>
3984 */
3985 public static final String CARRIER_ID = "carrier_id";
3986
Yuuki Habuaaea4a52019-02-22 11:29:26 +09003987 /**
3988 * The skip 464xlat flag. Flag works as follows.
3989 * {@link #SKIP_464XLAT_DEFAULT}: the APN will skip only APN is IMS and no internet.
3990 * {@link #SKIP_464XLAT_DISABLE}: the APN will NOT skip 464xlat
3991 * {@link #SKIP_464XLAT_ENABLE}: the APN will skip 464xlat
3992 * <p>Type: INTEGER</p>
3993 *
3994 * @hide
3995 */
3996 public static final String SKIP_464XLAT = "skip_464xlat";
3997
3998 /**
3999 * Possible value for the {@link #SKIP_464XLAT} field.
4000 * <p>Type: INTEGER</p>
4001 *
4002 * @hide
4003 */
4004 public static final int SKIP_464XLAT_DEFAULT = -1;
4005
4006 /**
4007 * Possible value for the {@link #SKIP_464XLAT} field.
4008 * <p>Type: INTEGER</p>
4009 *
4010 * @hide
4011 */
4012 public static final int SKIP_464XLAT_DISABLE = 0;
4013
4014 /**
4015 * Possible value for the {@link #SKIP_464XLAT} field.
4016 * <p>Type: INTEGER</p>
4017 *
4018 * @hide
4019 */
4020 public static final int SKIP_464XLAT_ENABLE = 1;
4021
4022
chen xu5caa18c2018-11-28 00:21:50 -08004023 /** @hide */
4024 @IntDef({
4025 UNEDITED,
4026 USER_EDITED,
4027 USER_DELETED,
4028 CARRIER_DELETED,
4029 CARRIER_EDITED,
4030 })
4031 @Retention(RetentionPolicy.SOURCE)
4032 public @interface EditStatus {}
Yuuki Habuaaea4a52019-02-22 11:29:26 +09004033
4034 /** @hide */
4035 @IntDef({
4036 SKIP_464XLAT_DEFAULT,
4037 SKIP_464XLAT_DISABLE,
4038 SKIP_464XLAT_ENABLE,
4039 })
4040 @Retention(RetentionPolicy.SOURCE)
4041 public @interface Skip464XlatStatus {}
4042
Hall Liu45a351e2019-11-21 16:35:37 -08004043 /**
4044 * Compat framework change ID for the APN db read permission change.
4045 *
4046 * In API level 30 and beyond, accessing the APN database will require the
4047 * {@link android.Manifest.permission#WRITE_APN_SETTINGS} permission. This change ID tracks
4048 * apps that are affected because they don't hold this permission.
4049 * @hide
4050 */
4051 @ChangeId
4052 public static final long APN_READING_PERMISSION_CHANGE_ID = 124107808L;
Dan Willemsen4980bf42017-02-14 14:17:12 -08004053 }
4054
4055 /**
Chen Xua32c7fc2019-10-21 22:47:27 -07004056 * Contains received cell broadcast messages. More details are available in 3GPP TS 23.041.
Dan Willemsen4980bf42017-02-14 14:17:12 -08004057 * @hide
4058 */
Jordan Liu657ef5a2019-08-16 14:07:03 -07004059 @SystemApi
Chen Xua32c7fc2019-10-21 22:47:27 -07004060 @TestApi
Dan Willemsen4980bf42017-02-14 14:17:12 -08004061 public static final class CellBroadcasts implements BaseColumns {
4062
4063 /**
4064 * Not instantiable.
4065 * @hide
4066 */
4067 private CellBroadcasts() {}
4068
4069 /**
4070 * The {@code content://} URI for this table.
Chen Xua32c7fc2019-10-21 22:47:27 -07004071 * Only privileged framework components running on phone or network stack uid can
4072 * query or modify this table.
Dan Willemsen4980bf42017-02-14 14:17:12 -08004073 */
Jordan Liu657ef5a2019-08-16 14:07:03 -07004074 @NonNull
Dan Willemsen4980bf42017-02-14 14:17:12 -08004075 public static final Uri CONTENT_URI = Uri.parse("content://cellbroadcasts");
4076
4077 /**
Chen Xua32c7fc2019-10-21 22:47:27 -07004078 * The {@code content://} URI for query cellbroadcast message history.
4079 * query results include following entries
4080 * <ul>
4081 * <li>{@link #_ID}</li>
4082 * <li>{@link #SLOT_INDEX}</li>
4083 * <li>{@link #GEOGRAPHICAL_SCOPE}</li>
4084 * <li>{@link #PLMN}</li>
4085 * <li>{@link #LAC}</li>
4086 * <li>{@link #CID}</li>
4087 * <li>{@link #SERIAL_NUMBER}</li>
4088 * <li>{@link #SERVICE_CATEGORY}</li>
4089 * <li>{@link #LANGUAGE_CODE}</li>
4090 * <li>{@link #MESSAGE_BODY}</li>
4091 * <li>{@link #DELIVERY_TIME}</li>
4092 * <li>{@link #MESSAGE_READ}</li>
4093 * <li>{@link #MESSAGE_FORMAT}</li>
4094 * <li>{@link #MESSAGE_PRIORITY}</li>
4095 * <li>{@link #ETWS_WARNING_TYPE}</li>
4096 * <li>{@link #CMAS_MESSAGE_CLASS}</li>
4097 * <li>{@link #CMAS_CATEGORY}</li>
4098 * <li>{@link #CMAS_RESPONSE_TYPE}</li>
4099 * <li>{@link #CMAS_SEVERITY}</li>
4100 * <li>{@link #CMAS_URGENCY}</li>
4101 * <li>{@link #CMAS_CERTAINTY}</li>
4102 * </ul>
4103 */
4104 @RequiresPermission(Manifest.permission.READ_CELL_BROADCASTS)
4105 @NonNull
4106 public static final Uri MESSAGE_HISTORY_URI = Uri.parse("content://cellbroadcasts/history");
4107
4108 /**
Chen Xuad2f91f2019-12-30 00:29:01 -08004109 * The authority for the legacy cellbroadcast provider.
4110 * This is used for OEM data migration. OEMs want to migrate message history or
4111 * sharepreference data to mainlined cellbroadcastreceiver app, should have a
4112 * contentprovider with authority: cellbroadcast-legacy. Mainlined cellbroadcastreceiver
4113 * will interact with this URI to retrieve data and persists to mainlined cellbroadcast app.
4114 *
4115 * @hide
4116 */
4117 @SystemApi
4118 public static final @NonNull String AUTHORITY_LEGACY = "cellbroadcast-legacy";
4119
4120 /**
4121 * A content:// style uri to the authority for the legacy cellbroadcast provider.
4122 * @hide
4123 */
4124 @SystemApi
4125 public static final @NonNull Uri AUTHORITY_LEGACY_URI =
4126 Uri.parse("content://cellbroadcast-legacy");
4127
4128 /**
4129 * Method name to {@link android.content.ContentProvider#call(String, String, Bundle)
4130 * for {@link #AUTHORITY_LEGACY}. Used to query cellbroadcast {@link Preference},
4131 * containing following supported entries
4132 * <ul>
4133 * <li>{@link #ENABLE_AREA_UPDATE_INFO_PREF}</li>
4134 * <li>{@link #ENABLE_TEST_ALERT_PREF}</li>
4135 * <li>{@link #ENABLE_STATE_LOCAL_TEST_PREF}</li>
4136 * <li>{@link #ENABLE_PUBLIC_SAFETY_PREF}</li>
4137 * <li>{@link #ENABLE_CMAS_AMBER_PREF}</li>
4138 * <li>{@link #ENABLE_CMAS_SEVERE_THREAT_PREF}</li>
4139 * <li>{@link #ENABLE_CMAS_EXTREME_THREAT_PREF}</li>
4140 * <li>{@link #ENABLE_CMAS_PRESIDENTIAL_PREF}</li>
4141 * <li>{@link #ENABLE_ALERT_VIBRATION_PREF}</li>
4142 * <li>{@link #ENABLE_EMERGENCY_PERF}</li>
4143 * <li>{@link #ENABLE_FULL_VOLUME_PREF}</li>
4144 * <li>{@link #ENABLE_CMAS_IN_SECOND_LANGUAGE_PREF}</li>
4145 * </ul>
4146 * @hide
4147 */
4148 @SystemApi
4149 public static final @NonNull String CALL_METHOD_GET_PREFERENCE = "get_preference";
4150
4151 /**
4152 * Arg name to {@link android.content.ContentProvider#call(String, String, Bundle)}
4153 * for {@link #AUTHORITY_LEGACY}.
4154 * Contains all supported shared preferences for cellbroadcast.
4155 *
4156 * @hide
4157 */
4158 @SystemApi
4159 public static final class Preference {
4160 /**
4161 * Not Instantiatable.
4162 * @hide
4163 */
4164 private Preference() {}
4165
4166 /** Preference to enable area update info alert */
4167 public static final @NonNull String ENABLE_AREA_UPDATE_INFO_PREF =
4168 "enable_area_update_info_alerts";
4169
4170 /** Preference to enable test alert */
4171 public static final @NonNull String ENABLE_TEST_ALERT_PREF =
4172 "enable_test_alerts";
4173
4174 /** Preference to enable state local test alert */
4175 public static final @NonNull String ENABLE_STATE_LOCAL_TEST_PREF
4176 = "enable_state_local_test_alerts";
4177
4178 /** Preference to enable public safety alert */
4179 public static final @NonNull String ENABLE_PUBLIC_SAFETY_PREF
4180 = "enable_public_safety_messages";
4181
4182 /** Preference to enable amber alert */
4183 public static final @NonNull String ENABLE_CMAS_AMBER_PREF
4184 = "enable_cmas_amber_alerts";
4185
4186 /** Preference to enable severe threat alert */
4187 public static final @NonNull String ENABLE_CMAS_SEVERE_THREAT_PREF
4188 = "enable_cmas_severe_threat_alerts";
4189
4190 /** Preference to enable extreme threat alert */
4191 public static final @NonNull String ENABLE_CMAS_EXTREME_THREAT_PREF =
4192 "enable_cmas_extreme_threat_alerts";
4193
4194 /** Preference to enable presidential alert */
4195 public static final @NonNull String ENABLE_CMAS_PRESIDENTIAL_PREF =
4196 "enable_cmas_presidential_alerts";
4197
4198 /** Preference to enable alert vibration */
4199 public static final @NonNull String ENABLE_ALERT_VIBRATION_PREF =
4200 "enable_alert_vibrate";
4201
4202 /** Preference to enable emergency alert */
4203 public static final @NonNull String ENABLE_EMERGENCY_PERF =
4204 "enable_emergency_alerts";
4205
4206 /** Preference to enable volume for alerts */
4207 public static final @NonNull String ENABLE_FULL_VOLUME_PREF =
4208 "use_full_volume";
4209
4210 /** Preference to enable receive alerts in second language */
4211 public static final @NonNull String ENABLE_CMAS_IN_SECOND_LANGUAGE_PREF =
4212 "receive_cmas_in_second_language";
4213 }
4214
4215 /**
Chen Xu515285b2019-10-03 16:48:56 -07004216 * The subscription which received this cell broadcast message.
Pengquan Meng02d6ac02019-08-27 11:20:17 -07004217 * <P>Type: INTEGER</P>
Pengquan Meng02d6ac02019-08-27 11:20:17 -07004218 */
4219 public static final String SUB_ID = "sub_id";
4220
4221 /**
Chen Xu515285b2019-10-03 16:48:56 -07004222 * The slot which received this cell broadcast message.
4223 * <P>Type: INTEGER</P>
Chen Xu515285b2019-10-03 16:48:56 -07004224 */
4225 public static final String SLOT_INDEX = "slot_index";
4226
4227 /**
Jordan Liu657ef5a2019-08-16 14:07:03 -07004228 * Message geographical scope. Valid values are:
4229 * <ul>
4230 * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_CELL_WIDE}. meaning the
4231 * message is for the radio service cell</li>
4232 * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_CELL_WIDE_IMMEDIATE},
4233 * meaning the message is for the radio service cell and immediately displayed</li>
4234 * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_PLMN_WIDE}, meaning the
4235 * message is for the PLMN (i.e. MCC/MNC)</li>
4236 * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_LOCATION_AREA_WIDE},
4237 * meaning the message is for the location area (in GSM) or service area (in UMTS)</li>
4238 * </ul>
4239 *
4240 * <p>A message meant for a particular scope is automatically dismissed when the device
4241 * exits that scope.</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08004242 * <P>Type: INTEGER</P>
4243 */
4244 public static final String GEOGRAPHICAL_SCOPE = "geo_scope";
4245
4246 /**
4247 * Message serial number.
Jordan Liu657ef5a2019-08-16 14:07:03 -07004248 * <p>
4249 * A 16-bit integer which identifies a particular CBS (cell
4250 * broadcast short message service) message. The core network is responsible for
4251 * allocating this value, and the value may be managed cyclically (3GPP TS 23.041 section
4252 * 9.2.1) once the serial message has been incremented a sufficient number of times.
4253 * </p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08004254 * <P>Type: INTEGER</P>
4255 */
4256 public static final String SERIAL_NUMBER = "serial_number";
4257
4258 /**
Jordan Liu657ef5a2019-08-16 14:07:03 -07004259 * PLMN (i.e. MCC/MNC) of broadcast sender. {@code SERIAL_NUMBER + PLMN + LAC + CID}
4260 * uniquely identifies a broadcast for duplicate detection purposes.
Dan Willemsen4980bf42017-02-14 14:17:12 -08004261 * <P>Type: TEXT</P>
4262 */
4263 public static final String PLMN = "plmn";
4264
4265 /**
Jordan Liu657ef5a2019-08-16 14:07:03 -07004266 * Location area code (LAC).
4267 * <p>Code representing location area (GSM) or service area (UMTS) of broadcast sender.
4268 * Unused for CDMA. Only included if Geographical Scope of message is not PLMN wide (01).
4269 * This value is sent by the network based on the cell tower.
Dan Willemsen4980bf42017-02-14 14:17:12 -08004270 * <P>Type: INTEGER</P>
4271 */
4272 public static final String LAC = "lac";
4273
4274 /**
4275 * Cell ID of message sender (GSM/UMTS). Unused for CDMA. Only included when the
4276 * Geographical Scope of message is cell wide (00 or 11).
4277 * <P>Type: INTEGER</P>
4278 */
4279 public static final String CID = "cid";
4280
4281 /**
Jordan Liu657ef5a2019-08-16 14:07:03 -07004282 * Service category which represents the general topic of the message.
4283 * <p>
4284 * For GSM/UMTS: message identifier (see 3GPP TS 23.041 section 9.4.1.2.2)
4285 * For CDMA: a 16-bit CDMA service category (see 3GPP2 C.R1001-D section 9.3)
4286 * </p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08004287 * <P>Type: INTEGER</P>
4288 */
4289 public static final String SERVICE_CATEGORY = "service_category";
4290
4291 /**
Jordan Liu657ef5a2019-08-16 14:07:03 -07004292 * Message language code. (See 3GPP TS 23.041 section 9.4.1.2.3 for details).
Dan Willemsen4980bf42017-02-14 14:17:12 -08004293 * <P>Type: TEXT</P>
4294 */
4295 public static final String LANGUAGE_CODE = "language";
4296
4297 /**
4298 * Message body.
4299 * <P>Type: TEXT</P>
4300 */
4301 public static final String MESSAGE_BODY = "body";
4302
4303 /**
4304 * Message delivery time.
Jordan Liu657ef5a2019-08-16 14:07:03 -07004305 * <p>This value is a system timestamp using {@link System#currentTimeMillis}</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08004306 * <P>Type: INTEGER (long)</P>
4307 */
4308 public static final String DELIVERY_TIME = "date";
4309
4310 /**
4311 * Has the message been viewed?
4312 * <P>Type: INTEGER (boolean)</P>
4313 */
4314 public static final String MESSAGE_READ = "read";
4315
4316 /**
Jordan Liu657ef5a2019-08-16 14:07:03 -07004317 * Message format ({@link android.telephony.SmsCbMessage#MESSAGE_FORMAT_3GPP} or
4318 * {@link android.telephony.SmsCbMessage#MESSAGE_FORMAT_3GPP2}).
Dan Willemsen4980bf42017-02-14 14:17:12 -08004319 * <P>Type: INTEGER</P>
4320 */
4321 public static final String MESSAGE_FORMAT = "format";
4322
4323 /**
Jordan Liu657ef5a2019-08-16 14:07:03 -07004324 * Message priority.
4325 * <p>This includes
4326 * <ul>
4327 * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_NORMAL}</li>
4328 * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_INTERACTIVE}</li>
4329 * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_URGENT}</li>
4330 * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_EMERGENCY}</li>
4331 * </p>
4332 * </ul>
Dan Willemsen4980bf42017-02-14 14:17:12 -08004333 * <P>Type: INTEGER</P>
4334 */
4335 public static final String MESSAGE_PRIORITY = "priority";
4336
4337 /**
Jordan Liu657ef5a2019-08-16 14:07:03 -07004338 * ETWS (Earthquake and Tsunami Warning System) warning type (ETWS alerts only).
4339 * <p>See {@link android.telephony.SmsCbEtwsInfo}</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08004340 * <P>Type: INTEGER</P>
4341 */
4342 public static final String ETWS_WARNING_TYPE = "etws_warning_type";
4343
4344 /**
Jordan Liu657ef5a2019-08-16 14:07:03 -07004345 * CMAS (Commercial Mobile Alert System) message class (CMAS alerts only).
4346 * <p>See {@link android.telephony.SmsCbCmasInfo}</p>
Dan Willemsen4980bf42017-02-14 14:17:12 -08004347 * <P>Type: INTEGER</P>
4348 */
4349 public static final String CMAS_MESSAGE_CLASS = "cmas_message_class";
4350
4351 /**
4352 * CMAS category (CMAS alerts only).
4353 * <P>Type: INTEGER</P>
4354 */
4355 public static final String CMAS_CATEGORY = "cmas_category";
4356
4357 /**
4358 * CMAS response type (CMAS alerts only).
4359 * <P>Type: INTEGER</P>
4360 */
4361 public static final String CMAS_RESPONSE_TYPE = "cmas_response_type";
4362
4363 /**
4364 * CMAS severity (CMAS alerts only).
4365 * <P>Type: INTEGER</P>
4366 */
4367 public static final String CMAS_SEVERITY = "cmas_severity";
4368
4369 /**
4370 * CMAS urgency (CMAS alerts only).
4371 * <P>Type: INTEGER</P>
4372 */
4373 public static final String CMAS_URGENCY = "cmas_urgency";
4374
4375 /**
4376 * CMAS certainty (CMAS alerts only).
4377 * <P>Type: INTEGER</P>
4378 */
4379 public static final String CMAS_CERTAINTY = "cmas_certainty";
4380
4381 /** The default sort order for this table. */
4382 public static final String DEFAULT_SORT_ORDER = DELIVERY_TIME + " DESC";
4383
4384 /**
Pengquan Menge3f37272019-08-12 23:09:34 -07004385 * The timestamp in millisecond of when the device received the message.
4386 * <P>Type: BIGINT</P>
Pengquan Meng02cfb3b2019-07-18 17:30:04 -07004387 */
4388 public static final String RECEIVED_TIME = "received_time";
4389
4390 /**
4391 * Indicates that whether the message has been broadcasted to the application.
4392 * <P>Type: BOOLEAN</P>
4393 */
4394 public static final String MESSAGE_BROADCASTED = "message_broadcasted";
4395
4396 /**
4397 * The Warning Area Coordinates Elements. This element is used for geo-fencing purpose.
4398 *
4399 * The geometry and its coordinates are separated vertical bar, the first item is the
4400 * geometry type and the remaining items are the parameter of this geometry.
4401 *
4402 * Only circle and polygon are supported. The coordinates are represented in Horizontal
4403 * coordinates format.
4404 *
4405 * Coordinate encoding:
4406 * "latitude, longitude"
4407 * where -90.00000 <= latitude <= 90.00000 and -180.00000 <= longitude <= 180.00000
4408 *
4409 * Polygon encoding:
4410 * "polygon|lat1,lng1|lat2,lng2|...|latn,lngn"
4411 * lat1,lng1 ... latn,lngn are the vertices coordinate of the polygon.
4412 *
4413 * Circle encoding:
4414 * "circle|lat,lng|radius".
4415 * lat,lng is the center of the circle. The unit of circle's radius is meter.
4416 *
4417 * Example:
4418 * "circle|0,0|100" mean a circle which center located at (0,0) and its radius is 100 meter.
4419 * "polygon|0,1.5|0,1|1,1|1,0" mean a polygon has vertices (0,1.5),(0,1),(1,1),(1,0).
4420 *
4421 * There could be more than one geometry store in this field, they are separated by a
4422 * semicolon.
4423 *
4424 * Example:
4425 * "circle|0,0|100;polygon|0,0|0,1.5|1,1|1,0;circle|100.123,100|200.123"
4426 *
4427 * <P>Type: TEXT</P>
4428 */
4429 public static final String GEOMETRIES = "geometries";
4430
4431 /**
Pengquan Meng02d6ac02019-08-27 11:20:17 -07004432 * Geo-Fencing Maximum Wait Time in second. The range of the time is [0, 255]. A device
4433 * shall allow to determine its position meeting operator policy. If the device is unable to
4434 * determine its position meeting operator policy within the GeoFencing Maximum Wait Time,
4435 * it shall present the alert to the user and discontinue further positioning determination
4436 * for the alert.
4437 *
4438 * <P>Type: INTEGER</P>
Pengquan Meng02d6ac02019-08-27 11:20:17 -07004439 */
4440 public static final String MAXIMUM_WAIT_TIME = "maximum_wait_time";
4441
4442 /**
Chen Xu515285b2019-10-03 16:48:56 -07004443 * Query columns for instantiating com.android.cellbroadcastreceiver.CellBroadcastMessage.
Jordan Liu657ef5a2019-08-16 14:07:03 -07004444 * @hide
Dan Willemsen4980bf42017-02-14 14:17:12 -08004445 */
Jordan Liu657ef5a2019-08-16 14:07:03 -07004446 @NonNull
Dan Willemsen4980bf42017-02-14 14:17:12 -08004447 public static final String[] QUERY_COLUMNS = {
4448 _ID,
4449 GEOGRAPHICAL_SCOPE,
4450 PLMN,
4451 LAC,
4452 CID,
4453 SERIAL_NUMBER,
4454 SERVICE_CATEGORY,
4455 LANGUAGE_CODE,
4456 MESSAGE_BODY,
4457 DELIVERY_TIME,
4458 MESSAGE_READ,
4459 MESSAGE_FORMAT,
4460 MESSAGE_PRIORITY,
4461 ETWS_WARNING_TYPE,
4462 CMAS_MESSAGE_CLASS,
4463 CMAS_CATEGORY,
4464 CMAS_RESPONSE_TYPE,
4465 CMAS_SEVERITY,
4466 CMAS_URGENCY,
4467 CMAS_CERTAINTY
4468 };
Pengquan Menge3f37272019-08-12 23:09:34 -07004469
4470 /**
4471 * Query columns for instantiating {@link android.telephony.SmsCbMessage} objects.
Jordan Liu657ef5a2019-08-16 14:07:03 -07004472 * @hide
Pengquan Menge3f37272019-08-12 23:09:34 -07004473 */
4474 public static final String[] QUERY_COLUMNS_FWK = {
4475 _ID,
Chen Xu515285b2019-10-03 16:48:56 -07004476 SLOT_INDEX,
Jack Yu750b8b12019-11-20 23:18:29 -08004477 SUB_ID,
Pengquan Menge3f37272019-08-12 23:09:34 -07004478 GEOGRAPHICAL_SCOPE,
4479 PLMN,
4480 LAC,
4481 CID,
4482 SERIAL_NUMBER,
4483 SERVICE_CATEGORY,
4484 LANGUAGE_CODE,
4485 MESSAGE_BODY,
4486 MESSAGE_FORMAT,
4487 MESSAGE_PRIORITY,
4488 ETWS_WARNING_TYPE,
4489 CMAS_MESSAGE_CLASS,
4490 CMAS_CATEGORY,
4491 CMAS_RESPONSE_TYPE,
4492 CMAS_SEVERITY,
4493 CMAS_URGENCY,
4494 CMAS_CERTAINTY,
4495 RECEIVED_TIME,
4496 MESSAGE_BROADCASTED,
Pengquan Meng02d6ac02019-08-27 11:20:17 -07004497 GEOMETRIES,
4498 MAXIMUM_WAIT_TIME
Pengquan Menge3f37272019-08-12 23:09:34 -07004499 };
Dan Willemsen4980bf42017-02-14 14:17:12 -08004500 }
Jordan Liub9b75ed2017-02-28 18:15:07 -08004501
4502 /**
4503 * Constants for interfacing with the ServiceStateProvider and the different fields of the
4504 * {@link ServiceState} class accessible through the provider.
4505 */
4506 public static final class ServiceStateTable {
4507
4508 /**
4509 * Not instantiable.
4510 * @hide
4511 */
4512 private ServiceStateTable() {}
4513
4514 /**
4515 * The authority string for the ServiceStateProvider
4516 */
4517 public static final String AUTHORITY = "service-state";
4518
4519 /**
4520 * The {@code content://} style URL for the ServiceStateProvider
4521 */
4522 public static final Uri CONTENT_URI = Uri.parse("content://service-state/");
4523
4524 /**
4525 * Generates a content {@link Uri} used to receive updates on a specific field in the
4526 * ServiceState provider.
4527 * <p>
4528 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
Makoto Onukic8c71142019-08-07 08:59:39 -07004529 * {@link ServiceState} while your app is running.
4530 * You can also use a {@link android.app.job.JobService} to
Jordan Liub9b75ed2017-02-28 18:15:07 -08004531 * ensure your app is notified of changes to the {@link Uri} even when it is not running.
Makoto Onukic8c71142019-08-07 08:59:39 -07004532 * Note, however, that using a {@link android.app.job.JobService}
4533 * does not guarantee timely delivery of
Jordan Liub9b75ed2017-02-28 18:15:07 -08004534 * updates to the {@link Uri}.
4535 *
Jordan Liu0f332522017-04-19 14:25:29 -07004536 * @param subscriptionId the subscriptionId to receive updates on
Jordan Liub9b75ed2017-02-28 18:15:07 -08004537 * @param field the ServiceState field to receive updates on
4538 * @return the Uri used to observe {@link ServiceState} changes
4539 */
Jordan Liu0f332522017-04-19 14:25:29 -07004540 public static Uri getUriForSubscriptionIdAndField(int subscriptionId, String field) {
4541 return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId))
Jordan Liub9b75ed2017-02-28 18:15:07 -08004542 .appendEncodedPath(field).build();
4543 }
4544
4545 /**
4546 * Generates a content {@link Uri} used to receive updates on every field in the
4547 * ServiceState provider.
4548 * <p>
4549 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
Makoto Onukic8c71142019-08-07 08:59:39 -07004550 * {@link ServiceState} while your app is running. You can also use a
4551 * {@link android.app.job.JobService} to
Jordan Liub9b75ed2017-02-28 18:15:07 -08004552 * ensure your app is notified of changes to the {@link Uri} even when it is not running.
Makoto Onukic8c71142019-08-07 08:59:39 -07004553 * Note, however, that using a {@link android.app.job.JobService}
4554 * does not guarantee timely delivery of
Jordan Liub9b75ed2017-02-28 18:15:07 -08004555 * updates to the {@link Uri}.
4556 *
Jordan Liu0f332522017-04-19 14:25:29 -07004557 * @param subscriptionId the subscriptionId to receive updates on
Jordan Liub9b75ed2017-02-28 18:15:07 -08004558 * @return the Uri used to observe {@link ServiceState} changes
4559 */
Jordan Liu0f332522017-04-19 14:25:29 -07004560 public static Uri getUriForSubscriptionId(int subscriptionId) {
4561 return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId)).build();
Jordan Liub9b75ed2017-02-28 18:15:07 -08004562 }
4563
4564 /**
4565 * Used to insert a ServiceState into the ServiceStateProvider as a ContentValues instance.
4566 *
4567 * @param state the ServiceState to convert into ContentValues
4568 * @return the convertedContentValues instance
4569 * @hide
4570 */
4571 public static ContentValues getContentValuesForServiceState(ServiceState state) {
4572 ContentValues values = new ContentValues();
Jack Yu2e273b22019-04-02 10:49:35 -07004573 final Parcel p = Parcel.obtain();
4574 state.writeToParcel(p, 0);
4575 // Turn the parcel to byte array. Safe to do this because the content values were never
4576 // written into a persistent storage. ServiceStateProvider keeps values in the memory.
4577 values.put(SERVICE_STATE, p.marshall());
Jordan Liub9b75ed2017-02-28 18:15:07 -08004578 return values;
4579 }
4580
4581 /**
Jack Yu2e273b22019-04-02 10:49:35 -07004582 * The current service state.
4583 *
4584 * This is the entire {@link ServiceState} object in byte array.
4585 *
4586 * @hide
4587 */
4588 public static final String SERVICE_STATE = "service_state";
4589
4590 /**
Jordan Liub9b75ed2017-02-28 18:15:07 -08004591 * An integer value indicating the current voice service state.
4592 * <p>
4593 * Valid values: {@link ServiceState#STATE_IN_SERVICE},
4594 * {@link ServiceState#STATE_OUT_OF_SERVICE}, {@link ServiceState#STATE_EMERGENCY_ONLY},
4595 * {@link ServiceState#STATE_POWER_OFF}.
4596 * <p>
4597 * This is the same as {@link ServiceState#getState()}.
4598 */
4599 public static final String VOICE_REG_STATE = "voice_reg_state";
4600
4601 /**
4602 * An integer value indicating the current data service state.
4603 * <p>
4604 * Valid values: {@link ServiceState#STATE_IN_SERVICE},
4605 * {@link ServiceState#STATE_OUT_OF_SERVICE}, {@link ServiceState#STATE_EMERGENCY_ONLY},
4606 * {@link ServiceState#STATE_POWER_OFF}.
4607 * <p>
4608 * This is the same as {@link ServiceState#getDataRegState()}.
4609 * @hide
4610 */
4611 public static final String DATA_REG_STATE = "data_reg_state";
4612
4613 /**
4614 * An integer value indicating the current voice roaming type.
4615 * <p>
4616 * This is the same as {@link ServiceState#getVoiceRoamingType()}.
4617 * @hide
4618 */
4619 public static final String VOICE_ROAMING_TYPE = "voice_roaming_type";
4620
4621 /**
4622 * An integer value indicating the current data roaming type.
4623 * <p>
4624 * This is the same as {@link ServiceState#getDataRoamingType()}.
4625 * @hide
4626 */
4627 public static final String DATA_ROAMING_TYPE = "data_roaming_type";
4628
4629 /**
4630 * The current registered voice network operator name in long alphanumeric format.
4631 * <p>
SongFerngWang2b1ea8d2019-11-20 02:11:09 +08004632 * This is the same as {@link ServiceState#getOperatorAlphaLong()}.
Jordan Liub9b75ed2017-02-28 18:15:07 -08004633 * @hide
4634 */
4635 public static final String VOICE_OPERATOR_ALPHA_LONG = "voice_operator_alpha_long";
4636
4637 /**
4638 * The current registered operator name in short alphanumeric format.
4639 * <p>
4640 * In GSM/UMTS, short format can be up to 8 characters long. The current registered voice
4641 * network operator name in long alphanumeric format.
4642 * <p>
SongFerngWang2b1ea8d2019-11-20 02:11:09 +08004643 * This is the same as {@link ServiceState#getOperatorAlphaShort()}.
Jordan Liub9b75ed2017-02-28 18:15:07 -08004644 * @hide
4645 */
4646 public static final String VOICE_OPERATOR_ALPHA_SHORT = "voice_operator_alpha_short";
4647
Jordan Liub9b75ed2017-02-28 18:15:07 -08004648 /**
4649 * The current registered operator numeric id.
4650 * <p>
4651 * In GSM/UMTS, numeric format is 3 digit country code plus 2 or 3 digit
4652 * network code.
4653 * <p>
4654 * This is the same as {@link ServiceState#getOperatorNumeric()}.
4655 */
4656 public static final String VOICE_OPERATOR_NUMERIC = "voice_operator_numeric";
4657
4658 /**
4659 * The current registered data network operator name in long alphanumeric format.
4660 * <p>
SongFerngWang2b1ea8d2019-11-20 02:11:09 +08004661 * This is the same as {@link ServiceState#getOperatorAlphaLong()}.
Jordan Liub9b75ed2017-02-28 18:15:07 -08004662 * @hide
4663 */
4664 public static final String DATA_OPERATOR_ALPHA_LONG = "data_operator_alpha_long";
4665
4666 /**
4667 * The current registered data network operator name in short alphanumeric format.
4668 * <p>
SongFerngWang2b1ea8d2019-11-20 02:11:09 +08004669 * This is the same as {@link ServiceState#getOperatorAlphaShort()}.
Jordan Liub9b75ed2017-02-28 18:15:07 -08004670 * @hide
4671 */
4672 public static final String DATA_OPERATOR_ALPHA_SHORT = "data_operator_alpha_short";
4673
4674 /**
4675 * The current registered data network operator numeric id.
4676 * <p>
SongFerngWang2b1ea8d2019-11-20 02:11:09 +08004677 * This is the same as {@link ServiceState#getOperatorNumeric()}.
Jordan Liub9b75ed2017-02-28 18:15:07 -08004678 * @hide
4679 */
4680 public static final String DATA_OPERATOR_NUMERIC = "data_operator_numeric";
4681
4682 /**
4683 * The current network selection mode.
4684 * <p>
4685 * This is the same as {@link ServiceState#getIsManualSelection()}.
4686 */
4687 public static final String IS_MANUAL_NETWORK_SELECTION = "is_manual_network_selection";
4688
4689 /**
4690 * This is the same as {@link ServiceState#getRilVoiceRadioTechnology()}.
4691 * @hide
4692 */
4693 public static final String RIL_VOICE_RADIO_TECHNOLOGY = "ril_voice_radio_technology";
4694
4695 /**
4696 * This is the same as {@link ServiceState#getRilDataRadioTechnology()}.
4697 * @hide
4698 */
4699 public static final String RIL_DATA_RADIO_TECHNOLOGY = "ril_data_radio_technology";
4700
4701 /**
4702 * This is the same as {@link ServiceState#getCssIndicator()}.
4703 * @hide
4704 */
4705 public static final String CSS_INDICATOR = "css_indicator";
4706
4707 /**
Jack Yu2661fac2018-03-15 13:51:05 -07004708 * This is the same as {@link ServiceState#getCdmaNetworkId()}.
Jordan Liub9b75ed2017-02-28 18:15:07 -08004709 * @hide
4710 */
4711 public static final String NETWORK_ID = "network_id";
4712
4713 /**
Jack Yu2661fac2018-03-15 13:51:05 -07004714 * This is the same as {@link ServiceState#getCdmaSystemId()}.
Jordan Liub9b75ed2017-02-28 18:15:07 -08004715 * @hide
4716 */
4717 public static final String SYSTEM_ID = "system_id";
4718
4719 /**
4720 * This is the same as {@link ServiceState#getCdmaRoamingIndicator()}.
4721 * @hide
4722 */
4723 public static final String CDMA_ROAMING_INDICATOR = "cdma_roaming_indicator";
4724
4725 /**
4726 * This is the same as {@link ServiceState#getCdmaDefaultRoamingIndicator()}.
4727 * @hide
4728 */
4729 public static final String CDMA_DEFAULT_ROAMING_INDICATOR =
4730 "cdma_default_roaming_indicator";
4731
4732 /**
4733 * This is the same as {@link ServiceState#getCdmaEriIconIndex()}.
4734 * @hide
4735 */
4736 public static final String CDMA_ERI_ICON_INDEX = "cdma_eri_icon_index";
4737
4738 /**
4739 * This is the same as {@link ServiceState#getCdmaEriIconMode()}.
4740 * @hide
4741 */
4742 public static final String CDMA_ERI_ICON_MODE = "cdma_eri_icon_mode";
4743
4744 /**
4745 * This is the same as {@link ServiceState#isEmergencyOnly()}.
4746 * @hide
4747 */
4748 public static final String IS_EMERGENCY_ONLY = "is_emergency_only";
4749
4750 /**
4751 * This is the same as {@link ServiceState#getDataRoamingFromRegistration()}.
4752 * @hide
4753 */
4754 public static final String IS_DATA_ROAMING_FROM_REGISTRATION =
4755 "is_data_roaming_from_registration";
4756
4757 /**
4758 * This is the same as {@link ServiceState#isUsingCarrierAggregation()}.
4759 * @hide
4760 */
4761 public static final String IS_USING_CARRIER_AGGREGATION = "is_using_carrier_aggregation";
SongFerngWang3cbcf752019-03-21 23:14:20 +08004762
4763 /**
4764 * The current registered raw data network operator name in long alphanumeric format.
4765 * <p>
4766 * This is the same as {@link ServiceState#getOperatorAlphaLongRaw()}.
4767 * @hide
4768 */
4769 public static final String OPERATOR_ALPHA_LONG_RAW = "operator_alpha_long_raw";
4770
4771 /**
4772 * The current registered raw data network operator name in short alphanumeric format.
4773 * <p>
4774 * This is the same as {@link ServiceState#getOperatorAlphaShortRaw()}.
4775 * @hide
4776 */
4777 public static final String OPERATOR_ALPHA_SHORT_RAW = "operator_alpha_short_raw";
Jordan Liub9b75ed2017-02-28 18:15:07 -08004778 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07004779
4780 /**
fionaxu58278be2018-01-29 14:08:12 -08004781 * Contains carrier identification information for the current subscriptions.
fionaxu3d0ad1f2017-10-25 23:09:36 -07004782 */
fionaxu62bc7472018-02-28 11:18:45 -08004783 public static final class CarrierId implements BaseColumns {
fionaxu3d0ad1f2017-10-25 23:09:36 -07004784 /**
fionaxu58278be2018-01-29 14:08:12 -08004785 * Not instantiable.
4786 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07004787 */
fionaxu62bc7472018-02-28 11:18:45 -08004788 private CarrierId() {}
fionaxu3d0ad1f2017-10-25 23:09:36 -07004789
4790 /**
fionaxu58278be2018-01-29 14:08:12 -08004791 * The {@code content://} style URI for this provider.
fionaxu3d0ad1f2017-10-25 23:09:36 -07004792 */
fionaxu62bc7472018-02-28 11:18:45 -08004793 public static final Uri CONTENT_URI = Uri.parse("content://carrier_id");
fionaxu3d0ad1f2017-10-25 23:09:36 -07004794
4795 /**
fionaxu62bc7472018-02-28 11:18:45 -08004796 * The authority string for the CarrierId Provider
fionaxu58278be2018-01-29 14:08:12 -08004797 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07004798 */
fionaxu62bc7472018-02-28 11:18:45 -08004799 public static final String AUTHORITY = "carrier_id";
fionaxu58278be2018-01-29 14:08:12 -08004800
fionaxu3d0ad1f2017-10-25 23:09:36 -07004801
4802 /**
fionaxu58278be2018-01-29 14:08:12 -08004803 * Generates a content {@link Uri} used to receive updates on carrier identity change
4804 * on the given subscriptionId
4805 * <p>
4806 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
fionaxuc8d483e2018-03-07 21:52:05 -08004807 * carrier identity {@link TelephonyManager#getSimCarrierId()}
Makoto Onukic8c71142019-08-07 08:59:39 -07004808 * while your app is running. You can also use a {@link android.app.job.JobService}
4809 * to ensure your app
fionaxu58278be2018-01-29 14:08:12 -08004810 * is notified of changes to the {@link Uri} even when it is not running.
Makoto Onukic8c71142019-08-07 08:59:39 -07004811 * Note, however, that using a {@link android.app.job.JobService} does not guarantee
4812 * timely delivery of updates to the {@link Uri}.
fionaxu58278be2018-01-29 14:08:12 -08004813 *
4814 * @param subscriptionId the subscriptionId to receive updates on
4815 * @return the Uri used to observe carrier identity changes
fionaxu3d0ad1f2017-10-25 23:09:36 -07004816 */
fionaxu58278be2018-01-29 14:08:12 -08004817 public static Uri getUriForSubscriptionId(int subscriptionId) {
4818 return CONTENT_URI.buildUpon().appendEncodedPath(
4819 String.valueOf(subscriptionId)).build();
4820 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07004821
4822 /**
chen xu45f66212019-03-06 14:43:40 -08004823 * Generates a content {@link Uri} used to receive updates on specific carrier identity
chen xud47a0682018-12-06 15:34:05 -08004824 * change on the given subscriptionId returned by
chen xu45f66212019-03-06 14:43:40 -08004825 * {@link TelephonyManager#getSimSpecificCarrierId()}.
4826 * @see TelephonyManager#ACTION_SUBSCRIPTION_SPECIFIC_CARRIER_IDENTITY_CHANGED
chen xudd44d812018-11-02 17:49:57 -07004827 * <p>
4828 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
chen xu45f66212019-03-06 14:43:40 -08004829 * specific carrier identity {@link TelephonyManager#getSimSpecificCarrierId()}
Makoto Onukic8c71142019-08-07 08:59:39 -07004830 * while your app is running. You can also use a {@link android.app.job.JobService}
4831 * to ensure your app
chen xudd44d812018-11-02 17:49:57 -07004832 * is notified of changes to the {@link Uri} even when it is not running.
Makoto Onukic8c71142019-08-07 08:59:39 -07004833 * Note, however, that using a {@link android.app.job.JobService} does not guarantee timely
4834 * delivery of updates to the {@link Uri}.
chen xudd44d812018-11-02 17:49:57 -07004835 *
4836 * @param subscriptionId the subscriptionId to receive updates on
chen xu45f66212019-03-06 14:43:40 -08004837 * @return the Uri used to observe specific carrier identity changes
chen xudd44d812018-11-02 17:49:57 -07004838 */
chen xu81653862019-02-28 10:44:54 -08004839 @NonNull
chen xu45f66212019-03-06 14:43:40 -08004840 public static Uri getSpecificCarrierIdUriForSubscriptionId(int subscriptionId) {
4841 return Uri.withAppendedPath(Uri.withAppendedPath(CONTENT_URI, "specific"),
chen xudd44d812018-11-02 17:49:57 -07004842 String.valueOf(subscriptionId));
4843 }
4844
4845 /**
fionaxu58278be2018-01-29 14:08:12 -08004846 * A user facing carrier name.
fionaxuc8d483e2018-03-07 21:52:05 -08004847 * @see TelephonyManager#getSimCarrierIdName()
fionaxu3d0ad1f2017-10-25 23:09:36 -07004848 * <P>Type: TEXT </P>
4849 */
fionaxu62bc7472018-02-28 11:18:45 -08004850 public static final String CARRIER_NAME = "carrier_name";
fionaxu3d0ad1f2017-10-25 23:09:36 -07004851
4852 /**
4853 * A unique carrier id
fionaxuc8d483e2018-03-07 21:52:05 -08004854 * @see TelephonyManager#getSimCarrierId()
fionaxu3d0ad1f2017-10-25 23:09:36 -07004855 * <P>Type: INTEGER </P>
4856 */
fionaxu62bc7472018-02-28 11:18:45 -08004857 public static final String CARRIER_ID = "carrier_id";
fionaxu3d0ad1f2017-10-25 23:09:36 -07004858
4859 /**
chen xudd44d812018-11-02 17:49:57 -07004860 * A fine-grained carrier id.
chen xu45f66212019-03-06 14:43:40 -08004861 * The specific carrier ID would be used for configuration purposes, but apps wishing to
4862 * know about the carrier itself should use the regular carrier ID returned by
4863 * {@link TelephonyManager#getSimCarrierId()}.
4864 *
4865 * @see TelephonyManager#getSimSpecificCarrierId()
chen xudd44d812018-11-02 17:49:57 -07004866 * This is not a database column, only used to notify content observers for
chen xu45f66212019-03-06 14:43:40 -08004867 * {@link #getSpecificCarrierIdUriForSubscriptionId(int)}
chen xudd44d812018-11-02 17:49:57 -07004868 */
chen xu45f66212019-03-06 14:43:40 -08004869 public static final String SPECIFIC_CARRIER_ID = "specific_carrier_id";
chen xudd44d812018-11-02 17:49:57 -07004870
4871 /**
chen xu45f66212019-03-06 14:43:40 -08004872 * A user facing carrier name for specific carrier id {@link #SPECIFIC_CARRIER_ID}.
4873 * @see TelephonyManager#getSimSpecificCarrierIdName()
chen xud47a0682018-12-06 15:34:05 -08004874 * This is not a database column, only used to notify content observers for
chen xu45f66212019-03-06 14:43:40 -08004875 * {@link #getSpecificCarrierIdUriForSubscriptionId(int)}
chen xud47a0682018-12-06 15:34:05 -08004876 */
chen xu45f66212019-03-06 14:43:40 -08004877 public static final String SPECIFIC_CARRIER_ID_NAME = "specific_carrier_id_name";
chen xud47a0682018-12-06 15:34:05 -08004878
4879 /**
chen xudd44d812018-11-02 17:49:57 -07004880 * A unique parent carrier id. The parent-child
4881 * relationship can be used to further differentiate a single carrier by different networks,
chen xu45f66212019-03-06 14:43:40 -08004882 * by prepaid v.s. postpaid. It's an optional field.
4883 * A carrier id with a valid parent_carrier_id is considered fine-grained specific carrier
4884 * ID, will not be returned as {@link #CARRIER_ID} but {@link #SPECIFIC_CARRIER_ID}.
chen xudd44d812018-11-02 17:49:57 -07004885 * <P>Type: INTEGER </P>
4886 * @hide
4887 */
4888 public static final String PARENT_CARRIER_ID = "parent_carrier_id";
4889
4890 /**
fionaxu58278be2018-01-29 14:08:12 -08004891 * Contains mappings between matching rules with carrier id for all carriers.
4892 * @hide
fionaxu3d0ad1f2017-10-25 23:09:36 -07004893 */
zoey chenb27edd72019-11-01 15:09:11 +08004894 @SystemApi
fionaxu58278be2018-01-29 14:08:12 -08004895 public static final class All implements BaseColumns {
zoey chenb27edd72019-11-01 15:09:11 +08004896
4897 /**
4898 * Not instantiable.
4899 * @hide
4900 */
4901 private All() {
4902 }
4903
fionaxu58278be2018-01-29 14:08:12 -08004904 /**
4905 * Numeric operator ID (as String). {@code MCC + MNC}
4906 * <P>Type: TEXT </P>
4907 */
4908 public static final String MCCMNC = "mccmnc";
4909
4910 /**
4911 * Group id level 1 (as String).
4912 * <P>Type: TEXT </P>
4913 */
4914 public static final String GID1 = "gid1";
4915
4916 /**
4917 * Group id level 2 (as String).
4918 * <P>Type: TEXT </P>
4919 */
4920 public static final String GID2 = "gid2";
4921
4922 /**
4923 * Public Land Mobile Network name.
4924 * <P>Type: TEXT </P>
4925 */
4926 public static final String PLMN = "plmn";
4927
4928 /**
4929 * Prefix xpattern of IMSI (International Mobile Subscriber Identity).
4930 * <P>Type: TEXT </P>
4931 */
4932 public static final String IMSI_PREFIX_XPATTERN = "imsi_prefix_xpattern";
4933
4934 /**
4935 * Service Provider Name.
4936 * <P>Type: TEXT </P>
4937 */
4938 public static final String SPN = "spn";
4939
4940 /**
4941 * Prefer APN name.
4942 * <P>Type: TEXT </P>
4943 */
4944 public static final String APN = "apn";
4945
4946 /**
4947 * Prefix of Integrated Circuit Card Identifier.
4948 * <P>Type: TEXT </P>
4949 */
4950 public static final String ICCID_PREFIX = "iccid_prefix";
4951
4952 /**
fionaxuf9583572018-06-08 16:55:25 -07004953 * Certificate for carrier privilege access rules.
4954 * <P>Type: TEXT in hex string </P>
4955 */
4956 public static final String PRIVILEGE_ACCESS_RULE = "privilege_access_rule";
4957
4958 /**
fionaxu58278be2018-01-29 14:08:12 -08004959 * The {@code content://} URI for this table.
4960 */
zoey chenb27edd72019-11-01 15:09:11 +08004961 @NonNull
fionaxu62bc7472018-02-28 11:18:45 -08004962 public static final Uri CONTENT_URI = Uri.parse("content://carrier_id/all");
fionaxu58278be2018-01-29 14:08:12 -08004963 }
fionaxu3d0ad1f2017-10-25 23:09:36 -07004964 }
changbettyc14ee332019-12-02 15:04:49 +08004965
4966 /**
4967 * Contains SIM Information
4968 * @hide
4969 */
4970 @SystemApi
4971 public static final class SimInfo {
4972 /**
4973 * Not instantiable.
4974 * @hide
4975 */
4976 private SimInfo() {}
4977
4978 /**
4979 * The {@code content://} style URI for this provider.
4980 */
4981 @NonNull
4982 public static final Uri CONTENT_URI = Uri.parse("content://telephony/siminfo");
4983 }
Dan Willemsen4980bf42017-02-14 14:17:12 -08004984}