Merge "New APIs for SMSC address"

am: 0a7690ce24

Change-Id: I46c3d46b1e72be5ba2debf59c5fbde3ccbee35f4
This commit is contained in:
Amit Mahajan
2019-10-31 16:33:25 -07:00
committed by android-build-merger
4 changed files with 102 additions and 0 deletions

View File

@@ -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";

View File

@@ -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;
}
}

View File

@@ -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);
}

View File

@@ -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();
}
}