Merge change 4147 into donut
* changes: On the way of refactoring out SingleServerProfile.java.
This commit is contained in:
@@ -20,8 +20,8 @@ import android.app.Notification;
|
|||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.vpn.SingleServerProfile;
|
|
||||||
import android.net.vpn.VpnManager;
|
import android.net.vpn.VpnManager;
|
||||||
|
import android.net.vpn.VpnProfile;
|
||||||
import android.net.vpn.VpnState;
|
import android.net.vpn.VpnState;
|
||||||
import android.os.FileObserver;
|
import android.os.FileObserver;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
@@ -38,7 +38,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* The service base class for managing a type of VPN connection.
|
* The service base class for managing a type of VPN connection.
|
||||||
*/
|
*/
|
||||||
abstract class VpnService<E extends SingleServerProfile> {
|
abstract class VpnService<E extends VpnProfile> {
|
||||||
private static final int NOTIFICATION_ID = 1;
|
private static final int NOTIFICATION_ID = 1;
|
||||||
private static final String PROFILES_ROOT = VpnManager.PROFILES_PATH + "/";
|
private static final String PROFILES_ROOT = VpnManager.PROFILES_PATH + "/";
|
||||||
public static final String DEFAULT_CONFIG_PATH = "/etc";
|
public static final String DEFAULT_CONFIG_PATH = "/etc";
|
||||||
|
|||||||
@@ -23,25 +23,4 @@ import android.os.Parcel;
|
|||||||
* {@hide}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
public abstract class SingleServerProfile extends VpnProfile {
|
public abstract class SingleServerProfile extends VpnProfile {
|
||||||
private String mServerName;
|
|
||||||
|
|
||||||
public void setServerName(String name) {
|
|
||||||
mServerName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getServerName() {
|
|
||||||
return mServerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void readFromParcel(Parcel in) {
|
|
||||||
super.readFromParcel(in);
|
|
||||||
mServerName = in.readString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel parcel, int flags) {
|
|
||||||
super.writeToParcel(parcel, flags);
|
|
||||||
parcel.writeString(mServerName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ public abstract class VpnProfile implements Parcelable, Serializable {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private String mName; // unique display name
|
private String mName; // unique display name
|
||||||
private String mId; // unique identifier
|
private String mId; // unique identifier
|
||||||
|
private String mServerName; // VPN server name
|
||||||
private String mDomainSuffices; // space separated list
|
private String mDomainSuffices; // space separated list
|
||||||
private String mRouteList; // space separated list
|
private String mRouteList; // space separated list
|
||||||
|
private String mSavedUsername;
|
||||||
private boolean mIsCustomized;
|
private boolean mIsCustomized;
|
||||||
private transient VpnState mState = VpnState.IDLE;
|
private transient VpnState mState = VpnState.IDLE;
|
||||||
|
|
||||||
@@ -57,6 +59,17 @@ public abstract class VpnProfile implements Parcelable, Serializable {
|
|||||||
return mId;
|
return mId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name of the VPN server. Used for DNS lookup.
|
||||||
|
*/
|
||||||
|
public void setServerName(String name) {
|
||||||
|
mServerName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerName() {
|
||||||
|
return mServerName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the domain suffices for DNS resolution.
|
* Sets the domain suffices for DNS resolution.
|
||||||
*
|
*
|
||||||
@@ -84,6 +97,14 @@ public abstract class VpnProfile implements Parcelable, Serializable {
|
|||||||
return mRouteList;
|
return mRouteList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSavedUsername(String name) {
|
||||||
|
mSavedUsername = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSavedUsername() {
|
||||||
|
return mSavedUsername;
|
||||||
|
}
|
||||||
|
|
||||||
public void setState(VpnState state) {
|
public void setState(VpnState state) {
|
||||||
mState = state;
|
mState = state;
|
||||||
}
|
}
|
||||||
@@ -116,8 +137,10 @@ public abstract class VpnProfile implements Parcelable, Serializable {
|
|||||||
protected void readFromParcel(Parcel in) {
|
protected void readFromParcel(Parcel in) {
|
||||||
mName = in.readString();
|
mName = in.readString();
|
||||||
mId = in.readString();
|
mId = in.readString();
|
||||||
|
mServerName = in.readString();
|
||||||
mDomainSuffices = in.readString();
|
mDomainSuffices = in.readString();
|
||||||
mRouteList = in.readString();
|
mRouteList = in.readString();
|
||||||
|
mSavedUsername = in.readString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Parcelable.Creator<VpnProfile> CREATOR =
|
public static final Parcelable.Creator<VpnProfile> CREATOR =
|
||||||
@@ -142,8 +165,10 @@ public abstract class VpnProfile implements Parcelable, Serializable {
|
|||||||
parcel.writeInt(mIsCustomized ? 1 : 0);
|
parcel.writeInt(mIsCustomized ? 1 : 0);
|
||||||
parcel.writeString(mName);
|
parcel.writeString(mName);
|
||||||
parcel.writeString(mId);
|
parcel.writeString(mId);
|
||||||
|
parcel.writeString(mServerName);
|
||||||
parcel.writeString(mDomainSuffices);
|
parcel.writeString(mDomainSuffices);
|
||||||
parcel.writeString(mRouteList);
|
parcel.writeString(mRouteList);
|
||||||
|
parcel.writeString(mSavedUsername);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
|
|||||||
Reference in New Issue
Block a user