diff options
author | 2024-11-14 11:49:08 +0000 | |
---|---|---|
committer | 2024-11-29 17:13:56 +0000 | |
commit | dc207544897a30fe412ffcc0deab07dd974358d1 (patch) | |
tree | cfc962fbcfb3c604aabc6b26fa23ce0b45300b77 /libs/binder/BackendUnifiedServiceManager.h | |
parent | bd28005fead6cea70a6213d37071ee7313f1839f (diff) |
Add binder to libbinder cache after addService
This will prevent system_server and other applications
from calling servicemanager for local binders.
Flag: RELEASE_LIBBINDER_CLIENT_CACHE
Bug: 333854840
Test: atest binderCacheUnitTest
Change-Id: I2693f21a3f5b7a5770481e5ac79719444284524d
Diffstat (limited to 'libs/binder/BackendUnifiedServiceManager.h')
-rw-r--r-- | libs/binder/BackendUnifiedServiceManager.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libs/binder/BackendUnifiedServiceManager.h b/libs/binder/BackendUnifiedServiceManager.h index abc0eda7eb..b46bf194a1 100644 --- a/libs/binder/BackendUnifiedServiceManager.h +++ b/libs/binder/BackendUnifiedServiceManager.h @@ -105,8 +105,7 @@ public: binder::ScopedTrace aidlTrace(ATRACE_TAG_AIDL, "BinderCacheWithInvalidation::setItem Successfully Cached"); std::lock_guard<std::mutex> lock(mCacheMutex); - Entry entry = {.service = item, .deathRecipient = deathRecipient}; - mCache[key] = entry; + mCache[key] = {.service = item, .deathRecipient = deathRecipient}; return binder::Status::ok(); } @@ -147,17 +146,20 @@ public: const sp<IBinder>& service) override; binder::Status getServiceDebugInfo(::std::vector<os::ServiceDebugInfo>* _aidl_return) override; + void enableAddServiceCache(bool value) { mEnableAddServiceCache = value; } // for legacy ABI const String16& getInterfaceDescriptor() const override { return mTheRealServiceManager->getInterfaceDescriptor(); } private: + bool mEnableAddServiceCache = true; std::shared_ptr<BinderCacheWithInvalidation> mCacheForGetService; sp<os::IServiceManager> mTheRealServiceManager; binder::Status toBinderService(const ::std::string& name, const os::Service& in, os::Service* _out); binder::Status updateCache(const std::string& serviceName, const os::Service& service); + binder::Status updateCache(const std::string& serviceName, const sp<IBinder>& binder); bool returnIfCached(const std::string& serviceName, os::Service* _out); }; |