1
我试图找到的远程()的实现,如:实施远程()
remote()->transact(CODE, data, &reply);
你们是否知道它在哪里?搜索Google变得徒劳无功。 或者如果你知道这个功能的作用,那对我来说是一个很大的帮助。 非常感谢
更新:它似乎远程()将返回一个指向类型BBinder,IBinder,BpBinder,或IPCThreadState对象的指针,但我不知道哪一个。
我试图找到的远程()的实现,如:实施远程()
remote()->transact(CODE, data, &reply);
你们是否知道它在哪里?搜索Google变得徒劳无功。 或者如果你知道这个功能的作用,那对我来说是一个很大的帮助。 非常感谢
更新:它似乎远程()将返回一个指向类型BBinder,IBinder,BpBinder,或IPCThreadState对象的指针,但我不知道哪一个。
的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();
};
所有熟悉BpXXX
像BpCamera
,BpCameraService
从BpInterface
延伸。
remote()通常返回一个BpBinder。 – StarPinkER 2013-03-20 11:32:16