diff options
-rw-r--r-- | res/values/cm_arrays.xml | 30 | ||||
-rw-r--r-- | res/values/cm_strings.xml | 7 | ||||
-rw-r--r-- | res/xml/wifi_advanced_settings.xml | 9 | ||||
-rw-r--r-- | src/com/android/settings/wifi/AdvancedWifiSettings.java | 22 |
4 files changed, 68 insertions, 0 deletions
diff --git a/res/values/cm_arrays.xml b/res/values/cm_arrays.xml index 55fe9b0..a08a55a 100644 --- a/res/values/cm_arrays.xml +++ b/res/values/cm_arrays.xml @@ -426,4 +426,34 @@ <item>200</item> </string-array> + <!-- Wi-Fi settings. Presented as a list dialog to the user to choose the Wi-Fi region code. --> + <string-array name="wifi_countrycode_entries"> + <item>United States</item> + <item>Canada, Taiwan</item> + <item>Germany</item> + <item>Europe</item> + <item>Japan, Russia</item> + <item>Australia</item> + <item>China</item> + <item>Korea</item> + <item>South Africa, Turkey</item> + <item>Israel, Singapore</item> + <item>Brazil</item> + <item>India</item> + </string-array> + + <string-array name="wifi_countrycode_values" translatable="false"> + <item>US</item> + <item>CA</item> + <item>DE</item> + <item>GB</item> + <item>JP</item> + <item>AU</item> + <item>CN</item> + <item>KR</item> + <item>TR</item> + <item>SG</item> + <item>BR</item> + <item>IN</item> + </string-array> </resources> diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index 1429ae6..d37a208 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -209,6 +209,13 @@ <string name="toggleWimax">WiMAX</string> <string name="toggleNfc">NFC</string> + <!-- Wi-Fi region code --> + <string name="wifi_setting_countrycode_title">Wi\u2011Fi region code</string> + <!-- Wi-Fi settings screen, setting summary for setting the wifi frequency band [CHAR LIMIT=50]--> + <string name="wifi_setting_countrycode_summary">Specify the region code for Wi\u2011Fi</string> + <!-- Wi-Fi settings screen, error message when the frequency band could not be set [CHAR LIMIT=50]. --> + <string name="wifi_setting_countrycode_error">There was a problem setting the region code.</string> + <!-- Profiles --> <string name="profile_menu_delete_title">Delete</string> <string name="profile_menu_triggers_title">Modify triggers</string> diff --git a/res/xml/wifi_advanced_settings.xml b/res/xml/wifi_advanced_settings.xml index ed6cfbd..7f25708 100644 --- a/res/xml/wifi_advanced_settings.xml +++ b/res/xml/wifi_advanced_settings.xml @@ -46,6 +46,15 @@ android:entries="@array/wifi_frequency_band_entries" android:entryValues="@array/wifi_frequency_band_values" /> + <ListPreference + android:key="wifi_countrycode" + android:title="@string/wifi_setting_countrycode_title" + android:summary="@string/wifi_setting_countrycode_summary" + android:persistent="false" + android:entries="@array/wifi_countrycode_entries" + android:entryValues="@array/wifi_countrycode_values" + /> + <Preference android:key="install_credentials" android:title="@string/wifi_install_credentials" diff --git a/src/com/android/settings/wifi/AdvancedWifiSettings.java b/src/com/android/settings/wifi/AdvancedWifiSettings.java index 4f5884e..7af6193 100644 --- a/src/com/android/settings/wifi/AdvancedWifiSettings.java +++ b/src/com/android/settings/wifi/AdvancedWifiSettings.java @@ -57,6 +57,7 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment private static final String KEY_MAC_ADDRESS = "mac_address"; private static final String KEY_CURRENT_IP_ADDRESS = "current_ip_address"; private static final String KEY_FREQUENCY_BAND = "frequency_band"; + private static final String KEY_COUNTRY_CODE = "wifi_countrycode"; private static final String KEY_NOTIFY_OPEN_NETWORKS = "notify_open_networks"; private static final String KEY_SLEEP_POLICY = "sleep_policy"; private static final String KEY_INSTALL_CREDENTIALS = "install_credentials"; @@ -185,6 +186,17 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment } } + ListPreference ccodePref = (ListPreference) findPreference(KEY_COUNTRY_CODE); + if (ccodePref != null) { + ccodePref.setOnPreferenceChangeListener(this); + String value = mWifiManager.getCountryCode(); + if (value != null) { + ccodePref.setValue(value); + } else { + Log.e(TAG, "Failed to fetch country code"); + } + } + ListPreference sleepPolicyPref = (ListPreference) findPreference(KEY_SLEEP_POLICY); if (sleepPolicyPref != null) { if (Utils.isWifiOnly(context)) { @@ -294,6 +306,16 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment return false; } + if (KEY_COUNTRY_CODE.equals(key)) { + try { + mWifiManager.setCountryCode((String) newValue, true); + } catch (IllegalArgumentException e) { + Toast.makeText(getActivity(), R.string.wifi_setting_countrycode_error, + Toast.LENGTH_SHORT).show(); + return false; + } + } + if (KEY_SLEEP_POLICY.equals(key)) { try { String stringValue = (String) newValue; |