Merge "Switch VVM SMS filter to Builder pattern" into nyc-mr1-dev
This commit is contained in:
@@ -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)
|
||||
*
|
||||
* <p>This takes effect only when the caller is the default dialer.
|
||||
* <p>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(:).
|
||||
*
|
||||
* <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);
|
||||
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.
|
||||
* <p>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.
|
||||
*
|
||||
* <p>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.
|
||||
*
|
||||
* <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.
|
||||
* <p>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.
|
||||
*
|
||||
* <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.
|
||||
|
||||
@@ -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;
|
||||
@@ -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:
|
||||
*
|
||||
* <p>[clientPrefix]:[prefix]:([key]=[value];)*
|
||||
*
|
||||
* <p>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.
|
||||
*
|
||||
* <p>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<String> DEFAULT_ORIGINATING_NUMBERS = Collections.emptyList();
|
||||
public static final int DEFAULT_DESTINATION_PORT = DESTINATION_PORT_ANY;
|
||||
|
||||
/**
|
||||
* Builder class for {@link VisualVoicemailSmsFilterSettings} objects.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static class Builder {
|
||||
|
||||
private String mClientPrefix = DEFAULT_CLIENT_PREFIX;
|
||||
private List<String> mOriginatingNumbers = DEFAULT_ORIGINATING_NUMBERS;
|
||||
private int mDestinationPort = DEFAULT_DESTINATION_PORT;
|
||||
|
||||
public VisualVoicemailSmsFilterSettings build() {
|
||||
return new VisualVoicemailSmsFilterSettings(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the client prefix for the visual voicemail SMS filter. The client prefix will appear
|
||||
* at the start of a visual voicemail SMS message, followed by a colon(:).
|
||||
*/
|
||||
public Builder setClientPrefix(String clientPrefix) {
|
||||
if (clientPrefix == null) {
|
||||
throw new IllegalArgumentException("Client prefix cannot be null");
|
||||
}
|
||||
mClientPrefix = clientPrefix;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the originating number whitelist for the visual voicemail SMS filter. 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.
|
||||
*/
|
||||
public Builder setOriginatingNumbers(List<String> originatingNumbers) {
|
||||
if (originatingNumbers == null) {
|
||||
throw new IllegalArgumentException("Originating numbers cannot be null");
|
||||
}
|
||||
mOriginatingNumbers = originatingNumbers;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the destination port for the visual voicemail SMS filter.
|
||||
*
|
||||
* @param destinationPort The destination port, or {@link #DESTINATION_PORT_ANY}, or {@link
|
||||
* #DESTINATION_PORT_DATA_SMS}
|
||||
*/
|
||||
public Builder setDestinationPort(int destinationPort) {
|
||||
mDestinationPort = destinationPort;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The client prefix for the visual voicemail SMS filter. The client prefix will appear at the
|
||||
* start of a visual voicemail SMS message, followed by a colon(:).
|
||||
*/
|
||||
public final String clientPrefix;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public final List<String> originatingNumbers;
|
||||
|
||||
/**
|
||||
* The destination port for the visual voicemail SMS filter, or {@link #DESTINATION_PORT_ANY},
|
||||
* or {@link #DESTINATION_PORT_DATA_SMS}
|
||||
*/
|
||||
public final int destinationPort;
|
||||
|
||||
/**
|
||||
* Use {@link Builder} to construct
|
||||
*/
|
||||
private VisualVoicemailSmsFilterSettings(Builder builder) {
|
||||
clientPrefix = builder.mClientPrefix;
|
||||
originatingNumbers = builder.mOriginatingNumbers;
|
||||
destinationPort = builder.mDestinationPort;
|
||||
}
|
||||
|
||||
public static final Creator<VisualVoicemailSmsFilterSettings> CREATOR =
|
||||
new Creator<VisualVoicemailSmsFilterSettings>() {
|
||||
@Override
|
||||
public VisualVoicemailSmsFilterSettings createFromParcel(Parcel in) {
|
||||
Builder builder = new Builder();
|
||||
builder.setClientPrefix(in.readString());
|
||||
builder.setOriginatingNumbers(in.createStringArrayList());
|
||||
builder.setDestinationPort(in.readInt());
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisualVoicemailSmsFilterSettings[] newArray(int size) {
|
||||
return new VisualVoicemailSmsFilterSettings[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(clientPrefix);
|
||||
dest.writeStringList(originatingNumbers);
|
||||
dest.writeInt(destinationPort);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import android.telephony.NeighboringCellInfo;
|
||||
import android.telephony.RadioAccessFamily;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.TelephonyHistogram;
|
||||
import android.telephony.VisualVoicemailSmsFilterSettings;
|
||||
import com.android.internal.telephony.CellNetworkScanResult;
|
||||
import com.android.internal.telephony.OperatorInfo;
|
||||
|
||||
@@ -454,24 +455,18 @@ 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);
|
||||
void enableVisualVoicemailSmsFilter(String callingPackage, int subId,
|
||||
in VisualVoicemailSmsFilterSettings settings);
|
||||
|
||||
boolean isVisualVoicemailSmsFilterEnabled(String packageName, int subId);
|
||||
oneway void disableVisualVoicemailSmsFilter(String callingPackage, int subId);
|
||||
|
||||
// Not oneway, caller needs to make sure the vaule is set before receiving a SMS
|
||||
void setVisualVoicemailSmsFilterClientPrefix(int subId, String prefix);
|
||||
// Get settings set by the calling package
|
||||
VisualVoicemailSmsFilterSettings getVisualVoicemailSmsFilterSettings(String callingPackage,
|
||||
int subId);
|
||||
|
||||
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);
|
||||
// Get settings set by the package, requires READ_PRIVILEGED_PHONE_STATE permission
|
||||
VisualVoicemailSmsFilterSettings getSystemVisualVoicemailSmsFilterSettings(String packageName,
|
||||
int subId);
|
||||
|
||||
/**
|
||||
* Returns the network type for data transmission
|
||||
|
||||
Reference in New Issue
Block a user