blob: cac0845c922568854a56b50f2e7d623bd9be5767 [file] [log] [blame]
Yifan Hongd5b5b2e2016-10-06 13:50:49 -07001
2#define LOG_TAG "hidl_test"
3
4#include "Bar.h"
Yifan Hong0c4c7a32016-11-28 15:59:24 -08005#include <android/log.h>
Yifan Hongd5b5b2e2016-10-06 13:50:49 -07006#include <inttypes.h>
7
8namespace android {
9namespace hardware {
10namespace tests {
11namespace bar {
12namespace V1_0 {
13namespace implementation {
14
15Bar::Bar() {
16 mFoo = IFoo::getService("", true);
17}
18
19// Methods from ::android::hardware::tests::foo::V1_0::IFoo follow.
20Return<void> Bar::doThis(float param) {
21 return mFoo->doThis(param);
22}
23
Yifan Hongd5b5b2e2016-10-06 13:50:49 -070024Return<int32_t> Bar::doThatAndReturnSomething(
25 int64_t param) {
26 return mFoo->doThatAndReturnSomething(param);
27}
28
29Return<double> Bar::doQuiteABit(
30 int32_t a,
31 int64_t b,
32 float c,
33 double d) {
34 return mFoo->doQuiteABit(a, b, c, d);
35}
36
37Return<void> Bar::doSomethingElse(
38 const hidl_array<int32_t, 15> &param, doSomethingElse_cb _cb) {
39 return mFoo->doSomethingElse(param, _cb);
40}
41
42Return<void> Bar::doStuffAndReturnAString(
43 doStuffAndReturnAString_cb _cb) {
44 return mFoo->doStuffAndReturnAString(_cb);
45}
46
47Return<void> Bar::mapThisVector(
48 const hidl_vec<int32_t> &param, mapThisVector_cb _cb) {
49 return mFoo->mapThisVector(param, _cb);
50}
51
52Return<void> Bar::callMe(
53 const sp<IFooCallback> &cb) {
54 return mFoo->callMe(cb);
55}
56
57Return<Bar::SomeEnum> Bar::useAnEnum(SomeEnum param) {
58 return mFoo->useAnEnum(param);
59}
60
61Return<void> Bar::haveAGooberVec(const hidl_vec<Goober>& param) {
62 return mFoo->haveAGooberVec(param);
63}
64
65Return<void> Bar::haveAGoober(const Goober &g) {
66 return mFoo->haveAGoober(g);
67}
68
69Return<void> Bar::haveAGooberArray(const hidl_array<Goober, 20> &lots) {
70 return mFoo->haveAGooberArray(lots);
71}
72
73Return<void> Bar::haveATypeFromAnotherFile(const Abc &def) {
74 return mFoo->haveATypeFromAnotherFile(def);
75}
76
77Return<void> Bar::haveSomeStrings(
78 const hidl_array<hidl_string, 3> &array,
79 haveSomeStrings_cb _cb) {
80 return mFoo->haveSomeStrings(array, _cb);
81}
82
83Return<void> Bar::haveAStringVec(
84 const hidl_vec<hidl_string> &vector,
85 haveAStringVec_cb _cb) {
86 return mFoo->haveAStringVec(vector, _cb);
87}
88
89Return<void> Bar::transposeMe(
90 const hidl_array<float, 3, 5> &in, transposeMe_cb _cb) {
91 return mFoo->transposeMe(in, _cb);
92}
93
94Return<void> Bar::callingDrWho(
95 const MultiDimensional &in, callingDrWho_cb _hidl_cb) {
96 return mFoo->callingDrWho(in, _hidl_cb);
97}
98
99Return<void> Bar::transpose(const StringMatrix5x3 &in, transpose_cb _hidl_cb) {
100 return mFoo->transpose(in, _hidl_cb);
101}
102
103Return<void> Bar::transpose2(
104 const hidl_array<hidl_string, 5, 3> &in, transpose2_cb _hidl_cb) {
105 return mFoo->transpose2(in, _hidl_cb);
106}
107
108Return<void> Bar::sendVec(
109 const hidl_vec<uint8_t> &data, sendVec_cb _hidl_cb) {
110 return mFoo->sendVec(data, _hidl_cb);
111}
112
113Return<void> Bar::sendVecVec(sendVecVec_cb _hidl_cb) {
114 return mFoo->sendVecVec(_hidl_cb);
115}
116
Andreas Huber847b1452016-10-19 14:10:55 -0700117Return<void> Bar::haveAVectorOfInterfaces(
118 const hidl_vec<sp<ISimple> > &in,
119 haveAVectorOfInterfaces_cb _hidl_cb) {
120 _hidl_cb(in);
121
122 return Void();
123}
124
Yifan Hong1d747312016-11-28 14:50:15 -0800125// TODO: remove after b/33173166 is fixed.
126struct Simple : public ISimple {
127 Simple(int32_t cookie)
128 : mCookie(cookie) {
129 }
130
131 Return<int32_t> getCookie() override {
132 return mCookie;
133 }
134
135private:
136 int32_t mCookie;
137};
138
139// TODO: use _hidl_cb(in) after b/33173166 is fixed.
Andreas Huber847b1452016-10-19 14:10:55 -0700140Return<void> Bar::haveAVectorOfGenericInterfaces(
Yifan Hongebcc3322016-11-28 16:09:46 -0800141 const hidl_vec<sp<android::hidl::base::V1_0::IBase> > &in,
Andreas Huber847b1452016-10-19 14:10:55 -0700142 haveAVectorOfGenericInterfaces_cb _hidl_cb) {
Yifan Hong1d747312016-11-28 14:50:15 -0800143 // _hidl_cb(in);
144 hidl_vec<sp<android::hidl::base::V1_0::IBase> > out;
145 out.resize(in.size());
146 for (size_t i = 0; i < in.size(); ++i) {
147 sp<ISimple> s = ISimple::castFrom(in[i]);
148 if (s.get() == nullptr) {
149 out[i] = new Simple(-1);
150 } else {
151 out[i] = new Simple(s->getCookie());
152 }
153 }
154 _hidl_cb(out);
Andreas Huber847b1452016-10-19 14:10:55 -0700155
156 return Void();
157}
158
Yifan Hongebfa6332016-10-14 10:41:41 -0700159Return<void> Bar::createMyHandle(createMyHandle_cb _hidl_cb) {
160 return mFoo->createMyHandle(_hidl_cb);
161}
162
163Return<void> Bar::createHandles(uint32_t size, createHandles_cb _hidl_cb) {
164 return mFoo->createHandles(size, _hidl_cb);
165}
166
167Return<void> Bar::closeHandles() {
168 return mFoo->closeHandles();
169}
170
Martijn Coenenb7307d52016-10-27 11:51:46 +0200171Return<void> Bar::echoNullInterface(const sp<IFooCallback> &cb, echoNullInterface_cb _hidl_cb) {
172 return mFoo->echoNullInterface(cb, _hidl_cb);
173}
174
Yifan Hongd5b5b2e2016-10-06 13:50:49 -0700175// Methods from ::android::hardware::tests::bar::V1_0::IBar follow.
176Return<void> Bar::thisIsNew() {
177 ALOGI("SERVER(Bar) thisIsNew");
178
179 return Void();
180}
181
Martijn Coenen403161a2016-11-18 15:29:32 +0100182Return<void> Bar::expectNullHandle(const hidl_handle& h, const Abc& xyz, expectNullHandle_cb _hidl_cb) {
183 ALOGI("SERVER(Bar) h = %p, xyz.z = %p", h.getNativeHandle(), xyz.z.getNativeHandle());
Yifan Hong688bb1e2016-10-27 13:18:43 -0700184 _hidl_cb(h == nullptr, xyz.z == nullptr);
185 return Void();
186}
187
Yifan Hongd5b5b2e2016-10-06 13:50:49 -0700188IBar* HIDL_FETCH_IBar(const char* /* name */) {
189 return new Bar();
190}
191
192} // namespace implementation
193} // namespace V1_0
194} // namespace bar
195} // namespace tests
196} // namespace hardware
197} // namespace android