summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2021-09-09 07:13:11 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2021-09-09 07:13:11 +0000
commit5d6cbc84f37da45d53ef9b31d23acad0a13334bc (patch)
tree093af51a796361d5ee02a29b08db29808ff1a82d
parent6b8dc5f24e55955836829a48c62826d2d972d9b3 (diff)
parent70cd0a8e1edd4c0aa70a0295268d2b518cb5481a (diff)
Merge changes from topics "vm_binder_server", "vm_binder_server_api" am: f1c5a0c193 am: 5ad97c18f5 am: 6ff3555b98 am: 70cd0a8e1e
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1820212 Change-Id: I96b2a41c64a196d9bf2698fb2a24fb24c27dc3cf
-rw-r--r--libs/binder/include_rpc_unstable/binder_rpc_unstable.hpp9
-rw-r--r--libs/binder/libbinder_rpc_unstable.cpp9
-rw-r--r--libs/binder/libbinder_rpc_unstable.map.txt1
3 files changed, 18 insertions, 1 deletions
diff --git a/libs/binder/include_rpc_unstable/binder_rpc_unstable.hpp b/libs/binder/include_rpc_unstable/binder_rpc_unstable.hpp
index 0309d6ca53..08f5eedacd 100644
--- a/libs/binder/include_rpc_unstable/binder_rpc_unstable.hpp
+++ b/libs/binder/include_rpc_unstable/binder_rpc_unstable.hpp
@@ -20,7 +20,16 @@ extern "C" {
struct AIBinder;
+// Starts an RPC server on a given port and a given root IBinder object.
+// This function sets up the server and joins before returning.
bool RunRpcServer(AIBinder* service, unsigned int port);
+
+// Starts an RPC server on a given port and a given root IBinder object.
+// This function sets up the server, calls readyCallback with a given param, and
+// then joins before returning.
+bool RunRpcServerCallback(AIBinder* service, unsigned int port, void (*readyCallback)(void* param),
+ void* param);
+
AIBinder* RpcClient(unsigned int cid, unsigned int port);
// Connect to an RPC server with preconnected file descriptors.
diff --git a/libs/binder/libbinder_rpc_unstable.cpp b/libs/binder/libbinder_rpc_unstable.cpp
index 304415a7ce..cad55fb439 100644
--- a/libs/binder/libbinder_rpc_unstable.cpp
+++ b/libs/binder/libbinder_rpc_unstable.cpp
@@ -29,7 +29,8 @@ using android::base::unique_fd;
extern "C" {
-bool RunRpcServer(AIBinder* service, unsigned int port) {
+bool RunRpcServerCallback(AIBinder* service, unsigned int port, void (*readyCallback)(void* param),
+ void* param) {
auto server = RpcServer::make();
server->iUnderstandThisCodeIsExperimentalAndIWillNotUseItInProduction();
if (status_t status = server->setupVsockServer(port); status != OK) {
@@ -38,6 +39,8 @@ bool RunRpcServer(AIBinder* service, unsigned int port) {
return false;
}
server->setRootObject(AIBinder_toPlatformBinder(service));
+
+ if (readyCallback) readyCallback(param);
server->join();
// Shutdown any open sessions since server failed.
@@ -45,6 +48,10 @@ bool RunRpcServer(AIBinder* service, unsigned int port) {
return true;
}
+bool RunRpcServer(AIBinder* service, unsigned int port) {
+ return RunRpcServerCallback(service, port, nullptr, nullptr);
+}
+
AIBinder* RpcClient(unsigned int cid, unsigned int port) {
auto session = RpcSession::make();
if (status_t status = session->setupVsockClient(cid, port); status != OK) {
diff --git a/libs/binder/libbinder_rpc_unstable.map.txt b/libs/binder/libbinder_rpc_unstable.map.txt
index 1138786a64..e8565695a3 100644
--- a/libs/binder/libbinder_rpc_unstable.map.txt
+++ b/libs/binder/libbinder_rpc_unstable.map.txt
@@ -1,6 +1,7 @@
LIBBINDER_RPC_UNSTABLE_SHIM { # platform-only
global:
RunRpcServer;
+ RunRpcServerCallback;
RpcClient;
RpcPreconnectedClient;
local: