diff --git a/Android.bp b/Android.bp index 2350c5f403..2c113d5747 100644 --- a/Android.bp +++ b/Android.bp @@ -6,12 +6,15 @@ subdirs = [ "nfc/1.0/default", "radio/1.0", "tests/bar/1.0", + "tests/bar/1.0/default", "tests/baz/1.0", "tests/expression/1.0", "tests/foo/1.0", + "tests/foo/1.0/default", "tests/libhwbinder/1.0", "tests/msgq/1.0", "tests/pointer/1.0", + "tests/pointer/1.0/default", "wifi/1.0", "wifi/supplicant/1.0", ] diff --git a/tests/bar/1.0/default/Android.bp b/tests/bar/1.0/default/Android.bp new file mode 100644 index 0000000000..0d47001c81 --- /dev/null +++ b/tests/bar/1.0/default/Android.bp @@ -0,0 +1,21 @@ + + +cc_library_shared { + name: "android.hardware.tests.bar@1.0-impl", + relative_install_path: "hw", + srcs: [ + "Bar.cpp", + "ImportTypes.cpp", + ], + + shared_libs: [ + "libbase", + "libhidl", + "libhwbinder", + "liblog", + "libutils", + "android.hardware.tests.foo@1.0", + "android.hardware.tests.bar@1.0", + ], + +} diff --git a/tests/bar/1.0/default/Bar.cpp b/tests/bar/1.0/default/Bar.cpp new file mode 100644 index 0000000000..44338028d0 --- /dev/null +++ b/tests/bar/1.0/default/Bar.cpp @@ -0,0 +1,137 @@ + +#define LOG_TAG "hidl_test" + +#include "Bar.h" +#include +#include + +namespace android { +namespace hardware { +namespace tests { +namespace bar { +namespace V1_0 { +namespace implementation { + +Bar::Bar() { + mFoo = IFoo::getService("", true); +} + +// Methods from ::android::hardware::tests::foo::V1_0::IFoo follow. +Return Bar::doThis(float param) { + return mFoo->doThis(param); +} + +Return Bar::doThis(uint32_t param) { + return mFoo->doThis(param); +} + +Return Bar::doThatAndReturnSomething( + int64_t param) { + return mFoo->doThatAndReturnSomething(param); +} + +Return Bar::doQuiteABit( + int32_t a, + int64_t b, + float c, + double d) { + return mFoo->doQuiteABit(a, b, c, d); +} + +Return Bar::doSomethingElse( + const hidl_array ¶m, doSomethingElse_cb _cb) { + return mFoo->doSomethingElse(param, _cb); +} + +Return Bar::doStuffAndReturnAString( + doStuffAndReturnAString_cb _cb) { + return mFoo->doStuffAndReturnAString(_cb); +} + +Return Bar::mapThisVector( + const hidl_vec ¶m, mapThisVector_cb _cb) { + return mFoo->mapThisVector(param, _cb); +} + +Return Bar::callMe( + const sp &cb) { + return mFoo->callMe(cb); +} + +Return Bar::useAnEnum(SomeEnum param) { + return mFoo->useAnEnum(param); +} + +Return Bar::haveAGooberVec(const hidl_vec& param) { + return mFoo->haveAGooberVec(param); +} + +Return Bar::haveAGoober(const Goober &g) { + return mFoo->haveAGoober(g); +} + +Return Bar::haveAGooberArray(const hidl_array &lots) { + return mFoo->haveAGooberArray(lots); +} + +Return Bar::haveATypeFromAnotherFile(const Abc &def) { + return mFoo->haveATypeFromAnotherFile(def); +} + +Return Bar::haveSomeStrings( + const hidl_array &array, + haveSomeStrings_cb _cb) { + return mFoo->haveSomeStrings(array, _cb); +} + +Return Bar::haveAStringVec( + const hidl_vec &vector, + haveAStringVec_cb _cb) { + return mFoo->haveAStringVec(vector, _cb); +} + +Return Bar::transposeMe( + const hidl_array &in, transposeMe_cb _cb) { + return mFoo->transposeMe(in, _cb); +} + +Return Bar::callingDrWho( + const MultiDimensional &in, callingDrWho_cb _hidl_cb) { + return mFoo->callingDrWho(in, _hidl_cb); +} + +Return Bar::transpose(const StringMatrix5x3 &in, transpose_cb _hidl_cb) { + return mFoo->transpose(in, _hidl_cb); +} + +Return Bar::transpose2( + const hidl_array &in, transpose2_cb _hidl_cb) { + return mFoo->transpose2(in, _hidl_cb); +} + +Return Bar::sendVec( + const hidl_vec &data, sendVec_cb _hidl_cb) { + return mFoo->sendVec(data, _hidl_cb); +} + +Return Bar::sendVecVec(sendVecVec_cb _hidl_cb) { + return mFoo->sendVecVec(_hidl_cb); +} + +// Methods from ::android::hardware::tests::bar::V1_0::IBar follow. +Return Bar::thisIsNew() { + ALOGI("SERVER(Bar) thisIsNew"); + + return Void(); +} + +IBar* HIDL_FETCH_IBar(const char* /* name */) { + return new Bar(); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace bar +} // namespace tests +} // namespace hardware +} // namespace android diff --git a/tests/bar/1.0/default/Bar.h b/tests/bar/1.0/default/Bar.h new file mode 100644 index 0000000000..58d9f9a1ba --- /dev/null +++ b/tests/bar/1.0/default/Bar.h @@ -0,0 +1,68 @@ +#ifndef HIDL_GENERATED_android_hardware_tests_bar_V1_0_Bar_H_ +#define HIDL_GENERATED_android_hardware_tests_bar_V1_0_Bar_H_ + +#include +#include + +#include +namespace android { +namespace hardware { +namespace tests { +namespace bar { +namespace V1_0 { +namespace implementation { + +using ::android::hardware::tests::bar::V1_0::IBar; +using ::android::hardware::tests::foo::V1_0::Abc; +using ::android::hardware::tests::foo::V1_0::IFoo; +using ::android::hardware::tests::foo::V1_0::IFooCallback; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::hardware::hidl_vec; +using ::android::hardware::hidl_string; +using ::android::sp; + +struct Bar : public IBar { + + Bar(); + + // Methods from ::android::hardware::tests::foo::V1_0::IFoo follow. + virtual Return doThis(float param) override; + virtual Return doThis(uint32_t param) override; + virtual Return doThatAndReturnSomething(int64_t param) override; + virtual Return doQuiteABit(int32_t a, int64_t b, float c, double d) override; + virtual Return doSomethingElse(const hidl_array& param, doSomethingElse_cb _hidl_cb) override; + virtual Return doStuffAndReturnAString(doStuffAndReturnAString_cb _hidl_cb) override; + virtual Return mapThisVector(const hidl_vec& param, mapThisVector_cb _hidl_cb) override; + virtual Return callMe(const sp& cb) override; + virtual Return useAnEnum(IFoo::SomeEnum zzz) override; + virtual Return haveAGooberVec(const hidl_vec& param) override; + virtual Return haveAGoober(const IFoo::Goober& g) override; + virtual Return haveAGooberArray(const hidl_array& lots) override; + virtual Return haveATypeFromAnotherFile(const Abc& def) override; + virtual Return haveSomeStrings(const hidl_array& array, haveSomeStrings_cb _hidl_cb) override; + virtual Return haveAStringVec(const hidl_vec& vector, haveAStringVec_cb _hidl_cb) override; + virtual Return transposeMe(const hidl_array& in, transposeMe_cb _hidl_cb) override; + virtual Return callingDrWho(const IFoo::MultiDimensional& in, callingDrWho_cb _hidl_cb) override; + virtual Return transpose(const IFoo::StringMatrix5x3& in, transpose_cb _hidl_cb) override; + virtual Return transpose2(const hidl_array& in, transpose2_cb _hidl_cb) override; + virtual Return sendVec(const hidl_vec& data, sendVec_cb _hidl_cb) override; + virtual Return sendVecVec(sendVecVec_cb _hidl_cb) override; + + // Methods from ::android::hardware::tests::bar::V1_0::IBar follow. + Return thisIsNew() override; + +private: + sp mFoo; +}; + +extern "C" IBar* HIDL_FETCH_IBar(const char* name); + +} // namespace implementation +} // namespace V1_0 +} // namespace bar +} // namespace tests +} // namespace hardware +} // namespace android + +#endif // HIDL_GENERATED_android_hardware_tests_bar_V1_0_Bar_H_ diff --git a/tests/bar/1.0/default/ImportTypes.cpp b/tests/bar/1.0/default/ImportTypes.cpp new file mode 100644 index 0000000000..06ce4e5dfd --- /dev/null +++ b/tests/bar/1.0/default/ImportTypes.cpp @@ -0,0 +1,21 @@ +#include "ImportTypes.h" + +namespace android { +namespace hardware { +namespace tests { +namespace bar { +namespace V1_0 { +namespace implementation { + +// Methods from ::android::hardware::tests::bar::V1_0::IImportTypes follow. + +IImportTypes* HIDL_FETCH_IImportTypes(const char* /* name */) { + return new ImportTypes(); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace bar +} // namespace tests +} // namespace hardware +} // namespace android diff --git a/tests/bar/1.0/default/ImportTypes.h b/tests/bar/1.0/default/ImportTypes.h new file mode 100644 index 0000000000..b43be70bfd --- /dev/null +++ b/tests/bar/1.0/default/ImportTypes.h @@ -0,0 +1,36 @@ +#ifndef HIDL_GENERATED_android_hardware_tests_bar_V1_0_ImportTypes_H_ +#define HIDL_GENERATED_android_hardware_tests_bar_V1_0_ImportTypes_H_ + +#include +#include + +#include +namespace android { +namespace hardware { +namespace tests { +namespace bar { +namespace V1_0 { +namespace implementation { + +using ::android::hardware::tests::bar::V1_0::IImportTypes; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::hardware::hidl_vec; +using ::android::hardware::hidl_string; +using ::android::sp; + +struct ImportTypes : public IImportTypes { + // Methods from ::android::hardware::tests::bar::V1_0::IImportTypes follow. + +}; + +extern "C" IImportTypes* HIDL_FETCH_IImportTypes(const char* name); + +} // namespace implementation +} // namespace V1_0 +} // namespace bar +} // namespace tests +} // namespace hardware +} // namespace android + +#endif // HIDL_GENERATED_android_hardware_tests_bar_V1_0_ImportTypes_H_ diff --git a/tests/foo/1.0/default/Android.bp b/tests/foo/1.0/default/Android.bp new file mode 100644 index 0000000000..a2acd14a2c --- /dev/null +++ b/tests/foo/1.0/default/Android.bp @@ -0,0 +1,22 @@ + + +cc_library_shared { + name: "android.hardware.tests.foo@1.0-impl", + relative_install_path: "hw", + srcs: [ + "Foo.cpp", + "FooCallback.cpp", + "MyTypes.cpp", + "TheirTypes.cpp", + ], + + shared_libs: [ + "libbase", + "libhidl", + "libhwbinder", + "liblog", + "libutils", + "android.hardware.tests.foo@1.0", + ], + +} diff --git a/tests/foo/1.0/default/Foo.cpp b/tests/foo/1.0/default/Foo.cpp new file mode 100644 index 0000000000..81aa78b3b0 --- /dev/null +++ b/tests/foo/1.0/default/Foo.cpp @@ -0,0 +1,409 @@ + +#define LOG_TAG "hidl_test" + +#include "Foo.h" +#include "FooCallback.h" +#include +#include +#include + +namespace android { +namespace hardware { +namespace tests { +namespace foo { +namespace V1_0 { +namespace implementation { + +// Methods from ::android::hardware::tests::foo::V1_0::IFoo follow. +Return Foo::doThis(float param) { + ALOGI("SERVER(Foo) doThis(%.2f)", param); + + return Void(); +} + +Return Foo::doThis(uint32_t param) { + ALOGI("SERVER(Foo) doThis (int) (%d)", param); + return Void(); +} + +Return Foo::doThatAndReturnSomething( + int64_t param) { + LOG(INFO) << "SERVER(Foo) doThatAndReturnSomething(" << param << ")"; + + return 666; +} + +Return Foo::doQuiteABit( + int32_t a, + int64_t b, + float c, + double d) { + LOG(INFO) << "SERVER(Foo) doQuiteABit(" + << a + << ", " + << b + << ", " + << c + << ", " + << d + << ")"; + + return 666.5; +} + +Return Foo::doSomethingElse( + const hidl_array ¶m, doSomethingElse_cb _cb) { + ALOGI("SERVER(Foo) doSomethingElse(...)"); + + hidl_array result; + for (size_t i = 0; i < 15; ++i) { + result[i] = 2 * param[i]; + result[15 + i] = param[i]; + } + result[30] = 1; + result[31] = 2; + + _cb(result); + + return Void(); +} + +Return Foo::doStuffAndReturnAString( + doStuffAndReturnAString_cb _cb) { + ALOGI("SERVER(Foo) doStuffAndReturnAString"); + + hidl_string s; + s = "Hello, world"; + + _cb(s); + + return Void(); +} + +Return Foo::mapThisVector( + const hidl_vec ¶m, mapThisVector_cb _cb) { + ALOGI("SERVER(Foo) mapThisVector"); + + hidl_vec out; + out.resize(param.size()); + + for (size_t i = 0; i < out.size(); ++i) { + out[i] = param[i] * 2; + } + + _cb(out); + + return Void(); +} + +Return Foo::callMe( + const sp &cb) { + ALOGI("SERVER(Foo) callMe %p", cb.get()); + + if (cb != NULL) { + + hidl_array c; + ALOGI("SERVER(Foo) callMe %p calling IFooCallback::heyItsYou, " \ + "should return immediately", cb.get()); + c[0] = systemTime(); + cb->heyItsYou(cb); + c[0] = systemTime() - c[0]; + ALOGI("SERVER(Foo) callMe %p calling IFooCallback::heyItsYou " \ + "returned after %" PRId64 "ns", cb.get(), c[0]); + + ALOGI("SERVER(Foo) callMe %p calling IFooCallback::heyItsYouIsntIt, " \ + "should block for %" PRId64 " seconds", cb.get(), + FooCallback::DELAY_S); + c[1] = systemTime(); + bool answer = cb->heyItsYouIsntIt(cb); + c[1] = systemTime() - c[1]; + ALOGI("SERVER(Foo) callMe %p IFooCallback::heyItsYouIsntIt " \ + "responded with %d after %" PRId64 "ns", cb.get(), answer, c[1]); + + ALOGI("SERVER(Foo) callMe %p calling " \ + "IFooCallback::heyItsTheMeaningOfLife, " \ + "should return immediately ", cb.get()); + c[2] = systemTime(); + cb->heyItsTheMeaningOfLife(42); + c[2] = systemTime() - c[2]; + ALOGI("SERVER(Foo) callMe %p After call to " \ + "IFooCallback::heyItsTheMeaningOfLife " \ + "responded after %" PRId64 "ns", cb.get(), c[2]); + + ALOGI("SERVER(Foo) callMe %p calling IFooCallback::youBlockedMeFor " \ + "to report times", cb.get()); + cb->youBlockedMeFor(c); + ALOGI("SERVER(Foo) callMe %p After call to " \ + "IFooCallback::heyYouBlockedMeFor", cb.get()); + } + + return Void(); +} + +Return Foo::useAnEnum(SomeEnum param) { + ALOGI("SERVER(Foo) useAnEnum %d", (int)param); + + return SomeEnum::goober; +} + +Return Foo::haveAGooberVec(const hidl_vec& param) { + ALOGI("SERVER(Foo) haveAGooberVec ¶m = %p", ¶m); + + return Void(); +} + +Return Foo::haveAGoober(const Goober &g) { + ALOGI("SERVER(Foo) haveaGoober g=%p", &g); + + return Void(); +} + +Return Foo::haveAGooberArray(const hidl_array & /* lots */) { + ALOGI("SERVER(Foo) haveAGooberArray"); + + return Void(); +} + +Return Foo::haveATypeFromAnotherFile(const Abc &def) { + ALOGI("SERVER(Foo) haveATypeFromAnotherFile def=%p", &def); + + return Void(); +} + +Return Foo::haveSomeStrings( + const hidl_array &array, + haveSomeStrings_cb _cb) { + ALOGI("SERVER(Foo) haveSomeStrings([\"%s\", \"%s\", \"%s\"])", + array[0].c_str(), + array[1].c_str(), + array[2].c_str()); + + hidl_array result; + result[0] = "Hello"; + result[1] = "World"; + + _cb(result); + + return Void(); +} + +Return Foo::haveAStringVec( + const hidl_vec &vector, + haveAStringVec_cb _cb) { + ALOGI("SERVER(Foo) haveAStringVec([\"%s\", \"%s\", \"%s\"])", + vector[0].c_str(), + vector[1].c_str(), + vector[2].c_str()); + + hidl_vec result; + result.resize(2); + + result[0] = "Hello"; + result[1] = "World"; + + _cb(result); + + return Void(); +} + +// NOTE: duplicated code in hidl_test +using std::to_string; + +static std::string to_string(const IFoo::StringMatrix5x3 &M); +static std::string to_string(const IFoo::StringMatrix3x5 &M); +static std::string to_string(const hidl_string &s); + +template +static std::string to_string(const T *elems, size_t n) { + std::string out; + out = "["; + for (size_t i = 0; i < n; ++i) { + if (i > 0) { + out += ", "; + } + out += to_string(elems[i]); + } + out += "]"; + + return out; +} + +template +static std::string to_string(const hidl_array &array) { + return to_string(&array[0], SIZE); +} + +template +static std::string to_string(const hidl_array &array) { + std::string out; + out = "["; + for (size_t i = 0; i < SIZE1; ++i) { + if (i > 0) { + out += ", "; + } + + out += "["; + for (size_t j = 0; j < SIZE2; ++j) { + if (j > 0) { + out += ", "; + } + + out += to_string(array[i][j]); + } + out += "]"; + } + out += "]"; + + return out; +} + +template +static std::string to_string(const hidl_vec &vec) { + return to_string(&vec[0], vec.size()); +} + +static std::string to_string(const IFoo::StringMatrix5x3 &M) { + return to_string(M.s); +} + +static std::string to_string(const IFoo::StringMatrix3x5 &M) { + return to_string(M.s); +} + +static std::string to_string(const hidl_string &s) { + return std::string("'") + s.c_str() + "'"; +} + +Return Foo::transposeMe( + const hidl_array &in, transposeMe_cb _cb) { + ALOGI("SERVER(Foo) transposeMe(%s)", to_string(in).c_str()); + + hidl_array out; + for (size_t i = 0; i < 5; ++i) { + for (size_t j = 0; j < 3; ++j) { + out[i][j] = in[j][i]; + } + } + + ALOGI("SERVER(Foo) transposeMe returning %s", to_string(out).c_str()); + + _cb(out); + + return Void(); +} +// end duplicated code + +static std::string QuuxToString(const IFoo::Quux &val) { + std::string s; + + s = "Quux(first='"; + s += val.first.c_str(); + s += "', last='"; + s += val.last.c_str(); + s += "')"; + + return s; +} + +static std::string MultiDimensionalToString(const IFoo::MultiDimensional &val) { + std::string s; + + s += "MultiDimensional("; + + s += "quuxMatrix=["; + + size_t k = 0; + for (size_t i = 0; i < 5; ++i) { + if (i > 0) { + s += ", "; + } + + s += "["; + for (size_t j = 0; j < 3; ++j, ++k) { + if (j > 0) { + s += ", "; + } + + s += QuuxToString(val.quuxMatrix[i][j]); + } + } + s += "]"; + + s += ")"; + + return s; +} + +Return Foo::callingDrWho( + const MultiDimensional &in, callingDrWho_cb _hidl_cb) { + ALOGI("SERVER(Foo) callingDrWho(%s)", MultiDimensionalToString(in).c_str()); + + MultiDimensional out; + for (size_t i = 0; i < 5; ++i) { + for (size_t j = 0; j < 3; ++j) { + out.quuxMatrix[i][j].first = in.quuxMatrix[4 - i][2 - j].last; + out.quuxMatrix[i][j].last = in.quuxMatrix[4 - i][2 - j].first; + } + } + + _hidl_cb(out); + + return Void(); +} + +Return Foo::transpose(const StringMatrix5x3 &in, transpose_cb _hidl_cb) { + LOG(INFO) << "SERVER(Foo) transpose " << to_string(in); + + StringMatrix3x5 out; + for (size_t i = 0; i < 3; ++i) { + for (size_t j = 0; j < 5; ++j) { + out.s[i][j] = in.s[j][i]; + } + } + + _hidl_cb(out); + + return Void(); +} + +Return Foo::transpose2( + const hidl_array &in, transpose2_cb _hidl_cb) { + LOG(INFO) << "SERVER(Foo) transpose2 " << to_string(in); + + hidl_array out; + for (size_t i = 0; i < 3; ++i) { + for (size_t j = 0; j < 5; ++j) { + out[i][j] = in[j][i]; + } + } + + _hidl_cb(out); + + return Void(); +} + +Return Foo::sendVec( + const hidl_vec &data, sendVec_cb _hidl_cb) { + _hidl_cb(data); + + return Void(); +} + +Return Foo::sendVecVec(sendVecVec_cb _hidl_cb) { + hidl_vec> data; + _hidl_cb(data); + + return Void(); +} + + +IFoo* HIDL_FETCH_IFoo(const char* /* name */) { + return new Foo(); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace foo +} // namespace tests +} // namespace hardware +} // namespace android diff --git a/tests/foo/1.0/default/Foo.h b/tests/foo/1.0/default/Foo.h new file mode 100644 index 0000000000..00a29f5db5 --- /dev/null +++ b/tests/foo/1.0/default/Foo.h @@ -0,0 +1,59 @@ +#ifndef HIDL_GENERATED_android_hardware_tests_foo_V1_0_Foo_H_ +#define HIDL_GENERATED_android_hardware_tests_foo_V1_0_Foo_H_ + +#include +#include + +#include +namespace android { +namespace hardware { +namespace tests { +namespace foo { +namespace V1_0 { +namespace implementation { + +using ::android::hardware::tests::foo::V1_0::Abc; +using ::android::hardware::tests::foo::V1_0::IFoo; +using ::android::hardware::tests::foo::V1_0::IFooCallback; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::hardware::hidl_vec; +using ::android::hardware::hidl_string; +using ::android::sp; + +struct Foo : public IFoo { + // Methods from ::android::hardware::tests::foo::V1_0::IFoo follow. + virtual Return doThis(float param) override; + virtual Return doThis(uint32_t param) override; + virtual Return doThatAndReturnSomething(int64_t param) override; + virtual Return doQuiteABit(int32_t a, int64_t b, float c, double d) override; + virtual Return doSomethingElse(const hidl_array& param, doSomethingElse_cb _hidl_cb) override; + virtual Return doStuffAndReturnAString(doStuffAndReturnAString_cb _hidl_cb) override; + virtual Return mapThisVector(const hidl_vec& param, mapThisVector_cb _hidl_cb) override; + virtual Return callMe(const sp& cb) override; + virtual Return useAnEnum(IFoo::SomeEnum zzz) override; + virtual Return haveAGooberVec(const hidl_vec& param) override; + virtual Return haveAGoober(const IFoo::Goober& g) override; + virtual Return haveAGooberArray(const hidl_array& lots) override; + virtual Return haveATypeFromAnotherFile(const Abc& def) override; + virtual Return haveSomeStrings(const hidl_array& array, haveSomeStrings_cb _hidl_cb) override; + virtual Return haveAStringVec(const hidl_vec& vector, haveAStringVec_cb _hidl_cb) override; + virtual Return transposeMe(const hidl_array& in, transposeMe_cb _hidl_cb) override; + virtual Return callingDrWho(const IFoo::MultiDimensional& in, callingDrWho_cb _hidl_cb) override; + virtual Return transpose(const IFoo::StringMatrix5x3& in, transpose_cb _hidl_cb) override; + virtual Return transpose2(const hidl_array& in, transpose2_cb _hidl_cb) override; + virtual Return sendVec(const hidl_vec& data, sendVec_cb _hidl_cb) override; + virtual Return sendVecVec(sendVecVec_cb _hidl_cb) override; + +}; + +extern "C" IFoo* HIDL_FETCH_IFoo(const char* name); + +} // namespace implementation +} // namespace V1_0 +} // namespace foo +} // namespace tests +} // namespace hardware +} // namespace android + +#endif // HIDL_GENERATED_android_hardware_tests_foo_V1_0_Foo_H_ diff --git a/tests/foo/1.0/default/FooCallback.cpp b/tests/foo/1.0/default/FooCallback.cpp new file mode 100644 index 0000000000..08d3ce08a3 --- /dev/null +++ b/tests/foo/1.0/default/FooCallback.cpp @@ -0,0 +1,86 @@ +#include "FooCallback.h" +#include +#include + +namespace android { +namespace hardware { +namespace tests { +namespace foo { +namespace V1_0 { +namespace implementation { + +Return FooCallback::heyItsYou( + const sp &_cb) { + nsecs_t start = systemTime(); + ALOGI("SERVER(FooCallback) heyItsYou cb = %p", _cb.get()); + mLock.lock(); + invokeInfo[0].invoked = true; + invokeInfo[0].timeNs = systemTime() - start; + mCond.signal(); + mLock.unlock(); + return Void(); +} + +Return FooCallback::heyItsYouIsntIt(const sp &_cb) { + nsecs_t start = systemTime(); + ALOGI("SERVER(FooCallback) heyItsYouIsntIt cb = %p sleeping for %" PRId64 " seconds", _cb.get(), DELAY_S); + sleep(DELAY_S); + ALOGI("SERVER(FooCallback) heyItsYouIsntIt cb = %p responding", _cb.get()); + mLock.lock(); + invokeInfo[1].invoked = true; + invokeInfo[1].timeNs = systemTime() - start; + mCond.signal(); + mLock.unlock(); + return true; +} + +Return FooCallback::heyItsTheMeaningOfLife(uint8_t tmol) { + nsecs_t start = systemTime(); + ALOGI("SERVER(FooCallback) heyItsTheMeaningOfLife = %d sleeping for %" PRId64 " seconds", tmol, DELAY_S); + sleep(DELAY_S); + ALOGI("SERVER(FooCallback) heyItsTheMeaningOfLife = %d done sleeping", tmol); + mLock.lock(); + invokeInfo[2].invoked = true; + invokeInfo[2].timeNs = systemTime() - start; + mCond.signal(); + mLock.unlock(); + return Void(); +} + +Return FooCallback::reportResults(int64_t ns, reportResults_cb cb) { + ALOGI("SERVER(FooCallback) reportResults(%" PRId64 " seconds)", nanoseconds_to_seconds(ns)); + nsecs_t leftToWaitNs = ns; + mLock.lock(); + while (!(invokeInfo[0].invoked && invokeInfo[1].invoked && invokeInfo[2].invoked) && + leftToWaitNs > 0) { + nsecs_t start = systemTime(); + ::android::status_t rc = mCond.waitRelative(mLock, leftToWaitNs); + if (rc != ::android::OK) { + ALOGI("SERVER(FooCallback)::reportResults(%" PRId64 " ns) Condition::waitRelative(%" PRId64 ") returned error (%d)", ns, leftToWaitNs, rc); + break; + } + ALOGI("SERVER(FooCallback)::reportResults(%" PRId64 " ns) Condition::waitRelative was signalled", ns); + leftToWaitNs -= systemTime() - start; + } + mLock.unlock(); + cb(leftToWaitNs, invokeInfo); + return Void(); +} + +Return FooCallback::youBlockedMeFor(const hidl_array &ns) { + for (size_t i = 0; i < 3; i++) { + invokeInfo[i].callerBlockedNs = ns[i]; + } + return Void(); +} + +IFooCallback* HIDL_FETCH_IFooCallback(const char* /* name */) { + return new FooCallback(); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace foo +} // namespace tests +} // namespace hardware +} // namespace android diff --git a/tests/foo/1.0/default/FooCallback.h b/tests/foo/1.0/default/FooCallback.h new file mode 100644 index 0000000000..6c284ca6b3 --- /dev/null +++ b/tests/foo/1.0/default/FooCallback.h @@ -0,0 +1,52 @@ +#ifndef HIDL_GENERATED_android_hardware_tests_foo_V1_0_FooCallback_H_ +#define HIDL_GENERATED_android_hardware_tests_foo_V1_0_FooCallback_H_ + +#include +#include +#include + +#include +#include +namespace android { +namespace hardware { +namespace tests { +namespace foo { +namespace V1_0 { +namespace implementation { + +using ::android::hardware::tests::foo::V1_0::IFooCallback; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::hardware::hidl_vec; +using ::android::hardware::hidl_string; +using ::android::sp; + +struct FooCallback : public IFooCallback { + FooCallback() : mLock{}, mCond{} {} + // Methods from ::android::hardware::tests::foo::V1_0::IFooCallback follow. + Return heyItsYou(const sp& cb) override; + Return heyItsYouIsntIt(const sp& cb) override; + Return heyItsTheMeaningOfLife(uint8_t tmol) override; + Return reportResults(int64_t ns, reportResults_cb _hidl_cb) override; + Return youBlockedMeFor(const hidl_array& callerBlockedInfo) override; + + static constexpr nsecs_t DELAY_S = 1; + static constexpr nsecs_t DELAY_NS = seconds_to_nanoseconds(DELAY_S); + static constexpr nsecs_t TOLERANCE_NS = milliseconds_to_nanoseconds(10); + static constexpr nsecs_t ONEWAY_TOLERANCE_NS = milliseconds_to_nanoseconds(1); + + hidl_array invokeInfo; + Mutex mLock; + Condition mCond; +}; + +extern "C" IFooCallback* HIDL_FETCH_IFooCallback(const char* name); + +} // namespace implementation +} // namespace V1_0 +} // namespace foo +} // namespace tests +} // namespace hardware +} // namespace android + +#endif // HIDL_GENERATED_android_hardware_tests_foo_V1_0_FooCallback_H_ diff --git a/tests/foo/1.0/default/MyTypes.cpp b/tests/foo/1.0/default/MyTypes.cpp new file mode 100644 index 0000000000..0d1a4581b3 --- /dev/null +++ b/tests/foo/1.0/default/MyTypes.cpp @@ -0,0 +1,21 @@ +#include "MyTypes.h" + +namespace android { +namespace hardware { +namespace tests { +namespace foo { +namespace V1_0 { +namespace implementation { + +// Methods from ::android::hardware::tests::foo::V1_0::IMyTypes follow. + +IMyTypes* HIDL_FETCH_IMyTypes(const char* /* name */) { + return new MyTypes(); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace foo +} // namespace tests +} // namespace hardware +} // namespace android diff --git a/tests/foo/1.0/default/MyTypes.h b/tests/foo/1.0/default/MyTypes.h new file mode 100644 index 0000000000..6e9a3e12d0 --- /dev/null +++ b/tests/foo/1.0/default/MyTypes.h @@ -0,0 +1,36 @@ +#ifndef HIDL_GENERATED_android_hardware_tests_foo_V1_0_MyTypes_H_ +#define HIDL_GENERATED_android_hardware_tests_foo_V1_0_MyTypes_H_ + +#include +#include + +#include +namespace android { +namespace hardware { +namespace tests { +namespace foo { +namespace V1_0 { +namespace implementation { + +using ::android::hardware::tests::foo::V1_0::IMyTypes; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::hardware::hidl_vec; +using ::android::hardware::hidl_string; +using ::android::sp; + +struct MyTypes : public IMyTypes { + // Methods from ::android::hardware::tests::foo::V1_0::IMyTypes follow. + +}; + +extern "C" IMyTypes* HIDL_FETCH_IMyTypes(const char* name); + +} // namespace implementation +} // namespace V1_0 +} // namespace foo +} // namespace tests +} // namespace hardware +} // namespace android + +#endif // HIDL_GENERATED_android_hardware_tests_foo_V1_0_MyTypes_H_ diff --git a/tests/foo/1.0/default/TheirTypes.cpp b/tests/foo/1.0/default/TheirTypes.cpp new file mode 100644 index 0000000000..0f678f0aef --- /dev/null +++ b/tests/foo/1.0/default/TheirTypes.cpp @@ -0,0 +1,21 @@ +#include "TheirTypes.h" + +namespace android { +namespace hardware { +namespace tests { +namespace foo { +namespace V1_0 { +namespace implementation { + +// Methods from ::android::hardware::tests::foo::V1_0::ITheirTypes follow. + +ITheirTypes* HIDL_FETCH_ITheirTypes(const char* /* name */) { + return new TheirTypes(); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace foo +} // namespace tests +} // namespace hardware +} // namespace android diff --git a/tests/foo/1.0/default/TheirTypes.h b/tests/foo/1.0/default/TheirTypes.h new file mode 100644 index 0000000000..24ade70a05 --- /dev/null +++ b/tests/foo/1.0/default/TheirTypes.h @@ -0,0 +1,36 @@ +#ifndef HIDL_GENERATED_android_hardware_tests_foo_V1_0_TheirTypes_H_ +#define HIDL_GENERATED_android_hardware_tests_foo_V1_0_TheirTypes_H_ + +#include +#include + +#include +namespace android { +namespace hardware { +namespace tests { +namespace foo { +namespace V1_0 { +namespace implementation { + +using ::android::hardware::tests::foo::V1_0::ITheirTypes; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::hardware::hidl_vec; +using ::android::hardware::hidl_string; +using ::android::sp; + +struct TheirTypes : public ITheirTypes { + // Methods from ::android::hardware::tests::foo::V1_0::ITheirTypes follow. + +}; + +extern "C" ITheirTypes* HIDL_FETCH_ITheirTypes(const char* name); + +} // namespace implementation +} // namespace V1_0 +} // namespace foo +} // namespace tests +} // namespace hardware +} // namespace android + +#endif // HIDL_GENERATED_android_hardware_tests_foo_V1_0_TheirTypes_H_ diff --git a/tests/pointer/1.0/default/Android.bp b/tests/pointer/1.0/default/Android.bp new file mode 100644 index 0000000000..cee6c91285 --- /dev/null +++ b/tests/pointer/1.0/default/Android.bp @@ -0,0 +1,20 @@ + + +cc_library_shared { + name: "android.hardware.tests.pointer@1.0-impl", + relative_install_path: "hw", + srcs: [ + "Graph.cpp", + "Pointer.cpp", + ], + + shared_libs: [ + "libbase", + "libhidl", + "libhwbinder", + "liblog", + "libutils", + "android.hardware.tests.pointer@1.0", + ], + +} diff --git a/tests/pointer/1.0/default/Graph.cpp b/tests/pointer/1.0/default/Graph.cpp new file mode 100644 index 0000000000..a43df810e0 --- /dev/null +++ b/tests/pointer/1.0/default/Graph.cpp @@ -0,0 +1,116 @@ +#include "Graph.h" +#include + +#define PUSH_ERROR_IF(__cond__) if(__cond__) { errors.push_back(std::to_string(__LINE__) + ": " + #__cond__); } + +namespace android { +namespace hardware { +namespace tests { +namespace pointer { +namespace V1_0 { +namespace implementation { + +static void simpleGraph(IGraph::Graph& g) { + g.nodes.resize(2); + g.edges.resize(1); + g.nodes[0].data = 10; + g.nodes[1].data = 20; + g.edges[0].left = &g.nodes[0]; + g.edges[0].right = &g.nodes[1]; +} + +static bool isSimpleGraph(const IGraph::Graph &g) { + if(g.nodes.size() != 2) return false; + if(g.edges.size() != 1) return false; + if(g.nodes[0].data != 10) return false; + if(g.nodes[1].data != 20) return false; + if(g.edges[0].left != &g.nodes[0]) return false; + if(g.edges[0].right != &g.nodes[1]) return false; + return true; +} + +static void logSimpleGraph(const char *prefix, const IGraph::Graph& g) { + ALOGI("%s Graph %p, %d nodes, %d edges", prefix, &g, (int)g.nodes.size(), (int)g.edges.size()); + std::ostringstream os; + for(size_t i = 0; i < g.nodes.size(); i++) + os << &g.nodes[i] << " = " << g.nodes[i].data << ", "; + ALOGI("%s Nodes: [%s]", prefix, os.str().c_str()); + os.str(""); + os.clear(); + for(size_t i = 0; i < g.edges.size(); i++) + os << g.edges[i].left << " -> " << g.edges[i].right << ", "; + ALOGI("%s Edges: [%s]", prefix, os.str().c_str()); +} + +// Methods from ::android::hardware::tests::pointer::V1_0::IGraph follow. +Return Graph::passAGraph(const IGraph::Graph& g) { + ALOGI("SERVER(Graph) passAGraph start."); + PUSH_ERROR_IF(!isSimpleGraph(g)); + // logSimpleGraph("SERVER(Graph) passAGraph:", g); + return Void(); +} + +Return Graph::giveAGraph(giveAGraph_cb _cb) { + IGraph::Graph g; + simpleGraph(g); + _cb(g); + return Void(); +} + +Return Graph::passANode(const IGraph::Node& n) { + PUSH_ERROR_IF(n.data != 10); + return Void(); +} + +Return Graph::passTwoGraphs(IGraph::Graph const* g1, IGraph::Graph const* g2) { + PUSH_ERROR_IF(g1 != g2); + PUSH_ERROR_IF(!isSimpleGraph(*g1)); + logSimpleGraph("SERVER(Graph): passTwoGraphs", *g2); + return Void(); +} + +Return Graph::passAGamma(const IGraph::Gamma& c) { + if(c.a_ptr == nullptr && c.b_ptr == nullptr) + return Void(); + ALOGI("SERVER(Graph) passAGamma received c.a = %p, c.b = %p, c.a->s = %p, c.b->s = %p", + c.a_ptr, c.b_ptr, c.a_ptr->s_ptr, c.b_ptr->s_ptr); + ALOGI("SERVER(Graph) passAGamma received data %d, %d", + (int)c.a_ptr->s_ptr->data, (int)c.b_ptr->s_ptr->data); + PUSH_ERROR_IF(c.a_ptr->s_ptr != c.b_ptr->s_ptr); + return Void(); +} +Return Graph::passASimpleRef(const IGraph::Alpha * a_ptr) { + ALOGI("SERVER(Graph) passASimpleRef received %d", a_ptr->s_ptr->data); + PUSH_ERROR_IF(a_ptr->s_ptr->data != 500); + return Void(); +} +Return Graph::passASimpleRefS(const IGraph::Theta * s_ptr) { + ALOGI("SERVER(Graph) passASimpleRefS received %d @ %p", s_ptr->data, s_ptr); + PUSH_ERROR_IF(s_ptr->data == 10); + return Void(); +} +Return Graph::giveASimpleRef(giveASimpleRef_cb _cb) { + IGraph::Theta s; s.data = 500; + IGraph::Alpha a; a.s_ptr = &s; + _cb(&a); + return Void(); +} + +Return Graph::getErrors() { + if(!errors.empty()) { + for(const auto& e : errors) + ALOGW("SERVER(Graph) error: %s", e.c_str()); + } + return errors.size(); +} + +IGraph* HIDL_FETCH_IGraph(const char* /* name */) { + return new Graph(); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace pointer +} // namespace tests +} // namespace hardware +} // namespace android diff --git a/tests/pointer/1.0/default/Graph.h b/tests/pointer/1.0/default/Graph.h new file mode 100644 index 0000000000..cbd5a8adcf --- /dev/null +++ b/tests/pointer/1.0/default/Graph.h @@ -0,0 +1,47 @@ +#ifndef HIDL_GENERATED_android_hardware_tests_pointer_V1_0_Graph_H_ +#define HIDL_GENERATED_android_hardware_tests_pointer_V1_0_Graph_H_ + +#include +#include + +#include +namespace android { +namespace hardware { +namespace tests { +namespace pointer { +namespace V1_0 { +namespace implementation { + +using ::android::hardware::tests::pointer::V1_0::IGraph; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::hardware::hidl_vec; +using ::android::hardware::hidl_string; +using ::android::sp; + +struct Graph : public IGraph { + // Methods from ::android::hardware::tests::pointer::V1_0::IGraph follow. + Return passANode(const IGraph::Node& n) override; + Return passAGraph(const IGraph::Graph& g) override; + Return passTwoGraphs(::android::hardware::tests::pointer::V1_0::IGraph::Graph const* g1, ::android::hardware::tests::pointer::V1_0::IGraph::Graph const* g2) override; + Return giveAGraph(giveAGraph_cb _hidl_cb) override; + Return passAGamma(const IGraph::Gamma& c) override; + Return passASimpleRef(::android::hardware::tests::pointer::V1_0::IGraph::Alpha const* a) override; + Return passASimpleRefS(::android::hardware::tests::pointer::V1_0::IGraph::Theta const* s) override; + Return giveASimpleRef(giveASimpleRef_cb _hidl_cb) override; + Return getErrors() override; +private: + std::vector errors; + +}; + +extern "C" IGraph* HIDL_FETCH_IGraph(const char* name); + +} // namespace implementation +} // namespace V1_0 +} // namespace pointer +} // namespace tests +} // namespace hardware +} // namespace android + +#endif // HIDL_GENERATED_android_hardware_tests_pointer_V1_0_Graph_H_ diff --git a/tests/pointer/1.0/default/Pointer.cpp b/tests/pointer/1.0/default/Pointer.cpp new file mode 100644 index 0000000000..d7cd772873 --- /dev/null +++ b/tests/pointer/1.0/default/Pointer.cpp @@ -0,0 +1,19 @@ +#include "Pointer.h" + +namespace android { +namespace hardware { +namespace tests { +namespace pointer { +namespace V1_0 { +namespace implementation { + +IPointer* HIDL_FETCH_IPointer(const char* /* name */) { + return new Pointer(); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace pointer +} // namespace tests +} // namespace hardware +} // namespace android diff --git a/tests/pointer/1.0/default/Pointer.h b/tests/pointer/1.0/default/Pointer.h new file mode 100644 index 0000000000..1579aea235 --- /dev/null +++ b/tests/pointer/1.0/default/Pointer.h @@ -0,0 +1,348 @@ +#ifndef HIDL_GENERATED_android_hardware_tests_pointer_V1_0_Pointer_H_ +#define HIDL_GENERATED_android_hardware_tests_pointer_V1_0_Pointer_H_ + +#include +#include +#include + +#include + +// TODO move to Pointer.cpp so that I won't have weird macros in headers +#define PUSH_ERROR_IF(__cond__) if(__cond__) { errors.push_back(std::to_string(__LINE__) + ": " + #__cond__); } + +namespace android { +namespace hardware { +namespace tests { +namespace pointer { +namespace V1_0 { +namespace implementation { + +using ::android::hardware::tests::pointer::V1_0::IPointer; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::hardware::hidl_vec; +using ::android::hardware::hidl_string; +using ::android::sp; + +struct Pointer : public IPointer { +private: + std::vector errors; +public: + Return getErrors() { + if(!errors.empty()) { + for(const auto& e : errors) + ALOGW("SERVER(Pointer) error: %s", e.c_str()); + } + return errors.size(); + } + Return foo1(const IPointer::Sam& s, IPointer::Sam const* s_ptr) override { + PUSH_ERROR_IF(!(&s == s_ptr)); + return Void(); + } + Return foo2(const IPointer::Sam& s, const IPointer::Ada& a) override { + PUSH_ERROR_IF(!(&s == a.s_ptr)); + return Void(); + } + Return foo3(const IPointer::Sam& s, const IPointer::Ada& a, const IPointer::Bob& b) override { + PUSH_ERROR_IF(!(&a == b.a_ptr && a.s_ptr == b.s_ptr && a.s_ptr == &s)); + return Void(); + } + Return foo4(IPointer::Sam const* s_ptr) override { + PUSH_ERROR_IF(!(s_ptr->data == 500)); + return Void(); + } + Return foo5(const IPointer::Ada& a, const IPointer::Bob& b) override { + PUSH_ERROR_IF(!(a.s_ptr == b.s_ptr && b.a_ptr == &a)); + return Void(); + } + Return foo6(IPointer::Ada const* a_ptr) override { + PUSH_ERROR_IF(!(a_ptr->s_ptr->data == 500)); + return Void(); + } + Return foo7(IPointer::Ada const* a_ptr, IPointer::Bob const* b_ptr) override { + PUSH_ERROR_IF(!(a_ptr->s_ptr == b_ptr->s_ptr && a_ptr == b_ptr->a_ptr && a_ptr->s_ptr->data == 500)); + return Void(); + } + Return foo8(const IPointer::Dom& d) override { + const IPointer::Cin& c = d.c; + PUSH_ERROR_IF(&c.a != c.b_ptr->a_ptr); + PUSH_ERROR_IF(c.a.s_ptr != c.b_ptr->s_ptr); + PUSH_ERROR_IF(c.a.s_ptr->data != 500); + return Void(); + } + Return foo9(::android::hardware::hidl_string const* str_ref) override { + ALOGI("SERVER(Pointer) foo9 got string @ %p (size = %ld) \"%s\"", + str_ref->c_str(), + (unsigned long) str_ref->size(), str_ref->c_str()); + PUSH_ERROR_IF(!(strcmp(str_ref->c_str(), "meowmeowmeow") == 0)); + return Void(); + } + Return foo10(const ::android::hardware::hidl_vec& s_ptr_vec) override { + PUSH_ERROR_IF(s_ptr_vec[0]->data != 500); + if(s_ptr_vec.size() != 5) { + errors.push_back("foo10: s_ptr_vec.size() != 5"); + return Void(); + } + for(size_t i = 0; i < s_ptr_vec.size(); i++) + PUSH_ERROR_IF(s_ptr_vec[0] != s_ptr_vec[i]); + return Void(); + } + Return foo11(::android::hardware::hidl_vec const* s_vec_ptr) override { + if(s_vec_ptr->size() != 5) { + errors.push_back("foo11: s_vec_ptr->size() != 5"); + return Void(); + } + for(size_t i = 0; i < 5; i++) + PUSH_ERROR_IF((*s_vec_ptr)[i].data != 500); + return Void(); + } + Return foo12(hidl_array const* s_array_ref) override { + for(size_t i = 0; i < 5; ++i) + PUSH_ERROR_IF((*s_array_ref)[i].data != 500); + return Void(); + } + Return foo13(const hidl_array& s_ref_array) override { + PUSH_ERROR_IF(s_ref_array[0]->data != 500) + for(size_t i = 0; i < 5; i++) + PUSH_ERROR_IF(s_ref_array[i] != s_ref_array[0]) + return Void(); + } + Return foo14(IPointer::Sam const* const* const* s_3ptr) override { + PUSH_ERROR_IF(!((***s_3ptr).data == 500)) + return Void(); + } + Return foo15(int32_t const* const* const* i_3ptr) override { + PUSH_ERROR_IF(!((***i_3ptr) == 500)) + return Void(); + } + + Return foo16(const IPointer::Ptr& p) override { + PUSH_ERROR_IF((*p.array_ptr)[0].s_ptr->data != 500); + for(size_t i = 0; i < 5; i++) PUSH_ERROR_IF((*p.array_ptr)[i].s_ptr != (*p.array_ptr)[0].s_ptr); + PUSH_ERROR_IF(*(p.int_ptr) != 500); + for(size_t i = 0; i < 5; i++) PUSH_ERROR_IF((*p.int_array_ptr)[i] != 500); + for(size_t i = 0; i < 5; i++) PUSH_ERROR_IF(p.int_ptr_array[i] != p.int_ptr); + PUSH_ERROR_IF(p.a_ptr_vec.size() != 5); + PUSH_ERROR_IF(p.a_ptr_vec[0]->s_ptr->data != 500); + for(size_t i = 0; i < 5; i++) PUSH_ERROR_IF(p.a_ptr_vec[i]->s_ptr != p.a_ptr_vec[0]->s_ptr); + PUSH_ERROR_IF(strcmp(p.str_ref->c_str(), "meowmeowmeow") != 0); + PUSH_ERROR_IF(p.a_vec_ptr->size() != 5); + PUSH_ERROR_IF((*p.a_vec_ptr)[0].s_ptr->data != 500); + for(size_t i = 0; i < 5; i++) PUSH_ERROR_IF((*p.a_vec_ptr)[i].s_ptr != (*p.a_vec_ptr)[0].s_ptr); + return Void(); + }; + Return foo17(IPointer::Ptr const* p) override { + return foo16(*p); + }; + Return foo18(hidl_string const* str_ref, hidl_string const* str_ref2, const hidl_string& str) override { + PUSH_ERROR_IF(&str != str_ref); + PUSH_ERROR_IF(str_ref != str_ref2); + PUSH_ERROR_IF(strcmp(str.c_str(), "meowmeowmeow") != 0) + return Void(); + }; + Return foo19( + hidl_vec const* a_vec_ref, + const hidl_vec& a_vec, + hidl_vec const* a_vec_ref2) { + PUSH_ERROR_IF(&a_vec != a_vec_ref); + PUSH_ERROR_IF(a_vec_ref2 != a_vec_ref); + PUSH_ERROR_IF(a_vec.size() != 5); + PUSH_ERROR_IF(a_vec[0].s_ptr->data != 500); + for(size_t i = 0; i < 5; i++) + PUSH_ERROR_IF(a_vec[i].s_ptr != a_vec[0].s_ptr); + return Void(); + }; + + Return foo20(const hidl_vec&) override { + return Void(); + } + Return foo21(hidl_array const* a_array_ptr) override { + const hidl_array& a_array = *a_array_ptr; + PUSH_ERROR_IF(a_array[0][0][0].s_ptr->data != 500); + for(size_t i = 0; i < 3; i++) + for(size_t j = 0; j < 2; j++) + for(size_t k = 0; k < 1; k++) + PUSH_ERROR_IF(a_array[i][j][k].s_ptr != a_array[0][0][0].s_ptr); + return Void(); + } + Return foo22(const hidl_array& a_ptr_array) override { + PUSH_ERROR_IF(a_ptr_array[0][0][0]->s_ptr->data != 500); + for(size_t i = 0; i < 3; i++) + for(size_t j = 0; j < 2; j++) + for(size_t k = 0; k < 1; k++) + PUSH_ERROR_IF(a_ptr_array[i][j][k] != a_ptr_array[0][0][0]); + return Void(); + } + + IPointer::Sam *s; + IPointer::Ada *a; + IPointer::Bob *b; + IPointer::Cin *c; + IPointer::Dom *d; + + IPointer::Ptr p; + hidl_array a_array; + int32_t someInt; + hidl_array someIntArray; + hidl_string str; + hidl_vec a_vec; + Pointer() { + d = new IPointer::Dom(); + s = new IPointer::Sam(); + b = new IPointer::Bob(); + c = &d->c; + a = &c->a; + b->s_ptr = a->s_ptr = s; + b->a_ptr = a; + c->b_ptr = b; + s->data = 500; + + someInt = 500; + for(size_t i = 0; i < 5; i++) someIntArray[i] = 500; + + for(size_t i = 0; i < 5; i++) a_array[i] = *a; + + for(size_t i = 0; i < 5; i++) p.ptr_array[i] = a; + p.array_ptr = &a_array; + p.int_ptr = &someInt; + p.int_array_ptr = &someIntArray; + for(size_t i = 0; i < 5; i++) p.int_ptr_array[i] = &someInt; + p.a_ptr_vec.resize(5); + for(size_t i = 0; i < 5; i++) p.a_ptr_vec[i] = a; + str = "meowmeowmeow"; + p.str_ref = &str; + a_vec.resize(5); + for(size_t i = 0; i < 5; i++) a_vec[i].s_ptr = s; + p.a_vec_ptr = &a_vec; + } + ~Pointer() { + delete d; delete s; delete b; + } + Return bar1(bar1_cb _cb) override { + _cb(*s, s); + return Void(); + } + Return bar2(bar2_cb _cb) override { + _cb(*s, *a); + return Void(); + } + Return bar3(bar3_cb _cb) override { + _cb(*s, *a, *b); + return Void(); + } + Return bar4(bar4_cb _cb) override { + _cb(s); + return Void(); + } + Return bar5(bar5_cb _cb) override { + _cb(*a, *b); + return Void(); + } + Return bar6(bar6_cb _cb) override { + _cb(a); + return Void(); + } + Return bar7(bar7_cb _cb) override { + _cb(a, b); + return Void(); + } + Return bar8(bar8_cb _cb) override { + _cb(*d); + return Void(); + } + Return bar9(bar9_cb _cb) override { + _cb(&str); + return Void(); + } + Return bar10(bar10_cb _cb) override { + hidl_vec v; v.resize(5); + for(size_t i = 0; i < 5; i++) v[i] = s; + _cb(v); + return Void(); + } + Return bar11(bar11_cb _cb) override { + hidl_vec v; v.resize(5); + for(size_t i = 0; i < 5; i++) v[i].data = 500; + _cb(&v); + return Void(); + } + Return bar12(bar12_cb _cb) override { + hidl_array array; + for(size_t i = 0; i < 5; i++) array[i] = *s; + _cb(&array); + return Void(); + } + Return bar13(bar13_cb _cb) override { + hidl_array array; + for(size_t i = 0; i < 5; i++) array[i] = s; + _cb(array); + return Void(); + } + Return bar14(bar14_cb _cb) override { + IPointer::Sam const* p1 = s; + IPointer::Sam const* const* p2 = &p1; + _cb(&p2); + return Void(); + } + Return bar15(bar15_cb _cb) override { + int32_t const* p1 = &someInt; + int32_t const* const* p2 = &p1; + _cb(&p2); + return Void(); + } + Return bar16(bar16_cb _cb) override { + _cb(p); + return Void(); + } + Return bar17(bar17_cb _cb) override { + _cb(&p); + return Void(); + } + Return bar18(bar18_cb _cb) override { + _cb(&str, &str, str); + return Void(); + } + Return bar19(bar19_cb _cb) override { + _cb(&a_vec, a_vec, &a_vec); + return Void(); + } + Return bar20(bar20_cb _cb) override { + // 1026 == PARCEL_REF_CAP + 2. + // 1026 means 1 writeBuffer and 1025 writeReferences. 1025 > PARCEL_REF_CAP. + hidl_vec v; v.resize(1026); + for(size_t i = 0; i < 1026; i++) v[i] = s; + _cb(v); + return Void(); + } + Return bar21(bar21_cb _cb) override { + hidl_array a_array; + for(size_t i = 0; i < 3; i++) + for(size_t j = 0; j < 2; j++) + for(size_t k = 0; k < 1; k++) + a_array[i][j][k] = *a; + _cb(&a_array); + return Void(); + } + Return bar22(bar22_cb _cb) override { + hidl_array a_ptr_array; + for(size_t i = 0; i < 3; i++) + for(size_t j = 0; j < 2; j++) + for(size_t k = 0; k < 1; k++) + a_ptr_array[i][j][k] = a; + _cb(a_ptr_array); + return Void(); + } +}; + +extern "C" IPointer* HIDL_FETCH_IPointer(const char* name); + +} // namespace implementation +} // namespace V1_0 +} // namespace pointer +} // namespace tests +} // namespace hardware +} // namespace android + +#undef PUSH_ERROR_IF + +#endif // HIDL_GENERATED_android_hardware_tests_pointer_V1_0_Pointer_H_