1

次のように、remote()の実装を見つけようとしています。

remote()->transact(CODE, data, &reply);

あなたたちはそれがどこにあるか知っていますか?グーグルを検索することは無駄であることがわかりました。または、その関数が何をするかを知っているなら、それは私にとって大きな助けになるでしょう。どうもありがとう

更新:remote()は、BBinder、IBinder、BpBinder、またはIPCThreadState型のオブジェクトへのポインターを返すようですが、どちらかはわかりません。

4

1 に答える 1

4

の実装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ます。

于 2013-03-20T12:09:05.887 に答える