Merge changes I18d2ccea,I4e80a75d,Ib8ea2a17,Iaba678ed

* changes:
  Remove hidden API usage of RouteInfo
  Remove reference of NetworkAgent#unwanted()
  Remove references of NetworkAgentConfig constructor
  Remove reference of @ValidationStatus annotation
This commit is contained in:
Treehugger Robot
2021-03-19 11:23:18 +00:00
committed by Gerrit Code Review
4 changed files with 22 additions and 16 deletions

View File

@@ -643,7 +643,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
String route, String gateway, String ifName) throws RemoteException {
final RouteInfo processRoute = new RouteInfo(new IpPrefix(route),
("".equals(gateway)) ? null : InetAddresses.parseNumericAddress(gateway),
ifName);
ifName, RouteInfo.RTN_UNICAST);
mDaemonHandler.post(() -> notifyRouteChange(updated, processRoute));
}

View File

@@ -1175,11 +1175,13 @@ public class Vpn {
if (!allowIPv4) {
lp.addRoute(new RouteInfo(new IpPrefix(
NetworkStackConstants.IPV4_ADDR_ANY, 0), RTN_UNREACHABLE));
NetworkStackConstants.IPV4_ADDR_ANY, 0), null /*gateway*/,
null /*iface*/, RTN_UNREACHABLE));
}
if (!allowIPv6) {
lp.addRoute(new RouteInfo(new IpPrefix(
NetworkStackConstants.IPV6_ADDR_ANY, 0), RTN_UNREACHABLE));
NetworkStackConstants.IPV6_ADDR_ANY, 0), null /*gateway*/,
null /*iface*/, RTN_UNREACHABLE));
}
// Concatenate search domains into a string.
@@ -1240,7 +1242,7 @@ public class Vpn {
mLegacyState = LegacyVpnInfo.STATE_CONNECTING;
updateState(DetailedState.CONNECTING, "agentConnect");
NetworkAgentConfig networkAgentConfig = new NetworkAgentConfig();
NetworkAgentConfig networkAgentConfig = new NetworkAgentConfig.Builder().build();
networkAgentConfig.allowBypass = mConfig.allowBypass && !mLockdown;
mNetworkCapabilities.setOwnerUid(mOwnerUID);
@@ -1263,7 +1265,7 @@ public class Vpn {
new NetworkScore.Builder().setLegacyInt(VPN_DEFAULT_SCORE).build(),
networkAgentConfig, mNetworkProvider) {
@Override
public void unwanted() {
public void onNetworkUnwanted() {
// We are user controlled, not driven by NetworkRequest.
}
};
@@ -2699,7 +2701,8 @@ public class Vpn {
mConfig.routes.clear();
for (final RouteInfo route : oldRoutes) {
mConfig.routes.add(new RouteInfo(route.getDestination(), RTN_UNREACHABLE));
mConfig.routes.add(new RouteInfo(route.getDestination(), null /*gateway*/,
null /*iface*/, RTN_UNREACHABLE));
}
if (mNetworkAgent != null) {
mNetworkAgent.sendLinkProperties(makeLinkProperties());
@@ -3038,10 +3041,12 @@ public class Vpn {
// Add a throw route for the VPN server endpoint, if one was specified.
if (endpointAddress instanceof Inet4Address) {
mConfig.routes.add(new RouteInfo(
new IpPrefix(endpointAddress, 32), RTN_THROW));
new IpPrefix(endpointAddress, 32), null /*gateway*/,
null /*iface*/, RTN_THROW));
} else if (endpointAddress instanceof Inet6Address) {
mConfig.routes.add(new RouteInfo(
new IpPrefix(endpointAddress, 128), RTN_THROW));
new IpPrefix(endpointAddress, 128), null /*gateway*/,
null /*iface*/, RTN_THROW));
} else {
Log.e(TAG, "Unknown IP address family for VPN endpoint: "
+ endpointAddress);

View File

@@ -405,7 +405,8 @@ public class VpnIkev2Utils {
for (final IkeTrafficSelector selector : trafficSelectors) {
for (final IpPrefix prefix :
new IpRange(selector.startingAddress, selector.endingAddress).asIpPrefixes()) {
routes.add(new RouteInfo(prefix, null));
routes.add(new RouteInfo(prefix, null /*gateway*/, null /*iface*/,
RouteInfo.RTN_UNICAST));
}
}

View File

@@ -42,7 +42,6 @@ import android.net.LinkAddress;
import android.net.LinkProperties;
import android.net.Network;
import android.net.NetworkAgent;
import android.net.NetworkAgent.ValidationStatus;
import android.net.NetworkAgentConfig;
import android.net.NetworkCapabilities;
import android.net.RouteInfo;
@@ -1442,17 +1441,16 @@ public class VcnGatewayConnection extends StateMachine {
caps,
lp,
Vcn.getNetworkScore(),
new NetworkAgentConfig(),
new NetworkAgentConfig.Builder().build(),
mVcnContext.getVcnNetworkProvider()) {
@Override
public void unwanted() {
public void onNetworkUnwanted() {
Slog.d(TAG, "NetworkAgent was unwanted");
teardownAsynchronously();
}
@Override
public void onValidationStatus(
@ValidationStatus int status, @Nullable Uri redirectUri) {
public void onValidationStatus(int status, @Nullable Uri redirectUri) {
if (status == NetworkAgent.VALIDATION_STATUS_VALID) {
clearFailedAttemptCounterAndSafeModeAlarm();
}
@@ -1798,8 +1796,10 @@ public class VcnGatewayConnection extends StateMachine {
lp.addDnsServer(addr);
}
lp.addRoute(new RouteInfo(new IpPrefix(Inet4Address.ANY, 0), null));
lp.addRoute(new RouteInfo(new IpPrefix(Inet6Address.ANY, 0), null));
lp.addRoute(new RouteInfo(new IpPrefix(Inet4Address.ANY, 0), null /*gateway*/,
null /*iface*/, RouteInfo.RTN_UNICAST));
lp.addRoute(new RouteInfo(new IpPrefix(Inet6Address.ANY, 0), null /*gateway*/,
null /*iface*/, RouteInfo.RTN_UNICAST));
lp.setMtu(gatewayConnectionConfig.getMaxMtu());