1 /* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.provider; 18 19 import android.Manifest; 20 import android.annotation.IntDef; 21 import android.annotation.NonNull; 22 import android.annotation.RequiresPermission; 23 import android.annotation.SdkConstant; 24 import android.annotation.SdkConstant.SdkConstantType; 25 import android.annotation.SystemApi; 26 import android.annotation.TestApi; 27 import android.compat.annotation.ChangeId; 28 import android.compat.annotation.EnabledAfter; 29 import android.compat.annotation.UnsupportedAppUsage; 30 import android.content.ComponentName; 31 import android.content.ContentResolver; 32 import android.content.ContentValues; 33 import android.content.Context; 34 import android.content.Intent; 35 import android.database.ContentObserver; 36 import android.database.Cursor; 37 import android.database.sqlite.SqliteWrapper; 38 import android.net.Uri; 39 import android.os.Build; 40 import android.os.Bundle; 41 import android.telephony.CarrierConfigManager; 42 import android.telephony.Rlog; 43 import android.telephony.ServiceState; 44 import android.telephony.SmsMessage; 45 import android.telephony.SubscriptionManager; 46 import android.telephony.TelephonyManager; 47 import android.telephony.UiccAccessRule; 48 import android.text.TextUtils; 49 import android.util.Patterns; 50 51 import com.android.internal.telephony.SmsApplication; 52 53 import java.lang.annotation.Retention; 54 import java.lang.annotation.RetentionPolicy; 55 import java.util.HashSet; 56 import java.util.Set; 57 import java.util.regex.Matcher; 58 import java.util.regex.Pattern; 59 60 /** 61 * The Telephony provider contains data related to phone operation, specifically SMS and MMS 62 * messages, access to the APN list, including the MMSC to use, and the service state. 63 * 64 * <p class="note"><strong>Note:</strong> These APIs are not available on all Android-powered 65 * devices. If your app depends on telephony features such as for managing SMS messages, include 66 * a <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code <uses-feature>} 67 * </a> element in your manifest that declares the {@code "android.hardware.telephony"} hardware 68 * feature. Alternatively, you can check for telephony availability at runtime using either 69 * {@link android.content.pm.PackageManager#hasSystemFeature 70 * hasSystemFeature(PackageManager.FEATURE_TELEPHONY)} or {@link 71 * android.telephony.TelephonyManager#getPhoneType}.</p> 72 * 73 * <h3>Creating an SMS app</h3> 74 * 75 * <p>Only the default SMS app (selected by the user in system settings) is able to write to the 76 * SMS Provider (the tables defined within the {@code Telephony} class) and only the default SMS 77 * app receives the {@link android.provider.Telephony.Sms.Intents#SMS_DELIVER_ACTION} broadcast 78 * when the user receives an SMS or the {@link 79 * android.provider.Telephony.Sms.Intents#WAP_PUSH_DELIVER_ACTION} broadcast when the user 80 * receives an MMS.</p> 81 * 82 * <p>Any app that wants to behave as the user's default SMS app must handle the following intents: 83 * <ul> 84 * <li>In a broadcast receiver, include an intent filter for {@link Sms.Intents#SMS_DELIVER_ACTION} 85 * (<code>"android.provider.Telephony.SMS_DELIVER"</code>). The broadcast receiver must also 86 * require the {@link android.Manifest.permission#BROADCAST_SMS} permission. 87 * <p>This allows your app to directly receive incoming SMS messages.</p></li> 88 * <li>In a broadcast receiver, include an intent filter for {@link 89 * Sms.Intents#WAP_PUSH_DELIVER_ACTION}} ({@code "android.provider.Telephony.WAP_PUSH_DELIVER"}) 90 * with the MIME type <code>"application/vnd.wap.mms-message"</code>. 91 * The broadcast receiver must also require the {@link 92 * android.Manifest.permission#BROADCAST_WAP_PUSH} permission. 93 * <p>This allows your app to directly receive incoming MMS messages.</p></li> 94 * <li>In your activity that delivers new messages, include an intent filter for 95 * {@link android.content.Intent#ACTION_SENDTO} (<code>"android.intent.action.SENDTO" 96 * </code>) with schemas, <code>sms:</code>, <code>smsto:</code>, <code>mms:</code>, and 97 * <code>mmsto:</code>. 98 * <p>This allows your app to receive intents from other apps that want to deliver a 99 * message.</p></li> 100 * <li>In a service, include an intent filter for {@link 101 * android.telephony.TelephonyManager#ACTION_RESPOND_VIA_MESSAGE} 102 * (<code>"android.intent.action.RESPOND_VIA_MESSAGE"</code>) with schemas, 103 * <code>sms:</code>, <code>smsto:</code>, <code>mms:</code>, and <code>mmsto:</code>. 104 * This service must also require the {@link 105 * android.Manifest.permission#SEND_RESPOND_VIA_MESSAGE} permission. 106 * <p>This allows users to respond to incoming phone calls with an immediate text message 107 * using your app.</p></li> 108 * </ul> 109 * 110 * <p>Other apps that are not selected as the default SMS app can only <em>read</em> the SMS 111 * Provider, but may also be notified when a new SMS arrives by listening for the {@link 112 * Sms.Intents#SMS_RECEIVED_ACTION} 113 * broadcast, which is a non-abortable broadcast that may be delivered to multiple apps. This 114 * broadcast is intended for apps that—while not selected as the default SMS app—need to 115 * read special incoming messages such as to perform phone number verification.</p> 116 * 117 * <p>For more information about building SMS apps, read the blog post, <a 118 * href="http://android-developers.blogspot.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html" 119 * >Getting Your SMS Apps Ready for KitKat</a>.</p> 120 * 121 */ 122 public final class Telephony { 123 private static final String TAG = "Telephony"; 124 125 /** 126 * Not instantiable. 127 * @hide 128 */ Telephony()129 private Telephony() { 130 } 131 132 /** 133 * Base columns for tables that contain text-based SMSs. 134 */ 135 public interface TextBasedSmsColumns { 136 137 /** Message type: all messages. */ 138 public static final int MESSAGE_TYPE_ALL = 0; 139 140 /** Message type: inbox. */ 141 public static final int MESSAGE_TYPE_INBOX = 1; 142 143 /** Message type: sent messages. */ 144 public static final int MESSAGE_TYPE_SENT = 2; 145 146 /** Message type: drafts. */ 147 public static final int MESSAGE_TYPE_DRAFT = 3; 148 149 /** Message type: outbox. */ 150 public static final int MESSAGE_TYPE_OUTBOX = 4; 151 152 /** Message type: failed outgoing message. */ 153 public static final int MESSAGE_TYPE_FAILED = 5; 154 155 /** Message type: queued to send later. */ 156 public static final int MESSAGE_TYPE_QUEUED = 6; 157 158 /** 159 * The type of message. 160 * <P>Type: INTEGER</P> 161 */ 162 public static final String TYPE = "type"; 163 164 /** 165 * The thread ID of the message. 166 * <P>Type: INTEGER</P> 167 */ 168 public static final String THREAD_ID = "thread_id"; 169 170 /** 171 * The address of the other party. 172 * <P>Type: TEXT</P> 173 */ 174 public static final String ADDRESS = "address"; 175 176 /** 177 * The date the message was received. 178 * <P>Type: INTEGER (long)</P> 179 */ 180 public static final String DATE = "date"; 181 182 /** 183 * The date the message was sent. 184 * <P>Type: INTEGER (long)</P> 185 */ 186 public static final String DATE_SENT = "date_sent"; 187 188 /** 189 * Has the message been read? 190 * <P>Type: INTEGER (boolean)</P> 191 */ 192 public static final String READ = "read"; 193 194 /** 195 * Has the message been seen by the user? The "seen" flag determines 196 * whether we need to show a notification. 197 * <P>Type: INTEGER (boolean)</P> 198 */ 199 public static final String SEEN = "seen"; 200 201 /** 202 * {@code TP-Status} value for the message, or -1 if no status has been received. 203 * <P>Type: INTEGER</P> 204 */ 205 public static final String STATUS = "status"; 206 207 /** TP-Status: no status received. */ 208 public static final int STATUS_NONE = -1; 209 /** TP-Status: complete. */ 210 public static final int STATUS_COMPLETE = 0; 211 /** TP-Status: pending. */ 212 public static final int STATUS_PENDING = 32; 213 /** TP-Status: failed. */ 214 public static final int STATUS_FAILED = 64; 215 216 /** 217 * The subject of the message, if present. 218 * <P>Type: TEXT</P> 219 */ 220 public static final String SUBJECT = "subject"; 221 222 /** 223 * The body of the message. 224 * <P>Type: TEXT</P> 225 */ 226 public static final String BODY = "body"; 227 228 /** 229 * The ID of the sender of the conversation, if present. 230 * <P>Type: INTEGER (reference to item in {@code content://contacts/people})</P> 231 */ 232 public static final String PERSON = "person"; 233 234 /** 235 * The protocol identifier code. 236 * <P>Type: INTEGER</P> 237 */ 238 public static final String PROTOCOL = "protocol"; 239 240 /** 241 * Is the {@code TP-Reply-Path} flag set? 242 * <P>Type: BOOLEAN</P> 243 */ 244 public static final String REPLY_PATH_PRESENT = "reply_path_present"; 245 246 /** 247 * The service center (SC) through which to send the message, if present. 248 * <P>Type: TEXT</P> 249 */ 250 public static final String SERVICE_CENTER = "service_center"; 251 252 /** 253 * Is the message locked? 254 * <P>Type: INTEGER (boolean)</P> 255 */ 256 public static final String LOCKED = "locked"; 257 258 /** 259 * The subscription to which the message belongs to. Its value will be 260 * < 0 if the sub id cannot be determined. 261 * <p>Type: INTEGER (long) </p> 262 */ 263 public static final String SUBSCRIPTION_ID = "sub_id"; 264 265 /** 266 * The MTU size of the mobile interface to which the APN connected 267 * @hide 268 */ 269 public static final String MTU = "mtu"; 270 271 /** 272 * Error code associated with sending or receiving this message 273 * <P>Type: INTEGER</P> 274 */ 275 public static final String ERROR_CODE = "error_code"; 276 277 /** 278 * The identity of the sender of a sent message. It is 279 * usually the package name of the app which sends the message. 280 * <p class="note"><strong>Note:</strong> 281 * This column is read-only. It is set by the provider and can not be changed by apps. 282 * <p>Type: TEXT</p> 283 */ 284 public static final String CREATOR = "creator"; 285 } 286 287 /** 288 * Columns in sms_changes table. 289 * @hide 290 */ 291 public interface TextBasedSmsChangesColumns { 292 /** 293 * The {@code content://} style URL for this table. 294 * @hide 295 */ 296 public static final Uri CONTENT_URI = Uri.parse("content://sms-changes"); 297 298 /** 299 * Primary key. 300 * <P>Type: INTEGER (long)</P> 301 * @hide 302 */ 303 public static final String ID = "_id"; 304 305 /** 306 * Triggers on sms table create a row in this table for each update/delete. 307 * This column is the "_id" of the row from sms table that was updated/deleted. 308 * <P>Type: INTEGER (long)</P> 309 * @hide 310 */ 311 public static final String ORIG_ROW_ID = "orig_rowid"; 312 313 /** 314 * Triggers on sms table create a row in this table for each update/delete. 315 * This column is the "sub_id" of the row from sms table that was updated/deleted. 316 * @hide 317 * <P>Type: INTEGER (long)</P> 318 */ 319 public static final String SUB_ID = "sub_id"; 320 321 /** 322 * The type of operation that created this row. 323 * {@link #TYPE_UPDATE} = update op 324 * {@link #TYPE_DELETE} = delete op 325 * @hide 326 * <P>Type: INTEGER (long)</P> 327 */ 328 public static final String TYPE = "type"; 329 330 /** 331 * One of the possible values for the above column "type". Indicates it is an update op. 332 * @hide 333 */ 334 public static final int TYPE_UPDATE = 0; 335 336 /** 337 * One of the possible values for the above column "type". Indicates it is a delete op. 338 * @hide 339 */ 340 public static final int TYPE_DELETE = 1; 341 342 /** 343 * This column contains a non-null value only if the operation on sms table is an update op 344 * and the column "read" is changed by the update op. 345 * <P>Type: INTEGER (boolean)</P> 346 * @hide 347 */ 348 public static final String NEW_READ_STATUS = "new_read_status"; 349 } 350 351 /** 352 * Contains all text-based SMS messages. 353 */ 354 public static final class Sms implements BaseColumns, TextBasedSmsColumns { 355 356 /** 357 * Not instantiable. 358 * @hide 359 */ Sms()360 private Sms() { 361 } 362 363 /** 364 * Used to determine the currently configured default SMS package. 365 * @param context context of the requesting application 366 * @return package name for the default SMS package or null 367 */ getDefaultSmsPackage(Context context)368 public static String getDefaultSmsPackage(Context context) { 369 ComponentName component = SmsApplication.getDefaultSmsApplication(context, false); 370 if (component != null) { 371 return component.getPackageName(); 372 } 373 return null; 374 } 375 376 /** 377 * Return cursor for table query. 378 * @hide 379 */ query(ContentResolver cr, String[] projection)380 public static Cursor query(ContentResolver cr, String[] projection) { 381 return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER); 382 } 383 384 /** 385 * Return cursor for table query. 386 * @hide 387 */ 388 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) query(ContentResolver cr, String[] projection, String where, String orderBy)389 public static Cursor query(ContentResolver cr, String[] projection, 390 String where, String orderBy) { 391 return cr.query(CONTENT_URI, projection, where, 392 null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy); 393 } 394 395 /** 396 * The {@code content://} style URL for this table. 397 */ 398 public static final Uri CONTENT_URI = Uri.parse("content://sms"); 399 400 /** 401 * The default sort order for this table. 402 */ 403 public static final String DEFAULT_SORT_ORDER = "date DESC"; 404 405 /** 406 * Add an SMS to the given URI. 407 * 408 * @param resolver the content resolver to use 409 * @param uri the URI to add the message to 410 * @param address the address of the sender 411 * @param body the body of the message 412 * @param subject the pseudo-subject of the message 413 * @param date the timestamp for the message 414 * @param read true if the message has been read, false if not 415 * @param deliveryReport true if a delivery report was requested, false if not 416 * @return the URI for the new message 417 * @hide 418 */ 419 @UnsupportedAppUsage addMessageToUri(ContentResolver resolver, Uri uri, String address, String body, String subject, Long date, boolean read, boolean deliveryReport)420 public static Uri addMessageToUri(ContentResolver resolver, 421 Uri uri, String address, String body, String subject, 422 Long date, boolean read, boolean deliveryReport) { 423 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(), 424 resolver, uri, address, body, subject, date, read, deliveryReport, -1L); 425 } 426 427 /** 428 * Add an SMS to the given URI. 429 * 430 * @param resolver the content resolver to use 431 * @param uri the URI to add the message to 432 * @param address the address of the sender 433 * @param body the body of the message 434 * @param subject the psuedo-subject of the message 435 * @param date the timestamp for the message 436 * @param read true if the message has been read, false if not 437 * @param deliveryReport true if a delivery report was requested, false if not 438 * @param subId the subscription which the message belongs to 439 * @return the URI for the new message 440 * @hide 441 */ 442 @UnsupportedAppUsage addMessageToUri(int subId, ContentResolver resolver, Uri uri, String address, String body, String subject, Long date, boolean read, boolean deliveryReport)443 public static Uri addMessageToUri(int subId, ContentResolver resolver, 444 Uri uri, String address, String body, String subject, 445 Long date, boolean read, boolean deliveryReport) { 446 return addMessageToUri(subId, resolver, uri, address, body, subject, 447 date, read, deliveryReport, -1L); 448 } 449 450 /** 451 * Add an SMS to the given URI with the specified thread ID. 452 * 453 * @param resolver the content resolver to use 454 * @param uri the URI to add the message to 455 * @param address the address of the sender 456 * @param body the body of the message 457 * @param subject the pseudo-subject of the message 458 * @param date the timestamp for the message 459 * @param read true if the message has been read, false if not 460 * @param deliveryReport true if a delivery report was requested, false if not 461 * @param threadId the thread_id of the message 462 * @return the URI for the new message 463 * @hide 464 */ 465 @UnsupportedAppUsage addMessageToUri(ContentResolver resolver, Uri uri, String address, String body, String subject, Long date, boolean read, boolean deliveryReport, long threadId)466 public static Uri addMessageToUri(ContentResolver resolver, 467 Uri uri, String address, String body, String subject, 468 Long date, boolean read, boolean deliveryReport, long threadId) { 469 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(), 470 resolver, uri, address, body, subject, 471 date, read, deliveryReport, threadId); 472 } 473 474 /** 475 * Add an SMS to the given URI with thread_id specified. 476 * 477 * @param resolver the content resolver to use 478 * @param uri the URI to add the message to 479 * @param address the address of the sender 480 * @param body the body of the message 481 * @param subject the psuedo-subject of the message 482 * @param date the timestamp for the message 483 * @param read true if the message has been read, false if not 484 * @param deliveryReport true if a delivery report was requested, false if not 485 * @param threadId the thread_id of the message 486 * @param subId the subscription which the message belongs to 487 * @return the URI for the new message 488 * @hide 489 */ 490 @UnsupportedAppUsage addMessageToUri(int subId, ContentResolver resolver, Uri uri, String address, String body, String subject, Long date, boolean read, boolean deliveryReport, long threadId)491 public static Uri addMessageToUri(int subId, ContentResolver resolver, 492 Uri uri, String address, String body, String subject, 493 Long date, boolean read, boolean deliveryReport, long threadId) { 494 ContentValues values = new ContentValues(8); 495 Rlog.v(TAG,"Telephony addMessageToUri sub id: " + subId); 496 497 values.put(SUBSCRIPTION_ID, subId); 498 values.put(ADDRESS, address); 499 if (date != null) { 500 values.put(DATE, date); 501 } 502 values.put(READ, read ? Integer.valueOf(1) : Integer.valueOf(0)); 503 values.put(SUBJECT, subject); 504 values.put(BODY, body); 505 if (deliveryReport) { 506 values.put(STATUS, STATUS_PENDING); 507 } 508 if (threadId != -1L) { 509 values.put(THREAD_ID, threadId); 510 } 511 return resolver.insert(uri, values); 512 } 513 514 /** 515 * Move a message to the given folder. 516 * 517 * @param context the context to use 518 * @param uri the message to move 519 * @param folder the folder to move to 520 * @return true if the operation succeeded 521 * @hide 522 */ 523 @UnsupportedAppUsage moveMessageToFolder(Context context, Uri uri, int folder, int error)524 public static boolean moveMessageToFolder(Context context, 525 Uri uri, int folder, int error) { 526 if (uri == null) { 527 return false; 528 } 529 530 boolean markAsUnread = false; 531 boolean markAsRead = false; 532 switch(folder) { 533 case MESSAGE_TYPE_INBOX: 534 case MESSAGE_TYPE_DRAFT: 535 break; 536 case MESSAGE_TYPE_OUTBOX: 537 case MESSAGE_TYPE_SENT: 538 markAsRead = true; 539 break; 540 case MESSAGE_TYPE_FAILED: 541 case MESSAGE_TYPE_QUEUED: 542 markAsUnread = true; 543 break; 544 default: 545 return false; 546 } 547 548 ContentValues values = new ContentValues(3); 549 550 values.put(TYPE, folder); 551 if (markAsUnread) { 552 values.put(READ, 0); 553 } else if (markAsRead) { 554 values.put(READ, 1); 555 } 556 values.put(ERROR_CODE, error); 557 558 return 1 == SqliteWrapper.update(context, context.getContentResolver(), 559 uri, values, null, null); 560 } 561 562 /** 563 * Returns true iff the folder (message type) identifies an 564 * outgoing message. 565 * @hide 566 */ 567 @UnsupportedAppUsage isOutgoingFolder(int messageType)568 public static boolean isOutgoingFolder(int messageType) { 569 return (messageType == MESSAGE_TYPE_FAILED) 570 || (messageType == MESSAGE_TYPE_OUTBOX) 571 || (messageType == MESSAGE_TYPE_SENT) 572 || (messageType == MESSAGE_TYPE_QUEUED); 573 } 574 575 /** 576 * Contains all text-based SMS messages in the SMS app inbox. 577 */ 578 public static final class Inbox implements BaseColumns, TextBasedSmsColumns { 579 580 /** 581 * Not instantiable. 582 * @hide 583 */ Inbox()584 private Inbox() { 585 } 586 587 /** 588 * The {@code content://} style URL for this table. 589 */ 590 public static final Uri CONTENT_URI = Uri.parse("content://sms/inbox"); 591 592 /** 593 * The default sort order for this table. 594 */ 595 public static final String DEFAULT_SORT_ORDER = "date DESC"; 596 597 /** 598 * Add an SMS to the Draft box. 599 * 600 * @param resolver the content resolver to use 601 * @param address the address of the sender 602 * @param body the body of the message 603 * @param subject the pseudo-subject of the message 604 * @param date the timestamp for the message 605 * @param read true if the message has been read, false if not 606 * @return the URI for the new message 607 * @hide 608 */ 609 @UnsupportedAppUsage addMessage(ContentResolver resolver, String address, String body, String subject, Long date, boolean read)610 public static Uri addMessage(ContentResolver resolver, 611 String address, String body, String subject, Long date, 612 boolean read) { 613 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(), 614 resolver, CONTENT_URI, address, body, subject, date, read, false); 615 } 616 617 /** 618 * Add an SMS to the Draft box. 619 * 620 * @param resolver the content resolver to use 621 * @param address the address of the sender 622 * @param body the body of the message 623 * @param subject the psuedo-subject of the message 624 * @param date the timestamp for the message 625 * @param read true if the message has been read, false if not 626 * @param subId the subscription which the message belongs to 627 * @return the URI for the new message 628 * @hide 629 */ 630 @UnsupportedAppUsage addMessage(int subId, ContentResolver resolver, String address, String body, String subject, Long date, boolean read)631 public static Uri addMessage(int subId, ContentResolver resolver, 632 String address, String body, String subject, Long date, boolean read) { 633 return addMessageToUri(subId, resolver, CONTENT_URI, address, body, 634 subject, date, read, false); 635 } 636 } 637 638 /** 639 * Contains all sent text-based SMS messages in the SMS app. 640 */ 641 public static final class Sent implements BaseColumns, TextBasedSmsColumns { 642 643 /** 644 * Not instantiable. 645 * @hide 646 */ Sent()647 private Sent() { 648 } 649 650 /** 651 * The {@code content://} style URL for this table. 652 */ 653 public static final Uri CONTENT_URI = Uri.parse("content://sms/sent"); 654 655 /** 656 * The default sort order for this table. 657 */ 658 public static final String DEFAULT_SORT_ORDER = "date DESC"; 659 660 /** 661 * Add an SMS to the Draft box. 662 * 663 * @param resolver the content resolver to use 664 * @param address the address of the sender 665 * @param body the body of the message 666 * @param subject the pseudo-subject of the message 667 * @param date the timestamp for the message 668 * @return the URI for the new message 669 * @hide 670 */ 671 @UnsupportedAppUsage addMessage(ContentResolver resolver, String address, String body, String subject, Long date)672 public static Uri addMessage(ContentResolver resolver, 673 String address, String body, String subject, Long date) { 674 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(), 675 resolver, CONTENT_URI, address, body, subject, date, true, false); 676 } 677 678 /** 679 * Add an SMS to the Draft box. 680 * 681 * @param resolver the content resolver to use 682 * @param address the address of the sender 683 * @param body the body of the message 684 * @param subject the psuedo-subject of the message 685 * @param date the timestamp for the message 686 * @param subId the subscription which the message belongs to 687 * @return the URI for the new message 688 * @hide 689 */ 690 @UnsupportedAppUsage addMessage(int subId, ContentResolver resolver, String address, String body, String subject, Long date)691 public static Uri addMessage(int subId, ContentResolver resolver, 692 String address, String body, String subject, Long date) { 693 return addMessageToUri(subId, resolver, CONTENT_URI, address, body, 694 subject, date, true, false); 695 } 696 } 697 698 /** 699 * Contains all draft text-based SMS messages in the SMS app. 700 */ 701 public static final class Draft implements BaseColumns, TextBasedSmsColumns { 702 703 /** 704 * Not instantiable. 705 * @hide 706 */ Draft()707 private Draft() { 708 } 709 710 /** 711 * The {@code content://} style URL for this table. 712 */ 713 public static final Uri CONTENT_URI = Uri.parse("content://sms/draft"); 714 715 /** 716 * @hide 717 */ 718 @UnsupportedAppUsage addMessage(ContentResolver resolver, String address, String body, String subject, Long date)719 public static Uri addMessage(ContentResolver resolver, 720 String address, String body, String subject, Long date) { 721 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(), 722 resolver, CONTENT_URI, address, body, subject, date, true, false); 723 } 724 725 /** 726 * Add an SMS to the Draft box. 727 * 728 * @param resolver the content resolver to use 729 * @param address the address of the sender 730 * @param body the body of the message 731 * @param subject the psuedo-subject of the message 732 * @param date the timestamp for the message 733 * @param subId the subscription which the message belongs to 734 * @return the URI for the new message 735 * @hide 736 */ 737 @UnsupportedAppUsage addMessage(int subId, ContentResolver resolver, String address, String body, String subject, Long date)738 public static Uri addMessage(int subId, ContentResolver resolver, 739 String address, String body, String subject, Long date) { 740 return addMessageToUri(subId, resolver, CONTENT_URI, address, body, 741 subject, date, true, false); 742 } 743 744 /** 745 * The default sort order for this table. 746 */ 747 public static final String DEFAULT_SORT_ORDER = "date DESC"; 748 } 749 750 /** 751 * Contains all pending outgoing text-based SMS messages. 752 */ 753 public static final class Outbox implements BaseColumns, TextBasedSmsColumns { 754 755 /** 756 * Not instantiable. 757 * @hide 758 */ Outbox()759 private Outbox() { 760 } 761 762 /** 763 * The {@code content://} style URL for this table. 764 */ 765 public static final Uri CONTENT_URI = Uri.parse("content://sms/outbox"); 766 767 /** 768 * The default sort order for this table. 769 */ 770 public static final String DEFAULT_SORT_ORDER = "date DESC"; 771 772 /** 773 * Add an SMS to the outbox. 774 * 775 * @param resolver the content resolver to use 776 * @param address the address of the sender 777 * @param body the body of the message 778 * @param subject the pseudo-subject of the message 779 * @param date the timestamp for the message 780 * @param deliveryReport whether a delivery report was requested for the message 781 * @return the URI for the new message 782 * @hide 783 */ 784 @UnsupportedAppUsage addMessage(ContentResolver resolver, String address, String body, String subject, Long date, boolean deliveryReport, long threadId)785 public static Uri addMessage(ContentResolver resolver, 786 String address, String body, String subject, Long date, 787 boolean deliveryReport, long threadId) { 788 return addMessageToUri(SubscriptionManager.getDefaultSmsSubscriptionId(), 789 resolver, CONTENT_URI, address, body, subject, date, 790 true, deliveryReport, threadId); 791 } 792 793 /** 794 * Add an SMS to the Out box. 795 * 796 * @param resolver the content resolver to use 797 * @param address the address of the sender 798 * @param body the body of the message 799 * @param subject the psuedo-subject of the message 800 * @param date the timestamp for the message 801 * @param deliveryReport whether a delivery report was requested for the message 802 * @param subId the subscription which the message belongs to 803 * @return the URI for the new message 804 * @hide 805 */ addMessage(int subId, ContentResolver resolver, String address, String body, String subject, Long date, boolean deliveryReport, long threadId)806 public static Uri addMessage(int subId, ContentResolver resolver, 807 String address, String body, String subject, Long date, 808 boolean deliveryReport, long threadId) { 809 return addMessageToUri(subId, resolver, CONTENT_URI, address, body, 810 subject, date, true, deliveryReport, threadId); 811 } 812 } 813 814 /** 815 * Contains a view of SMS conversations (also referred to as threads). This is similar to 816 * {@link Threads}, but only includes SMS messages and columns relevant to SMS 817 * conversations. 818 * <p> 819 * Note that this view ignores any information about MMS messages, it is a 820 * view of conversations as if MMS messages did not exist at all. This means that all 821 * relevant information, such as snippets and message count, will ignore any MMS messages 822 * that might be in the same thread through other views and present only data based on the 823 * SMS messages in that thread. 824 */ 825 public static final class Conversations 826 implements BaseColumns, TextBasedSmsColumns { 827 828 /** 829 * Not instantiable. 830 * @hide 831 */ Conversations()832 private Conversations() { 833 } 834 835 /** 836 * The {@code content://} style URL for this table. 837 */ 838 public static final Uri CONTENT_URI = Uri.parse("content://sms/conversations"); 839 840 /** 841 * The default sort order for this table. 842 */ 843 public static final String DEFAULT_SORT_ORDER = "date DESC"; 844 845 /** 846 * The first 45 characters of the body of the most recent message. 847 * <P>Type: TEXT</P> 848 */ 849 public static final String SNIPPET = "snippet"; 850 851 /** 852 * The number of messages in the conversation. 853 * <P>Type: INTEGER</P> 854 */ 855 public static final String MESSAGE_COUNT = "msg_count"; 856 } 857 858 /** 859 * Contains constants for SMS related Intents that are broadcast. 860 */ 861 public static final class Intents { 862 863 /** 864 * Not instantiable. 865 * @hide 866 */ Intents()867 private Intents() { 868 } 869 870 /** 871 * Set by BroadcastReceiver to indicate that the message was handled 872 * successfully. 873 */ 874 public static final int RESULT_SMS_HANDLED = 1; 875 876 /** 877 * Set by BroadcastReceiver to indicate a generic error while 878 * processing the message. 879 */ 880 public static final int RESULT_SMS_GENERIC_ERROR = 2; 881 882 /** 883 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate 884 * insufficient memory to store the message. 885 */ 886 public static final int RESULT_SMS_OUT_OF_MEMORY = 3; 887 888 /** 889 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate that 890 * the message, while possibly valid, is of a format or encoding that is not supported. 891 */ 892 public static final int RESULT_SMS_UNSUPPORTED = 4; 893 894 /** 895 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate a 896 * duplicate incoming message. 897 */ 898 public static final int RESULT_SMS_DUPLICATED = 5; 899 900 /** 901 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate a 902 * dispatch failure. 903 */ 904 public static final int RESULT_SMS_DISPATCH_FAILURE = 6; 905 906 /** 907 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate a null 908 * PDU was received. 909 */ 910 public static final int RESULT_SMS_NULL_PDU = 7; 911 912 /** 913 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate a null 914 * message was encountered. 915 */ 916 public static final int RESULT_SMS_NULL_MESSAGE = 8; 917 918 /** 919 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate an sms 920 * was received while the phone was in encrypted state. 921 */ 922 public static final int RESULT_SMS_RECEIVED_WHILE_ENCRYPTED = 9; 923 924 /** 925 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate a 926 * telephony database error. 927 */ 928 public static final int RESULT_SMS_DATABASE_ERROR = 10; 929 930 /** 931 * Set as a "result" extra in the {@link #SMS_REJECTED_ACTION} intent to indicate an 932 * invalid uri. 933 */ 934 public static final int RESULT_SMS_INVALID_URI = 11; 935 936 /** 937 * Activity action: Ask the user to change the default 938 * SMS application. This will show a dialog that asks the 939 * user whether they want to replace the current default 940 * SMS application with the one specified in 941 * {@link #EXTRA_PACKAGE_NAME}. 942 * <p> 943 * This is no longer supported since Q, please use 944 * {@link android.app.role.RoleManager#createRequestRoleIntent(String)} with 945 * {@link android.app.role.RoleManager#ROLE_SMS} instead. 946 */ 947 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 948 public static final String ACTION_CHANGE_DEFAULT = 949 "android.provider.Telephony.ACTION_CHANGE_DEFAULT"; 950 951 /** 952 * The PackageName string passed in as an 953 * extra for {@link #ACTION_CHANGE_DEFAULT} 954 * 955 * @see #ACTION_CHANGE_DEFAULT 956 * <p> 957 * This is no longer supported since Q, please use 958 * {@link android.app.role.RoleManager#createRequestRoleIntent(String)} with 959 * {@link android.app.role.RoleManager#ROLE_SMS} instead. 960 */ 961 public static final String EXTRA_PACKAGE_NAME = "package"; 962 963 /** 964 * Broadcast Action: A new text-based SMS message has been received 965 * by the device. This intent will only be delivered to the default 966 * sms app. That app is responsible for writing the message and notifying 967 * the user. The intent will have the following extra values:</p> 968 * 969 * <ul> 970 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs 971 * that make up the message.</li> 972 * <li><em>"format"</em> - A String describing the format of the PDUs. It can 973 * be either "3gpp" or "3gpp2".</li> 974 * <li><em>"subscription"</em> - An optional long value of the subscription id which 975 * received the message.</li> 976 * <li><em>"slot"</em> - An optional int value of the SIM slot containing the 977 * subscription.</li> 978 * <li><em>"phone"</em> - An optional int value of the phone id associated with the 979 * subscription.</li> 980 * <li><em>"errorCode"</em> - An optional int error code associated with receiving 981 * the message.</li> 982 * </ul> 983 * 984 * <p>The extra values can be extracted using 985 * {@link #getMessagesFromIntent(Intent)}.</p> 986 * 987 * <p>If a BroadcastReceiver encounters an error while processing 988 * this intent it should set the result code appropriately.</p> 989 * 990 * <p class="note"><strong>Note:</strong> 991 * The broadcast receiver that filters for this intent must declare 992 * {@link android.Manifest.permission#BROADCAST_SMS} as a required permission in 993 * the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code 994 * <receiver>}</a> tag. 995 * 996 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p> 997 */ 998 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 999 public static final String SMS_DELIVER_ACTION = 1000 "android.provider.Telephony.SMS_DELIVER"; 1001 1002 /** 1003 * Broadcast Action: A new text-based SMS message has been received 1004 * by the device. This intent will be delivered to all registered 1005 * receivers as a notification. These apps are not expected to write the 1006 * message or notify the user. The intent will have the following extra 1007 * values:</p> 1008 * 1009 * <ul> 1010 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs 1011 * that make up the message.</li> 1012 * </ul> 1013 * 1014 * <p>The extra values can be extracted using 1015 * {@link #getMessagesFromIntent(Intent)}.</p> 1016 * 1017 * <p>If a BroadcastReceiver encounters an error while processing 1018 * this intent it should set the result code appropriately.</p> 1019 * 1020 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p> 1021 */ 1022 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1023 public static final String SMS_RECEIVED_ACTION = 1024 "android.provider.Telephony.SMS_RECEIVED"; 1025 1026 /** 1027 * Broadcast Action: A new data based SMS message has been received 1028 * by the device. This intent will be delivered to all registered 1029 * receivers as a notification. The intent will have the following extra 1030 * values:</p> 1031 * 1032 * <ul> 1033 * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs 1034 * that make up the message.</li> 1035 * </ul> 1036 * 1037 * <p>The extra values can be extracted using 1038 * {@link #getMessagesFromIntent(Intent)}.</p> 1039 * 1040 * <p>If a BroadcastReceiver encounters an error while processing 1041 * this intent it should set the result code appropriately.</p> 1042 * 1043 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p> 1044 */ 1045 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1046 public static final String DATA_SMS_RECEIVED_ACTION = 1047 "android.intent.action.DATA_SMS_RECEIVED"; 1048 1049 /** 1050 * Broadcast Action: A new WAP PUSH message has been received by the 1051 * device. This intent will only be delivered to the default 1052 * sms app. That app is responsible for writing the message and notifying 1053 * the user. The intent will have the following extra values:</p> 1054 * 1055 * <ul> 1056 * <li><em>"transactionId"</em> - (Integer) The WAP transaction ID</li> 1057 * <li><em>"pduType"</em> - (Integer) The WAP PDU type</li> 1058 * <li><em>"header"</em> - (byte[]) The header of the message</li> 1059 * <li><em>"data"</em> - (byte[]) The data payload of the message</li> 1060 * <li><em>"contentTypeParameters" </em> 1061 * -(HashMap<String,String>) Any parameters associated with the content type 1062 * (decoded from the WSP Content-Type header)</li> 1063 * <li><em>"subscription"</em> - An optional long value of the subscription id which 1064 * received the message.</li> 1065 * <li><em>"slot"</em> - An optional int value of the SIM slot containing the 1066 * subscription.</li> 1067 * <li><em>"phone"</em> - An optional int value of the phone id associated with the 1068 * subscription.</li> 1069 * </ul> 1070 * 1071 * <p>If a BroadcastReceiver encounters an error while processing 1072 * this intent it should set the result code appropriately.</p> 1073 * 1074 * <p>The contentTypeParameters extra value is map of content parameters keyed by 1075 * their names.</p> 1076 * 1077 * <p>If any unassigned well-known parameters are encountered, the key of the map will 1078 * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter. If 1079 * a parameter has No-Value the value in the map will be null.</p> 1080 * 1081 * <p>Requires {@link android.Manifest.permission#RECEIVE_MMS} or 1082 * {@link android.Manifest.permission#RECEIVE_WAP_PUSH} (depending on WAP PUSH type) to 1083 * receive.</p> 1084 * 1085 * <p class="note"><strong>Note:</strong> 1086 * The broadcast receiver that filters for this intent must declare 1087 * {@link android.Manifest.permission#BROADCAST_WAP_PUSH} as a required permission in 1088 * the <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code 1089 * <receiver>}</a> tag. 1090 */ 1091 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1092 public static final String WAP_PUSH_DELIVER_ACTION = 1093 "android.provider.Telephony.WAP_PUSH_DELIVER"; 1094 1095 /** 1096 * Broadcast Action: A new WAP PUSH message has been received by the 1097 * device. This intent will be delivered to all registered 1098 * receivers as a notification. These apps are not expected to write the 1099 * message or notify the user. The intent will have the following extra 1100 * values:</p> 1101 * 1102 * <ul> 1103 * <li><em>"transactionId"</em> - (Integer) The WAP transaction ID</li> 1104 * <li><em>"pduType"</em> - (Integer) The WAP PDU type</li> 1105 * <li><em>"header"</em> - (byte[]) The header of the message</li> 1106 * <li><em>"data"</em> - (byte[]) The data payload of the message</li> 1107 * <li><em>"contentTypeParameters"</em> 1108 * - (HashMap<String,String>) Any parameters associated with the content type 1109 * (decoded from the WSP Content-Type header)</li> 1110 * </ul> 1111 * 1112 * <p>If a BroadcastReceiver encounters an error while processing 1113 * this intent it should set the result code appropriately.</p> 1114 * 1115 * <p>The contentTypeParameters extra value is map of content parameters keyed by 1116 * their names.</p> 1117 * 1118 * <p>If any unassigned well-known parameters are encountered, the key of the map will 1119 * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter. If 1120 * a parameter has No-Value the value in the map will be null.</p> 1121 * 1122 * <p>Requires {@link android.Manifest.permission#RECEIVE_MMS} or 1123 * {@link android.Manifest.permission#RECEIVE_WAP_PUSH} (depending on WAP PUSH type) to 1124 * receive.</p> 1125 */ 1126 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1127 public static final String WAP_PUSH_RECEIVED_ACTION = 1128 "android.provider.Telephony.WAP_PUSH_RECEIVED"; 1129 1130 /** 1131 * Broadcast Action: A new Cell Broadcast message has been received 1132 * by the device. The intent will have the following extra 1133 * values:</p> 1134 * 1135 * <ul> 1136 * <li><em>"message"</em> - An SmsCbMessage object containing the broadcast message 1137 * data. This is not an emergency alert, so ETWS and CMAS data will be null.</li> 1138 * </ul> 1139 * 1140 * <p>The extra values can be extracted using 1141 * {@link #getMessagesFromIntent(Intent)}.</p> 1142 * 1143 * <p>If a BroadcastReceiver encounters an error while processing 1144 * this intent it should set the result code appropriately.</p> 1145 * 1146 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p> 1147 */ 1148 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1149 public static final String SMS_CB_RECEIVED_ACTION = 1150 "android.provider.Telephony.SMS_CB_RECEIVED"; 1151 1152 /** 1153 * Action: A SMS based carrier provision intent. Used to identify default 1154 * carrier provisioning app on the device. 1155 * @hide 1156 */ 1157 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1158 @TestApi 1159 public static final String SMS_CARRIER_PROVISION_ACTION = 1160 "android.provider.Telephony.SMS_CARRIER_PROVISION"; 1161 1162 /** 1163 * Broadcast Action: A new Emergency Broadcast message has been received 1164 * by the device. The intent will have the following extra 1165 * values:</p> 1166 * 1167 * <ul> 1168 * <li><em>"message"</em> - An {@link android.telephony.SmsCbMessage} object 1169 * containing the broadcast message data, including ETWS or CMAS warning notification 1170 * info if present.</li> 1171 * </ul> 1172 * 1173 * <p>The extra values can be extracted using 1174 * {@link #getMessagesFromIntent(Intent)}.</p> 1175 * 1176 * <p>If a BroadcastReceiver encounters an error while processing 1177 * this intent it should set the result code appropriately.</p> 1178 * 1179 * <p>Requires {@link android.Manifest.permission#RECEIVE_EMERGENCY_BROADCAST} to 1180 * receive.</p> 1181 * @hide 1182 */ 1183 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1184 @SystemApi 1185 public static final String ACTION_SMS_EMERGENCY_CB_RECEIVED = 1186 "android.provider.action.SMS_EMERGENCY_CB_RECEIVED"; 1187 1188 /** 1189 * Broadcast Action: A new CDMA SMS has been received containing Service Category 1190 * Program Data (updates the list of enabled broadcast channels). The intent will 1191 * have the following extra values:</p> 1192 * 1193 * <ul> 1194 * <li><em>"operations"</em> - An array of CdmaSmsCbProgramData objects containing 1195 * the service category operations (add/delete/clear) to perform.</li> 1196 * </ul> 1197 * 1198 * <p>The extra values can be extracted using 1199 * {@link #getMessagesFromIntent(Intent)}.</p> 1200 * 1201 * <p>If a BroadcastReceiver encounters an error while processing 1202 * this intent it should set the result code appropriately.</p> 1203 * 1204 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p> 1205 */ 1206 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1207 public static final String SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION = 1208 "android.provider.Telephony.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED"; 1209 1210 /** 1211 * Broadcast Action: The SIM storage for SMS messages is full. If 1212 * space is not freed, messages targeted for the SIM (class 2) may 1213 * not be saved. 1214 * 1215 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p> 1216 */ 1217 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1218 public static final String SIM_FULL_ACTION = 1219 "android.provider.Telephony.SIM_FULL"; 1220 1221 /** 1222 * Broadcast Action: An incoming SMS has been rejected by the 1223 * telephony framework. This intent is sent in lieu of any 1224 * of the RECEIVED_ACTION intents. The intent will have the 1225 * following extra value:</p> 1226 * 1227 * <ul> 1228 * <li><em>"result"</em> - An int result code, e.g. {@link #RESULT_SMS_OUT_OF_MEMORY} 1229 * indicating the error returned to the network.</li> 1230 * </ul> 1231 * 1232 * <p>Requires {@link android.Manifest.permission#RECEIVE_SMS} to receive.</p> 1233 */ 1234 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1235 public static final String SMS_REJECTED_ACTION = 1236 "android.provider.Telephony.SMS_REJECTED"; 1237 1238 /** 1239 * Broadcast Action: An incoming MMS has been downloaded. The intent is sent to all 1240 * users, except for secondary users where SMS has been disabled and to managed 1241 * profiles. 1242 * @hide 1243 */ 1244 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1245 public static final String MMS_DOWNLOADED_ACTION = 1246 "android.provider.Telephony.MMS_DOWNLOADED"; 1247 1248 /** 1249 * Broadcast Action: A debug code has been entered in the dialer. This intent is 1250 * broadcast by the system and OEM telephony apps may need to receive these broadcasts. 1251 * These "secret codes" are used to activate developer menus by dialing certain codes. 1252 * And they are of the form {@code *#*#<code>#*#*}. The intent will have the data 1253 * URI: {@code android_secret_code://<code>}. It is possible that a manifest 1254 * receiver would be woken up even if it is not currently running. 1255 * 1256 * <p>Requires {@code android.Manifest.permission#CONTROL_INCALL_EXPERIENCE} to 1257 * send and receive.</p> 1258 * @deprecated it is no longer supported, use {@link 1259 * TelephonyManager#ACTION_SECRET_CODE} instead 1260 */ 1261 @Deprecated 1262 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1263 public static final String SECRET_CODE_ACTION = 1264 "android.provider.Telephony.SECRET_CODE"; 1265 1266 /** 1267 * Broadcast action: When the default SMS package changes, 1268 * the previous default SMS package and the new default SMS 1269 * package are sent this broadcast to notify them of the change. 1270 * A boolean is specified in {@link #EXTRA_IS_DEFAULT_SMS_APP} to 1271 * indicate whether the package is the new default SMS package. 1272 */ 1273 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1274 public static final String ACTION_DEFAULT_SMS_PACKAGE_CHANGED = 1275 "android.provider.action.DEFAULT_SMS_PACKAGE_CHANGED"; 1276 1277 /** 1278 * The IsDefaultSmsApp boolean passed as an 1279 * extra for {@link #ACTION_DEFAULT_SMS_PACKAGE_CHANGED} to indicate whether the 1280 * SMS app is becoming the default SMS app or is no longer the default. 1281 * 1282 * @see #ACTION_DEFAULT_SMS_PACKAGE_CHANGED 1283 */ 1284 public static final String EXTRA_IS_DEFAULT_SMS_APP = 1285 "android.provider.extra.IS_DEFAULT_SMS_APP"; 1286 1287 /** 1288 * Broadcast action: When a change is made to the SmsProvider or 1289 * MmsProvider by a process other than the default SMS application, 1290 * this intent is broadcast to the default SMS application so it can 1291 * re-sync or update the change. The uri that was used to call the provider 1292 * can be retrieved from the intent with getData(). The actual affected uris 1293 * (which would depend on the selection specified) are not included. 1294 */ 1295 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1296 public static final String ACTION_EXTERNAL_PROVIDER_CHANGE = 1297 "android.provider.action.EXTERNAL_PROVIDER_CHANGE"; 1298 1299 /** 1300 * Broadcast action: When SMS-MMS db is being created. If file-based encryption is 1301 * supported, this broadcast indicates creation of the db in credential-encrypted 1302 * storage. A boolean is specified in {@link #EXTRA_IS_INITIAL_CREATE} to indicate if 1303 * this is the initial create of the db. 1304 * 1305 * @see #EXTRA_IS_INITIAL_CREATE 1306 * 1307 * @hide 1308 */ 1309 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1310 public static final String ACTION_SMS_MMS_DB_CREATED = 1311 "android.provider.action.SMS_MMS_DB_CREATED"; 1312 1313 /** 1314 * Boolean flag passed as an extra with {@link #ACTION_SMS_MMS_DB_CREATED} to indicate 1315 * whether the DB creation is the initial creation on the device, that is it is after a 1316 * factory-data reset or a new device. Any subsequent creations of the DB (which 1317 * happens only in error scenarios) will have this flag set to false. 1318 * 1319 * @see #ACTION_SMS_MMS_DB_CREATED 1320 * 1321 * @hide 1322 */ 1323 public static final String EXTRA_IS_INITIAL_CREATE = 1324 "android.provider.extra.IS_INITIAL_CREATE"; 1325 1326 /** 1327 * Broadcast intent action indicating that the telephony provider SMS MMS database is 1328 * corrupted. A boolean is specified in {@link #EXTRA_IS_CORRUPTED} to indicate if the 1329 * database is corrupted. Requires the 1330 * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE permission. 1331 * 1332 * @hide 1333 */ 1334 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1335 public static final String ACTION_SMS_MMS_DB_LOST = 1336 "android.provider.action.SMS_MMS_DB_LOST"; 1337 1338 /** 1339 * Boolean flag passed as an extra with {@link #ACTION_SMS_MMS_DB_LOST} to indicate 1340 * whether the DB got corrupted or not. 1341 * 1342 * @see #ACTION_SMS_MMS_DB_LOST 1343 * 1344 * @hide 1345 */ 1346 public static final String EXTRA_IS_CORRUPTED = 1347 "android.provider.extra.IS_CORRUPTED"; 1348 1349 /** 1350 * Read the PDUs out of an {@link #SMS_RECEIVED_ACTION} or a 1351 * {@link #DATA_SMS_RECEIVED_ACTION} intent. 1352 * 1353 * @param intent the intent to read from 1354 * @return an array of SmsMessages for the PDUs 1355 */ getMessagesFromIntent(Intent intent)1356 public static SmsMessage[] getMessagesFromIntent(Intent intent) { 1357 Object[] messages; 1358 try { 1359 messages = (Object[]) intent.getSerializableExtra("pdus"); 1360 } 1361 catch (ClassCastException e) { 1362 Rlog.e(TAG, "getMessagesFromIntent: " + e); 1363 return null; 1364 } 1365 1366 if (messages == null) { 1367 Rlog.e(TAG, "pdus does not exist in the intent"); 1368 return null; 1369 } 1370 1371 String format = intent.getStringExtra("format"); 1372 int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, 1373 SubscriptionManager.getDefaultSmsSubscriptionId()); 1374 1375 Rlog.v(TAG, " getMessagesFromIntent sub_id : " + subId); 1376 1377 int pduCount = messages.length; 1378 SmsMessage[] msgs = new SmsMessage[pduCount]; 1379 1380 for (int i = 0; i < pduCount; i++) { 1381 byte[] pdu = (byte[]) messages[i]; 1382 msgs[i] = SmsMessage.createFromPdu(pdu, format); 1383 } 1384 return msgs; 1385 } 1386 } 1387 } 1388 1389 /** 1390 * Base column for the table that contain Carrier Public key. 1391 * @hide 1392 */ 1393 public interface CarrierColumns extends BaseColumns { 1394 1395 /** 1396 * Mobile Country Code (MCC). 1397 * <P> Type: TEXT </P> 1398 */ 1399 public static final String MCC = "mcc"; 1400 1401 /** 1402 * Mobile Network Code (MNC). 1403 * <P> Type: TEXT </P> 1404 */ 1405 public static final String MNC = "mnc"; 1406 1407 /** 1408 * KeyType whether the key is being used for WLAN or ePDG. 1409 * <P> Type: INTEGER </P> 1410 */ 1411 public static final String KEY_TYPE = "key_type"; 1412 1413 /** 1414 * MVNO type: 1415 * {@code SPN (Service Provider Name), IMSI, GID (Group Identifier Level 1)}. 1416 * <P> Type: TEXT </P> 1417 */ 1418 public static final String MVNO_TYPE = "mvno_type"; 1419 1420 /** 1421 * MVNO data. 1422 * Use the following examples. 1423 * <ul> 1424 * <li>SPN: A MOBILE, BEN NL, ...</li> 1425 * <li>IMSI: 302720x94, 2060188, ...</li> 1426 * <li>GID: 4E, 33, ...</li> 1427 * </ul> 1428 * <P> Type: TEXT </P> 1429 */ 1430 public static final String MVNO_MATCH_DATA = "mvno_match_data"; 1431 1432 /** 1433 * The carrier public key that is used for the IMSI encryption. 1434 * <P> Type: TEXT </P> 1435 */ 1436 public static final String PUBLIC_KEY = "public_key"; 1437 1438 /** 1439 * The key identifier Attribute value pair that helps a server locate 1440 * the private key to decrypt the permanent identity. 1441 * <P> Type: TEXT </P> 1442 */ 1443 public static final String KEY_IDENTIFIER = "key_identifier"; 1444 1445 /** 1446 * Date-Time in UTC when the key will expire. 1447 * <P> Type: INTEGER (long) </P> 1448 */ 1449 public static final String EXPIRATION_TIME = "expiration_time"; 1450 1451 /** 1452 * Timestamp when this table was last modified, in milliseconds since 1453 * January 1, 1970 00:00:00.0 UTC. 1454 * <P> Type: INTEGER (long) </P> 1455 */ 1456 public static final String LAST_MODIFIED = "last_modified"; 1457 1458 /** 1459 * The {@code content://} style URL for this table. 1460 */ 1461 @NonNull 1462 public static final Uri CONTENT_URI = Uri.parse("content://carrier_information/carrier"); 1463 } 1464 1465 /** 1466 * Base columns for tables that contain MMSs. 1467 */ 1468 public interface BaseMmsColumns extends BaseColumns { 1469 1470 /** Message box: all messages. */ 1471 public static final int MESSAGE_BOX_ALL = 0; 1472 /** Message box: inbox. */ 1473 public static final int MESSAGE_BOX_INBOX = 1; 1474 /** Message box: sent messages. */ 1475 public static final int MESSAGE_BOX_SENT = 2; 1476 /** Message box: drafts. */ 1477 public static final int MESSAGE_BOX_DRAFTS = 3; 1478 /** Message box: outbox. */ 1479 public static final int MESSAGE_BOX_OUTBOX = 4; 1480 /** Message box: failed. */ 1481 public static final int MESSAGE_BOX_FAILED = 5; 1482 1483 /** 1484 * The thread ID of the message. 1485 * <P>Type: INTEGER (long)</P> 1486 */ 1487 public static final String THREAD_ID = "thread_id"; 1488 1489 /** 1490 * The date the message was received. 1491 * <P>Type: INTEGER (long)</P> 1492 */ 1493 public static final String DATE = "date"; 1494 1495 /** 1496 * The date the message was sent. 1497 * <P>Type: INTEGER (long)</P> 1498 */ 1499 public static final String DATE_SENT = "date_sent"; 1500 1501 /** 1502 * The box which the message belongs to, e.g. {@link #MESSAGE_BOX_INBOX}. 1503 * <P>Type: INTEGER</P> 1504 */ 1505 public static final String MESSAGE_BOX = "msg_box"; 1506 1507 /** 1508 * Has the message been read? 1509 * <P>Type: INTEGER (boolean)</P> 1510 */ 1511 public static final String READ = "read"; 1512 1513 /** 1514 * Has the message been seen by the user? The "seen" flag determines 1515 * whether we need to show a new message notification. 1516 * <P>Type: INTEGER (boolean)</P> 1517 */ 1518 public static final String SEEN = "seen"; 1519 1520 /** 1521 * Does the message have only a text part (can also have a subject) with 1522 * no picture, slideshow, sound, etc. parts? 1523 * <P>Type: INTEGER (boolean)</P> 1524 */ 1525 public static final String TEXT_ONLY = "text_only"; 1526 1527 /** 1528 * The {@code Message-ID} of the message. 1529 * <P>Type: TEXT</P> 1530 */ 1531 public static final String MESSAGE_ID = "m_id"; 1532 1533 /** 1534 * The subject of the message, if present. 1535 * <P>Type: TEXT</P> 1536 */ 1537 public static final String SUBJECT = "sub"; 1538 1539 /** 1540 * The character set of the subject, if present. 1541 * <P>Type: INTEGER</P> 1542 */ 1543 public static final String SUBJECT_CHARSET = "sub_cs"; 1544 1545 /** 1546 * The {@code Content-Type} of the message. 1547 * <P>Type: TEXT</P> 1548 */ 1549 public static final String CONTENT_TYPE = "ct_t"; 1550 1551 /** 1552 * The {@code Content-Location} of the message. 1553 * <P>Type: TEXT</P> 1554 */ 1555 public static final String CONTENT_LOCATION = "ct_l"; 1556 1557 /** 1558 * The expiry time of the message. 1559 * <P>Type: INTEGER (long)</P> 1560 */ 1561 public static final String EXPIRY = "exp"; 1562 1563 /** 1564 * The class of the message. 1565 * <P>Type: TEXT</P> 1566 */ 1567 public static final String MESSAGE_CLASS = "m_cls"; 1568 1569 /** 1570 * The type of the message defined by MMS spec. 1571 * <P>Type: INTEGER</P> 1572 */ 1573 public static final String MESSAGE_TYPE = "m_type"; 1574 1575 /** 1576 * The version of the specification that this message conforms to. 1577 * <P>Type: INTEGER</P> 1578 */ 1579 public static final String MMS_VERSION = "v"; 1580 1581 /** 1582 * The size of the message. 1583 * <P>Type: INTEGER</P> 1584 */ 1585 public static final String MESSAGE_SIZE = "m_size"; 1586 1587 /** 1588 * The priority of the message. 1589 * <P>Type: INTEGER</P> 1590 */ 1591 public static final String PRIORITY = "pri"; 1592 1593 /** 1594 * The {@code read-report} of the message. 1595 * <P>Type: INTEGER (boolean)</P> 1596 */ 1597 public static final String READ_REPORT = "rr"; 1598 1599 /** 1600 * Is read report allowed? 1601 * <P>Type: INTEGER (boolean)</P> 1602 */ 1603 public static final String REPORT_ALLOWED = "rpt_a"; 1604 1605 /** 1606 * The {@code response-status} of the message. 1607 * <P>Type: INTEGER</P> 1608 */ 1609 public static final String RESPONSE_STATUS = "resp_st"; 1610 1611 /** 1612 * The {@code status} of the message. 1613 * <P>Type: INTEGER</P> 1614 */ 1615 public static final String STATUS = "st"; 1616 1617 /** 1618 * The {@code transaction-id} of the message. 1619 * <P>Type: TEXT</P> 1620 */ 1621 public static final String TRANSACTION_ID = "tr_id"; 1622 1623 /** 1624 * The {@code retrieve-status} of the message. 1625 * <P>Type: INTEGER</P> 1626 */ 1627 public static final String RETRIEVE_STATUS = "retr_st"; 1628 1629 /** 1630 * The {@code retrieve-text} of the message. 1631 * <P>Type: TEXT</P> 1632 */ 1633 public static final String RETRIEVE_TEXT = "retr_txt"; 1634 1635 /** 1636 * The character set of the retrieve-text. 1637 * <P>Type: INTEGER</P> 1638 */ 1639 public static final String RETRIEVE_TEXT_CHARSET = "retr_txt_cs"; 1640 1641 /** 1642 * The {@code read-status} of the message. 1643 * <P>Type: INTEGER</P> 1644 */ 1645 public static final String READ_STATUS = "read_status"; 1646 1647 /** 1648 * The {@code content-class} of the message. 1649 * <P>Type: INTEGER</P> 1650 */ 1651 public static final String CONTENT_CLASS = "ct_cls"; 1652 1653 /** 1654 * The {@code delivery-report} of the message. 1655 * <P>Type: INTEGER</P> 1656 */ 1657 public static final String DELIVERY_REPORT = "d_rpt"; 1658 1659 /** 1660 * The {@code delivery-time-token} of the message. 1661 * <P>Type: INTEGER</P> 1662 * @deprecated this column is no longer supported. 1663 * @hide 1664 */ 1665 @Deprecated 1666 public static final String DELIVERY_TIME_TOKEN = "d_tm_tok"; 1667 1668 /** 1669 * The {@code delivery-time} of the message. 1670 * <P>Type: INTEGER</P> 1671 */ 1672 public static final String DELIVERY_TIME = "d_tm"; 1673 1674 /** 1675 * The {@code response-text} of the message. 1676 * <P>Type: TEXT</P> 1677 */ 1678 public static final String RESPONSE_TEXT = "resp_txt"; 1679 1680 /** 1681 * The {@code sender-visibility} of the message. 1682 * <P>Type: TEXT</P> 1683 * @deprecated this column is no longer supported. 1684 * @hide 1685 */ 1686 @Deprecated 1687 public static final String SENDER_VISIBILITY = "s_vis"; 1688 1689 /** 1690 * The {@code reply-charging} of the message. 1691 * <P>Type: INTEGER</P> 1692 * @deprecated this column is no longer supported. 1693 * @hide 1694 */ 1695 @Deprecated 1696 public static final String REPLY_CHARGING = "r_chg"; 1697 1698 /** 1699 * The {@code reply-charging-deadline-token} of the message. 1700 * <P>Type: INTEGER</P> 1701 * @deprecated this column is no longer supported. 1702 * @hide 1703 */ 1704 @Deprecated 1705 public static final String REPLY_CHARGING_DEADLINE_TOKEN = "r_chg_dl_tok"; 1706 1707 /** 1708 * The {@code reply-charging-deadline} of the message. 1709 * <P>Type: INTEGER</P> 1710 * @deprecated this column is no longer supported. 1711 * @hide 1712 */ 1713 @Deprecated 1714 public static final String REPLY_CHARGING_DEADLINE = "r_chg_dl"; 1715 1716 /** 1717 * The {@code reply-charging-id} of the message. 1718 * <P>Type: TEXT</P> 1719 * @deprecated this column is no longer supported. 1720 * @hide 1721 */ 1722 @Deprecated 1723 public static final String REPLY_CHARGING_ID = "r_chg_id"; 1724 1725 /** 1726 * The {@code reply-charging-size} of the message. 1727 * <P>Type: INTEGER</P> 1728 * @deprecated this column is no longer supported. 1729 * @hide 1730 */ 1731 @Deprecated 1732 public static final String REPLY_CHARGING_SIZE = "r_chg_sz"; 1733 1734 /** 1735 * The {@code previously-sent-by} of the message. 1736 * <P>Type: TEXT</P> 1737 * @deprecated this column is no longer supported. 1738 * @hide 1739 */ 1740 @Deprecated 1741 public static final String PREVIOUSLY_SENT_BY = "p_s_by"; 1742 1743 /** 1744 * The {@code previously-sent-date} of the message. 1745 * <P>Type: INTEGER</P> 1746 * @deprecated this column is no longer supported. 1747 * @hide 1748 */ 1749 @Deprecated 1750 public static final String PREVIOUSLY_SENT_DATE = "p_s_d"; 1751 1752 /** 1753 * The {@code store} of the message. 1754 * <P>Type: TEXT</P> 1755 * @deprecated this column is no longer supported. 1756 * @hide 1757 */ 1758 @Deprecated 1759 public static final String STORE = "store"; 1760 1761 /** 1762 * The {@code mm-state} of the message. 1763 * <P>Type: INTEGER</P> 1764 * @deprecated this column is no longer supported. 1765 * @hide 1766 */ 1767 @Deprecated 1768 public static final String MM_STATE = "mm_st"; 1769 1770 /** 1771 * The {@code mm-flags-token} of the message. 1772 * <P>Type: INTEGER</P> 1773 * @deprecated this column is no longer supported. 1774 * @hide 1775 */ 1776 @Deprecated 1777 public static final String MM_FLAGS_TOKEN = "mm_flg_tok"; 1778 1779 /** 1780 * The {@code mm-flags} of the message. 1781 * <P>Type: TEXT</P> 1782 * @deprecated this column is no longer supported. 1783 * @hide 1784 */ 1785 @Deprecated 1786 public static final String MM_FLAGS = "mm_flg"; 1787 1788 /** 1789 * The {@code store-status} of the message. 1790 * <P>Type: TEXT</P> 1791 * @deprecated this column is no longer supported. 1792 * @hide 1793 */ 1794 @Deprecated 1795 public static final String STORE_STATUS = "store_st"; 1796 1797 /** 1798 * The {@code store-status-text} of the message. 1799 * <P>Type: TEXT</P> 1800 * @deprecated this column is no longer supported. 1801 * @hide 1802 */ 1803 @Deprecated 1804 public static final String STORE_STATUS_TEXT = "store_st_txt"; 1805 1806 /** 1807 * The {@code stored} of the message. 1808 * <P>Type: TEXT</P> 1809 * @deprecated this column is no longer supported. 1810 * @hide 1811 */ 1812 @Deprecated 1813 public static final String STORED = "stored"; 1814 1815 /** 1816 * The {@code totals} of the message. 1817 * <P>Type: TEXT</P> 1818 * @deprecated this column is no longer supported. 1819 * @hide 1820 */ 1821 @Deprecated 1822 public static final String TOTALS = "totals"; 1823 1824 /** 1825 * The {@code mbox-totals} of the message. 1826 * <P>Type: TEXT</P> 1827 * @deprecated this column is no longer supported. 1828 * @hide 1829 */ 1830 @Deprecated 1831 public static final String MBOX_TOTALS = "mb_t"; 1832 1833 /** 1834 * The {@code mbox-totals-token} of the message. 1835 * <P>Type: INTEGER</P> 1836 * @deprecated this column is no longer supported. 1837 * @hide 1838 */ 1839 @Deprecated 1840 public static final String MBOX_TOTALS_TOKEN = "mb_t_tok"; 1841 1842 /** 1843 * The {@code quotas} of the message. 1844 * <P>Type: TEXT</P> 1845 * @deprecated this column is no longer supported. 1846 * @hide 1847 */ 1848 @Deprecated 1849 public static final String QUOTAS = "qt"; 1850 1851 /** 1852 * The {@code mbox-quotas} of the message. 1853 * <P>Type: TEXT</P> 1854 * @deprecated this column is no longer supported. 1855 * @hide 1856 */ 1857 @Deprecated 1858 public static final String MBOX_QUOTAS = "mb_qt"; 1859 1860 /** 1861 * The {@code mbox-quotas-token} of the message. 1862 * <P>Type: INTEGER</P> 1863 * @deprecated this column is no longer supported. 1864 * @hide 1865 */ 1866 @Deprecated 1867 public static final String MBOX_QUOTAS_TOKEN = "mb_qt_tok"; 1868 1869 /** 1870 * The {@code message-count} of the message. 1871 * <P>Type: INTEGER</P> 1872 * @deprecated this column is no longer supported. 1873 * @hide 1874 */ 1875 @Deprecated 1876 public static final String MESSAGE_COUNT = "m_cnt"; 1877 1878 /** 1879 * The {@code start} of the message. 1880 * <P>Type: INTEGER</P> 1881 * @deprecated this column is no longer supported. 1882 * @hide 1883 */ 1884 @Deprecated 1885 public static final String START = "start"; 1886 1887 /** 1888 * The {@code distribution-indicator} of the message. 1889 * <P>Type: TEXT</P> 1890 * @deprecated this column is no longer supported. 1891 * @hide 1892 */ 1893 @Deprecated 1894 public static final String DISTRIBUTION_INDICATOR = "d_ind"; 1895 1896 /** 1897 * The {@code element-descriptor} of the message. 1898 * <P>Type: TEXT</P> 1899 * @deprecated this column is no longer supported. 1900 * @hide 1901 */ 1902 @Deprecated 1903 public static final String ELEMENT_DESCRIPTOR = "e_des"; 1904 1905 /** 1906 * The {@code limit} of the message. 1907 * <P>Type: INTEGER</P> 1908 * @deprecated this column is no longer supported. 1909 * @hide 1910 */ 1911 @Deprecated 1912 public static final String LIMIT = "limit"; 1913 1914 /** 1915 * The {@code recommended-retrieval-mode} of the message. 1916 * <P>Type: INTEGER</P> 1917 * @deprecated this column is no longer supported. 1918 * @hide 1919 */ 1920 @Deprecated 1921 public static final String RECOMMENDED_RETRIEVAL_MODE = "r_r_mod"; 1922 1923 /** 1924 * The {@code recommended-retrieval-mode-text} of the message. 1925 * <P>Type: TEXT</P> 1926 * @deprecated this column is no longer supported. 1927 * @hide 1928 */ 1929 @Deprecated 1930 public static final String RECOMMENDED_RETRIEVAL_MODE_TEXT = "r_r_mod_txt"; 1931 1932 /** 1933 * The {@code status-text} of the message. 1934 * <P>Type: TEXT</P> 1935 * @deprecated this column is no longer supported. 1936 * @hide 1937 */ 1938 @Deprecated 1939 public static final String STATUS_TEXT = "st_txt"; 1940 1941 /** 1942 * The {@code applic-id} of the message. 1943 * <P>Type: TEXT</P> 1944 * @deprecated this column is no longer supported. 1945 * @hide 1946 */ 1947 @Deprecated 1948 public static final String APPLIC_ID = "apl_id"; 1949 1950 /** 1951 * The {@code reply-applic-id} of the message. 1952 * <P>Type: TEXT</P> 1953 * @deprecated this column is no longer supported. 1954 * @hide 1955 */ 1956 @Deprecated 1957 public static final String REPLY_APPLIC_ID = "r_apl_id"; 1958 1959 /** 1960 * The {@code aux-applic-id} of the message. 1961 * <P>Type: TEXT</P> 1962 * @deprecated this column is no longer supported. 1963 * @hide 1964 */ 1965 @Deprecated 1966 public static final String AUX_APPLIC_ID = "aux_apl_id"; 1967 1968 /** 1969 * The {@code drm-content} of the message. 1970 * <P>Type: TEXT</P> 1971 * @deprecated this column is no longer supported. 1972 * @hide 1973 */ 1974 @Deprecated 1975 public static final String DRM_CONTENT = "drm_c"; 1976 1977 /** 1978 * The {@code adaptation-allowed} of the message. 1979 * <P>Type: TEXT</P> 1980 * @deprecated this column is no longer supported. 1981 * @hide 1982 */ 1983 @Deprecated 1984 public static final String ADAPTATION_ALLOWED = "adp_a"; 1985 1986 /** 1987 * The {@code replace-id} of the message. 1988 * <P>Type: TEXT</P> 1989 * @deprecated this column is no longer supported. 1990 * @hide 1991 */ 1992 @Deprecated 1993 public static final String REPLACE_ID = "repl_id"; 1994 1995 /** 1996 * The {@code cancel-id} of the message. 1997 * <P>Type: TEXT</P> 1998 * @deprecated this column is no longer supported. 1999 * @hide 2000 */ 2001 @Deprecated 2002 public static final String CANCEL_ID = "cl_id"; 2003 2004 /** 2005 * The {@code cancel-status} of the message. 2006 * <P>Type: INTEGER</P> 2007 * @deprecated this column is no longer supported. 2008 * @hide 2009 */ 2010 @Deprecated 2011 public static final String CANCEL_STATUS = "cl_st"; 2012 2013 /** 2014 * Is the message locked? 2015 * <P>Type: INTEGER (boolean)</P> 2016 */ 2017 public static final String LOCKED = "locked"; 2018 2019 /** 2020 * The subscription to which the message belongs to. Its value will be 2021 * < 0 if the sub id cannot be determined. 2022 * <p>Type: INTEGER (long)</p> 2023 */ 2024 public static final String SUBSCRIPTION_ID = "sub_id"; 2025 2026 /** 2027 * The identity of the sender of a sent message. It is 2028 * usually the package name of the app which sends the message. 2029 * <p class="note"><strong>Note:</strong> 2030 * This column is read-only. It is set by the provider and can not be changed by apps. 2031 * <p>Type: TEXT</p> 2032 */ 2033 public static final String CREATOR = "creator"; 2034 } 2035 2036 /** 2037 * Columns for the "canonical_addresses" table used by MMS and SMS. 2038 */ 2039 public interface CanonicalAddressesColumns extends BaseColumns { 2040 /** 2041 * An address used in MMS or SMS. Email addresses are 2042 * converted to lower case and are compared by string 2043 * equality. Other addresses are compared using 2044 * PHONE_NUMBERS_EQUAL. 2045 * <P>Type: TEXT</P> 2046 */ 2047 public static final String ADDRESS = "address"; 2048 } 2049 2050 /** 2051 * Columns for the "threads" table used by MMS and SMS. 2052 */ 2053 public interface ThreadsColumns extends BaseColumns { 2054 2055 /** 2056 * The date at which the thread was created. 2057 * <P>Type: INTEGER (long)</P> 2058 */ 2059 public static final String DATE = "date"; 2060 2061 /** 2062 * A string encoding of the recipient IDs of the recipients of 2063 * the message, in numerical order and separated by spaces. 2064 * <P>Type: TEXT</P> 2065 */ 2066 public static final String RECIPIENT_IDS = "recipient_ids"; 2067 2068 /** 2069 * The message count of the thread. 2070 * <P>Type: INTEGER</P> 2071 */ 2072 public static final String MESSAGE_COUNT = "message_count"; 2073 2074 /** 2075 * Indicates whether all messages of the thread have been read. 2076 * <P>Type: INTEGER</P> 2077 */ 2078 public static final String READ = "read"; 2079 2080 /** 2081 * The snippet of the latest message in the thread. 2082 * <P>Type: TEXT</P> 2083 */ 2084 public static final String SNIPPET = "snippet"; 2085 2086 /** 2087 * The charset of the snippet. 2088 * <P>Type: INTEGER</P> 2089 */ 2090 public static final String SNIPPET_CHARSET = "snippet_cs"; 2091 2092 /** 2093 * Type of the thread, either {@link Threads#COMMON_THREAD} or 2094 * {@link Threads#BROADCAST_THREAD}. 2095 * <P>Type: INTEGER</P> 2096 */ 2097 public static final String TYPE = "type"; 2098 2099 /** 2100 * Indicates whether there is a transmission error in the thread. 2101 * <P>Type: INTEGER</P> 2102 */ 2103 public static final String ERROR = "error"; 2104 2105 /** 2106 * Indicates whether this thread contains any attachments. 2107 * <P>Type: INTEGER</P> 2108 */ 2109 public static final String HAS_ATTACHMENT = "has_attachment"; 2110 2111 /** 2112 * If the thread is archived 2113 * <P>Type: INTEGER (boolean)</P> 2114 */ 2115 public static final String ARCHIVED = "archived"; 2116 } 2117 2118 /** 2119 * Helper functions for the "threads" table used by MMS and SMS. 2120 * 2121 * Thread IDs are determined by the participants in a conversation and can be used to match 2122 * both SMS and MMS messages. 2123 * 2124 * To avoid issues where applications might cache a thread ID, the thread ID of a deleted thread 2125 * must not be reused to point at a new thread. 2126 */ 2127 public static final class Threads implements ThreadsColumns { 2128 2129 @UnsupportedAppUsage 2130 private static final String[] ID_PROJECTION = { BaseColumns._ID }; 2131 2132 /** 2133 * Private {@code content://} style URL for this table. Used by 2134 * {@link #getOrCreateThreadId(android.content.Context, java.util.Set)}. 2135 */ 2136 @UnsupportedAppUsage 2137 private static final Uri THREAD_ID_CONTENT_URI = Uri.parse( 2138 "content://mms-sms/threadID"); 2139 2140 /** 2141 * The {@code content://} style URL for this table, by conversation. 2142 */ 2143 public static final Uri CONTENT_URI = Uri.withAppendedPath( 2144 MmsSms.CONTENT_URI, "conversations"); 2145 2146 /** 2147 * The {@code content://} style URL for this table, for obsolete threads. 2148 */ 2149 public static final Uri OBSOLETE_THREADS_URI = Uri.withAppendedPath( 2150 CONTENT_URI, "obsolete"); 2151 2152 /** Thread type: common thread. */ 2153 public static final int COMMON_THREAD = 0; 2154 2155 /** Thread type: broadcast thread. */ 2156 public static final int BROADCAST_THREAD = 1; 2157 2158 /** 2159 * Not instantiable. 2160 * @hide 2161 */ Threads()2162 private Threads() { 2163 } 2164 2165 /** 2166 * This is a single-recipient version of {@code getOrCreateThreadId}. 2167 * It's convenient for use with SMS messages. 2168 * @param context the context object to use. 2169 * @param recipient the recipient to send to. 2170 */ getOrCreateThreadId(Context context, String recipient)2171 public static long getOrCreateThreadId(Context context, String recipient) { 2172 Set<String> recipients = new HashSet<String>(); 2173 2174 recipients.add(recipient); 2175 return getOrCreateThreadId(context, recipients); 2176 } 2177 2178 /** 2179 * Given a set of recipients return its thread ID. 2180 * <p> 2181 * If a thread exists containing the provided participants, return its thread ID. Otherwise, 2182 * this will create a new thread containing the provided participants and return its ID. 2183 */ getOrCreateThreadId( Context context, Set<String> recipients)2184 public static long getOrCreateThreadId( 2185 Context context, Set<String> recipients) { 2186 Uri.Builder uriBuilder = THREAD_ID_CONTENT_URI.buildUpon(); 2187 2188 for (String recipient : recipients) { 2189 if (Mms.isEmailAddress(recipient)) { 2190 recipient = Mms.extractAddrSpec(recipient); 2191 } 2192 2193 uriBuilder.appendQueryParameter("recipient", recipient); 2194 } 2195 2196 Uri uri = uriBuilder.build(); 2197 //if (DEBUG) Rlog.v(TAG, "getOrCreateThreadId uri: " + uri); 2198 2199 Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(), 2200 uri, ID_PROJECTION, null, null, null); 2201 if (cursor != null) { 2202 try { 2203 if (cursor.moveToFirst()) { 2204 return cursor.getLong(0); 2205 } else { 2206 Rlog.e(TAG, "getOrCreateThreadId returned no rows!"); 2207 } 2208 } finally { 2209 cursor.close(); 2210 } 2211 } 2212 2213 Rlog.e(TAG, "getOrCreateThreadId failed with " + recipients.size() + " recipients"); 2214 throw new IllegalArgumentException("Unable to find or allocate a thread ID."); 2215 } 2216 } 2217 2218 /** 2219 * Columns for the "rcs_*" tables used by {@link android.telephony.ims.RcsMessageStore} classes. 2220 * 2221 * @hide - not meant for public use 2222 */ 2223 public interface RcsColumns { 2224 // TODO(sahinc): Turn this to true once the schema finalizes, so that people can update 2225 // their messaging databases. NOTE: move the switch/case update in MmsSmsDatabaseHelper to 2226 // the latest version of the database before turning this flag to true. 2227 boolean IS_RCS_TABLE_SCHEMA_CODE_COMPLETE = false; 2228 2229 /** 2230 * The authority for the content provider 2231 */ 2232 String AUTHORITY = "rcs"; 2233 2234 /** 2235 * The URI to start building upon to use {@link com.android.providers.telephony.RcsProvider} 2236 */ 2237 Uri CONTENT_AND_AUTHORITY = Uri.parse("content://" + AUTHORITY); 2238 2239 /** 2240 * The value to be used whenever a transaction that expects an integer to be returned 2241 * failed. 2242 */ 2243 int TRANSACTION_FAILED = Integer.MIN_VALUE; 2244 2245 /** 2246 * The value that denotes a timestamp was not set before (e.g. a message that is not 2247 * delivered yet will not have a DELIVERED_TIMESTAMP) 2248 */ 2249 long TIMESTAMP_NOT_SET = 0; 2250 2251 /** 2252 * The table that {@link android.telephony.ims.RcsThread} gets persisted to 2253 */ 2254 interface RcsThreadColumns { 2255 /** 2256 * The path that should be used for referring to 2257 * {@link android.telephony.ims.RcsThread}s in 2258 * {@link com.android.providers.telephony.RcsProvider} URIs. 2259 */ 2260 String RCS_THREAD_URI_PART = "thread"; 2261 2262 /** 2263 * The URI to query or modify {@link android.telephony.ims.RcsThread} via the content 2264 * provider. 2265 */ 2266 Uri RCS_THREAD_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY, RCS_THREAD_URI_PART); 2267 2268 /** 2269 * The unique identifier of an {@link android.telephony.ims.RcsThread} 2270 */ 2271 String RCS_THREAD_ID_COLUMN = "rcs_thread_id"; 2272 } 2273 2274 /** 2275 * The table that {@link android.telephony.ims.Rcs1To1Thread} gets persisted to 2276 */ 2277 interface Rcs1To1ThreadColumns extends RcsThreadColumns { 2278 /** 2279 * The path that should be used for referring to 2280 * {@link android.telephony.ims.Rcs1To1Thread}s in 2281 * {@link com.android.providers.telephony.RcsProvider} URIs. 2282 */ 2283 String RCS_1_TO_1_THREAD_URI_PART = "p2p_thread"; 2284 2285 /** 2286 * The URI to query or modify {@link android.telephony.ims.Rcs1To1Thread}s via the 2287 * content provider. Can also insert to this URI to create a new 1-to-1 thread. When 2288 * performing an insert, ensure that the provided content values contain the other 2289 * participant's ID under the key 2290 * {@link RcsParticipantColumns.RCS_PARTICIPANT_ID_COLUMN} 2291 */ 2292 Uri RCS_1_TO_1_THREAD_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY, 2293 RCS_1_TO_1_THREAD_URI_PART); 2294 2295 /** 2296 * The SMS/MMS thread to fallback to in case of an RCS outage 2297 */ 2298 String FALLBACK_THREAD_ID_COLUMN = "rcs_fallback_thread_id"; 2299 } 2300 2301 /** 2302 * The table that {@link android.telephony.ims.RcsGroupThread} gets persisted to 2303 */ 2304 interface RcsGroupThreadColumns extends RcsThreadColumns { 2305 /** 2306 * The path that should be used for referring to 2307 * {@link android.telephony.ims.RcsGroupThread}s in 2308 * {@link com.android.providers.telephony.RcsProvider} URIs. 2309 */ 2310 String RCS_GROUP_THREAD_URI_PART = "group_thread"; 2311 2312 /** 2313 * The URI to query or modify {@link android.telephony.ims.RcsGroupThread}s via the 2314 * content provider 2315 */ 2316 Uri RCS_GROUP_THREAD_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY, 2317 RCS_GROUP_THREAD_URI_PART); 2318 2319 /** 2320 * The owner/admin of the {@link android.telephony.ims.RcsGroupThread} 2321 */ 2322 String OWNER_PARTICIPANT_COLUMN = "owner_participant"; 2323 2324 /** 2325 * The user visible name of the group 2326 */ 2327 String GROUP_NAME_COLUMN = "group_name"; 2328 2329 /** 2330 * The user visible icon of the group 2331 */ 2332 String GROUP_ICON_COLUMN = "group_icon"; 2333 2334 /** 2335 * The RCS conference URI for this group 2336 */ 2337 String CONFERENCE_URI_COLUMN = "conference_uri"; 2338 } 2339 2340 /** 2341 * The view that enables polling from all types of RCS threads at once 2342 */ 2343 interface RcsUnifiedThreadColumns extends RcsThreadColumns, Rcs1To1ThreadColumns, 2344 RcsGroupThreadColumns { 2345 /** 2346 * The type of this {@link android.telephony.ims.RcsThread} 2347 */ 2348 String THREAD_TYPE_COLUMN = "thread_type"; 2349 2350 /** 2351 * Integer returned as a result from a database query that denotes the thread is 1 to 1 2352 */ 2353 int THREAD_TYPE_1_TO_1 = 0; 2354 2355 /** 2356 * Integer returned as a result from a database query that denotes the thread is 1 to 1 2357 */ 2358 int THREAD_TYPE_GROUP = 1; 2359 } 2360 2361 /** 2362 * The table that {@link android.telephony.ims.RcsParticipant} gets persisted to 2363 */ 2364 interface RcsParticipantColumns { 2365 /** 2366 * The path that should be used for referring to 2367 * {@link android.telephony.ims.RcsParticipant}s in 2368 * {@link com.android.providers.telephony.RcsProvider} URIs. 2369 */ 2370 String RCS_PARTICIPANT_URI_PART = "participant"; 2371 2372 /** 2373 * The URI to query or modify {@link android.telephony.ims.RcsParticipant}s via the 2374 * content provider 2375 */ 2376 Uri RCS_PARTICIPANT_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY, 2377 RCS_PARTICIPANT_URI_PART); 2378 2379 /** 2380 * The unique identifier of the entry in the database 2381 */ 2382 String RCS_PARTICIPANT_ID_COLUMN = "rcs_participant_id"; 2383 2384 /** 2385 * A foreign key on canonical_address table, also used by SMS/MMS 2386 */ 2387 String CANONICAL_ADDRESS_ID_COLUMN = "canonical_address_id"; 2388 2389 /** 2390 * The user visible RCS alias for this participant. 2391 */ 2392 String RCS_ALIAS_COLUMN = "rcs_alias"; 2393 } 2394 2395 /** 2396 * Additional constants to enable access to {@link android.telephony.ims.RcsParticipant} 2397 * related data 2398 */ 2399 interface RcsParticipantHelpers extends RcsParticipantColumns { 2400 /** 2401 * The view that unifies "rcs_participant" and "canonical_addresses" tables for easy 2402 * access to participant address. 2403 */ 2404 String RCS_PARTICIPANT_WITH_ADDRESS_VIEW = "rcs_participant_with_address_view"; 2405 2406 /** 2407 * The view that unifies "rcs_participant", "canonical_addresses" and 2408 * "rcs_thread_participant" junction table to get full information on participants that 2409 * contribute to threads. 2410 */ 2411 String RCS_PARTICIPANT_WITH_THREAD_VIEW = "rcs_participant_with_thread_view"; 2412 } 2413 2414 /** 2415 * The table that {@link android.telephony.ims.RcsMessage} gets persisted to 2416 */ 2417 interface RcsMessageColumns { 2418 /** 2419 * Denotes the type of this message (i.e. 2420 * {@link android.telephony.ims.RcsIncomingMessage} or 2421 * {@link android.telephony.ims.RcsOutgoingMessage} 2422 */ 2423 String MESSAGE_TYPE_COLUMN = "rcs_message_type"; 2424 2425 /** 2426 * The unique identifier for the message in the database - i.e. the primary key. 2427 */ 2428 String MESSAGE_ID_COLUMN = "rcs_message_row_id"; 2429 2430 /** 2431 * The globally unique RCS identifier for the message. Please see 4.4.5.2 - GSMA 2432 * RCC.53 (RCS Device API 1.6 Specification) 2433 */ 2434 String GLOBAL_ID_COLUMN = "rcs_message_global_id"; 2435 2436 /** 2437 * The subscription where this message was sent from/to. 2438 */ 2439 String SUB_ID_COLUMN = "sub_id"; 2440 2441 /** 2442 * The sending status of the message. 2443 * @see android.telephony.ims.RcsMessage.RcsMessageStatus 2444 */ 2445 String STATUS_COLUMN = "status"; 2446 2447 /** 2448 * The creation timestamp of the message. 2449 */ 2450 String ORIGINATION_TIMESTAMP_COLUMN = "origination_timestamp"; 2451 2452 /** 2453 * The text content of the message. 2454 */ 2455 String MESSAGE_TEXT_COLUMN = "rcs_text"; 2456 2457 /** 2458 * The latitude content of the message, if it contains a location. 2459 */ 2460 String LATITUDE_COLUMN = "latitude"; 2461 2462 /** 2463 * The longitude content of the message, if it contains a location. 2464 */ 2465 String LONGITUDE_COLUMN = "longitude"; 2466 } 2467 2468 /** 2469 * The table that additional information of {@link android.telephony.ims.RcsIncomingMessage} 2470 * gets persisted to. 2471 */ 2472 interface RcsIncomingMessageColumns extends RcsMessageColumns { 2473 /** 2474 The path that should be used for referring to 2475 * {@link android.telephony.ims.RcsIncomingMessage}s in 2476 * {@link com.android.providers.telephony.RcsProvider} URIs. 2477 */ 2478 String INCOMING_MESSAGE_URI_PART = "incoming_message"; 2479 2480 /** 2481 * The URI to query incoming messages through 2482 * {@link com.android.providers.telephony.RcsProvider} 2483 */ 2484 Uri INCOMING_MESSAGE_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY, 2485 INCOMING_MESSAGE_URI_PART); 2486 2487 /** 2488 * The ID of the {@link android.telephony.ims.RcsParticipant} that sent this message 2489 */ 2490 String SENDER_PARTICIPANT_ID_COLUMN = "sender_participant"; 2491 2492 /** 2493 * The timestamp of arrival for this message. 2494 */ 2495 String ARRIVAL_TIMESTAMP_COLUMN = "arrival_timestamp"; 2496 2497 /** 2498 * The time when the recipient has read this message. 2499 */ 2500 String SEEN_TIMESTAMP_COLUMN = "seen_timestamp"; 2501 } 2502 2503 /** 2504 * The table that additional information of {@link android.telephony.ims.RcsOutgoingMessage} 2505 * gets persisted to. 2506 */ 2507 interface RcsOutgoingMessageColumns extends RcsMessageColumns { 2508 /** 2509 * The path that should be used for referring to 2510 * {@link android.telephony.ims.RcsOutgoingMessage}s in 2511 * {@link com.android.providers.telephony.RcsProvider} URIs. 2512 */ 2513 String OUTGOING_MESSAGE_URI_PART = "outgoing_message"; 2514 2515 /** 2516 * The URI to query or modify {@link android.telephony.ims.RcsOutgoingMessage}s via the 2517 * content provider 2518 */ 2519 Uri OUTGOING_MESSAGE_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY, 2520 OUTGOING_MESSAGE_URI_PART); 2521 } 2522 2523 /** 2524 * The delivery information of an {@link android.telephony.ims.RcsOutgoingMessage} 2525 */ 2526 interface RcsMessageDeliveryColumns extends RcsOutgoingMessageColumns { 2527 /** 2528 * The path that should be used for referring to 2529 * {@link android.telephony.ims.RcsOutgoingMessageDelivery}s in 2530 * {@link com.android.providers.telephony.RcsProvider} URIs. 2531 */ 2532 String DELIVERY_URI_PART = "delivery"; 2533 2534 /** 2535 * The timestamp of delivery of this message. 2536 */ 2537 String DELIVERED_TIMESTAMP_COLUMN = "delivered_timestamp"; 2538 2539 /** 2540 * The time when the recipient has read this message. 2541 */ 2542 String SEEN_TIMESTAMP_COLUMN = "seen_timestamp"; 2543 } 2544 2545 /** 2546 * The views that allow querying {@link android.telephony.ims.RcsIncomingMessage} and 2547 * {@link android.telephony.ims.RcsOutgoingMessage} at the same time. 2548 */ 2549 interface RcsUnifiedMessageColumns extends RcsIncomingMessageColumns, 2550 RcsOutgoingMessageColumns { 2551 /** 2552 * The path that is used to query all {@link android.telephony.ims.RcsMessage} in 2553 * {@link com.android.providers.telephony.RcsProvider} URIs. 2554 */ 2555 String UNIFIED_MESSAGE_URI_PART = "message"; 2556 2557 /** 2558 * The URI to query all types of {@link android.telephony.ims.RcsMessage}s 2559 */ 2560 Uri UNIFIED_MESSAGE_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY, 2561 UNIFIED_MESSAGE_URI_PART); 2562 2563 /** 2564 * The name of the view that unites rcs_message and rcs_incoming_message tables. 2565 */ 2566 String UNIFIED_INCOMING_MESSAGE_VIEW = "unified_incoming_message_view"; 2567 2568 /** 2569 * The name of the view that unites rcs_message and rcs_outgoing_message tables. 2570 */ 2571 String UNIFIED_OUTGOING_MESSAGE_VIEW = "unified_outgoing_message_view"; 2572 2573 /** 2574 * The column that shows from which table the message entry came from. 2575 */ 2576 String MESSAGE_TYPE_COLUMN = "message_type"; 2577 2578 /** 2579 * Integer returned as a result from a database query that denotes that the message is 2580 * an incoming message 2581 */ 2582 int MESSAGE_TYPE_INCOMING = 1; 2583 2584 /** 2585 * Integer returned as a result from a database query that denotes that the message is 2586 * an outgoing message 2587 */ 2588 int MESSAGE_TYPE_OUTGOING = 0; 2589 } 2590 2591 /** 2592 * The table that {@link android.telephony.ims.RcsFileTransferPart} gets persisted to. 2593 */ 2594 interface RcsFileTransferColumns { 2595 /** 2596 * The path that should be used for referring to 2597 * {@link android.telephony.ims.RcsFileTransferPart}s in 2598 * {@link com.android.providers.telephony.RcsProvider} URIs. 2599 */ 2600 String FILE_TRANSFER_URI_PART = "file_transfer"; 2601 2602 /** 2603 * The URI to query or modify {@link android.telephony.ims.RcsFileTransferPart}s via the 2604 * content provider 2605 */ 2606 Uri FILE_TRANSFER_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY, 2607 FILE_TRANSFER_URI_PART); 2608 2609 /** 2610 * The globally unique file transfer ID for this RCS file transfer. 2611 */ 2612 String FILE_TRANSFER_ID_COLUMN = "rcs_file_transfer_id"; 2613 2614 /** 2615 * The RCS session ID for this file transfer. The ID is implementation dependent but 2616 * should be unique. 2617 */ 2618 String SESSION_ID_COLUMN = "session_id"; 2619 2620 /** 2621 * The URI that points to the content of this file transfer 2622 */ 2623 String CONTENT_URI_COLUMN = "content_uri"; 2624 2625 /** 2626 * The file type of this file transfer in bytes. The validity of types is not enforced 2627 * in {@link android.telephony.ims.RcsMessageStore} APIs. 2628 */ 2629 String CONTENT_TYPE_COLUMN = "content_type"; 2630 2631 /** 2632 * The size of the file transfer in bytes. 2633 */ 2634 String FILE_SIZE_COLUMN = "file_size"; 2635 2636 /** 2637 * Number of bytes that was successfully transmitted for this file transfer 2638 */ 2639 String SUCCESSFULLY_TRANSFERRED_BYTES = "transfer_offset"; 2640 2641 /** 2642 * The status of this file transfer 2643 * @see android.telephony.ims.RcsFileTransferPart.RcsFileTransferStatus 2644 */ 2645 String TRANSFER_STATUS_COLUMN = "transfer_status"; 2646 2647 /** 2648 * The on-screen width of the file transfer, if it contains multi-media 2649 */ 2650 String WIDTH_COLUMN = "width"; 2651 2652 /** 2653 * The on-screen height of the file transfer, if it contains multi-media 2654 */ 2655 String HEIGHT_COLUMN = "height"; 2656 2657 /** 2658 * The duration of the content in milliseconds if this file transfer contains 2659 * multi-media 2660 */ 2661 String DURATION_MILLIS_COLUMN = "duration"; 2662 2663 /** 2664 * The URI to the preview of the content of this file transfer 2665 */ 2666 String PREVIEW_URI_COLUMN = "preview_uri"; 2667 2668 /** 2669 * The type of the preview of the content of this file transfer. The validity of types 2670 * is not enforced in {@link android.telephony.ims.RcsMessageStore} APIs. 2671 */ 2672 String PREVIEW_TYPE_COLUMN = "preview_type"; 2673 } 2674 2675 /** 2676 * The table that holds the information for 2677 * {@link android.telephony.ims.RcsGroupThreadEvent} and its subclasses. 2678 */ 2679 interface RcsThreadEventColumns { 2680 /** 2681 * The string used in the {@link com.android.providers.telephony.RcsProvider} URI to 2682 * refer to participant joined events (example URI: 2683 * {@code content://rcs/group_thread/3/participant_joined_event}) 2684 */ 2685 String PARTICIPANT_JOINED_URI_PART = "participant_joined_event"; 2686 2687 /** 2688 * The string used in the {@link com.android.providers.telephony.RcsProvider} URI to 2689 * refer to participant left events. (example URI: 2690 * {@code content://rcs/group_thread/3/participant_left_event/4}) 2691 */ 2692 String PARTICIPANT_LEFT_URI_PART = "participant_left_event"; 2693 2694 /** 2695 * The string used in the {@link com.android.providers.telephony.RcsProvider} URI to 2696 * refer to name changed events. (example URI: 2697 * {@code content://rcs/group_thread/3/name_changed_event}) 2698 */ 2699 String NAME_CHANGED_URI_PART = "name_changed_event"; 2700 2701 /** 2702 * The string used in the {@link com.android.providers.telephony.RcsProvider} URI to 2703 * refer to icon changed events. (example URI: 2704 * {@code content://rcs/group_thread/3/icon_changed_event}) 2705 */ 2706 String ICON_CHANGED_URI_PART = "icon_changed_event"; 2707 2708 /** 2709 * The unique ID of this event in the database, i.e. the primary key 2710 */ 2711 String EVENT_ID_COLUMN = "event_id"; 2712 2713 /** 2714 * The type of this event 2715 * 2716 * @see RcsEventTypes 2717 */ 2718 String EVENT_TYPE_COLUMN = "event_type"; 2719 2720 /** 2721 * The timestamp in milliseconds of when this event happened 2722 */ 2723 String TIMESTAMP_COLUMN = "origination_timestamp"; 2724 2725 /** 2726 * The participant that generated this event 2727 */ 2728 String SOURCE_PARTICIPANT_ID_COLUMN = "source_participant"; 2729 2730 /** 2731 * The receiving participant of this event if this was an 2732 * {@link android.telephony.ims.RcsGroupThreadParticipantJoinedEvent} or 2733 * {@link android.telephony.ims.RcsGroupThreadParticipantLeftEvent} 2734 */ 2735 String DESTINATION_PARTICIPANT_ID_COLUMN = "destination_participant"; 2736 2737 /** 2738 * The URI for the new icon of the group thread if this was an 2739 * {@link android.telephony.ims.RcsGroupThreadIconChangedEvent} 2740 */ 2741 String NEW_ICON_URI_COLUMN = "new_icon_uri"; 2742 2743 /** 2744 * The URI for the new name of the group thread if this was an 2745 * {@link android.telephony.ims.RcsGroupThreadNameChangedEvent} 2746 */ 2747 String NEW_NAME_COLUMN = "new_name"; 2748 } 2749 2750 /** 2751 * The table that {@link android.telephony.ims.RcsParticipantAliasChangedEvent} gets 2752 * persisted to 2753 */ 2754 interface RcsParticipantEventColumns { 2755 /** 2756 * The path that should be used for referring to 2757 * {@link android.telephony.ims.RcsParticipantAliasChangedEvent}s in 2758 * {@link com.android.providers.telephony.RcsProvider} URIs. 2759 */ 2760 String ALIAS_CHANGE_EVENT_URI_PART = "alias_change_event"; 2761 2762 /** 2763 * The new alias of the participant 2764 */ 2765 String NEW_ALIAS_COLUMN = "new_alias"; 2766 } 2767 2768 /** 2769 * These values are used in {@link com.android.providers.telephony.RcsProvider} to determine 2770 * what kind of event is present in the storage. 2771 */ 2772 interface RcsEventTypes { 2773 /** 2774 * Integer constant that is stored in the 2775 * {@link com.android.providers.telephony.RcsProvider} database that denotes the event 2776 * is of type {@link android.telephony.ims.RcsParticipantAliasChangedEvent} 2777 */ 2778 int PARTICIPANT_ALIAS_CHANGED_EVENT_TYPE = 1; 2779 2780 /** 2781 * Integer constant that is stored in the 2782 * {@link com.android.providers.telephony.RcsProvider} database that denotes the event 2783 * is of type {@link android.telephony.ims.RcsGroupThreadParticipantJoinedEvent} 2784 */ 2785 int PARTICIPANT_JOINED_EVENT_TYPE = 2; 2786 2787 /** 2788 * Integer constant that is stored in the 2789 * {@link com.android.providers.telephony.RcsProvider} database that denotes the event 2790 * is of type {@link android.telephony.ims.RcsGroupThreadParticipantLeftEvent} 2791 */ 2792 int PARTICIPANT_LEFT_EVENT_TYPE = 4; 2793 2794 /** 2795 * Integer constant that is stored in the 2796 * {@link com.android.providers.telephony.RcsProvider} database that denotes the event 2797 * is of type {@link android.telephony.ims.RcsGroupThreadIconChangedEvent} 2798 */ 2799 int ICON_CHANGED_EVENT_TYPE = 8; 2800 2801 /** 2802 * Integer constant that is stored in the 2803 * {@link com.android.providers.telephony.RcsProvider} database that denotes the event 2804 * is of type {@link android.telephony.ims.RcsGroupThreadNameChangedEvent} 2805 */ 2806 int NAME_CHANGED_EVENT_TYPE = 16; 2807 } 2808 2809 /** 2810 * The view that allows unified querying across all events 2811 */ 2812 interface RcsUnifiedEventHelper extends RcsParticipantEventColumns, RcsThreadEventColumns { 2813 /** 2814 * The path that should be used for referring to 2815 * {@link android.telephony.ims.RcsEvent}s in 2816 * {@link com.android.providers.telephony.RcsProvider} URIs. 2817 */ 2818 String RCS_EVENT_QUERY_URI_PATH = "event"; 2819 2820 /** 2821 * The URI to query {@link android.telephony.ims.RcsEvent}s via the content provider. 2822 */ 2823 Uri RCS_EVENT_QUERY_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY, 2824 RCS_EVENT_QUERY_URI_PATH); 2825 } 2826 2827 /** 2828 * Allows RCS specific canonical address handling. 2829 */ 2830 interface RcsCanonicalAddressHelper { 2831 /** 2832 * Returns the canonical address ID for a canonical address, if now row exists, this 2833 * will add a row and return its ID. This helper works against the same table used by 2834 * the SMS and MMS threads, but is accessible only by the phone process for use by RCS 2835 * message storage. 2836 * 2837 * @throws IllegalArgumentException if unable to retrieve or create the canonical 2838 * address entry. 2839 */ getOrCreateCanonicalAddressId( ContentResolver contentResolver, String canonicalAddress)2840 static long getOrCreateCanonicalAddressId( 2841 ContentResolver contentResolver, String canonicalAddress) { 2842 2843 Uri.Builder uriBuilder = CONTENT_AND_AUTHORITY.buildUpon(); 2844 uriBuilder.appendPath("canonical-address"); 2845 uriBuilder.appendQueryParameter("address", canonicalAddress); 2846 Uri uri = uriBuilder.build(); 2847 2848 try (Cursor cursor = contentResolver.query(uri, null, null, null)) { 2849 if (cursor != null && cursor.moveToFirst()) { 2850 return cursor.getLong(cursor.getColumnIndex(CanonicalAddressesColumns._ID)); 2851 } else { 2852 Rlog.e(TAG, "getOrCreateCanonicalAddressId returned no rows"); 2853 } 2854 } 2855 2856 Rlog.e(TAG, "getOrCreateCanonicalAddressId failed"); 2857 throw new IllegalArgumentException( 2858 "Unable to find or allocate a canonical address ID"); 2859 } 2860 } 2861 } 2862 2863 /** 2864 * Contains all MMS messages. 2865 */ 2866 public static final class Mms implements BaseMmsColumns { 2867 2868 /** 2869 * Not instantiable. 2870 * @hide 2871 */ Mms()2872 private Mms() { 2873 } 2874 2875 /** 2876 * The {@code content://} URI for this table. 2877 */ 2878 public static final Uri CONTENT_URI = Uri.parse("content://mms"); 2879 2880 /** 2881 * Content URI for getting MMS report requests. 2882 */ 2883 public static final Uri REPORT_REQUEST_URI = Uri.withAppendedPath( 2884 CONTENT_URI, "report-request"); 2885 2886 /** 2887 * Content URI for getting MMS report status. 2888 */ 2889 public static final Uri REPORT_STATUS_URI = Uri.withAppendedPath( 2890 CONTENT_URI, "report-status"); 2891 2892 /** 2893 * The default sort order for this table. 2894 */ 2895 public static final String DEFAULT_SORT_ORDER = "date DESC"; 2896 2897 /** 2898 * Regex pattern for names and email addresses. 2899 * <ul> 2900 * <li><em>mailbox</em> = {@code name-addr}</li> 2901 * <li><em>name-addr</em> = {@code [display-name] angle-addr}</li> 2902 * <li><em>angle-addr</em> = {@code [CFWS] "<" addr-spec ">" [CFWS]}</li> 2903 * </ul> 2904 * @hide 2905 */ 2906 @UnsupportedAppUsage 2907 public static final Pattern NAME_ADDR_EMAIL_PATTERN = 2908 Pattern.compile("\\s*(\"[^\"]*\"|[^<>\"]+)\\s*<([^<>]+)>\\s*"); 2909 2910 /** 2911 * Helper method to query this table. 2912 * @hide 2913 */ query( ContentResolver cr, String[] projection)2914 public static Cursor query( 2915 ContentResolver cr, String[] projection) { 2916 return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER); 2917 } 2918 2919 /** 2920 * Helper method to query this table. 2921 * @hide 2922 */ query( ContentResolver cr, String[] projection, String where, String orderBy)2923 public static Cursor query( 2924 ContentResolver cr, String[] projection, 2925 String where, String orderBy) { 2926 return cr.query(CONTENT_URI, projection, 2927 where, null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy); 2928 } 2929 2930 /** 2931 * Helper method to extract email address from address string. 2932 * @hide 2933 */ 2934 @UnsupportedAppUsage extractAddrSpec(String address)2935 public static String extractAddrSpec(String address) { 2936 Matcher match = NAME_ADDR_EMAIL_PATTERN.matcher(address); 2937 2938 if (match.matches()) { 2939 return match.group(2); 2940 } 2941 return address; 2942 } 2943 2944 /** 2945 * Is the specified address an email address? 2946 * 2947 * @param address the input address to test 2948 * @return true if address is an email address; false otherwise. 2949 * @hide 2950 */ 2951 @UnsupportedAppUsage isEmailAddress(String address)2952 public static boolean isEmailAddress(String address) { 2953 if (TextUtils.isEmpty(address)) { 2954 return false; 2955 } 2956 2957 String s = extractAddrSpec(address); 2958 Matcher match = Patterns.EMAIL_ADDRESS.matcher(s); 2959 return match.matches(); 2960 } 2961 2962 /** 2963 * Is the specified number a phone number? 2964 * 2965 * @param number the input number to test 2966 * @return true if number is a phone number; false otherwise. 2967 * @hide 2968 */ 2969 @UnsupportedAppUsage isPhoneNumber(String number)2970 public static boolean isPhoneNumber(String number) { 2971 if (TextUtils.isEmpty(number)) { 2972 return false; 2973 } 2974 2975 Matcher match = Patterns.PHONE.matcher(number); 2976 return match.matches(); 2977 } 2978 2979 /** 2980 * Contains all MMS messages in the MMS app inbox. 2981 */ 2982 public static final class Inbox implements BaseMmsColumns { 2983 2984 /** 2985 * Not instantiable. 2986 * @hide 2987 */ Inbox()2988 private Inbox() { 2989 } 2990 2991 /** 2992 * The {@code content://} style URL for this table. 2993 */ 2994 public static final Uri 2995 CONTENT_URI = Uri.parse("content://mms/inbox"); 2996 2997 /** 2998 * The default sort order for this table. 2999 */ 3000 public static final String DEFAULT_SORT_ORDER = "date DESC"; 3001 } 3002 3003 /** 3004 * Contains all MMS messages in the MMS app sent folder. 3005 */ 3006 public static final class Sent implements BaseMmsColumns { 3007 3008 /** 3009 * Not instantiable. 3010 * @hide 3011 */ Sent()3012 private Sent() { 3013 } 3014 3015 /** 3016 * The {@code content://} style URL for this table. 3017 */ 3018 public static final Uri 3019 CONTENT_URI = Uri.parse("content://mms/sent"); 3020 3021 /** 3022 * The default sort order for this table. 3023 */ 3024 public static final String DEFAULT_SORT_ORDER = "date DESC"; 3025 } 3026 3027 /** 3028 * Contains all MMS messages in the MMS app drafts folder. 3029 */ 3030 public static final class Draft implements BaseMmsColumns { 3031 3032 /** 3033 * Not instantiable. 3034 * @hide 3035 */ Draft()3036 private Draft() { 3037 } 3038 3039 /** 3040 * The {@code content://} style URL for this table. 3041 */ 3042 public static final Uri 3043 CONTENT_URI = Uri.parse("content://mms/drafts"); 3044 3045 /** 3046 * The default sort order for this table. 3047 */ 3048 public static final String DEFAULT_SORT_ORDER = "date DESC"; 3049 } 3050 3051 /** 3052 * Contains all MMS messages in the MMS app outbox. 3053 */ 3054 public static final class Outbox implements BaseMmsColumns { 3055 3056 /** 3057 * Not instantiable. 3058 * @hide 3059 */ Outbox()3060 private Outbox() { 3061 } 3062 3063 /** 3064 * The {@code content://} style URL for this table. 3065 */ 3066 public static final Uri 3067 CONTENT_URI = Uri.parse("content://mms/outbox"); 3068 3069 /** 3070 * The default sort order for this table. 3071 */ 3072 public static final String DEFAULT_SORT_ORDER = "date DESC"; 3073 } 3074 3075 /** 3076 * Contains address information for an MMS message. 3077 */ 3078 public static final class Addr implements BaseColumns { 3079 3080 /** 3081 * Not instantiable. 3082 * @hide 3083 */ Addr()3084 private Addr() { 3085 } 3086 3087 /** 3088 * The ID of MM which this address entry belongs to. 3089 * <P>Type: INTEGER (long)</P> 3090 */ 3091 public static final String MSG_ID = "msg_id"; 3092 3093 /** 3094 * The ID of contact entry in Phone Book. 3095 * <P>Type: INTEGER (long)</P> 3096 */ 3097 public static final String CONTACT_ID = "contact_id"; 3098 3099 /** 3100 * The address text. 3101 * <P>Type: TEXT</P> 3102 */ 3103 public static final String ADDRESS = "address"; 3104 3105 /** 3106 * Type of address: must be one of {@code PduHeaders.BCC}, 3107 * {@code PduHeaders.CC}, {@code PduHeaders.FROM}, {@code PduHeaders.TO}. 3108 * <P>Type: INTEGER</P> 3109 */ 3110 public static final String TYPE = "type"; 3111 3112 /** 3113 * Character set of this entry (MMS charset value). 3114 * <P>Type: INTEGER</P> 3115 */ 3116 public static final String CHARSET = "charset"; 3117 3118 /** 3119 * Generates a Addr {@link Uri} for message, used to perform Addr table operation 3120 * for mms. 3121 * 3122 * @param messageId the messageId used to generate Addr {@link Uri} dynamically 3123 * @return the addrUri used to perform Addr table operation for mms 3124 */ 3125 @NonNull getAddrUriForMessage(@onNull String messageId)3126 public static Uri getAddrUriForMessage(@NonNull String messageId) { 3127 Uri addrUri = Mms.CONTENT_URI.buildUpon() 3128 .appendPath(String.valueOf(messageId)).appendPath("addr").build(); 3129 return addrUri; 3130 } 3131 } 3132 3133 /** 3134 * Contains message parts. 3135 * 3136 * To avoid issues where applications might cache a part ID, the ID of a deleted part must 3137 * not be reused to point at a new part. 3138 */ 3139 public static final class Part implements BaseColumns { 3140 3141 /** 3142 * Not instantiable. 3143 * @hide 3144 */ Part()3145 private Part() { 3146 } 3147 3148 /** 3149 * The name of part table. 3150 */ 3151 private static final String TABLE_PART = "part"; 3152 3153 /** 3154 * The {@code content://} style URL for this table. Can be appended with a part ID to 3155 * address individual parts. 3156 */ 3157 @NonNull 3158 public static final Uri CONTENT_URI = Uri.withAppendedPath(Mms.CONTENT_URI, TABLE_PART); 3159 3160 /** 3161 * The identifier of the message which this part belongs to. 3162 * <P>Type: INTEGER</P> 3163 */ 3164 public static final String MSG_ID = "mid"; 3165 3166 /** 3167 * The order of the part. 3168 * <P>Type: INTEGER</P> 3169 */ 3170 public static final String SEQ = "seq"; 3171 3172 /** 3173 * The content type of the part. 3174 * <P>Type: TEXT</P> 3175 */ 3176 public static final String CONTENT_TYPE = "ct"; 3177 3178 /** 3179 * The name of the part. 3180 * <P>Type: TEXT</P> 3181 */ 3182 public static final String NAME = "name"; 3183 3184 /** 3185 * The charset of the part. 3186 * <P>Type: TEXT</P> 3187 */ 3188 public static final String CHARSET = "chset"; 3189 3190 /** 3191 * The file name of the part. 3192 * <P>Type: TEXT</P> 3193 */ 3194 public static final String FILENAME = "fn"; 3195 3196 /** 3197 * The content disposition of the part. 3198 * <P>Type: TEXT</P> 3199 */ 3200 public static final String CONTENT_DISPOSITION = "cd"; 3201 3202 /** 3203 * The content ID of the part. 3204 * <P>Type: INTEGER</P> 3205 */ 3206 public static final String CONTENT_ID = "cid"; 3207 3208 /** 3209 * The content location of the part. 3210 * <P>Type: INTEGER</P> 3211 */ 3212 public static final String CONTENT_LOCATION = "cl"; 3213 3214 /** 3215 * The start of content-type of the message. 3216 * <P>Type: INTEGER</P> 3217 */ 3218 public static final String CT_START = "ctt_s"; 3219 3220 /** 3221 * The type of content-type of the message. 3222 * <P>Type: TEXT</P> 3223 */ 3224 public static final String CT_TYPE = "ctt_t"; 3225 3226 /** 3227 * The location (on filesystem) of the binary data of the part. 3228 * <P>Type: INTEGER</P> 3229 */ 3230 public static final String _DATA = "_data"; 3231 3232 /** 3233 * The message text. 3234 * <P>Type: TEXT</P> 3235 */ 3236 public static final String TEXT = "text"; 3237 3238 /** 3239 * Generates a Part {@link Uri} for message, used to perform Part table operation 3240 * for mms. 3241 * 3242 * @param messageId the messageId used to generate Part {@link Uri} dynamically 3243 * @return the partUri used to perform Part table operation for mms 3244 */ 3245 @NonNull getPartUriForMessage(@onNull String messageId)3246 public static Uri getPartUriForMessage(@NonNull String messageId) { 3247 Uri partUri = Mms.CONTENT_URI.buildUpon() 3248 .appendPath(String.valueOf(messageId)).appendPath( 3249 TABLE_PART).build(); 3250 return partUri; 3251 } 3252 } 3253 3254 /** 3255 * Message send rate table. 3256 */ 3257 public static final class Rate { 3258 3259 /** 3260 * Not instantiable. 3261 * @hide 3262 */ Rate()3263 private Rate() { 3264 } 3265 3266 /** 3267 * The {@code content://} style URL for this table. 3268 */ 3269 public static final Uri CONTENT_URI = Uri.withAppendedPath( 3270 Mms.CONTENT_URI, "rate"); 3271 3272 /** 3273 * When a message was successfully sent. 3274 * <P>Type: INTEGER (long)</P> 3275 */ 3276 public static final String SENT_TIME = "sent_time"; 3277 } 3278 3279 /** 3280 * Intents class. 3281 */ 3282 public static final class Intents { 3283 3284 /** 3285 * Not instantiable. 3286 * @hide 3287 */ Intents()3288 private Intents() { 3289 } 3290 3291 /** 3292 * Indicates that the contents of specified URIs were changed. 3293 * The application which is showing or caching these contents 3294 * should be updated. 3295 */ 3296 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3297 public static final String CONTENT_CHANGED_ACTION 3298 = "android.intent.action.CONTENT_CHANGED"; 3299 3300 /** 3301 * An extra field which stores the URI of deleted contents. 3302 */ 3303 public static final String DELETED_CONTENTS = "deleted_contents"; 3304 } 3305 } 3306 3307 /** 3308 * Contains all MMS and SMS messages. 3309 */ 3310 public static final class MmsSms implements BaseColumns { 3311 3312 /** 3313 * Not instantiable. 3314 * @hide 3315 */ MmsSms()3316 private MmsSms() { 3317 } 3318 3319 /** 3320 * The column to distinguish SMS and MMS messages in query results. 3321 */ 3322 public static final String TYPE_DISCRIMINATOR_COLUMN = 3323 "transport_type"; 3324 3325 /** 3326 * The {@code content://} style URL for this table. 3327 */ 3328 public static final Uri CONTENT_URI = Uri.parse("content://mms-sms/"); 3329 3330 /** 3331 * The {@code content://} style URL for this table, by conversation. 3332 */ 3333 public static final Uri CONTENT_CONVERSATIONS_URI = Uri.parse( 3334 "content://mms-sms/conversations"); 3335 3336 /** 3337 * The {@code content://} style URL for this table, by phone number. 3338 */ 3339 public static final Uri CONTENT_FILTER_BYPHONE_URI = Uri.parse( 3340 "content://mms-sms/messages/byphone"); 3341 3342 /** 3343 * The {@code content://} style URL for undelivered messages in this table. 3344 */ 3345 public static final Uri CONTENT_UNDELIVERED_URI = Uri.parse( 3346 "content://mms-sms/undelivered"); 3347 3348 /** 3349 * The {@code content://} style URL for draft messages in this table. 3350 */ 3351 public static final Uri CONTENT_DRAFT_URI = Uri.parse( 3352 "content://mms-sms/draft"); 3353 3354 /** 3355 * The {@code content://} style URL for locked messages in this table. 3356 * <P>This {@link Uri} is used to check at most one locked message found in the union of MMS 3357 * and SMS messages. Also this will return only _id column in response.</P> 3358 */ 3359 public static final Uri CONTENT_LOCKED_URI = Uri.parse( 3360 "content://mms-sms/locked"); 3361 3362 /** 3363 * Pass in a query parameter called "pattern" which is the text to search for. 3364 * The sort order is fixed to be: {@code thread_id ASC, date DESC}. 3365 */ 3366 public static final Uri SEARCH_URI = Uri.parse( 3367 "content://mms-sms/search"); 3368 3369 // Constants for message protocol types. 3370 3371 /** SMS protocol type. */ 3372 public static final int SMS_PROTO = 0; 3373 3374 /** MMS protocol type. */ 3375 public static final int MMS_PROTO = 1; 3376 3377 // Constants for error types of pending messages. 3378 3379 /** Error type: no error. */ 3380 public static final int NO_ERROR = 0; 3381 3382 /** Error type: generic transient error. */ 3383 public static final int ERR_TYPE_GENERIC = 1; 3384 3385 /** Error type: SMS protocol transient error. */ 3386 public static final int ERR_TYPE_SMS_PROTO_TRANSIENT = 2; 3387 3388 /** Error type: MMS protocol transient error. */ 3389 public static final int ERR_TYPE_MMS_PROTO_TRANSIENT = 3; 3390 3391 /** Error type: transport failure. */ 3392 public static final int ERR_TYPE_TRANSPORT_FAILURE = 4; 3393 3394 /** Error type: permanent error (along with all higher error values). */ 3395 public static final int ERR_TYPE_GENERIC_PERMANENT = 10; 3396 3397 /** Error type: SMS protocol permanent error. */ 3398 public static final int ERR_TYPE_SMS_PROTO_PERMANENT = 11; 3399 3400 /** Error type: MMS protocol permanent error. */ 3401 public static final int ERR_TYPE_MMS_PROTO_PERMANENT = 12; 3402 3403 /** 3404 * Contains pending messages info. 3405 */ 3406 public static final class PendingMessages implements BaseColumns { 3407 3408 /** 3409 * Not instantiable. 3410 * @hide 3411 */ PendingMessages()3412 private PendingMessages() { 3413 } 3414 3415 public static final Uri CONTENT_URI = Uri.withAppendedPath( 3416 MmsSms.CONTENT_URI, "pending"); 3417 3418 /** 3419 * The type of transport protocol (MMS or SMS). 3420 * <P>Type: INTEGER</P> 3421 */ 3422 public static final String PROTO_TYPE = "proto_type"; 3423 3424 /** 3425 * The ID of the message to be sent or downloaded. 3426 * <P>Type: INTEGER (long)</P> 3427 */ 3428 public static final String MSG_ID = "msg_id"; 3429 3430 /** 3431 * The type of the message to be sent or downloaded. 3432 * This field is only valid for MM. For SM, its value is always set to 0. 3433 * <P>Type: INTEGER</P> 3434 */ 3435 public static final String MSG_TYPE = "msg_type"; 3436 3437 /** 3438 * The type of the error code. 3439 * <P>Type: INTEGER</P> 3440 */ 3441 public static final String ERROR_TYPE = "err_type"; 3442 3443 /** 3444 * The error code of sending/retrieving process. 3445 * <P>Type: INTEGER</P> 3446 */ 3447 public static final String ERROR_CODE = "err_code"; 3448 3449 /** 3450 * How many times we tried to send or download the message. 3451 * <P>Type: INTEGER</P> 3452 */ 3453 public static final String RETRY_INDEX = "retry_index"; 3454 3455 /** 3456 * The time to do next retry. 3457 * <P>Type: INTEGER (long)</P> 3458 */ 3459 public static final String DUE_TIME = "due_time"; 3460 3461 /** 3462 * The time we last tried to send or download the message. 3463 * <P>Type: INTEGER (long)</P> 3464 */ 3465 public static final String LAST_TRY = "last_try"; 3466 3467 /** 3468 * The subscription to which the message belongs to. Its value will be 3469 * < 0 if the sub id cannot be determined. 3470 * <p>Type: INTEGER (long) </p> 3471 */ 3472 public static final String SUBSCRIPTION_ID = "pending_sub_id"; 3473 } 3474 3475 /** 3476 * Words table used by provider for full-text searches. 3477 * @hide 3478 */ 3479 public static final class WordsTable { 3480 3481 /** 3482 * Not instantiable. 3483 * @hide 3484 */ WordsTable()3485 private WordsTable() {} 3486 3487 /** 3488 * Primary key. 3489 * <P>Type: INTEGER (long)</P> 3490 */ 3491 public static final String ID = "_id"; 3492 3493 /** 3494 * Source row ID. 3495 * <P>Type: INTEGER (long)</P> 3496 */ 3497 public static final String SOURCE_ROW_ID = "source_id"; 3498 3499 /** 3500 * Table ID (either 1 or 2). 3501 * <P>Type: INTEGER</P> 3502 */ 3503 public static final String TABLE_ID = "table_to_use"; 3504 3505 /** 3506 * The words to index. 3507 * <P>Type: TEXT</P> 3508 */ 3509 public static final String INDEXED_TEXT = "index_text"; 3510 } 3511 } 3512 3513 /** 3514 * Carriers class contains information about APNs, including MMSC information. 3515 */ 3516 public static final class Carriers implements BaseColumns { 3517 3518 /** 3519 * Not instantiable. 3520 * @hide 3521 */ Carriers()3522 private Carriers() {} 3523 3524 /** 3525 * The {@code content://} style URL for this table. 3526 * For MSIM, this will return APNs for the default subscription 3527 * {@link SubscriptionManager#getDefaultSubscriptionId()}. To specify subId for MSIM, 3528 * use {@link Uri#withAppendedPath(Uri, String)} to append with subscription id. 3529 */ 3530 @NonNull 3531 public static final Uri CONTENT_URI = Uri.parse("content://telephony/carriers"); 3532 3533 /** 3534 * The {@code content://} style URL for this table. Used for APN query based on current 3535 * subscription. Instead of specifying carrier matching information in the selection, 3536 * this API will return all matching APNs from current subscription carrier and queries 3537 * will be applied on top of that. If there is no match for MVNO (Mobile Virtual Network 3538 * Operator) APNs, return APNs from its MNO (based on mccmnc) instead. For MSIM, this will 3539 * return APNs for the default subscription 3540 * {@link SubscriptionManager#getDefaultSubscriptionId()}. To specify subId for MSIM, 3541 * use {@link Uri#withAppendedPath(Uri, String)} to append with subscription id. 3542 */ 3543 @NonNull 3544 public static final Uri SIM_APN_URI = Uri.parse( 3545 "content://telephony/carriers/sim_apn_list"); 3546 3547 /** 3548 * The {@code content://} style URL to be called from DevicePolicyManagerService, 3549 * can manage DPC-owned APNs. 3550 * @hide 3551 */ 3552 public static final @NonNull Uri DPC_URI = Uri.parse("content://telephony/carriers/dpc"); 3553 3554 /** 3555 * The {@code content://} style URL to be called from Telephony to query APNs. 3556 * When DPC-owned APNs are enforced, only DPC-owned APNs are returned, otherwise only 3557 * non-DPC-owned APNs are returned. For MSIM, this will return APNs for the default 3558 * subscription {@link SubscriptionManager#getDefaultSubscriptionId()}. To specify subId 3559 * for MSIM, use {@link Uri#withAppendedPath(Uri, String)} to append with subscription id. 3560 * @hide 3561 */ 3562 public static final Uri FILTERED_URI = Uri.parse("content://telephony/carriers/filtered"); 3563 3564 /** 3565 * The {@code content://} style URL to be called from DevicePolicyManagerService 3566 * or Telephony to manage whether DPC-owned APNs are enforced. 3567 * @hide 3568 */ 3569 public static final Uri ENFORCE_MANAGED_URI = Uri.parse( 3570 "content://telephony/carriers/enforce_managed"); 3571 3572 /** 3573 * The column name for ENFORCE_MANAGED_URI, indicates whether DPC-owned APNs are enforced. 3574 * @hide 3575 */ 3576 public static final String ENFORCE_KEY = "enforced"; 3577 3578 /** 3579 * The default sort order for this table. 3580 */ 3581 public static final String DEFAULT_SORT_ORDER = "name ASC"; 3582 3583 /** 3584 * Entry name. 3585 * <P>Type: TEXT</P> 3586 */ 3587 public static final String NAME = "name"; 3588 3589 /** 3590 * APN name. 3591 * <P>Type: TEXT</P> 3592 */ 3593 public static final String APN = "apn"; 3594 3595 /** 3596 * Proxy address. 3597 * <P>Type: TEXT</P> 3598 */ 3599 public static final String PROXY = "proxy"; 3600 3601 /** 3602 * Proxy port. 3603 * <P>Type: TEXT</P> 3604 */ 3605 public static final String PORT = "port"; 3606 3607 /** 3608 * MMS proxy address. 3609 * <P>Type: TEXT</P> 3610 */ 3611 public static final String MMSPROXY = "mmsproxy"; 3612 3613 /** 3614 * MMS proxy port. 3615 * <P>Type: TEXT</P> 3616 */ 3617 public static final String MMSPORT = "mmsport"; 3618 3619 /** 3620 * Server address. 3621 * <P>Type: TEXT</P> 3622 */ 3623 public static final String SERVER = "server"; 3624 3625 /** 3626 * APN username. 3627 * <P>Type: TEXT</P> 3628 */ 3629 public static final String USER = "user"; 3630 3631 /** 3632 * APN password. 3633 * <P>Type: TEXT</P> 3634 */ 3635 public static final String PASSWORD = "password"; 3636 3637 /** 3638 * MMSC URL. 3639 * <P>Type: TEXT</P> 3640 */ 3641 public static final String MMSC = "mmsc"; 3642 3643 /** 3644 * Mobile Country Code (MCC). 3645 * <P>Type: TEXT</P> 3646 * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return 3647 * matching APNs based on current subscription carrier, thus no need to specify MCC and 3648 * other carrier matching information. In the future, Android will not support MCC for 3649 * APN query. 3650 */ 3651 public static final String MCC = "mcc"; 3652 3653 /** 3654 * Mobile Network Code (MNC). 3655 * <P>Type: TEXT</P> 3656 * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return 3657 * matching APNs based on current subscription carrier, thus no need to specify MNC and 3658 * other carrier matching information. In the future, Android will not support MNC for 3659 * APN query. 3660 */ 3661 public static final String MNC = "mnc"; 3662 3663 /** 3664 * Numeric operator ID (as String). Usually {@code MCC + MNC}. 3665 * <P>Type: TEXT</P> 3666 * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return 3667 * matching APNs based on current subscription carrier, thus no need to specify Numeric 3668 * and other carrier matching information. In the future, Android will not support Numeric 3669 * for APN query. 3670 */ 3671 public static final String NUMERIC = "numeric"; 3672 3673 /** 3674 * Authentication type. 3675 * <P>Type: INTEGER</P> 3676 */ 3677 public static final String AUTH_TYPE = "authtype"; 3678 3679 /** 3680 * Comma-delimited list of APN types. 3681 * <P>Type: TEXT</P> 3682 */ 3683 public static final String TYPE = "type"; 3684 3685 /** 3686 * The protocol to use to connect to this APN. 3687 * 3688 * One of the {@code PDP_type} values in TS 27.007 section 10.1.1. 3689 * For example: {@code IP}, {@code IPV6}, {@code IPV4V6}, or {@code PPP}. 3690 * <P>Type: TEXT</P> 3691 */ 3692 public static final String PROTOCOL = "protocol"; 3693 3694 /** 3695 * The protocol to use to connect to this APN when roaming. 3696 * The syntax is the same as protocol. 3697 * <P>Type: TEXT</P> 3698 */ 3699 public static final String ROAMING_PROTOCOL = "roaming_protocol"; 3700 3701 /** 3702 * Is this the current APN? 3703 * <P>Type: INTEGER (boolean)</P> 3704 */ 3705 public static final String CURRENT = "current"; 3706 3707 /** 3708 * Is this APN enabled? 3709 * <P>Type: INTEGER (boolean)</P> 3710 */ 3711 public static final String CARRIER_ENABLED = "carrier_enabled"; 3712 3713 /** 3714 * Radio Access Technology info. 3715 * To check what values are allowed, refer to {@link android.telephony.ServiceState}. 3716 * This should be spread to other technologies, 3717 * but is currently only used for LTE (14) and eHRPD (13). 3718 * <P>Type: INTEGER</P> 3719 * @deprecated this column is no longer supported, use {@link #NETWORK_TYPE_BITMASK} instead 3720 */ 3721 @Deprecated 3722 public static final String BEARER = "bearer"; 3723 3724 /** 3725 * Radio Access Technology bitmask. 3726 * To check what values can be contained, refer to {@link android.telephony.ServiceState}. 3727 * 0 indicates all techs otherwise first bit refers to RAT/bearer 1, second bit refers to 3728 * RAT/bearer 2 and so on. 3729 * Bitmask for a radio tech R is (1 << (R - 1)) 3730 * <P>Type: INTEGER</P> 3731 * @hide 3732 * @deprecated this column is no longer supported, use {@link #NETWORK_TYPE_BITMASK} instead 3733 */ 3734 @Deprecated 3735 public static final String BEARER_BITMASK = "bearer_bitmask"; 3736 3737 /** 3738 * Radio technology (network type) bitmask. 3739 * To check what values can be contained, refer to the NETWORK_TYPE_ constants in 3740 * {@link android.telephony.TelephonyManager}. 3741 * Bitmask for a radio tech R is (1 << (R - 1)) 3742 * <P>Type: INTEGER</P> 3743 */ 3744 public static final String NETWORK_TYPE_BITMASK = "network_type_bitmask"; 3745 3746 /** 3747 * MVNO type: 3748 * {@code SPN (Service Provider Name), IMSI, GID (Group Identifier Level 1)}. 3749 * <P>Type: TEXT</P> 3750 * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return 3751 * matching APNs based on current subscription carrier, thus no need to specify MVNO_TYPE 3752 * and other carrier matching information. In the future, Android will not support MVNO_TYPE 3753 * for APN query. 3754 */ 3755 public static final String MVNO_TYPE = "mvno_type"; 3756 3757 /** 3758 * MVNO data. 3759 * Use the following examples. 3760 * <ul> 3761 * <li>SPN: A MOBILE, BEN NL, ...</li> 3762 * <li>IMSI: 302720x94, 2060188, ...</li> 3763 * <li>GID: 4E, 33, ...</li> 3764 * </ul> 3765 * <P>Type: TEXT</P> 3766 * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return 3767 * matching APNs based on current subscription carrier, thus no need to specify 3768 * MVNO_MATCH_DATA and other carrier matching information. In the future, Android will not 3769 * support MVNO_MATCH_DATA for APN query. 3770 */ 3771 public static final String MVNO_MATCH_DATA = "mvno_match_data"; 3772 3773 /** 3774 * The subscription to which the APN belongs to 3775 * <p>Type: INTEGER (long) </p> 3776 */ 3777 public static final String SUBSCRIPTION_ID = "sub_id"; 3778 3779 /** 3780 * The profile_id to which the APN saved in modem. 3781 * <p>Type: INTEGER</p> 3782 *@hide 3783 */ 3784 public static final String PROFILE_ID = "profile_id"; 3785 3786 /** 3787 * If set to {@code true}, then the APN setting will persist to the modem. 3788 * <p>Type: INTEGER (boolean)</p> 3789 *@hide 3790 */ 3791 @SystemApi 3792 public static final String MODEM_PERSIST = "modem_cognitive"; 3793 3794 /** 3795 * The max number of connections of this APN. 3796 * <p>Type: INTEGER</p> 3797 *@hide 3798 */ 3799 @SystemApi 3800 public static final String MAX_CONNECTIONS = "max_conns"; 3801 3802 /** 3803 * The wait time for retrying the APN, in milliseconds. 3804 * <p>Type: INTEGER</p> 3805 *@hide 3806 */ 3807 @SystemApi 3808 public static final String WAIT_TIME_RETRY = "wait_time"; 3809 3810 /** 3811 * The max number of seconds this APN will support its maximum number of connections 3812 * as defined in {@link #MAX_CONNECTIONS}. 3813 * <p>Type: INTEGER</p> 3814 *@hide 3815 */ 3816 @SystemApi 3817 public static final String TIME_LIMIT_FOR_MAX_CONNECTIONS = "max_conns_time"; 3818 3819 /** 3820 * The MTU (maximum transmit unit) size of the mobile interface to which the APN is 3821 * connected, in bytes. 3822 * <p>Type: INTEGER </p> 3823 * @hide 3824 */ 3825 @SystemApi 3826 public static final String MTU = "mtu"; 3827 3828 /** 3829 * APN edit status. APN could be added/edited/deleted by a user or carrier. 3830 * see all possible returned APN edit status. 3831 * <ul> 3832 * <li>{@link #UNEDITED}</li> 3833 * <li>{@link #USER_EDITED}</li> 3834 * <li>{@link #USER_DELETED}</li> 3835 * <li>{@link #CARRIER_EDITED}</li> 3836 * <li>{@link #CARRIER_DELETED}</li> 3837 * </ul> 3838 * <p>Type: INTEGER </p> 3839 * @hide 3840 */ 3841 @SystemApi 3842 public static final String EDITED_STATUS = "edited"; 3843 3844 /** 3845 * {@code true} if this APN visible to the user, {@code false} otherwise. 3846 * <p>Type: INTEGER (boolean)</p> 3847 * @hide 3848 */ 3849 @SystemApi 3850 public static final String USER_VISIBLE = "user_visible"; 3851 3852 /** 3853 * {@code true} if the user allowed to edit this APN, {@code false} otherwise. 3854 * <p>Type: INTEGER (boolean)</p> 3855 * @hide 3856 */ 3857 @SystemApi 3858 public static final String USER_EDITABLE = "user_editable"; 3859 3860 /** 3861 * Integer value denoting an invalid APN id 3862 * @hide 3863 */ 3864 public static final int INVALID_APN_ID = -1; 3865 3866 /** 3867 * {@link #EDITED_STATUS APN edit status} indicates that this APN has not been edited or 3868 * fails to edit. 3869 * <p>Type: INTEGER </p> 3870 * @hide 3871 */ 3872 @SystemApi 3873 public static final @EditStatus int UNEDITED = 0; 3874 3875 /** 3876 * {@link #EDITED_STATUS APN edit status} indicates that this APN has been edited by users. 3877 * <p>Type: INTEGER </p> 3878 * @hide 3879 */ 3880 @SystemApi 3881 public static final @EditStatus int USER_EDITED = 1; 3882 3883 /** 3884 * {@link #EDITED_STATUS APN edit status} indicates that this APN has been deleted by users. 3885 * <p>Type: INTEGER </p> 3886 * @hide 3887 */ 3888 @SystemApi 3889 public static final @EditStatus int USER_DELETED = 2; 3890 3891 /** 3892 * {@link #EDITED_STATUS APN edit status} is an intermediate value used to indicate that an 3893 * entry deleted by the user is still present in the new APN database and therefore must 3894 * remain tagged as user deleted rather than completely removed from the database. 3895 * @hide 3896 */ 3897 public static final int USER_DELETED_BUT_PRESENT_IN_XML = 3; 3898 3899 /** 3900 * {@link #EDITED_STATUS APN edit status} indicates that this APN has been edited by 3901 * carriers. 3902 * <p>Type: INTEGER </p> 3903 * @hide 3904 */ 3905 @SystemApi 3906 public static final @EditStatus int CARRIER_EDITED = 4; 3907 3908 /** 3909 * {@link #EDITED_STATUS APN edit status} indicates that this APN has been deleted by 3910 * carriers. CARRIER_DELETED values are currently not used as there is no use case. 3911 * If they are used, delete() will have to change accordingly. Currently it is hardcoded to 3912 * USER_DELETED. 3913 * <p>Type: INTEGER </p> 3914 * @hide 3915 */ 3916 public static final @EditStatus int CARRIER_DELETED = 5; 3917 3918 /** 3919 * {@link #EDITED_STATUS APN edit status} is an intermediate value used to indicate that an 3920 * entry deleted by the carrier is still present in the new APN database and therefore must 3921 * remain tagged as user deleted rather than completely removed from the database. 3922 * @hide 3923 */ 3924 public static final int CARRIER_DELETED_BUT_PRESENT_IN_XML = 6; 3925 3926 /** 3927 * The owner of the APN. 3928 * <p>Type: INTEGER</p> 3929 * @hide 3930 */ 3931 public static final String OWNED_BY = "owned_by"; 3932 3933 /** 3934 * Possible value for the OWNED_BY field. 3935 * APN is owned by DPC. 3936 * @hide 3937 */ 3938 public static final int OWNED_BY_DPC = 0; 3939 3940 /** 3941 * Possible value for the OWNED_BY field. 3942 * APN is owned by other sources. 3943 * @hide 3944 */ 3945 public static final int OWNED_BY_OTHERS = 1; 3946 3947 /** 3948 * The APN set id. When the user manually selects an APN or the framework sets an APN as 3949 * preferred, all APNs with the same set id as the selected APN should be prioritized over 3950 * APNs in other sets. 3951 * <p>Type: INTEGER</p> 3952 * @hide 3953 */ 3954 @SystemApi 3955 public static final String APN_SET_ID = "apn_set_id"; 3956 3957 /** 3958 * Possible value for the {@link #APN_SET_ID} field. By default APNs will not belong to a 3959 * set. If the user manually selects an APN without apn set id, there is no need to 3960 * prioritize any specific APN set ids. 3961 * <p>Type: INTEGER</p> 3962 * @hide 3963 */ 3964 @SystemApi 3965 public static final int NO_APN_SET_ID = 0; 3966 3967 /** 3968 * A unique carrier id associated with this APN 3969 * {@see TelephonyManager#getSimCarrierId()} 3970 * <p>Type: STRING</p> 3971 */ 3972 public static final String CARRIER_ID = "carrier_id"; 3973 3974 /** 3975 * The skip 464xlat flag. Flag works as follows. 3976 * {@link #SKIP_464XLAT_DEFAULT}: the APN will skip only APN is IMS and no internet. 3977 * {@link #SKIP_464XLAT_DISABLE}: the APN will NOT skip 464xlat 3978 * {@link #SKIP_464XLAT_ENABLE}: the APN will skip 464xlat 3979 * <p>Type: INTEGER</p> 3980 * 3981 * @hide 3982 */ 3983 public static final String SKIP_464XLAT = "skip_464xlat"; 3984 3985 /** 3986 * Possible value for the {@link #SKIP_464XLAT} field. 3987 * <p>Type: INTEGER</p> 3988 * 3989 * @hide 3990 */ 3991 public static final int SKIP_464XLAT_DEFAULT = -1; 3992 3993 /** 3994 * Possible value for the {@link #SKIP_464XLAT} field. 3995 * <p>Type: INTEGER</p> 3996 * 3997 * @hide 3998 */ 3999 public static final int SKIP_464XLAT_DISABLE = 0; 4000 4001 /** 4002 * Possible value for the {@link #SKIP_464XLAT} field. 4003 * <p>Type: INTEGER</p> 4004 * 4005 * @hide 4006 */ 4007 public static final int SKIP_464XLAT_ENABLE = 1; 4008 4009 4010 /** @hide */ 4011 @IntDef({ 4012 UNEDITED, 4013 USER_EDITED, 4014 USER_DELETED, 4015 CARRIER_DELETED, 4016 CARRIER_EDITED, 4017 }) 4018 @Retention(RetentionPolicy.SOURCE) 4019 public @interface EditStatus {} 4020 4021 /** 4022 * Compat framework change ID for the APN db read permission change. 4023 * 4024 * In API level 30 and beyond, accessing the APN database will require the 4025 * {@link android.Manifest.permission#WRITE_APN_SETTINGS} permission. This change ID tracks 4026 * apps that are affected because they don't hold this permission. 4027 * @hide 4028 */ 4029 @ChangeId 4030 @EnabledAfter(targetSdkVersion = android.os.Build.VERSION_CODES.Q) 4031 public static final long APN_READING_PERMISSION_CHANGE_ID = 124107808L; 4032 } 4033 4034 /** 4035 * Contains received cell broadcast messages. More details are available in 3GPP TS 23.041. 4036 * @hide 4037 */ 4038 @SystemApi 4039 @TestApi 4040 public static final class CellBroadcasts implements BaseColumns { 4041 4042 /** 4043 * Not instantiable. 4044 * @hide 4045 */ CellBroadcasts()4046 private CellBroadcasts() {} 4047 4048 /** 4049 * The {@code content://} URI for this table. 4050 * Only privileged framework components running on phone or network stack uid can 4051 * query or modify this table. 4052 */ 4053 @NonNull 4054 public static final Uri CONTENT_URI = Uri.parse("content://cellbroadcasts"); 4055 4056 /** 4057 * The {@code content://} URI for query cellbroadcast message history. 4058 * query results include following entries 4059 * <ul> 4060 * <li>{@link #_ID}</li> 4061 * <li>{@link #SLOT_INDEX}</li> 4062 * <li>{@link #GEOGRAPHICAL_SCOPE}</li> 4063 * <li>{@link #PLMN}</li> 4064 * <li>{@link #LAC}</li> 4065 * <li>{@link #CID}</li> 4066 * <li>{@link #SERIAL_NUMBER}</li> 4067 * <li>{@link #SERVICE_CATEGORY}</li> 4068 * <li>{@link #LANGUAGE_CODE}</li> 4069 * <li>{@link #MESSAGE_BODY}</li> 4070 * <li>{@link #DELIVERY_TIME}</li> 4071 * <li>{@link #MESSAGE_READ}</li> 4072 * <li>{@link #MESSAGE_FORMAT}</li> 4073 * <li>{@link #MESSAGE_PRIORITY}</li> 4074 * <li>{@link #ETWS_WARNING_TYPE}</li> 4075 * <li>{@link #CMAS_MESSAGE_CLASS}</li> 4076 * <li>{@link #CMAS_CATEGORY}</li> 4077 * <li>{@link #CMAS_RESPONSE_TYPE}</li> 4078 * <li>{@link #CMAS_SEVERITY}</li> 4079 * <li>{@link #CMAS_URGENCY}</li> 4080 * <li>{@link #CMAS_CERTAINTY}</li> 4081 * </ul> 4082 */ 4083 @RequiresPermission(Manifest.permission.READ_CELL_BROADCASTS) 4084 @NonNull 4085 public static final Uri MESSAGE_HISTORY_URI = Uri.parse("content://cellbroadcasts/history"); 4086 4087 /** 4088 * The authority for the legacy cellbroadcast provider. 4089 * This is used for OEM data migration. OEMs want to migrate message history or 4090 * sharepreference data to mainlined cellbroadcastreceiver app, should have a 4091 * contentprovider with authority: cellbroadcast-legacy. Mainlined cellbroadcastreceiver 4092 * will interact with this URI to retrieve data and persists to mainlined cellbroadcast app. 4093 * 4094 * @hide 4095 */ 4096 @SystemApi 4097 public static final @NonNull String AUTHORITY_LEGACY = "cellbroadcast-legacy"; 4098 4099 /** 4100 * A content:// style uri to the authority for the legacy cellbroadcast provider. 4101 * @hide 4102 */ 4103 @SystemApi 4104 public static final @NonNull Uri AUTHORITY_LEGACY_URI = 4105 Uri.parse("content://cellbroadcast-legacy"); 4106 4107 /** 4108 * Method name to {@link android.content.ContentProvider#call(String, String, Bundle) 4109 * for {@link #AUTHORITY_LEGACY}. Used to query cellbroadcast {@link Preference}, 4110 * containing following supported entries 4111 * <ul> 4112 * <li>{@link #ENABLE_AREA_UPDATE_INFO_PREF}</li> 4113 * <li>{@link #ENABLE_TEST_ALERT_PREF}</li> 4114 * <li>{@link #ENABLE_STATE_LOCAL_TEST_PREF}</li> 4115 * <li>{@link #ENABLE_PUBLIC_SAFETY_PREF}</li> 4116 * <li>{@link #ENABLE_CMAS_AMBER_PREF}</li> 4117 * <li>{@link #ENABLE_CMAS_SEVERE_THREAT_PREF}</li> 4118 * <li>{@link #ENABLE_CMAS_EXTREME_THREAT_PREF}</li> 4119 * <li>{@link #ENABLE_CMAS_PRESIDENTIAL_PREF}</li> 4120 * <li>{@link #ENABLE_ALERT_VIBRATION_PREF}</li> 4121 * <li>{@link #ENABLE_EMERGENCY_PERF}</li> 4122 * <li>{@link #ENABLE_CMAS_IN_SECOND_LANGUAGE_PREF}</li> 4123 * </ul> 4124 * @hide 4125 */ 4126 @SystemApi 4127 public static final @NonNull String CALL_METHOD_GET_PREFERENCE = "get_preference"; 4128 4129 /** 4130 * Arg name to {@link android.content.ContentProvider#call(String, String, Bundle)} 4131 * for {@link #AUTHORITY_LEGACY}. 4132 * Contains all supported shared preferences for cellbroadcast. 4133 * 4134 * @hide 4135 */ 4136 @SystemApi 4137 public static final class Preference { 4138 /** 4139 * Not Instantiatable. 4140 * @hide 4141 */ Preference()4142 private Preference() {} 4143 4144 /** Preference to enable area update info alert */ 4145 public static final @NonNull String ENABLE_AREA_UPDATE_INFO_PREF = 4146 "enable_area_update_info_alerts"; 4147 4148 /** Preference to enable test alert */ 4149 public static final @NonNull String ENABLE_TEST_ALERT_PREF = 4150 "enable_test_alerts"; 4151 4152 /** Preference to enable state local test alert */ 4153 public static final @NonNull String ENABLE_STATE_LOCAL_TEST_PREF 4154 = "enable_state_local_test_alerts"; 4155 4156 /** Preference to enable public safety alert */ 4157 public static final @NonNull String ENABLE_PUBLIC_SAFETY_PREF 4158 = "enable_public_safety_messages"; 4159 4160 /** Preference to enable amber alert */ 4161 public static final @NonNull String ENABLE_CMAS_AMBER_PREF 4162 = "enable_cmas_amber_alerts"; 4163 4164 /** Preference to enable severe threat alert */ 4165 public static final @NonNull String ENABLE_CMAS_SEVERE_THREAT_PREF 4166 = "enable_cmas_severe_threat_alerts"; 4167 4168 /** Preference to enable extreme threat alert */ 4169 public static final @NonNull String ENABLE_CMAS_EXTREME_THREAT_PREF = 4170 "enable_cmas_extreme_threat_alerts"; 4171 4172 /** Preference to enable presidential alert */ 4173 public static final @NonNull String ENABLE_CMAS_PRESIDENTIAL_PREF = 4174 "enable_cmas_presidential_alerts"; 4175 4176 /** Preference to enable alert vibration */ 4177 public static final @NonNull String ENABLE_ALERT_VIBRATION_PREF = 4178 "enable_alert_vibrate"; 4179 4180 /** Preference to enable emergency alert */ 4181 public static final @NonNull String ENABLE_EMERGENCY_PERF = 4182 "enable_emergency_alerts"; 4183 4184 /** Preference to enable receive alerts in second language */ 4185 public static final @NonNull String ENABLE_CMAS_IN_SECOND_LANGUAGE_PREF = 4186 "receive_cmas_in_second_language"; 4187 } 4188 4189 /** 4190 * The subscription which received this cell broadcast message. 4191 * <P>Type: INTEGER</P> 4192 */ 4193 public static final String SUBSCRIPTION_ID = "sub_id"; 4194 4195 /** 4196 * The slot which received this cell broadcast message. 4197 * <P>Type: INTEGER</P> 4198 */ 4199 public static final String SLOT_INDEX = "slot_index"; 4200 4201 /** 4202 * Message geographical scope. Valid values are: 4203 * <ul> 4204 * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_CELL_WIDE}. meaning the 4205 * message is for the radio service cell</li> 4206 * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_CELL_WIDE_IMMEDIATE}, 4207 * meaning the message is for the radio service cell and immediately displayed</li> 4208 * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_PLMN_WIDE}, meaning the 4209 * message is for the PLMN (i.e. MCC/MNC)</li> 4210 * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_LOCATION_AREA_WIDE}, 4211 * meaning the message is for the location area (in GSM) or service area (in UMTS)</li> 4212 * </ul> 4213 * 4214 * <p>A message meant for a particular scope is automatically dismissed when the device 4215 * exits that scope.</p> 4216 * <P>Type: INTEGER</P> 4217 */ 4218 public static final String GEOGRAPHICAL_SCOPE = "geo_scope"; 4219 4220 /** 4221 * Message serial number. 4222 * <p> 4223 * A 16-bit integer which identifies a particular CBS (cell 4224 * broadcast short message service) message. The core network is responsible for 4225 * allocating this value, and the value may be managed cyclically (3GPP TS 23.041 section 4226 * 9.2.1) once the serial message has been incremented a sufficient number of times. 4227 * </p> 4228 * <P>Type: INTEGER</P> 4229 */ 4230 public static final String SERIAL_NUMBER = "serial_number"; 4231 4232 /** 4233 * PLMN (i.e. MCC/MNC) of broadcast sender. {@code SERIAL_NUMBER + PLMN + LAC + CID} 4234 * uniquely identifies a broadcast for duplicate detection purposes. 4235 * <P>Type: TEXT</P> 4236 */ 4237 public static final String PLMN = "plmn"; 4238 4239 /** 4240 * Location area code (LAC). 4241 * <p>Code representing location area (GSM) or service area (UMTS) of broadcast sender. 4242 * Unused for CDMA. Only included if Geographical Scope of message is not PLMN wide (01). 4243 * This value is sent by the network based on the cell tower. 4244 * <P>Type: INTEGER</P> 4245 */ 4246 public static final String LAC = "lac"; 4247 4248 /** 4249 * Cell ID of message sender (GSM/UMTS). Unused for CDMA. Only included when the 4250 * Geographical Scope of message is cell wide (00 or 11). 4251 * <P>Type: INTEGER</P> 4252 */ 4253 public static final String CID = "cid"; 4254 4255 /** 4256 * Service category which represents the general topic of the message. 4257 * <p> 4258 * For GSM/UMTS: message identifier (see 3GPP TS 23.041 section 9.4.1.2.2) 4259 * For CDMA: a 16-bit CDMA service category (see 3GPP2 C.R1001-D section 9.3) 4260 * </p> 4261 * <P>Type: INTEGER</P> 4262 */ 4263 public static final String SERVICE_CATEGORY = "service_category"; 4264 4265 /** 4266 * Message language code. (See 3GPP TS 23.041 section 9.4.1.2.3 for details). 4267 * <P>Type: TEXT</P> 4268 */ 4269 public static final String LANGUAGE_CODE = "language"; 4270 4271 /** 4272 * Dats coding scheme of the message. 4273 * <p> 4274 * The data coding scheme (dcs) value defined in 3GPP TS 23.038 section 4 4275 * </p> 4276 * <P>Type: INTEGER</P> 4277 */ 4278 public static final String DATA_CODING_SCHEME = "dcs"; 4279 4280 /** 4281 * Message body. 4282 * <P>Type: TEXT</P> 4283 */ 4284 public static final String MESSAGE_BODY = "body"; 4285 4286 /** 4287 * Message delivery time. 4288 * <p>This value is a system timestamp using {@link System#currentTimeMillis}</p> 4289 * <P>Type: INTEGER (long)</P> 4290 */ 4291 public static final String DELIVERY_TIME = "date"; 4292 4293 /** 4294 * Has the message been viewed? 4295 * <P>Type: INTEGER (boolean)</P> 4296 */ 4297 public static final String MESSAGE_READ = "read"; 4298 4299 /** 4300 * Message format ({@link android.telephony.SmsCbMessage#MESSAGE_FORMAT_3GPP} or 4301 * {@link android.telephony.SmsCbMessage#MESSAGE_FORMAT_3GPP2}). 4302 * <P>Type: INTEGER</P> 4303 */ 4304 public static final String MESSAGE_FORMAT = "format"; 4305 4306 /** 4307 * Message priority. 4308 * <p>This includes 4309 * <ul> 4310 * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_NORMAL}</li> 4311 * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_INTERACTIVE}</li> 4312 * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_URGENT}</li> 4313 * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_EMERGENCY}</li> 4314 * </p> 4315 * </ul> 4316 * <P>Type: INTEGER</P> 4317 */ 4318 public static final String MESSAGE_PRIORITY = "priority"; 4319 4320 /** 4321 * ETWS (Earthquake and Tsunami Warning System) warning type (ETWS alerts only). 4322 * <p>See {@link android.telephony.SmsCbEtwsInfo}</p> 4323 * <P>Type: INTEGER</P> 4324 */ 4325 public static final String ETWS_WARNING_TYPE = "etws_warning_type"; 4326 4327 /** 4328 * ETWS (Earthquake and Tsunami Warning System) primary message or not (ETWS alerts only). 4329 * <p>See {@link android.telephony.SmsCbEtwsInfo}</p> 4330 * <P>Type: BOOLEAN</P> 4331 * 4332 * @hide // TODO: Unhide this for S. 4333 */ 4334 public static final String ETWS_IS_PRIMARY = "etws_is_primary"; 4335 4336 /** 4337 * CMAS (Commercial Mobile Alert System) message class (CMAS alerts only). 4338 * <p>See {@link android.telephony.SmsCbCmasInfo}</p> 4339 * <P>Type: INTEGER</P> 4340 */ 4341 public static final String CMAS_MESSAGE_CLASS = "cmas_message_class"; 4342 4343 /** 4344 * CMAS category (CMAS alerts only). 4345 * <P>Type: INTEGER</P> 4346 */ 4347 public static final String CMAS_CATEGORY = "cmas_category"; 4348 4349 /** 4350 * CMAS response type (CMAS alerts only). 4351 * <P>Type: INTEGER</P> 4352 */ 4353 public static final String CMAS_RESPONSE_TYPE = "cmas_response_type"; 4354 4355 /** 4356 * CMAS severity (CMAS alerts only). 4357 * <P>Type: INTEGER</P> 4358 */ 4359 public static final String CMAS_SEVERITY = "cmas_severity"; 4360 4361 /** 4362 * CMAS urgency (CMAS alerts only). 4363 * <P>Type: INTEGER</P> 4364 */ 4365 public static final String CMAS_URGENCY = "cmas_urgency"; 4366 4367 /** 4368 * CMAS certainty (CMAS alerts only). 4369 * <P>Type: INTEGER</P> 4370 */ 4371 public static final String CMAS_CERTAINTY = "cmas_certainty"; 4372 4373 /** The default sort order for this table. */ 4374 public static final String DEFAULT_SORT_ORDER = DELIVERY_TIME + " DESC"; 4375 4376 /** 4377 * The timestamp in millisecond, reported by {@link System#currentTimeMillis()}, when the 4378 * device received the message. 4379 * <P>Type: BIGINT</P> 4380 */ 4381 public static final String RECEIVED_TIME = "received_time"; 4382 4383 /** 4384 * The timestamp in millisecond, reported by {@link System#currentTimeMillis()}, when 4385 * location was checked last time. Note this is only applicable to geo-targeting message. 4386 * For non geo-targeting message. the field will be set to -1. 4387 * <P>Type: BIGINT</P> 4388 */ 4389 public static final String LOCATION_CHECK_TIME = "location_check_time"; 4390 /** 4391 * Indicates that whether the message has been broadcasted to the application. 4392 * <P>Type: BOOLEAN</P> 4393 */ 4394 // TODO: deprecate this in S. 4395 public static final String MESSAGE_BROADCASTED = "message_broadcasted"; 4396 4397 /** 4398 * Indicates that whether the message has been displayed to the user. 4399 * <P>Type: BOOLEAN</P> 4400 */ 4401 public static final String MESSAGE_DISPLAYED = "message_displayed"; 4402 4403 /** 4404 * The Warning Area Coordinates Elements. This element is used for geo-fencing purpose. 4405 * 4406 * The geometry and its coordinates are separated vertical bar, the first item is the 4407 * geometry type and the remaining items are the parameter of this geometry. 4408 * 4409 * Only circle and polygon are supported. The coordinates are represented in Horizontal 4410 * coordinates format. 4411 * 4412 * Coordinate encoding: 4413 * "latitude, longitude" 4414 * where -90.00000 <= latitude <= 90.00000 and -180.00000 <= longitude <= 180.00000 4415 * 4416 * Polygon encoding: 4417 * "polygon|lat1,lng1|lat2,lng2|...|latn,lngn" 4418 * lat1,lng1 ... latn,lngn are the vertices coordinate of the polygon. 4419 * 4420 * Circle encoding: 4421 * "circle|lat,lng|radius". 4422 * lat,lng is the center of the circle. The unit of circle's radius is meter. 4423 * 4424 * Example: 4425 * "circle|0,0|100" mean a circle which center located at (0,0) and its radius is 100 meter. 4426 * "polygon|0,1.5|0,1|1,1|1,0" mean a polygon has vertices (0,1.5),(0,1),(1,1),(1,0). 4427 * 4428 * There could be more than one geometry store in this field, they are separated by a 4429 * semicolon. 4430 * 4431 * Example: 4432 * "circle|0,0|100;polygon|0,0|0,1.5|1,1|1,0;circle|100.123,100|200.123" 4433 * 4434 * <P>Type: TEXT</P> 4435 */ 4436 public static final String GEOMETRIES = "geometries"; 4437 4438 /** 4439 * Geo-Fencing Maximum Wait Time in second. The range of the time is [0, 255]. A device 4440 * shall allow to determine its position meeting operator policy. If the device is unable to 4441 * determine its position meeting operator policy within the GeoFencing Maximum Wait Time, 4442 * it shall present the alert to the user and discontinue further positioning determination 4443 * for the alert. 4444 * 4445 * <P>Type: INTEGER</P> 4446 */ 4447 public static final String MAXIMUM_WAIT_TIME = "maximum_wait_time"; 4448 4449 /** 4450 * Query columns for instantiating com.android.cellbroadcastreceiver.CellBroadcastMessage. 4451 * @hide 4452 */ 4453 @NonNull 4454 public static final String[] QUERY_COLUMNS = { 4455 _ID, 4456 GEOGRAPHICAL_SCOPE, 4457 PLMN, 4458 LAC, 4459 CID, 4460 SERIAL_NUMBER, 4461 SERVICE_CATEGORY, 4462 LANGUAGE_CODE, 4463 MESSAGE_BODY, 4464 DELIVERY_TIME, 4465 MESSAGE_READ, 4466 MESSAGE_FORMAT, 4467 MESSAGE_PRIORITY, 4468 ETWS_WARNING_TYPE, 4469 CMAS_MESSAGE_CLASS, 4470 CMAS_CATEGORY, 4471 CMAS_RESPONSE_TYPE, 4472 CMAS_SEVERITY, 4473 CMAS_URGENCY, 4474 CMAS_CERTAINTY 4475 }; 4476 } 4477 4478 /** 4479 * Constants for interfacing with the ServiceStateProvider and the different fields of the 4480 * {@link ServiceState} class accessible through the provider. 4481 */ 4482 public static final class ServiceStateTable { 4483 4484 /** 4485 * Not instantiable. 4486 * @hide 4487 */ ServiceStateTable()4488 private ServiceStateTable() {} 4489 4490 /** 4491 * The authority string for the ServiceStateProvider 4492 */ 4493 public static final String AUTHORITY = "service-state"; 4494 4495 /** 4496 * The {@code content://} style URL for the ServiceStateProvider 4497 */ 4498 public static final Uri CONTENT_URI = Uri.parse("content://service-state/"); 4499 4500 /** 4501 * Generates a content {@link Uri} used to receive updates on a specific field in the 4502 * ServiceState provider. 4503 * <p> 4504 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the 4505 * {@link ServiceState} while your app is running. 4506 * You can also use a {@link android.app.job.JobService} to 4507 * ensure your app is notified of changes to the {@link Uri} even when it is not running. 4508 * Note, however, that using a {@link android.app.job.JobService} 4509 * does not guarantee timely delivery of 4510 * updates to the {@link Uri}. 4511 * 4512 * @param subscriptionId the subscriptionId to receive updates on 4513 * @param field the ServiceState field to receive updates on 4514 * @return the Uri used to observe {@link ServiceState} changes 4515 */ getUriForSubscriptionIdAndField(int subscriptionId, String field)4516 public static Uri getUriForSubscriptionIdAndField(int subscriptionId, String field) { 4517 return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId)) 4518 .appendEncodedPath(field).build(); 4519 } 4520 4521 /** 4522 * Generates a content {@link Uri} used to receive updates on every field in the 4523 * ServiceState provider. 4524 * <p> 4525 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the 4526 * {@link ServiceState} while your app is running. You can also use a 4527 * {@link android.app.job.JobService} to 4528 * ensure your app is notified of changes to the {@link Uri} even when it is not running. 4529 * Note, however, that using a {@link android.app.job.JobService} 4530 * does not guarantee timely delivery of 4531 * updates to the {@link Uri}. 4532 * 4533 * @param subscriptionId the subscriptionId to receive updates on 4534 * @return the Uri used to observe {@link ServiceState} changes 4535 */ getUriForSubscriptionId(int subscriptionId)4536 public static Uri getUriForSubscriptionId(int subscriptionId) { 4537 return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId)).build(); 4538 } 4539 4540 /** 4541 * An integer value indicating the current voice service state. 4542 * <p> 4543 * Valid values: {@link ServiceState#STATE_IN_SERVICE}, 4544 * {@link ServiceState#STATE_OUT_OF_SERVICE}, {@link ServiceState#STATE_EMERGENCY_ONLY}, 4545 * {@link ServiceState#STATE_POWER_OFF}. 4546 * <p> 4547 * This is the same as {@link ServiceState#getState()}. 4548 */ 4549 public static final String VOICE_REG_STATE = "voice_reg_state"; 4550 4551 /** 4552 * The current registered operator numeric id. 4553 * <p> 4554 * In GSM/UMTS, numeric format is 3 digit country code plus 2 or 3 digit 4555 * network code. 4556 * <p> 4557 * This is the same as {@link ServiceState#getOperatorNumeric()}. 4558 */ 4559 public static final String VOICE_OPERATOR_NUMERIC = "voice_operator_numeric"; 4560 4561 /** 4562 * The current network selection mode. 4563 * <p> 4564 * This is the same as {@link ServiceState#getIsManualSelection()}. 4565 */ 4566 public static final String IS_MANUAL_NETWORK_SELECTION = "is_manual_network_selection"; 4567 } 4568 4569 /** 4570 * Contains carrier identification information for the current subscriptions. 4571 */ 4572 public static final class CarrierId implements BaseColumns { 4573 /** 4574 * Not instantiable. 4575 * @hide 4576 */ CarrierId()4577 private CarrierId() {} 4578 4579 /** 4580 * The {@code content://} style URI for this provider. 4581 */ 4582 public static final Uri CONTENT_URI = Uri.parse("content://carrier_id"); 4583 4584 /** 4585 * The authority string for the CarrierId Provider 4586 * @hide 4587 */ 4588 public static final String AUTHORITY = "carrier_id"; 4589 4590 4591 /** 4592 * Generates a content {@link Uri} used to receive updates on carrier identity change 4593 * on the given subscriptionId 4594 * <p> 4595 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the 4596 * carrier identity {@link TelephonyManager#getSimCarrierId()} 4597 * while your app is running. You can also use a {@link android.app.job.JobService} 4598 * to ensure your app 4599 * is notified of changes to the {@link Uri} even when it is not running. 4600 * Note, however, that using a {@link android.app.job.JobService} does not guarantee 4601 * timely delivery of updates to the {@link Uri}. 4602 * 4603 * @param subscriptionId the subscriptionId to receive updates on 4604 * @return the Uri used to observe carrier identity changes 4605 */ getUriForSubscriptionId(int subscriptionId)4606 public static Uri getUriForSubscriptionId(int subscriptionId) { 4607 return CONTENT_URI.buildUpon().appendEncodedPath( 4608 String.valueOf(subscriptionId)).build(); 4609 } 4610 4611 /** 4612 * Generates a content {@link Uri} used to receive updates on specific carrier identity 4613 * change on the given subscriptionId returned by 4614 * {@link TelephonyManager#getSimSpecificCarrierId()}. 4615 * @see TelephonyManager#ACTION_SUBSCRIPTION_SPECIFIC_CARRIER_IDENTITY_CHANGED 4616 * <p> 4617 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the 4618 * specific carrier identity {@link TelephonyManager#getSimSpecificCarrierId()} 4619 * while your app is running. You can also use a {@link android.app.job.JobService} 4620 * to ensure your app 4621 * is notified of changes to the {@link Uri} even when it is not running. 4622 * Note, however, that using a {@link android.app.job.JobService} does not guarantee timely 4623 * delivery of updates to the {@link Uri}. 4624 * 4625 * @param subscriptionId the subscriptionId to receive updates on 4626 * @return the Uri used to observe specific carrier identity changes 4627 */ 4628 @NonNull getSpecificCarrierIdUriForSubscriptionId(int subscriptionId)4629 public static Uri getSpecificCarrierIdUriForSubscriptionId(int subscriptionId) { 4630 return Uri.withAppendedPath(Uri.withAppendedPath(CONTENT_URI, "specific"), 4631 String.valueOf(subscriptionId)); 4632 } 4633 4634 /** 4635 * A user facing carrier name. 4636 * @see TelephonyManager#getSimCarrierIdName() 4637 * <P>Type: TEXT </P> 4638 */ 4639 public static final String CARRIER_NAME = "carrier_name"; 4640 4641 /** 4642 * A unique carrier id 4643 * @see TelephonyManager#getSimCarrierId() 4644 * <P>Type: INTEGER </P> 4645 */ 4646 public static final String CARRIER_ID = "carrier_id"; 4647 4648 /** 4649 * A fine-grained carrier id. 4650 * The specific carrier ID would be used for configuration purposes, but apps wishing to 4651 * know about the carrier itself should use the regular carrier ID returned by 4652 * {@link TelephonyManager#getSimCarrierId()}. 4653 * 4654 * @see TelephonyManager#getSimSpecificCarrierId() 4655 * This is not a database column, only used to notify content observers for 4656 * {@link #getSpecificCarrierIdUriForSubscriptionId(int)} 4657 */ 4658 public static final String SPECIFIC_CARRIER_ID = "specific_carrier_id"; 4659 4660 /** 4661 * A user facing carrier name for specific carrier id {@link #SPECIFIC_CARRIER_ID}. 4662 * @see TelephonyManager#getSimSpecificCarrierIdName() 4663 * This is not a database column, only used to notify content observers for 4664 * {@link #getSpecificCarrierIdUriForSubscriptionId(int)} 4665 */ 4666 public static final String SPECIFIC_CARRIER_ID_NAME = "specific_carrier_id_name"; 4667 4668 /** 4669 * A unique parent carrier id. The parent-child 4670 * relationship can be used to further differentiate a single carrier by different networks, 4671 * by prepaid v.s. postpaid. It's an optional field. 4672 * A carrier id with a valid parent_carrier_id is considered fine-grained specific carrier 4673 * ID, will not be returned as {@link #CARRIER_ID} but {@link #SPECIFIC_CARRIER_ID}. 4674 * <P>Type: INTEGER </P> 4675 * @hide 4676 */ 4677 public static final String PARENT_CARRIER_ID = "parent_carrier_id"; 4678 4679 /** 4680 * Contains mappings between matching rules with carrier id for all carriers. 4681 * @hide 4682 */ 4683 public static final class All implements BaseColumns { 4684 4685 /** 4686 * Not instantiable. 4687 * @hide 4688 */ All()4689 private All() { 4690 } 4691 4692 /** 4693 * Numeric operator ID (as String). {@code MCC + MNC} 4694 * <P>Type: TEXT </P> 4695 */ 4696 public static final String MCCMNC = "mccmnc"; 4697 4698 /** 4699 * Group id level 1 (as String). 4700 * <P>Type: TEXT </P> 4701 */ 4702 public static final String GID1 = "gid1"; 4703 4704 /** 4705 * Group id level 2 (as String). 4706 * <P>Type: TEXT </P> 4707 */ 4708 public static final String GID2 = "gid2"; 4709 4710 /** 4711 * Public Land Mobile Network name. 4712 * <P>Type: TEXT </P> 4713 */ 4714 public static final String PLMN = "plmn"; 4715 4716 /** 4717 * Prefix xpattern of IMSI (International Mobile Subscriber Identity). 4718 * <P>Type: TEXT </P> 4719 */ 4720 public static final String IMSI_PREFIX_XPATTERN = "imsi_prefix_xpattern"; 4721 4722 /** 4723 * Service Provider Name. 4724 * <P>Type: TEXT </P> 4725 */ 4726 public static final String SPN = "spn"; 4727 4728 /** 4729 * Prefer APN name. 4730 * <P>Type: TEXT </P> 4731 */ 4732 public static final String APN = "apn"; 4733 4734 /** 4735 * Prefix of Integrated Circuit Card Identifier. 4736 * <P>Type: TEXT </P> 4737 */ 4738 public static final String ICCID_PREFIX = "iccid_prefix"; 4739 4740 /** 4741 * Certificate for carrier privilege access rules. 4742 * <P>Type: TEXT in hex string </P> 4743 */ 4744 public static final String PRIVILEGE_ACCESS_RULE = "privilege_access_rule"; 4745 4746 /** 4747 * The {@code content://} URI for this table. 4748 */ 4749 @NonNull 4750 public static final Uri CONTENT_URI = Uri.parse("content://carrier_id/all"); 4751 } 4752 } 4753 4754 /** 4755 * Contains SIM Information 4756 * @hide 4757 */ 4758 public static final class SimInfo { 4759 /** 4760 * Not instantiable. 4761 * @hide 4762 */ SimInfo()4763 private SimInfo() {} 4764 4765 /** 4766 * The {@code content://} style URI for this provider. 4767 * @hide 4768 */ 4769 @NonNull 4770 public static final Uri CONTENT_URI = Uri.parse("content://telephony/siminfo"); 4771 4772 /** 4773 * TelephonyProvider unique key column name is the subscription id. 4774 * <P>Type: TEXT (String)</P> 4775 * 4776 * @hide 4777 */ 4778 public static final String COLUMN_UNIQUE_KEY_SUBSCRIPTION_ID = "_id"; 4779 4780 /** 4781 * TelephonyProvider column name for a unique identifier for the subscription within the 4782 * specific subscription type. For example, it contains SIM ICC Identifier subscriptions 4783 * on Local SIMs. and Mac-address for Remote-SIM Subscriptions for Bluetooth devices. 4784 * <P>Type: TEXT (String)</P> 4785 * 4786 * @hide 4787 */ 4788 public static final String COLUMN_ICC_ID = "icc_id"; 4789 4790 /** 4791 * TelephonyProvider column name for user SIM_SlOT_INDEX 4792 * <P>Type: INTEGER (int)</P> 4793 * 4794 * @hide 4795 */ 4796 public static final String COLUMN_SIM_SLOT_INDEX = "sim_id"; 4797 4798 /** 4799 * SIM is not inserted 4800 * @hide 4801 */ 4802 public static final int SIM_NOT_INSERTED = -1; 4803 4804 /** 4805 * TelephonyProvider column name Subscription-type. 4806 * <P>Type: INTEGER (int)</P> {@link #SUBSCRIPTION_TYPE_LOCAL_SIM} for Local-SIM 4807 * Subscriptions, {@link #SUBSCRIPTION_TYPE_REMOTE_SIM} for Remote-SIM Subscriptions. 4808 * Default value is 0. 4809 * 4810 * @hide 4811 */ 4812 public static final String COLUMN_SUBSCRIPTION_TYPE = "subscription_type"; 4813 4814 /** 4815 * This constant is to designate a subscription as a Local-SIM Subscription. 4816 * <p> A Local-SIM can be a physical SIM inserted into a sim-slot in the device, or eSIM on 4817 * the device. 4818 * </p> 4819 * 4820 * @hide 4821 */ 4822 public static final int SUBSCRIPTION_TYPE_LOCAL_SIM = 0; 4823 4824 /** 4825 * This constant is to designate a subscription as a Remote-SIM Subscription. 4826 * <p> 4827 * A Remote-SIM subscription is for a SIM on a phone connected to this device via some 4828 * connectivity mechanism, for example bluetooth. Similar to Local SIM, this subscription 4829 * can be used for SMS, Voice and data by proxying data through the connected device. 4830 * Certain data of the SIM, such as IMEI, are not accessible for Remote SIMs. 4831 * </p> 4832 * 4833 * <p> 4834 * A Remote-SIM is available only as long the phone stays connected to this device. 4835 * When the phone disconnects, Remote-SIM subscription is removed from this device and is 4836 * no longer known. All data associated with the subscription, such as stored SMS, call 4837 * logs, contacts etc, are removed from this device. 4838 * </p> 4839 * 4840 * <p> 4841 * If the phone re-connects to this device, a new Remote-SIM subscription is created for 4842 * the phone. The Subscription Id associated with the new subscription is different from 4843 * the Subscription Id of the previous Remote-SIM subscription created (and removed) for the 4844 * phone; i.e., new Remote-SIM subscription treats the reconnected phone as a Remote-SIM 4845 * that was never seen before. 4846 * </p> 4847 * 4848 * @hide 4849 */ 4850 public static final int SUBSCRIPTION_TYPE_REMOTE_SIM = 1; 4851 4852 /** 4853 * TelephonyProvider column name data_enabled_override_rules. 4854 * It's a list of rules for overriding data enabled settings. The syntax is 4855 * For example, "mms=nonDefault" indicates enabling data for mms in non-default 4856 * subscription. 4857 * "default=nonDefault&inVoiceCall" indicates enabling data for internet in non-default 4858 * subscription and while is in voice call. 4859 * 4860 * Default value is empty string. 4861 * 4862 * @hide 4863 */ 4864 public static final String COLUMN_DATA_ENABLED_OVERRIDE_RULES = 4865 "data_enabled_override_rules"; 4866 4867 /** 4868 * TelephonyProvider column name for user displayed name. 4869 * <P>Type: TEXT (String)</P> 4870 * 4871 * @hide 4872 */ 4873 public static final String COLUMN_DISPLAY_NAME = "display_name"; 4874 4875 /** 4876 * TelephonyProvider column name for the service provider name for the SIM. 4877 * <P>Type: TEXT (String)</P> 4878 * 4879 * @hide 4880 */ 4881 public static final String COLUMN_CARRIER_NAME = "carrier_name"; 4882 4883 /** 4884 * TelephonyProvider column name for source of the user displayed name. 4885 * <P>Type: INT (int)</P> with one of the NAME_SOURCE_XXXX values below 4886 * 4887 * @hide 4888 */ 4889 public static final String COLUMN_NAME_SOURCE = "name_source"; 4890 4891 /** The name_source is from the carrier id. {@hide} */ 4892 public static final int NAME_SOURCE_CARRIER_ID = 0; 4893 4894 /** 4895 * The name_source is from SIM EF_SPN. 4896 * @hide 4897 */ 4898 public static final int NAME_SOURCE_SIM_SPN = 1; 4899 4900 /** 4901 * The name_source is from user input 4902 * @hide 4903 */ 4904 public static final int NAME_SOURCE_USER_INPUT = 2; 4905 4906 /** 4907 * The name_source is carrier (carrier app, carrier config, etc.) 4908 * @hide 4909 */ 4910 public static final int NAME_SOURCE_CARRIER = 3; 4911 4912 /** 4913 * The name_source is from SIM EF_PNN. 4914 * @hide 4915 */ 4916 public static final int NAME_SOURCE_SIM_PNN = 4; 4917 4918 /** 4919 * TelephonyProvider column name for the color of a SIM. 4920 * <P>Type: INTEGER (int)</P> 4921 * 4922 * @hide 4923 */ 4924 public static final String COLUMN_COLOR = "color"; 4925 4926 /** The default color of a SIM {@hide} */ 4927 public static final int COLOR_DEFAULT = 0; 4928 4929 /** 4930 * TelephonyProvider column name for the phone number of a SIM. 4931 * <P>Type: TEXT (String)</P> 4932 * 4933 * @hide 4934 */ 4935 public static final String COLUMN_NUMBER = "number"; 4936 4937 /** 4938 * TelephonyProvider column name for the number display format of a SIM. 4939 * <P>Type: INTEGER (int)</P> 4940 * 4941 * @hide 4942 */ 4943 public static final String COLUMN_DISPLAY_NUMBER_FORMAT = "display_number_format"; 4944 4945 /** 4946 * TelephonyProvider column name for the default display format of a SIM 4947 * @hide 4948 */ 4949 public static final int DISPLAY_NUMBER_DEFAULT = 1; 4950 4951 /** 4952 * TelephonyProvider column name for whether data roaming is enabled. 4953 * <P>Type: INTEGER (int)</P> 4954 * 4955 * @hide 4956 */ 4957 public static final String COLUMN_DATA_ROAMING = "data_roaming"; 4958 4959 /** Indicates that data roaming is enabled for a subscription {@hide} */ 4960 public static final int DATA_ROAMING_ENABLE = 1; 4961 4962 /** Indicates that data roaming is disabled for a subscription {@hide} */ 4963 public static final int DATA_ROAMING_DISABLE = 0; 4964 4965 /** 4966 * TelephonyProvider column name for subscription carrier id. 4967 * @see TelephonyManager#getSimCarrierId() 4968 * <p>Type: INTEGER (int) </p> 4969 * 4970 * @hide 4971 */ 4972 public static final String COLUMN_CARRIER_ID = "carrier_id"; 4973 4974 /** 4975 * A comma-separated list of EHPLMNs associated with the subscription 4976 * <P>Type: TEXT (String)</P> 4977 * 4978 * @hide 4979 */ 4980 public static final String COLUMN_EHPLMNS = "ehplmns"; 4981 4982 /** 4983 * A comma-separated list of HPLMNs associated with the subscription 4984 * <P>Type: TEXT (String)</P> 4985 * 4986 * @hide 4987 */ 4988 public static final String COLUMN_HPLMNS = "hplmns"; 4989 4990 /** 4991 * TelephonyProvider column name for the MCC associated with a SIM, stored as a string. 4992 * <P>Type: TEXT (String)</P> 4993 * 4994 * @hide 4995 */ 4996 public static final String COLUMN_MCC_STRING = "mcc_string"; 4997 4998 /** 4999 * TelephonyProvider column name for the MNC associated with a SIM, stored as a string. 5000 * <P>Type: TEXT (String)</P> 5001 * 5002 * @hide 5003 */ 5004 public static final String COLUMN_MNC_STRING = "mnc_string"; 5005 5006 /** 5007 * TelephonyProvider column name for the MCC associated with a SIM. 5008 * <P>Type: INTEGER (int)</P> 5009 * 5010 * @hide 5011 */ 5012 public static final String COLUMN_MCC = "mcc"; 5013 5014 /** 5015 * TelephonyProvider column name for the MNC associated with a SIM. 5016 * <P>Type: INTEGER (int)</P> 5017 * 5018 * @hide 5019 */ 5020 public static final String COLUMN_MNC = "mnc"; 5021 5022 /** 5023 * TelephonyProvider column name for the iso country code associated with a SIM. 5024 * <P>Type: TEXT (String)</P> 5025 * 5026 * @hide 5027 */ 5028 public static final String COLUMN_ISO_COUNTRY_CODE = "iso_country_code"; 5029 5030 /** 5031 * TelephonyProvider column name for the sim provisioning status associated with a SIM. 5032 * <P>Type: INTEGER (int)</P> 5033 * 5034 * @hide 5035 */ 5036 public static final String COLUMN_SIM_PROVISIONING_STATUS = "sim_provisioning_status"; 5037 5038 /** The sim is provisioned {@hide} */ 5039 public static final int SIM_PROVISIONED = 0; 5040 5041 /** 5042 * TelephonyProvider column name for whether a subscription is embedded (that is, present on 5043 * an eSIM). 5044 * <p>Type: INTEGER (int), 1 for embedded or 0 for non-embedded. 5045 * 5046 * @hide 5047 */ 5048 public static final String COLUMN_IS_EMBEDDED = "is_embedded"; 5049 5050 /** 5051 * TelephonyProvider column name for SIM card identifier. For UICC card it is the ICCID of 5052 * the current enabled profile on the card, while for eUICC card it is the EID of the card. 5053 * <P>Type: TEXT (String)</P> 5054 * 5055 * @hide 5056 */ 5057 public static final String COLUMN_CARD_ID = "card_id"; 5058 5059 /** 5060 * TelephonyProvider column name for the encoded {@link UiccAccessRule}s from 5061 * {@link UiccAccessRule#encodeRules}. Only present if {@link #COLUMN_IS_EMBEDDED} is 1. 5062 * <p>TYPE: BLOB 5063 * 5064 * @hide 5065 */ 5066 public static final String COLUMN_ACCESS_RULES = "access_rules"; 5067 5068 /** 5069 * TelephonyProvider column name for the encoded {@link UiccAccessRule}s from 5070 * {@link UiccAccessRule#encodeRules} but for the rules that come from CarrierConfigs. 5071 * Only present if there are access rules in CarrierConfigs 5072 * <p>TYPE: BLOB 5073 * 5074 * @hide 5075 */ 5076 public static final String COLUMN_ACCESS_RULES_FROM_CARRIER_CONFIGS = 5077 "access_rules_from_carrier_configs"; 5078 5079 /** 5080 * TelephonyProvider column name identifying whether an embedded subscription is on a 5081 * removable card. Such subscriptions are marked inaccessible as soon as the current card 5082 * is removed. Otherwise, they will remain accessible unless explicitly deleted. Only 5083 * present if {@link #COLUMN_IS_EMBEDDED} is 1. 5084 * <p>TYPE: INTEGER (int), 1 for removable or 0 for non-removable. 5085 * 5086 * @hide 5087 */ 5088 public static final String COLUMN_IS_REMOVABLE = "is_removable"; 5089 5090 /** TelephonyProvider column name for extreme threat in CB settings {@hide} */ 5091 public static final String COLUMN_CB_EXTREME_THREAT_ALERT = 5092 "enable_cmas_extreme_threat_alerts"; 5093 5094 /** TelephonyProvider column name for severe threat in CB settings {@hide} */ 5095 public static final String COLUMN_CB_SEVERE_THREAT_ALERT = 5096 "enable_cmas_severe_threat_alerts"; 5097 5098 /** TelephonyProvider column name for amber alert in CB settings {@hide} */ 5099 public static final String COLUMN_CB_AMBER_ALERT = "enable_cmas_amber_alerts"; 5100 5101 /** TelephonyProvider column name for emergency alert in CB settings {@hide} */ 5102 public static final String COLUMN_CB_EMERGENCY_ALERT = "enable_emergency_alerts"; 5103 5104 /** TelephonyProvider column name for alert sound duration in CB settings {@hide} */ 5105 public static final String COLUMN_CB_ALERT_SOUND_DURATION = "alert_sound_duration"; 5106 5107 /** TelephonyProvider column name for alert reminder interval in CB settings {@hide} */ 5108 public static final String COLUMN_CB_ALERT_REMINDER_INTERVAL = "alert_reminder_interval"; 5109 5110 /** TelephonyProvider column name for enabling vibrate in CB settings {@hide} */ 5111 public static final String COLUMN_CB_ALERT_VIBRATE = "enable_alert_vibrate"; 5112 5113 /** TelephonyProvider column name for enabling alert speech in CB settings {@hide} */ 5114 public static final String COLUMN_CB_ALERT_SPEECH = "enable_alert_speech"; 5115 5116 /** TelephonyProvider column name for ETWS test alert in CB settings {@hide} */ 5117 public static final String COLUMN_CB_ETWS_TEST_ALERT = "enable_etws_test_alerts"; 5118 5119 /** TelephonyProvider column name for enable channel50 alert in CB settings {@hide} */ 5120 public static final String COLUMN_CB_CHANNEL_50_ALERT = "enable_channel_50_alerts"; 5121 5122 /** TelephonyProvider column name for CMAS test alert in CB settings {@hide} */ 5123 public static final String COLUMN_CB_CMAS_TEST_ALERT = "enable_cmas_test_alerts"; 5124 5125 /** TelephonyProvider column name for Opt out dialog in CB settings {@hide} */ 5126 public static final String COLUMN_CB_OPT_OUT_DIALOG = "show_cmas_opt_out_dialog"; 5127 5128 /** 5129 * TelephonyProvider column name for enable Volte. 5130 * 5131 * If this setting is not initialized (set to -1) then we use the Carrier Config value 5132 * {@link CarrierConfigManager#KEY_ENHANCED_4G_LTE_ON_BY_DEFAULT_BOOL}. 5133 * 5134 * @hide 5135 */ 5136 public static final String COLUMN_ENHANCED_4G_MODE_ENABLED = "volte_vt_enabled"; 5137 5138 /** TelephonyProvider column name for enable VT (Video Telephony over IMS) {@hide} */ 5139 public static final String COLUMN_VT_IMS_ENABLED = "vt_ims_enabled"; 5140 5141 /** TelephonyProvider column name for enable Wifi calling {@hide} */ 5142 public static final String COLUMN_WFC_IMS_ENABLED = "wfc_ims_enabled"; 5143 5144 /** TelephonyProvider column name for Wifi calling mode {@hide} */ 5145 public static final String COLUMN_WFC_IMS_MODE = "wfc_ims_mode"; 5146 5147 /** TelephonyProvider column name for Wifi calling mode in roaming {@hide} */ 5148 public static final String COLUMN_WFC_IMS_ROAMING_MODE = "wfc_ims_roaming_mode"; 5149 5150 /** TelephonyProvider column name for enable Wifi calling in roaming {@hide} */ 5151 public static final String COLUMN_WFC_IMS_ROAMING_ENABLED = "wfc_ims_roaming_enabled"; 5152 5153 /** 5154 * TelephonyProvider column name for determining if the user has enabled IMS RCS User 5155 * Capability Exchange (UCE) for this subscription. 5156 * 5157 * @hide 5158 */ 5159 public static final String COLUMN_IMS_RCS_UCE_ENABLED = "ims_rcs_uce_enabled"; 5160 5161 /** 5162 * TelephonyProvider column name for whether a subscription is opportunistic, that is, 5163 * whether the network it connects to is limited in functionality or coverage. 5164 * For example, CBRS. 5165 * <p>Type: INTEGER (int), 1 for opportunistic or 0 for non-opportunistic. 5166 * 5167 * @hide 5168 */ 5169 public static final String COLUMN_IS_OPPORTUNISTIC = "is_opportunistic"; 5170 5171 /** 5172 * TelephonyProvider column name for group ID. Subscriptions with same group ID 5173 * are considered bundled together, and should behave as a single subscription at 5174 * certain scenarios. 5175 * 5176 * @hide 5177 */ 5178 public static final String COLUMN_GROUP_UUID = "group_uuid"; 5179 5180 /** 5181 * TelephonyProvider column name for group owner. It's the package name who created 5182 * the subscription group. 5183 * 5184 * @hide 5185 */ 5186 public static final String COLUMN_GROUP_OWNER = "group_owner"; 5187 5188 /** 5189 * TelephonyProvider column name for whether a subscription is metered or not, that is, 5190 * whether the network it connects to charges for subscription or not. For example, paid 5191 * CBRS or unpaid. 5192 * 5193 * @hide 5194 */ 5195 public static final String COLUMN_IS_METERED = "is_metered"; 5196 5197 /** 5198 * TelephonyProvider column name for the profile class of a subscription 5199 * Only present if {@link #COLUMN_IS_EMBEDDED} is 1. 5200 * <P>Type: INTEGER (int)</P> 5201 * 5202 * @hide 5203 */ 5204 public static final String COLUMN_PROFILE_CLASS = "profile_class"; 5205 5206 /** 5207 * A testing profile can be pre-loaded or downloaded onto 5208 * the eUICC and provides connectivity to test equipment 5209 * for the purpose of testing the device and the eUICC. It 5210 * is not intended to store any operator credentials. 5211 * 5212 * @hide 5213 */ 5214 public static final int PROFILE_CLASS_TESTING = 0; 5215 5216 /** 5217 * A provisioning profile is pre-loaded onto the eUICC and 5218 * provides connectivity to a mobile network solely for the 5219 * purpose of provisioning profiles. 5220 * 5221 * @hide 5222 */ 5223 public static final int PROFILE_CLASS_PROVISIONING = 1; 5224 5225 /** 5226 * An operational profile can be pre-loaded or downloaded 5227 * onto the eUICC and provides services provided by the 5228 * operator. 5229 * 5230 * @hide 5231 */ 5232 public static final int PROFILE_CLASS_OPERATIONAL = 2; 5233 5234 /** 5235 * The profile class is unset. This occurs when profile class 5236 * info is not available. The subscription either has no profile 5237 * metadata or the profile metadata did not encode profile class. 5238 * 5239 * @hide 5240 */ 5241 public static final int PROFILE_CLASS_UNSET = -1; 5242 5243 /** 5244 * IMSI (International Mobile Subscriber Identity). 5245 * <P>Type: TEXT </P> 5246 * 5247 * @hide 5248 */ 5249 public static final String COLUMN_IMSI = "imsi"; 5250 5251 /** 5252 * Whether uicc applications is set to be enabled or disabled. By default it's enabled. 5253 * @hide 5254 */ 5255 public static final String COLUMN_UICC_APPLICATIONS_ENABLED = "uicc_applications_enabled"; 5256 5257 /** 5258 * TelephonyProvider column name for allowed network types. Indicate which network types 5259 * are allowed. Default is -1. 5260 * <P>Type: BIGINT (long) </P> 5261 * 5262 * @hide 5263 */ 5264 public static final String COLUMN_ALLOWED_NETWORK_TYPES = "allowed_network_types"; 5265 } 5266 } 5267