Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7488d08 authored by Taesu Lee's avatar Taesu Lee
Browse files

New APIs for SMSC address



Added getSmscAddress() and setSmscAddress() to access SMSC address in
(U)SIM through the SmsManager.
getSmscAddress() requires that the calling app is the default SMS app,
or has READ_PRIVILEGED_PHONE_STATE or the carrier privileges.
setSmscAddress() requires that the calling app is the default SMS app,
or has MODIFY_PHONE_STATE or the carrier privileges.

Test: Manual

Change-Id: Icb21aff450f71b30ef6a1181834014bf7b85b8e1
Signed-off-by: default avatarTaesu Lee <taesu82.lee@samsung.com>
parent 3f5a8f58
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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";
+70 −0
Original line number Diff line number Diff line
@@ -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;
    }
}
+19 −0
Original line number Diff line number Diff line
@@ -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);
}
+11 −0
Original line number Diff line number Diff line
@@ -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();
    }
}