summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andrei Homescu <ahomescu@google.com> 2022-08-24 23:54:59 +0000
committer Andrei Homescu <ahomescu@google.com> 2022-08-25 00:00:24 +0000
commit024727b29bd10909c2ddbb7a3cca9aa1dcec879d (patch)
tree1cbcc35097e6c836eab8a3f9cb4a5e1c7a61d82d
parentb125642ba6af3bb96a466c42f7161e85339f5dc9 (diff)
libbinder: add makeDefaultRpcTransportCtxFactory
Add a new OS-specific function that creates a new instance of the default RpcTransportCtxFactory. This is needed because Android and Trusty have different default transports: RpcTransportRaw and RpcTransportTipcTrusty, respectively. Bug: 230135749 Test: presubmit Change-Id: I4abd443fe9a08c1fa0cc41dfca7ef1cdb69fe0fb
-rw-r--r--libs/binder/OS.cpp5
-rw-r--r--libs/binder/OS.h3
-rw-r--r--libs/binder/RpcServer.cpp2
-rw-r--r--libs/binder/RpcSession.cpp2
-rw-r--r--libs/binder/trusty/OS.cpp6
5 files changed, 16 insertions, 2 deletions
diff --git a/libs/binder/OS.cpp b/libs/binder/OS.cpp
index cc4a03ba67..24ce2bb465 100644
--- a/libs/binder/OS.cpp
+++ b/libs/binder/OS.cpp
@@ -17,6 +17,7 @@
#include "OS.h"
#include <android-base/file.h>
+#include <binder/RpcTransportRaw.h>
#include <string.h>
using android::base::ErrnoError;
@@ -58,4 +59,8 @@ status_t dupFileDescriptor(int oldFd, int* newFd) {
return OK;
}
+std::unique_ptr<RpcTransportCtxFactory> makeDefaultRpcTransportCtxFactory() {
+ return RpcTransportCtxFactoryRaw::make();
+}
+
} // namespace android
diff --git a/libs/binder/OS.h b/libs/binder/OS.h
index d6e1c78ae9..5ab8bab0e7 100644
--- a/libs/binder/OS.h
+++ b/libs/binder/OS.h
@@ -20,6 +20,7 @@
#include <android-base/result.h>
#include <android-base/unique_fd.h>
+#include <binder/RpcTransport.h>
#include <utils/Errors.h>
namespace android {
@@ -30,4 +31,6 @@ status_t getRandomBytes(uint8_t* data, size_t size);
status_t dupFileDescriptor(int oldFd, int* newFd);
+std::unique_ptr<RpcTransportCtxFactory> makeDefaultRpcTransportCtxFactory();
+
} // namespace android
diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp
index 49be4dd9eb..2efd113fef 100644
--- a/libs/binder/RpcServer.cpp
+++ b/libs/binder/RpcServer.cpp
@@ -55,7 +55,7 @@ RpcServer::~RpcServer() {
sp<RpcServer> RpcServer::make(std::unique_ptr<RpcTransportCtxFactory> rpcTransportCtxFactory) {
// Default is without TLS.
if (rpcTransportCtxFactory == nullptr)
- rpcTransportCtxFactory = RpcTransportCtxFactoryRaw::make();
+ rpcTransportCtxFactory = makeDefaultRpcTransportCtxFactory();
auto ctx = rpcTransportCtxFactory->newServerCtx();
if (ctx == nullptr) return nullptr;
return sp<RpcServer>::make(std::move(ctx));
diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp
index 8ddfa93c00..eee28d6dde 100644
--- a/libs/binder/RpcSession.cpp
+++ b/libs/binder/RpcSession.cpp
@@ -68,7 +68,7 @@ RpcSession::~RpcSession() {
sp<RpcSession> RpcSession::make() {
// Default is without TLS.
- return make(RpcTransportCtxFactoryRaw::make());
+ return make(makeDefaultRpcTransportCtxFactory());
}
sp<RpcSession> RpcSession::make(std::unique_ptr<RpcTransportCtxFactory> rpcTransportCtxFactory) {
diff --git a/libs/binder/trusty/OS.cpp b/libs/binder/trusty/OS.cpp
index b21fe6acf5..1a76da554b 100644
--- a/libs/binder/trusty/OS.cpp
+++ b/libs/binder/trusty/OS.cpp
@@ -20,6 +20,8 @@
#include <lib/rand/rand.h>
#endif
+#include <binder/RpcTransportTipcTrusty.h>
+
#include "../OS.h"
using android::base::Result;
@@ -46,4 +48,8 @@ status_t dupFileDescriptor(int oldFd, int* newFd) {
return INVALID_OPERATION;
}
+std::unique_ptr<RpcTransportCtxFactory> makeDefaultRpcTransportCtxFactory() {
+ return RpcTransportCtxFactoryTipcTrusty::make();
+}
+
} // namespace android