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 com.google.android.mms.util.SqliteWrapper; 20 21 import android.annotation.SdkConstant; 22 import android.annotation.SdkConstant.SdkConstantType; 23 import android.content.ContentResolver; 24 import android.content.ContentValues; 25 import android.content.Context; 26 import android.content.Intent; 27 import android.database.Cursor; 28 import android.net.Uri; 29 import android.telephony.SmsMessage; 30 import android.text.TextUtils; 31 import android.text.util.Regex; 32 import android.util.Config; 33 import android.util.Log; 34 35 import java.util.HashSet; 36 import java.util.Set; 37 import java.util.regex.Matcher; 38 import java.util.regex.Pattern; 39 40 /** 41 * The Telephony provider contains data related to phone operation. 42 * 43 * @hide 44 */ 45 public final class Telephony { 46 private static final String TAG = "Telephony"; 47 private static final boolean DEBUG = true; 48 private static final boolean LOCAL_LOGV = DEBUG ? Config.LOGD : Config.LOGV; 49 50 // Constructor Telephony()51 public Telephony() { 52 } 53 54 /** 55 * Base columns for tables that contain text based SMSs. 56 */ 57 public interface TextBasedSmsColumns { 58 /** 59 * The type of the message 60 * <P>Type: INTEGER</P> 61 */ 62 public static final String TYPE = "type"; 63 64 public static final int MESSAGE_TYPE_ALL = 0; 65 public static final int MESSAGE_TYPE_INBOX = 1; 66 public static final int MESSAGE_TYPE_SENT = 2; 67 public static final int MESSAGE_TYPE_DRAFT = 3; 68 public static final int MESSAGE_TYPE_OUTBOX = 4; 69 public static final int MESSAGE_TYPE_FAILED = 5; // for failed outgoing messages 70 public static final int MESSAGE_TYPE_QUEUED = 6; // for messages to send later 71 72 73 /** 74 * The thread ID of the message 75 * <P>Type: INTEGER</P> 76 */ 77 public static final String THREAD_ID = "thread_id"; 78 79 /** 80 * The address of the other party 81 * <P>Type: TEXT</P> 82 */ 83 public static final String ADDRESS = "address"; 84 85 /** 86 * The person ID of the sender 87 * <P>Type: INTEGER (long)</P> 88 */ 89 public static final String PERSON_ID = "person"; 90 91 /** 92 * The date the message was sent 93 * <P>Type: INTEGER (long)</P> 94 */ 95 public static final String DATE = "date"; 96 97 /** 98 * Has the message been read 99 * <P>Type: INTEGER (boolean)</P> 100 */ 101 public static final String READ = "read"; 102 103 /** 104 * The TP-Status value for the message, or -1 if no status has 105 * been received 106 */ 107 public static final String STATUS = "status"; 108 109 public static final int STATUS_NONE = -1; 110 public static final int STATUS_COMPLETE = 0; 111 public static final int STATUS_PENDING = 64; 112 public static final int STATUS_FAILED = 128; 113 114 /** 115 * The subject of the message, if present 116 * <P>Type: TEXT</P> 117 */ 118 public static final String SUBJECT = "subject"; 119 120 /** 121 * The body of the message 122 * <P>Type: TEXT</P> 123 */ 124 public static final String BODY = "body"; 125 126 /** 127 * The id of the sender of the conversation, if present 128 * <P>Type: INTEGER (reference to item in content://contacts/people)</P> 129 */ 130 public static final String PERSON = "person"; 131 132 /** 133 * The protocol identifier code 134 * <P>Type: INTEGER</P> 135 */ 136 public static final String PROTOCOL = "protocol"; 137 138 /** 139 * Whether the <code>TP-Reply-Path</code> bit was set on this message 140 * <P>Type: BOOLEAN</P> 141 */ 142 public static final String REPLY_PATH_PRESENT = "reply_path_present"; 143 144 /** 145 * The service center (SC) through which to send the message, if present 146 * <P>Type: TEXT</P> 147 */ 148 public static final String SERVICE_CENTER = "service_center"; 149 150 /** 151 * Has the message been locked? 152 * <P>Type: INTEGER (boolean)</P> 153 */ 154 public static final String LOCKED = "locked"; 155 } 156 157 /** 158 * Contains all text based SMS messages. 159 */ 160 public static final class Sms implements BaseColumns, TextBasedSmsColumns { query(ContentResolver cr, String[] projection)161 public static final Cursor query(ContentResolver cr, String[] projection) { 162 return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER); 163 } 164 query(ContentResolver cr, String[] projection, String where, String orderBy)165 public static final Cursor query(ContentResolver cr, String[] projection, 166 String where, String orderBy) { 167 return cr.query(CONTENT_URI, projection, where, 168 null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy); 169 } 170 171 /** 172 * The content:// style URL for this table 173 */ 174 public static final Uri CONTENT_URI = 175 Uri.parse("content://sms"); 176 177 /** 178 * The default sort order for this table 179 */ 180 public static final String DEFAULT_SORT_ORDER = "date DESC"; 181 182 /** 183 * Add an SMS to the given URI. 184 * 185 * @param resolver the content resolver to use 186 * @param uri the URI to add the message to 187 * @param address the address of the sender 188 * @param body the body of the message 189 * @param subject the psuedo-subject of the message 190 * @param date the timestamp for the message 191 * @param read true if the message has been read, false if not 192 * @param deliveryReport true if a delivery report was requested, false if not 193 * @return the URI for the new message 194 */ addMessageToUri(ContentResolver resolver, Uri uri, String address, String body, String subject, Long date, boolean read, boolean deliveryReport)195 public static Uri addMessageToUri(ContentResolver resolver, 196 Uri uri, String address, String body, String subject, 197 Long date, boolean read, boolean deliveryReport) { 198 return addMessageToUri(resolver, uri, address, body, subject, 199 date, read, deliveryReport, -1L); 200 } 201 202 /** 203 * Add an SMS to the given URI with thread_id specified. 204 * 205 * @param resolver the content resolver to use 206 * @param uri the URI to add the message to 207 * @param address the address of the sender 208 * @param body the body of the message 209 * @param subject the psuedo-subject of the message 210 * @param date the timestamp for the message 211 * @param read true if the message has been read, false if not 212 * @param deliveryReport true if a delivery report was requested, false if not 213 * @param threadId the thread_id of the message 214 * @return the URI for the new message 215 */ addMessageToUri(ContentResolver resolver, Uri uri, String address, String body, String subject, Long date, boolean read, boolean deliveryReport, long threadId)216 public static Uri addMessageToUri(ContentResolver resolver, 217 Uri uri, String address, String body, String subject, 218 Long date, boolean read, boolean deliveryReport, long threadId) { 219 ContentValues values = new ContentValues(7); 220 221 values.put(ADDRESS, address); 222 if (date != null) { 223 values.put(DATE, date); 224 } 225 values.put(READ, read ? Integer.valueOf(1) : Integer.valueOf(0)); 226 values.put(SUBJECT, subject); 227 values.put(BODY, body); 228 if (deliveryReport) { 229 values.put(STATUS, STATUS_PENDING); 230 } 231 if (threadId != -1L) { 232 values.put(THREAD_ID, threadId); 233 } 234 return resolver.insert(uri, values); 235 } 236 237 /** 238 * Move a message to the given folder. 239 * 240 * @param context the context to use 241 * @param uri the message to move 242 * @param folder the folder to move to 243 * @return true if the operation succeeded 244 */ moveMessageToFolder(Context context, Uri uri, int folder)245 public static boolean moveMessageToFolder(Context context, 246 Uri uri, int folder) { 247 if (uri == null) { 248 return false; 249 } 250 251 boolean markAsUnread = false; 252 boolean markAsRead = false; 253 switch(folder) { 254 case MESSAGE_TYPE_INBOX: 255 case MESSAGE_TYPE_DRAFT: 256 break; 257 case MESSAGE_TYPE_OUTBOX: 258 case MESSAGE_TYPE_SENT: 259 markAsRead = true; 260 break; 261 case MESSAGE_TYPE_FAILED: 262 case MESSAGE_TYPE_QUEUED: 263 markAsUnread = true; 264 break; 265 default: 266 return false; 267 } 268 269 ContentValues values = new ContentValues(2); 270 271 values.put(TYPE, folder); 272 if (markAsUnread) { 273 values.put(READ, Integer.valueOf(0)); 274 } else if (markAsRead) { 275 values.put(READ, Integer.valueOf(1)); 276 } 277 278 return 1 == SqliteWrapper.update(context, context.getContentResolver(), 279 uri, values, null, null); 280 } 281 282 /** 283 * Returns true iff the folder (message type) identifies an 284 * outgoing message. 285 */ isOutgoingFolder(int messageType)286 public static boolean isOutgoingFolder(int messageType) { 287 return (messageType == MESSAGE_TYPE_FAILED) 288 || (messageType == MESSAGE_TYPE_OUTBOX) 289 || (messageType == MESSAGE_TYPE_SENT) 290 || (messageType == MESSAGE_TYPE_QUEUED); 291 } 292 293 /** 294 * Contains all text based SMS messages in the SMS app's inbox. 295 */ 296 public static final class Inbox implements BaseColumns, TextBasedSmsColumns { 297 /** 298 * The content:// style URL for this table 299 */ 300 public static final Uri CONTENT_URI = 301 Uri.parse("content://sms/inbox"); 302 303 /** 304 * The default sort order for this table 305 */ 306 public static final String DEFAULT_SORT_ORDER = "date DESC"; 307 308 /** 309 * Add an SMS to the Draft box. 310 * 311 * @param resolver the content resolver to use 312 * @param address the address of the sender 313 * @param body the body of the message 314 * @param subject the psuedo-subject of the message 315 * @param date the timestamp for the message 316 * @param read true if the message has been read, false if not 317 * @return the URI for the new message 318 */ addMessage(ContentResolver resolver, String address, String body, String subject, Long date, boolean read)319 public static Uri addMessage(ContentResolver resolver, 320 String address, String body, String subject, Long date, 321 boolean read) { 322 return addMessageToUri(resolver, CONTENT_URI, address, body, 323 subject, date, read, false); 324 } 325 } 326 327 /** 328 * Contains all sent text based SMS messages in the SMS app's. 329 */ 330 public static final class Sent implements BaseColumns, TextBasedSmsColumns { 331 /** 332 * The content:// style URL for this table 333 */ 334 public static final Uri CONTENT_URI = 335 Uri.parse("content://sms/sent"); 336 337 /** 338 * The default sort order for this table 339 */ 340 public static final String DEFAULT_SORT_ORDER = "date DESC"; 341 342 /** 343 * Add an SMS to the Draft box. 344 * 345 * @param resolver the content resolver to use 346 * @param address the address of the sender 347 * @param body the body of the message 348 * @param subject the psuedo-subject of the message 349 * @param date the timestamp for the message 350 * @return the URI for the new message 351 */ addMessage(ContentResolver resolver, String address, String body, String subject, Long date)352 public static Uri addMessage(ContentResolver resolver, 353 String address, String body, String subject, Long date) { 354 return addMessageToUri(resolver, CONTENT_URI, address, body, 355 subject, date, true, false); 356 } 357 } 358 359 /** 360 * Contains all sent text based SMS messages in the SMS app's. 361 */ 362 public static final class Draft implements BaseColumns, TextBasedSmsColumns { 363 /** 364 * The content:// style URL for this table 365 */ 366 public static final Uri CONTENT_URI = 367 Uri.parse("content://sms/draft"); 368 369 /** 370 * The default sort order for this table 371 */ 372 public static final String DEFAULT_SORT_ORDER = "date DESC"; 373 374 /** 375 * Add an SMS to the Draft box. 376 * 377 * @param resolver the content resolver to use 378 * @param address the address of the sender 379 * @param body the body of the message 380 * @param subject the psuedo-subject of the message 381 * @param date the timestamp for the message 382 * @return the URI for the new message 383 */ addMessage(ContentResolver resolver, String address, String body, String subject, Long date)384 public static Uri addMessage(ContentResolver resolver, 385 String address, String body, String subject, Long date) { 386 return addMessageToUri(resolver, CONTENT_URI, address, body, 387 subject, date, true, false); 388 } 389 390 /** 391 * Save over an existing draft message. 392 * 393 * @param resolver the content resolver to use 394 * @param uri of existing message 395 * @param body the new body for the draft message 396 * @return true is successful, false otherwise 397 */ saveMessage(ContentResolver resolver, Uri uri, String body)398 public static boolean saveMessage(ContentResolver resolver, 399 Uri uri, String body) { 400 ContentValues values = new ContentValues(2); 401 values.put(BODY, body); 402 values.put(DATE, System.currentTimeMillis()); 403 return resolver.update(uri, values, null, null) == 1; 404 } 405 } 406 407 /** 408 * Contains all pending outgoing text based SMS messages. 409 */ 410 public static final class Outbox implements BaseColumns, TextBasedSmsColumns { 411 /** 412 * The content:// style URL for this table 413 */ 414 public static final Uri CONTENT_URI = 415 Uri.parse("content://sms/outbox"); 416 417 /** 418 * The default sort order for this table 419 */ 420 public static final String DEFAULT_SORT_ORDER = "date DESC"; 421 422 /** 423 * Add an SMS to the Out box. 424 * 425 * @param resolver the content resolver to use 426 * @param address the address of the sender 427 * @param body the body of the message 428 * @param subject the psuedo-subject of the message 429 * @param date the timestamp for the message 430 * @param deliveryReport whether a delivery report was requested for the message 431 * @return the URI for the new message 432 */ addMessage(ContentResolver resolver, String address, String body, String subject, Long date, boolean deliveryReport, long threadId)433 public static Uri addMessage(ContentResolver resolver, 434 String address, String body, String subject, Long date, 435 boolean deliveryReport, long threadId) { 436 return addMessageToUri(resolver, CONTENT_URI, address, body, 437 subject, date, true, deliveryReport, threadId); 438 } 439 } 440 441 /** 442 * Contains all sent text-based SMS messages in the SMS app's. 443 */ 444 public static final class Conversations 445 implements BaseColumns, TextBasedSmsColumns { 446 /** 447 * The content:// style URL for this table 448 */ 449 public static final Uri CONTENT_URI = 450 Uri.parse("content://sms/conversations"); 451 452 /** 453 * The default sort order for this table 454 */ 455 public static final String DEFAULT_SORT_ORDER = "date DESC"; 456 457 /** 458 * The first 45 characters of the body of the message 459 * <P>Type: TEXT</P> 460 */ 461 public static final String SNIPPET = "snippet"; 462 463 /** 464 * The number of messages in the conversation 465 * <P>Type: INTEGER</P> 466 */ 467 public static final String MESSAGE_COUNT = "msg_count"; 468 } 469 470 /** 471 * Contains info about SMS related Intents that are broadcast. 472 */ 473 public static final class Intents { 474 /** 475 * Set by BroadcastReceiver. Indicates the message was handled 476 * successfully. 477 */ 478 public static final int RESULT_SMS_HANDLED = 1; 479 480 /** 481 * Set by BroadcastReceiver. Indicates a generic error while 482 * processing the message. 483 */ 484 public static final int RESULT_SMS_GENERIC_ERROR = 2; 485 486 /** 487 * Set by BroadcastReceiver. Indicates insufficient memory to store 488 * the message. 489 */ 490 public static final int RESULT_SMS_OUT_OF_MEMORY = 3; 491 492 /** 493 * Set by BroadcastReceiver. Indicates the message, while 494 * possibly valid, is of a format or encoding that is not 495 * supported. 496 */ 497 public static final int RESULT_SMS_UNSUPPORTED = 4; 498 499 /** 500 * Broadcast Action: A new text based SMS message has been received 501 * by the device. The intent will have the following extra 502 * values:</p> 503 * 504 * <ul> 505 * <li><em>pdus</em> - An Object[] od byte[]s containing the PDUs 506 * that make up the message.</li> 507 * </ul> 508 * 509 * <p>The extra values can be extracted using 510 * {@link #getMessagesFromIntent(Intent)}.</p> 511 * 512 * <p>If a BroadcastReceiver encounters an error while processing 513 * this intent it should set the result code appropriately.</p> 514 */ 515 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 516 public static final String SMS_RECEIVED_ACTION = 517 "android.provider.Telephony.SMS_RECEIVED"; 518 519 /** 520 * Broadcast Action: A new data based SMS message has been received 521 * by the device. The intent will have the following extra 522 * values:</p> 523 * 524 * <ul> 525 * <li><em>pdus</em> - An Object[] od byte[]s containing the PDUs 526 * that make up the message.</li> 527 * </ul> 528 * 529 * <p>The extra values can be extracted using 530 * {@link #getMessagesFromIntent(Intent)}.</p> 531 * 532 * <p>If a BroadcastReceiver encounters an error while processing 533 * this intent it should set the result code appropriately.</p> 534 */ 535 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 536 public static final String DATA_SMS_RECEIVED_ACTION = 537 "android.intent.action.DATA_SMS_RECEIVED"; 538 539 /** 540 * Broadcast Action: A new WAP PUSH message has been received by the 541 * device. The intent will have the following extra 542 * values:</p> 543 * 544 * <ul> 545 * <li><em>transactionId (Integer)</em> - The WAP transaction 546 * ID</li> 547 * <li><em>pduType (Integer)</em> - The WAP PDU type</li> 548 * <li><em>data</em> - The data payload of the message</li> 549 * </ul> 550 * 551 * <p>If a BroadcastReceiver encounters an error while processing 552 * this intent it should set the result code appropriately.</p> 553 */ 554 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 555 public static final String WAP_PUSH_RECEIVED_ACTION = 556 "android.provider.Telephony.WAP_PUSH_RECEIVED"; 557 558 /** 559 * Broadcast Action: The SIM storage for SMS messages is full. If 560 * space is not freed, messages targeted for the SIM (class 2) may 561 * not be saved. 562 */ 563 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 564 public static final String SIM_FULL_ACTION = 565 "android.provider.Telephony.SIM_FULL"; 566 567 /** 568 * Broadcast Action: An incoming SMS has been rejected by the 569 * telephony framework. This intent is sent in lieu of any 570 * of the RECEIVED_ACTION intents. The intent will have the 571 * following extra value:</p> 572 * 573 * <ul> 574 * <li><em>result</em> - An int result code, eg, 575 * <code>{@link #RESULT_SMS_OUT_OF_MEMORY}</code>, 576 * indicating the error returned to the network.</li> 577 * </ul> 578 579 */ 580 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 581 public static final String SMS_REJECTED_ACTION = 582 "android.provider.Telephony.SMS_REJECTED"; 583 584 /** 585 * Read the PDUs out of an {@link #SMS_RECEIVED_ACTION} or a 586 * {@link #DATA_SMS_RECEIVED_ACTION} intent. 587 * 588 * @param intent the intent to read from 589 * @return an array of SmsMessages for the PDUs 590 */ getMessagesFromIntent( Intent intent)591 public static final SmsMessage[] getMessagesFromIntent( 592 Intent intent) { 593 Object[] messages = (Object[]) intent.getSerializableExtra("pdus"); 594 byte[][] pduObjs = new byte[messages.length][]; 595 596 for (int i = 0; i < messages.length; i++) { 597 pduObjs[i] = (byte[]) messages[i]; 598 } 599 byte[][] pdus = new byte[pduObjs.length][]; 600 int pduCount = pdus.length; 601 SmsMessage[] msgs = new SmsMessage[pduCount]; 602 for (int i = 0; i < pduCount; i++) { 603 pdus[i] = pduObjs[i]; 604 msgs[i] = SmsMessage.createFromPdu(pdus[i]); 605 } 606 return msgs; 607 } 608 } 609 } 610 611 /** 612 * Base columns for tables that contain MMSs. 613 */ 614 public interface BaseMmsColumns extends BaseColumns { 615 616 public static final int MESSAGE_BOX_ALL = 0; 617 public static final int MESSAGE_BOX_INBOX = 1; 618 public static final int MESSAGE_BOX_SENT = 2; 619 public static final int MESSAGE_BOX_DRAFTS = 3; 620 public static final int MESSAGE_BOX_OUTBOX = 4; 621 622 /** 623 * The date the message was sent. 624 * <P>Type: INTEGER (long)</P> 625 */ 626 public static final String DATE = "date"; 627 628 /** 629 * The box which the message belong to, for example, MESSAGE_BOX_INBOX. 630 * <P>Type: INTEGER</P> 631 */ 632 public static final String MESSAGE_BOX = "msg_box"; 633 634 /** 635 * Has the message been read. 636 * <P>Type: INTEGER (boolean)</P> 637 */ 638 public static final String READ = "read"; 639 640 /** 641 * The Message-ID of the message. 642 * <P>Type: TEXT</P> 643 */ 644 public static final String MESSAGE_ID = "m_id"; 645 646 /** 647 * The subject of the message, if present. 648 * <P>Type: TEXT</P> 649 */ 650 public static final String SUBJECT = "sub"; 651 652 /** 653 * The character set of the subject, if present. 654 * <P>Type: INTEGER</P> 655 */ 656 public static final String SUBJECT_CHARSET = "sub_cs"; 657 658 /** 659 * The Content-Type of the message. 660 * <P>Type: TEXT</P> 661 */ 662 public static final String CONTENT_TYPE = "ct_t"; 663 664 /** 665 * The Content-Location of the message. 666 * <P>Type: TEXT</P> 667 */ 668 public static final String CONTENT_LOCATION = "ct_l"; 669 670 /** 671 * The address of the sender. 672 * <P>Type: TEXT</P> 673 */ 674 public static final String FROM = "from"; 675 676 /** 677 * The address of the recipients. 678 * <P>Type: TEXT</P> 679 */ 680 public static final String TO = "to"; 681 682 /** 683 * The address of the cc. recipients. 684 * <P>Type: TEXT</P> 685 */ 686 public static final String CC = "cc"; 687 688 /** 689 * The address of the bcc. recipients. 690 * <P>Type: TEXT</P> 691 */ 692 public static final String BCC = "bcc"; 693 694 /** 695 * The expiry time of the message. 696 * <P>Type: INTEGER</P> 697 */ 698 public static final String EXPIRY = "exp"; 699 700 /** 701 * The class of the message. 702 * <P>Type: TEXT</P> 703 */ 704 public static final String MESSAGE_CLASS = "m_cls"; 705 706 /** 707 * The type of the message defined by MMS spec. 708 * <P>Type: INTEGER</P> 709 */ 710 public static final String MESSAGE_TYPE = "m_type"; 711 712 /** 713 * The version of specification that this message conform. 714 * <P>Type: INTEGER</P> 715 */ 716 public static final String MMS_VERSION = "v"; 717 718 /** 719 * The size of the message. 720 * <P>Type: INTEGER</P> 721 */ 722 public static final String MESSAGE_SIZE = "m_size"; 723 724 /** 725 * The priority of the message. 726 * <P>Type: TEXT</P> 727 */ 728 public static final String PRIORITY = "pri"; 729 730 /** 731 * The read-report of the message. 732 * <P>Type: TEXT</P> 733 */ 734 public static final String READ_REPORT = "rr"; 735 736 /** 737 * Whether the report is allowed. 738 * <P>Type: TEXT</P> 739 */ 740 public static final String REPORT_ALLOWED = "rpt_a"; 741 742 /** 743 * The response-status of the message. 744 * <P>Type: INTEGER</P> 745 */ 746 public static final String RESPONSE_STATUS = "resp_st"; 747 748 /** 749 * The status of the message. 750 * <P>Type: INTEGER</P> 751 */ 752 public static final String STATUS = "st"; 753 754 /** 755 * The transaction-id of the message. 756 * <P>Type: TEXT</P> 757 */ 758 public static final String TRANSACTION_ID = "tr_id"; 759 760 /** 761 * The retrieve-status of the message. 762 * <P>Type: INTEGER</P> 763 */ 764 public static final String RETRIEVE_STATUS = "retr_st"; 765 766 /** 767 * The retrieve-text of the message. 768 * <P>Type: TEXT</P> 769 */ 770 public static final String RETRIEVE_TEXT = "retr_txt"; 771 772 /** 773 * The character set of the retrieve-text. 774 * <P>Type: TEXT</P> 775 */ 776 public static final String RETRIEVE_TEXT_CHARSET = "retr_txt_cs"; 777 778 /** 779 * The read-status of the message. 780 * <P>Type: INTEGER</P> 781 */ 782 public static final String READ_STATUS = "read_status"; 783 784 /** 785 * The content-class of the message. 786 * <P>Type: INTEGER</P> 787 */ 788 public static final String CONTENT_CLASS = "ct_cls"; 789 790 /** 791 * The delivery-report of the message. 792 * <P>Type: INTEGER</P> 793 */ 794 public static final String DELIVERY_REPORT = "d_rpt"; 795 796 /** 797 * The delivery-time-token of the message. 798 * <P>Type: INTEGER</P> 799 */ 800 public static final String DELIVERY_TIME_TOKEN = "d_tm_tok"; 801 802 /** 803 * The delivery-time of the message. 804 * <P>Type: INTEGER</P> 805 */ 806 public static final String DELIVERY_TIME = "d_tm"; 807 808 /** 809 * The response-text of the message. 810 * <P>Type: TEXT</P> 811 */ 812 public static final String RESPONSE_TEXT = "resp_txt"; 813 814 /** 815 * The sender-visibility of the message. 816 * <P>Type: TEXT</P> 817 */ 818 public static final String SENDER_VISIBILITY = "s_vis"; 819 820 /** 821 * The reply-charging of the message. 822 * <P>Type: INTEGER</P> 823 */ 824 public static final String REPLY_CHARGING = "r_chg"; 825 826 /** 827 * The reply-charging-deadline-token of the message. 828 * <P>Type: INTEGER</P> 829 */ 830 public static final String REPLY_CHARGING_DEADLINE_TOKEN = "r_chg_dl_tok"; 831 832 /** 833 * The reply-charging-deadline of the message. 834 * <P>Type: INTEGER</P> 835 */ 836 public static final String REPLY_CHARGING_DEADLINE = "r_chg_dl"; 837 838 /** 839 * The reply-charging-id of the message. 840 * <P>Type: TEXT</P> 841 */ 842 public static final String REPLY_CHARGING_ID = "r_chg_id"; 843 844 /** 845 * The reply-charging-size of the message. 846 * <P>Type: INTEGER</P> 847 */ 848 public static final String REPLY_CHARGING_SIZE = "r_chg_sz"; 849 850 /** 851 * The previously-sent-by of the message. 852 * <P>Type: TEXT</P> 853 */ 854 public static final String PREVIOUSLY_SENT_BY = "p_s_by"; 855 856 /** 857 * The previously-sent-date of the message. 858 * <P>Type: INTEGER</P> 859 */ 860 public static final String PREVIOUSLY_SENT_DATE = "p_s_d"; 861 862 /** 863 * The store of the message. 864 * <P>Type: TEXT</P> 865 */ 866 public static final String STORE = "store"; 867 868 /** 869 * The mm-state of the message. 870 * <P>Type: INTEGER</P> 871 */ 872 public static final String MM_STATE = "mm_st"; 873 874 /** 875 * The mm-flags-token of the message. 876 * <P>Type: INTEGER</P> 877 */ 878 public static final String MM_FLAGS_TOKEN = "mm_flg_tok"; 879 880 /** 881 * The mm-flags of the message. 882 * <P>Type: TEXT</P> 883 */ 884 public static final String MM_FLAGS = "mm_flg"; 885 886 /** 887 * The store-status of the message. 888 * <P>Type: TEXT</P> 889 */ 890 public static final String STORE_STATUS = "store_st"; 891 892 /** 893 * The store-status-text of the message. 894 * <P>Type: TEXT</P> 895 */ 896 public static final String STORE_STATUS_TEXT = "store_st_txt"; 897 898 /** 899 * The stored of the message. 900 * <P>Type: TEXT</P> 901 */ 902 public static final String STORED = "stored"; 903 904 /** 905 * The totals of the message. 906 * <P>Type: TEXT</P> 907 */ 908 public static final String TOTALS = "totals"; 909 910 /** 911 * The mbox-totals of the message. 912 * <P>Type: TEXT</P> 913 */ 914 public static final String MBOX_TOTALS = "mb_t"; 915 916 /** 917 * The mbox-totals-token of the message. 918 * <P>Type: INTEGER</P> 919 */ 920 public static final String MBOX_TOTALS_TOKEN = "mb_t_tok"; 921 922 /** 923 * The quotas of the message. 924 * <P>Type: TEXT</P> 925 */ 926 public static final String QUOTAS = "qt"; 927 928 /** 929 * The mbox-quotas of the message. 930 * <P>Type: TEXT</P> 931 */ 932 public static final String MBOX_QUOTAS = "mb_qt"; 933 934 /** 935 * The mbox-quotas-token of the message. 936 * <P>Type: INTEGER</P> 937 */ 938 public static final String MBOX_QUOTAS_TOKEN = "mb_qt_tok"; 939 940 /** 941 * The message-count of the message. 942 * <P>Type: INTEGER</P> 943 */ 944 public static final String MESSAGE_COUNT = "m_cnt"; 945 946 /** 947 * The start of the message. 948 * <P>Type: INTEGER</P> 949 */ 950 public static final String START = "start"; 951 952 /** 953 * The distribution-indicator of the message. 954 * <P>Type: TEXT</P> 955 */ 956 public static final String DISTRIBUTION_INDICATOR = "d_ind"; 957 958 /** 959 * The element-descriptor of the message. 960 * <P>Type: TEXT</P> 961 */ 962 public static final String ELEMENT_DESCRIPTOR = "e_des"; 963 964 /** 965 * The limit of the message. 966 * <P>Type: INTEGER</P> 967 */ 968 public static final String LIMIT = "limit"; 969 970 /** 971 * The recommended-retrieval-mode of the message. 972 * <P>Type: INTEGER</P> 973 */ 974 public static final String RECOMMENDED_RETRIEVAL_MODE = "r_r_mod"; 975 976 /** 977 * The recommended-retrieval-mode-text of the message. 978 * <P>Type: TEXT</P> 979 */ 980 public static final String RECOMMENDED_RETRIEVAL_MODE_TEXT = "r_r_mod_txt"; 981 982 /** 983 * The status-text of the message. 984 * <P>Type: TEXT</P> 985 */ 986 public static final String STATUS_TEXT = "st_txt"; 987 988 /** 989 * The applic-id of the message. 990 * <P>Type: TEXT</P> 991 */ 992 public static final String APPLIC_ID = "apl_id"; 993 994 /** 995 * The reply-applic-id of the message. 996 * <P>Type: TEXT</P> 997 */ 998 public static final String REPLY_APPLIC_ID = "r_apl_id"; 999 1000 /** 1001 * The aux-applic-id of the message. 1002 * <P>Type: TEXT</P> 1003 */ 1004 public static final String AUX_APPLIC_ID = "aux_apl_id"; 1005 1006 /** 1007 * The drm-content of the message. 1008 * <P>Type: TEXT</P> 1009 */ 1010 public static final String DRM_CONTENT = "drm_c"; 1011 1012 /** 1013 * The adaptation-allowed of the message. 1014 * <P>Type: TEXT</P> 1015 */ 1016 public static final String ADAPTATION_ALLOWED = "adp_a"; 1017 1018 /** 1019 * The replace-id of the message. 1020 * <P>Type: TEXT</P> 1021 */ 1022 public static final String REPLACE_ID = "repl_id"; 1023 1024 /** 1025 * The cancel-id of the message. 1026 * <P>Type: TEXT</P> 1027 */ 1028 public static final String CANCEL_ID = "cl_id"; 1029 1030 /** 1031 * The cancel-status of the message. 1032 * <P>Type: INTEGER</P> 1033 */ 1034 public static final String CANCEL_STATUS = "cl_st"; 1035 1036 /** 1037 * The thread ID of the message 1038 * <P>Type: INTEGER</P> 1039 */ 1040 public static final String THREAD_ID = "thread_id"; 1041 1042 /** 1043 * Has the message been locked? 1044 * <P>Type: INTEGER (boolean)</P> 1045 */ 1046 public static final String LOCKED = "locked"; 1047 } 1048 1049 /** 1050 * Columns for the "canonical_addresses" table used by MMS and 1051 * SMS." 1052 */ 1053 public interface CanonicalAddressesColumns extends BaseColumns { 1054 /** 1055 * An address used in MMS or SMS. Email addresses are 1056 * converted to lower case and are compared by string 1057 * equality. Other addresses are compared using 1058 * PHONE_NUMBERS_EQUAL. 1059 * <P>Type: TEXT</P> 1060 */ 1061 public static final String ADDRESS = "address"; 1062 } 1063 1064 /** 1065 * Columns for the "threads" table used by MMS and SMS. 1066 */ 1067 public interface ThreadsColumns extends BaseColumns { 1068 /** 1069 * The date at which the thread was created. 1070 * 1071 * <P>Type: INTEGER (long)</P> 1072 */ 1073 public static final String DATE = "date"; 1074 1075 /** 1076 * A string encoding of the recipient IDs of the recipients of 1077 * the message, in numerical order and separated by spaces. 1078 * <P>Type: TEXT</P> 1079 */ 1080 public static final String RECIPIENT_IDS = "recipient_ids"; 1081 1082 /** 1083 * The message count of the thread. 1084 * <P>Type: INTEGER</P> 1085 */ 1086 public static final String MESSAGE_COUNT = "message_count"; 1087 /** 1088 * Indicates whether all messages of the thread have been read. 1089 * <P>Type: INTEGER</P> 1090 */ 1091 public static final String READ = "read"; 1092 /** 1093 * The snippet of the latest message in the thread. 1094 * <P>Type: TEXT</P> 1095 */ 1096 public static final String SNIPPET = "snippet"; 1097 /** 1098 * The charset of the snippet. 1099 * <P>Type: INTEGER</P> 1100 */ 1101 public static final String SNIPPET_CHARSET = "snippet_cs"; 1102 /** 1103 * Type of the thread, either Threads.COMMON_THREAD or 1104 * Threads.BROADCAST_THREAD. 1105 * <P>Type: INTEGER</P> 1106 */ 1107 public static final String TYPE = "type"; 1108 /** 1109 * Indicates whether there is a transmission error in the thread. 1110 * <P>Type: INTEGER</P> 1111 */ 1112 public static final String ERROR = "error"; 1113 /** 1114 * Indicates whether this thread contains any attachments. 1115 * <P>Type: INTEGER</P> 1116 */ 1117 public static final String HAS_ATTACHMENT = "has_attachment"; 1118 } 1119 1120 /** 1121 * Helper functions for the "threads" table used by MMS and SMS. 1122 */ 1123 public static final class Threads implements ThreadsColumns { 1124 private static final String[] ID_PROJECTION = { BaseColumns._ID }; 1125 private static final String STANDARD_ENCODING = "UTF-8"; 1126 private static final Uri THREAD_ID_CONTENT_URI = Uri.parse( 1127 "content://mms-sms/threadID"); 1128 public static final Uri CONTENT_URI = Uri.withAppendedPath( 1129 MmsSms.CONTENT_URI, "conversations"); 1130 public static final Uri OBSOLETE_THREADS_URI = Uri.withAppendedPath( 1131 CONTENT_URI, "obsolete"); 1132 1133 public static final int COMMON_THREAD = 0; 1134 public static final int BROADCAST_THREAD = 1; 1135 1136 // No one should construct an instance of this class. Threads()1137 private Threads() { 1138 } 1139 1140 /** 1141 * This is a single-recipient version of 1142 * getOrCreateThreadId. It's convenient for use with SMS 1143 * messages. 1144 */ getOrCreateThreadId(Context context, String recipient)1145 public static long getOrCreateThreadId(Context context, String recipient) { 1146 Set<String> recipients = new HashSet<String>(); 1147 1148 recipients.add(recipient); 1149 return getOrCreateThreadId(context, recipients); 1150 } 1151 1152 /** 1153 * Given the recipients list and subject of an unsaved message, 1154 * return its thread ID. If the message starts a new thread, 1155 * allocate a new thread ID. Otherwise, use the appropriate 1156 * existing thread ID. 1157 * 1158 * Find the thread ID of the same set of recipients (in 1159 * any order, without any additions). If one 1160 * is found, return it. Otherwise, return a unique thread ID. 1161 */ getOrCreateThreadId( Context context, Set<String> recipients)1162 public static long getOrCreateThreadId( 1163 Context context, Set<String> recipients) { 1164 Uri.Builder uriBuilder = THREAD_ID_CONTENT_URI.buildUpon(); 1165 1166 for (String recipient : recipients) { 1167 if (Mms.isEmailAddress(recipient)) { 1168 recipient = Mms.extractAddrSpec(recipient); 1169 } 1170 1171 uriBuilder.appendQueryParameter("recipient", recipient); 1172 } 1173 1174 Uri uri = uriBuilder.build(); 1175 if (DEBUG) { 1176 Log.v(TAG, "getOrCreateThreadId uri: " + uri); 1177 } 1178 Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(), 1179 uri, ID_PROJECTION, null, null, null); 1180 if (DEBUG) { 1181 Log.v(TAG, "getOrCreateThreadId cursor cnt: " + cursor.getCount()); 1182 } 1183 if (cursor != null) { 1184 try { 1185 if (cursor.moveToFirst()) { 1186 return cursor.getLong(0); 1187 } else { 1188 Log.e(TAG, "getOrCreateThreadId returned no rows!"); 1189 } 1190 } finally { 1191 cursor.close(); 1192 } 1193 } 1194 1195 Log.e(TAG, "getOrCreateThreadId failed with uri " + uri.toString()); 1196 throw new IllegalArgumentException("Unable to find or allocate a thread ID."); 1197 } 1198 } 1199 1200 /** 1201 * Contains all MMS messages. 1202 */ 1203 public static final class Mms implements BaseMmsColumns { 1204 /** 1205 * The content:// style URL for this table 1206 */ 1207 public static final Uri CONTENT_URI = Uri.parse("content://mms"); 1208 1209 public static final Uri REPORT_REQUEST_URI = Uri.withAppendedPath( 1210 CONTENT_URI, "report-request"); 1211 1212 public static final Uri REPORT_STATUS_URI = Uri.withAppendedPath( 1213 CONTENT_URI, "report-status"); 1214 1215 /** 1216 * The default sort order for this table 1217 */ 1218 public static final String DEFAULT_SORT_ORDER = "date DESC"; 1219 1220 /** 1221 * mailbox = name-addr 1222 * name-addr = [display-name] angle-addr 1223 * angle-addr = [CFWS] "<" addr-spec ">" [CFWS] 1224 */ 1225 public static final Pattern NAME_ADDR_EMAIL_PATTERN = 1226 Pattern.compile("\\s*(\"[^\"]*\"|[^<>\"]+)\\s*<([^<>]+)>\\s*"); 1227 1228 /** 1229 * quoted-string = [CFWS] 1230 * DQUOTE *([FWS] qcontent) [FWS] DQUOTE 1231 * [CFWS] 1232 */ 1233 public static final Pattern QUOTED_STRING_PATTERN = 1234 Pattern.compile("\\s*\"([^\"]*)\"\\s*"); 1235 query( ContentResolver cr, String[] projection)1236 public static final Cursor query( 1237 ContentResolver cr, String[] projection) { 1238 return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER); 1239 } 1240 query( ContentResolver cr, String[] projection, String where, String orderBy)1241 public static final Cursor query( 1242 ContentResolver cr, String[] projection, 1243 String where, String orderBy) { 1244 return cr.query(CONTENT_URI, projection, 1245 where, null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy); 1246 } 1247 getMessageBoxName(int msgBox)1248 public static final String getMessageBoxName(int msgBox) { 1249 switch (msgBox) { 1250 case MESSAGE_BOX_ALL: 1251 return "all"; 1252 case MESSAGE_BOX_INBOX: 1253 return "inbox"; 1254 case MESSAGE_BOX_SENT: 1255 return "sent"; 1256 case MESSAGE_BOX_DRAFTS: 1257 return "drafts"; 1258 case MESSAGE_BOX_OUTBOX: 1259 return "outbox"; 1260 default: 1261 throw new IllegalArgumentException("Invalid message box: " + msgBox); 1262 } 1263 } 1264 extractAddrSpec(String address)1265 public static String extractAddrSpec(String address) { 1266 Matcher match = NAME_ADDR_EMAIL_PATTERN.matcher(address); 1267 1268 if (match.matches()) { 1269 return match.group(2); 1270 } 1271 return address; 1272 } 1273 1274 /** 1275 * Returns true if the address is an email address 1276 * 1277 * @param address the input address to be tested 1278 * @return true if address is an email address 1279 */ isEmailAddress(String address)1280 public static boolean isEmailAddress(String address) { 1281 if (TextUtils.isEmpty(address)) { 1282 return false; 1283 } 1284 1285 String s = extractAddrSpec(address); 1286 Matcher match = Regex.EMAIL_ADDRESS_PATTERN.matcher(s); 1287 return match.matches(); 1288 } 1289 1290 /** 1291 * Returns true if the number is a Phone number 1292 * 1293 * @param number the input number to be tested 1294 * @return true if number is a Phone number 1295 */ isPhoneNumber(String number)1296 public static boolean isPhoneNumber(String number) { 1297 if (TextUtils.isEmpty(number)) { 1298 return false; 1299 } 1300 1301 Matcher match = Regex.PHONE_PATTERN.matcher(number); 1302 return match.matches(); 1303 } 1304 1305 /** 1306 * Contains all MMS messages in the MMS app's inbox. 1307 */ 1308 public static final class Inbox implements BaseMmsColumns { 1309 /** 1310 * The content:// style URL for this table 1311 */ 1312 public static final Uri 1313 CONTENT_URI = Uri.parse("content://mms/inbox"); 1314 1315 /** 1316 * The default sort order for this table 1317 */ 1318 public static final String DEFAULT_SORT_ORDER = "date DESC"; 1319 } 1320 1321 /** 1322 * Contains all MMS messages in the MMS app's sent box. 1323 */ 1324 public static final class Sent implements BaseMmsColumns { 1325 /** 1326 * The content:// style URL for this table 1327 */ 1328 public static final Uri 1329 CONTENT_URI = Uri.parse("content://mms/sent"); 1330 1331 /** 1332 * The default sort order for this table 1333 */ 1334 public static final String DEFAULT_SORT_ORDER = "date DESC"; 1335 } 1336 1337 /** 1338 * Contains all MMS messages in the MMS app's drafts box. 1339 */ 1340 public static final class Draft implements BaseMmsColumns { 1341 /** 1342 * The content:// style URL for this table 1343 */ 1344 public static final Uri 1345 CONTENT_URI = Uri.parse("content://mms/drafts"); 1346 1347 /** 1348 * The default sort order for this table 1349 */ 1350 public static final String DEFAULT_SORT_ORDER = "date DESC"; 1351 } 1352 1353 /** 1354 * Contains all MMS messages in the MMS app's outbox. 1355 */ 1356 public static final class Outbox implements BaseMmsColumns { 1357 /** 1358 * The content:// style URL for this table 1359 */ 1360 public static final Uri 1361 CONTENT_URI = Uri.parse("content://mms/outbox"); 1362 1363 /** 1364 * The default sort order for this table 1365 */ 1366 public static final String DEFAULT_SORT_ORDER = "date DESC"; 1367 } 1368 1369 public static final class Addr implements BaseColumns { 1370 /** 1371 * The ID of MM which this address entry belongs to. 1372 */ 1373 public static final String MSG_ID = "msg_id"; 1374 1375 /** 1376 * The ID of contact entry in Phone Book. 1377 */ 1378 public static final String CONTACT_ID = "contact_id"; 1379 1380 /** 1381 * The address text. 1382 */ 1383 public static final String ADDRESS = "address"; 1384 1385 /** 1386 * Type of address, must be one of PduHeaders.BCC, 1387 * PduHeaders.CC, PduHeaders.FROM, PduHeaders.TO. 1388 */ 1389 public static final String TYPE = "type"; 1390 1391 /** 1392 * Character set of this entry. 1393 */ 1394 public static final String CHARSET = "charset"; 1395 } 1396 1397 public static final class Part implements BaseColumns { 1398 /** 1399 * The identifier of the message which this part belongs to. 1400 * <P>Type: INTEGER</P> 1401 */ 1402 public static final String MSG_ID = "mid"; 1403 1404 /** 1405 * The order of the part. 1406 * <P>Type: INTEGER</P> 1407 */ 1408 public static final String SEQ = "seq"; 1409 1410 /** 1411 * The content type of the part. 1412 * <P>Type: TEXT</P> 1413 */ 1414 public static final String CONTENT_TYPE = "ct"; 1415 1416 /** 1417 * The name of the part. 1418 * <P>Type: TEXT</P> 1419 */ 1420 public static final String NAME = "name"; 1421 1422 /** 1423 * The charset of the part. 1424 * <P>Type: TEXT</P> 1425 */ 1426 public static final String CHARSET = "chset"; 1427 1428 /** 1429 * The file name of the part. 1430 * <P>Type: TEXT</P> 1431 */ 1432 public static final String FILENAME = "fn"; 1433 1434 /** 1435 * The content disposition of the part. 1436 * <P>Type: TEXT</P> 1437 */ 1438 public static final String CONTENT_DISPOSITION = "cd"; 1439 1440 /** 1441 * The content ID of the part. 1442 * <P>Type: INTEGER</P> 1443 */ 1444 public static final String CONTENT_ID = "cid"; 1445 1446 /** 1447 * The content location of the part. 1448 * <P>Type: INTEGER</P> 1449 */ 1450 public static final String CONTENT_LOCATION = "cl"; 1451 1452 /** 1453 * The start of content-type of the message. 1454 * <P>Type: INTEGER</P> 1455 */ 1456 public static final String CT_START = "ctt_s"; 1457 1458 /** 1459 * The type of content-type of the message. 1460 * <P>Type: TEXT</P> 1461 */ 1462 public static final String CT_TYPE = "ctt_t"; 1463 1464 /** 1465 * The location(on filesystem) of the binary data of the part. 1466 * <P>Type: INTEGER</P> 1467 */ 1468 public static final String _DATA = "_data"; 1469 1470 public static final String TEXT = "text"; 1471 1472 } 1473 1474 public static final class Rate { 1475 public static final Uri CONTENT_URI = Uri.withAppendedPath( 1476 Mms.CONTENT_URI, "rate"); 1477 /** 1478 * When a message was successfully sent. 1479 * <P>Type: INTEGER</P> 1480 */ 1481 public static final String SENT_TIME = "sent_time"; 1482 } 1483 1484 public static final class ScrapSpace { 1485 /** 1486 * The content:// style URL for this table 1487 */ 1488 public static final Uri CONTENT_URI = Uri.parse("content://mms/scrapSpace"); 1489 1490 /** 1491 * This is the scrap file we use to store the media attachment when the user 1492 * chooses to capture a photo to be attached . We pass {#link@Uri} to the Camera app, 1493 * which streams the captured image to the uri. Internally we write the media content 1494 * to this file. It's named '.temp.jpg' so Gallery won't pick it up. 1495 */ 1496 public static final String SCRAP_FILE_PATH = "/sdcard/mms/scrapSpace/.temp.jpg"; 1497 } 1498 1499 public static final class Intents { Intents()1500 private Intents() { 1501 // Non-instantiatable. 1502 } 1503 1504 /** 1505 * The extra field to store the contents of the Intent, 1506 * which should be an array of Uri. 1507 */ 1508 public static final String EXTRA_CONTENTS = "contents"; 1509 /** 1510 * The extra field to store the type of the contents, 1511 * which should be an array of String. 1512 */ 1513 public static final String EXTRA_TYPES = "types"; 1514 /** 1515 * The extra field to store the 'Cc' addresses. 1516 */ 1517 public static final String EXTRA_CC = "cc"; 1518 /** 1519 * The extra field to store the 'Bcc' addresses; 1520 */ 1521 public static final String EXTRA_BCC = "bcc"; 1522 /** 1523 * The extra field to store the 'Subject'. 1524 */ 1525 public static final String EXTRA_SUBJECT = "subject"; 1526 /** 1527 * Indicates that the contents of specified URIs were changed. 1528 * The application which is showing or caching these contents 1529 * should be updated. 1530 */ 1531 public static final String 1532 CONTENT_CHANGED_ACTION = "android.intent.action.CONTENT_CHANGED"; 1533 /** 1534 * An extra field which stores the URI of deleted contents. 1535 */ 1536 public static final String DELETED_CONTENTS = "deleted_contents"; 1537 } 1538 } 1539 1540 /** 1541 * Contains all MMS and SMS messages. 1542 */ 1543 public static final class MmsSms implements BaseColumns { 1544 /** 1545 * The column to distinguish SMS & MMS messages in query results. 1546 */ 1547 public static final String TYPE_DISCRIMINATOR_COLUMN = 1548 "transport_type"; 1549 1550 public static final Uri CONTENT_URI = Uri.parse("content://mms-sms/"); 1551 1552 public static final Uri CONTENT_CONVERSATIONS_URI = Uri.parse( 1553 "content://mms-sms/conversations"); 1554 1555 public static final Uri CONTENT_FILTER_BYPHONE_URI = Uri.parse( 1556 "content://mms-sms/messages/byphone"); 1557 1558 public static final Uri CONTENT_UNDELIVERED_URI = Uri.parse( 1559 "content://mms-sms/undelivered"); 1560 1561 public static final Uri CONTENT_DRAFT_URI = Uri.parse( 1562 "content://mms-sms/draft"); 1563 1564 public static final Uri CONTENT_LOCKED_URI = Uri.parse( 1565 "content://mms-sms/locked"); 1566 1567 /*** 1568 * Pass in a query parameter called "pattern" which is the text 1569 * to search for. 1570 * The sort order is fixed to be thread_id ASC,date DESC. 1571 */ 1572 public static final Uri SEARCH_URI = Uri.parse( 1573 "content://mms-sms/search"); 1574 1575 // Constants for message protocol types. 1576 public static final int SMS_PROTO = 0; 1577 public static final int MMS_PROTO = 1; 1578 1579 // Constants for error types of pending messages. 1580 public static final int NO_ERROR = 0; 1581 public static final int ERR_TYPE_GENERIC = 1; 1582 public static final int ERR_TYPE_SMS_PROTO_TRANSIENT = 2; 1583 public static final int ERR_TYPE_MMS_PROTO_TRANSIENT = 3; 1584 public static final int ERR_TYPE_TRANSPORT_FAILURE = 4; 1585 public static final int ERR_TYPE_GENERIC_PERMANENT = 10; 1586 public static final int ERR_TYPE_SMS_PROTO_PERMANENT = 11; 1587 public static final int ERR_TYPE_MMS_PROTO_PERMANENT = 12; 1588 1589 public static final class PendingMessages implements BaseColumns { 1590 public static final Uri CONTENT_URI = Uri.withAppendedPath( 1591 MmsSms.CONTENT_URI, "pending"); 1592 /** 1593 * The type of transport protocol(MMS or SMS). 1594 * <P>Type: INTEGER</P> 1595 */ 1596 public static final String PROTO_TYPE = "proto_type"; 1597 /** 1598 * The ID of the message to be sent or downloaded. 1599 * <P>Type: INTEGER</P> 1600 */ 1601 public static final String MSG_ID = "msg_id"; 1602 /** 1603 * The type of the message to be sent or downloaded. 1604 * This field is only valid for MM. For SM, its value is always 1605 * set to 0. 1606 */ 1607 public static final String MSG_TYPE = "msg_type"; 1608 /** 1609 * The type of the error code. 1610 * <P>Type: INTEGER</P> 1611 */ 1612 public static final String ERROR_TYPE = "err_type"; 1613 /** 1614 * The error code of sending/retrieving process. 1615 * <P>Type: INTEGER</P> 1616 */ 1617 public static final String ERROR_CODE = "err_code"; 1618 /** 1619 * How many times we tried to send or download the message. 1620 * <P>Type: INTEGER</P> 1621 */ 1622 public static final String RETRY_INDEX = "retry_index"; 1623 /** 1624 * The time to do next retry. 1625 */ 1626 public static final String DUE_TIME = "due_time"; 1627 /** 1628 * The time we last tried to send or download the message. 1629 */ 1630 public static final String LAST_TRY = "last_try"; 1631 } 1632 } 1633 1634 public static final class Carriers implements BaseColumns { 1635 /** 1636 * The content:// style URL for this table 1637 */ 1638 public static final Uri CONTENT_URI = 1639 Uri.parse("content://telephony/carriers"); 1640 1641 /** 1642 * The default sort order for this table 1643 */ 1644 public static final String DEFAULT_SORT_ORDER = "name ASC"; 1645 1646 public static final String NAME = "name"; 1647 1648 public static final String APN = "apn"; 1649 1650 public static final String PROXY = "proxy"; 1651 1652 public static final String PORT = "port"; 1653 1654 public static final String MMSPROXY = "mmsproxy"; 1655 1656 public static final String MMSPORT = "mmsport"; 1657 1658 public static final String SERVER = "server"; 1659 1660 public static final String USER = "user"; 1661 1662 public static final String PASSWORD = "password"; 1663 1664 public static final String MMSC = "mmsc"; 1665 1666 public static final String MCC = "mcc"; 1667 1668 public static final String MNC = "mnc"; 1669 1670 public static final String NUMERIC = "numeric"; 1671 1672 public static final String AUTH_TYPE = "authtype"; 1673 1674 public static final String TYPE = "type"; 1675 1676 public static final String CURRENT = "current"; 1677 } 1678 1679 public static final class Intents { Intents()1680 private Intents() { 1681 // Not instantiable 1682 } 1683 1684 /** 1685 * Broadcast Action: A "secret code" has been entered in the dialer. Secret codes are 1686 * of the form *#*#<code>#*#*. The intent will have the data URI:</p> 1687 * 1688 * <p><code>android_secret_code://<code></code></p> 1689 */ 1690 public static final String SECRET_CODE_ACTION = 1691 "android.provider.Telephony.SECRET_CODE"; 1692 1693 /** 1694 * Broadcast Action: The Service Provider string(s) have been updated. Activities or 1695 * services that use these strings should update their display. 1696 * The intent will have the following extra values:</p> 1697 * <ul> 1698 * <li><em>showPlmn</em> - Boolean that indicates whether the PLMN should be shown.</li> 1699 * <li><em>plmn</em> - The operator name of the registered network, as a string.</li> 1700 * <li><em>showSpn</em> - Boolean that indicates whether the SPN should be shown.</li> 1701 * <li><em>spn</em> - The service provider name, as a string.</li> 1702 * </ul> 1703 * Note that <em>showPlmn</em> may indicate that <em>plmn</em> should be displayed, even 1704 * though the value for <em>plmn</em> is null. This can happen, for example, if the phone 1705 * has not registered to a network yet. In this case the receiver may substitute an 1706 * appropriate placeholder string (eg, "No service"). 1707 * 1708 * It is recommended to display <em>plmn</em> before / above <em>spn</em> if 1709 * both are displayed. 1710 * 1711 * <p>Note this is a protected intent that can only be sent 1712 * by the system. 1713 */ 1714 public static final String SPN_STRINGS_UPDATED_ACTION = 1715 "android.provider.Telephony.SPN_STRINGS_UPDATED"; 1716 1717 public static final String EXTRA_SHOW_PLMN = "showPlmn"; 1718 public static final String EXTRA_PLMN = "plmn"; 1719 public static final String EXTRA_SHOW_SPN = "showSpn"; 1720 public static final String EXTRA_SPN = "spn"; 1721 } 1722 } 1723