summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2010-12-29 15:52:41 -0800
committerLorenzo Colitti <lorenzo@google.com>2011-02-04 13:17:15 -0800
commita7e587fc8d0bcf67fd387c5f9b58b1063c217ae5 (patch)
treed169f07acca7c333ce817d5e21b6aff9cb634e55
parent5ac151ccec75fc1eee4d0b606b126a5b18582c32 (diff)
downloadpackages_apps_settings-a7e587fc8d0bcf67fd387c5f9b58b1063c217ae5.zip
packages_apps_settings-a7e587fc8d0bcf67fd387c5f9b58b1063c217ae5.tar.gz
packages_apps_settings-a7e587fc8d0bcf67fd387c5f9b58b1063c217ae5.tar.bz2
Support configuring the protocol in APN settings.
Change-Id: I435061a631bdb2f58935af607abf8cd7c5d252ba
-rw-r--r--res/values/arrays.xml16
-rw-r--r--res/values/strings.xml2
-rw-r--r--res/xml/apn_editor.xml7
-rw-r--r--src/com/android/settings/ApnEditor.java44
4 files changed, 68 insertions, 1 deletions
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index cb45473..6d55264 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -464,6 +464,22 @@
<item>3</item>
</string-array>
+ <!-- Authentication Types used in APN editor -->
+ <string-array name="apn_protocol_entries">
+ <item>IPv4</item>
+ <item>IPv6</item>
+ <item>IPv4/IPv6</item>
+ </string-array>
+
+ <string-array translatable="false" name="apn_protocol_values">
+ <!-- Do not translate. -->
+ <item>IP</item>
+ <!-- Do not translate. -->
+ <item>IPV6</item>
+ <!-- Do not translate. -->
+ <item>IPV4V6</item>
+ </string-array>
+
<!-- Apps on SD instalaltion location options in ApplicationSettings -->
<string-array name="app_install_location_entries">
<item>Internal device storage</item>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index fb1ec8c..5cc4d73 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1677,6 +1677,8 @@
<string name="apn_auth_type_pap_chap">PAP or CHAP</string>
<!-- Edit access point labels: The type of APN -->
<string name="apn_type">APN type</string>
+ <!-- Edit access point labels: The protocol of the APN, e.g., "IPv4", "IPv6", or "IPv4/IPv6". -->
+ <string name="apn_protocol">APN protocol</string>
<!-- Edit access point screen menu option to delete this APN -->
<string name="menu_delete">Delete APN</string>
<!-- APNs screen menu option to create a brand spanking new APN -->
diff --git a/res/xml/apn_editor.xml b/res/xml/apn_editor.xml
index 68a1b31..f000dd0 100644
--- a/res/xml/apn_editor.xml
+++ b/res/xml/apn_editor.xml
@@ -114,4 +114,11 @@
android:singleLine="true"
android:inputType="textNoSuggestions"
/>
+ <ListPreference
+ android:title="@string/apn_protocol"
+ android:dialogTitle="@string/apn_protocol"
+ android:key="apn_protocol"
+ android:entries="@array/apn_protocol_entries"
+ android:entryValues="@array/apn_protocol_values"
+ />
</PreferenceScreen>
diff --git a/src/com/android/settings/ApnEditor.java b/src/com/android/settings/ApnEditor.java
index 9328c14..f738823 100644
--- a/src/com/android/settings/ApnEditor.java
+++ b/src/com/android/settings/ApnEditor.java
@@ -48,6 +48,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 +70,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 +101,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 +119,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 +143,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 +245,7 @@ public class ApnEditor extends PreferenceActivity
mAuthType.setValue(null);
}
+ mProtocol.setValue(mCursor.getString(PROTOCOL_INDEX));
}
mName.setSummary(checkNull(mName.getText()));
@@ -264,6 +272,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 +308,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 +429,8 @@ public class ApnEditor extends PreferenceActivity
values.put(Telephony.Carriers.AUTH_TYPE, Integer.parseInt(authVal));
}
+ values.put(Telephony.Carriers.PROTOCOL, checkNotSet(mProtocol.getValue()));
+
values.put(Telephony.Carriers.TYPE, checkNotSet(mApnType.getText()));
values.put(Telephony.Carriers.MCC, mcc);