Merge "Always disconnect agents immediately." am: d925df8aa6 am: a89d79e3c7 am: 235cb64505

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2623893

Change-Id: I850e1253735cff84730e36f92cc3ce7763dac00a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Lorenzo Colitti 2023-06-15 06:31:03 +00:00 • committed by Automerger Merge Worker
commit 7ed3e7d540

View file

@ -319,7 +319,6 @@ import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.lang.IllegalArgumentException;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
@ -4013,7 +4012,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
// the destroyed flag is only just above the "current satisfier wins"
// tie-breaker. But technically anything that affects scoring should rematch.
rematchAllNetworksAndRequests();
mHandler.postDelayed(() -> nai.disconnect(), timeoutMs);
mHandler.postDelayed(() -> disconnectAndDestroyNetwork(nai), timeoutMs);
break;
}
}
@ -4612,6 +4611,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (DBG) {
log(nai.toShortString() + " disconnected, was satisfying " + nai.numNetworkRequests());
}
nai.disconnect();
// Clear all notifications of this network.
mNotifier.clearNotification(nai.network.getNetId());
// A network agent has disconnected.
@ -5896,7 +5898,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork((Network) msg.obj);
if (nai == null) break;
nai.onPreventAutomaticReconnect();
nai.disconnect();
disconnectAndDestroyNetwork(nai);
break;
case EVENT_SET_VPN_NETWORK_PREFERENCE:
handleSetVpnNetworkPreference((VpnNetworkPreferenceInfo) msg.obj);
@ -9043,7 +9045,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
break;
}
}
nai.disconnect();
disconnectAndDestroyNetwork(nai);
}
private void handleLingerComplete(NetworkAgentInfo oldNetwork) {
@ -9585,7 +9587,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
updateLegacyTypeTrackerAndVpnLockdownForRematch(changes, nais);
// Tear down all unneeded networks.
for (NetworkAgentInfo nai : mNetworkAgentInfos) {
// Iterate in reverse order because teardownUnneededNetwork removes the nai from
// mNetworkAgentInfos.
for (int i = mNetworkAgentInfos.size() - 1; i >= 0; i--) {
final NetworkAgentInfo nai = mNetworkAgentInfos.valueAt(i);
if (unneeded(nai, UnneededFor.TEARDOWN)) {
if (nai.getInactivityExpiry() > 0) {
// This network has active linger timers and no requests, but is not
@ -9968,7 +9973,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
// This has to happen after matching the requests, because callbacks are just requests.
notifyNetworkCallbacks(networkAgent, ConnectivityManager.CALLBACK_PRECHECK);
} else if (state == NetworkInfo.State.DISCONNECTED) {
networkAgent.disconnect();
if (networkAgent.isVPN()) {
updateVpnUids(networkAgent, networkAgent.networkCapabilities, null);
}