diff options
| -rw-r--r-- | libs/binder/BpBinder.cpp | 2 | ||||
| -rw-r--r-- | libs/binder/RpcSession.cpp | 5 | ||||
| -rw-r--r-- | libs/binder/include/binder/BpBinder.h | 1 | ||||
| -rw-r--r-- | libs/binder/include/binder/RpcSession.h | 10 |
4 files changed, 16 insertions, 2 deletions
diff --git a/libs/binder/BpBinder.cpp b/libs/binder/BpBinder.cpp index 687ee257fd..92df874b1f 100644 --- a/libs/binder/BpBinder.cpp +++ b/libs/binder/BpBinder.cpp @@ -510,7 +510,7 @@ void BpBinder::onLastStrongRef(const void* /*id*/) { ALOGV("onLastStrongRef BpBinder %p handle %d\n", this, binderHandle()); if (CC_UNLIKELY(isRpcBinder())) { - (void)rpcSession()->sendDecStrong(rpcAddress()); + (void)rpcSession()->sendDecStrong(this); return; } IF_ALOGV() { diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp index e8f984c717..886a2e952b 100644 --- a/libs/binder/RpcSession.cpp +++ b/libs/binder/RpcSession.cpp @@ -29,6 +29,7 @@ #include <android-base/hex.h> #include <android-base/macros.h> #include <android_runtime/vm.h> +#include <binder/BpBinder.h> #include <binder/Parcel.h> #include <binder/RpcServer.h> #include <binder/RpcTransportRaw.h> @@ -226,6 +227,10 @@ status_t RpcSession::transact(const sp<IBinder>& binder, uint32_t code, const Pa sp<RpcSession>::fromExisting(this), reply, flags); } +status_t RpcSession::sendDecStrong(const BpBinder* binder) { + return sendDecStrong(binder->getPrivateAccessor().rpcAddress()); +} + status_t RpcSession::sendDecStrong(uint64_t address) { ExclusiveConnection connection; status_t status = ExclusiveConnection::find(sp<RpcSession>::fromExisting(this), diff --git a/libs/binder/include/binder/BpBinder.h b/libs/binder/include/binder/BpBinder.h index 7f56658328..c0454b6fbd 100644 --- a/libs/binder/include/binder/BpBinder.h +++ b/libs/binder/include/binder/BpBinder.h @@ -118,6 +118,7 @@ public: friend class BpBinder; friend class ::android::Parcel; friend class ::android::ProcessState; + friend class ::android::RpcSession; friend class ::android::RpcState; explicit PrivateAccessor(const BpBinder* binder) : mBinder(binder) {} diff --git a/libs/binder/include/binder/RpcSession.h b/libs/binder/include/binder/RpcSession.h index 9c7c97035a..a841079ec4 100644 --- a/libs/binder/include/binder/RpcSession.h +++ b/libs/binder/include/binder/RpcSession.h @@ -153,7 +153,13 @@ public: [[nodiscard]] status_t transact(const sp<IBinder>& binder, uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags); - [[nodiscard]] status_t sendDecStrong(uint64_t address); + + /** + * Generally, you should not call this, unless you are testing error + * conditions, as this is called automatically by BpBinders when they are + * deleted (this is also why a raw pointer is used here) + */ + [[nodiscard]] status_t sendDecStrong(const BpBinder* binder); ~RpcSession(); @@ -172,6 +178,8 @@ private: friend RpcState; explicit RpcSession(std::unique_ptr<RpcTransportCtx> ctx); + [[nodiscard]] status_t sendDecStrong(uint64_t address); + class EventListener : public virtual RefBase { public: virtual void onSessionAllIncomingThreadsEnded(const sp<RpcSession>& session) = 0; |