Make callers of RoutingCoordinatorService pass in RouteInfoParcel

RoutingCoordinatorService's {add,remove,update}Route methods
all end up calling netd's *RouteParcel methods.

Make callers explicitly generate and pass in the parcel to the
manager class instead of having them pass in a RouteInfo and
having the service class convert the RouteInfo to a parcel.

Also remove the {add,remove,update}Route methods from
RoutingCoordinatorManager since they are unused.

This is a no-op refactor that simplifies upcoming changes.

RoutingCoordinator is not a stable interface and is not used
across the platform/mainline boundary, so there are no version
skew considerations.

Bug: 394308861
Test: atest ConnectivityCoverageTests
Flag: EXEMPT no-op refactor
Change-Id: Iedf4c9bc28c3fc8c289db421857acddc8c694990
This commit is contained in:
Lorenzo Colitti 2025-08-06 15:21:50 +09:00
commit 8f8e59abf7

View file

@ -360,6 +360,7 @@ import com.android.net.module.util.LinkPropertiesUtils;
import com.android.net.module.util.LinkPropertiesUtils.CompareOrUpdateResult;
import com.android.net.module.util.LinkPropertiesUtils.CompareResult;
import com.android.net.module.util.LocationPermissionChecker;
import com.android.net.module.util.NetdUtils;
import com.android.net.module.util.PerUidCounter;
import com.android.net.module.util.PermissionUtils;
import com.android.net.module.util.RoutingCoordinatorService;
@ -10594,7 +10595,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (route.hasGateway()) continue;
if (VDBG || DDBG) log("Adding Route [" + route + "] to network " + netId);
try {
mRoutingCoordinatorService.addRoute(netId, route);
mRoutingCoordinatorService.addRouteParcel(netId,
NetdUtils.toRouteInfoParcel(route));
} catch (Exception e) {
if ((route.getDestination().getAddress() instanceof Inet4Address) || VDBG) {
loge("Exception in addRoute for non-gateway: " + e);
@ -10605,7 +10607,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (!route.hasGateway()) continue;
if (VDBG || DDBG) log("Adding Route [" + route + "] to network " + netId);
try {
mRoutingCoordinatorService.addRoute(netId, route);
mRoutingCoordinatorService.addRouteParcel(netId,
NetdUtils.toRouteInfoParcel(route));
} catch (Exception e) {
if ((route.getGateway() instanceof Inet4Address) || VDBG) {
loge("Exception in addRoute for gateway: " + e);
@ -10616,7 +10619,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
for (RouteInfo route : routeDiff.removed) {
if (VDBG || DDBG) log("Removing Route [" + route + "] from network " + netId);
try {
mRoutingCoordinatorService.removeRoute(netId, route);
mRoutingCoordinatorService.removeRouteParcel(netId,
NetdUtils.toRouteInfoParcel(route));
} catch (Exception e) {
loge("Exception in removeRoute: " + e);
}
@ -10625,7 +10629,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
for (RouteInfo route : routeDiff.updated) {
if (VDBG || DDBG) log("Updating Route [" + route + "] from network " + netId);
try {
mRoutingCoordinatorService.updateRoute(netId, route);
mRoutingCoordinatorService.updateRouteParcel(netId,
NetdUtils.toRouteInfoParcel(route));
} catch (Exception e) {
loge("Exception in updateRoute: " + e);
}