Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8b01617 authored by Martijn Coenen's avatar Martijn Coenen
Browse files

Callback elision for HIDL interfaces.

Test: mma, hidl_test
Bug: 31380743
Change-Id: Ic5390d49a9493d1180bdd8a15bc47e891637890e
parent 3131b6fc
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -165,10 +165,8 @@ Return<void> Bar::takeAMask(BitField bf, uint8_t first, const MyMask& second, ui
    return Void();
}

Return<void> Bar::haveAInterface(const sp<ISimple> &in,
            haveAInterface_cb _hidl_cb) {
    _hidl_cb(in);
    return Void();
Return<sp<ISimple>> Bar::haveAInterface(const sp<ISimple> &in) {
    return in;
}


+1 −2
Original line number Diff line number Diff line
@@ -71,8 +71,7 @@ struct Bar : public IBar {

    Return<void> takeAMask(BitField bf, uint8_t first, const MyMask& second, uint8_t third,
            takeAMask_cb _hidl_cb) override;
    Return<void> haveAInterface(const sp<ISimple> &in,
            haveAInterface_cb _hidl_cb) override;
    Return<sp<ISimple>> haveAInterface(const sp<ISimple> &in);

private:
    sp<IFoo> mFoo;
+8 −10
Original line number Diff line number Diff line
@@ -17,8 +17,7 @@ Fetcher::Fetcher() {
    CHECK(!mPrecious->isRemote());
}

template <typename CB>
Return<void> selectService(bool sendRemote, CB &_hidl_cb, sp<IChild> &local) {
sp<IChild> selectService(bool sendRemote, sp<IChild> &local) {
    sp<IChild> toSend;
    if (sendRemote) {
        toSend = IChild::getService("child");
@@ -29,21 +28,20 @@ Return<void> selectService(bool sendRemote, CB &_hidl_cb, sp<IChild> &local) {
        toSend = local;
    }
    LOG(INFO) << "SERVER(Fetcher) selectService returning " << toSend.get();
    _hidl_cb(toSend);
    return Void();
    return toSend;
}

// Methods from ::android::hardware::tests::inheritance::V1_0::IFetcher follow.
Return<void> Fetcher::getGrandparent(bool sendRemote, getGrandparent_cb _hidl_cb)  {
    return selectService(sendRemote, _hidl_cb, mPrecious);
Return<sp<IGrandparent>> Fetcher::getGrandparent(bool sendRemote)  {
    return selectService(sendRemote, mPrecious);
}

Return<void> Fetcher::getParent(bool sendRemote, getParent_cb _hidl_cb)  {
    return selectService(sendRemote, _hidl_cb, mPrecious);
Return<sp<IParent>> Fetcher::getParent(bool sendRemote)  {
    return selectService(sendRemote, mPrecious);
}

Return<void> Fetcher::getChild(bool sendRemote, getChild_cb _hidl_cb)  {
    return selectService(sendRemote, _hidl_cb, mPrecious);
Return<sp<IChild>> Fetcher::getChild(bool sendRemote)  {
    return selectService(sendRemote, mPrecious);
}

IFetcher* HIDL_FETCH_IFetcher(const char* /* name */) {
+3 −3
Original line number Diff line number Diff line
@@ -25,9 +25,9 @@ struct Fetcher : public IFetcher {
    Fetcher();

    // Methods from ::android::hardware::tests::inheritance::V1_0::IFetcher follow.
    Return<void> getGrandparent(bool sendRemote, getGrandparent_cb _hidl_cb)  override;
    Return<void> getParent(bool sendRemote, getParent_cb _hidl_cb)  override;
    Return<void> getChild(bool sendRemote, getChild_cb _hidl_cb)  override;
    Return<sp<IGrandparent>> getGrandparent(bool sendRemote)  override;
    Return<sp<IParent>> getParent(bool sendRemote)  override;
    Return<sp<IChild>> getChild(bool sendRemote)  override;

private:
    sp<IChild> mPrecious;