Always have an AutomaticOnOffKeepalive to manage a KI

Test: FrameworksNetTests 'CtsNetTestCases' CtsHostsideNetworkTests
Change-Id: Ic216b525d8297fce0f390daae327e667a14b7775
This commit is contained in:
Chalard Jean 2023-01-24 17:11:27 +09:00 • committed by chiachangwang
commit 23f1bfd471

View file

@ -270,6 +270,7 @@ import com.android.networkstack.apishim.common.BroadcastOptionsShim;
import com.android.networkstack.apishim.common.UnsupportedApiLevelException;
import com.android.server.connectivity.AutodestructReference;
import com.android.server.connectivity.AutomaticOnOffKeepaliveTracker;
import com.android.server.connectivity.AutomaticOnOffKeepaliveTracker.AutomaticOnOffKeepalive;
import com.android.server.connectivity.CarrierPrivilegeAuthenticator;
import com.android.server.connectivity.ClatCoordinator;
import com.android.server.connectivity.ConnectivityFlags;
@ -5546,9 +5547,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
break;
}
case NetworkAgent.CMD_MONITOR_AUTOMATIC_KEEPALIVE: {
final Network network = (Network) msg.obj;
final int slot = msg.arg1;
final AutomaticOnOffKeepalive ki = (AutomaticOnOffKeepalive) msg.obj;
final Network network = ki.getNetwork();
boolean networkFound = false;
final ArrayList<NetworkAgentInfo> vpnsRunningOnThisNetwork = new ArrayList<>();
for (NetworkAgentInfo n : mNetworkAgentInfos) {
@ -5563,12 +5564,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (!networkFound) return;
if (!vpnsRunningOnThisNetwork.isEmpty()) {
mKeepaliveTracker.handleMonitorAutomaticKeepalive(network, slot,
mKeepaliveTracker.handleMonitorAutomaticKeepalive(ki,
// TODO: check all the VPNs running on top of this network
vpnsRunningOnThisNetwork.get(0).network.netId);
} else {
// If no VPN, then make sure the keepalive is running.
mKeepaliveTracker.handleMaybeResumeKeepalive(network, slot);
mKeepaliveTracker.handleMaybeResumeKeepalive(ki);
}
break;
}