Add Authentication Type field to the APN settings.

Bug: 1817100
This commit is contained in:
Jaikumar Ganesh
2009-10-26 13:01:36 -07:00
parent b3735744fd
commit 195bc43460
3 changed files with 115 additions and 41 deletions

View File

@@ -291,4 +291,23 @@
<item>中文 (繁體)</item> <item>中文 (繁體)</item>
</string-array> </string-array>
<!-- Authentication Types used in APN editor -->
<string-array name="apn_auth_entries">
<item>None</item>
<item>PAP</item>
<item>CHAP</item>
<item>PAP or CHAP</item>
</string-array>
<string-array translatable="false" name="apn_auth_values">
<!-- Do not translate. -->
<item>0</item>
<!-- Do not translate. -->
<item>1</item>
<!-- Do not translate. -->
<item>2</item>
<!-- Do not translate. -->
<item>3</item>
</string-array>
</resources> </resources>

View File

@@ -101,6 +101,12 @@
android:singleLine="true" android:singleLine="true"
android:inputType="number" android:inputType="number"
/> />
<ListPreference
android:title="@string/apn_auth_type"
android:key="auth_type"
android:entries="@array/apn_auth_entries"
android:entryValues="@array/apn_auth_values"
/>
<EditTextPreference <EditTextPreference
android:title="@string/apn_type" android:title="@string/apn_type"
android:dialogTitle="@string/apn_type" android:dialogTitle="@string/apn_type"

View File

@@ -27,23 +27,26 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.preference.EditTextPreference; import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.provider.Telephony; import android.provider.Telephony;
import com.android.internal.telephony.TelephonyProperties;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import com.android.internal.telephony.TelephonyProperties;
public class ApnEditor extends PreferenceActivity public class ApnEditor extends PreferenceActivity
implements SharedPreferences.OnSharedPreferenceChangeListener { implements SharedPreferences.OnSharedPreferenceChangeListener,
Preference.OnPreferenceChangeListener {
private final static String TAG = ApnEditor.class.getSimpleName(); private final static String TAG = ApnEditor.class.getSimpleName();
private final static String SAVED_POS = "pos"; private final static String SAVED_POS = "pos";
private final static String KEY_AUTH_TYPE = "auth_type";
private static final int MENU_DELETE = Menu.FIRST; private static final int MENU_DELETE = Menu.FIRST;
private static final int MENU_SAVE = Menu.FIRST + 1; private static final int MENU_SAVE = Menu.FIRST + 1;
@@ -62,7 +65,9 @@ public class ApnEditor extends PreferenceActivity
private EditTextPreference mMnc; private EditTextPreference mMnc;
private EditTextPreference mMmsProxy; private EditTextPreference mMmsProxy;
private EditTextPreference mMmsPort; private EditTextPreference mMmsPort;
private ListPreference mAuthType;
private EditTextPreference mApnType; private EditTextPreference mApnType;
private String mCurMnc; private String mCurMnc;
private String mCurMcc; private String mCurMcc;
@@ -90,7 +95,8 @@ public class ApnEditor extends PreferenceActivity
Telephony.Carriers.NUMERIC, // 11 Telephony.Carriers.NUMERIC, // 11
Telephony.Carriers.MMSPROXY,// 12 Telephony.Carriers.MMSPROXY,// 12
Telephony.Carriers.MMSPORT, // 13 Telephony.Carriers.MMSPORT, // 13
Telephony.Carriers.TYPE, // 14 Telephony.Carriers.AUTH_TYPE, // 14
Telephony.Carriers.TYPE, // 15
}; };
private static final int ID_INDEX = 0; private static final int ID_INDEX = 0;
@@ -106,7 +112,9 @@ public class ApnEditor extends PreferenceActivity
private static final int MNC_INDEX = 10; private static final int MNC_INDEX = 10;
private static final int MMSPROXY_INDEX = 12; private static final int MMSPROXY_INDEX = 12;
private static final int MMSPORT_INDEX = 13; private static final int MMSPORT_INDEX = 13;
private static final int TYPE_INDEX = 14; private static final int AUTH_TYPE_INDEX = 14;
private static final int TYPE_INDEX = 15;
@Override @Override
protected void onCreate(Bundle icicle) { protected void onCreate(Bundle icicle) {
@@ -129,6 +137,9 @@ public class ApnEditor extends PreferenceActivity
mMnc = (EditTextPreference) findPreference("apn_mnc"); mMnc = (EditTextPreference) findPreference("apn_mnc");
mApnType = (EditTextPreference) findPreference("apn_type"); mApnType = (EditTextPreference) findPreference("apn_type");
mAuthType = (ListPreference) findPreference("auth_type");
mAuthType.setOnPreferenceChangeListener(this);
mRes = getResources(); mRes = getResources();
final Intent intent = getIntent(); final Intent intent = getIntent();
@@ -216,6 +227,11 @@ public class ApnEditor extends PreferenceActivity
mCurMcc = mcc; mCurMcc = mcc;
} }
} }
int authVal = mCursor.getInt(AUTH_TYPE_INDEX);
if (authVal != -1) {
mAuthType.setValueIndex(authVal);
}
} }
mName.setSummary(checkNull(mName.getText())); mName.setSummary(checkNull(mName.getText()));
@@ -231,6 +247,33 @@ public class ApnEditor extends PreferenceActivity
mMcc.setSummary(checkNull(mMcc.getText())); mMcc.setSummary(checkNull(mMcc.getText()));
mMnc.setSummary(checkNull(mMnc.getText())); mMnc.setSummary(checkNull(mMnc.getText()));
mApnType.setSummary(checkNull(mApnType.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 @Override
@@ -335,6 +378,12 @@ public class ApnEditor extends PreferenceActivity
values.put(Telephony.Carriers.SERVER, checkNotSet(mServer.getText())); values.put(Telephony.Carriers.SERVER, checkNotSet(mServer.getText()));
values.put(Telephony.Carriers.PASSWORD, checkNotSet(mPassword.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.TYPE, checkNotSet(mApnType.getText()));
values.put(Telephony.Carriers.MCC, mcc); values.put(Telephony.Carriers.MCC, mcc);