Merge "move short code definitions to SmsManager Test API"

am: b6399511f8

Change-Id: I81bc6dffdd76c9930257e0f7612107145c13d5f6
This commit is contained in:
Chen Xu
2019-06-25 10:57:07 -07:00
committed by android-build-merger
4 changed files with 107 additions and 0 deletions

View File

@@ -1532,6 +1532,15 @@ package android.telephony {
method public void setVoiceRoamingType(int);
}
public final class SmsManager {
method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int checkSmsShortCodeDestination(String, String);
field public static final int SMS_CATEGORY_FREE_SHORT_CODE = 1; // 0x1
field public static final int SMS_CATEGORY_NOT_SHORT_CODE = 0; // 0x0
field public static final int SMS_CATEGORY_POSSIBLE_PREMIUM_SHORT_CODE = 3; // 0x3
field public static final int SMS_CATEGORY_PREMIUM_SHORT_CODE = 4; // 0x4
field public static final int SMS_CATEGORY_STANDARD_SHORT_CODE = 2; // 0x2
}
public class TelephonyManager {
method public int getCarrierIdListVersion();
method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getLine1AlphaTag();

View File

@@ -16,9 +16,11 @@
package android.telephony;
import android.annotation.IntDef;
import android.annotation.RequiresPermission;
import android.annotation.SuppressAutoDoc;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
import android.app.ActivityThread;
import android.app.PendingIntent;
@@ -43,6 +45,8 @@ import com.android.internal.telephony.ISms;
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.SmsRawData;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -2798,4 +2802,85 @@ public final class SmsManager {
config.getBoolean(MMS_CONFIG_SUPPORT_HTTP_CHARSET_HEADER));
return filtered;
}
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = {"SMS_CATEGORY_"},
value = {
SmsManager.SMS_CATEGORY_NOT_SHORT_CODE,
SmsManager.SMS_CATEGORY_FREE_SHORT_CODE,
SmsManager.SMS_CATEGORY_STANDARD_SHORT_CODE,
SmsManager.SMS_CATEGORY_POSSIBLE_PREMIUM_SHORT_CODE,
SmsManager.SMS_CATEGORY_PREMIUM_SHORT_CODE})
public @interface SmsShortCodeCategory {}
/**
* Return value from {@link #checkSmsShortCodeDestination(String, String)} ()} for regular
* phone numbers.
* @hide
*/
@TestApi
public static final int SMS_CATEGORY_NOT_SHORT_CODE = 0;
/**
* Return value from {@link #checkSmsShortCodeDestination(String, String)} ()} for free
* (no cost) short codes.
* @hide
*/
@TestApi
public static final int SMS_CATEGORY_FREE_SHORT_CODE = 1;
/**
* Return value from {@link #checkSmsShortCodeDestination(String, String)} ()} for
* standard rate (non-premium)
* short codes.
* @hide
*/
@TestApi
public static final int SMS_CATEGORY_STANDARD_SHORT_CODE = 2;
/**
* Return value from {@link #checkSmsShortCodeDestination(String, String)} ()} for possible
* premium short codes.
* @hide
*/
@TestApi
public static final int SMS_CATEGORY_POSSIBLE_PREMIUM_SHORT_CODE = 3;
/**
* Return value from {@link #checkSmsShortCodeDestination(String, String)} ()} for
* premium short codes.
* @hide
*/
@TestApi
public static final int SMS_CATEGORY_PREMIUM_SHORT_CODE = 4;
/**
* Check if the destination address is a possible premium short code.
* NOTE: the caller is expected to strip non-digits from the destination number with
* {@link PhoneNumberUtils#extractNetworkPortion} before calling this method.
*
* @param destAddress the destination address to test for possible short code
* @param countryIso the ISO country code
*
* @return
* {@link SmsManager#SMS_CATEGORY_NOT_SHORT_CODE},
* {@link SmsManager#SMS_CATEGORY_FREE_SHORT_CODE},
* {@link SmsManager#SMS_CATEGORY_POSSIBLE_PREMIUM_SHORT_CODE},
* {@link SmsManager#SMS_CATEGORY_PREMIUM_SHORT_CODE}, or
* {@link SmsManager#SMS_CATEGORY_STANDARD_SHORT_CODE}
*
* @hide
*/
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
@TestApi
public @SmsShortCodeCategory int checkSmsShortCodeDestination(
String destAddress, String countryIso) {
try {
ISms iccISms = getISmsServiceOrThrow();
if (iccISms != null) {
return iccISms.checkSmsShortCodeDestination(getSubscriptionId(),
ActivityThread.currentPackageName(), destAddress, countryIso);
}
} catch (RemoteException e) {
Log.e(TAG, "checkSmsShortCodeDestination() RemoteException", e);
}
return SmsManager.SMS_CATEGORY_NOT_SHORT_CODE;
}
}

View File

@@ -551,4 +551,11 @@ interface ISms {
* @param intent PendingIntent to be sent when an SMS is received containing the token.
*/
String createAppSpecificSmsToken(int subId, String callingPkg, in PendingIntent intent);
/**
* Check if the destination is a possible premium short code.
*
* @param destAddress the destination address to test for possible short code
*/
int checkSmsShortCodeDestination(int subId, String callingApk, String destAddress, String countryIso);
}

View File

@@ -188,4 +188,10 @@ public class ISmsImplBase extends ISms.Stub {
public String createAppSpecificSmsToken(int subId, String callingPkg, PendingIntent intent) {
throw new UnsupportedOperationException();
}
@Override
public int checkSmsShortCodeDestination(
int subid, String callingApk, String destAddress, String countryIso) {
throw new UnsupportedOperationException();
}
}