Update the avoid bad wifi settings on the handler thread.
am: 21924545a2
Change-Id: I595949881353f5779ed2bb55ff05f27b513cd6de
This commit is contained in:
@@ -857,6 +857,15 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
Settings.Global.NETWORK_SWITCH_NOTIFICATION_RATE_LIMIT_MILLIS,
|
Settings.Global.NETWORK_SWITCH_NOTIFICATION_RATE_LIMIT_MILLIS,
|
||||||
LingerMonitor.DEFAULT_NOTIFICATION_RATE_LIMIT_MILLIS);
|
LingerMonitor.DEFAULT_NOTIFICATION_RATE_LIMIT_MILLIS);
|
||||||
mLingerMonitor = new LingerMonitor(mContext, mNotifier, dailyLimit, rateLimit);
|
mLingerMonitor = new LingerMonitor(mContext, mNotifier, dailyLimit, rateLimit);
|
||||||
|
|
||||||
|
intentFilter = new IntentFilter();
|
||||||
|
intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
|
||||||
|
mContext.registerReceiverAsUser(new BroadcastReceiver() {
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
mHandler.sendEmptyMessage(EVENT_CONFIGURE_NETWORK_AVOID_BAD_WIFI);
|
||||||
|
}
|
||||||
|
}, UserHandle.ALL, intentFilter, null, null);
|
||||||
|
updateAvoidBadWifi();
|
||||||
}
|
}
|
||||||
|
|
||||||
private NetworkRequest createInternetRequestForTransport(
|
private NetworkRequest createInternetRequestForTransport(
|
||||||
@@ -2750,17 +2759,29 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
PROMPT_UNVALIDATED_DELAY_MS);
|
PROMPT_UNVALIDATED_DELAY_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
private boolean mAvoidBadWifi;
|
||||||
|
|
||||||
public boolean avoidBadWifi() {
|
public boolean avoidBadWifi() {
|
||||||
|
return mAvoidBadWifi;
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public boolean updateAvoidBadWifi() {
|
||||||
// There are two modes: either we always automatically avoid unvalidated wifi, or we show a
|
// There are two modes: either we always automatically avoid unvalidated wifi, or we show a
|
||||||
// dialog and don't switch to it. The behaviour is controlled by the NETWORK_AVOID_BAD_WIFI
|
// dialog and don't switch to it. The behaviour is controlled by the NETWORK_AVOID_BAD_WIFI
|
||||||
// setting. If the setting has no value, then the value is taken from the config value,
|
// setting. If the setting has no value, then the value is taken from the config value,
|
||||||
// which can be changed via OEM/carrier overlays.
|
// which can be changed via OEM/carrier overlays.
|
||||||
|
//
|
||||||
|
// The only valid values for NETWORK_AVOID_BAD_WIFI are null and unset. Currently, the unit
|
||||||
|
// test uses 0 in order to avoid having to mock out fetching the carrier setting.
|
||||||
int defaultAvoidBadWifi =
|
int defaultAvoidBadWifi =
|
||||||
mContext.getResources().getInteger(R.integer.config_networkAvoidBadWifi);
|
mContext.getResources().getInteger(R.integer.config_networkAvoidBadWifi);
|
||||||
int avoid = Settings.Global.getInt(mContext.getContentResolver(),
|
int avoid = Settings.Global.getInt(mContext.getContentResolver(),
|
||||||
Settings.Global.NETWORK_AVOID_BAD_WIFI, defaultAvoidBadWifi);
|
Settings.Global.NETWORK_AVOID_BAD_WIFI, defaultAvoidBadWifi);
|
||||||
return avoid == 1;
|
|
||||||
|
boolean prev = mAvoidBadWifi;
|
||||||
|
mAvoidBadWifi = (avoid == 1);
|
||||||
|
return mAvoidBadWifi != prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showValidationNotification(NetworkAgentInfo nai, NotificationType type) {
|
private void showValidationNotification(NetworkAgentInfo nai, NotificationType type) {
|
||||||
@@ -2899,7 +2920,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EVENT_CONFIGURE_NETWORK_AVOID_BAD_WIFI: {
|
case EVENT_CONFIGURE_NETWORK_AVOID_BAD_WIFI: {
|
||||||
|
if (updateAvoidBadWifi()) {
|
||||||
rematchAllNetworksAndRequests(null, 0);
|
rematchAllNetworksAndRequests(null, 0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EVENT_REQUEST_LINKPROPERTIES:
|
case EVENT_REQUEST_LINKPROPERTIES:
|
||||||
|
|||||||
Reference in New Issue
Block a user