Android IPC 通讯机制源码分析
2010-05-29 05:27:00 来源:WEB开发网if (error < NO_ERROR) reply.setError(error);//CameraService的onTransact函数
} else {
const status_t error = the_context_object->transact(tr.code, buffer, &reply, 0);
if (error < NO_ERROR) reply.setError(error);
}
//LOGI("<<<< TRANSACT from pid %d restore pid %d uid %d ",
// mCallingPid, origPid, origUid);
if ((tr.flags & TF_ONE_WAY) == 0) {
LOG_ONEWAY("Sending reply to %d!", mCallingPid);
sendReply(reply, 0);
} else {
LOG_ONEWAY("NOT sending reply to %d!", mCallingPid);
}
mCallingPid = origPid;
mCallingUid = origUid;
IF_LOG_TRANSACTIONS() {
TextOutput::Bundle _b(alog);
alog << "BC_REPLY thr " << (void*)pthread_self() << " / obj "
<< tr.target.ptr << ": " << indent << reply << dedent << endl;
}
..................................
}
break;
}
..................................
if ((tr.flags & TF_ONE_WAY) == 0) {
LOG_ONEWAY("Sending reply to %d!", mCallingPid);
sendReply(reply, 0); //通过binder kernel返回数据到caller进程这个过程大家
} else { //参照前面的叙述自己分析一下
LOG_ONEWAY("NOT sending reply to %d!", mCallingPid);
}
if (result != NO_ERROR) {
mLastError = result;
}
return result;
}
调用CameraService BBinder对象中的transact函数:
status_t BBinder::transact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
.....................
switch (code) {
case PING_TRANSACTION:
reply->writeInt32(pingBinder());
break;
更多精彩
赞助商链接