我正在尝试查找remote()的实现,如下所示:
remote()->transact(CODE, data, &reply);你们知道它在哪吗?在谷歌上搜索结果是徒劳的。或者,如果你知道这个函数是做什么的,它会对我有很大的帮助。非常感谢
更新: remote()似乎会返回一个指向BBinder、IBinder、BpBinder或IPCThreadState类型的对象的指针,但我不确定是哪一个。
发布于 2013-03-20 20:09:06
remote的实现很简单:
class BpRefBase : public virtual RefBase
{
protected:
BpRefBase(const sp<IBinder>& o);
virtual ~BpRefBase();
virtual void onFirstRef();
virtual void onLastStrongRef(const void* id);
virtual bool onIncStrongAttempted(uint32_t flags, const void* id);
inline IBinder* remote() { return mRemote; }
inline IBinder* remote() const { return mRemote; }
private:
BpRefBase(const BpRefBase& o);
BpRefBase& operator=(const BpRefBase& o);
IBinder* const mRemote;
RefBase::weakref_type* mRefs;
volatile int32_t mState;
};ServiceManager将管理所有已注册的服务,有关其工作原理,请查看an existing answer。当您从ServiceManager执行getService操作时,它将返回一个表示该服务的IBinder对象,然后此IBinder对象将被放入BpInterface中。那是你的遥控器。然后,您可以使用该BpInterface启动具有实际service(BnInterface)的绑定器事务。
template<typename INTERFACE>
class BpInterface : public INTERFACE, public BpRefBase
{
public:
BpInterface(const sp<IBinder>& remote);
protected:
virtual IBinder* onAsBinder();
};像BpCamera一样熟悉的BpXXX,BpCameraService都是从BpInterface扩展而来的。
https://stackoverflow.com/questions/15520098
复制相似问题