Merge "Fallback to other format for decoding pdu if needed."
am: 56a6b65322
Change-Id: I70595192f02e9797d5b019cf7d46b10aac6b4985
This commit is contained in:
@@ -187,15 +187,7 @@ public class SmsMessage {
|
|||||||
int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
|
int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
|
||||||
String format = (PHONE_TYPE_CDMA == activePhone) ?
|
String format = (PHONE_TYPE_CDMA == activePhone) ?
|
||||||
SmsConstants.FORMAT_3GPP2 : SmsConstants.FORMAT_3GPP;
|
SmsConstants.FORMAT_3GPP2 : SmsConstants.FORMAT_3GPP;
|
||||||
message = createFromPdu(pdu, format);
|
return 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -211,11 +203,18 @@ public class SmsMessage {
|
|||||||
* {@link android.provider.Telephony.Sms.Intents#SMS_RECEIVED_ACTION} intent
|
* {@link android.provider.Telephony.Sms.Intents#SMS_RECEIVED_ACTION} intent
|
||||||
*/
|
*/
|
||||||
public static SmsMessage createFromPdu(byte[] pdu, String format) {
|
public static SmsMessage createFromPdu(byte[] pdu, String format) {
|
||||||
SmsMessageBase wrappedMessage;
|
return createFromPdu(pdu, format, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SmsMessage createFromPdu(byte[] pdu, String format,
|
||||||
|
boolean fallbackToOtherFormat) {
|
||||||
if (pdu == null) {
|
if (pdu == null) {
|
||||||
Rlog.i(LOG_TAG, "createFromPdu(): pdu is null");
|
Rlog.i(LOG_TAG, "createFromPdu(): pdu is null");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
SmsMessageBase wrappedMessage;
|
||||||
|
String otherFormat = SmsConstants.FORMAT_3GPP2.equals(format) ? SmsConstants.FORMAT_3GPP :
|
||||||
|
SmsConstants.FORMAT_3GPP2;
|
||||||
if (SmsConstants.FORMAT_3GPP2.equals(format)) {
|
if (SmsConstants.FORMAT_3GPP2.equals(format)) {
|
||||||
wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromPdu(pdu);
|
wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromPdu(pdu);
|
||||||
} else if (SmsConstants.FORMAT_3GPP.equals(format)) {
|
} else if (SmsConstants.FORMAT_3GPP.equals(format)) {
|
||||||
@@ -228,8 +227,12 @@ public class SmsMessage {
|
|||||||
if (wrappedMessage != null) {
|
if (wrappedMessage != null) {
|
||||||
return new SmsMessage(wrappedMessage);
|
return new SmsMessage(wrappedMessage);
|
||||||
} else {
|
} else {
|
||||||
Rlog.e(LOG_TAG, "createFromPdu(): wrappedMessage is null");
|
if (fallbackToOtherFormat) {
|
||||||
return null;
|
return createFromPdu(pdu, otherFormat, false);
|
||||||
|
} else {
|
||||||
|
Rlog.e(LOG_TAG, "createFromPdu(): wrappedMessage is null");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user