Fix poor network detection setting

We used to base this on watchdog being turned on, but it should
be based on whether device is wifi only

Bug: 6576101
Change-Id: Ib5221287e6713c625d39ef986ceb278825fb4895
This commit is contained in:
Irfan Sheriff
2012-05-31 11:15:41 -07:00
parent a5ac7ce514
commit f0780a7cad
3 changed files with 16 additions and 18 deletions

View File

@@ -1198,10 +1198,10 @@
<string name="wifi_notify_open_networks">Network notification</string> <string name="wifi_notify_open_networks">Network notification</string>
<!-- Checkbox summary for option to notify user when open networks are nearby --> <!-- Checkbox summary for option to notify user when open networks are nearby -->
<string name="wifi_notify_open_networks_summary">Notify me when an open network is available</string> <string name="wifi_notify_open_networks_summary">Notify me when an open network is available</string>
<!-- Checkbox title for option to toggle wifi watchdog service --> <!-- Checkbox title for option to toggle poor network detection -->
<string name="wifi_enable_watchdog_service">Avoid poor connections</string> <string name="wifi_poor_network_detection">Avoid poor connections</string>
<!-- Checkbox summary for option to toggle wifi watchdog service --> <!-- Checkbox summary for option to toggle poor network detection -->
<string name="wifi_enable_watchdog_service_summary">Don\'t use a Wi-Fi network unless it has a good Internet connection</string> <string name="wifi_poor_network_detection_summary">Don\'t use a Wi-Fi network unless it has a good Internet connection</string>
<!-- Setting title for setting the wifi sleep policy. Do we keep Wi-Fi active when the screen turns off? --> <!-- Setting title for setting the wifi sleep policy. Do we keep Wi-Fi active when the screen turns off? -->
<string name="wifi_setting_sleep_policy_title">Keep Wi-Fi on during sleep</string> <string name="wifi_setting_sleep_policy_title">Keep Wi-Fi on during sleep</string>
<!-- Generic error message when the sleep policy could not be set. --> <!-- Generic error message when the sleep policy could not be set. -->

View File

@@ -34,9 +34,9 @@
<!-- android:dependency="enable_wifi" --> <!-- android:dependency="enable_wifi" -->
<CheckBoxPreference <CheckBoxPreference
android:key="wifi_enable_watchdog_service" android:key="wifi_poor_network_detection"
android:title="@string/wifi_enable_watchdog_service" android:title="@string/wifi_poor_network_detection"
android:summary="@string/wifi_enable_watchdog_service_summary" android:summary="@string/wifi_poor_network_detection_summary"
android:persistent="false" /> android:persistent="false" />
<ListPreference <ListPreference

View File

@@ -43,7 +43,7 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
private static final String KEY_FREQUENCY_BAND = "frequency_band"; private static final String KEY_FREQUENCY_BAND = "frequency_band";
private static final String KEY_NOTIFY_OPEN_NETWORKS = "notify_open_networks"; 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_SLEEP_POLICY = "sleep_policy";
private static final String KEY_ENABLE_WIFI_WATCHDOG = "wifi_enable_watchdog_service"; private static final String KEY_POOR_NETWORK_DETECTION = "wifi_poor_network_detection";
private WifiManager mWifiManager; private WifiManager mWifiManager;
@@ -73,16 +73,14 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0) == 1); Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0) == 1);
notifyOpenNetworks.setEnabled(mWifiManager.isWifiEnabled()); notifyOpenNetworks.setEnabled(mWifiManager.isWifiEnabled());
boolean watchdogEnabled = Secure.getInt(getContentResolver(), CheckBoxPreference poorNetworkDetection =
Secure.WIFI_WATCHDOG_ON, 1) != 0; (CheckBoxPreference) findPreference(KEY_POOR_NETWORK_DETECTION);
CheckBoxPreference watchdog = if (poorNetworkDetection != null) {
(CheckBoxPreference) findPreference(KEY_ENABLE_WIFI_WATCHDOG); if (Utils.isWifiOnly(getActivity())) {
if (watchdog != null) { getPreferenceScreen().removePreference(poorNetworkDetection);
if (watchdogEnabled) {
watchdog.setChecked(Secure.getInt(getContentResolver(),
Secure.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED, 1) == 1);
} else { } else {
getPreferenceScreen().removePreference(watchdog); poorNetworkDetection.setChecked(Secure.getInt(getContentResolver(),
Secure.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED, 1) == 1);
} }
} }
@@ -146,7 +144,7 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
Secure.putInt(getContentResolver(), Secure.putInt(getContentResolver(),
Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
((CheckBoxPreference) preference).isChecked() ? 1 : 0); ((CheckBoxPreference) preference).isChecked() ? 1 : 0);
} else if (KEY_ENABLE_WIFI_WATCHDOG.equals(key)) { } else if (KEY_POOR_NETWORK_DETECTION.equals(key)) {
Secure.putInt(getContentResolver(), Secure.putInt(getContentResolver(),
Secure.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED, Secure.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED,
((CheckBoxPreference) preference).isChecked() ? 1 : 0); ((CheckBoxPreference) preference).isChecked() ? 1 : 0);