test_data_ping_responder.cpp 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
  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. #include "tests/test_data.h"
  17. namespace android {
  18. namespace aidl {
  19. namespace test_data {
  20. namespace ping_responder {
  21. const char kCanonicalName[] = "android.os.IPingResponder";
  22. const char kInterfaceDefinition[] = R"(
  23. package android.os;
  24. import bar.Unused;
  25. interface IPingResponder {
  26. String Ping(String input);
  27. @nullable
  28. String NullablePing(@nullable String input);
  29. @utf8InCpp
  30. String Utf8Ping(@utf8InCpp String input);
  31. @utf8InCpp @nullable
  32. String NullableUtf8Ping(@utf8InCpp @nullable String input);
  33. }
  34. )";
  35. const char kCppOutputPath[] = "some/path/to/output.cpp";
  36. const char kCppParcelableHeader[] = "cpp-header-str";
  37. const char* kImportedParcelables[] = {
  38. "bar.Unused",
  39. nullptr,
  40. };
  41. const char* kImportedInterfaces[] = {
  42. nullptr,
  43. };
  44. const char kGenHeaderDir[] = "some/path";
  45. const char kGenInterfaceHeaderPath[] = "some/path/android/os/IPingResponder.h";
  46. const char kGenClientHeaderPath[] = "some/path/android/os/BpPingResponder.h";
  47. const char kGenServerHeaderPath[] = "some/path/android/os/BnPingResponder.h";
  48. const char kExpectedCppDepsOutput[] =
  49. R"(some/path/to/output.cpp : \
  50. android/os/IPingResponder.aidl \
  51. ./bar/Unused.aidl
  52. android/os/IPingResponder.aidl :
  53. ./bar/Unused.aidl :
  54. some/path/android/os/BpPingResponder.h \
  55. some/path/android/os/BnPingResponder.h \
  56. some/path/android/os/IPingResponder.h : \
  57. android/os/IPingResponder.aidl \
  58. ./bar/Unused.aidl
  59. )";
  60. const char kExpectedCppOutput[] =
  61. R"(#include <android/os/IPingResponder.h>
  62. #include <android/os/BpPingResponder.h>
  63. namespace android {
  64. namespace os {
  65. IMPLEMENT_META_INTERFACE(PingResponder, "android.os.IPingResponder")
  66. ::android::IBinder* IPingResponderDefault::onAsBinder() {
  67. return nullptr;
  68. }
  69. ::android::binder::Status IPingResponderDefault::Ping(const ::android::String16&, ::android::String16* ) {
  70. return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
  71. }
  72. ::android::binder::Status IPingResponderDefault::NullablePing(const ::std::unique_ptr<::android::String16>&, ::std::unique_ptr<::android::String16>* ) {
  73. return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
  74. }
  75. ::android::binder::Status IPingResponderDefault::Utf8Ping(const ::std::string&, ::std::string* ) {
  76. return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
  77. }
  78. ::android::binder::Status IPingResponderDefault::NullableUtf8Ping(const ::std::unique_ptr<::std::string>&, ::std::unique_ptr<::std::string>* ) {
  79. return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
  80. }
  81. } // namespace os
  82. } // namespace android
  83. #include <android/os/BpPingResponder.h>
  84. #include <binder/Parcel.h>
  85. #include <android-base/macros.h>
  86. namespace android {
  87. namespace os {
  88. BpPingResponder::BpPingResponder(const ::android::sp<::android::IBinder>& _aidl_impl)
  89. : BpInterface<IPingResponder>(_aidl_impl){
  90. }
  91. ::android::binder::Status BpPingResponder::Ping(const ::android::String16& input, ::android::String16* _aidl_return) {
  92. ::android::Parcel _aidl_data;
  93. ::android::Parcel _aidl_reply;
  94. ::android::status_t _aidl_ret_status = ::android::OK;
  95. ::android::binder::Status _aidl_status;
  96. _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
  97. if (((_aidl_ret_status) != (::android::OK))) {
  98. goto _aidl_error;
  99. }
  100. _aidl_ret_status = _aidl_data.writeString16(input);
  101. if (((_aidl_ret_status) != (::android::OK))) {
  102. goto _aidl_error;
  103. }
  104. _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* Ping */, _aidl_data, &_aidl_reply);
  105. if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IPingResponder::getDefaultImpl())) {
  106. return IPingResponder::getDefaultImpl()->Ping(input, _aidl_return);
  107. }
  108. if (((_aidl_ret_status) != (::android::OK))) {
  109. goto _aidl_error;
  110. }
  111. _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
  112. if (((_aidl_ret_status) != (::android::OK))) {
  113. goto _aidl_error;
  114. }
  115. if (!_aidl_status.isOk()) {
  116. return _aidl_status;
  117. }
  118. _aidl_ret_status = _aidl_reply.readString16(_aidl_return);
  119. if (((_aidl_ret_status) != (::android::OK))) {
  120. goto _aidl_error;
  121. }
  122. _aidl_error:
  123. _aidl_status.setFromStatusT(_aidl_ret_status);
  124. return _aidl_status;
  125. }
  126. ::android::binder::Status BpPingResponder::NullablePing(const ::std::unique_ptr<::android::String16>& input, ::std::unique_ptr<::android::String16>* _aidl_return) {
  127. ::android::Parcel _aidl_data;
  128. ::android::Parcel _aidl_reply;
  129. ::android::status_t _aidl_ret_status = ::android::OK;
  130. ::android::binder::Status _aidl_status;
  131. _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
  132. if (((_aidl_ret_status) != (::android::OK))) {
  133. goto _aidl_error;
  134. }
  135. _aidl_ret_status = _aidl_data.writeString16(input);
  136. if (((_aidl_ret_status) != (::android::OK))) {
  137. goto _aidl_error;
  138. }
  139. _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* NullablePing */, _aidl_data, &_aidl_reply);
  140. if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IPingResponder::getDefaultImpl())) {
  141. return IPingResponder::getDefaultImpl()->NullablePing(input, _aidl_return);
  142. }
  143. if (((_aidl_ret_status) != (::android::OK))) {
  144. goto _aidl_error;
  145. }
  146. _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
  147. if (((_aidl_ret_status) != (::android::OK))) {
  148. goto _aidl_error;
  149. }
  150. if (!_aidl_status.isOk()) {
  151. return _aidl_status;
  152. }
  153. _aidl_ret_status = _aidl_reply.readString16(_aidl_return);
  154. if (((_aidl_ret_status) != (::android::OK))) {
  155. goto _aidl_error;
  156. }
  157. _aidl_error:
  158. _aidl_status.setFromStatusT(_aidl_ret_status);
  159. return _aidl_status;
  160. }
  161. ::android::binder::Status BpPingResponder::Utf8Ping(const ::std::string& input, ::std::string* _aidl_return) {
  162. ::android::Parcel _aidl_data;
  163. ::android::Parcel _aidl_reply;
  164. ::android::status_t _aidl_ret_status = ::android::OK;
  165. ::android::binder::Status _aidl_status;
  166. _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
  167. if (((_aidl_ret_status) != (::android::OK))) {
  168. goto _aidl_error;
  169. }
  170. _aidl_ret_status = _aidl_data.writeUtf8AsUtf16(input);
  171. if (((_aidl_ret_status) != (::android::OK))) {
  172. goto _aidl_error;
  173. }
  174. _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* Utf8Ping */, _aidl_data, &_aidl_reply);
  175. if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IPingResponder::getDefaultImpl())) {
  176. return IPingResponder::getDefaultImpl()->Utf8Ping(input, _aidl_return);
  177. }
  178. if (((_aidl_ret_status) != (::android::OK))) {
  179. goto _aidl_error;
  180. }
  181. _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
  182. if (((_aidl_ret_status) != (::android::OK))) {
  183. goto _aidl_error;
  184. }
  185. if (!_aidl_status.isOk()) {
  186. return _aidl_status;
  187. }
  188. _aidl_ret_status = _aidl_reply.readUtf8FromUtf16(_aidl_return);
  189. if (((_aidl_ret_status) != (::android::OK))) {
  190. goto _aidl_error;
  191. }
  192. _aidl_error:
  193. _aidl_status.setFromStatusT(_aidl_ret_status);
  194. return _aidl_status;
  195. }
  196. ::android::binder::Status BpPingResponder::NullableUtf8Ping(const ::std::unique_ptr<::std::string>& input, ::std::unique_ptr<::std::string>* _aidl_return) {
  197. ::android::Parcel _aidl_data;
  198. ::android::Parcel _aidl_reply;
  199. ::android::status_t _aidl_ret_status = ::android::OK;
  200. ::android::binder::Status _aidl_status;
  201. _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
  202. if (((_aidl_ret_status) != (::android::OK))) {
  203. goto _aidl_error;
  204. }
  205. _aidl_ret_status = _aidl_data.writeUtf8AsUtf16(input);
  206. if (((_aidl_ret_status) != (::android::OK))) {
  207. goto _aidl_error;
  208. }
  209. _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableUtf8Ping */, _aidl_data, &_aidl_reply);
  210. if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IPingResponder::getDefaultImpl())) {
  211. return IPingResponder::getDefaultImpl()->NullableUtf8Ping(input, _aidl_return);
  212. }
  213. if (((_aidl_ret_status) != (::android::OK))) {
  214. goto _aidl_error;
  215. }
  216. _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
  217. if (((_aidl_ret_status) != (::android::OK))) {
  218. goto _aidl_error;
  219. }
  220. if (!_aidl_status.isOk()) {
  221. return _aidl_status;
  222. }
  223. _aidl_ret_status = _aidl_reply.readUtf8FromUtf16(_aidl_return);
  224. if (((_aidl_ret_status) != (::android::OK))) {
  225. goto _aidl_error;
  226. }
  227. _aidl_error:
  228. _aidl_status.setFromStatusT(_aidl_ret_status);
  229. return _aidl_status;
  230. }
  231. } // namespace os
  232. } // namespace android
  233. #include <android/os/BnPingResponder.h>
  234. #include <binder/Parcel.h>
  235. namespace android {
  236. namespace os {
  237. ::android::status_t BnPingResponder::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) {
  238. ::android::status_t _aidl_ret_status = ::android::OK;
  239. switch (_aidl_code) {
  240. case ::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* Ping */:
  241. {
  242. ::android::String16 in_input;
  243. ::android::String16 _aidl_return;
  244. if (!(_aidl_data.checkInterface(this))) {
  245. _aidl_ret_status = ::android::BAD_TYPE;
  246. break;
  247. }
  248. _aidl_ret_status = _aidl_data.readString16(&in_input);
  249. if (((_aidl_ret_status) != (::android::OK))) {
  250. break;
  251. }
  252. ::android::binder::Status _aidl_status(Ping(in_input, &_aidl_return));
  253. _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
  254. if (((_aidl_ret_status) != (::android::OK))) {
  255. break;
  256. }
  257. if (!_aidl_status.isOk()) {
  258. break;
  259. }
  260. _aidl_ret_status = _aidl_reply->writeString16(_aidl_return);
  261. if (((_aidl_ret_status) != (::android::OK))) {
  262. break;
  263. }
  264. }
  265. break;
  266. case ::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* NullablePing */:
  267. {
  268. ::std::unique_ptr<::android::String16> in_input;
  269. ::std::unique_ptr<::android::String16> _aidl_return;
  270. if (!(_aidl_data.checkInterface(this))) {
  271. _aidl_ret_status = ::android::BAD_TYPE;
  272. break;
  273. }
  274. _aidl_ret_status = _aidl_data.readString16(&in_input);
  275. if (((_aidl_ret_status) != (::android::OK))) {
  276. break;
  277. }
  278. ::android::binder::Status _aidl_status(NullablePing(in_input, &_aidl_return));
  279. _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
  280. if (((_aidl_ret_status) != (::android::OK))) {
  281. break;
  282. }
  283. if (!_aidl_status.isOk()) {
  284. break;
  285. }
  286. _aidl_ret_status = _aidl_reply->writeString16(_aidl_return);
  287. if (((_aidl_ret_status) != (::android::OK))) {
  288. break;
  289. }
  290. }
  291. break;
  292. case ::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* Utf8Ping */:
  293. {
  294. ::std::string in_input;
  295. ::std::string _aidl_return;
  296. if (!(_aidl_data.checkInterface(this))) {
  297. _aidl_ret_status = ::android::BAD_TYPE;
  298. break;
  299. }
  300. _aidl_ret_status = _aidl_data.readUtf8FromUtf16(&in_input);
  301. if (((_aidl_ret_status) != (::android::OK))) {
  302. break;
  303. }
  304. ::android::binder::Status _aidl_status(Utf8Ping(in_input, &_aidl_return));
  305. _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
  306. if (((_aidl_ret_status) != (::android::OK))) {
  307. break;
  308. }
  309. if (!_aidl_status.isOk()) {
  310. break;
  311. }
  312. _aidl_ret_status = _aidl_reply->writeUtf8AsUtf16(_aidl_return);
  313. if (((_aidl_ret_status) != (::android::OK))) {
  314. break;
  315. }
  316. }
  317. break;
  318. case ::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableUtf8Ping */:
  319. {
  320. ::std::unique_ptr<::std::string> in_input;
  321. ::std::unique_ptr<::std::string> _aidl_return;
  322. if (!(_aidl_data.checkInterface(this))) {
  323. _aidl_ret_status = ::android::BAD_TYPE;
  324. break;
  325. }
  326. _aidl_ret_status = _aidl_data.readUtf8FromUtf16(&in_input);
  327. if (((_aidl_ret_status) != (::android::OK))) {
  328. break;
  329. }
  330. ::android::binder::Status _aidl_status(NullableUtf8Ping(in_input, &_aidl_return));
  331. _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
  332. if (((_aidl_ret_status) != (::android::OK))) {
  333. break;
  334. }
  335. if (!_aidl_status.isOk()) {
  336. break;
  337. }
  338. _aidl_ret_status = _aidl_reply->writeUtf8AsUtf16(_aidl_return);
  339. if (((_aidl_ret_status) != (::android::OK))) {
  340. break;
  341. }
  342. }
  343. break;
  344. default:
  345. {
  346. _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
  347. }
  348. break;
  349. }
  350. if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
  351. _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
  352. }
  353. return _aidl_ret_status;
  354. }
  355. } // namespace os
  356. } // namespace android
  357. )";
  358. const char kExpectedIHeaderOutput[] =
  359. R"(#ifndef AIDL_GENERATED_ANDROID_OS_I_PING_RESPONDER_H_
  360. #define AIDL_GENERATED_ANDROID_OS_I_PING_RESPONDER_H_
  361. #include <binder/IBinder.h>
  362. #include <binder/IInterface.h>
  363. #include <binder/Status.h>
  364. #include <memory>
  365. #include <string>
  366. #include <utils/String16.h>
  367. #include <utils/StrongPointer.h>
  368. namespace android {
  369. namespace os {
  370. class IPingResponder : public ::android::IInterface {
  371. public:
  372. DECLARE_META_INTERFACE(PingResponder)
  373. virtual ::android::binder::Status Ping(const ::android::String16& input, ::android::String16* _aidl_return) = 0;
  374. virtual ::android::binder::Status NullablePing(const ::std::unique_ptr<::android::String16>& input, ::std::unique_ptr<::android::String16>* _aidl_return) = 0;
  375. virtual ::android::binder::Status Utf8Ping(const ::std::string& input, ::std::string* _aidl_return) = 0;
  376. virtual ::android::binder::Status NullableUtf8Ping(const ::std::unique_ptr<::std::string>& input, ::std::unique_ptr<::std::string>* _aidl_return) = 0;
  377. }; // class IPingResponder
  378. class IPingResponderDefault : public IPingResponder {
  379. public:
  380. ::android::IBinder* onAsBinder() override;
  381. ::android::binder::Status Ping(const ::android::String16& input, ::android::String16* _aidl_return) override;
  382. ::android::binder::Status NullablePing(const ::std::unique_ptr<::android::String16>& input, ::std::unique_ptr<::android::String16>* _aidl_return) override;
  383. ::android::binder::Status Utf8Ping(const ::std::string& input, ::std::string* _aidl_return) override;
  384. ::android::binder::Status NullableUtf8Ping(const ::std::unique_ptr<::std::string>& input, ::std::unique_ptr<::std::string>* _aidl_return) override;
  385. };
  386. } // namespace os
  387. } // namespace android
  388. #endif // AIDL_GENERATED_ANDROID_OS_I_PING_RESPONDER_H_
  389. )";
  390. const char kExpectedBpHeaderOutput[] =
  391. R"(#ifndef AIDL_GENERATED_ANDROID_OS_BP_PING_RESPONDER_H_
  392. #define AIDL_GENERATED_ANDROID_OS_BP_PING_RESPONDER_H_
  393. #include <binder/IBinder.h>
  394. #include <binder/IInterface.h>
  395. #include <utils/Errors.h>
  396. #include <android/os/IPingResponder.h>
  397. namespace android {
  398. namespace os {
  399. class BpPingResponder : public ::android::BpInterface<IPingResponder> {
  400. public:
  401. explicit BpPingResponder(const ::android::sp<::android::IBinder>& _aidl_impl);
  402. virtual ~BpPingResponder() = default;
  403. ::android::binder::Status Ping(const ::android::String16& input, ::android::String16* _aidl_return) override;
  404. ::android::binder::Status NullablePing(const ::std::unique_ptr<::android::String16>& input, ::std::unique_ptr<::android::String16>* _aidl_return) override;
  405. ::android::binder::Status Utf8Ping(const ::std::string& input, ::std::string* _aidl_return) override;
  406. ::android::binder::Status NullableUtf8Ping(const ::std::unique_ptr<::std::string>& input, ::std::unique_ptr<::std::string>* _aidl_return) override;
  407. }; // class BpPingResponder
  408. } // namespace os
  409. } // namespace android
  410. #endif // AIDL_GENERATED_ANDROID_OS_BP_PING_RESPONDER_H_
  411. )";
  412. const char kExpectedBnHeaderOutput[] =
  413. R"(#ifndef AIDL_GENERATED_ANDROID_OS_BN_PING_RESPONDER_H_
  414. #define AIDL_GENERATED_ANDROID_OS_BN_PING_RESPONDER_H_
  415. #include <binder/IInterface.h>
  416. #include <android/os/IPingResponder.h>
  417. namespace android {
  418. namespace os {
  419. class BnPingResponder : public ::android::BnInterface<IPingResponder> {
  420. public:
  421. ::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override;
  422. }; // class BnPingResponder
  423. } // namespace os
  424. } // namespace android
  425. #endif // AIDL_GENERATED_ANDROID_OS_BN_PING_RESPONDER_H_
  426. )";
  427. const char kExpectedCppOutputWithVersion[] =
  428. R"(#include <android/os/IPingResponder.h>
  429. #include <android/os/BpPingResponder.h>
  430. namespace android {
  431. namespace os {
  432. IMPLEMENT_META_INTERFACE(PingResponder, "android.os.IPingResponder")
  433. ::android::IBinder* IPingResponderDefault::onAsBinder() {
  434. return nullptr;
  435. }
  436. ::android::binder::Status IPingResponderDefault::Ping(const ::android::String16&, ::android::String16* ) {
  437. return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
  438. }
  439. ::android::binder::Status IPingResponderDefault::NullablePing(const ::std::unique_ptr<::android::String16>&, ::std::unique_ptr<::android::String16>* ) {
  440. return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
  441. }
  442. ::android::binder::Status IPingResponderDefault::Utf8Ping(const ::std::string&, ::std::string* ) {
  443. return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
  444. }
  445. ::android::binder::Status IPingResponderDefault::NullableUtf8Ping(const ::std::unique_ptr<::std::string>&, ::std::unique_ptr<::std::string>* ) {
  446. return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
  447. }
  448. int32_t IPingResponderDefault::getInterfaceVersion() {
  449. return 0;
  450. }
  451. } // namespace os
  452. } // namespace android
  453. #include <android/os/BpPingResponder.h>
  454. #include <binder/Parcel.h>
  455. #include <android-base/macros.h>
  456. namespace android {
  457. namespace os {
  458. BpPingResponder::BpPingResponder(const ::android::sp<::android::IBinder>& _aidl_impl)
  459. : BpInterface<IPingResponder>(_aidl_impl){
  460. }
  461. ::android::binder::Status BpPingResponder::Ping(const ::android::String16& input, ::android::String16* _aidl_return) {
  462. ::android::Parcel _aidl_data;
  463. ::android::Parcel _aidl_reply;
  464. ::android::status_t _aidl_ret_status = ::android::OK;
  465. ::android::binder::Status _aidl_status;
  466. _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
  467. if (((_aidl_ret_status) != (::android::OK))) {
  468. goto _aidl_error;
  469. }
  470. _aidl_ret_status = _aidl_data.writeString16(input);
  471. if (((_aidl_ret_status) != (::android::OK))) {
  472. goto _aidl_error;
  473. }
  474. _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* Ping */, _aidl_data, &_aidl_reply);
  475. if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IPingResponder::getDefaultImpl())) {
  476. return IPingResponder::getDefaultImpl()->Ping(input, _aidl_return);
  477. }
  478. if (((_aidl_ret_status) != (::android::OK))) {
  479. goto _aidl_error;
  480. }
  481. _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
  482. if (((_aidl_ret_status) != (::android::OK))) {
  483. goto _aidl_error;
  484. }
  485. if (!_aidl_status.isOk()) {
  486. return _aidl_status;
  487. }
  488. _aidl_ret_status = _aidl_reply.readString16(_aidl_return);
  489. if (((_aidl_ret_status) != (::android::OK))) {
  490. goto _aidl_error;
  491. }
  492. _aidl_error:
  493. _aidl_status.setFromStatusT(_aidl_ret_status);
  494. return _aidl_status;
  495. }
  496. ::android::binder::Status BpPingResponder::NullablePing(const ::std::unique_ptr<::android::String16>& input, ::std::unique_ptr<::android::String16>* _aidl_return) {
  497. ::android::Parcel _aidl_data;
  498. ::android::Parcel _aidl_reply;
  499. ::android::status_t _aidl_ret_status = ::android::OK;
  500. ::android::binder::Status _aidl_status;
  501. _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
  502. if (((_aidl_ret_status) != (::android::OK))) {
  503. goto _aidl_error;
  504. }
  505. _aidl_ret_status = _aidl_data.writeString16(input);
  506. if (((_aidl_ret_status) != (::android::OK))) {
  507. goto _aidl_error;
  508. }
  509. _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* NullablePing */, _aidl_data, &_aidl_reply);
  510. if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IPingResponder::getDefaultImpl())) {
  511. return IPingResponder::getDefaultImpl()->NullablePing(input, _aidl_return);
  512. }
  513. if (((_aidl_ret_status) != (::android::OK))) {
  514. goto _aidl_error;
  515. }
  516. _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
  517. if (((_aidl_ret_status) != (::android::OK))) {
  518. goto _aidl_error;
  519. }
  520. if (!_aidl_status.isOk()) {
  521. return _aidl_status;
  522. }
  523. _aidl_ret_status = _aidl_reply.readString16(_aidl_return);
  524. if (((_aidl_ret_status) != (::android::OK))) {
  525. goto _aidl_error;
  526. }
  527. _aidl_error:
  528. _aidl_status.setFromStatusT(_aidl_ret_status);
  529. return _aidl_status;
  530. }
  531. ::android::binder::Status BpPingResponder::Utf8Ping(const ::std::string& input, ::std::string* _aidl_return) {
  532. ::android::Parcel _aidl_data;
  533. ::android::Parcel _aidl_reply;
  534. ::android::status_t _aidl_ret_status = ::android::OK;
  535. ::android::binder::Status _aidl_status;
  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.writeUtf8AsUtf16(input);
  541. if (((_aidl_ret_status) != (::android::OK))) {
  542. goto _aidl_error;
  543. }
  544. _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* Utf8Ping */, _aidl_data, &_aidl_reply);
  545. if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IPingResponder::getDefaultImpl())) {
  546. return IPingResponder::getDefaultImpl()->Utf8Ping(input, _aidl_return);
  547. }
  548. if (((_aidl_ret_status) != (::android::OK))) {
  549. goto _aidl_error;
  550. }
  551. _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
  552. if (((_aidl_ret_status) != (::android::OK))) {
  553. goto _aidl_error;
  554. }
  555. if (!_aidl_status.isOk()) {
  556. return _aidl_status;
  557. }
  558. _aidl_ret_status = _aidl_reply.readUtf8FromUtf16(_aidl_return);
  559. if (((_aidl_ret_status) != (::android::OK))) {
  560. goto _aidl_error;
  561. }
  562. _aidl_error:
  563. _aidl_status.setFromStatusT(_aidl_ret_status);
  564. return _aidl_status;
  565. }
  566. ::android::binder::Status BpPingResponder::NullableUtf8Ping(const ::std::unique_ptr<::std::string>& input, ::std::unique_ptr<::std::string>* _aidl_return) {
  567. ::android::Parcel _aidl_data;
  568. ::android::Parcel _aidl_reply;
  569. ::android::status_t _aidl_ret_status = ::android::OK;
  570. ::android::binder::Status _aidl_status;
  571. _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
  572. if (((_aidl_ret_status) != (::android::OK))) {
  573. goto _aidl_error;
  574. }
  575. _aidl_ret_status = _aidl_data.writeUtf8AsUtf16(input);
  576. if (((_aidl_ret_status) != (::android::OK))) {
  577. goto _aidl_error;
  578. }
  579. _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableUtf8Ping */, _aidl_data, &_aidl_reply);
  580. if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IPingResponder::getDefaultImpl())) {
  581. return IPingResponder::getDefaultImpl()->NullableUtf8Ping(input, _aidl_return);
  582. }
  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.readUtf8FromUtf16(_aidl_return);
  594. if (((_aidl_ret_status) != (::android::OK))) {
  595. goto _aidl_error;
  596. }
  597. _aidl_error:
  598. _aidl_status.setFromStatusT(_aidl_ret_status);
  599. return _aidl_status;
  600. }
  601. int32_t BpPingResponder::getInterfaceVersion() {
  602. if (cached_version_ == -1) {
  603. ::android::Parcel data;
  604. ::android::Parcel reply;
  605. data.writeInterfaceToken(getInterfaceDescriptor());
  606. ::android::status_t err = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 16777214 /* getInterfaceVersion */, data, &reply);
  607. if (err == ::android::OK) {
  608. ::android::binder::Status _aidl_status;
  609. err = _aidl_status.readFromParcel(reply);
  610. if (err == ::android::OK && _aidl_status.isOk()) {
  611. cached_version_ = reply.readInt32();
  612. }
  613. }
  614. }
  615. return cached_version_;
  616. }
  617. } // namespace os
  618. } // namespace android
  619. #include <android/os/BnPingResponder.h>
  620. #include <binder/Parcel.h>
  621. namespace android {
  622. namespace os {
  623. ::android::status_t BnPingResponder::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) {
  624. ::android::status_t _aidl_ret_status = ::android::OK;
  625. switch (_aidl_code) {
  626. case ::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* Ping */:
  627. {
  628. ::android::String16 in_input;
  629. ::android::String16 _aidl_return;
  630. if (!(_aidl_data.checkInterface(this))) {
  631. _aidl_ret_status = ::android::BAD_TYPE;
  632. break;
  633. }
  634. _aidl_ret_status = _aidl_data.readString16(&in_input);
  635. if (((_aidl_ret_status) != (::android::OK))) {
  636. break;
  637. }
  638. ::android::binder::Status _aidl_status(Ping(in_input, &_aidl_return));
  639. _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
  640. if (((_aidl_ret_status) != (::android::OK))) {
  641. break;
  642. }
  643. if (!_aidl_status.isOk()) {
  644. break;
  645. }
  646. _aidl_ret_status = _aidl_reply->writeString16(_aidl_return);
  647. if (((_aidl_ret_status) != (::android::OK))) {
  648. break;
  649. }
  650. }
  651. break;
  652. case ::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* NullablePing */:
  653. {
  654. ::std::unique_ptr<::android::String16> in_input;
  655. ::std::unique_ptr<::android::String16> _aidl_return;
  656. if (!(_aidl_data.checkInterface(this))) {
  657. _aidl_ret_status = ::android::BAD_TYPE;
  658. break;
  659. }
  660. _aidl_ret_status = _aidl_data.readString16(&in_input);
  661. if (((_aidl_ret_status) != (::android::OK))) {
  662. break;
  663. }
  664. ::android::binder::Status _aidl_status(NullablePing(in_input, &_aidl_return));
  665. _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
  666. if (((_aidl_ret_status) != (::android::OK))) {
  667. break;
  668. }
  669. if (!_aidl_status.isOk()) {
  670. break;
  671. }
  672. _aidl_ret_status = _aidl_reply->writeString16(_aidl_return);
  673. if (((_aidl_ret_status) != (::android::OK))) {
  674. break;
  675. }
  676. }
  677. break;
  678. case ::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* Utf8Ping */:
  679. {
  680. ::std::string in_input;
  681. ::std::string _aidl_return;
  682. if (!(_aidl_data.checkInterface(this))) {
  683. _aidl_ret_status = ::android::BAD_TYPE;
  684. break;
  685. }
  686. _aidl_ret_status = _aidl_data.readUtf8FromUtf16(&in_input);
  687. if (((_aidl_ret_status) != (::android::OK))) {
  688. break;
  689. }
  690. ::android::binder::Status _aidl_status(Utf8Ping(in_input, &_aidl_return));
  691. _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
  692. if (((_aidl_ret_status) != (::android::OK))) {
  693. break;
  694. }
  695. if (!_aidl_status.isOk()) {
  696. break;
  697. }
  698. _aidl_ret_status = _aidl_reply->writeUtf8AsUtf16(_aidl_return);
  699. if (((_aidl_ret_status) != (::android::OK))) {
  700. break;
  701. }
  702. }
  703. break;
  704. case ::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableUtf8Ping */:
  705. {
  706. ::std::unique_ptr<::std::string> in_input;
  707. ::std::unique_ptr<::std::string> _aidl_return;
  708. if (!(_aidl_data.checkInterface(this))) {
  709. _aidl_ret_status = ::android::BAD_TYPE;
  710. break;
  711. }
  712. _aidl_ret_status = _aidl_data.readUtf8FromUtf16(&in_input);
  713. if (((_aidl_ret_status) != (::android::OK))) {
  714. break;
  715. }
  716. ::android::binder::Status _aidl_status(NullableUtf8Ping(in_input, &_aidl_return));
  717. _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
  718. if (((_aidl_ret_status) != (::android::OK))) {
  719. break;
  720. }
  721. if (!_aidl_status.isOk()) {
  722. break;
  723. }
  724. _aidl_ret_status = _aidl_reply->writeUtf8AsUtf16(_aidl_return);
  725. if (((_aidl_ret_status) != (::android::OK))) {
  726. break;
  727. }
  728. }
  729. break;
  730. case ::android::IBinder::FIRST_CALL_TRANSACTION + 16777214 /* getInterfaceVersion */:
  731. {
  732. _aidl_data.checkInterface(this);
  733. _aidl_reply->writeNoException();
  734. _aidl_reply->writeInt32(IPingResponder::VERSION);
  735. }
  736. break;
  737. default:
  738. {
  739. _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
  740. }
  741. break;
  742. }
  743. if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
  744. _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
  745. }
  746. return _aidl_ret_status;
  747. }
  748. int32_t BnPingResponder::getInterfaceVersion() {
  749. return IPingResponder::VERSION;
  750. }
  751. } // namespace os
  752. } // namespace android
  753. )";
  754. const char kExpectedIHeaderOutputWithVersion[] =
  755. R"(#ifndef AIDL_GENERATED_ANDROID_OS_I_PING_RESPONDER_H_
  756. #define AIDL_GENERATED_ANDROID_OS_I_PING_RESPONDER_H_
  757. #include <binder/IBinder.h>
  758. #include <binder/IInterface.h>
  759. #include <binder/Status.h>
  760. #include <memory>
  761. #include <string>
  762. #include <utils/String16.h>
  763. #include <utils/StrongPointer.h>
  764. namespace android {
  765. namespace os {
  766. class IPingResponder : public ::android::IInterface {
  767. public:
  768. DECLARE_META_INTERFACE(PingResponder)
  769. const int32_t VERSION = 10;
  770. virtual ::android::binder::Status Ping(const ::android::String16& input, ::android::String16* _aidl_return) = 0;
  771. virtual ::android::binder::Status NullablePing(const ::std::unique_ptr<::android::String16>& input, ::std::unique_ptr<::android::String16>* _aidl_return) = 0;
  772. virtual ::android::binder::Status Utf8Ping(const ::std::string& input, ::std::string* _aidl_return) = 0;
  773. virtual ::android::binder::Status NullableUtf8Ping(const ::std::unique_ptr<::std::string>& input, ::std::unique_ptr<::std::string>* _aidl_return) = 0;
  774. virtual int32_t getInterfaceVersion() = 0;
  775. }; // class IPingResponder
  776. class IPingResponderDefault : public IPingResponder {
  777. public:
  778. ::android::IBinder* onAsBinder() override;
  779. ::android::binder::Status Ping(const ::android::String16& input, ::android::String16* _aidl_return) override;
  780. ::android::binder::Status NullablePing(const ::std::unique_ptr<::android::String16>& input, ::std::unique_ptr<::android::String16>* _aidl_return) override;
  781. ::android::binder::Status Utf8Ping(const ::std::string& input, ::std::string* _aidl_return) override;
  782. ::android::binder::Status NullableUtf8Ping(const ::std::unique_ptr<::std::string>& input, ::std::unique_ptr<::std::string>* _aidl_return) override;
  783. int32_t getInterfaceVersion() override;
  784. };
  785. } // namespace os
  786. } // namespace android
  787. #endif // AIDL_GENERATED_ANDROID_OS_I_PING_RESPONDER_H_
  788. )";
  789. const char kExpectedBpHeaderOutputWithVersion[] =
  790. R"(#ifndef AIDL_GENERATED_ANDROID_OS_BP_PING_RESPONDER_H_
  791. #define AIDL_GENERATED_ANDROID_OS_BP_PING_RESPONDER_H_
  792. #include <binder/IBinder.h>
  793. #include <binder/IInterface.h>
  794. #include <utils/Errors.h>
  795. #include <android/os/IPingResponder.h>
  796. namespace android {
  797. namespace os {
  798. class BpPingResponder : public ::android::BpInterface<IPingResponder> {
  799. public:
  800. explicit BpPingResponder(const ::android::sp<::android::IBinder>& _aidl_impl);
  801. virtual ~BpPingResponder() = default;
  802. ::android::binder::Status Ping(const ::android::String16& input, ::android::String16* _aidl_return) override;
  803. ::android::binder::Status NullablePing(const ::std::unique_ptr<::android::String16>& input, ::std::unique_ptr<::android::String16>* _aidl_return) override;
  804. ::android::binder::Status Utf8Ping(const ::std::string& input, ::std::string* _aidl_return) override;
  805. ::android::binder::Status NullableUtf8Ping(const ::std::unique_ptr<::std::string>& input, ::std::unique_ptr<::std::string>* _aidl_return) override;
  806. int32_t getInterfaceVersion() override;
  807. private:
  808. int32_t cached_version_ = -1;
  809. }; // class BpPingResponder
  810. } // namespace os
  811. } // namespace android
  812. #endif // AIDL_GENERATED_ANDROID_OS_BP_PING_RESPONDER_H_
  813. )";
  814. const char kExpectedBnHeaderOutputWithVersion[] =
  815. R"(#ifndef AIDL_GENERATED_ANDROID_OS_BN_PING_RESPONDER_H_
  816. #define AIDL_GENERATED_ANDROID_OS_BN_PING_RESPONDER_H_
  817. #include <binder/IInterface.h>
  818. #include <android/os/IPingResponder.h>
  819. namespace android {
  820. namespace os {
  821. class BnPingResponder : public ::android::BnInterface<IPingResponder> {
  822. public:
  823. ::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override;
  824. int32_t getInterfaceVersion() final override;
  825. }; // class BnPingResponder
  826. } // namespace os
  827. } // namespace android
  828. #endif // AIDL_GENERATED_ANDROID_OS_BN_PING_RESPONDER_H_
  829. )";
  830. } // namespace ping_responder
  831. } // namespace test_data
  832. } // namespace aidl
  833. } // namespace android