Merge "Disconnect if the user cancels the no/partial connectivity dialog" into qt-dev am: 2bcfecdb21
am: 4bee989ec1
am: 37bf2c4591
Change-Id: I6213316de4d3de257898f2ac23ee321aa8a24afb
This commit is contained in:
@@ -52,6 +52,7 @@ public final class WifiNoInternetDialog extends AlertActivity implements
|
|||||||
private ConnectivityManager.NetworkCallback mNetworkCallback;
|
private ConnectivityManager.NetworkCallback mNetworkCallback;
|
||||||
private CheckBox mAlwaysAllow;
|
private CheckBox mAlwaysAllow;
|
||||||
private String mAction;
|
private String mAction;
|
||||||
|
private boolean mButtonClicked;
|
||||||
|
|
||||||
private boolean isKnownAction(Intent intent) {
|
private boolean isKnownAction(Intent intent) {
|
||||||
return intent.getAction().equals(ACTION_PROMPT_UNVALIDATED)
|
return intent.getAction().equals(ACTION_PROMPT_UNVALIDATED)
|
||||||
@@ -169,14 +170,31 @@ public final class WifiNoInternetDialog extends AlertActivity implements
|
|||||||
mCM.unregisterNetworkCallback(mNetworkCallback);
|
mCM.unregisterNetworkCallback(mNetworkCallback);
|
||||||
mNetworkCallback = null;
|
mNetworkCallback = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the user exits the no Internet or partial connectivity dialog without taking any
|
||||||
|
// action, disconnect the network, because once the dialog has been dismissed there is no
|
||||||
|
// way to use the network.
|
||||||
|
//
|
||||||
|
// Unfortunately, AlertDialog does not seem to offer any good way to get an onCancel or
|
||||||
|
// onDismiss callback. So we implement this ourselves.
|
||||||
|
if (isFinishing() && !mButtonClicked) {
|
||||||
|
if (ACTION_PROMPT_PARTIAL_CONNECTIVITY.equals(mAction)) {
|
||||||
|
mCM.setAcceptPartialConnectivity(mNetwork, false /* accept */, false /* always */);
|
||||||
|
} else if (ACTION_PROMPT_UNVALIDATED.equals(mAction)) {
|
||||||
|
mCM.setAcceptUnvalidated(mNetwork, false /* accept */, false /* always */);
|
||||||
|
}
|
||||||
|
}
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (which != BUTTON_NEGATIVE && which != BUTTON_POSITIVE) return;
|
if (which != BUTTON_NEGATIVE && which != BUTTON_POSITIVE) return;
|
||||||
final boolean always = mAlwaysAllow.isChecked();
|
final boolean always = mAlwaysAllow.isChecked();
|
||||||
final String what, action;
|
final String what, action;
|
||||||
|
|
||||||
|
mButtonClicked = true;
|
||||||
|
|
||||||
if (ACTION_PROMPT_UNVALIDATED.equals(mAction)) {
|
if (ACTION_PROMPT_UNVALIDATED.equals(mAction)) {
|
||||||
what = "NO_INTERNET";
|
what = "NO_INTERNET";
|
||||||
final boolean accept = (which == BUTTON_POSITIVE);
|
final boolean accept = (which == BUTTON_POSITIVE);
|
||||||
|
Reference in New Issue
Block a user