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

Commit 6ad5c9d4 authored by zhu youhua's avatar zhu youhua Committed by Linux Build Service Account
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.

Change-Id: Id554430378ae0837d5eba2d2029ead147b8c3e83
CRs-Fixed: 727110
parent 44ddbe73
Loading
Loading
Loading
Loading
+49 −7
Original line number Diff line number Diff line
@@ -454,9 +454,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.getDefaultSmsSubId());
    }

        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 {
@@ -749,12 +768,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.getDefaultSmsSubId());
    }

    /**
     * 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()));
    }

    /**
@@ -763,10 +797,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.getDefaultSmsSubId());
    }

     /**
      * 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}