Replace the way to add legacy routing

ConnectivityService is going to become a mainline module which
is not able to access hidden API. Thus, replace the usage from
NMS to INetd.

Bug: 170598012
Test: atest FrameworksNetTests ConnectivityManagerLegacyTest
Change-Id: Ice1bd1effab26555917bc1766354aeaebd41ad66
This commit is contained in:
Chiachang Wang
2020-11-06 14:48:30 +08:00
parent 60b84b216b
commit 6f95279de6

View File

@@ -1917,10 +1917,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
if (DBG) log("Adding legacy route " + bestRoute + if (DBG) log("Adding legacy route " + bestRoute +
" for UID/PID " + uid + "/" + Binder.getCallingPid()); " for UID/PID " + uid + "/" + Binder.getCallingPid());
final String dst = bestRoute.getDestinationLinkAddress().toString();
final String nextHop = bestRoute.hasGateway()
? bestRoute.getGateway().getHostAddress() : "";
try { try {
mNMS.addLegacyRouteForNetId(netId, bestRoute, uid); mNetd.networkAddLegacyRoute(netId, bestRoute.getInterface(), dst, nextHop , uid);
} catch (Exception e) { } catch (RemoteException | ServiceSpecificException e) {
// never crash - catch them all
if (DBG) loge("Exception trying to add a route: " + e); if (DBG) loge("Exception trying to add a route: " + e);
return false; return false;
} }