1d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 2d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong#define LOG_TAG "hidl_test" 3d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 4d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong#include "Bar.h" 5a4842ace3979643da9d4edd17b32877f6db78f7eMark Salyzyn 6d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong#include <inttypes.h> 7d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 8a4842ace3979643da9d4edd17b32877f6db78f7eMark Salyzyn#include <log/log.h> 9a4842ace3979643da9d4edd17b32877f6db78f7eMark Salyzyn 10d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hongnamespace android { 11d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hongnamespace hardware { 12d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hongnamespace tests { 13d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hongnamespace bar { 14d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hongnamespace V1_0 { 15d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hongnamespace implementation { 16d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 17d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongBar::Bar() { 18d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong mFoo = IFoo::getService("", true); 19d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 20d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 21d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong// Methods from ::android::hardware::tests::foo::V1_0::IFoo follow. 223bcfa475e29a169e888215d9b52cda50fa645ca5Steven MorelandReturn<void> Bar::convertToBoolIfSmall(Discriminator d, const hidl_vec<Union>& u, 233bcfa475e29a169e888215d9b52cda50fa645ca5Steven Moreland convertToBoolIfSmall_cb _hidl_cb) { 243bcfa475e29a169e888215d9b52cda50fa645ca5Steven Moreland return mFoo->convertToBoolIfSmall(d, u, _hidl_cb); 253bcfa475e29a169e888215d9b52cda50fa645ca5Steven Moreland} 263bcfa475e29a169e888215d9b52cda50fa645ca5Steven Moreland 27d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::doThis(float param) { 28d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->doThis(param); 29d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 30d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 31d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<int32_t> Bar::doThatAndReturnSomething( 32d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong int64_t param) { 33d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->doThatAndReturnSomething(param); 34d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 35d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 36d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<double> Bar::doQuiteABit( 37d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong int32_t a, 38d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong int64_t b, 39d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong float c, 40d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong double d) { 41d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->doQuiteABit(a, b, c, d); 42d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 43d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 44d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::doSomethingElse( 45d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong const hidl_array<int32_t, 15> ¶m, doSomethingElse_cb _cb) { 46d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->doSomethingElse(param, _cb); 47d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 48d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 49d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::doStuffAndReturnAString( 50d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong doStuffAndReturnAString_cb _cb) { 51d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->doStuffAndReturnAString(_cb); 52d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 53d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 54d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::mapThisVector( 55d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong const hidl_vec<int32_t> ¶m, mapThisVector_cb _cb) { 56d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->mapThisVector(param, _cb); 57d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 58d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 59d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::callMe( 60d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong const sp<IFooCallback> &cb) { 61d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->callMe(cb); 62d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 63d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 64d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<Bar::SomeEnum> Bar::useAnEnum(SomeEnum param) { 65d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->useAnEnum(param); 66d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 67d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 68d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::haveAGooberVec(const hidl_vec<Goober>& param) { 69d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->haveAGooberVec(param); 70d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 71d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 72d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::haveAGoober(const Goober &g) { 73d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->haveAGoober(g); 74d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 75d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 76d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::haveAGooberArray(const hidl_array<Goober, 20> &lots) { 77d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->haveAGooberArray(lots); 78d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 79d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 80d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::haveATypeFromAnotherFile(const Abc &def) { 81d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->haveATypeFromAnotherFile(def); 82d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 83d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 84d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::haveSomeStrings( 85d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong const hidl_array<hidl_string, 3> &array, 86d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong haveSomeStrings_cb _cb) { 87d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->haveSomeStrings(array, _cb); 88d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 89d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 90d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::haveAStringVec( 91d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong const hidl_vec<hidl_string> &vector, 92d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong haveAStringVec_cb _cb) { 93d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->haveAStringVec(vector, _cb); 94d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 95d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 96d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::transposeMe( 97d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong const hidl_array<float, 3, 5> &in, transposeMe_cb _cb) { 98d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->transposeMe(in, _cb); 99d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 100d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 101d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::callingDrWho( 102d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong const MultiDimensional &in, callingDrWho_cb _hidl_cb) { 103d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->callingDrWho(in, _hidl_cb); 104d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 105d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 106d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::transpose(const StringMatrix5x3 &in, transpose_cb _hidl_cb) { 107d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->transpose(in, _hidl_cb); 108d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 109d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 110d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::transpose2( 111d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong const hidl_array<hidl_string, 5, 3> &in, transpose2_cb _hidl_cb) { 112d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->transpose2(in, _hidl_cb); 113d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 114d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 115d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::sendVec( 116d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong const hidl_vec<uint8_t> &data, sendVec_cb _hidl_cb) { 117d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->sendVec(data, _hidl_cb); 118d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 119d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 120d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::sendVecVec(sendVecVec_cb _hidl_cb) { 121d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return mFoo->sendVecVec(_hidl_cb); 122d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 123d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 124847b14511a973be167af465491226a86492a10c6Andreas HuberReturn<void> Bar::haveAVectorOfInterfaces( 125847b14511a973be167af465491226a86492a10c6Andreas Huber const hidl_vec<sp<ISimple> > &in, 126847b14511a973be167af465491226a86492a10c6Andreas Huber haveAVectorOfInterfaces_cb _hidl_cb) { 127847b14511a973be167af465491226a86492a10c6Andreas Huber _hidl_cb(in); 128847b14511a973be167af465491226a86492a10c6Andreas Huber 129847b14511a973be167af465491226a86492a10c6Andreas Huber return Void(); 130847b14511a973be167af465491226a86492a10c6Andreas Huber} 131847b14511a973be167af465491226a86492a10c6Andreas Huber 132847b14511a973be167af465491226a86492a10c6Andreas HuberReturn<void> Bar::haveAVectorOfGenericInterfaces( 133ebcc3328e8bd0415514751853a5de8010cc8c6baYifan Hong const hidl_vec<sp<android::hidl::base::V1_0::IBase> > &in, 134847b14511a973be167af465491226a86492a10c6Andreas Huber haveAVectorOfGenericInterfaces_cb _hidl_cb) { 1350dbb9903cd8b414ca16f6b4bb379bfcadecea0a5Martijn Coenen _hidl_cb(in); 136847b14511a973be167af465491226a86492a10c6Andreas Huber 137847b14511a973be167af465491226a86492a10c6Andreas Huber return Void(); 138847b14511a973be167af465491226a86492a10c6Andreas Huber} 139847b14511a973be167af465491226a86492a10c6Andreas Huber 140ebfa633103e4efbe4c39c8abf906ae597a1d7a5bYifan HongReturn<void> Bar::createMyHandle(createMyHandle_cb _hidl_cb) { 141ebfa633103e4efbe4c39c8abf906ae597a1d7a5bYifan Hong return mFoo->createMyHandle(_hidl_cb); 142ebfa633103e4efbe4c39c8abf906ae597a1d7a5bYifan Hong} 143ebfa633103e4efbe4c39c8abf906ae597a1d7a5bYifan Hong 144ebfa633103e4efbe4c39c8abf906ae597a1d7a5bYifan HongReturn<void> Bar::createHandles(uint32_t size, createHandles_cb _hidl_cb) { 145ebfa633103e4efbe4c39c8abf906ae597a1d7a5bYifan Hong return mFoo->createHandles(size, _hidl_cb); 146ebfa633103e4efbe4c39c8abf906ae597a1d7a5bYifan Hong} 147ebfa633103e4efbe4c39c8abf906ae597a1d7a5bYifan Hong 148ebfa633103e4efbe4c39c8abf906ae597a1d7a5bYifan HongReturn<void> Bar::closeHandles() { 149ebfa633103e4efbe4c39c8abf906ae597a1d7a5bYifan Hong return mFoo->closeHandles(); 150ebfa633103e4efbe4c39c8abf906ae597a1d7a5bYifan Hong} 151ebfa633103e4efbe4c39c8abf906ae597a1d7a5bYifan Hong 152b7307d5c8acedec902c2a39de62065b2dbb9ae1aMartijn CoenenReturn<void> Bar::echoNullInterface(const sp<IFooCallback> &cb, echoNullInterface_cb _hidl_cb) { 153b7307d5c8acedec902c2a39de62065b2dbb9ae1aMartijn Coenen return mFoo->echoNullInterface(cb, _hidl_cb); 154b7307d5c8acedec902c2a39de62065b2dbb9ae1aMartijn Coenen} 155b7307d5c8acedec902c2a39de62065b2dbb9ae1aMartijn Coenen 156d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong// Methods from ::android::hardware::tests::bar::V1_0::IBar follow. 157d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongReturn<void> Bar::thisIsNew() { 158d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong ALOGI("SERVER(Bar) thisIsNew"); 159d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 160d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return Void(); 161d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 162d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 163403161ab73ad230ab27321a570b1c41d3b1af4a2Martijn CoenenReturn<void> Bar::expectNullHandle(const hidl_handle& h, const Abc& xyz, expectNullHandle_cb _hidl_cb) { 164403161ab73ad230ab27321a570b1c41d3b1af4a2Martijn Coenen ALOGI("SERVER(Bar) h = %p, xyz.z = %p", h.getNativeHandle(), xyz.z.getNativeHandle()); 165688bb1e2c619d159bda8796b347279da70d67418Yifan Hong _hidl_cb(h == nullptr, xyz.z == nullptr); 166688bb1e2c619d159bda8796b347279da70d67418Yifan Hong return Void(); 167688bb1e2c619d159bda8796b347279da70d67418Yifan Hong} 168688bb1e2c619d159bda8796b347279da70d67418Yifan Hong 169e7ce822b9660a897075ec4d3c352e1e7f7f787f3Yifan HongReturn<void> Bar::takeAMask(BitField bf, uint8_t first, const MyMask& second, uint8_t third, 170e7ce822b9660a897075ec4d3c352e1e7f7f787f3Yifan Hong takeAMask_cb _hidl_cb) { 171e7ce822b9660a897075ec4d3c352e1e7f7f787f3Yifan Hong _hidl_cb(bf, bf | first, second.value & bf, (bf | bf) & third); 172e7ce822b9660a897075ec4d3c352e1e7f7f787f3Yifan Hong return Void(); 173e7ce822b9660a897075ec4d3c352e1e7f7f787f3Yifan Hong} 174e7ce822b9660a897075ec4d3c352e1e7f7f787f3Yifan Hong 175e8b01617138898377df134525912ab1df753fe2cMartijn CoenenReturn<sp<ISimple>> Bar::haveAInterface(const sp<ISimple> &in) { 176e8b01617138898377df134525912ab1df753fe2cMartijn Coenen return in; 17787cc71c9fa394643389224e27d48ca1a1bee8ac7Yifan Hong} 17887cc71c9fa394643389224e27d48ca1a1bee8ac7Yifan Hong 17987cc71c9fa394643389224e27d48ca1a1bee8ac7Yifan Hong 180d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan HongIBar* HIDL_FETCH_IBar(const char* /* name */) { 181d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong return new Bar(); 182d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} 183d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong 184d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} // namespace implementation 185d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} // namespace V1_0 186d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} // namespace bar 187d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} // namespace tests 188d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} // namespace hardware 189d5b5b2eceaf4ac1469825ff47fe17e403f2ed400Yifan Hong} // namespace android 190