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