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

Commit ffcbbb38 authored by Sridhar Dubbaka's avatar Sridhar Dubbaka Committed by Linux Build Service Account
Browse files

MSIM(Telephony):Add changes to SMS APIs as per new SmsManager design

Changed SMS Msim APIs as per new SmsManager design.

Add change to fix for copying MO/MT SMS of SUB2 to its
SIM memory correctly in C+G mode, by calling current Phonetype based
on subscription

Change-Id: Iaee8b93ef373e34ddcc5b7d65365852e470467d4
parent ce87d60a
Loading
Loading
Loading
Loading
+34 −398

File changed.

Preview size limit exceeded, changes collapsed.

+42 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.telephony;
import android.os.Parcel;
import android.telephony.Rlog;
import android.content.res.Resources;
import android.telephony.SubscriptionManager;
import android.text.TextUtils;

import com.android.internal.telephony.GsmAlphabet;
@@ -254,6 +255,32 @@ 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 subId Subscription Id of the SMS
     * @return An SmsMessage representing the record.
     *
     * @hide
     */
    public static SmsMessage createFromEfRecord(int index, byte[] data, long subId) {
        SmsMessageBase wrappedMessage;

        if (isCdmaVoice(subId)) {
            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
@@ -745,12 +772,14 @@ public class SmsMessage {
     * @return true if Cdma format should be used for MO SMS, false otherwise.
     */
    private static boolean useCdmaFormatForMoSms() {
        if (!SmsManager.getDefault().isImsSmsSupported()) {
        SmsManager smsManager = SmsManager.getSmsManagerForSubscriber(
                SubscriptionManager.getDefaultSmsSubId());
        if (!smsManager.isImsSmsSupported()) {
            // use Voice technology to determine SMS format.
            return isCdmaVoice();
        }
        // 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,6 +792,17 @@ public class SmsMessage {
        return (PHONE_TYPE_CDMA == activePhone);
    }

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

    /**
     * Decide if the carrier supports long SMS.
     * {@hide}
+1 −1
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ import java.util.ArrayList;
     */
    @Deprecated
    public final ArrayList<android.telephony.SmsMessage> getAllMessagesFromSim() {
        return android.telephony.SmsManager.getAllMessagesFromIcc();
        return android.telephony.SmsManager.getDefault().getAllMessagesFromIcc();
    }

    /** Free space (TS 51.011 10.5.3).
+11 −10
Original line number Diff line number Diff line
@@ -126,13 +126,13 @@ public class UiccSmsController extends ISms.Stub {
    public void sendDataWithOrigPort(String callingPackage, String destAddr, String scAddr,
            int destPort, int origPort, byte[] data, PendingIntent sentIntent,
            PendingIntent deliveryIntent) {
         sendDataWithOrigPortUsingSubId(getDefaultSmsSubId(), callingPackage, destAddr,
         sendDataWithOrigPortUsingSubscriber(getDefaultSmsSubId(), callingPackage, destAddr,
                 scAddr, destPort, origPort, data, sentIntent, deliveryIntent);
    }

    public void sendDataWithOrigPortUsingSubId(long subId, String callingPackage, String destAddr,
            String scAddr, int destPort, int origPort, byte[] data, PendingIntent sentIntent,
            PendingIntent deliveryIntent) {
    public void sendDataWithOrigPortUsingSubscriber(long subId, String callingPackage,
            String destAddr, String scAddr, int destPort, int origPort, byte[] data,
            PendingIntent sentIntent, PendingIntent deliveryIntent) {
        IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId);
        if (iccSmsIntMgr != null) {
            iccSmsIntMgr.sendDataWithOrigPort(callingPackage, destAddr, scAddr, destPort,
@@ -161,8 +161,8 @@ public class UiccSmsController extends ISms.Stub {
        }
    }

    public void sendTextWithOptionsUsingSubId(long subId, String callingPackage, String destAddr,
            String scAddr, String parts, PendingIntent sentIntents,
    public void sendTextWithOptionsUsingSubscriber(long subId, String callingPackage,
            String destAddr, String scAddr, String parts, PendingIntent sentIntents,
            PendingIntent deliveryIntents, int priority, boolean isExpectMore,
            int validityPeriod) {
        IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId);
@@ -195,7 +195,7 @@ public class UiccSmsController extends ISms.Stub {
        }
    }

    public void sendMultipartTextWithOptionsUsingSubId(long subId, String callingPackage,
    public void sendMultipartTextWithOptionsUsingSubscriber(long subId, String callingPackage,
            String destAddr, String scAddr, List<String> parts, List<PendingIntent> sentIntents,
            List<PendingIntent> deliveryIntents, int priority, boolean isExpectMore,
            int validityPeriod) {
@@ -331,11 +331,12 @@ public class UiccSmsController extends ISms.Stub {

    @Override
    public void injectSmsPdu(byte[] pdu, String format, PendingIntent receivedIntent) {
        injectSmsPdu(getDefaultSmsSubId(), pdu, format, receivedIntent);
        injectSmsPduForSubscriber(getDefaultSmsSubId(), pdu, format, receivedIntent);
    }

    // FIXME: Add injectSmsPdu to ISms.aidl
    public void injectSmsPdu(long subId, byte[] pdu, String format, PendingIntent receivedIntent) {
    // FIXME: Add injectSmsPduForSubscriber to ISms.aidl
    public void injectSmsPduForSubscriber(long subId, byte[] pdu, String format,
            PendingIntent receivedIntent) {
        getIccSmsInterfaceManager(subId).injectSmsPdu(pdu, format, receivedIntent);
    }