Merge "Fix linter errors in IpServer and its dependencies"
This commit is contained in:
@@ -34,32 +34,53 @@ import java.util.ArrayList;
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public class TetheringDependencies {
|
public class TetheringDependencies {
|
||||||
|
/**
|
||||||
|
* Get a reference to the offload hardware interface to be used by tethering.
|
||||||
|
*/
|
||||||
public OffloadHardwareInterface getOffloadHardwareInterface(Handler h, SharedLog log) {
|
public OffloadHardwareInterface getOffloadHardwareInterface(Handler h, SharedLog log) {
|
||||||
return new OffloadHardwareInterface(h, log);
|
return new OffloadHardwareInterface(h, log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a reference to the UpstreamNetworkMonitor to be used by tethering.
|
||||||
|
*/
|
||||||
public UpstreamNetworkMonitor getUpstreamNetworkMonitor(Context ctx, StateMachine target,
|
public UpstreamNetworkMonitor getUpstreamNetworkMonitor(Context ctx, StateMachine target,
|
||||||
SharedLog log, int what) {
|
SharedLog log, int what) {
|
||||||
return new UpstreamNetworkMonitor(ctx, target, log, what);
|
return new UpstreamNetworkMonitor(ctx, target, log, what);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a reference to the IPv6TetheringCoordinator to be used by tethering.
|
||||||
|
*/
|
||||||
public IPv6TetheringCoordinator getIPv6TetheringCoordinator(
|
public IPv6TetheringCoordinator getIPv6TetheringCoordinator(
|
||||||
ArrayList<IpServer> notifyList, SharedLog log) {
|
ArrayList<IpServer> notifyList, SharedLog log) {
|
||||||
return new IPv6TetheringCoordinator(notifyList, log);
|
return new IPv6TetheringCoordinator(notifyList, log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get dependencies to be used by IpServer.
|
||||||
|
*/
|
||||||
public IpServer.Dependencies getIpServerDependencies() {
|
public IpServer.Dependencies getIpServerDependencies() {
|
||||||
return new IpServer.Dependencies();
|
return new IpServer.Dependencies();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether tethering is supported on the device.
|
||||||
|
*/
|
||||||
public boolean isTetheringSupported() {
|
public boolean isTetheringSupported() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the NetworkRequest that should be fulfilled by the default network.
|
||||||
|
*/
|
||||||
public NetworkRequest getDefaultNetworkRequest() {
|
public NetworkRequest getDefaultNetworkRequest() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a reference to the EntitlementManager to be used by tethering.
|
||||||
|
*/
|
||||||
public EntitlementManager getEntitlementManager(Context ctx, SharedLog log,
|
public EntitlementManager getEntitlementManager(Context ctx, SharedLog log,
|
||||||
MockableSystemProperties systemProperties) {
|
MockableSystemProperties systemProperties) {
|
||||||
return new EntitlementManager(ctx, log, systemProperties);
|
return new EntitlementManager(ctx, log, systemProperties);
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ public class DhcpLease {
|
|||||||
mHostname = hostname;
|
mHostname = hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the clientId associated with this lease, if any.
|
||||||
|
*
|
||||||
|
* <p>If the lease is not associated to a clientId, this returns null.
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public byte[] getClientId() {
|
public byte[] getClientId() {
|
||||||
if (mClientId == null) {
|
if (mClientId == null) {
|
||||||
@@ -97,6 +102,11 @@ public class DhcpLease {
|
|||||||
(hostname == null ? mHostname : hostname));
|
(hostname == null ? mHostname : hostname));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether this lease matches a client with the specified parameters.
|
||||||
|
* @param clientId clientId of the client if any, or null otherwise.
|
||||||
|
* @param hwAddr Hardware address of the client.
|
||||||
|
*/
|
||||||
public boolean matchesClient(@Nullable byte[] clientId, @NonNull MacAddress hwAddr) {
|
public boolean matchesClient(@Nullable byte[] clientId, @NonNull MacAddress hwAddr) {
|
||||||
if (mClientId != null) {
|
if (mClientId != null) {
|
||||||
return Arrays.equals(mClientId, clientId);
|
return Arrays.equals(mClientId, clientId);
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ import android.annotation.NonNull;
|
|||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.net.IpPrefix;
|
import android.net.IpPrefix;
|
||||||
import android.net.MacAddress;
|
import android.net.MacAddress;
|
||||||
import android.net.util.SharedLog;
|
|
||||||
import android.net.dhcp.DhcpServer.Clock;
|
import android.net.dhcp.DhcpServer.Clock;
|
||||||
|
import android.net.util.SharedLog;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
|
|
||||||
import java.net.Inet4Address;
|
import java.net.Inet4Address;
|
||||||
@@ -117,7 +117,7 @@ class DhcpLeaseRepository {
|
|||||||
*/
|
*/
|
||||||
private final LinkedHashMap<Inet4Address, Long> mDeclinedAddrs = new LinkedHashMap<>();
|
private final LinkedHashMap<Inet4Address, Long> mDeclinedAddrs = new LinkedHashMap<>();
|
||||||
|
|
||||||
public DhcpLeaseRepository(@NonNull IpPrefix prefix, @NonNull Set<Inet4Address> reservedAddrs,
|
DhcpLeaseRepository(@NonNull IpPrefix prefix, @NonNull Set<Inet4Address> reservedAddrs,
|
||||||
long leaseTimeMs, @NonNull SharedLog log, @NonNull Clock clock) {
|
long leaseTimeMs, @NonNull SharedLog log, @NonNull Clock clock) {
|
||||||
updateParams(prefix, reservedAddrs, leaseTimeMs);
|
updateParams(prefix, reservedAddrs, leaseTimeMs);
|
||||||
mLog = log;
|
mLog = log;
|
||||||
@@ -250,8 +250,8 @@ class DhcpLeaseRepository {
|
|||||||
// reqAddr null (RENEWING/REBINDING): client renewing its own lease for clientAddr.
|
// reqAddr null (RENEWING/REBINDING): client renewing its own lease for clientAddr.
|
||||||
// reqAddr set with sid not set (INIT-REBOOT): client verifying configuration.
|
// reqAddr set with sid not set (INIT-REBOOT): client verifying configuration.
|
||||||
// In both cases, throw if clientAddr or reqAddr does not match the known lease.
|
// In both cases, throw if clientAddr or reqAddr does not match the known lease.
|
||||||
throw new InvalidAddressException("Incorrect address for client in " +
|
throw new InvalidAddressException("Incorrect address for client in "
|
||||||
(reqAddr != null ? "INIT-REBOOT" : "RENEWING/REBINDING"));
|
+ (reqAddr != null ? "INIT-REBOOT" : "RENEWING/REBINDING"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,32 +32,32 @@ import java.net.InetSocketAddress;
|
|||||||
*/
|
*/
|
||||||
abstract class DhcpPacketListener extends FdEventsReader<DhcpPacketListener.Payload> {
|
abstract class DhcpPacketListener extends FdEventsReader<DhcpPacketListener.Payload> {
|
||||||
static final class Payload {
|
static final class Payload {
|
||||||
final byte[] bytes = new byte[DhcpPacket.MAX_LENGTH];
|
protected final byte[] mBytes = new byte[DhcpPacket.MAX_LENGTH];
|
||||||
Inet4Address srcAddr;
|
protected Inet4Address mSrcAddr;
|
||||||
int srcPort;
|
protected int mSrcPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DhcpPacketListener(@NonNull Handler handler) {
|
DhcpPacketListener(@NonNull Handler handler) {
|
||||||
super(handler, new Payload());
|
super(handler, new Payload());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int recvBufSize(@NonNull Payload buffer) {
|
protected int recvBufSize(@NonNull Payload buffer) {
|
||||||
return buffer.bytes.length;
|
return buffer.mBytes.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final void handlePacket(@NonNull Payload recvbuf, int length) {
|
protected final void handlePacket(@NonNull Payload recvbuf, int length) {
|
||||||
if (recvbuf.srcAddr == null) {
|
if (recvbuf.mSrcAddr == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final DhcpPacket packet = DhcpPacket.decodeFullPacket(recvbuf.bytes, length,
|
final DhcpPacket packet = DhcpPacket.decodeFullPacket(recvbuf.mBytes, length,
|
||||||
DhcpPacket.ENCAP_BOOTP);
|
DhcpPacket.ENCAP_BOOTP);
|
||||||
onReceive(packet, recvbuf.srcAddr, recvbuf.srcPort);
|
onReceive(packet, recvbuf.mSrcAddr, recvbuf.mSrcPort);
|
||||||
} catch (DhcpPacket.ParseException e) {
|
} catch (DhcpPacket.ParseException e) {
|
||||||
logParseError(recvbuf.bytes, length, e);
|
logParseError(recvbuf.mBytes, length, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,11 +66,11 @@ abstract class DhcpPacketListener extends FdEventsReader<DhcpPacketListener.Payl
|
|||||||
throws Exception {
|
throws Exception {
|
||||||
final InetSocketAddress addr = new InetSocketAddress();
|
final InetSocketAddress addr = new InetSocketAddress();
|
||||||
final int read = Os.recvfrom(
|
final int read = Os.recvfrom(
|
||||||
fd, packetBuffer.bytes, 0, packetBuffer.bytes.length, 0 /* flags */, addr);
|
fd, packetBuffer.mBytes, 0, packetBuffer.mBytes.length, 0 /* flags */, addr);
|
||||||
|
|
||||||
// Buffers with null srcAddr will be dropped in handlePacket()
|
// Buffers with null srcAddr will be dropped in handlePacket()
|
||||||
packetBuffer.srcAddr = inet4AddrOrNull(addr);
|
packetBuffer.mSrcAddr = inet4AddrOrNull(addr);
|
||||||
packetBuffer.srcPort = addr.getPort();
|
packetBuffer.mSrcPort = addr.getPort();
|
||||||
return read;
|
return read;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,13 @@ public class DhcpServer {
|
|||||||
@NonNull
|
@NonNull
|
||||||
private DhcpServingParams mServingParams;
|
private DhcpServingParams mServingParams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clock to be used by DhcpServer to track time for lease expiration.
|
||||||
|
*
|
||||||
|
* <p>The clock should track time as may be measured by clients obtaining a lease. It does not
|
||||||
|
* need to be monotonous across restarts of the server as long as leases are cleared when the
|
||||||
|
* server is stopped.
|
||||||
|
*/
|
||||||
public static class Clock {
|
public static class Clock {
|
||||||
/**
|
/**
|
||||||
* @see SystemClock#elapsedRealtime()
|
* @see SystemClock#elapsedRealtime()
|
||||||
@@ -110,13 +117,43 @@ public class DhcpServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dependencies for the DhcpServer. Useful to be mocked in tests.
|
||||||
|
*/
|
||||||
public interface Dependencies {
|
public interface Dependencies {
|
||||||
|
/**
|
||||||
|
* Send a packet to the specified datagram socket.
|
||||||
|
*
|
||||||
|
* @param fd File descriptor of the socket.
|
||||||
|
* @param buffer Data to be sent.
|
||||||
|
* @param dst Destination address of the packet.
|
||||||
|
*/
|
||||||
void sendPacket(@NonNull FileDescriptor fd, @NonNull ByteBuffer buffer,
|
void sendPacket(@NonNull FileDescriptor fd, @NonNull ByteBuffer buffer,
|
||||||
@NonNull InetAddress dst) throws ErrnoException, IOException;
|
@NonNull InetAddress dst) throws ErrnoException, IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DhcpLeaseRepository for the server.
|
||||||
|
* @param servingParams Parameters used to serve DHCP requests.
|
||||||
|
* @param log Log to be used by the repository.
|
||||||
|
* @param clock Clock that the repository must use to track time.
|
||||||
|
*/
|
||||||
DhcpLeaseRepository makeLeaseRepository(@NonNull DhcpServingParams servingParams,
|
DhcpLeaseRepository makeLeaseRepository(@NonNull DhcpServingParams servingParams,
|
||||||
@NonNull SharedLog log, @NonNull Clock clock);
|
@NonNull SharedLog log, @NonNull Clock clock);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a packet listener that will send packets to be processed.
|
||||||
|
*/
|
||||||
DhcpPacketListener makePacketListener();
|
DhcpPacketListener makePacketListener();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a clock that the server will use to track time.
|
||||||
|
*/
|
||||||
Clock makeClock();
|
Clock makeClock();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an entry to the ARP cache table.
|
||||||
|
* @param fd Datagram socket file descriptor that must use the new entry.
|
||||||
|
*/
|
||||||
void addArpEntry(@NonNull Inet4Address ipv4Addr, @NonNull MacAddress ethAddr,
|
void addArpEntry(@NonNull Inet4Address ipv4Addr, @NonNull MacAddress ethAddr,
|
||||||
@NonNull String ifname, @NonNull FileDescriptor fd) throws IOException;
|
@NonNull String ifname, @NonNull FileDescriptor fd) throws IOException;
|
||||||
}
|
}
|
||||||
@@ -212,7 +249,7 @@ public class DhcpServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class ServerHandler extends Handler {
|
private class ServerHandler extends Handler {
|
||||||
public ServerHandler(@NonNull Looper looper) {
|
ServerHandler(@NonNull Looper looper) {
|
||||||
super(looper);
|
super(looper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -496,22 +533,24 @@ public class DhcpServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class PacketListener extends DhcpPacketListener {
|
private class PacketListener extends DhcpPacketListener {
|
||||||
public PacketListener() {
|
PacketListener() {
|
||||||
super(mHandler);
|
super(mHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onReceive(DhcpPacket packet, Inet4Address srcAddr, int srcPort) {
|
protected void onReceive(@NonNull DhcpPacket packet, @NonNull Inet4Address srcAddr,
|
||||||
|
int srcPort) {
|
||||||
processPacket(packet, srcPort);
|
processPacket(packet, srcPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void logError(String msg, Exception e) {
|
protected void logError(@NonNull String msg, Exception e) {
|
||||||
mLog.e("Error receiving packet: " + msg, e);
|
mLog.e("Error receiving packet: " + msg, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void logParseError(byte[] packet, int length, DhcpPacket.ParseException e) {
|
protected void logParseError(@NonNull byte[] packet, int length,
|
||||||
|
@NonNull DhcpPacket.ParseException e) {
|
||||||
mLog.e("Error parsing packet", e);
|
mLog.e("Error parsing packet", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ import java.util.StringJoiner;
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public class SharedLog {
|
public class SharedLog {
|
||||||
private final static int DEFAULT_MAX_RECORDS = 500;
|
private static final int DEFAULT_MAX_RECORDS = 500;
|
||||||
private final static String COMPONENT_DELIMITER = ".";
|
private static final String COMPONENT_DELIMITER = ".";
|
||||||
|
|
||||||
private enum Category {
|
private enum Category {
|
||||||
NONE,
|
NONE,
|
||||||
@@ -69,6 +69,9 @@ public class SharedLog {
|
|||||||
mComponent = component;
|
mComponent = component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a SharedLog based on this log with an additional component prefix on each logged line.
|
||||||
|
*/
|
||||||
public SharedLog forSubComponent(String component) {
|
public SharedLog forSubComponent(String component) {
|
||||||
if (!isRootLogInstance()) {
|
if (!isRootLogInstance()) {
|
||||||
component = mComponent + COMPONENT_DELIMITER + component;
|
component = mComponent + COMPONENT_DELIMITER + component;
|
||||||
@@ -76,6 +79,11 @@ public class SharedLog {
|
|||||||
return new SharedLog(mLocalLog, mTag, component);
|
return new SharedLog(mLocalLog, mTag, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dump the contents of this log.
|
||||||
|
*
|
||||||
|
* <p>This method may be called on any thread.
|
||||||
|
*/
|
||||||
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
|
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
|
||||||
mLocalLog.readOnlyLocalLog().dump(fd, writer, args);
|
mLocalLog.readOnlyLocalLog().dump(fd, writer, args);
|
||||||
}
|
}
|
||||||
@@ -84,10 +92,21 @@ public class SharedLog {
|
|||||||
// Methods that both log an entry and emit it to the system log.
|
// Methods that both log an entry and emit it to the system log.
|
||||||
//////
|
//////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log an error due to an exception. This does not include the exception stacktrace.
|
||||||
|
*
|
||||||
|
* <p>The log entry will be also added to the system log.
|
||||||
|
* @see #e(String, Throwable)
|
||||||
|
*/
|
||||||
public void e(Exception e) {
|
public void e(Exception e) {
|
||||||
Log.e(mTag, record(Category.ERROR, e.toString()));
|
Log.e(mTag, record(Category.ERROR, e.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log an error message.
|
||||||
|
*
|
||||||
|
* <p>The log entry will be also added to the system log.
|
||||||
|
*/
|
||||||
public void e(String msg) {
|
public void e(String msg) {
|
||||||
Log.e(mTag, record(Category.ERROR, msg));
|
Log.e(mTag, record(Category.ERROR, msg));
|
||||||
}
|
}
|
||||||
@@ -96,7 +115,7 @@ public class SharedLog {
|
|||||||
* Log an error due to an exception, with the exception stacktrace if provided.
|
* Log an error due to an exception, with the exception stacktrace if provided.
|
||||||
*
|
*
|
||||||
* <p>The error and exception message appear in the shared log, but the stacktrace is only
|
* <p>The error and exception message appear in the shared log, but the stacktrace is only
|
||||||
* logged in general log output (logcat).
|
* logged in general log output (logcat). The log entry will be also added to the system log.
|
||||||
*/
|
*/
|
||||||
public void e(@NonNull String msg, @Nullable Throwable exception) {
|
public void e(@NonNull String msg, @Nullable Throwable exception) {
|
||||||
if (exception == null) {
|
if (exception == null) {
|
||||||
@@ -106,10 +125,20 @@ public class SharedLog {
|
|||||||
Log.e(mTag, record(Category.ERROR, msg + ": " + exception.getMessage()), exception);
|
Log.e(mTag, record(Category.ERROR, msg + ": " + exception.getMessage()), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log an informational message.
|
||||||
|
*
|
||||||
|
* <p>The log entry will be also added to the system log.
|
||||||
|
*/
|
||||||
public void i(String msg) {
|
public void i(String msg) {
|
||||||
Log.i(mTag, record(Category.NONE, msg));
|
Log.i(mTag, record(Category.NONE, msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a warning message.
|
||||||
|
*
|
||||||
|
* <p>The log entry will be also added to the system log.
|
||||||
|
*/
|
||||||
public void w(String msg) {
|
public void w(String msg) {
|
||||||
Log.w(mTag, record(Category.WARN, msg));
|
Log.w(mTag, record(Category.WARN, msg));
|
||||||
}
|
}
|
||||||
@@ -118,14 +147,30 @@ public class SharedLog {
|
|||||||
// Methods that only log an entry (and do NOT emit to the system log).
|
// Methods that only log an entry (and do NOT emit to the system log).
|
||||||
//////
|
//////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a general message to be only included in the in-memory log.
|
||||||
|
*
|
||||||
|
* <p>The log entry will *not* be added to the system log.
|
||||||
|
*/
|
||||||
public void log(String msg) {
|
public void log(String msg) {
|
||||||
record(Category.NONE, msg);
|
record(Category.NONE, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a general, formatted message to be only included in the in-memory log.
|
||||||
|
*
|
||||||
|
* <p>The log entry will *not* be added to the system log.
|
||||||
|
* @see String#format(String, Object...)
|
||||||
|
*/
|
||||||
public void logf(String fmt, Object... args) {
|
public void logf(String fmt, Object... args) {
|
||||||
log(String.format(fmt, args));
|
log(String.format(fmt, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with MARK level.
|
||||||
|
*
|
||||||
|
* <p>The log entry will *not* be added to the system log.
|
||||||
|
*/
|
||||||
public void mark(String msg) {
|
public void mark(String msg) {
|
||||||
record(Category.MARK, msg);
|
record(Category.MARK, msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ import android.annotation.NonNull;
|
|||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.net.IpPrefix;
|
import android.net.IpPrefix;
|
||||||
import android.net.MacAddress;
|
import android.net.MacAddress;
|
||||||
import android.net.util.SharedLog;
|
|
||||||
import android.net.dhcp.DhcpServer.Clock;
|
import android.net.dhcp.DhcpServer.Clock;
|
||||||
|
import android.net.util.SharedLog;
|
||||||
import android.support.test.filters.SmallTest;
|
import android.support.test.filters.SmallTest;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,16 @@
|
|||||||
|
|
||||||
package android.net.ip;
|
package android.net.ip;
|
||||||
|
|
||||||
|
import static android.net.ConnectivityManager.TETHERING_BLUETOOTH;
|
||||||
|
import static android.net.ConnectivityManager.TETHERING_USB;
|
||||||
|
import static android.net.ConnectivityManager.TETHERING_WIFI;
|
||||||
|
import static android.net.ConnectivityManager.TETHER_ERROR_ENABLE_NAT_ERROR;
|
||||||
|
import static android.net.ConnectivityManager.TETHER_ERROR_NO_ERROR;
|
||||||
|
import static android.net.ConnectivityManager.TETHER_ERROR_TETHER_IFACE_ERROR;
|
||||||
|
import static android.net.ip.IpServer.STATE_AVAILABLE;
|
||||||
|
import static android.net.ip.IpServer.STATE_TETHERED;
|
||||||
|
import static android.net.ip.IpServer.STATE_UNAVAILABLE;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@@ -31,16 +41,6 @@ import static org.mockito.Mockito.verify;
|
|||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import static android.net.ConnectivityManager.TETHER_ERROR_ENABLE_NAT_ERROR;
|
|
||||||
import static android.net.ConnectivityManager.TETHER_ERROR_NO_ERROR;
|
|
||||||
import static android.net.ConnectivityManager.TETHER_ERROR_TETHER_IFACE_ERROR;
|
|
||||||
import static android.net.ConnectivityManager.TETHERING_BLUETOOTH;
|
|
||||||
import static android.net.ConnectivityManager.TETHERING_USB;
|
|
||||||
import static android.net.ConnectivityManager.TETHERING_WIFI;
|
|
||||||
import static android.net.ip.IpServer.STATE_AVAILABLE;
|
|
||||||
import static android.net.ip.IpServer.STATE_TETHERED;
|
|
||||||
import static android.net.ip.IpServer.STATE_UNAVAILABLE;
|
|
||||||
|
|
||||||
import android.net.INetworkStatsService;
|
import android.net.INetworkStatsService;
|
||||||
import android.net.InterfaceConfiguration;
|
import android.net.InterfaceConfiguration;
|
||||||
import android.net.IpPrefix;
|
import android.net.IpPrefix;
|
||||||
@@ -60,8 +60,6 @@ import android.support.test.filters.SmallTest;
|
|||||||
import android.support.test.runner.AndroidJUnit4;
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import java.net.Inet4Address;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -71,6 +69,8 @@ import org.mockito.InOrder;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
import java.net.Inet4Address;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class IpServerTest {
|
public class IpServerTest {
|
||||||
|
|||||||
Reference in New Issue
Block a user