add default implementation to android.hardware.tests.foo/bar/pointer@1.0

Test: hidl_test
Test: mma

Merged-In: I808423c040099354513db0ad108210fcec17c8a7
Change-Id: I808423c040099354513db0ad108210fcec17c8a7
diff --git a/tests/foo/1.0/default/Android.bp b/tests/foo/1.0/default/Android.bp
new file mode 100644
index 0000000..a2acd14
--- /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 0000000..81aa78b
--- /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 <android-base/logging.h>
+#include <inttypes.h>
+#include <utils/Timers.h>
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace foo {
+namespace V1_0 {
+namespace implementation {
+
+// Methods from ::android::hardware::tests::foo::V1_0::IFoo follow.
+Return<void> Foo::doThis(float param) {
+    ALOGI("SERVER(Foo) doThis(%.2f)", param);
+
+    return Void();
+}
+
+Return<void> Foo::doThis(uint32_t param) {
+    ALOGI("SERVER(Foo) doThis (int) (%d)", param);
+    return Void();
+}
+
+Return<int32_t> Foo::doThatAndReturnSomething(
+        int64_t param) {
+    LOG(INFO) << "SERVER(Foo) doThatAndReturnSomething(" << param << ")";
+
+    return 666;
+}
+
+Return<double> 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<void> Foo::doSomethingElse(
+        const hidl_array<int32_t, 15> &param, doSomethingElse_cb _cb) {
+    ALOGI("SERVER(Foo) doSomethingElse(...)");
+
+    hidl_array<int32_t, 32> 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<void> Foo::doStuffAndReturnAString(
+        doStuffAndReturnAString_cb _cb) {
+    ALOGI("SERVER(Foo) doStuffAndReturnAString");
+
+    hidl_string s;
+    s = "Hello, world";
+
+    _cb(s);
+
+    return Void();
+}
+
+Return<void> Foo::mapThisVector(
+        const hidl_vec<int32_t> &param, mapThisVector_cb _cb) {
+    ALOGI("SERVER(Foo) mapThisVector");
+
+    hidl_vec<int32_t> out;
+    out.resize(param.size());
+
+    for (size_t i = 0; i < out.size(); ++i) {
+        out[i] = param[i] * 2;
+    }
+
+    _cb(out);
+
+    return Void();
+}
+
+Return<void> Foo::callMe(
+        const sp<IFooCallback> &cb) {
+    ALOGI("SERVER(Foo) callMe %p", cb.get());
+
+    if (cb != NULL) {
+
+        hidl_array<nsecs_t, 3> 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::SomeEnum> Foo::useAnEnum(SomeEnum param) {
+    ALOGI("SERVER(Foo) useAnEnum %d", (int)param);
+
+    return SomeEnum::goober;
+}
+
+Return<void> Foo::haveAGooberVec(const hidl_vec<Goober>& param) {
+    ALOGI("SERVER(Foo) haveAGooberVec &param = %p", &param);
+
+    return Void();
+}
+
+Return<void> Foo::haveAGoober(const Goober &g) {
+    ALOGI("SERVER(Foo) haveaGoober g=%p", &g);
+
+    return Void();
+}
+
+Return<void> Foo::haveAGooberArray(const hidl_array<Goober, 20> & /* lots */) {
+    ALOGI("SERVER(Foo) haveAGooberArray");
+
+    return Void();
+}
+
+Return<void> Foo::haveATypeFromAnotherFile(const Abc &def) {
+    ALOGI("SERVER(Foo) haveATypeFromAnotherFile def=%p", &def);
+
+    return Void();
+}
+
+Return<void> Foo::haveSomeStrings(
+        const hidl_array<hidl_string, 3> &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<hidl_string, 2> result;
+    result[0] = "Hello";
+    result[1] = "World";
+
+    _cb(result);
+
+    return Void();
+}
+
+Return<void> Foo::haveAStringVec(
+        const hidl_vec<hidl_string> &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<hidl_string> 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<typename T>
+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<typename T, size_t SIZE>
+static std::string to_string(const hidl_array<T, SIZE> &array) {
+    return to_string(&array[0], SIZE);
+}
+
+template<typename T, size_t SIZE1, size_t SIZE2>
+static std::string to_string(const hidl_array<T, SIZE1, SIZE2> &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<typename T>
+static std::string to_string(const hidl_vec<T> &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<void> Foo::transposeMe(
+        const hidl_array<float, 3, 5> &in, transposeMe_cb _cb) {
+    ALOGI("SERVER(Foo) transposeMe(%s)", to_string(in).c_str());
+
+    hidl_array<float, 5, 3> 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<void> 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<void> 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<void> Foo::transpose2(
+        const hidl_array<hidl_string, 5, 3> &in, transpose2_cb _hidl_cb) {
+    LOG(INFO) << "SERVER(Foo) transpose2 " << to_string(in);
+
+    hidl_array<hidl_string, 3, 5> 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<void> Foo::sendVec(
+        const hidl_vec<uint8_t> &data, sendVec_cb _hidl_cb) {
+    _hidl_cb(data);
+
+    return Void();
+}
+
+Return<void> Foo::sendVecVec(sendVecVec_cb _hidl_cb) {
+    hidl_vec<hidl_vec<uint8_t>> 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 0000000..00a29f5
--- /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 <android/hardware/tests/foo/1.0/IFoo.h>
+#include <hidl/Status.h>
+
+#include <hidl/MQDescriptor.h>
+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<void> doThis(float param)  override;
+    virtual Return<void> doThis(uint32_t param)  override;
+    virtual Return<int32_t> doThatAndReturnSomething(int64_t param)  override;
+    virtual Return<double> doQuiteABit(int32_t a, int64_t b, float c, double d)  override;
+    virtual Return<void> doSomethingElse(const hidl_array<int32_t, 15 /* 15 */>& param, doSomethingElse_cb _hidl_cb)  override;
+    virtual Return<void> doStuffAndReturnAString(doStuffAndReturnAString_cb _hidl_cb)  override;
+    virtual Return<void> mapThisVector(const hidl_vec<int32_t>& param, mapThisVector_cb _hidl_cb)  override;
+    virtual Return<void> callMe(const sp<IFooCallback>& cb)  override;
+    virtual Return<IFoo::SomeEnum> useAnEnum(IFoo::SomeEnum zzz)  override;
+    virtual Return<void> haveAGooberVec(const hidl_vec<IFoo::Goober>& param)  override;
+    virtual Return<void> haveAGoober(const IFoo::Goober& g)  override;
+    virtual Return<void> haveAGooberArray(const hidl_array<IFoo::Goober, 20 /* 20 */>& lots)  override;
+    virtual Return<void> haveATypeFromAnotherFile(const Abc& def)  override;
+    virtual Return<void> haveSomeStrings(const hidl_array<hidl_string, 3 /* 3 */>& array, haveSomeStrings_cb _hidl_cb)  override;
+    virtual Return<void> haveAStringVec(const hidl_vec<hidl_string>& vector, haveAStringVec_cb _hidl_cb)  override;
+    virtual Return<void> transposeMe(const hidl_array<float, 3 /* 3 */, 5 /* 5 */>& in, transposeMe_cb _hidl_cb)  override;
+    virtual Return<void> callingDrWho(const IFoo::MultiDimensional& in, callingDrWho_cb _hidl_cb)  override;
+    virtual Return<void> transpose(const IFoo::StringMatrix5x3& in, transpose_cb _hidl_cb)  override;
+    virtual Return<void> transpose2(const hidl_array<hidl_string, 5 /* 5 */, 3 /* 3 */>& in, transpose2_cb _hidl_cb)  override;
+    virtual Return<void> sendVec(const hidl_vec<uint8_t>& data, sendVec_cb _hidl_cb)  override;
+    virtual Return<void> 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 0000000..08d3ce0
--- /dev/null
+++ b/tests/foo/1.0/default/FooCallback.cpp
@@ -0,0 +1,86 @@
+#include "FooCallback.h"
+#include <android-base/logging.h>
+#include <inttypes.h>
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace foo {
+namespace V1_0 {
+namespace implementation {
+
+Return<void> FooCallback::heyItsYou(
+        const sp<IFooCallback> &_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<bool> FooCallback::heyItsYouIsntIt(const sp<IFooCallback> &_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<void> 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<void> 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<void> FooCallback::youBlockedMeFor(const hidl_array<int64_t, 3> &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 0000000..6c284ca
--- /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 <android/hardware/tests/foo/1.0/IFooCallback.h>
+#include <hidl/Status.h>
+#include <hidl/MQDescriptor.h>
+
+#include <utils/Condition.h>
+#include <utils/Timers.h>
+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<void> heyItsYou(const sp<IFooCallback>& cb)  override;
+    Return<bool> heyItsYouIsntIt(const sp<IFooCallback>& cb)  override;
+    Return<void> heyItsTheMeaningOfLife(uint8_t tmol)  override;
+    Return<void> reportResults(int64_t ns, reportResults_cb _hidl_cb)  override;
+    Return<void> youBlockedMeFor(const hidl_array<int64_t, 3 /* 3 */>& 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, 3> 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 0000000..0d1a458
--- /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 0000000..6e9a3e1
--- /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 <android/hardware/tests/foo/1.0/IMyTypes.h>
+#include <hidl/Status.h>
+
+#include <hidl/MQDescriptor.h>
+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 0000000..0f678f0
--- /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 0000000..24ade70
--- /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 <android/hardware/tests/foo/1.0/ITheirTypes.h>
+#include <hidl/Status.h>
+
+#include <hidl/MQDescriptor.h>
+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_