diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 6d8ca3268a2..6b8214c52dd 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -291,4 +291,23 @@
- 中文 (繁體)
+
+
+ - None
+ - PAP
+ - CHAP
+ - PAP or CHAP
+
+
+
+
+ - 0
+
+ - 1
+
+ - 2
+
+ - 3
+
+
diff --git a/res/xml/apn_editor.xml b/res/xml/apn_editor.xml
index 4ff801f1319..3835a2c0674 100644
--- a/res/xml/apn_editor.xml
+++ b/res/xml/apn_editor.xml
@@ -101,6 +101,12 @@
android:singleLine="true"
android:inputType="number"
/>
+
4) {
@@ -216,8 +227,13 @@ public class ApnEditor extends PreferenceActivity
mCurMcc = mcc;
}
}
+ int authVal = mCursor.getInt(AUTH_TYPE_INDEX);
+ if (authVal != -1) {
+ mAuthType.setValueIndex(authVal);
+ }
+
}
-
+
mName.setSummary(checkNull(mName.getText()));
mApn.setSummary(checkNull(mApn.getText()));
mProxy.setSummary(checkNull(mProxy.getText()));
@@ -231,6 +247,33 @@ public class ApnEditor extends PreferenceActivity
mMcc.setSummary(checkNull(mMcc.getText()));
mMnc.setSummary(checkNull(mMnc.getText()));
mApnType.setSummary(checkNull(mApnType.getText()));
+
+ String authVal = mAuthType.getValue();
+ if (authVal != null) {
+ int authValIndex = Integer.parseInt(authVal);
+ mAuthType.setValueIndex(authValIndex);
+
+ String []values = mRes.getStringArray(R.array.apn_auth_entries);
+ mAuthType.setSummary(values[authValIndex]);
+ } else {
+ mAuthType.setSummary(sNotSet);
+ }
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ String key = preference.getKey();
+ if (KEY_AUTH_TYPE.equals(key)) {
+ try {
+ int index = Integer.parseInt((String) newValue);
+ mAuthType.setValueIndex(index);
+
+ String []values = mRes.getStringArray(R.array.apn_auth_entries);
+ mAuthType.setSummary(values[index]);
+ } catch (NumberFormatException e) {
+ return false;
+ }
+ }
+ return true;
}
@Override
@@ -268,7 +311,7 @@ public class ApnEditor extends PreferenceActivity
}
return super.onOptionsItemSelected(item);
}
-
+
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
@@ -288,7 +331,7 @@ public class ApnEditor extends PreferenceActivity
validateAndSave(true);
icicle.putInt(SAVED_POS, mCursor.getInt(ID_INDEX));
}
-
+
/**
* Check the key fields' validity and save if valid.
* @param force save even if the fields are not valid, if the app is
@@ -300,7 +343,7 @@ public class ApnEditor extends PreferenceActivity
String apn = checkNotSet(mApn.getText());
String mcc = checkNotSet(mMcc.getText());
String mnc = checkNotSet(mMnc.getText());
-
+
String errorMsg = null;
if (name.length() < 1) {
errorMsg = mRes.getString(R.string.error_name_empty);
@@ -311,20 +354,20 @@ public class ApnEditor extends PreferenceActivity
} else if ((mnc.length() & 0xFFFE) != 2) {
errorMsg = mRes.getString(R.string.error_mnc_not23);
}
-
+
if (errorMsg != null && !force) {
showErrorMessage(errorMsg);
return false;
}
-
+
if (!mCursor.moveToFirst()) {
Log.w(TAG,
"Could not go to the first row in the Cursor when saving data.");
return false;
}
-
+
ContentValues values = new ContentValues();
-
+
values.put(Telephony.Carriers.NAME, name);
values.put(Telephony.Carriers.APN, apn);
values.put(Telephony.Carriers.PROXY, checkNotSet(mProxy.getText()));
@@ -334,22 +377,28 @@ public class ApnEditor extends PreferenceActivity
values.put(Telephony.Carriers.USER, checkNotSet(mUser.getText()));
values.put(Telephony.Carriers.SERVER, checkNotSet(mServer.getText()));
values.put(Telephony.Carriers.PASSWORD, checkNotSet(mPassword.getText()));
- values.put(Telephony.Carriers.MMSC, checkNotSet(mMmsc.getText()));
+ values.put(Telephony.Carriers.MMSC, checkNotSet(mMmsc.getText()));
+
+ String authVal = mAuthType.getValue();
+ if (authVal != null) {
+ values.put(Telephony.Carriers.AUTH_TYPE, Integer.parseInt(authVal));
+ }
+
values.put(Telephony.Carriers.TYPE, checkNotSet(mApnType.getText()));
values.put(Telephony.Carriers.MCC, mcc);
values.put(Telephony.Carriers.MNC, mnc);
-
+
values.put(Telephony.Carriers.NUMERIC, mcc + mnc);
-
+
if (mCurMnc != null && mCurMcc != null) {
if (mCurMnc.equals(mnc) && mCurMcc.equals(mcc)) {
values.put(Telephony.Carriers.CURRENT, 1);
}
}
-
+
getContentResolver().update(mUri, values, null, null);
-
+
return true;
}
@@ -365,7 +414,7 @@ public class ApnEditor extends PreferenceActivity
getContentResolver().delete(mUri, null, null);
finish();
}
-
+
private String starify(String value) {
if (value == null || value.length() == 0) {
return sNotSet;
@@ -377,7 +426,7 @@ public class ApnEditor extends PreferenceActivity
return new String(password);
}
}
-
+
private String checkNull(String value) {
if (value == null || value.length() == 0) {
return sNotSet;
@@ -385,7 +434,7 @@ public class ApnEditor extends PreferenceActivity
return value;
}
}
-
+
private String checkNotSet(String value) {
if (value == null || value.equals(sNotSet)) {
return "";
@@ -393,7 +442,7 @@ public class ApnEditor extends PreferenceActivity
return value;
}
}
-
+
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Preference pref = findPreference(key);
if (pref != null) {