Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0a59b500 authored by Hung-ying Tyan's avatar Hung-ying Tyan
Browse files

Integrate VPN with new keystore and misc fixes.

* Changes
  + Pass intent to keystore when needed and hooks to resume from it.
  + Generate random, unique ID for profile instead of base64 from its
    name.
  + Add VPN to "Wirless controls" description.
  + Add credential storage to "Security & location" description.
  + More hints to set password and unlock dialogs in credential storage
    settings for actions that come from other processes.
  + Sort VPN profiles according to the names.
  + Replace Keystore with CertTool in L2tpIpsecEditor
parent eb7836f1
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -24,6 +24,13 @@
            android:layout_height="fill_parent"
            android:padding="15dip">

        <TextView android:id="@+id/cstor_access_dialog_hint_from_action"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textSize="@dimen/vpn_connect_normal_text_size"
                android:text="@string/cstor_access_dialog_hint_from_action"
                android:layout_marginBottom="10sp" />

        <TextView android:id="@+id/cstor_error"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
+6 −2
Original line number Diff line number Diff line
@@ -437,7 +437,7 @@
    <!-- Main Settings screen settings title for things like Wi-Fi, bluetooth, airplane mode.  This will take you to another screen with those settings. -->
    <string name="radio_controls_title">Wireless controls</string>
    <!-- Main Settings screen settings summary text for the "Wireless controls" setting -->
    <string name="radio_controls_summary">Manage Wi-Fi, Bluetooth, airplane mode, &amp; mobile networks</string>
    <string name="radio_controls_summary">Manage Wi-Fi, Bluetooth, airplane mode, mobile networks, &amp; VPNs</string>


    <!-- mobile network settings screen, setting check box title -->
@@ -488,7 +488,7 @@
    <!-- Main Settings screen setting option title for the item to take you the security and location screen -->
    <string name="security_settings_title">Security &amp; location</string>
    <!-- Main Settings screen setting option summary text for the item tot ake you to the security and location screen -->
    <string name="security_settings_summary">Set My Location, screen unlock, SIM card lock</string>
    <string name="security_settings_summary">Set My Location, screen unlock, SIM card lock, credential storage lock</string>
    <!-- In the security screen, the header title for settings related to  Passwords-->
    <string name="security_passwords_title">Passwords</string>

@@ -1946,6 +1946,8 @@ found in the list of installed applications.</string>
    <string name="cstor_access_summary">Allow applications to access secure certificates and other credentials</string>
    <!-- Title of dialog to enable/dislable access to credential storage -->
    <string name="cstor_access_dialog_title">Enter password</string>
    <!-- Description of dialog to enable/dislable access to credential storage from an action that requires the credential storage -->
    <string name="cstor_access_dialog_hint_from_action">This action requires enabling the credential storage. Please enter the password to enable it.</string>

    <!-- Title of preference to set storage password -->
    <string name="cstor_set_passwd_title">Set password</string>
@@ -1977,6 +1979,8 @@ found in the list of installed applications.</string>
    <string name="cstor_confirm_password">Confirm new password:</string>
    <!-- Description when user set up the storage for the very first time -->
    <string name="cstor_first_time_hint">You must set a password for the credential storage.</string>
    <!-- Description when user set up the storage for the very first time from an action that requires the credential storage-->
    <string name="cstor_first_time_hint_from_action">This action requires the credential storage but the storage has not been activated before. To activiate it, you must set a password for the credential storage.</string>
    <string name="cstor_password_error">Please enter the correct password.</string>
    <string name="cstor_password_error_reset_warning">Please enter the correct password. You have one more try to enter the correct password before the credential storage is erased.</string>
    <string name="cstor_password_error_reset_warning_plural">Please enter the correct password. You have %d more tries to enter the correct password before the credential storage is erased.</string>
