OSDN Git Service

Don't auto-connect to networks that have no/limited connectivity.
authorLorenzo Colitti <lorenzo@google.com>
Thu, 30 May 2019 07:24:31 +0000 (16:24 +0900)
committerLorenzo Colitti <lorenzo@google.com>
Thu, 30 May 2019 07:33:42 +0000 (16:33 +0900)
Auto-reconnecting to a network with no or limited Internet
connectivity is not useful. This is because such networks cannot
be used unless the user taps the notification and interacts with
the resulting dialog. But the notification is only shown if the
user manually connects to the network, not if the system
auto-connects to it.

Bug: 130683832
Bug: 130766237
Test: atest FrameworksNetTests
Change-Id: I5413393529c4bad3a707df229307542486bcff33

services/core/java/com/android/server/ConnectivityService.java

index 45f7360..a119ebe 100644 (file)
@@ -3660,6 +3660,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
                 || nai.networkMisc.acceptPartialConnectivity) {
             return;
         }
+
+        // Stop automatically reconnecting to this network in the future. Automatically connecting
+        // to a network that provides no or limited connectivity is not useful, because the user
+        // cannot use that network except through the notification shown by this method, and the
+        // notification is only shown if the network is explicitly selected by the user.
+        nai.asyncChannel.sendMessage(NetworkAgent.CMD_PREVENT_AUTOMATIC_RECONNECT);
+
         // TODO: Evaluate if it's needed to wait 8 seconds for triggering notification when
         // NetworkMonitor detects the network is partial connectivity. Need to change the design to
         // popup the notification immediately when the network is partial connectivity.