Merge "SMS: Add a compatible API getRecipientAddress for 3GPP2 SMS"
This commit is contained in:
@@ -981,4 +981,13 @@ public class SmsMessage {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
* Returns the recipient address(receiver) of this SMS message in String form or null if
|
||||
* unavailable.
|
||||
*/
|
||||
public String getRecipientAddress() {
|
||||
return mWrappedSmsMessage.getRecipientAddress();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,9 @@ public abstract class SmsMessageBase {
|
||||
@UnsupportedAppUsage
|
||||
protected SmsAddress mOriginatingAddress;
|
||||
|
||||
/** {@hide} The address of the receiver */
|
||||
protected SmsAddress mRecipientAddress;
|
||||
|
||||
/** {@hide} The message body as a string. May be null if the message isn't text */
|
||||
@UnsupportedAppUsage
|
||||
protected String mMessageBody;
|
||||
@@ -457,4 +460,17 @@ public abstract class SmsMessageBase {
|
||||
|
||||
return ted;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
* Returns the receiver address of this SMS message in String
|
||||
* form or null if unavailable
|
||||
*/
|
||||
public String getRecipientAddress() {
|
||||
if (mRecipientAddress == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return mRecipientAddress.getAddressString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -601,18 +601,24 @@ public class SmsMessage extends SmsMessageBase {
|
||||
|
||||
} else if (addr.numberMode == CdmaSmsAddress.NUMBER_MODE_DATA_NETWORK) {
|
||||
if (numberType == 2)
|
||||
Rlog.e(LOG_TAG, "TODO: Originating Addr is email id");
|
||||
Rlog.e(LOG_TAG, "TODO: Addr is email id");
|
||||
else
|
||||
Rlog.e(LOG_TAG,
|
||||
"TODO: Originating Addr is data network address");
|
||||
"TODO: Addr is data network address");
|
||||
} else {
|
||||
Rlog.e(LOG_TAG, "Originating Addr is of incorrect type");
|
||||
Rlog.e(LOG_TAG, "Addr is of incorrect type");
|
||||
}
|
||||
} else {
|
||||
Rlog.e(LOG_TAG, "Incorrect Digit mode");
|
||||
}
|
||||
addr.origBytes = data;
|
||||
Rlog.i(LOG_TAG, "Originating Addr=" + addr.toString());
|
||||
Rlog.pii(LOG_TAG, "Addr=" + addr.toString());
|
||||
mOriginatingAddress = addr;
|
||||
if (parameterId == DESTINATION_ADDRESS) {
|
||||
// Original address awlays indicates one sender's address for 3GPP2
|
||||
// Here add recipient address support along with 3GPP
|
||||
mRecipientAddress = addr;
|
||||
}
|
||||
break;
|
||||
case ORIGINATING_SUB_ADDRESS:
|
||||
case DESTINATION_SUB_ADDRESS:
|
||||
@@ -667,7 +673,7 @@ public class SmsMessage extends SmsMessageBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a SMS message from its BearerData stream. (mobile-terminated only)
|
||||
* Parses a SMS message from its BearerData stream.
|
||||
*/
|
||||
public void parseSms() {
|
||||
// Message Waiting Info Record defined in 3GPP2 C.S-0005, 3.7.5.6
|
||||
@@ -697,16 +703,15 @@ public class SmsMessage extends SmsMessageBase {
|
||||
}
|
||||
|
||||
if (mOriginatingAddress != null) {
|
||||
mOriginatingAddress.address = new String(mOriginatingAddress.origBytes);
|
||||
if (mOriginatingAddress.ton == CdmaSmsAddress.TON_INTERNATIONAL_OR_IP) {
|
||||
if (mOriginatingAddress.address.charAt(0) != '+') {
|
||||
mOriginatingAddress.address = "+" + mOriginatingAddress.address;
|
||||
}
|
||||
}
|
||||
decodeSmsDisplayAddress(mOriginatingAddress);
|
||||
if (VDBG) Rlog.v(LOG_TAG, "SMS originating address: "
|
||||
+ mOriginatingAddress.address);
|
||||
}
|
||||
|
||||
if (mRecipientAddress != null) {
|
||||
decodeSmsDisplayAddress(mRecipientAddress);
|
||||
}
|
||||
|
||||
if (mBearerData.msgCenterTimeStamp != null) {
|
||||
mScTimeMillis = mBearerData.msgCenterTimeStamp.toMillis(true);
|
||||
}
|
||||
@@ -731,7 +736,8 @@ public class SmsMessage extends SmsMessageBase {
|
||||
status = mBearerData.errorClass << 8;
|
||||
status |= mBearerData.messageStatus;
|
||||
}
|
||||
} else if (mBearerData.messageType != BearerData.MESSAGE_TYPE_DELIVER) {
|
||||
} else if (mBearerData.messageType != BearerData.MESSAGE_TYPE_DELIVER
|
||||
&& mBearerData.messageType != BearerData.MESSAGE_TYPE_SUBMIT) {
|
||||
throw new RuntimeException("Unsupported message type: " + mBearerData.messageType);
|
||||
}
|
||||
|
||||
@@ -743,6 +749,16 @@ public class SmsMessage extends SmsMessageBase {
|
||||
}
|
||||
}
|
||||
|
||||
private void decodeSmsDisplayAddress(SmsAddress addr) {
|
||||
addr.address = new String(addr.origBytes);
|
||||
if (addr.ton == CdmaSmsAddress.TON_INTERNATIONAL_OR_IP) {
|
||||
if (addr.address.charAt(0) != '+') {
|
||||
addr.address = "+" + addr.address;
|
||||
}
|
||||
}
|
||||
Rlog.pii(LOG_TAG, " decodeSmsDisplayAddress = " + addr.address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a broadcast SMS, possibly containing a CMAS alert.
|
||||
*
|
||||
|
||||
@@ -71,9 +71,6 @@ public class SmsMessage extends SmsMessageBase {
|
||||
// e.g. 23.040 9.2.2.1
|
||||
private boolean mReplyPathPresent = false;
|
||||
|
||||
/** The address of the receiver. */
|
||||
private GsmSmsAddress mRecipientAddress;
|
||||
|
||||
/**
|
||||
* TP-Status - status of a previously submitted SMS.
|
||||
* This field applies to SMS-STATUS-REPORT messages. 0 indicates success;
|
||||
|
||||
Reference in New Issue
Block a user