diff options
-rw-r--r-- | res/values/arrays.xml | 28 | ||||
-rw-r--r-- | res/values/strings.xml | 6 | ||||
-rw-r--r-- | res/xml/wifi_advanced_settings.xml | 9 | ||||
-rw-r--r-- | src/com/android/settings/wifi/AdvancedWifiSettings.java | 22 |
4 files changed, 65 insertions, 0 deletions
diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 1eaf473..31da756 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -413,6 +413,34 @@ <item>2</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>Turkey</item> + <item>Singapore</item> + <item>Brazil</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> + </string-array> <!-- Display options for UsageStats class --> <string-array name="usage_stats_display_order_types"> diff --git a/res/values/strings.xml b/res/values/strings.xml index 27f5673..6a6c5b5 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1469,6 +1469,12 @@ <!-- Wi-Fi settings screen, error message when the frequency band could not be set [CHAR LIMIT=50]. --> <string name="wifi_setting_frequency_band_error">There was a problem setting the frequency band.</string> <!-- Wi-Fi settings screen, advanced, title of the item to show the Wi-Fi device's MAC address. --> + <string name="wifi_setting_countrycode_title">Wi-Fi 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-Fi</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> + <!-- Wi-Fi settings screen, advanced, title of the item to show the Wi-Fi device's MAC address. --> <string name="wifi_advanced_mac_address_title">MAC address</string> <!-- Title of the screen to adjust IP settings --> <!-- Wi-Fi settings screen, advanced, title of the item to show the Wi-Fi device's current IP address. --> diff --git a/res/xml/wifi_advanced_settings.xml b/res/xml/wifi_advanced_settings.xml index 10eab29..8b85004 100644 --- a/res/xml/wifi_advanced_settings.xml +++ b/res/xml/wifi_advanced_settings.xml @@ -48,6 +48,15 @@ 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" + /> + <CheckBoxPreference android:key="suspend_optimizations" android:title="@string/wifi_suspend_optimizations" diff --git a/src/com/android/settings/wifi/AdvancedWifiSettings.java b/src/com/android/settings/wifi/AdvancedWifiSettings.java index 809496a..99b2f10 100644 --- a/src/com/android/settings/wifi/AdvancedWifiSettings.java +++ b/src/com/android/settings/wifi/AdvancedWifiSettings.java @@ -42,6 +42,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_POOR_NETWORK_DETECTION = "wifi_poor_network_detection"; @@ -110,6 +111,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(getActivity())) { @@ -181,6 +193,16 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment } } + 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; |