diff options
| -rw-r--r-- | libs/binder/Android.bp | 99 | ||||
| -rw-r--r-- | libs/binder/OS_non_android_linux.cpp | 57 | ||||
| -rw-r--r-- | libs/binder/trusty/OS.cpp | 5 |
3 files changed, 141 insertions, 20 deletions
diff --git a/libs/binder/Android.bp b/libs/binder/Android.bp index f1cc5f05ec..bf3699ccab 100644 --- a/libs/binder/Android.bp +++ b/libs/binder/Android.bp @@ -22,23 +22,51 @@ package { } cc_library_headers { - name: "libbinder_headers", + name: "libbinder_headers_base", export_include_dirs: ["include"], vendor_available: true, recovery_available: true, host_supported: true, - // TODO(b/153609531): remove when no longer needed. native_bridge_supported: true, header_libs: [ - "libbase_headers", "libbinder_headers_platform_shared", + ], + export_header_lib_headers: [ + "libbinder_headers_platform_shared", + ], + apex_available: [ + "//apex_available:platform", + "com.android.media", + "com.android.media.swcodec", + ], + min_sdk_version: "29", + target: { + darwin: { + enabled: false, + }, + }, + visibility: [ + ":__subpackages__", + ], +} + +cc_library_headers { + name: "libbinder_headers", + vendor_available: true, + recovery_available: true, + host_supported: true, + native_bridge_supported: true, + + header_libs: [ + "libbase_headers", + "libbinder_headers_base", "libcutils_headers", "libutils_headers", ], export_header_lib_headers: [ "libbase_headers", - "libbinder_headers_platform_shared", + "libbinder_headers_base", "libcutils_headers", "libutils_headers", ], @@ -87,6 +115,7 @@ cc_defaults { "RpcSession.cpp", "RpcServer.cpp", "RpcState.cpp", + "RpcTransportRaw.cpp", "Stability.cpp", "Status.cpp", "TextOutput.cpp", @@ -94,17 +123,8 @@ cc_defaults { "file.cpp", ], - shared_libs: [ - "libcutils", - "libutils", - ], - - static_libs: [ - "libbase", - ], - header_libs: [ - "libbinder_headers", + "libbinder_headers_base", ], cflags: [ @@ -131,7 +151,6 @@ cc_defaults { srcs: [ "OS_android.cpp", "OS_unix_base.cpp", - "RpcTransportRaw.cpp", ], target: { @@ -156,11 +175,18 @@ cc_defaults { }, shared_libs: [ + "libcutils", "liblog", + "libutils", + ], + + static_libs: [ + "libbase", ], header_libs: [ "jni_headers", + "libbinder_headers", ], export_header_lib_headers: [ @@ -217,10 +243,15 @@ cc_defaults { host_supported: true, header_libs: [ + "libbinder_headers_base", "liblog_stub", "trusty_mock_headers", ], + shared_libs: [ + "libutils_binder_sdk", + ], + cflags: [ "-DBINDER_RPC_SINGLE_THREADED", "-DBINDER_ENABLE_LIBLOG_ASSERT", @@ -351,6 +382,44 @@ cc_library { afdo: true, } +cc_library_host_shared { + name: "libbinder_sdk", + + defaults: [ + "libbinder_common_defaults", + ], + + shared_libs: [ + "libutils_binder_sdk", + ], + + cflags: [ + "-DBINDER_ENABLE_LIBLOG_ASSERT", + "-DBINDER_DISABLE_NATIVE_HANDLE", + "-DBINDER_DISABLE_BLOB", + "-DBINDER_NO_LIBBASE", + ], + + header_libs: [ + "liblog_stub", + ], + + srcs: [ + "OS_non_android_linux.cpp", + "OS_unix_base.cpp", + ], + + visibility: [ + ":__subpackages__", + ], + + target: { + windows: { + enabled: false, + }, + }, +} + cc_library_static { name: "libbinder_rpc_no_kernel", vendor_available: true, diff --git a/libs/binder/OS_non_android_linux.cpp b/libs/binder/OS_non_android_linux.cpp new file mode 100644 index 0000000000..b525d1ac34 --- /dev/null +++ b/libs/binder/OS_non_android_linux.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "OS.h" + +#include <log/log.h> + +#include <syscall.h> +#include <cstdarg> + +#ifdef __ANDROID__ +#error "This module is not intended for Android, just bare Linux" +#endif +#ifdef __APPLE__ +#error "This module is not intended for MacOS" +#endif +#ifdef _WIN32 +#error "This module is not intended for Windows" +#endif + +namespace android::binder::os { + +void trace_begin(uint64_t, const char*) {} + +void trace_end(uint64_t) {} + +uint64_t GetThreadId() { + return syscall(__NR_gettid); +} + +bool report_sysprop_change() { + return false; +} + +} // namespace android::binder::os + +int __android_log_print(int /*prio*/, const char* /*tag*/, const char* fmt, ...) { + va_list args; + va_start(args, fmt); + vfprintf(stderr, fmt, args); + va_end(args); + + return 1; +} diff --git a/libs/binder/trusty/OS.cpp b/libs/binder/trusty/OS.cpp index 9869bf3460..a8dabc3a1d 100644 --- a/libs/binder/trusty/OS.cpp +++ b/libs/binder/trusty/OS.cpp @@ -126,8 +126,3 @@ int __android_log_print(int prio [[maybe_unused]], const char* tag, const char* return 1; } - -// TODO(b/285204695): remove once trusty mock doesn't depend on libbase -extern "C" int __android_log_buf_print(int, int, const char*, const char*, ...) { - return -ENOSYS; -} |