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

Commit 2d8b815c authored by Zongheng Wang's avatar Zongheng Wang Committed by Gerrit Code Review
Browse files

Merge "Replace Telephony internal API's usage with a public API"

parents e530a1e5 d639832b
Loading
Loading
Loading
Loading
+3 −44
Original line number Diff line number Diff line
@@ -25,9 +25,7 @@ import android.util.Log;

import com.android.bluetooth.util.GsmAlphabet;
import com.android.internal.telephony.SmsConstants;
import com.android.internal.telephony.SmsHeader;
import com.android.internal.telephony.cdma.sms.BearerData;
import com.android.internal.telephony.cdma.sms.UserData;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -554,48 +552,9 @@ public class BluetoothMapSmsPdu {
            /* This code is a reduced copy of the actual code used in the Android SMS sub system,
             * hence the comments have been left untouched. */
            for (int i = 0; i < msgCount; i++) {
                SmsHeader.ConcatRef concatRef = new SmsHeader.ConcatRef();
                concatRef.refNumber = refNumber;
                concatRef.seqNumber = i + 1;  // 1-based sequence
                concatRef.msgCount = msgCount;
                // We currently set this to true since our messaging app will never
                // send more than 255 parts (it converts the message to MMS well before that).
                // However, we should support 3rd party messaging apps that might need 16-bit
                // references
                // Note:  It's not sufficient to just flip this bit to true; it will have
                // ripple effects (several calculations assume 8-bit ref).
                concatRef.isEightBits = true;
                SmsHeader smsHeader = new SmsHeader();
                smsHeader.concatRef = concatRef;

                /* Depending on the type, call either GSM or CDMA getSubmitPdu(). The encoding
                 * will be determined(again) by getSubmitPdu().
                 * All packets need to be encoded using the same encoding, as the bMessage
                 * only have one filed to describe the encoding for all messages in a concatenated
                 * SMS... */
                if (encoding == SmsConstants.ENCODING_7BIT) {
                    smsHeader.languageTable = languageTable;
                    smsHeader.languageShiftTable = languageShiftTable;
                }

                if (phoneType == SMS_TYPE_GSM) {
                    data = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(null,
                            destinationAddress, smsFragments.get(i), false,
                            SmsHeader.toByteArray(smsHeader), encoding, languageTable,
                            languageShiftTable).encodedMessage;
                } else { // SMS_TYPE_CDMA
                    UserData uData = new UserData();
                    uData.payloadStr = smsFragments.get(i);
                    uData.userDataHeader = smsHeader;
                    if (encoding == SmsConstants.ENCODING_7BIT) {
                        uData.msgEncoding = UserData.ENCODING_GSM_7BIT_ALPHABET;
                    } else { // assume UTF-16
                        uData.msgEncoding = UserData.ENCODING_UNICODE_16;
                    }
                    uData.msgEncodingSet = true;
                    data = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(
                            destinationAddress, uData, false).encodedMessage;
                }
                data = SmsMessage.getSubmitPduEncodedMessage(phoneType == SMS_TYPE_GSM,
                    destinationAddress, smsFragments.get(i), encoding, languageTable,
                    languageShiftTable, refNumber, i + 1, msgCount);
                newPdu = new SmsPdu(data, encoding, phoneType, languageTable);
                pdus.add(newPdu);
            }