From a248f3586f844821a6c18243d0308c507e047128 Mon Sep 17 00:00:00 2001 From: Taesu Lee Date: Fri, 24 Apr 2020 15:11:08 +0900 Subject: [PATCH] Expose getSmsCapacityOnIcc() Unhide getSmsCapacityOnIcc() and it requires READ_PHONE_STATE instead. Bug: 154878196 Test: Manual Signed-off-by: Taesu Lee Merged-in: I86ba39d5073227ff55251fabc614fd3b9347285e Change-Id: I86ba39d5073227ff55251fabc614fd3b9347285e --- api/current.txt | 1 + api/system-current.txt | 1 - non-updatable-api/current.txt | 1 + non-updatable-api/system-current.txt | 1 - .../java/android/telephony/SmsManager.java | 28 ++++++++++++------- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/api/current.txt b/api/current.txt index 87b0cc85366a0..31c5c55e9fa8b 100644 --- a/api/current.txt +++ b/api/current.txt @@ -47902,6 +47902,7 @@ package android.telephony { method @NonNull public android.os.Bundle getCarrierConfigValues(); method public static android.telephony.SmsManager getDefault(); method public static int getDefaultSmsSubscriptionId(); + method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int getSmsCapacityOnIcc(); method public static android.telephony.SmsManager getSmsManagerForSubscriptionId(int); method @RequiresPermission(android.Manifest.permission.SMS_FINANCIAL_TRANSACTIONS) public void getSmsMessagesForFinancialApp(android.os.Bundle, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.SmsManager.FinancialSmsCallback); method @Nullable @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public String getSmscAddress(); diff --git a/api/system-current.txt b/api/system-current.txt index c0364a3de18fc..ae60b22997b20 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -11050,7 +11050,6 @@ package android.telephony { method public boolean disableCellBroadcastRange(int, int, int); method public boolean enableCellBroadcastRange(int, int, int); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getPremiumSmsConsent(@NonNull String); - method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getSmsCapacityOnIcc(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void sendMultipartTextMessageWithoutPersisting(String, String, java.util.List, java.util.List, java.util.List); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setPremiumSmsConsent(@NonNull String, int); field public static final int PREMIUM_SMS_CONSENT_ALWAYS_ALLOW = 3; // 0x3 diff --git a/non-updatable-api/current.txt b/non-updatable-api/current.txt index b1373de5ea6c5..1736173e06e2f 100644 --- a/non-updatable-api/current.txt +++ b/non-updatable-api/current.txt @@ -46070,6 +46070,7 @@ package android.telephony { method @NonNull public android.os.Bundle getCarrierConfigValues(); method public static android.telephony.SmsManager getDefault(); method public static int getDefaultSmsSubscriptionId(); + method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int getSmsCapacityOnIcc(); method public static android.telephony.SmsManager getSmsManagerForSubscriptionId(int); method @RequiresPermission(android.Manifest.permission.SMS_FINANCIAL_TRANSACTIONS) public void getSmsMessagesForFinancialApp(android.os.Bundle, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.SmsManager.FinancialSmsCallback); method @Nullable @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public String getSmscAddress(); diff --git a/non-updatable-api/system-current.txt b/non-updatable-api/system-current.txt index 31b71fb5ca4db..5c0a044462e58 100644 --- a/non-updatable-api/system-current.txt +++ b/non-updatable-api/system-current.txt @@ -9932,7 +9932,6 @@ package android.telephony { method public boolean disableCellBroadcastRange(int, int, int); method public boolean enableCellBroadcastRange(int, int, int); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getPremiumSmsConsent(@NonNull String); - method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getSmsCapacityOnIcc(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void sendMultipartTextMessageWithoutPersisting(String, String, java.util.List, java.util.List, java.util.List); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setPremiumSmsConsent(@NonNull String, int); field public static final int PREMIUM_SMS_CONSENT_ALWAYS_ALLOW = 3; // 0x3 diff --git a/telephony/java/android/telephony/SmsManager.java b/telephony/java/android/telephony/SmsManager.java index d6ce40c24b783..af49dc4bb9b3b 100644 --- a/telephony/java/android/telephony/SmsManager.java +++ b/telephony/java/android/telephony/SmsManager.java @@ -2091,17 +2091,25 @@ public final class SmsManager { } /** - * Gets the total capacity of SMS storage on RUIM and SIM cards - *

- * This is the number of 176 byte EF-SMS records which can be stored on the RUIM or SIM card. - *

- * See 3GPP TS 31.102 - 4.2.25 - EF-SMS for more information + * Gets the total capacity of SMS storage on the SIM card. * - * @return the total number of SMS records which can be stored on the RUIM or SIM cards. - * @hide + *

+ * This is the number of 176 byte EF-SMS records which can be stored on the SIM card. + * See 3GPP TS 31.102 - 4.2.25 - EF-SMS for more information. + *

+ * + *

Note: This method will never trigger an SMS disambiguation + * dialog. If this method is called on a device that has multiple active subscriptions, this + * {@link SmsManager} instance has been created with {@link #getDefault()}, and no user-defined + * default subscription is defined, the subscription ID associated with this method will be + * INVALID, which will result in the operation being completed on the subscription associated + * with logical slot 0. Use {@link #getSmsManagerForSubscriptionId(int)} to ensure the operation + * is performed on the correct subscription. + *

+ * + * @return the total number of SMS records which can be stored on the SIM card. */ - @SystemApi - @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int getSmsCapacityOnIcc() { int ret = 0; try { @@ -2110,7 +2118,7 @@ public final class SmsManager { ret = iccISms.getSmsCapacityOnIccForSubscriber(getSubscriptionId()); } } catch (RemoteException ex) { - //ignore it + throw new RuntimeException(ex); } return ret; }