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, the device can only use APNs with the same set id as the selected APN. 3950 * <p>Type: INTEGER</p> 3951 * @hide 3952 */ 3953 @SystemApi 3954 public static final String APN_SET_ID = "apn_set_id"; 3955 3956 /** 3957 * Possible value for the {@link #APN_SET_ID} field. By default APNs are added to set 0. 3958 * <p>Type: INTEGER</p> 3959 * @hide 3960 */ 3961 @SystemApi 3962 public static final int NO_APN_SET_ID = 0; 3963 3964 /** 3965 * Possible value for the {@link #APN_SET_ID} field. 3966 * APNs with MATCH_ALL_APN_SET_ID will be used regardless of any set ids of 3967 * the selected APN. 3968 * <p>Type: INTEGER</p> 3969 * @hide 3970 */ 3971 public static final int MATCH_ALL_APN_SET_ID = -1; 3972 3973 /** 3974 * A unique carrier id associated with this APN 3975 * {@see TelephonyManager#getSimCarrierId()} 3976 * <p>Type: STRING</p> 3977 */ 3978 public static final String CARRIER_ID = "carrier_id"; 3979 3980 /** 3981 * The skip 464xlat flag. Flag works as follows. 3982 * {@link #SKIP_464XLAT_DEFAULT}: the APN will skip only APN is IMS and no internet. 3983 * {@link #SKIP_464XLAT_DISABLE}: the APN will NOT skip 464xlat 3984 * {@link #SKIP_464XLAT_ENABLE}: the APN will skip 464xlat 3985 * <p>Type: INTEGER</p> 3986 * 3987 * @hide 3988 */ 3989 public static final String SKIP_464XLAT = "skip_464xlat"; 3990 3991 /** 3992 * Possible value for the {@link #SKIP_464XLAT} field. 3993 * <p>Type: INTEGER</p> 3994 * 3995 * @hide 3996 */ 3997 public static final int SKIP_464XLAT_DEFAULT = -1; 3998 3999 /** 4000 * Possible value for the {@link #SKIP_464XLAT} field. 4001 * <p>Type: INTEGER</p> 4002 * 4003 * @hide 4004 */ 4005 public static final int SKIP_464XLAT_DISABLE = 0; 4006 4007 /** 4008 * Possible value for the {@link #SKIP_464XLAT} field. 4009 * <p>Type: INTEGER</p> 4010 * 4011 * @hide 4012 */ 4013 public static final int SKIP_464XLAT_ENABLE = 1; 4014 4015 4016 /** @hide */ 4017 @IntDef({ 4018 UNEDITED, 4019 USER_EDITED, 4020 USER_DELETED, 4021 CARRIER_DELETED, 4022 CARRIER_EDITED, 4023 }) 4024 @Retention(RetentionPolicy.SOURCE) 4025 public @interface EditStatus {} 4026 4027 /** 4028 * Compat framework change ID for the APN db read permission change. 4029 * 4030 * In API level 30 and beyond, accessing the APN database will require the 4031 * {@link android.Manifest.permission#WRITE_APN_SETTINGS} permission. This change ID tracks 4032 * apps that are affected because they don't hold this permission. 4033 * @hide 4034 */ 4035 @ChangeId 4036 @EnabledAfter(targetSdkVersion = android.os.Build.VERSION_CODES.Q) 4037 public static final long APN_READING_PERMISSION_CHANGE_ID = 124107808L; 4038 } 4039 4040 /** 4041 * Contains received cell broadcast messages. More details are available in 3GPP TS 23.041. 4042 * @hide 4043 */ 4044 @SystemApi 4045 @TestApi 4046 public static final class CellBroadcasts implements BaseColumns { 4047 4048 /** 4049 * Not instantiable. 4050 * @hide 4051 */ CellBroadcasts()4052 private CellBroadcasts() {} 4053 4054 /** 4055 * The {@code content://} URI for this table. 4056 * Only privileged framework components running on phone or network stack uid can 4057 * query or modify this table. 4058 */ 4059 @NonNull 4060 public static final Uri CONTENT_URI = Uri.parse("content://cellbroadcasts"); 4061 4062 /** 4063 * The {@code content://} URI for query cellbroadcast message history. 4064 * query results include following entries 4065 * <ul> 4066 * <li>{@link #_ID}</li> 4067 * <li>{@link #SLOT_INDEX}</li> 4068 * <li>{@link #GEOGRAPHICAL_SCOPE}</li> 4069 * <li>{@link #PLMN}</li> 4070 * <li>{@link #LAC}</li> 4071 * <li>{@link #CID}</li> 4072 * <li>{@link #SERIAL_NUMBER}</li> 4073 * <li>{@link #SERVICE_CATEGORY}</li> 4074 * <li>{@link #LANGUAGE_CODE}</li> 4075 * <li>{@link #MESSAGE_BODY}</li> 4076 * <li>{@link #DELIVERY_TIME}</li> 4077 * <li>{@link #MESSAGE_READ}</li> 4078 * <li>{@link #MESSAGE_FORMAT}</li> 4079 * <li>{@link #MESSAGE_PRIORITY}</li> 4080 * <li>{@link #ETWS_WARNING_TYPE}</li> 4081 * <li>{@link #CMAS_MESSAGE_CLASS}</li> 4082 * <li>{@link #CMAS_CATEGORY}</li> 4083 * <li>{@link #CMAS_RESPONSE_TYPE}</li> 4084 * <li>{@link #CMAS_SEVERITY}</li> 4085 * <li>{@link #CMAS_URGENCY}</li> 4086 * <li>{@link #CMAS_CERTAINTY}</li> 4087 * </ul> 4088 */ 4089 @RequiresPermission(Manifest.permission.READ_CELL_BROADCASTS) 4090 @NonNull 4091 public static final Uri MESSAGE_HISTORY_URI = Uri.parse("content://cellbroadcasts/history"); 4092 4093 /** 4094 * The authority for the legacy cellbroadcast provider. 4095 * This is used for OEM data migration. OEMs want to migrate message history or 4096 * sharepreference data to mainlined cellbroadcastreceiver app, should have a 4097 * contentprovider with authority: cellbroadcast-legacy. Mainlined cellbroadcastreceiver 4098 * will interact with this URI to retrieve data and persists to mainlined cellbroadcast app. 4099 * 4100 * @hide 4101 */ 4102 @SystemApi 4103 public static final @NonNull String AUTHORITY_LEGACY = "cellbroadcast-legacy"; 4104 4105 /** 4106 * A content:// style uri to the authority for the legacy cellbroadcast provider. 4107 * @hide 4108 */ 4109 @SystemApi 4110 public static final @NonNull Uri AUTHORITY_LEGACY_URI = 4111 Uri.parse("content://cellbroadcast-legacy"); 4112 4113 /** 4114 * Method name to {@link android.content.ContentProvider#call(String, String, Bundle) 4115 * for {@link #AUTHORITY_LEGACY}. Used to query cellbroadcast {@link Preference}, 4116 * containing following supported entries 4117 * <ul> 4118 * <li>{@link #ENABLE_AREA_UPDATE_INFO_PREF}</li> 4119 * <li>{@link #ENABLE_TEST_ALERT_PREF}</li> 4120 * <li>{@link #ENABLE_STATE_LOCAL_TEST_PREF}</li> 4121 * <li>{@link #ENABLE_PUBLIC_SAFETY_PREF}</li> 4122 * <li>{@link #ENABLE_CMAS_AMBER_PREF}</li> 4123 * <li>{@link #ENABLE_CMAS_SEVERE_THREAT_PREF}</li> 4124 * <li>{@link #ENABLE_CMAS_EXTREME_THREAT_PREF}</li> 4125 * <li>{@link #ENABLE_CMAS_PRESIDENTIAL_PREF}</li> 4126 * <li>{@link #ENABLE_ALERT_VIBRATION_PREF}</li> 4127 * <li>{@link #ENABLE_EMERGENCY_PERF}</li> 4128 * <li>{@link #ENABLE_CMAS_IN_SECOND_LANGUAGE_PREF}</li> 4129 * </ul> 4130 * @hide 4131 */ 4132 @SystemApi 4133 public static final @NonNull String CALL_METHOD_GET_PREFERENCE = "get_preference"; 4134 4135 /** 4136 * Arg name to {@link android.content.ContentProvider#call(String, String, Bundle)} 4137 * for {@link #AUTHORITY_LEGACY}. 4138 * Contains all supported shared preferences for cellbroadcast. 4139 * 4140 * @hide 4141 */ 4142 @SystemApi 4143 public static final class Preference { 4144 /** 4145 * Not Instantiatable. 4146 * @hide 4147 */ Preference()4148 private Preference() {} 4149 4150 /** Preference to enable area update info alert */ 4151 public static final @NonNull String ENABLE_AREA_UPDATE_INFO_PREF = 4152 "enable_area_update_info_alerts"; 4153 4154 /** Preference to enable test alert */ 4155 public static final @NonNull String ENABLE_TEST_ALERT_PREF = 4156 "enable_test_alerts"; 4157 4158 /** Preference to enable state local test alert */ 4159 public static final @NonNull String ENABLE_STATE_LOCAL_TEST_PREF 4160 = "enable_state_local_test_alerts"; 4161 4162 /** Preference to enable public safety alert */ 4163 public static final @NonNull String ENABLE_PUBLIC_SAFETY_PREF 4164 = "enable_public_safety_messages"; 4165 4166 /** Preference to enable amber alert */ 4167 public static final @NonNull String ENABLE_CMAS_AMBER_PREF 4168 = "enable_cmas_amber_alerts"; 4169 4170 /** Preference to enable severe threat alert */ 4171 public static final @NonNull String ENABLE_CMAS_SEVERE_THREAT_PREF 4172 = "enable_cmas_severe_threat_alerts"; 4173 4174 /** Preference to enable extreme threat alert */ 4175 public static final @NonNull String ENABLE_CMAS_EXTREME_THREAT_PREF = 4176 "enable_cmas_extreme_threat_alerts"; 4177 4178 /** Preference to enable presidential alert */ 4179 public static final @NonNull String ENABLE_CMAS_PRESIDENTIAL_PREF = 4180 "enable_cmas_presidential_alerts"; 4181 4182 /** Preference to enable alert vibration */ 4183 public static final @NonNull String ENABLE_ALERT_VIBRATION_PREF = 4184 "enable_alert_vibrate"; 4185 4186 /** Preference to enable emergency alert */ 4187 public static final @NonNull String ENABLE_EMERGENCY_PERF = 4188 "enable_emergency_alerts"; 4189 4190 /** Preference to enable receive alerts in second language */ 4191 public static final @NonNull String ENABLE_CMAS_IN_SECOND_LANGUAGE_PREF = 4192 "receive_cmas_in_second_language"; 4193 } 4194 4195 /** 4196 * The subscription which received this cell broadcast message. 4197 * <P>Type: INTEGER</P> 4198 */ 4199 public static final String SUBSCRIPTION_ID = "sub_id"; 4200 4201 /** 4202 * The slot which received this cell broadcast message. 4203 * <P>Type: INTEGER</P> 4204 */ 4205 public static final String SLOT_INDEX = "slot_index"; 4206 4207 /** 4208 * Message geographical scope. Valid values are: 4209 * <ul> 4210 * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_CELL_WIDE}. meaning the 4211 * message is for the radio service cell</li> 4212 * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_CELL_WIDE_IMMEDIATE}, 4213 * meaning the message is for the radio service cell and immediately displayed</li> 4214 * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_PLMN_WIDE}, meaning the 4215 * message is for the PLMN (i.e. MCC/MNC)</li> 4216 * <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_LOCATION_AREA_WIDE}, 4217 * meaning the message is for the location area (in GSM) or service area (in UMTS)</li> 4218 * </ul> 4219 * 4220 * <p>A message meant for a particular scope is automatically dismissed when the device 4221 * exits that scope.</p> 4222 * <P>Type: INTEGER</P> 4223 */ 4224 public static final String GEOGRAPHICAL_SCOPE = "geo_scope"; 4225 4226 /** 4227 * Message serial number. 4228 * <p> 4229 * A 16-bit integer which identifies a particular CBS (cell 4230 * broadcast short message service) message. The core network is responsible for 4231 * allocating this value, and the value may be managed cyclically (3GPP TS 23.041 section 4232 * 9.2.1) once the serial message has been incremented a sufficient number of times. 4233 * </p> 4234 * <P>Type: INTEGER</P> 4235 */ 4236 public static final String SERIAL_NUMBER = "serial_number"; 4237 4238 /** 4239 * PLMN (i.e. MCC/MNC) of broadcast sender. {@code SERIAL_NUMBER + PLMN + LAC + CID} 4240 * uniquely identifies a broadcast for duplicate detection purposes. 4241 * <P>Type: TEXT</P> 4242 */ 4243 public static final String PLMN = "plmn"; 4244 4245 /** 4246 * Location area code (LAC). 4247 * <p>Code representing location area (GSM) or service area (UMTS) of broadcast sender. 4248 * Unused for CDMA. Only included if Geographical Scope of message is not PLMN wide (01). 4249 * This value is sent by the network based on the cell tower. 4250 * <P>Type: INTEGER</P> 4251 */ 4252 public static final String LAC = "lac"; 4253 4254 /** 4255 * Cell ID of message sender (GSM/UMTS). Unused for CDMA. Only included when the 4256 * Geographical Scope of message is cell wide (00 or 11). 4257 * <P>Type: INTEGER</P> 4258 */ 4259 public static final String CID = "cid"; 4260 4261 /** 4262 * Service category which represents the general topic of the message. 4263 * <p> 4264 * For GSM/UMTS: message identifier (see 3GPP TS 23.041 section 9.4.1.2.2) 4265 * For CDMA: a 16-bit CDMA service category (see 3GPP2 C.R1001-D section 9.3) 4266 * </p> 4267 * <P>Type: INTEGER</P> 4268 */ 4269 public static final String SERVICE_CATEGORY = "service_category"; 4270 4271 /** 4272 * Message language code. (See 3GPP TS 23.041 section 9.4.1.2.3 for details). 4273 * <P>Type: TEXT</P> 4274 */ 4275 public static final String LANGUAGE_CODE = "language"; 4276 4277 /** 4278 * Dats coding scheme of the message. 4279 * <p> 4280 * The data coding scheme (dcs) value defined in 3GPP TS 23.038 section 4 4281 * </p> 4282 * <P>Type: INTEGER</P> 4283 */ 4284 public static final String DATA_CODING_SCHEME = "dcs"; 4285 4286 /** 4287 * Message body. 4288 * <P>Type: TEXT</P> 4289 */ 4290 public static final String MESSAGE_BODY = "body"; 4291 4292 /** 4293 * Message delivery time. 4294 * <p>This value is a system timestamp using {@link System#currentTimeMillis}</p> 4295 * <P>Type: INTEGER (long)</P> 4296 */ 4297 public static final String DELIVERY_TIME = "date"; 4298 4299 /** 4300 * Has the message been viewed? 4301 * <P>Type: INTEGER (boolean)</P> 4302 */ 4303 public static final String MESSAGE_READ = "read"; 4304 4305 /** 4306 * Message format ({@link android.telephony.SmsCbMessage#MESSAGE_FORMAT_3GPP} or 4307 * {@link android.telephony.SmsCbMessage#MESSAGE_FORMAT_3GPP2}). 4308 * <P>Type: INTEGER</P> 4309 */ 4310 public static final String MESSAGE_FORMAT = "format"; 4311 4312 /** 4313 * Message priority. 4314 * <p>This includes 4315 * <ul> 4316 * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_NORMAL}</li> 4317 * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_INTERACTIVE}</li> 4318 * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_URGENT}</li> 4319 * <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_EMERGENCY}</li> 4320 * </p> 4321 * </ul> 4322 * <P>Type: INTEGER</P> 4323 */ 4324 public static final String MESSAGE_PRIORITY = "priority"; 4325 4326 /** 4327 * ETWS (Earthquake and Tsunami Warning System) warning type (ETWS alerts only). 4328 * <p>See {@link android.telephony.SmsCbEtwsInfo}</p> 4329 * <P>Type: INTEGER</P> 4330 */ 4331 public static final String ETWS_WARNING_TYPE = "etws_warning_type"; 4332 4333 /** 4334 * ETWS (Earthquake and Tsunami Warning System) primary message or not (ETWS alerts only). 4335 * <p>See {@link android.telephony.SmsCbEtwsInfo}</p> 4336 * <P>Type: BOOLEAN</P> 4337 * 4338 * @hide // TODO: Unhide this for S. 4339 */ 4340 public static final String ETWS_IS_PRIMARY = "etws_is_primary"; 4341 4342 /** 4343 * CMAS (Commercial Mobile Alert System) message class (CMAS alerts only). 4344 * <p>See {@link android.telephony.SmsCbCmasInfo}</p> 4345 * <P>Type: INTEGER</P> 4346 */ 4347 public static final String CMAS_MESSAGE_CLASS = "cmas_message_class"; 4348 4349 /** 4350 * CMAS category (CMAS alerts only). 4351 * <P>Type: INTEGER</P> 4352 */ 4353 public static final String CMAS_CATEGORY = "cmas_category"; 4354 4355 /** 4356 * CMAS response type (CMAS alerts only). 4357 * <P>Type: INTEGER</P> 4358 */ 4359 public static final String CMAS_RESPONSE_TYPE = "cmas_response_type"; 4360 4361 /** 4362 * CMAS severity (CMAS alerts only). 4363 * <P>Type: INTEGER</P> 4364 */ 4365 public static final String CMAS_SEVERITY = "cmas_severity"; 4366 4367 /** 4368 * CMAS urgency (CMAS alerts only). 4369 * <P>Type: INTEGER</P> 4370 */ 4371 public static final String CMAS_URGENCY = "cmas_urgency"; 4372 4373 /** 4374 * CMAS certainty (CMAS alerts only). 4375 * <P>Type: INTEGER</P> 4376 */ 4377 public static final String CMAS_CERTAINTY = "cmas_certainty"; 4378 4379 /** The default sort order for this table. */ 4380 public static final String DEFAULT_SORT_ORDER = DELIVERY_TIME + " DESC"; 4381 4382 /** 4383 * The timestamp in millisecond, reported by {@link System#currentTimeMillis()}, when the 4384 * device received the message. 4385 * <P>Type: BIGINT</P> 4386 */ 4387 public static final String RECEIVED_TIME = "received_time"; 4388 4389 /** 4390 * The timestamp in millisecond, reported by {@link System#currentTimeMillis()}, when 4391 * location was checked last time. Note this is only applicable to geo-targeting message. 4392 * For non geo-targeting message. the field will be set to -1. 4393 * <P>Type: BIGINT</P> 4394 */ 4395 public static final String LOCATION_CHECK_TIME = "location_check_time"; 4396 /** 4397 * Indicates that whether the message has been broadcasted to the application. 4398 * <P>Type: BOOLEAN</P> 4399 */ 4400 // TODO: deprecate this in S. 4401 public static final String MESSAGE_BROADCASTED = "message_broadcasted"; 4402 4403 /** 4404 * Indicates that whether the message has been displayed to the user. 4405 * <P>Type: BOOLEAN</P> 4406 */ 4407 public static final String MESSAGE_DISPLAYED = "message_displayed"; 4408 4409 /** 4410 * The Warning Area Coordinates Elements. This element is used for geo-fencing purpose. 4411 * 4412 * The geometry and its coordinates are separated vertical bar, the first item is the 4413 * geometry type and the remaining items are the parameter of this geometry. 4414 * 4415 * Only circle and polygon are supported. The coordinates are represented in Horizontal 4416 * coordinates format. 4417 * 4418 * Coordinate encoding: 4419 * "latitude, longitude" 4420 * where -90.00000 <= latitude <= 90.00000 and -180.00000 <= longitude <= 180.00000 4421 * 4422 * Polygon encoding: 4423 * "polygon|lat1,lng1|lat2,lng2|...|latn,lngn" 4424 * lat1,lng1 ... latn,lngn are the vertices coordinate of the polygon. 4425 * 4426 * Circle encoding: 4427 * "circle|lat,lng|radius". 4428 * lat,lng is the center of the circle. The unit of circle's radius is meter. 4429 * 4430 * Example: 4431 * "circle|0,0|100" mean a circle which center located at (0,0) and its radius is 100 meter. 4432 * "polygon|0,1.5|0,1|1,1|1,0" mean a polygon has vertices (0,1.5),(0,1),(1,1),(1,0). 4433 * 4434 * There could be more than one geometry store in this field, they are separated by a 4435 * semicolon. 4436 * 4437 * Example: 4438 * "circle|0,0|100;polygon|0,0|0,1.5|1,1|1,0;circle|100.123,100|200.123" 4439 * 4440 * <P>Type: TEXT</P> 4441 */ 4442 public static final String GEOMETRIES = "geometries"; 4443 4444 /** 4445 * Geo-Fencing Maximum Wait Time in second. The range of the time is [0, 255]. A device 4446 * shall allow to determine its position meeting operator policy. If the device is unable to 4447 * determine its position meeting operator policy within the GeoFencing Maximum Wait Time, 4448 * it shall present the alert to the user and discontinue further positioning determination 4449 * for the alert. 4450 * 4451 * <P>Type: INTEGER</P> 4452 */ 4453 public static final String MAXIMUM_WAIT_TIME = "maximum_wait_time"; 4454 4455 /** 4456 * Query columns for instantiating com.android.cellbroadcastreceiver.CellBroadcastMessage. 4457 * @hide 4458 */ 4459 @NonNull 4460 public static final String[] QUERY_COLUMNS = { 4461 _ID, 4462 GEOGRAPHICAL_SCOPE, 4463 PLMN, 4464 LAC, 4465 CID, 4466 SERIAL_NUMBER, 4467 SERVICE_CATEGORY, 4468 LANGUAGE_CODE, 4469 MESSAGE_BODY, 4470 DELIVERY_TIME, 4471 MESSAGE_READ, 4472 MESSAGE_FORMAT, 4473 MESSAGE_PRIORITY, 4474 ETWS_WARNING_TYPE, 4475 CMAS_MESSAGE_CLASS, 4476 CMAS_CATEGORY, 4477 CMAS_RESPONSE_TYPE, 4478 CMAS_SEVERITY, 4479 CMAS_URGENCY, 4480 CMAS_CERTAINTY 4481 }; 4482 } 4483 4484 /** 4485 * Constants for interfacing with the ServiceStateProvider and the different fields of the 4486 * {@link ServiceState} class accessible through the provider. 4487 */ 4488 public static final class ServiceStateTable { 4489 4490 /** 4491 * Not instantiable. 4492 * @hide 4493 */ ServiceStateTable()4494 private ServiceStateTable() {} 4495 4496 /** 4497 * The authority string for the ServiceStateProvider 4498 */ 4499 public static final String AUTHORITY = "service-state"; 4500 4501 /** 4502 * The {@code content://} style URL for the ServiceStateProvider 4503 */ 4504 public static final Uri CONTENT_URI = Uri.parse("content://service-state/"); 4505 4506 /** 4507 * Generates a content {@link Uri} used to receive updates on a specific field in the 4508 * ServiceState provider. 4509 * <p> 4510 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the 4511 * {@link ServiceState} while your app is running. 4512 * You can also use a {@link android.app.job.JobService} to 4513 * ensure your app is notified of changes to the {@link Uri} even when it is not running. 4514 * Note, however, that using a {@link android.app.job.JobService} 4515 * does not guarantee timely delivery of 4516 * updates to the {@link Uri}. 4517 * 4518 * @param subscriptionId the subscriptionId to receive updates on 4519 * @param field the ServiceState field to receive updates on 4520 * @return the Uri used to observe {@link ServiceState} changes 4521 */ getUriForSubscriptionIdAndField(int subscriptionId, String field)4522 public static Uri getUriForSubscriptionIdAndField(int subscriptionId, String field) { 4523 return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId)) 4524 .appendEncodedPath(field).build(); 4525 } 4526 4527 /** 4528 * Generates a content {@link Uri} used to receive updates on every field in the 4529 * ServiceState provider. 4530 * <p> 4531 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the 4532 * {@link ServiceState} while your app is running. You can also use a 4533 * {@link android.app.job.JobService} to 4534 * ensure your app is notified of changes to the {@link Uri} even when it is not running. 4535 * Note, however, that using a {@link android.app.job.JobService} 4536 * does not guarantee timely delivery of 4537 * updates to the {@link Uri}. 4538 * 4539 * @param subscriptionId the subscriptionId to receive updates on 4540 * @return the Uri used to observe {@link ServiceState} changes 4541 */ getUriForSubscriptionId(int subscriptionId)4542 public static Uri getUriForSubscriptionId(int subscriptionId) { 4543 return CONTENT_URI.buildUpon().appendEncodedPath(String.valueOf(subscriptionId)).build(); 4544 } 4545 4546 /** 4547 * An integer value indicating the current voice service state. 4548 * <p> 4549 * Valid values: {@link ServiceState#STATE_IN_SERVICE}, 4550 * {@link ServiceState#STATE_OUT_OF_SERVICE}, {@link ServiceState#STATE_EMERGENCY_ONLY}, 4551 * {@link ServiceState#STATE_POWER_OFF}. 4552 * <p> 4553 * This is the same as {@link ServiceState#getState()}. 4554 */ 4555 public static final String VOICE_REG_STATE = "voice_reg_state"; 4556 4557 /** 4558 * The current registered operator numeric id. 4559 * <p> 4560 * In GSM/UMTS, numeric format is 3 digit country code plus 2 or 3 digit 4561 * network code. 4562 * <p> 4563 * This is the same as {@link ServiceState#getOperatorNumeric()}. 4564 */ 4565 public static final String VOICE_OPERATOR_NUMERIC = "voice_operator_numeric"; 4566 4567 /** 4568 * The current network selection mode. 4569 * <p> 4570 * This is the same as {@link ServiceState#getIsManualSelection()}. 4571 */ 4572 public static final String IS_MANUAL_NETWORK_SELECTION = "is_manual_network_selection"; 4573 } 4574 4575 /** 4576 * Contains carrier identification information for the current subscriptions. 4577 */ 4578 public static final class CarrierId implements BaseColumns { 4579 /** 4580 * Not instantiable. 4581 * @hide 4582 */ CarrierId()4583 private CarrierId() {} 4584 4585 /** 4586 * The {@code content://} style URI for this provider. 4587 */ 4588 public static final Uri CONTENT_URI = Uri.parse("content://carrier_id"); 4589 4590 /** 4591 * The authority string for the CarrierId Provider 4592 * @hide 4593 */ 4594 public static final String AUTHORITY = "carrier_id"; 4595 4596 4597 /** 4598 * Generates a content {@link Uri} used to receive updates on carrier identity change 4599 * on the given subscriptionId 4600 * <p> 4601 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the 4602 * carrier identity {@link TelephonyManager#getSimCarrierId()} 4603 * while your app is running. You can also use a {@link android.app.job.JobService} 4604 * to ensure your app 4605 * is notified of changes to the {@link Uri} even when it is not running. 4606 * Note, however, that using a {@link android.app.job.JobService} does not guarantee 4607 * timely delivery of updates to the {@link Uri}. 4608 * 4609 * @param subscriptionId the subscriptionId to receive updates on 4610 * @return the Uri used to observe carrier identity changes 4611 */ getUriForSubscriptionId(int subscriptionId)4612 public static Uri getUriForSubscriptionId(int subscriptionId) { 4613 return CONTENT_URI.buildUpon().appendEncodedPath( 4614 String.valueOf(subscriptionId)).build(); 4615 } 4616 4617 /** 4618 * Generates a content {@link Uri} used to receive updates on specific carrier identity 4619 * change on the given subscriptionId returned by 4620 * {@link TelephonyManager#getSimSpecificCarrierId()}. 4621 * @see TelephonyManager#ACTION_SUBSCRIPTION_SPECIFIC_CARRIER_IDENTITY_CHANGED 4622 * <p> 4623 * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the 4624 * specific carrier identity {@link TelephonyManager#getSimSpecificCarrierId()} 4625 * while your app is running. You can also use a {@link android.app.job.JobService} 4626 * to ensure your app 4627 * is notified of changes to the {@link Uri} even when it is not running. 4628 * Note, however, that using a {@link android.app.job.JobService} does not guarantee timely 4629 * delivery of updates to the {@link Uri}. 4630 * 4631 * @param subscriptionId the subscriptionId to receive updates on 4632 * @return the Uri used to observe specific carrier identity changes 4633 */ 4634 @NonNull getSpecificCarrierIdUriForSubscriptionId(int subscriptionId)4635 public static Uri getSpecificCarrierIdUriForSubscriptionId(int subscriptionId) { 4636 return Uri.withAppendedPath(Uri.withAppendedPath(CONTENT_URI, "specific"), 4637 String.valueOf(subscriptionId)); 4638 } 4639 4640 /** 4641 * A user facing carrier name. 4642 * @see TelephonyManager#getSimCarrierIdName() 4643 * <P>Type: TEXT </P> 4644 */ 4645 public static final String CARRIER_NAME = "carrier_name"; 4646 4647 /** 4648 * A unique carrier id 4649 * @see TelephonyManager#getSimCarrierId() 4650 * <P>Type: INTEGER </P> 4651 */ 4652 public static final String CARRIER_ID = "carrier_id"; 4653 4654 /** 4655 * A fine-grained carrier id. 4656 * The specific carrier ID would be used for configuration purposes, but apps wishing to 4657 * know about the carrier itself should use the regular carrier ID returned by 4658 * {@link TelephonyManager#getSimCarrierId()}. 4659 * 4660 * @see TelephonyManager#getSimSpecificCarrierId() 4661 * This is not a database column, only used to notify content observers for 4662 * {@link #getSpecificCarrierIdUriForSubscriptionId(int)} 4663 */ 4664 public static final String SPECIFIC_CARRIER_ID = "specific_carrier_id"; 4665 4666 /** 4667 * A user facing carrier name for specific carrier id {@link #SPECIFIC_CARRIER_ID}. 4668 * @see TelephonyManager#getSimSpecificCarrierIdName() 4669 * This is not a database column, only used to notify content observers for 4670 * {@link #getSpecificCarrierIdUriForSubscriptionId(int)} 4671 */ 4672 public static final String SPECIFIC_CARRIER_ID_NAME = "specific_carrier_id_name"; 4673 4674 /** 4675 * A unique parent carrier id. The parent-child 4676 * relationship can be used to further differentiate a single carrier by different networks, 4677 * by prepaid v.s. postpaid. It's an optional field. 4678 * A carrier id with a valid parent_carrier_id is considered fine-grained specific carrier 4679 * ID, will not be returned as {@link #CARRIER_ID} but {@link #SPECIFIC_CARRIER_ID}. 4680 * <P>Type: INTEGER </P> 4681 * @hide 4682 */ 4683 public static final String PARENT_CARRIER_ID = "parent_carrier_id"; 4684 4685 /** 4686 * Contains mappings between matching rules with carrier id for all carriers. 4687 * @hide 4688 */ 4689 public static final class All implements BaseColumns { 4690 4691 /** 4692 * Not instantiable. 4693 * @hide 4694 */ All()4695 private All() { 4696 } 4697 4698 /** 4699 * Numeric operator ID (as String). {@code MCC + MNC} 4700 * <P>Type: TEXT </P> 4701 */ 4702 public static final String MCCMNC = "mccmnc"; 4703 4704 /** 4705 * Group id level 1 (as String). 4706 * <P>Type: TEXT </P> 4707 */ 4708 public static final String GID1 = "gid1"; 4709 4710 /** 4711 * Group id level 2 (as String). 4712 * <P>Type: TEXT </P> 4713 */ 4714 public static final String GID2 = "gid2"; 4715 4716 /** 4717 * Public Land Mobile Network name. 4718 * <P>Type: TEXT </P> 4719 */ 4720 public static final String PLMN = "plmn"; 4721 4722 /** 4723 * Prefix xpattern of IMSI (International Mobile Subscriber Identity). 4724 * <P>Type: TEXT </P> 4725 */ 4726 public static final String IMSI_PREFIX_XPATTERN = "imsi_prefix_xpattern"; 4727 4728 /** 4729 * Service Provider Name. 4730 * <P>Type: TEXT </P> 4731 */ 4732 public static final String SPN = "spn"; 4733 4734 /** 4735 * Prefer APN name. 4736 * <P>Type: TEXT </P> 4737 */ 4738 public static final String APN = "apn"; 4739 4740 /** 4741 * Prefix of Integrated Circuit Card Identifier. 4742 * <P>Type: TEXT </P> 4743 */ 4744 public static final String ICCID_PREFIX = "iccid_prefix"; 4745 4746 /** 4747 * Certificate for carrier privilege access rules. 4748 * <P>Type: TEXT in hex string </P> 4749 */ 4750 public static final String PRIVILEGE_ACCESS_RULE = "privilege_access_rule"; 4751 4752 /** 4753 * The {@code content://} URI for this table. 4754 */ 4755 @NonNull 4756 public static final Uri CONTENT_URI = Uri.parse("content://carrier_id/all"); 4757 } 4758 } 4759 4760 /** 4761 * Contains SIM Information 4762 * @hide 4763 */ 4764 public static final class SimInfo { 4765 /** 4766 * Not instantiable. 4767 * @hide 4768 */ SimInfo()4769 private SimInfo() {} 4770 4771 /** 4772 * The {@code content://} style URI for this provider. 4773 * @hide 4774 */ 4775 @NonNull 4776 public static final Uri CONTENT_URI = Uri.parse("content://telephony/siminfo"); 4777 4778 /** 4779 * TelephonyProvider unique key column name is the subscription id. 4780 * <P>Type: TEXT (String)</P> 4781 * 4782 * @hide 4783 */ 4784 public static final String COLUMN_UNIQUE_KEY_SUBSCRIPTION_ID = "_id"; 4785 4786 /** 4787 * TelephonyProvider column name for a unique identifier for the subscription within the 4788 * specific subscription type. For example, it contains SIM ICC Identifier subscriptions 4789 * on Local SIMs. and Mac-address for Remote-SIM Subscriptions for Bluetooth devices. 4790 * <P>Type: TEXT (String)</P> 4791 * 4792 * @hide 4793 */ 4794 public static final String COLUMN_ICC_ID = "icc_id"; 4795 4796 /** 4797 * TelephonyProvider column name for user SIM_SlOT_INDEX 4798 * <P>Type: INTEGER (int)</P> 4799 * 4800 * @hide 4801 */ 4802 public static final String COLUMN_SIM_SLOT_INDEX = "sim_id"; 4803 4804 /** 4805 * SIM is not inserted 4806 * @hide 4807 */ 4808 public static final int SIM_NOT_INSERTED = -1; 4809 4810 /** 4811 * TelephonyProvider column name Subscription-type. 4812 * <P>Type: INTEGER (int)</P> {@link #SUBSCRIPTION_TYPE_LOCAL_SIM} for Local-SIM 4813 * Subscriptions, {@link #SUBSCRIPTION_TYPE_REMOTE_SIM} for Remote-SIM Subscriptions. 4814 * Default value is 0. 4815 * 4816 * @hide 4817 */ 4818 public static final String COLUMN_SUBSCRIPTION_TYPE = "subscription_type"; 4819 4820 /** 4821 * This constant is to designate a subscription as a Local-SIM Subscription. 4822 * <p> A Local-SIM can be a physical SIM inserted into a sim-slot in the device, or eSIM on 4823 * the device. 4824 * </p> 4825 * 4826 * @hide 4827 */ 4828 public static final int SUBSCRIPTION_TYPE_LOCAL_SIM = 0; 4829 4830 /** 4831 * This constant is to designate a subscription as a Remote-SIM Subscription. 4832 * <p> 4833 * A Remote-SIM subscription is for a SIM on a phone connected to this device via some 4834 * connectivity mechanism, for example bluetooth. Similar to Local SIM, this subscription 4835 * can be used for SMS, Voice and data by proxying data through the connected device. 4836 * Certain data of the SIM, such as IMEI, are not accessible for Remote SIMs. 4837 * </p> 4838 * 4839 * <p> 4840 * A Remote-SIM is available only as long the phone stays connected to this device. 4841 * When the phone disconnects, Remote-SIM subscription is removed from this device and is 4842 * no longer known. All data associated with the subscription, such as stored SMS, call 4843 * logs, contacts etc, are removed from this device. 4844 * </p> 4845 * 4846 * <p> 4847 * If the phone re-connects to this device, a new Remote-SIM subscription is created for 4848 * the phone. The Subscription Id associated with the new subscription is different from 4849 * the Subscription Id of the previous Remote-SIM subscription created (and removed) for the 4850 * phone; i.e., new Remote-SIM subscription treats the reconnected phone as a Remote-SIM 4851 * that was never seen before. 4852 * </p> 4853 * 4854 * @hide 4855 */ 4856 public static final int SUBSCRIPTION_TYPE_REMOTE_SIM = 1; 4857 4858 /** 4859 * TelephonyProvider column name data_enabled_override_rules. 4860 * It's a list of rules for overriding data enabled settings. The syntax is 4861 * For example, "mms=nonDefault" indicates enabling data for mms in non-default 4862 * subscription. 4863 * "default=nonDefault&inVoiceCall" indicates enabling data for internet in non-default 4864 * subscription and while is in voice call. 4865 * 4866 * Default value is empty string. 4867 * 4868 * @hide 4869 */ 4870 public static final String COLUMN_DATA_ENABLED_OVERRIDE_RULES = 4871 "data_enabled_override_rules"; 4872 4873 /** 4874 * TelephonyProvider column name for user displayed name. 4875 * <P>Type: TEXT (String)</P> 4876 * 4877 * @hide 4878 */ 4879 public static final String COLUMN_DISPLAY_NAME = "display_name"; 4880 4881 /** 4882 * TelephonyProvider column name for the service provider name for the SIM. 4883 * <P>Type: TEXT (String)</P> 4884 * 4885 * @hide 4886 */ 4887 public static final String COLUMN_CARRIER_NAME = "carrier_name"; 4888 4889 /** 4890 * TelephonyProvider column name for source of the user displayed name. 4891 * <P>Type: INT (int)</P> with one of the NAME_SOURCE_XXXX values below 4892 * 4893 * @hide 4894 */ 4895 public static final String COLUMN_NAME_SOURCE = "name_source"; 4896 4897 /** The name_source is from the carrier id. {@hide} */ 4898 public static final int NAME_SOURCE_CARRIER_ID = 0; 4899 4900 /** 4901 * The name_source is from SIM EF_SPN. 4902 * @hide 4903 */ 4904 public static final int NAME_SOURCE_SIM_SPN = 1; 4905 4906 /** 4907 * The name_source is from user input 4908 * @hide 4909 */ 4910 public static final int NAME_SOURCE_USER_INPUT = 2; 4911 4912 /** 4913 * The name_source is carrier (carrier app, carrier config, etc.) 4914 * @hide 4915 */ 4916 public static final int NAME_SOURCE_CARRIER = 3; 4917 4918 /** 4919 * The name_source is from SIM EF_PNN. 4920 * @hide 4921 */ 4922 public static final int NAME_SOURCE_SIM_PNN = 4; 4923 4924 /** 4925 * TelephonyProvider column name for the color of a SIM. 4926 * <P>Type: INTEGER (int)</P> 4927 * 4928 * @hide 4929 */ 4930 public static final String COLUMN_COLOR = "color"; 4931 4932 /** The default color of a SIM {@hide} */ 4933 public static final int COLOR_DEFAULT = 0; 4934 4935 /** 4936 * TelephonyProvider column name for the phone number of a SIM. 4937 * <P>Type: TEXT (String)</P> 4938 * 4939 * @hide 4940 */ 4941 public static final String COLUMN_NUMBER = "number"; 4942 4943 /** 4944 * TelephonyProvider column name for the number display format of a SIM. 4945 * <P>Type: INTEGER (int)</P> 4946 * 4947 * @hide 4948 */ 4949 public static final String COLUMN_DISPLAY_NUMBER_FORMAT = "display_number_format"; 4950 4951 /** 4952 * TelephonyProvider column name for the default display format of a SIM 4953 * @hide 4954 */ 4955 public static final int DISPLAY_NUMBER_DEFAULT = 1; 4956 4957 /** 4958 * TelephonyProvider column name for whether data roaming is enabled. 4959 * <P>Type: INTEGER (int)</P> 4960 * 4961 * @hide 4962 */ 4963 public static final String COLUMN_DATA_ROAMING = "data_roaming"; 4964 4965 /** Indicates that data roaming is enabled for a subscription {@hide} */ 4966 public static final int DATA_ROAMING_ENABLE = 1; 4967 4968 /** Indicates that data roaming is disabled for a subscription {@hide} */ 4969 public static final int DATA_ROAMING_DISABLE = 0; 4970 4971 /** 4972 * TelephonyProvider column name for subscription carrier id. 4973 * @see TelephonyManager#getSimCarrierId() 4974 * <p>Type: INTEGER (int) </p> 4975 * 4976 * @hide 4977 */ 4978 public static final String COLUMN_CARRIER_ID = "carrier_id"; 4979 4980 /** 4981 * A comma-separated list of EHPLMNs associated with the subscription 4982 * <P>Type: TEXT (String)</P> 4983 * 4984 * @hide 4985 */ 4986 public static final String COLUMN_EHPLMNS = "ehplmns"; 4987 4988 /** 4989 * A comma-separated list of HPLMNs associated with the subscription 4990 * <P>Type: TEXT (String)</P> 4991 * 4992 * @hide 4993 */ 4994 public static final String COLUMN_HPLMNS = "hplmns"; 4995 4996 /** 4997 * TelephonyProvider column name for the MCC associated with a SIM, stored as a string. 4998 * <P>Type: TEXT (String)</P> 4999 * 5000 * @hide 5001 */ 5002 public static final String COLUMN_MCC_STRING = "mcc_string"; 5003 5004 /** 5005 * TelephonyProvider column name for the MNC associated with a SIM, stored as a string. 5006 * <P>Type: TEXT (String)</P> 5007 * 5008 * @hide 5009 */ 5010 public static final String COLUMN_MNC_STRING = "mnc_string"; 5011 5012 /** 5013 * TelephonyProvider column name for the MCC associated with a SIM. 5014 * <P>Type: INTEGER (int)</P> 5015 * 5016 * @hide 5017 */ 5018 public static final String COLUMN_MCC = "mcc"; 5019 5020 /** 5021 * TelephonyProvider column name for the MNC associated with a SIM. 5022 * <P>Type: INTEGER (int)</P> 5023 * 5024 * @hide 5025 */ 5026 public static final String COLUMN_MNC = "mnc"; 5027 5028 /** 5029 * TelephonyProvider column name for the iso country code associated with a SIM. 5030 * <P>Type: TEXT (String)</P> 5031 * 5032 * @hide 5033 */ 5034 public static final String COLUMN_ISO_COUNTRY_CODE = "iso_country_code"; 5035 5036 /** 5037 * TelephonyProvider column name for the sim provisioning status associated with a SIM. 5038 * <P>Type: INTEGER (int)</P> 5039 * 5040 * @hide 5041 */ 5042 public static final String COLUMN_SIM_PROVISIONING_STATUS = "sim_provisioning_status"; 5043 5044 /** The sim is provisioned {@hide} */ 5045 public static final int SIM_PROVISIONED = 0; 5046 5047 /** 5048 * TelephonyProvider column name for whether a subscription is embedded (that is, present on 5049 * an eSIM). 5050 * <p>Type: INTEGER (int), 1 for embedded or 0 for non-embedded. 5051 * 5052 * @hide 5053 */ 5054 public static final String COLUMN_IS_EMBEDDED = "is_embedded"; 5055 5056 /** 5057 * TelephonyProvider column name for SIM card identifier. For UICC card it is the ICCID of 5058 * the current enabled profile on the card, while for eUICC card it is the EID of the card. 5059 * <P>Type: TEXT (String)</P> 5060 * 5061 * @hide 5062 */ 5063 public static final String COLUMN_CARD_ID = "card_id"; 5064 5065 /** 5066 * TelephonyProvider column name for the encoded {@link UiccAccessRule}s from 5067 * {@link UiccAccessRule#encodeRules}. Only present if {@link #COLUMN_IS_EMBEDDED} is 1. 5068 * <p>TYPE: BLOB 5069 * 5070 * @hide 5071 */ 5072 public static final String COLUMN_ACCESS_RULES = "access_rules"; 5073 5074 /** 5075 * TelephonyProvider column name for the encoded {@link UiccAccessRule}s from 5076 * {@link UiccAccessRule#encodeRules} but for the rules that come from CarrierConfigs. 5077 * Only present if there are access rules in CarrierConfigs 5078 * <p>TYPE: BLOB 5079 * 5080 * @hide 5081 */ 5082 public static final String COLUMN_ACCESS_RULES_FROM_CARRIER_CONFIGS = 5083 "access_rules_from_carrier_configs"; 5084 5085 /** 5086 * TelephonyProvider column name identifying whether an embedded subscription is on a 5087 * removable card. Such subscriptions are marked inaccessible as soon as the current card 5088 * is removed. Otherwise, they will remain accessible unless explicitly deleted. Only 5089 * present if {@link #COLUMN_IS_EMBEDDED} is 1. 5090 * <p>TYPE: INTEGER (int), 1 for removable or 0 for non-removable. 5091 * 5092 * @hide 5093 */ 5094 public static final String COLUMN_IS_REMOVABLE = "is_removable"; 5095 5096 /** TelephonyProvider column name for extreme threat in CB settings {@hide} */ 5097 public static final String COLUMN_CB_EXTREME_THREAT_ALERT = 5098 "enable_cmas_extreme_threat_alerts"; 5099 5100 /** TelephonyProvider column name for severe threat in CB settings {@hide} */ 5101 public static final String COLUMN_CB_SEVERE_THREAT_ALERT = 5102 "enable_cmas_severe_threat_alerts"; 5103 5104 /** TelephonyProvider column name for amber alert in CB settings {@hide} */ 5105 public static final String COLUMN_CB_AMBER_ALERT = "enable_cmas_amber_alerts"; 5106 5107 /** TelephonyProvider column name for emergency alert in CB settings {@hide} */ 5108 public static final String COLUMN_CB_EMERGENCY_ALERT = "enable_emergency_alerts"; 5109 5110 /** TelephonyProvider column name for alert sound duration in CB settings {@hide} */ 5111 public static final String COLUMN_CB_ALERT_SOUND_DURATION = "alert_sound_duration"; 5112 5113 /** TelephonyProvider column name for alert reminder interval in CB settings {@hide} */ 5114 public static final String COLUMN_CB_ALERT_REMINDER_INTERVAL = "alert_reminder_interval"; 5115 5116 /** TelephonyProvider column name for enabling vibrate in CB settings {@hide} */ 5117 public static final String COLUMN_CB_ALERT_VIBRATE = "enable_alert_vibrate"; 5118 5119 /** TelephonyProvider column name for enabling alert speech in CB settings {@hide} */ 5120 public static final String COLUMN_CB_ALERT_SPEECH = "enable_alert_speech"; 5121 5122 /** TelephonyProvider column name for ETWS test alert in CB settings {@hide} */ 5123 public static final String COLUMN_CB_ETWS_TEST_ALERT = "enable_etws_test_alerts"; 5124 5125 /** TelephonyProvider column name for enable channel50 alert in CB settings {@hide} */ 5126 public static final String COLUMN_CB_CHANNEL_50_ALERT = "enable_channel_50_alerts"; 5127 5128 /** TelephonyProvider column name for CMAS test alert in CB settings {@hide} */ 5129 public static final String COLUMN_CB_CMAS_TEST_ALERT = "enable_cmas_test_alerts"; 5130 5131 /** TelephonyProvider column name for Opt out dialog in CB settings {@hide} */ 5132 public static final String COLUMN_CB_OPT_OUT_DIALOG = "show_cmas_opt_out_dialog"; 5133 5134 /** 5135 * TelephonyProvider column name for enable Volte. 5136 * 5137 * If this setting is not initialized (set to -1) then we use the Carrier Config value 5138 * {@link CarrierConfigManager#KEY_ENHANCED_4G_LTE_ON_BY_DEFAULT_BOOL}. 5139 * 5140 * @hide 5141 */ 5142 public static final String COLUMN_ENHANCED_4G_MODE_ENABLED = "volte_vt_enabled"; 5143 5144 /** TelephonyProvider column name for enable VT (Video Telephony over IMS) {@hide} */ 5145 public static final String COLUMN_VT_IMS_ENABLED = "vt_ims_enabled"; 5146 5147 /** TelephonyProvider column name for enable Wifi calling {@hide} */ 5148 public static final String COLUMN_WFC_IMS_ENABLED = "wfc_ims_enabled"; 5149 5150 /** TelephonyProvider column name for Wifi calling mode {@hide} */ 5151 public static final String COLUMN_WFC_IMS_MODE = "wfc_ims_mode"; 5152 5153 /** TelephonyProvider column name for Wifi calling mode in roaming {@hide} */ 5154 public static final String COLUMN_WFC_IMS_ROAMING_MODE = "wfc_ims_roaming_mode"; 5155 5156 /** TelephonyProvider column name for enable Wifi calling in roaming {@hide} */ 5157 public static final String COLUMN_WFC_IMS_ROAMING_ENABLED = "wfc_ims_roaming_enabled"; 5158 5159 /** 5160 * TelephonyProvider column name for determining if the user has enabled IMS RCS User 5161 * Capability Exchange (UCE) for this subscription. 5162 * 5163 * @hide 5164 */ 5165 public static final String COLUMN_IMS_RCS_UCE_ENABLED = "ims_rcs_uce_enabled"; 5166 5167 /** 5168 * TelephonyProvider column name for whether a subscription is opportunistic, that is, 5169 * whether the network it connects to is limited in functionality or coverage. 5170 * For example, CBRS. 5171 * <p>Type: INTEGER (int), 1 for opportunistic or 0 for non-opportunistic. 5172 * 5173 * @hide 5174 */ 5175 public static final String COLUMN_IS_OPPORTUNISTIC = "is_opportunistic"; 5176 5177 /** 5178 * TelephonyProvider column name for group ID. Subscriptions with same group ID 5179 * are considered bundled together, and should behave as a single subscription at 5180 * certain scenarios. 5181 * 5182 * @hide 5183 */ 5184 public static final String COLUMN_GROUP_UUID = "group_uuid"; 5185 5186 /** 5187 * TelephonyProvider column name for group owner. It's the package name who created 5188 * the subscription group. 5189 * 5190 * @hide 5191 */ 5192 public static final String COLUMN_GROUP_OWNER = "group_owner"; 5193 5194 /** 5195 * TelephonyProvider column name for whether a subscription is metered or not, that is, 5196 * whether the network it connects to charges for subscription or not. For example, paid 5197 * CBRS or unpaid. 5198 * 5199 * @hide 5200 */ 5201 public static final String COLUMN_IS_METERED = "is_metered"; 5202 5203 /** 5204 * TelephonyProvider column name for the profile class of a subscription 5205 * Only present if {@link #COLUMN_IS_EMBEDDED} is 1. 5206 * <P>Type: INTEGER (int)</P> 5207 * 5208 * @hide 5209 */ 5210 public static final String COLUMN_PROFILE_CLASS = "profile_class"; 5211 5212 /** 5213 * A testing profile can be pre-loaded or downloaded onto 5214 * the eUICC and provides connectivity to test equipment 5215 * for the purpose of testing the device and the eUICC. It 5216 * is not intended to store any operator credentials. 5217 * 5218 * @hide 5219 */ 5220 public static final int PROFILE_CLASS_TESTING = 0; 5221 5222 /** 5223 * A provisioning profile is pre-loaded onto the eUICC and 5224 * provides connectivity to a mobile network solely for the 5225 * purpose of provisioning profiles. 5226 * 5227 * @hide 5228 */ 5229 public static final int PROFILE_CLASS_PROVISIONING = 1; 5230 5231 /** 5232 * An operational profile can be pre-loaded or downloaded 5233 * onto the eUICC and provides services provided by the 5234 * operator. 5235 * 5236 * @hide 5237 */ 5238 public static final int PROFILE_CLASS_OPERATIONAL = 2; 5239 5240 /** 5241 * The profile class is unset. This occurs when profile class 5242 * info is not available. The subscription either has no profile 5243 * metadata or the profile metadata did not encode profile class. 5244 * 5245 * @hide 5246 */ 5247 public static final int PROFILE_CLASS_UNSET = -1; 5248 5249 /** 5250 * IMSI (International Mobile Subscriber Identity). 5251 * <P>Type: TEXT </P> 5252 * 5253 * @hide 5254 */ 5255 public static final String COLUMN_IMSI = "imsi"; 5256 5257 /** 5258 * Whether uicc applications is set to be enabled or disabled. By default it's enabled. 5259 * @hide 5260 */ 5261 public static final String COLUMN_UICC_APPLICATIONS_ENABLED = "uicc_applications_enabled"; 5262 5263 /** 5264 * TelephonyProvider column name for allowed network types. Indicate which network types 5265 * are allowed. Default is -1. 5266 * <P>Type: BIGINT (long) </P> 5267 * 5268 * @hide 5269 */ 5270 public static final String COLUMN_ALLOWED_NETWORK_TYPES = "allowed_network_types"; 5271 } 5272 } 5273