Merge "Add NetworkStack networking deps to SystemApi"
am: 9188b49259
Change-Id: Id8b31f100ab07ca9a38f4cff26c719dd9d74bc54
This commit is contained in:
@@ -3218,6 +3218,24 @@ package android.net {
|
||||
field public final android.net.RssiCurve rssiCurve;
|
||||
}
|
||||
|
||||
public final class StaticIpConfiguration implements android.os.Parcelable {
|
||||
ctor public StaticIpConfiguration();
|
||||
ctor public StaticIpConfiguration(android.net.StaticIpConfiguration);
|
||||
method public void addDnsServer(java.net.InetAddress);
|
||||
method public void clear();
|
||||
method public int describeContents();
|
||||
method public java.util.List<java.net.InetAddress> getDnsServers();
|
||||
method public String getDomains();
|
||||
method public java.net.InetAddress getGateway();
|
||||
method public android.net.LinkAddress getIpAddress();
|
||||
method public java.util.List<android.net.RouteInfo> getRoutes(String);
|
||||
method public void setDomains(String);
|
||||
method public void setGateway(java.net.InetAddress);
|
||||
method public void setIpAddress(android.net.LinkAddress);
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.net.StaticIpConfiguration> CREATOR;
|
||||
}
|
||||
|
||||
public class TrafficStats {
|
||||
method public static void setThreadStatsTagApp();
|
||||
method public static void setThreadStatsTagBackup();
|
||||
@@ -3243,6 +3261,47 @@ package android.net {
|
||||
|
||||
}
|
||||
|
||||
package android.net.apf {
|
||||
|
||||
public class ApfCapabilities {
|
||||
ctor public ApfCapabilities(int, int, int);
|
||||
method public boolean hasDataAccess();
|
||||
field public final int apfPacketFormat;
|
||||
field public final int apfVersionSupported;
|
||||
field public final int maximumApfProgramSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.net.captiveportal {
|
||||
|
||||
public final class CaptivePortalProbeResult {
|
||||
ctor public CaptivePortalProbeResult(int);
|
||||
ctor public CaptivePortalProbeResult(int, String, String);
|
||||
ctor public CaptivePortalProbeResult(int, String, String, android.net.captiveportal.CaptivePortalProbeSpec);
|
||||
method public boolean isFailed();
|
||||
method public boolean isPortal();
|
||||
method public boolean isSuccessful();
|
||||
field public static final android.net.captiveportal.CaptivePortalProbeResult FAILED;
|
||||
field public static final int FAILED_CODE = 599; // 0x257
|
||||
field public static final int PORTAL_CODE = 302; // 0x12e
|
||||
field public static final android.net.captiveportal.CaptivePortalProbeResult SUCCESS;
|
||||
field public static final int SUCCESS_CODE = 204; // 0xcc
|
||||
field public final String detectUrl;
|
||||
field @Nullable public final android.net.captiveportal.CaptivePortalProbeSpec probeSpec;
|
||||
field public final String redirectUrl;
|
||||
}
|
||||
|
||||
public abstract class CaptivePortalProbeSpec {
|
||||
method public String getEncodedSpec();
|
||||
method public abstract android.net.captiveportal.CaptivePortalProbeResult getResult(int, @Nullable String);
|
||||
method public java.net.URL getUrl();
|
||||
method public static java.util.Collection<android.net.captiveportal.CaptivePortalProbeSpec> parseCaptivePortalProbeSpecs(String);
|
||||
method @Nullable public static android.net.captiveportal.CaptivePortalProbeSpec parseSpecOrNull(@Nullable String);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.net.metrics {
|
||||
|
||||
public final class ApfProgramEvent implements android.net.metrics.IpConnectivityLog.Event {
|
||||
|
||||
@@ -669,6 +669,24 @@ package android.net {
|
||||
field public static final int RTN_UNREACHABLE = 7; // 0x7
|
||||
}
|
||||
|
||||
public final class StaticIpConfiguration implements android.os.Parcelable {
|
||||
ctor public StaticIpConfiguration();
|
||||
ctor public StaticIpConfiguration(android.net.StaticIpConfiguration);
|
||||
method public void addDnsServer(java.net.InetAddress);
|
||||
method public void clear();
|
||||
method public int describeContents();
|
||||
method public java.util.List<java.net.InetAddress> getDnsServers();
|
||||
method public String getDomains();
|
||||
method public java.net.InetAddress getGateway();
|
||||
method public android.net.LinkAddress getIpAddress();
|
||||
method public java.util.List<android.net.RouteInfo> getRoutes(String);
|
||||
method public void setDomains(String);
|
||||
method public void setGateway(java.net.InetAddress);
|
||||
method public void setIpAddress(android.net.LinkAddress);
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.net.StaticIpConfiguration> CREATOR;
|
||||
}
|
||||
|
||||
public class TrafficStats {
|
||||
method public static long getLoopbackRxBytes();
|
||||
method public static long getLoopbackRxPackets();
|
||||
@@ -678,6 +696,47 @@ package android.net {
|
||||
|
||||
}
|
||||
|
||||
package android.net.apf {
|
||||
|
||||
public class ApfCapabilities {
|
||||
ctor public ApfCapabilities(int, int, int);
|
||||
method public boolean hasDataAccess();
|
||||
field public final int apfPacketFormat;
|
||||
field public final int apfVersionSupported;
|
||||
field public final int maximumApfProgramSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.net.captiveportal {
|
||||
|
||||
public final class CaptivePortalProbeResult {
|
||||
ctor public CaptivePortalProbeResult(int);
|
||||
ctor public CaptivePortalProbeResult(int, String, String);
|
||||
ctor public CaptivePortalProbeResult(int, String, String, android.net.captiveportal.CaptivePortalProbeSpec);
|
||||
method public boolean isFailed();
|
||||
method public boolean isPortal();
|
||||
method public boolean isSuccessful();
|
||||
field public static final android.net.captiveportal.CaptivePortalProbeResult FAILED;
|
||||
field public static final int FAILED_CODE = 599; // 0x257
|
||||
field public static final int PORTAL_CODE = 302; // 0x12e
|
||||
field public static final android.net.captiveportal.CaptivePortalProbeResult SUCCESS;
|
||||
field public static final int SUCCESS_CODE = 204; // 0xcc
|
||||
field public final String detectUrl;
|
||||
field @Nullable public final android.net.captiveportal.CaptivePortalProbeSpec probeSpec;
|
||||
field public final String redirectUrl;
|
||||
}
|
||||
|
||||
public abstract class CaptivePortalProbeSpec {
|
||||
method public String getEncodedSpec();
|
||||
method public abstract android.net.captiveportal.CaptivePortalProbeResult getResult(int, @Nullable String);
|
||||
method public java.net.URL getUrl();
|
||||
method public static java.util.Collection<android.net.captiveportal.CaptivePortalProbeSpec> parseCaptivePortalProbeSpecs(String);
|
||||
method @Nullable public static android.net.captiveportal.CaptivePortalProbeSpec parseSpecOrNull(@Nullable String);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.net.metrics {
|
||||
|
||||
public final class ApfProgramEvent implements android.net.metrics.IpConnectivityLog.Event {
|
||||
|
||||
@@ -17,23 +17,38 @@
|
||||
package android.net;
|
||||
|
||||
import android.annotation.UnsupportedAppUsage;
|
||||
import android.net.NetworkUtils;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A simple object for retrieving the results of a DHCP request.
|
||||
* Optimized (attempted) for that jni interface
|
||||
* TODO - remove when DhcpInfo is deprecated. Move the remaining api to LinkProperties.
|
||||
* TODO: remove this class and replace with other existing constructs
|
||||
* @hide
|
||||
*/
|
||||
public class DhcpResults extends StaticIpConfiguration {
|
||||
public final class DhcpResults implements Parcelable {
|
||||
private static final String TAG = "DhcpResults";
|
||||
|
||||
@UnsupportedAppUsage
|
||||
public LinkAddress ipAddress;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
public InetAddress gateway;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
public final ArrayList<InetAddress> dnsServers = new ArrayList<>();
|
||||
|
||||
@UnsupportedAppUsage
|
||||
public String domains;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
public Inet4Address serverAddress;
|
||||
|
||||
@@ -48,23 +63,36 @@ public class DhcpResults extends StaticIpConfiguration {
|
||||
@UnsupportedAppUsage
|
||||
public int mtu;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
public DhcpResults() {
|
||||
super();
|
||||
}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Create a {@link StaticIpConfiguration} based on the DhcpResults.
|
||||
*/
|
||||
public StaticIpConfiguration toStaticIpConfiguration() {
|
||||
final StaticIpConfiguration s = new StaticIpConfiguration();
|
||||
// All these except dnsServers are immutable, so no need to make copies.
|
||||
s.ipAddress = ipAddress;
|
||||
s.gateway = gateway;
|
||||
s.dnsServers.addAll(dnsServers);
|
||||
s.domains = domains;
|
||||
return s;
|
||||
}
|
||||
|
||||
public DhcpResults(StaticIpConfiguration source) {
|
||||
super(source);
|
||||
if (source != null) {
|
||||
ipAddress = source.ipAddress;
|
||||
gateway = source.gateway;
|
||||
dnsServers.addAll(source.dnsServers);
|
||||
domains = source.domains;
|
||||
}
|
||||
}
|
||||
|
||||
/** copy constructor */
|
||||
@UnsupportedAppUsage
|
||||
public DhcpResults(DhcpResults source) {
|
||||
super(source);
|
||||
|
||||
this(source == null ? null : source.toStaticIpConfiguration());
|
||||
if (source != null) {
|
||||
// All these are immutable, so no need to make copies.
|
||||
serverAddress = source.serverAddress;
|
||||
vendorInfo = source.vendorInfo;
|
||||
leaseDuration = source.leaseDuration;
|
||||
@@ -72,6 +100,14 @@ public class DhcpResults extends StaticIpConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see StaticIpConfiguration#getRoutes(String)
|
||||
* @hide
|
||||
*/
|
||||
public List<RouteInfo> getRoutes(String iface) {
|
||||
return toStaticIpConfiguration().getRoutes(iface);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if this DHCP lease includes vendor hint that network link is
|
||||
* metered, and sensitive to heavy data transfers.
|
||||
@@ -85,7 +121,11 @@ public class DhcpResults extends StaticIpConfiguration {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
super.clear();
|
||||
ipAddress = null;
|
||||
gateway = null;
|
||||
dnsServers.clear();
|
||||
domains = null;
|
||||
serverAddress = null;
|
||||
vendorInfo = null;
|
||||
leaseDuration = 0;
|
||||
mtu = 0;
|
||||
@@ -111,20 +151,20 @@ public class DhcpResults extends StaticIpConfiguration {
|
||||
|
||||
DhcpResults target = (DhcpResults)obj;
|
||||
|
||||
return super.equals((StaticIpConfiguration) obj) &&
|
||||
Objects.equals(serverAddress, target.serverAddress) &&
|
||||
Objects.equals(vendorInfo, target.vendorInfo) &&
|
||||
leaseDuration == target.leaseDuration &&
|
||||
mtu == target.mtu;
|
||||
return toStaticIpConfiguration().equals(target.toStaticIpConfiguration())
|
||||
&& Objects.equals(serverAddress, target.serverAddress)
|
||||
&& Objects.equals(vendorInfo, target.vendorInfo)
|
||||
&& leaseDuration == target.leaseDuration
|
||||
&& mtu == target.mtu;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
/**
|
||||
* Implement the Parcelable interface
|
||||
*/
|
||||
public static final Creator<DhcpResults> CREATOR =
|
||||
new Creator<DhcpResults>() {
|
||||
public DhcpResults createFromParcel(Parcel in) {
|
||||
DhcpResults dhcpResults = new DhcpResults();
|
||||
readFromParcel(dhcpResults, in);
|
||||
return dhcpResults;
|
||||
return readFromParcel(in);
|
||||
}
|
||||
|
||||
public DhcpResults[] newArray(int size) {
|
||||
@@ -134,19 +174,26 @@ public class DhcpResults extends StaticIpConfiguration {
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
toStaticIpConfiguration().writeToParcel(dest, flags);
|
||||
dest.writeInt(leaseDuration);
|
||||
dest.writeInt(mtu);
|
||||
NetworkUtils.parcelInetAddress(dest, serverAddress, flags);
|
||||
dest.writeString(vendorInfo);
|
||||
}
|
||||
|
||||
private static void readFromParcel(DhcpResults dhcpResults, Parcel in) {
|
||||
StaticIpConfiguration.readFromParcel(dhcpResults, in);
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static DhcpResults readFromParcel(Parcel in) {
|
||||
final StaticIpConfiguration s = StaticIpConfiguration.CREATOR.createFromParcel(in);
|
||||
final DhcpResults dhcpResults = new DhcpResults(s);
|
||||
dhcpResults.leaseDuration = in.readInt();
|
||||
dhcpResults.mtu = in.readInt();
|
||||
dhcpResults.serverAddress = (Inet4Address) NetworkUtils.unparcelInetAddress(in);
|
||||
dhcpResults.vendorInfo = in.readString();
|
||||
return dhcpResults;
|
||||
}
|
||||
|
||||
// Utils for jni population - false on success
|
||||
@@ -184,25 +231,70 @@ public class DhcpResults extends StaticIpConfiguration {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setServerAddress(String addrString) {
|
||||
try {
|
||||
serverAddress = (Inet4Address) NetworkUtils.numericToInetAddress(addrString);
|
||||
} catch (IllegalArgumentException|ClassCastException e) {
|
||||
Log.e(TAG, "setServerAddress failed with addrString " + addrString);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a DNS server to this configuration.
|
||||
*/
|
||||
public void addDnsServer(InetAddress server) {
|
||||
dnsServers.add(server);
|
||||
}
|
||||
|
||||
public String getDomains() {
|
||||
return domains;
|
||||
}
|
||||
|
||||
public void setDomains(String domains) {
|
||||
this.domains = domains;
|
||||
}
|
||||
|
||||
public Inet4Address getServerAddress() {
|
||||
return serverAddress;
|
||||
}
|
||||
|
||||
public void setServerAddress(Inet4Address addr) {
|
||||
serverAddress = addr;
|
||||
}
|
||||
|
||||
public int getLeaseDuration() {
|
||||
return leaseDuration;
|
||||
}
|
||||
|
||||
public void setLeaseDuration(int duration) {
|
||||
leaseDuration = duration;
|
||||
}
|
||||
|
||||
public String getVendorInfo() {
|
||||
return vendorInfo;
|
||||
}
|
||||
|
||||
public void setVendorInfo(String info) {
|
||||
vendorInfo = info;
|
||||
}
|
||||
|
||||
public void setDomains(String newDomains) {
|
||||
domains = newDomains;
|
||||
public int getMtu() {
|
||||
return mtu;
|
||||
}
|
||||
|
||||
public void setMtu(int mtu) {
|
||||
this.mtu = mtu;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -17,11 +17,15 @@
|
||||
package android.net.captiveportal;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.TestApi;
|
||||
|
||||
/**
|
||||
* Result of calling isCaptivePortal().
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@TestApi
|
||||
public final class CaptivePortalProbeResult {
|
||||
public static final int SUCCESS_CODE = 204;
|
||||
public static final int FAILED_CODE = 599;
|
||||
|
||||
@@ -21,21 +21,26 @@ import static android.net.captiveportal.CaptivePortalProbeResult.SUCCESS_CODE;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.TestApi;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
/** @hide */
|
||||
@SystemApi
|
||||
@TestApi
|
||||
public abstract class CaptivePortalProbeSpec {
|
||||
public static final String HTTP_LOCATION_HEADER_NAME = "Location";
|
||||
|
||||
private static final String TAG = CaptivePortalProbeSpec.class.getSimpleName();
|
||||
private static final String REGEX_SEPARATOR = "@@/@@";
|
||||
private static final String SPEC_SEPARATOR = "@@,@@";
|
||||
@@ -55,7 +60,9 @@ public abstract class CaptivePortalProbeSpec {
|
||||
* @throws MalformedURLException The URL has invalid format for {@link URL#URL(String)}.
|
||||
* @throws ParseException The string is empty, does not match the above format, or a regular
|
||||
* expression is invalid for {@link Pattern#compile(String)}.
|
||||
* @hide
|
||||
*/
|
||||
@VisibleForTesting
|
||||
@NonNull
|
||||
public static CaptivePortalProbeSpec parseSpec(String spec) throws ParseException,
|
||||
MalformedURLException {
|
||||
@@ -113,7 +120,8 @@ public abstract class CaptivePortalProbeSpec {
|
||||
* <p>Each spec is separated by @@,@@ and follows the format for {@link #parseSpec(String)}.
|
||||
* <p>This method does not throw but ignores any entry that could not be parsed.
|
||||
*/
|
||||
public static CaptivePortalProbeSpec[] parseCaptivePortalProbeSpecs(String settingsVal) {
|
||||
public static Collection<CaptivePortalProbeSpec> parseCaptivePortalProbeSpecs(
|
||||
String settingsVal) {
|
||||
List<CaptivePortalProbeSpec> specs = new ArrayList<>();
|
||||
if (settingsVal != null) {
|
||||
for (String spec : TextUtils.split(settingsVal, SPEC_SEPARATOR)) {
|
||||
@@ -128,7 +136,7 @@ public abstract class CaptivePortalProbeSpec {
|
||||
if (specs.isEmpty()) {
|
||||
Log.e(TAG, String.format("could not create any validation spec from %s", settingsVal));
|
||||
}
|
||||
return specs.toArray(new CaptivePortalProbeSpec[specs.size()]);
|
||||
return specs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.android.captiveportallogin;
|
||||
|
||||
import static android.net.ConnectivityManager.EXTRA_CAPTIVE_PORTAL_PROBE_SPEC;
|
||||
import static android.net.captiveportal.CaptivePortalProbeSpec.HTTP_LOCATION_HEADER_NAME;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
@@ -40,7 +39,6 @@ import android.net.http.SslError;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
@@ -65,12 +63,11 @@ import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.lang.InterruptedException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@@ -81,6 +78,7 @@ public class CaptivePortalLoginActivity extends Activity {
|
||||
private static final boolean VDBG = false;
|
||||
|
||||
private static final int SOCKET_TIMEOUT_MS = 10000;
|
||||
public static final String HTTP_LOCATION_HEADER_NAME = "Location";
|
||||
|
||||
private enum Result {
|
||||
DISMISSED(MetricsEvent.ACTION_CAPTIVE_PORTAL_LOGIN_RESULT_DISMISSED),
|
||||
|
||||
@@ -29,7 +29,6 @@ import android.net.INetd;
|
||||
import android.net.IpPrefix;
|
||||
import android.net.LinkAddress;
|
||||
import android.net.LinkProperties;
|
||||
import android.net.Network;
|
||||
import android.net.ProvisioningConfigurationParcelable;
|
||||
import android.net.ProxyInfo;
|
||||
import android.net.ProxyInfoParcelable;
|
||||
@@ -1000,7 +999,9 @@ public class IpClient extends StateMachine {
|
||||
// mDhcpResults is never shared with any other owner so we don't have
|
||||
// to worry about concurrent modification.
|
||||
if (mDhcpResults != null) {
|
||||
for (RouteInfo route : mDhcpResults.getRoutes(mInterfaceName)) {
|
||||
final List<RouteInfo> routes =
|
||||
mDhcpResults.toStaticIpConfiguration().getRoutes(mInterfaceName);
|
||||
for (RouteInfo route : routes) {
|
||||
newLp.addRoute(route);
|
||||
}
|
||||
addAllReachableDnsServers(newLp, mDhcpResults.dnsServers);
|
||||
|
||||
@@ -93,6 +93,7 @@ import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -1146,7 +1147,10 @@ public class NetworkMonitor extends StateMachine {
|
||||
return null;
|
||||
}
|
||||
|
||||
return CaptivePortalProbeSpec.parseCaptivePortalProbeSpecs(settingsValue);
|
||||
final Collection<CaptivePortalProbeSpec> specs =
|
||||
CaptivePortalProbeSpec.parseCaptivePortalProbeSpecs(settingsValue);
|
||||
final CaptivePortalProbeSpec[] specsArray = new CaptivePortalProbeSpec[specs.size()];
|
||||
return specs.toArray(specsArray);
|
||||
} catch (Exception e) {
|
||||
// Don't let a misconfiguration bootloop the system.
|
||||
Log.e(TAG, "Error parsing configured fallback probe specs", e);
|
||||
|
||||
@@ -73,7 +73,7 @@ public final class IpConfigurationParcelableUtil {
|
||||
public static DhcpResultsParcelable toStableParcelable(@Nullable DhcpResults results) {
|
||||
if (results == null) return null;
|
||||
final DhcpResultsParcelable p = new DhcpResultsParcelable();
|
||||
p.baseConfiguration = toStableParcelable((StaticIpConfiguration) results);
|
||||
p.baseConfiguration = toStableParcelable(results.toStaticIpConfiguration());
|
||||
p.leaseDuration = results.leaseDuration;
|
||||
p.mtu = results.mtu;
|
||||
p.serverAddress = parcelAddress(results.serverAddress);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class IpConfigurationParcelableUtilTest {
|
||||
mDhcpResults.leaseDuration = 3600;
|
||||
mDhcpResults.mtu = 1450;
|
||||
// Any added DhcpResults field must be included in equals() to be tested properly
|
||||
assertFieldCountEquals(4, DhcpResults.class);
|
||||
assertFieldCountEquals(8, DhcpResults.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user