Move shared methods to net shared lib
The NetworkUtils.getNetworkPart() method is used by Settings and wifi. NetworkUtils is inside the incoming connectivity module. It will become inaccessible outside the module, so move the shared methods to shared lib and also move the related helper method. The corresponding usgae is also updated. Bug: 172183305 Test: atest FrameworksNetTests Change-Id: I47410afa27aad61f63759df41be959f323c1d100
This commit is contained in:
@@ -23,6 +23,8 @@ import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.net.module.util.NetUtils;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
@@ -58,7 +60,7 @@ public final class IpPrefix implements Parcelable {
|
||||
throw new IllegalArgumentException(
|
||||
"IpPrefix has " + address.length + " bytes which is neither 4 nor 16");
|
||||
}
|
||||
NetworkUtils.maskRawAddress(address, prefixLength);
|
||||
NetUtils.maskRawAddress(address, prefixLength);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,7 +191,7 @@ public final class IpPrefix implements Parcelable {
|
||||
if (addrBytes == null || addrBytes.length != this.address.length) {
|
||||
return false;
|
||||
}
|
||||
NetworkUtils.maskRawAddress(addrBytes, prefixLength);
|
||||
NetUtils.maskRawAddress(addrBytes, prefixLength);
|
||||
return Arrays.equals(this.address, addrBytes);
|
||||
}
|
||||
|
||||
@@ -203,7 +205,7 @@ public final class IpPrefix implements Parcelable {
|
||||
public boolean containsPrefix(@NonNull IpPrefix otherPrefix) {
|
||||
if (otherPrefix.getPrefixLength() < prefixLength) return false;
|
||||
final byte[] otherAddress = otherPrefix.getRawAddress();
|
||||
NetworkUtils.maskRawAddress(otherAddress, prefixLength);
|
||||
NetUtils.maskRawAddress(otherAddress, prefixLength);
|
||||
return Arrays.equals(otherAddress, address);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user