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

Commit 9cf46bfe authored by Thomas Nguyen's avatar Thomas Nguyen Committed by Android (Google) Code Review
Browse files

Merge "Fix for GSM-8bit decoding error" into tm-qpr-dev

parents 930daf3b 43fc8c6f
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.internal.telephony;

import static com.android.internal.telephony.SmsConstants.ENCODING_8BIT;

import android.annotation.Nullable;
import android.content.ComponentName;
import android.content.Context;
@@ -294,7 +296,18 @@ public class VisualVoicemailSmsFilter {
                result.firstMessage = message;
            }
            String body = message.getMessageBody();
            if (body == null && message.getUserData() != null) {

            /*
             * For visual voice mail SMS message, UTF-8 is used by default
             * {@link com.android.internal.telephony.SmsController#sendVisualVoicemailSmsForSubscriber}
             *
             * If config_sms_decode_gsm_8bit_data is enabled, GSM-8bit will be used to decode the
             * received message. However, the message is most likely encoded with UTF-8. Therefore,
             * we need to retry decoding the received message with UTF-8.
             */
            if ((body == null || message.getReceivedEncodingType() == ENCODING_8BIT)
                    && message.getUserData() != null) {
                Log.d(TAG, "getFullMessage decode using UTF-8");
                // Attempt to interpret the user data as UTF-8. UTF-8 string over data SMS using
                // 8BIT data coding scheme is our recommended way to send VVM SMS and is used in CTS
                // Tests. The OMTP visual voicemail specification does not specify the SMS type and
@@ -303,7 +316,8 @@ public class VisualVoicemailSmsFilter {
                try {
                    body = decoder.decode(byteBuffer).toString();
                } catch (CharacterCodingException e) {
                    // User data is not decode-able as UTF-8. Ignoring.
                    Log.e(TAG, "getFullMessage: got CharacterCodingException"
                            + " when decoding with UTF-8, e = " + e);
                    return null;
                }
            }