diff options
| -rw-r--r-- | api/current.txt | 2 | ||||
| -rw-r--r-- | telephony/java/android/telephony/SmsManager.java | 70 | ||||
| -rw-r--r-- | telephony/java/com/android/internal/telephony/ISms.aidl | 19 | ||||
| -rw-r--r-- | telephony/java/com/android/internal/telephony/ISmsImplBase.java | 11 |
4 files changed, 102 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index 8b06719dfad5..95338e882b85 100644 --- a/api/current.txt +++ b/api/current.txt @@ -44726,6 +44726,7 @@ package android.telephony { method public static int getDefaultSmsSubscriptionId(); 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(); method public int getSubscriptionId(); method public void injectSmsPdu(byte[], String, android.app.PendingIntent); method public void sendDataMessage(String, String, short, byte[], android.app.PendingIntent, android.app.PendingIntent); @@ -44733,6 +44734,7 @@ package android.telephony { method public void sendMultipartTextMessage(String, String, java.util.ArrayList<java.lang.String>, java.util.ArrayList<android.app.PendingIntent>, java.util.ArrayList<android.app.PendingIntent>); method public void sendTextMessage(String, String, String, android.app.PendingIntent, android.app.PendingIntent); method @RequiresPermission(allOf={android.Manifest.permission.MODIFY_PHONE_STATE, android.Manifest.permission.SEND_SMS}) public void sendTextMessageWithoutPersisting(String, String, String, android.app.PendingIntent, android.app.PendingIntent); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setSmscAddress(@NonNull String); field public static final String EXTRA_MMS_DATA = "android.telephony.extra.MMS_DATA"; field public static final String EXTRA_MMS_HTTP_STATUS = "android.telephony.extra.MMS_HTTP_STATUS"; field public static final String MMS_CONFIG_ALIAS_ENABLED = "aliasEnabled"; diff --git a/telephony/java/android/telephony/SmsManager.java b/telephony/java/android/telephony/SmsManager.java index 209d46253a07..f661bba4425f 100644 --- a/telephony/java/android/telephony/SmsManager.java +++ b/telephony/java/android/telephony/SmsManager.java @@ -3049,4 +3049,74 @@ public final class SmsManager { } return SmsManager.SMS_CATEGORY_NOT_SHORT_CODE; } + + /** + * Gets the SMSC address from (U)SIM. + * + * <p class="note"><strong>Note:</strong> Using this method requires that your app is the + * default SMS application, or READ_PRIVILEGED_PHONE_STATE permission, or has the carrier + * privileges.</p> + * + * <p class="note"><strong>Note:</strong> 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. + * </p> + * + * @return the SMSC address string, null if failed. + */ + @SuppressAutoDoc // for carrier privileges and default SMS application. + @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + @Nullable + public String getSmscAddress() { + String smsc = null; + + try { + ISms iSms = getISmsService(); + if (iSms != null) { + smsc = iSms.getSmscAddressFromIccEfForSubscriber( + getSubscriptionId(), ActivityThread.currentPackageName()); + } + } catch (RemoteException ex) { + // ignore it + } + return smsc; + } + + /** + * Sets the SMSC address on (U)SIM. + * + * <p class="note"><strong>Note:</strong> Using this method requires that your app is the + * default SMS application, or has {@link android.Manifest.permission#MODIFY_PHONE_STATE} + * permission, or has the carrier privileges.</p> + * + * <p class="note"><strong>Note:</strong> 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. + * </p> + * + * @param smsc the SMSC address string. + * @return true for success, false otherwise. + */ + @SuppressAutoDoc // for carrier privileges and default SMS application. + @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) + public boolean setSmscAddress(@NonNull String smsc) { + try { + ISms iSms = getISmsService(); + if (iSms != null) { + return iSms.setSmscAddressOnIccEfForSubscriber( + smsc, getSubscriptionId(), ActivityThread.currentPackageName()); + } + } catch (RemoteException ex) { + // ignore it + } + return false; + } } diff --git a/telephony/java/com/android/internal/telephony/ISms.aidl b/telephony/java/com/android/internal/telephony/ISms.aidl index 7441c26a8061..c1d700a2d190 100644 --- a/telephony/java/com/android/internal/telephony/ISms.aidl +++ b/telephony/java/com/android/internal/telephony/ISms.aidl @@ -586,4 +586,23 @@ interface ISms { * @param destAddress the destination address to test for possible short code */ int checkSmsShortCodeDestination(int subId, String callingApk, String destAddress, String countryIso); + + /** + * Gets the SMSC address from (U)SIM. + * + * @param subId the subscription Id. + * @param callingPackage the package name of the calling app. + * @return the SMSC address string, null if failed. + */ + String getSmscAddressFromIccEfForSubscriber(int subId, String callingPackage); + + /** + * Sets the SMSC address on (U)SIM. + * + * @param smsc the SMSC address string. + * @param subId the subscription Id. + * @param callingPackage the package name of the calling app. + * @return true for success, false otherwise. + */ + boolean setSmscAddressOnIccEfForSubscriber(String smsc, int subId, String callingPackage); } diff --git a/telephony/java/com/android/internal/telephony/ISmsImplBase.java b/telephony/java/com/android/internal/telephony/ISmsImplBase.java index aa1f94f2355a..ff816f24667e 100644 --- a/telephony/java/com/android/internal/telephony/ISmsImplBase.java +++ b/telephony/java/com/android/internal/telephony/ISmsImplBase.java @@ -208,4 +208,15 @@ public class ISmsImplBase extends ISms.Stub { int subid, String callingApk, String destAddress, String countryIso) { throw new UnsupportedOperationException(); } + + @Override + public String getSmscAddressFromIccEfForSubscriber(int subId, String callingPackage) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean setSmscAddressOnIccEfForSubscriber( + String smsc, int subId, String callingPackage) { + throw new UnsupportedOperationException(); + } } |