2016-10-18 18:44:17 -07:00
|
|
|
|
|
|
|
|
#define LOG_TAG "hidl_test"
|
|
|
|
|
|
|
|
|
|
#include "Fetcher.h"
|
|
|
|
|
#include <android-base/logging.h>
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
|
|
namespace android {
|
|
|
|
|
namespace hardware {
|
|
|
|
|
namespace tests {
|
|
|
|
|
namespace inheritance {
|
|
|
|
|
namespace V1_0 {
|
|
|
|
|
namespace implementation {
|
|
|
|
|
|
|
|
|
|
Fetcher::Fetcher() {
|
|
|
|
|
mPrecious = IChild::getService("local child", true);
|
|
|
|
|
CHECK(!mPrecious->isRemote());
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-02 15:19:53 +01:00
|
|
|
sp<IChild> selectService(bool sendRemote, sp<IChild> &local) {
|
2016-10-18 18:44:17 -07:00
|
|
|
sp<IChild> toSend;
|
|
|
|
|
if (sendRemote) {
|
|
|
|
|
toSend = IChild::getService("child");
|
|
|
|
|
if (!toSend->isRemote()) {
|
2016-11-02 16:50:01 -07:00
|
|
|
toSend = nullptr;
|
2016-10-18 18:44:17 -07:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
toSend = local;
|
|
|
|
|
}
|
2016-11-28 15:59:24 -08:00
|
|
|
LOG(INFO) << "SERVER(Fetcher) selectService returning " << toSend.get();
|
2017-01-02 15:19:53 +01:00
|
|
|
return toSend;
|
2016-10-18 18:44:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Methods from ::android::hardware::tests::inheritance::V1_0::IFetcher follow.
|
2017-01-02 15:19:53 +01:00
|
|
|
Return<sp<IGrandparent>> Fetcher::getGrandparent(bool sendRemote) {
|
|
|
|
|
return selectService(sendRemote, mPrecious);
|
2016-10-18 18:44:17 -07:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 15:19:53 +01:00
|
|
|
Return<sp<IParent>> Fetcher::getParent(bool sendRemote) {
|
|
|
|
|
return selectService(sendRemote, mPrecious);
|
2016-10-18 18:44:17 -07:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 15:19:53 +01:00
|
|
|
Return<sp<IChild>> Fetcher::getChild(bool sendRemote) {
|
|
|
|
|
return selectService(sendRemote, mPrecious);
|
2016-10-18 18:44:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IFetcher* HIDL_FETCH_IFetcher(const char* /* name */) {
|
|
|
|
|
return new Fetcher();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace implementation
|
|
|
|
|
} // namespace V1_0
|
|
|
|
|
} // namespace inheritance
|
|
|
|
|
} // namespace tests
|
|
|
|
|
} // namespace hardware
|
|
|
|
|
} // namespace android
|