diff --git a/res/values/strings.xml b/res/values/strings.xml
index 108bd5f9aed..5d89800df50 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1848,8 +1848,10 @@ found in the list of installed applications.
Are you sure you want to discard the changes made to this profile?
Unable to connect to the network. Do you want to try again?
Server name cannot be resolved. Do you want to check your server name setting?
+ Challenge error. Do you want to check your secret setting?
One or more secrets are missing in this VPN configuration. Do you want to check your secret setting?
The username or password you entered is incorrect. Do you want to try again?
+ Server hung up. The username or password you entered could be incorrect. Do you want to try again?
Add VPN
@@ -1895,6 +1897,8 @@ found in the list of installed applications.
L2TP secret
an L2TP secret
+ encryption
+ PPTP encryption
Set IPSec pre-shared key
diff --git a/src/com/android/settings/vpn/PptpEditor.java b/src/com/android/settings/vpn/PptpEditor.java
new file mode 100644
index 00000000000..fafe6a76bb7
--- /dev/null
+++ b/src/com/android/settings/vpn/PptpEditor.java
@@ -0,0 +1,75 @@
+/* * Copyright (C) 2009 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 com.android.settings.vpn;
+
+import com.android.settings.R;
+
+import android.content.Context;
+import android.net.vpn.PptpProfile;
+import android.preference.CheckBoxPreference;
+import android.preference.Preference;
+import android.preference.PreferenceGroup;
+
+/**
+ * The class for editing {@link PptpProfile}.
+ */
+class PptpEditor extends VpnProfileEditor {
+ private CheckBoxPreference mEncryption;
+
+ public PptpEditor(PptpProfile p) {
+ super(p);
+ }
+
+ @Override
+ protected void loadExtraPreferencesTo(PreferenceGroup subpanel) {
+ Context c = subpanel.getContext();
+ subpanel.addPreference(createEncryptionPreference(c));
+
+ PptpProfile profile = (PptpProfile) getProfile();
+ }
+
+ private Preference createEncryptionPreference(Context c) {
+ final PptpProfile profile = (PptpProfile) getProfile();
+ CheckBoxPreference encryption = mEncryption = new CheckBoxPreference(c);
+ boolean enabled = profile.isEncryptionEnabled();
+ setSecretTitle(encryption, R.string.vpn_pptp_encryption_title, enabled);
+ encryption.setChecked(enabled);
+ setEncryptionSummary(encryption, enabled);
+ encryption.setOnPreferenceChangeListener(
+ new Preference.OnPreferenceChangeListener() {
+ public boolean onPreferenceChange(
+ Preference pref, Object newValue) {
+ boolean enabled = (Boolean) newValue;
+ profile.setEncryptionEnabled(enabled);
+ setSecretTitle(mEncryption,
+ R.string.vpn_pptp_encryption_title, enabled);
+ setEncryptionSummary(mEncryption, enabled);
+ return true;
+ }
+ });
+ return encryption;
+ }
+
+ private void setEncryptionSummary(CheckBoxPreference encryption,
+ boolean enabled) {
+ Context c = encryption.getContext();
+ String formatString = c.getString(enabled
+ ? R.string.vpn_is_enabled
+ : R.string.vpn_is_disabled);
+ encryption.setSummary(String.format(
+ formatString, c.getString(R.string.vpn_pptp_encryption)));
+ }
+}
diff --git a/src/com/android/settings/vpn/VpnEditor.java b/src/com/android/settings/vpn/VpnEditor.java
index 162c129956e..497f4bfa42b 100644
--- a/src/com/android/settings/vpn/VpnEditor.java
+++ b/src/com/android/settings/vpn/VpnEditor.java
@@ -24,6 +24,7 @@ import android.content.Intent;
import android.net.vpn.L2tpIpsecProfile;
import android.net.vpn.L2tpIpsecPskProfile;
import android.net.vpn.L2tpProfile;
+import android.net.vpn.PptpProfile;
import android.net.vpn.VpnProfile;
import android.net.vpn.VpnType;
import android.os.Bundle;
@@ -162,6 +163,9 @@ public class VpnEditor extends PreferenceActivity {
case L2TP:
return new L2tpEditor((L2tpProfile) p);
+ case PPTP:
+ return new PptpEditor((PptpProfile) p);
+
default:
return new VpnProfileEditor(p);
}
diff --git a/src/com/android/settings/vpn/VpnSettings.java b/src/com/android/settings/vpn/VpnSettings.java
index 0dc171971e0..4dda152793f 100644
--- a/src/com/android/settings/vpn/VpnSettings.java
+++ b/src/com/android/settings/vpn/VpnSettings.java
@@ -109,6 +109,8 @@ public class VpnSettings extends PreferenceActivity implements
private static final int DIALOG_AUTH_ERROR = 3;
private static final int DIALOG_UNKNOWN_SERVER = 4;
private static final int DIALOG_SECRET_NOT_SET = 5;
+ private static final int DIALOG_CHALLENGE_ERROR = 6;
+ private static final int DIALOG_REMOTE_HUNG_UP_ERROR = 7;
private static final int NO_ERROR = 0;
@@ -204,6 +206,12 @@ public class VpnSettings extends PreferenceActivity implements
case DIALOG_AUTH_ERROR:
return createAuthErrorDialog();
+ case DIALOG_REMOTE_HUNG_UP_ERROR:
+ return createRemoteHungUpErrorDialog();
+
+ case DIALOG_CHALLENGE_ERROR:
+ return createChallengeErrorDialog();
+
case DIALOG_UNKNOWN_SERVER:
return createUnknownServerDialog();
@@ -244,17 +252,22 @@ public class VpnSettings extends PreferenceActivity implements
.setMessage(R.string.vpn_auth_error_dialog_msg)
.create();
}
- private Dialog createUnknownServerDialog() {
+
+ private Dialog createRemoteHungUpErrorDialog() {
return createCommonDialogBuilder()
+ .setMessage(R.string.vpn_remote_hung_up_error_dialog_msg)
+ .create();
+ }
+
+ private Dialog createChallengeErrorDialog() {
+ return createCommonEditDialogBuilder()
+ .setMessage(R.string.vpn_challenge_error_dialog_msg)
+ .create();
+ }
+
+ private Dialog createUnknownServerDialog() {
+ return createCommonEditDialogBuilder()
.setMessage(R.string.vpn_unknown_server_dialog_msg)
- .setPositiveButton(R.string.vpn_yes_button,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int w) {
- VpnProfile p = mConnectingActor.getProfile();
- onIdle();
- startVpnEditor(p);
- }
- })
.create();
}
@@ -271,6 +284,18 @@ public class VpnSettings extends PreferenceActivity implements
.create();
}
+ private AlertDialog.Builder createCommonEditDialogBuilder() {
+ return createCommonDialogBuilder()
+ .setPositiveButton(R.string.vpn_yes_button,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int w) {
+ VpnProfile p = mConnectingActor.getProfile();
+ onIdle();
+ startVpnEditor(p);
+ }
+ });
+ }
+
private AlertDialog.Builder createCommonDialogBuilder() {
return new AlertDialog.Builder(this)
.setTitle(android.R.string.dialog_alert_title)
@@ -723,6 +748,14 @@ public class VpnSettings extends PreferenceActivity implements
showDialog(DIALOG_AUTH_ERROR);
break;
+ case VpnManager.VPN_ERROR_REMOTE_HUNG_UP:
+ showDialog(DIALOG_REMOTE_HUNG_UP_ERROR);
+ break;
+
+ case VpnManager.VPN_ERROR_CHALLENGE:
+ showDialog(DIALOG_CHALLENGE_ERROR);
+ break;
+
case VpnManager.VPN_ERROR_UNKNOWN_SERVER:
showDialog(DIALOG_UNKNOWN_SERVER);
break;