Fix handling format based on API level accordingly.

Use SmsMessage#createFromPdu(pdu, format) at least on M and replace
SmsMessage#FORMAT_3GPP2 with "3gpp2".
 - SmsMessage#createFromPdu(pdu, format) is added in API level 23.
 - SmsMessage#FORMAT_3GPP2 is added in API level 28.

Test: Manual

Signed-off-by: Taesu Lee <taesu82.lee@samsung.com>
Change-Id: Icab2c6c3c86ee8b6597881bfac6066fed60db4d2
This commit is contained in:
Taesu Lee
2020-06-19 18:34:20 +09:00
parent dcfe928ff3
commit bd3b711aca
3 changed files with 8 additions and 7 deletions
@@ -87,7 +87,7 @@ public class SendStatusReceiver extends BroadcastReceiver {
final String format = intent.getStringExtra("format");
status = smsMessage.getStatus();
// Simple matching up CDMA status with GSM status.
if (SmsMessage.FORMAT_3GPP2.equals(format)) {
if ("3gpp2".equals(format)) {
final int errorClass = (status >> 24) & 0x03;
final int statusCode = (status >> 16) & 0x3f;
switch (errorClass) {
+3 -1
View File
@@ -1156,7 +1156,9 @@ public class MmsUtils {
public static SmsMessage getSmsMessageFromDeliveryReport(final Intent intent) {
final byte[] pdu = intent.getByteArrayExtra("pdu");
final String format = intent.getStringExtra("format");
return SmsMessage.createFromPdu(pdu, format);
return OsUtil.isAtLeastM()
? SmsMessage.createFromPdu(pdu, format)
: SmsMessage.createFromPdu(pdu);
}
/**
@@ -302,11 +302,10 @@ public class DebugUtils {
final int length = dis.readInt();
final byte[] pdu = new byte[length];
dis.read(pdu, 0, length);
if (format == null) {
messagesTemp[i] = SmsMessage.createFromPdu(pdu);
} else {
messagesTemp[i] = SmsMessage.createFromPdu(pdu, format);
}
messagesTemp[i] =
OsUtil.isAtLeastM()
? SmsMessage.createFromPdu(pdu, format)
: SmsMessage.createFromPdu(pdu);
}
messages = messagesTemp;
} catch (final FileNotFoundException e) {