Merge "Set isConnected, isBound, implCreated on server-side LocalSockets" am: 75ba827a4e

am: 6a29676687

Change-Id: Icb55f2b160f6bd2f6c12845613ea3b4ea834693d
This commit is contained in:
Neil Fuller
2017-01-04 12:38:50 +00:00
committed by android-build-merger
3 changed files with 37 additions and 30 deletions

View File

@@ -89,7 +89,7 @@ public class LocalServerSocket {
impl.accept(acceptedImpl); impl.accept(acceptedImpl);
return new LocalSocket(acceptedImpl, LocalSocket.SOCKET_UNKNOWN); return LocalSocket.createLocalSocketForAccept(acceptedImpl, LocalSocket.SOCKET_UNKNOWN);
} }
/** /**

View File

@@ -75,17 +75,24 @@ public class LocalSocket implements Closeable {
isConnected = true; isConnected = true;
} }
/** private LocalSocket(LocalSocketImpl impl, int sockType) {
* for use with AndroidServerSocket
* @param impl a SocketImpl
*/
/*package*/ LocalSocket(LocalSocketImpl impl, int sockType) {
this.impl = impl; this.impl = impl;
this.sockType = sockType; this.sockType = sockType;
this.isConnected = false; this.isConnected = false;
this.isBound = false; this.isBound = false;
} }
/**
* for use with LocalServerSocket.accept()
*/
static LocalSocket createLocalSocketForAccept(LocalSocketImpl impl, int sockType) {
LocalSocket socket = new LocalSocket(impl, sockType);
socket.isConnected = true;
socket.isBound = true;
socket.implCreated = true;
return socket;
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String toString() { public String toString() {

View File

@@ -235,9 +235,10 @@ class LocalSocketImpl
* @throws IOException * @throws IOException
*/ */
public void create(int sockType) throws IOException { public void create(int sockType) throws IOException {
// no error if socket already created if (fd != null) {
// need this for LocalServerSocket.accept() throw new IOException("LocalSocketImpl already has an fd");
if (fd == null) { }
int osType; int osType;
switch (sockType) { switch (sockType) {
case LocalSocket.SOCKET_DGRAM: case LocalSocket.SOCKET_DGRAM:
@@ -259,7 +260,6 @@ class LocalSocketImpl
e.rethrowAsIOException(); e.rethrowAsIOException();
} }
} }
}
/** /**
* Closes the socket. * Closes the socket.