Merge "Remove unused methods from LinkProperties." am: 561107dd24
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1448415 Change-Id: I7adcc9920cc2bdebe9a1dc22f32ce0955a4524dd
This commit is contained in:
@@ -22,7 +22,6 @@ import android.annotation.SystemApi;
|
||||
import android.annotation.TestApi;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.net.util.LinkPropertiesUtils;
|
||||
import android.net.util.LinkPropertiesUtils.CompareResult;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -1668,78 +1667,6 @@ public final class LinkProperties implements Parcelable {
|
||||
&& isIdenticalCaptivePortalData(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the DNS addresses in this LinkProperties with another
|
||||
* LinkProperties, examining only DNS addresses on the base link.
|
||||
*
|
||||
* @param target a LinkProperties with the new list of dns addresses
|
||||
* @return the differences between the DNS addresses.
|
||||
* @hide
|
||||
*/
|
||||
public @NonNull CompareResult<InetAddress> compareDnses(@Nullable LinkProperties target) {
|
||||
/*
|
||||
* Duplicate the InetAddresses into removed, we will be removing
|
||||
* dns address which are common between mDnses and target
|
||||
* leaving the addresses that are different. And dns address which
|
||||
* are in target but not in mDnses are placed in the
|
||||
* addedAddresses.
|
||||
*/
|
||||
return new CompareResult<>(mDnses, target != null ? target.getDnsServers() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the validated private DNS addresses in this LinkProperties with another
|
||||
* LinkProperties.
|
||||
*
|
||||
* @param target a LinkProperties with the new list of validated private dns addresses
|
||||
* @return the differences between the DNS addresses.
|
||||
* @hide
|
||||
*/
|
||||
public @NonNull CompareResult<InetAddress> compareValidatedPrivateDnses(
|
||||
@Nullable LinkProperties target) {
|
||||
return new CompareResult<>(mValidatedPrivateDnses,
|
||||
target != null ? target.getValidatedPrivateDnsServers() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares all routes in this LinkProperties with another LinkProperties,
|
||||
* examining both the the base link and all stacked links.
|
||||
*
|
||||
* @param target a LinkProperties with the new list of routes
|
||||
* @return the differences between the routes.
|
||||
* @hide
|
||||
*/
|
||||
public @NonNull CompareResult<RouteInfo> compareAllRoutes(@Nullable LinkProperties target) {
|
||||
/*
|
||||
* Duplicate the RouteInfos into removed, we will be removing
|
||||
* routes which are common between mRoutes and target
|
||||
* leaving the routes that are different. And route address which
|
||||
* are in target but not in mRoutes are placed in added.
|
||||
*/
|
||||
return new CompareResult<>(getAllRoutes(), target != null ? target.getAllRoutes() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares all interface names in this LinkProperties with another
|
||||
* LinkProperties, examining both the the base link and all stacked links.
|
||||
*
|
||||
* @param target a LinkProperties with the new list of interface names
|
||||
* @return the differences between the interface names.
|
||||
* @hide
|
||||
*/
|
||||
public @NonNull CompareResult<String> compareAllInterfaceNames(
|
||||
@Nullable LinkProperties target) {
|
||||
/*
|
||||
* Duplicate the interface names into removed, we will be removing
|
||||
* interface names which are common between this and target
|
||||
* leaving the interface names that are different. And interface names which
|
||||
* are in target but not in this are placed in added.
|
||||
*/
|
||||
return new CompareResult<>(getAllInterfaceNames(),
|
||||
target != null ? target.getAllInterfaceNames() : null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate hashcode based on significant fields
|
||||
*
|
||||
|
||||
@@ -25,6 +25,7 @@ java_library {
|
||||
"junit",
|
||||
"mockito-target-minus-junit4",
|
||||
"net-tests-utils",
|
||||
"net-utils-framework-common",
|
||||
"platform-test-annotations",
|
||||
],
|
||||
libs: [
|
||||
|
||||
@@ -32,7 +32,6 @@ import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.net.LinkProperties.ProvisioningChange;
|
||||
import android.net.util.LinkPropertiesUtils.CompareResult;
|
||||
import android.os.Build;
|
||||
import android.system.OsConstants;
|
||||
import android.util.ArraySet;
|
||||
@@ -41,6 +40,7 @@ import androidx.core.os.BuildCompat;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.net.module.util.LinkPropertiesUtils.CompareResult;
|
||||
import com.android.testutils.DevSdkIgnoreRule;
|
||||
import com.android.testutils.DevSdkIgnoreRule.IgnoreAfter;
|
||||
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo;
|
||||
@@ -447,23 +447,21 @@ public class LinkPropertiesTest {
|
||||
assertEquals(3, lp.getRoutes().size());
|
||||
assertAllRoutesHaveInterface("wlan0", lp);
|
||||
|
||||
// Check comparisons work.
|
||||
// Check routes are updated correctly when calling setInterfaceName.
|
||||
LinkProperties lp2 = new LinkProperties(lp);
|
||||
assertAllRoutesHaveInterface("wlan0", lp2);
|
||||
// LinkProperties#compareAllRoutes exists both in R and before R, but the return type
|
||||
// changed in R, so a test compiled with the R version of LinkProperties cannot run on Q.
|
||||
if (isAtLeastR()) {
|
||||
assertEquals(0, lp.compareAllRoutes(lp2).added.size());
|
||||
assertEquals(0, lp.compareAllRoutes(lp2).removed.size());
|
||||
}
|
||||
final CompareResult<RouteInfo> cr1 =
|
||||
new CompareResult<>(lp.getAllRoutes(), lp2.getAllRoutes());
|
||||
assertEquals(0, cr1.added.size());
|
||||
assertEquals(0, cr1.removed.size());
|
||||
|
||||
lp2.setInterfaceName("p2p0");
|
||||
assertAllRoutesHaveInterface("p2p0", lp2);
|
||||
assertAllRoutesNotHaveInterface("wlan0", lp2);
|
||||
if (isAtLeastR()) {
|
||||
assertEquals(3, lp.compareAllRoutes(lp2).added.size());
|
||||
assertEquals(3, lp.compareAllRoutes(lp2).removed.size());
|
||||
}
|
||||
final CompareResult<RouteInfo> cr2 =
|
||||
new CompareResult<>(lp.getAllRoutes(), lp2.getAllRoutes());
|
||||
assertEquals(3, cr2.added.size());
|
||||
assertEquals(3, cr2.removed.size());
|
||||
|
||||
// Remove route with incorrect interface, no route removed.
|
||||
lp.removeRoute(new RouteInfo(prefix2, null, null));
|
||||
|
||||
Reference in New Issue
Block a user