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

Commit 6ad88a8a authored by Chaitanya Saggurthi's avatar Chaitanya Saggurthi Committed by Amit Mahajan
Browse files

Send SMS using RIL_REQUEST_SEND_SMS_EXPECT_MORE

1) New commandinterface API sendSMSExpectMore to send sms using
   ril request RIL_REQUEST_SEND_SMS_EXPECT_MORE.
2) sendSMSExpectMore API to send multisegment sms pdu's except
   last pdu in GSM. In case of retry use sendSms even for
   multi segment message, because don't know how many
   segments are failed to send

Bug: 17570854
Change-Id: Icfc200a9c9c5940f0e10668b4385d1633a6c943b
parent b30d3481
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1051,6 +1051,16 @@ public interface CommandsInterface {
     */
    void sendSMS (String smscPDU, String pdu, Message response);

    /**
     * Send an SMS message, Identical to sendSMS,
     * except that more messages are expected to be sent soon
     * smscPDU is smsc address in PDU form GSM BCD format prefixed
     *      by a length byte (as expected by TS 27.005) or NULL for default SMSC
     * pdu is SMS in PDU format as an ASCII hex string
     *      less the SMSC address
     */
    void sendSMSExpectMore (String smscPDU, String pdu, Message response);

    /**
     * @param pdu is CDMA-SMS in internal pseudo-PDU format
     * @param response sent when operation completes
+13 −0
Original line number Diff line number Diff line
@@ -1272,6 +1272,19 @@ public final class RIL extends BaseCommands implements CommandsInterface {
        send(rr);
    }

    @Override
    public void
    sendSMSExpectMore (String smscPDU, String pdu, Message result) {
        RILRequest rr
                = RILRequest.obtain(RIL_REQUEST_SEND_SMS_EXPECT_MORE, result);

        constructGsmSendSmsRilRequest(rr, smscPDU, pdu);

        if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));

        send(rr);
    }

    private void
    constructCdmaSendSmsRilRequest(RILRequest rr, byte[] pdu) {
        int address_nbr_of_digits;
+8 −5
Original line number Diff line number Diff line
@@ -1034,6 +1034,7 @@ public abstract class SMSDispatcher extends Handler {
        public int mRetryCount;
        public int mImsRetry; // nonzero indicates initial message was sent over Ims
        public int mMessageRef;
        public boolean mExpectMore;
        String mFormat;

        public final PendingIntent mSentIntent;
@@ -1054,7 +1055,7 @@ public abstract class SMSDispatcher extends Handler {
        private SmsTracker(HashMap<String, Object> data, PendingIntent sentIntent,
                PendingIntent deliveryIntent, PackageInfo appInfo, String destAddr, String format,
                AtomicInteger unsentPartCount, AtomicBoolean anyPartFailed, Uri messageUri,
                SmsHeader smsHeader) {
                SmsHeader smsHeader, boolean isExpectMore) {
            mData = data;
            mSentIntent = sentIntent;
            mDeliveryIntent = deliveryIntent;
@@ -1062,6 +1063,7 @@ public abstract class SMSDispatcher extends Handler {
            mAppInfo = appInfo;
            mDestAddress = destAddr;
            mFormat = format;
            mExpectMore = isExpectMore;
            mImsRetry = 0;
            mMessageRef = 0;
            mUnsentPartCount = unsentPartCount;
@@ -1246,7 +1248,8 @@ public abstract class SMSDispatcher extends Handler {

    protected SmsTracker getSmsTracker(HashMap<String, Object> data, PendingIntent sentIntent,
            PendingIntent deliveryIntent, String format, AtomicInteger unsentPartCount,
            AtomicBoolean anyPartFailed, Uri messageUri, SmsHeader smsHeader) {
            AtomicBoolean anyPartFailed, Uri messageUri, SmsHeader smsHeader,
            boolean isExpectMore) {
        // Get calling app package name via UID from Binder call
        PackageManager pm = mContext.getPackageManager();
        String[] packageNames = pm.getPackagesForUid(Binder.getCallingUid());
@@ -1265,13 +1268,13 @@ public abstract class SMSDispatcher extends Handler {
        // and before displaying the number to the user if confirmation is required.
        String destAddr = PhoneNumberUtils.extractNetworkPortion((String) data.get("destAddr"));
        return new SmsTracker(data, sentIntent, deliveryIntent, appInfo, destAddr, format,
                unsentPartCount, anyPartFailed, messageUri, smsHeader);
                unsentPartCount, anyPartFailed, messageUri, smsHeader, isExpectMore);
    }

    protected SmsTracker getSmsTracker(HashMap<String, Object> data, PendingIntent sentIntent,
            PendingIntent deliveryIntent, String format, Uri messageUri) {
            PendingIntent deliveryIntent, String format, Uri messageUri, boolean isExpectMore) {
        return getSmsTracker(data, sentIntent, deliveryIntent, format, null/*unsentPartCount*/,
                null/*anyPartFailed*/, messageUri, null/*smsHeader*/);
                null/*anyPartFailed*/, messageUri, null/*smsHeader*/, isExpectMore);
    }

    protected HashMap<String, Object> getSmsTrackerMap(String destAddr, String scAddr,
+3 −3
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ public class CdmaSMSDispatcher extends SMSDispatcher {
                scAddr, destAddr, destPort, data, (deliveryIntent != null));
        HashMap map = getSmsTrackerMap(destAddr, scAddr, destPort, data, pdu);
        SmsTracker tracker = getSmsTracker(map, sentIntent, deliveryIntent, getFormat(),
                null/*messageUri*/);
                null /*messageUri*/, false);
        sendSubmitPdu(tracker);
    }

