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
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;
return e->mExtension;
}
+pid_t BBinder::getDebugPid() {
+ return getpid();
+}
+
void BBinder::setExtension(const sp<IBinder>& extension) {
Extras* e = getOrCreateExtras();
e->mExtension = extension;
INTERFACE_TRANSACTION = B_PACK_CHARS('_', 'N', 'T', 'F'),
SYSPROPS_TRANSACTION = B_PACK_CHARS('_', 'S', 'P', 'R'),
EXTENSION_TRANSACTION = B_PACK_CHARS('_', 'E', 'X', 'T'),
+ DEBUG_PID_TRANSACTION = B_PACK_CHARS('_', 'P', 'I', 'D'),
// Corresponds to TF_ONE_WAY -- an asynchronous call.
FLAG_ONEWAY = 0x00000001
*/
status_t getExtension(sp<IBinder>* out);
+ /**
+ * Dump PID for a binder, for debugging.
+ */
+ status_t getDebugPid(pid_t* outPid);
+
// NOLINTNEXTLINE(google-default-arguments)
virtual status_t transact( uint32_t code,
const Parcel& data,