Reland: "IPCThreadState: Add a public method to probe is a hwbinder
called is being served."
This reverts commit cc986a68b919f0ad8c624b5898d918a7930efffc.
Reason for revert: Dependencies which broke tests due to exclusion from
LOCAL_JNI_SHARED_LIBS have been added.
Change-Id: Iab2d8c65088744812301d980881a45ac2b119d0c
diff --git a/IPCThreadState.cpp b/IPCThreadState.cpp
index b275a7e..d97ad12 100644
--- a/IPCThreadState.cpp
+++ b/IPCThreadState.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "hw-IPCThreadState"
#include <hwbinder/IPCThreadState.h>
+#include <binderthreadstate/IPCThreadStateBase.h>
#include <hwbinder/Binder.h>
#include <hwbinder/BpHwBinder.h>
@@ -764,6 +765,7 @@
// TODO(b/67742352): remove this variable from the class
(void)mMyThreadId;
+ mIPCThreadStateBase = IPCThreadStateBase::self();
}
IPCThreadState::~IPCThreadState()
@@ -1114,6 +1116,9 @@
"Not enough command data for brTRANSACTION");
if (result != NO_ERROR) break;
+ // Record the fact that we're in a hwbinder call
+ mIPCThreadStateBase->pushCurrentState(
+ IPCThreadStateBase::CallState::HWBINDER);
Parcel buffer;
buffer.ipcSetDataReference(
reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer),
@@ -1177,6 +1182,7 @@
error = mContextObject->transact(tr.code, buffer, &reply, tr.flags, reply_callback);
}
+ mIPCThreadStateBase->popCurrentState();
if ((tr.flags & TF_ONE_WAY) == 0) {
if (!reply_sent) {
// Should have been a reply but there wasn't, so there
@@ -1249,6 +1255,11 @@
return result;
}
+bool IPCThreadState::isServingCall() const
+{
+ return mIPCThreadStateBase->getCurrentBinderCallState() == IPCThreadStateBase::CallState::HWBINDER;
+}
+
void IPCThreadState::threadDestructor(void *st)
{
IPCThreadState* const self = static_cast<IPCThreadState*>(st);