Merge "New CarrierMessagingService API for sms filtering" into nyc-dev

This commit is contained in:
Ji Yang
2016-03-03 21:10:44 +00:00
committed by Android (Google) Code Review
5 changed files with 76 additions and 7 deletions

View File

@@ -34237,7 +34237,8 @@ package android.service.carrier {
ctor public CarrierMessagingService();
method public android.os.IBinder onBind(android.content.Intent);
method public void onDownloadMms(android.net.Uri, int, android.net.Uri, android.service.carrier.CarrierMessagingService.ResultCallback<java.lang.Integer>);
method public void onFilterSms(android.service.carrier.MessagePdu, java.lang.String, int, int, android.service.carrier.CarrierMessagingService.ResultCallback<java.lang.Boolean>);
method public deprecated void onFilterSms(android.service.carrier.MessagePdu, java.lang.String, int, int, android.service.carrier.CarrierMessagingService.ResultCallback<java.lang.Boolean>);
method public void onReceiveTextSms(android.service.carrier.MessagePdu, java.lang.String, int, int, android.service.carrier.CarrierMessagingService.ResultCallback<java.lang.Integer>);
method public deprecated void onSendDataSms(byte[], int, java.lang.String, int, android.service.carrier.CarrierMessagingService.ResultCallback<android.service.carrier.CarrierMessagingService.SendSmsResult>);
method public void onSendDataSms(byte[], int, java.lang.String, int, int, android.service.carrier.CarrierMessagingService.ResultCallback<android.service.carrier.CarrierMessagingService.SendSmsResult>);
method public void onSendMms(android.net.Uri, int, android.net.Uri, android.service.carrier.CarrierMessagingService.ResultCallback<android.service.carrier.CarrierMessagingService.SendMmsResult>);
@@ -34248,6 +34249,9 @@ package android.service.carrier {
field public static final int DOWNLOAD_STATUS_ERROR = 2; // 0x2
field public static final int DOWNLOAD_STATUS_OK = 0; // 0x0
field public static final int DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK = 1; // 0x1
field public static final int RECEIVE_OPTIONS_DEFAULT = 0; // 0x0
field public static final int RECEIVE_OPTIONS_DROP = 1; // 0x1
field public static final int RECEIVE_OPTIONS_SKIP_NOTIFY_WHEN_CREDENTIAL_ENCRYPTED_STORAGE_UNAVAILABLE = 2; // 0x2
field public static final int SEND_FLAG_REQUEST_DELIVERY_STATUS = 1; // 0x1
field public static final int SEND_STATUS_ERROR = 2; // 0x2
field public static final int SEND_STATUS_OK = 0; // 0x0

View File

@@ -36725,7 +36725,8 @@ package android.service.carrier {
ctor public CarrierMessagingService();
method public android.os.IBinder onBind(android.content.Intent);
method public void onDownloadMms(android.net.Uri, int, android.net.Uri, android.service.carrier.CarrierMessagingService.ResultCallback<java.lang.Integer>);
method public void onFilterSms(android.service.carrier.MessagePdu, java.lang.String, int, int, android.service.carrier.CarrierMessagingService.ResultCallback<java.lang.Boolean>);
method public deprecated void onFilterSms(android.service.carrier.MessagePdu, java.lang.String, int, int, android.service.carrier.CarrierMessagingService.ResultCallback<java.lang.Boolean>);
method public void onReceiveTextSms(android.service.carrier.MessagePdu, java.lang.String, int, int, android.service.carrier.CarrierMessagingService.ResultCallback<java.lang.Integer>);
method public deprecated void onSendDataSms(byte[], int, java.lang.String, int, android.service.carrier.CarrierMessagingService.ResultCallback<android.service.carrier.CarrierMessagingService.SendSmsResult>);
method public void onSendDataSms(byte[], int, java.lang.String, int, int, android.service.carrier.CarrierMessagingService.ResultCallback<android.service.carrier.CarrierMessagingService.SendSmsResult>);
method public void onSendMms(android.net.Uri, int, android.net.Uri, android.service.carrier.CarrierMessagingService.ResultCallback<android.service.carrier.CarrierMessagingService.SendMmsResult>);
@@ -36736,6 +36737,9 @@ package android.service.carrier {
field public static final int DOWNLOAD_STATUS_ERROR = 2; // 0x2
field public static final int DOWNLOAD_STATUS_OK = 0; // 0x0
field public static final int DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK = 1; // 0x1
field public static final int RECEIVE_OPTIONS_DEFAULT = 0; // 0x0
field public static final int RECEIVE_OPTIONS_DROP = 1; // 0x1
field public static final int RECEIVE_OPTIONS_SKIP_NOTIFY_WHEN_CREDENTIAL_ENCRYPTED_STORAGE_UNAVAILABLE = 2; // 0x2
field public static final int SEND_FLAG_REQUEST_DELIVERY_STATUS = 1; // 0x1
field public static final int SEND_STATUS_ERROR = 2; // 0x2
field public static final int SEND_STATUS_OK = 0; // 0x0

View File

@@ -34254,7 +34254,8 @@ package android.service.carrier {
ctor public CarrierMessagingService();
method public android.os.IBinder onBind(android.content.Intent);
method public void onDownloadMms(android.net.Uri, int, android.net.Uri, android.service.carrier.CarrierMessagingService.ResultCallback<java.lang.Integer>);
method public void onFilterSms(android.service.carrier.MessagePdu, java.lang.String, int, int, android.service.carrier.CarrierMessagingService.ResultCallback<java.lang.Boolean>);
method public deprecated void onFilterSms(android.service.carrier.MessagePdu, java.lang.String, int, int, android.service.carrier.CarrierMessagingService.ResultCallback<java.lang.Boolean>);
method public void onReceiveTextSms(android.service.carrier.MessagePdu, java.lang.String, int, int, android.service.carrier.CarrierMessagingService.ResultCallback<java.lang.Integer>);
method public deprecated void onSendDataSms(byte[], int, java.lang.String, int, android.service.carrier.CarrierMessagingService.ResultCallback<android.service.carrier.CarrierMessagingService.SendSmsResult>);
method public void onSendDataSms(byte[], int, java.lang.String, int, int, android.service.carrier.CarrierMessagingService.ResultCallback<android.service.carrier.CarrierMessagingService.SendSmsResult>);
method public void onSendMms(android.net.Uri, int, android.net.Uri, android.service.carrier.CarrierMessagingService.ResultCallback<android.service.carrier.CarrierMessagingService.SendMmsResult>);
@@ -34265,6 +34266,9 @@ package android.service.carrier {
field public static final int DOWNLOAD_STATUS_ERROR = 2; // 0x2
field public static final int DOWNLOAD_STATUS_OK = 0; // 0x0
field public static final int DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK = 1; // 0x1
field public static final int RECEIVE_OPTIONS_DEFAULT = 0; // 0x0
field public static final int RECEIVE_OPTIONS_DROP = 1; // 0x1
field public static final int RECEIVE_OPTIONS_SKIP_NOTIFY_WHEN_CREDENTIAL_ENCRYPTED_STORAGE_UNAVAILABLE = 2; // 0x2
field public static final int SEND_FLAG_REQUEST_DELIVERY_STATUS = 1; // 0x1
field public static final int SEND_STATUS_ERROR = 2; // 0x2
field public static final int SEND_STATUS_OK = 0; // 0x0

View File

@@ -50,6 +50,30 @@ public abstract class CarrierMessagingService extends Service {
public static final String SERVICE_INTERFACE
= "android.service.carrier.CarrierMessagingService";
/**
* The default bitmask value passed to the callback of {@link #onReceiveTextSms} with all
* {@code RECEIVE_OPTIONS_x} flags cleared to indicate that the message should be kept and a
* new message notification should be shown.
*
* @see #RECEIVE_OPTIONS_DROP
* @see #RECEIVE_OPTIONS_SKIP_NOTIFY_WHEN_CREDENTIAL_ENCRYPTED_STORAGE_UNAVAILABLE
*/
public static final int RECEIVE_OPTIONS_DEFAULT = 0;
/**
* Used to set the flag in the bitmask passed to the callback of {@link #onReceiveTextSms} to
* indicate that the inbound SMS should be dropped.
*/
public static final int RECEIVE_OPTIONS_DROP = 0x1;
/**
* Used to set the flag in the bitmask passed to the callback of {@link #onReceiveTextSms} to
* indicate that a new message notification should not be shown to the user when the
* credential-encrypted storage of the device is not available before the user unlocks the
* phone. It is only applicable to devices that support file-based encryption.
*/
public static final int RECEIVE_OPTIONS_SKIP_NOTIFY_WHEN_CREDENTIAL_ENCRYPTED_STORAGE_UNAVAILABLE = 0x2;
/**
* Indicates that an SMS or MMS message was successfully sent.
*/
@@ -96,7 +120,9 @@ public abstract class CarrierMessagingService extends Service {
* @param subId SMS subscription ID of the SIM
* @param callback result callback. Call with {@code true} to keep an inbound SMS message and
* deliver to SMS apps, and {@code false} to drop the message.
* @deprecated Use {@link #onReceiveTextSms} instead.
*/
@Deprecated
public void onFilterSms(@NonNull MessagePdu pdu, @NonNull String format, int destPort,
int subId, @NonNull ResultCallback<Boolean> callback) {
// optional
@@ -106,6 +132,36 @@ public abstract class CarrierMessagingService extends Service {
}
}
/**
* Override this method to filter inbound SMS messages.
*
* <p>This method will be called once for every incoming text SMS. You can invoke the callback
* with a bitmask to tell the platform how to handle the SMS. For a SMS received on a
* file-based encryption capable device while the credential-encrypted storage is not available,
* this method will be called for the second time when the credential-encrypted storage becomes
* available after the user unlocks the phone, if the bit {@link #RECEIVE_OPTIONS_DROP} is not
* set when invoking the callback.
*
* @param pdu the PDUs of the message
* @param format the format of the PDUs, typically "3gpp" or "3gpp2"
* @param destPort the destination port of a binary SMS, this will be -1 for text SMS
* @param subId SMS subscription ID of the SIM
* @param callback result callback. Call with a bitmask integer to indicate how the incoming
* text SMS should be handled by the platform. Use {@link #RECEIVE_OPTIONS_DROP} and
* {@link #RECEIVE_OPTIONS_SKIP_NOTIFY_WHEN_CREDENTIAL_ENCRYPTED_STORAGE_UNAVAILABLE}
* to set the flags in the bitmask.
*/
public void onReceiveTextSms(@NonNull MessagePdu pdu, @NonNull String format,
int destPort, int subId, @NonNull final ResultCallback<Integer> callback) {
onFilterSms(pdu, format, destPort, subId, new ResultCallback<Boolean>() {
@Override
public void onReceiveResult(Boolean result) throws RemoteException {
callback.onReceiveResult(result ? RECEIVE_OPTIONS_DEFAULT : RECEIVE_OPTIONS_DROP
| RECEIVE_OPTIONS_SKIP_NOTIFY_WHEN_CREDENTIAL_ENCRYPTED_STORAGE_UNAVAILABLE);
}
});
}
/**
* Override this method to intercept text SMSs sent from the device.
* @deprecated Override {@link #onSendTextSms} below instead.
@@ -408,10 +464,11 @@ public abstract class CarrierMessagingService extends Service {
@Override
public void filterSms(MessagePdu pdu, String format, int destPort,
int subId, final ICarrierMessagingCallback callback) {
onFilterSms(pdu, format, destPort, subId, new ResultCallback<Boolean>() {
onReceiveTextSms(pdu, format, destPort, subId,
new ResultCallback<Integer>() {
@Override
public void onReceiveResult(final Boolean result) throws RemoteException {
callback.onFilterComplete(result);
public void onReceiveResult(Integer options) throws RemoteException {
callback.onFilterComplete(options);
}
});
}

View File

@@ -22,7 +22,7 @@ package android.service.carrier;
* @hide
*/
oneway interface ICarrierMessagingCallback {
void onFilterComplete(boolean keepMessage);
void onFilterComplete(int result);
void onSendSmsComplete(int result, int messageRef);
void onSendMultipartSmsComplete(int result, in int[] messageRefs);
void onSendMmsComplete(int result, in byte[] sendConfPdu);