summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/wifi/AdvancedWifiSettings.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/settings/wifi/AdvancedWifiSettings.java')
-rw-r--r--src/com/android/settings/wifi/AdvancedWifiSettings.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/com/android/settings/wifi/AdvancedWifiSettings.java b/src/com/android/settings/wifi/AdvancedWifiSettings.java
index 4f5884e..f764dd4 100644
--- a/src/com/android/settings/wifi/AdvancedWifiSettings.java
+++ b/src/com/android/settings/wifi/AdvancedWifiSettings.java
@@ -57,8 +57,10 @@ 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";
private static final String KEY_INSTALL_CREDENTIALS = "install_credentials";
private static final String KEY_WIFI_ASSISTANT = "wifi_assistant";
private static final String KEY_WIFI_DIRECT = "wifi_direct";
@@ -124,6 +126,19 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0) == 1);
notifyOpenNetworks.setEnabled(mWifiManager.isWifiEnabled());
+ SwitchPreference poorNetworkDetection =
+ (SwitchPreference) findPreference(KEY_POOR_NETWORK_DETECTION);
+ if (poorNetworkDetection != null) {
+ if (Utils.isWifiOnly(getActivity())) {
+ getPreferenceScreen().removePreference(poorNetworkDetection);
+ } else {
+ poorNetworkDetection.setChecked(Settings.Global.getInt(getContentResolver(),
+ Settings.Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED,
+ WifiManager.DEFAULT_POOR_NETWORK_AVOIDANCE_ENABLED ?
+ 1 : 0) == 1);
+ }
+ }
+
Intent intent = new Intent(Credentials.INSTALL_AS_USER_ACTION);
intent.setClassName("com.android.certinstaller",
"com.android.certinstaller.CertInstallerMain");
@@ -185,6 +200,23 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
}
}
+ ListPreference ccodePref = (ListPreference) findPreference(KEY_COUNTRY_CODE);
+ if (ccodePref != null) {
+ boolean hideWifiRegion = getResources()
+ .getBoolean(R.bool.config_hide_wifi_region_code);
+ if (hideWifiRegion) {
+ removePreference(KEY_COUNTRY_CODE);
+ } else {
+ 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)) {
@@ -245,6 +277,10 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
Global.putInt(getContentResolver(),
Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
((SwitchPreference) preference).isChecked() ? 1 : 0);
+ } else if (KEY_POOR_NETWORK_DETECTION.equals(key)) {
+ Global.putInt(getContentResolver(),
+ Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED,
+ ((SwitchPreference) preference).isChecked() ? 1 : 0);
} else {
return super.onPreferenceTreeClick(screen, preference);
}
@@ -294,6 +330,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;