OSDN Git Service

Set isConnected, isBound, implCreated on server-side LocalSockets
authorNeil Fuller <nfuller@google.com>
Wed, 4 Jan 2017 10:07:25 +0000 (10:07 +0000)
committerNeil Fuller <nfuller@google.com>
Wed, 4 Jan 2017 10:33:18 +0000 (10:33 +0000)
commitb08c7bc0bdc48ae95be2697ca27ea89a9dd92c3e
tree150b279b43f2d8e4c3731face92e5cfd48874ddb
parent80ff5ecd4a4076e992c4fca93648b48f16f6cd03
Set isConnected, isBound, implCreated on server-side LocalSockets

Previously LocalServerSocket.accept() would return a LocalSocket
instance with isConnected, isBound and implCreated set to false.
[implCreated determines whether impl.create() needs to called].

A socket created via accept() in this way is implicitly bound
and connected. impl.create() does not need to be called because
impl.accept(LocalSocketImpl s) is called instead and has the same
effect (s.fd and s.mFdCreatedInternally set correctly).

This change modifies the behavior so that the flags are now all
set to true in this case and isBound() and isConnected() will
now return the correct answer.

Attempts to call bind() and connect() will still throw
IOException as before, but with a different exception message.

Correctly setting implCreated in LocalSocket means that
LocalSocketImpl.create() will no longer be called for accept()
created sockets and no longer needs to treat the "fd != null"
case as a no-op: we can now assert that there must be no fd set
when create() is called as we will no longer call it with sockets
created using accept().

Bug: https://code.google.com/p/android/issues/detail?id=35942
Test: Device boot
Test: vogar --mode app_process cts/tests/tests/net/src/android/net/cts/LocalServerSocketTest.java
Test: vogar --mode app_process cts/tests/tests/net/src/android/net/cts/LocalSocketTest.java
Change-Id: I3ac55439412e84501ae7c5ae6c9976e03b2d6fc5
core/java/android/net/LocalServerSocket.java
core/java/android/net/LocalSocket.java
core/java/android/net/LocalSocketImpl.java