Merge "Add LinkProps and NetworkCaps methods to SystemApi"
am: 4bde11491b
Change-Id: I7ba317e49a6ad7a7413d9ff4e312aed0b700e695
This commit is contained in:
@@ -3061,14 +3061,30 @@ package android.net {
|
||||
|
||||
public final class LinkProperties implements android.os.Parcelable {
|
||||
ctor public LinkProperties();
|
||||
method public boolean addDnsServer(java.net.InetAddress);
|
||||
method public boolean addRoute(android.net.RouteInfo);
|
||||
method public void clear();
|
||||
method public String getTcpBufferSizes();
|
||||
method public java.util.List<java.net.InetAddress> getValidatedPrivateDnsServers();
|
||||
method public boolean hasGlobalIPv6Address();
|
||||
method public boolean hasIPv4Address();
|
||||
method public boolean hasIPv6DefaultRoute();
|
||||
method public boolean isIPv4Provisioned();
|
||||
method public boolean isIPv6Provisioned();
|
||||
method public boolean isProvisioned();
|
||||
method public boolean isReachable(java.net.InetAddress);
|
||||
method public boolean removeDnsServer(java.net.InetAddress);
|
||||
method public boolean removeRoute(android.net.RouteInfo);
|
||||
method public void setDnsServers(java.util.Collection<java.net.InetAddress>);
|
||||
method public void setDomains(String);
|
||||
method public void setHttpProxy(android.net.ProxyInfo);
|
||||
method public void setInterfaceName(String);
|
||||
method public void setLinkAddresses(java.util.Collection<android.net.LinkAddress>);
|
||||
method public void setMtu(int);
|
||||
method public void setPrivateDnsServerName(@Nullable String);
|
||||
method public void setTcpBufferSizes(String);
|
||||
method public void setUsePrivateDns(boolean);
|
||||
method public void setValidatedPrivateDnsServers(java.util.Collection<java.net.InetAddress>);
|
||||
}
|
||||
|
||||
public class Network implements android.os.Parcelable {
|
||||
@@ -3077,6 +3093,8 @@ package android.net {
|
||||
|
||||
public final class NetworkCapabilities implements android.os.Parcelable {
|
||||
method public int getSignalStrength();
|
||||
method public int[] getTransportTypes();
|
||||
method public boolean satisfiedByNetworkCapabilities(android.net.NetworkCapabilities);
|
||||
field public static final int NET_CAPABILITY_OEM_PAID = 22; // 0x16
|
||||
}
|
||||
|
||||
|
||||
@@ -620,6 +620,25 @@ package android.net {
|
||||
method public boolean isSameAddressAs(android.net.LinkAddress);
|
||||
}
|
||||
|
||||
public final class LinkProperties implements android.os.Parcelable {
|
||||
method public boolean addDnsServer(java.net.InetAddress);
|
||||
method public String getTcpBufferSizes();
|
||||
method public java.util.List<java.net.InetAddress> getValidatedPrivateDnsServers();
|
||||
method public boolean hasGlobalIPv6Address();
|
||||
method public boolean hasIPv4Address();
|
||||
method public boolean hasIPv6DefaultRoute();
|
||||
method public boolean isIPv4Provisioned();
|
||||
method public boolean isIPv6Provisioned();
|
||||
method public boolean isProvisioned();
|
||||
method public boolean isReachable(java.net.InetAddress);
|
||||
method public boolean removeDnsServer(java.net.InetAddress);
|
||||
method public boolean removeRoute(android.net.RouteInfo);
|
||||
method public void setPrivateDnsServerName(@Nullable String);
|
||||
method public void setTcpBufferSizes(String);
|
||||
method public void setUsePrivateDns(boolean);
|
||||
method public void setValidatedPrivateDnsServers(java.util.Collection<java.net.InetAddress>);
|
||||
}
|
||||
|
||||
public class Network implements android.os.Parcelable {
|
||||
method public android.net.Network getPrivateDnsBypassingCopy();
|
||||
}
|
||||
@@ -627,6 +646,7 @@ package android.net {
|
||||
public final class NetworkCapabilities implements android.os.Parcelable {
|
||||
method public int[] getCapabilities();
|
||||
method public int[] getTransportTypes();
|
||||
method public boolean satisfiedByNetworkCapabilities(android.net.NetworkCapabilities);
|
||||
}
|
||||
|
||||
public final class RouteInfo implements android.os.Parcelable {
|
||||
|
||||
@@ -19,6 +19,7 @@ package android.net;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.TestApi;
|
||||
import android.annotation.UnsupportedAppUsage;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
@@ -368,7 +369,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @return true if the DNS server was added, false if it was already present.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean addDnsServer(InetAddress dnsServer) {
|
||||
if (dnsServer != null && !mDnses.contains(dnsServer)) {
|
||||
mDnses.add(dnsServer);
|
||||
@@ -384,7 +386,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @return true if the DNS server was removed, false if it did not exist.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean removeDnsServer(InetAddress dnsServer) {
|
||||
if (dnsServer != null) {
|
||||
return mDnses.remove(dnsServer);
|
||||
@@ -423,6 +426,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @param usePrivateDns The private DNS state.
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public void setUsePrivateDns(boolean usePrivateDns) {
|
||||
mUsePrivateDns = usePrivateDns;
|
||||
}
|
||||
@@ -448,6 +453,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @param privateDnsServerName The private DNS server name.
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public void setPrivateDnsServerName(@Nullable String privateDnsServerName) {
|
||||
mPrivateDnsServerName = privateDnsServerName;
|
||||
}
|
||||
@@ -510,6 +517,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* object.
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public void setValidatedPrivateDnsServers(Collection<InetAddress> dnsServers) {
|
||||
mValidatedPrivateDnses.clear();
|
||||
for (InetAddress dnsServer: dnsServers) {
|
||||
@@ -525,6 +534,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* DNS servers on this link.
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public List<InetAddress> getValidatedPrivateDnsServers() {
|
||||
return Collections.unmodifiableList(mValidatedPrivateDnses);
|
||||
}
|
||||
@@ -636,7 +647,8 @@ public final class LinkProperties implements Parcelable {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public void setTcpBufferSizes(String tcpBufferSizes) {
|
||||
mTcpBufferSizes = tcpBufferSizes;
|
||||
}
|
||||
@@ -648,7 +660,8 @@ public final class LinkProperties implements Parcelable {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public String getTcpBufferSizes() {
|
||||
return mTcpBufferSizes;
|
||||
}
|
||||
@@ -699,7 +712,8 @@ public final class LinkProperties implements Parcelable {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean removeRoute(RouteInfo route) {
|
||||
return route != null &&
|
||||
Objects.equals(mIfaceName, route.getInterface()) &&
|
||||
@@ -960,7 +974,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @return {@code true} if there is an IPv4 address, {@code false} otherwise.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean hasIPv4Address() {
|
||||
for (LinkAddress address : mLinkAddresses) {
|
||||
if (address.getAddress() instanceof Inet4Address) {
|
||||
@@ -988,7 +1003,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @return {@code true} if there is a global preferred IPv6 address, {@code false} otherwise.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean hasGlobalIPv6Address() {
|
||||
for (LinkAddress address : mLinkAddresses) {
|
||||
if (address.getAddress() instanceof Inet6Address && address.isGlobalPreferred()) {
|
||||
@@ -1020,7 +1036,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @return {@code true} if there is an IPv6 default route, {@code false} otherwise.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean hasIPv6DefaultRoute() {
|
||||
for (RouteInfo r : mRoutes) {
|
||||
if (r.isIPv6Default()) {
|
||||
@@ -1099,6 +1116,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @return {@code true} if the link is provisioned, {@code false} otherwise.
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean isIPv4Provisioned() {
|
||||
return (hasIPv4Address() &&
|
||||
hasIPv4DefaultRoute() &&
|
||||
@@ -1112,7 +1131,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @return {@code true} if the link is provisioned, {@code false} otherwise.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean isIPv6Provisioned() {
|
||||
return (hasGlobalIPv6Address() &&
|
||||
hasIPv6DefaultRoute() &&
|
||||
@@ -1126,7 +1146,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @return {@code true} if the link is provisioned, {@code false} otherwise.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean isProvisioned() {
|
||||
return (isIPv4Provisioned() || isIPv6Provisioned());
|
||||
}
|
||||
@@ -1138,7 +1159,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* {@code false} otherwise.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean isReachable(InetAddress ip) {
|
||||
final List<RouteInfo> allRoutes = getAllRoutes();
|
||||
// If we don't have a route to this IP address, it's not reachable.
|
||||
|
||||
@@ -35,5 +35,4 @@ parcelable LinkPropertiesParcelable {
|
||||
int mtu;
|
||||
String tcpBufferSizes;
|
||||
IpPrefixParcelable nat64Prefix;
|
||||
LinkPropertiesParcelable[] stackedLinks;
|
||||
}
|
||||
@@ -712,6 +712,7 @@ public final class NetworkCapabilities implements Parcelable {
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public @Transport int[] getTransportTypes() {
|
||||
return BitUtils.unpackBits(mTransportTypes);
|
||||
}
|
||||
@@ -1312,6 +1313,8 @@ public final class NetworkCapabilities implements Parcelable {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean satisfiedByNetworkCapabilities(NetworkCapabilities nc) {
|
||||
return satisfiedByNetworkCapabilities(nc, false);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import android.net.INetd;
|
||||
import android.net.IpPrefix;
|
||||
import android.net.LinkAddress;
|
||||
import android.net.LinkProperties;
|
||||
import android.net.LinkProperties.ProvisioningChange;
|
||||
import android.net.Network;
|
||||
import android.net.ProvisioningConfigurationParcelable;
|
||||
import android.net.ProxyInfo;
|
||||
@@ -371,6 +370,11 @@ public class IpClient extends StateMachine {
|
||||
|
||||
private static final int IMMEDIATE_FAILURE_DURATION = 0;
|
||||
|
||||
private static final int PROV_CHANGE_STILL_NOT_PROVISIONED = 1;
|
||||
private static final int PROV_CHANGE_LOST_PROVISIONING = 2;
|
||||
private static final int PROV_CHANGE_GAINED_PROVISIONING = 3;
|
||||
private static final int PROV_CHANGE_STILL_PROVISIONED = 4;
|
||||
|
||||
private final State mStoppedState = new StoppedState();
|
||||
private final State mStoppingState = new StoppingState();
|
||||
private final State mStartedState = new StartedState();
|
||||
@@ -911,18 +915,18 @@ public class IpClient extends StateMachine {
|
||||
// object that is a correct and complete assessment of what changed, taking
|
||||
// account of the asymmetries described in the comments in this function.
|
||||
// Then switch to using it everywhere (IpReachabilityMonitor, etc.).
|
||||
private ProvisioningChange compareProvisioning(LinkProperties oldLp, LinkProperties newLp) {
|
||||
ProvisioningChange delta;
|
||||
private int compareProvisioning(LinkProperties oldLp, LinkProperties newLp) {
|
||||
int delta;
|
||||
InitialConfiguration config = mConfiguration != null ? mConfiguration.mInitialConfig : null;
|
||||
final boolean wasProvisioned = isProvisioned(oldLp, config);
|
||||
final boolean isProvisioned = isProvisioned(newLp, config);
|
||||
|
||||
if (!wasProvisioned && isProvisioned) {
|
||||
delta = ProvisioningChange.GAINED_PROVISIONING;
|
||||
delta = PROV_CHANGE_GAINED_PROVISIONING;
|
||||
} else if (wasProvisioned && isProvisioned) {
|
||||
delta = ProvisioningChange.STILL_PROVISIONED;
|
||||
delta = PROV_CHANGE_STILL_PROVISIONED;
|
||||
} else if (!wasProvisioned && !isProvisioned) {
|
||||
delta = ProvisioningChange.STILL_NOT_PROVISIONED;
|
||||
delta = PROV_CHANGE_STILL_NOT_PROVISIONED;
|
||||
} else {
|
||||
// (wasProvisioned && !isProvisioned)
|
||||
//
|
||||
@@ -934,7 +938,7 @@ public class IpClient extends StateMachine {
|
||||
// that to be a network without DNS servers and connect anyway.
|
||||
//
|
||||
// See the comment below.
|
||||
delta = ProvisioningChange.LOST_PROVISIONING;
|
||||
delta = PROV_CHANGE_LOST_PROVISIONING;
|
||||
}
|
||||
|
||||
final boolean lostIPv6 = oldLp.isIPv6Provisioned() && !newLp.isIPv6Provisioned();
|
||||
@@ -970,7 +974,7 @@ public class IpClient extends StateMachine {
|
||||
// delta will never be LOST_PROVISIONING. So check for loss of
|
||||
// provisioning here too.
|
||||
if (lostIPv4Address || (lostIPv6 && !ignoreIPv6ProvisioningLoss)) {
|
||||
delta = ProvisioningChange.LOST_PROVISIONING;
|
||||
delta = PROV_CHANGE_LOST_PROVISIONING;
|
||||
}
|
||||
|
||||
// Additionally:
|
||||
@@ -979,15 +983,15 @@ public class IpClient extends StateMachine {
|
||||
// IPv6 default route then also consider the loss of that default route
|
||||
// to be a loss of provisioning. See b/27962810.
|
||||
if (oldLp.hasGlobalIPv6Address() && (lostIPv6Router && !ignoreIPv6ProvisioningLoss)) {
|
||||
delta = ProvisioningChange.LOST_PROVISIONING;
|
||||
delta = PROV_CHANGE_LOST_PROVISIONING;
|
||||
}
|
||||
|
||||
return delta;
|
||||
}
|
||||
|
||||
private void dispatchCallback(ProvisioningChange delta, LinkProperties newLp) {
|
||||
private void dispatchCallback(int delta, LinkProperties newLp) {
|
||||
switch (delta) {
|
||||
case GAINED_PROVISIONING:
|
||||
case PROV_CHANGE_GAINED_PROVISIONING:
|
||||
if (DBG) {
|
||||
Log.d(mTag, "onProvisioningSuccess()");
|
||||
}
|
||||
@@ -995,7 +999,7 @@ public class IpClient extends StateMachine {
|
||||
mCallback.onProvisioningSuccess(newLp);
|
||||
break;
|
||||
|
||||
case LOST_PROVISIONING:
|
||||
case PROV_CHANGE_LOST_PROVISIONING:
|
||||
if (DBG) {
|
||||
Log.d(mTag, "onProvisioningFailure()");
|
||||
}
|
||||
@@ -1015,7 +1019,7 @@ public class IpClient extends StateMachine {
|
||||
// Updates all IpClient-related state concerned with LinkProperties.
|
||||
// Returns a ProvisioningChange for possibly notifying other interested
|
||||
// parties that are not fronted by IpClient.
|
||||
private ProvisioningChange setLinkProperties(LinkProperties newLp) {
|
||||
private int setLinkProperties(LinkProperties newLp) {
|
||||
if (mApfFilter != null) {
|
||||
mApfFilter.setLinkProperties(newLp);
|
||||
}
|
||||
@@ -1023,10 +1027,10 @@ public class IpClient extends StateMachine {
|
||||
mIpReachabilityMonitor.updateLinkProperties(newLp);
|
||||
}
|
||||
|
||||
ProvisioningChange delta = compareProvisioning(mLinkProperties, newLp);
|
||||
int delta = compareProvisioning(mLinkProperties, newLp);
|
||||
mLinkProperties = new LinkProperties(newLp);
|
||||
|
||||
if (delta == ProvisioningChange.GAINED_PROVISIONING) {
|
||||
if (delta == PROV_CHANGE_GAINED_PROVISIONING) {
|
||||
// TODO: Add a proper ProvisionedState and cancel the alarm in
|
||||
// its enter() method.
|
||||
mProvisioningTimeoutAlarm.cancel();
|
||||
@@ -1122,17 +1126,17 @@ public class IpClient extends StateMachine {
|
||||
if (Objects.equals(newLp, mLinkProperties)) {
|
||||
return true;
|
||||
}
|
||||
final ProvisioningChange delta = setLinkProperties(newLp);
|
||||
final int delta = setLinkProperties(newLp);
|
||||
if (sendCallbacks) {
|
||||
dispatchCallback(delta, newLp);
|
||||
}
|
||||
return (delta != ProvisioningChange.LOST_PROVISIONING);
|
||||
return (delta != PROV_CHANGE_LOST_PROVISIONING);
|
||||
}
|
||||
|
||||
private void handleIPv4Success(DhcpResults dhcpResults) {
|
||||
mDhcpResults = new DhcpResults(dhcpResults);
|
||||
final LinkProperties newLp = assembleLinkProperties();
|
||||
final ProvisioningChange delta = setLinkProperties(newLp);
|
||||
final int delta = setLinkProperties(newLp);
|
||||
|
||||
if (DBG) {
|
||||
Log.d(mTag, "onNewDhcpResults(" + Objects.toString(dhcpResults) + ")");
|
||||
@@ -1160,7 +1164,7 @@ public class IpClient extends StateMachine {
|
||||
|
||||
private void handleProvisioningFailure() {
|
||||
final LinkProperties newLp = assembleLinkProperties();
|
||||
ProvisioningChange delta = setLinkProperties(newLp);
|
||||
int delta = setLinkProperties(newLp);
|
||||
// If we've gotten here and we're still not provisioned treat that as
|
||||
// a total loss of provisioning.
|
||||
//
|
||||
@@ -1169,12 +1173,12 @@ public class IpClient extends StateMachine {
|
||||
// timeout expired.
|
||||
//
|
||||
// Regardless: GAME OVER.
|
||||
if (delta == ProvisioningChange.STILL_NOT_PROVISIONED) {
|
||||
delta = ProvisioningChange.LOST_PROVISIONING;
|
||||
if (delta == PROV_CHANGE_STILL_NOT_PROVISIONED) {
|
||||
delta = PROV_CHANGE_LOST_PROVISIONING;
|
||||
}
|
||||
|
||||
dispatchCallback(delta, newLp);
|
||||
if (delta == ProvisioningChange.LOST_PROVISIONING) {
|
||||
if (delta == PROV_CHANGE_LOST_PROVISIONING) {
|
||||
transitionTo(mStoppingState);
|
||||
}
|
||||
}
|
||||
@@ -1646,7 +1650,7 @@ public class IpClient extends StateMachine {
|
||||
mDhcpClient.sendMessage(DhcpClient.EVENT_LINKADDRESS_CONFIGURED);
|
||||
} else {
|
||||
logError("Failed to set IPv4 address.");
|
||||
dispatchCallback(ProvisioningChange.LOST_PROVISIONING,
|
||||
dispatchCallback(PROV_CHANGE_LOST_PROVISIONING,
|
||||
new LinkProperties(mLinkProperties));
|
||||
transitionTo(mStoppingState);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import static android.net.metrics.IpReachabilityEvent.PROVISIONING_LOST_ORGANIC;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.LinkProperties;
|
||||
import android.net.LinkProperties.ProvisioningChange;
|
||||
import android.net.RouteInfo;
|
||||
import android.net.ip.IpNeighborMonitor.NeighborEvent;
|
||||
import android.net.metrics.IpConnectivityLog;
|
||||
@@ -308,10 +307,11 @@ public class IpReachabilityMonitor {
|
||||
}
|
||||
}
|
||||
|
||||
final ProvisioningChange delta = LinkProperties.compareProvisioning(
|
||||
mLinkProperties, whatIfLp);
|
||||
final boolean lostProvisioning =
|
||||
(mLinkProperties.isIPv4Provisioned() && !whatIfLp.isIPv4Provisioned())
|
||||
|| (mLinkProperties.isIPv6Provisioned() && !whatIfLp.isIPv6Provisioned());
|
||||
|
||||
if (delta == ProvisioningChange.LOST_PROVISIONING) {
|
||||
if (lostProvisioning) {
|
||||
final String logMsg = "FAILURE: LOST_PROVISIONING, " + event;
|
||||
Log.w(TAG, logMsg);
|
||||
if (mCallback != null) {
|
||||
@@ -320,7 +320,7 @@ public class IpReachabilityMonitor {
|
||||
mCallback.notifyLost(ip, logMsg);
|
||||
}
|
||||
}
|
||||
logNudFailed(delta);
|
||||
logNudFailed(lostProvisioning);
|
||||
}
|
||||
|
||||
private boolean avoidingBadLinks() {
|
||||
@@ -370,11 +370,10 @@ public class IpReachabilityMonitor {
|
||||
mMetricsLog.log(mInterfaceParams.name, new IpReachabilityEvent(eventType));
|
||||
}
|
||||
|
||||
private void logNudFailed(ProvisioningChange delta) {
|
||||
private void logNudFailed(boolean lostProvisioning) {
|
||||
long duration = SystemClock.elapsedRealtime() - mLastProbeTimeMs;
|
||||
boolean isFromProbe = (duration < getProbeWakeLockDuration());
|
||||
boolean isProvisioningLost = (delta == ProvisioningChange.LOST_PROVISIONING);
|
||||
int eventType = nudFailureEventType(isFromProbe, isProvisioningLost);
|
||||
int eventType = nudFailureEventType(isFromProbe, lostProvisioning);
|
||||
mMetricsLog.log(mInterfaceParams.name, new IpReachabilityEvent(eventType));
|
||||
}
|
||||
|
||||
|
||||
@@ -182,9 +182,6 @@ public final class LinkPropertiesParcelableUtil {
|
||||
parcel.mtu = lp.getMtu();
|
||||
parcel.tcpBufferSizes = lp.getTcpBufferSizes();
|
||||
parcel.nat64Prefix = toStableParcelable(lp.getNat64Prefix());
|
||||
parcel.stackedLinks = toParcelableArray(
|
||||
lp.getStackedLinks(), LinkPropertiesParcelableUtil::toStableParcelable,
|
||||
LinkPropertiesParcelable.class);
|
||||
return parcel;
|
||||
}
|
||||
|
||||
@@ -216,9 +213,6 @@ public final class LinkPropertiesParcelableUtil {
|
||||
lp.setMtu(parcel.mtu);
|
||||
lp.setTcpBufferSizes(parcel.tcpBufferSizes);
|
||||
lp.setNat64Prefix(fromStableParcelable(parcel.nat64Prefix));
|
||||
for (LinkPropertiesParcelable stackedLink : parcel.stackedLinks) {
|
||||
lp.addStackedLink(fromStableParcelable(stackedLink));
|
||||
}
|
||||
return lp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,61 +48,52 @@ public class LinkPropertiesParcelableUtilTest {
|
||||
private LinkProperties mLinkProperties;
|
||||
|
||||
private static final String TEST_LINKPROPS_IFACE = "TEST_IFACE";
|
||||
private static final String TEST_STACKED_LINK_1_IFACE = "TEST_STACKED_IFACE_1";
|
||||
private static final String TEST_STACKED_LINK_2_IFACE = "TEST_STACKED_IFACE_2";
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mLinkProperties = makeLinkProperties(TEST_LINKPROPS_IFACE);
|
||||
mLinkProperties.addStackedLink(makeLinkProperties(TEST_STACKED_LINK_1_IFACE));
|
||||
mLinkProperties.addStackedLink(makeLinkProperties(TEST_STACKED_LINK_2_IFACE));
|
||||
}
|
||||
|
||||
private static LinkProperties makeLinkProperties(String iface) {
|
||||
final LinkProperties lp = new LinkProperties();
|
||||
lp.setInterfaceName(iface);
|
||||
lp.setLinkAddresses(Arrays.asList(
|
||||
mLinkProperties = new LinkProperties();
|
||||
mLinkProperties.setInterfaceName(TEST_LINKPROPS_IFACE);
|
||||
mLinkProperties.setLinkAddresses(Arrays.asList(
|
||||
new LinkAddress(InetAddresses.parseNumericAddress("192.168.0.42"), 16),
|
||||
new LinkAddress(InetAddresses.parseNumericAddress("2001:db8::7"), 42)));
|
||||
lp.setDnsServers(Arrays.asList(
|
||||
mLinkProperties.setDnsServers(Arrays.asList(
|
||||
InetAddresses.parseNumericAddress("2001:db8::42"),
|
||||
InetAddresses.parseNumericAddress("192.168.1.1")
|
||||
));
|
||||
lp.setValidatedPrivateDnsServers(Arrays.asList(
|
||||
mLinkProperties.setValidatedPrivateDnsServers(Arrays.asList(
|
||||
InetAddresses.parseNumericAddress("2001:db8::43"),
|
||||
InetAddresses.parseNumericAddress("192.168.42.43")
|
||||
));
|
||||
lp.setPcscfServers(Arrays.asList(
|
||||
mLinkProperties.setPcscfServers(Arrays.asList(
|
||||
InetAddresses.parseNumericAddress("2001:db8::47"),
|
||||
InetAddresses.parseNumericAddress("192.168.42.47")
|
||||
));
|
||||
lp.setUsePrivateDns(true);
|
||||
lp.setPrivateDnsServerName("test.example.com");
|
||||
lp.setDomains("test1.example.com,test2.example.com");
|
||||
lp.addRoute(new RouteInfo(
|
||||
mLinkProperties.setUsePrivateDns(true);
|
||||
mLinkProperties.setPrivateDnsServerName("test.example.com");
|
||||
mLinkProperties.setDomains("test1.example.com,test2.example.com");
|
||||
mLinkProperties.addRoute(new RouteInfo(
|
||||
new IpPrefix(InetAddresses.parseNumericAddress("2001:db8::44"), 45),
|
||||
InetAddresses.parseNumericAddress("2001:db8::45"),
|
||||
iface,
|
||||
TEST_LINKPROPS_IFACE,
|
||||
RouteInfo.RTN_UNICAST
|
||||
));
|
||||
lp.addRoute(new RouteInfo(
|
||||
mLinkProperties.addRoute(new RouteInfo(
|
||||
new IpPrefix(InetAddresses.parseNumericAddress("192.168.44.45"), 16),
|
||||
InetAddresses.parseNumericAddress("192.168.45.1"),
|
||||
iface,
|
||||
TEST_LINKPROPS_IFACE,
|
||||
RouteInfo.RTN_THROW
|
||||
));
|
||||
lp.setHttpProxy(new ProxyInfo("test3.example.com", 8000,
|
||||
mLinkProperties.setHttpProxy(new ProxyInfo("test3.example.com", 8000,
|
||||
"excl1.example.com,excl2.example.com"));
|
||||
lp.setMtu(5000);
|
||||
lp.setTcpBufferSizes("1,2,3,4,5,6");
|
||||
lp.setNat64Prefix(new IpPrefix(InetAddresses.parseNumericAddress("2001:db8::48"), 96));
|
||||
mLinkProperties.setMtu(5000);
|
||||
mLinkProperties.setTcpBufferSizes("1,2,3,4,5,6");
|
||||
mLinkProperties.setNat64Prefix(
|
||||
new IpPrefix(InetAddresses.parseNumericAddress("2001:db8::48"), 96));
|
||||
|
||||
// Verify that this test does not miss any new field added later.
|
||||
// If any added field is not included in LinkProperties#equals, assertLinkPropertiesEquals
|
||||
// must also be updated.
|
||||
assertFieldCountEquals(14, LinkProperties.class);
|
||||
|
||||
return lp;
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -186,7 +177,7 @@ public class LinkPropertiesParcelableUtilTest {
|
||||
private static void assertLinkPropertiesEquals(LinkProperties expected, LinkProperties actual) {
|
||||
assertEquals(expected, actual);
|
||||
|
||||
// LinkProperties equals() does not include stacked links
|
||||
assertEquals(expected.getStackedLinks(), actual.getStackedLinks());
|
||||
// Equality on stacked links is not tested as they should not be passed to processes using
|
||||
// LinkPropertiesParcelable.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user