Loading PREUPLOAD.cfg +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp cmds/idlcli/ include/input/ libs/binder/ndk/ libs/binderthreadstate/ libs/graphicsenv/ libs/gui/ libs/input/ Loading libs/binder/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -138,7 +138,6 @@ cc_library { "liblog", "libcutils", "libutils", "libbinderthreadstate", ], header_libs: [ Loading libs/binder/IPCThreadState.cpp +7 −8 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ #define LOG_TAG "IPCThreadState" #include <binder/IPCThreadState.h> #include <binderthreadstate/IPCThreadStateBase.h> #include <binder/Binder.h> #include <binder/BpBinder.h> Loading Loading @@ -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), Loading @@ -813,7 +813,6 @@ IPCThreadState::IPCThreadState() clearCaller(); mIn.setDataCapacity(256); mOut.setDataCapacity(256); mIPCThreadStateBase = IPCThreadStateBase::self(); } IPCThreadState::~IPCThreadState() Loading Loading @@ -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), Loading @@ -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; Loading Loading @@ -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); Loading @@ -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; Loading Loading @@ -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) Loading libs/binder/TEST_MAPPING +3 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,9 @@ }, { "name": "aidl_lazy_test" }, { "name": "libbinderthreadstateutils_test" } ] } libs/binder/include/binder/IPCThreadState.h +6 −27 Original line number Diff line number Diff line Loading @@ -29,8 +29,6 @@ typedef int uid_t; // --------------------------------------------------------------------------- namespace android { class IPCThreadStateBase; class IPCThreadState { public: Loading Loading @@ -113,31 +111,12 @@ public: // Service manager registration void setTheContextObject(sp<BBinder> obj); // Is this thread currently serving a binder call. This method // returns true if while traversing backwards from the function call // stack for this thread, we encounter a function serving a binder // call before encountering a hwbinder call / hitting the end of the // call stack. // Eg: If thread T1 went through the following call pattern // 1) T1 receives and executes hwbinder call H1. // 2) While handling H1, T1 makes binder call B1. // 3) The handler of B1, calls into T1 with a callback B2. // If isServingCall() is called during H1 before 3), this method // will return false, else true. // // ---- // | B2 | ---> While callback B2 is being handled, during 3). // ---- // | H1 | ---> While H1 is being handled. // ---- // Fig: Thread Call stack while handling B2 // WARNING: DO NOT USE THIS API // // This is since after 3), while traversing the thread call stack, // we hit a binder call before a hwbinder call / end of stack. This // method may be typically used to determine whether to use // hardware::IPCThreadState methods or IPCThreadState methods to // infer information about thread state. bool isServingCall() const; // Returns a pointer to the stack from the last time a transaction // was initiated by the kernel. Used to compare when making nested // calls between multiple different transports. const void* getServingStackPointer() const; // The work source represents the UID of the process we should attribute the transaction // to. We use -1 to specify that the work source was not set using #setWorkSource. Loading Loading @@ -181,6 +160,7 @@ private: Parcel mIn; Parcel mOut; status_t mLastError; const void* mServingStackPointer; pid_t mCallingPid; const char* mCallingSid; uid_t mCallingUid; Loading @@ -191,7 +171,6 @@ private: bool mPropagateWorkSource; int32_t mStrictModePolicy; int32_t mLastTransactionBinderFlags; IPCThreadStateBase *mIPCThreadStateBase; ProcessState::CallRestriction mCallRestriction; }; Loading Loading
PREUPLOAD.cfg +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp cmds/idlcli/ include/input/ libs/binder/ndk/ libs/binderthreadstate/ libs/graphicsenv/ libs/gui/ libs/input/ Loading
libs/binder/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -138,7 +138,6 @@ cc_library { "liblog", "libcutils", "libutils", "libbinderthreadstate", ], header_libs: [ Loading
libs/binder/IPCThreadState.cpp +7 −8 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ #define LOG_TAG "IPCThreadState" #include <binder/IPCThreadState.h> #include <binderthreadstate/IPCThreadStateBase.h> #include <binder/Binder.h> #include <binder/BpBinder.h> Loading Loading @@ -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), Loading @@ -813,7 +813,6 @@ IPCThreadState::IPCThreadState() clearCaller(); mIn.setDataCapacity(256); mOut.setDataCapacity(256); mIPCThreadStateBase = IPCThreadStateBase::self(); } IPCThreadState::~IPCThreadState() Loading Loading @@ -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), Loading @@ -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; Loading Loading @@ -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); Loading @@ -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; Loading Loading @@ -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) Loading
libs/binder/TEST_MAPPING +3 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,9 @@ }, { "name": "aidl_lazy_test" }, { "name": "libbinderthreadstateutils_test" } ] }
libs/binder/include/binder/IPCThreadState.h +6 −27 Original line number Diff line number Diff line Loading @@ -29,8 +29,6 @@ typedef int uid_t; // --------------------------------------------------------------------------- namespace android { class IPCThreadStateBase; class IPCThreadState { public: Loading Loading @@ -113,31 +111,12 @@ public: // Service manager registration void setTheContextObject(sp<BBinder> obj); // Is this thread currently serving a binder call. This method // returns true if while traversing backwards from the function call // stack for this thread, we encounter a function serving a binder // call before encountering a hwbinder call / hitting the end of the // call stack. // Eg: If thread T1 went through the following call pattern // 1) T1 receives and executes hwbinder call H1. // 2) While handling H1, T1 makes binder call B1. // 3) The handler of B1, calls into T1 with a callback B2. // If isServingCall() is called during H1 before 3), this method // will return false, else true. // // ---- // | B2 | ---> While callback B2 is being handled, during 3). // ---- // | H1 | ---> While H1 is being handled. // ---- // Fig: Thread Call stack while handling B2 // WARNING: DO NOT USE THIS API // // This is since after 3), while traversing the thread call stack, // we hit a binder call before a hwbinder call / end of stack. This // method may be typically used to determine whether to use // hardware::IPCThreadState methods or IPCThreadState methods to // infer information about thread state. bool isServingCall() const; // Returns a pointer to the stack from the last time a transaction // was initiated by the kernel. Used to compare when making nested // calls between multiple different transports. const void* getServingStackPointer() const; // The work source represents the UID of the process we should attribute the transaction // to. We use -1 to specify that the work source was not set using #setWorkSource. Loading Loading @@ -181,6 +160,7 @@ private: Parcel mIn; Parcel mOut; status_t mLastError; const void* mServingStackPointer; pid_t mCallingPid; const char* mCallingSid; uid_t mCallingUid; Loading @@ -191,7 +171,6 @@ private: bool mPropagateWorkSource; int32_t mStrictModePolicy; int32_t mLastTransactionBinderFlags; IPCThreadStateBase *mIPCThreadStateBase; ProcessState::CallRestriction mCallRestriction; }; Loading