From d5093c71de64b3a1f6b2fdf4d28a1cf25ebd27eb Mon Sep 17 00:00:00 2001 From: changbetty Date: Thu, 21 Nov 2019 11:07:14 +0800 Subject: [PATCH] [Telephony Mainline] Add new SystemApi method and SystemApi annotation for mainline SmsManager - add SystemApi and RequiresPermission - deleteMessageFromIcc - getMessagesFromIcc SmsMessage - make as public API - getRecipientAddress Bug: 144478274 Test: make Change-Id: I6b875142bc8308e582ea874e9c69d8bed11ae554 --- api/current.txt | 1 + api/system-current.txt | 3 ++ core/res/AndroidManifest.xml | 5 ++++ .../java/android/telephony/SmsManager.java | 28 +++++++++++++++---- .../java/android/telephony/SmsMessage.java | 2 +- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/api/current.txt b/api/current.txt index 52dd1a16cc938..c12890d738eca 100644 --- a/api/current.txt +++ b/api/current.txt @@ -45490,6 +45490,7 @@ package android.telephony { method public byte[] getPdu(); method public int getProtocolIdentifier(); method public String getPseudoSubject(); + method @Nullable public String getRecipientAddress(); method public String getServiceCenterAddress(); method public int getStatus(); method public int getStatusOnIcc(); diff --git a/api/system-current.txt b/api/system-current.txt index 11089277a067d..d044d15beab8f 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -8,6 +8,7 @@ package android { field public static final String ACCESS_DRM_CERTIFICATES = "android.permission.ACCESS_DRM_CERTIFICATES"; field @Deprecated public static final String ACCESS_FM_RADIO = "android.permission.ACCESS_FM_RADIO"; field public static final String ACCESS_INSTANT_APPS = "android.permission.ACCESS_INSTANT_APPS"; + field public static final String ACCESS_MESSAGES_ON_ICC = "android.permission.ACCESS_MESSAGES_ON_ICC"; field public static final String ACCESS_MOCK_LOCATION = "android.permission.ACCESS_MOCK_LOCATION"; field public static final String ACCESS_MTP = "android.permission.ACCESS_MTP"; field public static final String ACCESS_NETWORK_CONDITIONS = "android.permission.ACCESS_NETWORK_CONDITIONS"; @@ -9607,8 +9608,10 @@ package android.telephony { } public final class SmsManager { + method @RequiresPermission(android.Manifest.permission.ACCESS_MESSAGES_ON_ICC) public boolean deleteMessageFromIcc(int); method public boolean disableCellBroadcastRange(int, int, int); method public boolean enableCellBroadcastRange(int, int, int); + method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_MESSAGES_ON_ICC) public java.util.List getMessagesFromIcc(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getSmsCapacityOnIcc(); method public void sendMultipartTextMessage(@NonNull String, @NonNull String, @NonNull java.util.List, @Nullable java.util.List, @Nullable java.util.List, @NonNull String); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void sendMultipartTextMessageWithoutPersisting(String, String, java.util.List, java.util.List, java.util.List); diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index cb5b4a595ac3d..bb1864ed18484 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -721,6 +721,11 @@ + + + * - * @param messageIndex is the record index of the message on ICC - * @return true for success + * @param messageIndex This is the same index used to access a message + * from {@link #getMessagesFromIcc()}. + * @return true for success, false if the operation fails. Failure can be due to IPC failure, + * RIL/modem error which results in SMS failed to be deleted on SIM * * {@hide} */ - @UnsupportedAppUsage - public boolean - deleteMessageFromIcc(int messageIndex) { + @SystemApi + @RequiresPermission(Manifest.permission.ACCESS_MESSAGES_ON_ICC) + public boolean deleteMessageFromIcc(int messageIndex) { boolean success = false; try { @@ -1684,6 +1687,7 @@ public final class SmsManager { * {@hide} */ @UnsupportedAppUsage + @RequiresPermission(Manifest.permission.ACCESS_MESSAGES_ON_ICC) public boolean updateMessageOnIcc(int messageIndex, int newStatus, byte[] pdu) { boolean success = false; @@ -1716,8 +1720,22 @@ public final class SmsManager { * operation is performed on the correct subscription. *

* + * @return List of SmsMessage objects + * + * {@hide} + */ + @SystemApi + @RequiresPermission(Manifest.permission.ACCESS_MESSAGES_ON_ICC) + public @NonNull List getMessagesFromIcc() { + return getAllMessagesFromIcc(); + } + + /** * @return ArrayList of SmsMessage objects * + * This is similar to {@link #getMessagesFromIcc} except that it will return ArrayList. + * Suggested to use {@link #getMessagesFromIcc} instead. + * * {@hide} */ @UnsupportedAppUsage diff --git a/telephony/java/android/telephony/SmsMessage.java b/telephony/java/android/telephony/SmsMessage.java index b705d71c61d97..36ae21afe1549 100644 --- a/telephony/java/android/telephony/SmsMessage.java +++ b/telephony/java/android/telephony/SmsMessage.java @@ -1032,10 +1032,10 @@ public class SmsMessage { } /** - * {@hide} * Returns the recipient address(receiver) of this SMS message in String form or null if * unavailable. */ + @Nullable public String getRecipientAddress() { return mWrappedSmsMessage.getRecipientAddress(); }