diff options
| author | 2022-09-24 14:41:15 +0000 | |
|---|---|---|
| committer | 2022-09-24 14:41:15 +0000 | |
| commit | e2c515ef7b2b16e237182fd680e3a2ecfb583e14 (patch) | |
| tree | 93a369598885e08328f51de968aa9dcc99536088 | |
| parent | 8d8caa17e64ef9e58fc657deb38f416a886baa4f (diff) | |
| parent | 531fcadc02d688314ea754e19625acea13573543 (diff) | |
Merge "TrustyRpc: Adding a create session with initialization callback function"
| -rw-r--r-- | libs/binder/RpcTrusty.cpp | 11 | ||||
| -rw-r--r-- | libs/binder/include_trusty/binder/RpcTrusty.h | 4 |
2 files changed, 14 insertions, 1 deletions
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<IBinder> RpcTrustyConnect(const char* device, const char* port) { +sp<RpcSession> RpcTrustyConnectWithSessionInitializer( + const char* device, const char* port, + std::function<void(sp<RpcSession>&)> 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<IBinder> 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<IBinder> RpcTrustyConnect(const char* device, const char* port) { + auto session = RpcTrustyConnectWithSessionInitializer(device, port, [](auto) {}); return session->getRootObject(); } diff --git a/libs/binder/include_trusty/binder/RpcTrusty.h b/libs/binder/include_trusty/binder/RpcTrusty.h index f124e0c824..b034b9b65b 100644 --- a/libs/binder/include_trusty/binder/RpcTrusty.h +++ b/libs/binder/include_trusty/binder/RpcTrusty.h @@ -22,4 +22,8 @@ namespace android { sp<IBinder> RpcTrustyConnect(const char* device, const char* port); +sp<RpcSession> RpcTrustyConnectWithSessionInitializer( + const char* device, const char* port, + std::function<void(sp<RpcSession>&)> sessionInitializer); + } // namespace android |