diff options
author | 2020-01-31 14:56:45 -0800 | |
---|---|---|
committer | 2020-02-05 10:15:39 -0800 | |
commit | 39d887d308c0430a5046d7dfaec87dfaaea1a7aa (patch) | |
tree | ec5075cd89a63c7f73cfafe411bd0d2c1289406e /libs/binder/IPCThreadState.cpp | |
parent | c02c9230ea8ac7cd9916053f6d49075989c1260a (diff) |
Remove need for libbinderthreadstate.
Instead of having this library, libbinder/libhwbinder can keep track of
stack pointers so that when they recurse, we know which one was visited
most recently.
As with the original implementation of libbinderthreadstate, this is
somewhat of a hack. An explanation of why this is and what to do instead
is added in CallerUtils.h.
Bug: 148692216
Test: libbinderthreadstateutils_test
Change-Id: Ief28663728fb8786b06bf9e72238052b9af81d87
Merged-In: Ief28663728fb8786b06bf9e72238052b9af81d87
Diffstat (limited to 'libs/binder/IPCThreadState.cpp')
-rw-r--r-- | libs/binder/IPCThreadState.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp index 4981d7a111..4dcd07a776 100644 --- a/libs/binder/IPCThreadState.cpp +++ b/libs/binder/IPCThreadState.cpp @@ -17,7 +17,6 @@ #define LOG_TAG "IPCThreadState" #include <binder/IPCThreadState.h> -#include <binderthreadstate/IPCThreadStateBase.h> #include <binder/Binder.h> #include <binder/BpBinder.h> @@ -803,6 +802,7 @@ status_t IPCThreadState::clearDeathNotification(int32_t handle, BpBinder* proxy) IPCThreadState::IPCThreadState() : mProcess(ProcessState::self()), + mServingStackPointer(nullptr), mWorkSource(kUnsetWorkSource), mPropagateWorkSource(false), mStrictModePolicy(0), @@ -813,7 +813,6 @@ IPCThreadState::IPCThreadState() clearCaller(); mIn.setDataCapacity(256); mOut.setDataCapacity(256); - mIPCThreadStateBase = IPCThreadStateBase::self(); } IPCThreadState::~IPCThreadState() @@ -1163,9 +1162,6 @@ status_t IPCThreadState::executeCommand(int32_t cmd) "Not enough command data for brTRANSACTION"); if (result != NO_ERROR) break; - //Record the fact that we're in a binder call. - mIPCThreadStateBase->pushCurrentState( - IPCThreadStateBase::CallState::BINDER); Parcel buffer; buffer.ipcSetDataReference( reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer), @@ -1173,6 +1169,9 @@ status_t IPCThreadState::executeCommand(int32_t cmd) reinterpret_cast<const binder_size_t*>(tr.data.ptr.offsets), tr.offsets_size/sizeof(binder_size_t), freeBuffer, this); + const void* origServingStackPointer = mServingStackPointer; + mServingStackPointer = &origServingStackPointer; // anything on the stack + const pid_t origPid = mCallingPid; const char* origSid = mCallingSid; const uid_t origUid = mCallingUid; @@ -1223,7 +1222,6 @@ status_t IPCThreadState::executeCommand(int32_t cmd) error = the_context_object->transact(tr.code, buffer, &reply, tr.flags); } - mIPCThreadStateBase->popCurrentState(); //ALOGI("<<<< TRANSACT from pid %d restore pid %d sid %s uid %d\n", // mCallingPid, origPid, (origSid ? origSid : "<N/A>"), origUid); @@ -1235,6 +1233,7 @@ status_t IPCThreadState::executeCommand(int32_t cmd) LOG_ONEWAY("NOT sending reply to %d!", mCallingPid); } + mServingStackPointer = origServingStackPointer; mCallingPid = origPid; mCallingSid = origSid; mCallingUid = origUid; @@ -1290,8 +1289,8 @@ status_t IPCThreadState::executeCommand(int32_t cmd) return result; } -bool IPCThreadState::isServingCall() const { - return mIPCThreadStateBase->getCurrentBinderCallState() == IPCThreadStateBase::CallState::BINDER; +const void* IPCThreadState::getServingStackPointer() const { + return mServingStackPointer; } void IPCThreadState::threadDestructor(void *st) |