diff options
-rw-r--r-- | include/binder/IPCThreadState.h | 1 | ||||
-rw-r--r-- | libs/binder/IPCThreadState.cpp | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/include/binder/IPCThreadState.h b/include/binder/IPCThreadState.h index b54718f..3378d97 100644 --- a/include/binder/IPCThreadState.h +++ b/include/binder/IPCThreadState.h @@ -33,6 +33,7 @@ class IPCThreadState { public: static IPCThreadState* self(); + static IPCThreadState* selfOrNull(); // self(), but won't instantiate sp<ProcessState> process(); diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp index 13c58f0..95cfddf 100644 --- a/libs/binder/IPCThreadState.cpp +++ b/libs/binder/IPCThreadState.cpp @@ -318,6 +318,16 @@ restart: goto restart; } +IPCThreadState* IPCThreadState::selfOrNull() +{ + if (gHaveTLS) { + const pthread_key_t k = gTLS; + IPCThreadState* st = (IPCThreadState*)pthread_getspecific(k); + return st; + } + return NULL; +} + void IPCThreadState::shutdown() { gShutdown = true; |