QService: Fix binder out-parcel position as well
If we call binder APIs from within the same process, the parcel's
positions are not reset at the caller and callee ends for out-parcel
and in-parcel respectively. Reset the outparcel position to zero as
well if the calling process is the same as the current one.
Change-Id: Ie770b0565e62772a4c8ab635cbeba49adab43b66
diff --git a/libqservice/QService.cpp b/libqservice/QService.cpp
index 12dd995..5d2e5de 100644
--- a/libqservice/QService.cpp
+++ b/libqservice/QService.cpp
@@ -59,11 +59,15 @@
status_t err = (status_t) FAILED_TRANSACTION;
IPCThreadState* ipc = IPCThreadState::self();
//Rewind parcel in case we're calling from the same process
- if (ipc->getCallingPid() == getpid())
+ bool sameProcess = (ipc->getCallingPid() == getpid());
+ if(sameProcess)
inParcel->setDataPosition(0);
if (mClient.get()) {
ALOGD_IF(QSERVICE_DEBUG, "Dispatching command: %d", command);
err = mClient->notifyCallback(command, inParcel, outParcel);
+ //Rewind parcel in case we're calling from the same process
+ if (sameProcess)
+ outParcel->setDataPosition(0);
}
return err;
}