summaryrefslogtreecommitdiffstats
path: root/vpn
diff options
context:
space:
mode:
authorHung-ying Tyan <tyanh@google.com>2009-06-08 13:27:11 +0800
committerHung-ying Tyan <tyanh@google.com>2009-06-12 15:45:56 +0800
commitf94b6444a3d4dc6d904754f80b2f940be90e432b (patch)
tree6929a787d45050a738b8ac24f7322d001aceaf96 /vpn
parent78f0f8cb2efe9410127c39201e240f6d438eb53c (diff)
downloadframeworks_base-f94b6444a3d4dc6d904754f80b2f940be90e432b.zip
frameworks_base-f94b6444a3d4dc6d904754f80b2f940be90e432b.tar.gz
frameworks_base-f94b6444a3d4dc6d904754f80b2f940be90e432b.tar.bz2
Add the VPN services package, VPN service base classes and L2tpIpsecService.
Also add android.security.Keystore. This is a quick solution. Will be evolved to a more mature implementation. PATCH SET 2: + Add VpnServiceBinder to hide VpnService and its subclasses. + Add sendCommand2() to AndroidServiceProxy to work with the latest mtpd. PATCH SET 3: + Rebase to catch up with new commits; no changes made. PATCH SET 4: + Remove/comment out @Override on interface methods to be compilable for Java 1.5. PATCH SET 5: + Add L2tpService.java. + Make VpnService to work on SingleServerProfile; add serverIp to connect(); set system property "net.vpn.server_ip"; and move getPppOptionFilePath() from L2tpIpsecService to VpnService + Revise VpnManager to start VpnService without worrying about which type (as the type info is in VpnProfile) + Remove installation stuff from VpnManager PATCH SET 6: + Fix PATCH SET 5 (the patch was messed up). Please ignore PATCH SET 5. PATCH SET 7: + Fix styles. PATCH SET 8: + Add CANCELLED to VpnState. PATCH SET 9: + Make VpnProfile serializable (in order to save them to persistent storage) PATCH SET 10: + Remove Keystore.java as it's added in another CL.
Diffstat (limited to 'vpn')
-rw-r--r--vpn/java/android/net/vpn/L2tpIpsecProfile.java2
-rw-r--r--vpn/java/android/net/vpn/L2tpProfile.java2
-rw-r--r--vpn/java/android/net/vpn/VpnManager.java88
-rw-r--r--vpn/java/android/net/vpn/VpnProfile.java3
-rw-r--r--vpn/java/android/net/vpn/VpnState.java4
-rw-r--r--vpn/java/android/net/vpn/VpnType.java4
6 files changed, 26 insertions, 77 deletions
diff --git a/vpn/java/android/net/vpn/L2tpIpsecProfile.java b/vpn/java/android/net/vpn/L2tpIpsecProfile.java
index a7e53d1..893afbe 100644
--- a/vpn/java/android/net/vpn/L2tpIpsecProfile.java
+++ b/vpn/java/android/net/vpn/L2tpIpsecProfile.java
@@ -23,6 +23,8 @@ import android.os.Parcel;
* {@hide}
*/
public class L2tpIpsecProfile extends SingleServerProfile {
+ private static final long serialVersionUID = 1L;
+
private String mUserCertificate;
private String mCaCertificate;
private String mUserkey;
diff --git a/vpn/java/android/net/vpn/L2tpProfile.java b/vpn/java/android/net/vpn/L2tpProfile.java
index ca4ef75..559590f 100644
--- a/vpn/java/android/net/vpn/L2tpProfile.java
+++ b/vpn/java/android/net/vpn/L2tpProfile.java
@@ -21,6 +21,8 @@ package android.net.vpn;
* {@hide}
*/
public class L2tpProfile extends SingleServerProfile {
+ private static final long serialVersionUID = 1L;
+
@Override
public VpnType getType() {
return VpnType.L2TP;
diff --git a/vpn/java/android/net/vpn/VpnManager.java b/vpn/java/android/net/vpn/VpnManager.java
index 6c6e52a..98795bd 100644
--- a/vpn/java/android/net/vpn/VpnManager.java
+++ b/vpn/java/android/net/vpn/VpnManager.java
@@ -48,19 +48,8 @@ public class VpnManager {
private static final String PACKAGE_PREFIX =
VpnManager.class.getPackage().getName() + ".";
- /** Action to start the activity of installing a new profile. */
- public static final String ACTION_VPN_INSTALL_PROFILE =
- PACKAGE_PREFIX + "INSTALL_PROFILE";
- /**
- * Key to the installation path in the intent of installing a new profile.
- */
- public static final String KEY_INSTALLATION_PATH = "install_path";
- public static final String DEFAULT_INSTALLATION_PATH =
- "/data/local/tmp/vpn";
-
- // Action to start VPN installation monitor service
- private static final String SERVICE_VPN_INSTALL_MONITOR =
- PACKAGE_PREFIX + "INSTALLATION_MONITOR";
+ // Action to start VPN service
+ private static final String ACTION_VPN_SERVICE = PACKAGE_PREFIX + "SERVICE";
// Action to start VPN settings
private static final String ACTION_VPN_SETTINGS = PACKAGE_PREFIX + "SETTINGS";
@@ -112,53 +101,29 @@ public class VpnManager {
}
}
- private String getServiceActionName(VpnType type) {
- return PACKAGE_PREFIX + type.getServiceName();
- }
-
/**
- * Starts the VPN service of the specified type.
+ * Starts the VPN service to establish VPN connection.
*/
- public boolean startService(VpnType type) {
- String serviceAction = getServiceActionName(type);
- if (serviceAction != null) {
- Log.i(TAG, "start service: " + serviceAction);
- mContext.startService(new Intent(serviceAction));
- return true;
- } else {
- Log.w(TAG, "unknown vpn type to start service for: " + type);
- return false;
- }
+ public void startVpnService() {
+ mContext.startService(new Intent(ACTION_VPN_SERVICE));
}
/**
- * Stops the VPN service of the specified type.
+ * Stops the VPN service.
*/
- public void stopService(VpnType type) {
- String serviceAction = getServiceActionName(type);
- if (serviceAction != null) {
- Log.i(TAG, "stop service for: " + type);
- mContext.stopService(new Intent(serviceAction));
- } else {
- Log.w(TAG, "unknown vpn type to stop service for: " + type);
- }
+ public void stopVpnService() {
+ mContext.stopService(new Intent(ACTION_VPN_SERVICE));
}
/**
- * Binds the specified ServiceConnection with the VPN service of the
- * specified type.
+ * Binds the specified ServiceConnection with the VPN service.
*/
- public boolean bindService(VpnType type, ServiceConnection c) {
- String serviceAction = getServiceActionName(type);
- if (serviceAction == null) {
- Log.w(TAG, "unknown vpn type to bind service for: " + type);
- return false;
- }
- if (!mContext.bindService(new Intent(serviceAction), c, 0)) {
- Log.w(TAG, "failed to connect to service: " + type);
+ public boolean bindVpnService(ServiceConnection c) {
+ if (!mContext.bindService(new Intent(ACTION_VPN_SERVICE), c, 0)) {
+ Log.w(TAG, "failed to connect to VPN service");
return false;
} else {
- Log.v(TAG, "succeeded to connect to service: " + type);
+ Log.d(TAG, "succeeded to connect to VPN service");
return true;
}
}
@@ -181,21 +146,6 @@ public class VpnManager {
mContext.unregisterReceiver(r);
}
- /**
- * Starts the installation monitor service.
- * The service monitors the default installtion path (under /data/local/tmp)
- * and automatically starts the activity to create a new profile when new
- * configuration files appear in that path.
- */
- public void startInstallationMonitorService() {
- mContext.startService(new Intent(SERVICE_VPN_INSTALL_MONITOR));
- }
-
- /** Stops the installation monitor service. */
- public void stopInstallationMonitorService() {
- mContext.stopService(new Intent(SERVICE_VPN_INSTALL_MONITOR));
- }
-
/** Starts the VPN settings activity. */
public void startSettingsActivity() {
Intent intent = new Intent(ACTION_VPN_SETTINGS);
@@ -203,14 +153,10 @@ public class VpnManager {
mContext.startActivity(intent);
}
- /**
- * Starts the activity to install a customized profile.
- * @param installPath the path where all the configuration files are located
- */
- public void startInstallProfileActivity(String installPath) {
- Intent intent = new Intent(ACTION_VPN_INSTALL_PROFILE);
- intent.putExtra(KEY_INSTALLATION_PATH, installPath);
+ /** Creates an intent to start the VPN settings activity. */
+ public Intent createSettingsActivityIntent() {
+ Intent intent = new Intent(ACTION_VPN_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mContext.startActivity(intent);
+ return intent;
}
}
diff --git a/vpn/java/android/net/vpn/VpnProfile.java b/vpn/java/android/net/vpn/VpnProfile.java
index 7cf2608..1bfc102 100644
--- a/vpn/java/android/net/vpn/VpnProfile.java
+++ b/vpn/java/android/net/vpn/VpnProfile.java
@@ -27,7 +27,8 @@ import java.io.Serializable;
* A VPN profile.
* {@hide}
*/
-public abstract class VpnProfile implements Parcelable {
+public abstract class VpnProfile implements Parcelable, Serializable {
+ private static final long serialVersionUID = 1L;
private String mName; // unique display name
private String mId; // unique identifier
private String mDomainSuffices; // space separated list
diff --git a/vpn/java/android/net/vpn/VpnState.java b/vpn/java/android/net/vpn/VpnState.java
index 78117e0..977d938 100644
--- a/vpn/java/android/net/vpn/VpnState.java
+++ b/vpn/java/android/net/vpn/VpnState.java
@@ -24,8 +24,10 @@ package android.net.vpn;
* {@link CONNECTED} if successful; back to {@link IDLE} if failed.
* When the connection is about to be torn down, it goes to
* {@link DISCONNECTING} and then {@link IDLE}.
+ * {@link CANCELLED} is a state when a VPN connection attempt is aborted, and
+ * is in transition to {@link IDLE}.
* {@hide}
*/
public enum VpnState {
- CONNECTING, DISCONNECTING, CONNECTED, IDLE
+ CONNECTING, DISCONNECTING, CANCELLED, CONNECTED, IDLE
}
diff --git a/vpn/java/android/net/vpn/VpnType.java b/vpn/java/android/net/vpn/VpnType.java
index dcf2078..91b0ea2 100644
--- a/vpn/java/android/net/vpn/VpnType.java
+++ b/vpn/java/android/net/vpn/VpnType.java
@@ -39,8 +39,4 @@ public enum VpnType {
public Class<? extends VpnProfile> getProfileClass() {
return mClass;
}
-
- public String getServiceName() {
- return this.toString();
- }
}