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