Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e555b6f authored by Amit Mahajan's avatar Amit Mahajan Committed by android-build-merger
Browse files

Merge "Fallback to other format for decoding pdu if needed." am: 56a6b653 am: 66ddf809

am: 90501332

Change-Id: I4afe0494981b3a24a963340eadec09e6a3292428
parents fce424f8 90501332
Loading
Loading
Loading
Loading
+15 −12
Original line number Diff line number Diff line
@@ -187,15 +187,7 @@ public class SmsMessage {
        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;
        return createFromPdu(pdu, format);
    }

    /**
@@ -211,11 +203,18 @@ public class SmsMessage {
     * {@link android.provider.Telephony.Sms.Intents#SMS_RECEIVED_ACTION} intent
     */
    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) {
            Rlog.i(LOG_TAG, "createFromPdu(): pdu is null");
            return null;
        }
        SmsMessageBase wrappedMessage;
        String otherFormat = SmsConstants.FORMAT_3GPP2.equals(format) ? SmsConstants.FORMAT_3GPP :
                SmsConstants.FORMAT_3GPP2;
        if (SmsConstants.FORMAT_3GPP2.equals(format)) {
            wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromPdu(pdu);
        } else if (SmsConstants.FORMAT_3GPP.equals(format)) {
@@ -227,11 +226,15 @@ public class SmsMessage {

        if (wrappedMessage != null) {
            return new SmsMessage(wrappedMessage);
        } else {
            if (fallbackToOtherFormat) {
                return createFromPdu(pdu, otherFormat, false);
            } else {
                Rlog.e(LOG_TAG, "createFromPdu(): wrappedMessage is null");
                return null;
            }
        }
    }

    /**
     * TS 27.005 3.4.1 lines[0] and lines[1] are the two lines read from the