summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2021-09-13 16:27:34 -0700
committer Steven Moreland <smoreland@google.com> 2021-09-13 16:41:28 -0700
commit99157624317005011ae57e15a6482c35cea085e5 (patch)
tree4219b6435370e4cd20ff69914bf5105baeb6a0a4
parent728587b2851fa5aab102a16d55048a8deb23f18e (diff)
libbinder: hide BpBinder::create(*) functions
There is no need to have these around, and having them exposed potentially means they could be stuck in the ABI. They are created (instead of absorbed into the private constructors) because of the additional UID tracking logic there. Bug: 167966510 Test: binderRpcTest Change-Id: I673d7a4c591a1b004f3214e8a17b48e54e91171d
-rw-r--r--libs/binder/Parcel.cpp4
-rw-r--r--libs/binder/ProcessState.cpp4
-rw-r--r--libs/binder/RpcState.cpp7
-rw-r--r--libs/binder/include/binder/BpBinder.h21
4 files changed, 19 insertions, 17 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 9147e23363..9f95167f86 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -237,7 +237,7 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder) {
return INVALID_OPERATION;
}
}
- const int32_t handle = proxy ? proxy->getPrivateAccessorForId().binderHandle() : 0;
+ const int32_t handle = proxy ? proxy->getPrivateAccessor().binderHandle() : 0;
obj.hdr.type = BINDER_TYPE_HANDLE;
obj.binder = 0; /* Don't pass uninitialized stack data to a remote process */
obj.handle = handle;
@@ -572,7 +572,7 @@ void Parcel::markForBinder(const sp<IBinder>& binder) {
LOG_ALWAYS_FATAL_IF(mData != nullptr, "format must be set before data is written");
if (binder && binder->remoteBinder() && binder->remoteBinder()->isRpcBinder()) {
- markForRpc(binder->remoteBinder()->getPrivateAccessorForId().rpcSession());
+ markForRpc(binder->remoteBinder()->getPrivateAccessor().rpcSession());
}
}
diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp
index 15b8604101..4fe4fe651c 100644
--- a/libs/binder/ProcessState.cpp
+++ b/libs/binder/ProcessState.cpp
@@ -212,7 +212,7 @@ ssize_t ProcessState::getStrongRefCountForNode(const sp<BpBinder>& binder) {
binder_node_info_for_ref info;
memset(&info, 0, sizeof(binder_node_info_for_ref));
- info.handle = binder->getPrivateAccessorForId().binderHandle();
+ info.handle = binder->getPrivateAccessor().binderHandle();
status_t result = ioctl(mDriverFD, BINDER_GET_NODE_INFO_FOR_REF, &info);
@@ -301,7 +301,7 @@ sp<IBinder> ProcessState::getStrongProxyForHandle(int32_t handle)
return nullptr;
}
- sp<BpBinder> b = BpBinder::create(handle);
+ sp<BpBinder> b = BpBinder::PrivateAccessor::create(handle);
e->binder = b.get();
if (b) e->refs = b->getWeakRefs();
result = b;
diff --git a/libs/binder/RpcState.cpp b/libs/binder/RpcState.cpp
index 59643ba4ee..11a083ac11 100644
--- a/libs/binder/RpcState.cpp
+++ b/libs/binder/RpcState.cpp
@@ -56,7 +56,7 @@ status_t RpcState::onBinderLeaving(const sp<RpcSession>& session, const sp<IBind
bool isRemote = binder->remoteBinder();
bool isRpc = isRemote && binder->remoteBinder()->isRpcBinder();
- if (isRpc && binder->remoteBinder()->getPrivateAccessorForId().rpcSession() != session) {
+ if (isRpc && binder->remoteBinder()->getPrivateAccessor().rpcSession() != session) {
// We need to be able to send instructions over the socket for how to
// connect to a different server, and we also need to let the host
// process know that this is happening.
@@ -85,8 +85,7 @@ status_t RpcState::onBinderLeaving(const sp<RpcSession>& session, const sp<IBind
if (binder == node.binder) {
if (isRpc) {
// check integrity of data structure
- uint64_t actualAddr =
- binder->remoteBinder()->getPrivateAccessorForId().rpcAddress();
+ uint64_t actualAddr = binder->remoteBinder()->getPrivateAccessor().rpcAddress();
LOG_ALWAYS_FATAL_IF(addr != actualAddr, "Address mismatch %" PRIu64 " vs %" PRIu64,
addr, actualAddr);
}
@@ -185,7 +184,7 @@ status_t RpcState::onBinderEntering(const sp<RpcSession>& session, uint64_t addr
// Currently, all binders are assumed to be part of the same session (no
// device global binders in the RPC world).
- it->second.binder = *out = BpBinder::create(session, it->first);
+ it->second.binder = *out = BpBinder::PrivateAccessor::create(session, it->first);
it->second.timesRecd = 1;
return OK;
}
diff --git a/libs/binder/include/binder/BpBinder.h b/libs/binder/include/binder/BpBinder.h
index 9f2ce1efba..7f56658328 100644
--- a/libs/binder/include/binder/BpBinder.h
+++ b/libs/binder/include/binder/BpBinder.h
@@ -39,9 +39,6 @@ using binder_proxy_limit_callback = void(*)(int);
class BpBinder : public IBinder
{
public:
- static sp<BpBinder> create(int32_t handle);
- static sp<BpBinder> create(const sp<RpcSession>& session, uint64_t address);
-
/**
* Return value:
* true - this is associated with a socket RpcSession
@@ -116,13 +113,18 @@ public:
KeyedVector<const void*, entry_t> mObjects;
};
- class PrivateAccessorForId {
+ class PrivateAccessor {
private:
friend class BpBinder;
friend class ::android::Parcel;
friend class ::android::ProcessState;
friend class ::android::RpcState;
- explicit PrivateAccessorForId(const BpBinder* binder) : mBinder(binder) {}
+ explicit PrivateAccessor(const BpBinder* binder) : mBinder(binder) {}
+
+ static sp<BpBinder> create(int32_t handle) { return BpBinder::create(handle); }
+ static sp<BpBinder> create(const sp<RpcSession>& session, uint64_t address) {
+ return BpBinder::create(session, address);
+ }
// valid if !isRpcBinder
int32_t binderHandle() const { return mBinder->binderHandle(); }
@@ -133,14 +135,15 @@ public:
const BpBinder* mBinder;
};
- const PrivateAccessorForId getPrivateAccessorForId() const {
- return PrivateAccessorForId(this);
- }
+ const PrivateAccessor getPrivateAccessor() const { return PrivateAccessor(this); }
private:
- friend PrivateAccessorForId;
+ friend PrivateAccessor;
friend class sp<BpBinder>;
+ static sp<BpBinder> create(int32_t handle);
+ static sp<BpBinder> create(const sp<RpcSession>& session, uint64_t address);
+
struct BinderHandle {
int32_t handle;
};