aboutsummaryrefslogtreecommitdiff
path: root/third_party/sl4a/src/main/java/com/google/android/mobly/snippet/rpc/SimpleServer.java
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/sl4a/src/main/java/com/google/android/mobly/snippet/rpc/SimpleServer.java')
-rw-r--r--third_party/sl4a/src/main/java/com/google/android/mobly/snippet/rpc/SimpleServer.java31
1 files changed, 2 insertions, 29 deletions
diff --git a/third_party/sl4a/src/main/java/com/google/android/mobly/snippet/rpc/SimpleServer.java b/third_party/sl4a/src/main/java/com/google/android/mobly/snippet/rpc/SimpleServer.java
index 8d86723..db7255a 100644
--- a/third_party/sl4a/src/main/java/com/google/android/mobly/snippet/rpc/SimpleServer.java
+++ b/third_party/sl4a/src/main/java/com/google/android/mobly/snippet/rpc/SimpleServer.java
@@ -40,7 +40,7 @@ import org.json.JSONObject;
public abstract class SimpleServer {
private static int threadIndex = 0;
private final ConcurrentHashMap<Integer, ConnectionThread> mConnectionThreads =
- new ConcurrentHashMap<Integer, ConnectionThread>();
+ new ConcurrentHashMap<>();
private final List<SimpleServerObserver> mObservers = new ArrayList<>();
private volatile boolean mStopServer = false;
private ServerSocket mServer;
@@ -134,12 +134,7 @@ public abstract class SimpleServer {
}
}
- /** Returns the number of active connections to this server. */
- public int getNumberOfConnections() {
- return mConnectionThreads.size();
- }
-
- public static InetAddress getPrivateInetAddress() throws UnknownHostException, SocketException {
+ private InetAddress getPrivateInetAddress() throws UnknownHostException, SocketException {
InetAddress candidate = null;
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
@@ -162,28 +157,6 @@ public abstract class SimpleServer {
return InetAddress.getLocalHost(); // No damn matches. Give up, return local host.
}
- public static InetAddress getPublicInetAddress() throws UnknownHostException, SocketException {
-
- InetAddress candidate = null;
- Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
- for (NetworkInterface netint : Collections.list(nets)) {
- if (netint.isLoopback() || !netint.isUp()) { // Ignore if localhost or not active
- continue;
- }
- Enumeration<InetAddress> addresses = netint.getInetAddresses();
- for (InetAddress address : Collections.list(addresses)) {
- if (address instanceof Inet4Address) {
- return address; // Prefer ipv4
- }
- candidate = address; // Probably an ipv6
- }
- }
- if (candidate != null) {
- return candidate; // return ipv6 address if no suitable ipv6
- }
- return InetAddress.getLocalHost(); // No damn matches. Give up, return local host.
- }
-
/**
* Starts the RPC server bound to the localhost address.
*