diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2011-03-03 17:07:39 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-03-03 17:07:39 -0800 |
commit | a4fb8c868459ac0cf763916555c4e9963965242c (patch) | |
tree | 6edd5025af7de596738a6a52ffdae921f7643294 /src/com/android/settings/ApnEditor.java | |
parent | 9d76873546bb680d67a980dafd1b95de1b7c9f6c (diff) | |
parent | f4393101f80f0ca1a10771613a18565323b69fa2 (diff) | |
download | packages_apps_Settings-a4fb8c868459ac0cf763916555c4e9963965242c.zip packages_apps_Settings-a4fb8c868459ac0cf763916555c4e9963965242c.tar.gz packages_apps_Settings-a4fb8c868459ac0cf763916555c4e9963965242c.tar.bz2 |
am f4393101: Merge "Support configuring the protocol in APN settings." into gingerbread
* commit 'f4393101f80f0ca1a10771613a18565323b69fa2':
Support configuring the protocol in APN settings.
Diffstat (limited to 'src/com/android/settings/ApnEditor.java')
-rw-r--r-- | src/com/android/settings/ApnEditor.java | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/src/com/android/settings/ApnEditor.java b/src/com/android/settings/ApnEditor.java index 3f0c02f..0dbc99f 100644 --- a/src/com/android/settings/ApnEditor.java +++ b/src/com/android/settings/ApnEditor.java @@ -38,6 +38,7 @@ import android.view.Menu; import android.view.MenuItem; import com.android.internal.telephony.TelephonyProperties; +import com.android.internal.telephony.RILConstants; public class ApnEditor extends PreferenceActivity @@ -48,6 +49,7 @@ public class ApnEditor extends PreferenceActivity private final static String SAVED_POS = "pos"; private final static String KEY_AUTH_TYPE = "auth_type"; + private final static String KEY_PROTOCOL = "apn_protocol"; private static final int MENU_DELETE = Menu.FIRST; private static final int MENU_SAVE = Menu.FIRST + 1; @@ -69,6 +71,7 @@ public class ApnEditor extends PreferenceActivity private EditTextPreference mMmsPort; private ListPreference mAuthType; private EditTextPreference mApnType; + private ListPreference mProtocol; private String mCurMnc; private String mCurMcc; @@ -99,6 +102,7 @@ public class ApnEditor extends PreferenceActivity Telephony.Carriers.MMSPORT, // 13 Telephony.Carriers.AUTH_TYPE, // 14 Telephony.Carriers.TYPE, // 15 + Telephony.Carriers.PROTOCOL, // 16 }; private static final int ID_INDEX = 0; @@ -116,6 +120,7 @@ public class ApnEditor extends PreferenceActivity private static final int MMSPORT_INDEX = 13; private static final int AUTH_TYPE_INDEX = 14; private static final int TYPE_INDEX = 15; + private static final int PROTOCOL_INDEX = 16; @Override @@ -139,9 +144,12 @@ public class ApnEditor extends PreferenceActivity mMnc = (EditTextPreference) findPreference("apn_mnc"); mApnType = (EditTextPreference) findPreference("apn_type"); - mAuthType = (ListPreference) findPreference("auth_type"); + mAuthType = (ListPreference) findPreference(KEY_AUTH_TYPE); mAuthType.setOnPreferenceChangeListener(this); + mProtocol = (ListPreference) findPreference(KEY_PROTOCOL); + mProtocol.setOnPreferenceChangeListener(this); + mRes = getResources(); final Intent intent = getIntent(); @@ -238,6 +246,7 @@ public class ApnEditor extends PreferenceActivity mAuthType.setValue(null); } + mProtocol.setValue(mCursor.getString(PROTOCOL_INDEX)); } mName.setSummary(checkNull(mName.getText())); @@ -264,6 +273,28 @@ public class ApnEditor extends PreferenceActivity } else { mAuthType.setSummary(sNotSet); } + + mProtocol.setSummary( + checkNull(protocolDescription(mProtocol.getValue()))); + } + + /** + * Returns the UI choice (e.g., "IPv4/IPv6") corresponding to the given + * raw value of the protocol preference (e.g., "IPV4V6"). If unknown, + * return null. + */ + private String protocolDescription(String raw) { + int protocolIndex = mProtocol.findIndexOfValue(raw); + if (protocolIndex == -1) { + return null; + } else { + String[] values = mRes.getStringArray(R.array.apn_protocol_entries); + try { + return values[protocolIndex]; + } catch (ArrayIndexOutOfBoundsException e) { + return null; + } + } } public boolean onPreferenceChange(Preference preference, Object newValue) { @@ -278,6 +309,16 @@ public class ApnEditor extends PreferenceActivity } catch (NumberFormatException e) { return false; } + return true; + } + + if (KEY_PROTOCOL.equals(key)) { + String protocol = protocolDescription((String) newValue); + if (protocol == null) { + return false; + } + mProtocol.setSummary(protocol); + mProtocol.setValue((String) newValue); } return true; } @@ -389,6 +430,13 @@ public class ApnEditor extends PreferenceActivity values.put(Telephony.Carriers.AUTH_TYPE, Integer.parseInt(authVal)); } + values.put(Telephony.Carriers.PROTOCOL, checkNotSet(mProtocol.getValue())); + + // Hardcode IPv4 roaming for now until the carriers sort out all the + // billing arrangements. + values.put(Telephony.Carriers.ROAMING_PROTOCOL, + RILConstants.SETUP_DATA_PROTOCOL_IP); + values.put(Telephony.Carriers.TYPE, checkNotSet(mApnType.getText())); values.put(Telephony.Carriers.MCC, mcc); |