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

Commit 0e551682 authored by Sridhar Dubbaka's avatar Sridhar Dubbaka Committed by Ethan Chen
Browse files

Telephony:Copying MO/MT SMS of SUB2 to its SIM memory is fail in C+G.

Fix: In C+G configuration, While copying MO/MT SMS of SUB2 to its
SIM memory, in process of getting current Phonetype is returned with
default sub's(i.e,SUB1's)Phonetype which is CDMA type.
To fix this, get current Phonetype based on subscription id.

Change-Id: I394eadfb091c4901a553cf66192e8ee965b69eda
CRs-Fixed: 689036
parent 6ce1ab0e
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -550,7 +550,7 @@ public class MSimSmsManager {
            // ignore it
        }

        return createMessageListFromRawRecords(records);
        return createMessageListFromRawRecords(records, subscription);
    }

    /**
@@ -702,7 +702,8 @@ public class MSimSmsManager {
     *   <code>getAllMessagesFromIcc</code>
     * @return <code>ArrayList</code> of <code>SmsMessage</code> objects.
     */
    private static ArrayList<SmsMessage> createMessageListFromRawRecords(List<SmsRawData> records) {
    private static ArrayList<SmsMessage> createMessageListFromRawRecords(List<SmsRawData> records,
            int subscription) {
        ArrayList<SmsMessage> messages = new ArrayList<SmsMessage>();
        if (records != null) {
            int count = records.size();
@@ -710,7 +711,8 @@ public class MSimSmsManager {
                SmsRawData data = records.get(i);
                // List contains all records, including "free" records (null)
                if (data != null) {
                    SmsMessage sms = SmsMessage.createFromEfRecord(i+1, data.getBytes());
                    SmsMessage sms = SmsMessage.createFromEfRecord(i+1, data.getBytes(),
                            subscription);
                    if (sms != null) {
                        messages.add(sms);
                    }
+85 −0
Original line number Diff line number Diff line
@@ -264,6 +264,31 @@ public class SmsMessage {
        return wrappedMessage != null ? new SmsMessage(wrappedMessage) : null;
    }

    /**
     * Create an SmsMessage from an SMS EF record.
     *
     * @param index Index of SMS record. This should be index in ArrayList
     *              returned by SmsManager.getAllMessagesFromSim + 1.
     * @param data Record data.
     * @param sub Subscription index of the SMS
     * @return An SmsMessage representing the record.
     *
     * @hide
     */
    public static SmsMessage createFromEfRecord(int index, byte[] data, int sub) {
        SmsMessageBase wrappedMessage;

        if (isCdmaVoice(sub)) {
            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;
    }

    /**
     * Get the TP-Layer-Length for the given SMS-SUBMIT PDU Basically, the
     * length in bytes (not hex chars) less the SMSC header
@@ -456,6 +481,33 @@ public class SmsMessage {
        return new SubmitPdu(spb);
    }

    /**
     * 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.
     *
     * @param scAddress Service Centre address.  Null means use default.
     * @param sub Subscription of the message
     * @return a <code>SubmitPdu</code> containing the encoded SC
     *         address, if applicable, and the encoded message.
     *         Returns null on encode error.
     *
     * @hide
     */
    public static SubmitPdu getSubmitPdu(String scAddress,
            String destinationAddress, String message, boolean statusReportRequested, int sub) {
        SubmitPduBase spb;

        if (useCdmaFormatForMoSms(sub)) {
            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);
    }

    /**
     * Get an SMS-SUBMIT PDU for a data message to a destination address &amp; port.
     * This method will not attempt to use any GSM national language 7 bit encodings.
@@ -746,6 +798,26 @@ public class SmsMessage {
        return (SmsConstants.FORMAT_3GPP2.equals(SmsManager.getDefault().getImsSmsFormat()));
    }

    /**
     * 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.
     *
     * @param sub Subscription for which phone type is returned.
     *
     * @return true if Cdma format should be used for MO SMS, false otherwise.
     *
     * @hide
     */
    private static boolean useCdmaFormatForMoSms(int sub) {
        if (!MSimSmsManager.getDefault().isImsSmsSupported(sub)) {
            // use Voice technology to determine SMS format.
            return isCdmaVoice(sub);
        }
        // IMS is registered with SMS support, check the SMS format supported
        return (SmsConstants.FORMAT_3GPP2.equals(MSimSmsManager.getDefault().getImsSmsFormat(sub)));
    }

    /**
     * Determines whether or not to current phone type is cdma.
     *
@@ -756,6 +828,19 @@ public class SmsMessage {
        return (PHONE_TYPE_CDMA == activePhone);
    }

    /**
     * Determines whether or not to current phone type is cdma for given susbcription.
     *
     * @param subscription Subscription for which phone type is returned
     * @return true if current phone type is cdma, false otherwise.
     *
     * @hide
     */
    private static boolean isCdmaVoice(int subscription) {
        int activePhone = MSimTelephonyManager.getDefault().getCurrentPhoneType(subscription);
        return (PHONE_TYPE_CDMA == activePhone);
    }

    /**
     * {@hide}
     * Returns the recipient address(receiver) of this SMS message in String form or null if