Simply the EAP certificate selection in Wifi Setting.
-- use the new keystore APU to save one more selection in WiFi EAP setting.
This commit is contained in:
@@ -109,15 +109,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="2dip"
|
android:layout_marginTop="2dip"
|
||||||
android:singleLine="true" />
|
android:singleLine="true" />
|
||||||
<TextView android:id="@+id/client_certificate_text"
|
|
||||||
style="?android:attr/textAppearanceSmallInverse"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="8dip"
|
|
||||||
android:text="@string/please_select_client_certificate" />
|
|
||||||
<Spinner android:id="@+id/client_certificate_spinner"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
<TextView android:id="@+id/ca_certificate_text"
|
<TextView android:id="@+id/ca_certificate_text"
|
||||||
style="?android:attr/textAppearanceSmallInverse"
|
style="?android:attr/textAppearanceSmallInverse"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
@@ -127,13 +118,13 @@
|
|||||||
<Spinner android:id="@+id/ca_certificate_spinner"
|
<Spinner android:id="@+id/ca_certificate_spinner"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
<TextView android:id="@+id/private_key_text"
|
<TextView android:id="@+id/client_certificate_text"
|
||||||
style="?android:attr/textAppearanceSmallInverse"
|
style="?android:attr/textAppearanceSmallInverse"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dip"
|
android:layout_marginTop="8dip"
|
||||||
android:text="@string/please_select_private_key" />
|
android:text="@string/please_select_client_certificate" />
|
||||||
<Spinner android:id="@+id/private_key_spinner"
|
<Spinner android:id="@+id/client_certificate_spinner"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
<TextView android:id="@+id/private_key_passwd_text"
|
<TextView android:id="@+id/private_key_passwd_text"
|
||||||
|
@@ -674,8 +674,6 @@
|
|||||||
<!-- Caption for the ca certificate -->
|
<!-- Caption for the ca certificate -->
|
||||||
<string name="please_select_ca_certificate">CA certificate</string>
|
<string name="please_select_ca_certificate">CA certificate</string>
|
||||||
<!-- Caption for the Private Key -->
|
<!-- Caption for the Private Key -->
|
||||||
<string name="please_select_private_key">Private key</string>
|
|
||||||
<!-- Caption for the private key passwd -->
|
|
||||||
<string name="please_type_private_key_passwd">Private key password</string>
|
<string name="please_type_private_key_passwd">Private key password</string>
|
||||||
<!-- Caption for the wireless password -->
|
<!-- Caption for the wireless password -->
|
||||||
<string name="please_type_passphrase">Wireless password</string>
|
<string name="please_type_passphrase">Wireless password</string>
|
||||||
|
@@ -111,16 +111,13 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
|
|||||||
private EditText mIdentityEdit;
|
private EditText mIdentityEdit;
|
||||||
private TextView mAnonymousIdentityText;
|
private TextView mAnonymousIdentityText;
|
||||||
private EditText mAnonymousIdentityEdit;
|
private EditText mAnonymousIdentityEdit;
|
||||||
private TextView mClientCertText;
|
|
||||||
private Spinner mClientCertSpinner;
|
|
||||||
private TextView mCaCertText;
|
private TextView mCaCertText;
|
||||||
private Spinner mCaCertSpinner;
|
private Spinner mCaCertSpinner;
|
||||||
private TextView mPrivateKeyText;
|
private TextView mClientCertText;
|
||||||
private Spinner mPrivateKeySpinner;
|
private Spinner mClientCertSpinner;
|
||||||
private TextView mPrivateKeyPasswdText;
|
private TextView mPrivateKeyPasswdText;
|
||||||
private EditText mPrivateKeyPasswdEdit;
|
private EditText mPrivateKeyPasswdEdit;
|
||||||
private EditText[] mEnterpriseTextFields;
|
private EditText[] mEnterpriseTextFields;
|
||||||
private Spinner[] mEnterpriseSpinnerFields;
|
|
||||||
|
|
||||||
|
|
||||||
// Info-specific views
|
// Info-specific views
|
||||||
@@ -330,23 +327,20 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
|
|||||||
mEapSpinner.setSelection(getSelectionIndex(
|
mEapSpinner.setSelection(getSelectionIndex(
|
||||||
R.array.wifi_eap_entries, mState.getEap()));
|
R.array.wifi_eap_entries, mState.getEap()));
|
||||||
mClientCertSpinner.setSelection(getSelectionIndex(
|
mClientCertSpinner.setSelection(getSelectionIndex(
|
||||||
getAllCertificateKeys(), mState.getEnterpriseField(
|
getAllUserCertificateKeys(), mState.getEnterpriseField(
|
||||||
AccessPointState.CLIENT_CERT)));
|
AccessPointState.CLIENT_CERT)));
|
||||||
mCaCertSpinner.setSelection(getSelectionIndex(
|
mCaCertSpinner.setSelection(getSelectionIndex(
|
||||||
getAllCertificateKeys(), mState.getEnterpriseField(
|
getAllCaCertificateKeys(), mState.getEnterpriseField(
|
||||||
AccessPointState.CA_CERT)));
|
AccessPointState.CA_CERT)));
|
||||||
mPrivateKeySpinner.setSelection(getSelectionIndex(
|
|
||||||
getAllUserkeyKeys(), mState.getEnterpriseField(
|
|
||||||
AccessPointState.PRIVATE_KEY)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] getAllCertificateKeys() {
|
private String[] getAllCaCertificateKeys() {
|
||||||
return appendEmptyInSelection(mKeystore.getAllCertificateKeys());
|
return appendEmptyInSelection(mKeystore.getAllCaCertificateKeys());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] getAllUserkeyKeys() {
|
private String[] getAllUserCertificateKeys() {
|
||||||
return appendEmptyInSelection(mKeystore.getAllUserkeyKeys());
|
return appendEmptyInSelection(mKeystore.getAllUserCertificateKeys());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] appendEmptyInSelection(String[] keys) {
|
private String[] appendEmptyInSelection(String[] keys) {
|
||||||
@@ -367,9 +361,6 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
|
|||||||
mClientCertText =
|
mClientCertText =
|
||||||
(TextView) view.findViewById(R.id.client_certificate_text);
|
(TextView) view.findViewById(R.id.client_certificate_text);
|
||||||
mCaCertText = (TextView) view.findViewById(R.id.ca_certificate_text);
|
mCaCertText = (TextView) view.findViewById(R.id.ca_certificate_text);
|
||||||
mPrivateKeyText = (TextView) view.findViewById(R.id.private_key_text);
|
|
||||||
mPrivateKeyPasswdText =
|
|
||||||
(TextView) view.findViewById(R.id.private_key_passwd_text);
|
|
||||||
mPrivateKeyPasswdEdit =
|
mPrivateKeyPasswdEdit =
|
||||||
(EditText) view.findViewById(R.id.private_key_passwd_edit);
|
(EditText) view.findViewById(R.id.private_key_passwd_edit);
|
||||||
mEapText = (TextView) view.findViewById(R.id.eap_text);
|
mEapText = (TextView) view.findViewById(R.id.eap_text);
|
||||||
@@ -389,28 +380,18 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
|
|||||||
mClientCertSpinner.setOnItemSelectedListener(this);
|
mClientCertSpinner.setOnItemSelectedListener(this);
|
||||||
mClientCertSpinner.setPromptId(
|
mClientCertSpinner.setPromptId(
|
||||||
R.string.please_select_client_certificate);
|
R.string.please_select_client_certificate);
|
||||||
setSpinnerAdapter(mClientCertSpinner, getAllCertificateKeys());
|
setSpinnerAdapter(mClientCertSpinner, getAllUserCertificateKeys());
|
||||||
|
|
||||||
mCaCertSpinner =
|
mCaCertSpinner =
|
||||||
(Spinner) view.findViewById(R.id.ca_certificate_spinner);
|
(Spinner) view.findViewById(R.id.ca_certificate_spinner);
|
||||||
mCaCertSpinner.setOnItemSelectedListener(this);
|
mCaCertSpinner.setOnItemSelectedListener(this);
|
||||||
mCaCertSpinner.setPromptId(R.string.please_select_ca_certificate);
|
mCaCertSpinner.setPromptId(R.string.please_select_ca_certificate);
|
||||||
setSpinnerAdapter(mCaCertSpinner, getAllCertificateKeys());
|
setSpinnerAdapter(mCaCertSpinner, getAllCaCertificateKeys());
|
||||||
|
|
||||||
mPrivateKeySpinner =
|
|
||||||
(Spinner) view.findViewById(R.id.private_key_spinner);
|
|
||||||
mPrivateKeySpinner.setOnItemSelectedListener(this);
|
|
||||||
mPrivateKeySpinner.setPromptId(R.string.please_select_private_key);
|
|
||||||
setSpinnerAdapter(mPrivateKeySpinner, getAllUserkeyKeys());
|
|
||||||
|
|
||||||
mEnterpriseTextFields = new EditText[] {
|
mEnterpriseTextFields = new EditText[] {
|
||||||
mIdentityEdit, mAnonymousIdentityEdit, mPrivateKeyPasswdEdit
|
mIdentityEdit, mAnonymousIdentityEdit, mPrivateKeyPasswdEdit
|
||||||
};
|
};
|
||||||
|
|
||||||
mEnterpriseSpinnerFields = new Spinner[] {
|
|
||||||
mClientCertSpinner, mCaCertSpinner, mPrivateKeySpinner
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSpinnerAdapter(Spinner spinner, String[] items) {
|
private void setSpinnerAdapter(Spinner spinner, String[] items) {
|
||||||
@@ -656,33 +637,40 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
|
|||||||
|
|
||||||
private void updateEnterpriseFields(int securityType) {
|
private void updateEnterpriseFields(int securityType) {
|
||||||
int i;
|
int i;
|
||||||
for (i = AccessPointState.IDENTITY ;
|
|
||||||
i < AccessPointState.MAX_ENTRPRISE_FIELD ; i++) {
|
|
||||||
String value;
|
String value;
|
||||||
if (i <= AccessPointState.PRIVATE_KEY_PASSWD) {
|
for (i = AccessPointState.IDENTITY ;
|
||||||
|
i <= AccessPointState.PRIVATE_KEY_PASSWD ; i++) {
|
||||||
value = mEnterpriseTextFields[i].getText().toString();
|
value = mEnterpriseTextFields[i].getText().toString();
|
||||||
} else {
|
|
||||||
Spinner spinner = mEnterpriseSpinnerFields[i -
|
|
||||||
AccessPointState.CLIENT_CERT];
|
|
||||||
int index = spinner.getSelectedItemPosition();
|
|
||||||
if (index == (spinner.getCount() - 1)) {
|
|
||||||
value = "";
|
|
||||||
} else {
|
|
||||||
if (i != AccessPointState.PRIVATE_KEY) {
|
|
||||||
value = mKeystore.getCertificate(
|
|
||||||
getAllCertificateKeys()[index]);
|
|
||||||
} else {
|
|
||||||
value = mKeystore.getUserkey(
|
|
||||||
getAllUserkeyKeys()[index]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!TextUtils.isEmpty(value) ||
|
if (!TextUtils.isEmpty(value) ||
|
||||||
(i == AccessPointState.PRIVATE_KEY_PASSWD)) {
|
(i == AccessPointState.PRIVATE_KEY_PASSWD)) {
|
||||||
mState.setEnterpriseField(i, value);
|
mState.setEnterpriseField(i, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Spinner spinner = mClientCertSpinner;
|
||||||
|
int index = spinner.getSelectedItemPosition();
|
||||||
|
if (index != (spinner.getCount() - 1)) {
|
||||||
|
String key = getAllUserCertificateKeys()[index];
|
||||||
|
value = mKeystore.getUserCertificate(key);
|
||||||
|
if (!TextUtils.isEmpty(value)) {
|
||||||
|
mState.setEnterpriseField(AccessPointState.CLIENT_CERT,
|
||||||
|
value);
|
||||||
|
}
|
||||||
|
value = mKeystore.getUserPrivateKey(key);
|
||||||
|
if (!TextUtils.isEmpty(value)) {
|
||||||
|
mState.setEnterpriseField(AccessPointState.PRIVATE_KEY,
|
||||||
|
value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spinner = mCaCertSpinner;
|
||||||
|
index = spinner.getSelectedItemPosition();
|
||||||
|
if (index != (spinner.getCount() - 1)) {
|
||||||
|
String key = getAllCaCertificateKeys()[index];
|
||||||
|
value = mKeystore.getCaCertificate(key);
|
||||||
|
if (!TextUtils.isEmpty(value)) {
|
||||||
|
mState.setEnterpriseField(AccessPointState.CA_CERT,
|
||||||
|
value);
|
||||||
|
}
|
||||||
|
}
|
||||||
switch (securityType) {
|
switch (securityType) {
|
||||||
case SECURITY_WPA_EAP: {
|
case SECURITY_WPA_EAP: {
|
||||||
mState.setSecurity(AccessPointState.WPA_EAP);
|
mState.setSecurity(AccessPointState.WPA_EAP);
|
||||||
|
Reference in New Issue
Block a user