diff options
author | Keith Dart <keith.dart@gmail.com> | 2017-12-15 19:40:09 -0800 |
---|---|---|
committer | Ang Li <angli@google.com> | 2017-12-15 19:40:09 -0800 |
commit | aeddc8bcd123ddf6c865622464001fe0f3835b87 (patch) | |
tree | 2497bdc66fbe0df6b5990d0b71479b520eed6620 /third_party/sl4a/src/main/java/com/google/android/mobly/snippet/rpc/SimpleServer.java | |
parent | f48f37f7a4de86306cc7193d92b464fab491b67b (diff) | |
download | mobly-snippet-lib-aeddc8bcd123ddf6c865622464001fe0f3835b87.tar.gz |
Update gradle, dependency versions and fix lint reported issues (#80)
* Update to latest build tools.
* Fix lint issues and reformat.
* Add presubmit target.
* Fix IDE reported issues.
* Fix test runner versions in example.
* Review feedback changes.
* Make getPrivateInetAddress a private method.
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.java | 31 |
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. * |