Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 70cd0a8e authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes from topics "vm_binder_server", "vm_binder_server_api" am:...

Merge changes from topics "vm_binder_server", "vm_binder_server_api" am: f1c5a0c1 am: 5ad97c18 am: 6ff3555b

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1820212

Change-Id: I4a3dbdd8a747176e08f5bb771972f12a9fc1dba4
parents 287c8e85 6ff3555b
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -20,7 +20,16 @@ extern "C" {


struct AIBinder;
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);
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);
AIBinder* RpcClient(unsigned int cid, unsigned int port);


// Connect to an RPC server with preconnected file descriptors.
// Connect to an RPC server with preconnected file descriptors.
+8 −1
Original line number Original line Diff line number Diff line
@@ -29,7 +29,8 @@ using android::base::unique_fd;


extern "C" {
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();
    auto server = RpcServer::make();
    server->iUnderstandThisCodeIsExperimentalAndIWillNotUseItInProduction();
    server->iUnderstandThisCodeIsExperimentalAndIWillNotUseItInProduction();
    if (status_t status = server->setupVsockServer(port); status != OK) {
    if (status_t status = server->setupVsockServer(port); status != OK) {
@@ -38,6 +39,8 @@ bool RunRpcServer(AIBinder* service, unsigned int port) {
        return false;
        return false;
    }
    }
    server->setRootObject(AIBinder_toPlatformBinder(service));
    server->setRootObject(AIBinder_toPlatformBinder(service));

    if (readyCallback) readyCallback(param);
    server->join();
    server->join();


    // Shutdown any open sessions since server failed.
    // Shutdown any open sessions since server failed.
@@ -45,6 +48,10 @@ bool RunRpcServer(AIBinder* service, unsigned int port) {
    return true;
    return true;
}
}


bool RunRpcServer(AIBinder* service, unsigned int port) {
    return RunRpcServerCallback(service, port, nullptr, nullptr);
}

AIBinder* RpcClient(unsigned int cid, unsigned int port) {
AIBinder* RpcClient(unsigned int cid, unsigned int port) {
    auto session = RpcSession::make();
    auto session = RpcSession::make();
    if (status_t status = session->setupVsockClient(cid, port); status != OK) {
    if (status_t status = session->setupVsockClient(cid, port); status != OK) {
+1 −0
Original line number Original line Diff line number Diff line
LIBBINDER_RPC_UNSTABLE_SHIM { # platform-only
LIBBINDER_RPC_UNSTABLE_SHIM { # platform-only
  global:
  global:
    RunRpcServer;
    RunRpcServer;
    RunRpcServerCallback;
    RpcClient;
    RpcClient;
    RpcPreconnectedClient;
    RpcPreconnectedClient;
  local:
  local: