1 /*
2  * Copyright (C) 2018 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 <aidl/test_package/BnTest.h>
18 
19 #include <stdio.h>
20 #include <unistd.h>
21 #include <condition_variable>
22 #include <mutex>
23 
24 #include "utilities.h"
25 
26 using Bar = ::aidl::test_package::Bar;
27 using ByteEnum = ::aidl::test_package::ByteEnum;
28 using Foo = ::aidl::test_package::Foo;
29 using IEmpty = ::aidl::test_package::IEmpty;
30 using IntEnum = ::aidl::test_package::IntEnum;
31 using LongEnum = ::aidl::test_package::LongEnum;
32 using RegularPolygon = ::aidl::test_package::RegularPolygon;
33 
34 class MyTest : public ::aidl::test_package::BnTest,
35                public ThisShouldBeDestroyed {
36  public:
dump(int fd,const char ** args,uint32_t numArgs)37   binder_status_t dump(int fd, const char** args, uint32_t numArgs) override {
38     for (uint32_t i = 0; i < numArgs; i++) {
39       dprintf(fd, "%s", args[i]);
40     }
41     fsync(fd);
42     return STATUS_OK;
43   }
44 
GetName(std::string * _aidl_return)45   ::ndk::ScopedAStatus GetName(std::string* _aidl_return) override {
46     *_aidl_return = "CPP";
47     return ::ndk::ScopedAStatus(AStatus_newOk());
48   }
TestVoidReturn()49   ::ndk::ScopedAStatus TestVoidReturn() override {
50     return ::ndk::ScopedAStatus(AStatus_newOk());
51   }
TestOneway()52   ::ndk::ScopedAStatus TestOneway() override {
53     // This return code should be ignored since it is oneway.
54     return ::ndk::ScopedAStatus(AStatus_fromStatus(STATUS_UNKNOWN_ERROR));
55   }
56 
GiveMeMyCallingPid(int32_t * _aidl_return)57   ::ndk::ScopedAStatus GiveMeMyCallingPid(int32_t* _aidl_return) override {
58     *_aidl_return = AIBinder_getCallingPid();
59     return ::ndk::ScopedAStatus(AStatus_newOk());
60   }
GiveMeMyCallingUid(int32_t * _aidl_return)61   ::ndk::ScopedAStatus GiveMeMyCallingUid(int32_t* _aidl_return) override {
62     *_aidl_return = AIBinder_getCallingUid();
63     return ::ndk::ScopedAStatus(AStatus_newOk());
64   }
65 
66  private:
67   bool mCached = false;
68   std::mutex mCachedMutex;
69   std::condition_variable mCachedCondition;
70   int mCachedPid = -1;
71   int mCachedUid = -1;
72 
73  public:
CacheCallingInfoFromOneway()74   ::ndk::ScopedAStatus CacheCallingInfoFromOneway() override {
75     std::unique_lock<std::mutex> l(mCachedMutex);
76     mCached = true;
77     mCachedPid = AIBinder_getCallingPid();
78     mCachedUid = AIBinder_getCallingUid();
79     mCachedCondition.notify_all();
80 
81     return ::ndk::ScopedAStatus(AStatus_newOk());
82   }
GiveMeMyCallingPidFromOneway(int32_t * _aidl_return)83   ::ndk::ScopedAStatus GiveMeMyCallingPidFromOneway(
84       int32_t* _aidl_return) override {
85     std::unique_lock<std::mutex> l(mCachedMutex);
86     mCachedCondition.wait(l, [&] { return mCached; });
87 
88     *_aidl_return = mCachedPid;
89     return ::ndk::ScopedAStatus(AStatus_newOk());
90   }
GiveMeMyCallingUidFromOneway(int32_t * _aidl_return)91   ::ndk::ScopedAStatus GiveMeMyCallingUidFromOneway(
92       int32_t* _aidl_return) override {
93     std::unique_lock<std::mutex> l(mCachedMutex);
94     mCachedCondition.wait(l, [&] { return mCached; });
95 
96     *_aidl_return = mCachedUid;
97     return ::ndk::ScopedAStatus(AStatus_newOk());
98   }
RepeatInt(int32_t in_value,int32_t * _aidl_return)99   ::ndk::ScopedAStatus RepeatInt(int32_t in_value,
100                                  int32_t* _aidl_return) override {
101     *_aidl_return = in_value;
102     return ::ndk::ScopedAStatus(AStatus_newOk());
103   }
RepeatLong(int64_t in_value,int64_t * _aidl_return)104   ::ndk::ScopedAStatus RepeatLong(int64_t in_value,
105                                   int64_t* _aidl_return) override {
106     *_aidl_return = in_value;
107     return ::ndk::ScopedAStatus(AStatus_newOk());
108   }
RepeatFloat(float in_value,float * _aidl_return)109   ::ndk::ScopedAStatus RepeatFloat(float in_value,
110                                    float* _aidl_return) override {
111     *_aidl_return = in_value;
112     return ::ndk::ScopedAStatus(AStatus_newOk());
113   }
RepeatDouble(double in_value,double * _aidl_return)114   ::ndk::ScopedAStatus RepeatDouble(double in_value,
115                                     double* _aidl_return) override {
116     *_aidl_return = in_value;
117     return ::ndk::ScopedAStatus(AStatus_newOk());
118   }
RepeatBoolean(bool in_value,bool * _aidl_return)119   ::ndk::ScopedAStatus RepeatBoolean(bool in_value,
120                                      bool* _aidl_return) override {
121     *_aidl_return = in_value;
122     return ::ndk::ScopedAStatus(AStatus_newOk());
123   }
RepeatChar(char16_t in_value,char16_t * _aidl_return)124   ::ndk::ScopedAStatus RepeatChar(char16_t in_value,
125                                   char16_t* _aidl_return) override {
126     *_aidl_return = in_value;
127     return ::ndk::ScopedAStatus(AStatus_newOk());
128   }
RepeatByte(int8_t in_value,int8_t * _aidl_return)129   ::ndk::ScopedAStatus RepeatByte(int8_t in_value,
130                                   int8_t* _aidl_return) override {
131     *_aidl_return = in_value;
132     return ::ndk::ScopedAStatus(AStatus_newOk());
133   }
RepeatByteEnum(ByteEnum in_value,ByteEnum * _aidl_return)134   ::ndk::ScopedAStatus RepeatByteEnum(ByteEnum in_value, ByteEnum* _aidl_return) override {
135     *_aidl_return = in_value;
136     return ::ndk::ScopedAStatus(AStatus_newOk());
137   }
RepeatIntEnum(IntEnum in_value,IntEnum * _aidl_return)138   ::ndk::ScopedAStatus RepeatIntEnum(IntEnum in_value, IntEnum* _aidl_return) override {
139     *_aidl_return = in_value;
140     return ::ndk::ScopedAStatus(AStatus_newOk());
141   }
RepeatLongEnum(LongEnum in_value,LongEnum * _aidl_return)142   ::ndk::ScopedAStatus RepeatLongEnum(LongEnum in_value, LongEnum* _aidl_return) override {
143     *_aidl_return = in_value;
144     return ::ndk::ScopedAStatus(AStatus_newOk());
145   }
RepeatBinder(const::ndk::SpAIBinder & in_value,::ndk::SpAIBinder * _aidl_return)146   ::ndk::ScopedAStatus RepeatBinder(const ::ndk::SpAIBinder& in_value,
147                                     ::ndk::SpAIBinder* _aidl_return) override {
148     *_aidl_return = in_value;
149     return ::ndk::ScopedAStatus(AStatus_newOk());
150   }
RepeatNullableBinder(const::ndk::SpAIBinder & in_value,::ndk::SpAIBinder * _aidl_return)151   ::ndk::ScopedAStatus RepeatNullableBinder(
152       const ::ndk::SpAIBinder& in_value,
153       ::ndk::SpAIBinder* _aidl_return) override {
154     *_aidl_return = in_value;
155     return ::ndk::ScopedAStatus(AStatus_newOk());
156   }
RepeatInterface(const std::shared_ptr<IEmpty> & in_value,std::shared_ptr<IEmpty> * _aidl_return)157   ::ndk::ScopedAStatus RepeatInterface(
158       const std::shared_ptr<IEmpty>& in_value,
159       std::shared_ptr<IEmpty>* _aidl_return) override {
160     *_aidl_return = in_value;
161     return ::ndk::ScopedAStatus(AStatus_newOk());
162   }
RepeatNullableInterface(const std::shared_ptr<IEmpty> & in_value,std::shared_ptr<IEmpty> * _aidl_return)163   ::ndk::ScopedAStatus RepeatNullableInterface(
164       const std::shared_ptr<IEmpty>& in_value,
165       std::shared_ptr<IEmpty>* _aidl_return) override {
166     *_aidl_return = in_value;
167     return ::ndk::ScopedAStatus(AStatus_newOk());
168   }
RepeatFd(const::ndk::ScopedFileDescriptor & in_value,::ndk::ScopedFileDescriptor * _aidl_return)169   ::ndk::ScopedAStatus RepeatFd(
170       const ::ndk::ScopedFileDescriptor& in_value,
171       ::ndk::ScopedFileDescriptor* _aidl_return) override {
172     _aidl_return->set(dup(in_value.get()));
173     return ::ndk::ScopedAStatus(AStatus_newOk());
174   }
175 
RepeatFdArray(const std::vector<::ndk::ScopedFileDescriptor> & in_input,std::vector<::ndk::ScopedFileDescriptor> * out_repeated,std::vector<::ndk::ScopedFileDescriptor> * _aidl_return)176   ::ndk::ScopedAStatus RepeatFdArray(
177       const std::vector<::ndk::ScopedFileDescriptor>& in_input,
178       std::vector<::ndk::ScopedFileDescriptor>* out_repeated,
179       std::vector<::ndk::ScopedFileDescriptor>* _aidl_return) override {
180     out_repeated->clear();
181     for (auto& fd : in_input) {
182       out_repeated->emplace_back(dup(fd.get()));
183       _aidl_return->emplace_back(dup(fd.get()));
184     }
185     return ::ndk::ScopedAStatus(AStatus_newOk());
186   }
187 
RepeatNullableFd(const::ndk::ScopedFileDescriptor & in_value,::ndk::ScopedFileDescriptor * _aidl_return)188   ::ndk::ScopedAStatus RepeatNullableFd(
189       const ::ndk::ScopedFileDescriptor& in_value,
190       ::ndk::ScopedFileDescriptor* _aidl_return) override {
191     _aidl_return->set(dup(in_value.get()));
192     return ::ndk::ScopedAStatus(AStatus_newOk());
193   }
RepeatString(const std::string & in_value,std::string * _aidl_return)194   ::ndk::ScopedAStatus RepeatString(const std::string& in_value,
195                                     std::string* _aidl_return) override {
196     *_aidl_return = in_value;
197     return ::ndk::ScopedAStatus(AStatus_newOk());
198   }
RepeatNullableString(const std::optional<std::string> & in_value,std::optional<std::string> * _aidl_return)199   ::ndk::ScopedAStatus RepeatNullableString(
200       const std::optional<std::string>& in_value,
201       std::optional<std::string>* _aidl_return) override {
202     *_aidl_return = in_value;
203     return ::ndk::ScopedAStatus(AStatus_newOk());
204   }
RepeatPolygon(const RegularPolygon & in_value,RegularPolygon * _aidl_return)205   ::ndk::ScopedAStatus RepeatPolygon(const RegularPolygon& in_value,
206                                      RegularPolygon* _aidl_return) override {
207     *_aidl_return = in_value;
208     return ::ndk::ScopedAStatus(AStatus_newOk());
209   }
RepeatNullablePolygon(const std::optional<RegularPolygon> & in_value,std::optional<RegularPolygon> * _aidl_return)210   ::ndk::ScopedAStatus RepeatNullablePolygon(const std::optional<RegularPolygon>& in_value,
211                                              std::optional<RegularPolygon>* _aidl_return) override {
212     *_aidl_return = in_value;
213     return ::ndk::ScopedAStatus(AStatus_newOk());
214   }
RenamePolygon(RegularPolygon * value,const std::string & newName)215   ::ndk::ScopedAStatus RenamePolygon(RegularPolygon* value,
216                                      const std::string& newName) override {
217     value->name = newName;
218     return ::ndk::ScopedAStatus(AStatus_newOk());
219   }
RepeatBooleanArray(const std::vector<bool> & in_value,std::vector<bool> * out_repeated,std::vector<bool> * _aidl_return)220   ::ndk::ScopedAStatus RepeatBooleanArray(
221       const std::vector<bool>& in_value, std::vector<bool>* out_repeated,
222       std::vector<bool>* _aidl_return) override {
223     *out_repeated = in_value;
224     *_aidl_return = in_value;
225     return ::ndk::ScopedAStatus(AStatus_newOk());
226   }
RepeatByteArray(const std::vector<uint8_t> & in_value,std::vector<uint8_t> * out_repeated,std::vector<uint8_t> * _aidl_return)227   ::ndk::ScopedAStatus RepeatByteArray(const std::vector<uint8_t>& in_value,
228                                        std::vector<uint8_t>* out_repeated,
229                                        std::vector<uint8_t>* _aidl_return) override {
230     *out_repeated = in_value;
231     *_aidl_return = in_value;
232     return ::ndk::ScopedAStatus(AStatus_newOk());
233   }
RepeatCharArray(const std::vector<char16_t> & in_value,std::vector<char16_t> * out_repeated,std::vector<char16_t> * _aidl_return)234   ::ndk::ScopedAStatus RepeatCharArray(
235       const std::vector<char16_t>& in_value,
236       std::vector<char16_t>* out_repeated,
237       std::vector<char16_t>* _aidl_return) override {
238     *out_repeated = in_value;
239     *_aidl_return = in_value;
240     return ::ndk::ScopedAStatus(AStatus_newOk());
241   }
RepeatIntArray(const std::vector<int32_t> & in_value,std::vector<int32_t> * out_repeated,std::vector<int32_t> * _aidl_return)242   ::ndk::ScopedAStatus RepeatIntArray(
243       const std::vector<int32_t>& in_value, std::vector<int32_t>* out_repeated,
244       std::vector<int32_t>* _aidl_return) override {
245     *out_repeated = in_value;
246     *_aidl_return = in_value;
247     return ::ndk::ScopedAStatus(AStatus_newOk());
248   }
RepeatLongArray(const std::vector<int64_t> & in_value,std::vector<int64_t> * out_repeated,std::vector<int64_t> * _aidl_return)249   ::ndk::ScopedAStatus RepeatLongArray(
250       const std::vector<int64_t>& in_value, std::vector<int64_t>* out_repeated,
251       std::vector<int64_t>* _aidl_return) override {
252     *out_repeated = in_value;
253     *_aidl_return = in_value;
254     return ::ndk::ScopedAStatus(AStatus_newOk());
255   }
RepeatFloatArray(const std::vector<float> & in_value,std::vector<float> * out_repeated,std::vector<float> * _aidl_return)256   ::ndk::ScopedAStatus RepeatFloatArray(
257       const std::vector<float>& in_value, std::vector<float>* out_repeated,
258       std::vector<float>* _aidl_return) override {
259     *out_repeated = in_value;
260     *_aidl_return = in_value;
261     return ::ndk::ScopedAStatus(AStatus_newOk());
262   }
RepeatDoubleArray(const std::vector<double> & in_value,std::vector<double> * out_repeated,std::vector<double> * _aidl_return)263   ::ndk::ScopedAStatus RepeatDoubleArray(
264       const std::vector<double>& in_value, std::vector<double>* out_repeated,
265       std::vector<double>* _aidl_return) override {
266     *out_repeated = in_value;
267     *_aidl_return = in_value;
268     return ::ndk::ScopedAStatus(AStatus_newOk());
269   }
RepeatByteEnumArray(const std::vector<ByteEnum> & in_value,std::vector<ByteEnum> * out_repeated,std::vector<ByteEnum> * _aidl_return)270   ::ndk::ScopedAStatus RepeatByteEnumArray(const std::vector<ByteEnum>& in_value,
271                                            std::vector<ByteEnum>* out_repeated,
272                                            std::vector<ByteEnum>* _aidl_return) override {
273     *out_repeated = in_value;
274     *_aidl_return = in_value;
275     return ::ndk::ScopedAStatus(AStatus_newOk());
276   }
RepeatIntEnumArray(const std::vector<IntEnum> & in_value,std::vector<IntEnum> * out_repeated,std::vector<IntEnum> * _aidl_return)277   ::ndk::ScopedAStatus RepeatIntEnumArray(const std::vector<IntEnum>& in_value,
278                                           std::vector<IntEnum>* out_repeated,
279                                           std::vector<IntEnum>* _aidl_return) override {
280     *out_repeated = in_value;
281     *_aidl_return = in_value;
282     return ::ndk::ScopedAStatus(AStatus_newOk());
283   }
RepeatLongEnumArray(const std::vector<LongEnum> & in_value,std::vector<LongEnum> * out_repeated,std::vector<LongEnum> * _aidl_return)284   ::ndk::ScopedAStatus RepeatLongEnumArray(const std::vector<LongEnum>& in_value,
285                                            std::vector<LongEnum>* out_repeated,
286                                            std::vector<LongEnum>* _aidl_return) override {
287     *out_repeated = in_value;
288     *_aidl_return = in_value;
289     return ::ndk::ScopedAStatus(AStatus_newOk());
290   }
RepeatStringArray(const std::vector<std::string> & in_value,std::vector<std::string> * out_repeated,std::vector<std::string> * _aidl_return)291   ::ndk::ScopedAStatus RepeatStringArray(
292       const std::vector<std::string>& in_value,
293       std::vector<std::string>* out_repeated,
294       std::vector<std::string>* _aidl_return) override {
295     *out_repeated = in_value;
296     *_aidl_return = in_value;
297     return ::ndk::ScopedAStatus(AStatus_newOk());
298   }
RepeatRegularPolygonArray(const std::vector<RegularPolygon> & in_value,std::vector<RegularPolygon> * out_repeated,std::vector<RegularPolygon> * _aidl_return)299   ::ndk::ScopedAStatus RepeatRegularPolygonArray(
300       const std::vector<RegularPolygon>& in_value, std::vector<RegularPolygon>* out_repeated,
301       std::vector<RegularPolygon>* _aidl_return) override {
302     *out_repeated = in_value;
303     *_aidl_return = in_value;
304     return ::ndk::ScopedAStatus(AStatus_newOk());
305   }
306 
Repeat2StringList(const std::vector<std::string> & in_input,std::vector<std::string> * out_repeated,std::vector<std::string> * _aidl_return)307   ::ndk::ScopedAStatus Repeat2StringList(const std::vector<std::string>& in_input,
308                                          std::vector<std::string>* out_repeated,
309                                          std::vector<std::string>* _aidl_return) override {
310     *out_repeated = std::vector<std::string>();
311     *_aidl_return = std::vector<std::string>();
312     for (int i = 0; i < 2; i++) {
313       for (auto& s : in_input) {
314         out_repeated->emplace_back(s);
315         _aidl_return->emplace_back(s);
316       }
317     }
318 
319     return ::ndk::ScopedAStatus(AStatus_newOk());
320   }
321 
Repeat2RegularPolygonList(const std::vector<::aidl::test_package::RegularPolygon> & in_input,std::vector<::aidl::test_package::RegularPolygon> * out_repeated,std::vector<::aidl::test_package::RegularPolygon> * _aidl_return)322   ::ndk::ScopedAStatus Repeat2RegularPolygonList(
323       const std::vector<::aidl::test_package::RegularPolygon>& in_input,
324       std::vector<::aidl::test_package::RegularPolygon>* out_repeated,
325       std::vector<::aidl::test_package::RegularPolygon>* _aidl_return) override {
326     *out_repeated = std::vector<::aidl::test_package::RegularPolygon>();
327     *_aidl_return = std::vector<::aidl::test_package::RegularPolygon>();
328     for (int i = 0; i < 2; i++) {
329       for (auto& s : in_input) {
330         out_repeated->emplace_back(s);
331         _aidl_return->emplace_back(s);
332       }
333     }
334     return ::ndk::ScopedAStatus(AStatus_newOk());
335   }
336 
RepeatNullableBooleanArray(const std::optional<std::vector<bool>> & in_value,std::optional<std::vector<bool>> * _aidl_return)337   ::ndk::ScopedAStatus RepeatNullableBooleanArray(
338       const std::optional<std::vector<bool>>& in_value,
339       std::optional<std::vector<bool>>* _aidl_return) override {
340     *_aidl_return = in_value;
341     return ::ndk::ScopedAStatus(AStatus_newOk());
342   }
RepeatNullableByteArray(const std::optional<std::vector<uint8_t>> & in_value,std::optional<std::vector<uint8_t>> * _aidl_return)343   ::ndk::ScopedAStatus RepeatNullableByteArray(
344       const std::optional<std::vector<uint8_t>>& in_value,
345       std::optional<std::vector<uint8_t>>* _aidl_return) override {
346     *_aidl_return = in_value;
347     return ::ndk::ScopedAStatus(AStatus_newOk());
348   }
RepeatNullableCharArray(const std::optional<std::vector<char16_t>> & in_value,std::optional<std::vector<char16_t>> * _aidl_return)349   ::ndk::ScopedAStatus RepeatNullableCharArray(
350       const std::optional<std::vector<char16_t>>& in_value,
351       std::optional<std::vector<char16_t>>* _aidl_return) override {
352     *_aidl_return = in_value;
353     return ::ndk::ScopedAStatus(AStatus_newOk());
354   }
RepeatNullableIntArray(const std::optional<std::vector<int32_t>> & in_value,std::optional<std::vector<int32_t>> * _aidl_return)355   ::ndk::ScopedAStatus RepeatNullableIntArray(
356       const std::optional<std::vector<int32_t>>& in_value,
357       std::optional<std::vector<int32_t>>* _aidl_return) override {
358     *_aidl_return = in_value;
359     return ::ndk::ScopedAStatus(AStatus_newOk());
360   }
RepeatNullableLongArray(const std::optional<std::vector<int64_t>> & in_value,std::optional<std::vector<int64_t>> * _aidl_return)361   ::ndk::ScopedAStatus RepeatNullableLongArray(
362       const std::optional<std::vector<int64_t>>& in_value,
363       std::optional<std::vector<int64_t>>* _aidl_return) override {
364     *_aidl_return = in_value;
365     return ::ndk::ScopedAStatus(AStatus_newOk());
366   }
RepeatNullableFloatArray(const std::optional<std::vector<float>> & in_value,std::optional<std::vector<float>> * _aidl_return)367   ::ndk::ScopedAStatus RepeatNullableFloatArray(
368       const std::optional<std::vector<float>>& in_value,
369       std::optional<std::vector<float>>* _aidl_return) override {
370     *_aidl_return = in_value;
371     return ::ndk::ScopedAStatus(AStatus_newOk());
372   }
RepeatNullableDoubleArray(const std::optional<std::vector<double>> & in_value,std::optional<std::vector<double>> * _aidl_return)373   ::ndk::ScopedAStatus RepeatNullableDoubleArray(
374       const std::optional<std::vector<double>>& in_value,
375       std::optional<std::vector<double>>* _aidl_return) override {
376     *_aidl_return = in_value;
377     return ::ndk::ScopedAStatus(AStatus_newOk());
378   }
RepeatNullableByteEnumArray(const std::optional<std::vector<ByteEnum>> & in_value,std::optional<std::vector<ByteEnum>> * _aidl_return)379   ::ndk::ScopedAStatus RepeatNullableByteEnumArray(
380       const std::optional<std::vector<ByteEnum>>& in_value,
381       std::optional<std::vector<ByteEnum>>* _aidl_return) override {
382     *_aidl_return = in_value;
383     return ::ndk::ScopedAStatus(AStatus_newOk());
384   }
RepeatNullableIntEnumArray(const std::optional<std::vector<IntEnum>> & in_value,std::optional<std::vector<IntEnum>> * _aidl_return)385   ::ndk::ScopedAStatus RepeatNullableIntEnumArray(
386       const std::optional<std::vector<IntEnum>>& in_value,
387       std::optional<std::vector<IntEnum>>* _aidl_return) override {
388     *_aidl_return = in_value;
389     return ::ndk::ScopedAStatus(AStatus_newOk());
390   }
RepeatNullableLongEnumArray(const std::optional<std::vector<LongEnum>> & in_value,std::optional<std::vector<LongEnum>> * _aidl_return)391   ::ndk::ScopedAStatus RepeatNullableLongEnumArray(
392       const std::optional<std::vector<LongEnum>>& in_value,
393       std::optional<std::vector<LongEnum>>* _aidl_return) override {
394     *_aidl_return = in_value;
395     return ::ndk::ScopedAStatus(AStatus_newOk());
396   }
RepeatNullableStringArray(const std::optional<std::vector<std::optional<std::string>>> & in_value,std::optional<std::vector<std::optional<std::string>>> * _aidl_return)397   ::ndk::ScopedAStatus RepeatNullableStringArray(
398       const std::optional<std::vector<std::optional<std::string>>>& in_value,
399       std::optional<std::vector<std::optional<std::string>>>* _aidl_return) {
400     *_aidl_return = in_value;
401     return ::ndk::ScopedAStatus(AStatus_newOk());
402   }
DoubleRepeatNullableStringArray(const std::optional<std::vector<std::optional<std::string>>> & in_value,std::optional<std::vector<std::optional<std::string>>> * out_repeated,std::optional<std::vector<std::optional<std::string>>> * _aidl_return)403   ::ndk::ScopedAStatus DoubleRepeatNullableStringArray(
404       const std::optional<std::vector<std::optional<std::string>>>& in_value,
405       std::optional<std::vector<std::optional<std::string>>>* out_repeated,
406       std::optional<std::vector<std::optional<std::string>>>* _aidl_return)
407       override {
408     *out_repeated = in_value;
409     *_aidl_return = in_value;
410     return ::ndk::ScopedAStatus(AStatus_newOk());
411   }
412 
413 #ifdef USING_VERSION_1
RepeatStringNullableLater(const std::string & in_value,std::string * _aidl_return)414   ::ndk::ScopedAStatus RepeatStringNullableLater(const std::string& in_value,
415                                                  std::string* _aidl_return) override {
416     *_aidl_return = in_value;
417     return ::ndk::ScopedAStatus(AStatus_newOk());
418   }
419 #else
RepeatStringNullableLater(const std::optional<std::string> & in_value,std::optional<std::string> * _aidl_return)420   ::ndk::ScopedAStatus RepeatStringNullableLater(
421       const std::optional<std::string>& in_value,
422       std::optional<std::string>* _aidl_return) override {
423     *_aidl_return = in_value;
424     return ::ndk::ScopedAStatus(AStatus_newOk());
425   }
426 #endif
427 
428 #ifndef USING_VERSION_1
429   // All methods added from now on should be within this macro
NewMethodThatReturns10(int32_t * _aidl_return)430   ::ndk::ScopedAStatus NewMethodThatReturns10(int32_t* _aidl_return) override {
431     *_aidl_return = 10;
432     return ::ndk::ScopedAStatus(AStatus_newOk());
433   }
434 #endif
435 
repeatFoo(const Foo & in_inFoo,Foo * _aidl_return)436   ::ndk::ScopedAStatus repeatFoo(const Foo& in_inFoo, Foo* _aidl_return) {
437     *_aidl_return = in_inFoo;
438     return ::ndk::ScopedAStatus(AStatus_newOk());
439   }
440 
renameFoo(Foo * in_foo,const std::string & in_name)441   ::ndk::ScopedAStatus renameFoo(Foo* in_foo, const std::string& in_name) {
442     in_foo->a = in_name;
443     return ::ndk::ScopedAStatus(AStatus_newOk());
444   }
445 
renameBar(Foo * in_foo,const std::string & in_name)446   ::ndk::ScopedAStatus renameBar(Foo* in_foo, const std::string& in_name) {
447     in_foo->d.a = in_name;
448     return ::ndk::ScopedAStatus(AStatus_newOk());
449   }
450 
getF(const Foo & foo,int32_t * _aidl_return)451   ::ndk::ScopedAStatus getF(const Foo& foo, int32_t* _aidl_return) {
452     *_aidl_return = foo.f;
453     return ::ndk::ScopedAStatus(AStatus_newOk());
454   }
455 };
456