summaryrefslogtreecommitdiff
path: root/core/java/android/net/LocalServerSocket.java
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2022-01-19 18:08:40 +0900
committerLorenzo Colitti <lorenzo@google.com>2022-01-25 00:56:44 +0900
commit8093d78d1ca851b52cea53d7e4d08f5f298cc9f7 (patch)
tree396e117ecbf863249ffc7ff78ec132c5ca13206f /core/java/android/net/LocalServerSocket.java
parent64085cd5dbb350662731a04f40215d0cfdc9f9b5 (diff)
Add a module-lib API for constructing a LocalSocket from an fd.
This allows constructing a LocalSocket from a FileDescriptor referring to an already-connected socket. The LocalSocket can then be used to exchange ancillary filedescriptors and fetch peer socket credentials for the existing FD. The fd is not dup'd or closed by the API, and the caller is responsible for closing it. This is consistent with the constructor of the related LocalServerSocket class, which also takes an fd and does not manage its lifecycle. Bug: 200200870 Test: atest CoreTests:android.net.LocalSocketTest CtsNetTestCases:android.net.cts.LocalSocketTest Change-Id: I86448ba80475c4563194a4a2d9a0c0bbd0b76444
Diffstat (limited to 'core/java/android/net/LocalServerSocket.java')
-rw-r--r--core/java/android/net/LocalServerSocket.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/java/android/net/LocalServerSocket.java b/core/java/android/net/LocalServerSocket.java
index d1f49d2082f5..506cbcb0623d 100644
--- a/core/java/android/net/LocalServerSocket.java
+++ b/core/java/android/net/LocalServerSocket.java
@@ -55,7 +55,9 @@ public class LocalServerSocket implements Closeable {
* Create a LocalServerSocket from a file descriptor that's already
* been created and bound. listen() will be called immediately on it.
* Used for cases where file descriptors are passed in via environment
- * variables
+ * variables. The passed-in FileDescriptor is not managed by this class
+ * and must be closed by the caller. Calling {@link #close()} on a socket
+ * created by this method has no effect.
*
* @param fd bound file descriptor
* @throws IOException