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
committerSteve Kondik <steve@cyngn.com>2015-11-27 05:03:16 -0800
commit7f97eca31f5b822bdb24c4e24da600c5336267b9 (patch)
tree12268c211e384828e721875a7b0a56849d070821 /src/com/android/settings/wifi
parent08733a27c28ef84a6611f04a1fea03a7a915528f (diff)
downloadpackages_apps_Settings-7f97eca31f5b822bdb24c4e24da600c5336267b9.zip
packages_apps_Settings-7f97eca31f5b822bdb24c4e24da600c5336267b9.tar.gz
packages_apps_Settings-7f97eca31f5b822bdb24c4e24da600c5336267b9.tar.bz2
wifi: Allow configuration of country code for wifi (3/3)
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. Cherry-Pick: http://review.cyanogenmod.org/#/c/54904/ Require: I429326a77649c77ba40b00eb2236de3ca8839e57 Id9f00d3a678642c6c142fd1511af820d729507a7 JIRA: CML-118 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 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;