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 #define LOG_TAG "aidl_native_service"
17
18 #include <map>
19 #include <mutex>
20 #include <optional>
21 #include <sstream>
22 #include <string>
23 #include <vector>
24
25 #include <unistd.h>
26
27 #include <android-base/unique_fd.h>
28 #include <binder/IInterface.h>
29 #include <binder/IPCThreadState.h>
30 #include <binder/IServiceManager.h>
31 #include <binder/ProcessState.h>
32 #include <binder/Status.h>
33 #include <utils/Errors.h>
34 #include <utils/Log.h>
35 #include <utils/Looper.h>
36 #include <utils/String8.h>
37 #include <utils/StrongPointer.h>
38
39 #include "android/aidl/tests/BackendType.h"
40 #include "android/aidl/tests/BnTestService.h"
41 #include "android/aidl/tests/ITestService.h"
42
43 #include "android/aidl/tests/BnNamedCallback.h"
44 #include "android/aidl/tests/INamedCallback.h"
45
46 #include "android/aidl/versioned/tests/BnFooInterface.h"
47 #include "android/aidl/versioned/tests/IFooInterface.h"
48
49 #include <android/aidl/test/trunk/BnTrunkStableTest.h>
50 #include <android/aidl/test/trunk/ITrunkStableTest.h>
51
52 #include "android/aidl/tests/BnNewName.h"
53 #include "android/aidl/tests/BnOldName.h"
54
55 #include "android/aidl/tests/BnCppJavaTests.h"
56 #include "android/aidl/tests/ICppJavaTests.h"
57
58 #include "android/aidl/tests/Union.h"
59 #include "android/aidl/tests/extension/MyExt.h"
60 #include "android/aidl/tests/extension/MyExt2.h"
61 #include "android/aidl/tests/vintf/VintfExtendableParcelable.h"
62
63 #include "android/aidl/tests/nested/BnNestedService.h"
64
65 #include "android/aidl/tests/BnCircular.h"
66 #include "android/aidl/tests/ICircular.h"
67
68 #include "android/aidl/loggable/BnLoggableInterface.h"
69 #include "android/aidl/loggable/Data.h"
70
71 #include "android/aidl/fixedsizearray/FixedSizeArrayExample.h"
72
73 // libbase
74 using android::base::unique_fd;
75
76 // libutils:
77 using android::Looper;
78 using android::LooperCallback;
79 using android::OK;
80 using android::sp;
81 using android::status_t;
82 using android::String16;
83 using android::String8;
84
85 // libbinder:
86 using android::BnInterface;
87 using android::defaultServiceManager;
88 using android::IBinder;
89 using android::IInterface;
90 using android::IPCThreadState;
91 using android::Parcel;
92 using android::ProcessState;
93 using android::binder::Status;
94
95 // Generated code:
96 using android::aidl::tests::BackendType;
97 using android::aidl::tests::BadParcelable;
98 using android::aidl::tests::BnCircular;
99 using android::aidl::tests::BnCppJavaTests;
100 using android::aidl::tests::BnNamedCallback;
101 using android::aidl::tests::BnNewName;
102 using android::aidl::tests::BnOldName;
103 using android::aidl::tests::BnTestService;
104 using android::aidl::tests::ByteEnum;
105 using android::aidl::tests::CircularParcelable;
106 using android::aidl::tests::ConstantExpressionEnum;
107 using android::aidl::tests::GenericStructuredParcelable;
108 using android::aidl::tests::ICircular;
109 using android::aidl::tests::ICppJavaTests;
110 using android::aidl::tests::INamedCallback;
111 using android::aidl::tests::INewName;
112 using android::aidl::tests::IntEnum;
113 using android::aidl::tests::IOldName;
114 using android::aidl::tests::ITestService;
115 using android::aidl::tests::LongEnum;
116 using android::aidl::tests::RecursiveList;
117 using android::aidl::tests::SimpleParcelable;
118 using android::aidl::tests::StructuredParcelable;
119 using android::aidl::tests::Union;
120 using android::os::ParcelFileDescriptor;
121 using android::os::PersistableBundle;
122
123 // Standard library
124 using std::map;
125 using std::optional;
126 using std::string;
127 using std::vector;
128
129 namespace {
130
131 class NamedCallback : public BnNamedCallback {
132 public:
NamedCallback(String16 name)133 explicit NamedCallback(String16 name) : name_(name) {}
134
GetName(String16 * ret)135 Status GetName(String16* ret) {
136 *ret = name_;
137 return Status::ok();
138 }
139
140 private:
141 String16 name_;
142 };
143
144 class OldName : public BnOldName {
145 public:
146 OldName() = default;
147 ~OldName() = default;
148
RealName(String16 * output)149 Status RealName(String16* output) override {
150 *output = String16("OldName");
151 return Status::ok();
152 }
153 };
154
155 class NewName : public BnNewName {
156 public:
157 NewName() = default;
158 ~NewName() = default;
159
RealName(String16 * output)160 Status RealName(String16* output) override {
161 *output = String16("NewName");
162 return Status::ok();
163 }
164 };
165
166 class Circular : public BnCircular {
167 public:
Circular(sp<ITestService> srv)168 Circular(sp<ITestService> srv) : mSrv(srv) {}
169 ~Circular() = default;
170
GetTestService(sp<ITestService> * _aidl_return)171 Status GetTestService(sp<ITestService>* _aidl_return) override {
172 *_aidl_return = mSrv;
173 return Status::ok();
174 }
175
176 private:
177 sp<ITestService> mSrv;
178 };
179
180 template <typename T>
ReverseArray(const vector<T> & input,vector<T> * repeated,vector<T> * _aidl_return)181 Status ReverseArray(const vector<T>& input, vector<T>* repeated, vector<T>* _aidl_return) {
182 ALOGI("Reversing array of length %zu", input.size());
183 *repeated = input;
184 *_aidl_return = input;
185 std::reverse(_aidl_return->begin(), _aidl_return->end());
186 return Status::ok();
187 }
188
189 template <typename T>
RepeatNullable(const optional<T> & input,optional<T> * _aidl_return)190 Status RepeatNullable(const optional<T>& input, optional<T>* _aidl_return) {
191 ALOGI("Repeating nullable value");
192 *_aidl_return = input;
193 return Status::ok();
194 }
195
196 class CppJavaTests : public BnCppJavaTests {
197 public:
198 CppJavaTests() = default;
199 ~CppJavaTests() = default;
200
RepeatBadParcelable(const BadParcelable & input,BadParcelable * _aidl_return)201 Status RepeatBadParcelable(const BadParcelable& input, BadParcelable* _aidl_return) override {
202 *_aidl_return = input;
203 return Status::ok();
204 }
205
RepeatGenericParcelable(const GenericStructuredParcelable<int32_t,StructuredParcelable,IntEnum> & input,GenericStructuredParcelable<int32_t,StructuredParcelable,IntEnum> * repeat,GenericStructuredParcelable<int32_t,StructuredParcelable,IntEnum> * _aidl_return)206 Status RepeatGenericParcelable(
207 const GenericStructuredParcelable<int32_t, StructuredParcelable, IntEnum>& input,
208 GenericStructuredParcelable<int32_t, StructuredParcelable, IntEnum>* repeat,
209 GenericStructuredParcelable<int32_t, StructuredParcelable, IntEnum>* _aidl_return) {
210 ALOGI("Repeating Generic Parcelable");
211 *repeat = input;
212 *_aidl_return = input;
213 return Status::ok();
214 }
215
RepeatPersistableBundle(const PersistableBundle & input,PersistableBundle * _aidl_return)216 Status RepeatPersistableBundle(const PersistableBundle& input,
217 PersistableBundle* _aidl_return) override {
218 ALOGI("Repeated a PersistableBundle");
219 *_aidl_return = input;
220 return Status::ok();
221 }
222
ReversePersistableBundles(const vector<PersistableBundle> & input,vector<PersistableBundle> * repeated,vector<PersistableBundle> * _aidl_return)223 Status ReversePersistableBundles(const vector<PersistableBundle>& input,
224 vector<PersistableBundle>* repeated,
225 vector<PersistableBundle>* _aidl_return) override {
226 return ReverseArray(input, repeated, _aidl_return);
227 }
ReverseUnion(const Union & input,Union * repeated,Union * _aidl_return)228 Status ReverseUnion(const Union& input, Union* repeated, Union* _aidl_return) override {
229 ALOGI("Repeated a Union");
230 *repeated = input;
231 *_aidl_return = input;
232 auto reverse = [](auto& reversible) {
233 std::reverse(std::begin(reversible), std::end(reversible));
234 };
235 switch (input.getTag()) {
236 case Union::ns: // int[]
237 reverse(_aidl_return->get<Union::ns>());
238 break;
239 case Union::s: // String
240 reverse(_aidl_return->get<Union::s>());
241 break;
242 case Union::ss: // List<String>
243 reverse(_aidl_return->get<Union::ss>());
244 break;
245 default:
246 break;
247 }
248 return Status::ok();
249 }
ReverseNamedCallbackList(const vector<sp<IBinder>> & input,vector<sp<IBinder>> * repeated,vector<sp<IBinder>> * _aidl_return)250 Status ReverseNamedCallbackList(const vector<sp<IBinder>>& input, vector<sp<IBinder>>* repeated,
251 vector<sp<IBinder>>* _aidl_return) override {
252 return ReverseArray(input, repeated, _aidl_return);
253 }
254
RepeatFileDescriptor(unique_fd read,unique_fd * _aidl_return)255 Status RepeatFileDescriptor(unique_fd read, unique_fd* _aidl_return) override {
256 ALOGE("Repeating file descriptor");
257 *_aidl_return = unique_fd(dup(read.get()));
258 return Status::ok();
259 }
260
ReverseFileDescriptorArray(const vector<unique_fd> & input,vector<unique_fd> * repeated,vector<unique_fd> * _aidl_return)261 Status ReverseFileDescriptorArray(const vector<unique_fd>& input, vector<unique_fd>* repeated,
262 vector<unique_fd>* _aidl_return) override {
263 ALOGI("Reversing descriptor array of length %zu", input.size());
264 repeated->clear();
265 for (const auto& item : input) {
266 repeated->push_back(unique_fd(dup(item.get())));
267 _aidl_return->push_back(unique_fd(dup(item.get())));
268 }
269 std::reverse(_aidl_return->begin(), _aidl_return->end());
270 return Status::ok();
271 }
272 };
273
274 class NativeService : public BnTestService {
275 public:
NativeService()276 NativeService() {}
277 virtual ~NativeService() = default;
278
LogRepeatedStringToken(const String16 & token)279 void LogRepeatedStringToken(const String16& token) {
280 ALOGI("Repeating '%s' of length=%zu", android::String8(token).c_str(), token.size());
281 }
282
283 template <typename T>
LogRepeatedToken(const T & token)284 void LogRepeatedToken(const T& token) {
285 std::ostringstream token_str;
286 token_str << token;
287 ALOGI("Repeating token %s", token_str.str().c_str());
288 }
289
TestOneway()290 Status TestOneway() override { return Status::fromStatusT(android::UNKNOWN_ERROR); }
291
Deprecated()292 Status Deprecated() override { return Status::ok(); }
293
RepeatBoolean(bool token,bool * _aidl_return)294 Status RepeatBoolean(bool token, bool* _aidl_return) override {
295 LogRepeatedToken(token ? 1 : 0);
296 *_aidl_return = token;
297 return Status::ok();
298 }
RepeatByte(int8_t token,int8_t * _aidl_return)299 Status RepeatByte(int8_t token, int8_t* _aidl_return) override {
300 LogRepeatedToken(token);
301 *_aidl_return = token;
302 return Status::ok();
303 }
RepeatChar(char16_t token,char16_t * _aidl_return)304 Status RepeatChar(char16_t token, char16_t* _aidl_return) override {
305 LogRepeatedStringToken(String16(&token, 1));
306 *_aidl_return = token;
307 return Status::ok();
308 }
RepeatInt(int32_t token,int32_t * _aidl_return)309 Status RepeatInt(int32_t token, int32_t* _aidl_return) override {
310 LogRepeatedToken(token);
311 *_aidl_return = token;
312 return Status::ok();
313 }
RepeatLong(int64_t token,int64_t * _aidl_return)314 Status RepeatLong(int64_t token, int64_t* _aidl_return) override {
315 LogRepeatedToken(token);
316 *_aidl_return = token;
317 return Status::ok();
318 }
RepeatFloat(float token,float * _aidl_return)319 Status RepeatFloat(float token, float* _aidl_return) override {
320 LogRepeatedToken(token);
321 *_aidl_return = token;
322 return Status::ok();
323 }
RepeatDouble(double token,double * _aidl_return)324 Status RepeatDouble(double token, double* _aidl_return) override {
325 LogRepeatedToken(token);
326 *_aidl_return = token;
327 return Status::ok();
328 }
RepeatString(const String16 & token,String16 * _aidl_return)329 Status RepeatString(const String16& token, String16* _aidl_return) override {
330 LogRepeatedStringToken(token);
331 *_aidl_return = token;
332 return Status::ok();
333 }
RepeatByteEnum(ByteEnum token,ByteEnum * _aidl_return)334 Status RepeatByteEnum(ByteEnum token, ByteEnum* _aidl_return) override {
335 ALOGI("Repeating ByteEnum token %s", toString(token).c_str());
336 *_aidl_return = token;
337 return Status::ok();
338 }
RepeatIntEnum(IntEnum token,IntEnum * _aidl_return)339 Status RepeatIntEnum(IntEnum token, IntEnum* _aidl_return) override {
340 ALOGI("Repeating IntEnum token %s", toString(token).c_str());
341 *_aidl_return = token;
342 return Status::ok();
343 }
RepeatLongEnum(LongEnum token,LongEnum * _aidl_return)344 Status RepeatLongEnum(LongEnum token, LongEnum* _aidl_return) override {
345 ALOGI("Repeating LongEnum token %s", toString(token).c_str());
346 *_aidl_return = token;
347 return Status::ok();
348 }
349
ReverseBoolean(const vector<bool> & input,vector<bool> * repeated,vector<bool> * _aidl_return)350 Status ReverseBoolean(const vector<bool>& input,
351 vector<bool>* repeated,
352 vector<bool>* _aidl_return) override {
353 return ReverseArray(input, repeated, _aidl_return);
354 }
ReverseByte(const vector<uint8_t> & input,vector<uint8_t> * repeated,vector<uint8_t> * _aidl_return)355 Status ReverseByte(const vector<uint8_t>& input,
356 vector<uint8_t>* repeated,
357 vector<uint8_t>* _aidl_return) override {
358 return ReverseArray(input, repeated, _aidl_return);
359 }
ReverseChar(const vector<char16_t> & input,vector<char16_t> * repeated,vector<char16_t> * _aidl_return)360 Status ReverseChar(const vector<char16_t>& input,
361 vector<char16_t>* repeated,
362 vector<char16_t>* _aidl_return) override {
363 return ReverseArray(input, repeated, _aidl_return);
364 }
ReverseInt(const vector<int32_t> & input,vector<int32_t> * repeated,vector<int32_t> * _aidl_return)365 Status ReverseInt(const vector<int32_t>& input,
366 vector<int32_t>* repeated,
367 vector<int32_t>* _aidl_return) override {
368 return ReverseArray(input, repeated, _aidl_return);
369 }
ReverseLong(const vector<int64_t> & input,vector<int64_t> * repeated,vector<int64_t> * _aidl_return)370 Status ReverseLong(const vector<int64_t>& input,
371 vector<int64_t>* repeated,
372 vector<int64_t>* _aidl_return) override {
373 return ReverseArray(input, repeated, _aidl_return);
374 }
ReverseFloat(const vector<float> & input,vector<float> * repeated,vector<float> * _aidl_return)375 Status ReverseFloat(const vector<float>& input,
376 vector<float>* repeated,
377 vector<float>* _aidl_return) override {
378 return ReverseArray(input, repeated, _aidl_return);
379 }
ReverseDouble(const vector<double> & input,vector<double> * repeated,vector<double> * _aidl_return)380 Status ReverseDouble(const vector<double>& input,
381 vector<double>* repeated,
382 vector<double>* _aidl_return) override {
383 return ReverseArray(input, repeated, _aidl_return);
384 }
ReverseString(const vector<String16> & input,vector<String16> * repeated,vector<String16> * _aidl_return)385 Status ReverseString(const vector<String16>& input,
386 vector<String16>* repeated,
387 vector<String16>* _aidl_return) override {
388 return ReverseArray(input, repeated, _aidl_return);
389 }
ReverseByteEnum(const vector<ByteEnum> & input,vector<ByteEnum> * repeated,vector<ByteEnum> * _aidl_return)390 Status ReverseByteEnum(const vector<ByteEnum>& input, vector<ByteEnum>* repeated,
391 vector<ByteEnum>* _aidl_return) override {
392 return ReverseArray(input, repeated, _aidl_return);
393 }
ReverseIntEnum(const vector<IntEnum> & input,vector<IntEnum> * repeated,vector<IntEnum> * _aidl_return)394 Status ReverseIntEnum(const vector<IntEnum>& input, vector<IntEnum>* repeated,
395 vector<IntEnum>* _aidl_return) override {
396 return ReverseArray(input, repeated, _aidl_return);
397 }
ReverseLongEnum(const vector<LongEnum> & input,vector<LongEnum> * repeated,vector<LongEnum> * _aidl_return)398 Status ReverseLongEnum(const vector<LongEnum>& input, vector<LongEnum>* repeated,
399 vector<LongEnum>* _aidl_return) override {
400 return ReverseArray(input, repeated, _aidl_return);
401 }
402
SetOtherTestService(const String16 & name,const sp<INamedCallback> & service,bool * _aidl_return)403 Status SetOtherTestService(const String16& name, const sp<INamedCallback>& service,
404 bool* _aidl_return) override {
405 std::lock_guard<std::mutex> guard(service_map_mutex_);
406 const auto& existing = service_map_.find(name);
407 if (existing != service_map_.end() && existing->second == service) {
408 *_aidl_return = true;
409
410 return Status::ok();
411 } else {
412 *_aidl_return = false;
413 service_map_[name] = service;
414
415 return Status::ok();
416 }
417 }
418
GetOtherTestService(const String16 & name,sp<INamedCallback> * returned_service)419 Status GetOtherTestService(const String16& name,
420 sp<INamedCallback>* returned_service) override {
421 std::lock_guard<std::mutex> guard(service_map_mutex_);
422 if (service_map_.find(name) == service_map_.end()) {
423 sp<INamedCallback> new_item(new NamedCallback(name));
424 service_map_[name] = new_item;
425 }
426
427 *returned_service = service_map_[name];
428 return Status::ok();
429 }
430
VerifyName(const sp<INamedCallback> & service,const String16 & name,bool * returned_value)431 Status VerifyName(const sp<INamedCallback>& service, const String16& name,
432 bool* returned_value) override {
433 String16 foundName;
434 Status status = service->GetName(&foundName);
435
436 if (status.isOk()) {
437 *returned_value = foundName == name;
438 }
439
440 return status;
441 }
442
GetInterfaceArray(const vector<String16> & names,vector<sp<INamedCallback>> * _aidl_return)443 Status GetInterfaceArray(const vector<String16>& names,
444 vector<sp<INamedCallback>>* _aidl_return) override {
445 vector<sp<INamedCallback>> services(names.size());
446 for (size_t i = 0; i < names.size(); i++) {
447 if (auto st = GetOtherTestService(names[i], &services[i]); !st.isOk()) {
448 return st;
449 }
450 }
451 *_aidl_return = std::move(services);
452 return Status::ok();
453 }
454
VerifyNamesWithInterfaceArray(const vector<sp<INamedCallback>> & services,const vector<String16> & names,bool * _aidl_ret)455 Status VerifyNamesWithInterfaceArray(const vector<sp<INamedCallback>>& services,
456 const vector<String16>& names, bool* _aidl_ret) override {
457 if (services.size() == names.size()) {
458 for (size_t i = 0; i < services.size(); i++) {
459 if (auto st = VerifyName(services[i], names[i], _aidl_ret); !st.isOk() || !*_aidl_ret) {
460 return st;
461 }
462 }
463 *_aidl_ret = true;
464 } else {
465 *_aidl_ret = false;
466 }
467 return Status::ok();
468 }
469
GetNullableInterfaceArray(const optional<vector<optional<String16>>> & names,optional<vector<sp<INamedCallback>>> * _aidl_ret)470 Status GetNullableInterfaceArray(const optional<vector<optional<String16>>>& names,
471 optional<vector<sp<INamedCallback>>>* _aidl_ret) override {
472 vector<sp<INamedCallback>> services;
473 if (names.has_value()) {
474 for (const auto& name : *names) {
475 if (name.has_value()) {
476 sp<INamedCallback> ret;
477 if (auto st = GetOtherTestService(*name, &ret); !st.isOk()) {
478 return st;
479 }
480 services.push_back(std::move(ret));
481 } else {
482 services.emplace_back();
483 }
484 }
485 }
486 *_aidl_ret = std::move(services);
487 return Status::ok();
488 }
489
VerifyNamesWithNullableInterfaceArray(const optional<vector<sp<INamedCallback>>> & services,const optional<vector<optional<String16>>> & names,bool * _aidl_ret)490 Status VerifyNamesWithNullableInterfaceArray(const optional<vector<sp<INamedCallback>>>& services,
491 const optional<vector<optional<String16>>>& names,
492 bool* _aidl_ret) override {
493 if (services.has_value() && names.has_value()) {
494 if (services->size() == names->size()) {
495 for (size_t i = 0; i < services->size(); i++) {
496 if (services->at(i).get() && names->at(i).has_value()) {
497 if (auto st = VerifyName(services->at(i), names->at(i).value(), _aidl_ret);
498 !st.isOk() || !*_aidl_ret) {
499 return st;
500 }
501 } else if (services->at(i).get() || names->at(i).has_value()) {
502 *_aidl_ret = false;
503 return Status::ok();
504 } else {
505 // ok if service=null && name=null
506 }
507 }
508 *_aidl_ret = true;
509 } else {
510 *_aidl_ret = false;
511 }
512 } else {
513 *_aidl_ret = services.has_value() == names.has_value();
514 }
515 return Status::ok();
516 }
517
GetInterfaceList(const optional<vector<optional<String16>>> & names,optional<vector<sp<INamedCallback>>> * _aidl_ret)518 Status GetInterfaceList(const optional<vector<optional<String16>>>& names,
519 optional<vector<sp<INamedCallback>>>* _aidl_ret) override {
520 return GetNullableInterfaceArray(names, _aidl_ret);
521 }
522
VerifyNamesWithInterfaceList(const optional<vector<sp<INamedCallback>>> & services,const optional<vector<optional<String16>>> & names,bool * _aidl_ret)523 Status VerifyNamesWithInterfaceList(const optional<vector<sp<INamedCallback>>>& services,
524 const optional<vector<optional<String16>>>& names,
525 bool* _aidl_ret) override {
526 return VerifyNamesWithNullableInterfaceArray(services, names, _aidl_ret);
527 }
528
ReverseStringList(const vector<String16> & input,vector<String16> * repeated,vector<String16> * _aidl_return)529 Status ReverseStringList(const vector<String16>& input,
530 vector<String16>* repeated,
531 vector<String16>* _aidl_return) override {
532 return ReverseArray(input, repeated, _aidl_return);
533 }
534
RepeatParcelFileDescriptor(const ParcelFileDescriptor & read,ParcelFileDescriptor * _aidl_return)535 Status RepeatParcelFileDescriptor(const ParcelFileDescriptor& read,
536 ParcelFileDescriptor* _aidl_return) override {
537 ALOGE("Repeating parcel file descriptor");
538 _aidl_return->reset(unique_fd(dup(read.get())));
539 return Status::ok();
540 }
541
ReverseParcelFileDescriptorArray(const vector<ParcelFileDescriptor> & input,vector<ParcelFileDescriptor> * repeated,vector<ParcelFileDescriptor> * _aidl_return)542 Status ReverseParcelFileDescriptorArray(const vector<ParcelFileDescriptor>& input,
543 vector<ParcelFileDescriptor>* repeated,
544 vector<ParcelFileDescriptor>* _aidl_return) override {
545 ALOGI("Reversing parcel descriptor array of length %zu", input.size());
546 for (const auto& item : input) {
547 repeated->push_back(ParcelFileDescriptor(unique_fd(dup(item.get()))));
548 }
549
550 for (auto i = input.rbegin(); i != input.rend(); i++) {
551 _aidl_return->push_back(ParcelFileDescriptor(unique_fd(dup(i->get()))));
552 }
553 return Status::ok();
554 }
555
ThrowServiceException(int code)556 Status ThrowServiceException(int code) override {
557 return Status::fromServiceSpecificError(code);
558 }
559
RepeatNullableIntArray(const optional<vector<int32_t>> & input,optional<vector<int32_t>> * _aidl_return)560 Status RepeatNullableIntArray(const optional<vector<int32_t>>& input,
561 optional<vector<int32_t>>* _aidl_return) {
562 return RepeatNullable(input, _aidl_return);
563 }
564
RepeatNullableByteEnumArray(const optional<vector<ByteEnum>> & input,optional<vector<ByteEnum>> * _aidl_return)565 Status RepeatNullableByteEnumArray(const optional<vector<ByteEnum>>& input,
566 optional<vector<ByteEnum>>* _aidl_return) {
567 return RepeatNullable(input, _aidl_return);
568 }
569
RepeatNullableIntEnumArray(const optional<vector<IntEnum>> & input,optional<vector<IntEnum>> * _aidl_return)570 Status RepeatNullableIntEnumArray(const optional<vector<IntEnum>>& input,
571 optional<vector<IntEnum>>* _aidl_return) {
572 return RepeatNullable(input, _aidl_return);
573 }
574
RepeatNullableLongEnumArray(const optional<vector<LongEnum>> & input,optional<vector<LongEnum>> * _aidl_return)575 Status RepeatNullableLongEnumArray(const optional<vector<LongEnum>>& input,
576 optional<vector<LongEnum>>* _aidl_return) {
577 return RepeatNullable(input, _aidl_return);
578 }
579
RepeatNullableStringList(const optional<vector<optional<String16>>> & input,optional<vector<optional<String16>>> * _aidl_return)580 Status RepeatNullableStringList(const optional<vector<optional<String16>>>& input,
581 optional<vector<optional<String16>>>* _aidl_return) {
582 ALOGI("Repeating nullable string list");
583 return RepeatNullable(input, _aidl_return);
584 }
585
RepeatNullableString(const optional<String16> & input,optional<String16> * _aidl_return)586 Status RepeatNullableString(const optional<String16>& input, optional<String16>* _aidl_return) {
587 return RepeatNullable(input, _aidl_return);
588 }
589
RepeatNullableParcelable(const optional<ITestService::Empty> & input,optional<ITestService::Empty> * _aidl_return)590 Status RepeatNullableParcelable(const optional<ITestService::Empty>& input,
591 optional<ITestService::Empty>* _aidl_return) {
592 return RepeatNullable(input, _aidl_return);
593 }
594
RepeatNullableParcelableList(const optional<vector<optional<ITestService::Empty>>> & input,optional<vector<optional<ITestService::Empty>>> * _aidl_return)595 Status RepeatNullableParcelableList(
596 const optional<vector<optional<ITestService::Empty>>>& input,
597 optional<vector<optional<ITestService::Empty>>>* _aidl_return) {
598 return RepeatNullable(input, _aidl_return);
599 }
600
RepeatNullableParcelableArray(const optional<vector<optional<ITestService::Empty>>> & input,optional<vector<optional<ITestService::Empty>>> * _aidl_return)601 Status RepeatNullableParcelableArray(
602 const optional<vector<optional<ITestService::Empty>>>& input,
603 optional<vector<optional<ITestService::Empty>>>* _aidl_return) {
604 return RepeatNullable(input, _aidl_return);
605 }
606
TakesAnIBinder(const sp<IBinder> & input)607 Status TakesAnIBinder(const sp<IBinder>& input) override {
608 (void)input;
609 return Status::ok();
610 }
TakesANullableIBinder(const sp<IBinder> & input)611 Status TakesANullableIBinder(const sp<IBinder>& input) {
612 (void)input;
613 return Status::ok();
614 }
TakesAnIBinderList(const vector<sp<IBinder>> & input)615 Status TakesAnIBinderList(const vector<sp<IBinder>>& input) override {
616 (void)input;
617 return Status::ok();
618 }
TakesANullableIBinderList(const optional<vector<sp<IBinder>>> & input)619 Status TakesANullableIBinderList(const optional<vector<sp<IBinder>>>& input) {
620 (void)input;
621 return Status::ok();
622 }
623
RepeatUtf8CppString(const string & token,string * _aidl_return)624 Status RepeatUtf8CppString(const string& token,
625 string* _aidl_return) override {
626 ALOGI("Repeating utf8 string '%s' of length=%zu", token.c_str(), token.size());
627 *_aidl_return = token;
628 return Status::ok();
629 }
630
RepeatNullableUtf8CppString(const optional<string> & token,optional<string> * _aidl_return)631 Status RepeatNullableUtf8CppString(const optional<string>& token,
632 optional<string>* _aidl_return) override {
633 if (!token) {
634 ALOGI("Received null @utf8InCpp string");
635 return Status::ok();
636 }
637 ALOGI("Repeating utf8 string '%s' of length=%zu",
638 token->c_str(), token->size());
639 *_aidl_return = token;
640 return Status::ok();
641 }
642
ReverseUtf8CppString(const vector<string> & input,vector<string> * repeated,vector<string> * _aidl_return)643 Status ReverseUtf8CppString(const vector<string>& input,
644 vector<string>* repeated,
645 vector<string>* _aidl_return) {
646 return ReverseArray(input, repeated, _aidl_return);
647 }
648
ReverseNullableUtf8CppString(const optional<vector<optional<string>>> & input,optional<vector<optional<string>>> * repeated,optional<vector<optional<string>>> * _aidl_return)649 Status ReverseNullableUtf8CppString(const optional<vector<optional<string>>>& input,
650 optional<vector<optional<string>>>* repeated,
651 optional<vector<optional<string>>>* _aidl_return) {
652 return ReverseUtf8CppStringList(input, repeated, _aidl_return);
653 }
654
ReverseUtf8CppStringList(const optional<vector<optional<string>>> & input,optional<vector<optional<string>>> * repeated,optional<vector<optional<string>>> * _aidl_return)655 Status ReverseUtf8CppStringList(const optional<vector<optional<string>>>& input,
656 optional<vector<optional<string>>>* repeated,
657 optional<vector<optional<string>>>* _aidl_return) {
658 if (!input) {
659 ALOGI("Received null list of utf8 strings");
660 return Status::ok();
661 }
662 *_aidl_return = input;
663 *repeated = input;
664 std::reverse((*_aidl_return)->begin(), (*_aidl_return)->end());
665 return Status::ok();
666 }
667
GetCallback(bool return_null,sp<INamedCallback> * ret)668 Status GetCallback(bool return_null, sp<INamedCallback>* ret) {
669 if (!return_null) {
670 return GetOtherTestService(String16("ABT: always be testing"), ret);
671 }
672 return Status::ok();
673 }
674
FillOutStructuredParcelable(StructuredParcelable * parcelable)675 virtual ::android::binder::Status FillOutStructuredParcelable(StructuredParcelable* parcelable) {
676 parcelable->shouldBeJerry = "Jerry";
677 parcelable->shouldContainThreeFs = {parcelable->f, parcelable->f, parcelable->f};
678 parcelable->shouldBeByteBar = ByteEnum::BAR;
679 parcelable->shouldBeIntBar = IntEnum::BAR;
680 parcelable->shouldBeLongBar = LongEnum::BAR;
681 parcelable->shouldContainTwoByteFoos = {ByteEnum::FOO, ByteEnum::FOO};
682 parcelable->shouldContainTwoIntFoos = {IntEnum::FOO, IntEnum::FOO};
683 parcelable->shouldContainTwoLongFoos = {LongEnum::FOO, LongEnum::FOO};
684
685 parcelable->const_exprs_1 = ConstantExpressionEnum::decInt32_1;
686 parcelable->const_exprs_2 = ConstantExpressionEnum::decInt32_2;
687 parcelable->const_exprs_3 = ConstantExpressionEnum::decInt64_1;
688 parcelable->const_exprs_4 = ConstantExpressionEnum::decInt64_2;
689 parcelable->const_exprs_5 = ConstantExpressionEnum::decInt64_3;
690 parcelable->const_exprs_6 = ConstantExpressionEnum::decInt64_4;
691 parcelable->const_exprs_7 = ConstantExpressionEnum::hexInt32_1;
692 parcelable->const_exprs_8 = ConstantExpressionEnum::hexInt32_2;
693 parcelable->const_exprs_9 = ConstantExpressionEnum::hexInt32_3;
694 parcelable->const_exprs_10 = ConstantExpressionEnum::hexInt64_1;
695
696 parcelable->shouldSetBit0AndBit2 = StructuredParcelable::BIT0 | StructuredParcelable::BIT2;
697
698 parcelable->u = Union::make<Union::ns>({1, 2, 3});
699 parcelable->shouldBeConstS1 = Union::S1();
700 return Status::ok();
701 }
702
RepeatExtendableParcelable(const::android::aidl::tests::extension::ExtendableParcelable & ep,::android::aidl::tests::extension::ExtendableParcelable * ep2)703 ::android::binder::Status RepeatExtendableParcelable(
704 const ::android::aidl::tests::extension::ExtendableParcelable& ep,
705 ::android::aidl::tests::extension::ExtendableParcelable* ep2) {
706 ep2->a = ep.a;
707 ep2->b = ep.b;
708 std::shared_ptr<android::aidl::tests::extension::MyExt> myExt;
709 ep.ext.getParcelable(&myExt);
710 ep2->ext.setParcelable(myExt);
711
712 return Status::ok();
713 }
714
RepeatExtendableParcelableVintf(const::android::aidl::tests::extension::ExtendableParcelable & ep,::android::aidl::tests::extension::ExtendableParcelable * ep2)715 ::android::binder::Status RepeatExtendableParcelableVintf(
716 const ::android::aidl::tests::extension::ExtendableParcelable& ep,
717 ::android::aidl::tests::extension::ExtendableParcelable* ep2) {
718 ep2->a = ep.a;
719 ep2->b = ep.b;
720 std::shared_ptr<android::aidl::tests::vintf::VintfExtendableParcelable> myExt;
721 ep.ext.getParcelable(&myExt);
722 ep2->ext.setParcelable(myExt);
723
724 return Status::ok();
725 }
726
ReverseList(const RecursiveList & list,RecursiveList * ret)727 ::android::binder::Status ReverseList(const RecursiveList& list, RecursiveList* ret) override {
728 std::unique_ptr<RecursiveList> reversed;
729 const RecursiveList* cur = &list;
730 while (cur) {
731 auto node = std::make_unique<RecursiveList>();
732 node->value = cur->value;
733 node->next = std::move(reversed);
734 reversed = std::move(node);
735 cur = cur->next.get();
736 }
737 *ret = std::move(*reversed);
738 return Status::ok();
739 }
740
ReverseIBinderArray(const vector<sp<IBinder>> & input,vector<sp<IBinder>> * repeated,vector<sp<IBinder>> * _aidl_return)741 Status ReverseIBinderArray(const vector<sp<IBinder>>& input, vector<sp<IBinder>>* repeated,
742 vector<sp<IBinder>>* _aidl_return) override {
743 *repeated = input;
744 *_aidl_return = input;
745 std::reverse(_aidl_return->begin(), _aidl_return->end());
746 return Status::ok();
747 }
748
ReverseNullableIBinderArray(const std::optional<vector<sp<IBinder>>> & input,std::optional<vector<sp<IBinder>>> * repeated,std::optional<vector<sp<IBinder>>> * _aidl_return)749 Status ReverseNullableIBinderArray(const std::optional<vector<sp<IBinder>>>& input,
750 std::optional<vector<sp<IBinder>>>* repeated,
751 std::optional<vector<sp<IBinder>>>* _aidl_return) override {
752 *repeated = input;
753 *_aidl_return = input;
754 if (*_aidl_return) {
755 std::reverse((*_aidl_return)->begin(), (*_aidl_return)->end());
756 }
757 return Status::ok();
758 }
759
RepeatSimpleParcelable(const SimpleParcelable & input,SimpleParcelable * repeat,SimpleParcelable * _aidl_return)760 Status RepeatSimpleParcelable(const SimpleParcelable& input, SimpleParcelable* repeat,
761 SimpleParcelable* _aidl_return) override {
762 ALOGI("Repeated a SimpleParcelable %s", input.toString().c_str());
763 *repeat = input;
764 *_aidl_return = input;
765 return Status::ok();
766 }
767
ReverseSimpleParcelables(const vector<SimpleParcelable> & input,vector<SimpleParcelable> * repeated,vector<SimpleParcelable> * _aidl_return)768 Status ReverseSimpleParcelables(const vector<SimpleParcelable>& input,
769 vector<SimpleParcelable>* repeated,
770 vector<SimpleParcelable>* _aidl_return) override {
771 return ReverseArray(input, repeated, _aidl_return);
772 }
773
UnimplementedMethod(int32_t,int32_t *)774 Status UnimplementedMethod(int32_t /* arg */, int32_t* /* _aidl_return */) override {
775 LOG_ALWAYS_FATAL("UnimplementedMethod shouldn't be called");
776 }
777
GetOldNameInterface(sp<IOldName> * ret)778 Status GetOldNameInterface(sp<IOldName>* ret) {
779 *ret = new OldName;
780 return Status::ok();
781 }
782
GetNewNameInterface(sp<INewName> * ret)783 Status GetNewNameInterface(sp<INewName>* ret) {
784 *ret = new NewName;
785 return Status::ok();
786 }
787
GetUnionTags(const std::vector<Union> & input,std::vector<Union::Tag> * _aidl_return)788 Status GetUnionTags(const std::vector<Union>& input,
789 std::vector<Union::Tag>* _aidl_return) override {
790 std::vector<Union::Tag> tags;
791 std::transform(input.begin(), input.end(), std::back_inserter(tags),
792 std::mem_fn(&Union::getTag));
793 *_aidl_return = std::move(tags);
794 return Status::ok();
795 }
796
GetCppJavaTests(sp<IBinder> * ret)797 Status GetCppJavaTests(sp<IBinder>* ret) {
798 *ret = new CppJavaTests;
799 return Status::ok();
800 }
801
getBackendType(BackendType * _aidl_return)802 Status getBackendType(BackendType* _aidl_return) override {
803 *_aidl_return = BackendType::CPP;
804 return Status::ok();
805 }
806
GetCircular(CircularParcelable * cp,sp<ICircular> * _aidl_return)807 Status GetCircular(CircularParcelable* cp, sp<ICircular>* _aidl_return) override {
808 auto srv = sp<ITestService>::fromExisting(this);
809 cp->testService = srv;
810 *_aidl_return = new Circular(srv);
811 return Status::ok();
812 }
813
onTransact(uint32_t code,const Parcel & data,Parcel * reply,uint32_t flags)814 status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) override {
815 if (code == ::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* UnimplementedMethod */) {
816 // pretend that UnimplementedMethod isn't implemented by this service.
817 return android::UNKNOWN_TRANSACTION;
818 } else {
819 return BnTestService::onTransact(code, data, reply, flags);
820 }
821 }
822
823 private:
824 map<String16, sp<INamedCallback>> service_map_;
825 std::mutex service_map_mutex_;
826 };
827
828 class VersionedService : public android::aidl::versioned::tests::BnFooInterface {
829 public:
VersionedService()830 VersionedService() {}
831 virtual ~VersionedService() = default;
832
originalApi()833 Status originalApi() override { return Status::ok(); }
acceptUnionAndReturnString(const::android::aidl::versioned::tests::BazUnion & u,std::string * _aidl_return)834 Status acceptUnionAndReturnString(const ::android::aidl::versioned::tests::BazUnion& u,
835 std::string* _aidl_return) override {
836 switch (u.getTag()) {
837 case ::android::aidl::versioned::tests::BazUnion::intNum:
838 *_aidl_return =
839 std::to_string(u.get<::android::aidl::versioned::tests::BazUnion::intNum>());
840 break;
841 }
842 return Status::ok();
843 }
returnsLengthOfFooArray(const vector<::android::aidl::versioned::tests::Foo> & foos,int32_t * ret)844 Status returnsLengthOfFooArray(const vector<::android::aidl::versioned::tests::Foo>& foos,
845 int32_t* ret) override {
846 *ret = static_cast<int32_t>(foos.size());
847 return Status::ok();
848 }
ignoreParcelablesAndRepeatInt(const::android::aidl::versioned::tests::Foo & inFoo,::android::aidl::versioned::tests::Foo * inoutFoo,::android::aidl::versioned::tests::Foo * outFoo,int32_t value,int32_t * ret)849 Status ignoreParcelablesAndRepeatInt(const ::android::aidl::versioned::tests::Foo& inFoo,
850 ::android::aidl::versioned::tests::Foo* inoutFoo,
851 ::android::aidl::versioned::tests::Foo* outFoo,
852 int32_t value, int32_t* ret) override {
853 (void)inFoo;
854 (void)inoutFoo;
855 (void)outFoo;
856 *ret = value;
857 return Status::ok();
858 }
859 };
860
861 class TrunkStableService : public android::aidl::test::trunk::BnTrunkStableTest {
862 public:
TrunkStableService()863 TrunkStableService() {}
864 virtual ~TrunkStableService() = default;
865
repeatParcelable(const::android::aidl::test::trunk::ITrunkStableTest::MyParcelable & input,::android::aidl::test::trunk::ITrunkStableTest::MyParcelable * _aidl_return)866 Status repeatParcelable(
867 const ::android::aidl::test::trunk::ITrunkStableTest::MyParcelable& input,
868 ::android::aidl::test::trunk::ITrunkStableTest::MyParcelable* _aidl_return) override {
869 *_aidl_return = input;
870 return Status::ok();
871 }
repeatEnum(::android::aidl::test::trunk::ITrunkStableTest::MyEnum input,::android::aidl::test::trunk::ITrunkStableTest::MyEnum * _aidl_return)872 Status repeatEnum(::android::aidl::test::trunk::ITrunkStableTest::MyEnum input,
873 ::android::aidl::test::trunk::ITrunkStableTest::MyEnum* _aidl_return) override {
874 *_aidl_return = input;
875 return Status::ok();
876 }
repeatUnion(const::android::aidl::test::trunk::ITrunkStableTest::MyUnion & input,::android::aidl::test::trunk::ITrunkStableTest::MyUnion * _aidl_return)877 Status repeatUnion(
878 const ::android::aidl::test::trunk::ITrunkStableTest::MyUnion& input,
879 ::android::aidl::test::trunk::ITrunkStableTest::MyUnion* _aidl_return) override {
880 *_aidl_return = input;
881 return Status::ok();
882 }
callMyCallback(const::android::sp<::android::aidl::test::trunk::ITrunkStableTest::IMyCallback> & cb)883 Status callMyCallback(
884 const ::android::sp<::android::aidl::test::trunk::ITrunkStableTest::IMyCallback>& cb)
885 override {
886 if (!cb) return Status::fromExceptionCode(Status::Exception::EX_NULL_POINTER);
887 MyParcelable a, b;
888 MyEnum c = MyEnum::ZERO, d = MyEnum::ZERO;
889 MyUnion e, f;
890 auto status = cb->repeatParcelable(a, &b);
891 if (!status.isOk()) {
892 return status;
893 }
894 status = cb->repeatEnum(c, &d);
895 if (!status.isOk()) {
896 return status;
897 }
898 status = cb->repeatUnion(e, &f);
899 if (!status.isOk()) {
900 return status;
901 }
902 MyOtherParcelable g, h;
903 status = cb->repeatOtherParcelable(g, &h);
904 return Status::ok();
905 }
906
repeatOtherParcelable(const::android::aidl::test::trunk::ITrunkStableTest::MyOtherParcelable & input,::android::aidl::test::trunk::ITrunkStableTest::MyOtherParcelable * _aidl_return)907 Status repeatOtherParcelable(
908 const ::android::aidl::test::trunk::ITrunkStableTest::MyOtherParcelable& input,
909 ::android::aidl::test::trunk::ITrunkStableTest::MyOtherParcelable* _aidl_return) override {
910 *_aidl_return = input;
911 return Status::ok();
912 }
913 };
914
915 class LoggableInterfaceService : public android::aidl::loggable::BnLoggableInterface {
916 public:
LoggableInterfaceService()917 LoggableInterfaceService() {}
918 virtual ~LoggableInterfaceService() = default;
919
LogThis(bool,vector<bool> *,int8_t,vector<uint8_t> *,char16_t,vector<char16_t> *,int32_t,vector<int32_t> *,int64_t,vector<int64_t> *,float,vector<float> *,double,vector<double> *,const String16 &,vector<String16> *,vector<String16> *,const android::aidl::loggable::Data &,const sp<IBinder> &,optional<ParcelFileDescriptor> *,vector<ParcelFileDescriptor> *,vector<String16> * _aidl_return)920 virtual Status LogThis(bool, vector<bool>*, int8_t, vector<uint8_t>*, char16_t, vector<char16_t>*,
921 int32_t, vector<int32_t>*, int64_t, vector<int64_t>*, float,
922 vector<float>*, double, vector<double>*, const String16&,
923 vector<String16>*, vector<String16>*, const android::aidl::loggable::Data&,
924 const sp<IBinder>&, optional<ParcelFileDescriptor>*,
925 vector<ParcelFileDescriptor>*, vector<String16>* _aidl_return) override {
926 *_aidl_return = vector<String16>{String16("loggable")};
927 return Status::ok();
928 }
929 };
930
931 using namespace android::aidl::tests::nested;
932 class NestedService : public BnNestedService {
933 public:
NestedService()934 NestedService() {}
935 virtual ~NestedService() = default;
936
flipStatus(const ParcelableWithNested & p,INestedService::Result * _aidl_return)937 virtual Status flipStatus(const ParcelableWithNested& p, INestedService::Result* _aidl_return) {
938 if (p.status == ParcelableWithNested::Status::OK) {
939 _aidl_return->status = ParcelableWithNested::Status::NOT_OK;
940 } else {
941 _aidl_return->status = ParcelableWithNested::Status::OK;
942 }
943 return Status::ok();
944 }
flipStatusWithCallback(ParcelableWithNested::Status status,const sp<INestedService::ICallback> & cb)945 virtual Status flipStatusWithCallback(ParcelableWithNested::Status status,
946 const sp<INestedService::ICallback>& cb) {
947 if (status == ParcelableWithNested::Status::OK) {
948 return cb->done(ParcelableWithNested::Status::NOT_OK);
949 } else {
950 return cb->done(ParcelableWithNested::Status::OK);
951 }
952 }
953 };
954
955 using android::aidl::fixedsizearray::FixedSizeArrayExample;
956 class FixedSizeArrayService : public FixedSizeArrayExample::BnRepeatFixedSizeArray {
957 public:
FixedSizeArrayService()958 FixedSizeArrayService() {}
959 virtual ~FixedSizeArrayService() = default;
960
RepeatBytes(const std::array<uint8_t,3> & in_input,std::array<uint8_t,3> * out_repeated,std::array<uint8_t,3> * _aidl_return)961 Status RepeatBytes(const std::array<uint8_t, 3>& in_input, std::array<uint8_t, 3>* out_repeated,
962 std::array<uint8_t, 3>* _aidl_return) override {
963 *out_repeated = in_input;
964 *_aidl_return = in_input;
965 return Status::ok();
966 }
RepeatInts(const std::array<int32_t,3> & in_input,std::array<int32_t,3> * out_repeated,std::array<int32_t,3> * _aidl_return)967 Status RepeatInts(const std::array<int32_t, 3>& in_input, std::array<int32_t, 3>* out_repeated,
968 std::array<int32_t, 3>* _aidl_return) override {
969 *out_repeated = in_input;
970 *_aidl_return = in_input;
971 return Status::ok();
972 }
RepeatBinders(const std::array<sp<IBinder>,3> & in_input,std::array<sp<IBinder>,3> * out_repeated,std::array<sp<IBinder>,3> * _aidl_return)973 Status RepeatBinders(const std::array<sp<IBinder>, 3>& in_input,
974 std::array<sp<IBinder>, 3>* out_repeated,
975 std::array<sp<IBinder>, 3>* _aidl_return) override {
976 *out_repeated = in_input;
977 *_aidl_return = in_input;
978 return Status::ok();
979 }
RepeatParcelables(const std::array<FixedSizeArrayExample::IntParcelable,3> & in_input,std::array<FixedSizeArrayExample::IntParcelable,3> * out_repeated,std::array<FixedSizeArrayExample::IntParcelable,3> * _aidl_return)980 Status RepeatParcelables(
981 const std::array<FixedSizeArrayExample::IntParcelable, 3>& in_input,
982 std::array<FixedSizeArrayExample::IntParcelable, 3>* out_repeated,
983 std::array<FixedSizeArrayExample::IntParcelable, 3>* _aidl_return) override {
984 *out_repeated = in_input;
985 *_aidl_return = in_input;
986 return Status::ok();
987 }
Repeat2dBytes(const std::array<std::array<uint8_t,3>,2> & in_input,std::array<std::array<uint8_t,3>,2> * out_repeated,std::array<std::array<uint8_t,3>,2> * _aidl_return)988 Status Repeat2dBytes(const std::array<std::array<uint8_t, 3>, 2>& in_input,
989 std::array<std::array<uint8_t, 3>, 2>* out_repeated,
990 std::array<std::array<uint8_t, 3>, 2>* _aidl_return) override {
991 *out_repeated = in_input;
992 *_aidl_return = in_input;
993 return Status::ok();
994 }
Repeat2dInts(const std::array<std::array<int32_t,3>,2> & in_input,std::array<std::array<int32_t,3>,2> * out_repeated,std::array<std::array<int32_t,3>,2> * _aidl_return)995 Status Repeat2dInts(const std::array<std::array<int32_t, 3>, 2>& in_input,
996 std::array<std::array<int32_t, 3>, 2>* out_repeated,
997 std::array<std::array<int32_t, 3>, 2>* _aidl_return) override {
998 *out_repeated = in_input;
999 *_aidl_return = in_input;
1000 return Status::ok();
1001 }
Repeat2dBinders(const std::array<std::array<sp<IBinder>,3>,2> & in_input,std::array<std::array<sp<IBinder>,3>,2> * out_repeated,std::array<std::array<sp<IBinder>,3>,2> * _aidl_return)1002 Status Repeat2dBinders(const std::array<std::array<sp<IBinder>, 3>, 2>& in_input,
1003 std::array<std::array<sp<IBinder>, 3>, 2>* out_repeated,
1004 std::array<std::array<sp<IBinder>, 3>, 2>* _aidl_return) override {
1005 *out_repeated = in_input;
1006 *_aidl_return = in_input;
1007 return Status::ok();
1008 }
Repeat2dParcelables(const std::array<std::array<FixedSizeArrayExample::IntParcelable,3>,2> & in_input,std::array<std::array<FixedSizeArrayExample::IntParcelable,3>,2> * out_repeated,std::array<std::array<FixedSizeArrayExample::IntParcelable,3>,2> * _aidl_return)1009 Status Repeat2dParcelables(
1010 const std::array<std::array<FixedSizeArrayExample::IntParcelable, 3>, 2>& in_input,
1011 std::array<std::array<FixedSizeArrayExample::IntParcelable, 3>, 2>* out_repeated,
1012 std::array<std::array<FixedSizeArrayExample::IntParcelable, 3>, 2>* _aidl_return) override {
1013 *out_repeated = in_input;
1014 *_aidl_return = in_input;
1015 return Status::ok();
1016 }
1017 };
1018
1019 } // namespace
1020
main(int,char * [])1021 int main(int /* argc */, char* /* argv */[]) {
1022 IPCThreadState::self()->disableBackgroundScheduling(true);
1023
1024 std::vector<sp<IBinder>> services = {
1025 sp<FixedSizeArrayService>::make(), sp<LoggableInterfaceService>::make(),
1026 sp<NativeService>::make(), sp<NestedService>::make(),
1027 sp<TrunkStableService>::make(), sp<VersionedService>::make(),
1028 };
1029
1030 for (const auto& service : services) {
1031 status_t status =
1032 defaultServiceManager()->addService(service->getInterfaceDescriptor(), service);
1033 if (status != OK) {
1034 ALOGE("Failed to add service %s", String8(service->getInterfaceDescriptor()).c_str());
1035 return EXIT_FAILURE;
1036 }
1037 }
1038
1039 IPCThreadState::self()->joinThreadPool();
1040 return EXIT_FAILURE;
1041 }
1042