Loading libs/binder/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -525,7 +525,6 @@ cc_library { "libbase", "libbinder", "libbinder_ndk", "libcutils_sockets", "liblog", "libutils", ], Loading libs/binder/include_rpc_unstable/binder_rpc_unstable.hpp +4 −3 Original line number Diff line number Diff line Loading @@ -40,12 +40,13 @@ enum class ARpcSession_FileDescriptorTransportMode { [[nodiscard]] ARpcServer* ARpcServer_newVsock(AIBinder* service, unsigned int cid, unsigned int port); // Starts a Unix domain RPC server with a given init-managed Unix domain `name` // Starts a Unix domain RPC server with an open raw socket file descriptor // and a given root IBinder object. // The socket should be created in init.rc with the same `name`. // The socket should be created and bound to an address. // Returns an opaque handle to the running server instance, or null if the server // could not be started. [[nodiscard]] ARpcServer* ARpcServer_newInitUnixDomain(AIBinder* service, const char* name); // The socket will be closed by the server once the server goes out of scope. [[nodiscard]] ARpcServer* ARpcServer_newBoundSocket(AIBinder* service, int socketFd); // Starts an RPC server that bootstraps sessions using an existing Unix domain // socket pair, with a given root IBinder object. Loading libs/binder/libbinder_rpc_unstable.cpp +4 −11 Original line number Diff line number Diff line Loading @@ -105,22 +105,15 @@ ARpcServer* ARpcServer_newVsock(AIBinder* service, unsigned int cid, unsigned in return createObjectHandle<ARpcServer>(server); } ARpcServer* ARpcServer_newInitUnixDomain(AIBinder* service, const char* name) { ARpcServer* ARpcServer_newBoundSocket(AIBinder* service, int socketFd) { auto server = RpcServer::make(); auto fd = unique_fd(android_get_control_socket(name)); auto fd = unique_fd(socketFd); if (!fd.ok()) { LOG(ERROR) << "Failed to get fd for the socket:" << name; LOG(ERROR) << "Invalid socket fd " << socketFd; return nullptr; } // Control socket fds are inherited from init, so they don't have O_CLOEXEC set. // But we don't want any child processes to inherit the socket we are running // the server on, so attempt to set the flag now. if (fcntl(fd, F_SETFD, FD_CLOEXEC) != 0) { LOG(WARNING) << "Failed to set CLOEXEC on control socket with name " << name << " error: " << errno; } if (status_t status = server->setupRawSocketServer(std::move(fd)); status != OK) { LOG(ERROR) << "Failed to set up Unix Domain RPC server with name " << name LOG(ERROR) << "Failed to set up RPC server with fd " << socketFd << " error: " << statusToString(status).c_str(); return nullptr; } Loading libs/binder/libbinder_rpc_unstable.map.txt +1 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ LIBBINDER_RPC_UNSTABLE_SHIM { # platform-only ARpcServer_free; ARpcServer_join; ARpcServer_newInet; ARpcServer_newInitUnixDomain; ARpcServer_newBoundSocket; ARpcServer_newVsock; ARpcServer_shutdown; ARpcServer_start; Loading libs/binder/rust/rpcbinder/src/server.rs +6 −15 Original line number Diff line number Diff line Loading @@ -57,26 +57,17 @@ impl RpcServer { } /// Creates a binder RPC server, serving the supplied binder service implementation on the given /// socket file name. The socket should be initialized in init.rc with the same name. pub fn new_init_unix_domain( mut service: SpIBinder, socket_name: &str, ) -> Result<RpcServer, Error> { let socket_name = match CString::new(socket_name) { Ok(s) => s, Err(e) => { log::error!("Cannot convert {} to CString. Error: {:?}", socket_name, e); return Err(Error::from(ErrorKind::InvalidInput)); } }; /// socket file descriptor. The socket should be bound to an address before calling this /// function. pub fn new_bound_socket(mut service: SpIBinder, socket_fd: OwnedFd) -> Result<RpcServer, Error> { let service = service.as_native_mut(); // SAFETY: Service ownership is transferring to the server and won't be valid afterward. // Plus the binder objects are threadsafe. // The server takes ownership of the socket FD. unsafe { Self::checked_from_ptr(binder_rpc_unstable_bindgen::ARpcServer_newInitUnixDomain( service, socket_name.as_ptr(), Self::checked_from_ptr(binder_rpc_unstable_bindgen::ARpcServer_newBoundSocket( service, socket_fd.into_raw_fd(), )) } } Loading Loading
libs/binder/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -525,7 +525,6 @@ cc_library { "libbase", "libbinder", "libbinder_ndk", "libcutils_sockets", "liblog", "libutils", ], Loading
libs/binder/include_rpc_unstable/binder_rpc_unstable.hpp +4 −3 Original line number Diff line number Diff line Loading @@ -40,12 +40,13 @@ enum class ARpcSession_FileDescriptorTransportMode { [[nodiscard]] ARpcServer* ARpcServer_newVsock(AIBinder* service, unsigned int cid, unsigned int port); // Starts a Unix domain RPC server with a given init-managed Unix domain `name` // Starts a Unix domain RPC server with an open raw socket file descriptor // and a given root IBinder object. // The socket should be created in init.rc with the same `name`. // The socket should be created and bound to an address. // Returns an opaque handle to the running server instance, or null if the server // could not be started. [[nodiscard]] ARpcServer* ARpcServer_newInitUnixDomain(AIBinder* service, const char* name); // The socket will be closed by the server once the server goes out of scope. [[nodiscard]] ARpcServer* ARpcServer_newBoundSocket(AIBinder* service, int socketFd); // Starts an RPC server that bootstraps sessions using an existing Unix domain // socket pair, with a given root IBinder object. Loading
libs/binder/libbinder_rpc_unstable.cpp +4 −11 Original line number Diff line number Diff line Loading @@ -105,22 +105,15 @@ ARpcServer* ARpcServer_newVsock(AIBinder* service, unsigned int cid, unsigned in return createObjectHandle<ARpcServer>(server); } ARpcServer* ARpcServer_newInitUnixDomain(AIBinder* service, const char* name) { ARpcServer* ARpcServer_newBoundSocket(AIBinder* service, int socketFd) { auto server = RpcServer::make(); auto fd = unique_fd(android_get_control_socket(name)); auto fd = unique_fd(socketFd); if (!fd.ok()) { LOG(ERROR) << "Failed to get fd for the socket:" << name; LOG(ERROR) << "Invalid socket fd " << socketFd; return nullptr; } // Control socket fds are inherited from init, so they don't have O_CLOEXEC set. // But we don't want any child processes to inherit the socket we are running // the server on, so attempt to set the flag now. if (fcntl(fd, F_SETFD, FD_CLOEXEC) != 0) { LOG(WARNING) << "Failed to set CLOEXEC on control socket with name " << name << " error: " << errno; } if (status_t status = server->setupRawSocketServer(std::move(fd)); status != OK) { LOG(ERROR) << "Failed to set up Unix Domain RPC server with name " << name LOG(ERROR) << "Failed to set up RPC server with fd " << socketFd << " error: " << statusToString(status).c_str(); return nullptr; } Loading
libs/binder/libbinder_rpc_unstable.map.txt +1 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ LIBBINDER_RPC_UNSTABLE_SHIM { # platform-only ARpcServer_free; ARpcServer_join; ARpcServer_newInet; ARpcServer_newInitUnixDomain; ARpcServer_newBoundSocket; ARpcServer_newVsock; ARpcServer_shutdown; ARpcServer_start; Loading
libs/binder/rust/rpcbinder/src/server.rs +6 −15 Original line number Diff line number Diff line Loading @@ -57,26 +57,17 @@ impl RpcServer { } /// Creates a binder RPC server, serving the supplied binder service implementation on the given /// socket file name. The socket should be initialized in init.rc with the same name. pub fn new_init_unix_domain( mut service: SpIBinder, socket_name: &str, ) -> Result<RpcServer, Error> { let socket_name = match CString::new(socket_name) { Ok(s) => s, Err(e) => { log::error!("Cannot convert {} to CString. Error: {:?}", socket_name, e); return Err(Error::from(ErrorKind::InvalidInput)); } }; /// socket file descriptor. The socket should be bound to an address before calling this /// function. pub fn new_bound_socket(mut service: SpIBinder, socket_fd: OwnedFd) -> Result<RpcServer, Error> { let service = service.as_native_mut(); // SAFETY: Service ownership is transferring to the server and won't be valid afterward. // Plus the binder objects are threadsafe. // The server takes ownership of the socket FD. unsafe { Self::checked_from_ptr(binder_rpc_unstable_bindgen::ARpcServer_newInitUnixDomain( service, socket_name.as_ptr(), Self::checked_from_ptr(binder_rpc_unstable_bindgen::ARpcServer_newBoundSocket( service, socket_fd.into_raw_fd(), )) } } Loading