1 2 #define LOG_TAG "hidl_test" 3 4 #include "Fetcher.h" 5 #include <android-base/logging.h> 6 #include <inttypes.h> 7 8 namespace android { 9 namespace hardware { 10 namespace tests { 11 namespace inheritance { 12 namespace V1_0 { 13 namespace implementation { 14 Fetcher()15Fetcher::Fetcher() { 16 mPrecious = IChild::getService("local child", true); 17 CHECK(!mPrecious->isRemote()); 18 } 19 selectService(bool sendRemote,sp<IChild> & local)20sp<IChild> selectService(bool sendRemote, sp<IChild> &local) { 21 sp<IChild> toSend; 22 if (sendRemote) { 23 toSend = IChild::getService("child"); 24 if (!toSend->isRemote()) { 25 toSend = nullptr; 26 } 27 } else { 28 toSend = local; 29 } 30 LOG(INFO) << "SERVER(Fetcher) selectService returning " << toSend.get(); 31 return toSend; 32 } 33 34 // Methods from ::android::hardware::tests::inheritance::V1_0::IFetcher follow. getGrandparent(bool sendRemote)35Return<sp<IGrandparent>> Fetcher::getGrandparent(bool sendRemote) { 36 return selectService(sendRemote, mPrecious); 37 } 38 getParent(bool sendRemote)39Return<sp<IParent>> Fetcher::getParent(bool sendRemote) { 40 return selectService(sendRemote, mPrecious); 41 } 42 getChild(bool sendRemote)43Return<sp<IChild>> Fetcher::getChild(bool sendRemote) { 44 return selectService(sendRemote, mPrecious); 45 } 46 HIDL_FETCH_IFetcher(const char *)47IFetcher* HIDL_FETCH_IFetcher(const char* /* name */) { 48 return new Fetcher(); 49 } 50 51 } // namespace implementation 52 } // namespace V1_0 53 } // namespace inheritance 54 } // namespace tests 55 } // namespace hardware 56 } // namespace android 57