+27 −6
Original line number Diff line number Diff line
@@ -577,8 +577,7 @@ public class SecuritySettings extends PreferenceActivity implements
                    : R.string.cstor_password_error);
            if (count <= 3) {
                if (count == 1) {
                    v.setText(getString(
                            R.string.cstor_password_error_reset_warning));
                    v.setText(R.string.cstor_password_error_reset_warning);
                } else {
                    String format = getString(
                            R.string.cstor_password_error_reset_warning_plural);
@@ -691,11 +690,15 @@ public class SecuritySettings extends PreferenceActivity implements
            return v;
        }

        private void hideError() {
            View v = mView.findViewById(R.id.cstor_error);
        private void hide(int viewId) {
            View v = mView.findViewById(viewId);
            if (v != null) v.setVisibility(View.GONE);
        }

        private void hideError() {
            hide(R.id.cstor_error);
        }

        private String getText(int viewId) {
            return ((TextView) mView.findViewById(viewId)).getText().toString();
        }
@@ -705,6 +708,11 @@ public class SecuritySettings extends PreferenceActivity implements
            if (v != null) v.setText(text);
        }

        private void setText(int viewId, int textId) {
            TextView v = (TextView) mView.findViewById(viewId);
            if (v != null) v.setText(textId);
        }

        private void enablePreferences(boolean enabled) {
            mAccessCheckBox.setEnabled(enabled);
            mResetButton.setEnabled(enabled);
@@ -773,6 +781,12 @@ public class SecuritySettings extends PreferenceActivity implements
                    R.layout.cstor_unlock_dialog_view, null);
            hideError();

            // show extra hint only when the action comes from outside
            if ((mSpecialIntent == null)
                    && (mCstorAddCredentialHelper == null)) {
                hide(R.id.cstor_access_dialog_hint_from_action);
            }

            Dialog d = new AlertDialog.Builder(SecuritySettings.this)
                    .setView(mView)
                    .setTitle(R.string.cstor_access_dialog_title)
@@ -790,6 +804,13 @@ public class SecuritySettings extends PreferenceActivity implements
                    R.layout.cstor_set_password_dialog_view, null);
            hideError();

            // show extra hint only when the action comes from outside
            if ((mSpecialIntent != null)
                    || (mCstorAddCredentialHelper != null)) {
                setText(R.id.cstor_first_time_hint,
                        R.string.cstor_first_time_hint_from_action);
            }

            switch (id) {
                case CSTOR_INIT_DIALOG:
                    mView.findViewById(R.id.cstor_old_password_block)
@@ -835,9 +856,9 @@ public class SecuritySettings extends PreferenceActivity implements
            hideError();

            setText(R.id.cstor_credential_name_title,
                    getString(R.string.cstor_credential_name));
                    R.string.cstor_credential_name);
            setText(R.id.cstor_credential_info_title,
                    getString(R.string.cstor_credential_info));
                    R.string.cstor_credential_info);
            setText(R.id.cstor_credential_info,
                    mCstorAddCredentialHelper.getDescription().toString());

+0 −6
Original line number Diff line number Diff line
@@ -60,12 +60,6 @@ class L2tpEditor extends VpnProfileEditor {
                : validate(mSecretString, R.string.vpn_l2tp_secret));
    }

    @Override
    public void saveSecrets(String originalProfileName) {
        L2tpProfile profile = (L2tpProfile) getProfile();
        // TODO: fill up the implementation after keystore is available
    }

    private Preference createSecretPreference(Context c) {
        final L2tpProfile profile = (L2tpProfile) getProfile();
        CheckBoxPreference secret = mSecret = new CheckBoxPreference(c);
+3 −3
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceGroup;
import android.security.Keystore;
import android.security.CertTool;
import android.text.TextUtils;

/**
@@ -67,7 +67,7 @@ class L2tpIpsecEditor extends L2tpEditor {
        mUserCertificate = createListPreference(c,
                R.string.vpn_user_certificate_title,
                mProfile.getUserCertificate(),
                Keystore.getInstance().getAllUserCertificateKeys(),
                CertTool.getInstance().getAllUserCertificateKeys(),
                new Preference.OnPreferenceChangeListener() {
                    public boolean onPreferenceChange(
                            Preference pref, Object newValue) {
@@ -86,7 +86,7 @@ class L2tpIpsecEditor extends L2tpEditor {
        mCaCertificate = createListPreference(c,
                R.string.vpn_ca_certificate_title,
                mProfile.getCaCertificate(),
                Keystore.getInstance().getAllCaCertificateKeys(),
                CertTool.getInstance().getAllCaCertificateKeys(),
                new Preference.OnPreferenceChangeListener() {
                    public boolean onPreferenceChange(
                            Preference pref, Object newValue) {
Loading