summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/wifi
diff options
context:
space:
mode:
authorAndrew Dodd <atd7@cornell.edu>2012-09-12 21:59:20 -0400
committerGerrit Code Review <gerrit@review.cyanogenmod.com>2012-12-19 06:59:14 -0800
commit795acaa8b79d8b60cc334db0149cadd2f4ffddf4 (patch)
treec767b44f9d768da78292aaf6e50c708f129fade8 /src/com/android/settings/wifi
parent63608e3cb02ed2e67ba157c73ec50bc70726272d (diff)
downloadpackages_apps_settings-795acaa8b79d8b60cc334db0149cadd2f4ffddf4.zip
packages_apps_settings-795acaa8b79d8b60cc334db0149cadd2f4ffddf4.tar.gz
packages_apps_settings-795acaa8b79d8b60cc334db0149cadd2f4ffddf4.tar.bz2
wifi: Allow configuration of country code for wifi
Wifi country code handling is a nightmare - Most retail devices have region customization in /system for each country a device is shipped to. This doesn't work very well for a firmware like Cyanogenmod, where we try to support all target countries with one firmware package. For whatever reason, with newer Broadcom drivers/ firmware blobs, the old trick of using a universal region code (ccode=ALL in nvram_net.txt) does not seem to work. Who knows what the deal is for other wifi chipsets. The good thing is that wpa_supplicant has a standardized cross-chipset method for setting the region code, and we use that here. Change-Id: Ia9f5133f61f56d89ccb290e37a393f5de507e1cf
Diffstat (limited to 'src/com/android/settings/wifi')
-rw-r--r--src/com/android/settings/wifi/AdvancedWifiSettings.java22
1 files changed, 22 insertions, 0 deletions
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;