Return the registry in registerNetworkAgent.

This is a resubmit of
I0fd90716b9f5501bdcdc7ee5165321737a0076ae
which did not account for testing of this private method
in Telephony tests.

Also make the network agent registry two way to eliminate
reordering possibilities.

Test: ConnectivityCoverageTest, CtsNetTests
Change-Id: I9ca025b1369dcb1202f906d5cff79e3d935b40da
This commit is contained in:
Chalard Jean 2025-03-03 11:59:31 +09:00
commit 80d4326d76

View file

@ -228,6 +228,7 @@ import android.net.NattSocketKeepalive;
import android.net.Network;
import android.net.NetworkAgent;
import android.net.NetworkAgentConfig;
import android.net.NetworkAndAgentRegistryParcelable;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.net.NetworkInfo.DetailedState;
@ -9316,7 +9317,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
* @param providerId the ID of the provider owning this NetworkAgent.
* @return the network created for this agent.
*/
public Network registerNetworkAgent(INetworkAgent na,
public NetworkAndAgentRegistryParcelable registerNetworkAgent(INetworkAgent na,
NetworkInfo networkInfo,
LinkProperties linkProperties,
NetworkCapabilities networkCapabilities,
@ -9359,7 +9360,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
}
private Network registerNetworkAgentInternal(INetworkAgent na, NetworkInfo networkInfo,
private NetworkAndAgentRegistryParcelable registerNetworkAgentInternal(
INetworkAgent na, NetworkInfo networkInfo,
LinkProperties linkProperties, NetworkCapabilities networkCapabilities,
NetworkScore currentScore, NetworkAgentConfig networkAgentConfig,
@Nullable LocalNetworkConfig localNetworkConfig, int providerId,
@ -9391,8 +9393,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
// NetworkAgentInfo registration will finish when the NetworkMonitor is created.
// If the network disconnects or sends any other event before that, messages are deferred by
// NetworkAgent until nai.connect(), which will be called when finalizing the
// registration.
return nai.network;
// registration. TODO : have NetworkAgentInfo defer them instead.
final NetworkAndAgentRegistryParcelable result = new NetworkAndAgentRegistryParcelable();
result.network = nai.network;
result.registry = nai.getRegistry();
return result;
}
private void handleRegisterNetworkAgent(NetworkAgentInfo nai, INetworkMonitor networkMonitor) {