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

Commit 2fd12a21 authored by Yifan Hong's avatar Yifan Hong Committed by Automerger Merge Worker
Browse files

Merge "binder: Enable TLS for binderRpcTest" am: b4be81b1

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1747999

Change-Id: I6e956a6a40e5d34e7eb712d83c5e24b3218437c9
parents 6db7a9c9 b4be81b1
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -268,6 +268,15 @@ cc_library_shared {
    defaults: ["libbinder_tls_defaults"],
}

// For testing
cc_library_static {
    name: "libbinder_tls_static",
    defaults: ["libbinder_tls_defaults"],
    visibility: [
        ":__subpackages__",
    ],
}

// AIDL interface between libbinder and framework.jar
filegroup {
    name: "libbinder_aidl",
+2 −0
Original line number Diff line number Diff line
@@ -145,6 +145,7 @@ cc_test {
    defaults: [
        "binder_test_defaults",
        "libbinder_ndk_host_user",
        "libbinder_tls_shared_deps",
    ],

    srcs: [
@@ -159,6 +160,7 @@ cc_test {
        "liblog",
    ],
    static_libs: [
        "libbinder_tls_static",
        "binderRpcTestIface-cpp",
        "binderRpcTestIface-ndk",
    ],
+5 −2
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include <binder/RpcSession.h>
#include <binder/RpcTransport.h>
#include <binder/RpcTransportRaw.h>
#include <binder/RpcTransportTls.h>
#include <gtest/gtest.h>

#include <chrono>
@@ -54,16 +55,18 @@ static_assert(RPC_WIRE_PROTOCOL_VERSION + 1 == RPC_WIRE_PROTOCOL_VERSION_NEXT ||
              RPC_WIRE_PROTOCOL_VERSION == RPC_WIRE_PROTOCOL_VERSION_EXPERIMENTAL);
const char* kLocalInetAddress = "127.0.0.1";

enum class RpcSecurity { RAW };
enum class RpcSecurity { RAW, TLS };

static inline std::vector<RpcSecurity> RpcSecurityValues() {
    return {RpcSecurity::RAW};
    return {RpcSecurity::RAW, RpcSecurity::TLS};
}

static inline std::unique_ptr<RpcTransportCtxFactory> newFactory(RpcSecurity rpcSecurity) {
    switch (rpcSecurity) {
        case RpcSecurity::RAW:
            return RpcTransportCtxFactoryRaw::make();
        case RpcSecurity::TLS:
            return RpcTransportCtxFactoryTls::make();
        default:
            LOG_ALWAYS_FATAL("Unknown RpcSecurity %d", rpcSecurity);
    }