diff options
| author | 2016-03-03 21:10:44 +0000 | |
|---|---|---|
| committer | 2016-03-03 21:10:46 +0000 | |
| commit | 456b9620f0bbd91adf18a4f3e1cf8b1ee21faa5c (patch) | |
| tree | 4c2bf6aa2a312fc34ada286d22c2350e5f785fff | |
| parent | cd0683b2d7c64ce3d4ad1ea652ee28c58290f1dc (diff) | |
| parent | a8c9c6c593d603a84aa164410b91e2399ceb41ce (diff) | |
Merge "New CarrierMessagingService API for sms filtering" into nyc-dev
| -rw-r--r-- | api/current.txt | 6 | ||||
| -rw-r--r-- | api/system-current.txt | 6 | ||||
| -rw-r--r-- | api/test-current.txt | 6 | ||||
| -rw-r--r-- | core/java/android/service/carrier/CarrierMessagingService.java | 63 | ||||
| -rw-r--r-- | core/java/android/service/carrier/ICarrierMessagingCallback.aidl | 2 |
5 files changed, 76 insertions, 7 deletions
diff --git a/api/current.txt b/api/current.txt index a4f6607cd9b6..2152d6faa922 100644 --- a/api/current.txt +++ b/api/current.txt @@ -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 diff --git a/api/system-current.txt b/api/system-current.txt index 2d5e7f6d299c..8347cd7dcb07 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -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 diff --git a/api/test-current.txt b/api/test-current.txt index dcb2f3285cd8..98a000e0ade7 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -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 diff --git a/core/java/android/service/carrier/CarrierMessagingService.java b/core/java/android/service/carrier/CarrierMessagingService.java index f5396a347cf9..140341cfaece 100644 --- a/core/java/android/service/carrier/CarrierMessagingService.java +++ b/core/java/android/service/carrier/CarrierMessagingService.java @@ -51,6 +51,30 @@ public abstract class CarrierMessagingService extends Service { = "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. */ public static final int SEND_STATUS_OK = 0; @@ -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 @@ -107,6 +133,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); } }); } diff --git a/core/java/android/service/carrier/ICarrierMessagingCallback.aidl b/core/java/android/service/carrier/ICarrierMessagingCallback.aidl index 6118a20ca006..2753669fae84 100644 --- a/core/java/android/service/carrier/ICarrierMessagingCallback.aidl +++ b/core/java/android/service/carrier/ICarrierMessagingCallback.aidl @@ -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); |