Small cleanup of Network.
Test: runtest Change-Id: I56dbd37bb8f890938d360f45835de72be4beb91a
This commit is contained in:
@@ -136,7 +136,7 @@ public class Network implements Parcelable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify whether or not Private DNS should be bypassed when attempting
|
* Specify whether or not Private DNS should be bypassed when attempting
|
||||||
* to use {@link getAllByName()}/{@link getByName()} methods on the given
|
* to use {@link #getAllByName(String)}/{@link #getByName(String)} methods on the given
|
||||||
* instance for hostname resolution.
|
* instance for hostname resolution.
|
||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
@@ -163,13 +163,6 @@ public class Network implements Parcelable {
|
|||||||
* A {@code SocketFactory} that produces {@code Socket}'s bound to this network.
|
* A {@code SocketFactory} that produces {@code Socket}'s bound to this network.
|
||||||
*/
|
*/
|
||||||
private class NetworkBoundSocketFactory extends SocketFactory {
|
private class NetworkBoundSocketFactory extends SocketFactory {
|
||||||
private final int mNetId;
|
|
||||||
|
|
||||||
public NetworkBoundSocketFactory(int netId) {
|
|
||||||
super();
|
|
||||||
mNetId = netId;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Socket connectToHost(String host, int port, SocketAddress localAddress)
|
private Socket connectToHost(String host, int port, SocketAddress localAddress)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
// Lookup addresses only on this Network.
|
// Lookup addresses only on this Network.
|
||||||
@@ -195,7 +188,8 @@ public class Network implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException {
|
public Socket createSocket(String host, int port, InetAddress localHost, int localPort)
|
||||||
|
throws IOException {
|
||||||
return connectToHost(host, port, new InetSocketAddress(localHost, localPort));
|
return connectToHost(host, port, new InetSocketAddress(localHost, localPort));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,7 +253,7 @@ public class Network implements Parcelable {
|
|||||||
if (mNetworkBoundSocketFactory == null) {
|
if (mNetworkBoundSocketFactory == null) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mNetworkBoundSocketFactory == null) {
|
if (mNetworkBoundSocketFactory == null) {
|
||||||
mNetworkBoundSocketFactory = new NetworkBoundSocketFactory(netId);
|
mNetworkBoundSocketFactory = new NetworkBoundSocketFactory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -454,7 +448,7 @@ public class Network implements Parcelable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj instanceof Network == false) return false;
|
if (!(obj instanceof Network)) return false;
|
||||||
Network other = (Network)obj;
|
Network other = (Network)obj;
|
||||||
return this.netId == other.netId;
|
return this.netId == other.netId;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user