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

Commit 4b89f17e authored by Gil Cukierman's avatar Gil Cukierman Committed by Gerrit Code Review
Browse files

Merge "libbinder: allow fd transport in trusty by default" into main

parents 1175227b 33d6d19d
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -94,9 +94,8 @@ private:
    static sp<RpcServer> makeRpcServer(std::unique_ptr<RpcTransportCtx> ctx) {
        auto rpcServer = sp<RpcServer>::make(std::move(ctx));

        // TODO(b/266741352): follow-up to prevent needing this in the future
        // Trusty needs to be set to the latest stable version that is in prebuilts there.
        LOG_ALWAYS_FATAL_IF(!rpcServer->setProtocolVersion(0));
        // By default we use the latest stable version.
        LOG_ALWAYS_FATAL_IF(!rpcServer->setProtocolVersion(RPC_WIRE_PROTOCOL_VERSION));

        return rpcServer;
    }
+9 −0
Original line number Diff line number Diff line
@@ -27,6 +27,13 @@ using android::RpcTransportCtxFactoryTipcTrusty;
using android::sp;
using android::wp;

// The default behavior in trusty is to allow handles to be passed with tipc IPC.
// We add mode NONE so that servers do not reject connections from clients who do
// not change their default transport mode.
static const std::vector<RpcSession::FileDescriptorTransportMode> TRUSTY_SERVER_SUPPORTED_FD_MODES =
        {RpcSession::FileDescriptorTransportMode::TRUSTY,
         RpcSession::FileDescriptorTransportMode::NONE};

struct ARpcServerTrusty {
    sp<RpcServer> mRpcServer;

@@ -53,6 +60,8 @@ ARpcServerTrusty* ARpcServerTrusty_newPerSession(AIBinder* (*cb)(const void*, si
        return nullptr;
    }

    rpcServer->setSupportedFileDescriptorTransportModes(TRUSTY_SERVER_SUPPORTED_FD_MODES);

    rpcServer->setPerSessionRootObject(
            [cb, cbArgSp](wp<RpcSession> /*session*/, const void* addrPtr, size_t len) {
                auto* aib = (*cb)(addrPtr, len, cbArgSp.get());