Loading src/com/android/settings/wifi/ConfigureWifiSettings.java +5 −12 Original line number Diff line number Diff line Loading @@ -170,8 +170,8 @@ public class ConfigureWifiSettings extends SettingsPreferenceFragment } private boolean avoidBadWifiCurrentSettings() { return Settings.Global.getInt(getContentResolver(), Settings.Global.NETWORK_AVOID_BAD_WIFI, 0) == 1; return "1".equals(Settings.Global.getString(getContentResolver(), Settings.Global.NETWORK_AVOID_BAD_WIFI)); } @Override Loading @@ -183,17 +183,10 @@ public class ConfigureWifiSettings extends SettingsPreferenceFragment Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, ((SwitchPreference) preference).isChecked() ? 1 : 0); } else if (KEY_CELLULAR_FALLBACK.equals(key)) { // On: avoid bad wifi. Off: prompt. 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); } Settings.Global.putString(getContentResolver(), settingName, ((SwitchPreference) preference).isChecked() ? "1" : null); } else { return super.onPreferenceTreeClick(preference); } Loading src/com/android/settings/wifi/WifiNoInternetDialog.java +15 −13 Original line number Diff line number Diff line Loading @@ -164,24 +164,26 @@ public final class WifiNoInternetDialog extends AlertActivity implements public void onClick(DialogInterface dialog, int which) { if (which != BUTTON_NEGATIVE && which != BUTTON_POSITIVE) return; final boolean accept = (which == BUTTON_POSITIVE); final boolean always = mAlwaysAllow.isChecked(); final String what, action; if (ACTION_PROMPT_UNVALIDATED.equals(mAction)) { final String action = (accept ? "Connect" : "Ignore"); final boolean always = mAlwaysAllow.isChecked(); what = "NO_INTERNET"; final boolean accept = (which == BUTTON_POSITIVE); action = (accept ? "Connect" : "Ignore"); mCM.setAcceptUnvalidated(mNetwork, accept, always); Log.d(TAG, "NO_INTERNET: " + action + " network=" + mNetwork + (always ? " and remember" : "")); } else { final String action = (accept ? "Switch" : "Cancel"); Log.d(TAG, "LOST_INTERNET: " + action); // 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). // TODO: Use a value other than 1 here to indicate a persisted "yes" or "no" given mAlwaysAllow. if (accept) { Settings.Global.putInt(mAlertParams.mContext.getContentResolver(), Settings.Global.NETWORK_AVOID_BAD_WIFI, 1); what = "LOST_INTERNET"; final boolean avoid = (which == BUTTON_POSITIVE); action = (avoid ? "Switch away" : "Get stuck"); if (always) { Settings.Global.putString(mAlertParams.mContext.getContentResolver(), Settings.Global.NETWORK_AVOID_BAD_WIFI, avoid ? "1" : "0"); } else if (avoid) { mCM.setAvoidUnvalidated(mNetwork); } } Log.d(TAG, what + ": " + action + " network=" + mNetwork + (always ? " and remember" : "")); } } Loading
src/com/android/settings/wifi/ConfigureWifiSettings.java +5 −12 Original line number Diff line number Diff line Loading @@ -170,8 +170,8 @@ public class ConfigureWifiSettings extends SettingsPreferenceFragment } private boolean avoidBadWifiCurrentSettings() { return Settings.Global.getInt(getContentResolver(), Settings.Global.NETWORK_AVOID_BAD_WIFI, 0) == 1; return "1".equals(Settings.Global.getString(getContentResolver(), Settings.Global.NETWORK_AVOID_BAD_WIFI)); } @Override Loading @@ -183,17 +183,10 @@ public class ConfigureWifiSettings extends SettingsPreferenceFragment Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, ((SwitchPreference) preference).isChecked() ? 1 : 0); } else if (KEY_CELLULAR_FALLBACK.equals(key)) { // On: avoid bad wifi. Off: prompt. 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); } Settings.Global.putString(getContentResolver(), settingName, ((SwitchPreference) preference).isChecked() ? "1" : null); } else { return super.onPreferenceTreeClick(preference); } Loading
src/com/android/settings/wifi/WifiNoInternetDialog.java +15 −13 Original line number Diff line number Diff line Loading @@ -164,24 +164,26 @@ public final class WifiNoInternetDialog extends AlertActivity implements public void onClick(DialogInterface dialog, int which) { if (which != BUTTON_NEGATIVE && which != BUTTON_POSITIVE) return; final boolean accept = (which == BUTTON_POSITIVE); final boolean always = mAlwaysAllow.isChecked(); final String what, action; if (ACTION_PROMPT_UNVALIDATED.equals(mAction)) { final String action = (accept ? "Connect" : "Ignore"); final boolean always = mAlwaysAllow.isChecked(); what = "NO_INTERNET"; final boolean accept = (which == BUTTON_POSITIVE); action = (accept ? "Connect" : "Ignore"); mCM.setAcceptUnvalidated(mNetwork, accept, always); Log.d(TAG, "NO_INTERNET: " + action + " network=" + mNetwork + (always ? " and remember" : "")); } else { final String action = (accept ? "Switch" : "Cancel"); Log.d(TAG, "LOST_INTERNET: " + action); // 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). // TODO: Use a value other than 1 here to indicate a persisted "yes" or "no" given mAlwaysAllow. if (accept) { Settings.Global.putInt(mAlertParams.mContext.getContentResolver(), Settings.Global.NETWORK_AVOID_BAD_WIFI, 1); what = "LOST_INTERNET"; final boolean avoid = (which == BUTTON_POSITIVE); action = (avoid ? "Switch away" : "Get stuck"); if (always) { Settings.Global.putString(mAlertParams.mContext.getContentResolver(), Settings.Global.NETWORK_AVOID_BAD_WIFI, avoid ? "1" : "0"); } else if (avoid) { mCM.setAvoidUnvalidated(mNetwork); } } Log.d(TAG, what + ": " + action + " network=" + mNetwork + (always ? " and remember" : "")); } }