Add NetworkStack networking deps to SystemApi

Cherry-pick with conflicts fixed in CaptivePortalLoginActivity imports.
Test: atest FrameworksNetTests
Bug: 112869080
Merged-In: Id59dc06fb85e4ac88098f56b621ec880610759ce
Change-Id: I3c05e8fdd70497426d4fa433295c4fbdad07d9c9
This commit is contained in:
Remi NGUYEN VAN
2019-01-28 13:28:35 +09:00
parent 7e81ae73b4
commit 8bd18cff9a
3 changed files with 65 additions and 14 deletions

View File

@@ -16,10 +16,11 @@
package android.net;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
import android.net.LinkAddress;
import android.os.Parcelable;
import android.os.Parcel;
import android.os.Parcelable;
import java.net.InetAddress;
import java.util.ArrayList;
@@ -46,17 +47,22 @@ import java.util.Objects;
*
* @hide
*/
public class StaticIpConfiguration implements Parcelable {
@SystemApi
@TestApi
public final class StaticIpConfiguration implements Parcelable {
/** @hide */
@UnsupportedAppUsage
public LinkAddress ipAddress;
/** @hide */
@UnsupportedAppUsage
public InetAddress gateway;
/** @hide */
@UnsupportedAppUsage
public final ArrayList<InetAddress> dnsServers;
/** @hide */
@UnsupportedAppUsage
public String domains;
@UnsupportedAppUsage
public StaticIpConfiguration() {
dnsServers = new ArrayList<InetAddress>();
}
@@ -79,6 +85,41 @@ public class StaticIpConfiguration implements Parcelable {
domains = null;
}
public LinkAddress getIpAddress() {
return ipAddress;
}
public void setIpAddress(LinkAddress ipAddress) {
this.ipAddress = ipAddress;
}
public InetAddress getGateway() {
return gateway;
}
public void setGateway(InetAddress gateway) {
this.gateway = gateway;
}
public List<InetAddress> getDnsServers() {
return dnsServers;
}
public String getDomains() {
return domains;
}
public void setDomains(String newDomains) {
domains = newDomains;
}
/**
* Add a DNS server to this configuration.
*/
public void addDnsServer(InetAddress server) {
dnsServers.add(server);
}
/**
* Returns the network routes specified by this object. Will typically include a
* directly-connected route for the IP address's local subnet and a default route. If the
@@ -86,7 +127,6 @@ public class StaticIpConfiguration implements Parcelable {
* route to the gateway as well. This configuration is arguably invalid, but it used to work
* in K and earlier, and other OSes appear to accept it.
*/
@UnsupportedAppUsage
public List<RouteInfo> getRoutes(String iface) {
List<RouteInfo> routes = new ArrayList<RouteInfo>(3);
if (ipAddress != null) {
@@ -107,6 +147,7 @@ public class StaticIpConfiguration implements Parcelable {
* contained in the LinkProperties will not be a complete picture of the link's configuration,
* because any configuration information that is obtained dynamically by the network (e.g.,
* IPv6 configuration) will not be included.
* @hide
*/
public LinkProperties toLinkProperties(String iface) {
LinkProperties lp = new LinkProperties();
@@ -124,6 +165,7 @@ public class StaticIpConfiguration implements Parcelable {
return lp;
}
@Override
public String toString() {
StringBuffer str = new StringBuffer();
@@ -143,6 +185,7 @@ public class StaticIpConfiguration implements Parcelable {
return str.toString();
}
@Override
public int hashCode() {
int result = 13;
result = 47 * result + (ipAddress == null ? 0 : ipAddress.hashCode());
@@ -168,12 +211,10 @@ public class StaticIpConfiguration implements Parcelable {
}
/** Implement the Parcelable interface */
public static Creator<StaticIpConfiguration> CREATOR =
public static final Creator<StaticIpConfiguration> CREATOR =
new Creator<StaticIpConfiguration>() {
public StaticIpConfiguration createFromParcel(Parcel in) {
StaticIpConfiguration s = new StaticIpConfiguration();
readFromParcel(s, in);
return s;
return readFromParcel(in);
}
public StaticIpConfiguration[] newArray(int size) {
@@ -182,11 +223,13 @@ public class StaticIpConfiguration implements Parcelable {
};
/** Implement the Parcelable interface */
@Override
public int describeContents() {
return 0;
}
/** Implement the Parcelable interface */
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(ipAddress, flags);
NetworkUtils.parcelInetAddress(dest, gateway, flags);
@@ -197,7 +240,9 @@ public class StaticIpConfiguration implements Parcelable {
dest.writeString(domains);
}
protected static void readFromParcel(StaticIpConfiguration s, Parcel in) {
/** @hide */
public static StaticIpConfiguration readFromParcel(Parcel in) {
final StaticIpConfiguration s = new StaticIpConfiguration();
s.ipAddress = in.readParcelable(null);
s.gateway = NetworkUtils.unparcelInetAddress(in);
s.dnsServers.clear();
@@ -206,5 +251,6 @@ public class StaticIpConfiguration implements Parcelable {
s.dnsServers.add(NetworkUtils.unparcelInetAddress(in));
}
s.domains = in.readString();
return s;
}
}

View File

@@ -16,11 +16,16 @@
package android.net.apf;
import android.annotation.SystemApi;
import android.annotation.TestApi;
/**
* APF program support capabilities.
*
* @hide
*/
@SystemApi
@TestApi
public class ApfCapabilities {
/**
* Version of APF instruction set supported for packet filtering. 0 indicates no support for

View File

@@ -26,13 +26,13 @@ import android.os.Parcel;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.net.InetAddress;
import java.util.HashSet;
import java.util.Objects;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
@SmallTest
public class StaticIpConfigurationTest {
@@ -203,7 +203,7 @@ public class StaticIpConfigurationTest {
try {
s.writeToParcel(p, 0);
p.setDataPosition(0);
s2 = StaticIpConfiguration.CREATOR.createFromParcel(p);
s2 = StaticIpConfiguration.readFromParcel(p);
} finally {
p.recycle();
}