From 531fcadc02d688314ea754e19625acea13573543 Mon Sep 17 00:00:00 2001 From: Orlando Arbildo Date: Fri, 23 Sep 2022 18:14:04 +0000 Subject: TrustyRpc: Adding a create session with initialization callback function Original RpcTrustyConnect function didn't allow callbacks on the connection. Enabling this functionality required us to do some initialization on the session itself before connecting. Added a RpcTrustyConnectWithSessionInitializer function that allows the caller to pass a callback function that can be used to initialize the session object before a connection is made. Tested that this change can be used to modify setMaxIncomingThreads to enable callbacks and one-way functions on it. Bug: None Test: None Change-Id: I9b53b54131a2c7fd24294aae5ab102b7c0f154e2 --- libs/binder/RpcTrusty.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'libs/binder/RpcTrusty.cpp') diff --git a/libs/binder/RpcTrusty.cpp b/libs/binder/RpcTrusty.cpp index ea49eef676..3b53b05991 100644 --- a/libs/binder/RpcTrusty.cpp +++ b/libs/binder/RpcTrusty.cpp @@ -26,8 +26,12 @@ namespace android { using android::base::unique_fd; -sp RpcTrustyConnect(const char* device, const char* port) { +sp RpcTrustyConnectWithSessionInitializer( + const char* device, const char* port, + std::function&)> sessionInitializer) { auto session = RpcSession::make(RpcTransportCtxFactoryTipcAndroid::make()); + // using the callback to initialize the session + sessionInitializer(session); auto request = [=] { int tipcFd = tipc_connect(device, port); if (tipcFd < 0) { @@ -40,6 +44,11 @@ sp RpcTrustyConnect(const char* device, const char* port) { LOG(ERROR) << "Failed to set up Trusty client. Error: " << statusToString(status).c_str(); return nullptr; } + return session; +} + +sp RpcTrustyConnect(const char* device, const char* port) { + auto session = RpcTrustyConnectWithSessionInitializer(device, port, [](auto) {}); return session->getRootObject(); } -- cgit v1.2.3-59-g8ed1b