summaryrefslogtreecommitdiff
path: root/libs/binder/RpcTrusty.cpp
diff options
context:
space:
mode:
author Orlando Arbildo <oarbildo@google.com> 2022-09-24 15:57:35 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2022-09-24 15:57:35 +0000
commit2decd1ae01d69cc42665e1200c120036dcd7a8d9 (patch)
tree453e05ef677bf17171bcadc465cc8f95f492e859 /libs/binder/RpcTrusty.cpp
parent623da5972a195c66f95aaf834530be13b8f32f2b (diff)
parent12511760cb16673ae22c884923953825dd69e367 (diff)
Merge "TrustyRpc: Adding a create session with initialization callback function" am: e2c515ef7b am: 866d2f3c33 am: 12511760cb
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2229484 Change-Id: Ib20e8b74c1064ecc2298af6b98c4209349d471e0 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'libs/binder/RpcTrusty.cpp')
-rw-r--r--libs/binder/RpcTrusty.cpp11
1 files changed, 10 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();
}