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