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

Commit c2e91ac4 authored by Amit Mahajan's avatar Amit Mahajan Committed by Android Git Automerger
Browse files

am 3ce96a06: Adding a new param to calculateLength for SMS to indicate if...

am 3ce96a06: Adding a new param to calculateLength for SMS to indicate if called for a segment of multipart msg.

* commit '3ce96a06':
  Adding a new param to calculateLength for SMS to indicate if called for a segment of multipart msg.
parents 0cd59368 3ce96a06
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -297,7 +297,8 @@ public class SmsMessage {
    public static int[] calculateLength(CharSequence msgBody, boolean use7bitOnly) {
        // this function is for MO SMS
        TextEncodingDetails ted = (useCdmaFormatForMoSms()) ?
            com.android.internal.telephony.cdma.SmsMessage.calculateLength(msgBody, use7bitOnly) :
            com.android.internal.telephony.cdma.SmsMessage.calculateLength(msgBody, use7bitOnly,
                    true) :
            com.android.internal.telephony.gsm.SmsMessage.calculateLength(msgBody, use7bitOnly);
        int ret[] = new int[4];
        ret[0] = ted.msgCount;
@@ -320,7 +321,7 @@ public class SmsMessage {
    public static ArrayList<String> fragmentText(String text) {
        // This function is for MO SMS
        TextEncodingDetails ted = (useCdmaFormatForMoSms()) ?
            com.android.internal.telephony.cdma.SmsMessage.calculateLength(text, false) :
            com.android.internal.telephony.cdma.SmsMessage.calculateLength(text, false, true) :
            com.android.internal.telephony.gsm.SmsMessage.calculateLength(text, false);

        // TODO(cleanup): The code here could be rolled into the logic
+2 −1
Original line number Diff line number Diff line
@@ -783,7 +783,8 @@ public abstract class SMSDispatcher extends Handler {
    protected abstract void injectSmsPdu(byte[] pdu, String format, PendingIntent receivedIntent);

    /**
     * Calculate the number of septets needed to encode the message.
     * Calculate the number of septets needed to encode the message. This function should only be
     * called for individual segments of multipart message.
     *
     * @param messageBody the message to encode
     * @param use7bitOnly ignore (but still count) illegal characters if true
+1 −1
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ public class CdmaSMSDispatcher extends SMSDispatcher {
    @Override
    protected GsmAlphabet.TextEncodingDetails calculateLength(CharSequence messageBody,
            boolean use7bitOnly) {
        return SmsMessage.calculateLength(messageBody, use7bitOnly);
        return SmsMessage.calculateLength(messageBody, use7bitOnly, false);
    }

    /** {@inheritDoc} */
+3 −2
Original line number Diff line number Diff line
@@ -458,10 +458,11 @@ public class SmsMessage extends SmsMessageBase {
     *
     * @param messageBody the message to encode
     * @param use7bitOnly ignore (but still count) illegal characters if true
     * @param isEntireMsg indicates if this is entire msg or a segment in multipart msg
     * @return TextEncodingDetails
     */
    public static TextEncodingDetails calculateLength(CharSequence messageBody,
            boolean use7bitOnly) {
            boolean use7bitOnly, boolean isEntireMsg) {
        CharSequence newMsgBody = null;
        Resources r = Resources.getSystem();
        if (r.getBoolean(com.android.internal.R.bool.config_sms_force_7bit_encoding)) {
@@ -470,7 +471,7 @@ public class SmsMessage extends SmsMessageBase {
        if (TextUtils.isEmpty(newMsgBody)) {
            newMsgBody = messageBody;
        }
        return BearerData.calcTextEncodingDetails(newMsgBody, use7bitOnly);
        return BearerData.calcTextEncodingDetails(newMsgBody, use7bitOnly, isEntireMsg);
    }

    /**
+4 −2
Original line number Diff line number Diff line
@@ -469,10 +469,11 @@ public final class BearerData {
     *
     * @param msg message text
     * @param force7BitEncoding ignore (but still count) illegal characters if true
     * @param isEntireMsg indicates if this is entire msg or a segment in multipart msg
     * @return septet count, or -1 on failure
     */
    public static TextEncodingDetails calcTextEncodingDetails(CharSequence msg,
            boolean force7BitEncoding) {
            boolean force7BitEncoding, boolean isEntireMsg) {
        TextEncodingDetails ted;
        int septets = countAsciiSeptets(msg, force7BitEncoding);
        if (septets != -1 && septets <= SmsConstants.MAX_USER_DATA_SEPTETS) {
@@ -484,7 +485,8 @@ public final class BearerData {
        } else {
            ted = com.android.internal.telephony.gsm.SmsMessage.calculateLength(
                    msg, force7BitEncoding);
            if (ted.msgCount == 1 && ted.codeUnitSize == SmsConstants.ENCODING_7BIT) {
            if (ted.msgCount == 1 && ted.codeUnitSize == SmsConstants.ENCODING_7BIT &&
                    isEntireMsg) {
                // We don't support single-segment EMS, so calculate for 16-bit
                // TODO: Consider supporting single-segment EMS
                ted.codeUnitCount = msg.length();
Loading