Fix a bug where non-VPN networks would update VPN uids.

Previously, non VPNs would not be created when updateVpnUids()
is called inside handleRegisterNetworkAgent. Because the network
is not created, netd would refuse to set the UIDs with an error.
Now that networks are created immediately with the
QUEUE_NETWORK_AGENT_EVENTS_IN_SYSTEM_SERVER flag,
the network is created and netd does set the UID for any
network as if they were a VPN. This results in the UID having
the wrong default network, which in turns prevents it from
accessing Internet.

Test: new test in this patch
Bug: 408717088
Flag: EXEMPT bugfix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:97e690169779f9790aa8d6026fca6bdc3d61e1b3)
Merged-In: If68ea7d60919c0c7e177480f6167196381e00f35
Change-Id: If68ea7d60919c0c7e177480f6167196381e00f35
This commit is contained in:
Chalard Jean 2025-04-11 14:56:35 +09:00 • committed by Android Build Coastguard Worker
commit 409913a215

View file

@ -9528,7 +9528,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
nai.notifyRegistered(networkMonitor);
NetworkInfo networkInfo = nai.networkInfo;
updateNetworkInfo(nai, networkInfo);
updateVpnUids(nai, null, nai.networkCapabilities);
if (nai.isVPN()) updateVpnUids(nai, null, nai.networkCapabilities);
nai.processEnqueuedMessages(mTrackerHandler::handleMessage);
}