Methods Summary |
---|
public static int[] | calculateLength(java.lang.CharSequence msgBody, boolean use7bitOnly)Calculates the number of SMS's required to encode the message body and
the number of characters remaining until the next message.
// this function is for MO SMS
TextEncodingDetails ted = (useCdmaFormatForMoSms()) ?
com.android.internal.telephony.cdma.SmsMessage.calculateLength(msgBody, use7bitOnly,
true) :
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;
|
public static int[] | calculateLength(java.lang.String messageBody, boolean use7bitOnly)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.
return calculateLength((CharSequence)messageBody, use7bitOnly);
|
public static android.telephony.SmsMessage | createFromEfRecord(int index, byte[] data)Create an SmsMessage from an SMS EF record.
SmsMessageBase wrappedMessage;
if (isCdmaVoice()) {
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;
|
public static android.telephony.SmsMessage | createFromPdu(byte[] pdu)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. Guess format based on Voice
technology first, if it fails use other format.
SmsMessage message = null;
// cdma(3gpp2) vs gsm(3gpp) format info was not given,
// guess from active voice phone type
int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
String format = (PHONE_TYPE_CDMA == activePhone) ?
SmsConstants.FORMAT_3GPP2 : SmsConstants.FORMAT_3GPP;
message = createFromPdu(pdu, format);
if (null == message || null == message.mWrappedSmsMessage) {
// decoding pdu failed based on activePhone type, must be other format
format = (PHONE_TYPE_CDMA == activePhone) ?
SmsConstants.FORMAT_3GPP : SmsConstants.FORMAT_3GPP2;
message = createFromPdu(pdu, format);
}
return message;
|
public static android.telephony.SmsMessage | createFromPdu(byte[] pdu, java.lang.String 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.
SmsMessageBase wrappedMessage;
if (SmsConstants.FORMAT_3GPP2.equals(format)) {
wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromPdu(pdu);
} else if (SmsConstants.FORMAT_3GPP.equals(format)) {
wrappedMessage = com.android.internal.telephony.gsm.SmsMessage.createFromPdu(pdu);
} else {
Rlog.e(LOG_TAG, "createFromPdu(): unsupported message format " + format);
return null;
}
return new SmsMessage(wrappedMessage);
|
public static java.util.ArrayList | fragmentText(java.lang.String text)Divide a message text into several fragments, none bigger than
the maximum SMS message text size.
// This function is for MO SMS
TextEncodingDetails ted = (useCdmaFormatForMoSms()) ?
com.android.internal.telephony.cdma.SmsMessage.calculateLength(text, false, true) :
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 == SmsConstants.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 = SmsConstants.MAX_USER_DATA_SEPTETS - udhLength;
} else {
if (ted.msgCount > 1) {
limit = SmsConstants.MAX_USER_DATA_BYTES_WITH_HEADER;
// If EMS is not supported, break down EMS into single segment SMS
// and add page info " x/y".
// In the case of UCS2 encoding, we need 8 bytes for this,
// but we only have 6 bytes from UDH, so truncate the limit for
// each segment by 2 bytes (1 char).
// Make sure total number of segments is less than 10.
if (!hasEmsSupport() && ted.msgCount < 10) {
limit -= 2;
}
} else {
limit = SmsConstants.MAX_USER_DATA_BYTES;
}
}
String newMsgBody = null;
Resources r = Resources.getSystem();
if (r.getBoolean(com.android.internal.R.bool.config_sms_force_7bit_encoding)) {
newMsgBody = Sms7BitEncodingTranslator.translate(text);
}
if (TextUtils.isEmpty(newMsgBody)) {
newMsgBody = text;
}
int pos = 0; // Index in code units.
int textLen = newMsgBody.length();
ArrayList<String> result = new ArrayList<String>(ted.msgCount);
while (pos < textLen) {
int nextPos = 0; // Counts code units.
if (ted.codeUnitSize == SmsConstants.ENCODING_7BIT) {
if (useCdmaFormatForMoSms() && 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(newMsgBody, pos, limit,
ted.languageTable, ted.languageShiftTable);
}
} else { // Assume unicode.
nextPos = pos + Math.min(limit / 2, textLen - pos);
}
if ((nextPos <= pos) || (nextPos > textLen)) {
Rlog.e(LOG_TAG, "fragmentText failed (" + pos + " >= " + nextPos + " or " +
nextPos + " >= " + textLen + ")");
break;
}
result.add(newMsgBody.substring(pos, nextPos));
pos = nextPos;
}
return result;
|
public java.lang.String | getDisplayMessageBody()Returns the message body, or email message body if this message was from
an email gateway. Returns null if message body unavailable.
return mWrappedSmsMessage.getDisplayMessageBody();
|
public java.lang.String | getDisplayOriginatingAddress()Returns the originating address, or email from address if this message
was from an email gateway. Returns null if originating address
unavailable.
return mWrappedSmsMessage.getDisplayOriginatingAddress();
|
public java.lang.String | getEmailBody()
return mWrappedSmsMessage.getEmailBody();
|
public java.lang.String | getEmailFrom()
return mWrappedSmsMessage.getEmailFrom();
|
public int | getIndexOnIcc()Returns the record index of the message on the ICC (1-based index).
return mWrappedSmsMessage.getIndexOnIcc();
|
public int | getIndexOnSim()Returns the record index of the message on the SIM (1-based index).
return mWrappedSmsMessage.getIndexOnIcc();
|
public java.lang.String | getMessageBody()Returns the message body as a String, if it exists and is text based.
return mWrappedSmsMessage.getMessageBody();
|
public android.telephony.SmsMessage$MessageClass | getMessageClass()Returns the class of this message.
switch(mWrappedSmsMessage.getMessageClass()) {
case CLASS_0: return MessageClass.CLASS_0;
case CLASS_1: return MessageClass.CLASS_1;
case CLASS_2: return MessageClass.CLASS_2;
case CLASS_3: return MessageClass.CLASS_3;
default: return MessageClass.UNKNOWN;
}
|
public java.lang.String | getOriginatingAddress()Returns the originating address (sender) of this SMS message in String
form or null if unavailable
return mWrappedSmsMessage.getOriginatingAddress();
|
public byte[] | getPdu()Returns the raw PDU for the message.
return mWrappedSmsMessage.getPdu();
|
public int | getProtocolIdentifier()Get protocol identifier.
return mWrappedSmsMessage.getProtocolIdentifier();
|
public java.lang.String | getPseudoSubject()Unofficial convention of a subject line enclosed in parens empty string
if not present
return mWrappedSmsMessage.getPseudoSubject();
|
public java.lang.String | getServiceCenterAddress()Returns the address of the SMS service center that relayed this message
or null if there is none.
return mWrappedSmsMessage.getServiceCenterAddress();
|
public int | getStatus()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 mWrappedSmsMessage.getStatus();
|
public int | getStatusOnIcc()Returns the status of the message on the ICC (read, unread, sent, unsent).
return mWrappedSmsMessage.getStatusOnIcc();
|
public int | getStatusOnSim()Returns the status of the message on the SIM (read, unread, sent, unsent).
return mWrappedSmsMessage.getStatusOnIcc();
|
public int | getSubId()get Subscription information
return mSubId;
|
public static android.telephony.SmsMessage$SubmitPdu | getSubmitPdu(java.lang.String scAddress, java.lang.String destinationAddress, java.lang.String message, boolean statusReportRequested)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.
SubmitPduBase spb;
if (useCdmaFormatForMoSms()) {
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);
|
public static android.telephony.SmsMessage$SubmitPdu | getSubmitPdu(java.lang.String scAddress, java.lang.String destinationAddress, short destinationPort, byte[] data, boolean statusReportRequested)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.
SubmitPduBase spb;
if (useCdmaFormatForMoSms()) {
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);
|
public static int | getTPLayerLengthForPDU(java.lang.String pdu)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.
if (isCdmaVoice()) {
return com.android.internal.telephony.cdma.SmsMessage.getTPLayerLengthForPDU(pdu);
} else {
return com.android.internal.telephony.gsm.SmsMessage.getTPLayerLengthForPDU(pdu);
}
|
public long | getTimestampMillis()Returns the service centre timestamp in currentTimeMillis() format
return mWrappedSmsMessage.getTimestampMillis();
|
public byte[] | getUserData()returns the user data section minus the user data header if one was
present.
return mWrappedSmsMessage.getUserData();
|
public static boolean | hasEmsSupport()Decide if the carrier supports long SMS.
{@hide}
if (!isNoEmsSupportConfigListExisted()) {
return true;
}
String simOperator;
String gid;
final long identity = Binder.clearCallingIdentity();
try {
simOperator = TelephonyManager.getDefault().getSimOperatorNumeric();
gid = TelephonyManager.getDefault().getGroupIdLevel1();
} finally {
Binder.restoreCallingIdentity(identity);
}
for (NoEmsSupportConfig currentConfig : mNoEmsSupportConfigList) {
if (simOperator.startsWith(currentConfig.mOperatorNumber) &&
(TextUtils.isEmpty(currentConfig.mGid1) ||
(!TextUtils.isEmpty(currentConfig.mGid1)
&& currentConfig.mGid1.equalsIgnoreCase(gid)))) {
return false;
}
}
return true;
|
private static boolean | isCdmaVoice()Determines whether or not to current phone type is cdma.
int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
return (PHONE_TYPE_CDMA == activePhone);
|
public boolean | isCphsMwiMessage()Returns true for CPHS MWI toggle message.
return mWrappedSmsMessage.isCphsMwiMessage();
|
public boolean | isEmail()Returns true if message is an email.
return mWrappedSmsMessage.isEmail();
|
public boolean | isMWIClearMessage()returns true if this message is a CPHS voicemail / message waiting
indicator (MWI) clear message
return mWrappedSmsMessage.isMWIClearMessage();
|
public boolean | isMWISetMessage()returns true if this message is a CPHS voicemail / message waiting
indicator (MWI) set message
return mWrappedSmsMessage.isMWISetMessage();
|
public boolean | isMwiDontStore()returns true if this message is a "Message Waiting Indication Group:
Discard Message" notification and should not be stored.
return mWrappedSmsMessage.isMwiDontStore();
|
private static boolean | isNoEmsSupportConfigListExisted()
if (!mIsNoEmsSupportConfigListLoaded) {
Resources r = Resources.getSystem();
if (r != null) {
String[] listArray = r.getStringArray(
com.android.internal.R.array.no_ems_support_sim_operators);
if ((listArray != null) && (listArray.length > 0)) {
mNoEmsSupportConfigList = new NoEmsSupportConfig[listArray.length];
for (int i=0; i<listArray.length; i++) {
mNoEmsSupportConfigList[i] = new NoEmsSupportConfig(listArray[i].split(";"));
}
}
mIsNoEmsSupportConfigListLoaded = true;
}
}
if (mNoEmsSupportConfigList != null && mNoEmsSupportConfigList.length != 0) {
return true;
}
return false;
|
public boolean | isReplace()See TS 23.040 9.2.3.9 returns true if this is a "replace short message"
SMS
return mWrappedSmsMessage.isReplace();
|
public boolean | isReplyPathPresent()Returns true iff the TP-Reply-Path bit is set in
this message.
return mWrappedSmsMessage.isReplyPathPresent();
|
public boolean | isStatusReportMessage()Return true iff the message is a SMS-STATUS-REPORT message.
return mWrappedSmsMessage.isStatusReportMessage();
|
public static android.telephony.SmsMessage | newFromCMT(java.lang.String[] lines)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}
// received SMS in 3GPP format
SmsMessageBase wrappedMessage =
com.android.internal.telephony.gsm.SmsMessage.newFromCMT(lines);
return new SmsMessage(wrappedMessage);
|
public static android.telephony.SmsMessage | newFromParcel(android.os.Parcel p)
// received SMS in 3GPP2 format
SmsMessageBase wrappedMessage =
com.android.internal.telephony.cdma.SmsMessage.newFromParcel(p);
return new SmsMessage(wrappedMessage);
|
public void | setSubId(int subId)set Subscription information
mSubId = subId;
|
public static boolean | shouldAppendPageNumberAsPrefix()Check where to add " x/y" in each SMS segment, begin or end.
{@hide}
if (!isNoEmsSupportConfigListExisted()) {
return false;
}
String simOperator;
String gid;
final long identity = Binder.clearCallingIdentity();
try {
simOperator = TelephonyManager.getDefault().getSimOperatorNumeric();
gid = TelephonyManager.getDefault().getGroupIdLevel1();
} finally {
Binder.restoreCallingIdentity(identity);
}
for (NoEmsSupportConfig currentConfig : mNoEmsSupportConfigList) {
if (simOperator.startsWith(currentConfig.mOperatorNumber) &&
(TextUtils.isEmpty(currentConfig.mGid1) ||
(!TextUtils.isEmpty(currentConfig.mGid1)
&& currentConfig.mGid1.equalsIgnoreCase(gid)))) {
return currentConfig.mIsPrefix;
}
}
return false;
|
private static boolean | useCdmaFormatForMoSms()Determines whether or not to use CDMA format for MO SMS.
If SMS over IMS is supported, then format is based on IMS SMS format,
otherwise format is based on current phone type.
if (!SmsManager.getDefault().isImsSmsSupported()) {
// use Voice technology to determine SMS format.
return isCdmaVoice();
}
// IMS is registered with SMS support, check the SMS format supported
return (SmsConstants.FORMAT_3GPP2.equals(SmsManager.getDefault().getImsSmsFormat()));
|