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
3 changed files with 24 additions and 66 deletions

View file

@ -21,6 +21,7 @@ import android.net.LinkProperties;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.RouteInfo;
import android.net.RouteInfoParcel;
import com.android.net.module.util.IIpv4PrefixRequest;
@ -30,6 +31,7 @@ import com.android.net.module.util.IIpv4PrefixRequest;
// invocation to an incorrect interface" when calling the IPC.
@Descriptor("value=no.jarjar.com.android.net.module.util.IRoutingCoordinator")
interface IRoutingCoordinator {
/**
* Add a route for specific network
*
@ -38,7 +40,7 @@ interface IRoutingCoordinator {
* @throws ServiceSpecificException in case of failure, with an error code indicating the
* cause of the failure.
*/
void addRoute(int netId, in RouteInfo route);
void addRouteParcel(int netId, in RouteInfoParcel route);
/**
* Remove a route for specific network
@ -48,7 +50,7 @@ interface IRoutingCoordinator {
* @throws ServiceSpecificException in case of failure, with an error code indicating the
* cause of the failure.
*/
void removeRoute(int netId, in RouteInfo route);
void removeRouteParcel(int netId, in RouteInfoParcel route);
/**
* Update a route for specific network
@ -58,7 +60,7 @@ interface IRoutingCoordinator {
* @throws ServiceSpecificException in case of failure, with an error code indicating the
* cause of the failure.
*/
void updateRoute(int netId, in RouteInfo route);
void updateRouteParcel(int netId, in RouteInfoParcel route);
/**
* Adds an interface to a network. The interface must not be assigned to any network, including

View file

@ -21,7 +21,6 @@ import android.net.LinkAddress;
import android.net.LinkProperties;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.RouteInfo;
import android.os.IBinder;
import android.os.RemoteException;
@ -50,54 +49,6 @@ public class RoutingCoordinatorManager {
mService = IRoutingCoordinator.Stub.asInterface(binder);
}
/**
* Add a route for specific network
*
* @param netId the network to add the route to
* @param route the route to add
* @throws ServiceSpecificException in case of failure, with an error code indicating the
* cause of the failure.
*/
public void addRoute(final int netId, final RouteInfo route) {
try {
mService.addRoute(netId, route);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Remove a route for specific network
*
* @param netId the network to remove the route from
* @param route the route to remove
* @throws ServiceSpecificException in case of failure, with an error code indicating the
* cause of the failure.
*/
public void removeRoute(final int netId, final RouteInfo route) {
try {
mService.removeRoute(netId, route);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Update a route for specific network
*
* @param netId the network to update the route for
* @param route parcelable with route information
* @throws ServiceSpecificException in case of failure, with an error code indicating the
* cause of the failure.
*/
public void updateRoute(final int netId, final RouteInfo route) {
try {
mService.updateRoute(netId, route);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Adds an interface to a network. The interface must not be assigned to any network, including
* the specified network.

View file

@ -16,17 +16,14 @@
package com.android.net.module.util;
import static com.android.net.module.util.NetdUtils.toRouteInfoParcel;
import android.annotation.NonNull;
import android.content.Context;
import android.net.INetd;
import android.net.LinkAddress;
import android.net.LinkProperties;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.RouteInfo;
import android.net.RouteInfoParcel;
import android.os.RemoteException;
import android.os.ServiceSpecificException;
import android.util.ArraySet;
@ -84,9 +81,9 @@ public class RoutingCoordinatorService extends IRoutingCoordinator.Stub {
* cause of the failure.
*/
@Override
public void addRoute(final int netId, final RouteInfo route)
public void addRouteParcel(int netId, RouteInfoParcel route)
throws ServiceSpecificException, RemoteException {
mNetd.networkAddRouteParcel(netId, toRouteInfoParcel(route));
mNetd.networkAddRouteParcel(netId, route);
}
/**
@ -98,9 +95,9 @@ public class RoutingCoordinatorService extends IRoutingCoordinator.Stub {
* cause of the failure.
*/
@Override
public void removeRoute(final int netId, final RouteInfo route)
public void removeRouteParcel(int netId, RouteInfoParcel route)
throws ServiceSpecificException, RemoteException {
mNetd.networkRemoveRouteParcel(netId, toRouteInfoParcel(route));
mNetd.networkRemoveRouteParcel(netId, route);
}
/**
@ -112,9 +109,9 @@ public class RoutingCoordinatorService extends IRoutingCoordinator.Stub {
* cause of the failure.
*/
@Override
public void updateRoute(final int netId, final RouteInfo route)
public void updateRouteParcel(int netId, RouteInfoParcel route)
throws ServiceSpecificException, RemoteException {
mNetd.networkUpdateRouteParcel(netId, toRouteInfoParcel(route));
mNetd.networkUpdateRouteParcel(netId, route);
}
/**