diff --git a/res/values/strings.xml b/res/values/strings.xml index 386403f30bd..98a28820dba 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1611,7 +1611,10 @@ Limit battery used by Wi\u2011Fi Switch to cellular data if Wi\u2011Fi loses Internet access. - + + Cellular data fallback + + Use cellular data when Wi\u2011Fi loses Internet access. Additional charges may apply. Add network @@ -1772,11 +1775,10 @@ Don\u2019t ask again for this network - Wi\u2011Fi has no Internet access - Your device can automatically switch to other saved Wi\u2011Fi networks or cellular data. Cellular charges may apply. - Switch networks - Cancel - + Switch to cellular data? + Wi\u2011Fi lost Internet access. Your device can switch to cellular automatically when Wi\u2011Fi isn\u2019t working. Additional charges may apply. + Switch automatically + Stay on Wi\u2011Fi Connect diff --git a/res/xml/wifi_configure_settings.xml b/res/xml/wifi_configure_settings.xml index 3aeb83e9f7a..863007c724f 100644 --- a/res/xml/wifi_configure_settings.xml +++ b/res/xml/wifi_configure_settings.xml @@ -41,6 +41,11 @@ android:summary="@string/wifi_automatically_connect_summary" android:dialogTitle="@string/wifi_select_assistant_dialog_title" /> + + scorers = NetworkScorerAppManager.getAllValidScorers(context); @@ -148,6 +164,16 @@ public class ConfigureWifiSettings extends SettingsPreferenceFragment Log.e(TAG, "Invalid sleep policy value: " + value); } + private boolean avoidBadWifiConfig() { + return getActivity().getResources().getInteger( + com.android.internal.R.integer.config_networkAvoidBadWifi) == 1; + } + + private boolean avoidBadWifiCurrentSettings() { + return Settings.Global.getInt(getContentResolver(), + Settings.Global.NETWORK_AVOID_BAD_WIFI, 0) == 1; + } + @Override public boolean onPreferenceTreeClick(Preference preference) { String key = preference.getKey(); @@ -156,6 +182,18 @@ public class ConfigureWifiSettings extends SettingsPreferenceFragment Settings.Global.putInt(getContentResolver(), Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, ((SwitchPreference) preference).isChecked() ? 1 : 0); + } else if (KEY_CELLULAR_FALLBACK.equals(key)) { + String settingName = Settings.Global.NETWORK_AVOID_BAD_WIFI; + if (((SwitchPreference) preference).isChecked()) { + // The user wants to avoid bad wifi networks. Remember the choice. + Settings.Global.putInt(getContentResolver(), settingName, 1); + } else { + // Unset the setting. ConnectivityService interprets null to mean "use the carrier + // default". We don't set the setting to 0 because if we do, and the user switches + // to a carrier that does not restrict cellular fallback, then there is no way to + // set it to 1 again because on such a carrier the toggle is never shown. + Settings.Global.putString(getContentResolver(), settingName, null); + } } else { return super.onPreferenceTreeClick(preference); } diff --git a/src/com/android/settings/wifi/WifiNoInternetDialog.java b/src/com/android/settings/wifi/WifiNoInternetDialog.java index 289e0fcb159..0924498f3bc 100644 --- a/src/com/android/settings/wifi/WifiNoInternetDialog.java +++ b/src/com/android/settings/wifi/WifiNoInternetDialog.java @@ -173,8 +173,12 @@ public final class WifiNoInternetDialog extends AlertActivity implements } else { final String action = (accept ? "Switch" : "Cancel"); Log.d(TAG, "LOST_INTERNET: " + action); - Settings.Global.putInt(mAlertParams.mContext.getContentResolver(), - Settings.Global.NETWORK_AVOID_BAD_WIFI, accept ? 1 : 0); + // Only ever set the setting to 1. The values understood by ConnectivityService are null + // (use carrier default) or 1 (avoid bad networks regardless of carrier). + if (accept) { + Settings.Global.putInt(mAlertParams.mContext.getContentResolver(), + Settings.Global.NETWORK_AVOID_BAD_WIFI, 1); + } } } }