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" |
Christopher Wiley | e3550c6 | 2015-09-29 13:26:10 -0700 | [diff] [blame] | 30 | #include "type_cpp.h" |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 31 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 32 | using ::android::aidl::test::FakeIoDelegate; |
| 33 | using ::android::base::StringPrintf; |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 34 | using std::string; |
| 35 | using std::unique_ptr; |
| 36 | |
| 37 | namespace android { |
| 38 | namespace aidl { |
Christopher Wiley | f944e79 | 2015-09-29 10:00:46 -0700 | [diff] [blame] | 39 | namespace cpp { |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 40 | namespace { |
| 41 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 42 | const string kComplexTypeInterfaceAIDL = |
| 43 | R"(package android.os; |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 44 | import foo.IFooType; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 45 | interface IComplexTypeInterface { |
Casey Dahlin | d40e2fe | 2015-11-24 14:06:52 -0800 | [diff] [blame] | 46 | const int MY_CONSTANT = 3; |
Casey Dahlin | cb5317d | 2015-12-03 15:43:33 -0800 | [diff] [blame] | 47 | int[] Send(in @nullable int[] goes_in, inout double[] goes_in_and_out, out boolean[] goes_out); |
Casey Dahlin | 0dd08af | 2015-10-20 18:45:50 -0700 | [diff] [blame] | 48 | oneway void Piff(int times); |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 49 | IFooType TakesABinder(IFooType f); |
Casey Dahlin | ef88bce | 2016-04-15 11:55:30 -0700 | [diff] [blame] | 50 | @nullable IFooType NullableBinder(); |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 51 | List<String> StringListMethod(in java.util.List<String> input, out List<String> output); |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 52 | List<IBinder> BinderListMethod(in java.util.List<IBinder> input, out List<IBinder> output); |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 53 | FileDescriptor TakesAFileDescriptor(in FileDescriptor f); |
| 54 | FileDescriptor[] TakesAFileDescriptorArray(in FileDescriptor[] f); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 55 | })"; |
| 56 | |
| 57 | const char kExpectedComplexTypeClientHeaderOutput[] = |
| 58 | R"(#ifndef AIDL_GENERATED_ANDROID_OS_BP_COMPLEX_TYPE_INTERFACE_H_ |
| 59 | #define AIDL_GENERATED_ANDROID_OS_BP_COMPLEX_TYPE_INTERFACE_H_ |
| 60 | |
| 61 | #include <binder/IBinder.h> |
| 62 | #include <binder/IInterface.h> |
| 63 | #include <utils/Errors.h> |
| 64 | #include <android/os/IComplexTypeInterface.h> |
| 65 | |
| 66 | namespace android { |
| 67 | |
| 68 | namespace os { |
| 69 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 70 | class BpComplexTypeInterface : public ::android::BpInterface<IComplexTypeInterface> { |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 71 | public: |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 72 | explicit BpComplexTypeInterface(const ::android::sp<::android::IBinder>& _aidl_impl); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 73 | virtual ~BpComplexTypeInterface() = default; |
Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 74 | ::android::binder::Status Send(const ::std::unique_ptr<::std::vector<int32_t>>& goes_in, ::std::vector<double>* goes_in_and_out, ::std::vector<bool>* goes_out, ::std::vector<int32_t>* _aidl_return) override; |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 75 | ::android::binder::Status Piff(int32_t times) override; |
| 76 | ::android::binder::Status TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) override; |
Casey Dahlin | ef88bce | 2016-04-15 11:55:30 -0700 | [diff] [blame] | 77 | ::android::binder::Status NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) override; |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 78 | ::android::binder::Status StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) override; |
| 79 | ::android::binder::Status BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>& input, ::std::vector<::android::sp<::android::IBinder>>* output, ::std::vector<::android::sp<::android::IBinder>>* _aidl_return) override; |
Christopher Wiley | 7cb9c25 | 2016-04-11 11:07:33 -0700 | [diff] [blame] | 80 | ::android::binder::Status TakesAFileDescriptor(const ::android::base::unique_fd& f, ::android::base::unique_fd* _aidl_return) override; |
| 81 | ::android::binder::Status TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) override; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 82 | }; // class BpComplexTypeInterface |
| 83 | |
| 84 | } // namespace os |
| 85 | |
| 86 | } // namespace android |
| 87 | |
Christopher Wiley | 11a9d79 | 2016-02-24 17:20:33 -0800 | [diff] [blame] | 88 | #endif // AIDL_GENERATED_ANDROID_OS_BP_COMPLEX_TYPE_INTERFACE_H_ |
| 89 | )"; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 90 | |
| 91 | const char kExpectedComplexTypeClientSourceOutput[] = |
| 92 | R"(#include <android/os/BpComplexTypeInterface.h> |
| 93 | #include <binder/Parcel.h> |
| 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) { |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 104 | ::android::Parcel _aidl_data; |
| 105 | ::android::Parcel _aidl_reply; |
Christopher Wiley | 1095712 | 2015-12-04 14:35:38 -0800 | [diff] [blame] | 106 | ::android::status_t _aidl_ret_status = ::android::OK; |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 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; |
Christopher Wiley | 8993cb5 | 2015-10-21 09:53:24 -0700 | [diff] [blame] | 111 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 112 | _aidl_ret_status = _aidl_data.writeInt32Vector(goes_in); |
| 113 | if (((_aidl_ret_status) != (::android::OK))) { |
| 114 | goto _aidl_error; |
Christopher Wiley | bb96782 | 2015-10-27 14:04:53 -0700 | [diff] [blame] | 115 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 116 | _aidl_ret_status = _aidl_data.writeDoubleVector(*goes_in_and_out); |
| 117 | if (((_aidl_ret_status) != (::android::OK))) { |
| 118 | goto _aidl_error; |
Christopher Wiley | 0eb903e | 2015-10-20 17:07:08 -0700 | [diff] [blame] | 119 | } |
Christopher Wiley | 74b7bf1 | 2016-08-19 11:06:32 -0700 | [diff] [blame] | 120 | _aidl_ret_status = _aidl_data.writeVectorSize(*goes_out); |
| 121 | if (((_aidl_ret_status) != (::android::OK))) { |
| 122 | goto _aidl_error; |
| 123 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 124 | _aidl_ret_status = remote()->transact(IComplexTypeInterface::SEND, _aidl_data, &_aidl_reply); |
| 125 | if (((_aidl_ret_status) != (::android::OK))) { |
| 126 | goto _aidl_error; |
Christopher Wiley | 0eb903e | 2015-10-20 17:07:08 -0700 | [diff] [blame] | 127 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 128 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 129 | if (((_aidl_ret_status) != (::android::OK))) { |
| 130 | goto _aidl_error; |
Christopher Wiley | 433c8bb | 2015-11-12 14:20:46 -0800 | [diff] [blame] | 131 | } |
| 132 | if (!_aidl_status.isOk()) { |
| 133 | return _aidl_status; |
Christopher Wiley | 2aaeda8 | 2015-10-19 15:16:49 -0700 | [diff] [blame] | 134 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 135 | _aidl_ret_status = _aidl_reply.readInt32Vector(_aidl_return); |
| 136 | if (((_aidl_ret_status) != (::android::OK))) { |
| 137 | goto _aidl_error; |
Christopher Wiley | 0eb903e | 2015-10-20 17:07:08 -0700 | [diff] [blame] | 138 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 139 | _aidl_ret_status = _aidl_reply.readDoubleVector(goes_in_and_out); |
| 140 | if (((_aidl_ret_status) != (::android::OK))) { |
| 141 | goto _aidl_error; |
Christopher Wiley | bb96782 | 2015-10-27 14:04:53 -0700 | [diff] [blame] | 142 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 143 | _aidl_ret_status = _aidl_reply.readBoolVector(goes_out); |
| 144 | if (((_aidl_ret_status) != (::android::OK))) { |
| 145 | goto _aidl_error; |
Christopher Wiley | 0eb903e | 2015-10-20 17:07:08 -0700 | [diff] [blame] | 146 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 147 | _aidl_error: |
| 148 | _aidl_status.setFromStatusT(_aidl_ret_status); |
Christopher Wiley | 433c8bb | 2015-11-12 14:20:46 -0800 | [diff] [blame] | 149 | return _aidl_status; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 150 | } |
| 151 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 152 | ::android::binder::Status BpComplexTypeInterface::Piff(int32_t times) { |
| 153 | ::android::Parcel _aidl_data; |
| 154 | ::android::Parcel _aidl_reply; |
Christopher Wiley | 1095712 | 2015-12-04 14:35:38 -0800 | [diff] [blame] | 155 | ::android::status_t _aidl_ret_status = ::android::OK; |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 156 | ::android::binder::Status _aidl_status; |
| 157 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 158 | if (((_aidl_ret_status) != (::android::OK))) { |
| 159 | goto _aidl_error; |
Christopher Wiley | 8993cb5 | 2015-10-21 09:53:24 -0700 | [diff] [blame] | 160 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 161 | _aidl_ret_status = _aidl_data.writeInt32(times); |
| 162 | if (((_aidl_ret_status) != (::android::OK))) { |
| 163 | goto _aidl_error; |
Christopher Wiley | 0eb903e | 2015-10-20 17:07:08 -0700 | [diff] [blame] | 164 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 165 | _aidl_ret_status = remote()->transact(IComplexTypeInterface::PIFF, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_ONEWAY); |
| 166 | if (((_aidl_ret_status) != (::android::OK))) { |
| 167 | goto _aidl_error; |
Christopher Wiley | 0eb903e | 2015-10-20 17:07:08 -0700 | [diff] [blame] | 168 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 169 | _aidl_error: |
| 170 | _aidl_status.setFromStatusT(_aidl_ret_status); |
Christopher Wiley | 433c8bb | 2015-11-12 14:20:46 -0800 | [diff] [blame] | 171 | return _aidl_status; |
Casey Dahlin | 0dd08af | 2015-10-20 18:45:50 -0700 | [diff] [blame] | 172 | } |
| 173 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 174 | ::android::binder::Status BpComplexTypeInterface::TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) { |
| 175 | ::android::Parcel _aidl_data; |
| 176 | ::android::Parcel _aidl_reply; |
Christopher Wiley | 1095712 | 2015-12-04 14:35:38 -0800 | [diff] [blame] | 177 | ::android::status_t _aidl_ret_status = ::android::OK; |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 178 | ::android::binder::Status _aidl_status; |
| 179 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 180 | if (((_aidl_ret_status) != (::android::OK))) { |
| 181 | goto _aidl_error; |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 182 | } |
Casey Dahlin | 2dbab06 | 2016-01-05 17:41:08 -0800 | [diff] [blame] | 183 | _aidl_ret_status = _aidl_data.writeStrongBinder(::foo::IFooType::asBinder(f)); |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 184 | if (((_aidl_ret_status) != (::android::OK))) { |
| 185 | goto _aidl_error; |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 186 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 187 | _aidl_ret_status = remote()->transact(IComplexTypeInterface::TAKESABINDER, _aidl_data, &_aidl_reply); |
| 188 | if (((_aidl_ret_status) != (::android::OK))) { |
| 189 | goto _aidl_error; |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 190 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 191 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 192 | if (((_aidl_ret_status) != (::android::OK))) { |
| 193 | goto _aidl_error; |
Christopher Wiley | 433c8bb | 2015-11-12 14:20:46 -0800 | [diff] [blame] | 194 | } |
| 195 | if (!_aidl_status.isOk()) { |
| 196 | return _aidl_status; |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 197 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 198 | _aidl_ret_status = _aidl_reply.readStrongBinder(_aidl_return); |
| 199 | if (((_aidl_ret_status) != (::android::OK))) { |
| 200 | goto _aidl_error; |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 201 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 202 | _aidl_error: |
| 203 | _aidl_status.setFromStatusT(_aidl_ret_status); |
Christopher Wiley | 433c8bb | 2015-11-12 14:20:46 -0800 | [diff] [blame] | 204 | return _aidl_status; |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 205 | } |
| 206 | |
Casey Dahlin | ef88bce | 2016-04-15 11:55:30 -0700 | [diff] [blame] | 207 | ::android::binder::Status BpComplexTypeInterface::NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) { |
| 208 | ::android::Parcel _aidl_data; |
| 209 | ::android::Parcel _aidl_reply; |
| 210 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 211 | ::android::binder::Status _aidl_status; |
| 212 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 213 | if (((_aidl_ret_status) != (::android::OK))) { |
| 214 | goto _aidl_error; |
| 215 | } |
| 216 | _aidl_ret_status = remote()->transact(IComplexTypeInterface::NULLABLEBINDER, _aidl_data, &_aidl_reply); |
| 217 | if (((_aidl_ret_status) != (::android::OK))) { |
| 218 | goto _aidl_error; |
| 219 | } |
| 220 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 221 | if (((_aidl_ret_status) != (::android::OK))) { |
| 222 | goto _aidl_error; |
| 223 | } |
| 224 | if (!_aidl_status.isOk()) { |
| 225 | return _aidl_status; |
| 226 | } |
| 227 | _aidl_ret_status = _aidl_reply.readNullableStrongBinder(_aidl_return); |
| 228 | if (((_aidl_ret_status) != (::android::OK))) { |
| 229 | goto _aidl_error; |
| 230 | } |
| 231 | _aidl_error: |
| 232 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 233 | return _aidl_status; |
| 234 | } |
| 235 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 236 | ::android::binder::Status BpComplexTypeInterface::StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) { |
| 237 | ::android::Parcel _aidl_data; |
| 238 | ::android::Parcel _aidl_reply; |
Christopher Wiley | 1095712 | 2015-12-04 14:35:38 -0800 | [diff] [blame] | 239 | ::android::status_t _aidl_ret_status = ::android::OK; |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 240 | ::android::binder::Status _aidl_status; |
| 241 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 242 | if (((_aidl_ret_status) != (::android::OK))) { |
| 243 | goto _aidl_error; |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 244 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 245 | _aidl_ret_status = _aidl_data.writeString16Vector(input); |
| 246 | if (((_aidl_ret_status) != (::android::OK))) { |
| 247 | goto _aidl_error; |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 248 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 249 | _aidl_ret_status = remote()->transact(IComplexTypeInterface::STRINGLISTMETHOD, _aidl_data, &_aidl_reply); |
| 250 | if (((_aidl_ret_status) != (::android::OK))) { |
| 251 | goto _aidl_error; |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 252 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 253 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 254 | if (((_aidl_ret_status) != (::android::OK))) { |
| 255 | goto _aidl_error; |
Christopher Wiley | 433c8bb | 2015-11-12 14:20:46 -0800 | [diff] [blame] | 256 | } |
| 257 | if (!_aidl_status.isOk()) { |
| 258 | return _aidl_status; |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 259 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 260 | _aidl_ret_status = _aidl_reply.readString16Vector(_aidl_return); |
| 261 | if (((_aidl_ret_status) != (::android::OK))) { |
| 262 | goto _aidl_error; |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 263 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 264 | _aidl_ret_status = _aidl_reply.readString16Vector(output); |
| 265 | if (((_aidl_ret_status) != (::android::OK))) { |
| 266 | goto _aidl_error; |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 267 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 268 | _aidl_error: |
| 269 | _aidl_status.setFromStatusT(_aidl_ret_status); |
Christopher Wiley | 433c8bb | 2015-11-12 14:20:46 -0800 | [diff] [blame] | 270 | return _aidl_status; |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 271 | } |
| 272 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 273 | ::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) { |
| 274 | ::android::Parcel _aidl_data; |
| 275 | ::android::Parcel _aidl_reply; |
Christopher Wiley | 1095712 | 2015-12-04 14:35:38 -0800 | [diff] [blame] | 276 | ::android::status_t _aidl_ret_status = ::android::OK; |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 277 | ::android::binder::Status _aidl_status; |
| 278 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 279 | if (((_aidl_ret_status) != (::android::OK))) { |
| 280 | goto _aidl_error; |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 281 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 282 | _aidl_ret_status = _aidl_data.writeStrongBinderVector(input); |
| 283 | if (((_aidl_ret_status) != (::android::OK))) { |
| 284 | goto _aidl_error; |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 285 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 286 | _aidl_ret_status = remote()->transact(IComplexTypeInterface::BINDERLISTMETHOD, _aidl_data, &_aidl_reply); |
| 287 | if (((_aidl_ret_status) != (::android::OK))) { |
| 288 | goto _aidl_error; |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 289 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 290 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 291 | if (((_aidl_ret_status) != (::android::OK))) { |
| 292 | goto _aidl_error; |
Christopher Wiley | 433c8bb | 2015-11-12 14:20:46 -0800 | [diff] [blame] | 293 | } |
| 294 | if (!_aidl_status.isOk()) { |
| 295 | return _aidl_status; |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 296 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 297 | _aidl_ret_status = _aidl_reply.readStrongBinderVector(_aidl_return); |
| 298 | if (((_aidl_ret_status) != (::android::OK))) { |
| 299 | goto _aidl_error; |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 300 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 301 | _aidl_ret_status = _aidl_reply.readStrongBinderVector(output); |
| 302 | if (((_aidl_ret_status) != (::android::OK))) { |
| 303 | goto _aidl_error; |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 304 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 305 | _aidl_error: |
| 306 | _aidl_status.setFromStatusT(_aidl_ret_status); |
Christopher Wiley | 433c8bb | 2015-11-12 14:20:46 -0800 | [diff] [blame] | 307 | return _aidl_status; |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 308 | } |
| 309 | |
Christopher Wiley | 7cb9c25 | 2016-04-11 11:07:33 -0700 | [diff] [blame] | 310 | ::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptor(const ::android::base::unique_fd& f, ::android::base::unique_fd* _aidl_return) { |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 311 | ::android::Parcel _aidl_data; |
| 312 | ::android::Parcel _aidl_reply; |
Christopher Wiley | 1095712 | 2015-12-04 14:35:38 -0800 | [diff] [blame] | 313 | ::android::status_t _aidl_ret_status = ::android::OK; |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 314 | ::android::binder::Status _aidl_status; |
| 315 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 316 | if (((_aidl_ret_status) != (::android::OK))) { |
| 317 | goto _aidl_error; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 318 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 319 | _aidl_ret_status = _aidl_data.writeUniqueFileDescriptor(f); |
| 320 | if (((_aidl_ret_status) != (::android::OK))) { |
| 321 | goto _aidl_error; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 322 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 323 | _aidl_ret_status = remote()->transact(IComplexTypeInterface::TAKESAFILEDESCRIPTOR, _aidl_data, &_aidl_reply); |
| 324 | if (((_aidl_ret_status) != (::android::OK))) { |
| 325 | goto _aidl_error; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 326 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 327 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 328 | if (((_aidl_ret_status) != (::android::OK))) { |
| 329 | goto _aidl_error; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 330 | } |
| 331 | if (!_aidl_status.isOk()) { |
| 332 | return _aidl_status; |
| 333 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 334 | _aidl_ret_status = _aidl_reply.readUniqueFileDescriptor(_aidl_return); |
| 335 | if (((_aidl_ret_status) != (::android::OK))) { |
| 336 | goto _aidl_error; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 337 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 338 | _aidl_error: |
| 339 | _aidl_status.setFromStatusT(_aidl_ret_status); |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 340 | return _aidl_status; |
| 341 | } |
| 342 | |
Christopher Wiley | 7cb9c25 | 2016-04-11 11:07:33 -0700 | [diff] [blame] | 343 | ::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) { |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 344 | ::android::Parcel _aidl_data; |
| 345 | ::android::Parcel _aidl_reply; |
Christopher Wiley | 1095712 | 2015-12-04 14:35:38 -0800 | [diff] [blame] | 346 | ::android::status_t _aidl_ret_status = ::android::OK; |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 347 | ::android::binder::Status _aidl_status; |
| 348 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 349 | if (((_aidl_ret_status) != (::android::OK))) { |
| 350 | goto _aidl_error; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 351 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 352 | _aidl_ret_status = _aidl_data.writeUniqueFileDescriptorVector(f); |
| 353 | if (((_aidl_ret_status) != (::android::OK))) { |
| 354 | goto _aidl_error; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 355 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 356 | _aidl_ret_status = remote()->transact(IComplexTypeInterface::TAKESAFILEDESCRIPTORARRAY, _aidl_data, &_aidl_reply); |
| 357 | if (((_aidl_ret_status) != (::android::OK))) { |
| 358 | goto _aidl_error; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 359 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 360 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 361 | if (((_aidl_ret_status) != (::android::OK))) { |
| 362 | goto _aidl_error; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 363 | } |
| 364 | if (!_aidl_status.isOk()) { |
| 365 | return _aidl_status; |
| 366 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 367 | _aidl_ret_status = _aidl_reply.readUniqueFileDescriptorVector(_aidl_return); |
| 368 | if (((_aidl_ret_status) != (::android::OK))) { |
| 369 | goto _aidl_error; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 370 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 371 | _aidl_error: |
| 372 | _aidl_status.setFromStatusT(_aidl_ret_status); |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 373 | return _aidl_status; |
| 374 | } |
| 375 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 376 | } // namespace os |
| 377 | |
| 378 | } // namespace android |
| 379 | )"; |
| 380 | |
Martijn Coenen | b06c829 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 381 | const char kExpectedComplexTypeClientWithTraceSourceOutput[] = |
| 382 | R"(#include <android/os/BpComplexTypeInterface.h> |
| 383 | #include <binder/Parcel.h> |
| 384 | |
| 385 | namespace android { |
| 386 | |
| 387 | namespace os { |
| 388 | |
| 389 | BpComplexTypeInterface::BpComplexTypeInterface(const ::android::sp<::android::IBinder>& _aidl_impl) |
| 390 | : BpInterface<IComplexTypeInterface>(_aidl_impl){ |
| 391 | } |
| 392 | |
| 393 | ::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) { |
| 394 | ::android::Parcel _aidl_data; |
| 395 | ::android::Parcel _aidl_reply; |
| 396 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 397 | ::android::binder::Status _aidl_status; |
| 398 | ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "IComplexTypeInterface::Send::cppClient"); |
| 399 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 400 | if (((_aidl_ret_status) != (::android::OK))) { |
| 401 | goto _aidl_error; |
| 402 | } |
| 403 | _aidl_ret_status = _aidl_data.writeInt32Vector(goes_in); |
| 404 | if (((_aidl_ret_status) != (::android::OK))) { |
| 405 | goto _aidl_error; |
| 406 | } |
| 407 | _aidl_ret_status = _aidl_data.writeDoubleVector(*goes_in_and_out); |
| 408 | if (((_aidl_ret_status) != (::android::OK))) { |
| 409 | goto _aidl_error; |
| 410 | } |
| 411 | _aidl_ret_status = _aidl_data.writeVectorSize(*goes_out); |
| 412 | if (((_aidl_ret_status) != (::android::OK))) { |
| 413 | goto _aidl_error; |
| 414 | } |
| 415 | _aidl_ret_status = remote()->transact(IComplexTypeInterface::SEND, _aidl_data, &_aidl_reply); |
| 416 | if (((_aidl_ret_status) != (::android::OK))) { |
| 417 | goto _aidl_error; |
| 418 | } |
| 419 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 420 | if (((_aidl_ret_status) != (::android::OK))) { |
| 421 | goto _aidl_error; |
| 422 | } |
| 423 | if (!_aidl_status.isOk()) { |
| 424 | return _aidl_status; |
| 425 | } |
| 426 | _aidl_ret_status = _aidl_reply.readInt32Vector(_aidl_return); |
| 427 | if (((_aidl_ret_status) != (::android::OK))) { |
| 428 | goto _aidl_error; |
| 429 | } |
| 430 | _aidl_ret_status = _aidl_reply.readDoubleVector(goes_in_and_out); |
| 431 | if (((_aidl_ret_status) != (::android::OK))) { |
| 432 | goto _aidl_error; |
| 433 | } |
| 434 | _aidl_ret_status = _aidl_reply.readBoolVector(goes_out); |
| 435 | if (((_aidl_ret_status) != (::android::OK))) { |
| 436 | goto _aidl_error; |
| 437 | } |
| 438 | _aidl_error: |
| 439 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 440 | return _aidl_status; |
| 441 | } |
| 442 | |
| 443 | ::android::binder::Status BpComplexTypeInterface::Piff(int32_t times) { |
| 444 | ::android::Parcel _aidl_data; |
| 445 | ::android::Parcel _aidl_reply; |
| 446 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 447 | ::android::binder::Status _aidl_status; |
| 448 | ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "IComplexTypeInterface::Piff::cppClient"); |
| 449 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 450 | if (((_aidl_ret_status) != (::android::OK))) { |
| 451 | goto _aidl_error; |
| 452 | } |
| 453 | _aidl_ret_status = _aidl_data.writeInt32(times); |
| 454 | if (((_aidl_ret_status) != (::android::OK))) { |
| 455 | goto _aidl_error; |
| 456 | } |
| 457 | _aidl_ret_status = remote()->transact(IComplexTypeInterface::PIFF, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_ONEWAY); |
| 458 | if (((_aidl_ret_status) != (::android::OK))) { |
| 459 | goto _aidl_error; |
| 460 | } |
| 461 | _aidl_error: |
| 462 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 463 | return _aidl_status; |
| 464 | } |
| 465 | |
| 466 | ::android::binder::Status BpComplexTypeInterface::TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) { |
| 467 | ::android::Parcel _aidl_data; |
| 468 | ::android::Parcel _aidl_reply; |
| 469 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 470 | ::android::binder::Status _aidl_status; |
| 471 | ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "IComplexTypeInterface::TakesABinder::cppClient"); |
| 472 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 473 | if (((_aidl_ret_status) != (::android::OK))) { |
| 474 | goto _aidl_error; |
| 475 | } |
| 476 | _aidl_ret_status = _aidl_data.writeStrongBinder(::foo::IFooType::asBinder(f)); |
| 477 | if (((_aidl_ret_status) != (::android::OK))) { |
| 478 | goto _aidl_error; |
| 479 | } |
| 480 | _aidl_ret_status = remote()->transact(IComplexTypeInterface::TAKESABINDER, _aidl_data, &_aidl_reply); |
| 481 | if (((_aidl_ret_status) != (::android::OK))) { |
| 482 | goto _aidl_error; |
| 483 | } |
| 484 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 485 | if (((_aidl_ret_status) != (::android::OK))) { |
| 486 | goto _aidl_error; |
| 487 | } |
| 488 | if (!_aidl_status.isOk()) { |
| 489 | return _aidl_status; |
| 490 | } |
| 491 | _aidl_ret_status = _aidl_reply.readStrongBinder(_aidl_return); |
| 492 | if (((_aidl_ret_status) != (::android::OK))) { |
| 493 | goto _aidl_error; |
| 494 | } |
| 495 | _aidl_error: |
| 496 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 497 | return _aidl_status; |
| 498 | } |
| 499 | |
| 500 | ::android::binder::Status BpComplexTypeInterface::NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) { |
| 501 | ::android::Parcel _aidl_data; |
| 502 | ::android::Parcel _aidl_reply; |
| 503 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 504 | ::android::binder::Status _aidl_status; |
| 505 | ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "IComplexTypeInterface::NullableBinder::cppClient"); |
| 506 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 507 | if (((_aidl_ret_status) != (::android::OK))) { |
| 508 | goto _aidl_error; |
| 509 | } |
| 510 | _aidl_ret_status = remote()->transact(IComplexTypeInterface::NULLABLEBINDER, _aidl_data, &_aidl_reply); |
| 511 | if (((_aidl_ret_status) != (::android::OK))) { |
| 512 | goto _aidl_error; |
| 513 | } |
| 514 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 515 | if (((_aidl_ret_status) != (::android::OK))) { |
| 516 | goto _aidl_error; |
| 517 | } |
| 518 | if (!_aidl_status.isOk()) { |
| 519 | return _aidl_status; |
| 520 | } |
| 521 | _aidl_ret_status = _aidl_reply.readNullableStrongBinder(_aidl_return); |
| 522 | if (((_aidl_ret_status) != (::android::OK))) { |
| 523 | goto _aidl_error; |
| 524 | } |
| 525 | _aidl_error: |
| 526 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 527 | return _aidl_status; |
| 528 | } |
| 529 | |
| 530 | ::android::binder::Status BpComplexTypeInterface::StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) { |
| 531 | ::android::Parcel _aidl_data; |
| 532 | ::android::Parcel _aidl_reply; |
| 533 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 534 | ::android::binder::Status _aidl_status; |
| 535 | ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "IComplexTypeInterface::StringListMethod::cppClient"); |
| 536 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 537 | if (((_aidl_ret_status) != (::android::OK))) { |
| 538 | goto _aidl_error; |
| 539 | } |
| 540 | _aidl_ret_status = _aidl_data.writeString16Vector(input); |
| 541 | if (((_aidl_ret_status) != (::android::OK))) { |
| 542 | goto _aidl_error; |
| 543 | } |
| 544 | _aidl_ret_status = remote()->transact(IComplexTypeInterface::STRINGLISTMETHOD, _aidl_data, &_aidl_reply); |
| 545 | if (((_aidl_ret_status) != (::android::OK))) { |
| 546 | goto _aidl_error; |
| 547 | } |
| 548 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 549 | if (((_aidl_ret_status) != (::android::OK))) { |
| 550 | goto _aidl_error; |
| 551 | } |
| 552 | if (!_aidl_status.isOk()) { |
| 553 | return _aidl_status; |
| 554 | } |
| 555 | _aidl_ret_status = _aidl_reply.readString16Vector(_aidl_return); |
| 556 | if (((_aidl_ret_status) != (::android::OK))) { |
| 557 | goto _aidl_error; |
| 558 | } |
| 559 | _aidl_ret_status = _aidl_reply.readString16Vector(output); |
| 560 | if (((_aidl_ret_status) != (::android::OK))) { |
| 561 | goto _aidl_error; |
| 562 | } |
| 563 | _aidl_error: |
| 564 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 565 | return _aidl_status; |
| 566 | } |
| 567 | |
| 568 | ::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) { |
| 569 | ::android::Parcel _aidl_data; |
| 570 | ::android::Parcel _aidl_reply; |
| 571 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 572 | ::android::binder::Status _aidl_status; |
| 573 | ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "IComplexTypeInterface::BinderListMethod::cppClient"); |
| 574 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 575 | if (((_aidl_ret_status) != (::android::OK))) { |
| 576 | goto _aidl_error; |
| 577 | } |
| 578 | _aidl_ret_status = _aidl_data.writeStrongBinderVector(input); |
| 579 | if (((_aidl_ret_status) != (::android::OK))) { |
| 580 | goto _aidl_error; |
| 581 | } |
| 582 | _aidl_ret_status = remote()->transact(IComplexTypeInterface::BINDERLISTMETHOD, _aidl_data, &_aidl_reply); |
| 583 | if (((_aidl_ret_status) != (::android::OK))) { |
| 584 | goto _aidl_error; |
| 585 | } |
| 586 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 587 | if (((_aidl_ret_status) != (::android::OK))) { |
| 588 | goto _aidl_error; |
| 589 | } |
| 590 | if (!_aidl_status.isOk()) { |
| 591 | return _aidl_status; |
| 592 | } |
| 593 | _aidl_ret_status = _aidl_reply.readStrongBinderVector(_aidl_return); |
| 594 | if (((_aidl_ret_status) != (::android::OK))) { |
| 595 | goto _aidl_error; |
| 596 | } |
| 597 | _aidl_ret_status = _aidl_reply.readStrongBinderVector(output); |
| 598 | if (((_aidl_ret_status) != (::android::OK))) { |
| 599 | goto _aidl_error; |
| 600 | } |
| 601 | _aidl_error: |
| 602 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 603 | return _aidl_status; |
| 604 | } |
| 605 | |
| 606 | ::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptor(const ::android::base::unique_fd& f, ::android::base::unique_fd* _aidl_return) { |
| 607 | ::android::Parcel _aidl_data; |
| 608 | ::android::Parcel _aidl_reply; |
| 609 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 610 | ::android::binder::Status _aidl_status; |
| 611 | ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "IComplexTypeInterface::TakesAFileDescriptor::cppClient"); |
| 612 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 613 | if (((_aidl_ret_status) != (::android::OK))) { |
| 614 | goto _aidl_error; |
| 615 | } |
| 616 | _aidl_ret_status = _aidl_data.writeUniqueFileDescriptor(f); |
| 617 | if (((_aidl_ret_status) != (::android::OK))) { |
| 618 | goto _aidl_error; |
| 619 | } |
| 620 | _aidl_ret_status = remote()->transact(IComplexTypeInterface::TAKESAFILEDESCRIPTOR, _aidl_data, &_aidl_reply); |
| 621 | if (((_aidl_ret_status) != (::android::OK))) { |
| 622 | goto _aidl_error; |
| 623 | } |
| 624 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 625 | if (((_aidl_ret_status) != (::android::OK))) { |
| 626 | goto _aidl_error; |
| 627 | } |
| 628 | if (!_aidl_status.isOk()) { |
| 629 | return _aidl_status; |
| 630 | } |
| 631 | _aidl_ret_status = _aidl_reply.readUniqueFileDescriptor(_aidl_return); |
| 632 | if (((_aidl_ret_status) != (::android::OK))) { |
| 633 | goto _aidl_error; |
| 634 | } |
| 635 | _aidl_error: |
| 636 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 637 | return _aidl_status; |
| 638 | } |
| 639 | |
| 640 | ::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) { |
| 641 | ::android::Parcel _aidl_data; |
| 642 | ::android::Parcel _aidl_reply; |
| 643 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 644 | ::android::binder::Status _aidl_status; |
| 645 | ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "IComplexTypeInterface::TakesAFileDescriptorArray::cppClient"); |
| 646 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 647 | if (((_aidl_ret_status) != (::android::OK))) { |
| 648 | goto _aidl_error; |
| 649 | } |
| 650 | _aidl_ret_status = _aidl_data.writeUniqueFileDescriptorVector(f); |
| 651 | if (((_aidl_ret_status) != (::android::OK))) { |
| 652 | goto _aidl_error; |
| 653 | } |
| 654 | _aidl_ret_status = remote()->transact(IComplexTypeInterface::TAKESAFILEDESCRIPTORARRAY, _aidl_data, &_aidl_reply); |
| 655 | if (((_aidl_ret_status) != (::android::OK))) { |
| 656 | goto _aidl_error; |
| 657 | } |
| 658 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 659 | if (((_aidl_ret_status) != (::android::OK))) { |
| 660 | goto _aidl_error; |
| 661 | } |
| 662 | if (!_aidl_status.isOk()) { |
| 663 | return _aidl_status; |
| 664 | } |
| 665 | _aidl_ret_status = _aidl_reply.readUniqueFileDescriptorVector(_aidl_return); |
| 666 | if (((_aidl_ret_status) != (::android::OK))) { |
| 667 | goto _aidl_error; |
| 668 | } |
| 669 | _aidl_error: |
| 670 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 671 | return _aidl_status; |
| 672 | } |
| 673 | |
| 674 | } // namespace os |
| 675 | |
| 676 | } // namespace android |
| 677 | )"; |
| 678 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 679 | const char kExpectedComplexTypeServerHeaderOutput[] = |
| 680 | R"(#ifndef AIDL_GENERATED_ANDROID_OS_BN_COMPLEX_TYPE_INTERFACE_H_ |
| 681 | #define AIDL_GENERATED_ANDROID_OS_BN_COMPLEX_TYPE_INTERFACE_H_ |
| 682 | |
| 683 | #include <binder/IInterface.h> |
| 684 | #include <android/os/IComplexTypeInterface.h> |
| 685 | |
| 686 | namespace android { |
| 687 | |
| 688 | namespace os { |
| 689 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 690 | class BnComplexTypeInterface : public ::android::BnInterface<IComplexTypeInterface> { |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 691 | public: |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 692 | ::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags = 0) override; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 693 | }; // class BnComplexTypeInterface |
| 694 | |
| 695 | } // namespace os |
| 696 | |
| 697 | } // namespace android |
| 698 | |
Christopher Wiley | 11a9d79 | 2016-02-24 17:20:33 -0800 | [diff] [blame] | 699 | #endif // AIDL_GENERATED_ANDROID_OS_BN_COMPLEX_TYPE_INTERFACE_H_ |
| 700 | )"; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 701 | |
| 702 | const char kExpectedComplexTypeServerSourceOutput[] = |
| 703 | R"(#include <android/os/BnComplexTypeInterface.h> |
| 704 | #include <binder/Parcel.h> |
| 705 | |
| 706 | namespace android { |
| 707 | |
| 708 | namespace os { |
| 709 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 710 | ::android::status_t BnComplexTypeInterface::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) { |
Christopher Wiley | 1095712 | 2015-12-04 14:35:38 -0800 | [diff] [blame] | 711 | ::android::status_t _aidl_ret_status = ::android::OK; |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 712 | switch (_aidl_code) { |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 713 | case Call::SEND: |
| 714 | { |
Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 715 | ::std::unique_ptr<::std::vector<int32_t>> in_goes_in; |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 716 | ::std::vector<double> in_goes_in_and_out; |
| 717 | ::std::vector<bool> out_goes_out; |
| 718 | ::std::vector<int32_t> _aidl_return; |
| 719 | if (!(_aidl_data.checkInterface(this))) { |
| 720 | _aidl_ret_status = ::android::BAD_TYPE; |
Christopher Wiley | 8993cb5 | 2015-10-21 09:53:24 -0700 | [diff] [blame] | 721 | break; |
| 722 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 723 | _aidl_ret_status = _aidl_data.readInt32Vector(&in_goes_in); |
| 724 | if (((_aidl_ret_status) != (::android::OK))) { |
Christopher Wiley | 0eb903e | 2015-10-20 17:07:08 -0700 | [diff] [blame] | 725 | break; |
| 726 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 727 | _aidl_ret_status = _aidl_data.readDoubleVector(&in_goes_in_and_out); |
| 728 | if (((_aidl_ret_status) != (::android::OK))) { |
Christopher Wiley | bb96782 | 2015-10-27 14:04:53 -0700 | [diff] [blame] | 729 | break; |
| 730 | } |
Christopher Wiley | 74b7bf1 | 2016-08-19 11:06:32 -0700 | [diff] [blame] | 731 | _aidl_ret_status = _aidl_data.resizeOutVector(&out_goes_out); |
| 732 | if (((_aidl_ret_status) != (::android::OK))) { |
| 733 | break; |
| 734 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 735 | ::android::binder::Status _aidl_status(Send(in_goes_in, &in_goes_in_and_out, &out_goes_out, &_aidl_return)); |
| 736 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 737 | if (((_aidl_ret_status) != (::android::OK))) { |
Christopher Wiley | 0eb903e | 2015-10-20 17:07:08 -0700 | [diff] [blame] | 738 | break; |
| 739 | } |
Christopher Wiley | 433c8bb | 2015-11-12 14:20:46 -0800 | [diff] [blame] | 740 | if (!_aidl_status.isOk()) { |
Christopher Wiley | 2aaeda8 | 2015-10-19 15:16:49 -0700 | [diff] [blame] | 741 | break; |
| 742 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 743 | _aidl_ret_status = _aidl_reply->writeInt32Vector(_aidl_return); |
| 744 | if (((_aidl_ret_status) != (::android::OK))) { |
Christopher Wiley | 0eb903e | 2015-10-20 17:07:08 -0700 | [diff] [blame] | 745 | break; |
| 746 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 747 | _aidl_ret_status = _aidl_reply->writeDoubleVector(in_goes_in_and_out); |
| 748 | if (((_aidl_ret_status) != (::android::OK))) { |
Christopher Wiley | bb96782 | 2015-10-27 14:04:53 -0700 | [diff] [blame] | 749 | break; |
| 750 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 751 | _aidl_ret_status = _aidl_reply->writeBoolVector(out_goes_out); |
| 752 | if (((_aidl_ret_status) != (::android::OK))) { |
Christopher Wiley | 0eb903e | 2015-10-20 17:07:08 -0700 | [diff] [blame] | 753 | break; |
| 754 | } |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 755 | } |
| 756 | break; |
Casey Dahlin | 0dd08af | 2015-10-20 18:45:50 -0700 | [diff] [blame] | 757 | case Call::PIFF: |
| 758 | { |
| 759 | int32_t in_times; |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 760 | if (!(_aidl_data.checkInterface(this))) { |
| 761 | _aidl_ret_status = ::android::BAD_TYPE; |
Christopher Wiley | 8993cb5 | 2015-10-21 09:53:24 -0700 | [diff] [blame] | 762 | break; |
| 763 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 764 | _aidl_ret_status = _aidl_data.readInt32(&in_times); |
| 765 | if (((_aidl_ret_status) != (::android::OK))) { |
Christopher Wiley | 0eb903e | 2015-10-20 17:07:08 -0700 | [diff] [blame] | 766 | break; |
| 767 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 768 | ::android::binder::Status _aidl_status(Piff(in_times)); |
Casey Dahlin | 0dd08af | 2015-10-20 18:45:50 -0700 | [diff] [blame] | 769 | } |
| 770 | break; |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 771 | case Call::TAKESABINDER: |
| 772 | { |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 773 | ::android::sp<::foo::IFooType> in_f; |
| 774 | ::android::sp<::foo::IFooType> _aidl_return; |
| 775 | if (!(_aidl_data.checkInterface(this))) { |
| 776 | _aidl_ret_status = ::android::BAD_TYPE; |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 777 | break; |
| 778 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 779 | _aidl_ret_status = _aidl_data.readStrongBinder(&in_f); |
| 780 | if (((_aidl_ret_status) != (::android::OK))) { |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 781 | break; |
| 782 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 783 | ::android::binder::Status _aidl_status(TakesABinder(in_f, &_aidl_return)); |
| 784 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 785 | if (((_aidl_ret_status) != (::android::OK))) { |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 786 | break; |
| 787 | } |
Christopher Wiley | 433c8bb | 2015-11-12 14:20:46 -0800 | [diff] [blame] | 788 | if (!_aidl_status.isOk()) { |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 789 | break; |
| 790 | } |
Casey Dahlin | 2dbab06 | 2016-01-05 17:41:08 -0800 | [diff] [blame] | 791 | _aidl_ret_status = _aidl_reply->writeStrongBinder(::foo::IFooType::asBinder(_aidl_return)); |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 792 | if (((_aidl_ret_status) != (::android::OK))) { |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 793 | break; |
| 794 | } |
| 795 | } |
| 796 | break; |
Casey Dahlin | ef88bce | 2016-04-15 11:55:30 -0700 | [diff] [blame] | 797 | case Call::NULLABLEBINDER: |
| 798 | { |
| 799 | ::android::sp<::foo::IFooType> _aidl_return; |
| 800 | if (!(_aidl_data.checkInterface(this))) { |
| 801 | _aidl_ret_status = ::android::BAD_TYPE; |
| 802 | break; |
| 803 | } |
| 804 | ::android::binder::Status _aidl_status(NullableBinder(&_aidl_return)); |
| 805 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 806 | if (((_aidl_ret_status) != (::android::OK))) { |
| 807 | break; |
| 808 | } |
| 809 | if (!_aidl_status.isOk()) { |
| 810 | break; |
| 811 | } |
| 812 | _aidl_ret_status = _aidl_reply->writeStrongBinder(::foo::IFooType::asBinder(_aidl_return)); |
| 813 | if (((_aidl_ret_status) != (::android::OK))) { |
| 814 | break; |
| 815 | } |
| 816 | } |
| 817 | break; |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 818 | case Call::STRINGLISTMETHOD: |
| 819 | { |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 820 | ::std::vector<::android::String16> in_input; |
| 821 | ::std::vector<::android::String16> out_output; |
| 822 | ::std::vector<::android::String16> _aidl_return; |
| 823 | if (!(_aidl_data.checkInterface(this))) { |
| 824 | _aidl_ret_status = ::android::BAD_TYPE; |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 825 | break; |
| 826 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 827 | _aidl_ret_status = _aidl_data.readString16Vector(&in_input); |
| 828 | if (((_aidl_ret_status) != (::android::OK))) { |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 829 | break; |
| 830 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 831 | ::android::binder::Status _aidl_status(StringListMethod(in_input, &out_output, &_aidl_return)); |
| 832 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 833 | if (((_aidl_ret_status) != (::android::OK))) { |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 834 | break; |
| 835 | } |
Christopher Wiley | 433c8bb | 2015-11-12 14:20:46 -0800 | [diff] [blame] | 836 | if (!_aidl_status.isOk()) { |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 837 | break; |
| 838 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 839 | _aidl_ret_status = _aidl_reply->writeString16Vector(_aidl_return); |
| 840 | if (((_aidl_ret_status) != (::android::OK))) { |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 841 | break; |
| 842 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 843 | _aidl_ret_status = _aidl_reply->writeString16Vector(out_output); |
| 844 | if (((_aidl_ret_status) != (::android::OK))) { |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 845 | break; |
| 846 | } |
| 847 | } |
| 848 | break; |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 849 | case Call::BINDERLISTMETHOD: |
| 850 | { |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 851 | ::std::vector<::android::sp<::android::IBinder>> in_input; |
| 852 | ::std::vector<::android::sp<::android::IBinder>> out_output; |
| 853 | ::std::vector<::android::sp<::android::IBinder>> _aidl_return; |
| 854 | if (!(_aidl_data.checkInterface(this))) { |
| 855 | _aidl_ret_status = ::android::BAD_TYPE; |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 856 | break; |
| 857 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 858 | _aidl_ret_status = _aidl_data.readStrongBinderVector(&in_input); |
| 859 | if (((_aidl_ret_status) != (::android::OK))) { |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 860 | break; |
| 861 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 862 | ::android::binder::Status _aidl_status(BinderListMethod(in_input, &out_output, &_aidl_return)); |
| 863 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 864 | if (((_aidl_ret_status) != (::android::OK))) { |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 865 | break; |
| 866 | } |
Christopher Wiley | 433c8bb | 2015-11-12 14:20:46 -0800 | [diff] [blame] | 867 | if (!_aidl_status.isOk()) { |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 868 | break; |
| 869 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 870 | _aidl_ret_status = _aidl_reply->writeStrongBinderVector(_aidl_return); |
| 871 | if (((_aidl_ret_status) != (::android::OK))) { |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 872 | break; |
| 873 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 874 | _aidl_ret_status = _aidl_reply->writeStrongBinderVector(out_output); |
| 875 | if (((_aidl_ret_status) != (::android::OK))) { |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 876 | break; |
| 877 | } |
| 878 | } |
| 879 | break; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 880 | case Call::TAKESAFILEDESCRIPTOR: |
| 881 | { |
Christopher Wiley | 7cb9c25 | 2016-04-11 11:07:33 -0700 | [diff] [blame] | 882 | ::android::base::unique_fd in_f; |
| 883 | ::android::base::unique_fd _aidl_return; |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 884 | if (!(_aidl_data.checkInterface(this))) { |
| 885 | _aidl_ret_status = ::android::BAD_TYPE; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 886 | break; |
| 887 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 888 | _aidl_ret_status = _aidl_data.readUniqueFileDescriptor(&in_f); |
| 889 | if (((_aidl_ret_status) != (::android::OK))) { |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 890 | break; |
| 891 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 892 | ::android::binder::Status _aidl_status(TakesAFileDescriptor(in_f, &_aidl_return)); |
| 893 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 894 | if (((_aidl_ret_status) != (::android::OK))) { |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 895 | break; |
| 896 | } |
| 897 | if (!_aidl_status.isOk()) { |
| 898 | break; |
| 899 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 900 | _aidl_ret_status = _aidl_reply->writeUniqueFileDescriptor(_aidl_return); |
| 901 | if (((_aidl_ret_status) != (::android::OK))) { |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 902 | break; |
| 903 | } |
| 904 | } |
| 905 | break; |
| 906 | case Call::TAKESAFILEDESCRIPTORARRAY: |
| 907 | { |
Christopher Wiley | 7cb9c25 | 2016-04-11 11:07:33 -0700 | [diff] [blame] | 908 | ::std::vector<::android::base::unique_fd> in_f; |
| 909 | ::std::vector<::android::base::unique_fd> _aidl_return; |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 910 | if (!(_aidl_data.checkInterface(this))) { |
| 911 | _aidl_ret_status = ::android::BAD_TYPE; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 912 | break; |
| 913 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 914 | _aidl_ret_status = _aidl_data.readUniqueFileDescriptorVector(&in_f); |
| 915 | if (((_aidl_ret_status) != (::android::OK))) { |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 916 | break; |
| 917 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 918 | ::android::binder::Status _aidl_status(TakesAFileDescriptorArray(in_f, &_aidl_return)); |
| 919 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 920 | if (((_aidl_ret_status) != (::android::OK))) { |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 921 | break; |
| 922 | } |
| 923 | if (!_aidl_status.isOk()) { |
| 924 | break; |
| 925 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 926 | _aidl_ret_status = _aidl_reply->writeUniqueFileDescriptorVector(_aidl_return); |
| 927 | if (((_aidl_ret_status) != (::android::OK))) { |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 928 | break; |
| 929 | } |
| 930 | } |
| 931 | break; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 932 | default: |
| 933 | { |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 934 | _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 935 | } |
| 936 | break; |
| 937 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 938 | if (_aidl_ret_status == ::android::UNEXPECTED_NULL) { |
| 939 | _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply); |
Christopher Wiley | 433c8bb | 2015-11-12 14:20:46 -0800 | [diff] [blame] | 940 | } |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 941 | return _aidl_ret_status; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 942 | } |
| 943 | |
| 944 | } // namespace os |
| 945 | |
| 946 | } // namespace android |
| 947 | )"; |
| 948 | |
Martijn Coenen | b06c829 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 949 | const char kExpectedComplexTypeServerWithTraceSourceOutput[] = |
| 950 | R"(#include <android/os/BnComplexTypeInterface.h> |
| 951 | #include <binder/Parcel.h> |
| 952 | |
| 953 | namespace android { |
| 954 | |
| 955 | namespace os { |
| 956 | |
| 957 | ::android::status_t BnComplexTypeInterface::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) { |
| 958 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 959 | switch (_aidl_code) { |
| 960 | case Call::SEND: |
| 961 | { |
| 962 | ::std::unique_ptr<::std::vector<int32_t>> in_goes_in; |
| 963 | ::std::vector<double> in_goes_in_and_out; |
| 964 | ::std::vector<bool> out_goes_out; |
| 965 | ::std::vector<int32_t> _aidl_return; |
| 966 | if (!(_aidl_data.checkInterface(this))) { |
| 967 | _aidl_ret_status = ::android::BAD_TYPE; |
| 968 | break; |
| 969 | } |
| 970 | _aidl_ret_status = _aidl_data.readInt32Vector(&in_goes_in); |
| 971 | if (((_aidl_ret_status) != (::android::OK))) { |
| 972 | break; |
| 973 | } |
| 974 | _aidl_ret_status = _aidl_data.readDoubleVector(&in_goes_in_and_out); |
| 975 | if (((_aidl_ret_status) != (::android::OK))) { |
| 976 | break; |
| 977 | } |
| 978 | _aidl_ret_status = _aidl_data.resizeOutVector(&out_goes_out); |
| 979 | if (((_aidl_ret_status) != (::android::OK))) { |
| 980 | break; |
| 981 | } |
| 982 | atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::Send::cppServer"); |
| 983 | ::android::binder::Status _aidl_status(Send(in_goes_in, &in_goes_in_and_out, &out_goes_out, &_aidl_return)); |
| 984 | atrace_end(ATRACE_TAG_AIDL); |
| 985 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 986 | if (((_aidl_ret_status) != (::android::OK))) { |
| 987 | break; |
| 988 | } |
| 989 | if (!_aidl_status.isOk()) { |
| 990 | break; |
| 991 | } |
| 992 | _aidl_ret_status = _aidl_reply->writeInt32Vector(_aidl_return); |
| 993 | if (((_aidl_ret_status) != (::android::OK))) { |
| 994 | break; |
| 995 | } |
| 996 | _aidl_ret_status = _aidl_reply->writeDoubleVector(in_goes_in_and_out); |
| 997 | if (((_aidl_ret_status) != (::android::OK))) { |
| 998 | break; |
| 999 | } |
| 1000 | _aidl_ret_status = _aidl_reply->writeBoolVector(out_goes_out); |
| 1001 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1002 | break; |
| 1003 | } |
| 1004 | } |
| 1005 | break; |
| 1006 | case Call::PIFF: |
| 1007 | { |
| 1008 | int32_t in_times; |
| 1009 | if (!(_aidl_data.checkInterface(this))) { |
| 1010 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1011 | break; |
| 1012 | } |
| 1013 | _aidl_ret_status = _aidl_data.readInt32(&in_times); |
| 1014 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1015 | break; |
| 1016 | } |
| 1017 | atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::Piff::cppServer"); |
| 1018 | ::android::binder::Status _aidl_status(Piff(in_times)); |
| 1019 | atrace_end(ATRACE_TAG_AIDL); |
| 1020 | } |
| 1021 | break; |
| 1022 | case Call::TAKESABINDER: |
| 1023 | { |
| 1024 | ::android::sp<::foo::IFooType> in_f; |
| 1025 | ::android::sp<::foo::IFooType> _aidl_return; |
| 1026 | if (!(_aidl_data.checkInterface(this))) { |
| 1027 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1028 | break; |
| 1029 | } |
| 1030 | _aidl_ret_status = _aidl_data.readStrongBinder(&in_f); |
| 1031 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1032 | break; |
| 1033 | } |
| 1034 | atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::TakesABinder::cppServer"); |
| 1035 | ::android::binder::Status _aidl_status(TakesABinder(in_f, &_aidl_return)); |
| 1036 | atrace_end(ATRACE_TAG_AIDL); |
| 1037 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1038 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1039 | break; |
| 1040 | } |
| 1041 | if (!_aidl_status.isOk()) { |
| 1042 | break; |
| 1043 | } |
| 1044 | _aidl_ret_status = _aidl_reply->writeStrongBinder(::foo::IFooType::asBinder(_aidl_return)); |
| 1045 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1046 | break; |
| 1047 | } |
| 1048 | } |
| 1049 | break; |
| 1050 | case Call::NULLABLEBINDER: |
| 1051 | { |
| 1052 | ::android::sp<::foo::IFooType> _aidl_return; |
| 1053 | if (!(_aidl_data.checkInterface(this))) { |
| 1054 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1055 | break; |
| 1056 | } |
| 1057 | atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::NullableBinder::cppServer"); |
| 1058 | ::android::binder::Status _aidl_status(NullableBinder(&_aidl_return)); |
| 1059 | atrace_end(ATRACE_TAG_AIDL); |
| 1060 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1061 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1062 | break; |
| 1063 | } |
| 1064 | if (!_aidl_status.isOk()) { |
| 1065 | break; |
| 1066 | } |
| 1067 | _aidl_ret_status = _aidl_reply->writeStrongBinder(::foo::IFooType::asBinder(_aidl_return)); |
| 1068 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1069 | break; |
| 1070 | } |
| 1071 | } |
| 1072 | break; |
| 1073 | case Call::STRINGLISTMETHOD: |
| 1074 | { |
| 1075 | ::std::vector<::android::String16> in_input; |
| 1076 | ::std::vector<::android::String16> out_output; |
| 1077 | ::std::vector<::android::String16> _aidl_return; |
| 1078 | if (!(_aidl_data.checkInterface(this))) { |
| 1079 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1080 | break; |
| 1081 | } |
| 1082 | _aidl_ret_status = _aidl_data.readString16Vector(&in_input); |
| 1083 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1084 | break; |
| 1085 | } |
| 1086 | atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::StringListMethod::cppServer"); |
| 1087 | ::android::binder::Status _aidl_status(StringListMethod(in_input, &out_output, &_aidl_return)); |
| 1088 | atrace_end(ATRACE_TAG_AIDL); |
| 1089 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1090 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1091 | break; |
| 1092 | } |
| 1093 | if (!_aidl_status.isOk()) { |
| 1094 | break; |
| 1095 | } |
| 1096 | _aidl_ret_status = _aidl_reply->writeString16Vector(_aidl_return); |
| 1097 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1098 | break; |
| 1099 | } |
| 1100 | _aidl_ret_status = _aidl_reply->writeString16Vector(out_output); |
| 1101 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1102 | break; |
| 1103 | } |
| 1104 | } |
| 1105 | break; |
| 1106 | case Call::BINDERLISTMETHOD: |
| 1107 | { |
| 1108 | ::std::vector<::android::sp<::android::IBinder>> in_input; |
| 1109 | ::std::vector<::android::sp<::android::IBinder>> out_output; |
| 1110 | ::std::vector<::android::sp<::android::IBinder>> _aidl_return; |
| 1111 | if (!(_aidl_data.checkInterface(this))) { |
| 1112 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1113 | break; |
| 1114 | } |
| 1115 | _aidl_ret_status = _aidl_data.readStrongBinderVector(&in_input); |
| 1116 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1117 | break; |
| 1118 | } |
| 1119 | atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::BinderListMethod::cppServer"); |
| 1120 | ::android::binder::Status _aidl_status(BinderListMethod(in_input, &out_output, &_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->writeStrongBinderVector(_aidl_return); |
| 1130 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1131 | break; |
| 1132 | } |
| 1133 | _aidl_ret_status = _aidl_reply->writeStrongBinderVector(out_output); |
| 1134 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1135 | break; |
| 1136 | } |
| 1137 | } |
| 1138 | break; |
| 1139 | case Call::TAKESAFILEDESCRIPTOR: |
| 1140 | { |
| 1141 | ::android::base::unique_fd in_f; |
| 1142 | ::android::base::unique_fd _aidl_return; |
| 1143 | if (!(_aidl_data.checkInterface(this))) { |
| 1144 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1145 | break; |
| 1146 | } |
| 1147 | _aidl_ret_status = _aidl_data.readUniqueFileDescriptor(&in_f); |
| 1148 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1149 | break; |
| 1150 | } |
| 1151 | atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::TakesAFileDescriptor::cppServer"); |
| 1152 | ::android::binder::Status _aidl_status(TakesAFileDescriptor(in_f, &_aidl_return)); |
| 1153 | atrace_end(ATRACE_TAG_AIDL); |
| 1154 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1155 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1156 | break; |
| 1157 | } |
| 1158 | if (!_aidl_status.isOk()) { |
| 1159 | break; |
| 1160 | } |
| 1161 | _aidl_ret_status = _aidl_reply->writeUniqueFileDescriptor(_aidl_return); |
| 1162 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1163 | break; |
| 1164 | } |
| 1165 | } |
| 1166 | break; |
| 1167 | case Call::TAKESAFILEDESCRIPTORARRAY: |
| 1168 | { |
| 1169 | ::std::vector<::android::base::unique_fd> in_f; |
| 1170 | ::std::vector<::android::base::unique_fd> _aidl_return; |
| 1171 | if (!(_aidl_data.checkInterface(this))) { |
| 1172 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1173 | break; |
| 1174 | } |
| 1175 | _aidl_ret_status = _aidl_data.readUniqueFileDescriptorVector(&in_f); |
| 1176 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1177 | break; |
| 1178 | } |
| 1179 | atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::TakesAFileDescriptorArray::cppServer"); |
| 1180 | ::android::binder::Status _aidl_status(TakesAFileDescriptorArray(in_f, &_aidl_return)); |
| 1181 | atrace_end(ATRACE_TAG_AIDL); |
| 1182 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1183 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1184 | break; |
| 1185 | } |
| 1186 | if (!_aidl_status.isOk()) { |
| 1187 | break; |
| 1188 | } |
| 1189 | _aidl_ret_status = _aidl_reply->writeUniqueFileDescriptorVector(_aidl_return); |
| 1190 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1191 | break; |
| 1192 | } |
| 1193 | } |
| 1194 | break; |
| 1195 | default: |
| 1196 | { |
| 1197 | _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags); |
| 1198 | } |
| 1199 | break; |
| 1200 | } |
| 1201 | if (_aidl_ret_status == ::android::UNEXPECTED_NULL) { |
| 1202 | _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply); |
| 1203 | } |
| 1204 | return _aidl_ret_status; |
| 1205 | } |
| 1206 | |
| 1207 | } // namespace os |
| 1208 | |
| 1209 | } // namespace android |
| 1210 | )"; |
| 1211 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1212 | const char kExpectedComplexTypeInterfaceHeaderOutput[] = |
| 1213 | R"(#ifndef AIDL_GENERATED_ANDROID_OS_I_COMPLEX_TYPE_INTERFACE_H_ |
| 1214 | #define AIDL_GENERATED_ANDROID_OS_I_COMPLEX_TYPE_INTERFACE_H_ |
| 1215 | |
Christopher Wiley | 7cb9c25 | 2016-04-11 11:07:33 -0700 | [diff] [blame] | 1216 | #include <android-base/unique_fd.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1217 | #include <binder/IBinder.h> |
| 1218 | #include <binder/IInterface.h> |
Christopher Wiley | 433c8bb | 2015-11-12 14:20:46 -0800 | [diff] [blame] | 1219 | #include <binder/Status.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1220 | #include <cstdint> |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1221 | #include <foo/IFooType.h> |
Christopher Wiley | 041c8d7 | 2016-08-18 13:52:51 -0700 | [diff] [blame] | 1222 | #include <memory> |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 1223 | #include <utils/String16.h> |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1224 | #include <utils/StrongPointer.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1225 | #include <vector> |
| 1226 | |
| 1227 | namespace android { |
| 1228 | |
| 1229 | namespace os { |
| 1230 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 1231 | class IComplexTypeInterface : public ::android::IInterface { |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1232 | public: |
Christopher Wiley | 11a9d79 | 2016-02-24 17:20:33 -0800 | [diff] [blame] | 1233 | DECLARE_META_INTERFACE(ComplexTypeInterface) |
Christopher Wiley | fd7dc03 | 2016-02-02 17:58:39 -0800 | [diff] [blame] | 1234 | enum : int32_t { |
| 1235 | MY_CONSTANT = 3, |
| 1236 | }; |
Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 1237 | 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; |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 1238 | virtual ::android::binder::Status Piff(int32_t times) = 0; |
| 1239 | virtual ::android::binder::Status TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) = 0; |
Casey Dahlin | ef88bce | 2016-04-15 11:55:30 -0700 | [diff] [blame] | 1240 | virtual ::android::binder::Status NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) = 0; |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 1241 | virtual ::android::binder::Status StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) = 0; |
| 1242 | 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; |
Christopher Wiley | 7cb9c25 | 2016-04-11 11:07:33 -0700 | [diff] [blame] | 1243 | virtual ::android::binder::Status TakesAFileDescriptor(const ::android::base::unique_fd& f, ::android::base::unique_fd* _aidl_return) = 0; |
| 1244 | 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] | 1245 | enum Call { |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 1246 | SEND = ::android::IBinder::FIRST_CALL_TRANSACTION + 0, |
| 1247 | PIFF = ::android::IBinder::FIRST_CALL_TRANSACTION + 1, |
| 1248 | TAKESABINDER = ::android::IBinder::FIRST_CALL_TRANSACTION + 2, |
Casey Dahlin | ef88bce | 2016-04-15 11:55:30 -0700 | [diff] [blame] | 1249 | NULLABLEBINDER = ::android::IBinder::FIRST_CALL_TRANSACTION + 3, |
| 1250 | STRINGLISTMETHOD = ::android::IBinder::FIRST_CALL_TRANSACTION + 4, |
| 1251 | BINDERLISTMETHOD = ::android::IBinder::FIRST_CALL_TRANSACTION + 5, |
| 1252 | TAKESAFILEDESCRIPTOR = ::android::IBinder::FIRST_CALL_TRANSACTION + 6, |
| 1253 | TAKESAFILEDESCRIPTORARRAY = ::android::IBinder::FIRST_CALL_TRANSACTION + 7, |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1254 | }; |
| 1255 | }; // class IComplexTypeInterface |
| 1256 | |
| 1257 | } // namespace os |
| 1258 | |
| 1259 | } // namespace android |
| 1260 | |
Christopher Wiley | 11a9d79 | 2016-02-24 17:20:33 -0800 | [diff] [blame] | 1261 | #endif // AIDL_GENERATED_ANDROID_OS_I_COMPLEX_TYPE_INTERFACE_H_ |
| 1262 | )"; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1263 | |
| 1264 | const char kExpectedComplexTypeInterfaceSourceOutput[] = |
| 1265 | R"(#include <android/os/IComplexTypeInterface.h> |
| 1266 | #include <android/os/BpComplexTypeInterface.h> |
| 1267 | |
| 1268 | namespace android { |
| 1269 | |
| 1270 | namespace os { |
| 1271 | |
Christopher Wiley | 11a9d79 | 2016-02-24 17:20:33 -0800 | [diff] [blame] | 1272 | IMPLEMENT_META_INTERFACE(ComplexTypeInterface, "android.os.IComplexTypeInterface") |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1273 | |
| 1274 | } // namespace os |
| 1275 | |
| 1276 | } // namespace android |
| 1277 | )"; |
| 1278 | |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 1279 | } // namespace |
| 1280 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1281 | class ASTTest : public ::testing::Test { |
Christopher Wiley | 0c732db | 2015-09-29 14:36:44 -0700 | [diff] [blame] | 1282 | protected: |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1283 | ASTTest(string file_path, string file_contents) |
| 1284 | : file_path_(file_path), |
Christopher Wiley | 5679952 | 2015-10-31 10:17:04 -0700 | [diff] [blame] | 1285 | file_contents_(file_contents) { |
| 1286 | types_.Init(); |
| 1287 | } |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1288 | |
Christopher Wiley | 90be4e3 | 2015-10-20 14:55:25 -0700 | [diff] [blame] | 1289 | unique_ptr<AidlInterface> Parse() { |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1290 | io_delegate_.SetFileContents(file_path_, file_contents_); |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 1291 | |
Christopher Wiley | 90be4e3 | 2015-10-20 14:55:25 -0700 | [diff] [blame] | 1292 | unique_ptr<AidlInterface> ret; |
| 1293 | std::vector<std::unique_ptr<AidlImport>> imports; |
Christopher Wiley | 632801d | 2015-11-05 14:15:49 -0800 | [diff] [blame] | 1294 | AidlError err = ::android::aidl::internals::load_and_validate_aidl( |
Christopher Wiley | 90be4e3 | 2015-10-20 14:55:25 -0700 | [diff] [blame] | 1295 | {}, // no preprocessed files |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1296 | {"."}, |
| 1297 | file_path_, |
Martijn Coenen | b06c829 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 1298 | false, // generate_traces |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1299 | io_delegate_, |
| 1300 | &types_, |
Christopher Wiley | 90be4e3 | 2015-10-20 14:55:25 -0700 | [diff] [blame] | 1301 | &ret, |
| 1302 | &imports); |
Christopher Wiley | 4a2884b | 2015-10-07 11:27:45 -0700 | [diff] [blame] | 1303 | |
Christopher Wiley | 632801d | 2015-11-05 14:15:49 -0800 | [diff] [blame] | 1304 | if (err != AidlError::OK) |
Casey Dahlin | 2cc9316 | 2015-10-02 16:14:17 -0700 | [diff] [blame] | 1305 | return nullptr; |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 1306 | |
Casey Dahlin | 2cc9316 | 2015-10-02 16:14:17 -0700 | [diff] [blame] | 1307 | return ret; |
Christopher Wiley | 90be4e3 | 2015-10-20 14:55:25 -0700 | [diff] [blame] | 1308 | } |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 1309 | |
Christopher Wiley | 0c732db | 2015-09-29 14:36:44 -0700 | [diff] [blame] | 1310 | void Compare(Document* doc, const char* expected) { |
| 1311 | string output; |
| 1312 | unique_ptr<CodeWriter> cw = GetStringWriter(&output); |
| 1313 | |
| 1314 | doc->Write(cw.get()); |
| 1315 | |
Casey Dahlin | 80ada3d | 2015-10-20 20:33:56 -0700 | [diff] [blame] | 1316 | if (expected == output) { |
| 1317 | return; // Success |
| 1318 | } |
| 1319 | |
| 1320 | test::PrintDiff(expected, output); |
| 1321 | FAIL() << "Document contents did not match expected contents"; |
Christopher Wiley | 0c732db | 2015-09-29 14:36:44 -0700 | [diff] [blame] | 1322 | } |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1323 | |
| 1324 | const string file_path_; |
| 1325 | const string file_contents_; |
| 1326 | FakeIoDelegate io_delegate_; |
| 1327 | TypeNamespace types_; |
Christopher Wiley | 0c732db | 2015-09-29 14:36:44 -0700 | [diff] [blame] | 1328 | }; |
| 1329 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1330 | class ComplexTypeInterfaceASTTest : public ASTTest { |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1331 | public: |
| 1332 | ComplexTypeInterfaceASTTest() |
| 1333 | : ASTTest("android/os/IComplexTypeInterface.aidl", |
| 1334 | kComplexTypeInterfaceAIDL) { |
| 1335 | io_delegate_.SetFileContents("foo/IFooType.aidl", |
| 1336 | "package foo; interface IFooType {}"); |
| 1337 | } |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1338 | }; |
| 1339 | |
| 1340 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesClientHeader) { |
| 1341 | unique_ptr<AidlInterface> interface = Parse(); |
| 1342 | ASSERT_NE(interface, nullptr); |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1343 | unique_ptr<Document> doc = internals::BuildClientHeader(types_, *interface); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1344 | Compare(doc.get(), kExpectedComplexTypeClientHeaderOutput); |
| 1345 | } |
| 1346 | |
| 1347 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesClientSource) { |
| 1348 | unique_ptr<AidlInterface> interface = Parse(); |
| 1349 | ASSERT_NE(interface, nullptr); |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1350 | unique_ptr<Document> doc = internals::BuildClientSource(types_, *interface); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1351 | Compare(doc.get(), kExpectedComplexTypeClientSourceOutput); |
| 1352 | } |
| 1353 | |
Martijn Coenen | b06c829 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 1354 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesClientSourceWithTrace) { |
| 1355 | unique_ptr<AidlInterface> interface = Parse(); |
| 1356 | ASSERT_NE(interface, nullptr); |
| 1357 | interface->SetGenerateTraces(true); |
| 1358 | unique_ptr<Document> doc = internals::BuildClientSource(types_, *interface); |
| 1359 | Compare(doc.get(), kExpectedComplexTypeClientWithTraceSourceOutput); |
| 1360 | } |
| 1361 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1362 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesServerHeader) { |
| 1363 | unique_ptr<AidlInterface> interface = Parse(); |
| 1364 | ASSERT_NE(interface, nullptr); |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1365 | unique_ptr<Document> doc = internals::BuildServerHeader(types_, *interface); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1366 | Compare(doc.get(), kExpectedComplexTypeServerHeaderOutput); |
| 1367 | } |
| 1368 | |
| 1369 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesServerSource) { |
| 1370 | unique_ptr<AidlInterface> interface = Parse(); |
| 1371 | ASSERT_NE(interface, nullptr); |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1372 | unique_ptr<Document> doc = internals::BuildServerSource(types_, *interface); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1373 | Compare(doc.get(), kExpectedComplexTypeServerSourceOutput); |
| 1374 | } |
| 1375 | |
Martijn Coenen | b06c829 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 1376 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesServerSourceWithTrace) { |
| 1377 | unique_ptr<AidlInterface> interface = Parse(); |
| 1378 | ASSERT_NE(interface, nullptr); |
| 1379 | interface->SetGenerateTraces(true); |
| 1380 | unique_ptr<Document> doc = internals::BuildServerSource(types_, *interface); |
| 1381 | Compare(doc.get(), kExpectedComplexTypeServerWithTraceSourceOutput); |
| 1382 | } |
| 1383 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1384 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesInterfaceHeader) { |
| 1385 | unique_ptr<AidlInterface> interface = Parse(); |
| 1386 | ASSERT_NE(interface, nullptr); |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1387 | unique_ptr<Document> doc = internals::BuildInterfaceHeader(types_, *interface); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1388 | Compare(doc.get(), kExpectedComplexTypeInterfaceHeaderOutput); |
| 1389 | } |
| 1390 | |
| 1391 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesInterfaceSource) { |
| 1392 | unique_ptr<AidlInterface> interface = Parse(); |
| 1393 | ASSERT_NE(interface, nullptr); |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1394 | unique_ptr<Document> doc = internals::BuildInterfaceSource(types_, *interface); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1395 | Compare(doc.get(), kExpectedComplexTypeInterfaceSourceOutput); |
Christopher Wiley | 1dd458d | 2015-09-30 11:05:52 -0700 | [diff] [blame] | 1396 | } |
| 1397 | |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1398 | namespace test_io_handling { |
| 1399 | |
| 1400 | const char kInputPath[] = "a/IFoo.aidl"; |
| 1401 | const char kOutputPath[] = "output.cpp"; |
| 1402 | const char kHeaderDir[] = "headers"; |
| 1403 | const char kInterfaceHeaderRelPath[] = "a/IFoo.h"; |
| 1404 | |
| 1405 | } // namespace test_io_handling |
| 1406 | |
| 1407 | class IoErrorHandlingTest : public ASTTest { |
| 1408 | public: |
| 1409 | IoErrorHandlingTest () |
| 1410 | : ASTTest(test_io_handling::kInputPath, |
| 1411 | "package a; interface IFoo {}"), |
| 1412 | options_(GetOptions()) {} |
| 1413 | |
| 1414 | const unique_ptr<CppOptions> options_; |
| 1415 | |
| 1416 | private: |
| 1417 | static unique_ptr<CppOptions> GetOptions() { |
| 1418 | using namespace test_io_handling; |
| 1419 | |
| 1420 | const int argc = 4; |
| 1421 | const char* cmdline[argc] = { |
| 1422 | "aidl-cpp", kInputPath, kHeaderDir, kOutputPath |
| 1423 | }; |
| 1424 | return CppOptions::Parse(argc, cmdline); |
| 1425 | } |
| 1426 | }; |
| 1427 | |
| 1428 | TEST_F(IoErrorHandlingTest, GenerateCorrectlyAbsentErrors) { |
| 1429 | // Confirm that this is working correctly without I/O problems. |
| 1430 | const unique_ptr<AidlInterface> interface = Parse(); |
| 1431 | ASSERT_NE(interface, nullptr); |
| 1432 | ASSERT_TRUE(GenerateCpp(*options_, types_, *interface, io_delegate_)); |
| 1433 | } |
| 1434 | |
| 1435 | TEST_F(IoErrorHandlingTest, HandlesBadHeaderWrite) { |
| 1436 | using namespace test_io_handling; |
| 1437 | const unique_ptr<AidlInterface> interface = Parse(); |
| 1438 | ASSERT_NE(interface, nullptr); |
| 1439 | |
| 1440 | // Simulate issues closing the interface header. |
| 1441 | const string header_path = |
| 1442 | StringPrintf("%s%c%s", kHeaderDir, OS_PATH_SEPARATOR, |
| 1443 | kInterfaceHeaderRelPath); |
| 1444 | io_delegate_.AddBrokenFilePath(header_path); |
| 1445 | ASSERT_FALSE(GenerateCpp(*options_, types_, *interface, io_delegate_)); |
| 1446 | // We should never attempt to write the C++ file if we fail writing headers. |
| 1447 | ASSERT_FALSE(io_delegate_.GetWrittenContents(kOutputPath, nullptr)); |
| 1448 | // We should remove partial results. |
| 1449 | ASSERT_TRUE(io_delegate_.PathWasRemoved(header_path)); |
| 1450 | } |
| 1451 | |
| 1452 | TEST_F(IoErrorHandlingTest, HandlesBadCppWrite) { |
| 1453 | using test_io_handling::kOutputPath; |
| 1454 | const unique_ptr<AidlInterface> interface = Parse(); |
| 1455 | ASSERT_NE(interface, nullptr); |
| 1456 | |
| 1457 | // Simulate issues closing the cpp file. |
| 1458 | io_delegate_.AddBrokenFilePath(kOutputPath); |
| 1459 | ASSERT_FALSE(GenerateCpp(*options_, types_, *interface, io_delegate_)); |
| 1460 | // We should remove partial results. |
| 1461 | ASSERT_TRUE(io_delegate_.PathWasRemoved(kOutputPath)); |
| 1462 | } |
| 1463 | |
Christopher Wiley | f944e79 | 2015-09-29 10:00:46 -0700 | [diff] [blame] | 1464 | } // namespace cpp |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 1465 | } // namespace aidl |
| 1466 | } // namespace android |