Add visual voicemail SMS filter APIs
Added the following APIs to the framework:
VoicemailContracts.ACTION_VOICEMAIL_SMS_RECEIVED
VoicemailContracts.EXTRA_VOICEMAIL_SMS_TYPE
VoicemailContracts.EXTRA_VOICEMAIL_SMS_DATA
VoicemailContracts.EXTRA_VOICEMAIL_SMS_SUBID
TelphonyManager.setVisualVoicemailSmsFilterEnabled()
TelphonyManager.isVisualVoicemailSmsFilterEnabled()
TelphonyManager.setVisualVoicemailSmsFilterPrefix()
TelphonyManager.getVisualVoicemailSmsFilterPrefix()
TelphonyManager.setVisualVoicemailSmsFilterOriginatingNumbers()
TelphonyManager.getVisualVoicemailSmsFilterOriginatingNumbers()
TelphonyManager.setVisualVoicemailSmsFilterDestinationPort()
TelphonyManager.getVisualVoicemailSmsFilterDestinationPort()
TelphonyManager.VVM_SMS_FILTER_DESTINATION_PORT_ANY
TelphonyManager.VVM_SMS_FILTER_DESTINATION_PORT_DATA_SMS
These values are required to implement the VisualVoicemailSmsFilter in
frameworks/opt/telephony
All of the APIs are hidden.
Bug:27816386
Bug:27817303
Change-Id: I07736785da5fece84d1f3d27f270ac6fa94c1c56
(cherry picked from commit ecbcce11cecc26d124adac8016f63667d01f3ab1)
diff --git a/core/java/android/provider/VoicemailContract.java b/core/java/android/provider/VoicemailContract.java
index 8ee9d1e..9da121f 100644
--- a/core/java/android/provider/VoicemailContract.java
+++ b/core/java/android/provider/VoicemailContract.java
@@ -107,6 +107,47 @@
public static final String ACTION_SYNC_VOICEMAIL = "android.intent.action.SYNC_VOICEMAIL";
/**
+ * Broadcast intent to inform a new visual voicemail SMS has been received. This intent will
+ * only be delivered to the voicemail client. The intent will have the following extra values:
+ *
+ * <ul>
+ * <li><em>{@link #EXTRA_VOICEMAIL_SMS_TYPE}</em> - (String) The event type of the SMS. Common
+ * values are "SYNC" or "STATUS"</li>
+ * <li><em>{@link #EXTRA_VOICEMAIL_SMS_DATA}</em> - (Bundle) The fields sent by the SMS</li>
+ * <li><em>{@link #EXTRA_VOICEMAIL_SMS_SUBID}</em> - (Integer) The subscription ID of the
+ * phone account that received the SMS</li>
+ * </ul>
+ */
+ /** @hide */
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_VOICEMAIL_SMS_RECEIVED =
+ "android.intent.action.VOICEMAIL_SMS_RECEIVED";
+
+ /**
+ * Extra included in {@link #ACTION_VOICEMAIL_SMS_RECEIVED} broadcast intents to indicate the
+ * event type of the SMS. Common values are "SYNC" or "STATUS"
+ */
+ /** @hide */
+ public static final String EXTRA_VOICEMAIL_SMS_PREFIX =
+ "com.android.voicemail.extra.VOICEMAIL_SMS_PREFIX";
+
+ /**
+ * Extra included in {@link #ACTION_VOICEMAIL_SMS_RECEIVED} broadcast intents to indicate the
+ * fields sent by the SMS
+ */
+ /** @hide */
+ public static final String EXTRA_VOICEMAIL_SMS_FIELDS =
+ "com.android.voicemail.extra.VOICEMAIL_SMS_FIELDS";
+
+ /**
+ * Extra included in {@link #ACTION_VOICEMAIL_SMS_RECEIVED} broadcast intents to indicate he
+ * subscription ID of the phone account that received the SMS.
+ */
+ /** @hide */
+ public static final String EXTRA_VOICEMAIL_SMS_SUBID =
+ "com.android.voicemail.extra.VOICEMAIL_SMS_SUBID";
+
+ /**
* Extra included in {@link Intent#ACTION_PROVIDER_CHANGED} broadcast intents to indicate if the
* receiving package made this change.
*/
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 55d0d02..1fa259a 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -720,6 +720,21 @@
*/
public static final String VVM_TYPE_CVVM = "vvm_type_cvvm";
+ /* Visual voicemail SMS filter constants */
+
+ /**
+ * The visual voicemail SMS message does not have to be a data SMS, and can be directed to any
+ * port.
+ * @hide
+ */
+ public static final int VVM_SMS_FILTER_DESTINATION_PORT_ANY = -1;
+
+ /**
+ * The visual voicemail SMS message can be directed to any port, but must be a data SMS.
+ * @hide
+ */
+ public static final int VVM_SMS_FILTER_DESTINATION_PORT_DATA_SMS = -2;
+
//
//
// Device Info
@@ -1879,7 +1894,7 @@
return getSimOperatorNumericForPhone(phoneId);
}
- /**
+ /**
* Returns the MCC+MNC (mobile country code + mobile network code) of the
* provider of the SIM for a particular subscription. 5 or 6 decimal digits.
* <p>
@@ -2421,6 +2436,181 @@
}
/**
+ * Enables or disables the visual voicemail SMS filter for a phone account. When the filter is
+ * enabled, Incoming SMS messages matching the OMTP VVM SMS interface will be redirected to the
+ * visual voicemail client with
+ * {@link android.provider.VoicemailContract.ACTION_VOICEMAIL_SMS_RECEIVED}.
+ * @see #setVisualVoicemailSmsFilterPrefix(int, String)
+ * @see #setVisualVoicemailSmsFilterOriginatingNumbers(int, String[])
+ * @see #setVisualVoicemailSmsFilterDestinationPort(int, int)
+ *
+ * <p>This takes effect only when the caller is the default dialer.
+ *
+ * @param subId The subscription id of the phone account.
+ * @param value The new state of the filter
+ */
+ /** @hide */
+ public void setVisualVoicemailSmsFilterEnabled(int subId, boolean value){
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null)
+ telephony.setVisualVoicemailSmsFilterEnabled(subId, value);
+ } catch (RemoteException ex) {
+ } catch (NullPointerException ex) {
+ }
+ }
+
+ /**
+ * Returns whether the visual voicemail SMS filter is enabled for a phone account.
+ *
+ * @param packageName The visual voicemail client to read the settings from
+ * @param subId The subscription id of the phone account.
+ */
+ /** @hide */
+ public boolean isVisualVoicemailSmsFilterEnabled(String packageName, int subId){
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ return telephony.isVisualVoicemailSmsFilterEnabled(packageName, subId);
+ }
+ } catch (RemoteException ex) {
+ } catch (NullPointerException ex) {
+ }
+
+ return false;
+ }
+
+ /**
+ * Sets the client prefix for the visual voicemail SMS filter of a phone account. The client
+ * prefix will appear at the start of a visual voicemail SMS message, followed by a colon(:).
+ *
+ * <p>This takes effect only when the caller is the default dialer.
+ *
+ * @param subId The subscription id of the phone account.
+ * @param prefix The client prefix
+ */
+ /** @hide */
+ public void setVisualVoicemailSmsFilterClientPrefix(int subId, String prefix){
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ telephony.setVisualVoicemailSmsFilterClientPrefix(subId, prefix);
+ }
+ } catch (RemoteException ex) {
+ } catch (NullPointerException ex) {
+ }
+ }
+
+ /**
+ * Returns the client prefix for the visual voicemail SMS filter of a phone account. The client
+ * prefix will appear at the start of a visual voicemail SMS message, followed by a colon(:).
+ *
+ * @param packageName The visual voicemail client to read the settings from
+ * @param subId The subscription id of the phone account.
+ */
+ /** @hide */
+ public String getVisualVoicemailSmsFilterClientPrefix(String packageName, int subId){
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ return telephony.getVisualVoicemailSmsFilterClientPrefix(packageName, subId);
+ }
+ } catch (RemoteException ex) {
+ } catch (NullPointerException ex) {
+ }
+ return null;
+ }
+
+ /**
+ * Sets the originating number whitelist for the visual voicemail SMS filter of a phone
+ * account. If the list is not null only the SMS messages from a number in the list can be
+ * considered as a visual voicemail SMS. Otherwise, messages from any address will be
+ * considered.
+ *
+ * <p>This takes effect only when the caller is the default dialer.
+ *
+ * @param subId The subscription id of the phone account.
+ * @param numbers A array representing the white list, or null to disable number filtering.
+ */
+ /** @hide */
+ public void setVisualVoicemailSmsFilterOriginatingNumbers(int subId,
+ @Nullable String[] numbers) {
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ telephony.setVisualVoicemailSmsFilterOriginatingNumbers(subId, numbers);
+ }
+ } catch (RemoteException ex) {
+ } catch (NullPointerException ex) {
+ }
+ }
+
+ /**
+ * Returns the originating number whitelist for the visual voicemail SMS filter of a phone
+ * account. If the list is not null only the SMS messages from a number in the list can be
+ * considered as a visual voicemail SMS. Otherwise, messages from any address will be
+ * considered.
+ *
+ * @param packageName The visual voicemail client to read the settings from
+ * @param subId The subscription id of the phone account.
+ */
+ /** @hide */
+ public String[] getVisualVoicemailSmsFilterOriginatingNumbers(String packageName, int subId){
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ return telephony.getVisualVoicemailSmsFilterOriginatingNumbers(packageName, subId);
+ }
+ } catch (RemoteException ex) {
+ } catch (NullPointerException ex) {
+ }
+ return null;
+ }
+
+ /**
+ * Sets the destination port for the visual voicemail SMS filter of a phone
+ * account.
+ *
+ * <p>This takes effect only when the caller is the default dialer.
+ *
+ * @param subId The subscription id of the phone account.
+ * @param port The destination port, or {@link #VVM_SMS_FILTER_DESTINATION_PORT_ANY}, or
+ * {@link #VVM_SMS_FILTER_DESTINATION_PORT_DATA_SMS}
+ */
+ /** @hide */
+ public void setVisualVoicemailSmsFilterDestinationPort(int subId, int port){
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ telephony.setVisualVoicemailSmsFilterDestinationPort(subId, port);
+ }
+ } catch (RemoteException ex) {
+ } catch (NullPointerException ex) {
+ }
+ }
+
+ /**
+ * Returns the destination port for the visual voicemail SMS filter of a phone
+ * account.
+ *
+ * @param packageName The visual voicemail client to read the settings from
+ * @param subId The subscription id of the phone account.
+ * @returns port The destination port, or {@link #VVM_SMS_FILTER_DESTINATION_PORT_ANY}, or
+ * {@link #VVM_SMS_FILTER_DESTINATION_PORT_DATA_SMS}
+ */
+ /** @hide */
+ public int getVisualVoicemailSmsFilterDestinationPort(String packageName, int subId){
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ return telephony.getVisualVoicemailSmsFilterDestinationPort(packageName, subId);
+ }
+ } catch (RemoteException ex) {
+ } catch (NullPointerException ex) {
+ }
+ return VVM_SMS_FILTER_DESTINATION_PORT_ANY;
+ }
+ /**
* Returns the voice mail count. Return 0 if unavailable, -1 if there are unread voice messages
* but the count is unknown.
* <p>
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index 598b36e..cf61b0a 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -450,6 +450,26 @@
*/
int getVoiceMessageCountForSubscriber(int subId);
+ // Not oneway, caller needs to make sure the vaule is set before receiving a SMS
+ void setVisualVoicemailSmsFilterEnabled(int subId, boolean value);
+
+ boolean isVisualVoicemailSmsFilterEnabled(String packageName, int subId);
+
+ // Not oneway, caller needs to make sure the vaule is set before receiving a SMS
+ void setVisualVoicemailSmsFilterClientPrefix(int subId, String prefix);
+
+ String getVisualVoicemailSmsFilterClientPrefix(String packageName, int subId);
+
+ // Not oneway, caller needs to make sure the vaule is set before receiving a SMS
+ void setVisualVoicemailSmsFilterOriginatingNumbers(int subId, in String[] numbers);
+
+ String[] getVisualVoicemailSmsFilterOriginatingNumbers(String packageName, int subId);
+
+ // Not oneway, caller needs to make sure the vaule is set before receiving a SMS
+ void setVisualVoicemailSmsFilterDestinationPort(int subId, int port);
+
+ int getVisualVoicemailSmsFilterDestinationPort(String packageName, int subId);
+
/**
* Returns the network type for data transmission
* Legacy call, permission-free