binder经过interface_cast
在IInterface.h文件中
template
inline sp
{
return INTERFACE::asInterface(obj); //相当于return ICameraService::asInterface(obj);
}
然后来到ICameraService.h文件中,找到
DECLARE_meta_INTERFACE(CameraService); //点击这里进入
截图部分代码被替换后,最终形式
类似接口
#define DECLARE_meta_INTERFACE(CameraService)
static const android::String16 descriptor;
static android::sp
const android::sp& obj);
virtual const android::String16& getInterfaceDescriptor() const;
ICameraService();
virtual ~ICameraService();
类似接口的具体实现
#define IMPLEMENT_meta_INTERFACE(CameraService, NAME)
const android::String16 ICameraService::descriptor(NAME);
const android::String16&
ICameraService::getInterfaceDescriptor() const {
return ICameraService::descriptor;
}
android::sp
const android::sp& obj)
{
android::sp
if (obj != NULL) {
intr = static_cast
obj->queryLocalInterface(
ICameraService::descriptor).get());
if (intr == NULL) {
intr = new BpCameraService(obj);
}
}
return intr;
}
ICameraService::ICameraService() { }
ICameraService::~ICameraService() { }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)