Add the notification for actively prefer bad wifi
With this patch and "config_activelyPreferBadWifi=1"
(or SDK level >= U) and bad wifi avoidance turned off,
when the device connects to a bad wifi, after 20
seconds of the wifi not validating the device will
pop up a head-up notification with text
"<SSID> has no internet access".
When tapped, the notification will bring up the existing
Settings dialog :
*Wifi not connected to the internet*
You can switch to mobile whenever Wi-Fi is bad
□ Never show again
<Stay on Wi-Fi> <Switch to Mobile>
If the wifi validates and loses access again, the same
notification/dialog are shown if Settings.Global.
NETWORK_AVOID_BAD_WIFI=PROMPT ; if IGNORE, the device
stays stuck on wifi.
If AVOID, then bad wifi avoidance is turned on in the
first place, so none of this happens.
Behavior in other cases :
- If config_activelyPreferBadWifi=0, then upon connecting
to a wifi without internet, the behavior is unchanged :
the device stays on mobile and after 8 seconds a
notification pops up asking whether to stay connected.
If the network validates, then loses access, the behavior
depends on a few things :
- If config_networkAvoidBadWifi is 0 and Settings.Global.
NETWORK_AVOID_BAD_WIFI = IGNORE, then the device stays
on wifi and says nothing.
- If config_networkAvoidBadWifi is 0 and Settings.Global.
NETWORK_AVOID_BAD_WIFI = PROMPT, then
notification pops up asking whether to switch to mobile.
- If config_networkAvoidBadWifi is 1 (regardless of the
value of Settings.Global.NETWORK_AVOID_BAD_WIFI), or if
Settings.Global.NETWORK_AVOID_BAD_WIFI = AVOID, then
the device switches back to mobile.
- If Mobile is not connected, all the above applies. This
is not great for the messages including "switch to mobile"
but this patch doesn't change it.
Test: manual
Change-Id: Idb05b6a6e5c085f5ef72435d462e14bfd1341f87
This commit is contained in:
@@ -5238,6 +5238,16 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
// network was found not to have Internet access.
|
||||
nai.updateScoreForNetworkAgentUpdate();
|
||||
rematchAllNetworksAndRequests();
|
||||
|
||||
// Also, if this is WiFi and it should be preferred actively, now is the time to
|
||||
// prompt the user that they walked past and connected to a bad WiFi.
|
||||
if (nai.networkCapabilities.hasTransport(TRANSPORT_WIFI)
|
||||
&& !avoidBadWifi()
|
||||
&& activelyPreferBadWifi()) {
|
||||
// The notification will be removed if the network validates or disconnects.
|
||||
showNetworkNotification(nai, NotificationType.LOST_INTERNET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!shouldPromptUnvalidated(nai)) return;
|
||||
|
||||
Reference in New Issue
Block a user