Add a "Don't ask again" checkbox to the avoid bad wifi dialog.

Also update the settings code to reflect the new tristate
semantics of the NETWORK_AVOID_BAD_WIFI setting.

Bug: 31075769
Change-Id: Icd21d8272abe6afd42ee8a41e2c7e1a6af77f0b3
This commit is contained in:
Lorenzo Colitti
2016-09-19 01:08:07 +09:00
parent 0d00554d62
commit c179f33c87
2 changed files with 20 additions and 25 deletions

View File

@@ -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" : ""));
}
}