の実装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、登録されたすべてのサービスを管理します。その仕組みについては、既存の回答を確認してください。getServiceからの場合、そのサービスを表すオブジェクトServiceManagerが返され、このオブジェクトが に配置されます。それがあなたのリモコンです。次に、それを使用して、実際の でバインダー トランザクションを開始できます。IBinderIBinderBpInterfaceBpInterfaceservice(BnInterface)
template<typename INTERFACE>
class BpInterface : public INTERFACE, public BpRefBase
{
public:
BpInterface(const sp<IBinder>& remote);
protected:
virtual IBinder* onAsBinder();
};
すべておなじみBpXXXのようBpCameraに、BpCameraServiceから拡張しBpInterfaceます。