blob: 77a61adb1e8b1929e49811b00205aa3b388c1e8c [file] [log] [blame]
Chris Phoenixdadccd32016-07-07 14:49:20 -07001// AUTO_GENERATED FILE - DO NOT EDIT
2// see system/tools/hidl/templates/TemplateAll.cpp
Chris Phoenixd55ed642016-07-12 18:43:04 -07003//#include <android/hardware/tests/ITypes.h>
4//#include <android/hardware/tests/BpTypes.h>
5#include <ITypes.h>
6#include <BpTypes.h>
Chris Phoenixdadccd32016-07-07 14:49:20 -07007#include <iostream>
8#include <stdio.h>
9using std::cout;
10using std::endl;
11
12namespace android {
13namespace hardware {
14namespace tests {
15
16
Chris Phoenix60b2bca2016-07-25 13:06:07 -070017IMPLEMENT_HWBINDER_META_INTERFACE(Types, "android.hardware.tests.ITypes");
Chris Phoenixdadccd32016-07-07 14:49:20 -070018
19} // namespace tests
20} // namespace hardware
21} // namespace android
22
23
Chris Phoenixd55ed642016-07-12 18:43:04 -070024//#include <android/hardware/tests/BpTypes.h>
25#include <BpTypes.h>
Chris Phoenixdadccd32016-07-07 14:49:20 -070026#include <binder/Parcel.h>
27
28namespace android {
29namespace hardware {
30namespace tests {
31
32
33BpTypes::BpTypes(const ::android::sp<::android::hidl::IBinder>& _aidl_impl)
34 : BpInterface<ITypes>(_aidl_impl){
35}
36::android::hidl::binder::Status BpTypes::echoInteger(int32_t echo_me, const ITypes::simple_t& my_struct , ITypes::echoInteger_cb _cb ) {
37 ::android::hidl::Parcel _aidl_data;
38 ::android::hidl::Parcel _aidl_reply;
39 ::android::status_t _aidl_ret_status = ::android::OK;
40 ::android::hidl::binder::Status _aidl_status;
41 const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
42 int32_t _cb_ret;
43
44 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
45 if (((_aidl_ret_status) != (::android::OK))) {
46 goto _aidl_error;
47 }
48 _aidl_ret_status = _aidl_data.writeInt32((int32_t)echo_me);
49 if (((_aidl_ret_status) != (::android::OK))) {
50 goto _aidl_error;
51 }
52 {
53 uint64_t parent_handle;
54 _aidl_ret_status = _aidl_data.writeBuffer((void *)&my_struct, sizeof(my_struct), &parent_handle);
55 if (((_aidl_ret_status) != (::android::OK))) {
56 goto _aidl_error;
57 }
58 // struct fixup write_
59
60//field int1 doesn't need fixup
61
62//field int2 doesn't need fixup
63
64 }
65
66 _aidl_ret_status = remote()->transact(ITypes::ECHOINTEGER, _aidl_data, &_aidl_reply);
67 if (((_aidl_ret_status) != (::android::OK))) {
68 goto _aidl_error;
69 }
70 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
71 if (((_aidl_ret_status) != (::android::OK))) {
72 goto _aidl_error;
73 }
74 if (!_aidl_status.isOk()) {
75 return _aidl_status;
76 }
77 _aidl_ret_status = _aidl_reply.readInt32(&_cb_ret);
78 if (((_aidl_ret_status) != (::android::OK))) {
79 goto _aidl_error;
80 }
81
82
83 // Invoke callback to client
84 if (_cb != nullptr)
85 _cb(_cb_ret );
86
87
88_aidl_error:
89 _aidl_status.setFromStatusT(_aidl_ret_status);
90 return _aidl_status;
91}
92::android::hidl::binder::Status BpTypes::echoEnum(eu8 a, es8 b, eu16 c, es16 d, eu32 e, es32 f, eu64 g, es64 h, ec i, ITypes::echoEnum_cb _cb ) {
93 ::android::hidl::Parcel _aidl_data;
94 ::android::hidl::Parcel _aidl_reply;
95 ::android::status_t _aidl_ret_status = ::android::OK;
96 ::android::hidl::binder::Status _aidl_status;
97 const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
98 ITypes::eu8
99 _cb_a;
100ITypes::es8
101 _cb_b;
102ITypes::eu16
103 _cb_c;
104ITypes::es16
105 _cb_d;
106ITypes::eu32
107 _cb_e;
108ITypes::es32
109 _cb_f;
110ITypes::eu64
111 _cb_g;
112ITypes::es64
113 _cb_h;
114ITypes::ec
115 _cb_i;
116
117 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
118 if (((_aidl_ret_status) != (::android::OK))) {
119 goto _aidl_error;
120 }
121 _aidl_ret_status = _aidl_data.writeByte((int8_t)a);
122 if (((_aidl_ret_status) != (::android::OK))) {
123 goto _aidl_error;
124 }
125 _aidl_ret_status = _aidl_data.writeByte((int8_t)b);
126 if (((_aidl_ret_status) != (::android::OK))) {
127 goto _aidl_error;
128 }
129 _aidl_ret_status = _aidl_data.writeChar((char16_t)c);
130 if (((_aidl_ret_status) != (::android::OK))) {
131 goto _aidl_error;
132 }
133 _aidl_ret_status = _aidl_data.writeChar((char16_t)d);
134 if (((_aidl_ret_status) != (::android::OK))) {
135 goto _aidl_error;
136 }
137 _aidl_ret_status = _aidl_data.writeUint32((uint32_t)e);
138 if (((_aidl_ret_status) != (::android::OK))) {
139 goto _aidl_error;
140 }
141 _aidl_ret_status = _aidl_data.writeInt32((int32_t)f);
142 if (((_aidl_ret_status) != (::android::OK))) {
143 goto _aidl_error;
144 }
145 _aidl_ret_status = _aidl_data.writeUint64((uint64_t)g);
146 if (((_aidl_ret_status) != (::android::OK))) {
147 goto _aidl_error;
148 }
149 _aidl_ret_status = _aidl_data.writeInt64((int64_t)h);
150 if (((_aidl_ret_status) != (::android::OK))) {
151 goto _aidl_error;
152 }
153 _aidl_ret_status = _aidl_data.writeByte((int8_t)i);
154 if (((_aidl_ret_status) != (::android::OK))) {
155 goto _aidl_error;
156 }
157
158 _aidl_ret_status = remote()->transact(ITypes::ECHOENUM, _aidl_data, &_aidl_reply);
159 if (((_aidl_ret_status) != (::android::OK))) {
160 goto _aidl_error;
161 }
162 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
163 if (((_aidl_ret_status) != (::android::OK))) {
164 goto _aidl_error;
165 }
166 if (!_aidl_status.isOk()) {
167 return _aidl_status;
168 }
169 _aidl_ret_status = _aidl_reply.readByte((int8_t *)&_cb_a);
170 if (((_aidl_ret_status) != (::android::OK))) {
171 goto _aidl_error;
172 }
173 _aidl_ret_status = _aidl_reply.readByte((int8_t *)&_cb_b);
174 if (((_aidl_ret_status) != (::android::OK))) {
175 goto _aidl_error;
176 }
177 _aidl_ret_status = _aidl_reply.readChar((char16_t *)&_cb_c);
178 if (((_aidl_ret_status) != (::android::OK))) {
179 goto _aidl_error;
180 }
181 _aidl_ret_status = _aidl_reply.readChar((char16_t *)&_cb_d);
182 if (((_aidl_ret_status) != (::android::OK))) {
183 goto _aidl_error;
184 }
185 _aidl_ret_status = _aidl_reply.readUint32((uint32_t *)&_cb_e);
186 if (((_aidl_ret_status) != (::android::OK))) {
187 goto _aidl_error;
188 }
189 _aidl_ret_status = _aidl_reply.readInt32((int32_t *)&_cb_f);
190 if (((_aidl_ret_status) != (::android::OK))) {
191 goto _aidl_error;
192 }
193 _aidl_ret_status = _aidl_reply.readUint64((uint64_t *)&_cb_g);
194 if (((_aidl_ret_status) != (::android::OK))) {
195 goto _aidl_error;
196 }
197 _aidl_ret_status = _aidl_reply.readInt64((int64_t *)&_cb_h);
198 if (((_aidl_ret_status) != (::android::OK))) {
199 goto _aidl_error;
200 }
201 _aidl_ret_status = _aidl_reply.readByte((int8_t *)&_cb_i);
202 if (((_aidl_ret_status) != (::android::OK))) {
203 goto _aidl_error;
204 }
205
206
207 // Invoke callback to client
208 if (_cb != nullptr)
209 _cb(_cb_a , _cb_b , _cb_c , _cb_d , _cb_e , _cb_f , _cb_g , _cb_h , _cb_i );
210
211
212_aidl_error:
213 _aidl_status.setFromStatusT(_aidl_ret_status);
214 return _aidl_status;
215}
216::android::hidl::binder::Status BpTypes::echoScalar(uint8_t a, int8_t b, uint16_t c, int16_t d, uint32_t e, int32_t f, uint64_t g, int64_t h, char i, ITypes::echoScalar_cb _cb ) {
217 ::android::hidl::Parcel _aidl_data;
218 ::android::hidl::Parcel _aidl_reply;
219 ::android::status_t _aidl_ret_status = ::android::OK;
220 ::android::hidl::binder::Status _aidl_status;
221 const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
222 uint8_t _cb_a;
223int8_t _cb_b;
224uint16_t _cb_c;
225int16_t _cb_d;
226uint32_t _cb_e;
227int32_t _cb_f;
228uint64_t _cb_g;
229int64_t _cb_h;
230char _cb_i;
231
232 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
233 if (((_aidl_ret_status) != (::android::OK))) {
234 goto _aidl_error;
235 }
236 _aidl_ret_status = _aidl_data.writeByte((int8_t)a);
237 if (((_aidl_ret_status) != (::android::OK))) {
238 goto _aidl_error;
239 }
240 _aidl_ret_status = _aidl_data.writeByte((int8_t)b);
241 if (((_aidl_ret_status) != (::android::OK))) {
242 goto _aidl_error;
243 }
244 _aidl_ret_status = _aidl_data.writeChar((char16_t)c);
245 if (((_aidl_ret_status) != (::android::OK))) {
246 goto _aidl_error;
247 }
248 _aidl_ret_status = _aidl_data.writeChar((char16_t)d);
249 if (((_aidl_ret_status) != (::android::OK))) {
250 goto _aidl_error;
251 }
252 _aidl_ret_status = _aidl_data.writeUint32((uint32_t)e);
253 if (((_aidl_ret_status) != (::android::OK))) {
254 goto _aidl_error;
255 }
256 _aidl_ret_status = _aidl_data.writeInt32((int32_t)f);
257 if (((_aidl_ret_status) != (::android::OK))) {
258 goto _aidl_error;
259 }
260 _aidl_ret_status = _aidl_data.writeUint64((uint64_t)g);
261 if (((_aidl_ret_status) != (::android::OK))) {
262 goto _aidl_error;
263 }
264 _aidl_ret_status = _aidl_data.writeInt64((int64_t)h);
265 if (((_aidl_ret_status) != (::android::OK))) {
266 goto _aidl_error;
267 }
268 _aidl_ret_status = _aidl_data.writeByte((int8_t)i);
269 if (((_aidl_ret_status) != (::android::OK))) {
270 goto _aidl_error;
271 }
272
273 _aidl_ret_status = remote()->transact(ITypes::ECHOSCALAR, _aidl_data, &_aidl_reply);
274 if (((_aidl_ret_status) != (::android::OK))) {
275 goto _aidl_error;
276 }
277 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
278 if (((_aidl_ret_status) != (::android::OK))) {
279 goto _aidl_error;
280 }
281 if (!_aidl_status.isOk()) {
282 return _aidl_status;
283 }
284 _aidl_ret_status = _aidl_reply.readByte((int8_t*)&_cb_a);
285 if (((_aidl_ret_status) != (::android::OK))) {
286 goto _aidl_error;
287 }
288 _aidl_ret_status = _aidl_reply.readByte(&_cb_b);
289 if (((_aidl_ret_status) != (::android::OK))) {
290 goto _aidl_error;
291 }
292 _aidl_ret_status = _aidl_reply.readChar((char16_t*)&_cb_c);
293 if (((_aidl_ret_status) != (::android::OK))) {
294 goto _aidl_error;
295 }
296 _aidl_ret_status = _aidl_reply.readChar((char16_t*)&_cb_d);
297 if (((_aidl_ret_status) != (::android::OK))) {
298 goto _aidl_error;
299 }
300 _aidl_ret_status = _aidl_reply.readUint32(&_cb_e);
301 if (((_aidl_ret_status) != (::android::OK))) {
302 goto _aidl_error;
303 }
304 _aidl_ret_status = _aidl_reply.readInt32(&_cb_f);
305 if (((_aidl_ret_status) != (::android::OK))) {
306 goto _aidl_error;
307 }
308 _aidl_ret_status = _aidl_reply.readUint64(&_cb_g);
309 if (((_aidl_ret_status) != (::android::OK))) {
310 goto _aidl_error;
311 }
312 _aidl_ret_status = _aidl_reply.readInt64(&_cb_h);
313 if (((_aidl_ret_status) != (::android::OK))) {
314 goto _aidl_error;
315 }
316 _aidl_ret_status = _aidl_reply.readByte((int8_t*)&_cb_i);
317 if (((_aidl_ret_status) != (::android::OK))) {
318 goto _aidl_error;
319 }
320
321
322 // Invoke callback to client
323 if (_cb != nullptr)
324 _cb(_cb_a , _cb_b , _cb_c , _cb_d , _cb_e , _cb_f , _cb_g , _cb_h , _cb_i );
325
326
327_aidl_error:
328 _aidl_status.setFromStatusT(_aidl_ret_status);
329 return _aidl_status;
330}
331::android::hidl::binder::Status BpTypes::echoStruct(const ITypes::s0& s , ITypes::echoStruct_cb _cb ) {
332 ::android::hidl::Parcel _aidl_data;
333 ::android::hidl::Parcel _aidl_reply;
334 ::android::status_t _aidl_ret_status = ::android::OK;
335 ::android::hidl::binder::Status _aidl_status;
336 const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
337 ITypes::s0 *_cb_s ;
338
339 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
340 if (((_aidl_ret_status) != (::android::OK))) {
341 goto _aidl_error;
342 }
343 {
344 uint64_t parent_handle;
345 _aidl_ret_status = _aidl_data.writeBuffer((void *)&s, sizeof(s), &parent_handle);
346 if (((_aidl_ret_status) != (::android::OK))) {
347 goto _aidl_error;
348 }
349 // struct fixup write_
350 // struct fixup write_
351 _aidl_ret_status = _aidl_data.writeEmbeddedBuffer((void *)s.s1m1.str1.buffer,
352 (s.s1m1.str1.length < 0 ? strlen(s.s1m1.str1.buffer)+1 : s.s1m1.str1.length),
353 nullptr, parent_handle,
354 (size_t)((char *)&(s.s1m1.str1.buffer)-(char *)(&s)));
355 if (((_aidl_ret_status) != (::android::OK))) {
356 goto _aidl_error;
357 }
358 {
359 uint64_t child_handle;
360 void *bufp = (void *)s.s1v2.buffer;
361 size_t size = sizeof(ITypes::s1s
362[s.s1v2.count]);
363 size_t off = (size_t)((char *)&(s.s1v2.buffer)-(char *)(&s));
364 _aidl_ret_status = _aidl_data.writeEmbeddedBuffer(bufp,
365 size,
366 &child_handle,
367 parent_handle,
368 off /* offset_calculator */);
369 // Redefining a variable inside braces works like a static stack.
370 uint64_t parent_handle = child_handle;
371 if (((_aidl_ret_status) != (::android::OK))) {
372 goto _aidl_error;
373 }
374 for (size_t i1 = 0; i1 < s.s1v2.count; i1++) {
375 /* fixup_write_vec */
376 // struct fixup write_
377 _aidl_ret_status = _aidl_data.writeEmbeddedBuffer((void *)s.s1v2.buffer[i1].str1.buffer,
378 (s.s1v2.buffer[i1].str1.length < 0 ? strlen(s.s1v2.buffer[i1].str1.buffer)+1 : s.s1v2.buffer[i1].str1.length),
379 nullptr, parent_handle,
380 (size_t)((char *)&(s.s1v2.buffer[i1].str1.buffer)-(char *)(s.s1v2.buffer)));
381 if (((_aidl_ret_status) != (::android::OK))) {
382 goto _aidl_error;
383 }
384
385 }
386
387 }
388
389 }
390
391 _aidl_ret_status = remote()->transact(ITypes::ECHOSTRUCT, _aidl_data, &_aidl_reply);
392 if (((_aidl_ret_status) != (::android::OK))) {
393 goto _aidl_error;
394 }
395 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
396 if (((_aidl_ret_status) != (::android::OK))) {
397 goto _aidl_error;
398 }
399 if (!_aidl_status.isOk()) {
400 return _aidl_status;
401 }
402 {
403 uint64_t parent_handle;
404 _cb_s = (ITypes::s0 *)_aidl_reply.readBuffer(&parent_handle);
405 if ((_cb_s) == nullptr) {
406 goto _aidl_error;
407 }
408 // struct fixup read_ret_
409 // struct fixup read_ret_
Chris Phoenixd55ed642016-07-12 18:43:04 -0700410 _aidl_ret_pointer = _aidl_reply.readEmbeddedBuffer(nullptr, parent_handle,
Chris Phoenixdadccd32016-07-07 14:49:20 -0700411 (size_t)((char *)&((*_cb_s).s1m1.str1.buffer)-(char *)(&(*_cb_s))));
412 if (_aidl_ret_pointer == nullptr) {
413 goto _aidl_error;
414 }
415 {
416 uint64_t child_handle;
Chris Phoenixd55ed642016-07-12 18:43:04 -0700417 _aidl_ret_pointer = _aidl_reply.readEmbeddedBuffer(&child_handle, parent_handle,
Chris Phoenixdadccd32016-07-07 14:49:20 -0700418 (size_t)((char *)&((*_cb_s).s1v2.buffer)-(char *)(&(*_cb_s))));
419 // Redefining a variable inside braces works like a static stack.
420 uint64_t parent_handle = child_handle;
421 if (_aidl_ret_pointer == nullptr) {
422 goto _aidl_error;
423 }
424 for (size_t i1 = 0; i1 < (*_cb_s).s1v2.count; i1++) {
425 /* fixup_write_vec */
426 // struct fixup read_ret_
Chris Phoenixd55ed642016-07-12 18:43:04 -0700427 _aidl_ret_pointer = _aidl_reply.readEmbeddedBuffer(nullptr, parent_handle,
Chris Phoenixdadccd32016-07-07 14:49:20 -0700428 (size_t)((char *)&((*_cb_s).s1v2.buffer[i1].str1.buffer)-(char *)((*_cb_s).s1v2.buffer)));
429 if (_aidl_ret_pointer == nullptr) {
430 goto _aidl_error;
431 }
432
433 }
434
435 }
436
437 }
438
439
440 // Invoke callback to client
441 if (_cb != nullptr)
442 _cb(*_cb_s );
443
444
445_aidl_error:
446 _aidl_status.setFromStatusT(_aidl_ret_status);
447 return _aidl_status;
448}
449::android::hidl::binder::Status BpTypes::shareBufferWithRef(hidl_ref<lots_of_data> buffer, ITypes::shareBufferWithRef_cb _cb ) {
450 ::android::hidl::Parcel _aidl_data;
451 ::android::hidl::Parcel _aidl_reply;
452 ::android::status_t _aidl_ret_status = ::android::OK;
453 ::android::hidl::binder::Status _aidl_status;
454 const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
455 int32_t _cb_ret;
456
457 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
458 if (((_aidl_ret_status) != (::android::OK))) {
459 goto _aidl_error;
460 }
461 _aidl_ret_status = _aidl_data.writeFileDescriptor(buffer);
462 if (((_aidl_ret_status) != (::android::OK))) {
463 goto _aidl_error;
464 }
465
466 _aidl_ret_status = remote()->transact(ITypes::SHAREBUFFERWITHREF, _aidl_data, &_aidl_reply);
467 if (((_aidl_ret_status) != (::android::OK))) {
468 goto _aidl_error;
469 }
470 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
471 if (((_aidl_ret_status) != (::android::OK))) {
472 goto _aidl_error;
473 }
474 if (!_aidl_status.isOk()) {
475 return _aidl_status;
476 }
477 _aidl_ret_status = _aidl_reply.readInt32(&_cb_ret);
478 if (((_aidl_ret_status) != (::android::OK))) {
479 goto _aidl_error;
480 }
481
482
483 // Invoke callback to client
484 if (_cb != nullptr)
485 _cb(_cb_ret );
486
487
488_aidl_error:
489 _aidl_status.setFromStatusT(_aidl_ret_status);
490 return _aidl_status;
491}
492::android::hidl::binder::Status BpTypes::getHash(ITypes::getHash_cb _cb ) {
493 ::android::hidl::Parcel _aidl_data;
494 ::android::hidl::Parcel _aidl_reply;
495 ::android::status_t _aidl_ret_status = ::android::OK;
496 ::android::hidl::binder::Status _aidl_status;
497 const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
498 uint64_t _cb_hash;
499
500 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
501 if (((_aidl_ret_status) != (::android::OK))) {
502 goto _aidl_error;
503 }
504
505 _aidl_ret_status = remote()->transact(ITypes::GETHASH, _aidl_data, &_aidl_reply);
506 if (((_aidl_ret_status) != (::android::OK))) {
507 goto _aidl_error;
508 }
509 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
510 if (((_aidl_ret_status) != (::android::OK))) {
511 goto _aidl_error;
512 }
513 if (!_aidl_status.isOk()) {
514 return _aidl_status;
515 }
516 _aidl_ret_status = _aidl_reply.readUint64(&_cb_hash);
517 if (((_aidl_ret_status) != (::android::OK))) {
518 goto _aidl_error;
519 }
520
521
522 // Invoke callback to client
523 if (_cb != nullptr)
524 _cb(_cb_hash );
525
526
527_aidl_error:
528 _aidl_status.setFromStatusT(_aidl_ret_status);
529 return _aidl_status;
530}
531::android::hidl::binder::Status BpTypes::quit() {
532 ::android::hidl::Parcel _aidl_data;
533 ::android::hidl::Parcel _aidl_reply;
534 ::android::status_t _aidl_ret_status = ::android::OK;
535 ::android::hidl::binder::Status _aidl_status;
536 const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
537
538 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
539 if (((_aidl_ret_status) != (::android::OK))) {
540 goto _aidl_error;
541 }
542
543 _aidl_ret_status = remote()->transact(ITypes::QUIT, _aidl_data, &_aidl_reply);
544 if (((_aidl_ret_status) != (::android::OK))) {
545 goto _aidl_error;
546 }
547 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
548 if (((_aidl_ret_status) != (::android::OK))) {
549 goto _aidl_error;
550 }
551 if (!_aidl_status.isOk()) {
552 return _aidl_status;
553 }
554
555
556
557
558_aidl_error:
559 _aidl_status.setFromStatusT(_aidl_ret_status);
560 return _aidl_status;
561}
562
563
564} // namespace tests
565} // namespace hardware
566} // namespace android
567
568
569//
Chris Phoenixd55ed642016-07-12 18:43:04 -0700570//#include <android/hardware/tests/ITypes.h>
571//#include <android/hardware/tests/BpTypes.h>
572#include <ITypes.h>
573#include <BpTypes.h>
Chris Phoenixdadccd32016-07-07 14:49:20 -0700574
575
576#include <iostream>
Chris Phoenixd55ed642016-07-12 18:43:04 -0700577//#include <android/hardware/tests/BnTypes.h>
578#include <BnTypes.h>
Chris Phoenixdadccd32016-07-07 14:49:20 -0700579#include <binder/Parcel.h>
580
581namespace android {
582namespace hardware {
583namespace tests {
584
585
586::android::status_t BnTypes::onTransact(uint32_t _aidl_code, const ::android::hidl::Parcel& _aidl_data, ::android::hidl::Parcel* _aidl_reply, uint32_t _aidl_flags, TransactCallback _cb) {
587 ::android::status_t _aidl_ret_status = ::android::OK;
588 const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
589 switch (_aidl_code) {
590 case Call::ECHOINTEGER:
591 {
592int32_t echo_me;
593 ITypes::simple_t *my_struct ;
594
595 bool callback_called;
596 if (!(_aidl_data.checkInterface(this))) {
597 _aidl_ret_status = ::android::BAD_TYPE;
598 break;
599 }
600 _aidl_ret_status = _aidl_data.readInt32(&echo_me);
601 if (((_aidl_ret_status) != (::android::OK))) {
602 break;
603 }
604 {
605 uint64_t parent_handle;
606 my_struct = (ITypes::simple_t *)_aidl_data.readBuffer(&parent_handle);
607 if ((my_struct) == nullptr) {
608 break;
609 }
610 // struct fixup read_
611
612//field int1 doesn't need fixup
613
614//field int2 doesn't need fixup
615
616 }
617
618 // Make the call into the server
619 ::android::hidl::binder::Status _aidl_status(
620 echoInteger(echo_me , *my_struct , [&](auto ret ) {
621 callback_called = true;
622 // Write "OK" to parcel
623 ::android::hidl::binder::Status::ok().writeToParcel(_aidl_reply);
624 // Serialize
625 _aidl_reply->writeInt32(ret);
626
627 // Callback
628 _cb(*_aidl_reply);
629 }
630));
631
632//
633
634 if (!callback_called) {
635 // Callback not called, the call must have returned an error
636 // TODO set something like ERR_NO_CALLBACK if the call retuned OK
637 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
638 }
639
640 break;
641 }
642 case Call::ECHOENUM:
643 {
644ITypes::eu8
645 a;
646ITypes::es8
647 b;
648ITypes::eu16
649 c;
650ITypes::es16
651 d;
652ITypes::eu32
653 e;
654ITypes::es32
655 f;
656ITypes::eu64
657 g;
658ITypes::es64
659 h;
660ITypes::ec
661 i;
662
663 bool callback_called;
664 if (!(_aidl_data.checkInterface(this))) {
665 _aidl_ret_status = ::android::BAD_TYPE;
666 break;
667 }
668 _aidl_ret_status = _aidl_data.readByte((int8_t *)&a);
669 if (((_aidl_ret_status) != (::android::OK))) {
670 break;
671 }
672 _aidl_ret_status = _aidl_data.readByte((int8_t *)&b);
673 if (((_aidl_ret_status) != (::android::OK))) {
674 break;
675 }
676 _aidl_ret_status = _aidl_data.readChar((char16_t *)&c);
677 if (((_aidl_ret_status) != (::android::OK))) {
678 break;
679 }
680 _aidl_ret_status = _aidl_data.readChar((char16_t *)&d);
681 if (((_aidl_ret_status) != (::android::OK))) {
682 break;
683 }
684 _aidl_ret_status = _aidl_data.readUint32((uint32_t *)&e);
685 if (((_aidl_ret_status) != (::android::OK))) {
686 break;
687 }
688 _aidl_ret_status = _aidl_data.readInt32((int32_t *)&f);
689 if (((_aidl_ret_status) != (::android::OK))) {
690 break;
691 }
692 _aidl_ret_status = _aidl_data.readUint64((uint64_t *)&g);
693 if (((_aidl_ret_status) != (::android::OK))) {
694 break;
695 }
696 _aidl_ret_status = _aidl_data.readInt64((int64_t *)&h);
697 if (((_aidl_ret_status) != (::android::OK))) {
698 break;
699 }
700 _aidl_ret_status = _aidl_data.readByte((int8_t *)&i);
701 if (((_aidl_ret_status) != (::android::OK))) {
702 break;
703 }
704
705 // Make the call into the server
706 ::android::hidl::binder::Status _aidl_status(
707 echoEnum(a , b , c , d , e , f , g , h , i , [&](auto a , auto b , auto c , auto d , auto e , auto f , auto g , auto h , auto i ) {
708 callback_called = true;
709 // Write "OK" to parcel
710 ::android::hidl::binder::Status::ok().writeToParcel(_aidl_reply);
711 // Serialize
712 _aidl_ret_status = _aidl_reply->writeByte((int8_t)a);
713 if (((_aidl_ret_status) != (::android::OK))) {
714 return;
715 }
716 _aidl_ret_status = _aidl_reply->writeByte((int8_t)b);
717 if (((_aidl_ret_status) != (::android::OK))) {
718 return;
719 }
720 _aidl_ret_status = _aidl_reply->writeChar((char16_t)c);
721 if (((_aidl_ret_status) != (::android::OK))) {
722 return;
723 }
724 _aidl_ret_status = _aidl_reply->writeChar((char16_t)d);
725 if (((_aidl_ret_status) != (::android::OK))) {
726 return;
727 }
728 _aidl_ret_status = _aidl_reply->writeUint32((uint32_t)e);
729 if (((_aidl_ret_status) != (::android::OK))) {
730 return;
731 }
732 _aidl_ret_status = _aidl_reply->writeInt32((int32_t)f);
733 if (((_aidl_ret_status) != (::android::OK))) {
734 return;
735 }
736 _aidl_ret_status = _aidl_reply->writeUint64((uint64_t)g);
737 if (((_aidl_ret_status) != (::android::OK))) {
738 return;
739 }
740 _aidl_ret_status = _aidl_reply->writeInt64((int64_t)h);
741 if (((_aidl_ret_status) != (::android::OK))) {
742 return;
743 }
744 _aidl_ret_status = _aidl_reply->writeByte((int8_t)i);
745 if (((_aidl_ret_status) != (::android::OK))) {
746 return;
747 }
748
749 // Callback
750 _cb(*_aidl_reply);
751 }
752));
753
754//
755
756 if (!callback_called) {
757 // Callback not called, the call must have returned an error
758 // TODO set something like ERR_NO_CALLBACK if the call retuned OK
759 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
760 }
761
762 break;
763 }
764 case Call::ECHOSCALAR:
765 {
766uint8_t a;
767int8_t b;
768uint16_t c;
769int16_t d;
770uint32_t e;
771int32_t f;
772uint64_t g;
773int64_t h;
774char i;
775
776 bool callback_called;
777 if (!(_aidl_data.checkInterface(this))) {
778 _aidl_ret_status = ::android::BAD_TYPE;
779 break;
780 }
781 _aidl_ret_status = _aidl_data.readByte((int8_t*)&a);
782 if (((_aidl_ret_status) != (::android::OK))) {
783 break;
784 }
785 _aidl_ret_status = _aidl_data.readByte(&b);
786 if (((_aidl_ret_status) != (::android::OK))) {
787 break;
788 }
789 _aidl_ret_status = _aidl_data.readChar((char16_t*)&c);
790 if (((_aidl_ret_status) != (::android::OK))) {
791 break;
792 }
793 _aidl_ret_status = _aidl_data.readChar((char16_t*)&d);
794 if (((_aidl_ret_status) != (::android::OK))) {
795 break;
796 }
797 _aidl_ret_status = _aidl_data.readUint32(&e);
798 if (((_aidl_ret_status) != (::android::OK))) {
799 break;
800 }
801 _aidl_ret_status = _aidl_data.readInt32(&f);
802 if (((_aidl_ret_status) != (::android::OK))) {
803 break;
804 }
805 _aidl_ret_status = _aidl_data.readUint64(&g);
806 if (((_aidl_ret_status) != (::android::OK))) {
807 break;
808 }
809 _aidl_ret_status = _aidl_data.readInt64(&h);
810 if (((_aidl_ret_status) != (::android::OK))) {
811 break;
812 }
813 _aidl_ret_status = _aidl_data.readByte((int8_t*)&i);
814 if (((_aidl_ret_status) != (::android::OK))) {
815 break;
816 }
817
818 // Make the call into the server
819 ::android::hidl::binder::Status _aidl_status(
820 echoScalar(a , b , c , d , e , f , g , h , i , [&](auto a , auto b , auto c , auto d , auto e , auto f , auto g , auto h , auto i ) {
821 callback_called = true;
822 // Write "OK" to parcel
823 ::android::hidl::binder::Status::ok().writeToParcel(_aidl_reply);
824 // Serialize
825 _aidl_reply->writeByte((int8_t)a);
826 _aidl_reply->writeByte(b);
827 _aidl_reply->writeChar((char16_t)c);
828 _aidl_reply->writeChar((char16_t)d);
829 _aidl_reply->writeUint32(e);
830 _aidl_reply->writeInt32(f);
831 _aidl_reply->writeUint64(g);
832 _aidl_reply->writeInt64(h);
833 _aidl_reply->writeByte((int8_t)i);
834
835 // Callback
836 _cb(*_aidl_reply);
837 }
838));
839
840//
841
842 if (!callback_called) {
843 // Callback not called, the call must have returned an error
844 // TODO set something like ERR_NO_CALLBACK if the call retuned OK
845 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
846 }
847
848 break;
849 }
850 case Call::ECHOSTRUCT:
851 {
852 ITypes::s0 *s ;
853
854 bool callback_called;
855 if (!(_aidl_data.checkInterface(this))) {
856 _aidl_ret_status = ::android::BAD_TYPE;
857 break;
858 }
859 {
860 uint64_t parent_handle;
861 s = (ITypes::s0 *)_aidl_data.readBuffer(&parent_handle);
862 if ((s) == nullptr) {
863 break;
864 }
865 // struct fixup read_
866 // struct fixup read_
867 _aidl_ret_pointer = _aidl_data.readEmbeddedBuffer(nullptr, parent_handle,
868 (size_t)((char *)&((*s).s1m1.str1.buffer)-(char *)(&(*s))));
869 if (_aidl_ret_pointer == nullptr) {
870 break;
871 }
872 {
873 uint64_t child_handle;
874 _aidl_ret_pointer = _aidl_data.readEmbeddedBuffer(&child_handle, parent_handle,
875 (size_t)((char *)&((*s).s1v2.buffer)-(char *)(&(*s))));
876 // Redefining a variable inside braces works like a static stack.
877 uint64_t parent_handle = child_handle;
878 if (_aidl_ret_pointer == nullptr) {
879 break;
880 }
881 for (size_t i1 = 0; i1 < (*s).s1v2.count; i1++) {
882 /* fixup_write_vec */
883 // struct fixup read_
884 _aidl_ret_pointer = _aidl_data.readEmbeddedBuffer(nullptr, parent_handle,
885 (size_t)((char *)&((*s).s1v2.buffer[i1].str1.buffer)-(char *)((*s).s1v2.buffer)));
886 if (_aidl_ret_pointer == nullptr) {
887 break;
888 }
889
890 }
891
892 }
893
894 }
895
896 // Make the call into the server
897 ::android::hidl::binder::Status _aidl_status(
898 echoStruct(*s , [&](const ITypes::s0 & s ) {
899 callback_called = true;
900 // Write "OK" to parcel
901 ::android::hidl::binder::Status::ok().writeToParcel(_aidl_reply);
902 // Serialize
903 {
904 uint64_t parent_handle;
905 _aidl_ret_status = _aidl_reply->writeBuffer((void *)&s, sizeof(s), &parent_handle);
906 // struct fixup write_ret_
907 // struct fixup write_ret_
908 _aidl_ret_status = _aidl_reply->writeEmbeddedBuffer((void *)s.s1m1.str1.buffer,
909 (s.s1m1.str1.length < 0 ? strlen(s.s1m1.str1.buffer)+1 : s.s1m1.str1.length),
910 nullptr, parent_handle,
911 (size_t)((char *)&(s.s1m1.str1.buffer)-(char *)(&s)));
912 {
913 uint64_t child_handle;
914 void *bufp = (void *)s.s1v2.buffer;
915 size_t size = sizeof(ITypes::s1s
916[s.s1v2.count]);
917 size_t off = (size_t)((char *)&(s.s1v2.buffer)-(char *)(&s));
918 _aidl_ret_status = _aidl_reply->writeEmbeddedBuffer(bufp,
919 size,
920 &child_handle,
921 parent_handle,
922 off /* offset_calculator */);
923 // Redefining a variable inside braces works like a static stack.
924 uint64_t parent_handle = child_handle;
925 for (size_t i1 = 0; i1 < s.s1v2.count; i1++) {
926 /* fixup_write_vec */
927 // struct fixup write_ret_
928 _aidl_ret_status = _aidl_reply->writeEmbeddedBuffer((void *)s.s1v2.buffer[i1].str1.buffer,
929 (s.s1v2.buffer[i1].str1.length < 0 ? strlen(s.s1v2.buffer[i1].str1.buffer)+1 : s.s1v2.buffer[i1].str1.length),
930 nullptr, parent_handle,
931 (size_t)((char *)&(s.s1v2.buffer[i1].str1.buffer)-(char *)(s.s1v2.buffer)));
932
933 }
934
935 }
936
937 }
938
939 // Callback
940 _cb(*_aidl_reply);
941 }
942));
943
944//
945
946 if (!callback_called) {
947 // Callback not called, the call must have returned an error
948 // TODO set something like ERR_NO_CALLBACK if the call retuned OK
949 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
950 }
951
952 break;
953 }
954 case Call::SHAREBUFFERWITHREF:
955 {
956hidl_ref<lots_of_data> buffer;
957
958 bool callback_called;
959 if (!(_aidl_data.checkInterface(this))) {
960 _aidl_ret_status = ::android::BAD_TYPE;
961 break;
962 }
963 buffer = _aidl_data.readFileDescriptor();
964
965 // Make the call into the server
966 ::android::hidl::binder::Status _aidl_status(
967 shareBufferWithRef(buffer , [&](auto ret ) {
968 callback_called = true;
969 // Write "OK" to parcel
970 ::android::hidl::binder::Status::ok().writeToParcel(_aidl_reply);
971 // Serialize
972 _aidl_reply->writeInt32(ret);
973
974 // Callback
975 _cb(*_aidl_reply);
976 }
977));
978
979//
980
981 if (!callback_called) {
982 // Callback not called, the call must have returned an error
983 // TODO set something like ERR_NO_CALLBACK if the call retuned OK
984 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
985 }
986
987 break;
988 }
989 case Call::GETHASH:
990 {
991
992 bool callback_called;
993 if (!(_aidl_data.checkInterface(this))) {
994 _aidl_ret_status = ::android::BAD_TYPE;
995 break;
996 }
997
998 // Make the call into the server
999 ::android::hidl::binder::Status _aidl_status(
1000 getHash( [&](auto hash ) {
1001 callback_called = true;
1002 // Write "OK" to parcel
1003 ::android::hidl::binder::Status::ok().writeToParcel(_aidl_reply);
1004 // Serialize
1005 _aidl_reply->writeUint64(hash);
1006
1007 // Callback
1008 _cb(*_aidl_reply);
1009 }
1010));
1011
1012//
1013
1014 if (!callback_called) {
1015 // Callback not called, the call must have returned an error
1016 // TODO set something like ERR_NO_CALLBACK if the call retuned OK
1017 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
1018 }
1019
1020 break;
1021 }
1022 case Call::QUIT:
1023 {
1024
1025 bool callback_called;
1026 if (!(_aidl_data.checkInterface(this))) {
1027 _aidl_ret_status = ::android::BAD_TYPE;
1028 break;
1029 }
1030
1031 // Make the call into the server
1032 ::android::hidl::binder::Status _aidl_status(
1033 quit());
1034
1035//
1036
1037
1038 break;
1039 }
1040
1041 default:
1042 {
1043 _aidl_ret_status = ::android::hidl::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
1044 }
1045 break;
1046 }
1047 if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
1048 _aidl_ret_status = ::android::hidl::binder::Status::fromExceptionCode(::android::hidl::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
1049 }
1050 return _aidl_ret_status;
1051}
1052
1053} // namespace tests
1054} // namespace hardware
1055} // namespace android
1056