比方说下面的代码,变量mCamera实际上是通过 binder方式获取的远程服务端对象
// take a picture
status_t Camera::takePicture(int msgType)
{
ALOGV("takePicture: 0x%x", msgType);
sp <::android::hardware::ICamera> c = mCamera;
if (c == 0) return NO_INIT;
return c->takePicture(msgType);
}
那是不是意味着,调用的c->takePicture(msgType)时候,会指向类似下面的代码,因为c是代表远程对象,如果,要访问这个远程对象的方法,自然也要binder的方法进行获取,不知道,我这样说对不对?
// take a picture
status_t takePicture(int msgType)
{
ALOGV("takePicture: 0x%x", msgType);
Parcel data, reply;
data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
data.writeInt32(msgType);
remote()->transact(TAKE_PICTURE, data, &reply);
status_t ret = reply.readInt32();
return ret;
}