diff options
author | 2019-07-12 14:02:53 -0700 | |
---|---|---|
committer | 2019-07-15 20:05:35 +0000 | |
commit | 4411d71dd8336bec8426bc9203e5181bfbb051ff (patch) | |
tree | 07a0a16f6a8ec1859eb2865eab74ad3ac1550b57 /libs/binder/ProcessState.cpp | |
parent | c08d593279398a86ecee7c7c3edc577fc5d2839b (diff) |
libbinder: remove dead code for multiple contexts
Doesn't appear used.
Bug: N/A
Test: N/A
Change-Id: Iae8ef1decfbf3aade076261c8606d5f143eb8784
Diffstat (limited to 'libs/binder/ProcessState.cpp')
-rw-r--r-- | libs/binder/ProcessState.cpp | 95 |
1 files changed, 19 insertions, 76 deletions
diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp index b25cd7bf12..26b93ff7a6 100644 --- a/libs/binder/ProcessState.cpp +++ b/libs/binder/ProcessState.cpp @@ -24,7 +24,6 @@ #include <cutils/atomic.h> #include <utils/Log.h> #include <utils/String8.h> -#include <utils/String8.h> #include <utils/threads.h> #include <private/binder/binder_module.h> @@ -120,58 +119,11 @@ sp<ProcessState> ProcessState::initWithMmapSize(size_t mmap_size) { return gProcess; } -void ProcessState::setContextObject(const sp<IBinder>& object) -{ - setContextObject(object, String16("default")); -} - sp<IBinder> ProcessState::getContextObject(const sp<IBinder>& /*caller*/) { return getStrongProxyForHandle(0); } -void ProcessState::setContextObject(const sp<IBinder>& object, const String16& name) -{ - AutoMutex _l(mLock); - mContexts.add(name, object); -} - -sp<IBinder> ProcessState::getContextObject(const String16& name, const sp<IBinder>& caller) -{ - mLock.lock(); - sp<IBinder> object( - mContexts.indexOfKey(name) >= 0 ? mContexts.valueFor(name) : nullptr); - mLock.unlock(); - - //printf("Getting context object %s for %p\n", String8(name).string(), caller.get()); - - if (object != nullptr) return object; - - // Don't attempt to retrieve contexts if we manage them - if (mManagesContexts) { - ALOGE("getContextObject(%s) failed, but we manage the contexts!\n", - String8(name).string()); - return nullptr; - } - - IPCThreadState* ipc = IPCThreadState::self(); - { - Parcel data, reply; - // no interface token on this magic transaction - data.writeString16(name); - data.writeStrongBinder(caller); - status_t result = ipc->transact(0 /*magic*/, 0, data, &reply, 0); - if (result == NO_ERROR) { - object = reply.readStrongBinder(); - } - } - - ipc->flushCommands(); - - if (object != nullptr) setContextObject(object, name); - return object; -} - void ProcessState::startThreadPool() { AutoMutex _l(mLock); @@ -181,41 +133,33 @@ void ProcessState::startThreadPool() } } -bool ProcessState::isContextManager(void) const -{ - return mManagesContexts; -} - bool ProcessState::becomeContextManager(context_check_func checkFunc, void* userData) { - if (!mManagesContexts) { - AutoMutex _l(mLock); - mBinderContextCheckFunc = checkFunc; - mBinderContextUserData = userData; + AutoMutex _l(mLock); + mBinderContextCheckFunc = checkFunc; + mBinderContextUserData = userData; - flat_binder_object obj { - .flags = FLAT_BINDER_FLAG_TXN_SECURITY_CTX, - }; + flat_binder_object obj { + .flags = FLAT_BINDER_FLAG_TXN_SECURITY_CTX, + }; - status_t result = ioctl(mDriverFD, BINDER_SET_CONTEXT_MGR_EXT, &obj); + int result = ioctl(mDriverFD, BINDER_SET_CONTEXT_MGR_EXT, &obj); - // fallback to original method - if (result != 0) { - android_errorWriteLog(0x534e4554, "121035042"); + // fallback to original method + if (result != 0) { + android_errorWriteLog(0x534e4554, "121035042"); - int dummy = 0; - result = ioctl(mDriverFD, BINDER_SET_CONTEXT_MGR, &dummy); - } + int dummy = 0; + result = ioctl(mDriverFD, BINDER_SET_CONTEXT_MGR, &dummy); + } - if (result == 0) { - mManagesContexts = true; - } else if (result == -1) { - mBinderContextCheckFunc = nullptr; - mBinderContextUserData = nullptr; - ALOGE("Binder ioctl to become context manager failed: %s\n", strerror(errno)); - } + if (result == -1) { + mBinderContextCheckFunc = nullptr; + mBinderContextUserData = nullptr; + ALOGE("Binder ioctl to become context manager failed: %s\n", strerror(errno)); } - return mManagesContexts; + + return result == 0; } // Get references to userspace objects held by the kernel binder driver @@ -446,7 +390,6 @@ ProcessState::ProcessState(const char *driver, size_t mmap_size) , mExecutingThreadsCount(0) , mMaxThreads(DEFAULT_MAX_BINDER_THREADS) , mStarvationStartTimeMs(0) - , mManagesContexts(false) , mBinderContextCheckFunc(nullptr) , mBinderContextUserData(nullptr) , mThreadPoolStarted(false) |