blob: a9ba8cd1b8198d5e7d82752eccbc90fd5cf9d532 [file] [log] [blame]
Casey Dahlina834dd42015-09-23 11:52:15 -07001/*
2 * Copyright (C) 2015, 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 <string>
18
Elliott Hughes0a620672015-12-04 13:53:18 -080019#include <android-base/stringprintf.h>
Casey Dahlina834dd42015-09-23 11:52:15 -070020#include <gtest/gtest.h>
21
Casey Dahlin2cc93162015-10-02 16:14:17 -070022#include "aidl.h"
Casey Dahlina834dd42015-09-23 11:52:15 -070023#include "aidl_language.h"
24#include "ast_cpp.h"
25#include "code_writer.h"
Christopher Wileyad339272015-10-05 19:11:58 -070026#include "generate_cpp.h"
Christopher Wiley9d6e0b22015-11-13 12:18:16 -080027#include "os.h"
Christopher Wiley4a2884b2015-10-07 11:27:45 -070028#include "tests/fake_io_delegate.h"
Casey Dahlin80ada3d2015-10-20 20:33:56 -070029#include "tests/test_util.h"
Christopher Wileye3550c62015-09-29 13:26:10 -070030#include "type_cpp.h"
Casey Dahlina834dd42015-09-23 11:52:15 -070031
Casey Dahlinb8d9e882015-11-24 10:57:23 -080032using ::android::aidl::test::FakeIoDelegate;
33using ::android::base::StringPrintf;
Casey Dahlina834dd42015-09-23 11:52:15 -070034using std::string;
35using std::unique_ptr;
36
37namespace android {
38namespace aidl {
Christopher Wileyf944e792015-09-29 10:00:46 -070039namespace cpp {
Casey Dahlina834dd42015-09-23 11:52:15 -070040namespace {
41
Casey Dahlinb0966612015-10-19 16:35:26 -070042const string kComplexTypeInterfaceAIDL =
43R"(package android.os;
Casey Dahlin389781f2015-10-22 13:13:21 -070044import foo.IFooType;
Casey Dahlinb0966612015-10-19 16:35:26 -070045interface IComplexTypeInterface {
Casey Dahlind40e2fe2015-11-24 14:06:52 -080046 const int MY_CONSTANT = 3;
Casey Dahlincb5317d2015-12-03 15:43:33 -080047 int[] Send(in @nullable int[] goes_in, inout double[] goes_in_and_out, out boolean[] goes_out);
Casey Dahlin0dd08af2015-10-20 18:45:50 -070048 oneway void Piff(int times);
Casey Dahlin389781f2015-10-22 13:13:21 -070049 IFooType TakesABinder(IFooType f);
Casey Dahlinef88bce2016-04-15 11:55:30 -070050 @nullable IFooType NullableBinder();
Christopher Wiley56c9bf32015-10-30 10:41:12 -070051 List<String> StringListMethod(in java.util.List<String> input, out List<String> output);
Casey Dahlin7ecd69f2015-11-03 13:52:38 -080052 List<IBinder> BinderListMethod(in java.util.List<IBinder> input, out List<IBinder> output);
Casey Dahlina4ba4b62015-11-02 15:43:30 -080053 FileDescriptor TakesAFileDescriptor(in FileDescriptor f);
54 FileDescriptor[] TakesAFileDescriptorArray(in FileDescriptor[] f);
Casey Dahlinb0966612015-10-19 16:35:26 -070055})";
56
57const char kExpectedComplexTypeClientHeaderOutput[] =
58R"(#ifndef AIDL_GENERATED_ANDROID_OS_BP_COMPLEX_TYPE_INTERFACE_H_
59#define AIDL_GENERATED_ANDROID_OS_BP_COMPLEX_TYPE_INTERFACE_H_
60
61#include <binder/IBinder.h>
62#include <binder/IInterface.h>
63#include <utils/Errors.h>
64#include <android/os/IComplexTypeInterface.h>
65
66namespace android {
67
68namespace os {
69
Casey Dahlinb8d9e882015-11-24 10:57:23 -080070class BpComplexTypeInterface : public ::android::BpInterface<IComplexTypeInterface> {
Casey Dahlinb0966612015-10-19 16:35:26 -070071public:
Jiyong Parka755dc72018-06-29 13:52:24 +090072 explicit BpComplexTypeInterface(const ::android::sp<::android::IBinder>& _aidl_impl);
73 virtual ~BpComplexTypeInterface() = default;
74 ::android::binder::Status Send(const ::std::unique_ptr<::std::vector<int32_t>>& goes_in, ::std::vector<double>* goes_in_and_out, ::std::vector<bool>* goes_out, ::std::vector<int32_t>* _aidl_return) override;
75 ::android::binder::Status Piff(int32_t times) override;
76 ::android::binder::Status TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) override;
77 ::android::binder::Status NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) override;
78 ::android::binder::Status StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) override;
79 ::android::binder::Status BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>& input, ::std::vector<::android::sp<::android::IBinder>>* output, ::std::vector<::android::sp<::android::IBinder>>* _aidl_return) override;
80 ::android::binder::Status TakesAFileDescriptor(const ::android::base::unique_fd& f, ::android::base::unique_fd* _aidl_return) override;
81 ::android::binder::Status TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) override;
Casey Dahlinb0966612015-10-19 16:35:26 -070082}; // class BpComplexTypeInterface
83
84} // namespace os
85
86} // namespace android
87
Christopher Wiley11a9d792016-02-24 17:20:33 -080088#endif // AIDL_GENERATED_ANDROID_OS_BP_COMPLEX_TYPE_INTERFACE_H_
89)";
Casey Dahlinb0966612015-10-19 16:35:26 -070090
91const char kExpectedComplexTypeClientSourceOutput[] =
Jiyong Park75e1a742018-07-04 12:31:23 +090092 R"(#include <android/os/BpComplexTypeInterface.h>
Casey Dahlinb0966612015-10-19 16:35:26 -070093#include <binder/Parcel.h>
Jiyong Park75e1a742018-07-04 12:31:23 +090094#include <android-base/macros.h>
Casey Dahlinb0966612015-10-19 16:35:26 -070095
96namespace android {
97
98namespace os {
99
Casey Dahlinb8d9e882015-11-24 10:57:23 -0800100BpComplexTypeInterface::BpComplexTypeInterface(const ::android::sp<::android::IBinder>& _aidl_impl)
101 : BpInterface<IComplexTypeInterface>(_aidl_impl){
Casey Dahlinb0966612015-10-19 16:35:26 -0700102}
103
Casey Dahlin57dbe242015-12-04 11:44:02 -0800104::android::binder::Status BpComplexTypeInterface::Send(const ::std::unique_ptr<::std::vector<int32_t>>& goes_in, ::std::vector<double>* goes_in_and_out, ::std::vector<bool>* goes_out, ::std::vector<int32_t>* _aidl_return) {
Jiyong Parka755dc72018-06-29 13:52:24 +0900105 ::android::Parcel _aidl_data;
106 ::android::Parcel _aidl_reply;
107 ::android::status_t _aidl_ret_status = ::android::OK;
108 ::android::binder::Status _aidl_status;
109 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
110 if (((_aidl_ret_status) != (::android::OK))) {
111 goto _aidl_error;
112 }
113 _aidl_ret_status = _aidl_data.writeInt32Vector(goes_in);
114 if (((_aidl_ret_status) != (::android::OK))) {
115 goto _aidl_error;
116 }
117 _aidl_ret_status = _aidl_data.writeDoubleVector(*goes_in_and_out);
118 if (((_aidl_ret_status) != (::android::OK))) {
119 goto _aidl_error;
120 }
121 _aidl_ret_status = _aidl_data.writeVectorSize(*goes_out);
122 if (((_aidl_ret_status) != (::android::OK))) {
123 goto _aidl_error;
124 }
Jeongik Chab5d962f2018-11-17 09:12:28 +0900125 _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* Send */, _aidl_data, &_aidl_reply);
Jiyong Park75e1a742018-07-04 12:31:23 +0900126 if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
127 return IComplexTypeInterface::getDefaultImpl()->Send(goes_in, goes_in_and_out, goes_out, _aidl_return);
128 }
Jiyong Parka755dc72018-06-29 13:52:24 +0900129 if (((_aidl_ret_status) != (::android::OK))) {
130 goto _aidl_error;
131 }
132 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
133 if (((_aidl_ret_status) != (::android::OK))) {
134 goto _aidl_error;
135 }
136 if (!_aidl_status.isOk()) {
137 return _aidl_status;
138 }
139 _aidl_ret_status = _aidl_reply.readInt32Vector(_aidl_return);
140 if (((_aidl_ret_status) != (::android::OK))) {
141 goto _aidl_error;
142 }
143 _aidl_ret_status = _aidl_reply.readDoubleVector(goes_in_and_out);
144 if (((_aidl_ret_status) != (::android::OK))) {
145 goto _aidl_error;
146 }
147 _aidl_ret_status = _aidl_reply.readBoolVector(goes_out);
148 if (((_aidl_ret_status) != (::android::OK))) {
149 goto _aidl_error;
150 }
151 _aidl_error:
152 _aidl_status.setFromStatusT(_aidl_ret_status);
153 return _aidl_status;
Casey Dahlinb0966612015-10-19 16:35:26 -0700154}
155
Casey Dahlinb8d9e882015-11-24 10:57:23 -0800156::android::binder::Status BpComplexTypeInterface::Piff(int32_t times) {
Jiyong Parka755dc72018-06-29 13:52:24 +0900157 ::android::Parcel _aidl_data;
158 ::android::Parcel _aidl_reply;
159 ::android::status_t _aidl_ret_status = ::android::OK;
160 ::android::binder::Status _aidl_status;
161 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
162 if (((_aidl_ret_status) != (::android::OK))) {
163 goto _aidl_error;
164 }
165 _aidl_ret_status = _aidl_data.writeInt32(times);
166 if (((_aidl_ret_status) != (::android::OK))) {
167 goto _aidl_error;
168 }
Jeongik Chab5d962f2018-11-17 09:12:28 +0900169 _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* Piff */, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_ONEWAY);
Jiyong Park75e1a742018-07-04 12:31:23 +0900170 if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
171 return IComplexTypeInterface::getDefaultImpl()->Piff(times);
172 }
Jiyong Parka755dc72018-06-29 13:52:24 +0900173 if (((_aidl_ret_status) != (::android::OK))) {
174 goto _aidl_error;
175 }
176 _aidl_error:
177 _aidl_status.setFromStatusT(_aidl_ret_status);
178 return _aidl_status;
Casey Dahlin0dd08af2015-10-20 18:45:50 -0700179}
180
Casey Dahlinb8d9e882015-11-24 10:57:23 -0800181::android::binder::Status BpComplexTypeInterface::TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) {
Jiyong Parka755dc72018-06-29 13:52:24 +0900182 ::android::Parcel _aidl_data;
183 ::android::Parcel _aidl_reply;
184 ::android::status_t _aidl_ret_status = ::android::OK;
185 ::android::binder::Status _aidl_status;
186 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
187 if (((_aidl_ret_status) != (::android::OK))) {
188 goto _aidl_error;
189 }
190 _aidl_ret_status = _aidl_data.writeStrongBinder(::foo::IFooType::asBinder(f));
191 if (((_aidl_ret_status) != (::android::OK))) {
192 goto _aidl_error;
193 }
Jeongik Chab5d962f2018-11-17 09:12:28 +0900194 _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* TakesABinder */, _aidl_data, &_aidl_reply);
Jiyong Park75e1a742018-07-04 12:31:23 +0900195 if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
196 return IComplexTypeInterface::getDefaultImpl()->TakesABinder(f, _aidl_return);
197 }
Jiyong Parka755dc72018-06-29 13:52:24 +0900198 if (((_aidl_ret_status) != (::android::OK))) {
199 goto _aidl_error;
200 }
201 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
202 if (((_aidl_ret_status) != (::android::OK))) {
203 goto _aidl_error;
204 }
205 if (!_aidl_status.isOk()) {
206 return _aidl_status;
207 }
208 _aidl_ret_status = _aidl_reply.readStrongBinder(_aidl_return);
209 if (((_aidl_ret_status) != (::android::OK))) {
210 goto _aidl_error;
211 }
212 _aidl_error:
213 _aidl_status.setFromStatusT(_aidl_ret_status);
214 return _aidl_status;
Casey Dahlin389781f2015-10-22 13:13:21 -0700215}
216
Casey Dahlinef88bce2016-04-15 11:55:30 -0700217::android::binder::Status BpComplexTypeInterface::NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) {
Jiyong Parka755dc72018-06-29 13:52:24 +0900218 ::android::Parcel _aidl_data;
219 ::android::Parcel _aidl_reply;
220 ::android::status_t _aidl_ret_status = ::android::OK;
221 ::android::binder::Status _aidl_status;
222 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
223 if (((_aidl_ret_status) != (::android::OK))) {
224 goto _aidl_error;
225 }
Jeongik Chab5d962f2018-11-17 09:12:28 +0900226 _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableBinder */, _aidl_data, &_aidl_reply);
Jiyong Park75e1a742018-07-04 12:31:23 +0900227 if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
228 return IComplexTypeInterface::getDefaultImpl()->NullableBinder(_aidl_return);
229 }
Jiyong Parka755dc72018-06-29 13:52:24 +0900230 if (((_aidl_ret_status) != (::android::OK))) {
231 goto _aidl_error;
232 }
233 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
234 if (((_aidl_ret_status) != (::android::OK))) {
235 goto _aidl_error;
236 }
237 if (!_aidl_status.isOk()) {
238 return _aidl_status;
239 }
240 _aidl_ret_status = _aidl_reply.readNullableStrongBinder(_aidl_return);
241 if (((_aidl_ret_status) != (::android::OK))) {
242 goto _aidl_error;
243 }
244 _aidl_error:
245 _aidl_status.setFromStatusT(_aidl_ret_status);
246 return _aidl_status;
Casey Dahlinef88bce2016-04-15 11:55:30 -0700247}
248
Casey Dahlinb8d9e882015-11-24 10:57:23 -0800249::android::binder::Status BpComplexTypeInterface::StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) {
Jiyong Parka755dc72018-06-29 13:52:24 +0900250 ::android::Parcel _aidl_data;
251 ::android::Parcel _aidl_reply;
252 ::android::status_t _aidl_ret_status = ::android::OK;
253 ::android::binder::Status _aidl_status;
254 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
255 if (((_aidl_ret_status) != (::android::OK))) {
256 goto _aidl_error;
257 }
258 _aidl_ret_status = _aidl_data.writeString16Vector(input);
259 if (((_aidl_ret_status) != (::android::OK))) {
260 goto _aidl_error;
261 }
Jeongik Chab5d962f2018-11-17 09:12:28 +0900262 _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 4 /* StringListMethod */, _aidl_data, &_aidl_reply);
Jiyong Park75e1a742018-07-04 12:31:23 +0900263 if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
264 return IComplexTypeInterface::getDefaultImpl()->StringListMethod(input, output, _aidl_return);
265 }
Jiyong Parka755dc72018-06-29 13:52:24 +0900266 if (((_aidl_ret_status) != (::android::OK))) {
267 goto _aidl_error;
268 }
269 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
270 if (((_aidl_ret_status) != (::android::OK))) {
271 goto _aidl_error;
272 }
273 if (!_aidl_status.isOk()) {
274 return _aidl_status;
275 }
276 _aidl_ret_status = _aidl_reply.readString16Vector(_aidl_return);
277 if (((_aidl_ret_status) != (::android::OK))) {
278 goto _aidl_error;
279 }
280 _aidl_ret_status = _aidl_reply.readString16Vector(output);
281 if (((_aidl_ret_status) != (::android::OK))) {
282 goto _aidl_error;
283 }
284 _aidl_error:
285 _aidl_status.setFromStatusT(_aidl_ret_status);
286 return _aidl_status;
Christopher Wiley56c9bf32015-10-30 10:41:12 -0700287}
288
Casey Dahlinb8d9e882015-11-24 10:57:23 -0800289::android::binder::Status BpComplexTypeInterface::BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>& input, ::std::vector<::android::sp<::android::IBinder>>* output, ::std::vector<::android::sp<::android::IBinder>>* _aidl_return) {
Jiyong Parka755dc72018-06-29 13:52:24 +0900290 ::android::Parcel _aidl_data;
291 ::android::Parcel _aidl_reply;
292 ::android::status_t _aidl_ret_status = ::android::OK;
293 ::android::binder::Status _aidl_status;
294 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
295 if (((_aidl_ret_status) != (::android::OK))) {
296 goto _aidl_error;
297 }
298 _aidl_ret_status = _aidl_data.writeStrongBinderVector(input);
299 if (((_aidl_ret_status) != (::android::OK))) {
300 goto _aidl_error;
301 }
Jeongik Chab5d962f2018-11-17 09:12:28 +0900302 _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 5 /* BinderListMethod */, _aidl_data, &_aidl_reply);
Jiyong Park75e1a742018-07-04 12:31:23 +0900303 if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
304 return IComplexTypeInterface::getDefaultImpl()->BinderListMethod(input, output, _aidl_return);
305 }
Jiyong Parka755dc72018-06-29 13:52:24 +0900306 if (((_aidl_ret_status) != (::android::OK))) {
307 goto _aidl_error;
308 }
309 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
310 if (((_aidl_ret_status) != (::android::OK))) {
311 goto _aidl_error;
312 }
313 if (!_aidl_status.isOk()) {
314 return _aidl_status;
315 }
316 _aidl_ret_status = _aidl_reply.readStrongBinderVector(_aidl_return);
317 if (((_aidl_ret_status) != (::android::OK))) {
318 goto _aidl_error;
319 }
320 _aidl_ret_status = _aidl_reply.readStrongBinderVector(output);
321 if (((_aidl_ret_status) != (::android::OK))) {
322 goto _aidl_error;
323 }
324 _aidl_error:
325 _aidl_status.setFromStatusT(_aidl_ret_status);
326 return _aidl_status;
Casey Dahlin7ecd69f2015-11-03 13:52:38 -0800327}
328
Christopher Wiley7cb9c252016-04-11 11:07:33 -0700329::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptor(const ::android::base::unique_fd& f, ::android::base::unique_fd* _aidl_return) {
Jiyong Parka755dc72018-06-29 13:52:24 +0900330 ::android::Parcel _aidl_data;
331 ::android::Parcel _aidl_reply;
332 ::android::status_t _aidl_ret_status = ::android::OK;
333 ::android::binder::Status _aidl_status;
334 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
335 if (((_aidl_ret_status) != (::android::OK))) {
336 goto _aidl_error;
337 }
338 _aidl_ret_status = _aidl_data.writeUniqueFileDescriptor(f);
339 if (((_aidl_ret_status) != (::android::OK))) {
340 goto _aidl_error;
341 }
Jeongik Chab5d962f2018-11-17 09:12:28 +0900342 _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 6 /* TakesAFileDescriptor */, _aidl_data, &_aidl_reply);
Jiyong Park75e1a742018-07-04 12:31:23 +0900343 if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
344 return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptor(f, _aidl_return);
345 }
Jiyong Parka755dc72018-06-29 13:52:24 +0900346 if (((_aidl_ret_status) != (::android::OK))) {
347 goto _aidl_error;
348 }
349 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
350 if (((_aidl_ret_status) != (::android::OK))) {
351 goto _aidl_error;
352 }
353 if (!_aidl_status.isOk()) {
354 return _aidl_status;
355 }
356 _aidl_ret_status = _aidl_reply.readUniqueFileDescriptor(_aidl_return);
357 if (((_aidl_ret_status) != (::android::OK))) {
358 goto _aidl_error;
359 }
360 _aidl_error:
361 _aidl_status.setFromStatusT(_aidl_ret_status);
362 return _aidl_status;
Casey Dahlina4ba4b62015-11-02 15:43:30 -0800363}
364
Christopher Wiley7cb9c252016-04-11 11:07:33 -0700365::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) {
Jiyong Parka755dc72018-06-29 13:52:24 +0900366 ::android::Parcel _aidl_data;
367 ::android::Parcel _aidl_reply;
368 ::android::status_t _aidl_ret_status = ::android::OK;
369 ::android::binder::Status _aidl_status;
370 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
371 if (((_aidl_ret_status) != (::android::OK))) {
372 goto _aidl_error;
373 }
374 _aidl_ret_status = _aidl_data.writeUniqueFileDescriptorVector(f);
375 if (((_aidl_ret_status) != (::android::OK))) {
376 goto _aidl_error;
377 }
Jeongik Chab5d962f2018-11-17 09:12:28 +0900378 _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 7 /* TakesAFileDescriptorArray */, _aidl_data, &_aidl_reply);
Jiyong Park75e1a742018-07-04 12:31:23 +0900379 if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
380 return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptorArray(f, _aidl_return);
381 }
Jiyong Parka755dc72018-06-29 13:52:24 +0900382 if (((_aidl_ret_status) != (::android::OK))) {
383 goto _aidl_error;
384 }
385 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
386 if (((_aidl_ret_status) != (::android::OK))) {
387 goto _aidl_error;
388 }
389 if (!_aidl_status.isOk()) {
390 return _aidl_status;
391 }
392 _aidl_ret_status = _aidl_reply.readUniqueFileDescriptorVector(_aidl_return);
393 if (((_aidl_ret_status) != (::android::OK))) {
394 goto _aidl_error;
395 }
396 _aidl_error:
397 _aidl_status.setFromStatusT(_aidl_ret_status);
398 return _aidl_status;
Casey Dahlina4ba4b62015-11-02 15:43:30 -0800399}
400
Casey Dahlinb0966612015-10-19 16:35:26 -0700401} // namespace os
402
403} // namespace android
404)";
405
Martijn Coenenf1b50782018-02-21 21:06:23 +0100406const char kExpectedComplexTypeClientWithTraceSourceOutput[] =
Jiyong Park75e1a742018-07-04 12:31:23 +0900407 R"(#include <android/os/BpComplexTypeInterface.h>
Martijn Coenenf1b50782018-02-21 21:06:23 +0100408#include <binder/Parcel.h>
Jiyong Park75e1a742018-07-04 12:31:23 +0900409#include <android-base/macros.h>
Martijn Coenenf1b50782018-02-21 21:06:23 +0100410
411namespace android {
412
413namespace os {
414
415BpComplexTypeInterface::BpComplexTypeInterface(const ::android::sp<::android::IBinder>& _aidl_impl)
416 : BpInterface<IComplexTypeInterface>(_aidl_impl){
417}
418
419::android::binder::Status BpComplexTypeInterface::Send(const ::std::unique_ptr<::std::vector<int32_t>>& goes_in, ::std::vector<double>* goes_in_and_out, ::std::vector<bool>* goes_out, ::std::vector<int32_t>* _aidl_return) {
Jiyong Parka755dc72018-06-29 13:52:24 +0900420 ::android::Parcel _aidl_data;
421 ::android::Parcel _aidl_reply;
422 ::android::status_t _aidl_ret_status = ::android::OK;
423 ::android::binder::Status _aidl_status;
424 ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "IComplexTypeInterface::Send::cppClient");
425 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
426 if (((_aidl_ret_status) != (::android::OK))) {
427 goto _aidl_error;
428 }
429 _aidl_ret_status = _aidl_data.writeInt32Vector(goes_in);
430 if (((_aidl_ret_status) != (::android::OK))) {
431 goto _aidl_error;
432 }
433 _aidl_ret_status = _aidl_data.writeDoubleVector(*goes_in_and_out);
434 if (((_aidl_ret_status) != (::android::OK))) {
435 goto _aidl_error;
436 }
437 _aidl_ret_status = _aidl_data.writeVectorSize(*goes_out);
438 if (((_aidl_ret_status) != (::android::OK))) {
439 goto _aidl_error;
440 }
Jeongik Chab5d962f2018-11-17 09:12:28 +0900441 _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* Send */, _aidl_data, &_aidl_reply);
Jiyong Park75e1a742018-07-04 12:31:23 +0900442 if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
443 return IComplexTypeInterface::getDefaultImpl()->Send(goes_in, goes_in_and_out, goes_out, _aidl_return);
444 }
Jiyong Parka755dc72018-06-29 13:52:24 +0900445 if (((_aidl_ret_status) != (::android::OK))) {
446 goto _aidl_error;
447 }
448 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
449 if (((_aidl_ret_status) != (::android::OK))) {
450 goto _aidl_error;
451 }
452 if (!_aidl_status.isOk()) {
453 return _aidl_status;
454 }
455 _aidl_ret_status = _aidl_reply.readInt32Vector(_aidl_return);
456 if (((_aidl_ret_status) != (::android::OK))) {
457 goto _aidl_error;
458 }
459 _aidl_ret_status = _aidl_reply.readDoubleVector(goes_in_and_out);
460 if (((_aidl_ret_status) != (::android::OK))) {
461 goto _aidl_error;
462 }
463 _aidl_ret_status = _aidl_reply.readBoolVector(goes_out);
464 if (((_aidl_ret_status) != (::android::OK))) {
465 goto _aidl_error;
466 }
467 _aidl_error:
468 _aidl_status.setFromStatusT(_aidl_ret_status);
469 return _aidl_status;
Martijn Coenenf1b50782018-02-21 21:06:23 +0100470}
471
472::android::binder::Status BpComplexTypeInterface::Piff(int32_t times) {
Jiyong Parka755dc72018-06-29 13:52:24 +0900473 ::android::Parcel _aidl_data;
474 ::android::Parcel _aidl_reply;
475 ::android::status_t _aidl_ret_status = ::android::OK;
476 ::android::binder::Status _aidl_status;
477 ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "IComplexTypeInterface::Piff::cppClient");
478 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
479 if (((_aidl_ret_status) != (::android::OK))) {
480 goto _aidl_error;
481 }
482 _aidl_ret_status = _aidl_data.writeInt32(times);
483 if (((_aidl_ret_status) != (::android::OK))) {
484 goto _aidl_error;
485 }
Jeongik Chab5d962f2018-11-17 09:12:28 +0900486 _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* Piff */, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_ONEWAY);
Jiyong Park75e1a742018-07-04 12:31:23 +0900487 if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
488 return IComplexTypeInterface::getDefaultImpl()->Piff(times);
489 }
Jiyong Parka755dc72018-06-29 13:52:24 +0900490 if (((_aidl_ret_status) != (::android::OK))) {
491 goto _aidl_error;
492 }
493 _aidl_error:
494 _aidl_status.setFromStatusT(_aidl_ret_status);
495 return _aidl_status;
Martijn Coenenf1b50782018-02-21 21:06:23 +0100496}
497
498::android::binder::Status BpComplexTypeInterface::TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) {
Jiyong Parka755dc72018-06-29 13:52:24 +0900499 ::android::Parcel _aidl_data;
500 ::android::Parcel _aidl_reply;
501 ::android::status_t _aidl_ret_status = ::android::OK;
502 ::android::binder::Status _aidl_status;
503 ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "IComplexTypeInterface::TakesABinder::cppClient");
504 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
505 if (((_aidl_ret_status) != (::android::OK))) {
506 goto _aidl_error;
507 }
508 _aidl_ret_status = _aidl_data.writeStrongBinder(::foo::IFooType::asBinder(f));
509 if (((_aidl_ret_status) != (::android::OK))) {
510 goto _aidl_error;
511 }
Jeongik Chab5d962f2018-11-17 09:12:28 +0900512 _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* TakesABinder */, _aidl_data, &_aidl_reply);
Jiyong Park75e1a742018-07-04 12:31:23 +0900513 if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
514 return IComplexTypeInterface::getDefaultImpl()->TakesABinder(f, _aidl_return);
515 }
Jiyong Parka755dc72018-06-29 13:52:24 +0900516 if (((_aidl_ret_status) != (::android::OK))) {
517 goto _aidl_error;
518 }
519 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
520 if (((_aidl_ret_status) != (::android::OK))) {
521 goto _aidl_error;
522 }
523 if (!_aidl_status.isOk()) {
524 return _aidl_status;
525 }
526 _aidl_ret_status = _aidl_reply.readStrongBinder(_aidl_return);
527 if (((_aidl_ret_status) != (::android::OK))) {
528 goto _aidl_error;
529 }
530 _aidl_error:
531 _aidl_status.setFromStatusT(_aidl_ret_status);
532 return _aidl_status;
Martijn Coenenf1b50782018-02-21 21:06:23 +0100533}
534
535::android::binder::Status BpComplexTypeInterface::NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) {
Jiyong Parka755dc72018-06-29 13:52:24 +0900536 ::android::Parcel _aidl_data;
537 ::android::Parcel _aidl_reply;
538 ::android::status_t _aidl_ret_status = ::android::OK;
539 ::android::binder::Status _aidl_status;
540 ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "IComplexTypeInterface::NullableBinder::cppClient");
541 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
542 if (((_aidl_ret_status) != (::android::OK))) {
543 goto _aidl_error;
544 }
Jeongik Chab5d962f2018-11-17 09:12:28 +0900545 _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableBinder */, _aidl_data, &_aidl_reply);
Jiyong Park75e1a742018-07-04 12:31:23 +0900546 if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
547 return IComplexTypeInterface::getDefaultImpl()->NullableBinder(_aidl_return);
548 }
Jiyong Parka755dc72018-06-29 13:52:24 +0900549 if (((_aidl_ret_status) != (::android::OK))) {
550 goto _aidl_error;
551 }
552 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
553 if (((_aidl_ret_status) != (::android::OK))) {
554 goto _aidl_error;
555 }
556 if (!_aidl_status.isOk()) {
557 return _aidl_status;
558 }
559 _aidl_ret_status = _aidl_reply.readNullableStrongBinder(_aidl_return);
560 if (((_aidl_ret_status) != (::android::OK))) {
561 goto _aidl_error;
562 }
563 _aidl_error:
564 _aidl_status.setFromStatusT(_aidl_ret_status);
565 return _aidl_status;
Martijn Coenenf1b50782018-02-21 21:06:23 +0100566}
567
568::android::binder::Status BpComplexTypeInterface::StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) {
Jiyong Parka755dc72018-06-29 13:52:24 +0900569 ::android::Parcel _aidl_data;
570 ::android::Parcel _aidl_reply;
571 ::android::status_t _aidl_ret_status = ::android::OK;
572 ::android::binder::Status _aidl_status;
573 ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "IComplexTypeInterface::StringListMethod::cppClient");
574 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
575 if (((_aidl_ret_status) != (::android::OK))) {
576 goto _aidl_error;
577 }
578 _aidl_ret_status = _aidl_data.writeString16Vector(input);
579 if (((_aidl_ret_status) != (::android::OK))) {
580 goto _aidl_error;
581 }
Jeongik Chab5d962f2018-11-17 09:12:28 +0900582 _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 4 /* StringListMethod */, _aidl_data, &_aidl_reply);
Jiyong Park75e1a742018-07-04 12:31:23 +0900583 if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
584 return IComplexTypeInterface::getDefaultImpl()->StringListMethod(input, output, _aidl_return);
585 }
Jiyong Parka755dc72018-06-29 13:52:24 +0900586 if (((_aidl_ret_status) != (::android::OK))) {
587 goto _aidl_error;
588 }
589 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
590 if (((_aidl_ret_status) != (::android::OK))) {
591 goto _aidl_error;
592 }
593 if (!_aidl_status.isOk()) {
594 return _aidl_status;
595 }
596 _aidl_ret_status = _aidl_reply.readString16Vector(_aidl_return);
597 if (((_aidl_ret_status) != (::android::OK))) {
598 goto _aidl_error;
599 }
600 _aidl_ret_status = _aidl_reply.readString16Vector(output);
601 if (((_aidl_ret_status) != (::android::OK))) {
602 goto _aidl_error;
603 }
604 _aidl_error:
605 _aidl_status.setFromStatusT(_aidl_ret_status);
606 return _aidl_status;
Martijn Coenenf1b50782018-02-21 21:06:23 +0100607}
608
609::android::binder::Status BpComplexTypeInterface::BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>& input, ::std::vector<::android::sp<::android::IBinder>>* output, ::std::vector<::android::sp<::android::IBinder>>* _aidl_return) {
Jiyong Parka755dc72018-06-29 13:52:24 +0900610 ::android::Parcel _aidl_data;
611 ::android::Parcel _aidl_reply;
612 ::android::status_t _aidl_ret_status = ::android::OK;
613 ::android::binder::Status _aidl_status;
614 ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "IComplexTypeInterface::BinderListMethod::cppClient");
615 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
616 if (((_aidl_ret_status) != (::android::OK))) {
617 goto _aidl_error;
618 }
619 _aidl_ret_status = _aidl_data.writeStrongBinderVector(input);
620 if (((_aidl_ret_status) != (::android::OK))) {
621 goto _aidl_error;
622 }
Jeongik Chab5d962f2018-11-17 09:12:28 +0900623 _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 5 /* BinderListMethod */, _aidl_data, &_aidl_reply);
Jiyong Park75e1a742018-07-04 12:31:23 +0900624 if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
625 return IComplexTypeInterface::getDefaultImpl()->BinderListMethod(input, output, _aidl_return);
626 }
Jiyong Parka755dc72018-06-29 13:52:24 +0900627 if (((_aidl_ret_status) != (::android::OK))) {
628 goto _aidl_error;
629 }
630 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
631 if (((_aidl_ret_status) != (::android::OK))) {
632 goto _aidl_error;
633 }
634 if (!_aidl_status.isOk()) {
635 return _aidl_status;
636 }
637 _aidl_ret_status = _aidl_reply.readStrongBinderVector(_aidl_return);
638 if (((_aidl_ret_status) != (::android::OK))) {
639 goto _aidl_error;
640 }
641 _aidl_ret_status = _aidl_reply.readStrongBinderVector(output);
642 if (((_aidl_ret_status) != (::android::OK))) {
643 goto _aidl_error;
644 }
645 _aidl_error:
646 _aidl_status.setFromStatusT(_aidl_ret_status);
647 return _aidl_status;
Martijn Coenenf1b50782018-02-21 21:06:23 +0100648}
649
650::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptor(const ::android::base::unique_fd& f, ::android::base::unique_fd* _aidl_return) {
Jiyong Parka755dc72018-06-29 13:52:24 +0900651 ::android::Parcel _aidl_data;
652 ::android::Parcel _aidl_reply;
653 ::android::status_t _aidl_ret_status = ::android::OK;
654 ::android::binder::Status _aidl_status;
655 ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "IComplexTypeInterface::TakesAFileDescriptor::cppClient");
656 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
657 if (((_aidl_ret_status) != (::android::OK))) {
658 goto _aidl_error;
659 }
660 _aidl_ret_status = _aidl_data.writeUniqueFileDescriptor(f);
661 if (((_aidl_ret_status) != (::android::OK))) {
662 goto _aidl_error;
663 }
Jeongik Chab5d962f2018-11-17 09:12:28 +0900664 _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 6 /* TakesAFileDescriptor */, _aidl_data, &_aidl_reply);
Jiyong Park75e1a742018-07-04 12:31:23 +0900665 if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
666 return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptor(f, _aidl_return);
667 }
Jiyong Parka755dc72018-06-29 13:52:24 +0900668 if (((_aidl_ret_status) != (::android::OK))) {
669 goto _aidl_error;
670 }
671 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
672 if (((_aidl_ret_status) != (::android::OK))) {
673 goto _aidl_error;
674 }
675 if (!_aidl_status.isOk()) {
676 return _aidl_status;
677 }
678 _aidl_ret_status = _aidl_reply.readUniqueFileDescriptor(_aidl_return);
679 if (((_aidl_ret_status) != (::android::OK))) {
680 goto _aidl_error;
681 }
682 _aidl_error:
683 _aidl_status.setFromStatusT(_aidl_ret_status);
684 return _aidl_status;
Martijn Coenenf1b50782018-02-21 21:06:23 +0100685}
686
687::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) {
Jiyong Parka755dc72018-06-29 13:52:24 +0900688 ::android::Parcel _aidl_data;
689 ::android::Parcel _aidl_reply;
690 ::android::status_t _aidl_ret_status = ::android::OK;
691 ::android::binder::Status _aidl_status;
692 ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "IComplexTypeInterface::TakesAFileDescriptorArray::cppClient");
693 _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
694 if (((_aidl_ret_status) != (::android::OK))) {
695 goto _aidl_error;
696 }
697 _aidl_ret_status = _aidl_data.writeUniqueFileDescriptorVector(f);
698 if (((_aidl_ret_status) != (::android::OK))) {
699 goto _aidl_error;
700 }
Jeongik Chab5d962f2018-11-17 09:12:28 +0900701 _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 7 /* TakesAFileDescriptorArray */, _aidl_data, &_aidl_reply);
Jiyong Park75e1a742018-07-04 12:31:23 +0900702 if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
703 return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptorArray(f, _aidl_return);
704 }
Jiyong Parka755dc72018-06-29 13:52:24 +0900705 if (((_aidl_ret_status) != (::android::OK))) {
706 goto _aidl_error;
707 }
708 _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
709 if (((_aidl_ret_status) != (::android::OK))) {
710 goto _aidl_error;
711 }
712 if (!_aidl_status.isOk()) {
713 return _aidl_status;
714 }
715 _aidl_ret_status = _aidl_reply.readUniqueFileDescriptorVector(_aidl_return);
716 if (((_aidl_ret_status) != (::android::OK))) {
717 goto _aidl_error;
718 }
719 _aidl_error:
720 _aidl_status.setFromStatusT(_aidl_ret_status);
721 return _aidl_status;
Martijn Coenenf1b50782018-02-21 21:06:23 +0100722}
723
724} // namespace os
725
726} // namespace android
727)";
728
Casey Dahlinb0966612015-10-19 16:35:26 -0700729const char kExpectedComplexTypeServerHeaderOutput[] =
730R"(#ifndef AIDL_GENERATED_ANDROID_OS_BN_COMPLEX_TYPE_INTERFACE_H_
731#define AIDL_GENERATED_ANDROID_OS_BN_COMPLEX_TYPE_INTERFACE_H_
732
733#include <binder/IInterface.h>
734#include <android/os/IComplexTypeInterface.h>
735
736namespace android {
737
738namespace os {
739
Casey Dahlinb8d9e882015-11-24 10:57:23 -0800740class BnComplexTypeInterface : public ::android::BnInterface<IComplexTypeInterface> {
Casey Dahlinb0966612015-10-19 16:35:26 -0700741public:
Jiyong Park8533bd02018-10-29 21:31:18 +0900742 ::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override;
Casey Dahlinb0966612015-10-19 16:35:26 -0700743}; // class BnComplexTypeInterface
744
745} // namespace os
746
747} // namespace android
748
Christopher Wiley11a9d792016-02-24 17:20:33 -0800749#endif // AIDL_GENERATED_ANDROID_OS_BN_COMPLEX_TYPE_INTERFACE_H_
750)";
Casey Dahlinb0966612015-10-19 16:35:26 -0700751
752const char kExpectedComplexTypeServerSourceOutput[] =
Jeongik Chab5d962f2018-11-17 09:12:28 +0900753 R"(#include <android/os/BnComplexTypeInterface.h>
Casey Dahlinb0966612015-10-19 16:35:26 -0700754#include <binder/Parcel.h>
755
756namespace android {
757
758namespace os {
759
Casey Dahlinb8d9e882015-11-24 10:57:23 -0800760::android::status_t BnComplexTypeInterface::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) {
Jiyong Parka755dc72018-06-29 13:52:24 +0900761 ::android::status_t _aidl_ret_status = ::android::OK;
762 switch (_aidl_code) {
Jeongik Chab5d962f2018-11-17 09:12:28 +0900763 case ::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* Send */:
Jiyong Parka755dc72018-06-29 13:52:24 +0900764 {
765 ::std::unique_ptr<::std::vector<int32_t>> in_goes_in;
766 ::std::vector<double> in_goes_in_and_out;
767 ::std::vector<bool> out_goes_out;
768 ::std::vector<int32_t> _aidl_return;
769 if (!(_aidl_data.checkInterface(this))) {
770 _aidl_ret_status = ::android::BAD_TYPE;
771 break;
772 }
773 _aidl_ret_status = _aidl_data.readInt32Vector(&in_goes_in);
774 if (((_aidl_ret_status) != (::android::OK))) {
775 break;
776 }
777 _aidl_ret_status = _aidl_data.readDoubleVector(&in_goes_in_and_out);
778 if (((_aidl_ret_status) != (::android::OK))) {
779 break;
780 }
781 _aidl_ret_status = _aidl_data.resizeOutVector(&out_goes_out);
782 if (((_aidl_ret_status) != (::android::OK))) {
783 break;
784 }
785 ::android::binder::Status _aidl_status(Send(in_goes_in, &in_goes_in_and_out, &out_goes_out, &_aidl_return));
786 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
787 if (((_aidl_ret_status) != (::android::OK))) {
788 break;
789 }
790 if (!_aidl_status.isOk()) {
791 break;
792 }
793 _aidl_ret_status = _aidl_reply->writeInt32Vector(_aidl_return);
794 if (((_aidl_ret_status) != (::android::OK))) {
795 break;
796 }
797 _aidl_ret_status = _aidl_reply->writeDoubleVector(in_goes_in_and_out);
798 if (((_aidl_ret_status) != (::android::OK))) {
799 break;
800 }
801 _aidl_ret_status = _aidl_reply->writeBoolVector(out_goes_out);
802 if (((_aidl_ret_status) != (::android::OK))) {
803 break;
804 }
805 }
806 break;
Jeongik Chab5d962f2018-11-17 09:12:28 +0900807 case ::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* Piff */:
Jiyong Parka755dc72018-06-29 13:52:24 +0900808 {
809 int32_t in_times;
810 if (!(_aidl_data.checkInterface(this))) {
811 _aidl_ret_status = ::android::BAD_TYPE;
812 break;
813 }
814 _aidl_ret_status = _aidl_data.readInt32(&in_times);
815 if (((_aidl_ret_status) != (::android::OK))) {
816 break;
817 }
818 ::android::binder::Status _aidl_status(Piff(in_times));
819 }
820 break;
Jeongik Chab5d962f2018-11-17 09:12:28 +0900821 case ::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* TakesABinder */:
Jiyong Parka755dc72018-06-29 13:52:24 +0900822 {
823 ::android::sp<::foo::IFooType> in_f;
824 ::android::sp<::foo::IFooType> _aidl_return;
825 if (!(_aidl_data.checkInterface(this))) {
826 _aidl_ret_status = ::android::BAD_TYPE;
827 break;
828 }
829 _aidl_ret_status = _aidl_data.readStrongBinder(&in_f);
830 if (((_aidl_ret_status) != (::android::OK))) {
831 break;
832 }
833 ::android::binder::Status _aidl_status(TakesABinder(in_f, &_aidl_return));
834 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
835 if (((_aidl_ret_status) != (::android::OK))) {
836 break;
837 }
838 if (!_aidl_status.isOk()) {
839 break;
840 }
841 _aidl_ret_status = _aidl_reply->writeStrongBinder(::foo::IFooType::asBinder(_aidl_return));
842 if (((_aidl_ret_status) != (::android::OK))) {
843 break;
844 }
845 }
846 break;
Jeongik Chab5d962f2018-11-17 09:12:28 +0900847 case ::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableBinder */:
Jiyong Parka755dc72018-06-29 13:52:24 +0900848 {
849 ::android::sp<::foo::IFooType> _aidl_return;
850 if (!(_aidl_data.checkInterface(this))) {
851 _aidl_ret_status = ::android::BAD_TYPE;
852 break;
853 }
854 ::android::binder::Status _aidl_status(NullableBinder(&_aidl_return));
855 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
856 if (((_aidl_ret_status) != (::android::OK))) {
857 break;
858 }
859 if (!_aidl_status.isOk()) {
860 break;
861 }
862 _aidl_ret_status = _aidl_reply->writeStrongBinder(::foo::IFooType::asBinder(_aidl_return));
863 if (((_aidl_ret_status) != (::android::OK))) {
864 break;
865 }
866 }
867 break;
Jeongik Chab5d962f2018-11-17 09:12:28 +0900868 case ::android::IBinder::FIRST_CALL_TRANSACTION + 4 /* StringListMethod */:
Jiyong Parka755dc72018-06-29 13:52:24 +0900869 {
870 ::std::vector<::android::String16> in_input;
871 ::std::vector<::android::String16> out_output;
872 ::std::vector<::android::String16> _aidl_return;
873 if (!(_aidl_data.checkInterface(this))) {
874 _aidl_ret_status = ::android::BAD_TYPE;
875 break;
876 }
877 _aidl_ret_status = _aidl_data.readString16Vector(&in_input);
878 if (((_aidl_ret_status) != (::android::OK))) {
879 break;
880 }
881 ::android::binder::Status _aidl_status(StringListMethod(in_input, &out_output, &_aidl_return));
882 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
883 if (((_aidl_ret_status) != (::android::OK))) {
884 break;
885 }
886 if (!_aidl_status.isOk()) {
887 break;
888 }
889 _aidl_ret_status = _aidl_reply->writeString16Vector(_aidl_return);
890 if (((_aidl_ret_status) != (::android::OK))) {
891 break;
892 }
893 _aidl_ret_status = _aidl_reply->writeString16Vector(out_output);
894 if (((_aidl_ret_status) != (::android::OK))) {
895 break;
896 }
897 }
898 break;
Jeongik Chab5d962f2018-11-17 09:12:28 +0900899 case ::android::IBinder::FIRST_CALL_TRANSACTION + 5 /* BinderListMethod */:
Jiyong Parka755dc72018-06-29 13:52:24 +0900900 {
901 ::std::vector<::android::sp<::android::IBinder>> in_input;
902 ::std::vector<::android::sp<::android::IBinder>> out_output;
903 ::std::vector<::android::sp<::android::IBinder>> _aidl_return;
904 if (!(_aidl_data.checkInterface(this))) {
905 _aidl_ret_status = ::android::BAD_TYPE;
906 break;
907 }
908 _aidl_ret_status = _aidl_data.readStrongBinderVector(&in_input);
909 if (((_aidl_ret_status) != (::android::OK))) {
910 break;
911 }
912 ::android::binder::Status _aidl_status(BinderListMethod(in_input, &out_output, &_aidl_return));
913 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
914 if (((_aidl_ret_status) != (::android::OK))) {
915 break;
916 }
917 if (!_aidl_status.isOk()) {
918 break;
919 }
920 _aidl_ret_status = _aidl_reply->writeStrongBinderVector(_aidl_return);
921 if (((_aidl_ret_status) != (::android::OK))) {
922 break;
923 }
924 _aidl_ret_status = _aidl_reply->writeStrongBinderVector(out_output);
925 if (((_aidl_ret_status) != (::android::OK))) {
926 break;
927 }
928 }
929 break;
Jeongik Chab5d962f2018-11-17 09:12:28 +0900930 case ::android::IBinder::FIRST_CALL_TRANSACTION + 6 /* TakesAFileDescriptor */:
Jiyong Parka755dc72018-06-29 13:52:24 +0900931 {
932 ::android::base::unique_fd in_f;
933 ::android::base::unique_fd _aidl_return;
934 if (!(_aidl_data.checkInterface(this))) {
935 _aidl_ret_status = ::android::BAD_TYPE;
936 break;
937 }
938 _aidl_ret_status = _aidl_data.readUniqueFileDescriptor(&in_f);
939 if (((_aidl_ret_status) != (::android::OK))) {
940 break;
941 }
942 ::android::binder::Status _aidl_status(TakesAFileDescriptor(in_f, &_aidl_return));
943 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
944 if (((_aidl_ret_status) != (::android::OK))) {
945 break;
946 }
947 if (!_aidl_status.isOk()) {
948 break;
949 }
950 _aidl_ret_status = _aidl_reply->writeUniqueFileDescriptor(_aidl_return);
951 if (((_aidl_ret_status) != (::android::OK))) {
952 break;
953 }
954 }
955 break;
Jeongik Chab5d962f2018-11-17 09:12:28 +0900956 case ::android::IBinder::FIRST_CALL_TRANSACTION + 7 /* TakesAFileDescriptorArray */:
Jiyong Parka755dc72018-06-29 13:52:24 +0900957 {
958 ::std::vector<::android::base::unique_fd> in_f;
959 ::std::vector<::android::base::unique_fd> _aidl_return;
960 if (!(_aidl_data.checkInterface(this))) {
961 _aidl_ret_status = ::android::BAD_TYPE;
962 break;
963 }
964 _aidl_ret_status = _aidl_data.readUniqueFileDescriptorVector(&in_f);
965 if (((_aidl_ret_status) != (::android::OK))) {
966 break;
967 }
968 ::android::binder::Status _aidl_status(TakesAFileDescriptorArray(in_f, &_aidl_return));
969 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
970 if (((_aidl_ret_status) != (::android::OK))) {
971 break;
972 }
973 if (!_aidl_status.isOk()) {
974 break;
975 }
976 _aidl_ret_status = _aidl_reply->writeUniqueFileDescriptorVector(_aidl_return);
977 if (((_aidl_ret_status) != (::android::OK))) {
978 break;
979 }
980 }
981 break;
982 default:
983 {
984 _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
985 }
986 break;
987 }
988 if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
989 _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
990 }
991 return _aidl_ret_status;
Casey Dahlinb0966612015-10-19 16:35:26 -0700992}
993
994} // namespace os
995
996} // namespace android
997)";
998
Martijn Coenenf1b50782018-02-21 21:06:23 +0100999const char kExpectedComplexTypeServerWithTraceSourceOutput[] =
Jeongik Chab5d962f2018-11-17 09:12:28 +09001000 R"(#include <android/os/BnComplexTypeInterface.h>
Martijn Coenenf1b50782018-02-21 21:06:23 +01001001#include <binder/Parcel.h>
1002
1003namespace android {
1004
1005namespace os {
1006
1007::android::status_t BnComplexTypeInterface::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) {
Jiyong Parka755dc72018-06-29 13:52:24 +09001008 ::android::status_t _aidl_ret_status = ::android::OK;
1009 switch (_aidl_code) {
Jeongik Chab5d962f2018-11-17 09:12:28 +09001010 case ::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* Send */:
Jiyong Parka755dc72018-06-29 13:52:24 +09001011 {
1012 ::std::unique_ptr<::std::vector<int32_t>> in_goes_in;
1013 ::std::vector<double> in_goes_in_and_out;
1014 ::std::vector<bool> out_goes_out;
1015 ::std::vector<int32_t> _aidl_return;
1016 if (!(_aidl_data.checkInterface(this))) {
1017 _aidl_ret_status = ::android::BAD_TYPE;
1018 break;
1019 }
1020 _aidl_ret_status = _aidl_data.readInt32Vector(&in_goes_in);
1021 if (((_aidl_ret_status) != (::android::OK))) {
1022 break;
1023 }
1024 _aidl_ret_status = _aidl_data.readDoubleVector(&in_goes_in_and_out);
1025 if (((_aidl_ret_status) != (::android::OK))) {
1026 break;
1027 }
1028 _aidl_ret_status = _aidl_data.resizeOutVector(&out_goes_out);
1029 if (((_aidl_ret_status) != (::android::OK))) {
1030 break;
1031 }
1032 atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::Send::cppServer");
1033 ::android::binder::Status _aidl_status(Send(in_goes_in, &in_goes_in_and_out, &out_goes_out, &_aidl_return));
1034 atrace_end(ATRACE_TAG_AIDL);
1035 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
1036 if (((_aidl_ret_status) != (::android::OK))) {
1037 break;
1038 }
1039 if (!_aidl_status.isOk()) {
1040 break;
1041 }
1042 _aidl_ret_status = _aidl_reply->writeInt32Vector(_aidl_return);
1043 if (((_aidl_ret_status) != (::android::OK))) {
1044 break;
1045 }
1046 _aidl_ret_status = _aidl_reply->writeDoubleVector(in_goes_in_and_out);
1047 if (((_aidl_ret_status) != (::android::OK))) {
1048 break;
1049 }
1050 _aidl_ret_status = _aidl_reply->writeBoolVector(out_goes_out);
1051 if (((_aidl_ret_status) != (::android::OK))) {
1052 break;
1053 }
1054 }
1055 break;
Jeongik Chab5d962f2018-11-17 09:12:28 +09001056 case ::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* Piff */:
Jiyong Parka755dc72018-06-29 13:52:24 +09001057 {
1058 int32_t in_times;
1059 if (!(_aidl_data.checkInterface(this))) {
1060 _aidl_ret_status = ::android::BAD_TYPE;
1061 break;
1062 }
1063 _aidl_ret_status = _aidl_data.readInt32(&in_times);
1064 if (((_aidl_ret_status) != (::android::OK))) {
1065 break;
1066 }
1067 atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::Piff::cppServer");
1068 ::android::binder::Status _aidl_status(Piff(in_times));
1069 atrace_end(ATRACE_TAG_AIDL);
1070 }
1071 break;
Jeongik Chab5d962f2018-11-17 09:12:28 +09001072 case ::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* TakesABinder */:
Jiyong Parka755dc72018-06-29 13:52:24 +09001073 {
1074 ::android::sp<::foo::IFooType> in_f;
1075 ::android::sp<::foo::IFooType> _aidl_return;
1076 if (!(_aidl_data.checkInterface(this))) {
1077 _aidl_ret_status = ::android::BAD_TYPE;
1078 break;
1079 }
1080 _aidl_ret_status = _aidl_data.readStrongBinder(&in_f);
1081 if (((_aidl_ret_status) != (::android::OK))) {
1082 break;
1083 }
1084 atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::TakesABinder::cppServer");
1085 ::android::binder::Status _aidl_status(TakesABinder(in_f, &_aidl_return));
1086 atrace_end(ATRACE_TAG_AIDL);
1087 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
1088 if (((_aidl_ret_status) != (::android::OK))) {
1089 break;
1090 }
1091 if (!_aidl_status.isOk()) {
1092 break;
1093 }
1094 _aidl_ret_status = _aidl_reply->writeStrongBinder(::foo::IFooType::asBinder(_aidl_return));
1095 if (((_aidl_ret_status) != (::android::OK))) {
1096 break;
1097 }
1098 }
1099 break;
Jeongik Chab5d962f2018-11-17 09:12:28 +09001100 case ::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableBinder */:
Jiyong Parka755dc72018-06-29 13:52:24 +09001101 {
1102 ::android::sp<::foo::IFooType> _aidl_return;
1103 if (!(_aidl_data.checkInterface(this))) {
1104 _aidl_ret_status = ::android::BAD_TYPE;
1105 break;
1106 }
1107 atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::NullableBinder::cppServer");
1108 ::android::binder::Status _aidl_status(NullableBinder(&_aidl_return));
1109 atrace_end(ATRACE_TAG_AIDL);
1110 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
1111 if (((_aidl_ret_status) != (::android::OK))) {
1112 break;
1113 }
1114 if (!_aidl_status.isOk()) {
1115 break;
1116 }
1117 _aidl_ret_status = _aidl_reply->writeStrongBinder(::foo::IFooType::asBinder(_aidl_return));
1118 if (((_aidl_ret_status) != (::android::OK))) {
1119 break;
1120 }
1121 }
1122 break;
Jeongik Chab5d962f2018-11-17 09:12:28 +09001123 case ::android::IBinder::FIRST_CALL_TRANSACTION + 4 /* StringListMethod */:
Jiyong Parka755dc72018-06-29 13:52:24 +09001124 {
1125 ::std::vector<::android::String16> in_input;
1126 ::std::vector<::android::String16> out_output;
1127 ::std::vector<::android::String16> _aidl_return;
1128 if (!(_aidl_data.checkInterface(this))) {
1129 _aidl_ret_status = ::android::BAD_TYPE;
1130 break;
1131 }
1132 _aidl_ret_status = _aidl_data.readString16Vector(&in_input);
1133 if (((_aidl_ret_status) != (::android::OK))) {
1134 break;
1135 }
1136 atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::StringListMethod::cppServer");
1137 ::android::binder::Status _aidl_status(StringListMethod(in_input, &out_output, &_aidl_return));
1138 atrace_end(ATRACE_TAG_AIDL);
1139 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
1140 if (((_aidl_ret_status) != (::android::OK))) {
1141 break;
1142 }
1143 if (!_aidl_status.isOk()) {
1144 break;
1145 }
1146 _aidl_ret_status = _aidl_reply->writeString16Vector(_aidl_return);
1147 if (((_aidl_ret_status) != (::android::OK))) {
1148 break;
1149 }
1150 _aidl_ret_status = _aidl_reply->writeString16Vector(out_output);
1151 if (((_aidl_ret_status) != (::android::OK))) {
1152 break;
1153 }
1154 }
1155 break;
Jeongik Chab5d962f2018-11-17 09:12:28 +09001156 case ::android::IBinder::FIRST_CALL_TRANSACTION + 5 /* BinderListMethod */:
Jiyong Parka755dc72018-06-29 13:52:24 +09001157 {
1158 ::std::vector<::android::sp<::android::IBinder>> in_input;
1159 ::std::vector<::android::sp<::android::IBinder>> out_output;
1160 ::std::vector<::android::sp<::android::IBinder>> _aidl_return;
1161 if (!(_aidl_data.checkInterface(this))) {
1162 _aidl_ret_status = ::android::BAD_TYPE;
1163 break;
1164 }
1165 _aidl_ret_status = _aidl_data.readStrongBinderVector(&in_input);
1166 if (((_aidl_ret_status) != (::android::OK))) {
1167 break;
1168 }
1169 atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::BinderListMethod::cppServer");
1170 ::android::binder::Status _aidl_status(BinderListMethod(in_input, &out_output, &_aidl_return));
1171 atrace_end(ATRACE_TAG_AIDL);
1172 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
1173 if (((_aidl_ret_status) != (::android::OK))) {
1174 break;
1175 }
1176 if (!_aidl_status.isOk()) {
1177 break;
1178 }
1179 _aidl_ret_status = _aidl_reply->writeStrongBinderVector(_aidl_return);
1180 if (((_aidl_ret_status) != (::android::OK))) {
1181 break;
1182 }
1183 _aidl_ret_status = _aidl_reply->writeStrongBinderVector(out_output);
1184 if (((_aidl_ret_status) != (::android::OK))) {
1185 break;
1186 }
1187 }
1188 break;
Jeongik Chab5d962f2018-11-17 09:12:28 +09001189 case ::android::IBinder::FIRST_CALL_TRANSACTION + 6 /* TakesAFileDescriptor */:
Jiyong Parka755dc72018-06-29 13:52:24 +09001190 {
1191 ::android::base::unique_fd in_f;
1192 ::android::base::unique_fd _aidl_return;
1193 if (!(_aidl_data.checkInterface(this))) {
1194 _aidl_ret_status = ::android::BAD_TYPE;
1195 break;
1196 }
1197 _aidl_ret_status = _aidl_data.readUniqueFileDescriptor(&in_f);
1198 if (((_aidl_ret_status) != (::android::OK))) {
1199 break;
1200 }
1201 atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::TakesAFileDescriptor::cppServer");
1202 ::android::binder::Status _aidl_status(TakesAFileDescriptor(in_f, &_aidl_return));
1203 atrace_end(ATRACE_TAG_AIDL);
1204 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
1205 if (((_aidl_ret_status) != (::android::OK))) {
1206 break;
1207 }
1208 if (!_aidl_status.isOk()) {
1209 break;
1210 }
1211 _aidl_ret_status = _aidl_reply->writeUniqueFileDescriptor(_aidl_return);
1212 if (((_aidl_ret_status) != (::android::OK))) {
1213 break;
1214 }
1215 }
1216 break;
Jeongik Chab5d962f2018-11-17 09:12:28 +09001217 case ::android::IBinder::FIRST_CALL_TRANSACTION + 7 /* TakesAFileDescriptorArray */:
Jiyong Parka755dc72018-06-29 13:52:24 +09001218 {
1219 ::std::vector<::android::base::unique_fd> in_f;
1220 ::std::vector<::android::base::unique_fd> _aidl_return;
1221 if (!(_aidl_data.checkInterface(this))) {
1222 _aidl_ret_status = ::android::BAD_TYPE;
1223 break;
1224 }
1225 _aidl_ret_status = _aidl_data.readUniqueFileDescriptorVector(&in_f);
1226 if (((_aidl_ret_status) != (::android::OK))) {
1227 break;
1228 }
1229 atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::TakesAFileDescriptorArray::cppServer");
1230 ::android::binder::Status _aidl_status(TakesAFileDescriptorArray(in_f, &_aidl_return));
1231 atrace_end(ATRACE_TAG_AIDL);
1232 _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
1233 if (((_aidl_ret_status) != (::android::OK))) {
1234 break;
1235 }
1236 if (!_aidl_status.isOk()) {
1237 break;
1238 }
1239 _aidl_ret_status = _aidl_reply->writeUniqueFileDescriptorVector(_aidl_return);
1240 if (((_aidl_ret_status) != (::android::OK))) {
1241 break;
1242 }
1243 }
1244 break;
1245 default:
1246 {
1247 _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
1248 }
1249 break;
1250 }
1251 if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
1252 _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
1253 }
1254 return _aidl_ret_status;
Martijn Coenenf1b50782018-02-21 21:06:23 +01001255}
1256
1257} // namespace os
1258
1259} // namespace android
1260)";
1261
Casey Dahlinb0966612015-10-19 16:35:26 -07001262const char kExpectedComplexTypeInterfaceHeaderOutput[] =
Jiyong Park75e1a742018-07-04 12:31:23 +09001263 R"(#ifndef AIDL_GENERATED_ANDROID_OS_I_COMPLEX_TYPE_INTERFACE_H_
Casey Dahlinb0966612015-10-19 16:35:26 -07001264#define AIDL_GENERATED_ANDROID_OS_I_COMPLEX_TYPE_INTERFACE_H_
1265
Christopher Wiley7cb9c252016-04-11 11:07:33 -07001266#include <android-base/unique_fd.h>
Casey Dahlinb0966612015-10-19 16:35:26 -07001267#include <binder/IBinder.h>
1268#include <binder/IInterface.h>
Christopher Wiley433c8bb2015-11-12 14:20:46 -08001269#include <binder/Status.h>
Casey Dahlinb0966612015-10-19 16:35:26 -07001270#include <cstdint>
Casey Dahlin389781f2015-10-22 13:13:21 -07001271#include <foo/IFooType.h>
Christopher Wiley041c8d72016-08-18 13:52:51 -07001272#include <memory>
Christopher Wiley56c9bf32015-10-30 10:41:12 -07001273#include <utils/String16.h>
Casey Dahlin389781f2015-10-22 13:13:21 -07001274#include <utils/StrongPointer.h>
Casey Dahlinb0966612015-10-19 16:35:26 -07001275#include <vector>
1276
1277namespace android {
1278
1279namespace os {
1280
Casey Dahlinb8d9e882015-11-24 10:57:23 -08001281class IComplexTypeInterface : public ::android::IInterface {
Casey Dahlinb0966612015-10-19 16:35:26 -07001282public:
Jiyong Parka755dc72018-06-29 13:52:24 +09001283 DECLARE_META_INTERFACE(ComplexTypeInterface)
1284 enum : int32_t {
1285 MY_CONSTANT = 3,
1286 };
1287 virtual ::android::binder::Status Send(const ::std::unique_ptr<::std::vector<int32_t>>& goes_in, ::std::vector<double>* goes_in_and_out, ::std::vector<bool>* goes_out, ::std::vector<int32_t>* _aidl_return) = 0;
1288 virtual ::android::binder::Status Piff(int32_t times) = 0;
1289 virtual ::android::binder::Status TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) = 0;
1290 virtual ::android::binder::Status NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) = 0;
1291 virtual ::android::binder::Status StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) = 0;
1292 virtual ::android::binder::Status BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>& input, ::std::vector<::android::sp<::android::IBinder>>* output, ::std::vector<::android::sp<::android::IBinder>>* _aidl_return) = 0;
1293 virtual ::android::binder::Status TakesAFileDescriptor(const ::android::base::unique_fd& f, ::android::base::unique_fd* _aidl_return) = 0;
1294 virtual ::android::binder::Status TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) = 0;
Casey Dahlinb0966612015-10-19 16:35:26 -07001295}; // class IComplexTypeInterface
1296
Jiyong Park75e1a742018-07-04 12:31:23 +09001297class IComplexTypeInterfaceDefault : public IComplexTypeInterface {
1298public:
1299 ::android::IBinder* onAsBinder() override;
1300 ::android::binder::Status Send(const ::std::unique_ptr<::std::vector<int32_t>>& goes_in, ::std::vector<double>* goes_in_and_out, ::std::vector<bool>* goes_out, ::std::vector<int32_t>* _aidl_return) override;
1301 ::android::binder::Status Piff(int32_t times) override;
1302 ::android::binder::Status TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) override;
1303 ::android::binder::Status NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) override;
1304 ::android::binder::Status StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) override;
1305 ::android::binder::Status BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>& input, ::std::vector<::android::sp<::android::IBinder>>* output, ::std::vector<::android::sp<::android::IBinder>>* _aidl_return) override;
1306 ::android::binder::Status TakesAFileDescriptor(const ::android::base::unique_fd& f, ::android::base::unique_fd* _aidl_return) override;
1307 ::android::binder::Status TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) override;
1308
1309};
1310
Casey Dahlinb0966612015-10-19 16:35:26 -07001311} // namespace os
1312
1313} // namespace android
1314
Christopher Wiley11a9d792016-02-24 17:20:33 -08001315#endif // AIDL_GENERATED_ANDROID_OS_I_COMPLEX_TYPE_INTERFACE_H_
1316)";
Casey Dahlinb0966612015-10-19 16:35:26 -07001317
1318const char kExpectedComplexTypeInterfaceSourceOutput[] =
Jiyong Park75e1a742018-07-04 12:31:23 +09001319 R"(#include <android/os/IComplexTypeInterface.h>
Casey Dahlinb0966612015-10-19 16:35:26 -07001320#include <android/os/BpComplexTypeInterface.h>
1321
1322namespace android {
1323
1324namespace os {
1325
Christopher Wiley11a9d792016-02-24 17:20:33 -08001326IMPLEMENT_META_INTERFACE(ComplexTypeInterface, "android.os.IComplexTypeInterface")
Casey Dahlinb0966612015-10-19 16:35:26 -07001327
Jiyong Park75e1a742018-07-04 12:31:23 +09001328::android::IBinder* IComplexTypeInterfaceDefault::onAsBinder() {
1329 return nullptr;
1330}
1331
1332::android::binder::Status IComplexTypeInterfaceDefault::Send(const ::std::unique_ptr<::std::vector<int32_t>>&, ::std::vector<double>*, ::std::vector<bool>*, ::std::vector<int32_t>* ) {
1333 return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
1334}
1335
1336::android::binder::Status IComplexTypeInterfaceDefault::Piff(int32_t) {
1337 return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
1338}
1339
1340::android::binder::Status IComplexTypeInterfaceDefault::TakesABinder(const ::android::sp<::foo::IFooType>&, ::android::sp<::foo::IFooType>* ) {
1341 return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
1342}
1343
1344::android::binder::Status IComplexTypeInterfaceDefault::NullableBinder(::android::sp<::foo::IFooType>* ) {
1345 return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
1346}
1347
1348::android::binder::Status IComplexTypeInterfaceDefault::StringListMethod(const ::std::vector<::android::String16>&, ::std::vector<::android::String16>*, ::std::vector<::android::String16>* ) {
1349 return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
1350}
1351
1352::android::binder::Status IComplexTypeInterfaceDefault::BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>&, ::std::vector<::android::sp<::android::IBinder>>*, ::std::vector<::android::sp<::android::IBinder>>* ) {
1353 return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
1354}
1355
1356::android::binder::Status IComplexTypeInterfaceDefault::TakesAFileDescriptor(const ::android::base::unique_fd&, ::android::base::unique_fd* ) {
1357 return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
1358}
1359
1360::android::binder::Status IComplexTypeInterfaceDefault::TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>&, ::std::vector<::android::base::unique_fd>* ) {
1361 return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
1362}
1363
Casey Dahlinb0966612015-10-19 16:35:26 -07001364} // namespace os
1365
1366} // namespace android
1367)";
1368
Casey Dahlina834dd42015-09-23 11:52:15 -07001369} // namespace
1370
Casey Dahlinb0966612015-10-19 16:35:26 -07001371class ASTTest : public ::testing::Test {
Christopher Wiley0c732db2015-09-29 14:36:44 -07001372 protected:
Jiyong Park6f77e0c2018-07-28 16:55:44 +09001373 ASTTest(const string& cmdline, const string& file_contents)
1374 : options_(Options::From(cmdline)), file_contents_(file_contents) {
Christopher Wiley56799522015-10-31 10:17:04 -07001375 types_.Init();
1376 }
Casey Dahlinb0966612015-10-19 16:35:26 -07001377
Jiyong Parkb034bf02018-07-30 17:44:33 +09001378 AidlInterface* ParseSingleInterface() {
Jiyong Park6f77e0c2018-07-28 16:55:44 +09001379 io_delegate_.SetFileContents(options_.InputFiles().at(0), file_contents_);
Casey Dahlina834dd42015-09-23 11:52:15 -07001380
Jiyong Parkb034bf02018-07-30 17:44:33 +09001381 vector<AidlDefinedType*> defined_types;
1382 vector<string> imported_files;
Jiyong Park8c380532018-08-30 14:55:26 +09001383 ImportResolver import_resolver{io_delegate_, options_.InputFiles().at(0), {"."}, {}};
Jiyong Park6f77e0c2018-07-28 16:55:44 +09001384 AidlError err = ::android::aidl::internals::load_and_validate_aidl(
Jiyong Parkb034bf02018-07-30 17:44:33 +09001385 options_.InputFiles().front(), options_, io_delegate_, &types_, &defined_types,
1386 &imported_files);
Christopher Wiley4a2884b2015-10-07 11:27:45 -07001387
Steven Moreland5557f1c2018-07-02 13:50:23 -07001388 if (err != AidlError::OK) {
Casey Dahlin2cc93162015-10-02 16:14:17 -07001389 return nullptr;
Steven Moreland5557f1c2018-07-02 13:50:23 -07001390 }
Casey Dahlina834dd42015-09-23 11:52:15 -07001391
Jiyong Parkb034bf02018-07-30 17:44:33 +09001392 EXPECT_EQ(1ul, defined_types.size());
1393 EXPECT_NE(nullptr, defined_types.front()->AsInterface());
Steven Moreland5557f1c2018-07-02 13:50:23 -07001394
Jiyong Parkb034bf02018-07-30 17:44:33 +09001395 return defined_types.front()->AsInterface();
Christopher Wiley90be4e32015-10-20 14:55:25 -07001396 }
Casey Dahlina834dd42015-09-23 11:52:15 -07001397
Christopher Wiley0c732db2015-09-29 14:36:44 -07001398 void Compare(Document* doc, const char* expected) {
1399 string output;
Jiyong Parkb78e15b2018-07-04 20:31:03 +09001400 doc->Write(CodeWriter::ForString(&output).get());
Christopher Wiley0c732db2015-09-29 14:36:44 -07001401
Casey Dahlin80ada3d2015-10-20 20:33:56 -07001402 if (expected == output) {
1403 return; // Success
1404 }
1405
1406 test::PrintDiff(expected, output);
1407 FAIL() << "Document contents did not match expected contents";
Christopher Wiley0c732db2015-09-29 14:36:44 -07001408 }
Casey Dahlin389781f2015-10-22 13:13:21 -07001409
Jiyong Park6f77e0c2018-07-28 16:55:44 +09001410 const Options options_;
Casey Dahlin389781f2015-10-22 13:13:21 -07001411 const string file_contents_;
1412 FakeIoDelegate io_delegate_;
1413 TypeNamespace types_;
Christopher Wiley0c732db2015-09-29 14:36:44 -07001414};
1415
Casey Dahlinb0966612015-10-19 16:35:26 -07001416class ComplexTypeInterfaceASTTest : public ASTTest {
Casey Dahlin389781f2015-10-22 13:13:21 -07001417 public:
1418 ComplexTypeInterfaceASTTest()
Jiyong Parkfbbfa932018-07-30 21:44:10 +09001419 : ASTTest("aidl --lang=cpp -I . -o out android/os/IComplexTypeInterface.aidl",
Casey Dahlin389781f2015-10-22 13:13:21 -07001420 kComplexTypeInterfaceAIDL) {
1421 io_delegate_.SetFileContents("foo/IFooType.aidl",
1422 "package foo; interface IFooType {}");
1423 }
Casey Dahlinb0966612015-10-19 16:35:26 -07001424};
1425
1426TEST_F(ComplexTypeInterfaceASTTest, GeneratesClientHeader) {
Jiyong Parkb034bf02018-07-30 17:44:33 +09001427 AidlInterface* interface = ParseSingleInterface();
Casey Dahlinb0966612015-10-19 16:35:26 -07001428 ASSERT_NE(interface, nullptr);
Jiyong Parkfbbfa932018-07-30 21:44:10 +09001429 unique_ptr<Document> doc = internals::BuildClientHeader(types_, *interface, options_);
Casey Dahlinb0966612015-10-19 16:35:26 -07001430 Compare(doc.get(), kExpectedComplexTypeClientHeaderOutput);
1431}
1432
1433TEST_F(ComplexTypeInterfaceASTTest, GeneratesClientSource) {
Jiyong Parkb034bf02018-07-30 17:44:33 +09001434 AidlInterface* interface = ParseSingleInterface();
Casey Dahlinb0966612015-10-19 16:35:26 -07001435 ASSERT_NE(interface, nullptr);
Jiyong Parkfbbfa932018-07-30 21:44:10 +09001436 unique_ptr<Document> doc = internals::BuildClientSource(types_, *interface, options_);
Casey Dahlinb0966612015-10-19 16:35:26 -07001437 Compare(doc.get(), kExpectedComplexTypeClientSourceOutput);
1438}
1439
1440TEST_F(ComplexTypeInterfaceASTTest, GeneratesServerHeader) {
Jiyong Parkb034bf02018-07-30 17:44:33 +09001441 AidlInterface* interface = ParseSingleInterface();
Casey Dahlinb0966612015-10-19 16:35:26 -07001442 ASSERT_NE(interface, nullptr);
Jiyong Parkfbbfa932018-07-30 21:44:10 +09001443 unique_ptr<Document> doc = internals::BuildServerHeader(types_, *interface, options_);
Casey Dahlinb0966612015-10-19 16:35:26 -07001444 Compare(doc.get(), kExpectedComplexTypeServerHeaderOutput);
1445}
1446
1447TEST_F(ComplexTypeInterfaceASTTest, GeneratesServerSource) {
Jiyong Parkb034bf02018-07-30 17:44:33 +09001448 AidlInterface* interface = ParseSingleInterface();
Casey Dahlinb0966612015-10-19 16:35:26 -07001449 ASSERT_NE(interface, nullptr);
Jiyong Parkfbbfa932018-07-30 21:44:10 +09001450 unique_ptr<Document> doc = internals::BuildServerSource(types_, *interface, options_);
Casey Dahlinb0966612015-10-19 16:35:26 -07001451 Compare(doc.get(), kExpectedComplexTypeServerSourceOutput);
1452}
1453
1454TEST_F(ComplexTypeInterfaceASTTest, GeneratesInterfaceHeader) {
Jiyong Parkb034bf02018-07-30 17:44:33 +09001455 AidlInterface* interface = ParseSingleInterface();
Casey Dahlinb0966612015-10-19 16:35:26 -07001456 ASSERT_NE(interface, nullptr);
Jiyong Parkfbbfa932018-07-30 21:44:10 +09001457 unique_ptr<Document> doc = internals::BuildInterfaceHeader(types_, *interface, options_);
Casey Dahlinb0966612015-10-19 16:35:26 -07001458 Compare(doc.get(), kExpectedComplexTypeInterfaceHeaderOutput);
1459}
1460
1461TEST_F(ComplexTypeInterfaceASTTest, GeneratesInterfaceSource) {
Jiyong Parkb034bf02018-07-30 17:44:33 +09001462 AidlInterface* interface = ParseSingleInterface();
Casey Dahlinb0966612015-10-19 16:35:26 -07001463 ASSERT_NE(interface, nullptr);
Jiyong Parkfbbfa932018-07-30 21:44:10 +09001464 unique_ptr<Document> doc = internals::BuildInterfaceSource(types_, *interface, options_);
Casey Dahlinb0966612015-10-19 16:35:26 -07001465 Compare(doc.get(), kExpectedComplexTypeInterfaceSourceOutput);
Christopher Wiley1dd458d2015-09-30 11:05:52 -07001466}
1467
Jiyong Parkfbbfa932018-07-30 21:44:10 +09001468class ComplexTypeInterfaceASTTestWithTrace : public ASTTest {
1469 public:
1470 ComplexTypeInterfaceASTTestWithTrace()
1471 : ASTTest("aidl --lang=cpp -t -I . -o out android/os/IComplexTypeInterface.aidl",
1472 kComplexTypeInterfaceAIDL) {
1473 io_delegate_.SetFileContents("foo/IFooType.aidl", "package foo; interface IFooType {}");
1474 }
1475};
1476
1477TEST_F(ComplexTypeInterfaceASTTestWithTrace, GeneratesClientSource) {
Jiyong Parkb034bf02018-07-30 17:44:33 +09001478 AidlInterface* interface = ParseSingleInterface();
Jiyong Parkfbbfa932018-07-30 21:44:10 +09001479 ASSERT_NE(interface, nullptr);
1480 unique_ptr<Document> doc = internals::BuildClientSource(types_, *interface, options_);
1481 Compare(doc.get(), kExpectedComplexTypeClientWithTraceSourceOutput);
1482}
1483
1484TEST_F(ComplexTypeInterfaceASTTestWithTrace, GeneratesServerSource) {
Jiyong Parkb034bf02018-07-30 17:44:33 +09001485 AidlInterface* interface = ParseSingleInterface();
Jiyong Parkfbbfa932018-07-30 21:44:10 +09001486 ASSERT_NE(interface, nullptr);
1487 unique_ptr<Document> doc = internals::BuildServerSource(types_, *interface, options_);
1488 Compare(doc.get(), kExpectedComplexTypeServerWithTraceSourceOutput);
1489}
1490
Christopher Wiley9d6e0b22015-11-13 12:18:16 -08001491namespace test_io_handling {
1492
1493const char kInputPath[] = "a/IFoo.aidl";
1494const char kOutputPath[] = "output.cpp";
1495const char kHeaderDir[] = "headers";
1496const char kInterfaceHeaderRelPath[] = "a/IFoo.h";
1497
Jiyong Park6f77e0c2018-07-28 16:55:44 +09001498const string kCmdline = string("aidl-cpp ") + kInputPath + " " + kHeaderDir + " " + kOutputPath;
1499
Christopher Wiley9d6e0b22015-11-13 12:18:16 -08001500} // namespace test_io_handling
1501
1502class IoErrorHandlingTest : public ASTTest {
1503 public:
Jiyong Park6f77e0c2018-07-28 16:55:44 +09001504 IoErrorHandlingTest() : ASTTest(test_io_handling::kCmdline, "package a; interface IFoo {}") {}
Christopher Wiley9d6e0b22015-11-13 12:18:16 -08001505};
1506
1507TEST_F(IoErrorHandlingTest, GenerateCorrectlyAbsentErrors) {
1508 // Confirm that this is working correctly without I/O problems.
Jiyong Parkb034bf02018-07-30 17:44:33 +09001509 AidlInterface* interface = ParseSingleInterface();
Christopher Wiley9d6e0b22015-11-13 12:18:16 -08001510 ASSERT_NE(interface, nullptr);
Jiyong Park6f77e0c2018-07-28 16:55:44 +09001511 ASSERT_TRUE(GenerateCpp(options_.OutputFile(), options_, types_, *interface, io_delegate_));
Christopher Wiley9d6e0b22015-11-13 12:18:16 -08001512}
1513
1514TEST_F(IoErrorHandlingTest, HandlesBadHeaderWrite) {
1515 using namespace test_io_handling;
Jiyong Parkb034bf02018-07-30 17:44:33 +09001516 AidlInterface* interface = ParseSingleInterface();
Christopher Wiley9d6e0b22015-11-13 12:18:16 -08001517 ASSERT_NE(interface, nullptr);
1518
1519 // Simulate issues closing the interface header.
1520 const string header_path =
1521 StringPrintf("%s%c%s", kHeaderDir, OS_PATH_SEPARATOR,
1522 kInterfaceHeaderRelPath);
1523 io_delegate_.AddBrokenFilePath(header_path);
Jiyong Park6f77e0c2018-07-28 16:55:44 +09001524 ASSERT_FALSE(GenerateCpp(options_.OutputFile(), options_, types_, *interface, io_delegate_));
Christopher Wiley9d6e0b22015-11-13 12:18:16 -08001525 // We should never attempt to write the C++ file if we fail writing headers.
1526 ASSERT_FALSE(io_delegate_.GetWrittenContents(kOutputPath, nullptr));
1527 // We should remove partial results.
1528 ASSERT_TRUE(io_delegate_.PathWasRemoved(header_path));
1529}
1530
1531TEST_F(IoErrorHandlingTest, HandlesBadCppWrite) {
1532 using test_io_handling::kOutputPath;
Jiyong Parkb034bf02018-07-30 17:44:33 +09001533 AidlInterface* interface = ParseSingleInterface();
Christopher Wiley9d6e0b22015-11-13 12:18:16 -08001534 ASSERT_NE(interface, nullptr);
1535
1536 // Simulate issues closing the cpp file.
1537 io_delegate_.AddBrokenFilePath(kOutputPath);
Jiyong Park6f77e0c2018-07-28 16:55:44 +09001538 ASSERT_FALSE(GenerateCpp(options_.OutputFile(), options_, types_, *interface, io_delegate_));
Christopher Wiley9d6e0b22015-11-13 12:18:16 -08001539 // We should remove partial results.
1540 ASSERT_TRUE(io_delegate_.PathWasRemoved(kOutputPath));
1541}
1542
Christopher Wileyf944e792015-09-29 10:00:46 -07001543} // namespace cpp
Casey Dahlina834dd42015-09-23 11:52:15 -07001544} // namespace aidl
1545} // namespace android