@@ -138,7 +138,7 @@ public class CdmaSMSDispatcher extends SMSDispatcher {
            }
            HashMap map = getSmsTrackerMap(destAddr, scAddr, text, pdu);
            SmsTracker tracker = getSmsTracker(map, sentIntent, deliveryIntent, getFormat(),
                    messageUri);
                    messageUri, false);
            sendSubmitPdu(tracker);
        } else {
            Rlog.e(TAG, "CdmaSMSDispatcher.sendText(): getSubmitPdu() returned null");
@@ -184,7 +184,7 @@ public class CdmaSMSDispatcher extends SMSDispatcher {
        HashMap map = getSmsTrackerMap(destinationAddress, scAddress,
                message, submitPdu);
        SmsTracker tracker = getSmsTracker(map, sentIntent, deliveryIntent,
                getFormat(), unsentPartCount, anyPartFailed, messageUri, smsHeader);
                getFormat(), unsentPartCount, anyPartFailed, messageUri, smsHeader, false);
        sendSubmitPdu(tracker);
    }

+10 −5
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ public final class GsmSMSDispatcher extends SMSDispatcher {
        if (pdu != null) {
            HashMap map = getSmsTrackerMap(destAddr, scAddr, destPort, data, pdu);
            SmsTracker tracker = getSmsTracker(map, sentIntent, deliveryIntent, getFormat(),
                    null/*messageUri*/);
                    null /*messageUri*/, false);
            sendRawPdu(tracker);
        } else {
            Rlog.e(TAG, "GsmSMSDispatcher.sendData(): getSubmitPdu() returned null");
@@ -187,7 +187,7 @@ public final class GsmSMSDispatcher extends SMSDispatcher {
            }
            HashMap map = getSmsTrackerMap(destAddr, scAddr, text, pdu);
            SmsTracker tracker = getSmsTracker(map, sentIntent, deliveryIntent, getFormat(),
                    messageUri);
                    messageUri, false);
            sendRawPdu(tracker);
        } else {
            Rlog.e(TAG, "GsmSMSDispatcher.sendText(): getSubmitPdu() returned null");
@@ -221,7 +221,7 @@ public final class GsmSMSDispatcher extends SMSDispatcher {
                    message, pdu);
            SmsTracker tracker = getSmsTracker(map, sentIntent,
                    deliveryIntent, getFormat(), unsentPartCount, anyPartFailed, messageUri,
                    smsHeader);
                    smsHeader, !lastPart);
            sendRawPdu(tracker);
        } else {
            Rlog.e(TAG, "GsmSMSDispatcher.sendNewSubmitPdu(): getSubmitPdu() returned null");
@@ -312,8 +312,13 @@ public final class GsmSMSDispatcher extends SMSDispatcher {
                    pdu[1] = (byte) tracker.mMessageRef; // TP-MR
                }
            }
            if (tracker.mRetryCount == 0 && tracker.mExpectMore) {
                mCi.sendSMSExpectMore(IccUtils.bytesToHexString(smsc),
                        IccUtils.bytesToHexString(pdu), reply);
            } else {
                mCi.sendSMS(IccUtils.bytesToHexString(smsc),
                        IccUtils.bytesToHexString(pdu), reply);
            }
        } else {
            mCi.sendImsGsmSms(IccUtils.bytesToHexString(smsc),
                    IccUtils.bytesToHexString(pdu), tracker.mImsRetry,
Loading