Add NetworkUtils utilities to SystemApi

attach*Filter and addArpEntry are necessary for the NetworkStack but are
only usable for apps that have system permissions.
Also includes system API for IpPrefix, LinkAddress, LinkProperties,
Network, and static modifier in ApfCapabilities that were missed in
previous CLs.

Test: Builds, flashed, WiFi works
Bug: 112869080
Change-Id: If141ae6a2f9145f5af64ba002ca44938f39b90a9
This commit is contained in:
Remi NGUYEN VAN
2019-01-29 12:08:43 +09:00
parent 37053eb78e
commit c7fe99fdbe
5 changed files with 14 additions and 3 deletions

View File

@@ -104,6 +104,8 @@ public final class IpPrefix implements Parcelable {
*
* @hide
*/
@SystemApi
@TestApi
public IpPrefix(String prefix) {
// We don't reuse the (InetAddress, int) constructor because "error: call to this must be
// first statement in constructor". We could factor out setting the member variables to an

View File

@@ -176,6 +176,7 @@ public class LinkAddress implements Parcelable {
* @hide
*/
@SystemApi
@TestApi
public LinkAddress(InetAddress address, int prefixLength) {
this(address, prefixLength, 0, 0);
this.scope = scopeForUnicastAddress(address);
@@ -199,6 +200,7 @@ public class LinkAddress implements Parcelable {
* @hide
*/
@SystemApi
@TestApi
public LinkAddress(String address) {
this(address, 0, 0);
this.scope = scopeForUnicastAddress(this.address);
@@ -212,6 +214,8 @@ public class LinkAddress implements Parcelable {
* @param scope The address scope.
* @hide
*/
@SystemApi
@TestApi
public LinkAddress(String address, int flags, int scope) {
// This may throw an IllegalArgumentException; catching it is the caller's responsibility.
// TODO: consider rejecting mapped IPv4 addresses such as "::ffff:192.0.2.5/24".

View File

@@ -287,7 +287,8 @@ public final class LinkProperties implements Parcelable {
* @return true if {@code address} was added or updated, false otherwise.
* @hide
*/
@UnsupportedAppUsage
@SystemApi
@TestApi
public boolean addLinkAddress(LinkAddress address) {
if (address == null) {
return false;
@@ -315,6 +316,8 @@ public final class LinkProperties implements Parcelable {
* @return true if the address was removed, false if it did not exist.
* @hide
*/
@SystemApi
@TestApi
public boolean removeLinkAddress(LinkAddress toRemove) {
int i = findLinkAddressIndex(toRemove);
if (i >= 0) {

View File

@@ -123,6 +123,8 @@ public class Network implements Parcelable {
/**
* @hide
*/
@SystemApi
@TestApi
public Network(Network that) {
this(that.netId, that.mPrivateDnsBypass);
}

View File

@@ -81,14 +81,14 @@ public class ApfCapabilities {
/**
* @return Whether the APF Filter in the device should filter out IEEE 802.3 Frames.
*/
public boolean getApfDrop8023Frames(Context context) {
public static boolean getApfDrop8023Frames(Context context) {
return context.getResources().getBoolean(R.bool.config_apfDrop802_3Frames);
}
/**
* @return An array of blacklisted EtherType, packets with EtherTypes within it will be dropped.
*/
public int[] getApfEthTypeBlackList(Context context) {
public static int[] getApfEthTypeBlackList(Context context) {
return context.getResources().getIntArray(R.array.config_apfEthTypeBlackList);
}
}