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