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

Commit 2a545c65 authored by Martin Gross's avatar Martin Gross Committed by Steve Kondik
Browse files

Changing getPdus to use provided senderAddress to construct PDUs

getPDUs now checks if the provided senderAddress is a well formed SMS-
address. If this is the case, it used in the inital process of creating
the PDUs. If it isn't (for example: it is a vanish- or mail-address),
the MOCK_ADDRESS is initially used and later replaced with the alpha-
numeric string representing the provided address.

Change-Id: I512ae4074dd538b4394b9e9e5ba479625d2a4393
JIRA: CYAN-4057
Issue: https://jira.cyanogenmod.org/browse/CYAN-4057
parent 700c3219
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -617,13 +617,12 @@ public class ImsSMSDispatcher extends SMSDispatcher {
         */
        private byte[][] getPdus(String scAddress, String senderAddress, String msg) {

            // Get a SubmitPdu (use a phone number to get a valid pdu)
            SubmitPdu submitPdu =
                    android.telephony.SmsMessage.getSubmitPdu(
                                                        scAddress,
                                                        MOCK_ADDRESS,
                                                        msg,
                                                        false);
            // If we have a valid senderAddress, use it to get a valid SubmitPdu. Otherwise, we
            // should relay in a MOCK_ADDRESS to ensure a valid SubmitPdu
            boolean isWellFormed = PhoneNumberUtils.isWellFormedSmsAddress(senderAddress);
            String pduSenderAddress = isWellFormed ? senderAddress : MOCK_ADDRESS;
            SubmitPdu submitPdu = android.telephony.SmsMessage.getSubmitPdu(scAddress,
                    pduSenderAddress, msg, false);

            // Translate the submit data to a received PDU
            int dataLen = android.telephony.SmsMessage.calculateLength(msg, true)[1];
@@ -640,7 +639,7 @@ public class ImsSMSDispatcher extends SMSDispatcher {
                    encMsg, 0, submitPdu.encodedMessage.length - dataPos);
            byte[] encSender = null;
            // Check if the senderAddress is a vanish number
            if (!PhoneNumberUtils.isWellFormedSmsAddress(senderAddress)) {
            if (!isWellFormed) {
                try {
                    byte[] sender7BitPacked = GsmAlphabet.stringToGsm7BitPacked(senderAddress);
                    encSender = new byte[2 + sender7BitPacked.length - 1];