Add encryption option to PPTP UI.
Also add new error dialogs for L2TP challenge error and remote server hanging up error.
This commit is contained in:
@@ -1848,8 +1848,10 @@ found in the list of installed applications.</string>
|
||||
<string name="vpn_confirm_edit_profile_cancellation">Are you sure you want to discard the changes made to this profile?</string>
|
||||
<string name="vpn_confirm_reconnect">Unable to connect to the network. Do you want to try again?</string>
|
||||
<string name="vpn_unknown_server_dialog_msg">Server name cannot be resolved. Do you want to check your server name setting?</string>
|
||||
<string name="vpn_challenge_error_dialog_msg">Challenge error. Do you want to check your secret setting?</string>
|
||||
<string name="vpn_secret_not_set_dialog_msg">One or more secrets are missing in this VPN configuration. Do you want to check your secret setting?</string>
|
||||
<string name="vpn_auth_error_dialog_msg">The username or password you entered is incorrect. Do you want to try again?</string>
|
||||
<string name="vpn_remote_hung_up_error_dialog_msg">Server hung up. The username or password you entered could be incorrect. Do you want to try again?</string>
|
||||
|
||||
<!-- VPN type selection activity title -->
|
||||
<string name="vpn_type_title">Add VPN</string>
|
||||
@@ -1895,6 +1897,8 @@ found in the list of installed applications.</string>
|
||||
<!-- Complete term -->
|
||||
<string name="vpn_l2tp_secret">L2TP secret</string>
|
||||
<string name="vpn_a_l2tp_secret">an L2TP secret</string>
|
||||
<string name="vpn_pptp_encryption_title">encryption</string>
|
||||
<string name="vpn_pptp_encryption">PPTP encryption</string>
|
||||
|
||||
<!-- Preference title -->
|
||||
<string name="vpn_ipsec_presharedkey_title">Set IPSec pre-shared key</string>
|
||||
|
75
src/com/android/settings/vpn/PptpEditor.java
Normal file
75
src/com/android/settings/vpn/PptpEditor.java
Normal file
@@ -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)));
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user