Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 1 | /* |
| 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 Hughes | 0a62067 | 2015-12-04 13:53:18 -0800 | [diff] [blame] | 19 | #include <android-base/stringprintf.h> |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 20 | #include <gtest/gtest.h> |
| 21 | |
Casey Dahlin | 2cc9316 | 2015-10-02 16:14:17 -0700 | [diff] [blame] | 22 | #include "aidl.h" |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 23 | #include "aidl_language.h" |
| 24 | #include "ast_cpp.h" |
| 25 | #include "code_writer.h" |
Christopher Wiley | ad33927 | 2015-10-05 19:11:58 -0700 | [diff] [blame] | 26 | #include "generate_cpp.h" |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 27 | #include "os.h" |
Christopher Wiley | 4a2884b | 2015-10-07 11:27:45 -0700 | [diff] [blame] | 28 | #include "tests/fake_io_delegate.h" |
Casey Dahlin | 80ada3d | 2015-10-20 20:33:56 -0700 | [diff] [blame] | 29 | #include "tests/test_util.h" |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 30 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 31 | using ::android::aidl::test::FakeIoDelegate; |
| 32 | using ::android::base::StringPrintf; |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 33 | using std::string; |
| 34 | using std::unique_ptr; |
| 35 | |
| 36 | namespace android { |
| 37 | namespace aidl { |
Christopher Wiley | f944e79 | 2015-09-29 10:00:46 -0700 | [diff] [blame] | 38 | namespace cpp { |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 39 | namespace { |
| 40 | |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 41 | // clang-format off |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 42 | const string kComplexTypeInterfaceAIDL = |
| 43 | R"(package android.os; |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 44 | import foo.IFooType; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 45 | interface IComplexTypeInterface { |
Casey Dahlin | d40e2fe | 2015-11-24 14:06:52 -0800 | [diff] [blame] | 46 | const int MY_CONSTANT = 3; |
Casey Dahlin | cb5317d | 2015-12-03 15:43:33 -0800 | [diff] [blame] | 47 | int[] Send(in @nullable int[] goes_in, inout double[] goes_in_and_out, out boolean[] goes_out); |
Casey Dahlin | 0dd08af | 2015-10-20 18:45:50 -0700 | [diff] [blame] | 48 | oneway void Piff(int times); |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 49 | IFooType TakesABinder(IFooType f); |
Casey Dahlin | ef88bce | 2016-04-15 11:55:30 -0700 | [diff] [blame] | 50 | @nullable IFooType NullableBinder(); |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 51 | List<String> StringListMethod(in java.util.List<String> input, out List<String> output); |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 52 | List<IBinder> BinderListMethod(in java.util.List<IBinder> input, out List<IBinder> output); |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 53 | FileDescriptor TakesAFileDescriptor(in FileDescriptor f); |
| 54 | FileDescriptor[] TakesAFileDescriptorArray(in FileDescriptor[] f); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 55 | })"; |
| 56 | |
| 57 | const char kExpectedComplexTypeClientHeaderOutput[] = |
Devin Moore | 7aaa9cb | 2020-08-13 14:53:01 -0700 | [diff] [blame] | 58 | R"(#pragma once |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 59 | |
| 60 | #include <binder/IBinder.h> |
| 61 | #include <binder/IInterface.h> |
| 62 | #include <utils/Errors.h> |
| 63 | #include <android/os/IComplexTypeInterface.h> |
| 64 | |
| 65 | namespace android { |
| 66 | |
| 67 | namespace os { |
| 68 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 69 | class BpComplexTypeInterface : public ::android::BpInterface<IComplexTypeInterface> { |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 70 | public: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 71 | explicit BpComplexTypeInterface(const ::android::sp<::android::IBinder>& _aidl_impl); |
| 72 | virtual ~BpComplexTypeInterface() = default; |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 73 | ::android::binder::Status Send(const ::std::optional<::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; |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 74 | ::android::binder::Status Piff(int32_t times) override; |
| 75 | ::android::binder::Status TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) override; |
| 76 | ::android::binder::Status NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) override; |
| 77 | ::android::binder::Status StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) override; |
| 78 | ::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; |
Jiyong Park | 4f3e8c0 | 2019-11-22 14:28:47 +0900 | [diff] [blame] | 79 | ::android::binder::Status TakesAFileDescriptor(::android::base::unique_fd f, ::android::base::unique_fd* _aidl_return) override; |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 80 | ::android::binder::Status TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) override; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 81 | }; // class BpComplexTypeInterface |
| 82 | |
| 83 | } // namespace os |
| 84 | |
| 85 | } // namespace android |
Christopher Wiley | 11a9d79 | 2016-02-24 17:20:33 -0800 | [diff] [blame] | 86 | )"; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 87 | |
| 88 | const char kExpectedComplexTypeClientSourceOutput[] = |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 89 | R"(#include <android/os/BpComplexTypeInterface.h> |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 90 | #include <android/os/BnComplexTypeInterface.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 91 | #include <binder/Parcel.h> |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 92 | #include <android-base/macros.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 93 | |
| 94 | namespace android { |
| 95 | |
| 96 | namespace os { |
| 97 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 98 | BpComplexTypeInterface::BpComplexTypeInterface(const ::android::sp<::android::IBinder>& _aidl_impl) |
| 99 | : BpInterface<IComplexTypeInterface>(_aidl_impl){ |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 102 | ::android::binder::Status BpComplexTypeInterface::Send(const ::std::optional<::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 Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 103 | ::android::Parcel _aidl_data; |
| 104 | ::android::Parcel _aidl_reply; |
| 105 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 106 | ::android::binder::Status _aidl_status; |
| 107 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 108 | if (((_aidl_ret_status) != (::android::OK))) { |
| 109 | goto _aidl_error; |
| 110 | } |
| 111 | _aidl_ret_status = _aidl_data.writeInt32Vector(goes_in); |
| 112 | if (((_aidl_ret_status) != (::android::OK))) { |
| 113 | goto _aidl_error; |
| 114 | } |
| 115 | _aidl_ret_status = _aidl_data.writeDoubleVector(*goes_in_and_out); |
| 116 | if (((_aidl_ret_status) != (::android::OK))) { |
| 117 | goto _aidl_error; |
| 118 | } |
| 119 | _aidl_ret_status = _aidl_data.writeVectorSize(*goes_out); |
| 120 | if (((_aidl_ret_status) != (::android::OK))) { |
| 121 | goto _aidl_error; |
| 122 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 123 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_Send, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 124 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 125 | return IComplexTypeInterface::getDefaultImpl()->Send(goes_in, goes_in_and_out, goes_out, _aidl_return); |
| 126 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 127 | if (((_aidl_ret_status) != (::android::OK))) { |
| 128 | goto _aidl_error; |
| 129 | } |
| 130 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 131 | if (((_aidl_ret_status) != (::android::OK))) { |
| 132 | goto _aidl_error; |
| 133 | } |
| 134 | if (!_aidl_status.isOk()) { |
| 135 | return _aidl_status; |
| 136 | } |
| 137 | _aidl_ret_status = _aidl_reply.readInt32Vector(_aidl_return); |
| 138 | if (((_aidl_ret_status) != (::android::OK))) { |
| 139 | goto _aidl_error; |
| 140 | } |
| 141 | _aidl_ret_status = _aidl_reply.readDoubleVector(goes_in_and_out); |
| 142 | if (((_aidl_ret_status) != (::android::OK))) { |
| 143 | goto _aidl_error; |
| 144 | } |
| 145 | _aidl_ret_status = _aidl_reply.readBoolVector(goes_out); |
| 146 | if (((_aidl_ret_status) != (::android::OK))) { |
| 147 | goto _aidl_error; |
| 148 | } |
| 149 | _aidl_error: |
| 150 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 151 | return _aidl_status; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 152 | } |
| 153 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 154 | ::android::binder::Status BpComplexTypeInterface::Piff(int32_t times) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 155 | ::android::Parcel _aidl_data; |
| 156 | ::android::Parcel _aidl_reply; |
| 157 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 158 | ::android::binder::Status _aidl_status; |
| 159 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 160 | if (((_aidl_ret_status) != (::android::OK))) { |
| 161 | goto _aidl_error; |
| 162 | } |
| 163 | _aidl_ret_status = _aidl_data.writeInt32(times); |
| 164 | if (((_aidl_ret_status) != (::android::OK))) { |
| 165 | goto _aidl_error; |
| 166 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 167 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_Piff, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_ONEWAY); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 168 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 169 | return IComplexTypeInterface::getDefaultImpl()->Piff(times); |
| 170 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 171 | if (((_aidl_ret_status) != (::android::OK))) { |
| 172 | goto _aidl_error; |
| 173 | } |
| 174 | _aidl_error: |
| 175 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 176 | return _aidl_status; |
Casey Dahlin | 0dd08af | 2015-10-20 18:45:50 -0700 | [diff] [blame] | 177 | } |
| 178 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 179 | ::android::binder::Status BpComplexTypeInterface::TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 180 | ::android::Parcel _aidl_data; |
| 181 | ::android::Parcel _aidl_reply; |
| 182 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 183 | ::android::binder::Status _aidl_status; |
| 184 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 185 | if (((_aidl_ret_status) != (::android::OK))) { |
| 186 | goto _aidl_error; |
| 187 | } |
| 188 | _aidl_ret_status = _aidl_data.writeStrongBinder(::foo::IFooType::asBinder(f)); |
| 189 | if (((_aidl_ret_status) != (::android::OK))) { |
| 190 | goto _aidl_error; |
| 191 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 192 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesABinder, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 193 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 194 | return IComplexTypeInterface::getDefaultImpl()->TakesABinder(f, _aidl_return); |
| 195 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 196 | if (((_aidl_ret_status) != (::android::OK))) { |
| 197 | goto _aidl_error; |
| 198 | } |
| 199 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 200 | if (((_aidl_ret_status) != (::android::OK))) { |
| 201 | goto _aidl_error; |
| 202 | } |
| 203 | if (!_aidl_status.isOk()) { |
| 204 | return _aidl_status; |
| 205 | } |
| 206 | _aidl_ret_status = _aidl_reply.readStrongBinder(_aidl_return); |
| 207 | if (((_aidl_ret_status) != (::android::OK))) { |
| 208 | goto _aidl_error; |
| 209 | } |
| 210 | _aidl_error: |
| 211 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 212 | return _aidl_status; |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 213 | } |
| 214 | |
Casey Dahlin | ef88bce | 2016-04-15 11:55:30 -0700 | [diff] [blame] | 215 | ::android::binder::Status BpComplexTypeInterface::NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 216 | ::android::Parcel _aidl_data; |
| 217 | ::android::Parcel _aidl_reply; |
| 218 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 219 | ::android::binder::Status _aidl_status; |
| 220 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 221 | if (((_aidl_ret_status) != (::android::OK))) { |
| 222 | goto _aidl_error; |
| 223 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 224 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_NullableBinder, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 225 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 226 | return IComplexTypeInterface::getDefaultImpl()->NullableBinder(_aidl_return); |
| 227 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 228 | if (((_aidl_ret_status) != (::android::OK))) { |
| 229 | goto _aidl_error; |
| 230 | } |
| 231 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 232 | if (((_aidl_ret_status) != (::android::OK))) { |
| 233 | goto _aidl_error; |
| 234 | } |
| 235 | if (!_aidl_status.isOk()) { |
| 236 | return _aidl_status; |
| 237 | } |
| 238 | _aidl_ret_status = _aidl_reply.readNullableStrongBinder(_aidl_return); |
| 239 | if (((_aidl_ret_status) != (::android::OK))) { |
| 240 | goto _aidl_error; |
| 241 | } |
| 242 | _aidl_error: |
| 243 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 244 | return _aidl_status; |
Casey Dahlin | ef88bce | 2016-04-15 11:55:30 -0700 | [diff] [blame] | 245 | } |
| 246 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 247 | ::android::binder::Status BpComplexTypeInterface::StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 248 | ::android::Parcel _aidl_data; |
| 249 | ::android::Parcel _aidl_reply; |
| 250 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 251 | ::android::binder::Status _aidl_status; |
| 252 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 253 | if (((_aidl_ret_status) != (::android::OK))) { |
| 254 | goto _aidl_error; |
| 255 | } |
| 256 | _aidl_ret_status = _aidl_data.writeString16Vector(input); |
| 257 | if (((_aidl_ret_status) != (::android::OK))) { |
| 258 | goto _aidl_error; |
| 259 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 260 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_StringListMethod, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 261 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 262 | return IComplexTypeInterface::getDefaultImpl()->StringListMethod(input, output, _aidl_return); |
| 263 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 264 | if (((_aidl_ret_status) != (::android::OK))) { |
| 265 | goto _aidl_error; |
| 266 | } |
| 267 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 268 | if (((_aidl_ret_status) != (::android::OK))) { |
| 269 | goto _aidl_error; |
| 270 | } |
| 271 | if (!_aidl_status.isOk()) { |
| 272 | return _aidl_status; |
| 273 | } |
| 274 | _aidl_ret_status = _aidl_reply.readString16Vector(_aidl_return); |
| 275 | if (((_aidl_ret_status) != (::android::OK))) { |
| 276 | goto _aidl_error; |
| 277 | } |
| 278 | _aidl_ret_status = _aidl_reply.readString16Vector(output); |
| 279 | if (((_aidl_ret_status) != (::android::OK))) { |
| 280 | goto _aidl_error; |
| 281 | } |
| 282 | _aidl_error: |
| 283 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 284 | return _aidl_status; |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 285 | } |
| 286 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 287 | ::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 Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 288 | ::android::Parcel _aidl_data; |
| 289 | ::android::Parcel _aidl_reply; |
| 290 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 291 | ::android::binder::Status _aidl_status; |
| 292 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 293 | if (((_aidl_ret_status) != (::android::OK))) { |
| 294 | goto _aidl_error; |
| 295 | } |
| 296 | _aidl_ret_status = _aidl_data.writeStrongBinderVector(input); |
| 297 | if (((_aidl_ret_status) != (::android::OK))) { |
| 298 | goto _aidl_error; |
| 299 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 300 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_BinderListMethod, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 301 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 302 | return IComplexTypeInterface::getDefaultImpl()->BinderListMethod(input, output, _aidl_return); |
| 303 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 304 | if (((_aidl_ret_status) != (::android::OK))) { |
| 305 | goto _aidl_error; |
| 306 | } |
| 307 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 308 | if (((_aidl_ret_status) != (::android::OK))) { |
| 309 | goto _aidl_error; |
| 310 | } |
| 311 | if (!_aidl_status.isOk()) { |
| 312 | return _aidl_status; |
| 313 | } |
| 314 | _aidl_ret_status = _aidl_reply.readStrongBinderVector(_aidl_return); |
| 315 | if (((_aidl_ret_status) != (::android::OK))) { |
| 316 | goto _aidl_error; |
| 317 | } |
| 318 | _aidl_ret_status = _aidl_reply.readStrongBinderVector(output); |
| 319 | if (((_aidl_ret_status) != (::android::OK))) { |
| 320 | goto _aidl_error; |
| 321 | } |
| 322 | _aidl_error: |
| 323 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 324 | return _aidl_status; |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 325 | } |
| 326 | |
Jiyong Park | 4f3e8c0 | 2019-11-22 14:28:47 +0900 | [diff] [blame] | 327 | ::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptor(::android::base::unique_fd f, ::android::base::unique_fd* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 328 | ::android::Parcel _aidl_data; |
| 329 | ::android::Parcel _aidl_reply; |
| 330 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 331 | ::android::binder::Status _aidl_status; |
| 332 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 333 | if (((_aidl_ret_status) != (::android::OK))) { |
| 334 | goto _aidl_error; |
| 335 | } |
| 336 | _aidl_ret_status = _aidl_data.writeUniqueFileDescriptor(f); |
| 337 | if (((_aidl_ret_status) != (::android::OK))) { |
| 338 | goto _aidl_error; |
| 339 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 340 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptor, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 341 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
Jiyong Park | 4f3e8c0 | 2019-11-22 14:28:47 +0900 | [diff] [blame] | 342 | return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptor(std::move(f), _aidl_return); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 343 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 344 | if (((_aidl_ret_status) != (::android::OK))) { |
| 345 | goto _aidl_error; |
| 346 | } |
| 347 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 348 | if (((_aidl_ret_status) != (::android::OK))) { |
| 349 | goto _aidl_error; |
| 350 | } |
| 351 | if (!_aidl_status.isOk()) { |
| 352 | return _aidl_status; |
| 353 | } |
| 354 | _aidl_ret_status = _aidl_reply.readUniqueFileDescriptor(_aidl_return); |
| 355 | if (((_aidl_ret_status) != (::android::OK))) { |
| 356 | goto _aidl_error; |
| 357 | } |
| 358 | _aidl_error: |
| 359 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 360 | return _aidl_status; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 361 | } |
| 362 | |
Christopher Wiley | 7cb9c25 | 2016-04-11 11:07:33 -0700 | [diff] [blame] | 363 | ::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 364 | ::android::Parcel _aidl_data; |
| 365 | ::android::Parcel _aidl_reply; |
| 366 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 367 | ::android::binder::Status _aidl_status; |
| 368 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 369 | if (((_aidl_ret_status) != (::android::OK))) { |
| 370 | goto _aidl_error; |
| 371 | } |
| 372 | _aidl_ret_status = _aidl_data.writeUniqueFileDescriptorVector(f); |
| 373 | if (((_aidl_ret_status) != (::android::OK))) { |
| 374 | goto _aidl_error; |
| 375 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 376 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptorArray, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 377 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 378 | return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptorArray(f, _aidl_return); |
| 379 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 380 | if (((_aidl_ret_status) != (::android::OK))) { |
| 381 | goto _aidl_error; |
| 382 | } |
| 383 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 384 | if (((_aidl_ret_status) != (::android::OK))) { |
| 385 | goto _aidl_error; |
| 386 | } |
| 387 | if (!_aidl_status.isOk()) { |
| 388 | return _aidl_status; |
| 389 | } |
| 390 | _aidl_ret_status = _aidl_reply.readUniqueFileDescriptorVector(_aidl_return); |
| 391 | if (((_aidl_ret_status) != (::android::OK))) { |
| 392 | goto _aidl_error; |
| 393 | } |
| 394 | _aidl_error: |
| 395 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 396 | return _aidl_status; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 397 | } |
| 398 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 399 | } // namespace os |
| 400 | |
| 401 | } // namespace android |
| 402 | )"; |
| 403 | |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 404 | const char kExpectedComplexTypeClientWithTraceSourceOutput[] = |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 405 | R"(#include <android/os/BpComplexTypeInterface.h> |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 406 | #include <android/os/BnComplexTypeInterface.h> |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 407 | #include <binder/Parcel.h> |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 408 | #include <android-base/macros.h> |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 409 | |
| 410 | namespace android { |
| 411 | |
| 412 | namespace os { |
| 413 | |
| 414 | BpComplexTypeInterface::BpComplexTypeInterface(const ::android::sp<::android::IBinder>& _aidl_impl) |
| 415 | : BpInterface<IComplexTypeInterface>(_aidl_impl){ |
| 416 | } |
| 417 | |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 418 | ::android::binder::Status BpComplexTypeInterface::Send(const ::std::optional<::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 Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 419 | ::android::Parcel _aidl_data; |
| 420 | ::android::Parcel _aidl_reply; |
| 421 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 422 | ::android::binder::Status _aidl_status; |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 423 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::Send::cppClient"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 424 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 425 | if (((_aidl_ret_status) != (::android::OK))) { |
| 426 | goto _aidl_error; |
| 427 | } |
| 428 | _aidl_ret_status = _aidl_data.writeInt32Vector(goes_in); |
| 429 | if (((_aidl_ret_status) != (::android::OK))) { |
| 430 | goto _aidl_error; |
| 431 | } |
| 432 | _aidl_ret_status = _aidl_data.writeDoubleVector(*goes_in_and_out); |
| 433 | if (((_aidl_ret_status) != (::android::OK))) { |
| 434 | goto _aidl_error; |
| 435 | } |
| 436 | _aidl_ret_status = _aidl_data.writeVectorSize(*goes_out); |
| 437 | if (((_aidl_ret_status) != (::android::OK))) { |
| 438 | goto _aidl_error; |
| 439 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 440 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_Send, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 441 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 442 | return IComplexTypeInterface::getDefaultImpl()->Send(goes_in, goes_in_and_out, goes_out, _aidl_return); |
| 443 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 444 | if (((_aidl_ret_status) != (::android::OK))) { |
| 445 | goto _aidl_error; |
| 446 | } |
| 447 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 448 | if (((_aidl_ret_status) != (::android::OK))) { |
| 449 | goto _aidl_error; |
| 450 | } |
| 451 | if (!_aidl_status.isOk()) { |
| 452 | return _aidl_status; |
| 453 | } |
| 454 | _aidl_ret_status = _aidl_reply.readInt32Vector(_aidl_return); |
| 455 | if (((_aidl_ret_status) != (::android::OK))) { |
| 456 | goto _aidl_error; |
| 457 | } |
| 458 | _aidl_ret_status = _aidl_reply.readDoubleVector(goes_in_and_out); |
| 459 | if (((_aidl_ret_status) != (::android::OK))) { |
| 460 | goto _aidl_error; |
| 461 | } |
| 462 | _aidl_ret_status = _aidl_reply.readBoolVector(goes_out); |
| 463 | if (((_aidl_ret_status) != (::android::OK))) { |
| 464 | goto _aidl_error; |
| 465 | } |
| 466 | _aidl_error: |
| 467 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 468 | return _aidl_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | ::android::binder::Status BpComplexTypeInterface::Piff(int32_t times) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 472 | ::android::Parcel _aidl_data; |
| 473 | ::android::Parcel _aidl_reply; |
| 474 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 475 | ::android::binder::Status _aidl_status; |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 476 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::Piff::cppClient"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 477 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 478 | if (((_aidl_ret_status) != (::android::OK))) { |
| 479 | goto _aidl_error; |
| 480 | } |
| 481 | _aidl_ret_status = _aidl_data.writeInt32(times); |
| 482 | if (((_aidl_ret_status) != (::android::OK))) { |
| 483 | goto _aidl_error; |
| 484 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 485 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_Piff, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_ONEWAY); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 486 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 487 | return IComplexTypeInterface::getDefaultImpl()->Piff(times); |
| 488 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 489 | if (((_aidl_ret_status) != (::android::OK))) { |
| 490 | goto _aidl_error; |
| 491 | } |
| 492 | _aidl_error: |
| 493 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 494 | return _aidl_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | ::android::binder::Status BpComplexTypeInterface::TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 498 | ::android::Parcel _aidl_data; |
| 499 | ::android::Parcel _aidl_reply; |
| 500 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 501 | ::android::binder::Status _aidl_status; |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 502 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::TakesABinder::cppClient"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 503 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 504 | if (((_aidl_ret_status) != (::android::OK))) { |
| 505 | goto _aidl_error; |
| 506 | } |
| 507 | _aidl_ret_status = _aidl_data.writeStrongBinder(::foo::IFooType::asBinder(f)); |
| 508 | if (((_aidl_ret_status) != (::android::OK))) { |
| 509 | goto _aidl_error; |
| 510 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 511 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesABinder, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 512 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 513 | return IComplexTypeInterface::getDefaultImpl()->TakesABinder(f, _aidl_return); |
| 514 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 515 | if (((_aidl_ret_status) != (::android::OK))) { |
| 516 | goto _aidl_error; |
| 517 | } |
| 518 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 519 | if (((_aidl_ret_status) != (::android::OK))) { |
| 520 | goto _aidl_error; |
| 521 | } |
| 522 | if (!_aidl_status.isOk()) { |
| 523 | return _aidl_status; |
| 524 | } |
| 525 | _aidl_ret_status = _aidl_reply.readStrongBinder(_aidl_return); |
| 526 | if (((_aidl_ret_status) != (::android::OK))) { |
| 527 | goto _aidl_error; |
| 528 | } |
| 529 | _aidl_error: |
| 530 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 531 | return _aidl_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 532 | } |
| 533 | |
| 534 | ::android::binder::Status BpComplexTypeInterface::NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 535 | ::android::Parcel _aidl_data; |
| 536 | ::android::Parcel _aidl_reply; |
| 537 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 538 | ::android::binder::Status _aidl_status; |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 539 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::NullableBinder::cppClient"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 540 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 541 | if (((_aidl_ret_status) != (::android::OK))) { |
| 542 | goto _aidl_error; |
| 543 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 544 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_NullableBinder, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 545 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 546 | return IComplexTypeInterface::getDefaultImpl()->NullableBinder(_aidl_return); |
| 547 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 548 | if (((_aidl_ret_status) != (::android::OK))) { |
| 549 | goto _aidl_error; |
| 550 | } |
| 551 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 552 | if (((_aidl_ret_status) != (::android::OK))) { |
| 553 | goto _aidl_error; |
| 554 | } |
| 555 | if (!_aidl_status.isOk()) { |
| 556 | return _aidl_status; |
| 557 | } |
| 558 | _aidl_ret_status = _aidl_reply.readNullableStrongBinder(_aidl_return); |
| 559 | if (((_aidl_ret_status) != (::android::OK))) { |
| 560 | goto _aidl_error; |
| 561 | } |
| 562 | _aidl_error: |
| 563 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 564 | return _aidl_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | ::android::binder::Status BpComplexTypeInterface::StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 568 | ::android::Parcel _aidl_data; |
| 569 | ::android::Parcel _aidl_reply; |
| 570 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 571 | ::android::binder::Status _aidl_status; |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 572 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::StringListMethod::cppClient"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 573 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 574 | if (((_aidl_ret_status) != (::android::OK))) { |
| 575 | goto _aidl_error; |
| 576 | } |
| 577 | _aidl_ret_status = _aidl_data.writeString16Vector(input); |
| 578 | if (((_aidl_ret_status) != (::android::OK))) { |
| 579 | goto _aidl_error; |
| 580 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 581 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_StringListMethod, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 582 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 583 | return IComplexTypeInterface::getDefaultImpl()->StringListMethod(input, output, _aidl_return); |
| 584 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 585 | if (((_aidl_ret_status) != (::android::OK))) { |
| 586 | goto _aidl_error; |
| 587 | } |
| 588 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 589 | if (((_aidl_ret_status) != (::android::OK))) { |
| 590 | goto _aidl_error; |
| 591 | } |
| 592 | if (!_aidl_status.isOk()) { |
| 593 | return _aidl_status; |
| 594 | } |
| 595 | _aidl_ret_status = _aidl_reply.readString16Vector(_aidl_return); |
| 596 | if (((_aidl_ret_status) != (::android::OK))) { |
| 597 | goto _aidl_error; |
| 598 | } |
| 599 | _aidl_ret_status = _aidl_reply.readString16Vector(output); |
| 600 | if (((_aidl_ret_status) != (::android::OK))) { |
| 601 | goto _aidl_error; |
| 602 | } |
| 603 | _aidl_error: |
| 604 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 605 | return _aidl_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 606 | } |
| 607 | |
| 608 | ::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 Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 609 | ::android::Parcel _aidl_data; |
| 610 | ::android::Parcel _aidl_reply; |
| 611 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 612 | ::android::binder::Status _aidl_status; |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 613 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::BinderListMethod::cppClient"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 614 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 615 | if (((_aidl_ret_status) != (::android::OK))) { |
| 616 | goto _aidl_error; |
| 617 | } |
| 618 | _aidl_ret_status = _aidl_data.writeStrongBinderVector(input); |
| 619 | if (((_aidl_ret_status) != (::android::OK))) { |
| 620 | goto _aidl_error; |
| 621 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 622 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_BinderListMethod, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 623 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 624 | return IComplexTypeInterface::getDefaultImpl()->BinderListMethod(input, output, _aidl_return); |
| 625 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 626 | if (((_aidl_ret_status) != (::android::OK))) { |
| 627 | goto _aidl_error; |
| 628 | } |
| 629 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 630 | if (((_aidl_ret_status) != (::android::OK))) { |
| 631 | goto _aidl_error; |
| 632 | } |
| 633 | if (!_aidl_status.isOk()) { |
| 634 | return _aidl_status; |
| 635 | } |
| 636 | _aidl_ret_status = _aidl_reply.readStrongBinderVector(_aidl_return); |
| 637 | if (((_aidl_ret_status) != (::android::OK))) { |
| 638 | goto _aidl_error; |
| 639 | } |
| 640 | _aidl_ret_status = _aidl_reply.readStrongBinderVector(output); |
| 641 | if (((_aidl_ret_status) != (::android::OK))) { |
| 642 | goto _aidl_error; |
| 643 | } |
| 644 | _aidl_error: |
| 645 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 646 | return _aidl_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 647 | } |
| 648 | |
Jiyong Park | 4f3e8c0 | 2019-11-22 14:28:47 +0900 | [diff] [blame] | 649 | ::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptor(::android::base::unique_fd f, ::android::base::unique_fd* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 650 | ::android::Parcel _aidl_data; |
| 651 | ::android::Parcel _aidl_reply; |
| 652 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 653 | ::android::binder::Status _aidl_status; |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 654 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::TakesAFileDescriptor::cppClient"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 655 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 656 | if (((_aidl_ret_status) != (::android::OK))) { |
| 657 | goto _aidl_error; |
| 658 | } |
| 659 | _aidl_ret_status = _aidl_data.writeUniqueFileDescriptor(f); |
| 660 | if (((_aidl_ret_status) != (::android::OK))) { |
| 661 | goto _aidl_error; |
| 662 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 663 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptor, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 664 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
Jiyong Park | 4f3e8c0 | 2019-11-22 14:28:47 +0900 | [diff] [blame] | 665 | return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptor(std::move(f), _aidl_return); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 666 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 667 | if (((_aidl_ret_status) != (::android::OK))) { |
| 668 | goto _aidl_error; |
| 669 | } |
| 670 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 671 | if (((_aidl_ret_status) != (::android::OK))) { |
| 672 | goto _aidl_error; |
| 673 | } |
| 674 | if (!_aidl_status.isOk()) { |
| 675 | return _aidl_status; |
| 676 | } |
| 677 | _aidl_ret_status = _aidl_reply.readUniqueFileDescriptor(_aidl_return); |
| 678 | if (((_aidl_ret_status) != (::android::OK))) { |
| 679 | goto _aidl_error; |
| 680 | } |
| 681 | _aidl_error: |
| 682 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 683 | return _aidl_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | ::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 687 | ::android::Parcel _aidl_data; |
| 688 | ::android::Parcel _aidl_reply; |
| 689 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 690 | ::android::binder::Status _aidl_status; |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 691 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::TakesAFileDescriptorArray::cppClient"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 692 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 693 | if (((_aidl_ret_status) != (::android::OK))) { |
| 694 | goto _aidl_error; |
| 695 | } |
| 696 | _aidl_ret_status = _aidl_data.writeUniqueFileDescriptorVector(f); |
| 697 | if (((_aidl_ret_status) != (::android::OK))) { |
| 698 | goto _aidl_error; |
| 699 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 700 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptorArray, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 701 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 702 | return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptorArray(f, _aidl_return); |
| 703 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 704 | if (((_aidl_ret_status) != (::android::OK))) { |
| 705 | goto _aidl_error; |
| 706 | } |
| 707 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 708 | if (((_aidl_ret_status) != (::android::OK))) { |
| 709 | goto _aidl_error; |
| 710 | } |
| 711 | if (!_aidl_status.isOk()) { |
| 712 | return _aidl_status; |
| 713 | } |
| 714 | _aidl_ret_status = _aidl_reply.readUniqueFileDescriptorVector(_aidl_return); |
| 715 | if (((_aidl_ret_status) != (::android::OK))) { |
| 716 | goto _aidl_error; |
| 717 | } |
| 718 | _aidl_error: |
| 719 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 720 | return _aidl_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 721 | } |
| 722 | |
| 723 | } // namespace os |
| 724 | |
| 725 | } // namespace android |
| 726 | )"; |
| 727 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 728 | const char kExpectedComplexTypeServerHeaderOutput[] = |
Devin Moore | 7aaa9cb | 2020-08-13 14:53:01 -0700 | [diff] [blame] | 729 | R"(#pragma once |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 730 | |
| 731 | #include <binder/IInterface.h> |
| 732 | #include <android/os/IComplexTypeInterface.h> |
| 733 | |
| 734 | namespace android { |
| 735 | |
| 736 | namespace os { |
| 737 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 738 | class BnComplexTypeInterface : public ::android::BnInterface<IComplexTypeInterface> { |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 739 | public: |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 740 | static constexpr uint32_t TRANSACTION_Send = ::android::IBinder::FIRST_CALL_TRANSACTION + 0; |
| 741 | static constexpr uint32_t TRANSACTION_Piff = ::android::IBinder::FIRST_CALL_TRANSACTION + 1; |
| 742 | static constexpr uint32_t TRANSACTION_TakesABinder = ::android::IBinder::FIRST_CALL_TRANSACTION + 2; |
| 743 | static constexpr uint32_t TRANSACTION_NullableBinder = ::android::IBinder::FIRST_CALL_TRANSACTION + 3; |
| 744 | static constexpr uint32_t TRANSACTION_StringListMethod = ::android::IBinder::FIRST_CALL_TRANSACTION + 4; |
| 745 | static constexpr uint32_t TRANSACTION_BinderListMethod = ::android::IBinder::FIRST_CALL_TRANSACTION + 5; |
| 746 | static constexpr uint32_t TRANSACTION_TakesAFileDescriptor = ::android::IBinder::FIRST_CALL_TRANSACTION + 6; |
| 747 | static constexpr uint32_t TRANSACTION_TakesAFileDescriptorArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 7; |
Steven Moreland | 800508d | 2019-07-30 10:45:31 -0700 | [diff] [blame] | 748 | explicit BnComplexTypeInterface(); |
Jiyong Park | 8533bd0 | 2018-10-29 21:31:18 +0900 | [diff] [blame] | 749 | ::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 750 | }; // class BnComplexTypeInterface |
| 751 | |
| 752 | } // namespace os |
| 753 | |
| 754 | } // namespace android |
Christopher Wiley | 11a9d79 | 2016-02-24 17:20:33 -0800 | [diff] [blame] | 755 | )"; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 756 | |
| 757 | const char kExpectedComplexTypeServerSourceOutput[] = |
Jeongik Cha | b5d962f | 2018-11-17 09:12:28 +0900 | [diff] [blame] | 758 | R"(#include <android/os/BnComplexTypeInterface.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 759 | #include <binder/Parcel.h> |
Steven Moreland | a57d0a6 | 2019-07-30 09:41:14 -0700 | [diff] [blame] | 760 | #include <binder/Stability.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 761 | |
| 762 | namespace android { |
| 763 | |
| 764 | namespace os { |
| 765 | |
Steven Moreland | 800508d | 2019-07-30 10:45:31 -0700 | [diff] [blame] | 766 | BnComplexTypeInterface::BnComplexTypeInterface() |
| 767 | { |
Steven Moreland | a57d0a6 | 2019-07-30 09:41:14 -0700 | [diff] [blame] | 768 | ::android::internal::Stability::markCompilationUnit(this); |
Steven Moreland | 800508d | 2019-07-30 10:45:31 -0700 | [diff] [blame] | 769 | } |
| 770 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 771 | ::android::status_t BnComplexTypeInterface::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 772 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 773 | switch (_aidl_code) { |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 774 | case BnComplexTypeInterface::TRANSACTION_Send: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 775 | { |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 776 | ::std::optional<::std::vector<int32_t>> in_goes_in; |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 777 | ::std::vector<double> in_goes_in_and_out; |
| 778 | ::std::vector<bool> out_goes_out; |
| 779 | ::std::vector<int32_t> _aidl_return; |
| 780 | if (!(_aidl_data.checkInterface(this))) { |
| 781 | _aidl_ret_status = ::android::BAD_TYPE; |
| 782 | break; |
| 783 | } |
| 784 | _aidl_ret_status = _aidl_data.readInt32Vector(&in_goes_in); |
| 785 | if (((_aidl_ret_status) != (::android::OK))) { |
| 786 | break; |
| 787 | } |
| 788 | _aidl_ret_status = _aidl_data.readDoubleVector(&in_goes_in_and_out); |
| 789 | if (((_aidl_ret_status) != (::android::OK))) { |
| 790 | break; |
| 791 | } |
| 792 | _aidl_ret_status = _aidl_data.resizeOutVector(&out_goes_out); |
| 793 | if (((_aidl_ret_status) != (::android::OK))) { |
| 794 | break; |
| 795 | } |
| 796 | ::android::binder::Status _aidl_status(Send(in_goes_in, &in_goes_in_and_out, &out_goes_out, &_aidl_return)); |
| 797 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 798 | if (((_aidl_ret_status) != (::android::OK))) { |
| 799 | break; |
| 800 | } |
| 801 | if (!_aidl_status.isOk()) { |
| 802 | break; |
| 803 | } |
| 804 | _aidl_ret_status = _aidl_reply->writeInt32Vector(_aidl_return); |
| 805 | if (((_aidl_ret_status) != (::android::OK))) { |
| 806 | break; |
| 807 | } |
| 808 | _aidl_ret_status = _aidl_reply->writeDoubleVector(in_goes_in_and_out); |
| 809 | if (((_aidl_ret_status) != (::android::OK))) { |
| 810 | break; |
| 811 | } |
| 812 | _aidl_ret_status = _aidl_reply->writeBoolVector(out_goes_out); |
| 813 | if (((_aidl_ret_status) != (::android::OK))) { |
| 814 | break; |
| 815 | } |
| 816 | } |
| 817 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 818 | case BnComplexTypeInterface::TRANSACTION_Piff: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 819 | { |
| 820 | int32_t in_times; |
| 821 | if (!(_aidl_data.checkInterface(this))) { |
| 822 | _aidl_ret_status = ::android::BAD_TYPE; |
| 823 | break; |
| 824 | } |
| 825 | _aidl_ret_status = _aidl_data.readInt32(&in_times); |
| 826 | if (((_aidl_ret_status) != (::android::OK))) { |
| 827 | break; |
| 828 | } |
| 829 | ::android::binder::Status _aidl_status(Piff(in_times)); |
| 830 | } |
| 831 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 832 | case BnComplexTypeInterface::TRANSACTION_TakesABinder: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 833 | { |
| 834 | ::android::sp<::foo::IFooType> in_f; |
| 835 | ::android::sp<::foo::IFooType> _aidl_return; |
| 836 | if (!(_aidl_data.checkInterface(this))) { |
| 837 | _aidl_ret_status = ::android::BAD_TYPE; |
| 838 | break; |
| 839 | } |
| 840 | _aidl_ret_status = _aidl_data.readStrongBinder(&in_f); |
| 841 | if (((_aidl_ret_status) != (::android::OK))) { |
| 842 | break; |
| 843 | } |
| 844 | ::android::binder::Status _aidl_status(TakesABinder(in_f, &_aidl_return)); |
| 845 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 846 | if (((_aidl_ret_status) != (::android::OK))) { |
| 847 | break; |
| 848 | } |
| 849 | if (!_aidl_status.isOk()) { |
| 850 | break; |
| 851 | } |
| 852 | _aidl_ret_status = _aidl_reply->writeStrongBinder(::foo::IFooType::asBinder(_aidl_return)); |
| 853 | if (((_aidl_ret_status) != (::android::OK))) { |
| 854 | break; |
| 855 | } |
| 856 | } |
| 857 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 858 | case BnComplexTypeInterface::TRANSACTION_NullableBinder: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 859 | { |
| 860 | ::android::sp<::foo::IFooType> _aidl_return; |
| 861 | if (!(_aidl_data.checkInterface(this))) { |
| 862 | _aidl_ret_status = ::android::BAD_TYPE; |
| 863 | break; |
| 864 | } |
| 865 | ::android::binder::Status _aidl_status(NullableBinder(&_aidl_return)); |
| 866 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 867 | if (((_aidl_ret_status) != (::android::OK))) { |
| 868 | break; |
| 869 | } |
| 870 | if (!_aidl_status.isOk()) { |
| 871 | break; |
| 872 | } |
| 873 | _aidl_ret_status = _aidl_reply->writeStrongBinder(::foo::IFooType::asBinder(_aidl_return)); |
| 874 | if (((_aidl_ret_status) != (::android::OK))) { |
| 875 | break; |
| 876 | } |
| 877 | } |
| 878 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 879 | case BnComplexTypeInterface::TRANSACTION_StringListMethod: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 880 | { |
| 881 | ::std::vector<::android::String16> in_input; |
| 882 | ::std::vector<::android::String16> out_output; |
| 883 | ::std::vector<::android::String16> _aidl_return; |
| 884 | if (!(_aidl_data.checkInterface(this))) { |
| 885 | _aidl_ret_status = ::android::BAD_TYPE; |
| 886 | break; |
| 887 | } |
| 888 | _aidl_ret_status = _aidl_data.readString16Vector(&in_input); |
| 889 | if (((_aidl_ret_status) != (::android::OK))) { |
| 890 | break; |
| 891 | } |
| 892 | ::android::binder::Status _aidl_status(StringListMethod(in_input, &out_output, &_aidl_return)); |
| 893 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 894 | if (((_aidl_ret_status) != (::android::OK))) { |
| 895 | break; |
| 896 | } |
| 897 | if (!_aidl_status.isOk()) { |
| 898 | break; |
| 899 | } |
| 900 | _aidl_ret_status = _aidl_reply->writeString16Vector(_aidl_return); |
| 901 | if (((_aidl_ret_status) != (::android::OK))) { |
| 902 | break; |
| 903 | } |
| 904 | _aidl_ret_status = _aidl_reply->writeString16Vector(out_output); |
| 905 | if (((_aidl_ret_status) != (::android::OK))) { |
| 906 | break; |
| 907 | } |
| 908 | } |
| 909 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 910 | case BnComplexTypeInterface::TRANSACTION_BinderListMethod: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 911 | { |
| 912 | ::std::vector<::android::sp<::android::IBinder>> in_input; |
| 913 | ::std::vector<::android::sp<::android::IBinder>> out_output; |
| 914 | ::std::vector<::android::sp<::android::IBinder>> _aidl_return; |
| 915 | if (!(_aidl_data.checkInterface(this))) { |
| 916 | _aidl_ret_status = ::android::BAD_TYPE; |
| 917 | break; |
| 918 | } |
| 919 | _aidl_ret_status = _aidl_data.readStrongBinderVector(&in_input); |
| 920 | if (((_aidl_ret_status) != (::android::OK))) { |
| 921 | break; |
| 922 | } |
| 923 | ::android::binder::Status _aidl_status(BinderListMethod(in_input, &out_output, &_aidl_return)); |
| 924 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 925 | if (((_aidl_ret_status) != (::android::OK))) { |
| 926 | break; |
| 927 | } |
| 928 | if (!_aidl_status.isOk()) { |
| 929 | break; |
| 930 | } |
| 931 | _aidl_ret_status = _aidl_reply->writeStrongBinderVector(_aidl_return); |
| 932 | if (((_aidl_ret_status) != (::android::OK))) { |
| 933 | break; |
| 934 | } |
| 935 | _aidl_ret_status = _aidl_reply->writeStrongBinderVector(out_output); |
| 936 | if (((_aidl_ret_status) != (::android::OK))) { |
| 937 | break; |
| 938 | } |
| 939 | } |
| 940 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 941 | case BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptor: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 942 | { |
| 943 | ::android::base::unique_fd in_f; |
| 944 | ::android::base::unique_fd _aidl_return; |
| 945 | if (!(_aidl_data.checkInterface(this))) { |
| 946 | _aidl_ret_status = ::android::BAD_TYPE; |
| 947 | break; |
| 948 | } |
| 949 | _aidl_ret_status = _aidl_data.readUniqueFileDescriptor(&in_f); |
| 950 | if (((_aidl_ret_status) != (::android::OK))) { |
| 951 | break; |
| 952 | } |
Jiyong Park | 4f3e8c0 | 2019-11-22 14:28:47 +0900 | [diff] [blame] | 953 | ::android::binder::Status _aidl_status(TakesAFileDescriptor(std::move(in_f), &_aidl_return)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 954 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 955 | if (((_aidl_ret_status) != (::android::OK))) { |
| 956 | break; |
| 957 | } |
| 958 | if (!_aidl_status.isOk()) { |
| 959 | break; |
| 960 | } |
| 961 | _aidl_ret_status = _aidl_reply->writeUniqueFileDescriptor(_aidl_return); |
| 962 | if (((_aidl_ret_status) != (::android::OK))) { |
| 963 | break; |
| 964 | } |
| 965 | } |
| 966 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 967 | case BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptorArray: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 968 | { |
| 969 | ::std::vector<::android::base::unique_fd> in_f; |
| 970 | ::std::vector<::android::base::unique_fd> _aidl_return; |
| 971 | if (!(_aidl_data.checkInterface(this))) { |
| 972 | _aidl_ret_status = ::android::BAD_TYPE; |
| 973 | break; |
| 974 | } |
| 975 | _aidl_ret_status = _aidl_data.readUniqueFileDescriptorVector(&in_f); |
| 976 | if (((_aidl_ret_status) != (::android::OK))) { |
| 977 | break; |
| 978 | } |
| 979 | ::android::binder::Status _aidl_status(TakesAFileDescriptorArray(in_f, &_aidl_return)); |
| 980 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 981 | if (((_aidl_ret_status) != (::android::OK))) { |
| 982 | break; |
| 983 | } |
| 984 | if (!_aidl_status.isOk()) { |
| 985 | break; |
| 986 | } |
| 987 | _aidl_ret_status = _aidl_reply->writeUniqueFileDescriptorVector(_aidl_return); |
| 988 | if (((_aidl_ret_status) != (::android::OK))) { |
| 989 | break; |
| 990 | } |
| 991 | } |
| 992 | break; |
| 993 | default: |
| 994 | { |
| 995 | _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags); |
| 996 | } |
| 997 | break; |
| 998 | } |
| 999 | if (_aidl_ret_status == ::android::UNEXPECTED_NULL) { |
| 1000 | _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply); |
| 1001 | } |
| 1002 | return _aidl_ret_status; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1003 | } |
| 1004 | |
| 1005 | } // namespace os |
| 1006 | |
| 1007 | } // namespace android |
| 1008 | )"; |
| 1009 | |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 1010 | const char kExpectedComplexTypeServerWithTraceSourceOutput[] = |
Jeongik Cha | b5d962f | 2018-11-17 09:12:28 +0900 | [diff] [blame] | 1011 | R"(#include <android/os/BnComplexTypeInterface.h> |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 1012 | #include <binder/Parcel.h> |
Steven Moreland | a57d0a6 | 2019-07-30 09:41:14 -0700 | [diff] [blame] | 1013 | #include <binder/Stability.h> |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 1014 | |
| 1015 | namespace android { |
| 1016 | |
| 1017 | namespace os { |
| 1018 | |
Steven Moreland | 800508d | 2019-07-30 10:45:31 -0700 | [diff] [blame] | 1019 | BnComplexTypeInterface::BnComplexTypeInterface() |
| 1020 | { |
Steven Moreland | a57d0a6 | 2019-07-30 09:41:14 -0700 | [diff] [blame] | 1021 | ::android::internal::Stability::markCompilationUnit(this); |
Steven Moreland | 800508d | 2019-07-30 10:45:31 -0700 | [diff] [blame] | 1022 | } |
| 1023 | |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 1024 | ::android::status_t BnComplexTypeInterface::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1025 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 1026 | switch (_aidl_code) { |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 1027 | case BnComplexTypeInterface::TRANSACTION_Send: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1028 | { |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 1029 | ::std::optional<::std::vector<int32_t>> in_goes_in; |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1030 | ::std::vector<double> in_goes_in_and_out; |
| 1031 | ::std::vector<bool> out_goes_out; |
| 1032 | ::std::vector<int32_t> _aidl_return; |
| 1033 | if (!(_aidl_data.checkInterface(this))) { |
| 1034 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1035 | break; |
| 1036 | } |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 1037 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::Send::cppServer"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1038 | _aidl_ret_status = _aidl_data.readInt32Vector(&in_goes_in); |
| 1039 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1040 | break; |
| 1041 | } |
| 1042 | _aidl_ret_status = _aidl_data.readDoubleVector(&in_goes_in_and_out); |
| 1043 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1044 | break; |
| 1045 | } |
| 1046 | _aidl_ret_status = _aidl_data.resizeOutVector(&out_goes_out); |
| 1047 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1048 | break; |
| 1049 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1050 | ::android::binder::Status _aidl_status(Send(in_goes_in, &in_goes_in_and_out, &out_goes_out, &_aidl_return)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1051 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1052 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1053 | break; |
| 1054 | } |
| 1055 | if (!_aidl_status.isOk()) { |
| 1056 | break; |
| 1057 | } |
| 1058 | _aidl_ret_status = _aidl_reply->writeInt32Vector(_aidl_return); |
| 1059 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1060 | break; |
| 1061 | } |
| 1062 | _aidl_ret_status = _aidl_reply->writeDoubleVector(in_goes_in_and_out); |
| 1063 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1064 | break; |
| 1065 | } |
| 1066 | _aidl_ret_status = _aidl_reply->writeBoolVector(out_goes_out); |
| 1067 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1068 | break; |
| 1069 | } |
| 1070 | } |
| 1071 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 1072 | case BnComplexTypeInterface::TRANSACTION_Piff: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1073 | { |
| 1074 | int32_t in_times; |
| 1075 | if (!(_aidl_data.checkInterface(this))) { |
| 1076 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1077 | break; |
| 1078 | } |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 1079 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::Piff::cppServer"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1080 | _aidl_ret_status = _aidl_data.readInt32(&in_times); |
| 1081 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1082 | break; |
| 1083 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1084 | ::android::binder::Status _aidl_status(Piff(in_times)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1085 | } |
| 1086 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 1087 | case BnComplexTypeInterface::TRANSACTION_TakesABinder: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1088 | { |
| 1089 | ::android::sp<::foo::IFooType> in_f; |
| 1090 | ::android::sp<::foo::IFooType> _aidl_return; |
| 1091 | if (!(_aidl_data.checkInterface(this))) { |
| 1092 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1093 | break; |
| 1094 | } |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 1095 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::TakesABinder::cppServer"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1096 | _aidl_ret_status = _aidl_data.readStrongBinder(&in_f); |
| 1097 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1098 | break; |
| 1099 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1100 | ::android::binder::Status _aidl_status(TakesABinder(in_f, &_aidl_return)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1101 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1102 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1103 | break; |
| 1104 | } |
| 1105 | if (!_aidl_status.isOk()) { |
| 1106 | break; |
| 1107 | } |
| 1108 | _aidl_ret_status = _aidl_reply->writeStrongBinder(::foo::IFooType::asBinder(_aidl_return)); |
| 1109 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1110 | break; |
| 1111 | } |
| 1112 | } |
| 1113 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 1114 | case BnComplexTypeInterface::TRANSACTION_NullableBinder: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1115 | { |
| 1116 | ::android::sp<::foo::IFooType> _aidl_return; |
| 1117 | if (!(_aidl_data.checkInterface(this))) { |
| 1118 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1119 | break; |
| 1120 | } |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 1121 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::NullableBinder::cppServer"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1122 | ::android::binder::Status _aidl_status(NullableBinder(&_aidl_return)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1123 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1124 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1125 | break; |
| 1126 | } |
| 1127 | if (!_aidl_status.isOk()) { |
| 1128 | break; |
| 1129 | } |
| 1130 | _aidl_ret_status = _aidl_reply->writeStrongBinder(::foo::IFooType::asBinder(_aidl_return)); |
| 1131 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1132 | break; |
| 1133 | } |
| 1134 | } |
| 1135 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 1136 | case BnComplexTypeInterface::TRANSACTION_StringListMethod: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1137 | { |
| 1138 | ::std::vector<::android::String16> in_input; |
| 1139 | ::std::vector<::android::String16> out_output; |
| 1140 | ::std::vector<::android::String16> _aidl_return; |
| 1141 | if (!(_aidl_data.checkInterface(this))) { |
| 1142 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1143 | break; |
| 1144 | } |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 1145 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::StringListMethod::cppServer"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1146 | _aidl_ret_status = _aidl_data.readString16Vector(&in_input); |
| 1147 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1148 | break; |
| 1149 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1150 | ::android::binder::Status _aidl_status(StringListMethod(in_input, &out_output, &_aidl_return)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1151 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1152 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1153 | break; |
| 1154 | } |
| 1155 | if (!_aidl_status.isOk()) { |
| 1156 | break; |
| 1157 | } |
| 1158 | _aidl_ret_status = _aidl_reply->writeString16Vector(_aidl_return); |
| 1159 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1160 | break; |
| 1161 | } |
| 1162 | _aidl_ret_status = _aidl_reply->writeString16Vector(out_output); |
| 1163 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1164 | break; |
| 1165 | } |
| 1166 | } |
| 1167 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 1168 | case BnComplexTypeInterface::TRANSACTION_BinderListMethod: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1169 | { |
| 1170 | ::std::vector<::android::sp<::android::IBinder>> in_input; |
| 1171 | ::std::vector<::android::sp<::android::IBinder>> out_output; |
| 1172 | ::std::vector<::android::sp<::android::IBinder>> _aidl_return; |
| 1173 | if (!(_aidl_data.checkInterface(this))) { |
| 1174 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1175 | break; |
| 1176 | } |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 1177 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::BinderListMethod::cppServer"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1178 | _aidl_ret_status = _aidl_data.readStrongBinderVector(&in_input); |
| 1179 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1180 | break; |
| 1181 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1182 | ::android::binder::Status _aidl_status(BinderListMethod(in_input, &out_output, &_aidl_return)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1183 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1184 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1185 | break; |
| 1186 | } |
| 1187 | if (!_aidl_status.isOk()) { |
| 1188 | break; |
| 1189 | } |
| 1190 | _aidl_ret_status = _aidl_reply->writeStrongBinderVector(_aidl_return); |
| 1191 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1192 | break; |
| 1193 | } |
| 1194 | _aidl_ret_status = _aidl_reply->writeStrongBinderVector(out_output); |
| 1195 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1196 | break; |
| 1197 | } |
| 1198 | } |
| 1199 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 1200 | case BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptor: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1201 | { |
| 1202 | ::android::base::unique_fd in_f; |
| 1203 | ::android::base::unique_fd _aidl_return; |
| 1204 | if (!(_aidl_data.checkInterface(this))) { |
| 1205 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1206 | break; |
| 1207 | } |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 1208 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::TakesAFileDescriptor::cppServer"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1209 | _aidl_ret_status = _aidl_data.readUniqueFileDescriptor(&in_f); |
| 1210 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1211 | break; |
| 1212 | } |
Jiyong Park | 4f3e8c0 | 2019-11-22 14:28:47 +0900 | [diff] [blame] | 1213 | ::android::binder::Status _aidl_status(TakesAFileDescriptor(std::move(in_f), &_aidl_return)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1214 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1215 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1216 | break; |
| 1217 | } |
| 1218 | if (!_aidl_status.isOk()) { |
| 1219 | break; |
| 1220 | } |
| 1221 | _aidl_ret_status = _aidl_reply->writeUniqueFileDescriptor(_aidl_return); |
| 1222 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1223 | break; |
| 1224 | } |
| 1225 | } |
| 1226 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 1227 | case BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptorArray: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1228 | { |
| 1229 | ::std::vector<::android::base::unique_fd> in_f; |
| 1230 | ::std::vector<::android::base::unique_fd> _aidl_return; |
| 1231 | if (!(_aidl_data.checkInterface(this))) { |
| 1232 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1233 | break; |
| 1234 | } |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 1235 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::TakesAFileDescriptorArray::cppServer"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1236 | _aidl_ret_status = _aidl_data.readUniqueFileDescriptorVector(&in_f); |
| 1237 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1238 | break; |
| 1239 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1240 | ::android::binder::Status _aidl_status(TakesAFileDescriptorArray(in_f, &_aidl_return)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1241 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1242 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1243 | break; |
| 1244 | } |
| 1245 | if (!_aidl_status.isOk()) { |
| 1246 | break; |
| 1247 | } |
| 1248 | _aidl_ret_status = _aidl_reply->writeUniqueFileDescriptorVector(_aidl_return); |
| 1249 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1250 | break; |
| 1251 | } |
| 1252 | } |
| 1253 | break; |
| 1254 | default: |
| 1255 | { |
| 1256 | _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags); |
| 1257 | } |
| 1258 | break; |
| 1259 | } |
| 1260 | if (_aidl_ret_status == ::android::UNEXPECTED_NULL) { |
| 1261 | _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply); |
| 1262 | } |
| 1263 | return _aidl_ret_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 1264 | } |
| 1265 | |
| 1266 | } // namespace os |
| 1267 | |
| 1268 | } // namespace android |
| 1269 | )"; |
| 1270 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1271 | const char kExpectedComplexTypeInterfaceHeaderOutput[] = |
Devin Moore | 7aaa9cb | 2020-08-13 14:53:01 -0700 | [diff] [blame] | 1272 | R"(#pragma once |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1273 | |
Christopher Wiley | 7cb9c25 | 2016-04-11 11:07:33 -0700 | [diff] [blame] | 1274 | #include <android-base/unique_fd.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1275 | #include <binder/IBinder.h> |
| 1276 | #include <binder/IInterface.h> |
Christopher Wiley | 433c8bb | 2015-11-12 14:20:46 -0800 | [diff] [blame] | 1277 | #include <binder/Status.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1278 | #include <cstdint> |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1279 | #include <foo/IFooType.h> |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 1280 | #include <optional> |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 1281 | #include <utils/String16.h> |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1282 | #include <utils/StrongPointer.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1283 | #include <vector> |
| 1284 | |
| 1285 | namespace android { |
| 1286 | |
| 1287 | namespace os { |
| 1288 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 1289 | class IComplexTypeInterface : public ::android::IInterface { |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1290 | public: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1291 | DECLARE_META_INTERFACE(ComplexTypeInterface) |
| 1292 | enum : int32_t { |
| 1293 | MY_CONSTANT = 3, |
| 1294 | }; |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 1295 | virtual ::android::binder::Status Send(const ::std::optional<::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; |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1296 | virtual ::android::binder::Status Piff(int32_t times) = 0; |
| 1297 | virtual ::android::binder::Status TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) = 0; |
| 1298 | virtual ::android::binder::Status NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) = 0; |
| 1299 | virtual ::android::binder::Status StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) = 0; |
| 1300 | 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; |
Jiyong Park | 4f3e8c0 | 2019-11-22 14:28:47 +0900 | [diff] [blame] | 1301 | virtual ::android::binder::Status TakesAFileDescriptor(::android::base::unique_fd f, ::android::base::unique_fd* _aidl_return) = 0; |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1302 | virtual ::android::binder::Status TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) = 0; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1303 | }; // class IComplexTypeInterface |
| 1304 | |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 1305 | class IComplexTypeInterfaceDefault : public IComplexTypeInterface { |
| 1306 | public: |
Jooyung Han | 7bee8e3 | 2020-01-30 17:25:21 +0900 | [diff] [blame] | 1307 | ::android::IBinder* onAsBinder() override { |
| 1308 | return nullptr; |
| 1309 | } |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 1310 | ::android::binder::Status Send(const ::std::optional<::std::vector<int32_t>>&, ::std::vector<double>*, ::std::vector<bool>*, ::std::vector<int32_t>*) override { |
Jooyung Han | 7bee8e3 | 2020-01-30 17:25:21 +0900 | [diff] [blame] | 1311 | return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); |
| 1312 | } |
| 1313 | ::android::binder::Status Piff(int32_t) override { |
| 1314 | return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); |
| 1315 | } |
Jooyung Han | 6991d92 | 2020-01-30 18:13:55 +0900 | [diff] [blame] | 1316 | ::android::binder::Status TakesABinder(const ::android::sp<::foo::IFooType>&, ::android::sp<::foo::IFooType>*) override { |
Jooyung Han | 7bee8e3 | 2020-01-30 17:25:21 +0900 | [diff] [blame] | 1317 | return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); |
| 1318 | } |
Jooyung Han | 6991d92 | 2020-01-30 18:13:55 +0900 | [diff] [blame] | 1319 | ::android::binder::Status NullableBinder(::android::sp<::foo::IFooType>*) override { |
Jooyung Han | 7bee8e3 | 2020-01-30 17:25:21 +0900 | [diff] [blame] | 1320 | return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); |
| 1321 | } |
Jooyung Han | 6991d92 | 2020-01-30 18:13:55 +0900 | [diff] [blame] | 1322 | ::android::binder::Status StringListMethod(const ::std::vector<::android::String16>&, ::std::vector<::android::String16>*, ::std::vector<::android::String16>*) override { |
Jooyung Han | 7bee8e3 | 2020-01-30 17:25:21 +0900 | [diff] [blame] | 1323 | return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); |
| 1324 | } |
Jooyung Han | 6991d92 | 2020-01-30 18:13:55 +0900 | [diff] [blame] | 1325 | ::android::binder::Status BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>&, ::std::vector<::android::sp<::android::IBinder>>*, ::std::vector<::android::sp<::android::IBinder>>*) override { |
Jooyung Han | 7bee8e3 | 2020-01-30 17:25:21 +0900 | [diff] [blame] | 1326 | return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); |
| 1327 | } |
Jooyung Han | 6991d92 | 2020-01-30 18:13:55 +0900 | [diff] [blame] | 1328 | ::android::binder::Status TakesAFileDescriptor(::android::base::unique_fd, ::android::base::unique_fd*) override { |
Jooyung Han | 7bee8e3 | 2020-01-30 17:25:21 +0900 | [diff] [blame] | 1329 | return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); |
| 1330 | } |
Jooyung Han | 6991d92 | 2020-01-30 18:13:55 +0900 | [diff] [blame] | 1331 | ::android::binder::Status TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>&, ::std::vector<::android::base::unique_fd>*) override { |
Jooyung Han | 7bee8e3 | 2020-01-30 17:25:21 +0900 | [diff] [blame] | 1332 | return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); |
| 1333 | } |
| 1334 | }; // class IComplexTypeInterfaceDefault |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 1335 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1336 | } // namespace os |
| 1337 | |
| 1338 | } // namespace android |
Christopher Wiley | 11a9d79 | 2016-02-24 17:20:33 -0800 | [diff] [blame] | 1339 | )"; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1340 | |
| 1341 | const char kExpectedComplexTypeInterfaceSourceOutput[] = |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 1342 | R"(#include <android/os/IComplexTypeInterface.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1343 | #include <android/os/BpComplexTypeInterface.h> |
| 1344 | |
| 1345 | namespace android { |
| 1346 | |
| 1347 | namespace os { |
| 1348 | |
Ivan Lozano | b3f4d62 | 2019-11-25 09:30:02 -0800 | [diff] [blame] | 1349 | DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(ComplexTypeInterface, "android.os.IComplexTypeInterface") |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1350 | |
| 1351 | } // namespace os |
| 1352 | |
| 1353 | } // namespace android |
| 1354 | )"; |
| 1355 | |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1356 | const string kEnumAIDL = R"(package android.os; |
| 1357 | enum TestEnum { |
Daniel Norman | b28684e | 2019-10-17 15:31:39 -0700 | [diff] [blame] | 1358 | ZERO, |
| 1359 | ONE, |
| 1360 | THREE = 3, |
Daniel Norman | f0ca44f | 2019-10-25 09:59:44 -0700 | [diff] [blame] | 1361 | FOUR = 3 + 1, |
Daniel Norman | b28684e | 2019-10-17 15:31:39 -0700 | [diff] [blame] | 1362 | FIVE, |
Daniel Norman | f0ca44f | 2019-10-25 09:59:44 -0700 | [diff] [blame] | 1363 | SIX, |
| 1364 | SEVEN, |
| 1365 | EIGHT = 16 / 2, |
| 1366 | NINE, |
| 1367 | TEN, |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1368 | })"; |
| 1369 | |
| 1370 | const char kExpectedEnumHeaderOutput[] = |
Devin Moore | 7aaa9cb | 2020-08-13 14:53:01 -0700 | [diff] [blame] | 1371 | R"(#pragma once |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1372 | |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1373 | #include <array> |
| 1374 | #include <binder/Enums.h> |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1375 | #include <cstdint> |
Daniel Norman | 0c1bd36 | 2019-11-12 23:05:31 -0800 | [diff] [blame] | 1376 | #include <string> |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1377 | |
| 1378 | namespace android { |
| 1379 | |
| 1380 | namespace os { |
| 1381 | |
| 1382 | enum class TestEnum : int8_t { |
Daniel Norman | b28684e | 2019-10-17 15:31:39 -0700 | [diff] [blame] | 1383 | ZERO = 0, |
| 1384 | ONE = 1, |
| 1385 | THREE = 3, |
| 1386 | FOUR = 4, |
| 1387 | FIVE = 5, |
Daniel Norman | f0ca44f | 2019-10-25 09:59:44 -0700 | [diff] [blame] | 1388 | SIX = 6, |
| 1389 | SEVEN = 7, |
| 1390 | EIGHT = 8, |
| 1391 | NINE = 9, |
| 1392 | TEN = 10, |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1393 | }; |
| 1394 | |
Daniel Norman | 0c1bd36 | 2019-11-12 23:05:31 -0800 | [diff] [blame] | 1395 | static inline std::string toString(TestEnum val) { |
| 1396 | switch(val) { |
| 1397 | case TestEnum::ZERO: |
| 1398 | return "ZERO"; |
| 1399 | case TestEnum::ONE: |
| 1400 | return "ONE"; |
| 1401 | case TestEnum::THREE: |
| 1402 | return "THREE"; |
| 1403 | case TestEnum::FOUR: |
| 1404 | return "FOUR"; |
| 1405 | case TestEnum::FIVE: |
| 1406 | return "FIVE"; |
| 1407 | case TestEnum::SIX: |
| 1408 | return "SIX"; |
| 1409 | case TestEnum::SEVEN: |
| 1410 | return "SEVEN"; |
| 1411 | case TestEnum::EIGHT: |
| 1412 | return "EIGHT"; |
| 1413 | case TestEnum::NINE: |
| 1414 | return "NINE"; |
| 1415 | case TestEnum::TEN: |
| 1416 | return "TEN"; |
| 1417 | default: |
| 1418 | return std::to_string(static_cast<int8_t>(val)); |
| 1419 | } |
| 1420 | } |
| 1421 | |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1422 | } // namespace os |
| 1423 | |
| 1424 | } // namespace android |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1425 | namespace android { |
| 1426 | |
| 1427 | namespace internal { |
| 1428 | |
Jooyung Han | 0e2a03c | 2019-12-17 23:25:39 +0900 | [diff] [blame] | 1429 | #pragma clang diagnostic push |
| 1430 | #pragma clang diagnostic ignored "-Wc++17-extensions" |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1431 | template <> |
| 1432 | constexpr inline std::array<::android::os::TestEnum, 10> enum_values<::android::os::TestEnum> = { |
| 1433 | ::android::os::TestEnum::ZERO, |
| 1434 | ::android::os::TestEnum::ONE, |
| 1435 | ::android::os::TestEnum::THREE, |
| 1436 | ::android::os::TestEnum::FOUR, |
| 1437 | ::android::os::TestEnum::FIVE, |
| 1438 | ::android::os::TestEnum::SIX, |
| 1439 | ::android::os::TestEnum::SEVEN, |
| 1440 | ::android::os::TestEnum::EIGHT, |
| 1441 | ::android::os::TestEnum::NINE, |
| 1442 | ::android::os::TestEnum::TEN, |
| 1443 | }; |
Jooyung Han | 0e2a03c | 2019-12-17 23:25:39 +0900 | [diff] [blame] | 1444 | #pragma clang diagnostic pop |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1445 | |
| 1446 | } // namespace internal |
| 1447 | |
| 1448 | } // namespace android |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1449 | )"; |
| 1450 | |
| 1451 | const string kEnumWithBackingTypeAIDL = R"(package android.os; |
| 1452 | @Backing(type="long") |
| 1453 | enum TestEnum { |
| 1454 | FOO = 1, |
| 1455 | BAR = 2, |
| 1456 | })"; |
| 1457 | |
| 1458 | const char kExpectedEnumWithBackingTypeHeaderOutput[] = |
Devin Moore | 7aaa9cb | 2020-08-13 14:53:01 -0700 | [diff] [blame] | 1459 | R"(#pragma once |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1460 | |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1461 | #include <array> |
| 1462 | #include <binder/Enums.h> |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1463 | #include <cstdint> |
Daniel Norman | 0c1bd36 | 2019-11-12 23:05:31 -0800 | [diff] [blame] | 1464 | #include <string> |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1465 | |
| 1466 | namespace android { |
| 1467 | |
| 1468 | namespace os { |
| 1469 | |
| 1470 | enum class TestEnum : int64_t { |
Daniel Norman | 716d311 | 2019-09-10 13:11:56 -0700 | [diff] [blame] | 1471 | FOO = 1L, |
| 1472 | BAR = 2L, |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1473 | }; |
| 1474 | |
Daniel Norman | 0c1bd36 | 2019-11-12 23:05:31 -0800 | [diff] [blame] | 1475 | static inline std::string toString(TestEnum val) { |
| 1476 | switch(val) { |
| 1477 | case TestEnum::FOO: |
| 1478 | return "FOO"; |
| 1479 | case TestEnum::BAR: |
| 1480 | return "BAR"; |
| 1481 | default: |
| 1482 | return std::to_string(static_cast<int64_t>(val)); |
| 1483 | } |
| 1484 | } |
| 1485 | |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1486 | } // namespace os |
| 1487 | |
| 1488 | } // namespace android |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1489 | namespace android { |
| 1490 | |
| 1491 | namespace internal { |
| 1492 | |
Jooyung Han | 0e2a03c | 2019-12-17 23:25:39 +0900 | [diff] [blame] | 1493 | #pragma clang diagnostic push |
| 1494 | #pragma clang diagnostic ignored "-Wc++17-extensions" |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1495 | template <> |
| 1496 | constexpr inline std::array<::android::os::TestEnum, 2> enum_values<::android::os::TestEnum> = { |
| 1497 | ::android::os::TestEnum::FOO, |
| 1498 | ::android::os::TestEnum::BAR, |
| 1499 | }; |
Jooyung Han | 0e2a03c | 2019-12-17 23:25:39 +0900 | [diff] [blame] | 1500 | #pragma clang diagnostic pop |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1501 | |
| 1502 | } // namespace internal |
| 1503 | |
| 1504 | } // namespace android |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1505 | )"; |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1506 | // clang-format on |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1507 | |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 1508 | } // namespace |
| 1509 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1510 | class ASTTest : public ::testing::Test { |
Christopher Wiley | 0c732db | 2015-09-29 14:36:44 -0700 | [diff] [blame] | 1511 | protected: |
Jiyong Park | 6f77e0c | 2018-07-28 16:55:44 +0900 | [diff] [blame] | 1512 | ASTTest(const string& cmdline, const string& file_contents) |
| 1513 | : options_(Options::From(cmdline)), file_contents_(file_contents) { |
Christopher Wiley | 5679952 | 2015-10-31 10:17:04 -0700 | [diff] [blame] | 1514 | } |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1515 | |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1516 | AidlInterface* ParseSingleInterface() { |
Jiyong Park | 6f77e0c | 2018-07-28 16:55:44 +0900 | [diff] [blame] | 1517 | io_delegate_.SetFileContents(options_.InputFiles().at(0), file_contents_); |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 1518 | |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1519 | vector<string> imported_files; |
Jiyong Park | 8c38053 | 2018-08-30 14:55:26 +0900 | [diff] [blame] | 1520 | ImportResolver import_resolver{io_delegate_, options_.InputFiles().at(0), {"."}, {}}; |
Jiyong Park | 6f77e0c | 2018-07-28 16:55:44 +0900 | [diff] [blame] | 1521 | AidlError err = ::android::aidl::internals::load_and_validate_aidl( |
Jiyong Park | 8e79b7f | 2020-07-20 20:52:38 +0900 | [diff] [blame] | 1522 | options_.InputFiles().front(), options_, io_delegate_, &typenames_, &imported_files); |
Christopher Wiley | 4a2884b | 2015-10-07 11:27:45 -0700 | [diff] [blame] | 1523 | |
Steven Moreland | 5557f1c | 2018-07-02 13:50:23 -0700 | [diff] [blame] | 1524 | if (err != AidlError::OK) { |
Casey Dahlin | 2cc9316 | 2015-10-02 16:14:17 -0700 | [diff] [blame] | 1525 | return nullptr; |
Steven Moreland | 5557f1c | 2018-07-02 13:50:23 -0700 | [diff] [blame] | 1526 | } |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 1527 | |
Jiyong Park | 8e79b7f | 2020-07-20 20:52:38 +0900 | [diff] [blame] | 1528 | const auto& defined_types = typenames_.MainDocument().DefinedTypes(); |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1529 | EXPECT_EQ(1ul, defined_types.size()); |
Jiyong Park | 8e79b7f | 2020-07-20 20:52:38 +0900 | [diff] [blame] | 1530 | EXPECT_NE(nullptr, defined_types.front().get()->AsInterface()); |
Steven Moreland | 5557f1c | 2018-07-02 13:50:23 -0700 | [diff] [blame] | 1531 | |
Jiyong Park | 8e79b7f | 2020-07-20 20:52:38 +0900 | [diff] [blame] | 1532 | return defined_types.front().get()->AsInterface(); |
Christopher Wiley | 90be4e3 | 2015-10-20 14:55:25 -0700 | [diff] [blame] | 1533 | } |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 1534 | |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1535 | AidlEnumDeclaration* ParseSingleEnumDeclaration() { |
| 1536 | io_delegate_.SetFileContents(options_.InputFiles().at(0), file_contents_); |
| 1537 | |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1538 | vector<string> imported_files; |
| 1539 | AidlError err = ::android::aidl::internals::load_and_validate_aidl( |
Jiyong Park | 8e79b7f | 2020-07-20 20:52:38 +0900 | [diff] [blame] | 1540 | options_.InputFiles().front(), options_, io_delegate_, &typenames_, &imported_files); |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1541 | |
| 1542 | if (err != AidlError::OK) { |
| 1543 | return nullptr; |
| 1544 | } |
| 1545 | |
Jiyong Park | 8e79b7f | 2020-07-20 20:52:38 +0900 | [diff] [blame] | 1546 | const auto& defined_types = typenames_.MainDocument().DefinedTypes(); |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1547 | EXPECT_EQ(1ul, defined_types.size()); |
Jiyong Park | 8e79b7f | 2020-07-20 20:52:38 +0900 | [diff] [blame] | 1548 | EXPECT_NE(nullptr, defined_types.front().get()->AsEnumDeclaration()); |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1549 | |
Jiyong Park | 8e79b7f | 2020-07-20 20:52:38 +0900 | [diff] [blame] | 1550 | return defined_types.front().get()->AsEnumDeclaration(); |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1551 | } |
| 1552 | |
Christopher Wiley | 0c732db | 2015-09-29 14:36:44 -0700 | [diff] [blame] | 1553 | void Compare(Document* doc, const char* expected) { |
| 1554 | string output; |
Jiyong Park | b78e15b | 2018-07-04 20:31:03 +0900 | [diff] [blame] | 1555 | doc->Write(CodeWriter::ForString(&output).get()); |
Christopher Wiley | 0c732db | 2015-09-29 14:36:44 -0700 | [diff] [blame] | 1556 | |
Casey Dahlin | 80ada3d | 2015-10-20 20:33:56 -0700 | [diff] [blame] | 1557 | if (expected == output) { |
| 1558 | return; // Success |
| 1559 | } |
| 1560 | |
| 1561 | test::PrintDiff(expected, output); |
| 1562 | FAIL() << "Document contents did not match expected contents"; |
Christopher Wiley | 0c732db | 2015-09-29 14:36:44 -0700 | [diff] [blame] | 1563 | } |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1564 | |
Jiyong Park | 6f77e0c | 2018-07-28 16:55:44 +0900 | [diff] [blame] | 1565 | const Options options_; |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1566 | const string file_contents_; |
| 1567 | FakeIoDelegate io_delegate_; |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1568 | AidlTypenames typenames_; |
Christopher Wiley | 0c732db | 2015-09-29 14:36:44 -0700 | [diff] [blame] | 1569 | }; |
| 1570 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1571 | class ComplexTypeInterfaceASTTest : public ASTTest { |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1572 | public: |
| 1573 | ComplexTypeInterfaceASTTest() |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 1574 | : ASTTest("aidl --lang=cpp -I . -o out android/os/IComplexTypeInterface.aidl", |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1575 | kComplexTypeInterfaceAIDL) { |
| 1576 | io_delegate_.SetFileContents("foo/IFooType.aidl", |
| 1577 | "package foo; interface IFooType {}"); |
| 1578 | } |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1579 | }; |
| 1580 | |
| 1581 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesClientHeader) { |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1582 | AidlInterface* interface = ParseSingleInterface(); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1583 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1584 | unique_ptr<Document> doc = internals::BuildClientHeader(typenames_, *interface, options_); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1585 | Compare(doc.get(), kExpectedComplexTypeClientHeaderOutput); |
| 1586 | } |
| 1587 | |
| 1588 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesClientSource) { |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1589 | AidlInterface* interface = ParseSingleInterface(); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1590 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1591 | unique_ptr<Document> doc = internals::BuildClientSource(typenames_, *interface, options_); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1592 | Compare(doc.get(), kExpectedComplexTypeClientSourceOutput); |
| 1593 | } |
| 1594 | |
| 1595 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesServerHeader) { |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1596 | AidlInterface* interface = ParseSingleInterface(); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1597 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1598 | unique_ptr<Document> doc = internals::BuildServerHeader(typenames_, *interface, options_); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1599 | Compare(doc.get(), kExpectedComplexTypeServerHeaderOutput); |
| 1600 | } |
| 1601 | |
| 1602 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesServerSource) { |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1603 | AidlInterface* interface = ParseSingleInterface(); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1604 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1605 | unique_ptr<Document> doc = internals::BuildServerSource(typenames_, *interface, options_); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1606 | Compare(doc.get(), kExpectedComplexTypeServerSourceOutput); |
| 1607 | } |
| 1608 | |
| 1609 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesInterfaceHeader) { |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1610 | AidlInterface* interface = ParseSingleInterface(); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1611 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1612 | unique_ptr<Document> doc = internals::BuildInterfaceHeader(typenames_, *interface, options_); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1613 | Compare(doc.get(), kExpectedComplexTypeInterfaceHeaderOutput); |
| 1614 | } |
| 1615 | |
| 1616 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesInterfaceSource) { |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1617 | AidlInterface* interface = ParseSingleInterface(); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1618 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1619 | unique_ptr<Document> doc = internals::BuildInterfaceSource(typenames_, *interface, options_); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1620 | Compare(doc.get(), kExpectedComplexTypeInterfaceSourceOutput); |
Christopher Wiley | 1dd458d | 2015-09-30 11:05:52 -0700 | [diff] [blame] | 1621 | } |
| 1622 | |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 1623 | class ComplexTypeInterfaceASTTestWithTrace : public ASTTest { |
| 1624 | public: |
| 1625 | ComplexTypeInterfaceASTTestWithTrace() |
| 1626 | : ASTTest("aidl --lang=cpp -t -I . -o out android/os/IComplexTypeInterface.aidl", |
| 1627 | kComplexTypeInterfaceAIDL) { |
| 1628 | io_delegate_.SetFileContents("foo/IFooType.aidl", "package foo; interface IFooType {}"); |
| 1629 | } |
| 1630 | }; |
| 1631 | |
| 1632 | TEST_F(ComplexTypeInterfaceASTTestWithTrace, GeneratesClientSource) { |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1633 | AidlInterface* interface = ParseSingleInterface(); |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 1634 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1635 | unique_ptr<Document> doc = internals::BuildClientSource(typenames_, *interface, options_); |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 1636 | Compare(doc.get(), kExpectedComplexTypeClientWithTraceSourceOutput); |
| 1637 | } |
| 1638 | |
| 1639 | TEST_F(ComplexTypeInterfaceASTTestWithTrace, GeneratesServerSource) { |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1640 | AidlInterface* interface = ParseSingleInterface(); |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 1641 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1642 | unique_ptr<Document> doc = internals::BuildServerSource(typenames_, *interface, options_); |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 1643 | Compare(doc.get(), kExpectedComplexTypeServerWithTraceSourceOutput); |
| 1644 | } |
| 1645 | |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1646 | namespace test_io_handling { |
| 1647 | |
| 1648 | const char kInputPath[] = "a/IFoo.aidl"; |
| 1649 | const char kOutputPath[] = "output.cpp"; |
| 1650 | const char kHeaderDir[] = "headers"; |
| 1651 | const char kInterfaceHeaderRelPath[] = "a/IFoo.h"; |
| 1652 | |
Jiyong Park | 6f77e0c | 2018-07-28 16:55:44 +0900 | [diff] [blame] | 1653 | const string kCmdline = string("aidl-cpp ") + kInputPath + " " + kHeaderDir + " " + kOutputPath; |
| 1654 | |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1655 | } // namespace test_io_handling |
| 1656 | |
| 1657 | class IoErrorHandlingTest : public ASTTest { |
| 1658 | public: |
Jiyong Park | 6f77e0c | 2018-07-28 16:55:44 +0900 | [diff] [blame] | 1659 | IoErrorHandlingTest() : ASTTest(test_io_handling::kCmdline, "package a; interface IFoo {}") {} |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1660 | }; |
| 1661 | |
| 1662 | TEST_F(IoErrorHandlingTest, GenerateCorrectlyAbsentErrors) { |
| 1663 | // Confirm that this is working correctly without I/O problems. |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1664 | AidlInterface* interface = ParseSingleInterface(); |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1665 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1666 | ASSERT_TRUE(GenerateCpp(options_.OutputFile(), options_, typenames_, *interface, io_delegate_)); |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1667 | } |
| 1668 | |
| 1669 | TEST_F(IoErrorHandlingTest, HandlesBadHeaderWrite) { |
| 1670 | using namespace test_io_handling; |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1671 | AidlInterface* interface = ParseSingleInterface(); |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1672 | ASSERT_NE(interface, nullptr); |
| 1673 | |
| 1674 | // Simulate issues closing the interface header. |
| 1675 | const string header_path = |
| 1676 | StringPrintf("%s%c%s", kHeaderDir, OS_PATH_SEPARATOR, |
| 1677 | kInterfaceHeaderRelPath); |
| 1678 | io_delegate_.AddBrokenFilePath(header_path); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1679 | ASSERT_FALSE(GenerateCpp(options_.OutputFile(), options_, typenames_, *interface, io_delegate_)); |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1680 | // We should never attempt to write the C++ file if we fail writing headers. |
| 1681 | ASSERT_FALSE(io_delegate_.GetWrittenContents(kOutputPath, nullptr)); |
| 1682 | // We should remove partial results. |
| 1683 | ASSERT_TRUE(io_delegate_.PathWasRemoved(header_path)); |
| 1684 | } |
| 1685 | |
| 1686 | TEST_F(IoErrorHandlingTest, HandlesBadCppWrite) { |
| 1687 | using test_io_handling::kOutputPath; |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1688 | AidlInterface* interface = ParseSingleInterface(); |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1689 | ASSERT_NE(interface, nullptr); |
| 1690 | |
| 1691 | // Simulate issues closing the cpp file. |
| 1692 | io_delegate_.AddBrokenFilePath(kOutputPath); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1693 | ASSERT_FALSE(GenerateCpp(options_.OutputFile(), options_, typenames_, *interface, io_delegate_)); |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1694 | // We should remove partial results. |
| 1695 | ASSERT_TRUE(io_delegate_.PathWasRemoved(kOutputPath)); |
| 1696 | } |
| 1697 | |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1698 | class EnumASTTest : public ASTTest { |
| 1699 | public: |
| 1700 | EnumASTTest() : ASTTest("aidl --lang=cpp -I . -o out android/os/TestEnum.aidl", kEnumAIDL) {} |
| 1701 | }; |
| 1702 | |
| 1703 | TEST_F(EnumASTTest, GeneratesEnumHeader) { |
| 1704 | AidlEnumDeclaration* enum_decl = ParseSingleEnumDeclaration(); |
| 1705 | ASSERT_NE(enum_decl, nullptr); |
| 1706 | unique_ptr<Document> doc = internals::BuildEnumHeader(typenames_, *enum_decl); |
| 1707 | Compare(doc.get(), kExpectedEnumHeaderOutput); |
| 1708 | } |
| 1709 | |
| 1710 | class EnumWithBackingTypeASTTest : public ASTTest { |
| 1711 | public: |
| 1712 | EnumWithBackingTypeASTTest() |
| 1713 | : ASTTest("aidl --lang=cpp -I . -o out android/os/TestEnum.aidl", kEnumWithBackingTypeAIDL) {} |
| 1714 | }; |
| 1715 | |
| 1716 | TEST_F(EnumWithBackingTypeASTTest, GeneratesEnumHeader) { |
| 1717 | AidlEnumDeclaration* enum_decl = ParseSingleEnumDeclaration(); |
| 1718 | ASSERT_NE(enum_decl, nullptr); |
| 1719 | unique_ptr<Document> doc = internals::BuildEnumHeader(typenames_, *enum_decl); |
| 1720 | Compare(doc.get(), kExpectedEnumWithBackingTypeHeaderOutput); |
| 1721 | } |
| 1722 | |
Christopher Wiley | f944e79 | 2015-09-29 10:00:46 -0700 | [diff] [blame] | 1723 | } // namespace cpp |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 1724 | } // namespace aidl |
| 1725 | } // namespace android |