From 6ba5a259faf092d127a1f417d5bfe389f2236198 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Tue, 4 May 2021 22:49:00 +0000 Subject: libbinder: stop exporting private headers Having a 'private' include directory for a library is somewhat of an artifact. There is no need to export these (or once include_dirs is eliminated, make them available at any capacity). We want libbinder to completely encapsulate the kernel API. Bug: N/A Test: binderLibTest Change-Id: If84ff928a186f3397150660c2cc1faadb46b796c --- libs/binder/IPCThreadState.cpp | 3 +- libs/binder/Parcel.cpp | 2 +- libs/binder/ProcessState.cpp | 2 +- libs/binder/binder_module.h | 101 +++++++++++++++++++++ libs/binder/include/private/binder/binder_module.h | 101 --------------------- libs/binder/tests/binderLibTest.cpp | 2 +- 6 files changed, 105 insertions(+), 106 deletions(-) create mode 100644 libs/binder/binder_module.h delete mode 100644 libs/binder/include/private/binder/binder_module.h diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp index 6fb1227f63..ef7fd44419 100644 --- a/libs/binder/IPCThreadState.cpp +++ b/libs/binder/IPCThreadState.cpp @@ -29,8 +29,6 @@ #include #include -#include - #include #include #include @@ -43,6 +41,7 @@ #include #include "Static.h" +#include "binder_module.h" #if LOG_NDEBUG diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index 39d6a2ec4f..2e4f450bc1 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -48,10 +48,10 @@ #include #include -#include #include "RpcState.h" #include "Static.h" #include "Utils.h" +#include "binder_module.h" #define LOG_REFS(...) //#define LOG_REFS(...) ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__) diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp index a2efb1c95f..f7ca1e68cb 100644 --- a/libs/binder/ProcessState.cpp +++ b/libs/binder/ProcessState.cpp @@ -27,8 +27,8 @@ #include #include -#include #include "Static.h" +#include "binder_module.h" #include #include diff --git a/libs/binder/binder_module.h b/libs/binder/binder_module.h new file mode 100644 index 0000000000..9dea3b448b --- /dev/null +++ b/libs/binder/binder_module.h @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2008 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. + */ + +#ifndef _BINDER_MODULE_H_ +#define _BINDER_MODULE_H_ + +/* obtain structures and constants from the kernel header */ + +// TODO(b/31559095): bionic on host +#ifndef __ANDROID__ +#define __packed __attribute__((__packed__)) +#endif + +// TODO(b/31559095): bionic on host +#if defined(B_PACK_CHARS) && !defined(_UAPI_LINUX_BINDER_H) +#undef B_PACK_CHARS +#endif + +#include +#include + +#ifndef BR_FROZEN_REPLY +// Temporary definition of BR_FROZEN_REPLY. For production +// this will come from UAPI binder.h +#define BR_FROZEN_REPLY _IO('r', 18) +#endif // BR_FROZEN_REPLY + +#ifndef BINDER_FREEZE +/* + * Temporary definitions for freeze support. For the final version + * these will be defined in the UAPI binder.h file from upstream kernel. + */ +#define BINDER_FREEZE _IOW('b', 14, struct binder_freeze_info) + +struct binder_freeze_info { + // + // Group-leader PID of process to be frozen + // + uint32_t pid; + // + // Enable(1) / Disable(0) freeze for given PID + // + uint32_t enable; + // + // Timeout to wait for transactions to drain. + // 0: don't wait (ioctl will return EAGAIN if not drained) + // N: number of ms to wait + uint32_t timeout_ms; +}; +#endif // BINDER_FREEZE + +#ifndef BINDER_GET_FROZEN_INFO + +#define BINDER_GET_FROZEN_INFO _IOWR('b', 15, struct binder_frozen_status_info) + +struct binder_frozen_status_info { + // + // Group-leader PID of process to be queried + // + __u32 pid; + // + // Indicates whether the process has received any sync calls since last + // freeze (cleared at freeze/unfreeze) + // + __u32 sync_recv; + // + // Indicates whether the process has received any async calls since last + // freeze (cleared at freeze/unfreeze) + // + __u32 async_recv; +}; +#endif // BINDER_GET_FROZEN_INFO + +#ifndef BR_ONEWAY_SPAM_SUSPECT +// Temporary definition of BR_ONEWAY_SPAM_SUSPECT. For production +// this will come from UAPI binder.h +#define BR_ONEWAY_SPAM_SUSPECT _IO('r', 19) +#endif // BR_ONEWAY_SPAM_SUSPECT + +#ifndef BINDER_ENABLE_ONEWAY_SPAM_DETECTION +/* + * Temporary definitions for oneway spam detection support. For the final version + * these will be defined in the UAPI binder.h file from upstream kernel. + */ +#define BINDER_ENABLE_ONEWAY_SPAM_DETECTION _IOW('b', 16, __u32) +#endif // BINDER_ENABLE_ONEWAY_SPAM_DETECTION + +#endif // _BINDER_MODULE_H_ diff --git a/libs/binder/include/private/binder/binder_module.h b/libs/binder/include/private/binder/binder_module.h deleted file mode 100644 index 151235c16b..0000000000 --- a/libs/binder/include/private/binder/binder_module.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2008 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. - */ - -#ifndef _BINDER_MODULE_H_ -#define _BINDER_MODULE_H_ - -/* obtain structures and constants from the kernel header */ - -// TODO(b/31559095): bionic on host -#ifndef __ANDROID__ -#define __packed __attribute__((__packed__)) -#endif - -// TODO(b/31559095): bionic on host -#if defined(B_PACK_CHARS) && !defined(_UAPI_LINUX_BINDER_H) -#undef B_PACK_CHARS -#endif - -#include -#include - -#ifndef BR_FROZEN_REPLY -// Temporary definition of BR_FROZEN_REPLY. For production -// this will come from UAPI binder.h -#define BR_FROZEN_REPLY _IO('r', 18) -#endif //BR_FROZEN_REPLY - -#ifndef BINDER_FREEZE -/* - * Temporary definitions for freeze support. For the final version - * these will be defined in the UAPI binder.h file from upstream kernel. - */ -#define BINDER_FREEZE _IOW('b', 14, struct binder_freeze_info) - -struct binder_freeze_info { - // - // Group-leader PID of process to be frozen - // - uint32_t pid; - // - // Enable(1) / Disable(0) freeze for given PID - // - uint32_t enable; - // - // Timeout to wait for transactions to drain. - // 0: don't wait (ioctl will return EAGAIN if not drained) - // N: number of ms to wait - uint32_t timeout_ms; -}; -#endif //BINDER_FREEZE - -#ifndef BINDER_GET_FROZEN_INFO - -#define BINDER_GET_FROZEN_INFO _IOWR('b', 15, struct binder_frozen_status_info) - -struct binder_frozen_status_info { - // - // Group-leader PID of process to be queried - // - __u32 pid; - // - // Indicates whether the process has received any sync calls since last - // freeze (cleared at freeze/unfreeze) - // - __u32 sync_recv; - // - // Indicates whether the process has received any async calls since last - // freeze (cleared at freeze/unfreeze) - // - __u32 async_recv; -}; -#endif //BINDER_GET_FROZEN_INFO - -#ifndef BR_ONEWAY_SPAM_SUSPECT -// Temporary definition of BR_ONEWAY_SPAM_SUSPECT. For production -// this will come from UAPI binder.h -#define BR_ONEWAY_SPAM_SUSPECT _IO('r', 19) -#endif //BR_ONEWAY_SPAM_SUSPECT - -#ifndef BINDER_ENABLE_ONEWAY_SPAM_DETECTION -/* - * Temporary definitions for oneway spam detection support. For the final version - * these will be defined in the UAPI binder.h file from upstream kernel. - */ -#define BINDER_ENABLE_ONEWAY_SPAM_DETECTION _IOW('b', 16, __u32) -#endif //BINDER_ENABLE_ONEWAY_SPAM_DETECTION - -#endif // _BINDER_MODULE_H_ diff --git a/libs/binder/tests/binderLibTest.cpp b/libs/binder/tests/binderLibTest.cpp index dc8c0f157e..5676bd1939 100644 --- a/libs/binder/tests/binderLibTest.cpp +++ b/libs/binder/tests/binderLibTest.cpp @@ -31,11 +31,11 @@ #include #include -#include #include #include #include +#include "../binder_module.h" #include "binderAbiHelper.h" #define ARRAY_SIZE(array) (sizeof array / sizeof array[0]) -- cgit v1.2.3-59-g8ed1b From 704fc1a8ccffd8abc43ea126d4310b34c0e95bf2 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Tue, 4 May 2021 23:13:14 +0000 Subject: libbinder: RPC server setup debug logs Useful while debugging vsock on host. Bug: 185269356 Test: binderRpcTest Change-Id: I6c7156129086c272e6863636aff378e4a000c8af --- libs/binder/RpcServer.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp index 4df12ce2c6..de7160ee08 100644 --- a/libs/binder/RpcServer.cpp +++ b/libs/binder/RpcServer.cpp @@ -184,6 +184,8 @@ std::vector> RpcServer::listConnections() { } bool RpcServer::setupSocketServer(const RpcSocketAddress& addr) { + LOG_RPC_DETAIL("Setting up socket server %s", addr.toString().c_str()); + { std::lock_guard _l(mLock); LOG_ALWAYS_FATAL_IF(mServer.get() != -1, "Each RpcServer can only have one server."); @@ -208,6 +210,8 @@ bool RpcServer::setupSocketServer(const RpcSocketAddress& addr) { return false; } + LOG_RPC_DETAIL("Successfully setup socket server %s", addr.toString().c_str()); + mServer = std::move(serverFd); return true; } -- cgit v1.2.3-59-g8ed1b