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::hardware::tests::safeunion::V1_0::IOtherInterface> & c,setInterfaceC_cb _hidl_cb)205 Return<void> SafeUnion::setInterfaceC(const InterfaceTypeSafeUnion& myUnion, const sp<::android::hardware::tests::safeunion::V1_0::IOtherInterface>& c, setInterfaceC_cb _hidl_cb) {
206 LOG(INFO) << "SERVER(SafeUnion) setInterfaceC(myUnion, " << toString(c) << ")";
207
208 InterfaceTypeSafeUnion myNewUnion = myUnion;
209 myNewUnion.c(c);
210
211 _hidl_cb(myNewUnion);
212 return Void();
213 }
214
setInterfaceD(const InterfaceTypeSafeUnion & myUnion,const hidl_string & d,setInterfaceD_cb _hidl_cb)215 Return<void> SafeUnion::setInterfaceD(const InterfaceTypeSafeUnion& myUnion, const hidl_string& d,
216 setInterfaceD_cb _hidl_cb) {
217 LOG(INFO) << "SERVER(SafeUnion) setInterfaceD(myUnion, " << toString(d) << ")";
218
219 InterfaceTypeSafeUnion myNewUnion = myUnion;
220 myNewUnion.d(d);
221
222 _hidl_cb(myNewUnion);
223 return Void();
224 }
225
setInterfaceE(const InterfaceTypeSafeUnion & myUnion,const hidl_vec<hidl_string> & e,setInterfaceE_cb _hidl_cb)226 Return<void> SafeUnion::setInterfaceE(const InterfaceTypeSafeUnion& myUnion,
227 const hidl_vec<hidl_string>& e, setInterfaceE_cb _hidl_cb) {
228 LOG(INFO) << "SERVER(SafeUnion) setInterfaceE(myUnion, " << toString(e) << ")";
229
230 InterfaceTypeSafeUnion myNewUnion = myUnion;
231 myNewUnion.e(e);
232
233 _hidl_cb(myNewUnion);
234 return Void();
235 }
236
setInterfaceF(const InterfaceTypeSafeUnion & myUnion,const hidl_handle & f,setInterfaceF_cb _hidl_cb)237 Return<void> SafeUnion::setInterfaceF(const InterfaceTypeSafeUnion& myUnion, const hidl_handle& f,
238 setInterfaceF_cb _hidl_cb) {
239 LOG(INFO) << "SERVER(SafeUnion) setInterfaceF(myUnion, " << toString(f) << ")";
240
241 InterfaceTypeSafeUnion myNewUnion = myUnion;
242 myNewUnion.f(f);
243
244 _hidl_cb(myNewUnion);
245 return Void();
246 }
247
setInterfaceG(const InterfaceTypeSafeUnion & myUnion,const hidl_vec<hidl_handle> & g,setInterfaceG_cb _hidl_cb)248 Return<void> SafeUnion::setInterfaceG(const InterfaceTypeSafeUnion& myUnion,
249 const hidl_vec<hidl_handle>& g, setInterfaceG_cb _hidl_cb) {
250 LOG(INFO) << "SERVER(SafeUnion) setInterfaceG(myUnion, " << toString(g) << ")";
251
252 InterfaceTypeSafeUnion myNewUnion = myUnion;
253 myNewUnion.g(g);
254
255 _hidl_cb(myNewUnion);
256 return Void();
257 }
258
newHandleTypeSafeUnion(newHandleTypeSafeUnion_cb _hidl_cb)259 Return<void> SafeUnion::newHandleTypeSafeUnion(newHandleTypeSafeUnion_cb _hidl_cb) {
260 LOG(INFO) << "SERVER(SafeUnion) newHandleTypeSafeUnion()";
261
262 HandleTypeSafeUnion ret;
263 _hidl_cb(ret);
264 return Void();
265 }
266
setHandleA(const::android::hardware::tests::safeunion::V1_0::ISafeUnion::HandleTypeSafeUnion & myUnion,const hidl_handle & a,setHandleA_cb _hidl_cb)267 Return<void> SafeUnion::setHandleA(
268 const ::android::hardware::tests::safeunion::V1_0::ISafeUnion::HandleTypeSafeUnion& myUnion,
269 const hidl_handle& a, setHandleA_cb _hidl_cb) {
270 LOG(INFO) << "SERVER(SafeUnion) setHandleA(myUnion, " << toString(a) << ")";
271
272 HandleTypeSafeUnion myNewUnion = myUnion;
273 myNewUnion.a(a);
274
275 _hidl_cb(myNewUnion);
276 return Void();
277 }
278
setHandleB(const HandleTypeSafeUnion & myUnion,const hidl_array<hidl_handle,5> & b,setHandleB_cb _hidl_cb)279 Return<void> SafeUnion::setHandleB(const HandleTypeSafeUnion& myUnion,
280 const hidl_array<hidl_handle, 5>& b, setHandleB_cb _hidl_cb) {
281 LOG(INFO) << "SERVER(SafeUnion) setHandleB(myUnion, " << toString(b) << ")";
282
283 HandleTypeSafeUnion myNewUnion = myUnion;
284 myNewUnion.b(b);
285
286 _hidl_cb(myNewUnion);
287 return Void();
288 }
289
setHandleC(const HandleTypeSafeUnion & myUnion,const hidl_vec<hidl_handle> & c,setHandleC_cb _hidl_cb)290 Return<void> SafeUnion::setHandleC(const HandleTypeSafeUnion& myUnion,
291 const hidl_vec<hidl_handle>& c, setHandleC_cb _hidl_cb) {
292 LOG(INFO) << "SERVER(SafeUnion) setHandleC(myUnion, " << toString(c) << ")";
293
294 HandleTypeSafeUnion myNewUnion = myUnion;
295 myNewUnion.c(c);
296
297 _hidl_cb(myNewUnion);
298 return Void();
299 }
300
HIDL_FETCH_ISafeUnion(const char *)301 ISafeUnion* HIDL_FETCH_ISafeUnion(const char* /* name */) {
302 return new SafeUnion();
303 }
304
305 } // namespace implementation
306 } // namespace V1_0
307 } // namespace safeunion
308 } // namespace tests
309 } // namespace hardware
310 } // namespace android
311