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

This commit is contained in:
Thomas Nguyen
2022-11-23 22:42:21 +00:00
committed by Android (Google) Code Review
4 changed files with 47 additions and 16 deletions

View File

@@ -1019,6 +1019,17 @@ public class SmsMessage {
return mWrappedSmsMessage.isReplyPathPresent(); return mWrappedSmsMessage.isReplyPathPresent();
} }
/**
* Return the encoding type of a received SMS message, which is specified using ENCODING_*
* GSM: defined in android.telephony.SmsConstants
* CDMA: defined in android.telephony.cdma.UserData
*
* @hide
*/
public int getReceivedEncodingType() {
return mWrappedSmsMessage.getReceivedEncodingType();
}
/** /**
* Determines whether or not to use CDMA format for MO SMS. * Determines whether or not to use CDMA format for MO SMS.
* If SMS over IMS is supported, then format is based on IMS SMS format, * If SMS over IMS is supported, then format is based on IMS SMS format,

View File

@@ -16,6 +16,8 @@
package com.android.internal.telephony; package com.android.internal.telephony;
import static com.android.internal.telephony.SmsConstants.ENCODING_UNKNOWN;
import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage;
import android.os.Build; import android.os.Build;
import android.telephony.SmsMessage; import android.telephony.SmsMessage;
@@ -93,6 +95,15 @@ public abstract class SmsMessageBase {
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
protected boolean mMwiDontStore; protected boolean mMwiDontStore;
/**
* The encoding type of a received SMS message, which is specified using ENCODING_*
* GSM: defined in android.telephony.SmsConstants
* CDMA: defined in android.telephony.cdma.UserData
*
* @hide
*/
protected int mReceivedEncodingType = ENCODING_UNKNOWN;
/** /**
* Indicates status for messages stored on the ICC. * Indicates status for messages stored on the ICC.
*/ */
@@ -512,4 +523,8 @@ public abstract class SmsMessageBase {
return mRecipientAddress.getAddressString(); return mRecipientAddress.getAddressString();
} }
public int getReceivedEncodingType() {
return mReceivedEncodingType;
}
} }

View File

@@ -780,6 +780,7 @@ public class SmsMessage extends SmsMessageBase {
mUserData = mBearerData.userData.payload; mUserData = mBearerData.userData.payload;
mUserDataHeader = mBearerData.userData.userDataHeader; mUserDataHeader = mBearerData.userData.userDataHeader;
mMessageBody = mBearerData.userData.payloadStr; mMessageBody = mBearerData.userData.payloadStr;
mReceivedEncodingType = mBearerData.userData.msgEncoding;
} }
if (mOriginatingAddress != null) { if (mOriginatingAddress != null) {
@@ -860,6 +861,9 @@ public class SmsMessage extends SmsMessageBase {
Rlog.w(LOG_TAG, "BearerData.decode() returned null"); Rlog.w(LOG_TAG, "BearerData.decode() returned null");
return null; return null;
} }
if (bData.userData != null) {
mReceivedEncodingType = bData.userData.msgEncoding;
}
if (Rlog.isLoggable(LOGGABLE_TAG, Log.VERBOSE)) { if (Rlog.isLoggable(LOGGABLE_TAG, Log.VERBOSE)) {
Rlog.d(LOG_TAG, "MT raw BearerData = " + HexDump.toHexString(mEnvelope.bearerData)); Rlog.d(LOG_TAG, "MT raw BearerData = " + HexDump.toHexString(mEnvelope.bearerData));

View File

@@ -1396,28 +1396,28 @@ public class SmsMessage extends SmsMessageBase {
} else { } else {
switch ((mDataCodingScheme >> 2) & 0x3) { switch ((mDataCodingScheme >> 2) & 0x3) {
case 0: // GSM 7 bit default alphabet case 0: // GSM 7 bit default alphabet
encodingType = ENCODING_7BIT; encodingType = ENCODING_7BIT;
break; break;
case 2: // UCS 2 (16bit) case 2: // UCS 2 (16bit)
encodingType = ENCODING_16BIT; encodingType = ENCODING_16BIT;
break; break;
case 1: // 8 bit data case 1: // 8 bit data
//Support decoding the user data payload as pack GSM 8-bit (a GSM alphabet string // Support decoding the user data payload as pack GSM 8-bit (a GSM alphabet
//that's stored in 8-bit unpacked format) characters. // string that's stored in 8-bit unpacked format) characters.
if (r.getBoolean(com.android.internal. if (r.getBoolean(com.android.internal
R.bool.config_sms_decode_gsm_8bit_data)) { .R.bool.config_sms_decode_gsm_8bit_data)) {
encodingType = ENCODING_8BIT; encodingType = ENCODING_8BIT;
break; break;
} }
case 3: // reserved case 3: // reserved
Rlog.w(LOG_TAG, "1 - Unsupported SMS data coding scheme " Rlog.w(LOG_TAG, "1 - Unsupported SMS data coding scheme "
+ (mDataCodingScheme & 0xff)); + (mDataCodingScheme & 0xff));
encodingType = r.getInteger( encodingType = r.getInteger(
com.android.internal.R.integer.default_reserved_data_coding_scheme); com.android.internal.R.integer.default_reserved_data_coding_scheme);
break; break;
} }
} }
} else if ((mDataCodingScheme & 0xf0) == 0xf0) { } else if ((mDataCodingScheme & 0xf0) == 0xf0) {
@@ -1492,6 +1492,7 @@ public class SmsMessage extends SmsMessageBase {
encodingType == ENCODING_7BIT); encodingType == ENCODING_7BIT);
this.mUserData = p.getUserData(); this.mUserData = p.getUserData();
this.mUserDataHeader = p.getUserDataHeader(); this.mUserDataHeader = p.getUserDataHeader();
this.mReceivedEncodingType = encodingType;
/* /*
* Look for voice mail indication in TP_UDH TS23.040 9.2.3.24 * Look for voice mail indication in TP_UDH TS23.040 9.2.3.24