diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 6f9d571af5bf0..ddf5f2b06f6c2 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -723,21 +723,6 @@ 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 @@ -2439,65 +2424,30 @@ public class TelephonyManager { } /** - * Enables or disables the visual voicemail SMS filter for a phone account. When the filter is + * Enables 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. + *
This takes effect only when the caller is the default dialer. The enabled status and + * settings persist through default dialer changes, but the filter will only honor the setting + * set by the current default dialer. + * * * @param subId The subscription id of the phone account. - * @param value The new state of the filter + * @param settings The settings for 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) { + public void enableVisualVoicemailSmsFilter(int subId, + VisualVoicemailSmsFilterSettings settings) { + if(settings == null){ + throw new IllegalArgumentException("Settings cannot be null"); } - } - - /** - * 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); + telephony.enableVisualVoicemailSmsFilter(mContext.getOpPackageName(), subId, + settings); } } catch (RemoteException ex) { } catch (NullPointerException ex) { @@ -2505,114 +2455,70 @@ public class TelephonyManager { } /** - * 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(:). + * Disables the visual voicemail SMS filter for a phone account. * - * @param packageName The visual voicemail client to read the settings from - * @param subId The subscription id of the phone account. + *
This takes effect only when the caller is the default dialer. The enabled status and + * settings persist through default dialer changes, but the filter will only honor the setting + * set by the current default dialer. */ /** @hide */ - public String getVisualVoicemailSmsFilterClientPrefix(String packageName, int subId){ + public void disableVisualVoicemailSmsFilter(int subId) { try { ITelephony telephony = getITelephony(); if (telephony != null) { - return telephony.getVisualVoicemailSmsFilterClientPrefix(packageName, subId); + telephony.disableVisualVoicemailSmsFilter(mContext.getOpPackageName(), subId); } } catch (RemoteException ex) { } catch (NullPointerException ex) { } + } + + /** + * @returns the settings of the visual voicemail SMS filter for a phone account, or {@code null} + * if the filter is disabled. + * + *
This takes effect only when the caller is the default dialer. The enabled status and + * settings persist through default dialer changes, but the filter will only honor the setting + * set by the current default dialer. + */ + /** @hide */ + @Nullable + public VisualVoicemailSmsFilterSettings getVisualVoicemailSmsFilterSettings(int subId) { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony + .getVisualVoicemailSmsFilterSettings(mContext.getOpPackageName(), 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. + * @returns the settings of the visual voicemail SMS filter for a phone account set by the + * package, or {@code null} if the filter is disabled. * - *
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. + *
Requires the calling app to have READ_PRIVILEGED_PHONE_STATE permission. */ /** @hide */ - public void setVisualVoicemailSmsFilterOriginatingNumbers(int subId, - @Nullable String[] numbers) { + @Nullable + public VisualVoicemailSmsFilterSettings getVisualVoicemailSmsFilterSettings(String packageName, + int subId) { try { ITelephony telephony = getITelephony(); if (telephony != null) { - telephony.setVisualVoicemailSmsFilterOriginatingNumbers(subId, numbers); + return telephony.getSystemVisualVoicemailSmsFilterSettings(packageName, subId); } } 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/android/telephony/VisualVoicemailSmsFilterSettings.aidl b/telephony/java/android/telephony/VisualVoicemailSmsFilterSettings.aidl new file mode 100644 index 0000000000000..4b0539d03ee27 --- /dev/null +++ b/telephony/java/android/telephony/VisualVoicemailSmsFilterSettings.aidl @@ -0,0 +1,19 @@ +/* +* Copyright (C) 2016 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package android.telephony; + +parcelable VisualVoicemailSmsFilterSettings; diff --git a/telephony/java/android/telephony/VisualVoicemailSmsFilterSettings.java b/telephony/java/android/telephony/VisualVoicemailSmsFilterSettings.java new file mode 100644 index 0000000000000..5b81027655f04 --- /dev/null +++ b/telephony/java/android/telephony/VisualVoicemailSmsFilterSettings.java @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package android.telephony; + +import android.os.Parcel; +import android.os.Parcelable; + +import java.util.Collections; +import java.util.List; + +/** + * Class to represent various settings for the visual voicemail SMS filter. When the filter is + * enabled, incoming SMS matching the generalized OMTP format: + * + *
[clientPrefix]:[prefix]:([key]=[value];)* + * + *
will be regarded as a visual voicemail SMS, and removed before reaching the SMS provider. The + * intent {@link android.provider.VoicemailContract#ACTION_VOICEMAIL_SMS_RECEIVED} will then be sent + * to the default dialer with the information extracted from the SMS. + * + *
Use {@link android.telephony.VisualVoicemailSmsFilterSettings.Builder} to construct this
+ * class.
+ *
+ * @see android.telephony.TelephonyManager#enableVisualVoicemailSmsFilter
+ *
+ * @hide
+ */
+public class VisualVoicemailSmsFilterSettings implements Parcelable {
+
+
+ /**
+ * 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 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 DESTINATION_PORT_DATA_SMS = -2;
+
+ public static final String DEFAULT_CLIENT_PREFIX = "//VVM";
+ public static final List