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

Commit df03aeb3 authored by Chaitanya Saggurthi's avatar Chaitanya Saggurthi
Browse files

Telephony: Fix the failure of copying SMS to SIM card for sub2

While copying SMS of sub2 to its SIM memory, in process of getting
current Phonetype will return default sub's(i.e,sub1's)Phonetype. But
we want to get sub2's Phonetype here.

To fix this, get current Phonetype based on subscription id

Test: manual - Copy SMS to SIM card of sub2

Bug: 35025520
Change-Id: If415530d3f74dd357054cae6eb9c3ce8f7727342
parent df577343
Loading
Loading
Loading
Loading
+49 −7
Original line number Diff line number Diff line
@@ -463,9 +463,28 @@ public class SmsMessage {
     */
    public static SubmitPdu getSubmitPdu(String scAddress,
            String destinationAddress, String message, boolean statusReportRequested) {
        SubmitPduBase spb;
        return getSubmitPdu(scAddress, destinationAddress, message, statusReportRequested,
                SubscriptionManager.getDefaultSmsSubscriptionId());
    }

        if (useCdmaFormatForMoSms()) {
    /**
     * 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 destinationAddress the address of the destination for the message.
     * @param message String representation of the message payload.
     * @param statusReportRequested Indicates whether a report is requested for this message.
     * @param subId 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 subId) {
        SubmitPduBase spb;
        if (useCdmaFormatForMoSms(subId)) {
            spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
                    destinationAddress, message, statusReportRequested, null);
        } else {
@@ -758,12 +777,27 @@ public class SmsMessage {
     * @return true if Cdma format should be used for MO SMS, false otherwise.
     */
    private static boolean useCdmaFormatForMoSms() {
        if (!SmsManager.getDefault().isImsSmsSupported()) {
        // IMS is registered with SMS support, check the SMS format supported
        return useCdmaFormatForMoSms(SubscriptionManager.getDefaultSmsSubscriptionId());
    }

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

    /**
@@ -772,10 +806,18 @@ public class SmsMessage {
     * @return true if current phone type is cdma, false otherwise.
     */
    private static boolean isCdmaVoice() {
        int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
        return (PHONE_TYPE_CDMA == activePhone);
        return isCdmaVoice(SubscriptionManager.getDefaultSmsSubscriptionId());
    }

     /**
      * Determines whether or not to current phone type is cdma
      *
      * @return true if current phone type is cdma, false otherwise.
      */
     private static boolean isCdmaVoice(int subId) {
         int activePhone = TelephonyManager.getDefault().getCurrentPhoneType(subId);
         return (PHONE_TYPE_CDMA == activePhone);
   }
    /**
     * Decide if the carrier supports long SMS.
     * {@hide}