From f12ed60eca999e9a13351eae4a9a4a69ad46201d Mon Sep 17 00:00:00 2001 From: Zongheng Wang Date: Thu, 9 Jan 2020 17:57:30 +0800 Subject: Create a new API to decode Sms PDU Created createFromNativeSmsSubmitPdu() to avoid usage of hidden API createFromEfRecord(). Bug: 140562205 Test: Compile Change-Id: Ia6dda310a29b6969c26f85f98d2264b476fbf3f0 --- api/system-current.txt | 1 + telephony/java/android/telephony/SmsMessage.java | 28 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/api/system-current.txt b/api/system-current.txt index 9142cfe5ea60..f6191c3290ef 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -9123,6 +9123,7 @@ package android.telephony { } public class SmsMessage { + method @Nullable public static android.telephony.SmsMessage createFromNativeSmsSubmitPdu(@NonNull byte[], boolean); method @NonNull @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public static byte[] getSubmitPduEncodedMessage(boolean, @NonNull String, @NonNull String, int, int, int, int, int, int); } diff --git a/telephony/java/android/telephony/SmsMessage.java b/telephony/java/android/telephony/SmsMessage.java index b708b3ffbdd4..30a61c31ab81 100644 --- a/telephony/java/android/telephony/SmsMessage.java +++ b/telephony/java/android/telephony/SmsMessage.java @@ -331,6 +331,34 @@ public class SmsMessage { return wrappedMessage != null ? new SmsMessage(wrappedMessage) : null; } + /** + * Create an SmsMessage from a native SMS-Submit PDU, specified by Bluetooth Message Access + * Profile Specification v1.4.2 5.8. + * This is used by Bluetooth MAP profile to decode message when sending non UTF-8 SMS messages. + * + * @param data Message data. + * @param isCdma Indicates weather the type of the SMS is CDMA. + * @return An SmsMessage representing the message. + * + * @hide + */ + @SystemApi + @Nullable + public static SmsMessage createFromNativeSmsSubmitPdu(@NonNull byte[] data, boolean isCdma) { + SmsMessageBase wrappedMessage; + + if (isCdma) { + wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromEfRecord( + 0, data); + } else { + // Bluetooth uses its own method to decode GSM PDU so this part is not called. + wrappedMessage = com.android.internal.telephony.gsm.SmsMessage.createFromEfRecord( + 0, data); + } + + return wrappedMessage != null ? new SmsMessage(wrappedMessage) : null; + } + /** * Get the TP-Layer-Length for the given SMS-SUBMIT PDU Basically, the * length in bytes (not hex chars) less the SMSC header -- cgit v1.2.3-59-g8ed1b