diff options
Diffstat (limited to 'libs/binder/Binder.cpp')
-rw-r--r-- | libs/binder/Binder.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp index 693045e7f3..34b6ea5385 100644 --- a/libs/binder/Binder.cpp +++ b/libs/binder/Binder.cpp @@ -99,6 +99,32 @@ status_t IBinder::getExtension(sp<IBinder>* out) { return reply.readNullableStrongBinder(out); } +status_t IBinder::getDebugPid(pid_t* out) { + BBinder* local = this->localBinder(); + if (local != nullptr) { + *out = local->getDebugPid(); + return OK; + } + + BpBinder* proxy = this->remoteBinder(); + LOG_ALWAYS_FATAL_IF(proxy == nullptr); + + Parcel data; + Parcel reply; + status_t status = transact(DEBUG_PID_TRANSACTION, data, &reply); + if (status != OK) return status; + + int32_t pid; + status = reply.readInt32(&pid); + if (status != OK) return status; + + if (pid < 0 || pid > std::numeric_limits<pid_t>::max()) { + return BAD_VALUE; + } + *out = pid; + return OK; +} + // --------------------------------------------------------------------------- class BBinder::Extras @@ -152,6 +178,9 @@ status_t BBinder::transact( case EXTENSION_TRANSACTION: err = reply->writeStrongBinder(getExtension()); break; + case DEBUG_PID_TRANSACTION: + err = reply->writeInt32(getDebugPid()); + break; default: err = onTransact(code, data, reply, flags); break; @@ -250,6 +279,10 @@ sp<IBinder> BBinder::getExtension() { return e->mExtension; } +pid_t BBinder::getDebugPid() { + return getpid(); +} + void BBinder::setExtension(const sp<IBinder>& extension) { Extras* e = getOrCreateExtras(); e->mExtension = extension; |