1 /*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "SafeUnion.h"
18 #include <android-base/logging.h>
19
20 namespace android {
21 namespace hardware {
22 namespace tests {
23 namespace safeunion {
24 namespace V1_0 {
25 namespace implementation {
26
27 // Methods from ::android::hardware::tests::safeunion::V1_0::ISafeUnion follow.
newLargeSafeUnion(newLargeSafeUnion_cb _hidl_cb)28 Return<void> SafeUnion::newLargeSafeUnion(newLargeSafeUnion_cb _hidl_cb) {
29 LOG(INFO) << "SERVER(SafeUnion) newLargeSafeUnion()";
30
31 LargeSafeUnion ret;
32 _hidl_cb(ret);
33 return Void();
34 }
35
setA(const LargeSafeUnion & myUnion,int8_t a,setA_cb _hidl_cb)36 Return<void> SafeUnion::setA(const LargeSafeUnion& myUnion, int8_t a, setA_cb _hidl_cb) {
37 LOG(INFO) << "SERVER(SafeUnion) setA(myUnion, " << a << ")";
38
39 LargeSafeUnion myNewUnion = myUnion;
40 myNewUnion.a(a);
41
42 _hidl_cb(myNewUnion);
43 return Void();
44 }
45
setB(const LargeSafeUnion & myUnion,uint16_t b,setB_cb _hidl_cb)46 Return<void> SafeUnion::setB(const LargeSafeUnion& myUnion, uint16_t b, setB_cb _hidl_cb) {
47 LOG(INFO) << "SERVER(SafeUnion) setB(myUnion, " << b << ")";
48
49 LargeSafeUnion myNewUnion = myUnion;
50 myNewUnion.b(b);
51
52 _hidl_cb(myNewUnion);
53 return Void();
54 }
55
setC(const LargeSafeUnion & myUnion,int32_t c,setC_cb _hidl_cb)56 Return<void> SafeUnion::setC(const LargeSafeUnion& myUnion, int32_t c, setC_cb _hidl_cb) {
57 LOG(INFO) << "SERVER(SafeUnion) setC(myUnion, " << c << ")";
58
59 LargeSafeUnion myNewUnion = myUnion;
60 myNewUnion.c(c);
61
62 _hidl_cb(myNewUnion);
63 return Void();
64 }
65
setD(const LargeSafeUnion & myUnion,uint64_t d,setD_cb _hidl_cb)66 Return<void> SafeUnion::setD(const LargeSafeUnion& myUnion, uint64_t d, setD_cb _hidl_cb) {
67 LOG(INFO) << "SERVER(SafeUnion) setD(myUnion, " << d << ")";
68
69 LargeSafeUnion myNewUnion = myUnion;
70 myNewUnion.d(d);
71
72 _hidl_cb(myNewUnion);
73 return Void();
74 }
75
setE(const LargeSafeUnion & myUnion,const hidl_array<int8_t,13> & e,setE_cb _hidl_cb)76 Return<void> SafeUnion::setE(const LargeSafeUnion& myUnion, const hidl_array<int8_t, 13>& e, setE_cb _hidl_cb) {
77 LOG(INFO) << "SERVER(SafeUnion) setE(myUnion, " << toString(e) << ")";
78
79 LargeSafeUnion myNewUnion = myUnion;
80 myNewUnion.e(e);
81
82 _hidl_cb(myNewUnion);
83 return Void();
84 }
85
setF(const LargeSafeUnion & myUnion,const hidl_array<int64_t,5> & f,setF_cb _hidl_cb)86 Return<void> SafeUnion::setF(const LargeSafeUnion& myUnion, const hidl_array<int64_t, 5>& f, setF_cb _hidl_cb) {
87 LOG(INFO) << "SERVER(SafeUnion) setF(myUnion, " << toString(f) << ")";
88
89 LargeSafeUnion myNewUnion = myUnion;
90 myNewUnion.f(f);
91
92 _hidl_cb(myNewUnion);
93 return Void();
94 }
95
setG(const LargeSafeUnion & myUnion,const hidl_string & g,setG_cb _hidl_cb)96 Return<void> SafeUnion::setG(const LargeSafeUnion& myUnion, const hidl_string& g, setG_cb _hidl_cb) {
97 LOG(INFO) << "SERVER(SafeUnion) setG(myUnion, " << toString(g) << ")";
98
99 LargeSafeUnion myNewUnion = myUnion;
100 myNewUnion.g(g);
101
102 _hidl_cb(myNewUnion);
103 return Void();
104 }
105
setH(const LargeSafeUnion & myUnion,const hidl_vec<bool> & h,setH_cb _hidl_cb)106 Return<void> SafeUnion::setH(const LargeSafeUnion& myUnion, const hidl_vec<bool>& h, setH_cb _hidl_cb) {
107 LOG(INFO) << "SERVER(SafeUnion) setH(myUnion, " << toString(h) << ")";
108
109 LargeSafeUnion myNewUnion = myUnion;
110 myNewUnion.h(h);
111
112 _hidl_cb(myNewUnion);
113 return Void();
114 }
115
setI(const LargeSafeUnion & myUnion,const hidl_vec<uint64_t> & i,setI_cb _hidl_cb)116 Return<void> SafeUnion::setI(const LargeSafeUnion& myUnion, const hidl_vec<uint64_t>& i, setI_cb _hidl_cb) {
117 LOG(INFO) << "SERVER(SafeUnion) setI(myUnion, " << toString(i) << ")";
118
119 LargeSafeUnion myNewUnion = myUnion;
120 myNewUnion.i(i);
121
122 _hidl_cb(myNewUnion);
123 return Void();
124 }
125
setJ(const LargeSafeUnion & myUnion,const J & j,setJ_cb _hidl_cb)126 Return<void> SafeUnion::setJ(const LargeSafeUnion& myUnion, const J& j, setJ_cb _hidl_cb) {
127 LOG(INFO) << "SERVER(SafeUnion) setJ(myUnion, " << toString(j) << ")";
128
129 LargeSafeUnion myNewUnion = myUnion;
130 myNewUnion.j(j);
131
132 _hidl_cb(myNewUnion);
133 return Void();
134 }
135
setK(const LargeSafeUnion & myUnion,const LargeSafeUnion::K & k,setK_cb _hidl_cb)136 Return<void> SafeUnion::setK(const LargeSafeUnion& myUnion, const LargeSafeUnion::K& k, setK_cb _hidl_cb) {
137 LOG(INFO) << "SERVER(SafeUnion) setK(myUnion, " << toString(k) << ")";
138
139 LargeSafeUnion myNewUnion = myUnion;
140 myNewUnion.k(k);
141
142 _hidl_cb(myNewUnion);
143 return Void();
144 }
145
setL(const LargeSafeUnion & myUnion,const SmallSafeUnion & l,setL_cb _hidl_cb)146 Return<void> SafeUnion::setL(const LargeSafeUnion& myUnion, const SmallSafeUnion& l, setL_cb _hidl_cb) {
147 LOG(INFO) << "SERVER(SafeUnion) setL(myUnion, " << toString(l) << ")";
148
149 LargeSafeUnion myNewUnion = myUnion;
150 myNewUnion.l(l);
151
152 _hidl_cb(myNewUnion);
153 return Void();
154 }
155
setM(const LargeSafeUnion & myUnion,BitField m,setL_cb _hidl_cb)156 Return<void> SafeUnion::setM(const LargeSafeUnion& myUnion, BitField m, setL_cb _hidl_cb) {
157 LOG(INFO) << "SERVER(SafeUnion) setM(myUnion, " << toString(m) << ")";
158
159 LargeSafeUnion myNewUnion = myUnion;
160 myNewUnion.m(m);
161
162 _hidl_cb(myNewUnion);
163 return Void();
164 }
165
setN(const LargeSafeUnion & myUnion,hidl_bitfield<BitField> n,setL_cb _hidl_cb)166 Return<void> SafeUnion::setN(const LargeSafeUnion& myUnion, hidl_bitfield<BitField> n,
167 setL_cb _hidl_cb) {
168 LOG(INFO) << "SERVER(SafeUnion) setN(myUnion, " << n << ")";
169
170 LargeSafeUnion myNewUnion = myUnion;
171 myNewUnion.n(n);
172
173 _hidl_cb(myNewUnion);
174 return Void();
175 }
176
newInterfaceTypeSafeUnion(newInterfaceTypeSafeUnion_cb _hidl_cb)177 Return<void> SafeUnion::newInterfaceTypeSafeUnion(newInterfaceTypeSafeUnion_cb _hidl_cb) {
178 LOG(INFO) << "SERVER(SafeUnion) newInterfaceTypeSafeUnion()";
179
180 InterfaceTypeSafeUnion ret;
181 _hidl_cb(ret);
182 return Void();
183 }
184
setInterfaceA(const InterfaceTypeSafeUnion & myUnion,uint32_t a,setInterfaceA_cb _hidl_cb)185 Return<void> SafeUnion::setInterfaceA(const InterfaceTypeSafeUnion& myUnion, uint32_t a, setInterfaceA_cb _hidl_cb) {
186 LOG(INFO) << "SERVER(SafeUnion) setInterfaceA(myUnion, " << a << ")";
187
188 InterfaceTypeSafeUnion myNewUnion = myUnion;
189 myNewUnion.a(a);
190
191 _hidl_cb(myNewUnion);
192 return Void();
193 }
194
setInterfaceB(const InterfaceTypeSafeUnion & myUnion,const hidl_array<int8_t,7> & b,setInterfaceB_cb _hidl_cb)195 Return<void> SafeUnion::setInterfaceB(const InterfaceTypeSafeUnion& myUnion, const hidl_array<int8_t, 7>& b, setInterfaceB_cb _hidl_cb) {
196 LOG(INFO) << "SERVER(SafeUnion) setInterfaceB(myUnion, " << toString(b) << ")";
197
198 InterfaceTypeSafeUnion myNewUnion = myUnion;
199 myNewUnion.b(b);
200
201 _hidl_cb(myNewUnion);
202 return Void();
203 }
204
setInterfaceC(const InterfaceTypeSafeUnion & myUnion,const sp<::android::hidl::base::V1_0::IBase> & c,setInterfaceC_cb _hidl_cb)205 Return<void> SafeUnion::setInterfaceC(const InterfaceTypeSafeUnion& myUnion,
206 const sp<::android::hidl::base::V1_0::IBase>& c,
207 setInterfaceC_cb _hidl_cb) {
208 LOG(INFO) << "SERVER(SafeUnion) setInterfaceC(myUnion, " << toString(c) << ")";
209
210 InterfaceTypeSafeUnion myNewUnion = myUnion;
211 myNewUnion.c(c);
212
213 _hidl_cb(myNewUnion);
214 return Void();
215 }
216
setInterfaceD(const InterfaceTypeSafeUnion & myUnion,const hidl_string & d,setInterfaceD_cb _hidl_cb)217 Return<void> SafeUnion::setInterfaceD(const InterfaceTypeSafeUnion& myUnion, const hidl_string& d,
218 setInterfaceD_cb _hidl_cb) {
219 LOG(INFO) << "SERVER(SafeUnion) setInterfaceD(myUnion, " << toString(d) << ")";
220
221 InterfaceTypeSafeUnion myNewUnion = myUnion;
222 myNewUnion.d(d);
223
224 _hidl_cb(myNewUnion);
225 return Void();
226 }
227
setInterfaceE(const InterfaceTypeSafeUnion & myUnion,const hidl_vec<hidl_string> & e,setInterfaceE_cb _hidl_cb)228 Return<void> SafeUnion::setInterfaceE(const InterfaceTypeSafeUnion& myUnion,
229 const hidl_vec<hidl_string>& e, setInterfaceE_cb _hidl_cb) {
230 LOG(INFO) << "SERVER(SafeUnion) setInterfaceE(myUnion, " << toString(e) << ")";
231
232 InterfaceTypeSafeUnion myNewUnion = myUnion;
233 myNewUnion.e(e);
234
235 _hidl_cb(myNewUnion);
236 return Void();
237 }
238
setInterfaceF(const InterfaceTypeSafeUnion & myUnion,const hidl_handle & f,setInterfaceF_cb _hidl_cb)239 Return<void> SafeUnion::setInterfaceF(const InterfaceTypeSafeUnion& myUnion, const hidl_handle& f,
240 setInterfaceF_cb _hidl_cb) {
241 LOG(INFO) << "SERVER(SafeUnion) setInterfaceF(myUnion, " << toString(f) << ")";
242
243 InterfaceTypeSafeUnion myNewUnion = myUnion;
244 myNewUnion.f(f);
245
246 _hidl_cb(myNewUnion);
247 return Void();
248 }
249
setInterfaceG(const InterfaceTypeSafeUnion & myUnion,const hidl_vec<hidl_handle> & g,setInterfaceG_cb _hidl_cb)250 Return<void> SafeUnion::setInterfaceG(const InterfaceTypeSafeUnion& myUnion,
251 const hidl_vec<hidl_handle>& g, setInterfaceG_cb _hidl_cb) {
252 LOG(INFO) << "SERVER(SafeUnion) setInterfaceG(myUnion, " << toString(g) << ")";
253
254 InterfaceTypeSafeUnion myNewUnion = myUnion;
255 myNewUnion.g(g);
256
257 _hidl_cb(myNewUnion);
258 return Void();
259 }
260
newHandleTypeSafeUnion(newHandleTypeSafeUnion_cb _hidl_cb)261 Return<void> SafeUnion::newHandleTypeSafeUnion(newHandleTypeSafeUnion_cb _hidl_cb) {
262 LOG(INFO) << "SERVER(SafeUnion) newHandleTypeSafeUnion()";
263
264 HandleTypeSafeUnion ret;
265 _hidl_cb(ret);
266 return Void();
267 }
268
setHandleA(const::android::hardware::tests::safeunion::V1_0::ISafeUnion::HandleTypeSafeUnion & myUnion,const hidl_handle & a,setHandleA_cb _hidl_cb)269 Return<void> SafeUnion::setHandleA(
270 const ::android::hardware::tests::safeunion::V1_0::ISafeUnion::HandleTypeSafeUnion& myUnion,
271 const hidl_handle& a, setHandleA_cb _hidl_cb) {
272 LOG(INFO) << "SERVER(SafeUnion) setHandleA(myUnion, " << toString(a) << ")";
273
274 HandleTypeSafeUnion myNewUnion = myUnion;
275 myNewUnion.a(a);
276
277 _hidl_cb(myNewUnion);
278 return Void();
279 }
280
setHandleB(const HandleTypeSafeUnion & myUnion,const hidl_array<hidl_handle,5> & b,setHandleB_cb _hidl_cb)281 Return<void> SafeUnion::setHandleB(const HandleTypeSafeUnion& myUnion,
282 const hidl_array<hidl_handle, 5>& b, setHandleB_cb _hidl_cb) {
283 LOG(INFO) << "SERVER(SafeUnion) setHandleB(myUnion, " << toString(b) << ")";
284
285 HandleTypeSafeUnion myNewUnion = myUnion;
286 myNewUnion.b(b);
287
288 _hidl_cb(myNewUnion);
289 return Void();
290 }
291
setHandleC(const HandleTypeSafeUnion & myUnion,const hidl_vec<hidl_handle> & c,setHandleC_cb _hidl_cb)292 Return<void> SafeUnion::setHandleC(const HandleTypeSafeUnion& myUnion,
293 const hidl_vec<hidl_handle>& c, setHandleC_cb _hidl_cb) {
294 LOG(INFO) << "SERVER(SafeUnion) setHandleC(myUnion, " << toString(c) << ")";
295
296 HandleTypeSafeUnion myNewUnion = myUnion;
297 myNewUnion.c(c);
298
299 _hidl_cb(myNewUnion);
300 return Void();
301 }
302
HIDL_FETCH_ISafeUnion(const char *)303 ISafeUnion* HIDL_FETCH_ISafeUnion(const char* /* name */) {
304 return new SafeUnion();
305 }
306
307 } // namespace implementation
308 } // namespace V1_0
309 } // namespace safeunion
310 } // namespace tests
311 } // namespace hardware
312 } // namespace android
313