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

Commit ead9e626 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Gerrit Code Review
Browse files

Merge "SMSDispatcher: Add option for sending pseudo-multipart SMSes" into cm-10.1

parents 0e4a5241 2d562bdc
Loading
Loading
Loading
Loading
+57 −0
Original line number Diff line number Diff line
@@ -189,6 +189,7 @@ public abstract class SMSDispatcher extends Handler {
    protected boolean mSmsCapable = true;
    protected boolean mSmsReceiveDisabled;
    protected boolean mSmsSendDisabled;
    private   boolean mSmsPseudoMultipart;

    protected int mRemainingMessages = -1;

@@ -225,6 +226,7 @@ public abstract class SMSDispatcher extends Handler {
                                TelephonyProperties.PROPERTY_SMS_RECEIVE, mSmsCapable);
        mSmsSendDisabled = !SystemProperties.getBoolean(
                                TelephonyProperties.PROPERTY_SMS_SEND, mSmsCapable);
        mSmsPseudoMultipart = SystemProperties.getBoolean("telephony.sms.pseudo_multipart", false);
        Log.d(TAG, "SMSDispatcher: ctor mSmsCapable=" + mSmsCapable + " format=" + getFormat()
                + " mSmsReceiveDisabled=" + mSmsReceiveDisabled
                + " mSmsSendDisabled=" + mSmsSendDisabled);
@@ -846,6 +848,12 @@ public abstract class SMSDispatcher extends Handler {
    protected void sendMultipartText(String destAddr, String scAddr,
            ArrayList<String> parts, ArrayList<PendingIntent> sentIntents,
            ArrayList<PendingIntent> deliveryIntents) {
        if (mSmsPseudoMultipart) {
            // Send as individual messages as the combination of device and
            // carrier behavior may not process concatenated messages correctly.
            sendPseudoMultipartText(destAddr, scAddr, parts, sentIntents, deliveryIntents);
            return;
        }

        int refNumber = getNextConcatenatedRef() & 0x00FF;
        int msgCount = parts.size();
@@ -901,6 +909,55 @@ public abstract class SMSDispatcher extends Handler {

    }

    /**
     * Send a multi-part text based SMS as individual messages
     * (i.e., without User Data Headers).
     *
     * @param destAddr the address to send the message to
     * @param scAddr is the service center address or null to use
     *   the current default SMSC
     * @param parts an <code>ArrayList</code> of strings that, in order,
     *   comprise the original message
     * @param sentIntents if not null, an <code>ArrayList</code> of
     *   <code>PendingIntent</code>s (one for each message part) that is
     *   broadcast when the corresponding message part has been sent.
     *   The result code will be <code>Activity.RESULT_OK<code> for success,
     *   or one of these errors:
     *   <code>RESULT_ERROR_GENERIC_FAILURE</code>
     *   <code>RESULT_ERROR_RADIO_OFF</code>
     *   <code>RESULT_ERROR_NULL_PDU</code>
     *   <code>RESULT_ERROR_NO_SERVICE</code>.
     *  The per-application based SMS control checks sentIntent. If sentIntent
     *  is NULL the caller will be checked against all unknown applications,
     *  which cause smaller number of SMS to be sent in checking period.
     * @param deliveryIntents if not null, an <code>ArrayList</code> of
     *   <code>PendingIntent</code>s (one for each message part) that is
     *   broadcast when the corresponding message part has been delivered
     *   to the recipient.  The raw pdu of the status report is in the
     *   extended data ("pdu").
     */
    private void sendPseudoMultipartText(String destAddr, String scAddr,
            ArrayList<String> parts, ArrayList<PendingIntent> sentIntents,
            ArrayList<PendingIntent> deliveryIntents) {
        int msgCount = parts.size();

        mRemainingMessages = msgCount;

        for (int i = 0; i < msgCount; i++) {
            PendingIntent sentIntent = null;
            if (sentIntents != null && sentIntents.size() > i) {
                sentIntent = sentIntents.get(i);
            }

            PendingIntent deliveryIntent = null;
            if (deliveryIntents != null && deliveryIntents.size() > i) {
                deliveryIntent = deliveryIntents.get(i);
            }

            sendText(destAddr, scAddr, parts.get(i), sentIntent, deliveryIntent);
        }
    }

    /**
     * Create a new SubmitPdu and send it.
     */