diff --git a/core/java/android/provider/VoicemailContract.java b/core/java/android/provider/VoicemailContract.java index 8ee9d1eaf9149..9da121f15f172 100644 --- a/core/java/android/provider/VoicemailContract.java +++ b/core/java/android/provider/VoicemailContract.java @@ -106,6 +106,47 @@ public class VoicemailContract { @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 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: + * + * + */ + /** @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 94f6a23cb2961..ad381afc1a078 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -720,6 +720,21 @@ public class TelephonyManager { */ 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 @@ public class TelephonyManager { 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. *

@@ -2420,6 +2435,181 @@ public class TelephonyManager { return false; } + /** + * 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) + * + *

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(:). + * + *

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. + * + *

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. + * + *

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. diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index bb8aaad5db599..7655f867f04a4 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -450,6 +450,26 @@ interface ITelephony { */ 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