diff options
author | Wink Saville <> | 2009-04-02 01:37:02 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-04-02 01:37:02 -0700 |
commit | 767a662ecde33c3979bf02b793d392aca0403162 (patch) | |
tree | f55548c33a8267c39acc60f72051f9856e95e672 /telephony/java/android/telephony/gsm | |
parent | e9c08056fafab720856ab8516ea0e623a5c0e360 (diff) | |
download | frameworks_base-767a662ecde33c3979bf02b793d392aca0403162.zip frameworks_base-767a662ecde33c3979bf02b793d392aca0403162.tar.gz frameworks_base-767a662ecde33c3979bf02b793d392aca0403162.tar.bz2 |
AI 144185: Integrate cdma into the main code base.
Automated import of CL 144185
Diffstat (limited to 'telephony/java/android/telephony/gsm')
3 files changed, 433 insertions, 1482 deletions
diff --git a/telephony/java/android/telephony/gsm/GsmCellLocation.java b/telephony/java/android/telephony/gsm/GsmCellLocation.java index fb9b73a..637a11c 100644 --- a/telephony/java/android/telephony/gsm/GsmCellLocation.java +++ b/telephony/java/android/telephony/gsm/GsmCellLocation.java @@ -17,14 +17,12 @@ package android.telephony.gsm; import android.os.Bundle; -import com.android.internal.telephony.Phone; import android.telephony.CellLocation; /** * Represents the cell location on a GSM phone. */ -public class GsmCellLocation extends CellLocation -{ +public class GsmCellLocation extends CellLocation { private int mLac; private int mCid; @@ -82,7 +80,7 @@ public class GsmCellLocation extends CellLocation @Override public boolean equals(Object o) { GsmCellLocation s; - + try { s = (GsmCellLocation)o; } catch (ClassCastException ex) { @@ -100,7 +98,7 @@ public class GsmCellLocation extends CellLocation public String toString() { return "["+ mLac + "," + mCid + "]"; } - + /** * Test whether two objects hold the same data values or both are null * diff --git a/telephony/java/android/telephony/gsm/SmsManager.java b/telephony/java/android/telephony/gsm/SmsManager.java index c63b530..cdd707e 100644 --- a/telephony/java/android/telephony/gsm/SmsManager.java +++ b/telephony/java/android/telephony/gsm/SmsManager.java @@ -17,28 +17,35 @@ package android.telephony.gsm; import android.app.PendingIntent; -import android.os.RemoteException; -import android.os.IServiceManager; -import android.os.ServiceManager; -import android.os.ServiceManagerNative; -import android.text.TextUtils; - -import com.android.internal.telephony.gsm.EncodeException; -import com.android.internal.telephony.gsm.GsmAlphabet; -import com.android.internal.telephony.gsm.ISms; -import com.android.internal.telephony.gsm.SimConstants; -import com.android.internal.telephony.gsm.SmsRawData; import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; + /** * 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. */ -public final class SmsManager { +@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; + } + + private SmsManager() { + mSmsMgrProxy = android.telephony.SmsManager.getDefault(); + } /** * Send a text based SMS. @@ -55,28 +62,21 @@ public final class SmsManager { * <code>RESULT_ERROR_RADIO_OFF</code> * <code>RESULT_ERROR_NULL_PDU</code>. * The per-application based SMS control checks sentIntent. If sentIntent - * is NULL the caller will be checked against all unknown applicaitons, + * 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 <code>PendingIntent</code> 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. */ - public void sendTextMessage( + @Deprecated + public final 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"); - } - - SmsMessage.SubmitPdu pdus = SmsMessage.getSubmitPdu( - scAddress, destinationAddress, text, (deliveryIntent != null)); - sendRawPdu(pdus.encodedScAddress, pdus.encodedMessage, sentIntent, deliveryIntent); + mSmsMgrProxy.sendTextMessage(destinationAddress, scAddress, text, + sentIntent, deliveryIntent); } /** @@ -86,55 +86,24 @@ public final class SmsManager { * @param text the original message. Must not be null. * @return an <code>ArrayList</code> of strings that, in order, * comprise the original message + * @deprecated Use android.telephony.SmsManager. */ - public ArrayList<String> divideMessage(String text) { - int size = text.length(); - int[] params = SmsMessage.calculateLength(text, false); - /* SmsMessage.calculateLength returns an int[4] with: - * int[0] being the number of SMS's required, - * int[1] the number of code units used, - * 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. - */ - int messageCount = params[0]; - int encodingType = params[3]; - ArrayList<String> result = new ArrayList<String>(messageCount); - - int start = 0; - int limit; - - if (messageCount > 1) { - limit = (encodingType == SmsMessage.ENCODING_7BIT) ? - SmsMessage.MAX_USER_DATA_SEPTETS_WITH_HEADER : - SmsMessage.MAX_USER_DATA_BYTES_WITH_HEADER; - } else { - limit = (encodingType == SmsMessage.ENCODING_7BIT) ? - SmsMessage.MAX_USER_DATA_SEPTETS : SmsMessage.MAX_USER_DATA_BYTES; - } - - try { - while (start < size) { - int end = GsmAlphabet.findLimitIndex(text, start, limit, encodingType); - result.add(text.substring(start, end)); - start = end; - } - } catch (EncodeException e) { - // ignore it. - } - return result; + @Deprecated + public final ArrayList<String> 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 * <code>divideMessage</code>. - * + * * @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 <code>ArrayList</code> of strings that, in order, * comprise the original message - * @param sentIntents if not null, an <code>ArrayList</code> of + * @param sentIntents if not null, an <code>ArrayList</code> of * <code>PendingIntent</code>s (one for each message part) that is * broadcast when the corresponding message part has been sent. * The result code will be <code>Activity.RESULT_OK<code> for success, @@ -145,44 +114,21 @@ public final class SmsManager { * 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 <code>ArrayList</code> of + * @param deliveryIntents if not null, an <code>ArrayList</code> of * <code>PendingIntent</code>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. */ - public void sendMultipartTextMessage( + @Deprecated + public final void sendMultipartTextMessage( String destinationAddress, String scAddress, ArrayList<String> parts, ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> 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 simISms = ISms.Stub.asInterface(ServiceManager.getService("isms")); - if (simISms != null) { - simISms.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); - } + mSmsMgrProxy.sendMultipartTextMessage(destinationAddress, scAddress, parts, + sentIntents, deliveryIntents); } /** @@ -208,70 +154,14 @@ public final class SmsManager { * 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. */ - public void sendDataMessage( + @Deprecated + public final 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"); - } - - SmsMessage.SubmitPdu pdus = SmsMessage.getSubmitPdu(scAddress, destinationAddress, - destinationPort, data, (deliveryIntent != null)); - sendRawPdu(pdus.encodedScAddress, pdus.encodedMessage, sentIntent, deliveryIntent); - } - - /** - * Send a raw SMS PDU. - * - * @param smsc the SMSC to send the message through, or NULL for the - * default SMSC - * @param pdu the raw PDU to send - * @param sentIntent if not NULL this <code>PendingIntent</code> is - * broadcast when the message is sucessfully sent, or failed. - * The result code will be <code>Activity.RESULT_OK<code> for success, - * or one of these errors: - * <code>RESULT_ERROR_GENERIC_FAILURE</code> - * <code>RESULT_ERROR_RADIO_OFF</code> - * <code>RESULT_ERROR_NULL_PDU</code>. - * 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 <code>PendingIntent</code> is - * broadcast when the message is delivered to the recipient. The - * raw pdu of the status report is in the extended data ("pdu"). - * - */ - private void sendRawPdu(byte[] smsc, byte[] pdu, PendingIntent sentIntent, - PendingIntent deliveryIntent) { - try { - ISms simISms = ISms.Stub.asInterface(ServiceManager.getService("isms")); - if (simISms != null) { - simISms.sendRawPdu(smsc, pdu, 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() { - if (sInstance == null) { - sInstance = new SmsManager(); - } - return sInstance; - } - - private SmsManager() { - // nothing to see here + mSmsMgrProxy.sendDataMessage(destinationAddress, scAddress, destinationPort, + data, sentIntent, deliveryIntent); } /** @@ -282,22 +172,12 @@ public final class SmsManager { * @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} */ - public boolean copyMessageToSim(byte[] smsc, byte[] pdu, int status) { - boolean success = false; - - try { - ISms simISms = ISms.Stub.asInterface(ServiceManager.getService("isms")); - if (simISms != null) { - success = simISms.copyMessageToSimEf(status, pdu, smsc); - } - } catch (RemoteException ex) { - // ignore it - } - - return success; + @Deprecated + public final boolean copyMessageToSim(byte[] smsc, byte[] pdu, int status) { + return mSmsMgrProxy.copyMessageToIcc(smsc, pdu, status); } /** @@ -305,26 +185,12 @@ public final class SmsManager { * * @param messageIndex is the record index of the message on SIM * @return true for success - * + * @deprecated Use android.telephony.SmsManager. * {@hide} */ - public boolean - deleteMessageFromSim(int messageIndex) { - boolean success = false; - byte[] pdu = new byte[SimConstants.SMS_RECORD_LENGTH-1]; - Arrays.fill(pdu, (byte)0xff); - - try { - ISms simISms = ISms.Stub.asInterface(ServiceManager.getService("isms")); - if (simISms != null) { - success = simISms.updateMessageOnSimEf(messageIndex, - STATUS_ON_SIM_FREE, pdu); - } - } catch (RemoteException ex) { - // ignore it - } - - return success; + @Deprecated + public final boolean deleteMessageFromSim(int messageIndex) { + return mSmsMgrProxy.deleteMessageFromIcc(messageIndex); } /** @@ -336,97 +202,59 @@ public final class SmsManager { * 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} */ - public boolean updateMessageOnSim(int messageIndex, int newStatus, - byte[] pdu) { - boolean success = false; - - try { - ISms simISms = ISms.Stub.asInterface(ServiceManager.getService("isms")); - if (simISms != null) { - success = simISms.updateMessageOnSimEf(messageIndex, newStatus, pdu); - } - } catch (RemoteException ex) { - // ignore it - } - - return success; + @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 <code>ArrayList</code> of <code>SmsMessage</code> objects - * + * @deprecated Use android.telephony.SmsManager. * {@hide} */ - public ArrayList<SmsMessage> getAllMessagesFromSim() { - List<SmsRawData> records = null; + @Deprecated + public final ArrayList<android.telephony.SmsMessage> getAllMessagesFromSim() { + return mSmsMgrProxy.getAllMessagesFromIcc(); + } - try { - ISms simISms = ISms.Stub.asInterface(ServiceManager.getService("isms")); - if (simISms != null) { - records = simISms.getAllMessagesFromSimEf(); - } - } catch (RemoteException ex) { - // ignore it - } - - return createMessageListFromRawRecords(records); - } + /** Free space (TS 51.011 10.5.3). + * @deprecated Use android.telephony.SmsManager. */ + @Deprecated static public final int STATUS_ON_SIM_FREE = 0; - /** - * Create a list of <code>SmsMessage</code>s from a list of RawSmsData - * records returned by <code>getAllMessagesFromSim()</code> - * - * @param records SMS EF records, returned by - * <code>getAllMessagesFromSim</code> - * @return <code>ArrayList</code> of <code>SmsMessage</code> objects. - */ - private ArrayList<SmsMessage> createMessageListFromRawRecords(List records) { - ArrayList<SmsMessage> messages = new ArrayList<SmsMessage>(); - if (records != null) { - int count = records.size(); - for (int i = 0; i < count; i++) { - SmsRawData data = (SmsRawData)records.get(i); - // List contains all records, including "free" records (null) - if (data != null) { - SmsMessage sms = - SmsMessage.createFromEfRecord(i+1, data.getBytes()); - messages.add(sms); - } - } - } - return messages; - } + /** Received and read (TS 51.011 10.5.3). + * @deprecated Use android.telephony.SmsManager. */ + @Deprecated static public final int STATUS_ON_SIM_READ = 1; - /** Free space (TS 51.011 10.5.3). */ - static public final int STATUS_ON_SIM_FREE = 0; + /** Received and unread (TS 51.011 10.5.3). + * @deprecated Use android.telephony.SmsManager. */ + @Deprecated static public final int STATUS_ON_SIM_UNREAD = 3; - /** Received and read (TS 51.011 10.5.3). */ - static public final int STATUS_ON_SIM_READ = 1; + /** Stored and sent (TS 51.011 10.5.3). + * @deprecated Use android.telephony.SmsManager. */ + @Deprecated static public final int STATUS_ON_SIM_SENT = 5; - /** Received and unread (TS 51.011 10.5.3). */ - static public final int STATUS_ON_SIM_UNREAD = 3; + /** Stored and unsent (TS 51.011 10.5.3). + * @deprecated Use android.telephony.SmsManager. */ + @Deprecated static public final int STATUS_ON_SIM_UNSENT = 7; - /** Stored and sent (TS 51.011 10.5.3). */ - static public final int STATUS_ON_SIM_SENT = 5; + /** Generic failure cause + * @deprecated Use android.telephony.SmsManager. */ + @Deprecated static public final int RESULT_ERROR_GENERIC_FAILURE = 1; - /** Stored and unsent (TS 51.011 10.5.3). */ - static public final int STATUS_ON_SIM_UNSENT = 7; + /** 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; - // SMS send failure result codes + /** Failed because service is currently unavailable + * @deprecated Use android.telephony.SmsManager. */ + @Deprecated static public final int RESULT_ERROR_NO_SERVICE = 4; - /** 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; } diff --git a/telephony/java/android/telephony/gsm/SmsMessage.java b/telephony/java/android/telephony/gsm/SmsMessage.java index c2e0165..0928ddf 100644 --- a/telephony/java/android/telephony/gsm/SmsMessage.java +++ b/telephony/java/android/telephony/gsm/SmsMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 The Android Open Source Project + * 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. @@ -16,327 +16,117 @@ package android.telephony.gsm; -import android.telephony.PhoneNumberUtils; -import android.util.Config; -import android.util.Log; -import android.telephony.PhoneNumberUtils; -import android.text.format.Time; +import android.os.Parcel; +import android.telephony.TelephonyManager; -import com.android.internal.telephony.gsm.EncodeException; -import com.android.internal.telephony.gsm.GsmAlphabet; -import com.android.internal.telephony.gsm.SimUtils; -import com.android.internal.telephony.gsm.SmsHeader; +import com.android.internal.telephony.GsmAlphabet; +import com.android.internal.telephony.EncodeException; +import com.android.internal.telephony.SmsMessageBase; +import com.android.internal.telephony.SmsMessageBase.SubmitPduBase; -import java.io.ByteArrayOutputStream; -import java.io.UnsupportedEncodingException; import java.util.Arrays; -class SmsAddress { - // From TS 23.040 9.1.2.5 and TS 24.008 table 10.5.118 - static final int TON_UNKNOWN = 0; +import static android.telephony.TelephonyManager.PHONE_TYPE_CDMA; - static final int TON_INTERNATIONAL = 1; - static final int TON_NATIONAL = 2; - - static final int TON_NETWORK = 3; - - static final int TON_SUBSCRIBER = 4; - - static final int TON_ALPHANUMERIC = 5; - - static final int TON_APPREVIATED = 6; - - static final int OFFSET_ADDRESS_LENGTH = 0; - - static final int OFFSET_TOA = 1; - - static final int OFFSET_ADDRESS_VALUE = 2; - - int ton; - - String address; - - byte[] origBytes; +/** + * 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"; /** - * New SmsAddress from TS 23.040 9.1.2.5 Address Field - * - * @param offset the offset of the Address-Length byte - * @param length the length in bytes rounded up, e.g. "2 + - * (addressLength + 1) / 2" + * SMS Class enumeration. + * See TS 23.038. + * @deprecated Use android.telephony.SmsMessage. */ - - SmsAddress(byte[] data, int offset, int length) { - origBytes = new byte[length]; - System.arraycopy(data, offset, origBytes, 0, length); - - // addressLength is the count of semi-octets, not bytes - int addressLength = origBytes[OFFSET_ADDRESS_LENGTH] & 0xff; - - int toa = origBytes[OFFSET_TOA] & 0xff; - ton = 0x7 & (toa >> 4); - - // TOA must have its high bit set - if ((toa & 0x80) != 0x80) { - throw new RuntimeException("Invalid TOA - high bit must be set"); - } - - if (isAlphanumeric()) { - // An alphanumeric address - int countSeptets = addressLength * 4 / 7; - - address = GsmAlphabet.gsm7BitPackedToString(origBytes, - OFFSET_ADDRESS_VALUE, countSeptets); - } else { - // TS 23.040 9.1.2.5 says - // that "the MS shall interpret reserved values as 'Unknown' - // but shall store them exactly as received" - - byte lastByte = origBytes[length - 1]; - - if ((addressLength & 1) == 1) { - // Make sure the final unused BCD digit is 0xf - origBytes[length - 1] |= 0xf0; - } - address = PhoneNumberUtils.calledPartyBCDToString(origBytes, - OFFSET_TOA, length - OFFSET_TOA); - - // And restore origBytes - origBytes[length - 1] = lastByte; - } - } - - public String getAddressString() { - return address; + @Deprecated + public enum MessageClass{ + UNKNOWN, CLASS_0, CLASS_1, CLASS_2, CLASS_3; } - /** - * Returns true if this is an alphanumeric addres + /** Unknown encoding scheme (see TS 23.038) + * @deprecated Use android.telephony.SmsMessage. */ - public boolean isAlphanumeric() { - return ton == TON_ALPHANUMERIC; - } - - public boolean isNetworkSpecific() { - return ton == TON_NETWORK; - } + @Deprecated public static final int ENCODING_UNKNOWN = 0; - /** - * Returns true of this is a valid CPHS voice message waiting indicator - * address + /** 7-bit encoding scheme (see TS 23.038) + * @deprecated Use android.telephony.SmsMessage. */ - public boolean isCphsVoiceMessageIndicatorAddress() { - // CPHS-style MWI message - // See CPHS 4.7 B.4.2.1 - // - // Basically: - // - // - Originating address should be 4 bytes long and alphanumeric - // - Decode will result with two chars: - // - Char 1 - // 76543210 - // ^ set/clear indicator (0 = clear) - // ^^^ type of indicator (000 = voice) - // ^^^^ must be equal to 0001 - // - Char 2: - // 76543210 - // ^ line number (0 = line 1) - // ^^^^^^^ set to 0 - // - // Remember, since the alpha address is stored in 7-bit compact form, - // the "line number" is really the top bit of the first address value - // byte - - return (origBytes[OFFSET_ADDRESS_LENGTH] & 0xff) == 4 - && isAlphanumeric() && (origBytes[OFFSET_TOA] & 0x0f) == 0; - } + @Deprecated public static final int ENCODING_7BIT = 1; - /** - * Returns true if this is a valid CPHS voice message waiting indicator - * address indicating a "set" of "indicator 1" of type "voice message - * waiting" + /** 8-bit encoding scheme (see TS 23.038) + * @deprecated Use android.telephony.SmsMessage. */ - public boolean isCphsVoiceMessageSet() { - // 0x11 means "set" "voice message waiting" "indicator 1" - return isCphsVoiceMessageIndicatorAddress() - && (origBytes[OFFSET_ADDRESS_VALUE] & 0xff) == 0x11; + @Deprecated public static final int ENCODING_8BIT = 2; - } - - /** - * Returns true if this is a valid CPHS voice message waiting indicator - * address indicationg a "clear" of "indicator 1" of type "voice message - * waiting" + /** 16-bit encoding scheme (see TS 23.038) + * @deprecated Use android.telephony.SmsMessage. */ - public boolean isCphsVoiceMessageClear() { - // 0x10 means "clear" "voice message waiting" "indicator 1" - return isCphsVoiceMessageIndicatorAddress() - && (origBytes[OFFSET_ADDRESS_VALUE] & 0xff) == 0x10; - - } - - public boolean couldBeEmailGateway() { - // Some carriers seems to send email gateway messages in this form: - // from: an UNKNOWN TON, 3 or 4 digits long, beginning with a 5 - // PID: 0x00, Data coding scheme 0x03 - // So we just attempt to treat any message from an address length <= 4 - // as an email gateway - - return address.length() <= 4; - } - -} - -/** - * A Short Message Service message. - * - */ -public class SmsMessage { - static final String LOG_TAG = "GSM"; + @Deprecated public static final int ENCODING_16BIT = 3; - /** - * SMS Class enumeration. - * See TS 23.038. - * + /** The maximum number of payload bytes per message + * @deprecated Use android.telephony.SmsMessage. */ - public enum MessageClass { - UNKNOWN, CLASS_0, CLASS_1, CLASS_2, CLASS_3; - } - - /** Unknown encoding scheme (see TS 23.038) */ - public static final int ENCODING_UNKNOWN = 0; - /** 7-bit encoding scheme (see TS 23.038) */ - public static final int ENCODING_7BIT = 1; - /** 8-bit encoding scheme (see TS 23.038) */ - public static final int ENCODING_8BIT = 2; - /** 16-bit encoding scheme (see TS 23.038) */ - public static final int ENCODING_16BIT = 3; - - /** The maximum number of payload bytes per message */ - public static final int MAX_USER_DATA_BYTES = 140; + @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 */ - static final int MAX_USER_DATA_BYTES_WITH_HEADER = 134; + @Deprecated 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 + * @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. */ - public static final int MAX_USER_DATA_SEPTETS_WITH_HEADER = 153; - - /** The address of the SMSC. May be null */ - String scAddress; - - /** The address of the sender */ - SmsAddress originatingAddress; - - /** The message body as a string. May be null if the message isn't text */ - String messageBody; - - String pseudoSubject; - - /** Non-null this is an email gateway message */ - String emailFrom; - - /** Non-null if this is an email gateway message */ - String emailBody; - - boolean isEmail; - - long scTimeMillis; + @Deprecated public static final int MAX_USER_DATA_SEPTETS_WITH_HEADER = 153; - /** The raw PDU of the message */ - byte[] mPdu; - - /** The raw bytes for the user data section of the message */ - byte[] userData; - - SmsHeader userDataHeader; - - /** - * TP-Message-Type-Indicator - * 9.2.3 - */ - int mti; - - /** TP-Protocol-Identifier (TP-PID) */ - int protocolIdentifier; - - // TP-Data-Coding-Scheme - // see TS 23.038 - int dataCodingScheme; - - // TP-Reply-Path - // e.g. 23.040 9.2.2.1 - boolean replyPathPresent = false; - - // "Message Marked for Automatic Deletion Group" - // 23.038 Section 4 - boolean automaticDeletion; - - // "Message Waiting Indication Group" - // 23.038 Section 4 - private boolean isMwi; - - private boolean mwiSense; - - private boolean mwiDontStore; - - MessageClass messageClass; - - /** - * Indicates status for messages stored on the SIM. - */ - int statusOnSim = -1; - - /** - * Record index of message in the EF. + /** Contains actual SmsMessage. Only public for debugging and for framework layer. + * @deprecated Use android.telephony.SmsMessage. + * {@hide} */ - int indexOnSim = -1; - - /** TP-Message-Reference - Message Reference of sent message. @hide */ - public int messageRef; - - /** True if Status Report is for SMS-SUBMIT; false for SMS-COMMAND. */ - boolean forSubmit; + @Deprecated public SmsMessageBase mWrappedSmsMessage; - /** The address of the receiver. */ - SmsAddress recipientAddress; - - /** Time when SMS-SUBMIT was delivered from SC to MSE. */ - long dischargeTimeMillis; - - /** - * TP-Status - status of a previously submitted SMS. - * This field applies to SMS-STATUS-REPORT messages. 0 indicates success; - * see TS 23.040, 9.2.3.15 for description of other possible values. - */ - int status; + /** @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; - /** - * TP-Status - status of a previously submitted SMS. - * This field is true iff the message is a SMS-STATUS-REPORT message. - */ - boolean isStatusReportMessage = false; + //Constructor + /** @deprecated Use android.telephony.SmsMessage. */ + @Deprecated + public SubmitPdu() { + } - /** - * This class represents the encoded form of an outgoing SMS. - */ - public static class SubmitPdu { - public byte[] encodedScAddress; // Null if not applicable. - public byte[] encodedMessage; + /** @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) @@ -345,18 +135,33 @@ public class SmsMessage { } } + // 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) { - try { - SmsMessage msg = new SmsMessage(); - msg.parsePdu(pdu); - return msg; - } catch (RuntimeException ex) { - Log.e(LOG_TAG, "SMS PDU parsing failed: ", ex); - return null; + SmsMessageBase wrappedMessage; + int activePhone = TelephonyManager.getDefault().getPhoneType(); + + 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); } /** @@ -364,38 +169,70 @@ public class SmsMessage { * +CMT unsolicited response (PDU mode, of course) * +CMT: [<alpha>],<length><CR><LF><pdu> * - * Only public for debugging - * + * Only public for debugging and for RIL + * @deprecated Use android.telephony.SmsMessage. * {@hide} */ - /* package */ public static SmsMessage newFromCMT(String[] lines) { - try { - SmsMessage msg = new SmsMessage(); - msg.parsePdu(SimUtils.hexStringToBytes(lines[1])); - return msg; - } catch (RuntimeException ex) { - Log.e(LOG_TAG, "SMS PDU parsing failed: ", ex); - return null; + @Deprecated + public static SmsMessage newFromCMT(String[] lines){ + SmsMessageBase wrappedMessage; + int activePhone = TelephonyManager.getDefault().getPhoneType(); + + if (PHONE_TYPE_CDMA == activePhone) { + wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.newFromCMT(lines); + } else { + wrappedMessage = com.android.internal.telephony.gsm.SmsMessage.newFromCMT(lines); } + + return new SmsMessage(wrappedMessage); } - /* pacakge */ static SmsMessage newFromCMTI(String line) { - // the thinking here is not to read the message immediately - // FTA test case - Log.e(LOG_TAG, "newFromCMTI: not yet supported"); - return null; + /** @deprecated Use android.telephony.SmsMessage. + * @hide */ + @Deprecated + protected static SmsMessage newFromCMTI(String line) { + SmsMessageBase wrappedMessage; + int activePhone = TelephonyManager.getDefault().getPhoneType(); + + if (PHONE_TYPE_CDMA == activePhone) { + wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.newFromCMTI(line); + } else { + wrappedMessage = com.android.internal.telephony.gsm.SmsMessage.newFromCMTI(line); + } + + return new SmsMessage(wrappedMessage); } - /** @hide */ - /* package */ public static SmsMessage newFromCDS(String line) { - try { - SmsMessage msg = new SmsMessage(); - msg.parsePdu(SimUtils.hexStringToBytes(line)); - return msg; - } catch (RuntimeException ex) { - Log.e(LOG_TAG, "CDS SMS PDU parsing failed: ", ex); - return null; + /** @deprecated Use android.telephony.SmsMessage. + * @hide */ + @Deprecated + public static SmsMessage newFromCDS(String line) { + SmsMessageBase wrappedMessage; + int activePhone = TelephonyManager.getDefault().getPhoneType(); + + if (PHONE_TYPE_CDMA == activePhone) { + wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.newFromCDS(line); + } else { + wrappedMessage = com.android.internal.telephony.gsm.SmsMessage.newFromCDS(line); + } + + return new SmsMessage(wrappedMessage); + } + + /** @deprecated Use android.telephony.SmsMessage. + * @hide */ + @Deprecated + public static SmsMessage newFromParcel(Parcel p) { + SmsMessageBase wrappedMessage; + int activePhone = TelephonyManager.getDefault().getPhoneType(); + + if (PHONE_TYPE_CDMA == activePhone) { + wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.newFromParcel(p); + } else { + wrappedMessage = com.android.internal.telephony.gsm.SmsMessage.newFromParcel(p); } + + return new SmsMessage(wrappedMessage); } /** @@ -405,51 +242,40 @@ public class SmsMessage { * returned by SmsManager.getAllMessagesFromSim + 1. * @param data Record data. * @return An SmsMessage representing the record. - * + * + * @deprecated Use android.telephony.SmsMessage. * @hide */ + @Deprecated public static SmsMessage createFromEfRecord(int index, byte[] data) { - try { - SmsMessage msg = new SmsMessage(); - - msg.indexOnSim = index; - - // First byte is status: RECEIVED_READ, RECEIVED_UNREAD, STORED_SENT, - // or STORED_UNSENT - // See TS 51.011 10.5.3 - if ((data[0] & 1) == 0) { - Log.w(LOG_TAG, - "SMS parsing failed: Trying to parse a free record"); - return null; - } else { - msg.statusOnSim = data[0] & 0x07; - } + SmsMessageBase wrappedMessage; + int activePhone = TelephonyManager.getDefault().getPhoneType(); - int size = data.length - 1; - - // Note: Data may include trailing FF's. That's OK; message - // should still parse correctly. - byte[] pdu = new byte[size]; - System.arraycopy(data, 1, pdu, 0, size); - msg.parsePdu(pdu); - return msg; - } catch (RuntimeException ex) { - Log.e(LOG_TAG, "SMS PDU parsing failed: ", ex); - return null; + 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 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 len = pdu.length() / 2; - int smscLen = 0; + int activePhone = TelephonyManager.getDefault().getPhoneType(); - smscLen = Integer.parseInt(pdu.substring(0, 2), 16); - - return len - smscLen - 1; + if (PHONE_TYPE_CDMA == activePhone) { + return com.android.internal.telephony.cdma.SmsMessage.getTPLayerLengthForPDU(pdu); + } else { + return com.android.internal.telephony.gsm.SmsMessage.getTPLayerLengthForPDU(pdu); + } } /** @@ -466,7 +292,9 @@ public class SmsMessage { * 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) { int ret[] = new int[4]; @@ -517,10 +345,10 @@ public class SmsMessage { * units remaining until the next message. int[3] is the encoding * type that should be used for the message. */ + @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 @@ -529,92 +357,27 @@ public class SmsMessage { * @return a <code>SubmitPdu</code> 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().getPhoneType(); - // Perform null parameter checks. - if (message == null || destinationAddress == null) { - return null; - } - - SubmitPdu ret = new SubmitPdu(); - // MTI = SMS-SUBMIT, UDHI = header != null - byte mtiByte = (byte)(0x01 | (header != null ? 0x40 : 0x00)); - ByteArrayOutputStream bo = getSubmitPduHead( - scAddress, destinationAddress, mtiByte, - statusReportRequested, ret); - - try { - // First, try encoding it with the GSM alphabet - - // User Data (and length) - byte[] userData = GsmAlphabet.stringToGsm7BitPackedWithHeader(message, header); - - if ((0xff & userData[0]) > MAX_USER_DATA_SEPTETS) { - // Message too long - return null; - } - - // TP-Data-Coding-Scheme - // Default encoding, uncompressed - // To test writing messages to the SIM card, change this value 0x00 to 0x12, which - // means "bits 1 and 0 contain message class, and the class is 2". Note that this - // takes effect for the sender. In other words, messages sent by the phone with this - // change will end up on the receiver's SIM card. You can then send messages to - // yourself (on a phone with this change) and they'll end up on the SIM card. - bo.write(0x00); - - // (no TP-Validity-Period) - - bo.write(userData, 0, userData.length); - } catch (EncodeException ex) { - byte[] userData, textPart; - // Encoding to the 7-bit alphabet failed. Let's see if we can - // send it as a UCS-2 encoded message - - try { - textPart = message.getBytes("utf-16be"); - } catch (UnsupportedEncodingException uex) { - Log.e(LOG_TAG, - "Implausible UnsupportedEncodingException ", - uex); - return null; - } - - if (header != null) { - userData = new byte[header.length + textPart.length]; - - System.arraycopy(header, 0, userData, 0, header.length); - System.arraycopy(textPart, 0, userData, header.length, textPart.length); - } else { - userData = textPart; - } - - if (userData.length > MAX_USER_DATA_BYTES) { - // Message too long - return null; - } - - // TP-Data-Coding-Scheme - // Class 3, UCS-2 encoding, uncompressed - bo.write(0x0b); - - // (no TP-Validity-Period) - - // TP-UDL - bo.write(userData.length); - - bo.write(userData, 0, userData.length); + if (PHONE_TYPE_CDMA == activePhone) { + spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress, + destinationAddress, message, statusReportRequested, header); + } else { + spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress, + destinationAddress, message, statusReportRequested, header); } - ret.encodedMessage = bo.toByteArray(); - return ret; + return new SubmitPdu(spb); } - /** * Get an SMS-SUBMIT PDU for a destination address and a message * @@ -622,12 +385,23 @@ public class SmsMessage { * @return a <code>SubmitPdu</code> 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) { + String destinationAddress, String message, boolean statusReportRequested) { + SubmitPduBase spb; + int activePhone = TelephonyManager.getDefault().getPhoneType(); - return getSubmitPdu(scAddress, destinationAddress, message, statusReportRequested, null); + if (PHONE_TYPE_CDMA == activePhone) { + spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress, + destinationAddress, message, statusReportRequested); + } else { + spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress, + destinationAddress, message, statusReportRequested); + } + + return new SubmitPdu(spb); } /** @@ -641,478 +415,105 @@ public class SmsMessage { * @return a <code>SubmitPdu</code> 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) { - if (data.length > (MAX_USER_DATA_BYTES - 7 /* UDH size */)) { - Log.e(LOG_TAG, "SMS data message may only contain " - + (MAX_USER_DATA_BYTES - 7) + " bytes"); - return null; - } - - SubmitPdu ret = new SubmitPdu(); - ByteArrayOutputStream bo = getSubmitPduHead( - scAddress, destinationAddress, (byte) 0x41, // MTI = SMS-SUBMIT, - // TP-UDHI = true - statusReportRequested, ret); - - // TP-Data-Coding-Scheme - // No class, 8 bit data - bo.write(0x04); - - // (no TP-Validity-Period) - - // User data size - bo.write(data.length + 7); - - // User data header size - bo.write(0x06); // header is 6 octets - - // User data header, indicating the destination port - bo.write(SmsHeader.APPLICATION_PORT_ADDRESSING_16_BIT); // port - // addressing - // header - bo.write(0x04); // each port is 2 octets - bo.write((destinationPort >> 8) & 0xFF); // MSB of destination port - bo.write(destinationPort & 0xFF); // LSB of destination port - bo.write(0x00); // MSB of originating port - bo.write(0x00); // LSB of originating port - - // User data - bo.write(data, 0, data.length); - - ret.encodedMessage = bo.toByteArray(); - return ret; - } + SubmitPduBase spb; + int activePhone = TelephonyManager.getDefault().getPhoneType(); - /** - * Create the beginning of a SUBMIT PDU. This is the part of the - * SUBMIT PDU that is common to the two versions of {@link #getSubmitPdu}, - * one of which takes a byte array and the other of which takes a - * <code>String</code>. - * - * @param scAddress Service Centre address. null == use default - * @param destinationAddress the address of the destination for the message - * @param mtiByte - * @param ret <code>SubmitPdu</code> containing the encoded SC - * address, if applicable, and the encoded message - */ - private static ByteArrayOutputStream getSubmitPduHead( - String scAddress, String destinationAddress, byte mtiByte, - boolean statusReportRequested, SubmitPdu ret) { - ByteArrayOutputStream bo = new ByteArrayOutputStream( - MAX_USER_DATA_BYTES + 40); - - // SMSC address with length octet, or 0 - if (scAddress == null) { - ret.encodedScAddress = null; + if (PHONE_TYPE_CDMA == activePhone) { + spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress, + destinationAddress, destinationPort, data, statusReportRequested); } else { - ret.encodedScAddress = PhoneNumberUtils.networkPortionToCalledPartyBCDWithLength( - scAddress); - } - - // TP-Message-Type-Indicator (and friends) - if (statusReportRequested) { - // Set TP-Status-Report-Request bit. - mtiByte |= 0x20; - if (Config.LOGD) Log.d(LOG_TAG, "SMS status report requested"); - } - bo.write(mtiByte); - - // space for TP-Message-Reference - bo.write(0); - - byte[] daBytes; - - daBytes = PhoneNumberUtils.networkPortionToCalledPartyBCD(destinationAddress); - - // destination address length in BCD digits, ignoring TON byte and pad - // TODO Should be better. - bo.write((daBytes.length - 1) * 2 - - ((daBytes[daBytes.length - 1] & 0xf0) == 0xf0 ? 1 : 0)); - - // destination address - bo.write(daBytes, 0, daBytes.length); - - // TP-Protocol-Identifier - bo.write(0); - return bo; - } - - static class PduParser { - byte pdu[]; - - int cur; - - SmsHeader userDataHeader; - - byte[] userData; - - int mUserDataSeptetPadding; - - int mUserDataSize; - - PduParser(String s) { - this(SimUtils.hexStringToBytes(s)); - } - - PduParser(byte[] pdu) { - this.pdu = pdu; - cur = 0; - mUserDataSeptetPadding = 0; - } - - /** - * Parse and return the SC address prepended to SMS messages coming via - * the TS 27.005 / AT interface. Returns null on invalid address - */ - String getSCAddress() { - int len; - String ret; - - // length of SC Address - len = getByte(); - - if (len == 0) { - // no SC address - ret = null; - } else { - // SC address - try { - ret = PhoneNumberUtils - .calledPartyBCDToString(pdu, cur, len); - } catch (RuntimeException tr) { - Log.d(LOG_TAG, "invalid SC address: ", tr); - ret = null; - } - } - - cur += len; - - return ret; - } - - /** - * returns non-sign-extended byte value - */ - int getByte() { - return pdu[cur++] & 0xff; - } - - /** - * Any address except the SC address (eg, originating address) See TS - * 23.040 9.1.2.5 - */ - SmsAddress getAddress() { - SmsAddress ret; - - // "The Address-Length field is an integer representation of - // the number field, i.e. excludes any semi octet containing only - // fill bits." - // The TOA field is not included as part of this - int addressLength = pdu[cur] & 0xff; - int lengthBytes = 2 + (addressLength + 1) / 2; - - ret = new SmsAddress(pdu, cur, lengthBytes); - - cur += lengthBytes; - - return ret; - } - - /** - * Parses an SC timestamp and returns a currentTimeMillis()-style - * timestamp - */ - - long getSCTimestampMillis() { - // TP-Service-Centre-Time-Stamp - int year = SimUtils.bcdByteToInt(pdu[cur++]); - int month = SimUtils.bcdByteToInt(pdu[cur++]); - int day = SimUtils.bcdByteToInt(pdu[cur++]); - int hour = SimUtils.bcdByteToInt(pdu[cur++]); - int minute = SimUtils.bcdByteToInt(pdu[cur++]); - int second = SimUtils.bcdByteToInt(pdu[cur++]); - - // For the timezone, the most significant bit of the - // least signficant nibble is the sign byte - // (meaning the max range of this field is 79 quarter-hours, - // which is more than enough) - - byte tzByte = pdu[cur++]; - - // Mask out sign bit. - int timezoneOffset = SimUtils - .bcdByteToInt((byte) (tzByte & (~0x08))); - - timezoneOffset = ((tzByte & 0x08) == 0) ? timezoneOffset - : -timezoneOffset; - - Time time = new Time(Time.TIMEZONE_UTC); - - // It's 2006. Should I really support years < 2000? - time.year = year >= 90 ? year + 1900 : 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) - (timezoneOffset * 15 * 60 * 1000); - } - - /** - * Pulls the user data out of the PDU, and separates the payload from - * the header if there is one. - * - * @param hasUserDataHeader true if there is a user data header - * @param dataInSeptets true if the data payload is in septets instead - * of octets - * @return the number of septets or octets in the user data payload - */ - int constructUserData(boolean hasUserDataHeader, boolean dataInSeptets) - { - int offset = cur; - int userDataLength = pdu[offset++] & 0xff; - int headerSeptets = 0; - - if (hasUserDataHeader) { - int userDataHeaderLength = pdu[offset++] & 0xff; - - byte[] udh = new byte[userDataHeaderLength]; - System.arraycopy(pdu, offset, udh, 0, userDataHeaderLength); - userDataHeader = SmsHeader.parse(udh); - offset += userDataHeaderLength; - - int headerBits = (userDataHeaderLength + 1) * 8; - headerSeptets = headerBits / 7; - headerSeptets += (headerBits % 7) > 0 ? 1 : 0; - mUserDataSeptetPadding = (headerSeptets * 7) - headerBits; - } - - /* - * Here we just create the user data length to be the remainder of - * the pdu minus the user data hearder. This is because the count - * could mean the number of uncompressed sepets if the userdata is - * encoded in 7-bit. - */ - userData = new byte[pdu.length - offset]; - System.arraycopy(pdu, offset, userData, 0, userData.length); - cur = offset; - - if (dataInSeptets) { - // Return the number of septets - int count = userDataLength - headerSeptets; - // If count < 0, return 0 (means UDL was probably incorrect) - return count < 0 ? 0 : count; - } else { - // Return the number of octets - return userData.length; - } - } - - /** - * Returns the user data payload, not including the headers - * - * @return the user data payload, not including the headers - */ - byte[] getUserData() { - return userData; - } - - /** - * Returns the number of padding bits at the begining of the user data - * array before the start of the septets. - * - * @return the number of padding bits at the begining of the user data - * array before the start of the septets - */ - int getUserDataSeptetPadding() { - return mUserDataSeptetPadding; + spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress, + destinationAddress, destinationPort, data, statusReportRequested); } - /** - * Returns an object representing the user data headers - * - * @return an object representing the user data headers - * - * {@hide} - */ - SmsHeader getUserDataHeader() { - return userDataHeader; - } - -/* - XXX Not sure what this one is supposed to be doing, and no one is using - it. - String getUserDataGSM8bit() { - // System.out.println("remainder of pud:" + - // HexDump.dumpHexString(pdu, cur, pdu.length - cur)); - int count = pdu[cur++] & 0xff; - int size = pdu[cur++]; - - // skip over header for now - cur += size; - - if (pdu[cur - 1] == 0x01) { - int tid = pdu[cur++] & 0xff; - int type = pdu[cur++] & 0xff; - - size = pdu[cur++] & 0xff; - - int i = cur; - - while (pdu[i++] != '\0') { - } - - int length = i - cur; - String mimeType = new String(pdu, cur, length); - - cur += length; - - if (false) { - System.out.println("tid = 0x" + HexDump.toHexString(tid)); - System.out.println("type = 0x" + HexDump.toHexString(type)); - System.out.println("header size = " + size); - System.out.println("mimeType = " + mimeType); - System.out.println("remainder of header:" + - HexDump.dumpHexString(pdu, cur, (size - mimeType.length()))); - } - - cur += size - mimeType.length(); - - // System.out.println("data count = " + count + " cur = " + cur - // + " :" + HexDump.dumpHexString(pdu, cur, pdu.length - cur)); - - MMSMessage msg = MMSMessage.parseEncoding(mContext, pdu, cur, - pdu.length - cur); - } else { - System.out.println(new String(pdu, cur, pdu.length - cur - 1)); - } - - return SimUtils.bytesToHexString(pdu); - } -*/ - - /** - * Interprets the user data payload as pack GSM 7bit characters, and - * decodes them into a String. - * - * @param septetCount the number of septets in the user data payload - * @return a String with the decoded characters - */ - String getUserDataGSM7Bit(int septetCount) { - String ret; - - ret = GsmAlphabet.gsm7BitPackedToString(pdu, cur, septetCount, - mUserDataSeptetPadding); - - cur += (septetCount * 7) / 8; - - return ret; - } - - /** - * Interprets the user data payload as UCS2 characters, and - * decodes them into a String. - * - * @param byteCount the number of bytes in the user data payload - * @return a String with the decoded characters - */ - String getUserDataUCS2(int byteCount) { - String ret; - - try { - ret = new String(pdu, cur, byteCount, "utf-16"); - } catch (UnsupportedEncodingException ex) { - ret = ""; - Log.e(LOG_TAG, "implausible UnsupportedEncodingException", ex); - } - - cur += byteCount; - return ret; - } - - boolean moreDataPresent() { - return (pdu.length > cur); - } + 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 scAddress; + 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() { - if (originatingAddress == null) { - return null; - } - - return originatingAddress.getAddressString(); + 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() { - if (isEmail) { - return emailFrom; - } else { - return getOriginatingAddress(); - } + 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 messageBody; + return mWrappedSmsMessage.getMessageBody(); } /** * Returns the class of this message. + * @deprecated Use android.telephony.SmsMessage. */ + @Deprecated public MessageClass getMessageClass() { - return messageClass; + 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() { - if (isEmail) { - return emailBody; - } else { - return getMessageBody(); - } + 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 pseudoSubject == null ? "" : pseudoSubject; + return mWrappedSmsMessage.getPseudoSubject(); } /** * Returns the service centre timestamp in currentTimeMillis() format + * @deprecated Use android.telephony.SmsMessage. */ + @Deprecated public long getTimestampMillis() { - return scTimeMillis; + return mWrappedSmsMessage.getTimestampMillis(); } /** @@ -1120,129 +521,114 @@ public class SmsMessage { * * @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 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 emailBody; + 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 emailFrom; + return mWrappedSmsMessage.getEmailFrom(); } /** * Get protocol identifier. + * @deprecated Use android.telephony.SmsMessage. */ + @Deprecated public int getProtocolIdentifier() { - return protocolIdentifier; + return mWrappedSmsMessage.getProtocolIdentifier(); } /** - * See TS 23.040 9.2.3.9 returns true if this is a "replace short message" - * SMS + * 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 (protocolIdentifier & 0xc0) == 0x40 - && (protocolIdentifier & 0x3f) > 0 - && (protocolIdentifier & 0x3f) < 8; + 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 + * @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 originatingAddress.isCphsVoiceMessageClear() - || originatingAddress.isCphsVoiceMessageSet(); + 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() { - if (isMwi && (mwiSense == false)) { - return true; - } - - return originatingAddress != null - && originatingAddress.isCphsVoiceMessageClear(); + 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() { - if (isMwi && (mwiSense == true)) { - return true; - } - - return originatingAddress != null - && originatingAddress.isCphsVoiceMessageSet(); + 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() { - if (isMwi && mwiDontStore) { - return true; - } - - if (isCphsMwiMessage()) { - // See CPHS 4.2 Section B.4.2.1 - // If the user data is a single space char, do not store - // the message. Otherwise, store and display as usual - if (" ".equals(getMessageBody())) { - ; - } - return true; - } - - return false; + return mWrappedSmsMessage.isMwiDontStore(); } /** - * returns the user data section minus the user data header if one was - * present. + * returns the user data section minus the user data header if one was present. + * @deprecated Use android.telephony.SmsMessage. */ + @Deprecated public byte[] getUserData() { - return userData; + return mWrappedSmsMessage.getUserData(); } - /** - * Returns an object representing the user data header - * - * @return an object representing the user data header - * - * {@hide} - */ - public SmsHeader getUserDataHeader() { - return userDataHeader; - } + /* 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 mPdu; + return mWrappedSmsMessage.getPdu(); } /** @@ -1254,369 +640,108 @@ public class SmsMessage { * 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 statusOnSim; + 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 indexOnSim; + 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 previousely + * 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 for a description of other possible - * values. + * 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 status; + return mWrappedSmsMessage.getStatus(); } /** * Return true iff the message is a SMS-STATUS-REPORT message. + * @deprecated Use android.telephony.SmsMessage. */ + @Deprecated public boolean isStatusReportMessage() { - return isStatusReportMessage; + return mWrappedSmsMessage.isStatusReportMessage(); } /** * Returns true iff the <code>TP-Reply-Path</code> bit is set in * this message. + * @deprecated Use android.telephony.SmsMessage. */ + @Deprecated public boolean isReplyPathPresent() { - return replyPathPresent; - } - - /** - * TS 27.005 3.1, <pdu> definition "In the case of SMS: 3GPP TS 24.011 [6] - * SC address followed by 3GPP TS 23.040 [3] TPDU in hexadecimal format: - * ME/TA converts each octet of TP data unit into two IRA character long - * hexad number (e.g. octet with integer value 42 is presented to TE as two - * characters 2A (IRA 50 and 65))" ...in the case of cell broadcast, - * something else... - */ - private void parsePdu(byte[] pdu) { - mPdu = pdu; - // Log.d(LOG_TAG, "raw sms mesage:"); - // Log.d(LOG_TAG, s); - - PduParser p = new PduParser(pdu); - - scAddress = p.getSCAddress(); - - if (scAddress != null) { - if (Config.LOGD) Log.d(LOG_TAG, "SMS SC address: " + scAddress); - } - - // TODO(mkf) support reply path, user data header indicator - - // TP-Message-Type-Indicator - // 9.2.3 - int firstByte = p.getByte(); - - mti = firstByte & 0x3; - switch (mti) { - // TP-Message-Type-Indicator - // 9.2.3 - case 0: - parseSmsDeliver(p, firstByte); - break; - case 2: - parseSmsStatusReport(p, firstByte); - break; - default: - // TODO(mkf) the rest of these - throw new RuntimeException("Unsupported message type"); - } - } - - /** - * Parses a SMS-STATUS-REPORT message. - * - * @param p A PduParser, cued past the first byte. - * @param firstByte The first byte of the PDU, which contains MTI, etc. - */ - private void parseSmsStatusReport(PduParser p, int firstByte) { - isStatusReportMessage = true; - - // TP-Status-Report-Qualifier bit == 0 for SUBMIT - forSubmit = (firstByte & 0x20) == 0x00; - // TP-Message-Reference - messageRef = p.getByte(); - // TP-Recipient-Address - recipientAddress = p.getAddress(); - // TP-Service-Centre-Time-Stamp - scTimeMillis = p.getSCTimestampMillis(); - // TP-Discharge-Time - dischargeTimeMillis = p.getSCTimestampMillis(); - // TP-Status - status = p.getByte(); - - // The following are optional fields that may or may not be present. - if (p.moreDataPresent()) { - // TP-Parameter-Indicator - int extraParams = p.getByte(); - int moreExtraParams = extraParams; - while ((moreExtraParams & 0x80) != 0) { - // We only know how to parse a few extra parameters, all - // indicated in the first TP-PI octet, so skip over any - // additional TP-PI octets. - moreExtraParams = p.getByte(); - } - // TP-Protocol-Identifier - if ((extraParams & 0x01) != 0) { - protocolIdentifier = p.getByte(); - } - // TP-Data-Coding-Scheme - if ((extraParams & 0x02) != 0) { - dataCodingScheme = p.getByte(); - } - // TP-User-Data-Length (implies existence of TP-User-Data) - if ((extraParams & 0x04) != 0) { - boolean hasUserDataHeader = (firstByte & 0x40) == 0x40; - parseUserData(p, hasUserDataHeader); - } - } - } - - private void parseSmsDeliver(PduParser p, int firstByte) { - replyPathPresent = (firstByte & 0x80) == 0x80; - - originatingAddress = p.getAddress(); - - if (originatingAddress != null) { - if (Config.LOGV) Log.v(LOG_TAG, "SMS originating address: " - + originatingAddress.address); - } - - // TP-Protocol-Identifier (TP-PID) - // TS 23.040 9.2.3.9 - protocolIdentifier = p.getByte(); - - // TP-Data-Coding-Scheme - // see TS 23.038 - dataCodingScheme = p.getByte(); - - if (Config.LOGV) { - Log.v(LOG_TAG, "SMS TP-PID:" + protocolIdentifier - + " data coding scheme: " + dataCodingScheme); - } - - scTimeMillis = p.getSCTimestampMillis(); - - if (Config.LOGD) Log.d(LOG_TAG, "SMS SC timestamp: " + scTimeMillis); - - boolean hasUserDataHeader = (firstByte & 0x40) == 0x40; - - parseUserData(p, hasUserDataHeader); + return mWrappedSmsMessage.isReplyPathPresent(); } - /** - * Parses the User Data of an SMS. - * - * @param p The current PduParser. - * @param hasUserDataHeader Indicates whether a header is present in the - * User Data. + /** 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 void parseUserData(PduParser p, boolean hasUserDataHeader) { - boolean hasMessageClass = false; - boolean userDataCompressed = false; - - int encodingType = ENCODING_UNKNOWN; - - // Look up the data encoding scheme - if ((dataCodingScheme & 0x80) == 0) { - // Bits 7..4 == 0xxx - automaticDeletion = (0 != (dataCodingScheme & 0x40)); - userDataCompressed = (0 != (dataCodingScheme & 0x20)); - hasMessageClass = (0 != (dataCodingScheme & 0x10)); - - if (userDataCompressed) { - Log.w(LOG_TAG, "4 - Unsupported SMS data coding scheme " - + "(compression) " + (dataCodingScheme & 0xff)); - } else { - switch ((dataCodingScheme >> 2) & 0x3) { - case 0: // GSM 7 bit default alphabet - encodingType = ENCODING_7BIT; - break; - - case 2: // UCS 2 (16bit) - encodingType = ENCODING_16BIT; - break; - - case 1: // 8 bit data - case 3: // reserved - Log.w(LOG_TAG, "1 - Unsupported SMS data coding scheme " - + (dataCodingScheme & 0xff)); - encodingType = ENCODING_8BIT; - break; - } - } - } else if ((dataCodingScheme & 0xf0) == 0xf0) { - automaticDeletion = false; - hasMessageClass = true; - userDataCompressed = false; - - if (0 == (dataCodingScheme & 0x04)) { - // GSM 7 bit default alphabet - encodingType = ENCODING_7BIT; - } else { - // 8 bit data - encodingType = ENCODING_8BIT; - } - } else if ((dataCodingScheme & 0xF0) == 0xC0 - || (dataCodingScheme & 0xF0) == 0xD0 - || (dataCodingScheme & 0xF0) == 0xE0) { - // 3GPP TS 23.038 V7.0.0 (2006-03) section 4 - - // 0xC0 == 7 bit, don't store - // 0xD0 == 7 bit, store - // 0xE0 == UCS-2, store - - if ((dataCodingScheme & 0xF0) == 0xE0) { - encodingType = ENCODING_16BIT; - } else { - encodingType = ENCODING_7BIT; - } - - userDataCompressed = false; - boolean active = ((dataCodingScheme & 0x08) == 0x08); - - // bit 0x04 reserved - - if ((dataCodingScheme & 0x03) == 0x00) { - isMwi = true; - mwiSense = active; - mwiDontStore = ((dataCodingScheme & 0xF0) == 0xC0); - } else { - isMwi = false; - - Log.w(LOG_TAG, "MWI for fax, email, or other " - + (dataCodingScheme & 0xff)); - } + private static final SmsMessageBase getSmsFacility(){ + int activePhone = TelephonyManager.getDefault().getPhoneType(); + if (PHONE_TYPE_CDMA == activePhone) { + return new com.android.internal.telephony.cdma.SmsMessage(); } else { - Log.w(LOG_TAG, "3 - Unsupported SMS data coding scheme " - + (dataCodingScheme & 0xff)); - } - - // set both the user data and the user data header. - int count = p.constructUserData(hasUserDataHeader, - encodingType == ENCODING_7BIT); - this.userData = p.getUserData(); - this.userDataHeader = p.getUserDataHeader(); - - switch (encodingType) { - case ENCODING_UNKNOWN: - case ENCODING_8BIT: - messageBody = null; - break; - - case ENCODING_7BIT: - messageBody = p.getUserDataGSM7Bit(count); - break; - - case ENCODING_16BIT: - messageBody = p.getUserDataUCS2(count); - break; - } - - if (Config.LOGV) Log.v(LOG_TAG, "SMS message body (raw): '" + messageBody + "'"); - - if (messageBody != null) { - parseMessageBody(); - } - - if (!hasMessageClass) { - messageClass = MessageClass.UNKNOWN; - } else { - switch (dataCodingScheme & 0x3) { - case 0: - messageClass = MessageClass.CLASS_0; - break; - case 1: - messageClass = MessageClass.CLASS_1; - break; - case 2: - messageClass = MessageClass.CLASS_2; - break; - case 3: - messageClass = MessageClass.CLASS_3; - break; - } - } - } - - private void parseMessageBody() { - if (originatingAddress.couldBeEmailGateway()) { - extractEmailAddressFromMessageBody(); - } - } - - /** - * Try to parse this message as an email gateway message -> Neither - * of the standard ways are currently supported: There are two ways - * specified in TS 23.040 Section 3.8 (not supported via this mechanism) - - * SMS message "may have its TP-PID set for internet electronic mail - MT - * SMS format: [<from-address><space>]<message> - "Depending on the - * nature of the gateway, the destination/origination address is either - * derived from the content of the SMS TP-OA or TP-DA field, or the - * TP-OA/TP-DA field contains a generic gateway address and the to/from - * address is added at the beginning as shown above." - multiple addreses - * separated by commas, no spaces - subject field delimited by '()' or '##' - * and '#' Section 9.2.3.24.11 - */ - private void extractEmailAddressFromMessageBody() { - - /* - * a little guesswork here. I haven't found doc for this. - * the format could be either - * - * 1. [x@y][ ]/[subject][ ]/[body] - * -or- - * 2. [x@y][ ]/[body] - */ - int slash = 0, slash2 = 0, atSymbol = 0; - - try { - slash = messageBody.indexOf(" /"); - if (slash == -1) { - return; - } - - atSymbol = messageBody.indexOf('@'); - if (atSymbol == -1 || atSymbol > slash) { - return; - } - - emailFrom = messageBody.substring(0, slash); - - slash2 = messageBody.indexOf(" /", slash + 2); - - if (slash2 == -1) { - pseudoSubject = null; - emailBody = messageBody.substring(slash + 2); - } else { - pseudoSubject = messageBody.substring(slash + 2, slash2); - emailBody = messageBody.substring(slash2 + 2); - } - - isEmail = true; - } catch (Exception ex) { - Log.w(LOG_TAG, - "extractEmailAddressFromMessageBody: exception slash=" - + slash + ", atSymbol=" + atSymbol + ", slash2=" - + slash2, ex); + return new com.android.internal.telephony.gsm.SmsMessage(); } } - } + |