Merge "Set isConnected, isBound, implCreated on server-side LocalSockets"
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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() {
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user