From 33034b13cae1429d526722374bd39be3f9605ae4 Mon Sep 17 00:00:00 2001
From: Wink Saville Type: INTEGER Type: INTEGER Type: TEXT Type: INTEGER (long) Type: INTEGER (long) Type: INTEGER (long) Type: INTEGER (boolean) Type: TEXT Type: TEXT Type: INTEGER (reference to item in content://contacts/people) Type: INTEGER Type: BOOLEAN Type: TEXT Type: INTEGER (boolean) Type: INTEGER Type: TEXT Type: TEXT Type: INTEGERTP-Reply-Path
bit was set on this message
- *
The extra values can be extracted using - * {@link #getMessagesFromIntent(Intent)}.
- * - *If a BroadcastReceiver encounters an error while processing - * this intent it should set the result code appropriately.
- */ - @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) - public static final String SMS_RECEIVED_ACTION = - "android.provider.Telephony.SMS_RECEIVED"; - - /** - * Broadcast Action: A new data based SMS message has been received - * by the device. The intent will have the following extra - * values: - * - *The extra values can be extracted using - * {@link #getMessagesFromIntent(Intent)}.
- * - *If a BroadcastReceiver encounters an error while processing - * this intent it should set the result code appropriately.
- */ - @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) - public static final String DATA_SMS_RECEIVED_ACTION = - "android.intent.action.DATA_SMS_RECEIVED"; - - /** - * Broadcast Action: A new WAP PUSH message has been received by the - * device. The intent will have the following extra - * values: - * - *If a BroadcastReceiver encounters an error while processing - * this intent it should set the result code appropriately.
- * - *The contentTypeParameters extra value is map of content parameters keyed by - * their names.
- * - *If any unassigned well-known parameters are encountered, the key of the map will - * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter. If - * a parameter has No-Value the value in the map will be null.
- */ - @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) - public static final String WAP_PUSH_RECEIVED_ACTION = - "android.provider.Telephony.WAP_PUSH_RECEIVED"; - - /** - * Broadcast Action: A new Cell Broadcast message has been received - * by the device. The intent will have the following extra - * values: - * - *The extra values can be extracted using - * {@link #getMessagesFromIntent(Intent)}.
- * - *If a BroadcastReceiver encounters an error while processing - * this intent it should set the result code appropriately.
- */ - @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) - public static final String SMS_CB_RECEIVED_ACTION = - "android.provider.Telephony.SMS_CB_RECEIVED"; - - /** - * Broadcast Action: A new Emergency Broadcast message has been received - * by the device. The intent will have the following extra - * values: - * - *The extra values can be extracted using - * {@link #getMessagesFromIntent(Intent)}.
- * - *If a BroadcastReceiver encounters an error while processing - * this intent it should set the result code appropriately.
- */ - @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) - public static final String SMS_EMERGENCY_CB_RECEIVED_ACTION = - "android.provider.Telephony.SMS_EMERGENCY_CB_RECEIVED"; - - /** - * Broadcast Action: A new CDMA SMS has been received containing Service Category - * Program Data (updates the list of enabled broadcast channels). The intent will - * have the following extra values: - * - *The extra values can be extracted using - * {@link #getMessagesFromIntent(Intent)}.
- * - *If a BroadcastReceiver encounters an error while processing - * this intent it should set the result code appropriately.
- */ - @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) - public static final String SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION = - "android.provider.Telephony.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED"; - - /** - * Broadcast Action: The SIM storage for SMS messages is full. If - * space is not freed, messages targeted for the SIM (class 2) may - * not be saved. - */ - @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) - public static final String SIM_FULL_ACTION = - "android.provider.Telephony.SIM_FULL"; - - /** - * Broadcast Action: An incoming SMS has been rejected by the - * telephony framework. This intent is sent in lieu of any - * of the RECEIVED_ACTION intents. The intent will have the - * following extra value: - * - *{@link #RESULT_SMS_OUT_OF_MEMORY}
,
- * indicating the error returned to the network.Type: INTEGER (long)
- */ - public static final String DATE = "date"; - - /** - * The date the message was sent. - *Type: INTEGER (long)
- */ - public static final String DATE_SENT = "date_sent"; - - /** - * The box which the message belong to, for example, MESSAGE_BOX_INBOX. - *Type: INTEGER
- */ - public static final String MESSAGE_BOX = "msg_box"; - - /** - * Has the message been read. - *Type: INTEGER (boolean)
- */ - public static final String READ = "read"; - - /** - * Indicates whether this message has been seen by the user. The "seen" flag will be - * used to figure out whether we need to throw up a statusbar notification or not. - */ - public static final String SEEN = "seen"; - - /** - * The Message-ID of the message. - *Type: TEXT
- */ - public static final String MESSAGE_ID = "m_id"; - - /** - * The subject of the message, if present. - *Type: TEXT
- */ - public static final String SUBJECT = "sub"; - - /** - * The character set of the subject, if present. - *Type: INTEGER
- */ - public static final String SUBJECT_CHARSET = "sub_cs"; - - /** - * The Content-Type of the message. - *Type: TEXT
- */ - public static final String CONTENT_TYPE = "ct_t"; - - /** - * The Content-Location of the message. - *Type: TEXT
- */ - public static final String CONTENT_LOCATION = "ct_l"; - - /** - * The address of the sender. - *Type: TEXT
- */ - public static final String FROM = "from"; - - /** - * The address of the recipients. - *Type: TEXT
- */ - public static final String TO = "to"; - - /** - * The address of the cc. recipients. - *Type: TEXT
- */ - public static final String CC = "cc"; - - /** - * The address of the bcc. recipients. - *Type: TEXT
- */ - public static final String BCC = "bcc"; - - /** - * The expiry time of the message. - *Type: INTEGER
- */ - public static final String EXPIRY = "exp"; - - /** - * The class of the message. - *Type: TEXT
- */ - public static final String MESSAGE_CLASS = "m_cls"; - - /** - * The type of the message defined by MMS spec. - *Type: INTEGER
- */ - public static final String MESSAGE_TYPE = "m_type"; - - /** - * The version of specification that this message conform. - *Type: INTEGER
- */ - public static final String MMS_VERSION = "v"; - - /** - * The size of the message. - *Type: INTEGER
- */ - public static final String MESSAGE_SIZE = "m_size"; - - /** - * The priority of the message. - *Type: TEXT
- */ - public static final String PRIORITY = "pri"; - - /** - * The read-report of the message. - *Type: TEXT
- */ - public static final String READ_REPORT = "rr"; - - /** - * Whether the report is allowed. - *Type: TEXT
- */ - public static final String REPORT_ALLOWED = "rpt_a"; - - /** - * The response-status of the message. - *Type: INTEGER
- */ - public static final String RESPONSE_STATUS = "resp_st"; - - /** - * The status of the message. - *Type: INTEGER
- */ - public static final String STATUS = "st"; - - /** - * The transaction-id of the message. - *Type: TEXT
- */ - public static final String TRANSACTION_ID = "tr_id"; - - /** - * The retrieve-status of the message. - *Type: INTEGER
- */ - public static final String RETRIEVE_STATUS = "retr_st"; - - /** - * The retrieve-text of the message. - *Type: TEXT
- */ - public static final String RETRIEVE_TEXT = "retr_txt"; - - /** - * The character set of the retrieve-text. - *Type: TEXT
- */ - public static final String RETRIEVE_TEXT_CHARSET = "retr_txt_cs"; - - /** - * The read-status of the message. - *Type: INTEGER
- */ - public static final String READ_STATUS = "read_status"; - - /** - * The content-class of the message. - *Type: INTEGER
- */ - public static final String CONTENT_CLASS = "ct_cls"; - - /** - * The delivery-report of the message. - *Type: INTEGER
- */ - public static final String DELIVERY_REPORT = "d_rpt"; - - /** - * The delivery-time-token of the message. - *Type: INTEGER
- */ - public static final String DELIVERY_TIME_TOKEN = "d_tm_tok"; - - /** - * The delivery-time of the message. - *Type: INTEGER
- */ - public static final String DELIVERY_TIME = "d_tm"; - - /** - * The response-text of the message. - *Type: TEXT
- */ - public static final String RESPONSE_TEXT = "resp_txt"; - - /** - * The sender-visibility of the message. - *Type: TEXT
- */ - public static final String SENDER_VISIBILITY = "s_vis"; - - /** - * The reply-charging of the message. - *Type: INTEGER
- */ - public static final String REPLY_CHARGING = "r_chg"; - - /** - * The reply-charging-deadline-token of the message. - *Type: INTEGER
- */ - public static final String REPLY_CHARGING_DEADLINE_TOKEN = "r_chg_dl_tok"; - - /** - * The reply-charging-deadline of the message. - *Type: INTEGER
- */ - public static final String REPLY_CHARGING_DEADLINE = "r_chg_dl"; - - /** - * The reply-charging-id of the message. - *Type: TEXT
- */ - public static final String REPLY_CHARGING_ID = "r_chg_id"; - - /** - * The reply-charging-size of the message. - *Type: INTEGER
- */ - public static final String REPLY_CHARGING_SIZE = "r_chg_sz"; - - /** - * The previously-sent-by of the message. - *Type: TEXT
- */ - public static final String PREVIOUSLY_SENT_BY = "p_s_by"; - - /** - * The previously-sent-date of the message. - *Type: INTEGER
- */ - public static final String PREVIOUSLY_SENT_DATE = "p_s_d"; - - /** - * The store of the message. - *Type: TEXT
- */ - public static final String STORE = "store"; - - /** - * The mm-state of the message. - *Type: INTEGER
- */ - public static final String MM_STATE = "mm_st"; - - /** - * The mm-flags-token of the message. - *Type: INTEGER
- */ - public static final String MM_FLAGS_TOKEN = "mm_flg_tok"; - - /** - * The mm-flags of the message. - *Type: TEXT
- */ - public static final String MM_FLAGS = "mm_flg"; - - /** - * The store-status of the message. - *Type: TEXT
- */ - public static final String STORE_STATUS = "store_st"; - - /** - * The store-status-text of the message. - *Type: TEXT
- */ - public static final String STORE_STATUS_TEXT = "store_st_txt"; - - /** - * The stored of the message. - *Type: TEXT
- */ - public static final String STORED = "stored"; - - /** - * The totals of the message. - *Type: TEXT
- */ - public static final String TOTALS = "totals"; - - /** - * The mbox-totals of the message. - *Type: TEXT
- */ - public static final String MBOX_TOTALS = "mb_t"; - - /** - * The mbox-totals-token of the message. - *Type: INTEGER
- */ - public static final String MBOX_TOTALS_TOKEN = "mb_t_tok"; - - /** - * The quotas of the message. - *Type: TEXT
- */ - public static final String QUOTAS = "qt"; - - /** - * The mbox-quotas of the message. - *Type: TEXT
- */ - public static final String MBOX_QUOTAS = "mb_qt"; - - /** - * The mbox-quotas-token of the message. - *Type: INTEGER
- */ - public static final String MBOX_QUOTAS_TOKEN = "mb_qt_tok"; - - /** - * The message-count of the message. - *Type: INTEGER
- */ - public static final String MESSAGE_COUNT = "m_cnt"; - - /** - * The start of the message. - *Type: INTEGER
- */ - public static final String START = "start"; - - /** - * The distribution-indicator of the message. - *Type: TEXT
- */ - public static final String DISTRIBUTION_INDICATOR = "d_ind"; - - /** - * The element-descriptor of the message. - *Type: TEXT
- */ - public static final String ELEMENT_DESCRIPTOR = "e_des"; - - /** - * The limit of the message. - *Type: INTEGER
- */ - public static final String LIMIT = "limit"; - - /** - * The recommended-retrieval-mode of the message. - *Type: INTEGER
- */ - public static final String RECOMMENDED_RETRIEVAL_MODE = "r_r_mod"; - - /** - * The recommended-retrieval-mode-text of the message. - *Type: TEXT
- */ - public static final String RECOMMENDED_RETRIEVAL_MODE_TEXT = "r_r_mod_txt"; - - /** - * The status-text of the message. - *Type: TEXT
- */ - public static final String STATUS_TEXT = "st_txt"; - - /** - * The applic-id of the message. - *Type: TEXT
- */ - public static final String APPLIC_ID = "apl_id"; - - /** - * The reply-applic-id of the message. - *Type: TEXT
- */ - public static final String REPLY_APPLIC_ID = "r_apl_id"; - - /** - * The aux-applic-id of the message. - *Type: TEXT
- */ - public static final String AUX_APPLIC_ID = "aux_apl_id"; - - /** - * The drm-content of the message. - *Type: TEXT
- */ - public static final String DRM_CONTENT = "drm_c"; - - /** - * The adaptation-allowed of the message. - *Type: TEXT
- */ - public static final String ADAPTATION_ALLOWED = "adp_a"; - - /** - * The replace-id of the message. - *Type: TEXT
- */ - public static final String REPLACE_ID = "repl_id"; - - /** - * The cancel-id of the message. - *Type: TEXT
- */ - public static final String CANCEL_ID = "cl_id"; - - /** - * The cancel-status of the message. - *Type: INTEGER
- */ - public static final String CANCEL_STATUS = "cl_st"; - - /** - * The thread ID of the message - *Type: INTEGER
- */ - public static final String THREAD_ID = "thread_id"; - - /** - * Has the message been locked? - *Type: INTEGER (boolean)
- */ - public static final String LOCKED = "locked"; - - /** - * Meta data used externally. - *Type: TEXT
- */ - public static final String META_DATA = "meta_data"; - } - - /** - * Columns for the "canonical_addresses" table used by MMS and - * SMS." - */ - public interface CanonicalAddressesColumns extends BaseColumns { - /** - * An address used in MMS or SMS. Email addresses are - * converted to lower case and are compared by string - * equality. Other addresses are compared using - * PHONE_NUMBERS_EQUAL. - *Type: TEXT
- */ - public static final String ADDRESS = "address"; - } - - /** - * Columns for the "threads" table used by MMS and SMS. - */ - public interface ThreadsColumns extends BaseColumns { - /** - * The date at which the thread was created. - * - *Type: INTEGER (long)
- */ - public static final String DATE = "date"; - - /** - * A string encoding of the recipient IDs of the recipients of - * the message, in numerical order and separated by spaces. - *Type: TEXT
- */ - public static final String RECIPIENT_IDS = "recipient_ids"; - - /** - * The message count of the thread. - *Type: INTEGER
- */ - public static final String MESSAGE_COUNT = "message_count"; - /** - * Indicates whether all messages of the thread have been read. - *Type: INTEGER
- */ - public static final String READ = "read"; - - /** - * The snippet of the latest message in the thread. - *Type: TEXT
- */ - public static final String SNIPPET = "snippet"; - /** - * The charset of the snippet. - *Type: INTEGER
- */ - public static final String SNIPPET_CHARSET = "snippet_cs"; - /** - * Type of the thread, either Threads.COMMON_THREAD or - * Threads.BROADCAST_THREAD. - *Type: INTEGER
- */ - public static final String TYPE = "type"; - /** - * Indicates whether there is a transmission error in the thread. - *Type: INTEGER
- */ - public static final String ERROR = "error"; - /** - * Indicates whether this thread contains any attachments. - *Type: INTEGER
- */ - public static final String HAS_ATTACHMENT = "has_attachment"; - } - - /** - * Helper functions for the "threads" table used by MMS and SMS. - */ - public static final class Threads implements ThreadsColumns { - private static final String[] ID_PROJECTION = { BaseColumns._ID }; - private static final String STANDARD_ENCODING = "UTF-8"; - private static final Uri THREAD_ID_CONTENT_URI = Uri.parse( - "content://mms-sms/threadID"); - public static final Uri CONTENT_URI = Uri.withAppendedPath( - MmsSms.CONTENT_URI, "conversations"); - public static final Uri OBSOLETE_THREADS_URI = Uri.withAppendedPath( - CONTENT_URI, "obsolete"); - - public static final int COMMON_THREAD = 0; - public static final int BROADCAST_THREAD = 1; - - // No one should construct an instance of this class. - private Threads() { - } - - /** - * This is a single-recipient version of - * getOrCreateThreadId. It's convenient for use with SMS - * messages. - */ - public static long getOrCreateThreadId(Context context, String recipient) { - SetType: INTEGER
- */ - public static final String MSG_ID = "mid"; - - /** - * The order of the part. - *Type: INTEGER
- */ - public static final String SEQ = "seq"; - - /** - * The content type of the part. - *Type: TEXT
- */ - public static final String CONTENT_TYPE = "ct"; - - /** - * The name of the part. - *Type: TEXT
- */ - public static final String NAME = "name"; - - /** - * The charset of the part. - *Type: TEXT
- */ - public static final String CHARSET = "chset"; - - /** - * The file name of the part. - *Type: TEXT
- */ - public static final String FILENAME = "fn"; - - /** - * The content disposition of the part. - *Type: TEXT
- */ - public static final String CONTENT_DISPOSITION = "cd"; - - /** - * The content ID of the part. - *Type: INTEGER
- */ - public static final String CONTENT_ID = "cid"; - - /** - * The content location of the part. - *Type: INTEGER
- */ - public static final String CONTENT_LOCATION = "cl"; - - /** - * The start of content-type of the message. - *Type: INTEGER
- */ - public static final String CT_START = "ctt_s"; - - /** - * The type of content-type of the message. - *Type: TEXT
- */ - public static final String CT_TYPE = "ctt_t"; - - /** - * The location(on filesystem) of the binary data of the part. - *Type: INTEGER
- */ - public static final String _DATA = "_data"; - - public static final String TEXT = "text"; - - } - - public static final class Rate { - public static final Uri CONTENT_URI = Uri.withAppendedPath( - Mms.CONTENT_URI, "rate"); - /** - * When a message was successfully sent. - *Type: INTEGER
- */ - public static final String SENT_TIME = "sent_time"; - } - - public static final class Intents { - private Intents() { - // Non-instantiatable. - } - - /** - * The extra field to store the contents of the Intent, - * which should be an array of Uri. - */ - public static final String EXTRA_CONTENTS = "contents"; - /** - * The extra field to store the type of the contents, - * which should be an array of String. - */ - public static final String EXTRA_TYPES = "types"; - /** - * The extra field to store the 'Cc' addresses. - */ - public static final String EXTRA_CC = "cc"; - /** - * The extra field to store the 'Bcc' addresses; - */ - public static final String EXTRA_BCC = "bcc"; - /** - * The extra field to store the 'Subject'. - */ - public static final String EXTRA_SUBJECT = "subject"; - /** - * Indicates that the contents of specified URIs were changed. - * The application which is showing or caching these contents - * should be updated. - */ - public static final String - CONTENT_CHANGED_ACTION = "android.intent.action.CONTENT_CHANGED"; - /** - * An extra field which stores the URI of deleted contents. - */ - public static final String DELETED_CONTENTS = "deleted_contents"; - } - } - - /** - * Contains all MMS and SMS messages. - */ - public static final class MmsSms implements BaseColumns { - /** - * The column to distinguish SMS & MMS messages in query results. - */ - public static final String TYPE_DISCRIMINATOR_COLUMN = - "transport_type"; - - public static final Uri CONTENT_URI = Uri.parse("content://mms-sms/"); - - public static final Uri CONTENT_CONVERSATIONS_URI = Uri.parse( - "content://mms-sms/conversations"); - - public static final Uri CONTENT_FILTER_BYPHONE_URI = Uri.parse( - "content://mms-sms/messages/byphone"); - - public static final Uri CONTENT_UNDELIVERED_URI = Uri.parse( - "content://mms-sms/undelivered"); - - public static final Uri CONTENT_DRAFT_URI = Uri.parse( - "content://mms-sms/draft"); - - public static final Uri CONTENT_LOCKED_URI = Uri.parse( - "content://mms-sms/locked"); - - /*** - * Pass in a query parameter called "pattern" which is the text - * to search for. - * The sort order is fixed to be thread_id ASC,date DESC. - */ - public static final Uri SEARCH_URI = Uri.parse( - "content://mms-sms/search"); - - // Constants for message protocol types. - public static final int SMS_PROTO = 0; - public static final int MMS_PROTO = 1; - - // Constants for error types of pending messages. - public static final int NO_ERROR = 0; - public static final int ERR_TYPE_GENERIC = 1; - public static final int ERR_TYPE_SMS_PROTO_TRANSIENT = 2; - public static final int ERR_TYPE_MMS_PROTO_TRANSIENT = 3; - public static final int ERR_TYPE_TRANSPORT_FAILURE = 4; - public static final int ERR_TYPE_GENERIC_PERMANENT = 10; - public static final int ERR_TYPE_SMS_PROTO_PERMANENT = 11; - public static final int ERR_TYPE_MMS_PROTO_PERMANENT = 12; - - public static final class PendingMessages implements BaseColumns { - public static final Uri CONTENT_URI = Uri.withAppendedPath( - MmsSms.CONTENT_URI, "pending"); - /** - * The type of transport protocol(MMS or SMS). - *Type: INTEGER
- */ - public static final String PROTO_TYPE = "proto_type"; - /** - * The ID of the message to be sent or downloaded. - *Type: INTEGER
- */ - public static final String MSG_ID = "msg_id"; - /** - * The type of the message to be sent or downloaded. - * This field is only valid for MM. For SM, its value is always - * set to 0. - */ - public static final String MSG_TYPE = "msg_type"; - /** - * The type of the error code. - *Type: INTEGER
- */ - public static final String ERROR_TYPE = "err_type"; - /** - * The error code of sending/retrieving process. - *Type: INTEGER
- */ - public static final String ERROR_CODE = "err_code"; - /** - * How many times we tried to send or download the message. - *Type: INTEGER
- */ - public static final String RETRY_INDEX = "retry_index"; - /** - * The time to do next retry. - */ - public static final String DUE_TIME = "due_time"; - /** - * The time we last tried to send or download the message. - */ - public static final String LAST_TRY = "last_try"; - } - - public static final class WordsTable { - public static final String ID = "_id"; - public static final String SOURCE_ROW_ID = "source_id"; - public static final String TABLE_ID = "table_to_use"; - public static final String INDEXED_TEXT = "index_text"; - } - } - - public static final class Carriers implements BaseColumns { - /** - * The content:// style URL for this table - */ - public static final Uri CONTENT_URI = - Uri.parse("content://telephony/carriers"); - - /** - * The default sort order for this table - */ - public static final String DEFAULT_SORT_ORDER = "name ASC"; - - public static final String NAME = "name"; - - public static final String APN = "apn"; - - public static final String PROXY = "proxy"; - - public static final String PORT = "port"; - - public static final String MMSPROXY = "mmsproxy"; - - public static final String MMSPORT = "mmsport"; - - public static final String SERVER = "server"; - - public static final String USER = "user"; - - public static final String PASSWORD = "password"; - - public static final String MMSC = "mmsc"; - - public static final String MCC = "mcc"; - - public static final String MNC = "mnc"; - - public static final String NUMERIC = "numeric"; - - public static final String AUTH_TYPE = "authtype"; - - public static final String TYPE = "type"; - - public static final String INACTIVE_TIMER = "inactivetimer"; - - // Only if enabled try Data Connection. - public static final String ENABLED = "enabled"; - - // Rules apply based on class. - public static final String CLASS = "class"; - - /** - * The protocol to be used to connect to this APN. - * - * One of the PDP_type values in TS 27.007 section 10.1.1. - * For example, "IP", "IPV6", "IPV4V6", or "PPP". - */ - public static final String PROTOCOL = "protocol"; - - /** - * The protocol to be used to connect to this APN when roaming. - * - * The syntax is the same as protocol. - */ - public static final String ROAMING_PROTOCOL = "roaming_protocol"; - - public static final String CURRENT = "current"; - - /** - * Current status of APN - * true : enabled APN, false : disabled APN. - */ - public static final String CARRIER_ENABLED = "carrier_enabled"; - - /** - * Radio Access Technology info - * To check what values can hold, refer to ServiceState.java. - * This should be spread to other technologies, - * but currently only used for LTE(14) and EHRPD(13). - */ - public static final String BEARER = "bearer"; - } - - /** - * Contains received SMS cell broadcast messages. - */ - public static final class CellBroadcasts implements BaseColumns { - - /** Not instantiable. */ - private CellBroadcasts() {} - - /** - * The content:// style URL for this table - */ - public static final Uri CONTENT_URI = - Uri.parse("content://cellbroadcasts"); - - /** - * Message geographical scope. - *Type: INTEGER
- */ - public static final String GEOGRAPHICAL_SCOPE = "geo_scope"; - - /** - * Message serial number. - *Type: INTEGER
- */ - public static final String SERIAL_NUMBER = "serial_number"; - - /** - * PLMN of broadcast sender. (SERIAL_NUMBER + PLMN + LAC + CID) uniquely identifies a - * broadcast for duplicate detection purposes. - *Type: TEXT
- */ - public static final String PLMN = "plmn"; - - /** - * Location Area (GSM) or Service Area (UMTS) of broadcast sender. Unused for CDMA. - * Only included if Geographical Scope of message is not PLMN wide (01). - *Type: INTEGER
- */ - public static final String LAC = "lac"; - - /** - * Cell ID of message sender (GSM/UMTS). Unused for CDMA. Only included when the - * Geographical Scope of message is cell wide (00 or 11). - *Type: INTEGER
- */ - public static final String CID = "cid"; - - /** - * Message code (OBSOLETE: merged into SERIAL_NUMBER). - *Type: INTEGER
- */ - public static final String V1_MESSAGE_CODE = "message_code"; - - /** - * Message identifier (OBSOLETE: renamed to SERVICE_CATEGORY). - *Type: INTEGER
- */ - public static final String V1_MESSAGE_IDENTIFIER = "message_id"; - - /** - * Service category (GSM/UMTS message identifier, CDMA service category). - *Type: INTEGER
- */ - public static final String SERVICE_CATEGORY = "service_category"; - - /** - * Message language code. - *Type: TEXT
- */ - public static final String LANGUAGE_CODE = "language"; - - /** - * Message body. - *Type: TEXT
- */ - public static final String MESSAGE_BODY = "body"; - - /** - * Message delivery time. - *Type: INTEGER (long)
- */ - public static final String DELIVERY_TIME = "date"; - - /** - * Has the message been viewed? - *Type: INTEGER (boolean)
- */ - public static final String MESSAGE_READ = "read"; - - /** - * Message format (3GPP or 3GPP2). - *Type: INTEGER
- */ - public static final String MESSAGE_FORMAT = "format"; - - /** - * Message priority (including emergency). - *Type: INTEGER
- */ - public static final String MESSAGE_PRIORITY = "priority"; - - /** - * ETWS warning type (ETWS alerts only). - *Type: INTEGER
- */ - public static final String ETWS_WARNING_TYPE = "etws_warning_type"; - - /** - * CMAS message class (CMAS alerts only). - *Type: INTEGER
- */ - public static final String CMAS_MESSAGE_CLASS = "cmas_message_class"; - - /** - * CMAS category (CMAS alerts only). - *Type: INTEGER
- */ - public static final String CMAS_CATEGORY = "cmas_category"; - - /** - * CMAS response type (CMAS alerts only). - *Type: INTEGER
- */ - public static final String CMAS_RESPONSE_TYPE = "cmas_response_type"; - - /** - * CMAS severity (CMAS alerts only). - *Type: INTEGER
- */ - public static final String CMAS_SEVERITY = "cmas_severity"; - - /** - * CMAS urgency (CMAS alerts only). - *Type: INTEGER
- */ - public static final String CMAS_URGENCY = "cmas_urgency"; - - /** - * CMAS certainty (CMAS alerts only). - *Type: INTEGER
- */ - public static final String CMAS_CERTAINTY = "cmas_certainty"; - - /** - * The default sort order for this table - */ - public static final String DEFAULT_SORT_ORDER = DELIVERY_TIME + " DESC"; - - /** - * Query columns for instantiating {@link android.telephony.CellBroadcastMessage} objects. - */ - public static final String[] QUERY_COLUMNS = { - _ID, - GEOGRAPHICAL_SCOPE, - PLMN, - LAC, - CID, - SERIAL_NUMBER, - SERVICE_CATEGORY, - LANGUAGE_CODE, - MESSAGE_BODY, - DELIVERY_TIME, - MESSAGE_READ, - MESSAGE_FORMAT, - MESSAGE_PRIORITY, - ETWS_WARNING_TYPE, - CMAS_MESSAGE_CLASS, - CMAS_CATEGORY, - CMAS_RESPONSE_TYPE, - CMAS_SEVERITY, - CMAS_URGENCY, - CMAS_CERTAINTY - }; - } - - public static final class Intents { - private Intents() { - // Not instantiable - } - - /** - * Broadcast Action: A "secret code" has been entered in the dialer. Secret codes are - * of the form *#*##*#*. The intent will have the data URI:
- *
- * android_secret_code://<code>
- */
- public static final String SECRET_CODE_ACTION =
- "android.provider.Telephony.SECRET_CODE";
-
- /**
- * Broadcast Action: The Service Provider string(s) have been updated. Activities or
- * services that use these strings should update their display.
- * The intent will have the following extra values:
- *
- * - showPlmn - Boolean that indicates whether the PLMN should be shown.
- * - plmn - The operator name of the registered network, as a string.
- * - showSpn - Boolean that indicates whether the SPN should be shown.
- * - spn - The service provider name, as a string.
- *
- * Note that showPlmn may indicate that plmn should be displayed, even
- * though the value for plmn is null. This can happen, for example, if the phone
- * has not registered to a network yet. In this case the receiver may substitute an
- * appropriate placeholder string (eg, "No service").
- *
- * It is recommended to display plmn before / above spn if
- * both are displayed.
- *
- * Note this is a protected intent that can only be sent
- * by the system.
- */
- public static final String SPN_STRINGS_UPDATED_ACTION =
- "android.provider.Telephony.SPN_STRINGS_UPDATED";
-
- public static final String EXTRA_SHOW_PLMN = "showPlmn";
- public static final String EXTRA_PLMN = "plmn";
- public static final String EXTRA_SHOW_SPN = "showSpn";
- public static final String EXTRA_SPN = "spn";
- }
-}
diff --git a/core/java/com/google/android/mms/ContentType.java b/core/java/com/google/android/mms/ContentType.java
deleted file mode 100644
index 12a134399c33..000000000000
--- a/core/java/com/google/android/mms/ContentType.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (C) 2007-2008 Esmertec AG.
- * Copyright (C) 2007-2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms;
-
-import java.util.ArrayList;
-
-public class ContentType {
- public static final String MMS_MESSAGE = "application/vnd.wap.mms-message";
- // The phony content type for generic PDUs (e.g. ReadOrig.ind,
- // Notification.ind, Delivery.ind).
- public static final String MMS_GENERIC = "application/vnd.wap.mms-generic";
- public static final String MULTIPART_MIXED = "application/vnd.wap.multipart.mixed";
- public static final String MULTIPART_RELATED = "application/vnd.wap.multipart.related";
- public static final String MULTIPART_ALTERNATIVE = "application/vnd.wap.multipart.alternative";
-
- public static final String TEXT_PLAIN = "text/plain";
- public static final String TEXT_HTML = "text/html";
- public static final String TEXT_VCALENDAR = "text/x-vCalendar";
- public static final String TEXT_VCARD = "text/x-vCard";
-
- public static final String IMAGE_UNSPECIFIED = "image/*";
- public static final String IMAGE_JPEG = "image/jpeg";
- public static final String IMAGE_JPG = "image/jpg";
- public static final String IMAGE_GIF = "image/gif";
- public static final String IMAGE_WBMP = "image/vnd.wap.wbmp";
- public static final String IMAGE_PNG = "image/png";
- public static final String IMAGE_X_MS_BMP = "image/x-ms-bmp";
-
- public static final String AUDIO_UNSPECIFIED = "audio/*";
- public static final String AUDIO_AAC = "audio/aac";
- public static final String AUDIO_AMR = "audio/amr";
- public static final String AUDIO_IMELODY = "audio/imelody";
- public static final String AUDIO_MID = "audio/mid";
- public static final String AUDIO_MIDI = "audio/midi";
- public static final String AUDIO_MP3 = "audio/mp3";
- public static final String AUDIO_MPEG3 = "audio/mpeg3";
- public static final String AUDIO_MPEG = "audio/mpeg";
- public static final String AUDIO_MPG = "audio/mpg";
- public static final String AUDIO_MP4 = "audio/mp4";
- public static final String AUDIO_X_MID = "audio/x-mid";
- public static final String AUDIO_X_MIDI = "audio/x-midi";
- public static final String AUDIO_X_MP3 = "audio/x-mp3";
- public static final String AUDIO_X_MPEG3 = "audio/x-mpeg3";
- public static final String AUDIO_X_MPEG = "audio/x-mpeg";
- public static final String AUDIO_X_MPG = "audio/x-mpg";
- public static final String AUDIO_3GPP = "audio/3gpp";
- public static final String AUDIO_X_WAV = "audio/x-wav";
- public static final String AUDIO_OGG = "application/ogg";
-
- public static final String VIDEO_UNSPECIFIED = "video/*";
- public static final String VIDEO_3GPP = "video/3gpp";
- public static final String VIDEO_3G2 = "video/3gpp2";
- public static final String VIDEO_H263 = "video/h263";
- public static final String VIDEO_MP4 = "video/mp4";
-
- public static final String APP_SMIL = "application/smil";
- public static final String APP_WAP_XHTML = "application/vnd.wap.xhtml+xml";
- public static final String APP_XHTML = "application/xhtml+xml";
-
- public static final String APP_DRM_CONTENT = "application/vnd.oma.drm.content";
- public static final String APP_DRM_MESSAGE = "application/vnd.oma.drm.message";
-
- private static final ArrayList sSupportedContentTypes = new ArrayList();
- private static final ArrayList sSupportedImageTypes = new ArrayList();
- private static final ArrayList sSupportedAudioTypes = new ArrayList();
- private static final ArrayList sSupportedVideoTypes = new ArrayList();
-
- static {
- sSupportedContentTypes.add(TEXT_PLAIN);
- sSupportedContentTypes.add(TEXT_HTML);
- sSupportedContentTypes.add(TEXT_VCALENDAR);
- sSupportedContentTypes.add(TEXT_VCARD);
-
- sSupportedContentTypes.add(IMAGE_JPEG);
- sSupportedContentTypes.add(IMAGE_GIF);
- sSupportedContentTypes.add(IMAGE_WBMP);
- sSupportedContentTypes.add(IMAGE_PNG);
- sSupportedContentTypes.add(IMAGE_JPG);
- sSupportedContentTypes.add(IMAGE_X_MS_BMP);
- //supportedContentTypes.add(IMAGE_SVG); not yet supported.
-
- sSupportedContentTypes.add(AUDIO_AAC);
- sSupportedContentTypes.add(AUDIO_AMR);
- sSupportedContentTypes.add(AUDIO_IMELODY);
- sSupportedContentTypes.add(AUDIO_MID);
- sSupportedContentTypes.add(AUDIO_MIDI);
- sSupportedContentTypes.add(AUDIO_MP3);
- sSupportedContentTypes.add(AUDIO_MPEG3);
- sSupportedContentTypes.add(AUDIO_MPEG);
- sSupportedContentTypes.add(AUDIO_MPG);
- sSupportedContentTypes.add(AUDIO_X_MID);
- sSupportedContentTypes.add(AUDIO_X_MIDI);
- sSupportedContentTypes.add(AUDIO_X_MP3);
- sSupportedContentTypes.add(AUDIO_X_MPEG3);
- sSupportedContentTypes.add(AUDIO_X_MPEG);
- sSupportedContentTypes.add(AUDIO_X_MPG);
- sSupportedContentTypes.add(AUDIO_X_WAV);
- sSupportedContentTypes.add(AUDIO_3GPP);
- sSupportedContentTypes.add(AUDIO_OGG);
-
- sSupportedContentTypes.add(VIDEO_3GPP);
- sSupportedContentTypes.add(VIDEO_3G2);
- sSupportedContentTypes.add(VIDEO_H263);
- sSupportedContentTypes.add(VIDEO_MP4);
-
- sSupportedContentTypes.add(APP_SMIL);
- sSupportedContentTypes.add(APP_WAP_XHTML);
- sSupportedContentTypes.add(APP_XHTML);
-
- sSupportedContentTypes.add(APP_DRM_CONTENT);
- sSupportedContentTypes.add(APP_DRM_MESSAGE);
-
- // add supported image types
- sSupportedImageTypes.add(IMAGE_JPEG);
- sSupportedImageTypes.add(IMAGE_GIF);
- sSupportedImageTypes.add(IMAGE_WBMP);
- sSupportedImageTypes.add(IMAGE_PNG);
- sSupportedImageTypes.add(IMAGE_JPG);
- sSupportedImageTypes.add(IMAGE_X_MS_BMP);
-
- // add supported audio types
- sSupportedAudioTypes.add(AUDIO_AAC);
- sSupportedAudioTypes.add(AUDIO_AMR);
- sSupportedAudioTypes.add(AUDIO_IMELODY);
- sSupportedAudioTypes.add(AUDIO_MID);
- sSupportedAudioTypes.add(AUDIO_MIDI);
- sSupportedAudioTypes.add(AUDIO_MP3);
- sSupportedAudioTypes.add(AUDIO_MPEG3);
- sSupportedAudioTypes.add(AUDIO_MPEG);
- sSupportedAudioTypes.add(AUDIO_MPG);
- sSupportedAudioTypes.add(AUDIO_MP4);
- sSupportedAudioTypes.add(AUDIO_X_MID);
- sSupportedAudioTypes.add(AUDIO_X_MIDI);
- sSupportedAudioTypes.add(AUDIO_X_MP3);
- sSupportedAudioTypes.add(AUDIO_X_MPEG3);
- sSupportedAudioTypes.add(AUDIO_X_MPEG);
- sSupportedAudioTypes.add(AUDIO_X_MPG);
- sSupportedAudioTypes.add(AUDIO_X_WAV);
- sSupportedAudioTypes.add(AUDIO_3GPP);
- sSupportedAudioTypes.add(AUDIO_OGG);
-
- // add supported video types
- sSupportedVideoTypes.add(VIDEO_3GPP);
- sSupportedVideoTypes.add(VIDEO_3G2);
- sSupportedVideoTypes.add(VIDEO_H263);
- sSupportedVideoTypes.add(VIDEO_MP4);
- }
-
- // This class should never be instantiated.
- private ContentType() {
- }
-
- public static boolean isSupportedType(String contentType) {
- return (null != contentType) && sSupportedContentTypes.contains(contentType);
- }
-
- public static boolean isSupportedImageType(String contentType) {
- return isImageType(contentType) && isSupportedType(contentType);
- }
-
- public static boolean isSupportedAudioType(String contentType) {
- return isAudioType(contentType) && isSupportedType(contentType);
- }
-
- public static boolean isSupportedVideoType(String contentType) {
- return isVideoType(contentType) && isSupportedType(contentType);
- }
-
- public static boolean isTextType(String contentType) {
- return (null != contentType) && contentType.startsWith("text/");
- }
-
- public static boolean isImageType(String contentType) {
- return (null != contentType) && contentType.startsWith("image/");
- }
-
- public static boolean isAudioType(String contentType) {
- return (null != contentType) && contentType.startsWith("audio/");
- }
-
- public static boolean isVideoType(String contentType) {
- return (null != contentType) && contentType.startsWith("video/");
- }
-
- public static boolean isDrmType(String contentType) {
- return (null != contentType)
- && (contentType.equals(APP_DRM_CONTENT)
- || contentType.equals(APP_DRM_MESSAGE));
- }
-
- public static boolean isUnspecified(String contentType) {
- return (null != contentType) && contentType.endsWith("*");
- }
-
- @SuppressWarnings("unchecked")
- public static ArrayList getImageTypes() {
- return (ArrayList) sSupportedImageTypes.clone();
- }
-
- @SuppressWarnings("unchecked")
- public static ArrayList getAudioTypes() {
- return (ArrayList) sSupportedAudioTypes.clone();
- }
-
- @SuppressWarnings("unchecked")
- public static ArrayList getVideoTypes() {
- return (ArrayList) sSupportedVideoTypes.clone();
- }
-
- @SuppressWarnings("unchecked")
- public static ArrayList getSupportedTypes() {
- return (ArrayList) sSupportedContentTypes.clone();
- }
-}
diff --git a/core/java/com/google/android/mms/InvalidHeaderValueException.java b/core/java/com/google/android/mms/InvalidHeaderValueException.java
deleted file mode 100644
index 73d78328e257..000000000000
--- a/core/java/com/google/android/mms/InvalidHeaderValueException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms;
-
-/**
- * Thrown when an invalid header value was set.
- */
-public class InvalidHeaderValueException extends MmsException {
- private static final long serialVersionUID = -2053384496042052262L;
-
- /**
- * Constructs an InvalidHeaderValueException with no detailed message.
- */
- public InvalidHeaderValueException() {
- super();
- }
-
- /**
- * Constructs an InvalidHeaderValueException with the specified detailed message.
- *
- * @param message the detailed message.
- */
- public InvalidHeaderValueException(String message) {
- super(message);
- }
-}
diff --git a/core/java/com/google/android/mms/MmsException.java b/core/java/com/google/android/mms/MmsException.java
deleted file mode 100644
index 6ca0c7eab9ac..000000000000
--- a/core/java/com/google/android/mms/MmsException.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms;
-
-/**
- * A generic exception that is thrown by the Mms client.
- */
-public class MmsException extends Exception {
- private static final long serialVersionUID = -7323249827281485390L;
-
- /**
- * Creates a new MmsException.
- */
- public MmsException() {
- super();
- }
-
- /**
- * Creates a new MmsException with the specified detail message.
- *
- * @param message the detail message.
- */
- public MmsException(String message) {
- super(message);
- }
-
- /**
- * Creates a new MmsException with the specified cause.
- *
- * @param cause the cause.
- */
- public MmsException(Throwable cause) {
- super(cause);
- }
-
- /**
- * Creates a new MmsException with the specified detail message and cause.
- *
- * @param message the detail message.
- * @param cause the cause.
- */
- public MmsException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/core/java/com/google/android/mms/package.html b/core/java/com/google/android/mms/package.html
deleted file mode 100755
index c9f96a66ab3b..000000000000
--- a/core/java/com/google/android/mms/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-{@hide}
-
-
diff --git a/core/java/com/google/android/mms/pdu/AcknowledgeInd.java b/core/java/com/google/android/mms/pdu/AcknowledgeInd.java
deleted file mode 100644
index 0e96c60bd096..000000000000
--- a/core/java/com/google/android/mms/pdu/AcknowledgeInd.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import com.google.android.mms.InvalidHeaderValueException;
-
-/**
- * M-Acknowledge.ind PDU.
- */
-public class AcknowledgeInd extends GenericPdu {
- /**
- * Constructor, used when composing a M-Acknowledge.ind pdu.
- *
- * @param mmsVersion current viersion of mms
- * @param transactionId the transaction-id value
- * @throws InvalidHeaderValueException if parameters are invalid.
- * NullPointerException if transactionId is null.
- */
- public AcknowledgeInd(int mmsVersion, byte[] transactionId)
- throws InvalidHeaderValueException {
- super();
-
- setMessageType(PduHeaders.MESSAGE_TYPE_ACKNOWLEDGE_IND);
- setMmsVersion(mmsVersion);
- setTransactionId(transactionId);
- }
-
- /**
- * Constructor with given headers.
- *
- * @param headers Headers for this PDU.
- */
- AcknowledgeInd(PduHeaders headers) {
- super(headers);
- }
-
- /**
- * Get X-Mms-Report-Allowed field value.
- *
- * @return the X-Mms-Report-Allowed value
- */
- public int getReportAllowed() {
- return mPduHeaders.getOctet(PduHeaders.REPORT_ALLOWED);
- }
-
- /**
- * Set X-Mms-Report-Allowed field value.
- *
- * @param value the value
- * @throws InvalidHeaderValueException if the value is invalid.
- */
- public void setReportAllowed(int value) throws InvalidHeaderValueException {
- mPduHeaders.setOctet(value, PduHeaders.REPORT_ALLOWED);
- }
-
- /**
- * Get X-Mms-Transaction-Id field value.
- *
- * @return the X-Mms-Report-Allowed value
- */
- public byte[] getTransactionId() {
- return mPduHeaders.getTextString(PduHeaders.TRANSACTION_ID);
- }
-
- /**
- * Set X-Mms-Transaction-Id field value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setTransactionId(byte[] value) {
- mPduHeaders.setTextString(value, PduHeaders.TRANSACTION_ID);
- }
-}
diff --git a/core/java/com/google/android/mms/pdu/Base64.java b/core/java/com/google/android/mms/pdu/Base64.java
deleted file mode 100644
index 604bee0d50fe..000000000000
--- a/core/java/com/google/android/mms/pdu/Base64.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-public class Base64 {
- /**
- * Used to get the number of Quadruples.
- */
- static final int FOURBYTE = 4;
-
- /**
- * Byte used to pad output.
- */
- static final byte PAD = (byte) '=';
-
- /**
- * The base length.
- */
- static final int BASELENGTH = 255;
-
- // Create arrays to hold the base64 characters
- private static byte[] base64Alphabet = new byte[BASELENGTH];
-
- // Populating the character arrays
- static {
- for (int i = 0; i < BASELENGTH; i++) {
- base64Alphabet[i] = (byte) -1;
- }
- for (int i = 'Z'; i >= 'A'; i--) {
- base64Alphabet[i] = (byte) (i - 'A');
- }
- for (int i = 'z'; i >= 'a'; i--) {
- base64Alphabet[i] = (byte) (i - 'a' + 26);
- }
- for (int i = '9'; i >= '0'; i--) {
- base64Alphabet[i] = (byte) (i - '0' + 52);
- }
-
- base64Alphabet['+'] = 62;
- base64Alphabet['/'] = 63;
- }
-
- /**
- * Decodes Base64 data into octects
- *
- * @param base64Data Byte array containing Base64 data
- * @return Array containing decoded data.
- */
- public static byte[] decodeBase64(byte[] base64Data) {
- // RFC 2045 requires that we discard ALL non-Base64 characters
- base64Data = discardNonBase64(base64Data);
-
- // handle the edge case, so we don't have to worry about it later
- if (base64Data.length == 0) {
- return new byte[0];
- }
-
- int numberQuadruple = base64Data.length / FOURBYTE;
- byte decodedData[] = null;
- byte b1 = 0, b2 = 0, b3 = 0, b4 = 0, marker0 = 0, marker1 = 0;
-
- // Throw away anything not in base64Data
-
- int encodedIndex = 0;
- int dataIndex = 0;
- {
- // this sizes the output array properly - rlw
- int lastData = base64Data.length;
- // ignore the '=' padding
- while (base64Data[lastData - 1] == PAD) {
- if (--lastData == 0) {
- return new byte[0];
- }
- }
- decodedData = new byte[lastData - numberQuadruple];
- }
-
- for (int i = 0; i < numberQuadruple; i++) {
- dataIndex = i * 4;
- marker0 = base64Data[dataIndex + 2];
- marker1 = base64Data[dataIndex + 3];
-
- b1 = base64Alphabet[base64Data[dataIndex]];
- b2 = base64Alphabet[base64Data[dataIndex + 1]];
-
- if (marker0 != PAD && marker1 != PAD) {
- //No PAD e.g 3cQl
- b3 = base64Alphabet[marker0];
- b4 = base64Alphabet[marker1];
-
- decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
- decodedData[encodedIndex + 1] =
- (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
- decodedData[encodedIndex + 2] = (byte) (b3 << 6 | b4);
- } else if (marker0 == PAD) {
- //Two PAD e.g. 3c[Pad][Pad]
- decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
- } else if (marker1 == PAD) {
- //One PAD e.g. 3cQ[Pad]
- b3 = base64Alphabet[marker0];
-
- decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
- decodedData[encodedIndex + 1] =
- (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
- }
- encodedIndex += 3;
- }
- return decodedData;
- }
-
- /**
- * Check octect wheter it is a base64 encoding.
- *
- * @param octect to be checked byte
- * @return ture if it is base64 encoding, false otherwise.
- */
- private static boolean isBase64(byte octect) {
- if (octect == PAD) {
- return true;
- } else if (base64Alphabet[octect] == -1) {
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * Discards any characters outside of the base64 alphabet, per
- * the requirements on page 25 of RFC 2045 - "Any characters
- * outside of the base64 alphabet are to be ignored in base64
- * encoded data."
- *
- * @param data The base-64 encoded data to groom
- * @return The data, less non-base64 characters (see RFC 2045).
- */
- static byte[] discardNonBase64(byte[] data) {
- byte groomedData[] = new byte[data.length];
- int bytesCopied = 0;
-
- for (int i = 0; i < data.length; i++) {
- if (isBase64(data[i])) {
- groomedData[bytesCopied++] = data[i];
- }
- }
-
- byte packedData[] = new byte[bytesCopied];
-
- System.arraycopy(groomedData, 0, packedData, 0, bytesCopied);
-
- return packedData;
- }
-}
diff --git a/core/java/com/google/android/mms/pdu/CharacterSets.java b/core/java/com/google/android/mms/pdu/CharacterSets.java
deleted file mode 100644
index 4e22ca5e2cf8..000000000000
--- a/core/java/com/google/android/mms/pdu/CharacterSets.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import java.io.UnsupportedEncodingException;
-import java.util.HashMap;
-
-public class CharacterSets {
- /**
- * IANA assigned MIB enum numbers.
- *
- * From wap-230-wsp-20010705-a.pdf
- * Any-charset =
- * Equivalent to the special RFC2616 charset value "*"
- */
- public static final int ANY_CHARSET = 0x00;
- public static final int US_ASCII = 0x03;
- public static final int ISO_8859_1 = 0x04;
- public static final int ISO_8859_2 = 0x05;
- public static final int ISO_8859_3 = 0x06;
- public static final int ISO_8859_4 = 0x07;
- public static final int ISO_8859_5 = 0x08;
- public static final int ISO_8859_6 = 0x09;
- public static final int ISO_8859_7 = 0x0A;
- public static final int ISO_8859_8 = 0x0B;
- public static final int ISO_8859_9 = 0x0C;
- public static final int SHIFT_JIS = 0x11;
- public static final int UTF_8 = 0x6A;
- public static final int BIG5 = 0x07EA;
- public static final int UCS2 = 0x03E8;
- public static final int UTF_16 = 0x03F7;
-
- /**
- * If the encoding of given data is unsupported, use UTF_8 to decode it.
- */
- public static final int DEFAULT_CHARSET = UTF_8;
-
- /**
- * Array of MIB enum numbers.
- */
- private static final int[] MIBENUM_NUMBERS = {
- ANY_CHARSET,
- US_ASCII,
- ISO_8859_1,
- ISO_8859_2,
- ISO_8859_3,
- ISO_8859_4,
- ISO_8859_5,
- ISO_8859_6,
- ISO_8859_7,
- ISO_8859_8,
- ISO_8859_9,
- SHIFT_JIS,
- UTF_8,
- BIG5,
- UCS2,
- UTF_16,
- };
-
- /**
- * The Well-known-charset Mime name.
- */
- public static final String MIMENAME_ANY_CHARSET = "*";
- public static final String MIMENAME_US_ASCII = "us-ascii";
- public static final String MIMENAME_ISO_8859_1 = "iso-8859-1";
- public static final String MIMENAME_ISO_8859_2 = "iso-8859-2";
- public static final String MIMENAME_ISO_8859_3 = "iso-8859-3";
- public static final String MIMENAME_ISO_8859_4 = "iso-8859-4";
- public static final String MIMENAME_ISO_8859_5 = "iso-8859-5";
- public static final String MIMENAME_ISO_8859_6 = "iso-8859-6";
- public static final String MIMENAME_ISO_8859_7 = "iso-8859-7";
- public static final String MIMENAME_ISO_8859_8 = "iso-8859-8";
- public static final String MIMENAME_ISO_8859_9 = "iso-8859-9";
- public static final String MIMENAME_SHIFT_JIS = "shift_JIS";
- public static final String MIMENAME_UTF_8 = "utf-8";
- public static final String MIMENAME_BIG5 = "big5";
- public static final String MIMENAME_UCS2 = "iso-10646-ucs-2";
- public static final String MIMENAME_UTF_16 = "utf-16";
-
- public static final String DEFAULT_CHARSET_NAME = MIMENAME_UTF_8;
-
- /**
- * Array of the names of character sets.
- */
- private static final String[] MIME_NAMES = {
- MIMENAME_ANY_CHARSET,
- MIMENAME_US_ASCII,
- MIMENAME_ISO_8859_1,
- MIMENAME_ISO_8859_2,
- MIMENAME_ISO_8859_3,
- MIMENAME_ISO_8859_4,
- MIMENAME_ISO_8859_5,
- MIMENAME_ISO_8859_6,
- MIMENAME_ISO_8859_7,
- MIMENAME_ISO_8859_8,
- MIMENAME_ISO_8859_9,
- MIMENAME_SHIFT_JIS,
- MIMENAME_UTF_8,
- MIMENAME_BIG5,
- MIMENAME_UCS2,
- MIMENAME_UTF_16,
- };
-
- private static final HashMap MIBENUM_TO_NAME_MAP;
- private static final HashMap NAME_TO_MIBENUM_MAP;
-
- static {
- // Create the HashMaps.
- MIBENUM_TO_NAME_MAP = new HashMap();
- NAME_TO_MIBENUM_MAP = new HashMap();
- assert(MIBENUM_NUMBERS.length == MIME_NAMES.length);
- int count = MIBENUM_NUMBERS.length - 1;
- for(int i = 0; i <= count; i++) {
- MIBENUM_TO_NAME_MAP.put(MIBENUM_NUMBERS[i], MIME_NAMES[i]);
- NAME_TO_MIBENUM_MAP.put(MIME_NAMES[i], MIBENUM_NUMBERS[i]);
- }
- }
-
- private CharacterSets() {} // Non-instantiatable
-
- /**
- * Map an MIBEnum number to the name of the charset which this number
- * is assigned to by IANA.
- *
- * @param mibEnumValue An IANA assigned MIBEnum number.
- * @return The name string of the charset.
- * @throws UnsupportedEncodingException
- */
- public static String getMimeName(int mibEnumValue)
- throws UnsupportedEncodingException {
- String name = MIBENUM_TO_NAME_MAP.get(mibEnumValue);
- if (name == null) {
- throw new UnsupportedEncodingException();
- }
- return name;
- }
-
- /**
- * Map a well-known charset name to its assigned MIBEnum number.
- *
- * @param mimeName The charset name.
- * @return The MIBEnum number assigned by IANA for this charset.
- * @throws UnsupportedEncodingException
- */
- public static int getMibEnumValue(String mimeName)
- throws UnsupportedEncodingException {
- if(null == mimeName) {
- return -1;
- }
-
- Integer mibEnumValue = NAME_TO_MIBENUM_MAP.get(mimeName);
- if (mibEnumValue == null) {
- throw new UnsupportedEncodingException();
- }
- return mibEnumValue;
- }
-}
diff --git a/core/java/com/google/android/mms/pdu/DeliveryInd.java b/core/java/com/google/android/mms/pdu/DeliveryInd.java
deleted file mode 100644
index dafa8d11b871..000000000000
--- a/core/java/com/google/android/mms/pdu/DeliveryInd.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import com.google.android.mms.InvalidHeaderValueException;
-
-/**
- * M-Delivery.Ind Pdu.
- */
-public class DeliveryInd extends GenericPdu {
- /**
- * Empty constructor.
- * Since the Pdu corresponding to this class is constructed
- * by the Proxy-Relay server, this class is only instantiated
- * by the Pdu Parser.
- *
- * @throws InvalidHeaderValueException if error occurs.
- */
- public DeliveryInd() throws InvalidHeaderValueException {
- super();
- setMessageType(PduHeaders.MESSAGE_TYPE_DELIVERY_IND);
- }
-
- /**
- * Constructor with given headers.
- *
- * @param headers Headers for this PDU.
- */
- DeliveryInd(PduHeaders headers) {
- super(headers);
- }
-
- /**
- * Get Date value.
- *
- * @return the value
- */
- public long getDate() {
- return mPduHeaders.getLongInteger(PduHeaders.DATE);
- }
-
- /**
- * Set Date value.
- *
- * @param value the value
- */
- public void setDate(long value) {
- mPduHeaders.setLongInteger(value, PduHeaders.DATE);
- }
-
- /**
- * Get Message-ID value.
- *
- * @return the value
- */
- public byte[] getMessageId() {
- return mPduHeaders.getTextString(PduHeaders.MESSAGE_ID);
- }
-
- /**
- * Set Message-ID value.
- *
- * @param value the value, should not be null
- * @throws NullPointerException if the value is null.
- */
- public void setMessageId(byte[] value) {
- mPduHeaders.setTextString(value, PduHeaders.MESSAGE_ID);
- }
-
- /**
- * Get Status value.
- *
- * @return the value
- */
- public int getStatus() {
- return mPduHeaders.getOctet(PduHeaders.STATUS);
- }
-
- /**
- * Set Status value.
- *
- * @param value the value
- * @throws InvalidHeaderValueException if the value is invalid.
- */
- public void setStatus(int value) throws InvalidHeaderValueException {
- mPduHeaders.setOctet(value, PduHeaders.STATUS);
- }
-
- /**
- * Get To value.
- *
- * @return the value
- */
- public EncodedStringValue[] getTo() {
- return mPduHeaders.getEncodedStringValues(PduHeaders.TO);
- }
-
- /**
- * set To value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setTo(EncodedStringValue[] value) {
- mPduHeaders.setEncodedStringValues(value, PduHeaders.TO);
- }
-
- /*
- * Optional, not supported header fields:
- *
- * public byte[] getApplicId() {return null;}
- * public void setApplicId(byte[] value) {}
- *
- * public byte[] getAuxApplicId() {return null;}
- * public void getAuxApplicId(byte[] value) {}
- *
- * public byte[] getReplyApplicId() {return 0x00;}
- * public void setReplyApplicId(byte[] value) {}
- *
- * public EncodedStringValue getStatusText() {return null;}
- * public void setStatusText(EncodedStringValue value) {}
- */
-}
diff --git a/core/java/com/google/android/mms/pdu/EncodedStringValue.java b/core/java/com/google/android/mms/pdu/EncodedStringValue.java
deleted file mode 100644
index 9495c1c5700e..000000000000
--- a/core/java/com/google/android/mms/pdu/EncodedStringValue.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Copyright (C) 2007-2008 Esmertec AG.
- * Copyright (C) 2007-2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import android.util.Log;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-
-/**
- * Encoded-string-value = Text-string | Value-length Char-set Text-string
- */
-public class EncodedStringValue implements Cloneable {
- private static final String TAG = "EncodedStringValue";
- private static final boolean DEBUG = false;
- private static final boolean LOCAL_LOGV = false;
-
- /**
- * The Char-set value.
- */
- private int mCharacterSet;
-
- /**
- * The Text-string value.
- */
- private byte[] mData;
-
- /**
- * Constructor.
- *
- * @param charset the Char-set value
- * @param data the Text-string value
- * @throws NullPointerException if Text-string value is null.
- */
- public EncodedStringValue(int charset, byte[] data) {
- // TODO: CharSet needs to be validated against MIBEnum.
- if(null == data) {
- throw new NullPointerException("EncodedStringValue: Text-string is null.");
- }
-
- mCharacterSet = charset;
- mData = new byte[data.length];
- System.arraycopy(data, 0, mData, 0, data.length);
- }
-
- /**
- * Constructor.
- *
- * @param data the Text-string value
- * @throws NullPointerException if Text-string value is null.
- */
- public EncodedStringValue(byte[] data) {
- this(CharacterSets.DEFAULT_CHARSET, data);
- }
-
- public EncodedStringValue(String data) {
- try {
- mData = data.getBytes(CharacterSets.DEFAULT_CHARSET_NAME);
- mCharacterSet = CharacterSets.DEFAULT_CHARSET;
- } catch (UnsupportedEncodingException e) {
- Log.e(TAG, "Default encoding must be supported.", e);
- }
- }
-
- /**
- * Get Char-set value.
- *
- * @return the value
- */
- public int getCharacterSet() {
- return mCharacterSet;
- }
-
- /**
- * Set Char-set value.
- *
- * @param charset the Char-set value
- */
- public void setCharacterSet(int charset) {
- // TODO: CharSet needs to be validated against MIBEnum.
- mCharacterSet = charset;
- }
-
- /**
- * Get Text-string value.
- *
- * @return the value
- */
- public byte[] getTextString() {
- byte[] byteArray = new byte[mData.length];
-
- System.arraycopy(mData, 0, byteArray, 0, mData.length);
- return byteArray;
- }
-
- /**
- * Set Text-string value.
- *
- * @param textString the Text-string value
- * @throws NullPointerException if Text-string value is null.
- */
- public void setTextString(byte[] textString) {
- if(null == textString) {
- throw new NullPointerException("EncodedStringValue: Text-string is null.");
- }
-
- mData = new byte[textString.length];
- System.arraycopy(textString, 0, mData, 0, textString.length);
- }
-
- /**
- * Convert this object to a {@link java.lang.String}. If the encoding of
- * the EncodedStringValue is null or unsupported, it will be
- * treated as iso-8859-1 encoding.
- *
- * @return The decoded String.
- */
- public String getString() {
- if (CharacterSets.ANY_CHARSET == mCharacterSet) {
- return new String(mData); // system default encoding.
- } else {
- try {
- String name = CharacterSets.getMimeName(mCharacterSet);
- return new String(mData, name);
- } catch (UnsupportedEncodingException e) {
- if (LOCAL_LOGV) {
- Log.v(TAG, e.getMessage(), e);
- }
- try {
- return new String(mData, CharacterSets.MIMENAME_ISO_8859_1);
- } catch (UnsupportedEncodingException _) {
- return new String(mData); // system default encoding.
- }
- }
- }
- }
-
- /**
- * Append to Text-string.
- *
- * @param textString the textString to append
- * @throws NullPointerException if the text String is null
- * or an IOException occured.
- */
- public void appendTextString(byte[] textString) {
- if(null == textString) {
- throw new NullPointerException("Text-string is null.");
- }
-
- if(null == mData) {
- mData = new byte[textString.length];
- System.arraycopy(textString, 0, mData, 0, textString.length);
- } else {
- ByteArrayOutputStream newTextString = new ByteArrayOutputStream();
- try {
- newTextString.write(mData);
- newTextString.write(textString);
- } catch (IOException e) {
- e.printStackTrace();
- throw new NullPointerException(
- "appendTextString: failed when write a new Text-string");
- }
-
- mData = newTextString.toByteArray();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#clone()
- */
- @Override
- public Object clone() throws CloneNotSupportedException {
- super.clone();
- int len = mData.length;
- byte[] dstBytes = new byte[len];
- System.arraycopy(mData, 0, dstBytes, 0, len);
-
- try {
- return new EncodedStringValue(mCharacterSet, dstBytes);
- } catch (Exception e) {
- Log.e(TAG, "failed to clone an EncodedStringValue: " + this);
- e.printStackTrace();
- throw new CloneNotSupportedException(e.getMessage());
- }
- }
-
- /**
- * Split this encoded string around matches of the given pattern.
- *
- * @param pattern the delimiting pattern
- * @return the array of encoded strings computed by splitting this encoded
- * string around matches of the given pattern
- */
- public EncodedStringValue[] split(String pattern) {
- String[] temp = getString().split(pattern);
- EncodedStringValue[] ret = new EncodedStringValue[temp.length];
- for (int i = 0; i < ret.length; ++i) {
- try {
- ret[i] = new EncodedStringValue(mCharacterSet,
- temp[i].getBytes());
- } catch (NullPointerException _) {
- // Can't arrive here
- return null;
- }
- }
- return ret;
- }
-
- /**
- * Extract an EncodedStringValue[] from a given String.
- */
- public static EncodedStringValue[] extract(String src) {
- String[] values = src.split(";");
-
- ArrayList list = new ArrayList();
- for (int i = 0; i < values.length; i++) {
- if (values[i].length() > 0) {
- list.add(new EncodedStringValue(values[i]));
- }
- }
-
- int len = list.size();
- if (len > 0) {
- return list.toArray(new EncodedStringValue[len]);
- } else {
- return null;
- }
- }
-
- /**
- * Concatenate an EncodedStringValue[] into a single String.
- */
- public static String concat(EncodedStringValue[] addr) {
- StringBuilder sb = new StringBuilder();
- int maxIndex = addr.length - 1;
- for (int i = 0; i <= maxIndex; i++) {
- sb.append(addr[i].getString());
- if (i < maxIndex) {
- sb.append(";");
- }
- }
-
- return sb.toString();
- }
-
- public static EncodedStringValue copy(EncodedStringValue value) {
- if (value == null) {
- return null;
- }
-
- return new EncodedStringValue(value.mCharacterSet, value.mData);
- }
-
- public static EncodedStringValue[] encodeStrings(String[] array) {
- int count = array.length;
- if (count > 0) {
- EncodedStringValue[] encodedArray = new EncodedStringValue[count];
- for (int i = 0; i < count; i++) {
- encodedArray[i] = new EncodedStringValue(array[i]);
- }
- return encodedArray;
- }
- return null;
- }
-}
diff --git a/core/java/com/google/android/mms/pdu/GenericPdu.java b/core/java/com/google/android/mms/pdu/GenericPdu.java
deleted file mode 100644
index 705de6afb8b6..000000000000
--- a/core/java/com/google/android/mms/pdu/GenericPdu.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import com.google.android.mms.InvalidHeaderValueException;
-
-public class GenericPdu {
- /**
- * The headers of pdu.
- */
- PduHeaders mPduHeaders = null;
-
- /**
- * Constructor.
- */
- public GenericPdu() {
- mPduHeaders = new PduHeaders();
- }
-
- /**
- * Constructor.
- *
- * @param headers Headers for this PDU.
- */
- GenericPdu(PduHeaders headers) {
- mPduHeaders = headers;
- }
-
- /**
- * Get the headers of this PDU.
- *
- * @return A PduHeaders of this PDU.
- */
- PduHeaders getPduHeaders() {
- return mPduHeaders;
- }
-
- /**
- * Get X-Mms-Message-Type field value.
- *
- * @return the X-Mms-Report-Allowed value
- */
- public int getMessageType() {
- return mPduHeaders.getOctet(PduHeaders.MESSAGE_TYPE);
- }
-
- /**
- * Set X-Mms-Message-Type field value.
- *
- * @param value the value
- * @throws InvalidHeaderValueException if the value is invalid.
- * RuntimeException if field's value is not Octet.
- */
- public void setMessageType(int value) throws InvalidHeaderValueException {
- mPduHeaders.setOctet(value, PduHeaders.MESSAGE_TYPE);
- }
-
- /**
- * Get X-Mms-MMS-Version field value.
- *
- * @return the X-Mms-MMS-Version value
- */
- public int getMmsVersion() {
- return mPduHeaders.getOctet(PduHeaders.MMS_VERSION);
- }
-
- /**
- * Set X-Mms-MMS-Version field value.
- *
- * @param value the value
- * @throws InvalidHeaderValueException if the value is invalid.
- * RuntimeException if field's value is not Octet.
- */
- public void setMmsVersion(int value) throws InvalidHeaderValueException {
- mPduHeaders.setOctet(value, PduHeaders.MMS_VERSION);
- }
-
- /**
- * Get From value.
- * From-value = Value-length
- * (Address-present-token Encoded-string-value | Insert-address-token)
- *
- * @return the value
- */
- public EncodedStringValue getFrom() {
- return mPduHeaders.getEncodedStringValue(PduHeaders.FROM);
- }
-
- /**
- * Set From value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setFrom(EncodedStringValue value) {
- mPduHeaders.setEncodedStringValue(value, PduHeaders.FROM);
- }
-}
diff --git a/core/java/com/google/android/mms/pdu/MultimediaMessagePdu.java b/core/java/com/google/android/mms/pdu/MultimediaMessagePdu.java
deleted file mode 100644
index 5a85e0e79ddc..000000000000
--- a/core/java/com/google/android/mms/pdu/MultimediaMessagePdu.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import com.google.android.mms.InvalidHeaderValueException;
-
-/**
- * Multimedia message PDU.
- */
-public class MultimediaMessagePdu extends GenericPdu{
- /**
- * The body.
- */
- private PduBody mMessageBody;
-
- /**
- * Constructor.
- */
- public MultimediaMessagePdu() {
- super();
- }
-
- /**
- * Constructor.
- *
- * @param header the header of this PDU
- * @param body the body of this PDU
- */
- public MultimediaMessagePdu(PduHeaders header, PduBody body) {
- super(header);
- mMessageBody = body;
- }
-
- /**
- * Constructor with given headers.
- *
- * @param headers Headers for this PDU.
- */
- MultimediaMessagePdu(PduHeaders headers) {
- super(headers);
- }
-
- /**
- * Get body of the PDU.
- *
- * @return the body
- */
- public PduBody getBody() {
- return mMessageBody;
- }
-
- /**
- * Set body of the PDU.
- *
- * @param body the body
- */
- public void setBody(PduBody body) {
- mMessageBody = body;
- }
-
- /**
- * Get subject.
- *
- * @return the value
- */
- public EncodedStringValue getSubject() {
- return mPduHeaders.getEncodedStringValue(PduHeaders.SUBJECT);
- }
-
- /**
- * Set subject.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setSubject(EncodedStringValue value) {
- mPduHeaders.setEncodedStringValue(value, PduHeaders.SUBJECT);
- }
-
- /**
- * Get To value.
- *
- * @return the value
- */
- public EncodedStringValue[] getTo() {
- return mPduHeaders.getEncodedStringValues(PduHeaders.TO);
- }
-
- /**
- * Add a "To" value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void addTo(EncodedStringValue value) {
- mPduHeaders.appendEncodedStringValue(value, PduHeaders.TO);
- }
-
- /**
- * Get X-Mms-Priority value.
- *
- * @return the value
- */
- public int getPriority() {
- return mPduHeaders.getOctet(PduHeaders.PRIORITY);
- }
-
- /**
- * Set X-Mms-Priority value.
- *
- * @param value the value
- * @throws InvalidHeaderValueException if the value is invalid.
- */
- public void setPriority(int value) throws InvalidHeaderValueException {
- mPduHeaders.setOctet(value, PduHeaders.PRIORITY);
- }
-
- /**
- * Get Date value.
- *
- * @return the value
- */
- public long getDate() {
- return mPduHeaders.getLongInteger(PduHeaders.DATE);
- }
-
- /**
- * Set Date value in seconds.
- *
- * @param value the value
- */
- public void setDate(long value) {
- mPduHeaders.setLongInteger(value, PduHeaders.DATE);
- }
-}
diff --git a/core/java/com/google/android/mms/pdu/NotificationInd.java b/core/java/com/google/android/mms/pdu/NotificationInd.java
deleted file mode 100644
index c56cba6d14bf..000000000000
--- a/core/java/com/google/android/mms/pdu/NotificationInd.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import com.google.android.mms.InvalidHeaderValueException;
-
-/**
- * M-Notification.ind PDU.
- */
-public class NotificationInd extends GenericPdu {
- /**
- * Empty constructor.
- * Since the Pdu corresponding to this class is constructed
- * by the Proxy-Relay server, this class is only instantiated
- * by the Pdu Parser.
- *
- * @throws InvalidHeaderValueException if error occurs.
- * RuntimeException if an undeclared error occurs.
- */
- public NotificationInd() throws InvalidHeaderValueException {
- super();
- setMessageType(PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND);
- }
-
- /**
- * Constructor with given headers.
- *
- * @param headers Headers for this PDU.
- */
- NotificationInd(PduHeaders headers) {
- super(headers);
- }
-
- /**
- * Get X-Mms-Content-Class Value.
- *
- * @return the value
- */
- public int getContentClass() {
- return mPduHeaders.getOctet(PduHeaders.CONTENT_CLASS);
- }
-
- /**
- * Set X-Mms-Content-Class Value.
- *
- * @param value the value
- * @throws InvalidHeaderValueException if the value is invalid.
- * RuntimeException if an undeclared error occurs.
- */
- public void setContentClass(int value) throws InvalidHeaderValueException {
- mPduHeaders.setOctet(value, PduHeaders.CONTENT_CLASS);
- }
-
- /**
- * Get X-Mms-Content-Location value.
- * When used in a PDU other than M-Mbox-Delete.conf and M-Delete.conf:
- * Content-location-value = Uri-value
- *
- * @return the value
- */
- public byte[] getContentLocation() {
- return mPduHeaders.getTextString(PduHeaders.CONTENT_LOCATION);
- }
-
- /**
- * Set X-Mms-Content-Location value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- * RuntimeException if an undeclared error occurs.
- */
- public void setContentLocation(byte[] value) {
- mPduHeaders.setTextString(value, PduHeaders.CONTENT_LOCATION);
- }
-
- /**
- * Get X-Mms-Expiry value.
- *
- * Expiry-value = Value-length
- * (Absolute-token Date-value | Relative-token Delta-seconds-value)
- *
- * @return the value
- */
- public long getExpiry() {
- return mPduHeaders.getLongInteger(PduHeaders.EXPIRY);
- }
-
- /**
- * Set X-Mms-Expiry value.
- *
- * @param value the value
- * @throws RuntimeException if an undeclared error occurs.
- */
- public void setExpiry(long value) {
- mPduHeaders.setLongInteger(value, PduHeaders.EXPIRY);
- }
-
- /**
- * Get From value.
- * From-value = Value-length
- * (Address-present-token Encoded-string-value | Insert-address-token)
- *
- * @return the value
- */
- public EncodedStringValue getFrom() {
- return mPduHeaders.getEncodedStringValue(PduHeaders.FROM);
- }
-
- /**
- * Set From value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- * RuntimeException if an undeclared error occurs.
- */
- public void setFrom(EncodedStringValue value) {
- mPduHeaders.setEncodedStringValue(value, PduHeaders.FROM);
- }
-
- /**
- * Get X-Mms-Message-Class value.
- * Message-class-value = Class-identifier | Token-text
- * Class-identifier = Personal | Advertisement | Informational | Auto
- *
- * @return the value
- */
- public byte[] getMessageClass() {
- return mPduHeaders.getTextString(PduHeaders.MESSAGE_CLASS);
- }
-
- /**
- * Set X-Mms-Message-Class value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- * RuntimeException if an undeclared error occurs.
- */
- public void setMessageClass(byte[] value) {
- mPduHeaders.setTextString(value, PduHeaders.MESSAGE_CLASS);
- }
-
- /**
- * Get X-Mms-Message-Size value.
- * Message-size-value = Long-integer
- *
- * @return the value
- */
- public long getMessageSize() {
- return mPduHeaders.getLongInteger(PduHeaders.MESSAGE_SIZE);
- }
-
- /**
- * Set X-Mms-Message-Size value.
- *
- * @param value the value
- * @throws RuntimeException if an undeclared error occurs.
- */
- public void setMessageSize(long value) {
- mPduHeaders.setLongInteger(value, PduHeaders.MESSAGE_SIZE);
- }
-
- /**
- * Get subject.
- *
- * @return the value
- */
- public EncodedStringValue getSubject() {
- return mPduHeaders.getEncodedStringValue(PduHeaders.SUBJECT);
- }
-
- /**
- * Set subject.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- * RuntimeException if an undeclared error occurs.
- */
- public void setSubject(EncodedStringValue value) {
- mPduHeaders.setEncodedStringValue(value, PduHeaders.SUBJECT);
- }
-
- /**
- * Get X-Mms-Transaction-Id.
- *
- * @return the value
- */
- public byte[] getTransactionId() {
- return mPduHeaders.getTextString(PduHeaders.TRANSACTION_ID);
- }
-
- /**
- * Set X-Mms-Transaction-Id.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- * RuntimeException if an undeclared error occurs.
- */
- public void setTransactionId(byte[] value) {
- mPduHeaders.setTextString(value, PduHeaders.TRANSACTION_ID);
- }
-
- /**
- * Get X-Mms-Delivery-Report Value.
- *
- * @return the value
- */
- public int getDeliveryReport() {
- return mPduHeaders.getOctet(PduHeaders.DELIVERY_REPORT);
- }
-
- /**
- * Set X-Mms-Delivery-Report Value.
- *
- * @param value the value
- * @throws InvalidHeaderValueException if the value is invalid.
- * RuntimeException if an undeclared error occurs.
- */
- public void setDeliveryReport(int value) throws InvalidHeaderValueException {
- mPduHeaders.setOctet(value, PduHeaders.DELIVERY_REPORT);
- }
-
- /*
- * Optional, not supported header fields:
- *
- * public byte[] getApplicId() {return null;}
- * public void setApplicId(byte[] value) {}
- *
- * public byte[] getAuxApplicId() {return null;}
- * public void getAuxApplicId(byte[] value) {}
- *
- * public byte getDrmContent() {return 0x00;}
- * public void setDrmContent(byte value) {}
- *
- * public byte getDistributionIndicator() {return 0x00;}
- * public void setDistributionIndicator(byte value) {}
- *
- * public ElementDescriptorValue getElementDescriptor() {return null;}
- * public void getElementDescriptor(ElementDescriptorValue value) {}
- *
- * public byte getPriority() {return 0x00;}
- * public void setPriority(byte value) {}
- *
- * public byte getRecommendedRetrievalMode() {return 0x00;}
- * public void setRecommendedRetrievalMode(byte value) {}
- *
- * public byte getRecommendedRetrievalModeText() {return 0x00;}
- * public void setRecommendedRetrievalModeText(byte value) {}
- *
- * public byte[] getReplaceId() {return 0x00;}
- * public void setReplaceId(byte[] value) {}
- *
- * public byte[] getReplyApplicId() {return 0x00;}
- * public void setReplyApplicId(byte[] value) {}
- *
- * public byte getReplyCharging() {return 0x00;}
- * public void setReplyCharging(byte value) {}
- *
- * public byte getReplyChargingDeadline() {return 0x00;}
- * public void setReplyChargingDeadline(byte value) {}
- *
- * public byte[] getReplyChargingId() {return 0x00;}
- * public void setReplyChargingId(byte[] value) {}
- *
- * public long getReplyChargingSize() {return 0;}
- * public void setReplyChargingSize(long value) {}
- *
- * public byte getStored() {return 0x00;}
- * public void setStored(byte value) {}
- */
-}
diff --git a/core/java/com/google/android/mms/pdu/NotifyRespInd.java b/core/java/com/google/android/mms/pdu/NotifyRespInd.java
deleted file mode 100644
index 2cc2fce0812d..000000000000
--- a/core/java/com/google/android/mms/pdu/NotifyRespInd.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import com.google.android.mms.InvalidHeaderValueException;
-
-/**
- * M-NofifyResp.ind PDU.
- */
-public class NotifyRespInd extends GenericPdu {
- /**
- * Constructor, used when composing a M-NotifyResp.ind pdu.
- *
- * @param mmsVersion current version of mms
- * @param transactionId the transaction-id value
- * @param status the status value
- * @throws InvalidHeaderValueException if parameters are invalid.
- * NullPointerException if transactionId is null.
- * RuntimeException if an undeclared error occurs.
- */
- public NotifyRespInd(int mmsVersion,
- byte[] transactionId,
- int status) throws InvalidHeaderValueException {
- super();
- setMessageType(PduHeaders.MESSAGE_TYPE_NOTIFYRESP_IND);
- setMmsVersion(mmsVersion);
- setTransactionId(transactionId);
- setStatus(status);
- }
-
- /**
- * Constructor with given headers.
- *
- * @param headers Headers for this PDU.
- */
- NotifyRespInd(PduHeaders headers) {
- super(headers);
- }
-
- /**
- * Get X-Mms-Report-Allowed field value.
- *
- * @return the X-Mms-Report-Allowed value
- */
- public int getReportAllowed() {
- return mPduHeaders.getOctet(PduHeaders.REPORT_ALLOWED);
- }
-
- /**
- * Set X-Mms-Report-Allowed field value.
- *
- * @param value the value
- * @throws InvalidHeaderValueException if the value is invalid.
- * RuntimeException if an undeclared error occurs.
- */
- public void setReportAllowed(int value) throws InvalidHeaderValueException {
- mPduHeaders.setOctet(value, PduHeaders.REPORT_ALLOWED);
- }
-
- /**
- * Set X-Mms-Status field value.
- *
- * @param value the value
- * @throws InvalidHeaderValueException if the value is invalid.
- * RuntimeException if an undeclared error occurs.
- */
- public void setStatus(int value) throws InvalidHeaderValueException {
- mPduHeaders.setOctet(value, PduHeaders.STATUS);
- }
-
- /**
- * GetX-Mms-Status field value.
- *
- * @return the X-Mms-Status value
- */
- public int getStatus() {
- return mPduHeaders.getOctet(PduHeaders.STATUS);
- }
-
- /**
- * Get X-Mms-Transaction-Id field value.
- *
- * @return the X-Mms-Report-Allowed value
- */
- public byte[] getTransactionId() {
- return mPduHeaders.getTextString(PduHeaders.TRANSACTION_ID);
- }
-
- /**
- * Set X-Mms-Transaction-Id field value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- * RuntimeException if an undeclared error occurs.
- */
- public void setTransactionId(byte[] value) {
- mPduHeaders.setTextString(value, PduHeaders.TRANSACTION_ID);
- }
-}
diff --git a/core/java/com/google/android/mms/pdu/PduBody.java b/core/java/com/google/android/mms/pdu/PduBody.java
deleted file mode 100644
index fa0416c6be6a..000000000000
--- a/core/java/com/google/android/mms/pdu/PduBody.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Vector;
-
-public class PduBody {
- private Vector mParts = null;
-
- private Map mPartMapByContentId = null;
- private Map mPartMapByContentLocation = null;
- private Map mPartMapByName = null;
- private Map mPartMapByFileName = null;
-
- /**
- * Constructor.
- */
- public PduBody() {
- mParts = new Vector();
-
- mPartMapByContentId = new HashMap();
- mPartMapByContentLocation = new HashMap();
- mPartMapByName = new HashMap();
- mPartMapByFileName = new HashMap();
- }
-
- private void putPartToMaps(PduPart part) {
- // Put part to mPartMapByContentId.
- byte[] contentId = part.getContentId();
- if(null != contentId) {
- mPartMapByContentId.put(new String(contentId), part);
- }
-
- // Put part to mPartMapByContentLocation.
- byte[] contentLocation = part.getContentLocation();
- if(null != contentLocation) {
- String clc = new String(contentLocation);
- mPartMapByContentLocation.put(clc, part);
- }
-
- // Put part to mPartMapByName.
- byte[] name = part.getName();
- if(null != name) {
- String clc = new String(name);
- mPartMapByName.put(clc, part);
- }
-
- // Put part to mPartMapByFileName.
- byte[] fileName = part.getFilename();
- if(null != fileName) {
- String clc = new String(fileName);
- mPartMapByFileName.put(clc, part);
- }
- }
-
- /**
- * Appends the specified part to the end of this body.
- *
- * @param part part to be appended
- * @return true when success, false when fail
- * @throws NullPointerException when part is null
- */
- public boolean addPart(PduPart part) {
- if(null == part) {
- throw new NullPointerException();
- }
-
- putPartToMaps(part);
- return mParts.add(part);
- }
-
- /**
- * Inserts the specified part at the specified position.
- *
- * @param index index at which the specified part is to be inserted
- * @param part part to be inserted
- * @throws NullPointerException when part is null
- */
- public void addPart(int index, PduPart part) {
- if(null == part) {
- throw new NullPointerException();
- }
-
- putPartToMaps(part);
- mParts.add(index, part);
- }
-
- /**
- * Removes the part at the specified position.
- *
- * @param index index of the part to return
- * @return part at the specified index
- */
- public PduPart removePart(int index) {
- return mParts.remove(index);
- }
-
- /**
- * Remove all of the parts.
- */
- public void removeAll() {
- mParts.clear();
- }
-
- /**
- * Get the part at the specified position.
- *
- * @param index index of the part to return
- * @return part at the specified index
- */
- public PduPart getPart(int index) {
- return mParts.get(index);
- }
-
- /**
- * Get the index of the specified part.
- *
- * @param part the part object
- * @return index the index of the first occurrence of the part in this body
- */
- public int getPartIndex(PduPart part) {
- return mParts.indexOf(part);
- }
-
- /**
- * Get the number of parts.
- *
- * @return the number of parts
- */
- public int getPartsNum() {
- return mParts.size();
- }
-
- /**
- * Get pdu part by content id.
- *
- * @param cid the value of content id.
- * @return the pdu part.
- */
- public PduPart getPartByContentId(String cid) {
- return mPartMapByContentId.get(cid);
- }
-
- /**
- * Get pdu part by Content-Location. Content-Location of part is
- * the same as filename and name(param of content-type).
- *
- * @param fileName the value of filename.
- * @return the pdu part.
- */
- public PduPart getPartByContentLocation(String contentLocation) {
- return mPartMapByContentLocation.get(contentLocation);
- }
-
- /**
- * Get pdu part by name.
- *
- * @param fileName the value of filename.
- * @return the pdu part.
- */
- public PduPart getPartByName(String name) {
- return mPartMapByName.get(name);
- }
-
- /**
- * Get pdu part by filename.
- *
- * @param fileName the value of filename.
- * @return the pdu part.
- */
- public PduPart getPartByFileName(String filename) {
- return mPartMapByFileName.get(filename);
- }
-}
diff --git a/core/java/com/google/android/mms/pdu/PduComposer.java b/core/java/com/google/android/mms/pdu/PduComposer.java
deleted file mode 100644
index d426f89bcb6c..000000000000
--- a/core/java/com/google/android/mms/pdu/PduComposer.java
+++ /dev/null
@@ -1,1179 +0,0 @@
-/*
- * Copyright (C) 2007-2008 Esmertec AG.
- * Copyright (C) 2007-2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.util.Log;
-import android.text.TextUtils;
-
-import java.io.ByteArrayOutputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.HashMap;
-
-public class PduComposer {
- /**
- * Address type.
- */
- static private final int PDU_PHONE_NUMBER_ADDRESS_TYPE = 1;
- static private final int PDU_EMAIL_ADDRESS_TYPE = 2;
- static private final int PDU_IPV4_ADDRESS_TYPE = 3;
- static private final int PDU_IPV6_ADDRESS_TYPE = 4;
- static private final int PDU_UNKNOWN_ADDRESS_TYPE = 5;
-
- /**
- * Address regular expression string.
- */
- static final String REGEXP_PHONE_NUMBER_ADDRESS_TYPE = "\\+?[0-9|\\.|\\-]+";
- static final String REGEXP_EMAIL_ADDRESS_TYPE = "[a-zA-Z| ]*\\<{0,1}[a-zA-Z| ]+@{1}" +
- "[a-zA-Z| ]+\\.{1}[a-zA-Z| ]+\\>{0,1}";
- static final String REGEXP_IPV6_ADDRESS_TYPE =
- "[a-fA-F]{4}\\:{1}[a-fA-F0-9]{4}\\:{1}[a-fA-F0-9]{4}\\:{1}" +
- "[a-fA-F0-9]{4}\\:{1}[a-fA-F0-9]{4}\\:{1}[a-fA-F0-9]{4}\\:{1}" +
- "[a-fA-F0-9]{4}\\:{1}[a-fA-F0-9]{4}";
- static final String REGEXP_IPV4_ADDRESS_TYPE = "[0-9]{1,3}\\.{1}[0-9]{1,3}\\.{1}" +
- "[0-9]{1,3}\\.{1}[0-9]{1,3}";
-
- /**
- * The postfix strings of address.
- */
- static final String STRING_PHONE_NUMBER_ADDRESS_TYPE = "/TYPE=PLMN";
- static final String STRING_IPV4_ADDRESS_TYPE = "/TYPE=IPV4";
- static final String STRING_IPV6_ADDRESS_TYPE = "/TYPE=IPV6";
-
- /**
- * Error values.
- */
- static private final int PDU_COMPOSE_SUCCESS = 0;
- static private final int PDU_COMPOSE_CONTENT_ERROR = 1;
- static private final int PDU_COMPOSE_FIELD_NOT_SET = 2;
- static private final int PDU_COMPOSE_FIELD_NOT_SUPPORTED = 3;
-
- /**
- * WAP values defined in WSP spec.
- */
- static private final int QUOTED_STRING_FLAG = 34;
- static private final int END_STRING_FLAG = 0;
- static private final int LENGTH_QUOTE = 31;
- static private final int TEXT_MAX = 127;
- static private final int SHORT_INTEGER_MAX = 127;
- static private final int LONG_INTEGER_LENGTH_MAX = 8;
-
- /**
- * Block size when read data from InputStream.
- */
- static private final int PDU_COMPOSER_BLOCK_SIZE = 1024;
-
- /**
- * The output message.
- */
- protected ByteArrayOutputStream mMessage = null;
-
- /**
- * The PDU.
- */
- private GenericPdu mPdu = null;
-
- /**
- * Current visiting position of the mMessage.
- */
- protected int mPosition = 0;
-
- /**
- * Message compose buffer stack.
- */
- private BufferStack mStack = null;
-
- /**
- * Content resolver.
- */
- private final ContentResolver mResolver;
-
- /**
- * Header of this pdu.
- */
- private PduHeaders mPduHeader = null;
-
- /**
- * Map of all content type
- */
- private static HashMap mContentTypeMap = null;
-
- static {
- mContentTypeMap = new HashMap();
-
- int i;
- for (i = 0; i < PduContentTypes.contentTypes.length; i++) {
- mContentTypeMap.put(PduContentTypes.contentTypes[i], i);
- }
- }
-
- /**
- * Constructor.
- *
- * @param context the context
- * @param pdu the pdu to be composed
- */
- public PduComposer(Context context, GenericPdu pdu) {
- mPdu = pdu;
- mResolver = context.getContentResolver();
- mPduHeader = pdu.getPduHeaders();
- mStack = new BufferStack();
- mMessage = new ByteArrayOutputStream();
- mPosition = 0;
- }
-
- /**
- * Make the message. No need to check whether mandatory fields are set,
- * because the constructors of outgoing pdus are taking care of this.
- *
- * @return OutputStream of maked message. Return null if
- * the PDU is invalid.
- */
- public byte[] make() {
- // Get Message-type.
- int type = mPdu.getMessageType();
-
- /* make the message */
- switch (type) {
- case PduHeaders.MESSAGE_TYPE_SEND_REQ:
- if (makeSendReqPdu() != PDU_COMPOSE_SUCCESS) {
- return null;
- }
- break;
- case PduHeaders.MESSAGE_TYPE_NOTIFYRESP_IND:
- if (makeNotifyResp() != PDU_COMPOSE_SUCCESS) {
- return null;
- }
- break;
- case PduHeaders.MESSAGE_TYPE_ACKNOWLEDGE_IND:
- if (makeAckInd() != PDU_COMPOSE_SUCCESS) {
- return null;
- }
- break;
- case PduHeaders.MESSAGE_TYPE_READ_REC_IND:
- if (makeReadRecInd() != PDU_COMPOSE_SUCCESS) {
- return null;
- }
- break;
- default:
- return null;
- }
-
- return mMessage.toByteArray();
- }
-
- /**
- * Copy buf to mMessage.
- */
- protected void arraycopy(byte[] buf, int pos, int length) {
- mMessage.write(buf, pos, length);
- mPosition = mPosition + length;
- }
-
- /**
- * Append a byte to mMessage.
- */
- protected void append(int value) {
- mMessage.write(value);
- mPosition ++;
- }
-
- /**
- * Append short integer value to mMessage.
- * This implementation doesn't check the validity of parameter, since it
- * assumes that the values are validated in the GenericPdu setter methods.
- */
- protected void appendShortInteger(int value) {
- /*
- * From WAP-230-WSP-20010705-a:
- * Short-integer = OCTET
- * ; Integers in range 0-127 shall be encoded as a one octet value
- * ; with the most significant bit set to one (1xxx xxxx) and with
- * ; the value in the remaining least significant bits.
- * In our implementation, only low 7 bits are stored and otherwise
- * bits are ignored.
- */
- append((value | 0x80) & 0xff);
- }
-
- /**
- * Append an octet number between 128 and 255 into mMessage.
- * NOTE:
- * A value between 0 and 127 should be appended by using appendShortInteger.
- * This implementation doesn't check the validity of parameter, since it
- * assumes that the values are validated in the GenericPdu setter methods.
- */
- protected void appendOctet(int number) {
- append(number);
- }
-
- /**
- * Append a short length into mMessage.
- * This implementation doesn't check the validity of parameter, since it
- * assumes that the values are validated in the GenericPdu setter methods.
- */
- protected void appendShortLength(int value) {
- /*
- * From WAP-230-WSP-20010705-a:
- * Short-length =
- */
- append(value);
- }
-
- /**
- * Append long integer into mMessage. it's used for really long integers.
- * This implementation doesn't check the validity of parameter, since it
- * assumes that the values are validated in the GenericPdu setter methods.
- */
- protected void appendLongInteger(long longInt) {
- /*
- * From WAP-230-WSP-20010705-a:
- * Long-integer = Short-length Multi-octet-integer
- * ; The Short-length indicates the length of the Multi-octet-integer
- * Multi-octet-integer = 1*30 OCTET
- * ; The content octets shall be an unsigned integer value with the
- * ; most significant octet encoded first (big-endian representation).
- * ; The minimum number of octets must be used to encode the value.
- */
- int size;
- long temp = longInt;
-
- // Count the length of the long integer.
- for(size = 0; (temp != 0) && (size < LONG_INTEGER_LENGTH_MAX); size++) {
- temp = (temp >>> 8);
- }
-
- // Set Length.
- appendShortLength(size);
-
- // Count and set the long integer.
- int i;
- int shift = (size -1) * 8;
-
- for (i = 0; i < size; i++) {
- append((int)((longInt >>> shift) & 0xff));
- shift = shift - 8;
- }
- }
-
- /**
- * Append text string into mMessage.
- * This implementation doesn't check the validity of parameter, since it
- * assumes that the values are validated in the GenericPdu setter methods.
- */
- protected void appendTextString(byte[] text) {
- /*
- * From WAP-230-WSP-20010705-a:
- * Text-string = [Quote] *TEXT End-of-string
- * ; If the first character in the TEXT is in the range of 128-255,
- * ; a Quote character must precede it. Otherwise the Quote character
- * ;must be omitted. The Quote is not part of the contents.
- */
- if (((text[0])&0xff) > TEXT_MAX) { // No need to check for <= 255
- append(TEXT_MAX);
- }
-
- arraycopy(text, 0, text.length);
- append(0);
- }
-
- /**
- * Append text string into mMessage.
- * This implementation doesn't check the validity of parameter, since it
- * assumes that the values are validated in the GenericPdu setter methods.
- */
- protected void appendTextString(String str) {
- /*
- * From WAP-230-WSP-20010705-a:
- * Text-string = [Quote] *TEXT End-of-string
- * ; If the first character in the TEXT is in the range of 128-255,
- * ; a Quote character must precede it. Otherwise the Quote character
- * ;must be omitted. The Quote is not part of the contents.
- */
- appendTextString(str.getBytes());
- }
-
- /**
- * Append encoded string value to mMessage.
- * This implementation doesn't check the validity of parameter, since it
- * assumes that the values are validated in the GenericPdu setter methods.
- */
- protected void appendEncodedString(EncodedStringValue enStr) {
- /*
- * From OMA-TS-MMS-ENC-V1_3-20050927-C:
- * Encoded-string-value = Text-string | Value-length Char-set Text-string
- */
- assert(enStr != null);
-
- int charset = enStr.getCharacterSet();
- byte[] textString = enStr.getTextString();
- if (null == textString) {
- return;
- }
-
- /*
- * In the implementation of EncodedStringValue, the charset field will
- * never be 0. It will always be composed as
- * Encoded-string-value = Value-length Char-set Text-string
- */
- mStack.newbuf();
- PositionMarker start = mStack.mark();
-
- appendShortInteger(charset);
- appendTextString(textString);
-
- int len = start.getLength();
- mStack.pop();
- appendValueLength(len);
- mStack.copy();
- }
-
- /**
- * Append uintvar integer into mMessage.
- * This implementation doesn't check the validity of parameter, since it
- * assumes that the values are validated in the GenericPdu setter methods.
- */
- protected void appendUintvarInteger(long value) {
- /*
- * From WAP-230-WSP-20010705-a:
- * To encode a large unsigned integer, split it into 7-bit fragments
- * and place them in the payloads of multiple octets. The most significant
- * bits are placed in the first octets with the least significant bits
- * ending up in the last octet. All octets MUST set the Continue bit to 1
- * except the last octet, which MUST set the Continue bit to 0.
- */
- int i;
- long max = SHORT_INTEGER_MAX;
-
- for (i = 0; i < 5; i++) {
- if (value < max) {
- break;
- }
-
- max = (max << 7) | 0x7fl;
- }
-
- while(i > 0) {
- long temp = value >>> (i * 7);
- temp = temp & 0x7f;
-
- append((int)((temp | 0x80) & 0xff));
-
- i--;
- }
-
- append((int)(value & 0x7f));
- }
-
- /**
- * Append date value into mMessage.
- * This implementation doesn't check the validity of parameter, since it
- * assumes that the values are validated in the GenericPdu setter methods.
- */
- protected void appendDateValue(long date) {
- /*
- * From OMA-TS-MMS-ENC-V1_3-20050927-C:
- * Date-value = Long-integer
- */
- appendLongInteger(date);
- }
-
- /**
- * Append value length to mMessage.
- * This implementation doesn't check the validity of parameter, since it
- * assumes that the values are validated in the GenericPdu setter methods.
- */
- protected void appendValueLength(long value) {
- /*
- * From WAP-230-WSP-20010705-a:
- * Value-length = Short-length | (Length-quote Length)
- * ; Value length is used to indicate the length of the value to follow
- * Short-length =
- * Length-quote =
- * Length = Uintvar-integer
- */
- if (value < LENGTH_QUOTE) {
- appendShortLength((int) value);
- return;
- }
-
- append(LENGTH_QUOTE);
- appendUintvarInteger(value);
- }
-
- /**
- * Append quoted string to mMessage.
- * This implementation doesn't check the validity of parameter, since it
- * assumes that the values are validated in the GenericPdu setter methods.
- */
- protected void appendQuotedString(byte[] text) {
- /*
- * From WAP-230-WSP-20010705-a:
- * Quoted-string = *TEXT End-of-string
- * ;The TEXT encodes an RFC2616 Quoted-string with the enclosing
- * ;quotation-marks <"> removed.
- */
- append(QUOTED_STRING_FLAG);
- arraycopy(text, 0, text.length);
- append(END_STRING_FLAG);
- }
-
- /**
- * Append quoted string to mMessage.
- * This implementation doesn't check the validity of parameter, since it
- * assumes that the values are validated in the GenericPdu setter methods.
- */
- protected void appendQuotedString(String str) {
- /*
- * From WAP-230-WSP-20010705-a:
- * Quoted-string = *TEXT End-of-string
- * ;The TEXT encodes an RFC2616 Quoted-string with the enclosing
- * ;quotation-marks <"> removed.
- */
- appendQuotedString(str.getBytes());
- }
-
- private EncodedStringValue appendAddressType(EncodedStringValue address) {
- EncodedStringValue temp = null;
-
- try {
- int addressType = checkAddressType(address.getString());
- temp = EncodedStringValue.copy(address);
- if (PDU_PHONE_NUMBER_ADDRESS_TYPE == addressType) {
- // Phone number.
- temp.appendTextString(STRING_PHONE_NUMBER_ADDRESS_TYPE.getBytes());
- } else if (PDU_IPV4_ADDRESS_TYPE == addressType) {
- // Ipv4 address.
- temp.appendTextString(STRING_IPV4_ADDRESS_TYPE.getBytes());
- } else if (PDU_IPV6_ADDRESS_TYPE == addressType) {
- // Ipv6 address.
- temp.appendTextString(STRING_IPV6_ADDRESS_TYPE.getBytes());
- }
- } catch (NullPointerException e) {
- return null;
- }
-
- return temp;
- }
-
- /**
- * Append header to mMessage.
- */
- private int appendHeader(int field) {
- switch (field) {
- case PduHeaders.MMS_VERSION:
- appendOctet(field);
-
- int version = mPduHeader.getOctet(field);
- if (0 == version) {
- appendShortInteger(PduHeaders.CURRENT_MMS_VERSION);
- } else {
- appendShortInteger(version);
- }
-
- break;
-
- case PduHeaders.MESSAGE_ID:
- case PduHeaders.TRANSACTION_ID:
- byte[] textString = mPduHeader.getTextString(field);
- if (null == textString) {
- return PDU_COMPOSE_FIELD_NOT_SET;
- }
-
- appendOctet(field);
- appendTextString(textString);
- break;
-
- case PduHeaders.TO:
- case PduHeaders.BCC:
- case PduHeaders.CC:
- EncodedStringValue[] addr = mPduHeader.getEncodedStringValues(field);
-
- if (null == addr) {
- return PDU_COMPOSE_FIELD_NOT_SET;
- }
-
- EncodedStringValue temp;
- for (int i = 0; i < addr.length; i++) {
- temp = appendAddressType(addr[i]);
- if (temp == null) {
- return PDU_COMPOSE_CONTENT_ERROR;
- }
-
- appendOctet(field);
- appendEncodedString(temp);
- }
- break;
-
- case PduHeaders.FROM:
- // Value-length (Address-present-token Encoded-string-value | Insert-address-token)
- appendOctet(field);
-
- EncodedStringValue from = mPduHeader.getEncodedStringValue(field);
- if ((from == null)
- || TextUtils.isEmpty(from.getString())
- || new String(from.getTextString()).equals(
- PduHeaders.FROM_INSERT_ADDRESS_TOKEN_STR)) {
- // Length of from = 1
- append(1);
- // Insert-address-token =
- append(PduHeaders.FROM_INSERT_ADDRESS_TOKEN);
- } else {
- mStack.newbuf();
- PositionMarker fstart = mStack.mark();
-
- // Address-present-token =
- append(PduHeaders.FROM_ADDRESS_PRESENT_TOKEN);
-
- temp = appendAddressType(from);
- if (temp == null) {
- return PDU_COMPOSE_CONTENT_ERROR;
- }
-
- appendEncodedString(temp);
-
- int flen = fstart.getLength();
- mStack.pop();
- appendValueLength(flen);
- mStack.copy();
- }
- break;
-
- case PduHeaders.READ_STATUS:
- case PduHeaders.STATUS:
- case PduHeaders.REPORT_ALLOWED:
- case PduHeaders.PRIORITY:
- case PduHeaders.DELIVERY_REPORT:
- case PduHeaders.READ_REPORT:
- int octet = mPduHeader.getOctet(field);
- if (0 == octet) {
- return PDU_COMPOSE_FIELD_NOT_SET;
- }
-
- appendOctet(field);
- appendOctet(octet);
- break;
-
- case PduHeaders.DATE:
- long date = mPduHeader.getLongInteger(field);
- if (-1 == date) {
- return PDU_COMPOSE_FIELD_NOT_SET;
- }
-
- appendOctet(field);
- appendDateValue(date);
- break;
-
- case PduHeaders.SUBJECT:
- EncodedStringValue enString =
- mPduHeader.getEncodedStringValue(field);
- if (null == enString) {
- return PDU_COMPOSE_FIELD_NOT_SET;
- }
-
- appendOctet(field);
- appendEncodedString(enString);
- break;
-
- case PduHeaders.MESSAGE_CLASS:
- byte[] messageClass = mPduHeader.getTextString(field);
- if (null == messageClass) {
- return PDU_COMPOSE_FIELD_NOT_SET;
- }
-
- appendOctet(field);
- if (Arrays.equals(messageClass,
- PduHeaders.MESSAGE_CLASS_ADVERTISEMENT_STR.getBytes())) {
- appendOctet(PduHeaders.MESSAGE_CLASS_ADVERTISEMENT);
- } else if (Arrays.equals(messageClass,
- PduHeaders.MESSAGE_CLASS_AUTO_STR.getBytes())) {
- appendOctet(PduHeaders.MESSAGE_CLASS_AUTO);
- } else if (Arrays.equals(messageClass,
- PduHeaders.MESSAGE_CLASS_PERSONAL_STR.getBytes())) {
- appendOctet(PduHeaders.MESSAGE_CLASS_PERSONAL);
- } else if (Arrays.equals(messageClass,
- PduHeaders.MESSAGE_CLASS_INFORMATIONAL_STR.getBytes())) {
- appendOctet(PduHeaders.MESSAGE_CLASS_INFORMATIONAL);
- } else {
- appendTextString(messageClass);
- }
- break;
-
- case PduHeaders.EXPIRY:
- long expiry = mPduHeader.getLongInteger(field);
- if (-1 == expiry) {
- return PDU_COMPOSE_FIELD_NOT_SET;
- }
-
- appendOctet(field);
-
- mStack.newbuf();
- PositionMarker expiryStart = mStack.mark();
-
- append(PduHeaders.VALUE_RELATIVE_TOKEN);
- appendLongInteger(expiry);
-
- int expiryLength = expiryStart.getLength();
- mStack.pop();
- appendValueLength(expiryLength);
- mStack.copy();
- break;
-
- default:
- return PDU_COMPOSE_FIELD_NOT_SUPPORTED;
- }
-
- return PDU_COMPOSE_SUCCESS;
- }
-
- /**
- * Make ReadRec.Ind.
- */
- private int makeReadRecInd() {
- if (mMessage == null) {
- mMessage = new ByteArrayOutputStream();
- mPosition = 0;
- }
-
- // X-Mms-Message-Type
- appendOctet(PduHeaders.MESSAGE_TYPE);
- appendOctet(PduHeaders.MESSAGE_TYPE_READ_REC_IND);
-
- // X-Mms-MMS-Version
- if (appendHeader(PduHeaders.MMS_VERSION) != PDU_COMPOSE_SUCCESS) {
- return PDU_COMPOSE_CONTENT_ERROR;
- }
-
- // Message-ID
- if (appendHeader(PduHeaders.MESSAGE_ID) != PDU_COMPOSE_SUCCESS) {
- return PDU_COMPOSE_CONTENT_ERROR;
- }
-
- // To
- if (appendHeader(PduHeaders.TO) != PDU_COMPOSE_SUCCESS) {
- return PDU_COMPOSE_CONTENT_ERROR;
- }
-
- // From
- if (appendHeader(PduHeaders.FROM) != PDU_COMPOSE_SUCCESS) {
- return PDU_COMPOSE_CONTENT_ERROR;
- }
-
- // Date Optional
- appendHeader(PduHeaders.DATE);
-
- // X-Mms-Read-Status
- if (appendHeader(PduHeaders.READ_STATUS) != PDU_COMPOSE_SUCCESS) {
- return PDU_COMPOSE_CONTENT_ERROR;
- }
-
- // X-Mms-Applic-ID Optional(not support)
- // X-Mms-Reply-Applic-ID Optional(not support)
- // X-Mms-Aux-Applic-Info Optional(not support)
-
- return PDU_COMPOSE_SUCCESS;
- }
-
- /**
- * Make NotifyResp.Ind.
- */
- private int makeNotifyResp() {
- if (mMessage == null) {
- mMessage = new ByteArrayOutputStream();
- mPosition = 0;
- }
-
- // X-Mms-Message-Type
- appendOctet(PduHeaders.MESSAGE_TYPE);
- appendOctet(PduHeaders.MESSAGE_TYPE_NOTIFYRESP_IND);
-
- // X-Mms-Transaction-ID
- if (appendHeader(PduHeaders.TRANSACTION_ID) != PDU_COMPOSE_SUCCESS) {
- return PDU_COMPOSE_CONTENT_ERROR;
- }
-
- // X-Mms-MMS-Version
- if (appendHeader(PduHeaders.MMS_VERSION) != PDU_COMPOSE_SUCCESS) {
- return PDU_COMPOSE_CONTENT_ERROR;
- }
-
- // X-Mms-Status
- if (appendHeader(PduHeaders.STATUS) != PDU_COMPOSE_SUCCESS) {
- return PDU_COMPOSE_CONTENT_ERROR;
- }
-
- // X-Mms-Report-Allowed Optional (not support)
- return PDU_COMPOSE_SUCCESS;
- }
-
- /**
- * Make Acknowledge.Ind.
- */
- private int makeAckInd() {
- if (mMessage == null) {
- mMessage = new ByteArrayOutputStream();
- mPosition = 0;
- }
-
- // X-Mms-Message-Type
- appendOctet(PduHeaders.MESSAGE_TYPE);
- appendOctet(PduHeaders.MESSAGE_TYPE_ACKNOWLEDGE_IND);
-
- // X-Mms-Transaction-ID
- if (appendHeader(PduHeaders.TRANSACTION_ID) != PDU_COMPOSE_SUCCESS) {
- return PDU_COMPOSE_CONTENT_ERROR;
- }
-
- // X-Mms-MMS-Version
- if (appendHeader(PduHeaders.MMS_VERSION) != PDU_COMPOSE_SUCCESS) {
- return PDU_COMPOSE_CONTENT_ERROR;
- }
-
- // X-Mms-Report-Allowed Optional
- appendHeader(PduHeaders.REPORT_ALLOWED);
-
- return PDU_COMPOSE_SUCCESS;
- }
-
- /**
- * Make Send.req.
- */
- private int makeSendReqPdu() {
- if (mMessage == null) {
- mMessage = new ByteArrayOutputStream();
- mPosition = 0;
- }
-
- // X-Mms-Message-Type
- appendOctet(PduHeaders.MESSAGE_TYPE);
- appendOctet(PduHeaders.MESSAGE_TYPE_SEND_REQ);
-
- // X-Mms-Transaction-ID
- appendOctet(PduHeaders.TRANSACTION_ID);
-
- byte[] trid = mPduHeader.getTextString(PduHeaders.TRANSACTION_ID);
- if (trid == null) {
- // Transaction-ID should be set(by Transaction) before make().
- throw new IllegalArgumentException("Transaction-ID is null.");
- }
- appendTextString(trid);
-
- // X-Mms-MMS-Version
- if (appendHeader(PduHeaders.MMS_VERSION) != PDU_COMPOSE_SUCCESS) {
- return PDU_COMPOSE_CONTENT_ERROR;
- }
-
- // Date Date-value Optional.
- appendHeader(PduHeaders.DATE);
-
- // From
- if (appendHeader(PduHeaders.FROM) != PDU_COMPOSE_SUCCESS) {
- return PDU_COMPOSE_CONTENT_ERROR;
- }
-
- boolean recipient = false;
-
- // To
- if (appendHeader(PduHeaders.TO) != PDU_COMPOSE_CONTENT_ERROR) {
- recipient = true;
- }
-
- // Cc
- if (appendHeader(PduHeaders.CC) != PDU_COMPOSE_CONTENT_ERROR) {
- recipient = true;
- }
-
- // Bcc
- if (appendHeader(PduHeaders.BCC) != PDU_COMPOSE_CONTENT_ERROR) {
- recipient = true;
- }
-
- // Need at least one of "cc", "bcc" and "to".
- if (false == recipient) {
- return PDU_COMPOSE_CONTENT_ERROR;
- }
-
- // Subject Optional
- appendHeader(PduHeaders.SUBJECT);
-
- // X-Mms-Message-Class Optional
- // Message-class-value = Class-identifier | Token-text
- appendHeader(PduHeaders.MESSAGE_CLASS);
-
- // X-Mms-Expiry Optional
- appendHeader(PduHeaders.EXPIRY);
-
- // X-Mms-Priority Optional
- appendHeader(PduHeaders.PRIORITY);
-
- // X-Mms-Delivery-Report Optional
- appendHeader(PduHeaders.DELIVERY_REPORT);
-
- // X-Mms-Read-Report Optional
- appendHeader(PduHeaders.READ_REPORT);
-
- // Content-Type
- appendOctet(PduHeaders.CONTENT_TYPE);
-
- // Message body
- return makeMessageBody();
- }
-
- /**
- * Make message body.
- */
- private int makeMessageBody() {
- // 1. add body informations
- mStack.newbuf(); // Switching buffer because we need to
-
- PositionMarker ctStart = mStack.mark();
-
- // This contentTypeIdentifier should be used for type of attachment...
- String contentType = new String(mPduHeader.getTextString(PduHeaders.CONTENT_TYPE));
- Integer contentTypeIdentifier = mContentTypeMap.get(contentType);
- if (contentTypeIdentifier == null) {
- // content type is mandatory
- return PDU_COMPOSE_CONTENT_ERROR;
- }
-
- appendShortInteger(contentTypeIdentifier.intValue());
-
- // content-type parameter: start
- PduBody body = ((SendReq) mPdu).getBody();
- if (null == body || body.getPartsNum() == 0) {
- // empty message
- appendUintvarInteger(0);
- mStack.pop();
- mStack.copy();
- return PDU_COMPOSE_SUCCESS;
- }
-
- PduPart part;
- try {
- part = body.getPart(0);
-
- byte[] start = part.getContentId();
- if (start != null) {
- appendOctet(PduPart.P_DEP_START);
- if (('<' == start[0]) && ('>' == start[start.length - 1])) {
- appendTextString(start);
- } else {
- appendTextString("<" + new String(start) + ">");
- }
- }
-
- // content-type parameter: type
- appendOctet(PduPart.P_CT_MR_TYPE);
- appendTextString(part.getContentType());
- }
- catch (ArrayIndexOutOfBoundsException e){
- e.printStackTrace();
- }
-
- int ctLength = ctStart.getLength();
- mStack.pop();
- appendValueLength(ctLength);
- mStack.copy();
-
- // 3. add content
- int partNum = body.getPartsNum();
- appendUintvarInteger(partNum);
- for (int i = 0; i < partNum; i++) {
- part = body.getPart(i);
- mStack.newbuf(); // Leaving space for header lengh and data length
- PositionMarker attachment = mStack.mark();
-
- mStack.newbuf(); // Leaving space for Content-Type length
- PositionMarker contentTypeBegin = mStack.mark();
-
- byte[] partContentType = part.getContentType();
-
- if (partContentType == null) {
- // content type is mandatory
- return PDU_COMPOSE_CONTENT_ERROR;
- }
-
- // content-type value
- Integer partContentTypeIdentifier =
- mContentTypeMap.get(new String(partContentType));
- if (partContentTypeIdentifier == null) {
- appendTextString(partContentType);
- } else {
- appendShortInteger(partContentTypeIdentifier.intValue());
- }
-
- /* Content-type parameter : name.
- * The value of name, filename, content-location is the same.
- * Just one of them is enough for this PDU.
- */
- byte[] name = part.getName();
-
- if (null == name) {
- name = part.getFilename();
-
- if (null == name) {
- name = part.getContentLocation();
-
- if (null == name) {
- /* at lease one of name, filename, Content-location
- * should be available.
- */
- return PDU_COMPOSE_CONTENT_ERROR;
- }
- }
- }
- appendOctet(PduPart.P_DEP_NAME);
- appendTextString(name);
-
- // content-type parameter : charset
- int charset = part.getCharset();
- if (charset != 0) {
- appendOctet(PduPart.P_CHARSET);
- appendShortInteger(charset);
- }
-
- int contentTypeLength = contentTypeBegin.getLength();
- mStack.pop();
- appendValueLength(contentTypeLength);
- mStack.copy();
-
- // content id
- byte[] contentId = part.getContentId();
-
- if (null != contentId) {
- appendOctet(PduPart.P_CONTENT_ID);
- if (('<' == contentId[0]) && ('>' == contentId[contentId.length - 1])) {
- appendQuotedString(contentId);
- } else {
- appendQuotedString("<" + new String(contentId) + ">");
- }
- }
-
- // content-location
- byte[] contentLocation = part.getContentLocation();
- if (null != contentLocation) {
- appendOctet(PduPart.P_CONTENT_LOCATION);
- appendTextString(contentLocation);
- }
-
- // content
- int headerLength = attachment.getLength();
-
- int dataLength = 0; // Just for safety...
- byte[] partData = part.getData();
-
- if (partData != null) {
- arraycopy(partData, 0, partData.length);
- dataLength = partData.length;
- } else {
- InputStream cr;
- try {
- byte[] buffer = new byte[PDU_COMPOSER_BLOCK_SIZE];
- cr = mResolver.openInputStream(part.getDataUri());
- int len = 0;
- while ((len = cr.read(buffer)) != -1) {
- mMessage.write(buffer, 0, len);
- mPosition += len;
- dataLength += len;
- }
- } catch (FileNotFoundException e) {
- return PDU_COMPOSE_CONTENT_ERROR;
- } catch (IOException e) {
- return PDU_COMPOSE_CONTENT_ERROR;
- } catch (RuntimeException e) {
- return PDU_COMPOSE_CONTENT_ERROR;
- }
- }
-
- if (dataLength != (attachment.getLength() - headerLength)) {
- throw new RuntimeException("BUG: Length sanity check failed");
- }
-
- mStack.pop();
- appendUintvarInteger(headerLength);
- appendUintvarInteger(dataLength);
- mStack.copy();
- }
-
- return PDU_COMPOSE_SUCCESS;
- }
-
- /**
- * Record current message informations.
- */
- static private class LengthRecordNode {
- ByteArrayOutputStream currentMessage = null;
- public int currentPosition = 0;
-
- public LengthRecordNode next = null;
- }
-
- /**
- * Mark current message position and stact size.
- */
- private class PositionMarker {
- private int c_pos; // Current position
- private int currentStackSize; // Current stack size
-
- int getLength() {
- // If these assert fails, likely that you are finding the
- // size of buffer that is deep in BufferStack you can only
- // find the length of the buffer that is on top
- if (currentStackSize != mStack.stackSize) {
- throw new RuntimeException("BUG: Invalid call to getLength()");
- }
-
- return mPosition - c_pos;
- }
- }
-
- /**
- * This implementation can be OPTIMIZED to use only
- * 2 buffers. This optimization involves changing BufferStack
- * only... Its usage (interface) will not change.
- */
- private class BufferStack {
- private LengthRecordNode stack = null;
- private LengthRecordNode toCopy = null;
-
- int stackSize = 0;
-
- /**
- * Create a new message buffer and push it into the stack.
- */
- void newbuf() {
- // You can't create a new buff when toCopy != null
- // That is after calling pop() and before calling copy()
- // If you do, it is a bug
- if (toCopy != null) {
- throw new RuntimeException("BUG: Invalid newbuf() before copy()");
- }
-
- LengthRecordNode temp = new LengthRecordNode();
-
- temp.currentMessage = mMessage;
- temp.currentPosition = mPosition;
-
- temp.next = stack;
- stack = temp;
-
- stackSize = stackSize + 1;
-
- mMessage = new ByteArrayOutputStream();
- mPosition = 0;
- }
-
- /**
- * Pop the message before and record current message in the stack.
- */
- void pop() {
- ByteArrayOutputStream currentMessage = mMessage;
- int currentPosition = mPosition;
-
- mMessage = stack.currentMessage;
- mPosition = stack.currentPosition;
-
- toCopy = stack;
- // Re using the top element of the stack to avoid memory allocation
-
- stack = stack.next;
- stackSize = stackSize - 1;
-
- toCopy.currentMessage = currentMessage;
- toCopy.currentPosition = currentPosition;
- }
-
- /**
- * Append current message to the message before.
- */
- void copy() {
- arraycopy(toCopy.currentMessage.toByteArray(), 0,
- toCopy.currentPosition);
-
- toCopy = null;
- }
-
- /**
- * Mark current message position
- */
- PositionMarker mark() {
- PositionMarker m = new PositionMarker();
-
- m.c_pos = mPosition;
- m.currentStackSize = stackSize;
-
- return m;
- }
- }
-
- /**
- * Check address type.
- *
- * @param address address string without the postfix stinng type,
- * such as "/TYPE=PLMN", "/TYPE=IPv6" and "/TYPE=IPv4"
- * @return PDU_PHONE_NUMBER_ADDRESS_TYPE if it is phone number,
- * PDU_EMAIL_ADDRESS_TYPE if it is email address,
- * PDU_IPV4_ADDRESS_TYPE if it is ipv4 address,
- * PDU_IPV6_ADDRESS_TYPE if it is ipv6 address,
- * PDU_UNKNOWN_ADDRESS_TYPE if it is unknown.
- */
- protected static int checkAddressType(String address) {
- /**
- * From OMA-TS-MMS-ENC-V1_3-20050927-C.pdf, section 8.
- * address = ( e-mail / device-address / alphanum-shortcode / num-shortcode)
- * e-mail = mailbox; to the definition of mailbox as described in
- * section 3.4 of [RFC2822], but excluding the
- * obsolete definitions as indicated by the "obs-" prefix.
- * device-address = ( global-phone-number "/TYPE=PLMN" )
- * / ( ipv4 "/TYPE=IPv4" ) / ( ipv6 "/TYPE=IPv6" )
- * / ( escaped-value "/TYPE=" address-type )
- *
- * global-phone-number = ["+"] 1*( DIGIT / written-sep )
- * written-sep =("-"/".")
- *
- * ipv4 = 1*3DIGIT 3( "." 1*3DIGIT ) ; IPv4 address value
- *
- * ipv6 = 4HEXDIG 7( ":" 4HEXDIG ) ; IPv6 address per RFC 2373
- */
-
- if (null == address) {
- return PDU_UNKNOWN_ADDRESS_TYPE;
- }
-
- if (address.matches(REGEXP_IPV4_ADDRESS_TYPE)) {
- // Ipv4 address.
- return PDU_IPV4_ADDRESS_TYPE;
- }else if (address.matches(REGEXP_PHONE_NUMBER_ADDRESS_TYPE)) {
- // Phone number.
- return PDU_PHONE_NUMBER_ADDRESS_TYPE;
- } else if (address.matches(REGEXP_EMAIL_ADDRESS_TYPE)) {
- // Email address.
- return PDU_EMAIL_ADDRESS_TYPE;
- } else if (address.matches(REGEXP_IPV6_ADDRESS_TYPE)) {
- // Ipv6 address.
- return PDU_IPV6_ADDRESS_TYPE;
- } else {
- // Unknown address.
- return PDU_UNKNOWN_ADDRESS_TYPE;
- }
- }
-}
diff --git a/core/java/com/google/android/mms/pdu/PduContentTypes.java b/core/java/com/google/android/mms/pdu/PduContentTypes.java
deleted file mode 100644
index 7799e0e834af..000000000000
--- a/core/java/com/google/android/mms/pdu/PduContentTypes.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-public class PduContentTypes {
- /**
- * All content types. From:
- * http://www.openmobilealliance.org/tech/omna/omna-wsp-content-type.htm
- */
- static final String[] contentTypes = {
- "*/*", /* 0x00 */
- "text/*", /* 0x01 */
- "text/html", /* 0x02 */
- "text/plain", /* 0x03 */
- "text/x-hdml", /* 0x04 */
- "text/x-ttml", /* 0x05 */
- "text/x-vCalendar", /* 0x06 */
- "text/x-vCard", /* 0x07 */
- "text/vnd.wap.wml", /* 0x08 */
- "text/vnd.wap.wmlscript", /* 0x09 */
- "text/vnd.wap.wta-event", /* 0x0A */
- "multipart/*", /* 0x0B */
- "multipart/mixed", /* 0x0C */
- "multipart/form-data", /* 0x0D */
- "multipart/byterantes", /* 0x0E */
- "multipart/alternative", /* 0x0F */
- "application/*", /* 0x10 */
- "application/java-vm", /* 0x11 */
- "application/x-www-form-urlencoded", /* 0x12 */
- "application/x-hdmlc", /* 0x13 */
- "application/vnd.wap.wmlc", /* 0x14 */
- "application/vnd.wap.wmlscriptc", /* 0x15 */
- "application/vnd.wap.wta-eventc", /* 0x16 */
- "application/vnd.wap.uaprof", /* 0x17 */
- "application/vnd.wap.wtls-ca-certificate", /* 0x18 */
- "application/vnd.wap.wtls-user-certificate", /* 0x19 */
- "application/x-x509-ca-cert", /* 0x1A */
- "application/x-x509-user-cert", /* 0x1B */
- "image/*", /* 0x1C */
- "image/gif", /* 0x1D */
- "image/jpeg", /* 0x1E */
- "image/tiff", /* 0x1F */
- "image/png", /* 0x20 */
- "image/vnd.wap.wbmp", /* 0x21 */
- "application/vnd.wap.multipart.*", /* 0x22 */
- "application/vnd.wap.multipart.mixed", /* 0x23 */
- "application/vnd.wap.multipart.form-data", /* 0x24 */
- "application/vnd.wap.multipart.byteranges", /* 0x25 */
- "application/vnd.wap.multipart.alternative", /* 0x26 */
- "application/xml", /* 0x27 */
- "text/xml", /* 0x28 */
- "application/vnd.wap.wbxml", /* 0x29 */
- "application/x-x968-cross-cert", /* 0x2A */
- "application/x-x968-ca-cert", /* 0x2B */
- "application/x-x968-user-cert", /* 0x2C */
- "text/vnd.wap.si", /* 0x2D */
- "application/vnd.wap.sic", /* 0x2E */
- "text/vnd.wap.sl", /* 0x2F */
- "application/vnd.wap.slc", /* 0x30 */
- "text/vnd.wap.co", /* 0x31 */
- "application/vnd.wap.coc", /* 0x32 */
- "application/vnd.wap.multipart.related", /* 0x33 */
- "application/vnd.wap.sia", /* 0x34 */
- "text/vnd.wap.connectivity-xml", /* 0x35 */
- "application/vnd.wap.connectivity-wbxml", /* 0x36 */
- "application/pkcs7-mime", /* 0x37 */
- "application/vnd.wap.hashed-certificate", /* 0x38 */
- "application/vnd.wap.signed-certificate", /* 0x39 */
- "application/vnd.wap.cert-response", /* 0x3A */
- "application/xhtml+xml", /* 0x3B */
- "application/wml+xml", /* 0x3C */
- "text/css", /* 0x3D */
- "application/vnd.wap.mms-message", /* 0x3E */
- "application/vnd.wap.rollover-certificate", /* 0x3F */
- "application/vnd.wap.locc+wbxml", /* 0x40 */
- "application/vnd.wap.loc+xml", /* 0x41 */
- "application/vnd.syncml.dm+wbxml", /* 0x42 */
- "application/vnd.syncml.dm+xml", /* 0x43 */
- "application/vnd.syncml.notification", /* 0x44 */
- "application/vnd.wap.xhtml+xml", /* 0x45 */
- "application/vnd.wv.csp.cir", /* 0x46 */
- "application/vnd.oma.dd+xml", /* 0x47 */
- "application/vnd.oma.drm.message", /* 0x48 */
- "application/vnd.oma.drm.content", /* 0x49 */
- "application/vnd.oma.drm.rights+xml", /* 0x4A */
- "application/vnd.oma.drm.rights+wbxml", /* 0x4B */
- "application/vnd.wv.csp+xml", /* 0x4C */
- "application/vnd.wv.csp+wbxml", /* 0x4D */
- "application/vnd.syncml.ds.notification", /* 0x4E */
- "audio/*", /* 0x4F */
- "video/*", /* 0x50 */
- "application/vnd.oma.dd2+xml", /* 0x51 */
- "application/mikey" /* 0x52 */
- };
-}
diff --git a/core/java/com/google/android/mms/pdu/PduHeaders.java b/core/java/com/google/android/mms/pdu/PduHeaders.java
deleted file mode 100644
index 43138150f804..000000000000
--- a/core/java/com/google/android/mms/pdu/PduHeaders.java
+++ /dev/null
@@ -1,721 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import com.google.android.mms.InvalidHeaderValueException;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-public class PduHeaders {
- /**
- * All pdu header fields.
- */
- public static final int BCC = 0x81;
- public static final int CC = 0x82;
- public static final int CONTENT_LOCATION = 0x83;
- public static final int CONTENT_TYPE = 0x84;
- public static final int DATE = 0x85;
- public static final int DELIVERY_REPORT = 0x86;
- public static final int DELIVERY_TIME = 0x87;
- public static final int EXPIRY = 0x88;
- public static final int FROM = 0x89;
- public static final int MESSAGE_CLASS = 0x8A;
- public static final int MESSAGE_ID = 0x8B;
- public static final int MESSAGE_TYPE = 0x8C;
- public static final int MMS_VERSION = 0x8D;
- public static final int MESSAGE_SIZE = 0x8E;
- public static final int PRIORITY = 0x8F;
-
- public static final int READ_REPLY = 0x90;
- public static final int READ_REPORT = 0x90;
- public static final int REPORT_ALLOWED = 0x91;
- public static final int RESPONSE_STATUS = 0x92;
- public static final int RESPONSE_TEXT = 0x93;
- public static final int SENDER_VISIBILITY = 0x94;
- public static final int STATUS = 0x95;
- public static final int SUBJECT = 0x96;
- public static final int TO = 0x97;
- public static final int TRANSACTION_ID = 0x98;
- public static final int RETRIEVE_STATUS = 0x99;
- public static final int RETRIEVE_TEXT = 0x9A;
- public static final int READ_STATUS = 0x9B;
- public static final int REPLY_CHARGING = 0x9C;
- public static final int REPLY_CHARGING_DEADLINE = 0x9D;
- public static final int REPLY_CHARGING_ID = 0x9E;
- public static final int REPLY_CHARGING_SIZE = 0x9F;
-
- public static final int PREVIOUSLY_SENT_BY = 0xA0;
- public static final int PREVIOUSLY_SENT_DATE = 0xA1;
- public static final int STORE = 0xA2;
- public static final int MM_STATE = 0xA3;
- public static final int MM_FLAGS = 0xA4;
- public static final int STORE_STATUS = 0xA5;
- public static final int STORE_STATUS_TEXT = 0xA6;
- public static final int STORED = 0xA7;
- public static final int ATTRIBUTES = 0xA8;
- public static final int TOTALS = 0xA9;
- public static final int MBOX_TOTALS = 0xAA;
- public static final int QUOTAS = 0xAB;
- public static final int MBOX_QUOTAS = 0xAC;
- public static final int MESSAGE_COUNT = 0xAD;
- public static final int CONTENT = 0xAE;
- public static final int START = 0xAF;
-
- public static final int ADDITIONAL_HEADERS = 0xB0;
- public static final int DISTRIBUTION_INDICATOR = 0xB1;
- public static final int ELEMENT_DESCRIPTOR = 0xB2;
- public static final int LIMIT = 0xB3;
- public static final int RECOMMENDED_RETRIEVAL_MODE = 0xB4;
- public static final int RECOMMENDED_RETRIEVAL_MODE_TEXT = 0xB5;
- public static final int STATUS_TEXT = 0xB6;
- public static final int APPLIC_ID = 0xB7;
- public static final int REPLY_APPLIC_ID = 0xB8;
- public static final int AUX_APPLIC_ID = 0xB9;
- public static final int CONTENT_CLASS = 0xBA;
- public static final int DRM_CONTENT = 0xBB;
- public static final int ADAPTATION_ALLOWED = 0xBC;
- public static final int REPLACE_ID = 0xBD;
- public static final int CANCEL_ID = 0xBE;
- public static final int CANCEL_STATUS = 0xBF;
-
- /**
- * X-Mms-Message-Type field types.
- */
- public static final int MESSAGE_TYPE_SEND_REQ = 0x80;
- public static final int MESSAGE_TYPE_SEND_CONF = 0x81;
- public static final int MESSAGE_TYPE_NOTIFICATION_IND = 0x82;
- public static final int MESSAGE_TYPE_NOTIFYRESP_IND = 0x83;
- public static final int MESSAGE_TYPE_RETRIEVE_CONF = 0x84;
- public static final int MESSAGE_TYPE_ACKNOWLEDGE_IND = 0x85;
- public static final int MESSAGE_TYPE_DELIVERY_IND = 0x86;
- public static final int MESSAGE_TYPE_READ_REC_IND = 0x87;
- public static final int MESSAGE_TYPE_READ_ORIG_IND = 0x88;
- public static final int MESSAGE_TYPE_FORWARD_REQ = 0x89;
- public static final int MESSAGE_TYPE_FORWARD_CONF = 0x8A;
- public static final int MESSAGE_TYPE_MBOX_STORE_REQ = 0x8B;
- public static final int MESSAGE_TYPE_MBOX_STORE_CONF = 0x8C;
- public static final int MESSAGE_TYPE_MBOX_VIEW_REQ = 0x8D;
- public static final int MESSAGE_TYPE_MBOX_VIEW_CONF = 0x8E;
- public static final int MESSAGE_TYPE_MBOX_UPLOAD_REQ = 0x8F;
- public static final int MESSAGE_TYPE_MBOX_UPLOAD_CONF = 0x90;
- public static final int MESSAGE_TYPE_MBOX_DELETE_REQ = 0x91;
- public static final int MESSAGE_TYPE_MBOX_DELETE_CONF = 0x92;
- public static final int MESSAGE_TYPE_MBOX_DESCR = 0x93;
- public static final int MESSAGE_TYPE_DELETE_REQ = 0x94;
- public static final int MESSAGE_TYPE_DELETE_CONF = 0x95;
- public static final int MESSAGE_TYPE_CANCEL_REQ = 0x96;
- public static final int MESSAGE_TYPE_CANCEL_CONF = 0x97;
-
- /**
- * X-Mms-Delivery-Report |
- * X-Mms-Read-Report |
- * X-Mms-Report-Allowed |
- * X-Mms-Sender-Visibility |
- * X-Mms-Store |
- * X-Mms-Stored |
- * X-Mms-Totals |
- * X-Mms-Quotas |
- * X-Mms-Distribution-Indicator |
- * X-Mms-DRM-Content |
- * X-Mms-Adaptation-Allowed |
- * field types.
- */
- public static final int VALUE_YES = 0x80;
- public static final int VALUE_NO = 0x81;
-
- /**
- * Delivery-Time |
- * Expiry and Reply-Charging-Deadline |
- * field type components.
- */
- public static final int VALUE_ABSOLUTE_TOKEN = 0x80;
- public static final int VALUE_RELATIVE_TOKEN = 0x81;
-
- /**
- * X-Mms-MMS-Version field types.
- */
- public static final int MMS_VERSION_1_3 = ((1 << 4) | 3);
- public static final int MMS_VERSION_1_2 = ((1 << 4) | 2);
- public static final int MMS_VERSION_1_1 = ((1 << 4) | 1);
- public static final int MMS_VERSION_1_0 = ((1 << 4) | 0);
-
- // Current version is 1.2.
- public static final int CURRENT_MMS_VERSION = MMS_VERSION_1_2;
-
- /**
- * From field type components.
- */
- public static final int FROM_ADDRESS_PRESENT_TOKEN = 0x80;
- public static final int FROM_INSERT_ADDRESS_TOKEN = 0x81;
-
- public static final String FROM_ADDRESS_PRESENT_TOKEN_STR = "address-present-token";
- public static final String FROM_INSERT_ADDRESS_TOKEN_STR = "insert-address-token";
-
- /**
- * X-Mms-Status Field.
- */
- public static final int STATUS_EXPIRED = 0x80;
- public static final int STATUS_RETRIEVED = 0x81;
- public static final int STATUS_REJECTED = 0x82;
- public static final int STATUS_DEFERRED = 0x83;
- public static final int STATUS_UNRECOGNIZED = 0x84;
- public static final int STATUS_INDETERMINATE = 0x85;
- public static final int STATUS_FORWARDED = 0x86;
- public static final int STATUS_UNREACHABLE = 0x87;
-
- /**
- * MM-Flags field type components.
- */
- public static final int MM_FLAGS_ADD_TOKEN = 0x80;
- public static final int MM_FLAGS_REMOVE_TOKEN = 0x81;
- public static final int MM_FLAGS_FILTER_TOKEN = 0x82;
-
- /**
- * X-Mms-Message-Class field types.
- */
- public static final int MESSAGE_CLASS_PERSONAL = 0x80;
- public static final int MESSAGE_CLASS_ADVERTISEMENT = 0x81;
- public static final int MESSAGE_CLASS_INFORMATIONAL = 0x82;
- public static final int MESSAGE_CLASS_AUTO = 0x83;
-
- public static final String MESSAGE_CLASS_PERSONAL_STR = "personal";
- public static final String MESSAGE_CLASS_ADVERTISEMENT_STR = "advertisement";
- public static final String MESSAGE_CLASS_INFORMATIONAL_STR = "informational";
- public static final String MESSAGE_CLASS_AUTO_STR = "auto";
-
- /**
- * X-Mms-Priority field types.
- */
- public static final int PRIORITY_LOW = 0x80;
- public static final int PRIORITY_NORMAL = 0x81;
- public static final int PRIORITY_HIGH = 0x82;
-
- /**
- * X-Mms-Response-Status field types.
- */
- public static final int RESPONSE_STATUS_OK = 0x80;
- public static final int RESPONSE_STATUS_ERROR_UNSPECIFIED = 0x81;
- public static final int RESPONSE_STATUS_ERROR_SERVICE_DENIED = 0x82;
-
- public static final int RESPONSE_STATUS_ERROR_MESSAGE_FORMAT_CORRUPT = 0x83;
- public static final int RESPONSE_STATUS_ERROR_SENDING_ADDRESS_UNRESOLVED = 0x84;
-
- public static final int RESPONSE_STATUS_ERROR_MESSAGE_NOT_FOUND = 0x85;
- public static final int RESPONSE_STATUS_ERROR_NETWORK_PROBLEM = 0x86;
- public static final int RESPONSE_STATUS_ERROR_CONTENT_NOT_ACCEPTED = 0x87;
- public static final int RESPONSE_STATUS_ERROR_UNSUPPORTED_MESSAGE = 0x88;
- public static final int RESPONSE_STATUS_ERROR_TRANSIENT_FAILURE = 0xC0;
-
- public static final int RESPONSE_STATUS_ERROR_TRANSIENT_SENDNG_ADDRESS_UNRESOLVED = 0xC1;
- public static final int RESPONSE_STATUS_ERROR_TRANSIENT_MESSAGE_NOT_FOUND = 0xC2;
- public static final int RESPONSE_STATUS_ERROR_TRANSIENT_NETWORK_PROBLEM = 0xC3;
- public static final int RESPONSE_STATUS_ERROR_TRANSIENT_PARTIAL_SUCCESS = 0xC4;
-
- public static final int RESPONSE_STATUS_ERROR_PERMANENT_FAILURE = 0xE0;
- public static final int RESPONSE_STATUS_ERROR_PERMANENT_SERVICE_DENIED = 0xE1;
- public static final int RESPONSE_STATUS_ERROR_PERMANENT_MESSAGE_FORMAT_CORRUPT = 0xE2;
- public static final int RESPONSE_STATUS_ERROR_PERMANENT_SENDING_ADDRESS_UNRESOLVED = 0xE3;
- public static final int RESPONSE_STATUS_ERROR_PERMANENT_MESSAGE_NOT_FOUND = 0xE4;
- public static final int RESPONSE_STATUS_ERROR_PERMANENT_CONTENT_NOT_ACCEPTED = 0xE5;
- public static final int RESPONSE_STATUS_ERROR_PERMANENT_REPLY_CHARGING_LIMITATIONS_NOT_MET = 0xE6;
- public static final int RESPONSE_STATUS_ERROR_PERMANENT_REPLY_CHARGING_REQUEST_NOT_ACCEPTED = 0xE6;
- public static final int RESPONSE_STATUS_ERROR_PERMANENT_REPLY_CHARGING_FORWARDING_DENIED = 0xE8;
- public static final int RESPONSE_STATUS_ERROR_PERMANENT_REPLY_CHARGING_NOT_SUPPORTED = 0xE9;
- public static final int RESPONSE_STATUS_ERROR_PERMANENT_ADDRESS_HIDING_NOT_SUPPORTED = 0xEA;
- public static final int RESPONSE_STATUS_ERROR_PERMANENT_LACK_OF_PREPAID = 0xEB;
- public static final int RESPONSE_STATUS_ERROR_PERMANENT_END = 0xFF;
-
- /**
- * X-Mms-Retrieve-Status field types.
- */
- public static final int RETRIEVE_STATUS_OK = 0x80;
- public static final int RETRIEVE_STATUS_ERROR_TRANSIENT_FAILURE = 0xC0;
- public static final int RETRIEVE_STATUS_ERROR_TRANSIENT_MESSAGE_NOT_FOUND = 0xC1;
- public static final int RETRIEVE_STATUS_ERROR_TRANSIENT_NETWORK_PROBLEM = 0xC2;
- public static final int RETRIEVE_STATUS_ERROR_PERMANENT_FAILURE = 0xE0;
- public static final int RETRIEVE_STATUS_ERROR_PERMANENT_SERVICE_DENIED = 0xE1;
- public static final int RETRIEVE_STATUS_ERROR_PERMANENT_MESSAGE_NOT_FOUND = 0xE2;
- public static final int RETRIEVE_STATUS_ERROR_PERMANENT_CONTENT_UNSUPPORTED = 0xE3;
- public static final int RETRIEVE_STATUS_ERROR_END = 0xFF;
-
- /**
- * X-Mms-Sender-Visibility field types.
- */
- public static final int SENDER_VISIBILITY_HIDE = 0x80;
- public static final int SENDER_VISIBILITY_SHOW = 0x81;
-
- /**
- * X-Mms-Read-Status field types.
- */
- public static final int READ_STATUS_READ = 0x80;
- public static final int READ_STATUS__DELETED_WITHOUT_BEING_READ = 0x81;
-
- /**
- * X-Mms-Cancel-Status field types.
- */
- public static final int CANCEL_STATUS_REQUEST_SUCCESSFULLY_RECEIVED = 0x80;
- public static final int CANCEL_STATUS_REQUEST_CORRUPTED = 0x81;
-
- /**
- * X-Mms-Reply-Charging field types.
- */
- public static final int REPLY_CHARGING_REQUESTED = 0x80;
- public static final int REPLY_CHARGING_REQUESTED_TEXT_ONLY = 0x81;
- public static final int REPLY_CHARGING_ACCEPTED = 0x82;
- public static final int REPLY_CHARGING_ACCEPTED_TEXT_ONLY = 0x83;
-
- /**
- * X-Mms-MM-State field types.
- */
- public static final int MM_STATE_DRAFT = 0x80;
- public static final int MM_STATE_SENT = 0x81;
- public static final int MM_STATE_NEW = 0x82;
- public static final int MM_STATE_RETRIEVED = 0x83;
- public static final int MM_STATE_FORWARDED = 0x84;
-
- /**
- * X-Mms-Recommended-Retrieval-Mode field types.
- */
- public static final int RECOMMENDED_RETRIEVAL_MODE_MANUAL = 0x80;
-
- /**
- * X-Mms-Content-Class field types.
- */
- public static final int CONTENT_CLASS_TEXT = 0x80;
- public static final int CONTENT_CLASS_IMAGE_BASIC = 0x81;
- public static final int CONTENT_CLASS_IMAGE_RICH = 0x82;
- public static final int CONTENT_CLASS_VIDEO_BASIC = 0x83;
- public static final int CONTENT_CLASS_VIDEO_RICH = 0x84;
- public static final int CONTENT_CLASS_MEGAPIXEL = 0x85;
- public static final int CONTENT_CLASS_CONTENT_BASIC = 0x86;
- public static final int CONTENT_CLASS_CONTENT_RICH = 0x87;
-
- /**
- * X-Mms-Store-Status field types.
- */
- public static final int STORE_STATUS_SUCCESS = 0x80;
- public static final int STORE_STATUS_ERROR_TRANSIENT_FAILURE = 0xC0;
- public static final int STORE_STATUS_ERROR_TRANSIENT_NETWORK_PROBLEM = 0xC1;
- public static final int STORE_STATUS_ERROR_PERMANENT_FAILURE = 0xE0;
- public static final int STORE_STATUS_ERROR_PERMANENT_SERVICE_DENIED = 0xE1;
- public static final int STORE_STATUS_ERROR_PERMANENT_MESSAGE_FORMAT_CORRUPT = 0xE2;
- public static final int STORE_STATUS_ERROR_PERMANENT_MESSAGE_NOT_FOUND = 0xE3;
- public static final int STORE_STATUS_ERROR_PERMANENT_MMBOX_FULL = 0xE4;
- public static final int STORE_STATUS_ERROR_END = 0xFF;
-
- /**
- * The map contains the value of all headers.
- */
- private HashMap mHeaderMap = null;
-
- /**
- * Constructor of PduHeaders.
- */
- public PduHeaders() {
- mHeaderMap = new HashMap();
- }
-
- /**
- * Get octet value by header field.
- *
- * @param field the field
- * @return the octet value of the pdu header
- * with specified header field. Return 0 if
- * the value is not set.
- */
- protected int getOctet(int field) {
- Integer octet = (Integer) mHeaderMap.get(field);
- if (null == octet) {
- return 0;
- }
-
- return octet;
- }
-
- /**
- * Set octet value to pdu header by header field.
- *
- * @param value the value
- * @param field the field
- * @throws InvalidHeaderValueException if the value is invalid.
- */
- protected void setOctet(int value, int field)
- throws InvalidHeaderValueException{
- /**
- * Check whether this field can be set for specific
- * header and check validity of the field.
- */
- switch (field) {
- case REPORT_ALLOWED:
- case ADAPTATION_ALLOWED:
- case DELIVERY_REPORT:
- case DRM_CONTENT:
- case DISTRIBUTION_INDICATOR:
- case QUOTAS:
- case READ_REPORT:
- case STORE:
- case STORED:
- case TOTALS:
- case SENDER_VISIBILITY:
- if ((VALUE_YES != value) && (VALUE_NO != value)) {
- // Invalid value.
- throw new InvalidHeaderValueException("Invalid Octet value!");
- }
- break;
- case READ_STATUS:
- if ((READ_STATUS_READ != value) &&
- (READ_STATUS__DELETED_WITHOUT_BEING_READ != value)) {
- // Invalid value.
- throw new InvalidHeaderValueException("Invalid Octet value!");
- }
- break;
- case CANCEL_STATUS:
- if ((CANCEL_STATUS_REQUEST_SUCCESSFULLY_RECEIVED != value) &&
- (CANCEL_STATUS_REQUEST_CORRUPTED != value)) {
- // Invalid value.
- throw new InvalidHeaderValueException("Invalid Octet value!");
- }
- break;
- case PRIORITY:
- if ((value < PRIORITY_LOW) || (value > PRIORITY_HIGH)) {
- // Invalid value.
- throw new InvalidHeaderValueException("Invalid Octet value!");
- }
- break;
- case STATUS:
- if ((value < STATUS_EXPIRED) || (value > STATUS_UNREACHABLE)) {
- // Invalid value.
- throw new InvalidHeaderValueException("Invalid Octet value!");
- }
- break;
- case REPLY_CHARGING:
- if ((value < REPLY_CHARGING_REQUESTED)
- || (value > REPLY_CHARGING_ACCEPTED_TEXT_ONLY)) {
- // Invalid value.
- throw new InvalidHeaderValueException("Invalid Octet value!");
- }
- break;
- case MM_STATE:
- if ((value < MM_STATE_DRAFT) || (value > MM_STATE_FORWARDED)) {
- // Invalid value.
- throw new InvalidHeaderValueException("Invalid Octet value!");
- }
- break;
- case RECOMMENDED_RETRIEVAL_MODE:
- if (RECOMMENDED_RETRIEVAL_MODE_MANUAL != value) {
- // Invalid value.
- throw new InvalidHeaderValueException("Invalid Octet value!");
- }
- break;
- case CONTENT_CLASS:
- if ((value < CONTENT_CLASS_TEXT)
- || (value > CONTENT_CLASS_CONTENT_RICH)) {
- // Invalid value.
- throw new InvalidHeaderValueException("Invalid Octet value!");
- }
- break;
- case RETRIEVE_STATUS:
- // According to oma-ts-mms-enc-v1_3, section 7.3.50, we modify the invalid value.
- if ((value > RETRIEVE_STATUS_ERROR_TRANSIENT_NETWORK_PROBLEM) &&
- (value < RETRIEVE_STATUS_ERROR_PERMANENT_FAILURE)) {
- value = RETRIEVE_STATUS_ERROR_TRANSIENT_FAILURE;
- } else if ((value > RETRIEVE_STATUS_ERROR_PERMANENT_CONTENT_UNSUPPORTED) &&
- (value <= RETRIEVE_STATUS_ERROR_END)) {
- value = RETRIEVE_STATUS_ERROR_PERMANENT_FAILURE;
- } else if ((value < RETRIEVE_STATUS_OK) ||
- ((value > RETRIEVE_STATUS_OK) &&
- (value < RETRIEVE_STATUS_ERROR_TRANSIENT_FAILURE)) ||
- (value > RETRIEVE_STATUS_ERROR_END)) {
- value = RETRIEVE_STATUS_ERROR_PERMANENT_FAILURE;
- }
- break;
- case STORE_STATUS:
- // According to oma-ts-mms-enc-v1_3, section 7.3.58, we modify the invalid value.
- if ((value > STORE_STATUS_ERROR_TRANSIENT_NETWORK_PROBLEM) &&
- (value < STORE_STATUS_ERROR_PERMANENT_FAILURE)) {
- value = STORE_STATUS_ERROR_TRANSIENT_FAILURE;
- } else if ((value > STORE_STATUS_ERROR_PERMANENT_MMBOX_FULL) &&
- (value <= STORE_STATUS_ERROR_END)) {
- value = STORE_STATUS_ERROR_PERMANENT_FAILURE;
- } else if ((value < STORE_STATUS_SUCCESS) ||
- ((value > STORE_STATUS_SUCCESS) &&
- (value < STORE_STATUS_ERROR_TRANSIENT_FAILURE)) ||
- (value > STORE_STATUS_ERROR_END)) {
- value = STORE_STATUS_ERROR_PERMANENT_FAILURE;
- }
- break;
- case RESPONSE_STATUS:
- // According to oma-ts-mms-enc-v1_3, section 7.3.48, we modify the invalid value.
- if ((value > RESPONSE_STATUS_ERROR_TRANSIENT_PARTIAL_SUCCESS) &&
- (value < RESPONSE_STATUS_ERROR_PERMANENT_FAILURE)) {
- value = RESPONSE_STATUS_ERROR_TRANSIENT_FAILURE;
- } else if (((value > RESPONSE_STATUS_ERROR_PERMANENT_LACK_OF_PREPAID) &&
- (value <= RESPONSE_STATUS_ERROR_PERMANENT_END)) ||
- (value < RESPONSE_STATUS_OK) ||
- ((value > RESPONSE_STATUS_ERROR_UNSUPPORTED_MESSAGE) &&
- (value < RESPONSE_STATUS_ERROR_TRANSIENT_FAILURE)) ||
- (value > RESPONSE_STATUS_ERROR_PERMANENT_END)) {
- value = RESPONSE_STATUS_ERROR_PERMANENT_FAILURE;
- }
- break;
- case MMS_VERSION:
- if ((value < MMS_VERSION_1_0)|| (value > MMS_VERSION_1_3)) {
- value = CURRENT_MMS_VERSION; // Current version is the default value.
- }
- break;
- case MESSAGE_TYPE:
- if ((value < MESSAGE_TYPE_SEND_REQ) || (value > MESSAGE_TYPE_CANCEL_CONF)) {
- // Invalid value.
- throw new InvalidHeaderValueException("Invalid Octet value!");
- }
- break;
- default:
- // This header value should not be Octect.
- throw new RuntimeException("Invalid header field!");
- }
- mHeaderMap.put(field, value);
- }
-
- /**
- * Get TextString value by header field.
- *
- * @param field the field
- * @return the TextString value of the pdu header
- * with specified header field
- */
- protected byte[] getTextString(int field) {
- return (byte[]) mHeaderMap.get(field);
- }
-
- /**
- * Set TextString value to pdu header by header field.
- *
- * @param value the value
- * @param field the field
- * @return the TextString value of the pdu header
- * with specified header field
- * @throws NullPointerException if the value is null.
- */
- protected void setTextString(byte[] value, int field) {
- /**
- * Check whether this field can be set for specific
- * header and check validity of the field.
- */
- if (null == value) {
- throw new NullPointerException();
- }
-
- switch (field) {
- case TRANSACTION_ID:
- case REPLY_CHARGING_ID:
- case AUX_APPLIC_ID:
- case APPLIC_ID:
- case REPLY_APPLIC_ID:
- case MESSAGE_ID:
- case REPLACE_ID:
- case CANCEL_ID:
- case CONTENT_LOCATION:
- case MESSAGE_CLASS:
- case CONTENT_TYPE:
- break;
- default:
- // This header value should not be Text-String.
- throw new RuntimeException("Invalid header field!");
- }
- mHeaderMap.put(field, value);
- }
-
- /**
- * Get EncodedStringValue value by header field.
- *
- * @param field the field
- * @return the EncodedStringValue value of the pdu header
- * with specified header field
- */
- protected EncodedStringValue getEncodedStringValue(int field) {
- return (EncodedStringValue) mHeaderMap.get(field);
- }
-
- /**
- * Get TO, CC or BCC header value.
- *
- * @param field the field
- * @return the EncodeStringValue array of the pdu header
- * with specified header field
- */
- protected EncodedStringValue[] getEncodedStringValues(int field) {
- ArrayList list =
- (ArrayList) mHeaderMap.get(field);
- if (null == list) {
- return null;
- }
- EncodedStringValue[] values = new EncodedStringValue[list.size()];
- return list.toArray(values);
- }
-
- /**
- * Set EncodedStringValue value to pdu header by header field.
- *
- * @param value the value
- * @param field the field
- * @return the EncodedStringValue value of the pdu header
- * with specified header field
- * @throws NullPointerException if the value is null.
- */
- protected void setEncodedStringValue(EncodedStringValue value, int field) {
- /**
- * Check whether this field can be set for specific
- * header and check validity of the field.
- */
- if (null == value) {
- throw new NullPointerException();
- }
-
- switch (field) {
- case SUBJECT:
- case RECOMMENDED_RETRIEVAL_MODE_TEXT:
- case RETRIEVE_TEXT:
- case STATUS_TEXT:
- case STORE_STATUS_TEXT:
- case RESPONSE_TEXT:
- case FROM:
- case PREVIOUSLY_SENT_BY:
- case MM_FLAGS:
- break;
- default:
- // This header value should not be Encoded-String-Value.
- throw new RuntimeException("Invalid header field!");
- }
-
- mHeaderMap.put(field, value);
- }
-
- /**
- * Set TO, CC or BCC header value.
- *
- * @param value the value
- * @param field the field
- * @return the EncodedStringValue value array of the pdu header
- * with specified header field
- * @throws NullPointerException if the value is null.
- */
- protected void setEncodedStringValues(EncodedStringValue[] value, int field) {
- /**
- * Check whether this field can be set for specific
- * header and check validity of the field.
- */
- if (null == value) {
- throw new NullPointerException();
- }
-
- switch (field) {
- case BCC:
- case CC:
- case TO:
- break;
- default:
- // This header value should not be Encoded-String-Value.
- throw new RuntimeException("Invalid header field!");
- }
-
- ArrayList list = new ArrayList();
- for (int i = 0; i < value.length; i++) {
- list.add(value[i]);
- }
- mHeaderMap.put(field, list);
- }
-
- /**
- * Append one EncodedStringValue to another.
- *
- * @param value the EncodedStringValue to append
- * @param field the field
- * @throws NullPointerException if the value is null.
- */
- protected void appendEncodedStringValue(EncodedStringValue value,
- int field) {
- if (null == value) {
- throw new NullPointerException();
- }
-
- switch (field) {
- case BCC:
- case CC:
- case TO:
- break;
- default:
- throw new RuntimeException("Invalid header field!");
- }
-
- ArrayList list =
- (ArrayList) mHeaderMap.get(field);
- if (null == list) {
- list = new ArrayList();
- }
- list.add(value);
- mHeaderMap.put(field, list);
- }
-
- /**
- * Get LongInteger value by header field.
- *
- * @param field the field
- * @return the LongInteger value of the pdu header
- * with specified header field. if return -1, the
- * field is not existed in pdu header.
- */
- protected long getLongInteger(int field) {
- Long longInteger = (Long) mHeaderMap.get(field);
- if (null == longInteger) {
- return -1;
- }
-
- return longInteger.longValue();
- }
-
- /**
- * Set LongInteger value to pdu header by header field.
- *
- * @param value the value
- * @param field the field
- */
- protected void setLongInteger(long value, int field) {
- /**
- * Check whether this field can be set for specific
- * header and check validity of the field.
- */
- switch (field) {
- case DATE:
- case REPLY_CHARGING_SIZE:
- case MESSAGE_SIZE:
- case MESSAGE_COUNT:
- case START:
- case LIMIT:
- case DELIVERY_TIME:
- case EXPIRY:
- case REPLY_CHARGING_DEADLINE:
- case PREVIOUSLY_SENT_DATE:
- break;
- default:
- // This header value should not be LongInteger.
- throw new RuntimeException("Invalid header field!");
- }
- mHeaderMap.put(field, value);
- }
-}
diff --git a/core/java/com/google/android/mms/pdu/PduParser.java b/core/java/com/google/android/mms/pdu/PduParser.java
deleted file mode 100755
index 015d864a01ea..000000000000
--- a/core/java/com/google/android/mms/pdu/PduParser.java
+++ /dev/null
@@ -1,1912 +0,0 @@
-/*
- * Copyright (C) 2007-2008 Esmertec AG.
- * Copyright (C) 2007-2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import com.google.android.mms.ContentType;
-import com.google.android.mms.InvalidHeaderValueException;
-
-import android.util.Log;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
-import java.util.HashMap;
-
-import android.content.res.Resources;
-
-public class PduParser {
- /**
- * The next are WAP values defined in WSP specification.
- */
- private static final int QUOTE = 127;
- private static final int LENGTH_QUOTE = 31;
- private static final int TEXT_MIN = 32;
- private static final int TEXT_MAX = 127;
- private static final int SHORT_INTEGER_MAX = 127;
- private static final int SHORT_LENGTH_MAX = 30;
- private static final int LONG_INTEGER_LENGTH_MAX = 8;
- private static final int QUOTED_STRING_FLAG = 34;
- private static final int END_STRING_FLAG = 0x00;
- //The next two are used by the interface "parseWapString" to
- //distinguish Text-String and Quoted-String.
- private static final int TYPE_TEXT_STRING = 0;
- private static final int TYPE_QUOTED_STRING = 1;
- private static final int TYPE_TOKEN_STRING = 2;
-
- /**
- * Specify the part position.
- */
- private static final int THE_FIRST_PART = 0;
- private static final int THE_LAST_PART = 1;
-
- /**
- * The pdu data.
- */
- private ByteArrayInputStream mPduDataStream = null;
-
- /**
- * Store pdu headers
- */
- private PduHeaders mHeaders = null;
-
- /**
- * Store pdu parts.
- */
- private PduBody mBody = null;
-
- /**
- * Store the "type" parameter in "Content-Type" header field.
- */
- private static byte[] mTypeParam = null;
-
- /**
- * Store the "start" parameter in "Content-Type" header field.
- */
- private static byte[] mStartParam = null;
-
- /**
- * The log tag.
- */
- private static final String LOG_TAG = "PduParser";
- private static final boolean DEBUG = false;
- private static final boolean LOCAL_LOGV = false;
-
- /**
- * Constructor.
- *
- * @param pduDataStream pdu data to be parsed
- */
- public PduParser(byte[] pduDataStream) {
- mPduDataStream = new ByteArrayInputStream(pduDataStream);
- }
-
- /**
- * Parse the pdu.
- *
- * @return the pdu structure if parsing successfully.
- * null if parsing error happened or mandatory fields are not set.
- */
- public GenericPdu parse(){
- if (mPduDataStream == null) {
- return null;
- }
-
- /* parse headers */
- mHeaders = parseHeaders(mPduDataStream);
- if (null == mHeaders) {
- // Parse headers failed.
- return null;
- }
-
- /* get the message type */
- int messageType = mHeaders.getOctet(PduHeaders.MESSAGE_TYPE);
-
- /* check mandatory header fields */
- if (false == checkMandatoryHeader(mHeaders)) {
- log("check mandatory headers failed!");
- return null;
- }
-
- if ((PduHeaders.MESSAGE_TYPE_SEND_REQ == messageType) ||
- (PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF == messageType)) {
- /* need to parse the parts */
- mBody = parseParts(mPduDataStream);
- if (null == mBody) {
- // Parse parts failed.
- return null;
- }
- }
-
- switch (messageType) {
- case PduHeaders.MESSAGE_TYPE_SEND_REQ:
- SendReq sendReq = new SendReq(mHeaders, mBody);
- return sendReq;
- case PduHeaders.MESSAGE_TYPE_SEND_CONF:
- SendConf sendConf = new SendConf(mHeaders);
- return sendConf;
- case PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND:
- NotificationInd notificationInd =
- new NotificationInd(mHeaders);
- return notificationInd;
- case PduHeaders.MESSAGE_TYPE_NOTIFYRESP_IND:
- NotifyRespInd notifyRespInd =
- new NotifyRespInd(mHeaders);
- return notifyRespInd;
- case PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF:
- RetrieveConf retrieveConf =
- new RetrieveConf(mHeaders, mBody);
-
- byte[] contentType = retrieveConf.getContentType();
- if (null == contentType) {
- return null;
- }
- String ctTypeStr = new String(contentType);
- if (ctTypeStr.equals(ContentType.MULTIPART_MIXED)
- || ctTypeStr.equals(ContentType.MULTIPART_RELATED)
- || ctTypeStr.equals(ContentType.MULTIPART_ALTERNATIVE)) {
- // The MMS content type must be "application/vnd.wap.multipart.mixed"
- // or "application/vnd.wap.multipart.related"
- // or "application/vnd.wap.multipart.alternative"
- return retrieveConf;
- } else if (ctTypeStr.equals(ContentType.MULTIPART_ALTERNATIVE)) {
- // "application/vnd.wap.multipart.alternative"
- // should take only the first part.
- PduPart firstPart = mBody.getPart(0);
- mBody.removeAll();
- mBody.addPart(0, firstPart);
- return retrieveConf;
- }
- return null;
- case PduHeaders.MESSAGE_TYPE_DELIVERY_IND:
- DeliveryInd deliveryInd =
- new DeliveryInd(mHeaders);
- return deliveryInd;
- case PduHeaders.MESSAGE_TYPE_ACKNOWLEDGE_IND:
- AcknowledgeInd acknowledgeInd =
- new AcknowledgeInd(mHeaders);
- return acknowledgeInd;
- case PduHeaders.MESSAGE_TYPE_READ_ORIG_IND:
- ReadOrigInd readOrigInd =
- new ReadOrigInd(mHeaders);
- return readOrigInd;
- case PduHeaders.MESSAGE_TYPE_READ_REC_IND:
- ReadRecInd readRecInd =
- new ReadRecInd(mHeaders);
- return readRecInd;
- default:
- log("Parser doesn't support this message type in this version!");
- return null;
- }
- }
-
- /**
- * Parse pdu headers.
- *
- * @param pduDataStream pdu data input stream
- * @return headers in PduHeaders structure, null when parse fail
- */
- protected PduHeaders parseHeaders(ByteArrayInputStream pduDataStream){
- if (pduDataStream == null) {
- return null;
- }
-
- boolean keepParsing = true;
- PduHeaders headers = new PduHeaders();
-
- while (keepParsing && (pduDataStream.available() > 0)) {
- pduDataStream.mark(1);
- int headerField = extractByteValue(pduDataStream);
- /* parse custom text header */
- if ((headerField >= TEXT_MIN) && (headerField <= TEXT_MAX)) {
- pduDataStream.reset();
- byte [] bVal = parseWapString(pduDataStream, TYPE_TEXT_STRING);
- if (LOCAL_LOGV) {
- Log.v(LOG_TAG, "TextHeader: " + new String(bVal));
- }
- /* we should ignore it at the moment */
- continue;
- }
- switch (headerField) {
- case PduHeaders.MESSAGE_TYPE:
- {
- int messageType = extractByteValue(pduDataStream);
- switch (messageType) {
- // We don't support these kind of messages now.
- case PduHeaders.MESSAGE_TYPE_FORWARD_REQ:
- case PduHeaders.MESSAGE_TYPE_FORWARD_CONF:
- case PduHeaders.MESSAGE_TYPE_MBOX_STORE_REQ:
- case PduHeaders.MESSAGE_TYPE_MBOX_STORE_CONF:
- case PduHeaders.MESSAGE_TYPE_MBOX_VIEW_REQ:
- case PduHeaders.MESSAGE_TYPE_MBOX_VIEW_CONF:
- case PduHeaders.MESSAGE_TYPE_MBOX_UPLOAD_REQ:
- case PduHeaders.MESSAGE_TYPE_MBOX_UPLOAD_CONF:
- case PduHeaders.MESSAGE_TYPE_MBOX_DELETE_REQ:
- case PduHeaders.MESSAGE_TYPE_MBOX_DELETE_CONF:
- case PduHeaders.MESSAGE_TYPE_MBOX_DESCR:
- case PduHeaders.MESSAGE_TYPE_DELETE_REQ:
- case PduHeaders.MESSAGE_TYPE_DELETE_CONF:
- case PduHeaders.MESSAGE_TYPE_CANCEL_REQ:
- case PduHeaders.MESSAGE_TYPE_CANCEL_CONF:
- return null;
- }
- try {
- headers.setOctet(messageType, headerField);
- } catch(InvalidHeaderValueException e) {
- log("Set invalid Octet value: " + messageType +
- " into the header filed: " + headerField);
- return null;
- } catch(RuntimeException e) {
- log(headerField + "is not Octet header field!");
- return null;
- }
- break;
- }
- /* Octect value */
- case PduHeaders.REPORT_ALLOWED:
- case PduHeaders.ADAPTATION_ALLOWED:
- case PduHeaders.DELIVERY_REPORT:
- case PduHeaders.DRM_CONTENT:
- case PduHeaders.DISTRIBUTION_INDICATOR:
- case PduHeaders.QUOTAS:
- case PduHeaders.READ_REPORT:
- case PduHeaders.STORE:
- case PduHeaders.STORED:
- case PduHeaders.TOTALS:
- case PduHeaders.SENDER_VISIBILITY:
- case PduHeaders.READ_STATUS:
- case PduHeaders.CANCEL_STATUS:
- case PduHeaders.PRIORITY:
- case PduHeaders.STATUS:
- case PduHeaders.REPLY_CHARGING:
- case PduHeaders.MM_STATE:
- case PduHeaders.RECOMMENDED_RETRIEVAL_MODE:
- case PduHeaders.CONTENT_CLASS:
- case PduHeaders.RETRIEVE_STATUS:
- case PduHeaders.STORE_STATUS:
- /**
- * The following field has a different value when
- * used in the M-Mbox-Delete.conf and M-Delete.conf PDU.
- * For now we ignore this fact, since we do not support these PDUs
- */
- case PduHeaders.RESPONSE_STATUS:
- {
- int value = extractByteValue(pduDataStream);
-
- try {
- headers.setOctet(value, headerField);
- } catch(InvalidHeaderValueException e) {
- log("Set invalid Octet value: " + value +
- " into the header filed: " + headerField);
- return null;
- } catch(RuntimeException e) {
- log(headerField + "is not Octet header field!");
- return null;
- }
- break;
- }
-
- /* Long-Integer */
- case PduHeaders.DATE:
- case PduHeaders.REPLY_CHARGING_SIZE:
- case PduHeaders.MESSAGE_SIZE:
- {
- try {
- long value = parseLongInteger(pduDataStream);
- headers.setLongInteger(value, headerField);
- } catch(RuntimeException e) {
- log(headerField + "is not Long-Integer header field!");
- return null;
- }
- break;
- }
-
- /* Integer-Value */
- case PduHeaders.MESSAGE_COUNT:
- case PduHeaders.START:
- case PduHeaders.LIMIT:
- {
- try {
- long value = parseIntegerValue(pduDataStream);
- headers.setLongInteger(value, headerField);
- } catch(RuntimeException e) {
- log(headerField + "is not Long-Integer header field!");
- return null;
- }
- break;
- }
-
- /* Text-String */
- case PduHeaders.TRANSACTION_ID:
- case PduHeaders.REPLY_CHARGING_ID:
- case PduHeaders.AUX_APPLIC_ID:
- case PduHeaders.APPLIC_ID:
- case PduHeaders.REPLY_APPLIC_ID:
- /**
- * The next three header fields are email addresses
- * as defined in RFC2822,
- * not including the characters "<" and ">"
- */
- case PduHeaders.MESSAGE_ID:
- case PduHeaders.REPLACE_ID:
- case PduHeaders.CANCEL_ID:
- /**
- * The following field has a different value when
- * used in the M-Mbox-Delete.conf and M-Delete.conf PDU.
- * For now we ignore this fact, since we do not support these PDUs
- */
- case PduHeaders.CONTENT_LOCATION:
- {
- byte[] value = parseWapString(pduDataStream, TYPE_TEXT_STRING);
- if (null != value) {
- try {
- headers.setTextString(value, headerField);
- } catch(NullPointerException e) {
- log("null pointer error!");
- } catch(RuntimeException e) {
- log(headerField + "is not Text-String header field!");
- return null;
- }
- }
- break;
- }
-
- /* Encoded-string-value */
- case PduHeaders.SUBJECT:
- case PduHeaders.RECOMMENDED_RETRIEVAL_MODE_TEXT:
- case PduHeaders.RETRIEVE_TEXT:
- case PduHeaders.STATUS_TEXT:
- case PduHeaders.STORE_STATUS_TEXT:
- /* the next one is not support
- * M-Mbox-Delete.conf and M-Delete.conf now */
- case PduHeaders.RESPONSE_TEXT:
- {
- EncodedStringValue value =
- parseEncodedStringValue(pduDataStream);
- if (null != value) {
- try {
- headers.setEncodedStringValue(value, headerField);
- } catch(NullPointerException e) {
- log("null pointer error!");
- } catch (RuntimeException e) {
- log(headerField + "is not Encoded-String-Value header field!");
- return null;
- }
- }
- break;
- }
-
- /* Addressing model */
- case PduHeaders.BCC:
- case PduHeaders.CC:
- case PduHeaders.TO:
- {
- EncodedStringValue value =
- parseEncodedStringValue(pduDataStream);
- if (null != value) {
- byte[] address = value.getTextString();
- if (null != address) {
- String str = new String(address);
- int endIndex = str.indexOf("/");
- if (endIndex > 0) {
- str = str.substring(0, endIndex);
- }
- try {
- value.setTextString(str.getBytes());
- } catch(NullPointerException e) {
- log("null pointer error!");
- return null;
- }
- }
-
- try {
- headers.appendEncodedStringValue(value, headerField);
- } catch(NullPointerException e) {
- log("null pointer error!");
- } catch(RuntimeException e) {
- log(headerField + "is not Encoded-String-Value header field!");
- return null;
- }
- }
- break;
- }
-
- /* Value-length
- * (Absolute-token Date-value | Relative-token Delta-seconds-value) */
- case PduHeaders.DELIVERY_TIME:
- case PduHeaders.EXPIRY:
- case PduHeaders.REPLY_CHARGING_DEADLINE:
- {
- /* parse Value-length */
- parseValueLength(pduDataStream);
-
- /* Absolute-token or Relative-token */
- int token = extractByteValue(pduDataStream);
-
- /* Date-value or Delta-seconds-value */
- long timeValue;
- try {
- timeValue = parseLongInteger(pduDataStream);
- } catch(RuntimeException e) {
- log(headerField + "is not Long-Integer header field!");
- return null;
- }
- if (PduHeaders.VALUE_RELATIVE_TOKEN == token) {
- /* need to convert the Delta-seconds-value
- * into Date-value */
- timeValue = System.currentTimeMillis()/1000 + timeValue;
- }
-
- try {
- headers.setLongInteger(timeValue, headerField);
- } catch(RuntimeException e) {
- log(headerField + "is not Long-Integer header field!");
- return null;
- }
- break;
- }
-
- case PduHeaders.FROM: {
- /* From-value =
- * Value-length
- * (Address-present-token Encoded-string-value | Insert-address-token)
- */
- EncodedStringValue from = null;
- parseValueLength(pduDataStream); /* parse value-length */
-
- /* Address-present-token or Insert-address-token */
- int fromToken = extractByteValue(pduDataStream);
-
- /* Address-present-token or Insert-address-token */
- if (PduHeaders.FROM_ADDRESS_PRESENT_TOKEN == fromToken) {
- /* Encoded-string-value */
- from = parseEncodedStringValue(pduDataStream);
- if (null != from) {
- byte[] address = from.getTextString();
- if (null != address) {
- String str = new String(address);
- int endIndex = str.indexOf("/");
- if (endIndex > 0) {
- str = str.substring(0, endIndex);
- }
- try {
- from.setTextString(str.getBytes());
- } catch(NullPointerException e) {
- log("null pointer error!");
- return null;
- }
- }
- }
- } else {
- try {
- from = new EncodedStringValue(
- PduHeaders.FROM_INSERT_ADDRESS_TOKEN_STR.getBytes());
- } catch(NullPointerException e) {
- log(headerField + "is not Encoded-String-Value header field!");
- return null;
- }
- }
-
- try {
- headers.setEncodedStringValue(from, PduHeaders.FROM);
- } catch(NullPointerException e) {
- log("null pointer error!");
- } catch(RuntimeException e) {
- log(headerField + "is not Encoded-String-Value header field!");
- return null;
- }
- break;
- }
-
- case PduHeaders.MESSAGE_CLASS: {
- /* Message-class-value = Class-identifier | Token-text */
- pduDataStream.mark(1);
- int messageClass = extractByteValue(pduDataStream);
-
- if (messageClass >= PduHeaders.MESSAGE_CLASS_PERSONAL) {
- /* Class-identifier */
- try {
- if (PduHeaders.MESSAGE_CLASS_PERSONAL == messageClass) {
- headers.setTextString(
- PduHeaders.MESSAGE_CLASS_PERSONAL_STR.getBytes(),
- PduHeaders.MESSAGE_CLASS);
- } else if (PduHeaders.MESSAGE_CLASS_ADVERTISEMENT == messageClass) {
- headers.setTextString(
- PduHeaders.MESSAGE_CLASS_ADVERTISEMENT_STR.getBytes(),
- PduHeaders.MESSAGE_CLASS);
- } else if (PduHeaders.MESSAGE_CLASS_INFORMATIONAL == messageClass) {
- headers.setTextString(
- PduHeaders.MESSAGE_CLASS_INFORMATIONAL_STR.getBytes(),
- PduHeaders.MESSAGE_CLASS);
- } else if (PduHeaders.MESSAGE_CLASS_AUTO == messageClass) {
- headers.setTextString(
- PduHeaders.MESSAGE_CLASS_AUTO_STR.getBytes(),
- PduHeaders.MESSAGE_CLASS);
- }
- } catch(NullPointerException e) {
- log("null pointer error!");
- } catch(RuntimeException e) {
- log(headerField + "is not Text-String header field!");
- return null;
- }
- } else {
- /* Token-text */
- pduDataStream.reset();
- byte[] messageClassString = parseWapString(pduDataStream, TYPE_TEXT_STRING);
- if (null != messageClassString) {
- try {
- headers.setTextString(messageClassString, PduHeaders.MESSAGE_CLASS);
- } catch(NullPointerException e) {
- log("null pointer error!");
- } catch(RuntimeException e) {
- log(headerField + "is not Text-String header field!");
- return null;
- }
- }
- }
- break;
- }
-
- case PduHeaders.MMS_VERSION: {
- int version = parseShortInteger(pduDataStream);
-
- try {
- headers.setOctet(version, PduHeaders.MMS_VERSION);
- } catch(InvalidHeaderValueException e) {
- log("Set invalid Octet value: " + version +
- " into the header filed: " + headerField);
- return null;
- } catch(RuntimeException e) {
- log(headerField + "is not Octet header field!");
- return null;
- }
- break;
- }
-
- case PduHeaders.PREVIOUSLY_SENT_BY: {
- /* Previously-sent-by-value =
- * Value-length Forwarded-count-value Encoded-string-value */
- /* parse value-length */
- parseValueLength(pduDataStream);
-
- /* parse Forwarded-count-value */
- try {
- parseIntegerValue(pduDataStream);
- } catch(RuntimeException e) {
- log(headerField + " is not Integer-Value");
- return null;
- }
-
- /* parse Encoded-string-value */
- EncodedStringValue previouslySentBy =
- parseEncodedStringValue(pduDataStream);
- if (null != previouslySentBy) {
- try {
- headers.setEncodedStringValue(previouslySentBy,
- PduHeaders.PREVIOUSLY_SENT_BY);
- } catch(NullPointerException e) {
- log("null pointer error!");
- } catch(RuntimeException e) {
- log(headerField + "is not Encoded-String-Value header field!");
- return null;
- }
- }
- break;
- }
-
- case PduHeaders.PREVIOUSLY_SENT_DATE: {
- /* Previously-sent-date-value =
- * Value-length Forwarded-count-value Date-value */
- /* parse value-length */
- parseValueLength(pduDataStream);
-
- /* parse Forwarded-count-value */
- try {
- parseIntegerValue(pduDataStream);
- } catch(RuntimeException e) {
- log(headerField + " is not Integer-Value");
- return null;
- }
-
- /* Date-value */
- try {
- long perviouslySentDate = parseLongInteger(pduDataStream);
- headers.setLongInteger(perviouslySentDate,
- PduHeaders.PREVIOUSLY_SENT_DATE);
- } catch(RuntimeException e) {
- log(headerField + "is not Long-Integer header field!");
- return null;
- }
- break;
- }
-
- case PduHeaders.MM_FLAGS: {
- /* MM-flags-value =
- * Value-length
- * ( Add-token | Remove-token | Filter-token )
- * Encoded-string-value
- */
-
- /* parse Value-length */
- parseValueLength(pduDataStream);
-
- /* Add-token | Remove-token | Filter-token */
- extractByteValue(pduDataStream);
-
- /* Encoded-string-value */
- parseEncodedStringValue(pduDataStream);
-
- /* not store this header filed in "headers",
- * because now PduHeaders doesn't support it */
- break;
- }
-
- /* Value-length
- * (Message-total-token | Size-total-token) Integer-Value */
- case PduHeaders.MBOX_TOTALS:
- case PduHeaders.MBOX_QUOTAS:
- {
- /* Value-length */
- parseValueLength(pduDataStream);
-
- /* Message-total-token | Size-total-token */
- extractByteValue(pduDataStream);
-
- /*Integer-Value*/
- try {
- parseIntegerValue(pduDataStream);
- } catch(RuntimeException e) {
- log(headerField + " is not Integer-Value");
- return null;
- }
-
- /* not store these headers filed in "headers",
- because now PduHeaders doesn't support them */
- break;
- }
-
- case PduHeaders.ELEMENT_DESCRIPTOR: {
- parseContentType(pduDataStream, null);
-
- /* not store this header filed in "headers",
- because now PduHeaders doesn't support it */
- break;
- }
-
- case PduHeaders.CONTENT_TYPE: {
- HashMap map =
- new HashMap();
- byte[] contentType =
- parseContentType(pduDataStream, map);
-
- if (null != contentType) {
- try {
- headers.setTextString(contentType, PduHeaders.CONTENT_TYPE);
- } catch(NullPointerException e) {
- log("null pointer error!");
- } catch(RuntimeException e) {
- log(headerField + "is not Text-String header field!");
- return null;
- }
- }
-
- /* get start parameter */
- mStartParam = (byte[]) map.get(PduPart.P_START);
-
- /* get charset parameter */
- mTypeParam= (byte[]) map.get(PduPart.P_TYPE);
-
- keepParsing = false;
- break;
- }
-
- case PduHeaders.CONTENT:
- case PduHeaders.ADDITIONAL_HEADERS:
- case PduHeaders.ATTRIBUTES:
- default: {
- log("Unknown header");
- }
- }
- }
-
- return headers;
- }
-
- /**
- * Parse pdu parts.
- *
- * @param pduDataStream pdu data input stream
- * @return parts in PduBody structure
- */
- protected static PduBody parseParts(ByteArrayInputStream pduDataStream) {
- if (pduDataStream == null) {
- return null;
- }
-
- int count = parseUnsignedInt(pduDataStream); // get the number of parts
- PduBody body = new PduBody();
-
- for (int i = 0 ; i < count ; i++) {
- int headerLength = parseUnsignedInt(pduDataStream);
- int dataLength = parseUnsignedInt(pduDataStream);
- PduPart part = new PduPart();
- int startPos = pduDataStream.available();
- if (startPos <= 0) {
- // Invalid part.
- return null;
- }
-
- /* parse part's content-type */
- HashMap map = new HashMap();
- byte[] contentType = parseContentType(pduDataStream, map);
- if (null != contentType) {
- part.setContentType(contentType);
- } else {
- part.setContentType((PduContentTypes.contentTypes[0]).getBytes()); //"*/*"
- }
-
- /* get name parameter */
- byte[] name = (byte[]) map.get(PduPart.P_NAME);
- if (null != name) {
- part.setName(name);
- }
-
- /* get charset parameter */
- Integer charset = (Integer) map.get(PduPart.P_CHARSET);
- if (null != charset) {
- part.setCharset(charset);
- }
-
- /* parse part's headers */
- int endPos = pduDataStream.available();
- int partHeaderLen = headerLength - (startPos - endPos);
- if (partHeaderLen > 0) {
- if (false == parsePartHeaders(pduDataStream, part, partHeaderLen)) {
- // Parse part header faild.
- return null;
- }
- } else if (partHeaderLen < 0) {
- // Invalid length of content-type.
- return null;
- }
-
- /* FIXME: check content-id, name, filename and content location,
- * if not set anyone of them, generate a default content-location
- */
- if ((null == part.getContentLocation())
- && (null == part.getName())
- && (null == part.getFilename())
- && (null == part.getContentId())) {
- part.setContentLocation(Long.toOctalString(
- System.currentTimeMillis()).getBytes());
- }
-
- /* get part's data */
- if (dataLength > 0) {
- byte[] partData = new byte[dataLength];
- String partContentType = new String(part.getContentType());
- pduDataStream.read(partData, 0, dataLength);
- if (partContentType.equalsIgnoreCase(ContentType.MULTIPART_ALTERNATIVE)) {
- // parse "multipart/vnd.wap.multipart.alternative".
- PduBody childBody = parseParts(new ByteArrayInputStream(partData));
- // take the first part of children.
- part = childBody.getPart(0);
- } else {
- // Check Content-Transfer-Encoding.
- byte[] partDataEncoding = part.getContentTransferEncoding();
- if (null != partDataEncoding) {
- String encoding = new String(partDataEncoding);
- if (encoding.equalsIgnoreCase(PduPart.P_BASE64)) {
- // Decode "base64" into "binary".
- partData = Base64.decodeBase64(partData);
- } else if (encoding.equalsIgnoreCase(PduPart.P_QUOTED_PRINTABLE)) {
- // Decode "quoted-printable" into "binary".
- partData = QuotedPrintable.decodeQuotedPrintable(partData);
- } else {
- // "binary" is the default encoding.
- }
- }
- if (null == partData) {
- log("Decode part data error!");
- return null;
- }
- part.setData(partData);
- }
- }
-
- /* add this part to body */
- if (THE_FIRST_PART == checkPartPosition(part)) {
- /* this is the first part */
- body.addPart(0, part);
- } else {
- /* add the part to the end */
- body.addPart(part);
- }
- }
-
- return body;
- }
-
- /**
- * Log status.
- *
- * @param text log information
- */
- private static void log(String text) {
- if (LOCAL_LOGV) {
- Log.v(LOG_TAG, text);
- }
- }
-
- /**
- * Parse unsigned integer.
- *
- * @param pduDataStream pdu data input stream
- * @return the integer, -1 when failed
- */
- protected static int parseUnsignedInt(ByteArrayInputStream pduDataStream) {
- /**
- * From wap-230-wsp-20010705-a.pdf
- * The maximum size of a uintvar is 32 bits.
- * So it will be encoded in no more than 5 octets.
- */
- assert(null != pduDataStream);
- int result = 0;
- int temp = pduDataStream.read();
- if (temp == -1) {
- return temp;
- }
-
- while((temp & 0x80) != 0) {
- result = result << 7;
- result |= temp & 0x7F;
- temp = pduDataStream.read();
- if (temp == -1) {
- return temp;
- }
- }
-
- result = result << 7;
- result |= temp & 0x7F;
-
- return result;
- }
-
- /**
- * Parse value length.
- *
- * @param pduDataStream pdu data input stream
- * @return the integer
- */
- protected static int parseValueLength(ByteArrayInputStream pduDataStream) {
- /**
- * From wap-230-wsp-20010705-a.pdf
- * Value-length = Short-length | (Length-quote Length)
- * Short-length =
- * Length-quote =
- * Length = Uintvar-integer
- * Uintvar-integer = 1*5 OCTET
- */
- assert(null != pduDataStream);
- int temp = pduDataStream.read();
- assert(-1 != temp);
- int first = temp & 0xFF;
-
- if (first <= SHORT_LENGTH_MAX) {
- return first;
- } else if (first == LENGTH_QUOTE) {
- return parseUnsignedInt(pduDataStream);
- }
-
- throw new RuntimeException ("Value length > LENGTH_QUOTE!");
- }
-
- /**
- * Parse encoded string value.
- *
- * @param pduDataStream pdu data input stream
- * @return the EncodedStringValue
- */
- protected static EncodedStringValue parseEncodedStringValue(ByteArrayInputStream pduDataStream){
- /**
- * From OMA-TS-MMS-ENC-V1_3-20050927-C.pdf
- * Encoded-string-value = Text-string | Value-length Char-set Text-string
- */
- assert(null != pduDataStream);
- pduDataStream.mark(1);
- EncodedStringValue returnValue = null;
- int charset = 0;
- int temp = pduDataStream.read();
- assert(-1 != temp);
- int first = temp & 0xFF;
- if (first == 0) {
- return null; // Blank subject, bail.
- }
-
- pduDataStream.reset();
- if (first < TEXT_MIN) {
- parseValueLength(pduDataStream);
-
- charset = parseShortInteger(pduDataStream); //get the "Charset"
- }
-
- byte[] textString = parseWapString(pduDataStream, TYPE_TEXT_STRING);
-
- try {
- if (0 != charset) {
- returnValue = new EncodedStringValue(charset, textString);
- } else {
- returnValue = new EncodedStringValue(textString);
- }
- } catch(Exception e) {
- return null;
- }
-
- return returnValue;
- }
-
- /**
- * Parse Text-String or Quoted-String.
- *
- * @param pduDataStream pdu data input stream
- * @param stringType TYPE_TEXT_STRING or TYPE_QUOTED_STRING
- * @return the string without End-of-string in byte array
- */
- protected static byte[] parseWapString(ByteArrayInputStream pduDataStream,
- int stringType) {
- assert(null != pduDataStream);
- /**
- * From wap-230-wsp-20010705-a.pdf
- * Text-string = [Quote] *TEXT End-of-string
- * If the first character in the TEXT is in the range of 128-255,
- * a Quote character must precede it.
- * Otherwise the Quote character must be omitted.
- * The Quote is not part of the contents.
- * Quote =
- * End-of-string =
- *
- * Quoted-string = *TEXT End-of-string
- *
- * Token-text = Token End-of-string
- */
-
- // Mark supposed beginning of Text-string
- // We will have to mark again if first char is QUOTE or QUOTED_STRING_FLAG
- pduDataStream.mark(1);
-
- // Check first char
- int temp = pduDataStream.read();
- assert(-1 != temp);
- if ((TYPE_QUOTED_STRING == stringType) &&
- (QUOTED_STRING_FLAG == temp)) {
- // Mark again if QUOTED_STRING_FLAG and ignore it
- pduDataStream.mark(1);
- } else if ((TYPE_TEXT_STRING == stringType) &&
- (QUOTE == temp)) {
- // Mark again if QUOTE and ignore it
- pduDataStream.mark(1);
- } else {
- // Otherwise go back to origin
- pduDataStream.reset();
- }
-
- // We are now definitely at the beginning of string
- /**
- * Return *TOKEN or *TEXT (Text-String without QUOTE,
- * Quoted-String without QUOTED_STRING_FLAG and without End-of-string)
- */
- return getWapString(pduDataStream, stringType);
- }
-
- /**
- * Check TOKEN data defined in RFC2616.
- * @param ch checking data
- * @return true when ch is TOKEN, false when ch is not TOKEN
- */
- protected static boolean isTokenCharacter(int ch) {
- /**
- * Token = 1*
- * separators = "("(40) | ")"(41) | "<"(60) | ">"(62) | "@"(64)
- * | ","(44) | ";"(59) | ":"(58) | "\"(92) | <">(34)
- * | "/"(47) | "["(91) | "]"(93) | "?"(63) | "="(61)
- * | "{"(123) | "}"(125) | SP(32) | HT(9)
- * CHAR =
- * CTL =
- * SP =
- * HT =
- */
- if((ch < 33) || (ch > 126)) {
- return false;
- }
-
- switch(ch) {
- case '"': /* '"' */
- case '(': /* '(' */
- case ')': /* ')' */
- case ',': /* ',' */
- case '/': /* '/' */
- case ':': /* ':' */
- case ';': /* ';' */
- case '<': /* '<' */
- case '=': /* '=' */
- case '>': /* '>' */
- case '?': /* '?' */
- case '@': /* '@' */
- case '[': /* '[' */
- case '\\': /* '\' */
- case ']': /* ']' */
- case '{': /* '{' */
- case '}': /* '}' */
- return false;
- }
-
- return true;
- }
-
- /**
- * Check TEXT data defined in RFC2616.
- * @param ch checking data
- * @return true when ch is TEXT, false when ch is not TEXT
- */
- protected static boolean isText(int ch) {
- /**
- * TEXT =
- * CTL =
- * LWS = [CRLF] 1*( SP | HT )
- * CRLF = CR LF
- * CR =
- * LF =
- */
- if(((ch >= 32) && (ch <= 126)) || ((ch >= 128) && (ch <= 255))) {
- return true;
- }
-
- switch(ch) {
- case '\t': /* '\t' */
- case '\n': /* '\n' */
- case '\r': /* '\r' */
- return true;
- }
-
- return false;
- }
-
- protected static byte[] getWapString(ByteArrayInputStream pduDataStream,
- int stringType) {
- assert(null != pduDataStream);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- int temp = pduDataStream.read();
- assert(-1 != temp);
- while((-1 != temp) && ('\0' != temp)) {
- // check each of the character
- if (stringType == TYPE_TOKEN_STRING) {
- if (isTokenCharacter(temp)) {
- out.write(temp);
- }
- } else {
- if (isText(temp)) {
- out.write(temp);
- }
- }
-
- temp = pduDataStream.read();
- assert(-1 != temp);
- }
-
- if (out.size() > 0) {
- return out.toByteArray();
- }
-
- return null;
- }
-
- /**
- * Extract a byte value from the input stream.
- *
- * @param pduDataStream pdu data input stream
- * @return the byte
- */
- protected static int extractByteValue(ByteArrayInputStream pduDataStream) {
- assert(null != pduDataStream);
- int temp = pduDataStream.read();
- assert(-1 != temp);
- return temp & 0xFF;
- }
-
- /**
- * Parse Short-Integer.
- *
- * @param pduDataStream pdu data input stream
- * @return the byte
- */
- protected static int parseShortInteger(ByteArrayInputStream pduDataStream) {
- /**
- * From wap-230-wsp-20010705-a.pdf
- * Short-integer = OCTET
- * Integers in range 0-127 shall be encoded as a one
- * octet value with the most significant bit set to one (1xxx xxxx)
- * and with the value in the remaining least significant bits.
- */
- assert(null != pduDataStream);
- int temp = pduDataStream.read();
- assert(-1 != temp);
- return temp & 0x7F;
- }
-
- /**
- * Parse Long-Integer.
- *
- * @param pduDataStream pdu data input stream
- * @return long integer
- */
- protected static long parseLongInteger(ByteArrayInputStream pduDataStream) {
- /**
- * From wap-230-wsp-20010705-a.pdf
- * Long-integer = Short-length Multi-octet-integer
- * The Short-length indicates the length of the Multi-octet-integer
- * Multi-octet-integer = 1*30 OCTET
- * The content octets shall be an unsigned integer value
- * with the most significant octet encoded first (big-endian representation).
- * The minimum number of octets must be used to encode the value.
- * Short-length =
- */
- assert(null != pduDataStream);
- int temp = pduDataStream.read();
- assert(-1 != temp);
- int count = temp & 0xFF;
-
- if (count > LONG_INTEGER_LENGTH_MAX) {
- throw new RuntimeException("Octet count greater than 8 and I can't represent that!");
- }
-
- long result = 0;
-
- for (int i = 0 ; i < count ; i++) {
- temp = pduDataStream.read();
- assert(-1 != temp);
- result <<= 8;
- result += (temp & 0xFF);
- }
-
- return result;
- }
-
- /**
- * Parse Integer-Value.
- *
- * @param pduDataStream pdu data input stream
- * @return long integer
- */
- protected static long parseIntegerValue(ByteArrayInputStream pduDataStream) {
- /**
- * From wap-230-wsp-20010705-a.pdf
- * Integer-Value = Short-integer | Long-integer
- */
- assert(null != pduDataStream);
- pduDataStream.mark(1);
- int temp = pduDataStream.read();
- assert(-1 != temp);
- pduDataStream.reset();
- if (temp > SHORT_INTEGER_MAX) {
- return parseShortInteger(pduDataStream);
- } else {
- return parseLongInteger(pduDataStream);
- }
- }
-
- /**
- * To skip length of the wap value.
- *
- * @param pduDataStream pdu data input stream
- * @param length area size
- * @return the values in this area
- */
- protected static int skipWapValue(ByteArrayInputStream pduDataStream, int length) {
- assert(null != pduDataStream);
- byte[] area = new byte[length];
- int readLen = pduDataStream.read(area, 0, length);
- if (readLen < length) { //The actually read length is lower than the length
- return -1;
- } else {
- return readLen;
- }
- }
-
- /**
- * Parse content type parameters. For now we just support
- * four parameters used in mms: "type", "start", "name", "charset".
- *
- * @param pduDataStream pdu data input stream
- * @param map to store parameters of Content-Type field
- * @param length length of all the parameters
- */
- protected static void parseContentTypeParams(ByteArrayInputStream pduDataStream,
- HashMap map, Integer length) {
- /**
- * From wap-230-wsp-20010705-a.pdf
- * Parameter = Typed-parameter | Untyped-parameter
- * Typed-parameter = Well-known-parameter-token Typed-value
- * the actual expected type of the value is implied by the well-known parameter
- * Well-known-parameter-token = Integer-value
- * the code values used for parameters are specified in the Assigned Numbers appendix
- * Typed-value = Compact-value | Text-value
- * In addition to the expected type, there may be no value.
- * If the value cannot be encoded using the expected type, it shall be encoded as text.
- * Compact-value = Integer-value |
- * Date-value | Delta-seconds-value | Q-value | Version-value |
- * Uri-value
- * Untyped-parameter = Token-text Untyped-value
- * the type of the value is unknown, but it shall be encoded as an integer,
- * if that is possible.
- * Untyped-value = Integer-value | Text-value
- */
- assert(null != pduDataStream);
- assert(length > 0);
-
- int startPos = pduDataStream.available();
- int tempPos = 0;
- int lastLen = length;
- while(0 < lastLen) {
- int param = pduDataStream.read();
- assert(-1 != param);
- lastLen--;
-
- switch (param) {
- /**
- * From rfc2387, chapter 3.1
- * The type parameter must be specified and its value is the MIME media
- * type of the "root" body part. It permits a MIME user agent to
- * determine the content-type without reference to the enclosed body
- * part. If the value of the type parameter and the root body part's
- * content-type differ then the User Agent's behavior is undefined.
- *
- * From wap-230-wsp-20010705-a.pdf
- * type = Constrained-encoding
- * Constrained-encoding = Extension-Media | Short-integer
- * Extension-media = *TEXT End-of-string
- */
- case PduPart.P_TYPE:
- case PduPart.P_CT_MR_TYPE:
- pduDataStream.mark(1);
- int first = extractByteValue(pduDataStream);
- pduDataStream.reset();
- if (first > TEXT_MAX) {
- // Short-integer (well-known type)
- int index = parseShortInteger(pduDataStream);
-
- if (index < PduContentTypes.contentTypes.length) {
- byte[] type = (PduContentTypes.contentTypes[index]).getBytes();
- map.put(PduPart.P_TYPE, type);
- } else {
- //not support this type, ignore it.
- }
- } else {
- // Text-String (extension-media)
- byte[] type = parseWapString(pduDataStream, TYPE_TEXT_STRING);
- if ((null != type) && (null != map)) {
- map.put(PduPart.P_TYPE, type);
- }
- }
-
- tempPos = pduDataStream.available();
- lastLen = length - (startPos - tempPos);
- break;
-
- /**
- * From oma-ts-mms-conf-v1_3.pdf, chapter 10.2.3.
- * Start Parameter Referring to Presentation
- *
- * From rfc2387, chapter 3.2
- * The start parameter, if given, is the content-ID of the compound
- * object's "root". If not present the "root" is the first body part in
- * the Multipart/Related entity. The "root" is the element the
- * applications processes first.
- *
- * From wap-230-wsp-20010705-a.pdf
- * start = Text-String
- */
- case PduPart.P_START:
- case PduPart.P_DEP_START:
- byte[] start = parseWapString(pduDataStream, TYPE_TEXT_STRING);
- if ((null != start) && (null != map)) {
- map.put(PduPart.P_START, start);
- }
-
- tempPos = pduDataStream.available();
- lastLen = length - (startPos - tempPos);
- break;
-
- /**
- * From oma-ts-mms-conf-v1_3.pdf
- * In creation, the character set SHALL be either us-ascii
- * (IANA MIBenum 3) or utf-8 (IANA MIBenum 106)[Unicode].
- * In retrieval, both us-ascii and utf-8 SHALL be supported.
- *
- * From wap-230-wsp-20010705-a.pdf
- * charset = Well-known-charset|Text-String
- * Well-known-charset = Any-charset | Integer-value
- * Both are encoded using values from Character Set
- * Assignments table in Assigned Numbers
- * Any-charset =
- * Equivalent to the special RFC2616 charset value "*"
- */
- case PduPart.P_CHARSET:
- pduDataStream.mark(1);
- int firstValue = extractByteValue(pduDataStream);
- pduDataStream.reset();
- //Check first char
- if (((firstValue > TEXT_MIN) && (firstValue < TEXT_MAX)) ||
- (END_STRING_FLAG == firstValue)) {
- //Text-String (extension-charset)
- byte[] charsetStr = parseWapString(pduDataStream, TYPE_TEXT_STRING);
- try {
- int charsetInt = CharacterSets.getMibEnumValue(
- new String(charsetStr));
- map.put(PduPart.P_CHARSET, charsetInt);
- } catch (UnsupportedEncodingException e) {
- // Not a well-known charset, use "*".
- Log.e(LOG_TAG, Arrays.toString(charsetStr), e);
- map.put(PduPart.P_CHARSET, CharacterSets.ANY_CHARSET);
- }
- } else {
- //Well-known-charset
- int charset = (int) parseIntegerValue(pduDataStream);
- if (map != null) {
- map.put(PduPart.P_CHARSET, charset);
- }
- }
-
- tempPos = pduDataStream.available();
- lastLen = length - (startPos - tempPos);
- break;
-
- /**
- * From oma-ts-mms-conf-v1_3.pdf
- * A name for multipart object SHALL be encoded using name-parameter
- * for Content-Type header in WSP multipart headers.
- *
- * From wap-230-wsp-20010705-a.pdf
- * name = Text-String
- */
- case PduPart.P_DEP_NAME:
- case PduPart.P_NAME:
- byte[] name = parseWapString(pduDataStream, TYPE_TEXT_STRING);
- if ((null != name) && (null != map)) {
- map.put(PduPart.P_NAME, name);
- }
-
- tempPos = pduDataStream.available();
- lastLen = length - (startPos - tempPos);
- break;
- default:
- if (LOCAL_LOGV) {
- Log.v(LOG_TAG, "Not supported Content-Type parameter");
- }
- if (-1 == skipWapValue(pduDataStream, lastLen)) {
- Log.e(LOG_TAG, "Corrupt Content-Type");
- } else {
- lastLen = 0;
- }
- break;
- }
- }
-
- if (0 != lastLen) {
- Log.e(LOG_TAG, "Corrupt Content-Type");
- }
- }
-
- /**
- * Parse content type.
- *
- * @param pduDataStream pdu data input stream
- * @param map to store parameters in Content-Type header field
- * @return Content-Type value
- */
- protected static byte[] parseContentType(ByteArrayInputStream pduDataStream,
- HashMap map) {
- /**
- * From wap-230-wsp-20010705-a.pdf
- * Content-type-value = Constrained-media | Content-general-form
- * Content-general-form = Value-length Media-type
- * Media-type = (Well-known-media | Extension-Media) *(Parameter)
- */
- assert(null != pduDataStream);
-
- byte[] contentType = null;
- pduDataStream.mark(1);
- int temp = pduDataStream.read();
- assert(-1 != temp);
- pduDataStream.reset();
-
- int cur = (temp & 0xFF);
-
- if (cur < TEXT_MIN) {
- int length = parseValueLength(pduDataStream);
- int startPos = pduDataStream.available();
- pduDataStream.mark(1);
- temp = pduDataStream.read();
- assert(-1 != temp);
- pduDataStream.reset();
- int first = (temp & 0xFF);
-
- if ((first >= TEXT_MIN) && (first <= TEXT_MAX)) {
- contentType = parseWapString(pduDataStream, TYPE_TEXT_STRING);
- } else if (first > TEXT_MAX) {
- int index = parseShortInteger(pduDataStream);
-
- if (index < PduContentTypes.contentTypes.length) { //well-known type
- contentType = (PduContentTypes.contentTypes[index]).getBytes();
- } else {
- pduDataStream.reset();
- contentType = parseWapString(pduDataStream, TYPE_TEXT_STRING);
- }
- } else {
- Log.e(LOG_TAG, "Corrupt content-type");
- return (PduContentTypes.contentTypes[0]).getBytes(); //"*/*"
- }
-
- int endPos = pduDataStream.available();
- int parameterLen = length - (startPos - endPos);
- if (parameterLen > 0) {//have parameters
- parseContentTypeParams(pduDataStream, map, parameterLen);
- }
-
- if (parameterLen < 0) {
- Log.e(LOG_TAG, "Corrupt MMS message");
- return (PduContentTypes.contentTypes[0]).getBytes(); //"*/*"
- }
- } else if (cur <= TEXT_MAX) {
- contentType = parseWapString(pduDataStream, TYPE_TEXT_STRING);
- } else {
- contentType =
- (PduContentTypes.contentTypes[parseShortInteger(pduDataStream)]).getBytes();
- }
-
- return contentType;
- }
-
- /**
- * Parse part's headers.
- *
- * @param pduDataStream pdu data input stream
- * @param part to store the header informations of the part
- * @param length length of the headers
- * @return true if parse successfully, false otherwise
- */
- protected static boolean parsePartHeaders(ByteArrayInputStream pduDataStream,
- PduPart part, int length) {
- assert(null != pduDataStream);
- assert(null != part);
- assert(length > 0);
-
- /**
- * From oma-ts-mms-conf-v1_3.pdf, chapter 10.2.
- * A name for multipart object SHALL be encoded using name-parameter
- * for Content-Type header in WSP multipart headers.
- * In decoding, name-parameter of Content-Type SHALL be used if available.
- * If name-parameter of Content-Type is not available,
- * filename parameter of Content-Disposition header SHALL be used if available.
- * If neither name-parameter of Content-Type header nor filename parameter
- * of Content-Disposition header is available,
- * Content-Location header SHALL be used if available.
- *
- * Within SMIL part the reference to the media object parts SHALL use
- * either Content-ID or Content-Location mechanism [RFC2557]
- * and the corresponding WSP part headers in media object parts
- * contain the corresponding definitions.
- */
- int startPos = pduDataStream.available();
- int tempPos = 0;
- int lastLen = length;
- while(0 < lastLen) {
- int header = pduDataStream.read();
- assert(-1 != header);
- lastLen--;
-
- if (header > TEXT_MAX) {
- // Number assigned headers.
- switch (header) {
- case PduPart.P_CONTENT_LOCATION:
- /**
- * From wap-230-wsp-20010705-a.pdf, chapter 8.4.2.21
- * Content-location-value = Uri-value
- */
- byte[] contentLocation = parseWapString(pduDataStream, TYPE_TEXT_STRING);
- if (null != contentLocation) {
- part.setContentLocation(contentLocation);
- }
-
- tempPos = pduDataStream.available();
- lastLen = length - (startPos - tempPos);
- break;
- case PduPart.P_CONTENT_ID:
- /**
- * From wap-230-wsp-20010705-a.pdf, chapter 8.4.2.21
- * Content-ID-value = Quoted-string
- */
- byte[] contentId = parseWapString(pduDataStream, TYPE_QUOTED_STRING);
- if (null != contentId) {
- part.setContentId(contentId);
- }
-
- tempPos = pduDataStream.available();
- lastLen = length - (startPos - tempPos);
- break;
- case PduPart.P_DEP_CONTENT_DISPOSITION:
- case PduPart.P_CONTENT_DISPOSITION:
- /**
- * From wap-230-wsp-20010705-a.pdf, chapter 8.4.2.21
- * Content-disposition-value = Value-length Disposition *(Parameter)
- * Disposition = Form-data | Attachment | Inline | Token-text
- * Form-data =
- * Attachment =
- * Inline =
- */
-
- /*
- * some carrier mmsc servers do not support content_disposition
- * field correctly
- */
- boolean contentDisposition = Resources.getSystem().getBoolean(com
- .android.internal.R.bool.config_mms_content_disposition_support);
-
- if (contentDisposition) {
- int len = parseValueLength(pduDataStream);
- pduDataStream.mark(1);
- int thisStartPos = pduDataStream.available();
- int thisEndPos = 0;
- int value = pduDataStream.read();
-
- if (value == PduPart.P_DISPOSITION_FROM_DATA ) {
- part.setContentDisposition(PduPart.DISPOSITION_FROM_DATA);
- } else if (value == PduPart.P_DISPOSITION_ATTACHMENT) {
- part.setContentDisposition(PduPart.DISPOSITION_ATTACHMENT);
- } else if (value == PduPart.P_DISPOSITION_INLINE) {
- part.setContentDisposition(PduPart.DISPOSITION_INLINE);
- } else {
- pduDataStream.reset();
- /* Token-text */
- part.setContentDisposition(parseWapString(pduDataStream
- , TYPE_TEXT_STRING));
- }
-
- /* get filename parameter and skip other parameters */
- thisEndPos = pduDataStream.available();
- if (thisStartPos - thisEndPos < len) {
- value = pduDataStream.read();
- if (value == PduPart.P_FILENAME) { //filename is text-string
- part.setFilename(parseWapString(pduDataStream
- , TYPE_TEXT_STRING));
- }
-
- /* skip other parameters */
- thisEndPos = pduDataStream.available();
- if (thisStartPos - thisEndPos < len) {
- int last = len - (thisStartPos - thisEndPos);
- byte[] temp = new byte[last];
- pduDataStream.read(temp, 0, last);
- }
- }
-
- tempPos = pduDataStream.available();
- lastLen = length - (startPos - tempPos);
- }
- break;
- default:
- if (LOCAL_LOGV) {
- Log.v(LOG_TAG, "Not supported Part headers: " + header);
- }
- if (-1 == skipWapValue(pduDataStream, lastLen)) {
- Log.e(LOG_TAG, "Corrupt Part headers");
- return false;
- }
- lastLen = 0;
- break;
- }
- } else if ((header >= TEXT_MIN) && (header <= TEXT_MAX)) {
- // Not assigned header.
- byte[] tempHeader = parseWapString(pduDataStream, TYPE_TEXT_STRING);
- byte[] tempValue = parseWapString(pduDataStream, TYPE_TEXT_STRING);
-
- // Check the header whether it is "Content-Transfer-Encoding".
- if (true ==
- PduPart.CONTENT_TRANSFER_ENCODING.equalsIgnoreCase(new String(tempHeader))) {
- part.setContentTransferEncoding(tempValue);
- }
-
- tempPos = pduDataStream.available();
- lastLen = length - (startPos - tempPos);
- } else {
- if (LOCAL_LOGV) {
- Log.v(LOG_TAG, "Not supported Part headers: " + header);
- }
- // Skip all headers of this part.
- if (-1 == skipWapValue(pduDataStream, lastLen)) {
- Log.e(LOG_TAG, "Corrupt Part headers");
- return false;
- }
- lastLen = 0;
- }
- }
-
- if (0 != lastLen) {
- Log.e(LOG_TAG, "Corrupt Part headers");
- return false;
- }
-
- return true;
- }
-
- /**
- * Check the position of a specified part.
- *
- * @param part the part to be checked
- * @return part position, THE_FIRST_PART when it's the
- * first one, THE_LAST_PART when it's the last one.
- */
- private static int checkPartPosition(PduPart part) {
- assert(null != part);
- if ((null == mTypeParam) &&
- (null == mStartParam)) {
- return THE_LAST_PART;
- }
-
- /* check part's content-id */
- if (null != mStartParam) {
- byte[] contentId = part.getContentId();
- if (null != contentId) {
- if (true == Arrays.equals(mStartParam, contentId)) {
- return THE_FIRST_PART;
- }
- }
- }
-
- /* check part's content-type */
- if (null != mTypeParam) {
- byte[] contentType = part.getContentType();
- if (null != contentType) {
- if (true == Arrays.equals(mTypeParam, contentType)) {
- return THE_FIRST_PART;
- }
- }
- }
-
- return THE_LAST_PART;
- }
-
- /**
- * Check mandatory headers of a pdu.
- *
- * @param headers pdu headers
- * @return true if the pdu has all of the mandatory headers, false otherwise.
- */
- protected static boolean checkMandatoryHeader(PduHeaders headers) {
- if (null == headers) {
- return false;
- }
-
- /* get message type */
- int messageType = headers.getOctet(PduHeaders.MESSAGE_TYPE);
-
- /* check Mms-Version field */
- int mmsVersion = headers.getOctet(PduHeaders.MMS_VERSION);
- if (0 == mmsVersion) {
- // Every message should have Mms-Version field.
- return false;
- }
-
- /* check mandatory header fields */
- switch (messageType) {
- case PduHeaders.MESSAGE_TYPE_SEND_REQ:
- // Content-Type field.
- byte[] srContentType = headers.getTextString(PduHeaders.CONTENT_TYPE);
- if (null == srContentType) {
- return false;
- }
-
- // From field.
- EncodedStringValue srFrom = headers.getEncodedStringValue(PduHeaders.FROM);
- if (null == srFrom) {
- return false;
- }
-
- // Transaction-Id field.
- byte[] srTransactionId = headers.getTextString(PduHeaders.TRANSACTION_ID);
- if (null == srTransactionId) {
- return false;
- }
-
- break;
- case PduHeaders.MESSAGE_TYPE_SEND_CONF:
- // Response-Status field.
- int scResponseStatus = headers.getOctet(PduHeaders.RESPONSE_STATUS);
- if (0 == scResponseStatus) {
- return false;
- }
-
- // Transaction-Id field.
- byte[] scTransactionId = headers.getTextString(PduHeaders.TRANSACTION_ID);
- if (null == scTransactionId) {
- return false;
- }
-
- break;
- case PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND:
- // Content-Location field.
- byte[] niContentLocation = headers.getTextString(PduHeaders.CONTENT_LOCATION);
- if (null == niContentLocation) {
- return false;
- }
-
- // Expiry field.
- long niExpiry = headers.getLongInteger(PduHeaders.EXPIRY);
- if (-1 == niExpiry) {
- return false;
- }
-
- // Message-Class field.
- byte[] niMessageClass = headers.getTextString(PduHeaders.MESSAGE_CLASS);
- if (null == niMessageClass) {
- return false;
- }
-
- // Message-Size field.
- long niMessageSize = headers.getLongInteger(PduHeaders.MESSAGE_SIZE);
- if (-1 == niMessageSize) {
- return false;
- }
-
- // Transaction-Id field.
- byte[] niTransactionId = headers.getTextString(PduHeaders.TRANSACTION_ID);
- if (null == niTransactionId) {
- return false;
- }
-
- break;
- case PduHeaders.MESSAGE_TYPE_NOTIFYRESP_IND:
- // Status field.
- int nriStatus = headers.getOctet(PduHeaders.STATUS);
- if (0 == nriStatus) {
- return false;
- }
-
- // Transaction-Id field.
- byte[] nriTransactionId = headers.getTextString(PduHeaders.TRANSACTION_ID);
- if (null == nriTransactionId) {
- return false;
- }
-
- break;
- case PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF:
- // Content-Type field.
- byte[] rcContentType = headers.getTextString(PduHeaders.CONTENT_TYPE);
- if (null == rcContentType) {
- return false;
- }
-
- // Date field.
- long rcDate = headers.getLongInteger(PduHeaders.DATE);
- if (-1 == rcDate) {
- return false;
- }
-
- break;
- case PduHeaders.MESSAGE_TYPE_DELIVERY_IND:
- // Date field.
- long diDate = headers.getLongInteger(PduHeaders.DATE);
- if (-1 == diDate) {
- return false;
- }
-
- // Message-Id field.
- byte[] diMessageId = headers.getTextString(PduHeaders.MESSAGE_ID);
- if (null == diMessageId) {
- return false;
- }
-
- // Status field.
- int diStatus = headers.getOctet(PduHeaders.STATUS);
- if (0 == diStatus) {
- return false;
- }
-
- // To field.
- EncodedStringValue[] diTo = headers.getEncodedStringValues(PduHeaders.TO);
- if (null == diTo) {
- return false;
- }
-
- break;
- case PduHeaders.MESSAGE_TYPE_ACKNOWLEDGE_IND:
- // Transaction-Id field.
- byte[] aiTransactionId = headers.getTextString(PduHeaders.TRANSACTION_ID);
- if (null == aiTransactionId) {
- return false;
- }
-
- break;
- case PduHeaders.MESSAGE_TYPE_READ_ORIG_IND:
- // Date field.
- long roDate = headers.getLongInteger(PduHeaders.DATE);
- if (-1 == roDate) {
- return false;
- }
-
- // From field.
- EncodedStringValue roFrom = headers.getEncodedStringValue(PduHeaders.FROM);
- if (null == roFrom) {
- return false;
- }
-
- // Message-Id field.
- byte[] roMessageId = headers.getTextString(PduHeaders.MESSAGE_ID);
- if (null == roMessageId) {
- return false;
- }
-
- // Read-Status field.
- int roReadStatus = headers.getOctet(PduHeaders.READ_STATUS);
- if (0 == roReadStatus) {
- return false;
- }
-
- // To field.
- EncodedStringValue[] roTo = headers.getEncodedStringValues(PduHeaders.TO);
- if (null == roTo) {
- return false;
- }
-
- break;
- case PduHeaders.MESSAGE_TYPE_READ_REC_IND:
- // From field.
- EncodedStringValue rrFrom = headers.getEncodedStringValue(PduHeaders.FROM);
- if (null == rrFrom) {
- return false;
- }
-
- // Message-Id field.
- byte[] rrMessageId = headers.getTextString(PduHeaders.MESSAGE_ID);
- if (null == rrMessageId) {
- return false;
- }
-
- // Read-Status field.
- int rrReadStatus = headers.getOctet(PduHeaders.READ_STATUS);
- if (0 == rrReadStatus) {
- return false;
- }
-
- // To field.
- EncodedStringValue[] rrTo = headers.getEncodedStringValues(PduHeaders.TO);
- if (null == rrTo) {
- return false;
- }
-
- break;
- default:
- // Parser doesn't support this message type in this version.
- return false;
- }
-
- return true;
- }
-}
diff --git a/core/java/com/google/android/mms/pdu/PduPart.java b/core/java/com/google/android/mms/pdu/PduPart.java
deleted file mode 100644
index b43e388b6517..000000000000
--- a/core/java/com/google/android/mms/pdu/PduPart.java
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * Copyright (C) 2007-2008 Esmertec AG.
- * Copyright (C) 2007-2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import android.net.Uri;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * The pdu part.
- */
-public class PduPart {
- /**
- * Well-Known Parameters.
- */
- public static final int P_Q = 0x80;
- public static final int P_CHARSET = 0x81;
- public static final int P_LEVEL = 0x82;
- public static final int P_TYPE = 0x83;
- public static final int P_DEP_NAME = 0x85;
- public static final int P_DEP_FILENAME = 0x86;
- public static final int P_DIFFERENCES = 0x87;
- public static final int P_PADDING = 0x88;
- // This value of "TYPE" s used with Content-Type: multipart/related
- public static final int P_CT_MR_TYPE = 0x89;
- public static final int P_DEP_START = 0x8A;
- public static final int P_DEP_START_INFO = 0x8B;
- public static final int P_DEP_COMMENT = 0x8C;
- public static final int P_DEP_DOMAIN = 0x8D;
- public static final int P_MAX_AGE = 0x8E;
- public static final int P_DEP_PATH = 0x8F;
- public static final int P_SECURE = 0x90;
- public static final int P_SEC = 0x91;
- public static final int P_MAC = 0x92;
- public static final int P_CREATION_DATE = 0x93;
- public static final int P_MODIFICATION_DATE = 0x94;
- public static final int P_READ_DATE = 0x95;
- public static final int P_SIZE = 0x96;
- public static final int P_NAME = 0x97;
- public static final int P_FILENAME = 0x98;
- public static final int P_START = 0x99;
- public static final int P_START_INFO = 0x9A;
- public static final int P_COMMENT = 0x9B;
- public static final int P_DOMAIN = 0x9C;
- public static final int P_PATH = 0x9D;
-
- /**
- * Header field names.
- */
- public static final int P_CONTENT_TYPE = 0x91;
- public static final int P_CONTENT_LOCATION = 0x8E;
- public static final int P_CONTENT_ID = 0xC0;
- public static final int P_DEP_CONTENT_DISPOSITION = 0xAE;
- public static final int P_CONTENT_DISPOSITION = 0xC5;
- // The next header is unassigned header, use reserved header(0x48) value.
- public static final int P_CONTENT_TRANSFER_ENCODING = 0xC8;
-
- /**
- * Content=Transfer-Encoding string.
- */
- public static final String CONTENT_TRANSFER_ENCODING =
- "Content-Transfer-Encoding";
-
- /**
- * Value of Content-Transfer-Encoding.
- */
- public static final String P_BINARY = "binary";
- public static final String P_7BIT = "7bit";
- public static final String P_8BIT = "8bit";
- public static final String P_BASE64 = "base64";
- public static final String P_QUOTED_PRINTABLE = "quoted-printable";
-
- /**
- * Value of disposition can be set to PduPart when the value is octet in
- * the PDU.
- * "from-data" instead of Form-data.
- * "attachment" instead of Attachment.
- * "inline" instead of Inline.
- */
- static final byte[] DISPOSITION_FROM_DATA = "from-data".getBytes();
- static final byte[] DISPOSITION_ATTACHMENT = "attachment".getBytes();
- static final byte[] DISPOSITION_INLINE = "inline".getBytes();
-
- /**
- * Content-Disposition value.
- */
- public static final int P_DISPOSITION_FROM_DATA = 0x80;
- public static final int P_DISPOSITION_ATTACHMENT = 0x81;
- public static final int P_DISPOSITION_INLINE = 0x82;
-
- /**
- * Header of part.
- */
- private Map mPartHeader = null;
-
- /**
- * Data uri.
- */
- private Uri mUri = null;
-
- /**
- * Part data.
- */
- private byte[] mPartData = null;
-
- private static final String TAG = "PduPart";
-
- /**
- * Empty Constructor.
- */
- public PduPart() {
- mPartHeader = new HashMap();
- }
-
- /**
- * Set part data. The data are stored as byte array.
- *
- * @param data the data
- */
- public void setData(byte[] data) {
- if(data == null) {
- return;
- }
-
- mPartData = new byte[data.length];
- System.arraycopy(data, 0, mPartData, 0, data.length);
- }
-
- /**
- * @return A copy of the part data or null if the data wasn't set or
- * the data is stored as Uri.
- * @see #getDataUri
- */
- public byte[] getData() {
- if(mPartData == null) {
- return null;
- }
-
- byte[] byteArray = new byte[mPartData.length];
- System.arraycopy(mPartData, 0, byteArray, 0, mPartData.length);
- return byteArray;
- }
-
- /**
- * Set data uri. The data are stored as Uri.
- *
- * @param uri the uri
- */
- public void setDataUri(Uri uri) {
- mUri = uri;
- }
-
- /**
- * @return The Uri of the part data or null if the data wasn't set or
- * the data is stored as byte array.
- * @see #getData
- */
- public Uri getDataUri() {
- return mUri;
- }
-
- /**
- * Set Content-id value
- *
- * @param contentId the content-id value
- * @throws NullPointerException if the value is null.
- */
- public void setContentId(byte[] contentId) {
- if((contentId == null) || (contentId.length == 0)) {
- throw new IllegalArgumentException(
- "Content-Id may not be null or empty.");
- }
-
- if ((contentId.length > 1)
- && ((char) contentId[0] == '<')
- && ((char) contentId[contentId.length - 1] == '>')) {
- mPartHeader.put(P_CONTENT_ID, contentId);
- return;
- }
-
- // Insert beginning '<' and trailing '>' for Content-Id.
- byte[] buffer = new byte[contentId.length + 2];
- buffer[0] = (byte) (0xff & '<');
- buffer[buffer.length - 1] = (byte) (0xff & '>');
- System.arraycopy(contentId, 0, buffer, 1, contentId.length);
- mPartHeader.put(P_CONTENT_ID, buffer);
- }
-
- /**
- * Get Content-id value.
- *
- * @return the value
- */
- public byte[] getContentId() {
- return (byte[]) mPartHeader.get(P_CONTENT_ID);
- }
-
- /**
- * Set Char-set value.
- *
- * @param charset the value
- */
- public void setCharset(int charset) {
- mPartHeader.put(P_CHARSET, charset);
- }
-
- /**
- * Get Char-set value
- *
- * @return the charset value. Return 0 if charset was not set.
- */
- public int getCharset() {
- Integer charset = (Integer) mPartHeader.get(P_CHARSET);
- if(charset == null) {
- return 0;
- } else {
- return charset.intValue();
- }
- }
-
- /**
- * Set Content-Location value.
- *
- * @param contentLocation the value
- * @throws NullPointerException if the value is null.
- */
- public void setContentLocation(byte[] contentLocation) {
- if(contentLocation == null) {
- throw new NullPointerException("null content-location");
- }
-
- mPartHeader.put(P_CONTENT_LOCATION, contentLocation);
- }
-
- /**
- * Get Content-Location value.
- *
- * @return the value
- * return PduPart.disposition[0] instead of (Form-data).
- * return PduPart.disposition[1] instead of (Attachment).
- * return PduPart.disposition[2] instead of (Inline).
- */
- public byte[] getContentLocation() {
- return (byte[]) mPartHeader.get(P_CONTENT_LOCATION);
- }
-
- /**
- * Set Content-Disposition value.
- * Use PduPart.disposition[0] instead of (Form-data).
- * Use PduPart.disposition[1] instead of (Attachment).
- * Use PduPart.disposition[2] instead of (Inline).
- *
- * @param contentDisposition the value
- * @throws NullPointerException if the value is null.
- */
- public void setContentDisposition(byte[] contentDisposition) {
- if(contentDisposition == null) {
- throw new NullPointerException("null content-disposition");
- }
-
- mPartHeader.put(P_CONTENT_DISPOSITION, contentDisposition);
- }
-
- /**
- * Get Content-Disposition value.
- *
- * @return the value
- */
- public byte[] getContentDisposition() {
- return (byte[]) mPartHeader.get(P_CONTENT_DISPOSITION);
- }
-
- /**
- * Set Content-Type value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setContentType(byte[] contentType) {
- if(contentType == null) {
- throw new NullPointerException("null content-type");
- }
-
- mPartHeader.put(P_CONTENT_TYPE, contentType);
- }
-
- /**
- * Get Content-Type value of part.
- *
- * @return the value
- */
- public byte[] getContentType() {
- return (byte[]) mPartHeader.get(P_CONTENT_TYPE);
- }
-
- /**
- * Set Content-Transfer-Encoding value
- *
- * @param contentId the content-id value
- * @throws NullPointerException if the value is null.
- */
- public void setContentTransferEncoding(byte[] contentTransferEncoding) {
- if(contentTransferEncoding == null) {
- throw new NullPointerException("null content-transfer-encoding");
- }
-
- mPartHeader.put(P_CONTENT_TRANSFER_ENCODING, contentTransferEncoding);
- }
-
- /**
- * Get Content-Transfer-Encoding value.
- *
- * @return the value
- */
- public byte[] getContentTransferEncoding() {
- return (byte[]) mPartHeader.get(P_CONTENT_TRANSFER_ENCODING);
- }
-
- /**
- * Set Content-type parameter: name.
- *
- * @param name the name value
- * @throws NullPointerException if the value is null.
- */
- public void setName(byte[] name) {
- if(null == name) {
- throw new NullPointerException("null content-id");
- }
-
- mPartHeader.put(P_NAME, name);
- }
-
- /**
- * Get content-type parameter: name.
- *
- * @return the name
- */
- public byte[] getName() {
- return (byte[]) mPartHeader.get(P_NAME);
- }
-
- /**
- * Get Content-disposition parameter: filename
- *
- * @param fileName the filename value
- * @throws NullPointerException if the value is null.
- */
- public void setFilename(byte[] fileName) {
- if(null == fileName) {
- throw new NullPointerException("null content-id");
- }
-
- mPartHeader.put(P_FILENAME, fileName);
- }
-
- /**
- * Set Content-disposition parameter: filename
- *
- * @return the filename
- */
- public byte[] getFilename() {
- return (byte[]) mPartHeader.get(P_FILENAME);
- }
-
- public String generateLocation() {
- // Assumption: At least one of the content-location / name / filename
- // or content-id should be set. This is guaranteed by the PduParser
- // for incoming messages and by MM composer for outgoing messages.
- byte[] location = (byte[]) mPartHeader.get(P_NAME);
- if(null == location) {
- location = (byte[]) mPartHeader.get(P_FILENAME);
-
- if (null == location) {
- location = (byte[]) mPartHeader.get(P_CONTENT_LOCATION);
- }
- }
-
- if (null == location) {
- byte[] contentId = (byte[]) mPartHeader.get(P_CONTENT_ID);
- return "cid:" + new String(contentId);
- } else {
- return new String(location);
- }
- }
-}
-
diff --git a/core/java/com/google/android/mms/pdu/PduPersister.java b/core/java/com/google/android/mms/pdu/PduPersister.java
deleted file mode 100644
index ee285aaba1c8..000000000000
--- a/core/java/com/google/android/mms/pdu/PduPersister.java
+++ /dev/null
@@ -1,1477 +0,0 @@
-/*
- * Copyright (C) 2007-2008 Esmertec AG.
- * Copyright (C) 2007-2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import com.google.android.mms.ContentType;
-import com.google.android.mms.InvalidHeaderValueException;
-import com.google.android.mms.MmsException;
-import com.google.android.mms.util.DownloadDrmHelper;
-import com.google.android.mms.util.DrmConvertSession;
-import com.google.android.mms.util.PduCache;
-import com.google.android.mms.util.PduCacheEntry;
-import com.google.android.mms.util.SqliteWrapper;
-
-import android.content.ContentResolver;
-import android.content.ContentUris;
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.DatabaseUtils;
-import android.database.sqlite.SQLiteException;
-import android.drm.DrmManagerClient;
-import android.net.Uri;
-import android.os.FileUtils;
-import android.provider.MediaStore;
-import android.provider.Telephony;
-import android.provider.Telephony.Mms;
-import android.provider.Telephony.MmsSms;
-import android.provider.Telephony.Threads;
-import android.provider.Telephony.Mms.Addr;
-import android.provider.Telephony.Mms.Part;
-import android.provider.Telephony.MmsSms.PendingMessages;
-import android.text.TextUtils;
-import android.util.Log;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import com.google.android.mms.pdu.EncodedStringValue;
-
-/**
- * This class is the high-level manager of PDU storage.
- */
-public class PduPersister {
- private static final String TAG = "PduPersister";
- private static final boolean DEBUG = false;
- private static final boolean LOCAL_LOGV = false;
-
- private static final long DUMMY_THREAD_ID = Long.MAX_VALUE;
-
- /**
- * The uri of temporary drm objects.
- */
- public static final String TEMPORARY_DRM_OBJECT_URI =
- "content://mms/" + Long.MAX_VALUE + "/part";
- /**
- * Indicate that we transiently failed to process a MM.
- */
- public static final int PROC_STATUS_TRANSIENT_FAILURE = 1;
- /**
- * Indicate that we permanently failed to process a MM.
- */
- public static final int PROC_STATUS_PERMANENTLY_FAILURE = 2;
- /**
- * Indicate that we have successfully processed a MM.
- */
- public static final int PROC_STATUS_COMPLETED = 3;
-
- private static PduPersister sPersister;
- private static final PduCache PDU_CACHE_INSTANCE;
-
- private static final int[] ADDRESS_FIELDS = new int[] {
- PduHeaders.BCC,
- PduHeaders.CC,
- PduHeaders.FROM,
- PduHeaders.TO
- };
-
- private static final String[] PDU_PROJECTION = new String[] {
- Mms._ID,
- Mms.MESSAGE_BOX,
- Mms.THREAD_ID,
- Mms.RETRIEVE_TEXT,
- Mms.SUBJECT,
- Mms.CONTENT_LOCATION,
- Mms.CONTENT_TYPE,
- Mms.MESSAGE_CLASS,
- Mms.MESSAGE_ID,
- Mms.RESPONSE_TEXT,
- Mms.TRANSACTION_ID,
- Mms.CONTENT_CLASS,
- Mms.DELIVERY_REPORT,
- Mms.MESSAGE_TYPE,
- Mms.MMS_VERSION,
- Mms.PRIORITY,
- Mms.READ_REPORT,
- Mms.READ_STATUS,
- Mms.REPORT_ALLOWED,
- Mms.RETRIEVE_STATUS,
- Mms.STATUS,
- Mms.DATE,
- Mms.DELIVERY_TIME,
- Mms.EXPIRY,
- Mms.MESSAGE_SIZE,
- Mms.SUBJECT_CHARSET,
- Mms.RETRIEVE_TEXT_CHARSET,
- };
-
- private static final int PDU_COLUMN_ID = 0;
- private static final int PDU_COLUMN_MESSAGE_BOX = 1;
- private static final int PDU_COLUMN_THREAD_ID = 2;
- private static final int PDU_COLUMN_RETRIEVE_TEXT = 3;
- private static final int PDU_COLUMN_SUBJECT = 4;
- private static final int PDU_COLUMN_CONTENT_LOCATION = 5;
- private static final int PDU_COLUMN_CONTENT_TYPE = 6;
- private static final int PDU_COLUMN_MESSAGE_CLASS = 7;
- private static final int PDU_COLUMN_MESSAGE_ID = 8;
- private static final int PDU_COLUMN_RESPONSE_TEXT = 9;
- private static final int PDU_COLUMN_TRANSACTION_ID = 10;
- private static final int PDU_COLUMN_CONTENT_CLASS = 11;
- private static final int PDU_COLUMN_DELIVERY_REPORT = 12;
- private static final int PDU_COLUMN_MESSAGE_TYPE = 13;
- private static final int PDU_COLUMN_MMS_VERSION = 14;
- private static final int PDU_COLUMN_PRIORITY = 15;
- private static final int PDU_COLUMN_READ_REPORT = 16;
- private static final int PDU_COLUMN_READ_STATUS = 17;
- private static final int PDU_COLUMN_REPORT_ALLOWED = 18;
- private static final int PDU_COLUMN_RETRIEVE_STATUS = 19;
- private static final int PDU_COLUMN_STATUS = 20;
- private static final int PDU_COLUMN_DATE = 21;
- private static final int PDU_COLUMN_DELIVERY_TIME = 22;
- private static final int PDU_COLUMN_EXPIRY = 23;
- private static final int PDU_COLUMN_MESSAGE_SIZE = 24;
- private static final int PDU_COLUMN_SUBJECT_CHARSET = 25;
- private static final int PDU_COLUMN_RETRIEVE_TEXT_CHARSET = 26;
-
- private static final String[] PART_PROJECTION = new String[] {
- Part._ID,
- Part.CHARSET,
- Part.CONTENT_DISPOSITION,
- Part.CONTENT_ID,
- Part.CONTENT_LOCATION,
- Part.CONTENT_TYPE,
- Part.FILENAME,
- Part.NAME,
- Part.TEXT
- };
-
- private static final int PART_COLUMN_ID = 0;
- private static final int PART_COLUMN_CHARSET = 1;
- private static final int PART_COLUMN_CONTENT_DISPOSITION = 2;
- private static final int PART_COLUMN_CONTENT_ID = 3;
- private static final int PART_COLUMN_CONTENT_LOCATION = 4;
- private static final int PART_COLUMN_CONTENT_TYPE = 5;
- private static final int PART_COLUMN_FILENAME = 6;
- private static final int PART_COLUMN_NAME = 7;
- private static final int PART_COLUMN_TEXT = 8;
-
- private static final HashMap MESSAGE_BOX_MAP;
- // These map are used for convenience in persist() and load().
- private static final HashMap CHARSET_COLUMN_INDEX_MAP;
- private static final HashMap ENCODED_STRING_COLUMN_INDEX_MAP;
- private static final HashMap TEXT_STRING_COLUMN_INDEX_MAP;
- private static final HashMap OCTET_COLUMN_INDEX_MAP;
- private static final HashMap LONG_COLUMN_INDEX_MAP;
- private static final HashMap CHARSET_COLUMN_NAME_MAP;
- private static final HashMap ENCODED_STRING_COLUMN_NAME_MAP;
- private static final HashMap TEXT_STRING_COLUMN_NAME_MAP;
- private static final HashMap OCTET_COLUMN_NAME_MAP;
- private static final HashMap LONG_COLUMN_NAME_MAP;
-
- static {
- MESSAGE_BOX_MAP = new HashMap();
- MESSAGE_BOX_MAP.put(Mms.Inbox.CONTENT_URI, Mms.MESSAGE_BOX_INBOX);
- MESSAGE_BOX_MAP.put(Mms.Sent.CONTENT_URI, Mms.MESSAGE_BOX_SENT);
- MESSAGE_BOX_MAP.put(Mms.Draft.CONTENT_URI, Mms.MESSAGE_BOX_DRAFTS);
- MESSAGE_BOX_MAP.put(Mms.Outbox.CONTENT_URI, Mms.MESSAGE_BOX_OUTBOX);
-
- CHARSET_COLUMN_INDEX_MAP = new HashMap();
- CHARSET_COLUMN_INDEX_MAP.put(PduHeaders.SUBJECT, PDU_COLUMN_SUBJECT_CHARSET);
- CHARSET_COLUMN_INDEX_MAP.put(PduHeaders.RETRIEVE_TEXT, PDU_COLUMN_RETRIEVE_TEXT_CHARSET);
-
- CHARSET_COLUMN_NAME_MAP = new HashMap();
- CHARSET_COLUMN_NAME_MAP.put(PduHeaders.SUBJECT, Mms.SUBJECT_CHARSET);
- CHARSET_COLUMN_NAME_MAP.put(PduHeaders.RETRIEVE_TEXT, Mms.RETRIEVE_TEXT_CHARSET);
-
- // Encoded string field code -> column index/name map.
- ENCODED_STRING_COLUMN_INDEX_MAP = new HashMap();
- ENCODED_STRING_COLUMN_INDEX_MAP.put(PduHeaders.RETRIEVE_TEXT, PDU_COLUMN_RETRIEVE_TEXT);
- ENCODED_STRING_COLUMN_INDEX_MAP.put(PduHeaders.SUBJECT, PDU_COLUMN_SUBJECT);
-
- ENCODED_STRING_COLUMN_NAME_MAP = new HashMap();
- ENCODED_STRING_COLUMN_NAME_MAP.put(PduHeaders.RETRIEVE_TEXT, Mms.RETRIEVE_TEXT);
- ENCODED_STRING_COLUMN_NAME_MAP.put(PduHeaders.SUBJECT, Mms.SUBJECT);
-
- // Text string field code -> column index/name map.
- TEXT_STRING_COLUMN_INDEX_MAP = new HashMap();
- TEXT_STRING_COLUMN_INDEX_MAP.put(PduHeaders.CONTENT_LOCATION, PDU_COLUMN_CONTENT_LOCATION);
- TEXT_STRING_COLUMN_INDEX_MAP.put(PduHeaders.CONTENT_TYPE, PDU_COLUMN_CONTENT_TYPE);
- TEXT_STRING_COLUMN_INDEX_MAP.put(PduHeaders.MESSAGE_CLASS, PDU_COLUMN_MESSAGE_CLASS);
- TEXT_STRING_COLUMN_INDEX_MAP.put(PduHeaders.MESSAGE_ID, PDU_COLUMN_MESSAGE_ID);
- TEXT_STRING_COLUMN_INDEX_MAP.put(PduHeaders.RESPONSE_TEXT, PDU_COLUMN_RESPONSE_TEXT);
- TEXT_STRING_COLUMN_INDEX_MAP.put(PduHeaders.TRANSACTION_ID, PDU_COLUMN_TRANSACTION_ID);
-
- TEXT_STRING_COLUMN_NAME_MAP = new HashMap();
- TEXT_STRING_COLUMN_NAME_MAP.put(PduHeaders.CONTENT_LOCATION, Mms.CONTENT_LOCATION);
- TEXT_STRING_COLUMN_NAME_MAP.put(PduHeaders.CONTENT_TYPE, Mms.CONTENT_TYPE);
- TEXT_STRING_COLUMN_NAME_MAP.put(PduHeaders.MESSAGE_CLASS, Mms.MESSAGE_CLASS);
- TEXT_STRING_COLUMN_NAME_MAP.put(PduHeaders.MESSAGE_ID, Mms.MESSAGE_ID);
- TEXT_STRING_COLUMN_NAME_MAP.put(PduHeaders.RESPONSE_TEXT, Mms.RESPONSE_TEXT);
- TEXT_STRING_COLUMN_NAME_MAP.put(PduHeaders.TRANSACTION_ID, Mms.TRANSACTION_ID);
-
- // Octet field code -> column index/name map.
- OCTET_COLUMN_INDEX_MAP = new HashMap();
- OCTET_COLUMN_INDEX_MAP.put(PduHeaders.CONTENT_CLASS, PDU_COLUMN_CONTENT_CLASS);
- OCTET_COLUMN_INDEX_MAP.put(PduHeaders.DELIVERY_REPORT, PDU_COLUMN_DELIVERY_REPORT);
- OCTET_COLUMN_INDEX_MAP.put(PduHeaders.MESSAGE_TYPE, PDU_COLUMN_MESSAGE_TYPE);
- OCTET_COLUMN_INDEX_MAP.put(PduHeaders.MMS_VERSION, PDU_COLUMN_MMS_VERSION);
- OCTET_COLUMN_INDEX_MAP.put(PduHeaders.PRIORITY, PDU_COLUMN_PRIORITY);
- OCTET_COLUMN_INDEX_MAP.put(PduHeaders.READ_REPORT, PDU_COLUMN_READ_REPORT);
- OCTET_COLUMN_INDEX_MAP.put(PduHeaders.READ_STATUS, PDU_COLUMN_READ_STATUS);
- OCTET_COLUMN_INDEX_MAP.put(PduHeaders.REPORT_ALLOWED, PDU_COLUMN_REPORT_ALLOWED);
- OCTET_COLUMN_INDEX_MAP.put(PduHeaders.RETRIEVE_STATUS, PDU_COLUMN_RETRIEVE_STATUS);
- OCTET_COLUMN_INDEX_MAP.put(PduHeaders.STATUS, PDU_COLUMN_STATUS);
-
- OCTET_COLUMN_NAME_MAP = new HashMap();
- OCTET_COLUMN_NAME_MAP.put(PduHeaders.CONTENT_CLASS, Mms.CONTENT_CLASS);
- OCTET_COLUMN_NAME_MAP.put(PduHeaders.DELIVERY_REPORT, Mms.DELIVERY_REPORT);
- OCTET_COLUMN_NAME_MAP.put(PduHeaders.MESSAGE_TYPE, Mms.MESSAGE_TYPE);
- OCTET_COLUMN_NAME_MAP.put(PduHeaders.MMS_VERSION, Mms.MMS_VERSION);
- OCTET_COLUMN_NAME_MAP.put(PduHeaders.PRIORITY, Mms.PRIORITY);
- OCTET_COLUMN_NAME_MAP.put(PduHeaders.READ_REPORT, Mms.READ_REPORT);
- OCTET_COLUMN_NAME_MAP.put(PduHeaders.READ_STATUS, Mms.READ_STATUS);
- OCTET_COLUMN_NAME_MAP.put(PduHeaders.REPORT_ALLOWED, Mms.REPORT_ALLOWED);
- OCTET_COLUMN_NAME_MAP.put(PduHeaders.RETRIEVE_STATUS, Mms.RETRIEVE_STATUS);
- OCTET_COLUMN_NAME_MAP.put(PduHeaders.STATUS, Mms.STATUS);
-
- // Long field code -> column index/name map.
- LONG_COLUMN_INDEX_MAP = new HashMap();
- LONG_COLUMN_INDEX_MAP.put(PduHeaders.DATE, PDU_COLUMN_DATE);
- LONG_COLUMN_INDEX_MAP.put(PduHeaders.DELIVERY_TIME, PDU_COLUMN_DELIVERY_TIME);
- LONG_COLUMN_INDEX_MAP.put(PduHeaders.EXPIRY, PDU_COLUMN_EXPIRY);
- LONG_COLUMN_INDEX_MAP.put(PduHeaders.MESSAGE_SIZE, PDU_COLUMN_MESSAGE_SIZE);
-
- LONG_COLUMN_NAME_MAP = new HashMap();
- LONG_COLUMN_NAME_MAP.put(PduHeaders.DATE, Mms.DATE);
- LONG_COLUMN_NAME_MAP.put(PduHeaders.DELIVERY_TIME, Mms.DELIVERY_TIME);
- LONG_COLUMN_NAME_MAP.put(PduHeaders.EXPIRY, Mms.EXPIRY);
- LONG_COLUMN_NAME_MAP.put(PduHeaders.MESSAGE_SIZE, Mms.MESSAGE_SIZE);
-
- PDU_CACHE_INSTANCE = PduCache.getInstance();
- }
-
- private final Context mContext;
- private final ContentResolver mContentResolver;
- private final DrmManagerClient mDrmManagerClient;
-
- private PduPersister(Context context) {
- mContext = context;
- mContentResolver = context.getContentResolver();
- mDrmManagerClient = new DrmManagerClient(context);
- }
-
- /** Get(or create if not exist) an instance of PduPersister */
- public static PduPersister getPduPersister(Context context) {
- if ((sPersister == null) || !context.equals(sPersister.mContext)) {
- sPersister = new PduPersister(context);
- }
-
- return sPersister;
- }
-
- private void setEncodedStringValueToHeaders(
- Cursor c, int columnIndex,
- PduHeaders headers, int mapColumn) {
- String s = c.getString(columnIndex);
- if ((s != null) && (s.length() > 0)) {
- int charsetColumnIndex = CHARSET_COLUMN_INDEX_MAP.get(mapColumn);
- int charset = c.getInt(charsetColumnIndex);
- EncodedStringValue value = new EncodedStringValue(
- charset, getBytes(s));
- headers.setEncodedStringValue(value, mapColumn);
- }
- }
-
- private void setTextStringToHeaders(
- Cursor c, int columnIndex,
- PduHeaders headers, int mapColumn) {
- String s = c.getString(columnIndex);
- if (s != null) {
- headers.setTextString(getBytes(s), mapColumn);
- }
- }
-
- private void setOctetToHeaders(
- Cursor c, int columnIndex,
- PduHeaders headers, int mapColumn) throws InvalidHeaderValueException {
- if (!c.isNull(columnIndex)) {
- int b = c.getInt(columnIndex);
- headers.setOctet(b, mapColumn);
- }
- }
-
- private void setLongToHeaders(
- Cursor c, int columnIndex,
- PduHeaders headers, int mapColumn) {
- if (!c.isNull(columnIndex)) {
- long l = c.getLong(columnIndex);
- headers.setLongInteger(l, mapColumn);
- }
- }
-
- private Integer getIntegerFromPartColumn(Cursor c, int columnIndex) {
- if (!c.isNull(columnIndex)) {
- return c.getInt(columnIndex);
- }
- return null;
- }
-
- private byte[] getByteArrayFromPartColumn(Cursor c, int columnIndex) {
- if (!c.isNull(columnIndex)) {
- return getBytes(c.getString(columnIndex));
- }
- return null;
- }
-
- private PduPart[] loadParts(long msgId) throws MmsException {
- Cursor c = SqliteWrapper.query(mContext, mContentResolver,
- Uri.parse("content://mms/" + msgId + "/part"),
- PART_PROJECTION, null, null, null);
-
- PduPart[] parts = null;
-
- try {
- if ((c == null) || (c.getCount() == 0)) {
- if (LOCAL_LOGV) {
- Log.v(TAG, "loadParts(" + msgId + "): no part to load.");
- }
- return null;
- }
-
- int partCount = c.getCount();
- int partIdx = 0;
- parts = new PduPart[partCount];
- while (c.moveToNext()) {
- PduPart part = new PduPart();
- Integer charset = getIntegerFromPartColumn(
- c, PART_COLUMN_CHARSET);
- if (charset != null) {
- part.setCharset(charset);
- }
-
- byte[] contentDisposition = getByteArrayFromPartColumn(
- c, PART_COLUMN_CONTENT_DISPOSITION);
- if (contentDisposition != null) {
- part.setContentDisposition(contentDisposition);
- }
-
- byte[] contentId = getByteArrayFromPartColumn(
- c, PART_COLUMN_CONTENT_ID);
- if (contentId != null) {
- part.setContentId(contentId);
- }
-
- byte[] contentLocation = getByteArrayFromPartColumn(
- c, PART_COLUMN_CONTENT_LOCATION);
- if (contentLocation != null) {
- part.setContentLocation(contentLocation);
- }
-
- byte[] contentType = getByteArrayFromPartColumn(
- c, PART_COLUMN_CONTENT_TYPE);
- if (contentType != null) {
- part.setContentType(contentType);
- } else {
- throw new MmsException("Content-Type must be set.");
- }
-
- byte[] fileName = getByteArrayFromPartColumn(
- c, PART_COLUMN_FILENAME);
- if (fileName != null) {
- part.setFilename(fileName);
- }
-
- byte[] name = getByteArrayFromPartColumn(
- c, PART_COLUMN_NAME);
- if (name != null) {
- part.setName(name);
- }
-
- // Construct a Uri for this part.
- long partId = c.getLong(PART_COLUMN_ID);
- Uri partURI = Uri.parse("content://mms/part/" + partId);
- part.setDataUri(partURI);
-
- // For images/audio/video, we won't keep their data in Part
- // because their renderer accept Uri as source.
- String type = toIsoString(contentType);
- if (!ContentType.isImageType(type)
- && !ContentType.isAudioType(type)
- && !ContentType.isVideoType(type)) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- InputStream is = null;
-
- // Store simple string values directly in the database instead of an
- // external file. This makes the text searchable and retrieval slightly
- // faster.
- if (ContentType.TEXT_PLAIN.equals(type) || ContentType.APP_SMIL.equals(type)
- || ContentType.TEXT_HTML.equals(type)) {
- String text = c.getString(PART_COLUMN_TEXT);
- byte [] blob = new EncodedStringValue(text != null ? text : "")
- .getTextString();
- baos.write(blob, 0, blob.length);
- } else {
-
- try {
- is = mContentResolver.openInputStream(partURI);
-
- byte[] buffer = new byte[256];
- int len = is.read(buffer);
- while (len >= 0) {
- baos.write(buffer, 0, len);
- len = is.read(buffer);
- }
- } catch (IOException e) {
- Log.e(TAG, "Failed to load part data", e);
- c.close();
- throw new MmsException(e);
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- Log.e(TAG, "Failed to close stream", e);
- } // Ignore
- }
- }
- }
- part.setData(baos.toByteArray());
- }
- parts[partIdx++] = part;
- }
- } finally {
- if (c != null) {
- c.close();
- }
- }
-
- return parts;
- }
-
- private void loadAddress(long msgId, PduHeaders headers) {
- Cursor c = SqliteWrapper.query(mContext, mContentResolver,
- Uri.parse("content://mms/" + msgId + "/addr"),
- new String[] { Addr.ADDRESS, Addr.CHARSET, Addr.TYPE },
- null, null, null);
-
- if (c != null) {
- try {
- while (c.moveToNext()) {
- String addr = c.getString(0);
- if (!TextUtils.isEmpty(addr)) {
- int addrType = c.getInt(2);
- switch (addrType) {
- case PduHeaders.FROM:
- headers.setEncodedStringValue(
- new EncodedStringValue(c.getInt(1), getBytes(addr)),
- addrType);
- break;
- case PduHeaders.TO:
- case PduHeaders.CC:
- case PduHeaders.BCC:
- headers.appendEncodedStringValue(
- new EncodedStringValue(c.getInt(1), getBytes(addr)),
- addrType);
- break;
- default:
- Log.e(TAG, "Unknown address type: " + addrType);
- break;
- }
- }
- }
- } finally {
- c.close();
- }
- }
- }
-
- /**
- * Load a PDU from storage by given Uri.
- *
- * @param uri The Uri of the PDU to be loaded.
- * @return A generic PDU object, it may be cast to dedicated PDU.
- * @throws MmsException Failed to load some fields of a PDU.
- */
- public GenericPdu load(Uri uri) throws MmsException {
- GenericPdu pdu = null;
- PduCacheEntry cacheEntry = null;
- int msgBox = 0;
- long threadId = -1;
- try {
- synchronized(PDU_CACHE_INSTANCE) {
- if (PDU_CACHE_INSTANCE.isUpdating(uri)) {
- if (LOCAL_LOGV) {
- Log.v(TAG, "load: " + uri + " blocked by isUpdating()");
- }
- try {
- PDU_CACHE_INSTANCE.wait();
- } catch (InterruptedException e) {
- Log.e(TAG, "load: ", e);
- }
- cacheEntry = PDU_CACHE_INSTANCE.get(uri);
- if (cacheEntry != null) {
- return cacheEntry.getPdu();
- }
- }
- // Tell the cache to indicate to other callers that this item
- // is currently being updated.
- PDU_CACHE_INSTANCE.setUpdating(uri, true);
- }
-
- Cursor c = SqliteWrapper.query(mContext, mContentResolver, uri,
- PDU_PROJECTION, null, null, null);
- PduHeaders headers = new PduHeaders();
- Set> set;
- long msgId = ContentUris.parseId(uri);
-
- try {
- if ((c == null) || (c.getCount() != 1) || !c.moveToFirst()) {
- throw new MmsException("Bad uri: " + uri);
- }
-
- msgBox = c.getInt(PDU_COLUMN_MESSAGE_BOX);
- threadId = c.getLong(PDU_COLUMN_THREAD_ID);
-
- set = ENCODED_STRING_COLUMN_INDEX_MAP.entrySet();
- for (Entry e : set) {
- setEncodedStringValueToHeaders(
- c, e.getValue(), headers, e.getKey());
- }
-
- set = TEXT_STRING_COLUMN_INDEX_MAP.entrySet();
- for (Entry e : set) {
- setTextStringToHeaders(
- c, e.getValue(), headers, e.getKey());
- }
-
- set = OCTET_COLUMN_INDEX_MAP.entrySet();
- for (Entry e : set) {
- setOctetToHeaders(
- c, e.getValue(), headers, e.getKey());
- }
-
- set = LONG_COLUMN_INDEX_MAP.entrySet();
- for (Entry e : set) {
- setLongToHeaders(
- c, e.getValue(), headers, e.getKey());
- }
- } finally {
- if (c != null) {
- c.close();
- }
- }
-
- // Check whether 'msgId' has been assigned a valid value.
- if (msgId == -1L) {
- throw new MmsException("Error! ID of the message: -1.");
- }
-
- // Load address information of the MM.
- loadAddress(msgId, headers);
-
- int msgType = headers.getOctet(PduHeaders.MESSAGE_TYPE);
- PduBody body = new PduBody();
-
- // For PDU which type is M_retrieve.conf or Send.req, we should
- // load multiparts and put them into the body of the PDU.
- if ((msgType == PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF)
- || (msgType == PduHeaders.MESSAGE_TYPE_SEND_REQ)) {
- PduPart[] parts = loadParts(msgId);
- if (parts != null) {
- int partsNum = parts.length;
- for (int i = 0; i < partsNum; i++) {
- body.addPart(parts[i]);
- }
- }
- }
-
- switch (msgType) {
- case PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND:
- pdu = new NotificationInd(headers);
- break;
- case PduHeaders.MESSAGE_TYPE_DELIVERY_IND:
- pdu = new DeliveryInd(headers);
- break;
- case PduHeaders.MESSAGE_TYPE_READ_ORIG_IND:
- pdu = new ReadOrigInd(headers);
- break;
- case PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF:
- pdu = new RetrieveConf(headers, body);
- break;
- case PduHeaders.MESSAGE_TYPE_SEND_REQ:
- pdu = new SendReq(headers, body);
- break;
- case PduHeaders.MESSAGE_TYPE_ACKNOWLEDGE_IND:
- pdu = new AcknowledgeInd(headers);
- break;
- case PduHeaders.MESSAGE_TYPE_NOTIFYRESP_IND:
- pdu = new NotifyRespInd(headers);
- break;
- case PduHeaders.MESSAGE_TYPE_READ_REC_IND:
- pdu = new ReadRecInd(headers);
- break;
- case PduHeaders.MESSAGE_TYPE_SEND_CONF:
- case PduHeaders.MESSAGE_TYPE_FORWARD_REQ:
- case PduHeaders.MESSAGE_TYPE_FORWARD_CONF:
- case PduHeaders.MESSAGE_TYPE_MBOX_STORE_REQ:
- case PduHeaders.MESSAGE_TYPE_MBOX_STORE_CONF:
- case PduHeaders.MESSAGE_TYPE_MBOX_VIEW_REQ:
- case PduHeaders.MESSAGE_TYPE_MBOX_VIEW_CONF:
- case PduHeaders.MESSAGE_TYPE_MBOX_UPLOAD_REQ:
- case PduHeaders.MESSAGE_TYPE_MBOX_UPLOAD_CONF:
- case PduHeaders.MESSAGE_TYPE_MBOX_DELETE_REQ:
- case PduHeaders.MESSAGE_TYPE_MBOX_DELETE_CONF:
- case PduHeaders.MESSAGE_TYPE_MBOX_DESCR:
- case PduHeaders.MESSAGE_TYPE_DELETE_REQ:
- case PduHeaders.MESSAGE_TYPE_DELETE_CONF:
- case PduHeaders.MESSAGE_TYPE_CANCEL_REQ:
- case PduHeaders.MESSAGE_TYPE_CANCEL_CONF:
- throw new MmsException(
- "Unsupported PDU type: " + Integer.toHexString(msgType));
-
- default:
- throw new MmsException(
- "Unrecognized PDU type: " + Integer.toHexString(msgType));
- }
- } finally {
- synchronized(PDU_CACHE_INSTANCE) {
- if (pdu != null) {
- assert(PDU_CACHE_INSTANCE.get(uri) == null);
- // Update the cache entry with the real info
- cacheEntry = new PduCacheEntry(pdu, msgBox, threadId);
- PDU_CACHE_INSTANCE.put(uri, cacheEntry);
- }
- PDU_CACHE_INSTANCE.setUpdating(uri, false);
- PDU_CACHE_INSTANCE.notifyAll(); // tell anybody waiting on this entry to go ahead
- }
- }
- return pdu;
- }
-
- private void persistAddress(
- long msgId, int type, EncodedStringValue[] array) {
- ContentValues values = new ContentValues(3);
-
- for (EncodedStringValue addr : array) {
- values.clear(); // Clear all values first.
- values.put(Addr.ADDRESS, toIsoString(addr.getTextString()));
- values.put(Addr.CHARSET, addr.getCharacterSet());
- values.put(Addr.TYPE, type);
-
- Uri uri = Uri.parse("content://mms/" + msgId + "/addr");
- SqliteWrapper.insert(mContext, mContentResolver, uri, values);
- }
- }
-
- public Uri persistPart(PduPart part, long msgId)
- throws MmsException {
- Uri uri = Uri.parse("content://mms/" + msgId + "/part");
- ContentValues values = new ContentValues(8);
-
- int charset = part.getCharset();
- if (charset != 0 ) {
- values.put(Part.CHARSET, charset);
- }
-
- String contentType = null;
- if (part.getContentType() != null) {
- contentType = toIsoString(part.getContentType());
-
- // There is no "image/jpg" in Android (and it's an invalid mimetype).
- // Change it to "image/jpeg"
- if (ContentType.IMAGE_JPG.equals(contentType)) {
- contentType = ContentType.IMAGE_JPEG;
- }
-
- values.put(Part.CONTENT_TYPE, contentType);
- // To ensure the SMIL part is always the first part.
- if (ContentType.APP_SMIL.equals(contentType)) {
- values.put(Part.SEQ, -1);
- }
- } else {
- throw new MmsException("MIME type of the part must be set.");
- }
-
- if (part.getFilename() != null) {
- String fileName = new String(part.getFilename());
- values.put(Part.FILENAME, fileName);
- }
-
- if (part.getName() != null) {
- String name = new String(part.getName());
- values.put(Part.NAME, name);
- }
-
- Object value = null;
- if (part.getContentDisposition() != null) {
- value = toIsoString(part.getContentDisposition());
- values.put(Part.CONTENT_DISPOSITION, (String) value);
- }
-
- if (part.getContentId() != null) {
- value = toIsoString(part.getContentId());
- values.put(Part.CONTENT_ID, (String) value);
- }
-
- if (part.getContentLocation() != null) {
- value = toIsoString(part.getContentLocation());
- values.put(Part.CONTENT_LOCATION, (String) value);
- }
-
- Uri res = SqliteWrapper.insert(mContext, mContentResolver, uri, values);
- if (res == null) {
- throw new MmsException("Failed to persist part, return null.");
- }
-
- persistData(part, res, contentType);
- // After successfully store the data, we should update
- // the dataUri of the part.
- part.setDataUri(res);
-
- return res;
- }
-
- /**
- * Save data of the part into storage. The source data may be given
- * by a byte[] or a Uri. If it's a byte[], directly save it
- * into storage, otherwise load source data from the dataUri and then
- * save it. If the data is an image, we may scale down it according
- * to user preference.
- *
- * @param part The PDU part which contains data to be saved.
- * @param uri The URI of the part.
- * @param contentType The MIME type of the part.
- * @throws MmsException Cannot find source data or error occurred
- * while saving the data.
- */
- private void persistData(PduPart part, Uri uri,
- String contentType)
- throws MmsException {
- OutputStream os = null;
- InputStream is = null;
- DrmConvertSession drmConvertSession = null;
- Uri dataUri = null;
- String path = null;
-
- try {
- byte[] data = part.getData();
- if (ContentType.TEXT_PLAIN.equals(contentType)
- || ContentType.APP_SMIL.equals(contentType)
- || ContentType.TEXT_HTML.equals(contentType)) {
- ContentValues cv = new ContentValues();
- cv.put(Telephony.Mms.Part.TEXT, new EncodedStringValue(data).getString());
- if (mContentResolver.update(uri, cv, null, null) != 1) {
- throw new MmsException("unable to update " + uri.toString());
- }
- } else {
- boolean isDrm = DownloadDrmHelper.isDrmConvertNeeded(contentType);
- if (isDrm) {
- if (uri != null) {
- try {
- path = convertUriToPath(mContext, uri);
- if (LOCAL_LOGV) {
- Log.v(TAG, "drm uri: " + uri + " path: " + path);
- }
- File f = new File(path);
- long len = f.length();
- if (LOCAL_LOGV) {
- Log.v(TAG, "drm path: " + path + " len: " + len);
- }
- if (len > 0) {
- // we're not going to re-persist and re-encrypt an already
- // converted drm file
- return;
- }
- } catch (Exception e) {
- Log.e(TAG, "Can't get file info for: " + part.getDataUri(), e);
- }
- }
- // We haven't converted the file yet, start the conversion
- drmConvertSession = DrmConvertSession.open(mContext, contentType);
- if (drmConvertSession == null) {
- throw new MmsException("Mimetype " + contentType +
- " can not be converted.");
- }
- }
- os = mContentResolver.openOutputStream(uri);
- if (data == null) {
- dataUri = part.getDataUri();
- if ((dataUri == null) || (dataUri == uri)) {
- Log.w(TAG, "Can't find data for this part.");
- return;
- }
- is = mContentResolver.openInputStream(dataUri);
-
- if (LOCAL_LOGV) {
- Log.v(TAG, "Saving data to: " + uri);
- }
-
- byte[] buffer = new byte[8192];
- for (int len = 0; (len = is.read(buffer)) != -1; ) {
- if (!isDrm) {
- os.write(buffer, 0, len);
- } else {
- byte[] convertedData = drmConvertSession.convert(buffer, len);
- if (convertedData != null) {
- os.write(convertedData, 0, convertedData.length);
- } else {
- throw new MmsException("Error converting drm data.");
- }
- }
- }
- } else {
- if (LOCAL_LOGV) {
- Log.v(TAG, "Saving data to: " + uri);
- }
- if (!isDrm) {
- os.write(data);
- } else {
- dataUri = uri;
- byte[] convertedData = drmConvertSession.convert(data, data.length);
- if (convertedData != null) {
- os.write(convertedData, 0, convertedData.length);
- } else {
- throw new MmsException("Error converting drm data.");
- }
- }
- }
- }
- } catch (FileNotFoundException e) {
- Log.e(TAG, "Failed to open Input/Output stream.", e);
- throw new MmsException(e);
- } catch (IOException e) {
- Log.e(TAG, "Failed to read/write data.", e);
- throw new MmsException(e);
- } finally {
- if (os != null) {
- try {
- os.close();
- } catch (IOException e) {
- Log.e(TAG, "IOException while closing: " + os, e);
- } // Ignore
- }
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- Log.e(TAG, "IOException while closing: " + is, e);
- } // Ignore
- }
- if (drmConvertSession != null) {
- drmConvertSession.close(path);
-
- // Reset the permissions on the encrypted part file so everyone has only read
- // permission.
- File f = new File(path);
- ContentValues values = new ContentValues(0);
- SqliteWrapper.update(mContext, mContentResolver,
- Uri.parse("content://mms/resetFilePerm/" + f.getName()),
- values, null, null);
- }
- }
- }
-
- /**
- * This method expects uri in the following format
- * content://media// (or)
- * file://sdcard/test.mp4
- * http://test.com/test.mp4
- *
- * Here shall be "video" or "audio" or "images"
- * the index of the content in given table
- */
- static public String convertUriToPath(Context context, Uri uri) {
- String path = null;
- if (null != uri) {
- String scheme = uri.getScheme();
- if (null == scheme || scheme.equals("") ||
- scheme.equals(ContentResolver.SCHEME_FILE)) {
- path = uri.getPath();
-
- } else if (scheme.equals("http")) {
- path = uri.toString();
-
- } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
- String[] projection = new String[] {MediaStore.MediaColumns.DATA};
- Cursor cursor = null;
- try {
- cursor = context.getContentResolver().query(uri, projection, null,
- null, null);
- if (null == cursor || 0 == cursor.getCount() || !cursor.moveToFirst()) {
- throw new IllegalArgumentException("Given Uri could not be found" +
- " in media store");
- }
- int pathIndex = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
- path = cursor.getString(pathIndex);
- } catch (SQLiteException e) {
- throw new IllegalArgumentException("Given Uri is not formatted in a way " +
- "so that it can be found in media store.");
- } finally {
- if (null != cursor) {
- cursor.close();
- }
- }
- } else {
- throw new IllegalArgumentException("Given Uri scheme is not supported");
- }
- }
- return path;
- }
-
- private void updateAddress(
- long msgId, int type, EncodedStringValue[] array) {
- // Delete old address information and then insert new ones.
- SqliteWrapper.delete(mContext, mContentResolver,
- Uri.parse("content://mms/" + msgId + "/addr"),
- Addr.TYPE + "=" + type, null);
-
- persistAddress(msgId, type, array);
- }
-
- /**
- * Update headers of a SendReq.
- *
- * @param uri The PDU which need to be updated.
- * @param pdu New headers.
- * @throws MmsException Bad URI or updating failed.
- */
- public void updateHeaders(Uri uri, SendReq sendReq) {
- synchronized(PDU_CACHE_INSTANCE) {
- // If the cache item is getting updated, wait until it's done updating before
- // purging it.
- if (PDU_CACHE_INSTANCE.isUpdating(uri)) {
- if (LOCAL_LOGV) {
- Log.v(TAG, "updateHeaders: " + uri + " blocked by isUpdating()");
- }
- try {
- PDU_CACHE_INSTANCE.wait();
- } catch (InterruptedException e) {
- Log.e(TAG, "updateHeaders: ", e);
- }
- }
- }
- PDU_CACHE_INSTANCE.purge(uri);
-
- ContentValues values = new ContentValues(10);
- byte[] contentType = sendReq.getContentType();
- if (contentType != null) {
- values.put(Mms.CONTENT_TYPE, toIsoString(contentType));
- }
-
- long date = sendReq.getDate();
- if (date != -1) {
- values.put(Mms.DATE, date);
- }
-
- int deliveryReport = sendReq.getDeliveryReport();
- if (deliveryReport != 0) {
- values.put(Mms.DELIVERY_REPORT, deliveryReport);
- }
-
- long expiry = sendReq.getExpiry();
- if (expiry != -1) {
- values.put(Mms.EXPIRY, expiry);
- }
-
- byte[] msgClass = sendReq.getMessageClass();
- if (msgClass != null) {
- values.put(Mms.MESSAGE_CLASS, toIsoString(msgClass));
- }
-
- int priority = sendReq.getPriority();
- if (priority != 0) {
- values.put(Mms.PRIORITY, priority);
- }
-
- int readReport = sendReq.getReadReport();
- if (readReport != 0) {
- values.put(Mms.READ_REPORT, readReport);
- }
-
- byte[] transId = sendReq.getTransactionId();
- if (transId != null) {
- values.put(Mms.TRANSACTION_ID, toIsoString(transId));
- }
-
- EncodedStringValue subject = sendReq.getSubject();
- if (subject != null) {
- values.put(Mms.SUBJECT, toIsoString(subject.getTextString()));
- values.put(Mms.SUBJECT_CHARSET, subject.getCharacterSet());
- } else {
- values.put(Mms.SUBJECT, "");
- }
-
- long messageSize = sendReq.getMessageSize();
- if (messageSize > 0) {
- values.put(Mms.MESSAGE_SIZE, messageSize);
- }
-
- PduHeaders headers = sendReq.getPduHeaders();
- HashSet recipients = new HashSet();
- for (int addrType : ADDRESS_FIELDS) {
- EncodedStringValue[] array = null;
- if (addrType == PduHeaders.FROM) {
- EncodedStringValue v = headers.getEncodedStringValue(addrType);
- if (v != null) {
- array = new EncodedStringValue[1];
- array[0] = v;
- }
- } else {
- array = headers.getEncodedStringValues(addrType);
- }
-
- if (array != null) {
- long msgId = ContentUris.parseId(uri);
- updateAddress(msgId, addrType, array);
- if (addrType == PduHeaders.TO) {
- for (EncodedStringValue v : array) {
- if (v != null) {
- recipients.add(v.getString());
- }
- }
- }
- }
- }
- if (!recipients.isEmpty()) {
- long threadId = Threads.getOrCreateThreadId(mContext, recipients);
- values.put(Mms.THREAD_ID, threadId);
- }
-
- SqliteWrapper.update(mContext, mContentResolver, uri, values, null, null);
- }
-
- private void updatePart(Uri uri, PduPart part) throws MmsException {
- ContentValues values = new ContentValues(7);
-
- int charset = part.getCharset();
- if (charset != 0 ) {
- values.put(Part.CHARSET, charset);
- }
-
- String contentType = null;
- if (part.getContentType() != null) {
- contentType = toIsoString(part.getContentType());
- values.put(Part.CONTENT_TYPE, contentType);
- } else {
- throw new MmsException("MIME type of the part must be set.");
- }
-
- if (part.getFilename() != null) {
- String fileName = new String(part.getFilename());
- values.put(Part.FILENAME, fileName);
- }
-
- if (part.getName() != null) {
- String name = new String(part.getName());
- values.put(Part.NAME, name);
- }
-
- Object value = null;
- if (part.getContentDisposition() != null) {
- value = toIsoString(part.getContentDisposition());
- values.put(Part.CONTENT_DISPOSITION, (String) value);
- }
-
- if (part.getContentId() != null) {
- value = toIsoString(part.getContentId());
- values.put(Part.CONTENT_ID, (String) value);
- }
-
- if (part.getContentLocation() != null) {
- value = toIsoString(part.getContentLocation());
- values.put(Part.CONTENT_LOCATION, (String) value);
- }
-
- SqliteWrapper.update(mContext, mContentResolver, uri, values, null, null);
-
- // Only update the data when:
- // 1. New binary data supplied or
- // 2. The Uri of the part is different from the current one.
- if ((part.getData() != null)
- || (uri != part.getDataUri())) {
- persistData(part, uri, contentType);
- }
- }
-
- /**
- * Update all parts of a PDU.
- *
- * @param uri The PDU which need to be updated.
- * @param body New message body of the PDU.
- * @throws MmsException Bad URI or updating failed.
- */
- public void updateParts(Uri uri, PduBody body)
- throws MmsException {
- try {
- PduCacheEntry cacheEntry;
- synchronized(PDU_CACHE_INSTANCE) {
- if (PDU_CACHE_INSTANCE.isUpdating(uri)) {
- if (LOCAL_LOGV) {
- Log.v(TAG, "updateParts: " + uri + " blocked by isUpdating()");
- }
- try {
- PDU_CACHE_INSTANCE.wait();
- } catch (InterruptedException e) {
- Log.e(TAG, "updateParts: ", e);
- }
- cacheEntry = PDU_CACHE_INSTANCE.get(uri);
- if (cacheEntry != null) {
- ((MultimediaMessagePdu) cacheEntry.getPdu()).setBody(body);
- }
- }
- // Tell the cache to indicate to other callers that this item
- // is currently being updated.
- PDU_CACHE_INSTANCE.setUpdating(uri, true);
- }
-
- ArrayList toBeCreated = new ArrayList();
- HashMap toBeUpdated = new HashMap();
-
- int partsNum = body.getPartsNum();
- StringBuilder filter = new StringBuilder().append('(');
- for (int i = 0; i < partsNum; i++) {
- PduPart part = body.getPart(i);
- Uri partUri = part.getDataUri();
- if ((partUri == null) || !partUri.getAuthority().startsWith("mms")) {
- toBeCreated.add(part);
- } else {
- toBeUpdated.put(partUri, part);
-
- // Don't use 'i > 0' to determine whether we should append
- // 'AND' since 'i = 0' may be skipped in another branch.
- if (filter.length() > 1) {
- filter.append(" AND ");
- }
-
- filter.append(Part._ID);
- filter.append("!=");
- DatabaseUtils.appendEscapedSQLString(filter, partUri.getLastPathSegment());
- }
- }
- filter.append(')');
-
- long msgId = ContentUris.parseId(uri);
-
- // Remove the parts which doesn't exist anymore.
- SqliteWrapper.delete(mContext, mContentResolver,
- Uri.parse(Mms.CONTENT_URI + "/" + msgId + "/part"),
- filter.length() > 2 ? filter.toString() : null, null);
-
- // Create new parts which didn't exist before.
- for (PduPart part : toBeCreated) {
- persistPart(part, msgId);
- }
-
- // Update the modified parts.
- for (Map.Entry e : toBeUpdated.entrySet()) {
- updatePart(e.getKey(), e.getValue());
- }
- } finally {
- synchronized(PDU_CACHE_INSTANCE) {
- PDU_CACHE_INSTANCE.setUpdating(uri, false);
- PDU_CACHE_INSTANCE.notifyAll();
- }
- }
- }
-
- /**
- * Persist a PDU object to specific location in the storage.
- *
- * @param pdu The PDU object to be stored.
- * @param uri Where to store the given PDU object.
- * @return A Uri which can be used to access the stored PDU.
- */
- public Uri persist(GenericPdu pdu, Uri uri) throws MmsException {
- if (uri == null) {
- throw new MmsException("Uri may not be null.");
- }
- long msgId = -1;
- try {
- msgId = ContentUris.parseId(uri);
- } catch (NumberFormatException e) {
- // the uri ends with "inbox" or something else like that
- }
- boolean existingUri = msgId != -1;
-
- if (!existingUri && MESSAGE_BOX_MAP.get(uri) == null) {
- throw new MmsException(
- "Bad destination, must be one of "
- + "content://mms/inbox, content://mms/sent, "
- + "content://mms/drafts, content://mms/outbox, "
- + "content://mms/temp.");
- }
- synchronized(PDU_CACHE_INSTANCE) {
- // If the cache item is getting updated, wait until it's done updating before
- // purging it.
- if (PDU_CACHE_INSTANCE.isUpdating(uri)) {
- if (LOCAL_LOGV) {
- Log.v(TAG, "persist: " + uri + " blocked by isUpdating()");
- }
- try {
- PDU_CACHE_INSTANCE.wait();
- } catch (InterruptedException e) {
- Log.e(TAG, "persist1: ", e);
- }
- }
- }
- PDU_CACHE_INSTANCE.purge(uri);
-
- PduHeaders header = pdu.getPduHeaders();
- PduBody body = null;
- ContentValues values = new ContentValues();
- Set> set;
-
- set = ENCODED_STRING_COLUMN_NAME_MAP.entrySet();
- for (Entry e : set) {
- int field = e.getKey();
- EncodedStringValue encodedString = header.getEncodedStringValue(field);
- if (encodedString != null) {
- String charsetColumn = CHARSET_COLUMN_NAME_MAP.get(field);
- values.put(e.getValue(), toIsoString(encodedString.getTextString()));
- values.put(charsetColumn, encodedString.getCharacterSet());
- }
- }
-
- set = TEXT_STRING_COLUMN_NAME_MAP.entrySet();
- for (Entry e : set){
- byte[] text = header.getTextString(e.getKey());
- if (text != null) {
- values.put(e.getValue(), toIsoString(text));
- }
- }
-
- set = OCTET_COLUMN_NAME_MAP.entrySet();
- for (Entry e : set){
- int b = header.getOctet(e.getKey());
- if (b != 0) {
- values.put(e.getValue(), b);
- }
- }
-
- set = LONG_COLUMN_NAME_MAP.entrySet();
- for (Entry e : set){
- long l = header.getLongInteger(e.getKey());
- if (l != -1L) {
- values.put(e.getValue(), l);
- }
- }
-
- HashMap addressMap =
- new HashMap(ADDRESS_FIELDS.length);
- // Save address information.
- for (int addrType : ADDRESS_FIELDS) {
- EncodedStringValue[] array = null;
- if (addrType == PduHeaders.FROM) {
- EncodedStringValue v = header.getEncodedStringValue(addrType);
- if (v != null) {
- array = new EncodedStringValue[1];
- array[0] = v;
- }
- } else {
- array = header.getEncodedStringValues(addrType);
- }
- addressMap.put(addrType, array);
- }
-
- HashSet recipients = new HashSet();
- int msgType = pdu.getMessageType();
- // Here we only allocate thread ID for M-Notification.ind,
- // M-Retrieve.conf and M-Send.req.
- // Some of other PDU types may be allocated a thread ID outside
- // this scope.
- if ((msgType == PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND)
- || (msgType == PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF)
- || (msgType == PduHeaders.MESSAGE_TYPE_SEND_REQ)) {
- EncodedStringValue[] array = null;
- switch (msgType) {
- case PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND:
- case PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF:
- array = addressMap.get(PduHeaders.FROM);
- break;
- case PduHeaders.MESSAGE_TYPE_SEND_REQ:
- array = addressMap.get(PduHeaders.TO);
- break;
- }
-
- if (array != null) {
- for (EncodedStringValue v : array) {
- if (v != null) {
- recipients.add(v.getString());
- }
- }
- }
- if (!recipients.isEmpty()) {
- long threadId = Threads.getOrCreateThreadId(mContext, recipients);
- values.put(Mms.THREAD_ID, threadId);
- }
- }
-
- // Save parts first to avoid inconsistent message is loaded
- // while saving the parts.
- long dummyId = System.currentTimeMillis(); // Dummy ID of the msg.
- // Get body if the PDU is a RetrieveConf or SendReq.
- if (pdu instanceof MultimediaMessagePdu) {
- body = ((MultimediaMessagePdu) pdu).getBody();
- // Start saving parts if necessary.
- if (body != null) {
- int partsNum = body.getPartsNum();
- for (int i = 0; i < partsNum; i++) {
- PduPart part = body.getPart(i);
- persistPart(part, dummyId);
- }
- }
- }
-
- Uri res = null;
- if (existingUri) {
- res = uri;
- SqliteWrapper.update(mContext, mContentResolver, res, values, null, null);
- } else {
- res = SqliteWrapper.insert(mContext, mContentResolver, uri, values);
- if (res == null) {
- throw new MmsException("persist() failed: return null.");
- }
- // Get the real ID of the PDU and update all parts which were
- // saved with the dummy ID.
- msgId = ContentUris.parseId(res);
- }
-
- values = new ContentValues(1);
- values.put(Part.MSG_ID, msgId);
- SqliteWrapper.update(mContext, mContentResolver,
- Uri.parse("content://mms/" + dummyId + "/part"),
- values, null, null);
- // We should return the longest URI of the persisted PDU, for
- // example, if input URI is "content://mms/inbox" and the _ID of
- // persisted PDU is '8', we should return "content://mms/inbox/8"
- // instead of "content://mms/8".
- // FIXME: Should the MmsProvider be responsible for this???
- if (!existingUri) {
- res = Uri.parse(uri + "/" + msgId);
- }
-
- // Save address information.
- for (int addrType : ADDRESS_FIELDS) {
- EncodedStringValue[] array = addressMap.get(addrType);
- if (array != null) {
- persistAddress(msgId, addrType, array);
- }
- }
-
- return res;
- }
-
- /**
- * Move a PDU object from one location to another.
- *
- * @param from Specify the PDU object to be moved.
- * @param to The destination location, should be one of the following:
- * "content://mms/inbox", "content://mms/sent",
- * "content://mms/drafts", "content://mms/outbox",
- * "content://mms/trash".
- * @return New Uri of the moved PDU.
- * @throws MmsException Error occurred while moving the message.
- */
- public Uri move(Uri from, Uri to) throws MmsException {
- // Check whether the 'msgId' has been assigned a valid value.
- long msgId = ContentUris.parseId(from);
- if (msgId == -1L) {
- throw new MmsException("Error! ID of the message: -1.");
- }
-
- // Get corresponding int value of destination box.
- Integer msgBox = MESSAGE_BOX_MAP.get(to);
- if (msgBox == null) {
- throw new MmsException(
- "Bad destination, must be one of "
- + "content://mms/inbox, content://mms/sent, "
- + "content://mms/drafts, content://mms/outbox, "
- + "content://mms/temp.");
- }
-
- ContentValues values = new ContentValues(1);
- values.put(Mms.MESSAGE_BOX, msgBox);
- SqliteWrapper.update(mContext, mContentResolver, from, values, null, null);
- return ContentUris.withAppendedId(to, msgId);
- }
-
- /**
- * Wrap a byte[] into a String.
- */
- public static String toIsoString(byte[] bytes) {
- try {
- return new String(bytes, CharacterSets.MIMENAME_ISO_8859_1);
- } catch (UnsupportedEncodingException e) {
- // Impossible to reach here!
- Log.e(TAG, "ISO_8859_1 must be supported!", e);
- return "";
- }
- }
-
- /**
- * Unpack a given String into a byte[].
- */
- public static byte[] getBytes(String data) {
- try {
- return data.getBytes(CharacterSets.MIMENAME_ISO_8859_1);
- } catch (UnsupportedEncodingException e) {
- // Impossible to reach here!
- Log.e(TAG, "ISO_8859_1 must be supported!", e);
- return new byte[0];
- }
- }
-
- /**
- * Remove all objects in the temporary path.
- */
- public void release() {
- Uri uri = Uri.parse(TEMPORARY_DRM_OBJECT_URI);
- SqliteWrapper.delete(mContext, mContentResolver, uri, null, null);
- }
-
- /**
- * Find all messages to be sent or downloaded before certain time.
- */
- public Cursor getPendingMessages(long dueTime) {
- Uri.Builder uriBuilder = PendingMessages.CONTENT_URI.buildUpon();
- uriBuilder.appendQueryParameter("protocol", "mms");
-
- String selection = PendingMessages.ERROR_TYPE + " < ?"
- + " AND " + PendingMessages.DUE_TIME + " <= ?";
-
- String[] selectionArgs = new String[] {
- String.valueOf(MmsSms.ERR_TYPE_GENERIC_PERMANENT),
- String.valueOf(dueTime)
- };
-
- return SqliteWrapper.query(mContext, mContentResolver,
- uriBuilder.build(), null, selection, selectionArgs,
- PendingMessages.DUE_TIME);
- }
-}
diff --git a/core/java/com/google/android/mms/pdu/QuotedPrintable.java b/core/java/com/google/android/mms/pdu/QuotedPrintable.java
deleted file mode 100644
index a34ed1263891..000000000000
--- a/core/java/com/google/android/mms/pdu/QuotedPrintable.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import java.io.ByteArrayOutputStream;
-
-public class QuotedPrintable {
- private static byte ESCAPE_CHAR = '=';
-
- /**
- * Decodes an array quoted-printable characters into an array of original bytes.
- * Escaped characters are converted back to their original representation.
- *
- *
- * This function implements a subset of
- * quoted-printable encoding specification (rule #1 and rule #2)
- * as defined in RFC 1521.
- *
- *
- * @param bytes array of quoted-printable characters
- * @return array of original bytes,
- * null if quoted-printable decoding is unsuccessful.
- */
- public static final byte[] decodeQuotedPrintable(byte[] bytes) {
- if (bytes == null) {
- return null;
- }
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- for (int i = 0; i < bytes.length; i++) {
- int b = bytes[i];
- if (b == ESCAPE_CHAR) {
- try {
- if('\r' == (char)bytes[i + 1] &&
- '\n' == (char)bytes[i + 2]) {
- i += 2;
- continue;
- }
- int u = Character.digit((char) bytes[++i], 16);
- int l = Character.digit((char) bytes[++i], 16);
- if (u == -1 || l == -1) {
- return null;
- }
- buffer.write((char) ((u << 4) + l));
- } catch (ArrayIndexOutOfBoundsException e) {
- return null;
- }
- } else {
- buffer.write(b);
- }
- }
- return buffer.toByteArray();
- }
-}
diff --git a/core/java/com/google/android/mms/pdu/ReadOrigInd.java b/core/java/com/google/android/mms/pdu/ReadOrigInd.java
deleted file mode 100644
index 1bfc0bb3e258..000000000000
--- a/core/java/com/google/android/mms/pdu/ReadOrigInd.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import com.google.android.mms.InvalidHeaderValueException;
-
-public class ReadOrigInd extends GenericPdu {
- /**
- * Empty constructor.
- * Since the Pdu corresponding to this class is constructed
- * by the Proxy-Relay server, this class is only instantiated
- * by the Pdu Parser.
- *
- * @throws InvalidHeaderValueException if error occurs.
- */
- public ReadOrigInd() throws InvalidHeaderValueException {
- super();
- setMessageType(PduHeaders.MESSAGE_TYPE_READ_ORIG_IND);
- }
-
- /**
- * Constructor with given headers.
- *
- * @param headers Headers for this PDU.
- */
- ReadOrigInd(PduHeaders headers) {
- super(headers);
- }
-
- /**
- * Get Date value.
- *
- * @return the value
- */
- public long getDate() {
- return mPduHeaders.getLongInteger(PduHeaders.DATE);
- }
-
- /**
- * Set Date value.
- *
- * @param value the value
- */
- public void setDate(long value) {
- mPduHeaders.setLongInteger(value, PduHeaders.DATE);
- }
-
- /**
- * Get From value.
- * From-value = Value-length
- * (Address-present-token Encoded-string-value | Insert-address-token)
- *
- * @return the value
- */
- public EncodedStringValue getFrom() {
- return mPduHeaders.getEncodedStringValue(PduHeaders.FROM);
- }
-
- /**
- * Set From value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setFrom(EncodedStringValue value) {
- mPduHeaders.setEncodedStringValue(value, PduHeaders.FROM);
- }
-
- /**
- * Get Message-ID value.
- *
- * @return the value
- */
- public byte[] getMessageId() {
- return mPduHeaders.getTextString(PduHeaders.MESSAGE_ID);
- }
-
- /**
- * Set Message-ID value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setMessageId(byte[] value) {
- mPduHeaders.setTextString(value, PduHeaders.MESSAGE_ID);
- }
-
- /**
- * Get X-MMS-Read-status value.
- *
- * @return the value
- */
- public int getReadStatus() {
- return mPduHeaders.getOctet(PduHeaders.READ_STATUS);
- }
-
- /**
- * Set X-MMS-Read-status value.
- *
- * @param value the value
- * @throws InvalidHeaderValueException if the value is invalid.
- */
- public void setReadStatus(int value) throws InvalidHeaderValueException {
- mPduHeaders.setOctet(value, PduHeaders.READ_STATUS);
- }
-
- /**
- * Get To value.
- *
- * @return the value
- */
- public EncodedStringValue[] getTo() {
- return mPduHeaders.getEncodedStringValues(PduHeaders.TO);
- }
-
- /**
- * Set To value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setTo(EncodedStringValue[] value) {
- mPduHeaders.setEncodedStringValues(value, PduHeaders.TO);
- }
-
- /*
- * Optional, not supported header fields:
- *
- * public byte[] getApplicId() {return null;}
- * public void setApplicId(byte[] value) {}
- *
- * public byte[] getAuxApplicId() {return null;}
- * public void getAuxApplicId(byte[] value) {}
- *
- * public byte[] getReplyApplicId() {return 0x00;}
- * public void setReplyApplicId(byte[] value) {}
- */
-}
diff --git a/core/java/com/google/android/mms/pdu/ReadRecInd.java b/core/java/com/google/android/mms/pdu/ReadRecInd.java
deleted file mode 100644
index 880e3ac3ddd4..000000000000
--- a/core/java/com/google/android/mms/pdu/ReadRecInd.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import com.google.android.mms.InvalidHeaderValueException;
-
-public class ReadRecInd extends GenericPdu {
- /**
- * Constructor, used when composing a M-ReadRec.ind pdu.
- *
- * @param from the from value
- * @param messageId the message ID value
- * @param mmsVersion current viersion of mms
- * @param readStatus the read status value
- * @param to the to value
- * @throws InvalidHeaderValueException if parameters are invalid.
- * NullPointerException if messageId or to is null.
- */
- public ReadRecInd(EncodedStringValue from,
- byte[] messageId,
- int mmsVersion,
- int readStatus,
- EncodedStringValue[] to) throws InvalidHeaderValueException {
- super();
- setMessageType(PduHeaders.MESSAGE_TYPE_READ_REC_IND);
- setFrom(from);
- setMessageId(messageId);
- setMmsVersion(mmsVersion);
- setTo(to);
- setReadStatus(readStatus);
- }
-
- /**
- * Constructor with given headers.
- *
- * @param headers Headers for this PDU.
- */
- ReadRecInd(PduHeaders headers) {
- super(headers);
- }
-
- /**
- * Get Date value.
- *
- * @return the value
- */
- public long getDate() {
- return mPduHeaders.getLongInteger(PduHeaders.DATE);
- }
-
- /**
- * Set Date value.
- *
- * @param value the value
- */
- public void setDate(long value) {
- mPduHeaders.setLongInteger(value, PduHeaders.DATE);
- }
-
- /**
- * Get Message-ID value.
- *
- * @return the value
- */
- public byte[] getMessageId() {
- return mPduHeaders.getTextString(PduHeaders.MESSAGE_ID);
- }
-
- /**
- * Set Message-ID value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setMessageId(byte[] value) {
- mPduHeaders.setTextString(value, PduHeaders.MESSAGE_ID);
- }
-
- /**
- * Get To value.
- *
- * @return the value
- */
- public EncodedStringValue[] getTo() {
- return mPduHeaders.getEncodedStringValues(PduHeaders.TO);
- }
-
- /**
- * Set To value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setTo(EncodedStringValue[] value) {
- mPduHeaders.setEncodedStringValues(value, PduHeaders.TO);
- }
-
- /**
- * Get X-MMS-Read-status value.
- *
- * @return the value
- */
- public int getReadStatus() {
- return mPduHeaders.getOctet(PduHeaders.READ_STATUS);
- }
-
- /**
- * Set X-MMS-Read-status value.
- *
- * @param value the value
- * @throws InvalidHeaderValueException if the value is invalid.
- */
- public void setReadStatus(int value) throws InvalidHeaderValueException {
- mPduHeaders.setOctet(value, PduHeaders.READ_STATUS);
- }
-
- /*
- * Optional, not supported header fields:
- *
- * public byte[] getApplicId() {return null;}
- * public void setApplicId(byte[] value) {}
- *
- * public byte[] getAuxApplicId() {return null;}
- * public void getAuxApplicId(byte[] value) {}
- *
- * public byte[] getReplyApplicId() {return 0x00;}
- * public void setReplyApplicId(byte[] value) {}
- */
-}
diff --git a/core/java/com/google/android/mms/pdu/RetrieveConf.java b/core/java/com/google/android/mms/pdu/RetrieveConf.java
deleted file mode 100644
index 98e67c068d98..000000000000
--- a/core/java/com/google/android/mms/pdu/RetrieveConf.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import com.google.android.mms.InvalidHeaderValueException;
-
-/**
- * M-Retrive.conf Pdu.
- */
-public class RetrieveConf extends MultimediaMessagePdu {
- /**
- * Empty constructor.
- * Since the Pdu corresponding to this class is constructed
- * by the Proxy-Relay server, this class is only instantiated
- * by the Pdu Parser.
- *
- * @throws InvalidHeaderValueException if error occurs.
- */
- public RetrieveConf() throws InvalidHeaderValueException {
- super();
- setMessageType(PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF);
- }
-
- /**
- * Constructor with given headers.
- *
- * @param headers Headers for this PDU.
- */
- RetrieveConf(PduHeaders headers) {
- super(headers);
- }
-
- /**
- * Constructor with given headers and body
- *
- * @param headers Headers for this PDU.
- * @param body Body of this PDu.
- */
- RetrieveConf(PduHeaders headers, PduBody body) {
- super(headers, body);
- }
-
- /**
- * Get CC value.
- *
- * @return the value
- */
- public EncodedStringValue[] getCc() {
- return mPduHeaders.getEncodedStringValues(PduHeaders.CC);
- }
-
- /**
- * Add a "CC" value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void addCc(EncodedStringValue value) {
- mPduHeaders.appendEncodedStringValue(value, PduHeaders.CC);
- }
-
- /**
- * Get Content-type value.
- *
- * @return the value
- */
- public byte[] getContentType() {
- return mPduHeaders.getTextString(PduHeaders.CONTENT_TYPE);
- }
-
- /**
- * Set Content-type value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setContentType(byte[] value) {
- mPduHeaders.setTextString(value, PduHeaders.CONTENT_TYPE);
- }
-
- /**
- * Get X-Mms-Delivery-Report value.
- *
- * @return the value
- */
- public int getDeliveryReport() {
- return mPduHeaders.getOctet(PduHeaders.DELIVERY_REPORT);
- }
-
- /**
- * Set X-Mms-Delivery-Report value.
- *
- * @param value the value
- * @throws InvalidHeaderValueException if the value is invalid.
- */
- public void setDeliveryReport(int value) throws InvalidHeaderValueException {
- mPduHeaders.setOctet(value, PduHeaders.DELIVERY_REPORT);
- }
-
- /**
- * Get From value.
- * From-value = Value-length
- * (Address-present-token Encoded-string-value | Insert-address-token)
- *
- * @return the value
- */
- public EncodedStringValue getFrom() {
- return mPduHeaders.getEncodedStringValue(PduHeaders.FROM);
- }
-
- /**
- * Set From value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setFrom(EncodedStringValue value) {
- mPduHeaders.setEncodedStringValue(value, PduHeaders.FROM);
- }
-
- /**
- * Get X-Mms-Message-Class value.
- * Message-class-value = Class-identifier | Token-text
- * Class-identifier = Personal | Advertisement | Informational | Auto
- *
- * @return the value
- */
- public byte[] getMessageClass() {
- return mPduHeaders.getTextString(PduHeaders.MESSAGE_CLASS);
- }
-
- /**
- * Set X-Mms-Message-Class value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setMessageClass(byte[] value) {
- mPduHeaders.setTextString(value, PduHeaders.MESSAGE_CLASS);
- }
-
- /**
- * Get Message-ID value.
- *
- * @return the value
- */
- public byte[] getMessageId() {
- return mPduHeaders.getTextString(PduHeaders.MESSAGE_ID);
- }
-
- /**
- * Set Message-ID value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setMessageId(byte[] value) {
- mPduHeaders.setTextString(value, PduHeaders.MESSAGE_ID);
- }
-
- /**
- * Get X-Mms-Read-Report value.
- *
- * @return the value
- */
- public int getReadReport() {
- return mPduHeaders.getOctet(PduHeaders.READ_REPORT);
- }
-
- /**
- * Set X-Mms-Read-Report value.
- *
- * @param value the value
- * @throws InvalidHeaderValueException if the value is invalid.
- */
- public void setReadReport(int value) throws InvalidHeaderValueException {
- mPduHeaders.setOctet(value, PduHeaders.READ_REPORT);
- }
-
- /**
- * Get X-Mms-Retrieve-Status value.
- *
- * @return the value
- */
- public int getRetrieveStatus() {
- return mPduHeaders.getOctet(PduHeaders.RETRIEVE_STATUS);
- }
-
- /**
- * Set X-Mms-Retrieve-Status value.
- *
- * @param value the value
- * @throws InvalidHeaderValueException if the value is invalid.
- */
- public void setRetrieveStatus(int value) throws InvalidHeaderValueException {
- mPduHeaders.setOctet(value, PduHeaders.RETRIEVE_STATUS);
- }
-
- /**
- * Get X-Mms-Retrieve-Text value.
- *
- * @return the value
- */
- public EncodedStringValue getRetrieveText() {
- return mPduHeaders.getEncodedStringValue(PduHeaders.RETRIEVE_TEXT);
- }
-
- /**
- * Set X-Mms-Retrieve-Text value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setRetrieveText(EncodedStringValue value) {
- mPduHeaders.setEncodedStringValue(value, PduHeaders.RETRIEVE_TEXT);
- }
-
- /**
- * Get X-Mms-Transaction-Id.
- *
- * @return the value
- */
- public byte[] getTransactionId() {
- return mPduHeaders.getTextString(PduHeaders.TRANSACTION_ID);
- }
-
- /**
- * Set X-Mms-Transaction-Id.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setTransactionId(byte[] value) {
- mPduHeaders.setTextString(value, PduHeaders.TRANSACTION_ID);
- }
-
- /*
- * Optional, not supported header fields:
- *
- * public byte[] getApplicId() {return null;}
- * public void setApplicId(byte[] value) {}
- *
- * public byte[] getAuxApplicId() {return null;}
- * public void getAuxApplicId(byte[] value) {}
- *
- * public byte getContentClass() {return 0x00;}
- * public void setApplicId(byte value) {}
- *
- * public byte getDrmContent() {return 0x00;}
- * public void setDrmContent(byte value) {}
- *
- * public byte getDistributionIndicator() {return 0x00;}
- * public void setDistributionIndicator(byte value) {}
- *
- * public PreviouslySentByValue getPreviouslySentBy() {return null;}
- * public void setPreviouslySentBy(PreviouslySentByValue value) {}
- *
- * public PreviouslySentDateValue getPreviouslySentDate() {}
- * public void setPreviouslySentDate(PreviouslySentDateValue value) {}
- *
- * public MmFlagsValue getMmFlags() {return null;}
- * public void setMmFlags(MmFlagsValue value) {}
- *
- * public MmStateValue getMmState() {return null;}
- * public void getMmState(MmStateValue value) {}
- *
- * public byte[] getReplaceId() {return 0x00;}
- * public void setReplaceId(byte[] value) {}
- *
- * public byte[] getReplyApplicId() {return 0x00;}
- * public void setReplyApplicId(byte[] value) {}
- *
- * public byte getReplyCharging() {return 0x00;}
- * public void setReplyCharging(byte value) {}
- *
- * public byte getReplyChargingDeadline() {return 0x00;}
- * public void setReplyChargingDeadline(byte value) {}
- *
- * public byte[] getReplyChargingId() {return 0x00;}
- * public void setReplyChargingId(byte[] value) {}
- *
- * public long getReplyChargingSize() {return 0;}
- * public void setReplyChargingSize(long value) {}
- */
-}
diff --git a/core/java/com/google/android/mms/pdu/SendConf.java b/core/java/com/google/android/mms/pdu/SendConf.java
deleted file mode 100644
index 0568fe79c5ff..000000000000
--- a/core/java/com/google/android/mms/pdu/SendConf.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import com.google.android.mms.InvalidHeaderValueException;
-
-public class SendConf extends GenericPdu {
- /**
- * Empty constructor.
- * Since the Pdu corresponding to this class is constructed
- * by the Proxy-Relay server, this class is only instantiated
- * by the Pdu Parser.
- *
- * @throws InvalidHeaderValueException if error occurs.
- */
- public SendConf() throws InvalidHeaderValueException {
- super();
- setMessageType(PduHeaders.MESSAGE_TYPE_SEND_CONF);
- }
-
- /**
- * Constructor with given headers.
- *
- * @param headers Headers for this PDU.
- */
- SendConf(PduHeaders headers) {
- super(headers);
- }
-
- /**
- * Get Message-ID value.
- *
- * @return the value
- */
- public byte[] getMessageId() {
- return mPduHeaders.getTextString(PduHeaders.MESSAGE_ID);
- }
-
- /**
- * Set Message-ID value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setMessageId(byte[] value) {
- mPduHeaders.setTextString(value, PduHeaders.MESSAGE_ID);
- }
-
- /**
- * Get X-Mms-Response-Status.
- *
- * @return the value
- */
- public int getResponseStatus() {
- return mPduHeaders.getOctet(PduHeaders.RESPONSE_STATUS);
- }
-
- /**
- * Set X-Mms-Response-Status.
- *
- * @param value the values
- * @throws InvalidHeaderValueException if the value is invalid.
- */
- public void setResponseStatus(int value) throws InvalidHeaderValueException {
- mPduHeaders.setOctet(value, PduHeaders.RESPONSE_STATUS);
- }
-
- /**
- * Get X-Mms-Transaction-Id field value.
- *
- * @return the X-Mms-Report-Allowed value
- */
- public byte[] getTransactionId() {
- return mPduHeaders.getTextString(PduHeaders.TRANSACTION_ID);
- }
-
- /**
- * Set X-Mms-Transaction-Id field value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setTransactionId(byte[] value) {
- mPduHeaders.setTextString(value, PduHeaders.TRANSACTION_ID);
- }
-
- /*
- * Optional, not supported header fields:
- *
- * public byte[] getContentLocation() {return null;}
- * public void setContentLocation(byte[] value) {}
- *
- * public EncodedStringValue getResponseText() {return null;}
- * public void setResponseText(EncodedStringValue value) {}
- *
- * public byte getStoreStatus() {return 0x00;}
- * public void setStoreStatus(byte value) {}
- *
- * public byte[] getStoreStatusText() {return null;}
- * public void setStoreStatusText(byte[] value) {}
- */
-}
diff --git a/core/java/com/google/android/mms/pdu/SendReq.java b/core/java/com/google/android/mms/pdu/SendReq.java
deleted file mode 100644
index 597cd00b9961..000000000000
--- a/core/java/com/google/android/mms/pdu/SendReq.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * Copyright (C) 2007-2008 Esmertec AG.
- * Copyright (C) 2007-2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.pdu;
-
-import android.util.Log;
-
-import com.google.android.mms.InvalidHeaderValueException;
-
-public class SendReq extends MultimediaMessagePdu {
- private static final String TAG = "SendReq";
-
- public SendReq() {
- super();
-
- try {
- setMessageType(PduHeaders.MESSAGE_TYPE_SEND_REQ);
- setMmsVersion(PduHeaders.CURRENT_MMS_VERSION);
- // FIXME: Content-type must be decided according to whether
- // SMIL part present.
- setContentType("application/vnd.wap.multipart.related".getBytes());
- setFrom(new EncodedStringValue(PduHeaders.FROM_INSERT_ADDRESS_TOKEN_STR.getBytes()));
- setTransactionId(generateTransactionId());
- } catch (InvalidHeaderValueException e) {
- // Impossible to reach here since all headers we set above are valid.
- Log.e(TAG, "Unexpected InvalidHeaderValueException.", e);
- throw new RuntimeException(e);
- }
- }
-
- private byte[] generateTransactionId() {
- String transactionId = "T" + Long.toHexString(System.currentTimeMillis());
- return transactionId.getBytes();
- }
-
- /**
- * Constructor, used when composing a M-Send.req pdu.
- *
- * @param contentType the content type value
- * @param from the from value
- * @param mmsVersion current viersion of mms
- * @param transactionId the transaction-id value
- * @throws InvalidHeaderValueException if parameters are invalid.
- * NullPointerException if contentType, form or transactionId is null.
- */
- public SendReq(byte[] contentType,
- EncodedStringValue from,
- int mmsVersion,
- byte[] transactionId) throws InvalidHeaderValueException {
- super();
- setMessageType(PduHeaders.MESSAGE_TYPE_SEND_REQ);
- setContentType(contentType);
- setFrom(from);
- setMmsVersion(mmsVersion);
- setTransactionId(transactionId);
- }
-
- /**
- * Constructor with given headers.
- *
- * @param headers Headers for this PDU.
- */
- SendReq(PduHeaders headers) {
- super(headers);
- }
-
- /**
- * Constructor with given headers and body
- *
- * @param headers Headers for this PDU.
- * @param body Body of this PDu.
- */
- SendReq(PduHeaders headers, PduBody body) {
- super(headers, body);
- }
-
- /**
- * Get Bcc value.
- *
- * @return the value
- */
- public EncodedStringValue[] getBcc() {
- return mPduHeaders.getEncodedStringValues(PduHeaders.BCC);
- }
-
- /**
- * Add a "BCC" value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void addBcc(EncodedStringValue value) {
- mPduHeaders.appendEncodedStringValue(value, PduHeaders.BCC);
- }
-
- /**
- * Set "BCC" value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setBcc(EncodedStringValue[] value) {
- mPduHeaders.setEncodedStringValues(value, PduHeaders.BCC);
- }
-
- /**
- * Get CC value.
- *
- * @return the value
- */
- public EncodedStringValue[] getCc() {
- return mPduHeaders.getEncodedStringValues(PduHeaders.CC);
- }
-
- /**
- * Add a "CC" value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void addCc(EncodedStringValue value) {
- mPduHeaders.appendEncodedStringValue(value, PduHeaders.CC);
- }
-
- /**
- * Set "CC" value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setCc(EncodedStringValue[] value) {
- mPduHeaders.setEncodedStringValues(value, PduHeaders.CC);
- }
-
- /**
- * Get Content-type value.
- *
- * @return the value
- */
- public byte[] getContentType() {
- return mPduHeaders.getTextString(PduHeaders.CONTENT_TYPE);
- }
-
- /**
- * Set Content-type value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setContentType(byte[] value) {
- mPduHeaders.setTextString(value, PduHeaders.CONTENT_TYPE);
- }
-
- /**
- * Get X-Mms-Delivery-Report value.
- *
- * @return the value
- */
- public int getDeliveryReport() {
- return mPduHeaders.getOctet(PduHeaders.DELIVERY_REPORT);
- }
-
- /**
- * Set X-Mms-Delivery-Report value.
- *
- * @param value the value
- * @throws InvalidHeaderValueException if the value is invalid.
- */
- public void setDeliveryReport(int value) throws InvalidHeaderValueException {
- mPduHeaders.setOctet(value, PduHeaders.DELIVERY_REPORT);
- }
-
- /**
- * Get X-Mms-Expiry value.
- *
- * Expiry-value = Value-length
- * (Absolute-token Date-value | Relative-token Delta-seconds-value)
- *
- * @return the value
- */
- public long getExpiry() {
- return mPduHeaders.getLongInteger(PduHeaders.EXPIRY);
- }
-
- /**
- * Set X-Mms-Expiry value.
- *
- * @param value the value
- */
- public void setExpiry(long value) {
- mPduHeaders.setLongInteger(value, PduHeaders.EXPIRY);
- }
-
- /**
- * Get X-Mms-MessageSize value.
- *
- * Expiry-value = size of message
- *
- * @return the value
- */
- public long getMessageSize() {
- return mPduHeaders.getLongInteger(PduHeaders.MESSAGE_SIZE);
- }
-
- /**
- * Set X-Mms-MessageSize value.
- *
- * @param value the value
- */
- public void setMessageSize(long value) {
- mPduHeaders.setLongInteger(value, PduHeaders.MESSAGE_SIZE);
- }
-
- /**
- * Get X-Mms-Message-Class value.
- * Message-class-value = Class-identifier | Token-text
- * Class-identifier = Personal | Advertisement | Informational | Auto
- *
- * @return the value
- */
- public byte[] getMessageClass() {
- return mPduHeaders.getTextString(PduHeaders.MESSAGE_CLASS);
- }
-
- /**
- * Set X-Mms-Message-Class value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setMessageClass(byte[] value) {
- mPduHeaders.setTextString(value, PduHeaders.MESSAGE_CLASS);
- }
-
- /**
- * Get X-Mms-Read-Report value.
- *
- * @return the value
- */
- public int getReadReport() {
- return mPduHeaders.getOctet(PduHeaders.READ_REPORT);
- }
-
- /**
- * Set X-Mms-Read-Report value.
- *
- * @param value the value
- * @throws InvalidHeaderValueException if the value is invalid.
- */
- public void setReadReport(int value) throws InvalidHeaderValueException {
- mPduHeaders.setOctet(value, PduHeaders.READ_REPORT);
- }
-
- /**
- * Set "To" value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setTo(EncodedStringValue[] value) {
- mPduHeaders.setEncodedStringValues(value, PduHeaders.TO);
- }
-
- /**
- * Get X-Mms-Transaction-Id field value.
- *
- * @return the X-Mms-Report-Allowed value
- */
- public byte[] getTransactionId() {
- return mPduHeaders.getTextString(PduHeaders.TRANSACTION_ID);
- }
-
- /**
- * Set X-Mms-Transaction-Id field value.
- *
- * @param value the value
- * @throws NullPointerException if the value is null.
- */
- public void setTransactionId(byte[] value) {
- mPduHeaders.setTextString(value, PduHeaders.TRANSACTION_ID);
- }
-
- /*
- * Optional, not supported header fields:
- *
- * public byte getAdaptationAllowed() {return 0};
- * public void setAdaptationAllowed(btye value) {};
- *
- * public byte[] getApplicId() {return null;}
- * public void setApplicId(byte[] value) {}
- *
- * public byte[] getAuxApplicId() {return null;}
- * public void getAuxApplicId(byte[] value) {}
- *
- * public byte getContentClass() {return 0x00;}
- * public void setApplicId(byte value) {}
- *
- * public long getDeliveryTime() {return 0};
- * public void setDeliveryTime(long value) {};
- *
- * public byte getDrmContent() {return 0x00;}
- * public void setDrmContent(byte value) {}
- *
- * public MmFlagsValue getMmFlags() {return null;}
- * public void setMmFlags(MmFlagsValue value) {}
- *
- * public MmStateValue getMmState() {return null;}
- * public void getMmState(MmStateValue value) {}
- *
- * public byte[] getReplyApplicId() {return 0x00;}
- * public void setReplyApplicId(byte[] value) {}
- *
- * public byte getReplyCharging() {return 0x00;}
- * public void setReplyCharging(byte value) {}
- *
- * public byte getReplyChargingDeadline() {return 0x00;}
- * public void setReplyChargingDeadline(byte value) {}
- *
- * public byte[] getReplyChargingId() {return 0x00;}
- * public void setReplyChargingId(byte[] value) {}
- *
- * public long getReplyChargingSize() {return 0;}
- * public void setReplyChargingSize(long value) {}
- *
- * public byte[] getReplyApplicId() {return 0x00;}
- * public void setReplyApplicId(byte[] value) {}
- *
- * public byte getStore() {return 0x00;}
- * public void setStore(byte value) {}
- */
-}
diff --git a/core/java/com/google/android/mms/pdu/package.html b/core/java/com/google/android/mms/pdu/package.html
deleted file mode 100755
index c9f96a66ab3b..000000000000
--- a/core/java/com/google/android/mms/pdu/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-{@hide}
-
-
diff --git a/core/java/com/google/android/mms/util/AbstractCache.java b/core/java/com/google/android/mms/util/AbstractCache.java
deleted file mode 100644
index 39b2abf15a64..000000000000
--- a/core/java/com/google/android/mms/util/AbstractCache.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2008 Esmertec AG.
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.util;
-
-import android.util.Log;
-
-import java.util.HashMap;
-
-public abstract class AbstractCache {
- private static final String TAG = "AbstractCache";
- private static final boolean DEBUG = false;
- private static final boolean LOCAL_LOGV = false;
-
- private static final int MAX_CACHED_ITEMS = 500;
-
- private final HashMap> mCacheMap;
-
- protected AbstractCache() {
- mCacheMap = new HashMap>();
- }
-
- public boolean put(K key, V value) {
- if (LOCAL_LOGV) {
- Log.v(TAG, "Trying to put " + key + " into cache.");
- }
-
- if (mCacheMap.size() >= MAX_CACHED_ITEMS) {
- // TODO Should remove the oldest or least hit cached entry
- // and then cache the new one.
- if (LOCAL_LOGV) {
- Log.v(TAG, "Failed! size limitation reached.");
- }
- return false;
- }
-
- if (key != null) {
- CacheEntry cacheEntry = new CacheEntry();
- cacheEntry.value = value;
- mCacheMap.put(key, cacheEntry);
-
- if (LOCAL_LOGV) {
- Log.v(TAG, key + " cached, " + mCacheMap.size() + " items total.");
- }
- return true;
- }
- return false;
- }
-
- public V get(K key) {
- if (LOCAL_LOGV) {
- Log.v(TAG, "Trying to get " + key + " from cache.");
- }
-
- if (key != null) {
- CacheEntry cacheEntry = mCacheMap.get(key);
- if (cacheEntry != null) {
- cacheEntry.hit++;
- if (LOCAL_LOGV) {
- Log.v(TAG, key + " hit " + cacheEntry.hit + " times.");
- }
- return cacheEntry.value;
- }
- }
- return null;
- }
-
- public V purge(K key) {
- if (LOCAL_LOGV) {
- Log.v(TAG, "Trying to purge " + key);
- }
-
- CacheEntry v = mCacheMap.remove(key);
-
- if (LOCAL_LOGV) {
- Log.v(TAG, mCacheMap.size() + " items cached.");
- }
-
- return v != null ? v.value : null;
- }
-
- public void purgeAll() {
- if (LOCAL_LOGV) {
- Log.v(TAG, "Purging cache, " + mCacheMap.size()
- + " items dropped.");
- }
- mCacheMap.clear();
- }
-
- public int size() {
- return mCacheMap.size();
- }
-
- private static class CacheEntry {
- int hit;
- V value;
- }
-}
diff --git a/core/java/com/google/android/mms/util/DownloadDrmHelper.java b/core/java/com/google/android/mms/util/DownloadDrmHelper.java
deleted file mode 100644
index 6852eca4890d..000000000000
--- a/core/java/com/google/android/mms/util/DownloadDrmHelper.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.android.mms.util;
-
-import android.content.Context;
-import android.drm.DrmManagerClient;
-import android.util.Log;
-
-public class DownloadDrmHelper {
- private static final String TAG = "DownloadDrmHelper";
-
- /** The MIME type of special DRM files */
- public static final String MIMETYPE_DRM_MESSAGE = "application/vnd.oma.drm.message";
-
- /** The extensions of special DRM files */
- public static final String EXTENSION_DRM_MESSAGE = ".dm";
-
- public static final String EXTENSION_INTERNAL_FWDL = ".fl";
-
- /**
- * Checks if the Media Type is a DRM Media Type
- *
- * @param drmManagerClient A DrmManagerClient
- * @param mimetype Media Type to check
- * @return True if the Media Type is DRM else false
- */
- public static boolean isDrmMimeType(Context context, String mimetype) {
- boolean result = false;
- if (context != null) {
- try {
- DrmManagerClient drmClient = new DrmManagerClient(context);
- if (drmClient != null && mimetype != null && mimetype.length() > 0) {
- result = drmClient.canHandle("", mimetype);
- }
- } catch (IllegalArgumentException e) {
- Log.w(TAG,
- "DrmManagerClient instance could not be created, context is Illegal.");
- } catch (IllegalStateException e) {
- Log.w(TAG, "DrmManagerClient didn't initialize properly.");
- }
- }
- return result;
- }
-
- /**
- * Checks if the Media Type needs to be DRM converted
- *
- * @param mimetype Media type of the content
- * @return True if convert is needed else false
- */
- public static boolean isDrmConvertNeeded(String mimetype) {
- return MIMETYPE_DRM_MESSAGE.equals(mimetype);
- }
-
- /**
- * Modifies the file extension for a DRM Forward Lock file NOTE: This
- * function shouldn't be called if the file shouldn't be DRM converted
- */
- public static String modifyDrmFwLockFileExtension(String filename) {
- if (filename != null) {
- int extensionIndex;
- extensionIndex = filename.lastIndexOf(".");
- if (extensionIndex != -1) {
- filename = filename.substring(0, extensionIndex);
- }
- filename = filename.concat(EXTENSION_INTERNAL_FWDL);
- }
- return filename;
- }
-
- /**
- * Gets the original mime type of DRM protected content.
- *
- * @param context The context
- * @param path Path to the file
- * @param containingMime The current mime type of of the file i.e. the
- * containing mime type
- * @return The original mime type of the file if DRM protected else the
- * currentMime
- */
- public static String getOriginalMimeType(Context context, String path, String containingMime) {
- String result = containingMime;
- DrmManagerClient drmClient = new DrmManagerClient(context);
- try {
- if (drmClient.canHandle(path, null)) {
- result = drmClient.getOriginalMimeType(path);
- }
- } catch (IllegalArgumentException ex) {
- Log.w(TAG,
- "Can't get original mime type since path is null or empty string.");
- } catch (IllegalStateException ex) {
- Log.w(TAG, "DrmManagerClient didn't initialize properly.");
- }
- return result;
- }
-}
diff --git a/core/java/com/google/android/mms/util/DrmConvertSession.java b/core/java/com/google/android/mms/util/DrmConvertSession.java
deleted file mode 100644
index 2d8f274f2bd4..000000000000
--- a/core/java/com/google/android/mms/util/DrmConvertSession.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.google.android.mms.util;
-
-import android.content.Context;
-import android.drm.DrmConvertedStatus;
-import android.drm.DrmManagerClient;
-import android.util.Log;
-import android.provider.Downloads;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-
-public class DrmConvertSession {
- private DrmManagerClient mDrmClient;
- private int mConvertSessionId;
- private static final String TAG = "DrmConvertSession";
-
- private DrmConvertSession(DrmManagerClient drmClient, int convertSessionId) {
- mDrmClient = drmClient;
- mConvertSessionId = convertSessionId;
- }
-
- /**
- * Start of converting a file.
- *
- * @param context The context of the application running the convert session.
- * @param mimeType Mimetype of content that shall be converted.
- * @return A convert session or null in case an error occurs.
- */
- public static DrmConvertSession open(Context context, String mimeType) {
- DrmManagerClient drmClient = null;
- int convertSessionId = -1;
- if (context != null && mimeType != null && !mimeType.equals("")) {
- try {
- drmClient = new DrmManagerClient(context);
- try {
- convertSessionId = drmClient.openConvertSession(mimeType);
- } catch (IllegalArgumentException e) {
- Log.w(TAG, "Conversion of Mimetype: " + mimeType
- + " is not supported.", e);
- } catch (IllegalStateException e) {
- Log.w(TAG, "Could not access Open DrmFramework.", e);
- }
- } catch (IllegalArgumentException e) {
- Log.w(TAG,
- "DrmManagerClient instance could not be created, context is Illegal.");
- } catch (IllegalStateException e) {
- Log.w(TAG, "DrmManagerClient didn't initialize properly.");
- }
- }
-
- if (drmClient == null || convertSessionId < 0) {
- return null;
- } else {
- return new DrmConvertSession(drmClient, convertSessionId);
- }
- }
- /**
- * Convert a buffer of data to protected format.
- *
- * @param buffer Buffer filled with data to convert.
- * @param size The number of bytes that shall be converted.
- * @return A Buffer filled with converted data, if execution is ok, in all
- * other case null.
- */
- public byte [] convert(byte[] inBuffer, int size) {
- byte[] result = null;
- if (inBuffer != null) {
- DrmConvertedStatus convertedStatus = null;
- try {
- if (size != inBuffer.length) {
- byte[] buf = new byte[size];
- System.arraycopy(inBuffer, 0, buf, 0, size);
- convertedStatus = mDrmClient.convertData(mConvertSessionId, buf);
- } else {
- convertedStatus = mDrmClient.convertData(mConvertSessionId, inBuffer);
- }
-
- if (convertedStatus != null &&
- convertedStatus.statusCode == DrmConvertedStatus.STATUS_OK &&
- convertedStatus.convertedData != null) {
- result = convertedStatus.convertedData;
- }
- } catch (IllegalArgumentException e) {
- Log.w(TAG, "Buffer with data to convert is illegal. Convertsession: "
- + mConvertSessionId, e);
- } catch (IllegalStateException e) {
- Log.w(TAG, "Could not convert data. Convertsession: " +
- mConvertSessionId, e);
- }
- } else {
- throw new IllegalArgumentException("Parameter inBuffer is null");
- }
- return result;
- }
-
- /**
- * Ends a conversion session of a file.
- *
- * @param fileName The filename of the converted file.
- * @return Downloads.Impl.STATUS_SUCCESS if execution is ok.
- * Downloads.Impl.STATUS_FILE_ERROR in case converted file can not
- * be accessed. Downloads.Impl.STATUS_NOT_ACCEPTABLE if a problem
- * occurs when accessing drm framework.
- * Downloads.Impl.STATUS_UNKNOWN_ERROR if a general error occurred.
- */
- public int close(String filename) {
- DrmConvertedStatus convertedStatus = null;
- int result = Downloads.Impl.STATUS_UNKNOWN_ERROR;
- if (mDrmClient != null && mConvertSessionId >= 0) {
- try {
- convertedStatus = mDrmClient.closeConvertSession(mConvertSessionId);
- if (convertedStatus == null ||
- convertedStatus.statusCode != DrmConvertedStatus.STATUS_OK ||
- convertedStatus.convertedData == null) {
- result = Downloads.Impl.STATUS_NOT_ACCEPTABLE;
- } else {
- RandomAccessFile rndAccessFile = null;
- try {
- rndAccessFile = new RandomAccessFile(filename, "rw");
- rndAccessFile.seek(convertedStatus.offset);
- rndAccessFile.write(convertedStatus.convertedData);
- result = Downloads.Impl.STATUS_SUCCESS;
- } catch (FileNotFoundException e) {
- result = Downloads.Impl.STATUS_FILE_ERROR;
- Log.w(TAG, "File: " + filename + " could not be found.", e);
- } catch (IOException e) {
- result = Downloads.Impl.STATUS_FILE_ERROR;
- Log.w(TAG, "Could not access File: " + filename + " .", e);
- } catch (IllegalArgumentException e) {
- result = Downloads.Impl.STATUS_FILE_ERROR;
- Log.w(TAG, "Could not open file in mode: rw", e);
- } catch (SecurityException e) {
- Log.w(TAG, "Access to File: " + filename +
- " was denied denied by SecurityManager.", e);
- } finally {
- if (rndAccessFile != null) {
- try {
- rndAccessFile.close();
- } catch (IOException e) {
- result = Downloads.Impl.STATUS_FILE_ERROR;
- Log.w(TAG, "Failed to close File:" + filename
- + ".", e);
- }
- }
- }
- }
- } catch (IllegalStateException e) {
- Log.w(TAG, "Could not close convertsession. Convertsession: " +
- mConvertSessionId, e);
- }
- }
- return result;
- }
-}
diff --git a/core/java/com/google/android/mms/util/PduCache.java b/core/java/com/google/android/mms/util/PduCache.java
deleted file mode 100644
index de83124bad7b..000000000000
--- a/core/java/com/google/android/mms/util/PduCache.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Copyright (C) 2008 Esmertec AG.
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.util;
-
-import android.content.ContentUris;
-import android.content.UriMatcher;
-import android.net.Uri;
-import android.provider.Telephony.Mms;
-import android.util.Log;
-
-import java.util.HashMap;
-import java.util.HashSet;
-
-public final class PduCache extends AbstractCache {
- private static final String TAG = "PduCache";
- private static final boolean DEBUG = false;
- private static final boolean LOCAL_LOGV = false;
-
- private static final int MMS_ALL = 0;
- private static final int MMS_ALL_ID = 1;
- private static final int MMS_INBOX = 2;
- private static final int MMS_INBOX_ID = 3;
- private static final int MMS_SENT = 4;
- private static final int MMS_SENT_ID = 5;
- private static final int MMS_DRAFTS = 6;
- private static final int MMS_DRAFTS_ID = 7;
- private static final int MMS_OUTBOX = 8;
- private static final int MMS_OUTBOX_ID = 9;
- private static final int MMS_CONVERSATION = 10;
- private static final int MMS_CONVERSATION_ID = 11;
-
- private static final UriMatcher URI_MATCHER;
- private static final HashMap MATCH_TO_MSGBOX_ID_MAP;
-
- private static PduCache sInstance;
-
- static {
- URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH);
- URI_MATCHER.addURI("mms", null, MMS_ALL);
- URI_MATCHER.addURI("mms", "#", MMS_ALL_ID);
- URI_MATCHER.addURI("mms", "inbox", MMS_INBOX);
- URI_MATCHER.addURI("mms", "inbox/#", MMS_INBOX_ID);
- URI_MATCHER.addURI("mms", "sent", MMS_SENT);
- URI_MATCHER.addURI("mms", "sent/#", MMS_SENT_ID);
- URI_MATCHER.addURI("mms", "drafts", MMS_DRAFTS);
- URI_MATCHER.addURI("mms", "drafts/#", MMS_DRAFTS_ID);
- URI_MATCHER.addURI("mms", "outbox", MMS_OUTBOX);
- URI_MATCHER.addURI("mms", "outbox/#", MMS_OUTBOX_ID);
- URI_MATCHER.addURI("mms-sms", "conversations", MMS_CONVERSATION);
- URI_MATCHER.addURI("mms-sms", "conversations/#", MMS_CONVERSATION_ID);
-
- MATCH_TO_MSGBOX_ID_MAP = new HashMap();
- MATCH_TO_MSGBOX_ID_MAP.put(MMS_INBOX, Mms.MESSAGE_BOX_INBOX);
- MATCH_TO_MSGBOX_ID_MAP.put(MMS_SENT, Mms.MESSAGE_BOX_SENT);
- MATCH_TO_MSGBOX_ID_MAP.put(MMS_DRAFTS, Mms.MESSAGE_BOX_DRAFTS);
- MATCH_TO_MSGBOX_ID_MAP.put(MMS_OUTBOX, Mms.MESSAGE_BOX_OUTBOX);
- }
-
- private final HashMap> mMessageBoxes;
- private final HashMap> mThreads;
- private final HashSet mUpdating;
-
- private PduCache() {
- mMessageBoxes = new HashMap>();
- mThreads = new HashMap>();
- mUpdating = new HashSet();
- }
-
- synchronized public static final PduCache getInstance() {
- if (sInstance == null) {
- if (LOCAL_LOGV) {
- Log.v(TAG, "Constructing new PduCache instance.");
- }
- sInstance = new PduCache();
- }
- return sInstance;
- }
-
- @Override
- synchronized public boolean put(Uri uri, PduCacheEntry entry) {
- int msgBoxId = entry.getMessageBox();
- HashSet msgBox = mMessageBoxes.get(msgBoxId);
- if (msgBox == null) {
- msgBox = new HashSet();
- mMessageBoxes.put(msgBoxId, msgBox);
- }
-
- long threadId = entry.getThreadId();
- HashSet thread = mThreads.get(threadId);
- if (thread == null) {
- thread = new HashSet();
- mThreads.put(threadId, thread);
- }
-
- Uri finalKey = normalizeKey(uri);
- boolean result = super.put(finalKey, entry);
- if (result) {
- msgBox.add(finalKey);
- thread.add(finalKey);
- }
- setUpdating(uri, false);
- return result;
- }
-
- synchronized public void setUpdating(Uri uri, boolean updating) {
- if (updating) {
- mUpdating.add(uri);
- } else {
- mUpdating.remove(uri);
- }
- }
-
- synchronized public boolean isUpdating(Uri uri) {
- return mUpdating.contains(uri);
- }
-
- @Override
- synchronized public PduCacheEntry purge(Uri uri) {
- int match = URI_MATCHER.match(uri);
- switch (match) {
- case MMS_ALL_ID:
- return purgeSingleEntry(uri);
- case MMS_INBOX_ID:
- case MMS_SENT_ID:
- case MMS_DRAFTS_ID:
- case MMS_OUTBOX_ID:
- String msgId = uri.getLastPathSegment();
- return purgeSingleEntry(Uri.withAppendedPath(Mms.CONTENT_URI, msgId));
- // Implicit batch of purge, return null.
- case MMS_ALL:
- case MMS_CONVERSATION:
- purgeAll();
- return null;
- case MMS_INBOX:
- case MMS_SENT:
- case MMS_DRAFTS:
- case MMS_OUTBOX:
- purgeByMessageBox(MATCH_TO_MSGBOX_ID_MAP.get(match));
- return null;
- case MMS_CONVERSATION_ID:
- purgeByThreadId(ContentUris.parseId(uri));
- return null;
- default:
- return null;
- }
- }
-
- private PduCacheEntry purgeSingleEntry(Uri key) {
- mUpdating.remove(key);
- PduCacheEntry entry = super.purge(key);
- if (entry != null) {
- removeFromThreads(key, entry);
- removeFromMessageBoxes(key, entry);
- return entry;
- }
- return null;
- }
-
- @Override
- synchronized public void purgeAll() {
- super.purgeAll();
-
- mMessageBoxes.clear();
- mThreads.clear();
- mUpdating.clear();
- }
-
- /**
- * @param uri The Uri to be normalized.
- * @return Uri The normalized key of cached entry.
- */
- private Uri normalizeKey(Uri uri) {
- int match = URI_MATCHER.match(uri);
- Uri normalizedKey = null;
-
- switch (match) {
- case MMS_ALL_ID:
- normalizedKey = uri;
- break;
- case MMS_INBOX_ID:
- case MMS_SENT_ID:
- case MMS_DRAFTS_ID:
- case MMS_OUTBOX_ID:
- String msgId = uri.getLastPathSegment();
- normalizedKey = Uri.withAppendedPath(Mms.CONTENT_URI, msgId);
- break;
- default:
- return null;
- }
-
- if (LOCAL_LOGV) {
- Log.v(TAG, uri + " -> " + normalizedKey);
- }
- return normalizedKey;
- }
-
- private void purgeByMessageBox(Integer msgBoxId) {
- if (LOCAL_LOGV) {
- Log.v(TAG, "Purge cache in message box: " + msgBoxId);
- }
-
- if (msgBoxId != null) {
- HashSet msgBox = mMessageBoxes.remove(msgBoxId);
- if (msgBox != null) {
- for (Uri key : msgBox) {
- mUpdating.remove(key);
- PduCacheEntry entry = super.purge(key);
- if (entry != null) {
- removeFromThreads(key, entry);
- }
- }
- }
- }
- }
-
- private void removeFromThreads(Uri key, PduCacheEntry entry) {
- HashSet thread = mThreads.get(entry.getThreadId());
- if (thread != null) {
- thread.remove(key);
- }
- }
-
- private void purgeByThreadId(long threadId) {
- if (LOCAL_LOGV) {
- Log.v(TAG, "Purge cache in thread: " + threadId);
- }
-
- HashSet thread = mThreads.remove(threadId);
- if (thread != null) {
- for (Uri key : thread) {
- mUpdating.remove(key);
- PduCacheEntry entry = super.purge(key);
- if (entry != null) {
- removeFromMessageBoxes(key, entry);
- }
- }
- }
- }
-
- private void removeFromMessageBoxes(Uri key, PduCacheEntry entry) {
- HashSet msgBox = mThreads.get(Long.valueOf(entry.getMessageBox()));
- if (msgBox != null) {
- msgBox.remove(key);
- }
- }
-}
diff --git a/core/java/com/google/android/mms/util/PduCacheEntry.java b/core/java/com/google/android/mms/util/PduCacheEntry.java
deleted file mode 100644
index 8b4138628113..000000000000
--- a/core/java/com/google/android/mms/util/PduCacheEntry.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2008 Esmertec AG.
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.util;
-
-import com.google.android.mms.pdu.GenericPdu;
-
-public final class PduCacheEntry {
- private final GenericPdu mPdu;
- private final int mMessageBox;
- private final long mThreadId;
-
- public PduCacheEntry(GenericPdu pdu, int msgBox, long threadId) {
- mPdu = pdu;
- mMessageBox = msgBox;
- mThreadId = threadId;
- }
-
- public GenericPdu getPdu() {
- return mPdu;
- }
-
- public int getMessageBox() {
- return mMessageBox;
- }
-
- public long getThreadId() {
- return mThreadId;
- }
-}
diff --git a/core/java/com/google/android/mms/util/SqliteWrapper.java b/core/java/com/google/android/mms/util/SqliteWrapper.java
deleted file mode 100644
index bcdac22ce142..000000000000
--- a/core/java/com/google/android/mms/util/SqliteWrapper.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2008 Esmertec AG.
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.mms.util;
-
-import android.app.ActivityManager;
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteException;
-import android.net.Uri;
-import android.util.Log;
-import android.widget.Toast;
-
-public final class SqliteWrapper {
- private static final String TAG = "SqliteWrapper";
- private static final String SQLITE_EXCEPTION_DETAIL_MESSAGE
- = "unable to open database file";
-
- private SqliteWrapper() {
- // Forbidden being instantiated.
- }
-
- // FIXME: It looks like outInfo.lowMemory does not work well as we expected.
- // after run command: adb shell fillup -p 100, outInfo.lowMemory is still false.
- private static boolean isLowMemory(Context context) {
- if (null == context) {
- return false;
- }
-
- ActivityManager am = (ActivityManager)
- context.getSystemService(Context.ACTIVITY_SERVICE);
- ActivityManager.MemoryInfo outInfo = new ActivityManager.MemoryInfo();
- am.getMemoryInfo(outInfo);
-
- return outInfo.lowMemory;
- }
-
- // FIXME: need to optimize this method.
- private static boolean isLowMemory(SQLiteException e) {
- return e.getMessage().equals(SQLITE_EXCEPTION_DETAIL_MESSAGE);
- }
-
- public static void checkSQLiteException(Context context, SQLiteException e) {
- if (isLowMemory(e)) {
- Toast.makeText(context, com.android.internal.R.string.low_memory,
- Toast.LENGTH_SHORT).show();
- } else {
- throw e;
- }
- }
-
- public static Cursor query(Context context, ContentResolver resolver, Uri uri,
- String[] projection, String selection, String[] selectionArgs, String sortOrder) {
- try {
- return resolver.query(uri, projection, selection, selectionArgs, sortOrder);
- } catch (SQLiteException e) {
- Log.e(TAG, "Catch a SQLiteException when query: ", e);
- checkSQLiteException(context, e);
- return null;
- }
- }
-
- public static boolean requery(Context context, Cursor cursor) {
- try {
- return cursor.requery();
- } catch (SQLiteException e) {
- Log.e(TAG, "Catch a SQLiteException when requery: ", e);
- checkSQLiteException(context, e);
- return false;
- }
- }
- public static int update(Context context, ContentResolver resolver, Uri uri,
- ContentValues values, String where, String[] selectionArgs) {
- try {
- return resolver.update(uri, values, where, selectionArgs);
- } catch (SQLiteException e) {
- Log.e(TAG, "Catch a SQLiteException when update: ", e);
- checkSQLiteException(context, e);
- return -1;
- }
- }
-
- public static int delete(Context context, ContentResolver resolver, Uri uri,
- String where, String[] selectionArgs) {
- try {
- return resolver.delete(uri, where, selectionArgs);
- } catch (SQLiteException e) {
- Log.e(TAG, "Catch a SQLiteException when delete: ", e);
- checkSQLiteException(context, e);
- return -1;
- }
- }
-
- public static Uri insert(Context context, ContentResolver resolver,
- Uri uri, ContentValues values) {
- try {
- return resolver.insert(uri, values);
- } catch (SQLiteException e) {
- Log.e(TAG, "Catch a SQLiteException when insert: ", e);
- checkSQLiteException(context, e);
- return null;
- }
- }
-}
diff --git a/core/java/com/google/android/mms/util/package.html b/core/java/com/google/android/mms/util/package.html
deleted file mode 100755
index c9f96a66ab3b..000000000000
--- a/core/java/com/google/android/mms/util/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-{@hide}
-
-
diff --git a/core/tests/coretests/Android.mk b/core/tests/coretests/Android.mk
index 88f3f348e76b..b6b15c46fb5e 100644
--- a/core/tests/coretests/Android.mk
+++ b/core/tests/coretests/Android.mk
@@ -23,7 +23,7 @@ LOCAL_SRC_FILES := \
LOCAL_DX_FLAGS := --core-library
LOCAL_STATIC_JAVA_LIBRARIES := core-tests android-common frameworks-core-util-lib mockwebserver guava littlemock
-LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common
LOCAL_PACKAGE_NAME := FrameworksCoreTests
LOCAL_CERTIFICATE := platform
diff --git a/packages/SettingsProvider/Android.mk b/packages/SettingsProvider/Android.mk
index bf4ab1b70aeb..a2ea55465239 100644
--- a/packages/SettingsProvider/Android.mk
+++ b/packages/SettingsProvider/Android.mk
@@ -5,7 +5,7 @@ LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_JAVA_LIBRARIES :=
+LOCAL_JAVA_LIBRARIES := telephony-common
LOCAL_PACKAGE_NAME := SettingsProvider
LOCAL_CERTIFICATE := platform
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 423c802f2881..de078d2039d3 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -33,12 +33,14 @@ import android.net.ConnectivityManager;
import android.os.SystemProperties;
import android.provider.Settings;
import android.provider.Settings.Secure;
+import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import com.android.internal.content.PackageHelper;
import com.android.internal.telephony.BaseCommands;
import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.RILConstants;
import com.android.internal.util.XmlUtils;
import com.android.internal.widget.LockPatternUtils;
@@ -1590,7 +1592,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
// Set the preferred network mode to 0 = Global, CDMA default
int type;
- if (BaseCommands.getLteOnCdmaModeStatic() == Phone.LTE_ON_CDMA_TRUE) {
+ if (TelephonyManager.getLteOnCdmaModeStatic() == PhoneConstants.LTE_ON_CDMA_TRUE) {
type = Phone.NT_MODE_GLOBAL;
} else {
type = SystemProperties.getInt("ro.telephony.default_network",
diff --git a/packages/SystemUI/Android.mk b/packages/SystemUI/Android.mk
index c23a8a1d37ac..6026258d4382 100644
--- a/packages/SystemUI/Android.mk
+++ b/packages/SystemUI/Android.mk
@@ -6,7 +6,7 @@ LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src) \
../../../ex/carousel/java/com/android/ex/carousel/carousel.rs
-LOCAL_JAVA_LIBRARIES := services
+LOCAL_JAVA_LIBRARIES := services telephony-common
LOCAL_STATIC_JAVA_LIBRARIES := android-common-carousel
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CarrierLabel.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CarrierLabel.java
index 491fad11fad6..66494e459482 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CarrierLabel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CarrierLabel.java
@@ -20,13 +20,14 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.provider.Telephony;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Slog;
import android.view.View;
import android.widget.TextView;
+import com.android.internal.telephony.TelephonyIntents;
+
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;
@@ -60,7 +61,7 @@ public class CarrierLabel extends TextView {
if (!mAttached) {
mAttached = true;
IntentFilter filter = new IntentFilter();
- filter.addAction(Telephony.Intents.SPN_STRINGS_UPDATED_ACTION);
+ filter.addAction(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION);
getContext().registerReceiver(mIntentReceiver, filter, null, getHandler());
}
}
@@ -78,11 +79,11 @@ public class CarrierLabel extends TextView {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
- if (Telephony.Intents.SPN_STRINGS_UPDATED_ACTION.equals(action)) {
- updateNetworkName(intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_SPN, false),
- intent.getStringExtra(Telephony.Intents.EXTRA_SPN),
- intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_PLMN, false),
- intent.getStringExtra(Telephony.Intents.EXTRA_PLMN));
+ if (TelephonyIntents.SPN_STRINGS_UPDATED_ACTION.equals(action)) {
+ updateNetworkName(intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_SPN, false),
+ intent.getStringExtra(TelephonyIntents.EXTRA_SPN),
+ intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_PLMN, false),
+ intent.getStringExtra(TelephonyIntents.EXTRA_PLMN));
}
}
};
@@ -108,7 +109,7 @@ public class CarrierLabel extends TextView {
setText(str);
}
-
+
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
index 374226d3a536..9b8bd224e7fa 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
@@ -39,6 +39,7 @@ import android.telephony.TelephonyManager;
import android.util.Slog;
import com.android.internal.telephony.IccCard;
+import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.cdma.EriInfo;
import com.android.internal.telephony.cdma.TtyIntent;
@@ -76,7 +77,7 @@ public class PhoneStatusBarPolicy {
// Assume it's all good unless we hear otherwise. We don't always seem
// to get broadcasts that it *is* there.
- IccCard.State mSimState = IccCard.State.READY;
+ IccCardConstants.State mSimState = IccCardConstants.State.READY;
// ringer volume
private boolean mVolumeVisible;
@@ -205,26 +206,27 @@ public class PhoneStatusBarPolicy {
}
private final void updateSimState(Intent intent) {
- String stateExtra = intent.getStringExtra(IccCard.INTENT_KEY_ICC_STATE);
- if (IccCard.INTENT_VALUE_ICC_ABSENT.equals(stateExtra)) {
- mSimState = IccCard.State.ABSENT;
+ String stateExtra = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE);
+ if (IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(stateExtra)) {
+ mSimState = IccCardConstants.State.ABSENT;
}
- else if (IccCard.INTENT_VALUE_ICC_READY.equals(stateExtra)) {
- mSimState = IccCard.State.READY;
+ else if (IccCardConstants.INTENT_VALUE_ICC_READY.equals(stateExtra)) {
+ mSimState = IccCardConstants.State.READY;
}
- else if (IccCard.INTENT_VALUE_ICC_LOCKED.equals(stateExtra)) {
- final String lockedReason = intent.getStringExtra(IccCard.INTENT_KEY_LOCKED_REASON);
- if (IccCard.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) {
- mSimState = IccCard.State.PIN_REQUIRED;
+ else if (IccCardConstants.INTENT_VALUE_ICC_LOCKED.equals(stateExtra)) {
+ final String lockedReason =
+ intent.getStringExtra(IccCardConstants.INTENT_KEY_LOCKED_REASON);
+ if (IccCardConstants.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) {
+ mSimState = IccCardConstants.State.PIN_REQUIRED;
}
- else if (IccCard.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) {
- mSimState = IccCard.State.PUK_REQUIRED;
+ else if (IccCardConstants.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) {
+ mSimState = IccCardConstants.State.PUK_REQUIRED;
}
else {
- mSimState = IccCard.State.NETWORK_LOCKED;
+ mSimState = IccCardConstants.State.NETWORK_LOCKED;
}
} else {
- mSimState = IccCard.State.UNKNOWN;
+ mSimState = IccCardConstants.State.UNKNOWN;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
index 106826701348..4d22f3304f35 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
@@ -51,6 +51,7 @@ import android.widget.TextView;
import com.android.internal.app.IBatteryStats;
import com.android.internal.telephony.IccCard;
+import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.cdma.EriInfo;
import com.android.server.am.BatteryStatsService;
@@ -68,7 +69,7 @@ public class NetworkController extends BroadcastReceiver {
boolean mHspaDataDistinguishable;
final TelephonyManager mPhone;
boolean mDataConnected;
- IccCard.State mSimState = IccCard.State.READY;
+ IccCardConstants.State mSimState = IccCardConstants.State.READY;
int mPhoneState = TelephonyManager.CALL_STATE_IDLE;
int mDataNetType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
int mDataState = TelephonyManager.DATA_DISCONNECTED;
@@ -220,7 +221,7 @@ public class NetworkController extends BroadcastReceiver {
filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
- filter.addAction(Telephony.Intents.SPN_STRINGS_UPDATED_ACTION);
+ filter.addAction(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION);
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
filter.addAction(ConnectivityManager.INET_CONDITION_ACTION);
filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
@@ -335,11 +336,11 @@ public class NetworkController extends BroadcastReceiver {
updateSimState(intent);
updateDataIcon();
refreshViews();
- } else if (action.equals(Telephony.Intents.SPN_STRINGS_UPDATED_ACTION)) {
- updateNetworkName(intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_SPN, false),
- intent.getStringExtra(Telephony.Intents.EXTRA_SPN),
- intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_PLMN, false),
- intent.getStringExtra(Telephony.Intents.EXTRA_PLMN));
+ } else if (action.equals(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION)) {
+ updateNetworkName(intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_SPN, false),
+ intent.getStringExtra(TelephonyIntents.EXTRA_SPN),
+ intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_PLMN, false),
+ intent.getStringExtra(TelephonyIntents.EXTRA_PLMN));
refreshViews();
} else if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION) ||
action.equals(ConnectivityManager.INET_CONDITION_ACTION)) {
@@ -422,26 +423,27 @@ public class NetworkController extends BroadcastReceiver {
};
private final void updateSimState(Intent intent) {
- String stateExtra = intent.getStringExtra(IccCard.INTENT_KEY_ICC_STATE);
- if (IccCard.INTENT_VALUE_ICC_ABSENT.equals(stateExtra)) {
- mSimState = IccCard.State.ABSENT;
+ String stateExtra = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE);
+ if (IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(stateExtra)) {
+ mSimState = IccCardConstants.State.ABSENT;
}
- else if (IccCard.INTENT_VALUE_ICC_READY.equals(stateExtra)) {
- mSimState = IccCard.State.READY;
+ else if (IccCardConstants.INTENT_VALUE_ICC_READY.equals(stateExtra)) {
+ mSimState = IccCardConstants.State.READY;
}
- else if (IccCard.INTENT_VALUE_ICC_LOCKED.equals(stateExtra)) {
- final String lockedReason = intent.getStringExtra(IccCard.INTENT_KEY_LOCKED_REASON);
- if (IccCard.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) {
- mSimState = IccCard.State.PIN_REQUIRED;
+ else if (IccCardConstants.INTENT_VALUE_ICC_LOCKED.equals(stateExtra)) {
+ final String lockedReason =
+ intent.getStringExtra(IccCardConstants.INTENT_KEY_LOCKED_REASON);
+ if (IccCardConstants.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) {
+ mSimState = IccCardConstants.State.PIN_REQUIRED;
}
- else if (IccCard.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) {
- mSimState = IccCard.State.PUK_REQUIRED;
+ else if (IccCardConstants.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) {
+ mSimState = IccCardConstants.State.PUK_REQUIRED;
}
else {
- mSimState = IccCard.State.NETWORK_LOCKED;
+ mSimState = IccCardConstants.State.NETWORK_LOCKED;
}
} else {
- mSimState = IccCard.State.UNKNOWN;
+ mSimState = IccCardConstants.State.UNKNOWN;
}
}
@@ -638,7 +640,8 @@ public class NetworkController extends BroadcastReceiver {
if (!isCdma()) {
// GSM case, we have to check also the sim state
- if (mSimState == IccCard.State.READY || mSimState == IccCard.State.UNKNOWN) {
+ if (mSimState == IccCardConstants.State.READY ||
+ mSimState == IccCardConstants.State.UNKNOWN) {
if (hasService() && mDataState == TelephonyManager.DATA_CONNECTED) {
switch (mDataActivity) {
case TelephonyManager.DATA_ACTIVITY_IN:
diff --git a/packages/WAPPushManager/Android.mk b/packages/WAPPushManager/Android.mk
index c1d8f4b6cdc9..35ec647f332d 100644
--- a/packages/WAPPushManager/Android.mk
+++ b/packages/WAPPushManager/Android.mk
@@ -10,6 +10,7 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := WAPPushManager
+LOCAL_JAVA_LIBRARIES += telephony-common
LOCAL_STATIC_JAVA_LIBRARIES += android-common
LOCAL_PROGUARD_FLAGS := -include $(LOCAL_PATH)/proguard.flags
diff --git a/packages/WAPPushManager/tests/Android.mk b/packages/WAPPushManager/tests/Android.mk
index 0a95b526cf1d..7128b0ddf1bd 100644
--- a/packages/WAPPushManager/tests/Android.mk
+++ b/packages/WAPPushManager/tests/Android.mk
@@ -18,7 +18,7 @@ include $(CLEAR_VARS)
# We only want this apk build for tests.
LOCAL_MODULE_TAGS := tests
-LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common
# Include all test java files.
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java b/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
index d0fe42d74dfa..c1fd51563a6f 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
@@ -17,8 +17,7 @@
package com.android.internal.policy.impl;
import com.android.internal.R;
-import com.android.internal.telephony.IccCard;
-import com.android.internal.telephony.IccCard.State;
+import com.android.internal.telephony.IccCardConstants;
import com.android.internal.widget.DigitalClock;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.TransportControlView;
@@ -88,7 +87,7 @@ class KeyguardStatusViewManager implements OnClickListener {
private int mBatteryLevel = 100;
// last known SIM state
- protected State mSimState;
+ protected IccCardConstants.State mSimState;
private LockPatternUtils mLockPatternUtils;
private KeyguardUpdateMonitor mUpdateMonitor;
@@ -435,17 +434,18 @@ class KeyguardStatusViewManager implements OnClickListener {
/**
* Determine the current status of the lock screen given the sim state and other stuff.
*/
- public StatusMode getStatusForIccState(IccCard.State simState) {
+ public StatusMode getStatusForIccState(IccCardConstants.State simState) {
// Since reading the SIM may take a while, we assume it is present until told otherwise.
if (simState == null) {
return StatusMode.Normal;
}
final boolean missingAndNotProvisioned = (!mUpdateMonitor.isDeviceProvisioned()
- && (simState == IccCard.State.ABSENT || simState == IccCard.State.PERM_DISABLED));
+ && (simState == IccCardConstants.State.ABSENT ||
+ simState == IccCardConstants.State.PERM_DISABLED));
// Assume we're NETWORK_LOCKED if not provisioned
- simState = missingAndNotProvisioned ? State.NETWORK_LOCKED : simState;
+ simState = missingAndNotProvisioned ? IccCardConstants.State.NETWORK_LOCKED : simState;
switch (simState) {
case ABSENT:
return StatusMode.SimMissing;
@@ -477,7 +477,7 @@ class KeyguardStatusViewManager implements OnClickListener {
*
* @param simState
*/
- private void updateCarrierStateWithSimStatus(State simState) {
+ private void updateCarrierStateWithSimStatus(IccCardConstants.State simState) {
if (DEBUG) Log.d(TAG, "updateCarrierTextWithSimStatus(), simState = " + simState);
CharSequence carrierText = null;
@@ -663,7 +663,7 @@ class KeyguardStatusViewManager implements OnClickListener {
private SimStateCallback mSimStateCallback = new SimStateCallback() {
- public void onSimStateChanged(State simState) {
+ public void onSimStateChanged(IccCardConstants.State simState) {
updateCarrierStateWithSimStatus(simState);
}
};
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java b/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
index dfe9134d28cb..5cd0349c20a7 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
@@ -34,14 +34,8 @@ import android.os.BatteryManager;
import android.os.Handler;
import android.os.Message;
import android.provider.Settings;
-import android.provider.Telephony;
-import static android.provider.Telephony.Intents.EXTRA_PLMN;
-import static android.provider.Telephony.Intents.EXTRA_SHOW_PLMN;
-import static android.provider.Telephony.Intents.EXTRA_SHOW_SPN;
-import static android.provider.Telephony.Intents.EXTRA_SPN;
-import static android.provider.Telephony.Intents.SPN_STRINGS_UPDATED_ACTION;
-
-import com.android.internal.telephony.IccCard;
+
+import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.TelephonyIntents;
import android.telephony.TelephonyManager;
@@ -70,7 +64,7 @@ public class KeyguardUpdateMonitor {
private final Context mContext;
- private IccCard.State mSimState = IccCard.State.READY;
+ private IccCardConstants.State mSimState = IccCardConstants.State.READY;
private boolean mDeviceProvisioned;
@@ -115,44 +109,44 @@ public class KeyguardUpdateMonitor {
* the intent and provide a {@link SimCard.State} result.
*/
private static class SimArgs {
- public final IccCard.State simState;
+ public final IccCardConstants.State simState;
- SimArgs(IccCard.State state) {
+ SimArgs(IccCardConstants.State state) {
simState = state;
}
static SimArgs fromIntent(Intent intent) {
- IccCard.State state;
+ IccCardConstants.State state;
if (!TelephonyIntents.ACTION_SIM_STATE_CHANGED.equals(intent.getAction())) {
throw new IllegalArgumentException("only handles intent ACTION_SIM_STATE_CHANGED");
}
- String stateExtra = intent.getStringExtra(IccCard.INTENT_KEY_ICC_STATE);
- if (IccCard.INTENT_VALUE_ICC_ABSENT.equals(stateExtra)) {
+ String stateExtra = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE);
+ if (IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(stateExtra)) {
final String absentReason = intent
- .getStringExtra(IccCard.INTENT_KEY_LOCKED_REASON);
+ .getStringExtra(IccCardConstants.INTENT_KEY_LOCKED_REASON);
- if (IccCard.INTENT_VALUE_ABSENT_ON_PERM_DISABLED.equals(
+ if (IccCardConstants.INTENT_VALUE_ABSENT_ON_PERM_DISABLED.equals(
absentReason)) {
- state = IccCard.State.PERM_DISABLED;
+ state = IccCardConstants.State.PERM_DISABLED;
} else {
- state = IccCard.State.ABSENT;
+ state = IccCardConstants.State.ABSENT;
}
- } else if (IccCard.INTENT_VALUE_ICC_READY.equals(stateExtra)) {
- state = IccCard.State.READY;
- } else if (IccCard.INTENT_VALUE_ICC_LOCKED.equals(stateExtra)) {
+ } else if (IccCardConstants.INTENT_VALUE_ICC_READY.equals(stateExtra)) {
+ state = IccCardConstants.State.READY;
+ } else if (IccCardConstants.INTENT_VALUE_ICC_LOCKED.equals(stateExtra)) {
final String lockedReason = intent
- .getStringExtra(IccCard.INTENT_KEY_LOCKED_REASON);
- if (IccCard.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) {
- state = IccCard.State.PIN_REQUIRED;
- } else if (IccCard.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) {
- state = IccCard.State.PUK_REQUIRED;
+ .getStringExtra(IccCardConstants.INTENT_KEY_LOCKED_REASON);
+ if (IccCardConstants.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) {
+ state = IccCardConstants.State.PIN_REQUIRED;
+ } else if (IccCardConstants.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) {
+ state = IccCardConstants.State.PUK_REQUIRED;
} else {
- state = IccCard.State.UNKNOWN;
+ state = IccCardConstants.State.UNKNOWN;
}
- } else if (IccCard.INTENT_VALUE_LOCKED_NETWORK.equals(stateExtra)) {
- state = IccCard.State.NETWORK_LOCKED;
+ } else if (IccCardConstants.INTENT_VALUE_LOCKED_NETWORK.equals(stateExtra)) {
+ state = IccCardConstants.State.NETWORK_LOCKED;
} else {
- state = IccCard.State.UNKNOWN;
+ state = IccCardConstants.State.UNKNOWN;
}
return new SimArgs(state);
}
@@ -253,7 +247,7 @@ public class KeyguardUpdateMonitor {
}
// take a guess to start
- mSimState = IccCard.State.READY;
+ mSimState = IccCardConstants.State.READY;
mBatteryStatus = new BatteryStatus(BATTERY_STATUS_UNKNOWN, 100, 0, 0);
mTelephonyPlmn = getDefaultPlmn();
@@ -266,7 +260,7 @@ public class KeyguardUpdateMonitor {
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
- filter.addAction(SPN_STRINGS_UPDATED_ACTION);
+ filter.addAction(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION);
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
filter.addAction(Intent.ACTION_USER_SWITCHED);
@@ -281,7 +275,7 @@ public class KeyguardUpdateMonitor {
|| Intent.ACTION_TIME_CHANGED.equals(action)
|| Intent.ACTION_TIMEZONE_CHANGED.equals(action)) {
mHandler.sendMessage(mHandler.obtainMessage(MSG_TIME_UPDATE));
- } else if (SPN_STRINGS_UPDATED_ACTION.equals(action)) {
+ } else if (TelephonyIntents.SPN_STRINGS_UPDATED_ACTION.equals(action)) {
mTelephonyPlmn = getTelephonyPlmnFrom(intent);
mTelephonySpn = getTelephonySpnFrom(intent);
mHandler.sendMessage(mHandler.obtainMessage(MSG_CARRIER_INFO_UPDATE));
@@ -296,7 +290,7 @@ public class KeyguardUpdateMonitor {
} else if (TelephonyIntents.ACTION_SIM_STATE_CHANGED.equals(action)) {
if (DEBUG_SIM_STATES) {
Log.v(TAG, "action " + action + " state" +
- intent.getStringExtra(IccCard.INTENT_KEY_ICC_STATE));
+ intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE));
}
mHandler.sendMessage(mHandler.obtainMessage(
MSG_SIM_STATE_CHANGE, SimArgs.fromIntent(intent)));
@@ -405,15 +399,14 @@ public class KeyguardUpdateMonitor {
* Handle {@link #MSG_SIM_STATE_CHANGE}
*/
private void handleSimStateChange(SimArgs simArgs) {
- final IccCard.State state = simArgs.simState;
+ final IccCardConstants.State state = simArgs.simState;
if (DEBUG) {
Log.d(TAG, "handleSimStateChange: intentValue = " + simArgs + " "
+ "state resolved to " + state.toString());
}
- if (state != IccCard.State.UNKNOWN && state != mSimState) {
- if (DEBUG_SIM_STATES) Log.v(TAG, "dispatching state: " + state);
+ if (state != IccCardConstants.State.UNKNOWN && state != mSimState) {
mSimState = state;
for (int i = 0; i < mSimStateCallbacks.size(); i++) {
mSimStateCallbacks.get(i).onSimStateChanged(state);
@@ -466,12 +459,12 @@ public class KeyguardUpdateMonitor {
}
/**
- * @param intent The intent with action {@link Telephony.Intents#SPN_STRINGS_UPDATED_ACTION}
+ * @param intent The intent with action {@link TelephonyIntents#SPN_STRINGS_UPDATED_ACTION}
* @return The string to use for the plmn, or null if it should not be shown.
*/
private CharSequence getTelephonyPlmnFrom(Intent intent) {
- if (intent.getBooleanExtra(EXTRA_SHOW_PLMN, false)) {
- final String plmn = intent.getStringExtra(EXTRA_PLMN);
+ if (intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_PLMN, false)) {
+ final String plmn = intent.getStringExtra(TelephonyIntents.EXTRA_PLMN);
if (plmn != null) {
return plmn;
} else {
@@ -494,8 +487,8 @@ public class KeyguardUpdateMonitor {
* @return The string to use for the plmn, or null if it should not be shown.
*/
private CharSequence getTelephonySpnFrom(Intent intent) {
- if (intent.getBooleanExtra(EXTRA_SHOW_SPN, false)) {
- final String spn = intent.getStringExtra(EXTRA_SPN);
+ if (intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_SPN, false)) {
+ final String spn = intent.getStringExtra(TelephonyIntents.EXTRA_SPN);
if (spn != null) {
return spn;
}
@@ -601,7 +594,7 @@ public class KeyguardUpdateMonitor {
* Callback to notify of sim state change.
*/
interface SimStateCallback {
- void onSimStateChanged(IccCard.State simState);
+ void onSimStateChanged(IccCardConstants.State simState);
}
/**
@@ -646,7 +639,7 @@ public class KeyguardUpdateMonitor {
mHandler.obtainMessage(MSG_CLOCK_VISIBILITY_CHANGED).sendToTarget();
}
- public IccCard.State getSimState() {
+ public IccCardConstants.State getSimState() {
return mSimState;
}
@@ -659,7 +652,7 @@ public class KeyguardUpdateMonitor {
* through mHandler, this *must* be called from the UI thread.
*/
public void reportSimUnlocked() {
- handleSimStateChange(new SimArgs(IccCard.State.READY));
+ handleSimStateChange(new SimArgs(IccCardConstants.State.READY));
}
public boolean isDevicePluggedIn() {
@@ -725,8 +718,8 @@ public class KeyguardUpdateMonitor {
}
public boolean isSimLocked() {
- return mSimState == IccCard.State.PIN_REQUIRED
- || mSimState == IccCard.State.PUK_REQUIRED
- || mSimState == IccCard.State.PERM_DISABLED;
+ return mSimState == IccCardConstants.State.PIN_REQUIRED
+ || mSimState == IccCardConstants.State.PUK_REQUIRED
+ || mSimState == IccCardConstants.State.PERM_DISABLED;
}
}
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
index e84e912227c8..02eeedfd94cc 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
@@ -19,7 +19,7 @@ package com.android.internal.policy.impl;
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
import com.android.internal.policy.impl.KeyguardUpdateMonitor.InfoCallbackImpl;
-import com.android.internal.telephony.IccCard;
+import com.android.internal.telephony.IccCardConstants;
import com.android.internal.widget.LockPatternUtils;
import android.app.ActivityManagerNative;
@@ -621,10 +621,10 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
final boolean requireSim = !SystemProperties.getBoolean("keyguard.no_require_sim",
false);
final boolean provisioned = mUpdateMonitor.isDeviceProvisioned();
- final IccCard.State state = mUpdateMonitor.getSimState();
+ final IccCardConstants.State state = mUpdateMonitor.getSimState();
final boolean lockedOrMissing = state.isPinLocked()
- || ((state == IccCard.State.ABSENT
- || state == IccCard.State.PERM_DISABLED)
+ || ((state == IccCardConstants.State.ABSENT
+ || state == IccCardConstants.State.PERM_DISABLED)
&& requireSim);
if (!lockedOrMissing && !provisioned) {
@@ -727,7 +727,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
}
/** {@inheritDoc} */
- public void onSimStateChanged(IccCard.State simState) {
+ public void onSimStateChanged(IccCardConstants.State simState) {
if (DEBUG) Log.d(TAG, "onSimStateChanged: " + simState);
switch (simState) {
diff --git a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
index 35e782082eba..041211c70c5c 100644
--- a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
+++ b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
@@ -20,7 +20,7 @@ import com.android.internal.R;
import com.android.internal.policy.impl.KeyguardUpdateMonitor.InfoCallback;
import com.android.internal.policy.impl.KeyguardUpdateMonitor.InfoCallbackImpl;
import com.android.internal.policy.impl.LockPatternKeyguardView.UnlockMode;
-import com.android.internal.telephony.IccCard;
+import com.android.internal.telephony.IccCardConstants;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockScreenWidgetCallback;
import com.android.internal.widget.LockScreenWidgetInterface;
@@ -267,8 +267,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
private boolean stuckOnLockScreenBecauseSimMissing() {
return mRequiresSim
&& (!mUpdateMonitor.isDeviceProvisioned())
- && (mUpdateMonitor.getSimState() == IccCard.State.ABSENT ||
- mUpdateMonitor.getSimState() == IccCard.State.PERM_DISABLED);
+ && (mUpdateMonitor.getSimState() == IccCardConstants.State.ABSENT ||
+ mUpdateMonitor.getSimState() == IccCardConstants.State.PERM_DISABLED);
}
/**
@@ -289,9 +289,9 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
}
public void goToUnlockScreen() {
- final IccCard.State simState = mUpdateMonitor.getSimState();
+ final IccCardConstants.State simState = mUpdateMonitor.getSimState();
if (stuckOnLockScreenBecauseSimMissing()
- || (simState == IccCard.State.PUK_REQUIRED
+ || (simState == IccCardConstants.State.PUK_REQUIRED
&& !mLockPatternUtils.isPukUnlockScreenEnable())){
// stuck on lock screen when sim missing or
// puk'd but puk unlock screen is disabled
@@ -757,7 +757,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
public void wakeWhenReadyTq(int keyCode) {
if (DEBUG) Log.d(TAG, "onWakeKey");
if (keyCode == KeyEvent.KEYCODE_MENU && isSecure() && (mMode == Mode.LockScreen)
- && (mUpdateMonitor.getSimState() != IccCard.State.PUK_REQUIRED)) {
+ && (mUpdateMonitor.getSimState() != IccCardConstants.State.PUK_REQUIRED)) {
if (DEBUG) Log.d(TAG, "switching screens to unlock screen because wake key was MENU");
updateScreen(Mode.UnlockScreen, false);
getCallback().pokeWakelock();
@@ -811,10 +811,10 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
secure = mLockPatternUtils.isLockPatternEnabled();
break;
case SimPin:
- secure = mUpdateMonitor.getSimState() == IccCard.State.PIN_REQUIRED;
+ secure = mUpdateMonitor.getSimState() == IccCardConstants.State.PIN_REQUIRED;
break;
case SimPuk:
- secure = mUpdateMonitor.getSimState() == IccCard.State.PUK_REQUIRED;
+ secure = mUpdateMonitor.getSimState() == IccCardConstants.State.PUK_REQUIRED;
break;
case Account:
secure = true;
@@ -1044,9 +1044,9 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
* the lock screen (lock or unlock).
*/
private Mode getInitialMode() {
- final IccCard.State simState = mUpdateMonitor.getSimState();
+ final IccCardConstants.State simState = mUpdateMonitor.getSimState();
if (stuckOnLockScreenBecauseSimMissing() ||
- (simState == IccCard.State.PUK_REQUIRED &&
+ (simState == IccCardConstants.State.PUK_REQUIRED &&
!mLockPatternUtils.isPukUnlockScreenEnable())) {
return Mode.LockScreen;
} else {
@@ -1062,11 +1062,11 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
* Given the current state of things, what should the unlock screen be?
*/
private UnlockMode getUnlockMode() {
- final IccCard.State simState = mUpdateMonitor.getSimState();
+ final IccCardConstants.State simState = mUpdateMonitor.getSimState();
UnlockMode currentMode;
- if (simState == IccCard.State.PIN_REQUIRED) {
+ if (simState == IccCardConstants.State.PIN_REQUIRED) {
currentMode = UnlockMode.SimPin;
- } else if (simState == IccCard.State.PUK_REQUIRED) {
+ } else if (simState == IccCardConstants.State.PUK_REQUIRED) {
currentMode = UnlockMode.SimPuk;
} else {
final int mode = mLockPatternUtils.getKeyguardStoredPasswordQuality();
diff --git a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardViewProperties.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardViewProperties.java
index 58d14eddb79a..6d3c20a6b2f7 100644
--- a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardViewProperties.java
+++ b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardViewProperties.java
@@ -19,7 +19,7 @@ package com.android.internal.policy.impl;
import com.android.internal.widget.LockPatternUtils;
import android.content.Context;
-import com.android.internal.telephony.IccCard;
+import com.android.internal.telephony.IccCardConstants;
/**
* Knows how to create a lock pattern keyguard view, and answer questions about
@@ -55,10 +55,11 @@ public class LockPatternKeyguardViewProperties implements KeyguardViewProperties
}
private boolean isSimPinSecure() {
- final IccCard.State simState = mUpdateMonitor.getSimState();
- return (simState == IccCard.State.PIN_REQUIRED
- || simState == IccCard.State.PUK_REQUIRED
- || simState == IccCard.State.PERM_DISABLED);
+ final IccCardConstants.State simState = mUpdateMonitor.getSimState();
+ return (simState == IccCardConstants.State.PIN_REQUIRED
+ || simState == IccCardConstants.State.PUK_REQUIRED
+ || simState == IccCardConstants.State.ABSENT
+ || simState == IccCardConstants.State.PERM_DISABLED);
}
}
diff --git a/policy/src/com/android/internal/policy/impl/LockScreen.java b/policy/src/com/android/internal/policy/impl/LockScreen.java
index ec954fefbb70..26078ec8aefd 100644
--- a/policy/src/com/android/internal/policy/impl/LockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/LockScreen.java
@@ -19,7 +19,7 @@ package com.android.internal.policy.impl;
import com.android.internal.R;
import com.android.internal.policy.impl.KeyguardUpdateMonitor.InfoCallbackImpl;
import com.android.internal.policy.impl.KeyguardUpdateMonitor.SimStateCallback;
-import com.android.internal.telephony.IccCard.State;
+import com.android.internal.telephony.IccCardConstants;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.SlidingTab;
import com.android.internal.widget.WaveView;
@@ -105,7 +105,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
};
SimStateCallback mSimStateCallback = new SimStateCallback() {
- public void onSimStateChanged(State simState) {
+ public void onSimStateChanged(IccCardConstants.State simState) {
updateTargets();
}
};
diff --git a/policy/tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java b/policy/tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java
index db71e2b2b2d9..862e6831e5e8 100644
--- a/policy/tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java
+++ b/policy/tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java
@@ -18,7 +18,7 @@ package com.android.internal.policy.impl;
import android.content.Context;
import com.android.internal.policy.impl.KeyguardViewCallback;
-import com.android.internal.telephony.IccCard;
+import com.android.internal.telephony.IccCardConstants;
import android.content.res.Configuration;
import android.test.AndroidTestCase;
import android.view.View;
@@ -40,14 +40,14 @@ public class LockPatternKeyguardViewTest extends AndroidTestCase {
private static class MockUpdateMonitor extends KeyguardUpdateMonitor {
- public IccCard.State simState = IccCard.State.READY;
+ public IccCardConstants.State simState = IccCardConstants.State.READY;
private MockUpdateMonitor(Context context) {
super(context);
}
@Override
- public IccCard.State getSimState() {
+ public IccCardConstants.State getSimState() {
return simState;
}
}
@@ -318,7 +318,7 @@ public class LockPatternKeyguardViewTest extends AndroidTestCase {
public void testMenuDoesntGoToUnlockScreenOnWakeWhenPukLocked() {
// PUK locked
- mUpdateMonitor.simState = IccCard.State.PUK_REQUIRED;
+ mUpdateMonitor.simState = IccCardConstants.State.PUK_REQUIRED;
// wake by menu
mLPKV.wakeWhenReadyTq(KeyEvent.KEYCODE_MENU);
diff --git a/services/java/Android.mk b/services/java/Android.mk
index c756d29f104e..e70a6c96bece 100644
--- a/services/java/Android.mk
+++ b/services/java/Android.mk
@@ -11,7 +11,7 @@ LOCAL_SRC_FILES := \
LOCAL_MODULE:= services
-LOCAL_JAVA_LIBRARIES := android.policy
+LOCAL_JAVA_LIBRARIES := android.policy telephony-common
LOCAL_NO_EMMA_INSTRUMENT := true
LOCAL_NO_EMMA_COMPILE := true
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index 7bbc8b5209ac..230f07bb5baf 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -77,6 +77,7 @@ import android.util.SparseIntArray;
import com.android.internal.net.LegacyVpnInfo;
import com.android.internal.net.VpnConfig;
import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneConstants;
import com.android.server.am.BatteryStatsService;
import com.android.server.connectivity.Tethering;
import com.android.server.connectivity.Vpn;
@@ -1008,7 +1009,7 @@ private NetworkStateTracker makeWimaxStateTracker() {
try {
if (!ConnectivityManager.isNetworkTypeValid(networkType) ||
mNetConfigs[networkType] == null) {
- return Phone.APN_REQUEST_FAILED;
+ return PhoneConstants.APN_REQUEST_FAILED;
}
FeatureUser f = new FeatureUser(networkType, feature, binder);
@@ -1027,7 +1028,7 @@ private NetworkStateTracker makeWimaxStateTracker() {
uidRules = mUidRules.get(Binder.getCallingUid(), RULE_ALLOW_ALL);
}
if (networkMetered && (uidRules & RULE_REJECT_METERED) != 0) {
- return Phone.APN_REQUEST_FAILED;
+ return PhoneConstants.APN_REQUEST_FAILED;
}
NetworkStateTracker network = mNetTrackers[usedNetworkType];
@@ -1039,7 +1040,7 @@ private NetworkStateTracker makeWimaxStateTracker() {
if (ni.isAvailable() == false) {
if (!TextUtils.equals(feature,Phone.FEATURE_ENABLE_DUN_ALWAYS)) {
if (DBG) log("special network not available ni=" + ni.getTypeName());
- return Phone.APN_TYPE_NOT_AVAILABLE;
+ return PhoneConstants.APN_TYPE_NOT_AVAILABLE;
} else {
// else make the attempt anyway - probably giving REQUEST_STARTED below
if (DBG) {
@@ -1088,10 +1089,10 @@ private NetworkStateTracker makeWimaxStateTracker() {
} finally {
Binder.restoreCallingIdentity(token);
}
- return Phone.APN_ALREADY_ACTIVE;
+ return PhoneConstants.APN_ALREADY_ACTIVE;
}
if (VDBG) log("special network already connecting");
- return Phone.APN_REQUEST_STARTED;
+ return PhoneConstants.APN_REQUEST_STARTED;
}
// check if the radio in play can make another contact
@@ -1102,7 +1103,7 @@ private NetworkStateTracker makeWimaxStateTracker() {
feature);
}
network.reconnect();
- return Phone.APN_REQUEST_STARTED;
+ return PhoneConstants.APN_REQUEST_STARTED;
} else {
// need to remember this unsupported request so we respond appropriately on stop
synchronized(this) {
@@ -1115,7 +1116,7 @@ private NetworkStateTracker makeWimaxStateTracker() {
return -1;
}
}
- return Phone.APN_TYPE_NOT_AVAILABLE;
+ return PhoneConstants.APN_TYPE_NOT_AVAILABLE;
} finally {
if (DBG) {
final long execTime = SystemClock.elapsedRealtime() - startTime;
@@ -2037,7 +2038,7 @@ private NetworkStateTracker makeWimaxStateTracker() {
// @see bug/4455071
/** Notify TetheringService if interface name has been changed. */
if (TextUtils.equals(mNetTrackers[netType].getNetworkInfo().getReason(),
- Phone.REASON_LINK_PROPERTIES_CHANGED)) {
+ PhoneConstants.REASON_LINK_PROPERTIES_CHANGED)) {
if (isTetheringSupported()) {
mTethering.handleTetherIfaceChange();
}
diff --git a/services/java/com/android/server/TelephonyRegistry.java b/services/java/com/android/server/TelephonyRegistry.java
index 1b1638a52e97..c23a1d9c10ec 100644
--- a/services/java/com/android/server/TelephonyRegistry.java
+++ b/services/java/com/android/server/TelephonyRegistry.java
@@ -44,6 +44,7 @@ import com.android.internal.telephony.ITelephonyRegistry;
import com.android.internal.telephony.IPhoneStateListener;
import com.android.internal.telephony.DefaultPhoneNotifier;
import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.ServiceStateTracker;
import com.android.internal.telephony.TelephonyIntents;
import com.android.server.am.BatteryStatsService;
@@ -622,7 +623,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
}
Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
- intent.putExtra(Phone.STATE_KEY, DefaultPhoneNotifier.convertCallState(state).toString());
+ intent.putExtra(PhoneConstants.STATE_KEY,
+ DefaultPhoneNotifier.convertCallState(state).toString());
if (!TextUtils.isEmpty(incomingNumber)) {
intent.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber);
}
@@ -637,34 +639,35 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
// status bar takes care of that after taking into account all of the
// required info.
Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
- intent.putExtra(Phone.STATE_KEY, DefaultPhoneNotifier.convertDataState(state).toString());
+ intent.putExtra(PhoneConstants.STATE_KEY,
+ DefaultPhoneNotifier.convertDataState(state).toString());
if (!isDataConnectivityPossible) {
- intent.putExtra(Phone.NETWORK_UNAVAILABLE_KEY, true);
+ intent.putExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY, true);
}
if (reason != null) {
- intent.putExtra(Phone.STATE_CHANGE_REASON_KEY, reason);
+ intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
}
if (linkProperties != null) {
- intent.putExtra(Phone.DATA_LINK_PROPERTIES_KEY, linkProperties);
+ intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties);
String iface = linkProperties.getInterfaceName();
if (iface != null) {
- intent.putExtra(Phone.DATA_IFACE_NAME_KEY, iface);
+ intent.putExtra(PhoneConstants.DATA_IFACE_NAME_KEY, iface);
}
}
if (linkCapabilities != null) {
- intent.putExtra(Phone.DATA_LINK_CAPABILITIES_KEY, linkCapabilities);
+ intent.putExtra(PhoneConstants.DATA_LINK_CAPABILITIES_KEY, linkCapabilities);
}
- if (roaming) intent.putExtra(Phone.DATA_NETWORK_ROAMING_KEY, true);
+ if (roaming) intent.putExtra(PhoneConstants.DATA_NETWORK_ROAMING_KEY, true);
- intent.putExtra(Phone.DATA_APN_KEY, apn);
- intent.putExtra(Phone.DATA_APN_TYPE_KEY, apnType);
+ intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
+ intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
mContext.sendStickyBroadcast(intent);
}
private void broadcastDataConnectionFailed(String reason, String apnType) {
Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED);
- intent.putExtra(Phone.FAILURE_REASON_KEY, reason);
- intent.putExtra(Phone.DATA_APN_TYPE_KEY, apnType);
+ intent.putExtra(PhoneConstants.FAILURE_REASON_KEY, reason);
+ intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
mContext.sendStickyBroadcast(intent);
}
diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java
index 88a0ccbe702d..682ecf86124f 100644
--- a/services/java/com/android/server/connectivity/Tethering.java
+++ b/services/java/com/android/server/connectivity/Tethering.java
@@ -47,6 +47,7 @@ import android.provider.Settings;
import android.util.Log;
import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneConstants;
import com.android.internal.util.IState;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
@@ -1190,7 +1191,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
boolean retValue = true;
if (apnType == ConnectivityManager.TYPE_NONE) return false;
if (apnType != mMobileApnReserved) turnOffUpstreamMobileConnection();
- int result = Phone.APN_REQUEST_FAILED;
+ int result = PhoneConstants.APN_REQUEST_FAILED;
String enableString = enableString(apnType);
if (enableString == null) return false;
try {
@@ -1199,14 +1200,14 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
} catch (Exception e) {
}
switch (result) {
- case Phone.APN_ALREADY_ACTIVE:
- case Phone.APN_REQUEST_STARTED:
+ case PhoneConstants.APN_ALREADY_ACTIVE:
+ case PhoneConstants.APN_REQUEST_STARTED:
mMobileApnReserved = apnType;
Message m = obtainMessage(CMD_CELL_CONNECTION_RENEW);
m.arg1 = ++mCurrentConnectionSequence;
sendMessageDelayed(m, CELL_CONNECTION_RENEW_MS);
break;
- case Phone.APN_REQUEST_FAILED:
+ case PhoneConstants.APN_REQUEST_FAILED:
default:
retValue = false;
break;
diff --git a/services/java/com/android/server/location/GpsLocationProvider.java b/services/java/com/android/server/location/GpsLocationProvider.java
index ce534992bb41..4ad6140d1471 100755
--- a/services/java/com/android/server/location/GpsLocationProvider.java
+++ b/services/java/com/android/server/location/GpsLocationProvider.java
@@ -60,6 +60,7 @@ import com.android.internal.app.IBatteryStats;
import com.android.internal.location.GpsNetInitiatedHandler;
import com.android.internal.location.GpsNetInitiatedHandler.GpsNiNotification;
import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneConstants;
import java.io.File;
import java.io.FileInputStream;
@@ -1285,8 +1286,8 @@ public class GpsLocationProvider implements LocationProviderInterface {
int result = mConnMgr.startUsingNetworkFeature(
ConnectivityManager.TYPE_MOBILE, Phone.FEATURE_ENABLE_SUPL);
mAGpsDataConnectionIpAddr = ipaddr;
- if (result == Phone.APN_ALREADY_ACTIVE) {
- if (DEBUG) Log.d(TAG, "Phone.APN_ALREADY_ACTIVE");
+ if (result == PhoneConstants.APN_ALREADY_ACTIVE) {
+ if (DEBUG) Log.d(TAG, "PhoneConstants.APN_ALREADY_ACTIVE");
if (mAGpsApn != null) {
Log.d(TAG, "mAGpsDataConnectionIpAddr " + mAGpsDataConnectionIpAddr);
if (mAGpsDataConnectionIpAddr != 0xffffffff) {
@@ -1300,12 +1301,12 @@ public class GpsLocationProvider implements LocationProviderInterface {
native_agps_data_conn_open(mAGpsApn);
mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPEN;
} else {
- Log.e(TAG, "mAGpsApn not set when receiving Phone.APN_ALREADY_ACTIVE");
+ Log.e(TAG, "mAGpsApn not set when receiving PhoneConstants.APN_ALREADY_ACTIVE");
mAGpsDataConnectionState = AGPS_DATA_CONNECTION_CLOSED;
native_agps_data_conn_failed();
}
- } else if (result == Phone.APN_REQUEST_STARTED) {
- if (DEBUG) Log.d(TAG, "Phone.APN_REQUEST_STARTED");
+ } else if (result == PhoneConstants.APN_REQUEST_STARTED) {
+ if (DEBUG) Log.d(TAG, "PhoneConstants.APN_REQUEST_STARTED");
// Nothing to do here
} else {
if (DEBUG) Log.d(TAG, "startUsingNetworkFeature failed");
diff --git a/telephony/java/android/telephony/CellBroadcastMessage.java b/telephony/java/android/telephony/CellBroadcastMessage.java
deleted file mode 100644
index 36c238d8acd2..000000000000
--- a/telephony/java/android/telephony/CellBroadcastMessage.java
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package android.telephony;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.graphics.Typeface;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.provider.Telephony;
-import android.telephony.SmsCbCmasInfo;
-import android.telephony.SmsCbEtwsInfo;
-import android.telephony.SmsCbLocation;
-import android.telephony.SmsCbMessage;
-import android.text.Spannable;
-import android.text.SpannableStringBuilder;
-import android.text.format.DateUtils;
-import android.text.style.StyleSpan;
-
-/**
- * Application wrapper for {@link SmsCbMessage}. This is Parcelable so that
- * decoded broadcast message objects can be passed between running Services.
- * New broadcasts are received by the CellBroadcastReceiver app, which exports
- * the database of previously received broadcasts at "content://cellbroadcasts/".
- * The "android.permission.READ_CELL_BROADCASTS" permission is required to read
- * from the ContentProvider, and writes to the database are not allowed.
- *
- * Use {@link #createFromCursor} to create CellBroadcastMessage objects from rows
- * in the database cursor returned by the ContentProvider.
- *
- * {@hide}
- */
-public class CellBroadcastMessage implements Parcelable {
-
- /** Identifier for getExtra() when adding this object to an Intent. */
- public static final String SMS_CB_MESSAGE_EXTRA =
- "com.android.cellbroadcastreceiver.SMS_CB_MESSAGE";
-
- /** SmsCbMessage. */
- private final SmsCbMessage mSmsCbMessage;
-
- private final long mDeliveryTime;
- private boolean mIsRead;
-
- public CellBroadcastMessage(SmsCbMessage message) {
- mSmsCbMessage = message;
- mDeliveryTime = System.currentTimeMillis();
- mIsRead = false;
- }
-
- private CellBroadcastMessage(SmsCbMessage message, long deliveryTime, boolean isRead) {
- mSmsCbMessage = message;
- mDeliveryTime = deliveryTime;
- mIsRead = isRead;
- }
-
- private CellBroadcastMessage(Parcel in) {
- mSmsCbMessage = new SmsCbMessage(in);
- mDeliveryTime = in.readLong();
- mIsRead = (in.readInt() != 0);
- }
-
- /** Parcelable: no special flags. */
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- mSmsCbMessage.writeToParcel(out, flags);
- out.writeLong(mDeliveryTime);
- out.writeInt(mIsRead ? 1 : 0);
- }
-
- public static final Parcelable.Creator CREATOR
- = new Parcelable.Creator() {
- public CellBroadcastMessage createFromParcel(Parcel in) {
- return new CellBroadcastMessage(in);
- }
-
- public CellBroadcastMessage[] newArray(int size) {
- return new CellBroadcastMessage[size];
- }
- };
-
- /**
- * Create a CellBroadcastMessage from a row in the database.
- * @param cursor an open SQLite cursor pointing to the row to read
- * @return the new CellBroadcastMessage
- * @throws IllegalArgumentException if one of the required columns is missing
- */
- public static CellBroadcastMessage createFromCursor(Cursor cursor) {
- int geoScope = cursor.getInt(
- cursor.getColumnIndexOrThrow(Telephony.CellBroadcasts.GEOGRAPHICAL_SCOPE));
- int serialNum = cursor.getInt(
- cursor.getColumnIndexOrThrow(Telephony.CellBroadcasts.SERIAL_NUMBER));
- int category = cursor.getInt(
- cursor.getColumnIndexOrThrow(Telephony.CellBroadcasts.SERVICE_CATEGORY));
- String language = cursor.getString(
- cursor.getColumnIndexOrThrow(Telephony.CellBroadcasts.LANGUAGE_CODE));
- String body = cursor.getString(
- cursor.getColumnIndexOrThrow(Telephony.CellBroadcasts.MESSAGE_BODY));
- int format = cursor.getInt(
- cursor.getColumnIndexOrThrow(Telephony.CellBroadcasts.MESSAGE_FORMAT));
- int priority = cursor.getInt(
- cursor.getColumnIndexOrThrow(Telephony.CellBroadcasts.MESSAGE_PRIORITY));
-
- String plmn;
- int plmnColumn = cursor.getColumnIndex(Telephony.CellBroadcasts.PLMN);
- if (plmnColumn != -1 && !cursor.isNull(plmnColumn)) {
- plmn = cursor.getString(plmnColumn);
- } else {
- plmn = null;
- }
-
- int lac;
- int lacColumn = cursor.getColumnIndex(Telephony.CellBroadcasts.LAC);
- if (lacColumn != -1 && !cursor.isNull(lacColumn)) {
- lac = cursor.getInt(lacColumn);
- } else {
- lac = -1;
- }
-
- int cid;
- int cidColumn = cursor.getColumnIndex(Telephony.CellBroadcasts.CID);
- if (cidColumn != -1 && !cursor.isNull(cidColumn)) {
- cid = cursor.getInt(cidColumn);
- } else {
- cid = -1;
- }
-
- SmsCbLocation location = new SmsCbLocation(plmn, lac, cid);
-
- SmsCbEtwsInfo etwsInfo;
- int etwsWarningTypeColumn = cursor.getColumnIndex(
- Telephony.CellBroadcasts.ETWS_WARNING_TYPE);
- if (etwsWarningTypeColumn != -1 && !cursor.isNull(etwsWarningTypeColumn)) {
- int warningType = cursor.getInt(etwsWarningTypeColumn);
- etwsInfo = new SmsCbEtwsInfo(warningType, false, false, null);
- } else {
- etwsInfo = null;
- }
-
- SmsCbCmasInfo cmasInfo;
- int cmasMessageClassColumn = cursor.getColumnIndex(
- Telephony.CellBroadcasts.CMAS_MESSAGE_CLASS);
- if (cmasMessageClassColumn != -1 && !cursor.isNull(cmasMessageClassColumn)) {
- int messageClass = cursor.getInt(cmasMessageClassColumn);
-
- int cmasCategory;
- int cmasCategoryColumn = cursor.getColumnIndex(
- Telephony.CellBroadcasts.CMAS_CATEGORY);
- if (cmasCategoryColumn != -1 && !cursor.isNull(cmasCategoryColumn)) {
- cmasCategory = cursor.getInt(cmasCategoryColumn);
- } else {
- cmasCategory = SmsCbCmasInfo.CMAS_CATEGORY_UNKNOWN;
- }
-
- int responseType;
- int cmasResponseTypeColumn = cursor.getColumnIndex(
- Telephony.CellBroadcasts.CMAS_RESPONSE_TYPE);
- if (cmasResponseTypeColumn != -1 && !cursor.isNull(cmasResponseTypeColumn)) {
- responseType = cursor.getInt(cmasResponseTypeColumn);
- } else {
- responseType = SmsCbCmasInfo.CMAS_RESPONSE_TYPE_UNKNOWN;
- }
-
- int severity;
- int cmasSeverityColumn = cursor.getColumnIndex(
- Telephony.CellBroadcasts.CMAS_SEVERITY);
- if (cmasSeverityColumn != -1 && !cursor.isNull(cmasSeverityColumn)) {
- severity = cursor.getInt(cmasSeverityColumn);
- } else {
- severity = SmsCbCmasInfo.CMAS_SEVERITY_UNKNOWN;
- }
-
- int urgency;
- int cmasUrgencyColumn = cursor.getColumnIndex(
- Telephony.CellBroadcasts.CMAS_URGENCY);
- if (cmasUrgencyColumn != -1 && !cursor.isNull(cmasUrgencyColumn)) {
- urgency = cursor.getInt(cmasUrgencyColumn);
- } else {
- urgency = SmsCbCmasInfo.CMAS_URGENCY_UNKNOWN;
- }
-
- int certainty;
- int cmasCertaintyColumn = cursor.getColumnIndex(
- Telephony.CellBroadcasts.CMAS_CERTAINTY);
- if (cmasCertaintyColumn != -1 && !cursor.isNull(cmasCertaintyColumn)) {
- certainty = cursor.getInt(cmasCertaintyColumn);
- } else {
- certainty = SmsCbCmasInfo.CMAS_CERTAINTY_UNKNOWN;
- }
-
- cmasInfo = new SmsCbCmasInfo(messageClass, cmasCategory, responseType, severity,
- urgency, certainty);
- } else {
- cmasInfo = null;
- }
-
- SmsCbMessage msg = new SmsCbMessage(format, geoScope, serialNum, location, category,
- language, body, priority, etwsInfo, cmasInfo);
-
- long deliveryTime = cursor.getLong(cursor.getColumnIndexOrThrow(
- Telephony.CellBroadcasts.DELIVERY_TIME));
- boolean isRead = (cursor.getInt(cursor.getColumnIndexOrThrow(
- Telephony.CellBroadcasts.MESSAGE_READ)) != 0);
-
- return new CellBroadcastMessage(msg, deliveryTime, isRead);
- }
-
- /**
- * Return a ContentValues object for insertion into the database.
- * @return a new ContentValues object containing this object's data
- */
- public ContentValues getContentValues() {
- ContentValues cv = new ContentValues(16);
- SmsCbMessage msg = mSmsCbMessage;
- cv.put(Telephony.CellBroadcasts.GEOGRAPHICAL_SCOPE, msg.getGeographicalScope());
- SmsCbLocation location = msg.getLocation();
- if (location.getPlmn() != null) {
- cv.put(Telephony.CellBroadcasts.PLMN, location.getPlmn());
- }
- if (location.getLac() != -1) {
- cv.put(Telephony.CellBroadcasts.LAC, location.getLac());
- }
- if (location.getCid() != -1) {
- cv.put(Telephony.CellBroadcasts.CID, location.getCid());
- }
- cv.put(Telephony.CellBroadcasts.SERIAL_NUMBER, msg.getSerialNumber());
- cv.put(Telephony.CellBroadcasts.SERVICE_CATEGORY, msg.getServiceCategory());
- cv.put(Telephony.CellBroadcasts.LANGUAGE_CODE, msg.getLanguageCode());
- cv.put(Telephony.CellBroadcasts.MESSAGE_BODY, msg.getMessageBody());
- cv.put(Telephony.CellBroadcasts.DELIVERY_TIME, mDeliveryTime);
- cv.put(Telephony.CellBroadcasts.MESSAGE_READ, mIsRead);
- cv.put(Telephony.CellBroadcasts.MESSAGE_FORMAT, msg.getMessageFormat());
- cv.put(Telephony.CellBroadcasts.MESSAGE_PRIORITY, msg.getMessagePriority());
-
- SmsCbEtwsInfo etwsInfo = mSmsCbMessage.getEtwsWarningInfo();
- if (etwsInfo != null) {
- cv.put(Telephony.CellBroadcasts.ETWS_WARNING_TYPE, etwsInfo.getWarningType());
- }
-
- SmsCbCmasInfo cmasInfo = mSmsCbMessage.getCmasWarningInfo();
- if (cmasInfo != null) {
- cv.put(Telephony.CellBroadcasts.CMAS_MESSAGE_CLASS, cmasInfo.getMessageClass());
- cv.put(Telephony.CellBroadcasts.CMAS_CATEGORY, cmasInfo.getCategory());
- cv.put(Telephony.CellBroadcasts.CMAS_RESPONSE_TYPE, cmasInfo.getResponseType());
- cv.put(Telephony.CellBroadcasts.CMAS_SEVERITY, cmasInfo.getSeverity());
- cv.put(Telephony.CellBroadcasts.CMAS_URGENCY, cmasInfo.getUrgency());
- cv.put(Telephony.CellBroadcasts.CMAS_CERTAINTY, cmasInfo.getCertainty());
- }
-
- return cv;
- }
-
- /**
- * Set or clear the "read message" flag.
- * @param isRead true if the message has been read; false if not
- */
- public void setIsRead(boolean isRead) {
- mIsRead = isRead;
- }
-
- public String getLanguageCode() {
- return mSmsCbMessage.getLanguageCode();
- }
-
- public int getServiceCategory() {
- return mSmsCbMessage.getServiceCategory();
- }
-
- public long getDeliveryTime() {
- return mDeliveryTime;
- }
-
- public String getMessageBody() {
- return mSmsCbMessage.getMessageBody();
- }
-
- public boolean isRead() {
- return mIsRead;
- }
-
- public int getSerialNumber() {
- return mSmsCbMessage.getSerialNumber();
- }
-
- public SmsCbCmasInfo getCmasWarningInfo() {
- return mSmsCbMessage.getCmasWarningInfo();
- }
-
- public SmsCbEtwsInfo getEtwsWarningInfo() {
- return mSmsCbMessage.getEtwsWarningInfo();
- }
-
- /**
- * Return whether the broadcast is an emergency (PWS) message type.
- * This includes lower priority test messages and Amber alerts.
- *
- * All public alerts show the flashing warning icon in the dialog,
- * but only emergency alerts play the alert sound and speak the message.
- *
- * @return true if the message is PWS type; false otherwise
- */
- public boolean isPublicAlertMessage() {
- return mSmsCbMessage.isEmergencyMessage();
- }
-
- /**
- * Returns whether the broadcast is an emergency (PWS) message type,
- * including test messages, but excluding lower priority Amber alert broadcasts.
- *
- * @return true if the message is PWS type, excluding Amber alerts
- */
- public boolean isEmergencyAlertMessage() {
- if (!mSmsCbMessage.isEmergencyMessage()) {
- return false;
- }
- SmsCbCmasInfo cmasInfo = mSmsCbMessage.getCmasWarningInfo();
- if (cmasInfo != null &&
- cmasInfo.getMessageClass() == SmsCbCmasInfo.CMAS_CLASS_CHILD_ABDUCTION_EMERGENCY) {
- return false;
- }
- return true;
- }
-
- /**
- * Return whether the broadcast is an ETWS emergency message type.
- * @return true if the message is ETWS emergency type; false otherwise
- */
- public boolean isEtwsMessage() {
- return mSmsCbMessage.isEtwsMessage();
- }
-
- /**
- * Return whether the broadcast is a CMAS emergency message type.
- * @return true if the message is CMAS emergency type; false otherwise
- */
- public boolean isCmasMessage() {
- return mSmsCbMessage.isCmasMessage();
- }
-
- /**
- * Return the CMAS message class.
- * @return the CMAS message class, e.g. {@link SmsCbCmasInfo#CMAS_CLASS_SEVERE_THREAT}, or
- * {@link SmsCbCmasInfo#CMAS_CLASS_UNKNOWN} if this is not a CMAS alert
- */
- public int getCmasMessageClass() {
- if (mSmsCbMessage.isCmasMessage()) {
- return mSmsCbMessage.getCmasWarningInfo().getMessageClass();
- } else {
- return SmsCbCmasInfo.CMAS_CLASS_UNKNOWN;
- }
- }
-
- /**
- * Return whether the broadcast is an ETWS popup alert.
- * This method checks the message ID and the message code.
- * @return true if the message indicates an ETWS popup alert
- */
- public boolean isEtwsPopupAlert() {
- SmsCbEtwsInfo etwsInfo = mSmsCbMessage.getEtwsWarningInfo();
- return etwsInfo != null && etwsInfo.isPopupAlert();
- }
-
- /**
- * Return whether the broadcast is an ETWS emergency user alert.
- * This method checks the message ID and the message code.
- * @return true if the message indicates an ETWS emergency user alert
- */
- public boolean isEtwsEmergencyUserAlert() {
- SmsCbEtwsInfo etwsInfo = mSmsCbMessage.getEtwsWarningInfo();
- return etwsInfo != null && etwsInfo.isEmergencyUserAlert();
- }
-
- /**
- * Return whether the broadcast is an ETWS test message.
- * @return true if the message is an ETWS test message; false otherwise
- */
- public boolean isEtwsTestMessage() {
- SmsCbEtwsInfo etwsInfo = mSmsCbMessage.getEtwsWarningInfo();
- return etwsInfo != null &&
- etwsInfo.getWarningType() == SmsCbEtwsInfo.ETWS_WARNING_TYPE_TEST_MESSAGE;
- }
-
- /**
- * Return the abbreviated date string for the message delivery time.
- * @param context the context object
- * @return a String to use in the broadcast list UI
- */
- public String getDateString(Context context) {
- int flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_SHOW_TIME |
- DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_DATE |
- DateUtils.FORMAT_CAP_AMPM;
- return DateUtils.formatDateTime(context, mDeliveryTime, flags);
- }
-
- /**
- * Return the date string for the message delivery time, suitable for text-to-speech.
- * @param context the context object
- * @return a String for populating the list item AccessibilityEvent for TTS
- */
- public String getSpokenDateString(Context context) {
- int flags = DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE;
- return DateUtils.formatDateTime(context, mDeliveryTime, flags);
- }
-}
diff --git a/telephony/java/android/telephony/CellLocation.java b/telephony/java/android/telephony/CellLocation.java
index 5eaa5a074114..42c2aff03060 100644
--- a/telephony/java/android/telephony/CellLocation.java
+++ b/telephony/java/android/telephony/CellLocation.java
@@ -26,7 +26,7 @@ import android.provider.Settings;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.gsm.GsmCellLocation;
import com.android.internal.telephony.ITelephony;
-import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneConstants;
/**
* Abstract class that represents the location of the device. {@more}
@@ -64,9 +64,9 @@ public abstract class CellLocation {
// TelephonyManager.getDefault().getCurrentPhoneType() handles the case when
// ITelephony interface is not up yet.
switch(TelephonyManager.getDefault().getCurrentPhoneType()) {
- case Phone.PHONE_TYPE_CDMA:
+ case PhoneConstants.PHONE_TYPE_CDMA:
return new CdmaCellLocation(bundle);
- case Phone.PHONE_TYPE_GSM:
+ case PhoneConstants.PHONE_TYPE_GSM:
return new GsmCellLocation(bundle);
default:
return null;
@@ -92,9 +92,9 @@ public abstract class CellLocation {
// TelephonyManager.getDefault().getCurrentPhoneType() handles the case when
// ITelephony interface is not up yet.
switch(TelephonyManager.getDefault().getCurrentPhoneType()) {
- case Phone.PHONE_TYPE_CDMA:
+ case PhoneConstants.PHONE_TYPE_CDMA:
return new CdmaCellLocation();
- case Phone.PHONE_TYPE_GSM:
+ case PhoneConstants.PHONE_TYPE_GSM:
return new GsmCellLocation();
default:
return null;
diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java
index 698206c6de85..def6939aef28 100644
--- a/telephony/java/android/telephony/PhoneStateListener.java
+++ b/telephony/java/android/telephony/PhoneStateListener.java
@@ -26,7 +26,6 @@ import android.telephony.CellInfo;
import android.util.Log;
import com.android.internal.telephony.IPhoneStateListener;
-import com.android.internal.telephony.Phone;
/**
* A listener class for monitoring changes in specific telephony states
diff --git a/telephony/java/android/telephony/SmsCbCmasInfo.java b/telephony/java/android/telephony/SmsCbCmasInfo.java
deleted file mode 100644
index 7a89d94ab2ef..000000000000
--- a/telephony/java/android/telephony/SmsCbCmasInfo.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.telephony;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * Contains CMAS warning notification Type 1 elements for a {@link SmsCbMessage}.
- * Supported values for each element are defined in TIA-1149-0-1 (CMAS over CDMA) and
- * 3GPP TS 23.041 (for GSM/UMTS).
- *
- * {@hide}
- */
-public class SmsCbCmasInfo implements Parcelable {
-
- // CMAS message class (in GSM/UMTS message identifier or CDMA service category).
-
- /** Presidential-level alert (Korean Public Alert System Class 0 message). */
- public static final int CMAS_CLASS_PRESIDENTIAL_LEVEL_ALERT = 0x00;
-
- /** Extreme threat to life and property (Korean Public Alert System Class 1 message). */
- public static final int CMAS_CLASS_EXTREME_THREAT = 0x01;
-
- /** Severe threat to life and property (Korean Public Alert System Class 1 message). */
- public static final int CMAS_CLASS_SEVERE_THREAT = 0x02;
-
- /** Child abduction emergency (AMBER Alert). */
- public static final int CMAS_CLASS_CHILD_ABDUCTION_EMERGENCY = 0x03;
-
- /** CMAS test message. */
- public static final int CMAS_CLASS_REQUIRED_MONTHLY_TEST = 0x04;
-
- /** CMAS exercise. */
- public static final int CMAS_CLASS_CMAS_EXERCISE = 0x05;
-
- /** CMAS category for operator defined use. */
- public static final int CMAS_CLASS_OPERATOR_DEFINED_USE = 0x06;
-
- /** CMAS category for warning types that are reserved for future extension. */
- public static final int CMAS_CLASS_UNKNOWN = -1;
-
- // CMAS alert category (in CDMA type 1 elements record).
-
- /** CMAS alert category: Geophysical including landslide. */
- public static final int CMAS_CATEGORY_GEO = 0x00;
-
- /** CMAS alert category: Meteorological including flood. */
- public static final int CMAS_CATEGORY_MET = 0x01;
-
- /** CMAS alert category: General emergency and public safety. */
- public static final int CMAS_CATEGORY_SAFETY = 0x02;
-
- /** CMAS alert category: Law enforcement, military, homeland/local/private security. */
- public static final int CMAS_CATEGORY_SECURITY = 0x03;
-
- /** CMAS alert category: Rescue and recovery. */
- public static final int CMAS_CATEGORY_RESCUE = 0x04;
-
- /** CMAS alert category: Fire suppression and rescue. */
- public static final int CMAS_CATEGORY_FIRE = 0x05;
-
- /** CMAS alert category: Medical and public health. */
- public static final int CMAS_CATEGORY_HEALTH = 0x06;
-
- /** CMAS alert category: Pollution and other environmental. */
- public static final int CMAS_CATEGORY_ENV = 0x07;
-
- /** CMAS alert category: Public and private transportation. */
- public static final int CMAS_CATEGORY_TRANSPORT = 0x08;
-
- /** CMAS alert category: Utility, telecom, other non-transport infrastructure. */
- public static final int CMAS_CATEGORY_INFRA = 0x09;
-
- /** CMAS alert category: Chem, bio, radiological, nuclear, high explosive threat or attack. */
- public static final int CMAS_CATEGORY_CBRNE = 0x0a;
-
- /** CMAS alert category: Other events. */
- public static final int CMAS_CATEGORY_OTHER = 0x0b;
-
- /**
- * CMAS alert category is unknown. The category is only available for CDMA broadcasts
- * containing a type 1 elements record, so GSM and UMTS broadcasts always return unknown.
- */
- public static final int CMAS_CATEGORY_UNKNOWN = -1;
-
- // CMAS response type (in CDMA type 1 elements record).
-
- /** CMAS response type: Take shelter in place. */
- public static final int CMAS_RESPONSE_TYPE_SHELTER = 0x00;
-
- /** CMAS response type: Evacuate (Relocate). */
- public static final int CMAS_RESPONSE_TYPE_EVACUATE = 0x01;
-
- /** CMAS response type: Make preparations. */
- public static final int CMAS_RESPONSE_TYPE_PREPARE = 0x02;
-
- /** CMAS response type: Execute a pre-planned activity. */
- public static final int CMAS_RESPONSE_TYPE_EXECUTE = 0x03;
-
- /** CMAS response type: Attend to information sources. */
- public static final int CMAS_RESPONSE_TYPE_MONITOR = 0x04;
-
- /** CMAS response type: Avoid hazard. */
- public static final int CMAS_RESPONSE_TYPE_AVOID = 0x05;
-
- /** CMAS response type: Evaluate the information in this message (not for public warnings). */
- public static final int CMAS_RESPONSE_TYPE_ASSESS = 0x06;
-
- /** CMAS response type: No action recommended. */
- public static final int CMAS_RESPONSE_TYPE_NONE = 0x07;
-
- /**
- * CMAS response type is unknown. The response type is only available for CDMA broadcasts
- * containing a type 1 elements record, so GSM and UMTS broadcasts always return unknown.
- */
- public static final int CMAS_RESPONSE_TYPE_UNKNOWN = -1;
-
- // 4-bit CMAS severity (in GSM/UMTS message identifier or CDMA type 1 elements record).
-
- /** CMAS severity type: Extraordinary threat to life or property. */
- public static final int CMAS_SEVERITY_EXTREME = 0x0;
-
- /** CMAS severity type: Significant threat to life or property. */
- public static final int CMAS_SEVERITY_SEVERE = 0x1;
-
- /**
- * CMAS alert severity is unknown. The severity is available for CDMA warning alerts
- * containing a type 1 elements record and for all GSM and UMTS alerts except for the
- * Presidential-level alert class (Korean Public Alert System Class 0).
- */
- public static final int CMAS_SEVERITY_UNKNOWN = -1;
-
- // CMAS urgency (in GSM/UMTS message identifier or CDMA type 1 elements record).
-
- /** CMAS urgency type: Responsive action should be taken immediately. */
- public static final int CMAS_URGENCY_IMMEDIATE = 0x0;
-
- /** CMAS urgency type: Responsive action should be taken within the next hour. */
- public static final int CMAS_URGENCY_EXPECTED = 0x1;
-
- /**
- * CMAS alert urgency is unknown. The urgency is available for CDMA warning alerts
- * containing a type 1 elements record and for all GSM and UMTS alerts except for the
- * Presidential-level alert class (Korean Public Alert System Class 0).
- */
- public static final int CMAS_URGENCY_UNKNOWN = -1;
-
- // CMAS certainty (in GSM/UMTS message identifier or CDMA type 1 elements record).
-
- /** CMAS certainty type: Determined to have occurred or to be ongoing. */
- public static final int CMAS_CERTAINTY_OBSERVED = 0x0;
-
- /** CMAS certainty type: Likely (probability > ~50%). */
- public static final int CMAS_CERTAINTY_LIKELY = 0x1;
-
- /**
- * CMAS alert certainty is unknown. The certainty is available for CDMA warning alerts
- * containing a type 1 elements record and for all GSM and UMTS alerts except for the
- * Presidential-level alert class (Korean Public Alert System Class 0).
- */
- public static final int CMAS_CERTAINTY_UNKNOWN = -1;
-
- /** CMAS message class. */
- private final int mMessageClass;
-
- /** CMAS category. */
- private final int mCategory;
-
- /** CMAS response type. */
- private final int mResponseType;
-
- /** CMAS severity. */
- private final int mSeverity;
-
- /** CMAS urgency. */
- private final int mUrgency;
-
- /** CMAS certainty. */
- private final int mCertainty;
-
- /** Create a new SmsCbCmasInfo object with the specified values. */
- public SmsCbCmasInfo(int messageClass, int category, int responseType, int severity,
- int urgency, int certainty) {
- mMessageClass = messageClass;
- mCategory = category;
- mResponseType = responseType;
- mSeverity = severity;
- mUrgency = urgency;
- mCertainty = certainty;
- }
-
- /** Create a new SmsCbCmasInfo object from a Parcel. */
- SmsCbCmasInfo(Parcel in) {
- mMessageClass = in.readInt();
- mCategory = in.readInt();
- mResponseType = in.readInt();
- mSeverity = in.readInt();
- mUrgency = in.readInt();
- mCertainty = in.readInt();
- }
-
- /**
- * Flatten this object into a Parcel.
- *
- * @param dest The Parcel in which the object should be written.
- * @param flags Additional flags about how the object should be written (ignored).
- */
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(mMessageClass);
- dest.writeInt(mCategory);
- dest.writeInt(mResponseType);
- dest.writeInt(mSeverity);
- dest.writeInt(mUrgency);
- dest.writeInt(mCertainty);
- }
-
- /**
- * Returns the CMAS message class, e.g. {@link #CMAS_CLASS_PRESIDENTIAL_LEVEL_ALERT}.
- * @return one of the {@code CMAS_CLASS} values
- */
- public int getMessageClass() {
- return mMessageClass;
- }
-
- /**
- * Returns the CMAS category, e.g. {@link #CMAS_CATEGORY_GEO}.
- * @return one of the {@code CMAS_CATEGORY} values
- */
- public int getCategory() {
- return mCategory;
- }
-
- /**
- * Returns the CMAS response type, e.g. {@link #CMAS_RESPONSE_TYPE_SHELTER}.
- * @return one of the {@code CMAS_RESPONSE_TYPE} values
- */
- public int getResponseType() {
- return mResponseType;
- }
-
- /**
- * Returns the CMAS severity, e.g. {@link #CMAS_SEVERITY_EXTREME}.
- * @return one of the {@code CMAS_SEVERITY} values
- */
- public int getSeverity() {
- return mSeverity;
- }
-
- /**
- * Returns the CMAS urgency, e.g. {@link #CMAS_URGENCY_IMMEDIATE}.
- * @return one of the {@code CMAS_URGENCY} values
- */
- public int getUrgency() {
- return mUrgency;
- }
-
- /**
- * Returns the CMAS certainty, e.g. {@link #CMAS_CERTAINTY_OBSERVED}.
- * @return one of the {@code CMAS_CERTAINTY} values
- */
- public int getCertainty() {
- return mCertainty;
- }
-
- @Override
- public String toString() {
- return "SmsCbCmasInfo{messageClass=" + mMessageClass + ", category=" + mCategory
- + ", responseType=" + mResponseType + ", severity=" + mSeverity
- + ", urgency=" + mUrgency + ", certainty=" + mCertainty + '}';
- }
-
- /**
- * Describe the kinds of special objects contained in the marshalled representation.
- * @return a bitmask indicating this Parcelable contains no special objects
- */
- @Override
- public int describeContents() {
- return 0;
- }
-
- /** Creator for unparcelling objects. */
- public static final Parcelable.Creator
- CREATOR = new Parcelable.Creator() {
- public SmsCbCmasInfo createFromParcel(Parcel in) {
- return new SmsCbCmasInfo(in);
- }
-
- public SmsCbCmasInfo[] newArray(int size) {
- return new SmsCbCmasInfo[size];
- }
- };
-}
diff --git a/telephony/java/android/telephony/SmsCbEtwsInfo.java b/telephony/java/android/telephony/SmsCbEtwsInfo.java
deleted file mode 100644
index 0890d528f866..000000000000
--- a/telephony/java/android/telephony/SmsCbEtwsInfo.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.telephony;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.text.format.Time;
-
-import com.android.internal.telephony.IccUtils;
-
-import java.util.Arrays;
-
-/**
- * Contains information elements for a GSM or UMTS ETWS warning notification.
- * Supported values for each element are defined in 3GPP TS 23.041.
- *
- * {@hide}
- */
-public class SmsCbEtwsInfo implements Parcelable {
-
- /** ETWS warning type for earthquake. */
- public static final int ETWS_WARNING_TYPE_EARTHQUAKE = 0x00;
-
- /** ETWS warning type for tsunami. */
- public static final int ETWS_WARNING_TYPE_TSUNAMI = 0x01;
-
- /** ETWS warning type for earthquake and tsunami. */
- public static final int ETWS_WARNING_TYPE_EARTHQUAKE_AND_TSUNAMI = 0x02;
-
- /** ETWS warning type for test messages. */
- public static final int ETWS_WARNING_TYPE_TEST_MESSAGE = 0x03;
-
- /** ETWS warning type for other emergency types. */
- public static final int ETWS_WARNING_TYPE_OTHER_EMERGENCY = 0x04;
-
- /** Unknown ETWS warning type. */
- public static final int ETWS_WARNING_TYPE_UNKNOWN = -1;
-
- /** One of the ETWS warning type constants defined in this class. */
- private final int mWarningType;
-
- /** Whether or not to activate the emergency user alert tone and vibration. */
- private final boolean mEmergencyUserAlert;
-
- /** Whether or not to activate a popup alert. */
- private final boolean mActivatePopup;
-
- /**
- * 50-byte security information (ETWS primary notification for GSM only). As of Release 10,
- * 3GPP TS 23.041 states that the UE shall ignore the ETWS primary notification timestamp
- * and digital signature if received. Therefore it is treated as a raw byte array and
- * parceled with the broadcast intent if present, but the timestamp is only computed if an
- * application asks for the individual components.
- */
- private final byte[] mWarningSecurityInformation;
-
- /** Create a new SmsCbEtwsInfo object with the specified values. */
- public SmsCbEtwsInfo(int warningType, boolean emergencyUserAlert, boolean activatePopup,
- byte[] warningSecurityInformation) {
- mWarningType = warningType;
- mEmergencyUserAlert = emergencyUserAlert;
- mActivatePopup = activatePopup;
- mWarningSecurityInformation = warningSecurityInformation;
- }
-
- /** Create a new SmsCbEtwsInfo object from a Parcel. */
- SmsCbEtwsInfo(Parcel in) {
- mWarningType = in.readInt();
- mEmergencyUserAlert = (in.readInt() != 0);
- mActivatePopup = (in.readInt() != 0);
- mWarningSecurityInformation = in.createByteArray();
- }
-
- /**
- * Flatten this object into a Parcel.
- *
- * @param dest The Parcel in which the object should be written.
- * @param flags Additional flags about how the object should be written (ignored).
- */
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(mWarningType);
- dest.writeInt(mEmergencyUserAlert ? 1 : 0);
- dest.writeInt(mActivatePopup ? 1 : 0);
- dest.writeByteArray(mWarningSecurityInformation);
- }
-
- /**
- * Returns the ETWS warning type.
- * @return a warning type such as {@link #ETWS_WARNING_TYPE_EARTHQUAKE}
- */
- public int getWarningType() {
- return mWarningType;
- }
-
- /**
- * Returns the ETWS emergency user alert flag.
- * @return true to notify terminal to activate emergency user alert; false otherwise
- */
- public boolean isEmergencyUserAlert() {
- return mEmergencyUserAlert;
- }
-
- /**
- * Returns the ETWS activate popup flag.
- * @return true to notify terminal to activate display popup; false otherwise
- */
- public boolean isPopupAlert() {
- return mActivatePopup;
- }
-
- /**
- * Returns the Warning-Security-Information timestamp (GSM primary notifications only).
- * As of Release 10, 3GPP TS 23.041 states that the UE shall ignore this value if received.
- * @return a UTC timestamp in System.currentTimeMillis() format, or 0 if not present
- */
- public long getPrimaryNotificationTimestamp() {
- if (mWarningSecurityInformation == null || mWarningSecurityInformation.length < 7) {
- return 0;
- }
-
- int year = IccUtils.gsmBcdByteToInt(mWarningSecurityInformation[0]);
- int month = IccUtils.gsmBcdByteToInt(mWarningSecurityInformation[1]);
- int day = IccUtils.gsmBcdByteToInt(mWarningSecurityInformation[2]);
- int hour = IccUtils.gsmBcdByteToInt(mWarningSecurityInformation[3]);
- int minute = IccUtils.gsmBcdByteToInt(mWarningSecurityInformation[4]);
- int second = IccUtils.gsmBcdByteToInt(mWarningSecurityInformation[5]);
-
- // For the timezone, the most significant bit of the
- // least significant nibble is the sign byte
- // (meaning the max range of this field is 79 quarter-hours,
- // which is more than enough)
-
- byte tzByte = mWarningSecurityInformation[6];
-
- // Mask out sign bit.
- int timezoneOffset = IccUtils.gsmBcdByteToInt((byte) (tzByte & (~0x08)));
-
- timezoneOffset = ((tzByte & 0x08) == 0) ? timezoneOffset : -timezoneOffset;
-
- Time time = new Time(Time.TIMEZONE_UTC);
-
- // We only need to support years above 2000.
- time.year = year + 2000;
- time.month = month - 1;
- time.monthDay = day;
- time.hour = hour;
- time.minute = minute;
- time.second = second;
-
- // Timezone offset is in quarter hours.
- return time.toMillis(true) - (long) (timezoneOffset * 15 * 60 * 1000);
- }
-
- /**
- * Returns the digital signature (GSM primary notifications only). As of Release 10,
- * 3GPP TS 23.041 states that the UE shall ignore this value if received.
- * @return a byte array containing a copy of the primary notification digital signature
- */
- public byte[] getPrimaryNotificationSignature() {
- if (mWarningSecurityInformation == null || mWarningSecurityInformation.length < 50) {
- return null;
- }
- return Arrays.copyOfRange(mWarningSecurityInformation, 7, 50);
- }
-
- @Override
- public String toString() {
- return "SmsCbEtwsInfo{warningType=" + mWarningType + ", emergencyUserAlert="
- + mEmergencyUserAlert + ", activatePopup=" + mActivatePopup + '}';
- }
-
- /**
- * Describe the kinds of special objects contained in the marshalled representation.
- * @return a bitmask indicating this Parcelable contains no special objects
- */
- @Override
- public int describeContents() {
- return 0;
- }
-
- /** Creator for unparcelling objects. */
- public static final Creator CREATOR = new Creator() {
- public SmsCbEtwsInfo createFromParcel(Parcel in) {
- return new SmsCbEtwsInfo(in);
- }
-
- public SmsCbEtwsInfo[] newArray(int size) {
- return new SmsCbEtwsInfo[size];
- }
- };
-}
diff --git a/telephony/java/android/telephony/SmsCbLocation.java b/telephony/java/android/telephony/SmsCbLocation.java
deleted file mode 100644
index 7b5bd0d4bb71..000000000000
--- a/telephony/java/android/telephony/SmsCbLocation.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.telephony;
-
-import android.os.Bundle;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.telephony.gsm.GsmCellLocation;
-
-/**
- * Represents the location and geographical scope of a cell broadcast message.
- * For GSM/UMTS, the Location Area and Cell ID are set when the broadcast
- * geographical scope is cell wide or Location Area wide. For CDMA, the
- * broadcast geographical scope is always PLMN wide.
- *
- * @hide
- */
-public class SmsCbLocation implements Parcelable {
-
- /** The PLMN. Note that this field may be an empty string, but isn't allowed to be null. */
- private final String mPlmn;
-
- private final int mLac;
- private final int mCid;
-
- /**
- * Construct an empty location object. This is used for some test cases, and for
- * cell broadcasts saved in older versions of the database without location info.
- */
- public SmsCbLocation() {
- mPlmn = "";
- mLac = -1;
- mCid = -1;
- }
-
- /**
- * Construct a location object for the PLMN. This class is immutable, so
- * the same object can be reused for multiple broadcasts.
- */
- public SmsCbLocation(String plmn) {
- mPlmn = plmn;
- mLac = -1;
- mCid = -1;
- }
-
- /**
- * Construct a location object for the PLMN, LAC, and Cell ID. This class is immutable, so
- * the same object can be reused for multiple broadcasts.
- */
- public SmsCbLocation(String plmn, int lac, int cid) {
- mPlmn = plmn;
- mLac = lac;
- mCid = cid;
- }
-
- /**
- * Initialize the object from a Parcel.
- */
- public SmsCbLocation(Parcel in) {
- mPlmn = in.readString();
- mLac = in.readInt();
- mCid = in.readInt();
- }
-
- /**
- * Returns the MCC/MNC of the network as a String.
- * @return the PLMN identifier (MCC+MNC) as a String
- */
- public String getPlmn() {
- return mPlmn;
- }
-
- /**
- * Returns the GSM location area code, or UMTS service area code.
- * @return location area code, -1 if unknown, 0xffff max legal value
- */
- public int getLac() {
- return mLac;
- }
-
- /**
- * Returns the GSM or UMTS cell ID.
- * @return gsm cell id, -1 if unknown, 0xffff max legal value
- */
- public int getCid() {
- return mCid;
- }
-
- @Override
- public int hashCode() {
- int hash = mPlmn.hashCode();
- hash = hash * 31 + mLac;
- hash = hash * 31 + mCid;
- return hash;
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- }
- if (o == null || !(o instanceof SmsCbLocation)) {
- return false;
- }
- SmsCbLocation other = (SmsCbLocation) o;
- return mPlmn.equals(other.mPlmn) && mLac == other.mLac && mCid == other.mCid;
- }
-
- @Override
- public String toString() {
- return '[' + mPlmn + ',' + mLac + ',' + mCid + ']';
- }
-
- /**
- * Test whether this location is within the location area of the specified object.
- *
- * @param area the location area to compare with this location
- * @return true if this location is contained within the specified location area
- */
- public boolean isInLocationArea(SmsCbLocation area) {
- if (mCid != -1 && mCid != area.mCid) {
- return false;
- }
- if (mLac != -1 && mLac != area.mLac) {
- return false;
- }
- return mPlmn.equals(area.mPlmn);
- }
-
- /**
- * Test whether this location is within the location area of the CellLocation.
- *
- * @param plmn the PLMN to use for comparison
- * @param lac the Location Area (GSM) or Service Area (UMTS) to compare with
- * @param cid the Cell ID to compare with
- * @return true if this location is contained within the specified PLMN, LAC, and Cell ID
- */
- public boolean isInLocationArea(String plmn, int lac, int cid) {
- if (!mPlmn.equals(plmn)) {
- return false;
- }
-
- if (mLac != -1 && mLac != lac) {
- return false;
- }
-
- if (mCid != -1 && mCid != cid) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Flatten this object into a Parcel.
- *
- * @param dest The Parcel in which the object should be written.
- * @param flags Additional flags about how the object should be written (ignored).
- */
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeString(mPlmn);
- dest.writeInt(mLac);
- dest.writeInt(mCid);
- }
-
- public static final Parcelable.Creator CREATOR
- = new Parcelable.Creator() {
- @Override
- public SmsCbLocation createFromParcel(Parcel in) {
- return new SmsCbLocation(in);
- }
-
- @Override
- public SmsCbLocation[] newArray(int size) {
- return new SmsCbLocation[size];
- }
- };
-
- /**
- * Describe the kinds of special objects contained in the marshalled representation.
- * @return a bitmask indicating this Parcelable contains no special objects
- */
- @Override
- public int describeContents() {
- return 0;
- }
-}
diff --git a/telephony/java/android/telephony/SmsCbMessage.java b/telephony/java/android/telephony/SmsCbMessage.java
deleted file mode 100644
index 046bf8c700eb..000000000000
--- a/telephony/java/android/telephony/SmsCbMessage.java
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.telephony;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * Parcelable object containing a received cell broadcast message. There are four different types
- * of Cell Broadcast messages:
- *
- *
- * - opt-in informational broadcasts, e.g. news, weather, stock quotes, sports scores
- * - cell information messages, broadcast on channel 50, indicating the current cell name for
- * roaming purposes (required to display on the idle screen in Brazil)
- * - emergency broadcasts for the Japanese Earthquake and Tsunami Warning System (ETWS)
- * - emergency broadcasts for the American Commercial Mobile Alert Service (CMAS)
- *
- *
- * There are also four different CB message formats: GSM, ETWS Primary Notification (GSM only),
- * UMTS, and CDMA. Some fields are only applicable for some message formats. Other fields were
- * unified under a common name, avoiding some names, such as "Message Identifier", that refer to
- * two completely different concepts in 3GPP and CDMA.
- *
- *
The GSM/UMTS Message Identifier field is available via {@link #getServiceCategory}, the name
- * of the equivalent field in CDMA. In both cases the service category is a 16-bit value, but 3GPP
- * and 3GPP2 have completely different meanings for the respective values. For ETWS and CMAS, the
- * application should
- *
- *
The CDMA Message Identifier field is available via {@link #getSerialNumber}, which is used
- * to detect the receipt of a duplicate message to be discarded. In CDMA, the message ID is
- * unique to the current PLMN. In GSM/UMTS, there is a 16-bit serial number containing a 2-bit
- * Geographical Scope field which indicates whether the 10-bit message code and 4-bit update number
- * are considered unique to the PLMN, to the current cell, or to the current Location Area (or
- * Service Area in UMTS). The relevant values are concatenated into a single String which will be
- * unique if the messages are not duplicates.
- *
- *
The SMS dispatcher does not detect duplicate messages. However, it does concatenate the
- * pages of a GSM multi-page cell broadcast into a single SmsCbMessage object.
- *
- *
Interested applications with {@code RECEIVE_SMS_PERMISSION} can register to receive
- * {@code SMS_CB_RECEIVED_ACTION} broadcast intents for incoming non-emergency broadcasts.
- * Only system applications such as the CellBroadcastReceiver may receive notifications for
- * emergency broadcasts (ETWS and CMAS). This is intended to prevent any potential for delays or
- * interference with the immediate display of the alert message and playing of the alert sound and
- * vibration pattern, which could be caused by poorly written or malicious non-system code.
- *
- * @hide
- */
-public class SmsCbMessage implements Parcelable {
-
- protected static final String LOG_TAG = "SMSCB";
-
- /** Cell wide geographical scope with immediate display (GSM/UMTS only). */
- public static final int GEOGRAPHICAL_SCOPE_CELL_WIDE_IMMEDIATE = 0;
-
- /** PLMN wide geographical scope (GSM/UMTS and all CDMA broadcasts). */
- public static final int GEOGRAPHICAL_SCOPE_PLMN_WIDE = 1;
-
- /** Location / service area wide geographical scope (GSM/UMTS only). */
- public static final int GEOGRAPHICAL_SCOPE_LA_WIDE = 2;
-
- /** Cell wide geographical scope (GSM/UMTS only). */
- public static final int GEOGRAPHICAL_SCOPE_CELL_WIDE = 3;
-
- /** GSM or UMTS format cell broadcast. */
- public static final int MESSAGE_FORMAT_3GPP = 1;
-
- /** CDMA format cell broadcast. */
- public static final int MESSAGE_FORMAT_3GPP2 = 2;
-
- /** Normal message priority. */
- public static final int MESSAGE_PRIORITY_NORMAL = 0;
-
- /** Interactive message priority. */
- public static final int MESSAGE_PRIORITY_INTERACTIVE = 1;
-
- /** Urgent message priority. */
- public static final int MESSAGE_PRIORITY_URGENT = 2;
-
- /** Emergency message priority. */
- public static final int MESSAGE_PRIORITY_EMERGENCY = 3;
-
- /** Format of this message (for interpretation of service category values). */
- private final int mMessageFormat;
-
- /** Geographical scope of broadcast. */
- private final int mGeographicalScope;
-
- /**
- * Serial number of broadcast (message identifier for CDMA, geographical scope + message code +
- * update number for GSM/UMTS). The serial number plus the location code uniquely identify
- * a cell broadcast for duplicate detection.
- */
- private final int mSerialNumber;
-
- /**
- * Location identifier for this message. It consists of the current operator MCC/MNC as a
- * 5 or 6-digit decimal string. In addition, for GSM/UMTS, if the Geographical Scope of the
- * message is not binary 01, the Location Area is included for comparison. If the GS is
- * 00 or 11, the Cell ID is also included. LAC and Cell ID are -1 if not specified.
- */
- private final SmsCbLocation mLocation;
-
- /**
- * 16-bit CDMA service category or GSM/UMTS message identifier. For ETWS and CMAS warnings,
- * the information provided by the category is also available via {@link #getEtwsWarningInfo()}
- * or {@link #getCmasWarningInfo()}.
- */
- private final int mServiceCategory;
-
- /** Message language, as a two-character string, e.g. "en". */
- private final String mLanguage;
-
- /** Message body, as a String. */
- private final String mBody;
-
- /** Message priority (including emergency priority). */
- private final int mPriority;
-
- /** ETWS warning notification information (ETWS warnings only). */
- private final SmsCbEtwsInfo mEtwsWarningInfo;
-
- /** CMAS warning notification information (CMAS warnings only). */
- private final SmsCbCmasInfo mCmasWarningInfo;
-
- /**
- * Create a new SmsCbMessage with the specified data.
- */
- public SmsCbMessage(int messageFormat, int geographicalScope, int serialNumber,
- SmsCbLocation location, int serviceCategory, String language, String body,
- int priority, SmsCbEtwsInfo etwsWarningInfo, SmsCbCmasInfo cmasWarningInfo) {
- mMessageFormat = messageFormat;
- mGeographicalScope = geographicalScope;
- mSerialNumber = serialNumber;
- mLocation = location;
- mServiceCategory = serviceCategory;
- mLanguage = language;
- mBody = body;
- mPriority = priority;
- mEtwsWarningInfo = etwsWarningInfo;
- mCmasWarningInfo = cmasWarningInfo;
- }
-
- /** Create a new SmsCbMessage object from a Parcel. */
- public SmsCbMessage(Parcel in) {
- mMessageFormat = in.readInt();
- mGeographicalScope = in.readInt();
- mSerialNumber = in.readInt();
- mLocation = new SmsCbLocation(in);
- mServiceCategory = in.readInt();
- mLanguage = in.readString();
- mBody = in.readString();
- mPriority = in.readInt();
- int type = in.readInt();
- switch (type) {
- case 'E':
- // unparcel ETWS warning information
- mEtwsWarningInfo = new SmsCbEtwsInfo(in);
- mCmasWarningInfo = null;
- break;
-
- case 'C':
- // unparcel CMAS warning information
- mEtwsWarningInfo = null;
- mCmasWarningInfo = new SmsCbCmasInfo(in);
- break;
-
- default:
- mEtwsWarningInfo = null;
- mCmasWarningInfo = null;
- }
- }
-
- /**
- * Flatten this object into a Parcel.
- *
- * @param dest The Parcel in which the object should be written.
- * @param flags Additional flags about how the object should be written (ignored).
- */
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(mMessageFormat);
- dest.writeInt(mGeographicalScope);
- dest.writeInt(mSerialNumber);
- mLocation.writeToParcel(dest, flags);
- dest.writeInt(mServiceCategory);
- dest.writeString(mLanguage);
- dest.writeString(mBody);
- dest.writeInt(mPriority);
- if (mEtwsWarningInfo != null) {
- // parcel ETWS warning information
- dest.writeInt('E');
- mEtwsWarningInfo.writeToParcel(dest, flags);
- } else if (mCmasWarningInfo != null) {
- // parcel CMAS warning information
- dest.writeInt('C');
- mCmasWarningInfo.writeToParcel(dest, flags);
- } else {
- // no ETWS or CMAS warning information
- dest.writeInt('0');
- }
- }
-
- public static final Parcelable.Creator CREATOR
- = new Parcelable.Creator() {
- @Override
- public SmsCbMessage createFromParcel(Parcel in) {
- return new SmsCbMessage(in);
- }
-
- @Override
- public SmsCbMessage[] newArray(int size) {
- return new SmsCbMessage[size];
- }
- };
-
- /**
- * Return the geographical scope of this message (GSM/UMTS only).
- *
- * @return Geographical scope
- */
- public int getGeographicalScope() {
- return mGeographicalScope;
- }
-
- /**
- * Return the broadcast serial number of broadcast (message identifier for CDMA, or
- * geographical scope + message code + update number for GSM/UMTS). The serial number plus
- * the location code uniquely identify a cell broadcast for duplicate detection.
- *
- * @return the 16-bit CDMA message identifier or GSM/UMTS serial number
- */
- public int getSerialNumber() {
- return mSerialNumber;
- }
-
- /**
- * Return the location identifier for this message, consisting of the MCC/MNC as a
- * 5 or 6-digit decimal string. In addition, for GSM/UMTS, if the Geographical Scope of the
- * message is not binary 01, the Location Area is included. If the GS is 00 or 11, the
- * cell ID is also included. The {@link SmsCbLocation} object includes a method to test
- * if the location is included within another location area or within a PLMN and CellLocation.
- *
- * @return the geographical location code for duplicate message detection
- */
- public SmsCbLocation getLocation() {
- return mLocation;
- }
-
- /**
- * Return the 16-bit CDMA service category or GSM/UMTS message identifier. The interpretation
- * of the category is radio technology specific. For ETWS and CMAS warnings, the information
- * provided by the category is available via {@link #getEtwsWarningInfo()} or
- * {@link #getCmasWarningInfo()} in a radio technology independent format.
- *
- * @return the radio technology specific service category
- */
- public int getServiceCategory() {
- return mServiceCategory;
- }
-
- /**
- * Get the ISO-639-1 language code for this message, or null if unspecified
- *
- * @return Language code
- */
- public String getLanguageCode() {
- return mLanguage;
- }
-
- /**
- * Get the body of this message, or null if no body available
- *
- * @return Body, or null
- */
- public String getMessageBody() {
- return mBody;
- }
-
- /**
- * Get the message format ({@link #MESSAGE_FORMAT_3GPP} or {@link #MESSAGE_FORMAT_3GPP2}).
- * @return an integer representing 3GPP or 3GPP2 message format
- */
- public int getMessageFormat() {
- return mMessageFormat;
- }
-
- /**
- * Get the message priority. Normal broadcasts return {@link #MESSAGE_PRIORITY_NORMAL}
- * and emergency broadcasts return {@link #MESSAGE_PRIORITY_EMERGENCY}. CDMA also may return
- * {@link #MESSAGE_PRIORITY_INTERACTIVE} or {@link #MESSAGE_PRIORITY_URGENT}.
- * @return an integer representing the message priority
- */
- public int getMessagePriority() {
- return mPriority;
- }
-
- /**
- * If this is an ETWS warning notification then this method will return an object containing
- * the ETWS warning type, the emergency user alert flag, and the popup flag. If this is an
- * ETWS primary notification (GSM only), there will also be a 7-byte timestamp and 43-byte
- * digital signature. As of Release 10, 3GPP TS 23.041 states that the UE shall ignore the
- * ETWS primary notification timestamp and digital signature if received.
- *
- * @return an SmsCbEtwsInfo object, or null if this is not an ETWS warning notification
- */
- public SmsCbEtwsInfo getEtwsWarningInfo() {
- return mEtwsWarningInfo;
- }
-
- /**
- * If this is a CMAS warning notification then this method will return an object containing
- * the CMAS message class, category, response type, severity, urgency and certainty.
- * The message class is always present. Severity, urgency and certainty are present for CDMA
- * warning notifications containing a type 1 elements record and for GSM and UMTS warnings
- * except for the Presidential-level alert category. Category and response type are only
- * available for CDMA notifications containing a type 1 elements record.
- *
- * @return an SmsCbCmasInfo object, or null if this is not a CMAS warning notification
- */
- public SmsCbCmasInfo getCmasWarningInfo() {
- return mCmasWarningInfo;
- }
-
- /**
- * Return whether this message is an emergency (PWS) message type.
- * @return true if the message is a public warning notification; false otherwise
- */
- public boolean isEmergencyMessage() {
- return mPriority == MESSAGE_PRIORITY_EMERGENCY;
- }
-
- /**
- * Return whether this message is an ETWS warning alert.
- * @return true if the message is an ETWS warning notification; false otherwise
- */
- public boolean isEtwsMessage() {
- return mEtwsWarningInfo != null;
- }
-
- /**
- * Return whether this message is a CMAS warning alert.
- * @return true if the message is a CMAS warning notification; false otherwise
- */
- public boolean isCmasMessage() {
- return mCmasWarningInfo != null;
- }
-
- @Override
- public String toString() {
- return "SmsCbMessage{geographicalScope=" + mGeographicalScope + ", serialNumber="
- + mSerialNumber + ", location=" + mLocation + ", serviceCategory="
- + mServiceCategory + ", language=" + mLanguage + ", body=" + mBody
- + ", priority=" + mPriority
- + (mEtwsWarningInfo != null ? (", " + mEtwsWarningInfo.toString()) : "")
- + (mCmasWarningInfo != null ? (", " + mCmasWarningInfo.toString()) : "") + '}';
- }
-
- /**
- * Describe the kinds of special objects contained in the marshalled representation.
- * @return a bitmask indicating this Parcelable contains no special objects
- */
- @Override
- public int describeContents() {
- return 0;
- }
-}
diff --git a/telephony/java/android/telephony/SmsManager.java b/telephony/java/android/telephony/SmsManager.java
deleted file mode 100644
index 44bdaeb7876e..000000000000
--- a/telephony/java/android/telephony/SmsManager.java
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.telephony;
-
-import android.app.PendingIntent;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.text.TextUtils;
-
-import com.android.internal.telephony.ISms;
-import com.android.internal.telephony.IccConstants;
-import com.android.internal.telephony.SmsRawData;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/*
- * TODO(code review): Curious question... Why are a lot of these
- * methods not declared as static, since they do not seem to require
- * any local object state? Presumably this cannot be changed without
- * interfering with the API...
- */
-
-/**
- * Manages SMS operations such as sending data, text, and pdu SMS messages.
- * Get this object by calling the static method SmsManager.getDefault().
- */
-public final class SmsManager {
- /** Singleton object constructed during class initialization. */
- private static final SmsManager sInstance = new SmsManager();
-
- /**
- * Send a text based SMS.
- *
- * @param destinationAddress the address to send the message to
- * @param scAddress is the service center address or null to use
- * the current default SMSC
- * @param text the body of the message to send
- * @param sentIntent if not NULL this PendingIntent
is
- * broadcast when the message is successfully sent, or failed.
- * The result code will be Activity.RESULT_OK
for success,
- * or one of these errors:
- * RESULT_ERROR_GENERIC_FAILURE
- * RESULT_ERROR_RADIO_OFF
- * RESULT_ERROR_NULL_PDU
- * For RESULT_ERROR_GENERIC_FAILURE
the sentIntent may include
- * the extra "errorCode" containing a radio technology specific value,
- * generally only useful for troubleshooting.
- * The per-application based SMS control checks sentIntent. If sentIntent
- * is NULL the caller will be checked against all unknown applications,
- * which cause smaller number of SMS to be sent in checking period.
- * @param deliveryIntent if not NULL this PendingIntent
is
- * broadcast when the message is delivered to the recipient. The
- * raw pdu of the status report is in the extended data ("pdu").
- *
- * @throws IllegalArgumentException if destinationAddress or text are empty
- */
- public void sendTextMessage(
- String destinationAddress, String scAddress, String text,
- PendingIntent sentIntent, PendingIntent deliveryIntent) {
- if (TextUtils.isEmpty(destinationAddress)) {
- throw new IllegalArgumentException("Invalid destinationAddress");
- }
-
- if (TextUtils.isEmpty(text)) {
- throw new IllegalArgumentException("Invalid message body");
- }
-
- try {
- ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms"));
- if (iccISms != null) {
- iccISms.sendText(destinationAddress, scAddress, text, sentIntent, deliveryIntent);
- }
- } catch (RemoteException ex) {
- // ignore it
- }
- }
-
- /**
- * Divide a message text into several fragments, none bigger than
- * the maximum SMS message size.
- *
- * @param text the original message. Must not be null.
- * @return an ArrayList
of strings that, in order,
- * comprise the original message
- */
- public ArrayList divideMessage(String text) {
- return SmsMessage.fragmentText(text);
- }
-
- /**
- * Send a multi-part text based SMS. The callee should have already
- * divided the message into correctly sized parts by calling
- * divideMessage
.
- *
- * @param destinationAddress the address to send the message to
- * @param scAddress is the service center address or null to use
- * the current default SMSC
- * @param parts an ArrayList
of strings that, in order,
- * comprise the original message
- * @param sentIntents if not null, an ArrayList
of
- * PendingIntent
s (one for each message part) that is
- * broadcast when the corresponding message part has been sent.
- * The result code will be Activity.RESULT_OK
for success,
- * or one of these errors:
- * RESULT_ERROR_GENERIC_FAILURE
- * RESULT_ERROR_RADIO_OFF
- * RESULT_ERROR_NULL_PDU
- * For RESULT_ERROR_GENERIC_FAILURE
each sentIntent may include
- * the extra "errorCode" containing a radio technology specific value,
- * generally only useful for troubleshooting.
- * The per-application based SMS control checks sentIntent. If sentIntent
- * is NULL the caller will be checked against all unknown applications,
- * which cause smaller number of SMS to be sent in checking period.
- * @param deliveryIntents if not null, an ArrayList
of
- * PendingIntent
s (one for each message part) that is
- * broadcast when the corresponding message part has been delivered
- * to the recipient. The raw pdu of the status report is in the
- * extended data ("pdu").
- *
- * @throws IllegalArgumentException if destinationAddress or data are empty
- */
- public void sendMultipartTextMessage(
- String destinationAddress, String scAddress, ArrayList parts,
- ArrayList sentIntents, ArrayList deliveryIntents) {
- if (TextUtils.isEmpty(destinationAddress)) {
- throw new IllegalArgumentException("Invalid destinationAddress");
- }
- if (parts == null || parts.size() < 1) {
- throw new IllegalArgumentException("Invalid message body");
- }
-
- if (parts.size() > 1) {
- try {
- ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms"));
- if (iccISms != null) {
- iccISms.sendMultipartText(destinationAddress, scAddress, parts,
- sentIntents, deliveryIntents);
- }
- } catch (RemoteException ex) {
- // ignore it
- }
- } else {
- PendingIntent sentIntent = null;
- PendingIntent deliveryIntent = null;
- if (sentIntents != null && sentIntents.size() > 0) {
- sentIntent = sentIntents.get(0);
- }
- if (deliveryIntents != null && deliveryIntents.size() > 0) {
- deliveryIntent = deliveryIntents.get(0);
- }
- sendTextMessage(destinationAddress, scAddress, parts.get(0),
- sentIntent, deliveryIntent);
- }
- }
-
- /**
- * Send a data based SMS to a specific application port.
- *
- * @param destinationAddress the address to send the message to
- * @param scAddress is the service center address or null to use
- * the current default SMSC
- * @param destinationPort the port to deliver the message to
- * @param data the body of the message to send
- * @param sentIntent if not NULL this PendingIntent
is
- * broadcast when the message is successfully sent, or failed.
- * The result code will be Activity.RESULT_OK
for success,
- * or one of these errors:
- * RESULT_ERROR_GENERIC_FAILURE
- * RESULT_ERROR_RADIO_OFF
- * RESULT_ERROR_NULL_PDU
- * For RESULT_ERROR_GENERIC_FAILURE
the sentIntent may include
- * the extra "errorCode" containing a radio technology specific value,
- * generally only useful for troubleshooting.
- * The per-application based SMS control checks sentIntent. If sentIntent
- * is NULL the caller will be checked against all unknown applications,
- * which cause smaller number of SMS to be sent in checking period.
- * @param deliveryIntent if not NULL this PendingIntent
is
- * broadcast when the message is delivered to the recipient. The
- * raw pdu of the status report is in the extended data ("pdu").
- *
- * @throws IllegalArgumentException if destinationAddress or data are empty
- */
- public void sendDataMessage(
- String destinationAddress, String scAddress, short destinationPort,
- byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent) {
- if (TextUtils.isEmpty(destinationAddress)) {
- throw new IllegalArgumentException("Invalid destinationAddress");
- }
-
- if (data == null || data.length == 0) {
- throw new IllegalArgumentException("Invalid message data");
- }
-
- try {
- ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms"));
- if (iccISms != null) {
- iccISms.sendData(destinationAddress, scAddress, destinationPort & 0xFFFF,
- data, sentIntent, deliveryIntent);
- }
- } catch (RemoteException ex) {
- // ignore it
- }
- }
-
- /**
- * Get the default instance of the SmsManager
- *
- * @return the default instance of the SmsManager
- */
- public static SmsManager getDefault() {
- return sInstance;
- }
-
- private SmsManager() {
- //nothing
- }
-
- /**
- * Copy a raw SMS PDU to the ICC.
- * ICC (Integrated Circuit Card) is the card of the device.
- * For example, this can be the SIM or USIM for GSM.
- *
- * @param smsc the SMSC for this message, or NULL for the default SMSC
- * @param pdu the raw PDU to store
- * @param status message status (STATUS_ON_ICC_READ, STATUS_ON_ICC_UNREAD,
- * STATUS_ON_ICC_SENT, STATUS_ON_ICC_UNSENT)
- * @return true for success
- *
- * {@hide}
- */
- public boolean copyMessageToIcc(byte[] smsc, byte[] pdu, int status) {
- boolean success = false;
-
- try {
- ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms"));
- if (iccISms != null) {
- success = iccISms.copyMessageToIccEf(status, pdu, smsc);
- }
- } catch (RemoteException ex) {
- // ignore it
- }
-
- return success;
- }
-
- /**
- * Delete the specified message from the ICC.
- * ICC (Integrated Circuit Card) is the card of the device.
- * For example, this can be the SIM or USIM for GSM.
- *
- * @param messageIndex is the record index of the message on ICC
- * @return true for success
- *
- * {@hide}
- */
- public boolean
- deleteMessageFromIcc(int messageIndex) {
- boolean success = false;
- byte[] pdu = new byte[IccConstants.SMS_RECORD_LENGTH-1];
- Arrays.fill(pdu, (byte)0xff);
-
- try {
- ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms"));
- if (iccISms != null) {
- success = iccISms.updateMessageOnIccEf(messageIndex, STATUS_ON_ICC_FREE, pdu);
- }
- } catch (RemoteException ex) {
- // ignore it
- }
-
- return success;
- }
-
- /**
- * Update the specified message on the ICC.
- * ICC (Integrated Circuit Card) is the card of the device.
- * For example, this can be the SIM or USIM for GSM.
- *
- * @param messageIndex record index of message to update
- * @param newStatus new message status (STATUS_ON_ICC_READ,
- * STATUS_ON_ICC_UNREAD, STATUS_ON_ICC_SENT,
- * STATUS_ON_ICC_UNSENT, STATUS_ON_ICC_FREE)
- * @param pdu the raw PDU to store
- * @return true for success
- *
- * {@hide}
- */
- public boolean updateMessageOnIcc(int messageIndex, int newStatus, byte[] pdu) {
- boolean success = false;
-
- try {
- ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms"));
- if (iccISms != null) {
- success = iccISms.updateMessageOnIccEf(messageIndex, newStatus, pdu);
- }
- } catch (RemoteException ex) {
- // ignore it
- }
-
- return success;
- }
-
- /**
- * Retrieves all messages currently stored on ICC.
- * ICC (Integrated Circuit Card) is the card of the device.
- * For example, this can be the SIM or USIM for GSM.
- *
- * @return ArrayList
of SmsMessage
objects
- *
- * {@hide}
- */
- public static ArrayList getAllMessagesFromIcc() {
- List records = null;
-
- try {
- ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms"));
- if (iccISms != null) {
- records = iccISms.getAllMessagesFromIccEf();
- }
- } catch (RemoteException ex) {
- // ignore it
- }
-
- return createMessageListFromRawRecords(records);
- }
-
- /**
- * Enable reception of cell broadcast (SMS-CB) messages with the given
- * message identifier. Note that if two different clients enable the same
- * message identifier, they must both disable it for the device to stop
- * receiving those messages. All received messages will be broadcast in an
- * intent with the action "android.provider.Telephony.SMS_CB_RECEIVED".
- * Note: This call is blocking, callers may want to avoid calling it from
- * the main thread of an application.
- *
- * @param messageIdentifier Message identifier as specified in TS 23.041
- * @return true if successful, false otherwise
- * @see #disableCellBroadcast(int)
- *
- * {@hide}
- */
- public boolean enableCellBroadcast(int messageIdentifier) {
- boolean success = false;
-
- try {
- ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms"));
- if (iccISms != null) {
- success = iccISms.enableCellBroadcast(messageIdentifier);
- }
- } catch (RemoteException ex) {
- // ignore it
- }
-
- return success;
- }
-
- /**
- * Disable reception of cell broadcast (SMS-CB) messages with the given
- * message identifier. Note that if two different clients enable the same
- * message identifier, they must both disable it for the device to stop
- * receiving those messages.
- * Note: This call is blocking, callers may want to avoid calling it from
- * the main thread of an application.
- *
- * @param messageIdentifier Message identifier as specified in TS 23.041
- * @return true if successful, false otherwise
- *
- * @see #enableCellBroadcast(int)
- *
- * {@hide}
- */
- public boolean disableCellBroadcast(int messageIdentifier) {
- boolean success = false;
-
- try {
- ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms"));
- if (iccISms != null) {
- success = iccISms.disableCellBroadcast(messageIdentifier);
- }
- } catch (RemoteException ex) {
- // ignore it
- }
-
- return success;
- }
-
- /**
- * Enable reception of cell broadcast (SMS-CB) messages with the given
- * message identifier range. Note that if two different clients enable the same
- * message identifier, they must both disable it for the device to stop
- * receiving those messages. All received messages will be broadcast in an
- * intent with the action "android.provider.Telephony.SMS_CB_RECEIVED".
- * Note: This call is blocking, callers may want to avoid calling it from
- * the main thread of an application.
- *
- * @param startMessageId first message identifier as specified in TS 23.041
- * @param endMessageId last message identifier as specified in TS 23.041
- * @return true if successful, false otherwise
- * @see #disableCellBroadcastRange(int, int)
- *
- * {@hide}
- */
- public boolean enableCellBroadcastRange(int startMessageId, int endMessageId) {
- boolean success = false;
-
- try {
- ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms"));
- if (iccISms != null) {
- success = iccISms.enableCellBroadcastRange(startMessageId, endMessageId);
- }
- } catch (RemoteException ex) {
- // ignore it
- }
-
- return success;
- }
-
- /**
- * Disable reception of cell broadcast (SMS-CB) messages with the given
- * message identifier range. Note that if two different clients enable the same
- * message identifier, they must both disable it for the device to stop
- * receiving those messages.
- * Note: This call is blocking, callers may want to avoid calling it from
- * the main thread of an application.
- *
- * @param startMessageId first message identifier as specified in TS 23.041
- * @param endMessageId last message identifier as specified in TS 23.041
- * @return true if successful, false otherwise
- *
- * @see #enableCellBroadcastRange(int, int)
- *
- * {@hide}
- */
- public boolean disableCellBroadcastRange(int startMessageId, int endMessageId) {
- boolean success = false;
-
- try {
- ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms"));
- if (iccISms != null) {
- success = iccISms.disableCellBroadcastRange(startMessageId, endMessageId);
- }
- } catch (RemoteException ex) {
- // ignore it
- }
-
- return success;
- }
-
- /**
- * Create a list of SmsMessage
s from a list of RawSmsData
- * records returned by getAllMessagesFromIcc()
- *
- * @param records SMS EF records, returned by
- * getAllMessagesFromIcc
- * @return ArrayList
of SmsMessage
objects.
- */
- private static ArrayList createMessageListFromRawRecords(List records) {
- ArrayList messages = new ArrayList();
- if (records != null) {
- int count = records.size();
- for (int i = 0; i < count; i++) {
- SmsRawData data = records.get(i);
- // List contains all records, including "free" records (null)
- if (data != null) {
- SmsMessage sms = SmsMessage.createFromEfRecord(i+1, data.getBytes());
- if (sms != null) {
- messages.add(sms);
- }
- }
- }
- }
- return messages;
- }
-
- // see SmsMessage.getStatusOnIcc
-
- /** Free space (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27). */
- static public final int STATUS_ON_ICC_FREE = 0;
-
- /** Received and read (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27). */
- static public final int STATUS_ON_ICC_READ = 1;
-
- /** Received and unread (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27). */
- static public final int STATUS_ON_ICC_UNREAD = 3;
-
- /** Stored and sent (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27). */
- static public final int STATUS_ON_ICC_SENT = 5;
-
- /** Stored and unsent (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27). */
- static public final int STATUS_ON_ICC_UNSENT = 7;
-
- // SMS send failure result codes
-
- /** Generic failure cause */
- static public final int RESULT_ERROR_GENERIC_FAILURE = 1;
- /** Failed because radio was explicitly turned off */
- static public final int RESULT_ERROR_RADIO_OFF = 2;
- /** Failed because no pdu provided */
- static public final int RESULT_ERROR_NULL_PDU = 3;
- /** Failed because service is currently unavailable */
- static public final int RESULT_ERROR_NO_SERVICE = 4;
- /** Failed because we reached the sending queue limit. {@hide} */
- static public final int RESULT_ERROR_LIMIT_EXCEEDED = 5;
- /** Failed because FDN is enabled. {@hide} */
- static public final int RESULT_ERROR_FDN_CHECK_FAILURE = 6;
-}
diff --git a/telephony/java/android/telephony/SmsMessage.java b/telephony/java/android/telephony/SmsMessage.java
deleted file mode 100644
index 141074717c21..000000000000
--- a/telephony/java/android/telephony/SmsMessage.java
+++ /dev/null
@@ -1,680 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.telephony;
-
-import android.os.Parcel;
-import android.util.Log;
-
-import com.android.internal.telephony.GsmAlphabet;
-import com.android.internal.telephony.SmsHeader;
-import com.android.internal.telephony.SmsMessageBase;
-import com.android.internal.telephony.SmsMessageBase.SubmitPduBase;
-import com.android.internal.telephony.SmsMessageBase.TextEncodingDetails;
-
-import java.lang.Math;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import static android.telephony.TelephonyManager.PHONE_TYPE_CDMA;
-
-
-/**
- * A Short Message Service message.
- */
-public class SmsMessage {
- private static final String LOG_TAG = "SMS";
-
- /**
- * SMS Class enumeration.
- * See TS 23.038.
- *
- */
- public enum MessageClass{
- UNKNOWN, CLASS_0, CLASS_1, CLASS_2, CLASS_3;
- }
-
- /** User data text encoding code unit size */
- public static final int ENCODING_UNKNOWN = 0;
- public static final int ENCODING_7BIT = 1;
- public static final int ENCODING_8BIT = 2;
- public static final int ENCODING_16BIT = 3;
- /**
- * @hide This value is not defined in global standard. Only in Korea, this is used.
- */
- public static final int ENCODING_KSC5601 = 4;
-
- /** The maximum number of payload bytes per message */
- public static final int MAX_USER_DATA_BYTES = 140;
-
- /**
- * The maximum number of payload bytes per message if a user data header
- * is present. This assumes the header only contains the
- * CONCATENATED_8_BIT_REFERENCE element.
- */
- public static final int MAX_USER_DATA_BYTES_WITH_HEADER = 134;
-
- /** The maximum number of payload septets per message */
- public static final int MAX_USER_DATA_SEPTETS = 160;
-
- /**
- * The maximum number of payload septets per message if a user data header
- * is present. This assumes the header only contains the
- * CONCATENATED_8_BIT_REFERENCE element.
- */
- public static final int MAX_USER_DATA_SEPTETS_WITH_HEADER = 153;
-
- /**
- * Indicates a 3GPP format SMS message.
- * @hide pending API council approval
- */
- public static final String FORMAT_3GPP = "3gpp";
-
- /**
- * Indicates a 3GPP2 format SMS message.
- * @hide pending API council approval
- */
- public static final String FORMAT_3GPP2 = "3gpp2";
-
- /** Contains actual SmsMessage. Only public for debugging and for framework layer.
- *
- * @hide
- */
- public SmsMessageBase mWrappedSmsMessage;
-
- public static class SubmitPdu {
-
- public byte[] encodedScAddress; // Null if not applicable.
- public byte[] encodedMessage;
-
- public String toString() {
- return "SubmitPdu: encodedScAddress = "
- + Arrays.toString(encodedScAddress)
- + ", encodedMessage = "
- + Arrays.toString(encodedMessage);
- }
-
- /**
- * @hide
- */
- protected SubmitPdu(SubmitPduBase spb) {
- this.encodedMessage = spb.encodedMessage;
- this.encodedScAddress = spb.encodedScAddress;
- }
-
- }
-
- private SmsMessage(SmsMessageBase smb) {
- mWrappedSmsMessage = smb;
- }
-
- /**
- * Create an SmsMessage from a raw PDU.
- *
- * This method will soon be deprecated and all applications which handle
- * incoming SMS messages by processing the {@code SMS_RECEIVED_ACTION} broadcast
- * intent must now pass the new {@code format} String extra from the intent
- * into the new method {@code createFromPdu(byte[], String)} which takes an
- * extra format parameter. This is required in order to correctly decode the PDU on
- * devices that require support for both 3GPP and 3GPP2 formats at the same time,
- * such as dual-mode GSM/CDMA and CDMA/LTE phones.
- */
- public static SmsMessage createFromPdu(byte[] pdu) {
- int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
- String format = (PHONE_TYPE_CDMA == activePhone) ? FORMAT_3GPP2 : FORMAT_3GPP;
- return createFromPdu(pdu, format);
- }
-
- /**
- * Create an SmsMessage from a raw PDU with the specified message format. The
- * message format is passed in the {@code SMS_RECEIVED_ACTION} as the {@code format}
- * String extra, and will be either "3gpp" for GSM/UMTS/LTE messages in 3GPP format
- * or "3gpp2" for CDMA/LTE messages in 3GPP2 format.
- *
- * @param pdu the message PDU from the SMS_RECEIVED_ACTION intent
- * @param format the format extra from the SMS_RECEIVED_ACTION intent
- * @hide pending API council approval
- */
- public static SmsMessage createFromPdu(byte[] pdu, String format) {
- SmsMessageBase wrappedMessage;
-
- if (FORMAT_3GPP2.equals(format)) {
- wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromPdu(pdu);
- } else if (FORMAT_3GPP.equals(format)) {
- wrappedMessage = com.android.internal.telephony.gsm.SmsMessage.createFromPdu(pdu);
- } else {
- Log.e(LOG_TAG, "createFromPdu(): unsupported message format " + format);
- return null;
- }
-
- return new SmsMessage(wrappedMessage);
- }
-
- /**
- * TS 27.005 3.4.1 lines[0] and lines[1] are the two lines read from the
- * +CMT unsolicited response (PDU mode, of course)
- * +CMT: [<alpha>],
- *
- * Only public for debugging and for RIL
- *
- * {@hide}
- */
- public static SmsMessage newFromCMT(String[] lines) {
- // received SMS in 3GPP format
- SmsMessageBase wrappedMessage =
- com.android.internal.telephony.gsm.SmsMessage.newFromCMT(lines);
-
- return new SmsMessage(wrappedMessage);
- }
-
- /** @hide */
- public static SmsMessage newFromParcel(Parcel p) {
- // received SMS in 3GPP2 format
- SmsMessageBase wrappedMessage =
- com.android.internal.telephony.cdma.SmsMessage.newFromParcel(p);
-
- return new SmsMessage(wrappedMessage);
- }
-
- /**
- * Create an SmsMessage from an SMS EF record.
- *
- * @param index Index of SMS record. This should be index in ArrayList
- * returned by SmsManager.getAllMessagesFromSim + 1.
- * @param data Record data.
- * @return An SmsMessage representing the record.
- *
- * @hide
- */
- public static SmsMessage createFromEfRecord(int index, byte[] data) {
- SmsMessageBase wrappedMessage;
- int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
-
- if (PHONE_TYPE_CDMA == activePhone) {
- wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromEfRecord(
- index, data);
- } else {
- wrappedMessage = com.android.internal.telephony.gsm.SmsMessage.createFromEfRecord(
- index, data);
- }
-
- return wrappedMessage != null ? new SmsMessage(wrappedMessage) : null;
- }
-
- /**
- * Get the TP-Layer-Length for the given SMS-SUBMIT PDU Basically, the
- * length in bytes (not hex chars) less the SMSC header
- *
- * FIXME: This method is only used by a CTS test case that isn't run on CDMA devices.
- * We should probably deprecate it and remove the obsolete test case.
- */
- public static int getTPLayerLengthForPDU(String pdu) {
- int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
-
- if (PHONE_TYPE_CDMA == activePhone) {
- return com.android.internal.telephony.cdma.SmsMessage.getTPLayerLengthForPDU(pdu);
- } else {
- return com.android.internal.telephony.gsm.SmsMessage.getTPLayerLengthForPDU(pdu);
- }
- }
-
- /*
- * TODO(cleanup): It would make some sense if the result of
- * preprocessing a message to determine the proper encoding (i.e.
- * the resulting data structure from calculateLength) could be
- * passed as an argument to the actual final encoding function.
- * This would better ensure that the logic behind size calculation
- * actually matched the encoding.
- */
-
- /**
- * Calculates the number of SMS's required to encode the message body and
- * the number of characters remaining until the next message.
- *
- * @param msgBody the message to encode
- * @param use7bitOnly if true, characters that are not part of the
- * radio-specific 7-bit encoding are counted as single
- * space chars. If false, and if the messageBody contains
- * non-7-bit encodable characters, length is calculated
- * using a 16-bit encoding.
- * @return an int[4] with int[0] being the number of SMS's
- * required, int[1] the number of code units used, and
- * int[2] is the number of code units remaining until the
- * next message. int[3] is an indicator of the encoding
- * code unit size (see the ENCODING_* definitions in this
- * class).
- */
- public static int[] calculateLength(CharSequence msgBody, boolean use7bitOnly) {
- int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
- TextEncodingDetails ted = (PHONE_TYPE_CDMA == activePhone) ?
- com.android.internal.telephony.cdma.SmsMessage.calculateLength(msgBody, use7bitOnly) :
- com.android.internal.telephony.gsm.SmsMessage.calculateLength(msgBody, use7bitOnly);
- int ret[] = new int[4];
- ret[0] = ted.msgCount;
- ret[1] = ted.codeUnitCount;
- ret[2] = ted.codeUnitsRemaining;
- ret[3] = ted.codeUnitSize;
- return ret;
- }
-
- /**
- * Divide a message text into several fragments, none bigger than
- * the maximum SMS message text size.
- *
- * @param text text, must not be null.
- * @return an ArrayList
of strings that, in order,
- * comprise the original msg text
- *
- * @hide
- */
- public static ArrayList fragmentText(String text) {
- int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
- TextEncodingDetails ted = (PHONE_TYPE_CDMA == activePhone) ?
- com.android.internal.telephony.cdma.SmsMessage.calculateLength(text, false) :
- com.android.internal.telephony.gsm.SmsMessage.calculateLength(text, false);
-
- // TODO(cleanup): The code here could be rolled into the logic
- // below cleanly if these MAX_* constants were defined more
- // flexibly...
-
- int limit;
- if (ted.codeUnitSize == ENCODING_7BIT) {
- int udhLength;
- if (ted.languageTable != 0 && ted.languageShiftTable != 0) {
- udhLength = GsmAlphabet.UDH_SEPTET_COST_TWO_SHIFT_TABLES;
- } else if (ted.languageTable != 0 || ted.languageShiftTable != 0) {
- udhLength = GsmAlphabet.UDH_SEPTET_COST_ONE_SHIFT_TABLE;
- } else {
- udhLength = 0;
- }
-
- if (ted.msgCount > 1) {
- udhLength += GsmAlphabet.UDH_SEPTET_COST_CONCATENATED_MESSAGE;
- }
-
- if (udhLength != 0) {
- udhLength += GsmAlphabet.UDH_SEPTET_COST_LENGTH;
- }
-
- limit = MAX_USER_DATA_SEPTETS - udhLength;
- } else {
- if (ted.msgCount > 1) {
- limit = MAX_USER_DATA_BYTES_WITH_HEADER;
- } else {
- limit = MAX_USER_DATA_BYTES;
- }
- }
-
- int pos = 0; // Index in code units.
- int textLen = text.length();
- ArrayList result = new ArrayList(ted.msgCount);
- while (pos < textLen) {
- int nextPos = 0; // Counts code units.
- if (ted.codeUnitSize == ENCODING_7BIT) {
- if (activePhone == PHONE_TYPE_CDMA && ted.msgCount == 1) {
- // For a singleton CDMA message, the encoding must be ASCII...
- nextPos = pos + Math.min(limit, textLen - pos);
- } else {
- // For multi-segment messages, CDMA 7bit equals GSM 7bit encoding (EMS mode).
- nextPos = GsmAlphabet.findGsmSeptetLimitIndex(text, pos, limit,
- ted.languageTable, ted.languageShiftTable);
- }
- } else { // Assume unicode.
- nextPos = pos + Math.min(limit / 2, textLen - pos);
- }
- if ((nextPos <= pos) || (nextPos > textLen)) {
- Log.e(LOG_TAG, "fragmentText failed (" + pos + " >= " + nextPos + " or " +
- nextPos + " >= " + textLen + ")");
- break;
- }
- result.add(text.substring(pos, nextPos));
- pos = nextPos;
- }
- return result;
- }
-
- /**
- * Calculates the number of SMS's required to encode the message body and
- * the number of characters remaining until the next message, given the
- * current encoding.
- *
- * @param messageBody the message to encode
- * @param use7bitOnly if true, characters that are not part of the radio
- * specific (GSM / CDMA) alphabet encoding are converted to as a
- * single space characters. If false, a messageBody containing
- * non-GSM or non-CDMA alphabet characters are encoded using
- * 16-bit encoding.
- * @return an int[4] with int[0] being the number of SMS's required, int[1]
- * the number of code units used, and int[2] is the number of code
- * units remaining until the next message. int[3] is the encoding
- * type that should be used for the message.
- */
- public static int[] calculateLength(String messageBody, boolean use7bitOnly) {
- return calculateLength((CharSequence)messageBody, use7bitOnly);
- }
-
- /*
- * TODO(cleanup): It looks like there is now no useful reason why
- * apps should generate pdus themselves using these routines,
- * instead of handing the raw data to SMSDispatcher (and thereby
- * have the phone process do the encoding). Moreover, CDMA now
- * has shared state (in the form of the msgId system property)
- * which can only be modified by the phone process, and hence
- * makes the output of these routines incorrect. Since they now
- * serve no purpose, they should probably just return null
- * directly, and be deprecated. Going further in that direction,
- * the above parsers of serialized pdu data should probably also
- * be gotten rid of, hiding all but the necessarily visible
- * structured data from client apps. A possible concern with
- * doing this is that apps may be using these routines to generate
- * pdus that are then sent elsewhere, some network server, for
- * example, and that always returning null would thereby break
- * otherwise useful apps.
- */
-
- /**
- * Get an SMS-SUBMIT PDU for a destination address and a message.
- * This method will not attempt to use any GSM national language 7 bit encodings.
- *
- * @param scAddress Service Centre address. Null means use default.
- * @return a SubmitPdu
containing the encoded SC
- * address, if applicable, and the encoded message.
- * Returns null on encode error.
- */
- public static SubmitPdu getSubmitPdu(String scAddress,
- String destinationAddress, String message, boolean statusReportRequested) {
- SubmitPduBase spb;
- int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
-
- if (PHONE_TYPE_CDMA == activePhone) {
- spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
- destinationAddress, message, statusReportRequested, null);
- } else {
- spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress,
- destinationAddress, message, statusReportRequested);
- }
-
- return new SubmitPdu(spb);
- }
-
- /**
- * Get an SMS-SUBMIT PDU for a data message to a destination address & port.
- * This method will not attempt to use any GSM national language 7 bit encodings.
- *
- * @param scAddress Service Centre address. null == use default
- * @param destinationAddress the address of the destination for the message
- * @param destinationPort the port to deliver the message to at the
- * destination
- * @param data the data for the message
- * @return a SubmitPdu
containing the encoded SC
- * address, if applicable, and the encoded message.
- * Returns null on encode error.
- */
- public static SubmitPdu getSubmitPdu(String scAddress,
- String destinationAddress, short destinationPort, byte[] data,
- boolean statusReportRequested) {
- SubmitPduBase spb;
- int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
-
- if (PHONE_TYPE_CDMA == activePhone) {
- spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
- destinationAddress, destinationPort, data, statusReportRequested);
- } else {
- spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress,
- destinationAddress, destinationPort, data, statusReportRequested);
- }
-
- return new SubmitPdu(spb);
- }
-
- /**
- * Returns the address of the SMS service center that relayed this message
- * or null if there is none.
- */
- public String getServiceCenterAddress() {
- return mWrappedSmsMessage.getServiceCenterAddress();
- }
-
- /**
- * Returns the originating address (sender) of this SMS message in String
- * form or null if unavailable
- */
- public String getOriginatingAddress() {
- return mWrappedSmsMessage.getOriginatingAddress();
- }
-
- /**
- * Returns the originating address, or email from address if this message
- * was from an email gateway. Returns null if originating address
- * unavailable.
- */
- public String getDisplayOriginatingAddress() {
- return mWrappedSmsMessage.getDisplayOriginatingAddress();
- }
-
- /**
- * Returns the message body as a String, if it exists and is text based.
- * @return message body is there is one, otherwise null
- */
- public String getMessageBody() {
- return mWrappedSmsMessage.getMessageBody();
- }
-
- /**
- * Returns the class of this message.
- */
- public MessageClass getMessageClass() {
- return mWrappedSmsMessage.getMessageClass();
- }
-
- /**
- * Returns the message body, or email message body if this message was from
- * an email gateway. Returns null if message body unavailable.
- */
- public String getDisplayMessageBody() {
- return mWrappedSmsMessage.getDisplayMessageBody();
- }
-
- /**
- * Unofficial convention of a subject line enclosed in parens empty string
- * if not present
- */
- public String getPseudoSubject() {
- return mWrappedSmsMessage.getPseudoSubject();
- }
-
- /**
- * Returns the service centre timestamp in currentTimeMillis() format
- */
- public long getTimestampMillis() {
- return mWrappedSmsMessage.getTimestampMillis();
- }
-
- /**
- * Returns true if message is an email.
- *
- * @return true if this message came through an email gateway and email
- * sender / subject / parsed body are available
- */
- public boolean isEmail() {
- return mWrappedSmsMessage.isEmail();
- }
-
- /**
- * @return if isEmail() is true, body of the email sent through the gateway.
- * null otherwise
- */
- public String getEmailBody() {
- return mWrappedSmsMessage.getEmailBody();
- }
-
- /**
- * @return if isEmail() is true, email from address of email sent through
- * the gateway. null otherwise
- */
- public String getEmailFrom() {
- return mWrappedSmsMessage.getEmailFrom();
- }
-
- /**
- * Get protocol identifier.
- */
- public int getProtocolIdentifier() {
- return mWrappedSmsMessage.getProtocolIdentifier();
- }
-
- /**
- * See TS 23.040 9.2.3.9 returns true if this is a "replace short message"
- * SMS
- */
- public boolean isReplace() {
- return mWrappedSmsMessage.isReplace();
- }
-
- /**
- * Returns true for CPHS MWI toggle message.
- *
- * @return true if this is a CPHS MWI toggle message See CPHS 4.2 section
- * B.4.2
- */
- public boolean isCphsMwiMessage() {
- return mWrappedSmsMessage.isCphsMwiMessage();
- }
-
- /**
- * returns true if this message is a CPHS voicemail / message waiting
- * indicator (MWI) clear message
- */
- public boolean isMWIClearMessage() {
- return mWrappedSmsMessage.isMWIClearMessage();
- }
-
- /**
- * returns true if this message is a CPHS voicemail / message waiting
- * indicator (MWI) set message
- */
- public boolean isMWISetMessage() {
- return mWrappedSmsMessage.isMWISetMessage();
- }
-
- /**
- * returns true if this message is a "Message Waiting Indication Group:
- * Discard Message" notification and should not be stored.
- */
- public boolean isMwiDontStore() {
- return mWrappedSmsMessage.isMwiDontStore();
- }
-
- /**
- * returns the user data section minus the user data header if one was
- * present.
- */
- public byte[] getUserData() {
- return mWrappedSmsMessage.getUserData();
- }
-
- /**
- * Returns the raw PDU for the message.
- *
- * @return the raw PDU for the message.
- */
- public byte[] getPdu() {
- return mWrappedSmsMessage.getPdu();
- }
-
- /**
- * Returns the status of the message on the SIM (read, unread, sent, unsent).
- *
- * @return the status of the message on the SIM. These are:
- * SmsManager.STATUS_ON_SIM_FREE
- * SmsManager.STATUS_ON_SIM_READ
- * SmsManager.STATUS_ON_SIM_UNREAD
- * SmsManager.STATUS_ON_SIM_SEND
- * SmsManager.STATUS_ON_SIM_UNSENT
- * @deprecated Use getStatusOnIcc instead.
- */
- @Deprecated public int getStatusOnSim() {
- return mWrappedSmsMessage.getStatusOnIcc();
- }
-
- /**
- * Returns the status of the message on the ICC (read, unread, sent, unsent).
- *
- * @return the status of the message on the ICC. These are:
- * SmsManager.STATUS_ON_ICC_FREE
- * SmsManager.STATUS_ON_ICC_READ
- * SmsManager.STATUS_ON_ICC_UNREAD
- * SmsManager.STATUS_ON_ICC_SEND
- * SmsManager.STATUS_ON_ICC_UNSENT
- */
- public int getStatusOnIcc() {
- return mWrappedSmsMessage.getStatusOnIcc();
- }
-
- /**
- * Returns the record index of the message on the SIM (1-based index).
- * @return the record index of the message on the SIM, or -1 if this
- * SmsMessage was not created from a SIM SMS EF record.
- * @deprecated Use getIndexOnIcc instead.
- */
- @Deprecated public int getIndexOnSim() {
- return mWrappedSmsMessage.getIndexOnIcc();
- }
-
- /**
- * Returns the record index of the message on the ICC (1-based index).
- * @return the record index of the message on the ICC, or -1 if this
- * SmsMessage was not created from a ICC SMS EF record.
- */
- public int getIndexOnIcc() {
- return mWrappedSmsMessage.getIndexOnIcc();
- }
-
- /**
- * GSM:
- * For an SMS-STATUS-REPORT message, this returns the status field from
- * the status report. This field indicates the status of a previously
- * submitted SMS, if requested. See TS 23.040, 9.2.3.15 TP-Status for a
- * description of values.
- * CDMA:
- * For not interfering with status codes from GSM, the value is
- * shifted to the bits 31-16.
- * The value is composed of an error class (bits 25-24) and a status code (bits 23-16).
- * Possible codes are described in C.S0015-B, v2.0, 4.5.21.
- *
- * @return 0 indicates the previously sent message was received.
- * See TS 23.040, 9.9.2.3.15 and C.S0015-B, v2.0, 4.5.21
- * for a description of other possible values.
- */
- public int getStatus() {
- return mWrappedSmsMessage.getStatus();
- }
-
- /**
- * Return true iff the message is a SMS-STATUS-REPORT message.
- */
- public boolean isStatusReportMessage() {
- return mWrappedSmsMessage.isStatusReportMessage();
- }
-
- /**
- * Returns true iff the TP-Reply-Path
bit is set in
- * this message.
- */
- public boolean isReplyPathPresent() {
- return mWrappedSmsMessage.isReplyPathPresent();
- }
-}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index bc50906e0c7d..fa4b7cdc16ab 100755
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -23,15 +23,20 @@ import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
+import android.util.Log;
import com.android.internal.telephony.IPhoneSubInfo;
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.ITelephonyRegistry;
-import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.PhoneFactory;
+import com.android.internal.telephony.PhoneConstants;
+import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.TelephonyProperties;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* Provides access to information about the telephony services on
@@ -131,25 +136,25 @@ public class TelephonyManager {
* Retrieve with
* {@link android.content.Intent#getStringExtra(String)}.
*/
- public static final String EXTRA_STATE = Phone.STATE_KEY;
+ public static final String EXTRA_STATE = PhoneConstants.STATE_KEY;
/**
* Value used with {@link #EXTRA_STATE} corresponding to
* {@link #CALL_STATE_IDLE}.
*/
- public static final String EXTRA_STATE_IDLE = Phone.State.IDLE.toString();
+ public static final String EXTRA_STATE_IDLE = PhoneConstants.State.IDLE.toString();
/**
* Value used with {@link #EXTRA_STATE} corresponding to
* {@link #CALL_STATE_RINGING}.
*/
- public static final String EXTRA_STATE_RINGING = Phone.State.RINGING.toString();
+ public static final String EXTRA_STATE_RINGING = PhoneConstants.State.RINGING.toString();
/**
* Value used with {@link #EXTRA_STATE} corresponding to
* {@link #CALL_STATE_OFFHOOK}.
*/
- public static final String EXTRA_STATE_OFFHOOK = Phone.State.OFFHOOK.toString();
+ public static final String EXTRA_STATE_OFFHOOK = PhoneConstants.State.OFFHOOK.toString();
/**
* The lookup key used with the {@link #ACTION_PHONE_STATE_CHANGED} broadcast
@@ -279,13 +284,13 @@ public class TelephonyManager {
}
/** No phone radio. */
- public static final int PHONE_TYPE_NONE = Phone.PHONE_TYPE_NONE;
+ public static final int PHONE_TYPE_NONE = PhoneConstants.PHONE_TYPE_NONE;
/** Phone radio is GSM. */
- public static final int PHONE_TYPE_GSM = Phone.PHONE_TYPE_GSM;
+ public static final int PHONE_TYPE_GSM = PhoneConstants.PHONE_TYPE_GSM;
/** Phone radio is CDMA. */
- public static final int PHONE_TYPE_CDMA = Phone.PHONE_TYPE_CDMA;
+ public static final int PHONE_TYPE_CDMA = PhoneConstants.PHONE_TYPE_CDMA;
/** Phone is via SIP. */
- public static final int PHONE_TYPE_SIP = Phone.PHONE_TYPE_SIP;
+ public static final int PHONE_TYPE_SIP = PhoneConstants.PHONE_TYPE_SIP;
/**
* Returns the current phone type.
@@ -348,8 +353,125 @@ public class TelephonyManager {
int mode = SystemProperties.getInt("ro.telephony.default_network", -1);
if (mode == -1)
return PHONE_TYPE_NONE;
- return PhoneFactory.getPhoneType(mode);
+ return getPhoneType(mode);
}
+
+ /**
+ * This function returns the type of the phone, depending
+ * on the network mode.
+ *
+ * @param network mode
+ * @return Phone Type
+ *
+ * @hide
+ */
+ public static int getPhoneType(int networkMode) {
+ switch(networkMode) {
+ case RILConstants.NETWORK_MODE_CDMA:
+ case RILConstants.NETWORK_MODE_CDMA_NO_EVDO:
+ case RILConstants.NETWORK_MODE_EVDO_NO_CDMA:
+ return PhoneConstants.PHONE_TYPE_CDMA;
+
+ case RILConstants.NETWORK_MODE_WCDMA_PREF:
+ case RILConstants.NETWORK_MODE_GSM_ONLY:
+ case RILConstants.NETWORK_MODE_WCDMA_ONLY:
+ case RILConstants.NETWORK_MODE_GSM_UMTS:
+ return PhoneConstants.PHONE_TYPE_GSM;
+
+ // Use CDMA Phone for the global mode including CDMA
+ case RILConstants.NETWORK_MODE_GLOBAL:
+ case RILConstants.NETWORK_MODE_LTE_CDMA_EVDO:
+ case RILConstants.NETWORK_MODE_LTE_CMDA_EVDO_GSM_WCDMA:
+ return PhoneConstants.PHONE_TYPE_CDMA;
+
+ case RILConstants.NETWORK_MODE_LTE_ONLY:
+ if (getLteOnCdmaModeStatic() == PhoneConstants.LTE_ON_CDMA_TRUE) {
+ return PhoneConstants.PHONE_TYPE_CDMA;
+ } else {
+ return PhoneConstants.PHONE_TYPE_GSM;
+ }
+ default:
+ return PhoneConstants.PHONE_TYPE_GSM;
+ }
+ }
+
+ /**
+ * The contents of the /proc/cmdline file
+ */
+ private static String getProcCmdLine()
+ {
+ String cmdline = "";
+ FileInputStream is = null;
+ try {
+ is = new FileInputStream("/proc/cmdline");
+ byte [] buffer = new byte[2048];
+ int count = is.read(buffer);
+ if (count > 0) {
+ cmdline = new String(buffer, 0, count);
+ }
+ } catch (IOException e) {
+ Log.d(TAG, "No /proc/cmdline exception=" + e);
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ Log.d(TAG, "/proc/cmdline=" + cmdline);
+ return cmdline;
+ }
+
+ /** Kernel command line */
+ private static final String sKernelCmdLine = getProcCmdLine();
+
+ /** Pattern for selecting the product type from the kernel command line */
+ private static final Pattern sProductTypePattern =
+ Pattern.compile("\\sproduct_type\\s*=\\s*(\\w+)");
+
+ /** The ProductType used for LTE on CDMA devices */
+ private static final String sLteOnCdmaProductType =
+ SystemProperties.get(TelephonyProperties.PROPERTY_LTE_ON_CDMA_PRODUCT_TYPE, "");
+
+ /**
+ * Return if the current radio is LTE on CDMA. This
+ * is a tri-state return value as for a period of time
+ * the mode may be unknown.
+ *
+ * @return {@link PhoneConstants#LTE_ON_CDMA_UNKNOWN}, {@link PhoneConstants#LTE_ON_CDMA_FALSE}
+ * or {@link PhoneConstants#LTE_ON_CDMA_TRUE}
+ *
+ * @hide
+ */
+ public static int getLteOnCdmaModeStatic() {
+ int retVal;
+ int curVal;
+ String productType = "";
+
+ curVal = SystemProperties.getInt(TelephonyProperties.PROPERTY_LTE_ON_CDMA_DEVICE,
+ PhoneConstants.LTE_ON_CDMA_UNKNOWN);
+ retVal = curVal;
+ if (retVal == PhoneConstants.LTE_ON_CDMA_UNKNOWN) {
+ Matcher matcher = sProductTypePattern.matcher(sKernelCmdLine);
+ if (matcher.find()) {
+ productType = matcher.group(1);
+ if (sLteOnCdmaProductType.equals(productType)) {
+ retVal = PhoneConstants.LTE_ON_CDMA_TRUE;
+ } else {
+ retVal = PhoneConstants.LTE_ON_CDMA_FALSE;
+ }
+ } else {
+ retVal = PhoneConstants.LTE_ON_CDMA_FALSE;
+ }
+ }
+
+ Log.d(TAG, "getLteOnCdmaMode=" + retVal + " curVal=" + curVal +
+ " product_type='" + productType +
+ "' lteOnCdmaProductType='" + sLteOnCdmaProductType + "'");
+ return retVal;
+ }
+
//
//
// Current Network
@@ -695,10 +817,10 @@ public class TelephonyManager {
return getITelephony().getLteOnCdmaMode();
} catch (RemoteException ex) {
// Assume no ICC card if remote exception which shouldn't happen
- return Phone.LTE_ON_CDMA_UNKNOWN;
+ return PhoneConstants.LTE_ON_CDMA_UNKNOWN;
} catch (NullPointerException ex) {
// This could happen before phone restarts due to crashing
- return Phone.LTE_ON_CDMA_UNKNOWN;
+ return PhoneConstants.LTE_ON_CDMA_UNKNOWN;
}
}
diff --git a/telephony/java/android/telephony/gsm/SmsManager.java b/telephony/java/android/telephony/gsm/SmsManager.java
deleted file mode 100644
index 3b75298b593d..000000000000
--- a/telephony/java/android/telephony/gsm/SmsManager.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.telephony.gsm;
-
-import android.app.PendingIntent;
-
-import java.util.ArrayList;
-
-
-/**
- * Manages SMS operations such as sending data, text, and pdu SMS messages.
- * Get this object by calling the static method SmsManager.getDefault().
- * @deprecated Replaced by android.telephony.SmsManager that supports both GSM and CDMA.
- */
-@Deprecated public final class SmsManager {
- private static SmsManager sInstance;
- private android.telephony.SmsManager mSmsMgrProxy;
-
- /** Get the default instance of the SmsManager
- *
- * @return the default instance of the SmsManager
- * @deprecated Use android.telephony.SmsManager.
- */
- @Deprecated
- public static final SmsManager getDefault() {
- if (sInstance == null) {
- sInstance = new SmsManager();
- }
- return sInstance;
- }
-
- @Deprecated
- private SmsManager() {
- mSmsMgrProxy = android.telephony.SmsManager.getDefault();
- }
-
- /**
- * Send a text based SMS.
- *
- * @param destinationAddress the address to send the message to
- * @param scAddress is the service center address or null to use
- * the current default SMSC
- * @param text the body of the message to send
- * @param sentIntent if not NULL this PendingIntent
is
- * broadcast when the message is successfully sent, or failed.
- * The result code will be Activity.RESULT_OK for success,
- * or one of these errors:
- * RESULT_ERROR_GENERIC_FAILURE
- * RESULT_ERROR_RADIO_OFF
- * RESULT_ERROR_NULL_PDU
.
- * The per-application based SMS control checks sentIntent. If sentIntent
- * is NULL the caller will be checked against all unknown applications,
- * which cause smaller number of SMS to be sent in checking period.
- * @param deliveryIntent if not NULL this PendingIntent
is
- * broadcast when the message is delivered to the recipient. The
- * raw pdu of the status report is in the extended data ("pdu").
- *
- * @throws IllegalArgumentException if destinationAddress or text are empty
- * @deprecated Use android.telephony.SmsManager.
- */
- @Deprecated
- public final void sendTextMessage(
- String destinationAddress, String scAddress, String text,
- PendingIntent sentIntent, PendingIntent deliveryIntent) {
- mSmsMgrProxy.sendTextMessage(destinationAddress, scAddress, text,
- sentIntent, deliveryIntent);
- }
-
- /**
- * Divide a text message into several messages, none bigger than
- * the maximum SMS message size.
- *
- * @param text the original message. Must not be null.
- * @return an ArrayList
of strings that, in order,
- * comprise the original message
- * @deprecated Use android.telephony.SmsManager.
- */
- @Deprecated
- public final ArrayList divideMessage(String text) {
- return mSmsMgrProxy.divideMessage(text);
- }
-
- /**
- * Send a multi-part text based SMS. The callee should have already
- * divided the message into correctly sized parts by calling
- * divideMessage
.
- *
- * @param destinationAddress the address to send the message to
- * @param scAddress is the service center address or null to use
- * the current default SMSC
- * @param parts an ArrayList
of strings that, in order,
- * comprise the original message
- * @param sentIntents if not null, an ArrayList
of
- * PendingIntent
s (one for each message part) that is
- * broadcast when the corresponding message part has been sent.
- * The result code will be Activity.RESULT_OK for success,
- * or one of these errors:
- * RESULT_ERROR_GENERIC_FAILURE
- * RESULT_ERROR_RADIO_OFF
- * RESULT_ERROR_NULL_PDU
.
- * The per-application based SMS control checks sentIntent. If sentIntent
- * is NULL the caller will be checked against all unknown applicaitons,
- * which cause smaller number of SMS to be sent in checking period.
- * @param deliveryIntents if not null, an ArrayList
of
- * PendingIntent
s (one for each message part) that is
- * broadcast when the corresponding message part has been delivered
- * to the recipient. The raw pdu of the status report is in the
- * extended data ("pdu").
- *
- * @throws IllegalArgumentException if destinationAddress or data are empty
- * @deprecated Use android.telephony.SmsManager.
- */
- @Deprecated
- public final void sendMultipartTextMessage(
- String destinationAddress, String scAddress, ArrayList parts,
- ArrayList sentIntents, ArrayList deliveryIntents) {
- mSmsMgrProxy.sendMultipartTextMessage(destinationAddress, scAddress, parts,
- sentIntents, deliveryIntents);
- }
-
- /**
- * Send a data based SMS to a specific application port.
- *
- * @param destinationAddress the address to send the message to
- * @param scAddress is the service center address or null to use
- * the current default SMSC
- * @param destinationPort the port to deliver the message to
- * @param data the body of the message to send
- * @param sentIntent if not NULL this PendingIntent
is
- * broadcast when the message is sucessfully sent, or failed.
- * The result code will be Activity.RESULT_OK for success,
- * or one of these errors:
- * RESULT_ERROR_GENERIC_FAILURE
- * RESULT_ERROR_RADIO_OFF
- * RESULT_ERROR_NULL_PDU
.
- * The per-application based SMS control checks sentIntent. If sentIntent
- * is NULL the caller will be checked against all unknown applicaitons,
- * which cause smaller number of SMS to be sent in checking period.
- * @param deliveryIntent if not NULL this PendingIntent
is
- * broadcast when the message is delivered to the recipient. The
- * raw pdu of the status report is in the extended data ("pdu").
- *
- * @throws IllegalArgumentException if destinationAddress or data are empty
- * @deprecated Use android.telephony.SmsManager.
- */
- @Deprecated
- public final void sendDataMessage(
- String destinationAddress, String scAddress, short destinationPort,
- byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent) {
- mSmsMgrProxy.sendDataMessage(destinationAddress, scAddress, destinationPort,
- data, sentIntent, deliveryIntent);
- }
-
- /**
- * Copy a raw SMS PDU to the SIM.
- *
- * @param smsc the SMSC for this message, or NULL for the default SMSC
- * @param pdu the raw PDU to store
- * @param status message status (STATUS_ON_SIM_READ, STATUS_ON_SIM_UNREAD,
- * STATUS_ON_SIM_SENT, STATUS_ON_SIM_UNSENT)
- * @return true for success
- * @deprecated Use android.telephony.SmsManager.
- * {@hide}
- */
- @Deprecated
- public final boolean copyMessageToSim(byte[] smsc, byte[] pdu, int status) {
- return mSmsMgrProxy.copyMessageToIcc(smsc, pdu, status);
- }
-
- /**
- * Delete the specified message from the SIM.
- *
- * @param messageIndex is the record index of the message on SIM
- * @return true for success
- * @deprecated Use android.telephony.SmsManager.
- * {@hide}
- */
- @Deprecated
- public final boolean deleteMessageFromSim(int messageIndex) {
- return mSmsMgrProxy.deleteMessageFromIcc(messageIndex);
- }
-
- /**
- * Update the specified message on the SIM.
- *
- * @param messageIndex record index of message to update
- * @param newStatus new message status (STATUS_ON_SIM_READ,
- * STATUS_ON_SIM_UNREAD, STATUS_ON_SIM_SENT,
- * STATUS_ON_SIM_UNSENT, STATUS_ON_SIM_FREE)
- * @param pdu the raw PDU to store
- * @return true for success
- * @deprecated Use android.telephony.SmsManager.
- * {@hide}
- */
- @Deprecated
- public final boolean updateMessageOnSim(int messageIndex, int newStatus, byte[] pdu) {
- return mSmsMgrProxy.updateMessageOnIcc(messageIndex, newStatus, pdu);
- }
-
- /**
- * Retrieves all messages currently stored on SIM.
- * @return ArrayList
of SmsMessage
objects
- * @deprecated Use android.telephony.SmsManager.
- * {@hide}
- */
- @Deprecated
- public final ArrayList getAllMessagesFromSim() {
- return mSmsMgrProxy.getAllMessagesFromIcc();
- }
-
- /** Free space (TS 51.011 10.5.3).
- * @deprecated Use android.telephony.SmsManager. */
- @Deprecated static public final int STATUS_ON_SIM_FREE = 0;
-
- /** Received and read (TS 51.011 10.5.3).
- * @deprecated Use android.telephony.SmsManager. */
- @Deprecated static public final int STATUS_ON_SIM_READ = 1;
-
- /** Received and unread (TS 51.011 10.5.3).
- * @deprecated Use android.telephony.SmsManager. */
- @Deprecated static public final int STATUS_ON_SIM_UNREAD = 3;
-
- /** Stored and sent (TS 51.011 10.5.3).
- * @deprecated Use android.telephony.SmsManager. */
- @Deprecated static public final int STATUS_ON_SIM_SENT = 5;
-
- /** Stored and unsent (TS 51.011 10.5.3).
- * @deprecated Use android.telephony.SmsManager. */
- @Deprecated static public final int STATUS_ON_SIM_UNSENT = 7;
-
- /** Generic failure cause
- * @deprecated Use android.telephony.SmsManager. */
- @Deprecated static public final int RESULT_ERROR_GENERIC_FAILURE = 1;
-
- /** Failed because radio was explicitly turned off
- * @deprecated Use android.telephony.SmsManager. */
- @Deprecated static public final int RESULT_ERROR_RADIO_OFF = 2;
-
- /** Failed because no pdu provided
- * @deprecated Use android.telephony.SmsManager. */
- @Deprecated static public final int RESULT_ERROR_NULL_PDU = 3;
-
- /** Failed because service is currently unavailable
- * @deprecated Use android.telephony.SmsManager. */
- @Deprecated static public final int RESULT_ERROR_NO_SERVICE = 4;
-
-}
diff --git a/telephony/java/android/telephony/gsm/SmsMessage.java b/telephony/java/android/telephony/gsm/SmsMessage.java
deleted file mode 100644
index 8d86ec296854..000000000000
--- a/telephony/java/android/telephony/gsm/SmsMessage.java
+++ /dev/null
@@ -1,628 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.telephony.gsm;
-
-import android.os.Parcel;
-import android.telephony.TelephonyManager;
-
-import com.android.internal.telephony.GsmAlphabet;
-import com.android.internal.telephony.EncodeException;
-import com.android.internal.telephony.SmsHeader;
-import com.android.internal.telephony.SmsMessageBase;
-import com.android.internal.telephony.SmsMessageBase.SubmitPduBase;
-
-import java.util.Arrays;
-
-import static android.telephony.TelephonyManager.PHONE_TYPE_CDMA;
-
-
-/**
- * A Short Message Service message.
- * @deprecated Replaced by android.telephony.SmsMessage that supports both GSM and CDMA.
- */
-@Deprecated
-public class SmsMessage {
- private static final boolean LOCAL_DEBUG = true;
- private static final String LOG_TAG = "SMS";
-
- /**
- * SMS Class enumeration.
- * See TS 23.038.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public enum MessageClass{
- UNKNOWN, CLASS_0, CLASS_1, CLASS_2, CLASS_3;
- }
-
- /** Unknown encoding scheme (see TS 23.038)
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated public static final int ENCODING_UNKNOWN = 0;
-
- /** 7-bit encoding scheme (see TS 23.038)
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated public static final int ENCODING_7BIT = 1;
-
- /** 8-bit encoding scheme (see TS 23.038)
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated public static final int ENCODING_8BIT = 2;
-
- /** 16-bit encoding scheme (see TS 23.038)
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated public static final int ENCODING_16BIT = 3;
-
- /** The maximum number of payload bytes per message
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated public static final int MAX_USER_DATA_BYTES = 140;
-
- /**
- * The maximum number of payload bytes per message if a user data header
- * is present. This assumes the header only contains the
- * CONCATENATED_8_BIT_REFERENCE element.
- *
- * @deprecated Use android.telephony.SmsMessage.
- * @hide pending API Council approval to extend the public API
- */
- @Deprecated public static final int MAX_USER_DATA_BYTES_WITH_HEADER = 134;
-
- /** The maximum number of payload septets per message
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated public static final int MAX_USER_DATA_SEPTETS = 160;
-
- /**
- * The maximum number of payload septets per message if a user data header
- * is present. This assumes the header only contains the
- * CONCATENATED_8_BIT_REFERENCE element.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated public static final int MAX_USER_DATA_SEPTETS_WITH_HEADER = 153;
-
- /** Contains actual SmsMessage. Only public for debugging and for framework layer.
- * @deprecated Use android.telephony.SmsMessage.
- * {@hide}
- */
- @Deprecated public SmsMessageBase mWrappedSmsMessage;
-
- /** @deprecated Use android.telephony.SmsMessage. */
- @Deprecated
- public static class SubmitPdu {
- /** @deprecated Use android.telephony.SmsMessage. */
- @Deprecated public byte[] encodedScAddress; // Null if not applicable.
- /** @deprecated Use android.telephony.SmsMessage. */
- @Deprecated public byte[] encodedMessage;
-
- //Constructor
- /** @deprecated Use android.telephony.SmsMessage. */
- @Deprecated
- public SubmitPdu() {
- }
-
- /** @deprecated Use android.telephony.SmsMessage.
- * {@hide}
- */
- @Deprecated
- protected SubmitPdu(SubmitPduBase spb) {
- this.encodedMessage = spb.encodedMessage;
- this.encodedScAddress = spb.encodedScAddress;
- }
-
- /** @deprecated Use android.telephony.SmsMessage. */
- @Deprecated
- public String toString() {
- return "SubmitPdu: encodedScAddress = "
- + Arrays.toString(encodedScAddress)
- + ", encodedMessage = "
- + Arrays.toString(encodedMessage);
- }
- }
-
- // Constructor
- /** @deprecated Use android.telephony.SmsMessage. */
- @Deprecated
- public SmsMessage() {
- this(getSmsFacility());
- }
-
- private SmsMessage(SmsMessageBase smb) {
- mWrappedSmsMessage = smb;
- }
-
- /**
- * Create an SmsMessage from a raw PDU.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public static SmsMessage createFromPdu(byte[] pdu) {
- SmsMessageBase wrappedMessage;
- int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
-
- if (PHONE_TYPE_CDMA == activePhone) {
- wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromPdu(pdu);
- } else {
- wrappedMessage = com.android.internal.telephony.gsm.SmsMessage.createFromPdu(pdu);
- }
-
- return new SmsMessage(wrappedMessage);
- }
-
- /**
- * Get the TP-Layer-Length for the given SMS-SUBMIT PDU Basically, the
- * length in bytes (not hex chars) less the SMSC header
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public static int getTPLayerLengthForPDU(String pdu) {
- int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
-
- if (PHONE_TYPE_CDMA == activePhone) {
- return com.android.internal.telephony.cdma.SmsMessage.getTPLayerLengthForPDU(pdu);
- } else {
- return com.android.internal.telephony.gsm.SmsMessage.getTPLayerLengthForPDU(pdu);
- }
- }
-
- /**
- * Calculates the number of SMS's required to encode the message body and
- * the number of characters remaining until the next message, given the
- * current encoding.
- *
- * @param messageBody the message to encode
- * @param use7bitOnly if true, characters that are not part of the GSM
- * alphabet are counted as a single space char. If false, a
- * messageBody containing non-GSM alphabet characters is calculated
- * for 16-bit encoding.
- * @return an int[4] with int[0] being the number of SMS's required, int[1]
- * the number of code units used, and int[2] is the number of code
- * units remaining until the next message. int[3] is the encoding
- * type that should be used for the message.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public static int[] calculateLength(CharSequence messageBody, boolean use7bitOnly) {
- SmsMessageBase.TextEncodingDetails ted =
- com.android.internal.telephony.gsm.SmsMessage
- .calculateLength(messageBody, use7bitOnly);
- int ret[] = new int[4];
- ret[0] = ted.msgCount;
- ret[1] = ted.codeUnitCount;
- ret[2] = ted.codeUnitsRemaining;
- ret[3] = ted.codeUnitSize;
- return ret;
- }
-
- /**
- * Calculates the number of SMS's required to encode the message body and
- * the number of characters remaining until the next message, given the
- * current encoding.
- *
- * @param messageBody the message to encode
- * @param use7bitOnly if true, characters that are not part of the GSM
- * alphabet are counted as a single space char. If false, a
- * messageBody containing non-GSM alphabet characters is calculated
- * for 16-bit encoding.
- * @return an int[4] with int[0] being the number of SMS's required, int[1]
- * the number of code units used, and int[2] is the number of code
- * units remaining until the next message. int[3] is the encoding
- * type that should be used for the message.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public static int[] calculateLength(String messageBody, boolean use7bitOnly) {
- return calculateLength((CharSequence)messageBody, use7bitOnly);
- }
-
- /**
- * Get an SMS-SUBMIT PDU for a destination address and a message
- *
- * @param scAddress Service Centre address. Null means use default.
- * @return a SubmitPdu
containing the encoded SC
- * address, if applicable, and the encoded message.
- * Returns null on encode error.
- * @deprecated Use android.telephony.SmsMessage.
- * @hide
- */
- @Deprecated
- public static SubmitPdu getSubmitPdu(String scAddress,
- String destinationAddress, String message,
- boolean statusReportRequested, byte[] header) {
- SubmitPduBase spb;
- int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
-
- if (PHONE_TYPE_CDMA == activePhone) {
- spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
- destinationAddress, message, statusReportRequested,
- SmsHeader.fromByteArray(header));
- } else {
- spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress,
- destinationAddress, message, statusReportRequested, header);
- }
-
- return new SubmitPdu(spb);
- }
-
- /**
- * Get an SMS-SUBMIT PDU for a destination address and a message
- *
- * @param scAddress Service Centre address. Null means use default.
- * @return a SubmitPdu
containing the encoded SC
- * address, if applicable, and the encoded message.
- * Returns null on encode error.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public static SubmitPdu getSubmitPdu(String scAddress,
- String destinationAddress, String message, boolean statusReportRequested) {
- SubmitPduBase spb;
- int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
-
- if (PHONE_TYPE_CDMA == activePhone) {
- spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
- destinationAddress, message, statusReportRequested, null);
- } else {
- spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress,
- destinationAddress, message, statusReportRequested);
- }
-
- return new SubmitPdu(spb);
- }
-
- /**
- * Get an SMS-SUBMIT PDU for a data message to a destination address & port
- *
- * @param scAddress Service Centre address. null == use default
- * @param destinationAddress the address of the destination for the message
- * @param destinationPort the port to deliver the message to at the
- * destination
- * @param data the dat for the message
- * @return a SubmitPdu
containing the encoded SC
- * address, if applicable, and the encoded message.
- * Returns null on encode error.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public static SubmitPdu getSubmitPdu(String scAddress,
- String destinationAddress, short destinationPort, byte[] data,
- boolean statusReportRequested) {
- SubmitPduBase spb;
- int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
-
- if (PHONE_TYPE_CDMA == activePhone) {
- spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
- destinationAddress, destinationPort, data, statusReportRequested);
- } else {
- spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress,
- destinationAddress, destinationPort, data, statusReportRequested);
- }
-
- return new SubmitPdu(spb);
- }
-
- /**
- * Returns the address of the SMS service center that relayed this message
- * or null if there is none.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public String getServiceCenterAddress() {
- return mWrappedSmsMessage.getServiceCenterAddress();
- }
-
- /**
- * Returns the originating address (sender) of this SMS message in String
- * form or null if unavailable
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public String getOriginatingAddress() {
- return mWrappedSmsMessage.getOriginatingAddress();
- }
-
- /**
- * Returns the originating address, or email from address if this message
- * was from an email gateway. Returns null if originating address
- * unavailable.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public String getDisplayOriginatingAddress() {
- return mWrappedSmsMessage.getDisplayOriginatingAddress();
- }
-
- /**
- * Returns the message body as a String, if it exists and is text based.
- * @return message body is there is one, otherwise null
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public String getMessageBody() {
- return mWrappedSmsMessage.getMessageBody();
- }
-
- /**
- * Returns the class of this message.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public MessageClass getMessageClass() {
- int index = mWrappedSmsMessage.getMessageClass().ordinal();
-
- return MessageClass.values()[index];
- }
-
- /**
- * Returns the message body, or email message body if this message was from
- * an email gateway. Returns null if message body unavailable.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public String getDisplayMessageBody() {
- return mWrappedSmsMessage.getDisplayMessageBody();
- }
-
- /**
- * Unofficial convention of a subject line enclosed in parens empty string
- * if not present
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public String getPseudoSubject() {
- return mWrappedSmsMessage.getPseudoSubject();
- }
-
- /**
- * Returns the service centre timestamp in currentTimeMillis() format
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public long getTimestampMillis() {
- return mWrappedSmsMessage.getTimestampMillis();
- }
-
- /**
- * Returns true if message is an email.
- *
- * @return true if this message came through an email gateway and email
- * sender / subject / parsed body are available
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public boolean isEmail() {
- return mWrappedSmsMessage.isEmail();
- }
-
- /**
- * @return if isEmail() is true, body of the email sent through the gateway.
- * null otherwise
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public String getEmailBody() {
- return mWrappedSmsMessage.getEmailBody();
- }
-
- /**
- * @return if isEmail() is true, email from address of email sent through
- * the gateway. null otherwise
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public String getEmailFrom() {
- return mWrappedSmsMessage.getEmailFrom();
- }
-
- /**
- * Get protocol identifier.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public int getProtocolIdentifier() {
- return mWrappedSmsMessage.getProtocolIdentifier();
- }
-
- /**
- * See TS 23.040 9.2.3.9 returns true if this is a "replace short message" SMS
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public boolean isReplace() {
- return mWrappedSmsMessage.isReplace();
- }
-
- /**
- * Returns true for CPHS MWI toggle message.
- *
- * @return true if this is a CPHS MWI toggle message See CPHS 4.2 section B.4.2
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public boolean isCphsMwiMessage() {
- return mWrappedSmsMessage.isCphsMwiMessage();
- }
-
- /**
- * returns true if this message is a CPHS voicemail / message waiting
- * indicator (MWI) clear message
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public boolean isMWIClearMessage() {
- return mWrappedSmsMessage.isMWIClearMessage();
- }
-
- /**
- * returns true if this message is a CPHS voicemail / message waiting
- * indicator (MWI) set message
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public boolean isMWISetMessage() {
- return mWrappedSmsMessage.isMWISetMessage();
- }
-
- /**
- * returns true if this message is a "Message Waiting Indication Group:
- * Discard Message" notification and should not be stored.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public boolean isMwiDontStore() {
- return mWrappedSmsMessage.isMwiDontStore();
- }
-
- /**
- * returns the user data section minus the user data header if one was present.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public byte[] getUserData() {
- return mWrappedSmsMessage.getUserData();
- }
-
- /* Not part of the SDK interface and only needed by specific classes:
- protected SmsHeader getUserDataHeader()
- */
-
- /**
- * Returns the raw PDU for the message.
- *
- * @return the raw PDU for the message.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public byte[] getPdu() {
- return mWrappedSmsMessage.getPdu();
- }
-
- /**
- * Returns the status of the message on the SIM (read, unread, sent, unsent).
- *
- * @return the status of the message on the SIM. These are:
- * SmsManager.STATUS_ON_SIM_FREE
- * SmsManager.STATUS_ON_SIM_READ
- * SmsManager.STATUS_ON_SIM_UNREAD
- * SmsManager.STATUS_ON_SIM_SEND
- * SmsManager.STATUS_ON_SIM_UNSENT
- * @deprecated Use android.telephony.SmsMessage and getStatusOnIcc instead.
- */
- @Deprecated
- public int getStatusOnSim() {
- return mWrappedSmsMessage.getStatusOnIcc();
- }
-
- /**
- * Returns the status of the message on the ICC (read, unread, sent, unsent).
- *
- * @return the status of the message on the ICC. These are:
- * SmsManager.STATUS_ON_ICC_FREE
- * SmsManager.STATUS_ON_ICC_READ
- * SmsManager.STATUS_ON_ICC_UNREAD
- * SmsManager.STATUS_ON_ICC_SEND
- * SmsManager.STATUS_ON_ICC_UNSENT
- * @deprecated Use android.telephony.SmsMessage.
- * @hide
- */
- @Deprecated
- public int getStatusOnIcc() {
-
- return mWrappedSmsMessage.getStatusOnIcc();
- }
-
- /**
- * Returns the record index of the message on the SIM (1-based index).
- * @return the record index of the message on the SIM, or -1 if this
- * SmsMessage was not created from a SIM SMS EF record.
- * @deprecated Use android.telephony.SmsMessage and getIndexOnIcc instead.
- */
- @Deprecated
- public int getIndexOnSim() {
- return mWrappedSmsMessage.getIndexOnIcc();
- }
-
- /**
- * Returns the record index of the message on the ICC (1-based index).
- * @return the record index of the message on the ICC, or -1 if this
- * SmsMessage was not created from a ICC SMS EF record.
- * @deprecated Use android.telephony.SmsMessage.
- * @hide
- */
- @Deprecated
- public int getIndexOnIcc() {
-
- return mWrappedSmsMessage.getIndexOnIcc();
- }
-
- /**
- * GSM:
- * For an SMS-STATUS-REPORT message, this returns the status field from
- * the status report. This field indicates the status of a previously
- * submitted SMS, if requested. See TS 23.040, 9.2.3.15 TP-Status for a
- * description of values.
- * CDMA:
- * For not interfering with status codes from GSM, the value is
- * shifted to the bits 31-16.
- * The value is composed of an error class (bits 25-24) and a status code (bits 23-16).
- * Possible codes are described in C.S0015-B, v2.0, 4.5.21.
- *
- * @return 0 indicates the previously sent message was received.
- * See TS 23.040, 9.9.2.3.15 and C.S0015-B, v2.0, 4.5.21
- * for a description of other possible values.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public int getStatus() {
- return mWrappedSmsMessage.getStatus();
- }
-
- /**
- * Return true iff the message is a SMS-STATUS-REPORT message.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public boolean isStatusReportMessage() {
- return mWrappedSmsMessage.isStatusReportMessage();
- }
-
- /**
- * Returns true iff the TP-Reply-Path
bit is set in
- * this message.
- * @deprecated Use android.telephony.SmsMessage.
- */
- @Deprecated
- public boolean isReplyPathPresent() {
- return mWrappedSmsMessage.isReplyPathPresent();
- }
-
- /** This method returns the reference to a specific
- * SmsMessage object, which is used for accessing its static methods.
- * @return Specific SmsMessage.
- * @deprecated Use android.telephony.SmsMessage.
- */
- private static final SmsMessageBase getSmsFacility(){
- int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
- if (PHONE_TYPE_CDMA == activePhone) {
- return new com.android.internal.telephony.cdma.SmsMessage();
- } else {
- return new com.android.internal.telephony.gsm.SmsMessage();
- }
- }
-}
diff --git a/telephony/java/com/android/internal/telephony/ATParseEx.java b/telephony/java/com/android/internal/telephony/ATParseEx.java
deleted file mode 100644
index c93b875e8bd0..000000000000
--- a/telephony/java/com/android/internal/telephony/ATParseEx.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.telephony;
-
-/**
- * {@hide}
- */
-public class ATParseEx extends RuntimeException
-{
- public
- ATParseEx()
- {
- super();
- }
-
- public
- ATParseEx(String s)
- {
- super(s);
- }
-}
diff --git a/telephony/java/com/android/internal/telephony/ATResponseParser.java b/telephony/java/com/android/internal/telephony/ATResponseParser.java
deleted file mode 100644
index fdb05262da4c..000000000000
--- a/telephony/java/com/android/internal/telephony/ATResponseParser.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.telephony;
-
-/**
- * {@hide}
- */
-public class ATResponseParser
-{
- /*************************** Instance Variables **************************/
-
- private String line;
- private int next = 0;
- private int tokStart, tokEnd;
-
- /***************************** Class Methods *****************************/
-
- public
- ATResponseParser (String line)
- {
- this.line = line;
- }
-
- public boolean
- nextBoolean()
- {
- // "\s*(\d)(,|$)"
- // \d is '0' or '1'
-
- nextTok();
-
- if (tokEnd - tokStart > 1) {
- throw new ATParseEx();
- }
- char c = line.charAt(tokStart);
-
- if (c == '0') return false;
- if (c == '1') return true;
- throw new ATParseEx();
- }
-
-
- /** positive int only */
- public int
- nextInt()
- {
- // "\s*(\d+)(,|$)"
- int ret = 0;
-
- nextTok();
-
- for (int i = tokStart ; i < tokEnd ; i++) {
- char c = line.charAt(i);
-
- // Yes, ASCII decimal digits only
- if (c < '0' || c > '9') {
- throw new ATParseEx();
- }
-
- ret *= 10;
- ret += c - '0';
- }
-
- return ret;
- }
-
- public String
- nextString()
- {
- nextTok();
-
- return line.substring(tokStart, tokEnd);
- }
-
- public boolean
- hasMore()
- {
- return next < line.length();
- }
-
- private void
- nextTok()
- {
- int len = line.length();
-
- if (next == 0) {
- skipPrefix();
- }
-
- if (next >= len) {
- throw new ATParseEx();
- }
-
- try {
- // \s*("([^"]*)"|(.*)\s*)(,|$)
-
- char c = line.charAt(next++);
- boolean hasQuote = false;
-
- c = skipWhiteSpace(c);
-
- if (c == '"') {
- if (next >= len) {
- throw new ATParseEx();
- }
- c = line.charAt(next++);
- tokStart = next - 1;
- while (c != '"' && next < len) {
- c = line.charAt(next++);
- }
- if (c != '"') {
- throw new ATParseEx();
- }
- tokEnd = next - 1;
- if (next < len && line.charAt(next++) != ',') {
- throw new ATParseEx();
- }
- } else {
- tokStart = next - 1;
- tokEnd = tokStart;
- while (c != ',') {
- if (!Character.isWhitespace(c)) {
- tokEnd = next;
- }
- if (next == len) {
- break;
- }
- c = line.charAt(next++);
- }
- }
- } catch (StringIndexOutOfBoundsException ex) {
- throw new ATParseEx();
- }
- }
-
-
- /** Throws ATParseEx if whitespace extends to the end of string */
- private char
- skipWhiteSpace (char c)
- {
- int len;
- len = line.length();
- while (next < len && Character.isWhitespace(c)) {
- c = line.charAt(next++);
- }
-
- if (Character.isWhitespace(c)) {
- throw new ATParseEx();
- }
- return c;
- }
-
-
- private void
- skipPrefix()
- {
- // consume "^[^:]:"
-
- next = 0;
- int s = line.length();
- while (next < s){
- char c = line.charAt(next++);
-
- if (c == ':') {
- return;
- }
- }
-
- throw new ATParseEx("missing prefix");
- }
-
-}
diff --git a/telephony/java/com/android/internal/telephony/AdnRecord.java b/telephony/java/com/android/internal/telephony/AdnRecord.java
deleted file mode 100644
index 1bf2d3c61d50..000000000000
--- a/telephony/java/com/android/internal/telephony/AdnRecord.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.telephony;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.telephony.PhoneNumberUtils;
-import android.text.TextUtils;
-import android.util.Log;
-
-import java.util.Arrays;
-
-
-/**
- *
- * Used to load or store ADNs (Abbreviated Dialing Numbers).
- *
- * {@hide}
- *
- */
-public class AdnRecord implements Parcelable {
- static final String LOG_TAG = "GSM";
-
- //***** Instance Variables
-
- String alphaTag = null;
- String number = null;
- String[] emails;
- int extRecord = 0xff;
- int efid; // or 0 if none
- int recordNumber; // or 0 if none
-
-
- //***** Constants
-
- // In an ADN record, everything but the alpha identifier
- // is in a footer that's 14 bytes
- static final int FOOTER_SIZE_BYTES = 14;
-
- // Maximum size of the un-extended number field
- static final int MAX_NUMBER_SIZE_BYTES = 11;
-
- static final int EXT_RECORD_LENGTH_BYTES = 13;
- static final int EXT_RECORD_TYPE_ADDITIONAL_DATA = 2;
- static final int EXT_RECORD_TYPE_MASK = 3;
- static final int MAX_EXT_CALLED_PARTY_LENGTH = 0xa;
-
- // ADN offset
- static final int ADN_BCD_NUMBER_LENGTH = 0;
- static final int ADN_TON_AND_NPI = 1;
- static final int ADN_DIALING_NUMBER_START = 2;
- static final int ADN_DIALING_NUMBER_END = 11;
- static final int ADN_CAPABILITY_ID = 12;
- static final int ADN_EXTENSION_ID = 13;
-
- //***** Static Methods
-
- public static final Parcelable.Creator CREATOR
- = new Parcelable.Creator() {
- public AdnRecord createFromParcel(Parcel source) {
- int efid;
- int recordNumber;
- String alphaTag;
- String number;
- String[] emails;
-
- efid = source.readInt();
- recordNumber = source.readInt();
- alphaTag = source.readString();
- number = source.readString();
- emails = source.readStringArray();
-
- return new AdnRecord(efid, recordNumber, alphaTag, number, emails);
- }
-
- public AdnRecord[] newArray(int size) {
- return new AdnRecord[size];
- }
- };
-
-
- //***** Constructor
- public AdnRecord (byte[] record) {
- this(0, 0, record);
- }
-
- public AdnRecord (int efid, int recordNumber, byte[] record) {
- this.efid = efid;
- this.recordNumber = recordNumber;
- parseRecord(record);
- }
-
- public AdnRecord (String alphaTag, String number) {
- this(0, 0, alphaTag, number);
- }
-
- public AdnRecord (String alphaTag, String number, String[] emails) {
- this(0, 0, alphaTag, number, emails);
- }
-
- public AdnRecord (int efid, int recordNumber, String alphaTag, String number, String[] emails) {
- this.efid = efid;
- this.recordNumber = recordNumber;
- this.alphaTag = alphaTag;
- this.number = number;
- this.emails = emails;
- }
-
- public AdnRecord(int efid, int recordNumber, String alphaTag, String number) {
- this.efid = efid;
- this.recordNumber = recordNumber;
- this.alphaTag = alphaTag;
- this.number = number;
- this.emails = null;
- }
-
- //***** Instance Methods
-
- public String getAlphaTag() {
- return alphaTag;
- }
-
- public String getNumber() {
- return number;
- }
-
- public String[] getEmails() {
- return emails;
- }
-
- public void setEmails(String[] emails) {
- this.emails = emails;
- }
-
- public String toString() {
- return "ADN Record '" + alphaTag + "' '" + number + " " + emails + "'";
- }
-
- public boolean isEmpty() {
- return TextUtils.isEmpty(alphaTag) && TextUtils.isEmpty(number) && emails == null;
- }
-
- public boolean hasExtendedRecord() {
- return extRecord != 0 && extRecord != 0xff;
- }
-
- /** Helper function for {@link #isEqual}. */
- private static boolean stringCompareNullEqualsEmpty(String s1, String s2) {
- if (s1 == s2) {
- return true;
- }
- if (s1 == null) {
- s1 = "";
- }
- if (s2 == null) {
- s2 = "";
- }
- return (s1.equals(s2));
- }
-
- public boolean isEqual(AdnRecord adn) {
- return ( stringCompareNullEqualsEmpty(alphaTag, adn.alphaTag) &&
- stringCompareNullEqualsEmpty(number, adn.number) &&
- Arrays.equals(emails, adn.emails));
- }
- //***** Parcelable Implementation
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(efid);
- dest.writeInt(recordNumber);
- dest.writeString(alphaTag);
- dest.writeString(number);
- dest.writeStringArray(emails);
- }
-
- /**
- * Build adn hex byte array based on record size
- * The format of byte array is defined in 51.011 10.5.1
- *
- * @param recordSize is the size X of EF record
- * @return hex byte[recordSize] to be written to EF record
- * return null for wrong format of dialing number or tag
- */
- public byte[] buildAdnString(int recordSize) {
- byte[] bcdNumber;
- byte[] byteTag;
- byte[] adnString;
- int footerOffset = recordSize - FOOTER_SIZE_BYTES;
-
- // create an empty record
- adnString = new byte[recordSize];
- for (int i = 0; i < recordSize; i++) {
- adnString[i] = (byte) 0xFF;
- }
-
- if (TextUtils.isEmpty(number)) {
- Log.w(LOG_TAG, "[buildAdnString] Empty dialing number");
- return adnString; // return the empty record (for delete)
- } else if (number.length()
- > (ADN_DIALING_NUMBER_END - ADN_DIALING_NUMBER_START + 1) * 2) {
- Log.w(LOG_TAG,
- "[buildAdnString] Max length of dialing number is 20");
- return null;
- } else if (alphaTag != null && alphaTag.length() > footerOffset) {
- Log.w(LOG_TAG,
- "[buildAdnString] Max length of tag is " + footerOffset);
- return null;
- } else {
- bcdNumber = PhoneNumberUtils.numberToCalledPartyBCD(number);
-
- System.arraycopy(bcdNumber, 0, adnString,
- footerOffset + ADN_TON_AND_NPI, bcdNumber.length);
-
- adnString[footerOffset + ADN_BCD_NUMBER_LENGTH]
- = (byte) (bcdNumber.length);
- adnString[footerOffset + ADN_CAPABILITY_ID]
- = (byte) 0xFF; // Capability Id
- adnString[footerOffset + ADN_EXTENSION_ID]
- = (byte) 0xFF; // Extension Record Id
-
- if (!TextUtils.isEmpty(alphaTag)) {
- byteTag = GsmAlphabet.stringToGsm8BitPacked(alphaTag);
- System.arraycopy(byteTag, 0, adnString, 0, byteTag.length);
- }
-
- return adnString;
- }
- }
-
- /**
- * See TS 51.011 10.5.10
- */
- public void
- appendExtRecord (byte[] extRecord) {
- try {
- if (extRecord.length != EXT_RECORD_LENGTH_BYTES) {
- return;
- }
-
- if ((extRecord[0] & EXT_RECORD_TYPE_MASK)
- != EXT_RECORD_TYPE_ADDITIONAL_DATA) {
- return;
- }
-
- if ((0xff & extRecord[1]) > MAX_EXT_CALLED_PARTY_LENGTH) {
- // invalid or empty record
- return;
- }
-
- number += PhoneNumberUtils.calledPartyBCDFragmentToString(
- extRecord, 2, 0xff & extRecord[1]);
-
- // We don't support ext record chaining.
-
- } catch (RuntimeException ex) {
- Log.w(LOG_TAG, "Error parsing AdnRecord ext record", ex);
- }
- }
-
- //***** Private Methods
-
- /**
- * alphaTag and number are set to null on invalid format
- */
- private void
- parseRecord(byte[] record) {
- try {
- alphaTag = IccUtils.adnStringFieldToString(
- record, 0, record.length - FOOTER_SIZE_BYTES);
-
- int footerOffset = record.length - FOOTER_SIZE_BYTES;
-
- int numberLength = 0xff & record[footerOffset];
-
- if (numberLength > MAX_NUMBER_SIZE_BYTES) {
- // Invalid number length
- number = "";
- return;
- }
-
- // Please note 51.011 10.5.1:
- //
- // "If the Dialling Number/SSC String does not contain
- // a dialling number, e.g. a control string deactivating
- // a service, the TON/NPI byte shall be set to 'FF' by
- // the ME (see note 2)."
-
- number = PhoneNumberUtils.calledPartyBCDToString(
- record, footerOffset + 1, numberLength);
-
-
- extRecord = 0xff & record[record.length - 1];
-
- emails = null;
-
- } catch (RuntimeException ex) {
- Log.w(LOG_TAG, "Error parsing AdnRecord", ex);
- number = "";
- alphaTag = "";
- emails = null;
- }
- }
-}
diff --git a/telephony/java/com/android/internal/telephony/AdnRecordCache.java b/telephony/java/com/android/internal/telephony/AdnRecordCache.java
deleted file mode 100644
index db5f4da6bd97..000000000000
--- a/telephony/java/com/android/internal/telephony/AdnRecordCache.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.telephony;
-
-import android.os.AsyncResult;
-import android.os.Handler;
-import android.os.Message;
-import android.util.Log;
-import android.util.SparseArray;
-
-import com.android.internal.telephony.gsm.UsimPhoneBookManager;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-/**
- * {@hide}
- */
-public final class AdnRecordCache extends Handler implements IccConstants {
- //***** Instance Variables
-
- private IccFileHandler mFh;
- private UsimPhoneBookManager mUsimPhoneBookManager;
-
- // Indexed by EF ID
- SparseArray> adnLikeFiles
- = new SparseArray>();
-
- // People waiting for ADN-like files to be loaded
- SparseArray> adnLikeWaiters
- = new SparseArray>();
-
- // People waiting for adn record to be updated
- SparseArray userWriteResponse = new SparseArray();
-
- //***** Event Constants
-
- static final int EVENT_LOAD_ALL_ADN_LIKE_DONE = 1;
- static final int EVENT_UPDATE_ADN_DONE = 2;
-
- //***** Constructor
-
-
-
- public AdnRecordCache(IccFileHandler fh) {
- mFh = fh;
- mUsimPhoneBookManager = new UsimPhoneBookManager(mFh, this);
- }
-
- //***** Called from SIMRecords
-
- /**
- * Called from SIMRecords.onRadioNotAvailable and SIMRecords.handleSimRefresh.
- */
- public void reset() {
- adnLikeFiles.clear();
- mUsimPhoneBookManager.reset();
-
- clearWaiters();
- clearUserWriters();
-
- }
-
- private void clearWaiters() {
- int size = adnLikeWaiters.size();
- for (int i = 0; i < size; i++) {
- ArrayList waiters = adnLikeWaiters.valueAt(i);
- AsyncResult ar = new AsyncResult(null, null, new RuntimeException("AdnCache reset"));
- notifyWaiters(waiters, ar);
- }
- adnLikeWaiters.clear();
- }
-
- private void clearUserWriters() {
- int size = userWriteResponse.size();
- for (int i = 0; i < size; i++) {
- sendErrorResponse(userWriteResponse.valueAt(i), "AdnCace reset");
- }
- userWriteResponse.clear();
- }
-
- /**
- * @return List of AdnRecords for efid if we've already loaded them this
- * radio session, or null if we haven't
- */
- public ArrayList
- getRecordsIfLoaded(int efid) {
- return adnLikeFiles.get(efid);
- }
-
- /**
- * Returns extension ef associated with ADN-like EF or -1 if
- * we don't know.
- *
- * See 3GPP TS 51.011 for this mapping
- */
- int extensionEfForEf(int efid) {
- switch (efid) {
- case EF_MBDN: return EF_EXT6;
- case EF_ADN: return EF_EXT1;
- case EF_SDN: return EF_EXT3;
- case EF_FDN: return EF_EXT2;
- case EF_MSISDN: return EF_EXT1;
- case EF_PBR: return 0; // The EF PBR doesn't have an extension record
- default: return -1;
- }
- }
-
- private void sendErrorResponse(Message response, String errString) {
- if (response != null) {
- Exception e = new RuntimeException(errString);
- AsyncResult.forMessage(response).exception = e;
- response.sendToTarget();
- }
- }
-
- /**
- * Update an ADN-like record in EF by record index
- *
- * @param efid must be one among EF_ADN, EF_FDN, and EF_SDN
- * @param adn is the new adn to be stored
- * @param recordIndex is the 1-based adn record index
- * @param pin2 is required to update EF_FDN, otherwise must be null
- * @param response message to be posted when done
- * response.exception hold the exception in error
- */
- public void updateAdnByIndex(int efid, AdnRecord adn, int recordIndex, String pin2,
- Message response) {
-
- int extensionEF = extensionEfForEf(efid);
- if (extensionEF < 0) {
- sendErrorResponse(response, "EF is not known ADN-like EF:" + efid);
- return;
- }
-
- Message pendingResponse = userWriteResponse.get(efid);
- if (pendingResponse != null) {
- sendErrorResponse(response, "Have pending update for EF:" + efid);
- return;
- }
-
- userWriteResponse.put(efid, response);
-
- new AdnRecordLoader(mFh).updateEF(adn, efid, extensionEF,
- recordIndex, pin2,
- obtainMessage(EVENT_UPDATE_ADN_DONE, efid, recordIndex, adn));
- }
-
- /**
- * Replace oldAdn with newAdn in ADN-like record in EF
- *
- * The ADN-like records must be read through requestLoadAllAdnLike() before
- *
- * @param efid must be one of EF_ADN, EF_FDN, and EF_SDN
- * @param oldAdn is the adn to be replaced
- * If oldAdn.isEmpty() is ture, it insert the newAdn
- * @param newAdn is the adn to be stored
- * If newAdn.isEmpty() is true, it delete the oldAdn
- * @param pin2 is required to update EF_FDN, otherwise must be null
- * @param response message to be posted when done
- * response.exception hold the exception in error
- */
- public void updateAdnBySearch(int efid, AdnRecord oldAdn, AdnRecord newAdn,
- String pin2, Message response) {
-
- int extensionEF;
- extensionEF = extensionEfForEf(efid);
-
- if (extensionEF < 0) {
- sendErrorResponse(response, "EF is not known ADN-like EF:" + efid);
- return;
- }
-
- ArrayList oldAdnList;
-
- if (efid == EF_PBR) {
- oldAdnList = mUsimPhoneBookManager.loadEfFilesFromUsim();
- } else {
- oldAdnList = getRecordsIfLoaded(efid);
- }
-
- if (oldAdnList == null) {
- sendErrorResponse(response, "Adn list not exist for EF:" + efid);
- return;
- }
-
- int index = -1;
- int count = 1;
- for (Iterator it = oldAdnList.iterator(); it.hasNext(); ) {
- if (oldAdn.isEqual(it.next())) {
- index = count;
- break;
- }
- count++;
- }
-
- if (index == -1) {
- sendErrorResponse(response, "Adn record don't exist for " + oldAdn);
- return;
- }
-
- if (efid == EF_PBR) {
- AdnRecord foundAdn = oldAdnList.get(index-1);
- efid = foundAdn.efid;
- extensionEF = foundAdn.extRecord;
- index = foundAdn.recordNumber;
-
- newAdn.efid = efid;
- newAdn.extRecord = extensionEF;
- newAdn.recordNumber = index;
- }
-
- Message pendingResponse = userWriteResponse.get(efid);
-
- if (pendingResponse != null) {
- sendErrorResponse(response, "Have pending update for EF:" + efid);
- return;
- }
-
- userWriteResponse.put(efid, response);
-
- new AdnRecordLoader(mFh).updateEF(newAdn, efid, extensionEF,
- index, pin2,
- obtainMessage(EVENT_UPDATE_ADN_DONE, efid, index, newAdn));
- }
-
-
- /**
- * Responds with exception (in response) if efid is not a known ADN-like
- * record
- */
- public void
- requestLoadAllAdnLike (int efid, int extensionEf, Message response) {
- ArrayList waiters;
- ArrayList result;
-
- if (efid == EF_PBR) {
- result = mUsimPhoneBookManager.loadEfFilesFromUsim();
- } else {
- result = getRecordsIfLoaded(efid);
- }
-
- // Have we already loaded this efid?
- if (result != null) {
- if (response != null) {
- AsyncResult.forMessage(response).result = result;
- response.sendToTarget();
- }
-
- return;
- }
-
- // Have we already *started* loading this efid?
-
- waiters = adnLikeWaiters.get(efid);
-
- if (waiters != null) {
- // There's a pending request for this EF already
- // just add ourselves to it
-
- waiters.add(response);
- return;
- }
-
- // Start loading efid
-
- waiters = new ArrayList();
- waiters.add(response);
-
- adnLikeWaiters.put(efid, waiters);
-
-
- if (extensionEf < 0) {
- // respond with error if not known ADN-like record
-
- if (response != null) {
- AsyncResult.forMessage(response).exception
- = new RuntimeException("EF is not known ADN-like EF:" + efid);
- response.sendToTarget();
- }
-
- return;
- }
-
- new AdnRecordLoader(mFh).loadAllFromEF(efid, extensionEf,
- obtainMessage(EVENT_LOAD_ALL_ADN_LIKE_DONE, efid, 0));
- }
-
- //***** Private methods
-
- private void
- notifyWaiters(ArrayList waiters, AsyncResult ar) {
-
- if (waiters == null) {
- return;
- }
-
- for (int i = 0, s = waiters.size() ; i < s ; i++) {
- Message waiter = waiters.get(i);
-
- AsyncResult.forMessage(waiter, ar.result, ar.exception);
- waiter.sendToTarget();
- }
- }
-
- //***** Overridden from Handler
-
- public void
- handleMessage(Message msg) {
- AsyncResult ar;
- int efid;
-
- switch(msg.what) {
- case EVENT_LOAD_ALL_ADN_LIKE_DONE:
- /* arg1 is efid, obj.result is ArrayList*/
- ar = (AsyncResult) msg.obj;
- efid = msg.arg1;
- ArrayList waiters;
-
- waiters = adnLikeWaiters.get(efid);
- adnLikeWaiters.delete(efid);
-
- if (ar.exception == null) {
- adnLikeFiles.put(efid, (ArrayList) ar.result);
- }
- notifyWaiters(waiters, ar);
- break;
- case EVENT_UPDATE_ADN_DONE:
- ar = (AsyncResult)msg.obj;
- efid = msg.arg1;
- int index = msg.arg2;
- AdnRecord adn = (AdnRecord) (ar.userObj);
-
- if (ar.exception == null) {
- adnLikeFiles.get(efid).set(index - 1, adn);
- mUsimPhoneBookManager.invalidateCache();
- }
-
- Message response = userWriteResponse.get(efid);
- userWriteResponse.delete(efid);
-
- AsyncResult.forMessage(response, null, ar.exception);
- response.sendToTarget();
- break;
- }
-
- }
-
-
-}
diff --git a/telephony/java/com/android/internal/telephony/AdnRecordLoader.java b/telephony/java/com/android/internal/telephony/AdnRecordLoader.java
deleted file mode 100644
index 084fae6067f8..000000000000
--- a/telephony/java/com/android/internal/telephony/AdnRecordLoader.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.telephony;
-
-import java.util.ArrayList;
-
-import android.os.AsyncResult;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.util.Log;
-
-
-public class AdnRecordLoader extends Handler {
- final static String LOG_TAG = "RIL_AdnRecordLoader";
-
- //***** Instance Variables
-
- private IccFileHandler mFh;
- int ef;
- int extensionEF;
- int pendingExtLoads;
- Message userResponse;
- String pin2;
-
- // For "load one"
- int recordNumber;
-
- // for "load all"
- ArrayList adns; // only valid after EVENT_ADN_LOAD_ALL_DONE
-
- // Either an AdnRecord or a reference to adns depending
- // if this is a load one or load all operation
- Object result;
-
- //***** Event Constants
-
- static final int EVENT_ADN_LOAD_DONE = 1;
- static final int EVENT_EXT_RECORD_LOAD_DONE = 2;
- static final int EVENT_ADN_LOAD_ALL_DONE = 3;
- static final int EVENT_EF_LINEAR_RECORD_SIZE_DONE = 4;
- static final int EVENT_UPDATE_RECORD_DONE = 5;
-
- //***** Constructor
-
- public AdnRecordLoader(IccFileHandler fh) {
- // The telephony unit-test cases may create AdnRecords
- // in secondary threads
- super(Looper.getMainLooper());
- mFh = fh;
- }
-
- /**
- * Resulting AdnRecord is placed in response.obj.result
- * or response.obj.exception is set
- */
- public void
- loadFromEF(int ef, int extensionEF, int recordNumber,
- Message response) {
- this.ef = ef;
- this.extensionEF = extensionEF;
- this.recordNumber = recordNumber;
- this.userResponse = response;
-
- mFh.loadEFLinearFixed(
- ef, recordNumber,
- obtainMessage(EVENT_ADN_LOAD_DONE));
-
- }
-
-
- /**
- * Resulting ArrayList<adnRecord> is placed in response.obj.result
- * or response.obj.exception is set
- */
- public void
- loadAllFromEF(int ef, int extensionEF,
- Message response) {
- this.ef = ef;
- this.extensionEF = extensionEF;
- this.userResponse = response;
-
- mFh.loadEFLinearFixedAll(
- ef,
- obtainMessage(EVENT_ADN_LOAD_ALL_DONE));
-
- }
-
- /**
- * Write adn to a EF SIM record
- * It will get the record size of EF record and compose hex adn array
- * then write the hex array to EF record
- *
- * @param adn is set with alphaTag and phone number
- * @param ef EF fileid
- * @param extensionEF extension EF fileid
- * @param recordNumber 1-based record index
- * @param pin2 for CHV2 operations, must be null if pin2 is not needed
- * @param response will be sent to its handler when completed
- */
- public void
- updateEF(AdnRecord adn, int ef, int extensionEF, int recordNumber,
- String pin2, Message response) {
- this.ef = ef;
- this.extensionEF = extensionEF;
- this.recordNumber = recordNumber;
- this.userResponse = response;
- this.pin2 = pin2;
-
- mFh.getEFLinearRecordSize( ef,
- obtainMessage(EVENT_EF_LINEAR_RECORD_SIZE_DONE, adn));
- }
-
- //***** Overridden from Handler
-
- public void
- handleMessage(Message msg) {
- AsyncResult ar;
- byte data[];
- AdnRecord adn;
-
- try {
- switch (msg.what) {
- case EVENT_EF_LINEAR_RECORD_SIZE_DONE:
- ar = (AsyncResult)(msg.obj);
- adn = (AdnRecord)(ar.userObj);
-
- if (ar.exception != null) {
- throw new RuntimeException("get EF record size failed",
- ar.exception);
- }
-
- int[] recordSize = (int[])ar.result;
- // recordSize is int[3] array
- // int[0] is the record length
- // int[1] is the total length of the EF file
- // int[2] is the number of records in the EF file
- // So int[0] * int[2] = int[1]
- if (recordSize.length != 3 || recordNumber > recordSize[2]) {
- throw new RuntimeException("get wrong EF record size format",
- ar.exception);
- }
-
- data = adn.buildAdnString(recordSize[0]);
-
- if(data == null) {
- throw new RuntimeException("wrong ADN format",
- ar.exception);
- }
-
- mFh.updateEFLinearFixed(ef, recordNumber,
- data, pin2, obtainMessage(EVENT_UPDATE_RECORD_DONE));
-
- pendingExtLoads = 1;
-
- break;
- case EVENT_UPDATE_RECORD_DONE:
- ar = (AsyncResult)(msg.obj);
- if (ar.exception != null) {
- throw new RuntimeException("update EF adn record failed",
- ar.exception);
- }
- pendingExtLoads = 0;
- result = null;
- break;
- case EVENT_ADN_LOAD_DONE:
- ar = (AsyncResult)(msg.obj);
- data = (byte[])(ar.result);
-
- if (ar.exception != null) {
- throw new RuntimeException("load failed", ar.exception);
- }
-
- if (false) {
- Log.d(LOG_TAG,"ADN EF: 0x"
- + Integer.toHexString(ef)
- + ":" + recordNumber
- + "\n" + IccUtils.bytesToHexString(data));
- }
-
- adn = new AdnRecord(ef, recordNumber, data);
- result = adn;
-
- if (adn.hasExtendedRecord()) {
- // If we have a valid value in the ext record field,
- // we're not done yet: we need to read the corresponding
- // ext record and append it
-
- pendingExtLoads = 1;
-
- mFh.loadEFLinearFixed(
- extensionEF, adn.extRecord,
- obtainMessage(EVENT_EXT_RECORD_LOAD_DONE, adn));
- }
- break;
-
- case EVENT_EXT_RECORD_LOAD_DONE:
- ar = (AsyncResult)(msg.obj);
- data = (byte[])(ar.result);
- adn = (AdnRecord)(ar.userObj);
-
- if (ar.exception != null) {
- throw new RuntimeException("load failed", ar.exception);
- }
-
- Log.d(LOG_TAG,"ADN extension EF: 0x"
- + Integer.toHexString(extensionEF)
- + ":" + adn.extRecord
- + "\n" + IccUtils.bytesToHexString(data));
-
- adn.appendExtRecord(data);
-
- pendingExtLoads--;
- // result should have been set in
- // EVENT_ADN_LOAD_DONE or EVENT_ADN_LOAD_ALL_DONE
- break;
-
- case EVENT_ADN_LOAD_ALL_DONE:
- ar = (AsyncResult)(msg.obj);
- ArrayList datas = (ArrayList)(ar.result);
-
- if (ar.exception != null) {
- throw new RuntimeException("load failed", ar.exception);
- }
-
- adns = new ArrayList(datas.size());
- result = adns;
- pendingExtLoads = 0;
-
- for(int i = 0, s = datas.size() ; i < s ; i++) {
- adn = new AdnRecord(ef, 1 + i, datas.get(i));
- adns.add(adn);
-
- if (adn.hasExtendedRecord()) {
- // If we have a valid value in the ext record field,
- // we're not done yet: we need to read the corresponding
- // ext record and append it
-
- pendingExtLoads++;
-
- mFh.loadEFLinearFixed(
- extensionEF, adn.extRecord,
- obtainMessage(EVENT_EXT_RECORD_LOAD_DONE, adn));
- }
- }
- break;
- }
- } catch (RuntimeException exc) {
- if (userResponse != null) {
- AsyncResult.forMessage(userResponse)
- .exception = exc;
- userResponse.sendToTarget();
- // Loading is all or nothing--either every load succeeds
- // or we fail the whole thing.
- userResponse = null;
- }
- return;
- }
-
- if (userResponse != null && pendingExtLoads == 0) {
- AsyncResult.forMessage(userResponse).result
- = result;
-
- userResponse.sendToTarget();
- userResponse = null;
- }
- }
-
-
-}
diff --git a/telephony/java/com/android/internal/telephony/ApnContext.java b/telephony/java/com/android/internal/telephony/ApnContext.java
deleted file mode 100644
index 3a3044e8a2fb..000000000000
--- a/telephony/java/com/android/internal/telephony/ApnContext.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.telephony;
-
-import android.util.Log;
-
-import java.io.FileDescriptor;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Maintain the Apn context
- */
-public class ApnContext {
-
- public final String LOG_TAG;
-
- protected static final boolean DBG = true;
-
- private final String mApnType;
-
- private DataConnectionTracker.State mState;
-
- private ArrayList mWaitingApns = null;
-
- /** A zero indicates that all waiting APNs had a permanent error */
- private AtomicInteger mWaitingApnsPermanentFailureCountDown;
-
- private ApnSetting mApnSetting;
-
- DataConnection mDataConnection;
-
- DataConnectionAc mDataConnectionAc;
-
- String mReason;
-
- /**
- * user/app requested connection on this APN
- */
- AtomicBoolean mDataEnabled;
-
- /**
- * carrier requirements met
- */
- AtomicBoolean mDependencyMet;
-
- public ApnContext(String apnType, String logTag) {
- mApnType = apnType;
- mState = DataConnectionTracker.State.IDLE;
- setReason(Phone.REASON_DATA_ENABLED);
- mDataEnabled = new AtomicBoolean(false);
- mDependencyMet = new AtomicBoolean(true);
- mWaitingApnsPermanentFailureCountDown = new AtomicInteger(0);
- LOG_TAG = logTag;
- }
-
- public String getApnType() {
- return mApnType;
- }
-
- public synchronized DataConnection getDataConnection() {
- return mDataConnection;
- }
-
- public synchronized void setDataConnection(DataConnection dc) {
- if (DBG) {
- log("setDataConnection: old dc=" + mDataConnection + " new dc=" + dc + " this=" + this);
- }
- mDataConnection = dc;
- }
-
-
- public synchronized DataConnectionAc getDataConnectionAc() {
- return mDataConnectionAc;
- }
-
- public synchronized void setDataConnectionAc(DataConnectionAc dcac) {
- if (DBG) {
- log("setDataConnectionAc: old dcac=" + mDataConnectionAc + " new dcac=" + dcac);
- }
- if (dcac != null) {
- dcac.addApnContextSync(this);
- } else {
- if (mDataConnectionAc != null) {
- mDataConnectionAc.removeApnContextSync(this);
- }
- }
- mDataConnectionAc = dcac;
- }
-
- public synchronized ApnSetting getApnSetting() {
- return mApnSetting;
- }
-
- public synchronized void setApnSetting(ApnSetting apnSetting) {
- mApnSetting = apnSetting;
- }
-
- public synchronized void setWaitingApns(ArrayList waitingApns) {
- mWaitingApns = waitingApns;
- mWaitingApnsPermanentFailureCountDown.set(mWaitingApns.size());
- }
-
- public int getWaitingApnsPermFailCount() {
- return mWaitingApnsPermanentFailureCountDown.get();
- }
-
- public void decWaitingApnsPermFailCount() {
- mWaitingApnsPermanentFailureCountDown.decrementAndGet();
- }
-
- public synchronized ApnSetting getNextWaitingApn() {
- ArrayList list = mWaitingApns;
- ApnSetting apn = null;
-
- if (list != null) {
- if (!list.isEmpty()) {
- apn = list.get(0);
- }
- }
- return apn;
- }
-
- public synchronized void removeWaitingApn(ApnSetting apn) {
- if (mWaitingApns != null) {
- mWaitingApns.remove(apn);
- }
- }
-
- public synchronized ArrayList getWaitingApns() {
- return mWaitingApns;
- }
-
- public synchronized void setState(DataConnectionTracker.State s) {
- if (DBG) {
- log("setState: " + s + ", previous state:" + mState);
- }
-
- mState = s;
-
- if (mState == DataConnectionTracker.State.FAILED) {
- if (mWaitingApns != null) {
- mWaitingApns.clear(); // when teardown the connection and set to IDLE
- }
- }
- }
-
- public synchronized DataConnectionTracker.State getState() {
- return mState;
- }
-
- public boolean isDisconnected() {
- DataConnectionTracker.State currentState = getState();
- return ((currentState == DataConnectionTracker.State.IDLE) ||
- currentState == DataConnectionTracker.State.FAILED);
- }
-
- public synchronized void setReason(String reason) {
- if (DBG) {
- log("set reason as " + reason + ",current state " + mState);
- }
- mReason = reason;
- }
-
- public synchronized String getReason() {
- return mReason;
- }
-
- public boolean isReady() {
- return mDataEnabled.get() && mDependencyMet.get();
- }
-
- public void setEnabled(boolean enabled) {
- if (DBG) {
- log("set enabled as " + enabled + ", current state is " + mDataEnabled.get());
- }
- mDataEnabled.set(enabled);
- }
-
- public boolean isEnabled() {
- return mDataEnabled.get();
- }
-
- public void setDependencyMet(boolean met) {
- if (DBG) {
- log("set mDependencyMet as " + met + " current state is " + mDependencyMet.get());
- }
- mDependencyMet.set(met);
- }
-
- public boolean getDependencyMet() {
- return mDependencyMet.get();
- }
-
- @Override
- public String toString() {
- // We don't print mDataConnection because its recursive.
- return "{mApnType=" + mApnType + " mState=" + getState() + " mWaitingApns=" + mWaitingApns +
- " mWaitingApnsPermanentFailureCountDown=" + mWaitingApnsPermanentFailureCountDown +
- " mApnSetting=" + mApnSetting + " mDataConnectionAc=" + mDataConnectionAc +
- " mReason=" + mReason + " mDataEnabled=" + mDataEnabled +
- " mDependencyMet=" + mDependencyMet + "}";
- }
-
- protected void log(String s) {
- Log.d(LOG_TAG, "[ApnContext:" + mApnType + "] " + s);
- }
-
- public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
- pw.println("ApnContext: " + this.toString());
- }
-}
diff --git a/telephony/java/com/android/internal/telephony/ApnSetting.java b/telephony/java/com/android/internal/telephony/ApnSetting.java
deleted file mode 100755
index ad69fdb36b77..000000000000
--- a/telephony/java/com/android/internal/telephony/ApnSetting.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.telephony;
-
-/**
- * This class represents a apn setting for create PDP link
- */
-public class ApnSetting {
-
- static final String V2_FORMAT_REGEX = "^\\[ApnSettingV2\\]\\s*";
-
- public final String carrier;
- public final String apn;
- public final String proxy;
- public final String port;
- public final String mmsc;
- public final String mmsProxy;
- public final String mmsPort;
- public final String user;
- public final String password;
- public final int authType;
- public final String[] types;
- public final int id;
- public final String numeric;
- public final String protocol;
- public final String roamingProtocol;
- /**
- * Current status of APN
- * true : enabled APN, false : disabled APN.
- */
- public final boolean carrierEnabled;
- /**
- * Radio Access Technology info
- * To check what values can hold, refer to ServiceState.java.
- * This should be spread to other technologies,
- * but currently only used for LTE(14) and EHRPD(13).
- */
- public final int bearer;
-
- public ApnSetting(int id, String numeric, String carrier, String apn,
- String proxy, String port,
- String mmsc, String mmsProxy, String mmsPort,
- String user, String password, int authType, String[] types,
- String protocol, String roamingProtocol, boolean carrierEnabled, int bearer) {
- this.id = id;
- this.numeric = numeric;
- this.carrier = carrier;
- this.apn = apn;
- this.proxy = proxy;
- this.port = port;
- this.mmsc = mmsc;
- this.mmsProxy = mmsProxy;
- this.mmsPort = mmsPort;
- this.user = user;
- this.password = password;
- this.authType = authType;
- this.types = types;
- this.protocol = protocol;
- this.roamingProtocol = roamingProtocol;
- this.carrierEnabled = carrierEnabled;
- this.bearer = bearer;
- }
-
- /**
- * Creates an ApnSetting object from a string.
- *
- * @param data the string to read.
- *
- * The string must be in one of two formats (newlines added for clarity,
- * spaces are optional):
- *
- * v1 format:
- * , , , , , ,
- * , , , , ,,
- * [, ...]
- *
- * v2 format:
- * [ApnSettingV2] , , , , , ,
- * , , ,