Support IBinder array in the NDK/Rust backends.
IBinder[] in AIDL is mapped to
- vector<SpAIBinder> in NDK
- Vec<SpIBinder>, [&SpIBinder], Vec<Option<SpIBinder>> in Rust (according to the
position)
@nullable IBinder[] in AIDL is mapped to
- optional<vector<optional<SpAIBinder>>> in NDK
- Option<Vec<Option<SpIBinder>>>, Option<&[Option<SpIBinder>]> in Rust
Bug: 151817759
Test: aidl_integration_test, aidl_unittests, golden_test.sh check
Change-Id: I34d0afe9621a95ac9a06487915ee933cccb3d5ed
diff --git a/Android.bp b/Android.bp
index f198914..6948749 100644
--- a/Android.bp
+++ b/Android.bp
@@ -410,6 +410,7 @@
"tests/aidl_test_client_ndk_parcelables.cpp",
"tests/aidl_test_client_ndk_versioned_interface.cpp",
"tests/aidl_test_client_ndk_nested.cpp",
+ "tests/aidl_test_client_ndk_nullables.cpp",
],
}
diff --git a/aidl_language.cpp b/aidl_language.cpp
index 39db473..5d74338 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -1276,11 +1276,6 @@
}
if ((lang == Options::Language::NDK || lang == Options::Language::RUST) && IsArray() &&
- GetName() == "IBinder") {
- AIDL_ERROR(this) << "The " << to_string(lang) << " backend does not support array of IBinder";
- return false;
- }
- if ((lang == Options::Language::NDK || lang == Options::Language::RUST) && IsArray() &&
IsNullable()) {
if (GetName() == "ParcelFileDescriptor") {
AIDL_ERROR(this) << "The " << to_string(lang)
diff --git a/aidl_to_ndk.cpp b/aidl_to_ndk.cpp
index 49766e0..f4557d7 100644
--- a/aidl_to_ndk.cpp
+++ b/aidl_to_ndk.cpp
@@ -303,14 +303,24 @@
.read_func = StandardRead("::ndk::AParcel_readRequiredStrongBinder"),
.write_func = StandardRead("::ndk::AParcel_writeRequiredStrongBinder"),
},
- .array = nullptr,
+ .array = std::shared_ptr<TypeInfo::Aspect>(new TypeInfo::Aspect{
+ .cpp_name = "std::vector<::ndk::SpAIBinder>",
+ .value_is_cheap = false,
+ .read_func = StandardRead("::ndk::AParcel_readVector"),
+ .write_func = StandardWrite("::ndk::AParcel_writeVector"),
+ }),
.nullable = std::shared_ptr<TypeInfo::Aspect>(new TypeInfo::Aspect{
.cpp_name = "::ndk::SpAIBinder",
.value_is_cheap = false,
.read_func = StandardRead("::ndk::AParcel_readNullableStrongBinder"),
.write_func = StandardRead("::ndk::AParcel_writeNullableStrongBinder"),
}),
- .nullable_array = nullptr,
+ .nullable_array = std::shared_ptr<TypeInfo::Aspect>(new TypeInfo::Aspect{
+ .cpp_name = "std::optional<std::vector<::ndk::SpAIBinder>>",
+ .value_is_cheap = false,
+ .read_func = StandardRead("::ndk::AParcel_readVector"),
+ .write_func = StandardWrite("::ndk::AParcel_writeVector"),
+ }),
}},
{"ParcelFileDescriptor",
TypeInfo{
diff --git a/aidl_to_rust.cpp b/aidl_to_rust.cpp
index 78bc451..6e71126 100644
--- a/aidl_to_rust.cpp
+++ b/aidl_to_rust.cpp
@@ -114,7 +114,7 @@
return "u8";
} else if (element_type_name == "String" && mode == StorageMode::UNSIZED_ARGUMENT) {
return "str";
- } else if (element_type_name == "ParcelFileDescriptor") {
+ } else if (element_type_name == "ParcelFileDescriptor" || element_type_name == "IBinder") {
if (type.IsArray() && mode == StorageMode::DEFAULT_VALUE) {
// Out-arguments of ParcelFileDescriptors arrays need to
// be Vec<Option<ParcelFileDescriptor>> so resize_out_vec
@@ -163,7 +163,7 @@
element_mode = StorageMode::VALUE;
}
rust_name = GetRustName(type, typenames, element_mode);
- if (type.IsNullable() && rust_name == "String") {
+ if (type.IsNullable() && (rust_name == "String" || rust_name == "binder::SpIBinder")) {
// The mapping for nullable string arrays is
// optional<vector<optional<string>>> in the NDK,
// so we do the same
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index d0a7a64..5e0f473 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -4757,8 +4757,8 @@
{"rust_StringArray", "Can only have one dimensional arrays."},
{"cpp_IBinder", ""},
{"java_IBinder", ""},
- {"ndk_IBinder", "The ndk backend does not support array of IBinder"},
- {"rust_IBinder", "The rust backend does not support array of IBinder"},
+ {"ndk_IBinder", ""},
+ {"rust_IBinder", ""},
{"cpp_ParcelFileDescriptor", ""},
{"java_ParcelFileDescriptor", ""},
{"ndk_ParcelFileDescriptor", ""},
diff --git a/tests/aidl_test_client_ndk_nullables.cpp b/tests/aidl_test_client_ndk_nullables.cpp
new file mode 100644
index 0000000..17c2c73
--- /dev/null
+++ b/tests/aidl_test_client_ndk_nullables.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android/binder_auto_utils.h>
+#include <android/binder_manager.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include <aidl/android/aidl/tests/ITestService.h>
+
+using aidl::android::aidl::tests::BackendType;
+using aidl::android::aidl::tests::INamedCallback;
+using aidl::android::aidl::tests::ITestService;
+using testing::Eq;
+
+struct AidlTest : testing::Test {
+ template <typename T>
+ std::shared_ptr<T> getService() {
+ ndk::SpAIBinder binder = ndk::SpAIBinder(AServiceManager_getService(T::descriptor));
+ return T::fromBinder(binder);
+ }
+ void SetUp() override {
+ service = getService<ITestService>();
+ auto status = service->getBackendType(&backend);
+ ASSERT_TRUE(status.isOk()) << status.getDescription();
+ }
+ std::shared_ptr<ITestService> service;
+ BackendType backend;
+};
+
+TEST_F(AidlTest, binderArray) {
+ std::vector<ndk::SpAIBinder> repeated;
+ if (backend == BackendType::JAVA) {
+ // Java can only modify out-argument arrays in-place
+ repeated.resize(2);
+ }
+ // get INamedCallback for "SpAIBinder" object
+ std::shared_ptr<INamedCallback> callback;
+ auto status = service->GetCallback(false, &callback);
+ ASSERT_TRUE(status.isOk()) << status.getDescription();
+
+ std::vector<ndk::SpAIBinder> reversed;
+ std::vector<ndk::SpAIBinder> input{service->asBinder(), callback->asBinder()};
+ status = service->ReverseIBinderArray(input, &repeated, &reversed);
+ ASSERT_TRUE(status.isOk()) << status.getDescription();
+
+ EXPECT_THAT(input, Eq(repeated));
+ std::reverse(std::begin(reversed), std::end(reversed));
+ EXPECT_THAT(input, Eq(reversed));
+}
+
+TEST_F(AidlTest, nullableBinderArray) {
+ std::optional<std::vector<ndk::SpAIBinder>> repeated;
+ if (backend == BackendType::JAVA) {
+ // Java can only modify out-argument arrays in-place
+ repeated = std::vector<ndk::SpAIBinder>(2);
+ }
+
+ std::optional<std::vector<ndk::SpAIBinder>> reversed;
+ std::optional<std::vector<ndk::SpAIBinder>> input =
+ std::vector<ndk::SpAIBinder>{service->asBinder(), service->asBinder()};
+ auto status = service->ReverseNullableIBinderArray(input, &repeated, &reversed);
+ ASSERT_TRUE(status.isOk()) << status.getDescription();
+
+ EXPECT_THAT(input, Eq(repeated));
+ ASSERT_TRUE(reversed);
+ std::reverse(std::begin(*reversed), std::end(*reversed));
+ EXPECT_THAT(input, Eq(reversed));
+}
\ No newline at end of file
diff --git a/tests/aidl_test_client_nullables.cpp b/tests/aidl_test_client_nullables.cpp
index f82c950..c38d595 100644
--- a/tests/aidl_test_client_nullables.cpp
+++ b/tests/aidl_test_client_nullables.cpp
@@ -161,8 +161,6 @@
}
TEST_F(AidlTest, binderArray) {
- if (!cpp_java_tests) GTEST_SKIP() << "Service does not support the CPP/Java-only tests.";
-
std::vector<sp<IBinder>> repeated;
if (backend == BackendType::JAVA) {
// Java can only modify out-argument arrays in-place
@@ -171,7 +169,7 @@
std::vector<sp<IBinder>> reversed;
std::vector<sp<IBinder>> input{new BBinder(), new BBinder()};
- auto status = cpp_java_tests->ReverseIBinderArray(input, &repeated, &reversed);
+ auto status = service->ReverseIBinderArray(input, &repeated, &reversed);
ASSERT_TRUE(status.isOk()) << status;
EXPECT_THAT(input, Eq(repeated));
@@ -180,8 +178,6 @@
}
TEST_F(AidlTest, nullableBinderArray) {
- if (!cpp_java_tests) GTEST_SKIP() << "Service does not support the CPP/Java-only tests.";
-
std::optional<std::vector<sp<IBinder>>> repeated;
if (backend == BackendType::JAVA) {
// Java can only modify out-argument arrays in-place
@@ -191,7 +187,7 @@
std::optional<std::vector<sp<IBinder>>> reversed;
std::optional<std::vector<sp<IBinder>>> input = std::vector<sp<IBinder>>{new BBinder(), nullptr};
- auto status = cpp_java_tests->ReverseNullableIBinderArray(input, &repeated, &reversed);
+ auto status = service->ReverseNullableIBinderArray(input, &repeated, &reversed);
ASSERT_TRUE(status.isOk()) << status;
EXPECT_THAT(input, Eq(repeated));
diff --git a/tests/aidl_test_service.cpp b/tests/aidl_test_service.cpp
index eecfdf0..adfc8c8 100644
--- a/tests/aidl_test_service.cpp
+++ b/tests/aidl_test_service.cpp
@@ -269,26 +269,6 @@
(void)input;
return Status::ok();
}
-
- Status ReverseIBinderArray(const vector<sp<IBinder>>& input, vector<sp<IBinder>>* repeated,
- vector<sp<IBinder>>* _aidl_return) override {
- ALOGI("Reversing IBinder array of length %zu", input.size());
- *repeated = input;
- *_aidl_return = input;
- std::reverse(_aidl_return->begin(), _aidl_return->end());
- return Status::ok();
- }
-
- Status ReverseNullableIBinderArray(const std::optional<vector<sp<IBinder>>>& input,
- std::optional<vector<sp<IBinder>>>* repeated,
- std::optional<vector<sp<IBinder>>>* _aidl_return) override {
- *repeated = input;
- *_aidl_return = input;
- if (*_aidl_return) {
- std::reverse((*_aidl_return)->begin(), (*_aidl_return)->end());
- }
- return Status::ok();
- }
};
class NativeService : public BnTestService {
@@ -624,6 +604,25 @@
return Status::ok();
}
+ Status ReverseIBinderArray(const vector<sp<IBinder>>& input, vector<sp<IBinder>>* repeated,
+ vector<sp<IBinder>>* _aidl_return) override {
+ *repeated = input;
+ *_aidl_return = input;
+ std::reverse(_aidl_return->begin(), _aidl_return->end());
+ return Status::ok();
+ }
+
+ Status ReverseNullableIBinderArray(const std::optional<vector<sp<IBinder>>>& input,
+ std::optional<vector<sp<IBinder>>>* repeated,
+ std::optional<vector<sp<IBinder>>>* _aidl_return) override {
+ *repeated = input;
+ *_aidl_return = input;
+ if (*_aidl_return) {
+ std::reverse((*_aidl_return)->begin(), (*_aidl_return)->end());
+ }
+ return Status::ok();
+ }
+
Status UnimplementedMethod(int32_t /* arg */, int32_t* /* _aidl_return */) override {
LOG_ALWAYS_FATAL("UnimplementedMethod shouldn't be called");
}
diff --git a/tests/android/aidl/tests/ICppJavaTests.aidl b/tests/android/aidl/tests/ICppJavaTests.aidl
index ab585d0..89fcae6 100644
--- a/tests/android/aidl/tests/ICppJavaTests.aidl
+++ b/tests/android/aidl/tests/ICppJavaTests.aidl
@@ -45,7 +45,4 @@
void TakesAnIBinderList(in List<IBinder> input);
void TakesANullableIBinderList(in @nullable List<IBinder> input);
- IBinder[] ReverseIBinderArray(in IBinder[] input, out IBinder[] repeated);
- @nullable IBinder[] ReverseNullableIBinderArray(
- in @nullable IBinder[] input, out @nullable IBinder[] repeated);
}
diff --git a/tests/android/aidl/tests/ITestService.aidl b/tests/android/aidl/tests/ITestService.aidl
index 07f7a2b..c5f6fe7 100644
--- a/tests/android/aidl/tests/ITestService.aidl
+++ b/tests/android/aidl/tests/ITestService.aidl
@@ -172,6 +172,10 @@
RecursiveList ReverseList(in RecursiveList list);
+ IBinder[] ReverseIBinderArray(in IBinder[] input, out IBinder[] repeated);
+ @nullable IBinder[] ReverseNullableIBinderArray(
+ in @nullable IBinder[] input, out @nullable IBinder[] repeated);
+
// All these constant expressions should be equal to 1
const int A1 = (~(-1)) == 0;
const int A2 = ~~(1 << 31) == (1 << 31);
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp
index 3b46127..070c29e 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp
@@ -1985,6 +1985,98 @@
return _aidl_status;
}
+::android::binder::Status BpTestService::ReverseIBinderArray(const ::std::vector<::android::sp<::android::IBinder>>& input, ::std::vector<::android::sp<::android::IBinder>>* repeated, ::std::vector<::android::sp<::android::IBinder>>* _aidl_return) {
+ ::android::Parcel _aidl_data;
+ _aidl_data.markSensitive();
+ _aidl_data.markForBinder(remoteStrong());
+ ::android::Parcel _aidl_reply;
+ ::android::status_t _aidl_ret_status = ::android::OK;
+ ::android::binder::Status _aidl_status;
+ _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+ if (((_aidl_ret_status) != (::android::OK))) {
+ goto _aidl_error;
+ }
+ _aidl_ret_status = _aidl_data.writeStrongBinderVector(input);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ goto _aidl_error;
+ }
+ _aidl_ret_status = _aidl_data.writeVectorSize(*repeated);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ goto _aidl_error;
+ }
+ _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseIBinderArray, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+ if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+ return ITestService::getDefaultImpl()->ReverseIBinderArray(input, repeated, _aidl_return);
+ }
+ if (((_aidl_ret_status) != (::android::OK))) {
+ goto _aidl_error;
+ }
+ _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ goto _aidl_error;
+ }
+ if (!_aidl_status.isOk()) {
+ return _aidl_status;
+ }
+ _aidl_ret_status = _aidl_reply.readStrongBinderVector(_aidl_return);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ goto _aidl_error;
+ }
+ _aidl_ret_status = _aidl_reply.readStrongBinderVector(repeated);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ goto _aidl_error;
+ }
+ _aidl_error:
+ _aidl_status.setFromStatusT(_aidl_ret_status);
+ return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ReverseNullableIBinderArray(const ::std::optional<::std::vector<::android::sp<::android::IBinder>>>& input, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* repeated, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* _aidl_return) {
+ ::android::Parcel _aidl_data;
+ _aidl_data.markSensitive();
+ _aidl_data.markForBinder(remoteStrong());
+ ::android::Parcel _aidl_reply;
+ ::android::status_t _aidl_ret_status = ::android::OK;
+ ::android::binder::Status _aidl_status;
+ _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+ if (((_aidl_ret_status) != (::android::OK))) {
+ goto _aidl_error;
+ }
+ _aidl_ret_status = _aidl_data.writeStrongBinderVector(input);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ goto _aidl_error;
+ }
+ _aidl_ret_status = _aidl_data.writeVectorSize(*repeated);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ goto _aidl_error;
+ }
+ _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseNullableIBinderArray, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+ if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+ return ITestService::getDefaultImpl()->ReverseNullableIBinderArray(input, repeated, _aidl_return);
+ }
+ if (((_aidl_ret_status) != (::android::OK))) {
+ goto _aidl_error;
+ }
+ _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ goto _aidl_error;
+ }
+ if (!_aidl_status.isOk()) {
+ return _aidl_status;
+ }
+ _aidl_ret_status = _aidl_reply.readStrongBinderVector(_aidl_return);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ goto _aidl_error;
+ }
+ _aidl_ret_status = _aidl_reply.readStrongBinderVector(repeated);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ goto _aidl_error;
+ }
+ _aidl_error:
+ _aidl_status.setFromStatusT(_aidl_ret_status);
+ return _aidl_status;
+}
+
::android::binder::Status BpTestService::GetOldNameInterface(::android::sp<::android::aidl::tests::IOldName>* _aidl_return) {
::android::Parcel _aidl_data;
_aidl_data.markSensitive();
@@ -3519,6 +3611,76 @@
}
}
break;
+ case BnTestService::TRANSACTION_ReverseIBinderArray:
+ {
+ ::std::vector<::android::sp<::android::IBinder>> in_input;
+ ::std::vector<::android::sp<::android::IBinder>> out_repeated;
+ ::std::vector<::android::sp<::android::IBinder>> _aidl_return;
+ if (!(_aidl_data.checkInterface(this))) {
+ _aidl_ret_status = ::android::BAD_TYPE;
+ break;
+ }
+ _aidl_ret_status = _aidl_data.readStrongBinderVector(&in_input);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ break;
+ }
+ _aidl_ret_status = _aidl_data.resizeOutVector(&out_repeated);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ break;
+ }
+ ::android::binder::Status _aidl_status(ReverseIBinderArray(in_input, &out_repeated, &_aidl_return));
+ _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ break;
+ }
+ if (!_aidl_status.isOk()) {
+ break;
+ }
+ _aidl_ret_status = _aidl_reply->writeStrongBinderVector(_aidl_return);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ break;
+ }
+ _aidl_ret_status = _aidl_reply->writeStrongBinderVector(out_repeated);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ break;
+ }
+ }
+ break;
+ case BnTestService::TRANSACTION_ReverseNullableIBinderArray:
+ {
+ ::std::optional<::std::vector<::android::sp<::android::IBinder>>> in_input;
+ ::std::optional<::std::vector<::android::sp<::android::IBinder>>> out_repeated;
+ ::std::optional<::std::vector<::android::sp<::android::IBinder>>> _aidl_return;
+ if (!(_aidl_data.checkInterface(this))) {
+ _aidl_ret_status = ::android::BAD_TYPE;
+ break;
+ }
+ _aidl_ret_status = _aidl_data.readStrongBinderVector(&in_input);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ break;
+ }
+ _aidl_ret_status = _aidl_data.resizeOutVector(&out_repeated);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ break;
+ }
+ ::android::binder::Status _aidl_status(ReverseNullableIBinderArray(in_input, &out_repeated, &_aidl_return));
+ _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ break;
+ }
+ if (!_aidl_status.isOk()) {
+ break;
+ }
+ _aidl_ret_status = _aidl_reply->writeStrongBinderVector(_aidl_return);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ break;
+ }
+ _aidl_ret_status = _aidl_reply->writeStrongBinderVector(out_repeated);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ break;
+ }
+ }
+ break;
case BnTestService::TRANSACTION_GetOldNameInterface:
{
::android::sp<::android::aidl::tests::IOldName> _aidl_return;
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnTestService.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnTestService.h
index 13bebe1..2c4baba 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnTestService.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnTestService.h
@@ -57,10 +57,12 @@
static constexpr uint32_t TRANSACTION_FillOutStructuredParcelable = ::android::IBinder::FIRST_CALL_TRANSACTION + 46;
static constexpr uint32_t TRANSACTION_RepeatExtendableParcelable = ::android::IBinder::FIRST_CALL_TRANSACTION + 47;
static constexpr uint32_t TRANSACTION_ReverseList = ::android::IBinder::FIRST_CALL_TRANSACTION + 48;
- static constexpr uint32_t TRANSACTION_GetOldNameInterface = ::android::IBinder::FIRST_CALL_TRANSACTION + 49;
- static constexpr uint32_t TRANSACTION_GetNewNameInterface = ::android::IBinder::FIRST_CALL_TRANSACTION + 50;
- static constexpr uint32_t TRANSACTION_GetCppJavaTests = ::android::IBinder::FIRST_CALL_TRANSACTION + 51;
- static constexpr uint32_t TRANSACTION_getBackendType = ::android::IBinder::FIRST_CALL_TRANSACTION + 52;
+ static constexpr uint32_t TRANSACTION_ReverseIBinderArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 49;
+ static constexpr uint32_t TRANSACTION_ReverseNullableIBinderArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 50;
+ static constexpr uint32_t TRANSACTION_GetOldNameInterface = ::android::IBinder::FIRST_CALL_TRANSACTION + 51;
+ static constexpr uint32_t TRANSACTION_GetNewNameInterface = ::android::IBinder::FIRST_CALL_TRANSACTION + 52;
+ static constexpr uint32_t TRANSACTION_GetCppJavaTests = ::android::IBinder::FIRST_CALL_TRANSACTION + 53;
+ static constexpr uint32_t TRANSACTION_getBackendType = ::android::IBinder::FIRST_CALL_TRANSACTION + 54;
explicit BnTestService();
::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override;
}; // class BnTestService
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpTestService.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpTestService.h
index 17d8818..6258345 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpTestService.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpTestService.h
@@ -61,6 +61,8 @@
::android::binder::Status FillOutStructuredParcelable(::android::aidl::tests::StructuredParcelable* parcel) override;
::android::binder::Status RepeatExtendableParcelable(const ::android::aidl::tests::extension::ExtendableParcelable& ep, ::android::aidl::tests::extension::ExtendableParcelable* ep2) override;
::android::binder::Status ReverseList(const ::android::aidl::tests::RecursiveList& list, ::android::aidl::tests::RecursiveList* _aidl_return) override;
+ ::android::binder::Status ReverseIBinderArray(const ::std::vector<::android::sp<::android::IBinder>>& input, ::std::vector<::android::sp<::android::IBinder>>* repeated, ::std::vector<::android::sp<::android::IBinder>>* _aidl_return) override;
+ ::android::binder::Status ReverseNullableIBinderArray(const ::std::optional<::std::vector<::android::sp<::android::IBinder>>>& input, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* repeated, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* _aidl_return) override;
::android::binder::Status GetOldNameInterface(::android::sp<::android::aidl::tests::IOldName>* _aidl_return) override;
::android::binder::Status GetNewNameInterface(::android::sp<::android::aidl::tests::INewName>* _aidl_return) override;
::android::binder::Status GetCppJavaTests(::android::sp<::android::IBinder>* _aidl_return) override;
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h
index 1a4afb0..03a4bdb 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h
@@ -150,6 +150,8 @@
virtual ::android::binder::Status FillOutStructuredParcelable(::android::aidl::tests::StructuredParcelable* parcel) = 0;
virtual ::android::binder::Status RepeatExtendableParcelable(const ::android::aidl::tests::extension::ExtendableParcelable& ep, ::android::aidl::tests::extension::ExtendableParcelable* ep2) = 0;
virtual ::android::binder::Status ReverseList(const ::android::aidl::tests::RecursiveList& list, ::android::aidl::tests::RecursiveList* _aidl_return) = 0;
+ virtual ::android::binder::Status ReverseIBinderArray(const ::std::vector<::android::sp<::android::IBinder>>& input, ::std::vector<::android::sp<::android::IBinder>>* repeated, ::std::vector<::android::sp<::android::IBinder>>* _aidl_return) = 0;
+ virtual ::android::binder::Status ReverseNullableIBinderArray(const ::std::optional<::std::vector<::android::sp<::android::IBinder>>>& input, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* repeated, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* _aidl_return) = 0;
virtual ::android::binder::Status GetOldNameInterface(::android::sp<::android::aidl::tests::IOldName>* _aidl_return) = 0;
virtual ::android::binder::Status GetNewNameInterface(::android::sp<::android::aidl::tests::INewName>* _aidl_return) = 0;
virtual ::android::binder::Status GetCppJavaTests(::android::sp<::android::IBinder>* _aidl_return) = 0;
@@ -308,6 +310,12 @@
::android::binder::Status ReverseList(const ::android::aidl::tests::RecursiveList&, ::android::aidl::tests::RecursiveList*) override {
return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
}
+ ::android::binder::Status ReverseIBinderArray(const ::std::vector<::android::sp<::android::IBinder>>&, ::std::vector<::android::sp<::android::IBinder>>*, ::std::vector<::android::sp<::android::IBinder>>*) override {
+ return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+ }
+ ::android::binder::Status ReverseNullableIBinderArray(const ::std::optional<::std::vector<::android::sp<::android::IBinder>>>&, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>*, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>*) override {
+ return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+ }
::android::binder::Status GetOldNameInterface(::android::sp<::android::aidl::tests::IOldName>*) override {
return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
index 5d8af5a..ff17cee 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
@@ -222,6 +222,14 @@
{
return null;
}
+ @Override public android.os.IBinder[] ReverseIBinderArray(android.os.IBinder[] input, android.os.IBinder[] repeated) throws android.os.RemoteException
+ {
+ return null;
+ }
+ @Override public android.os.IBinder[] ReverseNullableIBinderArray(android.os.IBinder[] input, android.os.IBinder[] repeated) throws android.os.RemoteException
+ {
+ return null;
+ }
@Override public android.aidl.tests.IOldName GetOldNameInterface() throws android.os.RemoteException
{
return null;
@@ -909,6 +917,42 @@
}
break;
}
+ case TRANSACTION_ReverseIBinderArray:
+ {
+ android.os.IBinder[] _arg0;
+ _arg0 = data.createBinderArray();
+ android.os.IBinder[] _arg1;
+ int _arg1_length = data.readInt();
+ if ((_arg1_length<0)) {
+ _arg1 = null;
+ }
+ else {
+ _arg1 = new android.os.IBinder[_arg1_length];
+ }
+ android.os.IBinder[] _result = this.ReverseIBinderArray(_arg0, _arg1);
+ reply.writeNoException();
+ reply.writeBinderArray(_result);
+ reply.writeBinderArray(_arg1);
+ break;
+ }
+ case TRANSACTION_ReverseNullableIBinderArray:
+ {
+ android.os.IBinder[] _arg0;
+ _arg0 = data.createBinderArray();
+ android.os.IBinder[] _arg1;
+ int _arg1_length = data.readInt();
+ if ((_arg1_length<0)) {
+ _arg1 = null;
+ }
+ else {
+ _arg1 = new android.os.IBinder[_arg1_length];
+ }
+ android.os.IBinder[] _result = this.ReverseNullableIBinderArray(_arg0, _arg1);
+ reply.writeNoException();
+ reply.writeBinderArray(_result);
+ reply.writeBinderArray(_arg1);
+ break;
+ }
case TRANSACTION_GetOldNameInterface:
{
android.aidl.tests.IOldName _result = this.GetOldNameInterface();
@@ -2293,6 +2337,68 @@
}
return _result;
}
+ @Override public android.os.IBinder[] ReverseIBinderArray(android.os.IBinder[] input, android.os.IBinder[] repeated) throws android.os.RemoteException
+ {
+ android.os.Parcel _data = android.os.Parcel.obtain(asBinder());
+ _data.markSensitive();
+ android.os.Parcel _reply = android.os.Parcel.obtain();
+ android.os.IBinder[] _result;
+ try {
+ _data.writeInterfaceToken(DESCRIPTOR);
+ _data.writeBinderArray(input);
+ if ((repeated==null)) {
+ _data.writeInt(-1);
+ }
+ else {
+ _data.writeInt(repeated.length);
+ }
+ boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseIBinderArray, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+ if (!_status) {
+ if (getDefaultImpl() != null) {
+ return getDefaultImpl().ReverseIBinderArray(input, repeated);
+ }
+ }
+ _reply.readException();
+ _result = _reply.createBinderArray();
+ _reply.readBinderArray(repeated);
+ }
+ finally {
+ _reply.recycle();
+ _data.recycle();
+ }
+ return _result;
+ }
+ @Override public android.os.IBinder[] ReverseNullableIBinderArray(android.os.IBinder[] input, android.os.IBinder[] repeated) throws android.os.RemoteException
+ {
+ android.os.Parcel _data = android.os.Parcel.obtain(asBinder());
+ _data.markSensitive();
+ android.os.Parcel _reply = android.os.Parcel.obtain();
+ android.os.IBinder[] _result;
+ try {
+ _data.writeInterfaceToken(DESCRIPTOR);
+ _data.writeBinderArray(input);
+ if ((repeated==null)) {
+ _data.writeInt(-1);
+ }
+ else {
+ _data.writeInt(repeated.length);
+ }
+ boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseNullableIBinderArray, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+ if (!_status) {
+ if (getDefaultImpl() != null) {
+ return getDefaultImpl().ReverseNullableIBinderArray(input, repeated);
+ }
+ }
+ _reply.readException();
+ _result = _reply.createBinderArray();
+ _reply.readBinderArray(repeated);
+ }
+ finally {
+ _reply.recycle();
+ _data.recycle();
+ }
+ return _result;
+ }
@Override public android.aidl.tests.IOldName GetOldNameInterface() throws android.os.RemoteException
{
android.os.Parcel _data = android.os.Parcel.obtain(asBinder());
@@ -2437,10 +2543,12 @@
static final int TRANSACTION_FillOutStructuredParcelable = (android.os.IBinder.FIRST_CALL_TRANSACTION + 46);
static final int TRANSACTION_RepeatExtendableParcelable = (android.os.IBinder.FIRST_CALL_TRANSACTION + 47);
static final int TRANSACTION_ReverseList = (android.os.IBinder.FIRST_CALL_TRANSACTION + 48);
- static final int TRANSACTION_GetOldNameInterface = (android.os.IBinder.FIRST_CALL_TRANSACTION + 49);
- static final int TRANSACTION_GetNewNameInterface = (android.os.IBinder.FIRST_CALL_TRANSACTION + 50);
- static final int TRANSACTION_GetCppJavaTests = (android.os.IBinder.FIRST_CALL_TRANSACTION + 51);
- static final int TRANSACTION_getBackendType = (android.os.IBinder.FIRST_CALL_TRANSACTION + 52);
+ static final int TRANSACTION_ReverseIBinderArray = (android.os.IBinder.FIRST_CALL_TRANSACTION + 49);
+ static final int TRANSACTION_ReverseNullableIBinderArray = (android.os.IBinder.FIRST_CALL_TRANSACTION + 50);
+ static final int TRANSACTION_GetOldNameInterface = (android.os.IBinder.FIRST_CALL_TRANSACTION + 51);
+ static final int TRANSACTION_GetNewNameInterface = (android.os.IBinder.FIRST_CALL_TRANSACTION + 52);
+ static final int TRANSACTION_GetCppJavaTests = (android.os.IBinder.FIRST_CALL_TRANSACTION + 53);
+ static final int TRANSACTION_getBackendType = (android.os.IBinder.FIRST_CALL_TRANSACTION + 54);
public static boolean setDefaultImpl(android.aidl.tests.ITestService impl) {
// Only one user of this interface can use this function
// at a time. This is a heuristic to detect if two different
@@ -2616,6 +2724,8 @@
public void FillOutStructuredParcelable(android.aidl.tests.StructuredParcelable parcel) throws android.os.RemoteException;
public void RepeatExtendableParcelable(android.aidl.tests.extension.ExtendableParcelable ep, android.aidl.tests.extension.ExtendableParcelable ep2) throws android.os.RemoteException;
public android.aidl.tests.RecursiveList ReverseList(android.aidl.tests.RecursiveList list) throws android.os.RemoteException;
+ public android.os.IBinder[] ReverseIBinderArray(android.os.IBinder[] input, android.os.IBinder[] repeated) throws android.os.RemoteException;
+ public android.os.IBinder[] ReverseNullableIBinderArray(android.os.IBinder[] input, android.os.IBinder[] repeated) throws android.os.RemoteException;
public android.aidl.tests.IOldName GetOldNameInterface() throws android.os.RemoteException;
public android.aidl.tests.INewName GetNewNameInterface() throws android.os.RemoteException;
// Retrieve the ICppJavaTests if the server supports it
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp b/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp
index ab5d5f9..6d6dc40 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp
@@ -983,7 +983,57 @@
break;
}
- case (FIRST_CALL_TRANSACTION + 49 /*GetOldNameInterface*/): {
+ case (FIRST_CALL_TRANSACTION + 49 /*ReverseIBinderArray*/): {
+ std::vector<::ndk::SpAIBinder> in_input;
+ std::vector<::ndk::SpAIBinder> out_repeated;
+ std::vector<::ndk::SpAIBinder> _aidl_return;
+
+ _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_input);
+ if (_aidl_ret_status != STATUS_OK) break;
+
+ _aidl_ret_status = ::ndk::AParcel_resizeVector(_aidl_in, &out_repeated);
+ if (_aidl_ret_status != STATUS_OK) break;
+
+ ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseIBinderArray(in_input, &out_repeated, &_aidl_return);
+ _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+ if (_aidl_ret_status != STATUS_OK) break;
+
+ if (!AStatus_isOk(_aidl_status.get())) break;
+
+ _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+ if (_aidl_ret_status != STATUS_OK) break;
+
+ _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, out_repeated);
+ if (_aidl_ret_status != STATUS_OK) break;
+
+ break;
+ }
+ case (FIRST_CALL_TRANSACTION + 50 /*ReverseNullableIBinderArray*/): {
+ std::optional<std::vector<::ndk::SpAIBinder>> in_input;
+ std::optional<std::vector<::ndk::SpAIBinder>> out_repeated;
+ std::optional<std::vector<::ndk::SpAIBinder>> _aidl_return;
+
+ _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_input);
+ if (_aidl_ret_status != STATUS_OK) break;
+
+ _aidl_ret_status = ::ndk::AParcel_resizeVector(_aidl_in, &out_repeated);
+ if (_aidl_ret_status != STATUS_OK) break;
+
+ ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseNullableIBinderArray(in_input, &out_repeated, &_aidl_return);
+ _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+ if (_aidl_ret_status != STATUS_OK) break;
+
+ if (!AStatus_isOk(_aidl_status.get())) break;
+
+ _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+ if (_aidl_ret_status != STATUS_OK) break;
+
+ _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, out_repeated);
+ if (_aidl_ret_status != STATUS_OK) break;
+
+ break;
+ }
+ case (FIRST_CALL_TRANSACTION + 51 /*GetOldNameInterface*/): {
std::shared_ptr<::aidl::android::aidl::tests::IOldName> _aidl_return;
::ndk::ScopedAStatus _aidl_status = _aidl_impl->GetOldNameInterface(&_aidl_return);
@@ -997,7 +1047,7 @@
break;
}
- case (FIRST_CALL_TRANSACTION + 50 /*GetNewNameInterface*/): {
+ case (FIRST_CALL_TRANSACTION + 52 /*GetNewNameInterface*/): {
std::shared_ptr<::aidl::android::aidl::tests::INewName> _aidl_return;
::ndk::ScopedAStatus _aidl_status = _aidl_impl->GetNewNameInterface(&_aidl_return);
@@ -1011,7 +1061,7 @@
break;
}
- case (FIRST_CALL_TRANSACTION + 51 /*GetCppJavaTests*/): {
+ case (FIRST_CALL_TRANSACTION + 53 /*GetCppJavaTests*/): {
::ndk::SpAIBinder _aidl_return;
::ndk::ScopedAStatus _aidl_status = _aidl_impl->GetCppJavaTests(&_aidl_return);
@@ -1025,7 +1075,7 @@
break;
}
- case (FIRST_CALL_TRANSACTION + 52 /*getBackendType*/): {
+ case (FIRST_CALL_TRANSACTION + 54 /*getBackendType*/): {
::aidl::android::aidl::tests::BackendType _aidl_return;
::ndk::ScopedAStatus _aidl_status = _aidl_impl->getBackendType(&_aidl_return);
@@ -3126,6 +3176,100 @@
_aidl_status_return:
return _aidl_status;
}
+::ndk::ScopedAStatus BpTestService::ReverseIBinderArray(const std::vector<::ndk::SpAIBinder>& in_input, std::vector<::ndk::SpAIBinder>* out_repeated, std::vector<::ndk::SpAIBinder>* _aidl_return) {
+ binder_status_t _aidl_ret_status = STATUS_OK;
+ ::ndk::ScopedAStatus _aidl_status;
+ ::ndk::ScopedAParcel _aidl_in;
+ ::ndk::ScopedAParcel _aidl_out;
+
+ _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+ AParcel_markSensitive(_aidl_in.get());
+ if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+ _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), in_input);
+ if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+ _aidl_ret_status = ::ndk::AParcel_writeVectorSize(_aidl_in.get(), *out_repeated);
+ if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+ _aidl_ret_status = AIBinder_transact(
+ asBinder().get(),
+ (FIRST_CALL_TRANSACTION + 49 /*ReverseIBinderArray*/),
+ _aidl_in.getR(),
+ _aidl_out.getR(),
+ FLAG_CLEAR_BUF
+ #ifdef BINDER_STABILITY_SUPPORT
+ | FLAG_PRIVATE_LOCAL
+ #endif // BINDER_STABILITY_SUPPORT
+ );
+ if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+ _aidl_status = ITestService::getDefaultImpl()->ReverseIBinderArray(in_input, out_repeated, _aidl_return);
+ goto _aidl_status_return;
+ }
+ if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+ _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+ if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+ if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+ _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+ if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+ _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), out_repeated);
+ if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+ _aidl_error:
+ _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+ _aidl_status_return:
+ return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ReverseNullableIBinderArray(const std::optional<std::vector<::ndk::SpAIBinder>>& in_input, std::optional<std::vector<::ndk::SpAIBinder>>* out_repeated, std::optional<std::vector<::ndk::SpAIBinder>>* _aidl_return) {
+ binder_status_t _aidl_ret_status = STATUS_OK;
+ ::ndk::ScopedAStatus _aidl_status;
+ ::ndk::ScopedAParcel _aidl_in;
+ ::ndk::ScopedAParcel _aidl_out;
+
+ _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+ AParcel_markSensitive(_aidl_in.get());
+ if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+ _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), in_input);
+ if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+ _aidl_ret_status = ::ndk::AParcel_writeVectorSize(_aidl_in.get(), *out_repeated);
+ if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+ _aidl_ret_status = AIBinder_transact(
+ asBinder().get(),
+ (FIRST_CALL_TRANSACTION + 50 /*ReverseNullableIBinderArray*/),
+ _aidl_in.getR(),
+ _aidl_out.getR(),
+ FLAG_CLEAR_BUF
+ #ifdef BINDER_STABILITY_SUPPORT
+ | FLAG_PRIVATE_LOCAL
+ #endif // BINDER_STABILITY_SUPPORT
+ );
+ if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+ _aidl_status = ITestService::getDefaultImpl()->ReverseNullableIBinderArray(in_input, out_repeated, _aidl_return);
+ goto _aidl_status_return;
+ }
+ if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+ _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+ if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+ if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+ _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+ if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+ _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), out_repeated);
+ if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+ _aidl_error:
+ _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+ _aidl_status_return:
+ return _aidl_status;
+}
::ndk::ScopedAStatus BpTestService::GetOldNameInterface(std::shared_ptr<::aidl::android::aidl::tests::IOldName>* _aidl_return) {
binder_status_t _aidl_ret_status = STATUS_OK;
::ndk::ScopedAStatus _aidl_status;
@@ -3138,7 +3282,7 @@
_aidl_ret_status = AIBinder_transact(
asBinder().get(),
- (FIRST_CALL_TRANSACTION + 49 /*GetOldNameInterface*/),
+ (FIRST_CALL_TRANSACTION + 51 /*GetOldNameInterface*/),
_aidl_in.getR(),
_aidl_out.getR(),
FLAG_CLEAR_BUF
@@ -3176,7 +3320,7 @@
_aidl_ret_status = AIBinder_transact(
asBinder().get(),
- (FIRST_CALL_TRANSACTION + 50 /*GetNewNameInterface*/),
+ (FIRST_CALL_TRANSACTION + 52 /*GetNewNameInterface*/),
_aidl_in.getR(),
_aidl_out.getR(),
FLAG_CLEAR_BUF
@@ -3214,7 +3358,7 @@
_aidl_ret_status = AIBinder_transact(
asBinder().get(),
- (FIRST_CALL_TRANSACTION + 51 /*GetCppJavaTests*/),
+ (FIRST_CALL_TRANSACTION + 53 /*GetCppJavaTests*/),
_aidl_in.getR(),
_aidl_out.getR(),
FLAG_CLEAR_BUF
@@ -3252,7 +3396,7 @@
_aidl_ret_status = AIBinder_transact(
asBinder().get(),
- (FIRST_CALL_TRANSACTION + 52 /*getBackendType*/),
+ (FIRST_CALL_TRANSACTION + 54 /*getBackendType*/),
_aidl_in.getR(),
_aidl_out.getR(),
FLAG_CLEAR_BUF
@@ -3576,6 +3720,16 @@
_aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
return _aidl_status;
}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseIBinderArray(const std::vector<::ndk::SpAIBinder>& /*in_input*/, std::vector<::ndk::SpAIBinder>* /*out_repeated*/, std::vector<::ndk::SpAIBinder>* /*_aidl_return*/) {
+ ::ndk::ScopedAStatus _aidl_status;
+ _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+ return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseNullableIBinderArray(const std::optional<std::vector<::ndk::SpAIBinder>>& /*in_input*/, std::optional<std::vector<::ndk::SpAIBinder>>* /*out_repeated*/, std::optional<std::vector<::ndk::SpAIBinder>>* /*_aidl_return*/) {
+ ::ndk::ScopedAStatus _aidl_status;
+ _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+ return _aidl_status;
+}
::ndk::ScopedAStatus ITestServiceDefault::GetOldNameInterface(std::shared_ptr<::aidl::android::aidl::tests::IOldName>* /*_aidl_return*/) {
::ndk::ScopedAStatus _aidl_status;
_aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BpTestService.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BpTestService.h
index 2418d87..0668d48 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BpTestService.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BpTestService.h
@@ -62,6 +62,8 @@
::ndk::ScopedAStatus FillOutStructuredParcelable(::aidl::android::aidl::tests::StructuredParcelable* in_parcel) override;
::ndk::ScopedAStatus RepeatExtendableParcelable(const ::aidl::android::aidl::tests::extension::ExtendableParcelable& in_ep, ::aidl::android::aidl::tests::extension::ExtendableParcelable* out_ep2) override;
::ndk::ScopedAStatus ReverseList(const ::aidl::android::aidl::tests::RecursiveList& in_list, ::aidl::android::aidl::tests::RecursiveList* _aidl_return) override;
+ ::ndk::ScopedAStatus ReverseIBinderArray(const std::vector<::ndk::SpAIBinder>& in_input, std::vector<::ndk::SpAIBinder>* out_repeated, std::vector<::ndk::SpAIBinder>* _aidl_return) override;
+ ::ndk::ScopedAStatus ReverseNullableIBinderArray(const std::optional<std::vector<::ndk::SpAIBinder>>& in_input, std::optional<std::vector<::ndk::SpAIBinder>>* out_repeated, std::optional<std::vector<::ndk::SpAIBinder>>* _aidl_return) override;
::ndk::ScopedAStatus GetOldNameInterface(std::shared_ptr<::aidl::android::aidl::tests::IOldName>* _aidl_return) override;
::ndk::ScopedAStatus GetNewNameInterface(std::shared_ptr<::aidl::android::aidl::tests::INewName>* _aidl_return) override;
::ndk::ScopedAStatus GetCppJavaTests(::ndk::SpAIBinder* _aidl_return) override;
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h
index 364e49a..0e6aaa0 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h
@@ -155,10 +155,12 @@
static constexpr uint32_t TRANSACTION_FillOutStructuredParcelable = FIRST_CALL_TRANSACTION + 46;
static constexpr uint32_t TRANSACTION_RepeatExtendableParcelable = FIRST_CALL_TRANSACTION + 47;
static constexpr uint32_t TRANSACTION_ReverseList = FIRST_CALL_TRANSACTION + 48;
- static constexpr uint32_t TRANSACTION_GetOldNameInterface = FIRST_CALL_TRANSACTION + 49;
- static constexpr uint32_t TRANSACTION_GetNewNameInterface = FIRST_CALL_TRANSACTION + 50;
- static constexpr uint32_t TRANSACTION_GetCppJavaTests = FIRST_CALL_TRANSACTION + 51;
- static constexpr uint32_t TRANSACTION_getBackendType = FIRST_CALL_TRANSACTION + 52;
+ static constexpr uint32_t TRANSACTION_ReverseIBinderArray = FIRST_CALL_TRANSACTION + 49;
+ static constexpr uint32_t TRANSACTION_ReverseNullableIBinderArray = FIRST_CALL_TRANSACTION + 50;
+ static constexpr uint32_t TRANSACTION_GetOldNameInterface = FIRST_CALL_TRANSACTION + 51;
+ static constexpr uint32_t TRANSACTION_GetNewNameInterface = FIRST_CALL_TRANSACTION + 52;
+ static constexpr uint32_t TRANSACTION_GetCppJavaTests = FIRST_CALL_TRANSACTION + 53;
+ static constexpr uint32_t TRANSACTION_getBackendType = FIRST_CALL_TRANSACTION + 54;
static std::shared_ptr<ITestService> fromBinder(const ::ndk::SpAIBinder& binder);
static binder_status_t writeToParcel(AParcel* parcel, const std::shared_ptr<ITestService>& instance);
@@ -214,6 +216,8 @@
virtual ::ndk::ScopedAStatus FillOutStructuredParcelable(::aidl::android::aidl::tests::StructuredParcelable* in_parcel) = 0;
virtual ::ndk::ScopedAStatus RepeatExtendableParcelable(const ::aidl::android::aidl::tests::extension::ExtendableParcelable& in_ep, ::aidl::android::aidl::tests::extension::ExtendableParcelable* out_ep2) = 0;
virtual ::ndk::ScopedAStatus ReverseList(const ::aidl::android::aidl::tests::RecursiveList& in_list, ::aidl::android::aidl::tests::RecursiveList* _aidl_return) = 0;
+ virtual ::ndk::ScopedAStatus ReverseIBinderArray(const std::vector<::ndk::SpAIBinder>& in_input, std::vector<::ndk::SpAIBinder>* out_repeated, std::vector<::ndk::SpAIBinder>* _aidl_return) = 0;
+ virtual ::ndk::ScopedAStatus ReverseNullableIBinderArray(const std::optional<std::vector<::ndk::SpAIBinder>>& in_input, std::optional<std::vector<::ndk::SpAIBinder>>* out_repeated, std::optional<std::vector<::ndk::SpAIBinder>>* _aidl_return) = 0;
virtual ::ndk::ScopedAStatus GetOldNameInterface(std::shared_ptr<::aidl::android::aidl::tests::IOldName>* _aidl_return) = 0;
virtual ::ndk::ScopedAStatus GetNewNameInterface(std::shared_ptr<::aidl::android::aidl::tests::INewName>* _aidl_return) = 0;
virtual ::ndk::ScopedAStatus GetCppJavaTests(::ndk::SpAIBinder* _aidl_return) = 0;
@@ -272,6 +276,8 @@
::ndk::ScopedAStatus FillOutStructuredParcelable(::aidl::android::aidl::tests::StructuredParcelable* in_parcel) override;
::ndk::ScopedAStatus RepeatExtendableParcelable(const ::aidl::android::aidl::tests::extension::ExtendableParcelable& in_ep, ::aidl::android::aidl::tests::extension::ExtendableParcelable* out_ep2) override;
::ndk::ScopedAStatus ReverseList(const ::aidl::android::aidl::tests::RecursiveList& in_list, ::aidl::android::aidl::tests::RecursiveList* _aidl_return) override;
+ ::ndk::ScopedAStatus ReverseIBinderArray(const std::vector<::ndk::SpAIBinder>& in_input, std::vector<::ndk::SpAIBinder>* out_repeated, std::vector<::ndk::SpAIBinder>* _aidl_return) override;
+ ::ndk::ScopedAStatus ReverseNullableIBinderArray(const std::optional<std::vector<::ndk::SpAIBinder>>& in_input, std::optional<std::vector<::ndk::SpAIBinder>>* out_repeated, std::optional<std::vector<::ndk::SpAIBinder>>* _aidl_return) override;
::ndk::ScopedAStatus GetOldNameInterface(std::shared_ptr<::aidl::android::aidl::tests::IOldName>* _aidl_return) override;
::ndk::ScopedAStatus GetNewNameInterface(std::shared_ptr<::aidl::android::aidl::tests::INewName>* _aidl_return) override;
::ndk::ScopedAStatus GetCppJavaTests(::ndk::SpAIBinder* _aidl_return) override;
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs
index 0400780..b58ae31 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs
@@ -62,6 +62,8 @@
fn FillOutStructuredParcelable(&self, _arg_parcel: &mut crate::mangled::_7_android_4_aidl_5_tests_20_StructuredParcelable) -> binder::public_api::Result<()>;
fn RepeatExtendableParcelable(&self, _arg_ep: &crate::mangled::_7_android_4_aidl_5_tests_9_extension_20_ExtendableParcelable, _arg_ep2: &mut crate::mangled::_7_android_4_aidl_5_tests_9_extension_20_ExtendableParcelable) -> binder::public_api::Result<()>;
fn ReverseList(&self, _arg_list: &crate::mangled::_7_android_4_aidl_5_tests_13_RecursiveList) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_13_RecursiveList>;
+ fn ReverseIBinderArray(&self, _arg_input: &[binder::SpIBinder], _arg_repeated: &mut Vec<Option<binder::SpIBinder>>) -> binder::public_api::Result<Vec<binder::SpIBinder>>;
+ fn ReverseNullableIBinderArray(&self, _arg_input: Option<&[Option<binder::SpIBinder>]>, _arg_repeated: &mut Option<Vec<Option<binder::SpIBinder>>>) -> binder::public_api::Result<Option<Vec<Option<binder::SpIBinder>>>>;
fn GetOldNameInterface(&self) -> binder::public_api::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>>;
fn GetNewNameInterface(&self) -> binder::public_api::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>>;
fn GetCppJavaTests(&self) -> binder::public_api::Result<Option<binder::SpIBinder>>;
@@ -221,6 +223,12 @@
fn ReverseList(&self, _arg_list: &crate::mangled::_7_android_4_aidl_5_tests_13_RecursiveList) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_13_RecursiveList> {
Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
}
+ fn ReverseIBinderArray(&self, _arg_input: &[binder::SpIBinder], _arg_repeated: &mut Vec<Option<binder::SpIBinder>>) -> binder::public_api::Result<Vec<binder::SpIBinder>> {
+ Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+ }
+ fn ReverseNullableIBinderArray(&self, _arg_input: Option<&[Option<binder::SpIBinder>]>, _arg_repeated: &mut Option<Vec<Option<binder::SpIBinder>>>) -> binder::public_api::Result<Option<Vec<Option<binder::SpIBinder>>>> {
+ Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+ }
fn GetOldNameInterface(&self) -> binder::public_api::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>> {
Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
}
@@ -284,10 +292,12 @@
pub const FillOutStructuredParcelable: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 46;
pub const RepeatExtendableParcelable: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 47;
pub const ReverseList: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 48;
- pub const GetOldNameInterface: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 49;
- pub const GetNewNameInterface: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 50;
- pub const GetCppJavaTests: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 51;
- pub const getBackendType: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 52;
+ pub const ReverseIBinderArray: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 49;
+ pub const ReverseNullableIBinderArray: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 50;
+ pub const GetOldNameInterface: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 51;
+ pub const GetNewNameInterface: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 52;
+ pub const GetCppJavaTests: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 53;
+ pub const getBackendType: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 54;
}
pub type ITestServiceDefaultRef = Option<std::sync::Arc<dyn ITestServiceDefault>>;
use lazy_static::lazy_static;
@@ -1224,6 +1234,44 @@
let _aidl_return: crate::mangled::_7_android_4_aidl_5_tests_13_RecursiveList = _aidl_reply.read()?;
Ok(_aidl_return)
}
+ fn ReverseIBinderArray(&self, _arg_input: &[binder::SpIBinder], _arg_repeated: &mut Vec<Option<binder::SpIBinder>>) -> binder::public_api::Result<Vec<binder::SpIBinder>> {
+ let _aidl_reply = self.binder.transact(transactions::ReverseIBinderArray, binder::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_aidl_data| {
+ _aidl_data.mark_sensitive();
+ _aidl_data.write(_arg_input)?;
+ _aidl_data.write_slice_size(Some(_arg_repeated))?;
+ Ok(())
+ });
+ if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+ if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+ return _aidl_default_impl.ReverseIBinderArray(_arg_input, _arg_repeated);
+ }
+ }
+ let _aidl_reply = _aidl_reply?;
+ let _aidl_status: binder::Status = _aidl_reply.read()?;
+ if !_aidl_status.is_ok() { return Err(_aidl_status); }
+ let _aidl_return: Vec<binder::SpIBinder> = _aidl_reply.read()?;
+ _aidl_reply.read_onto(_arg_repeated)?;
+ Ok(_aidl_return)
+ }
+ fn ReverseNullableIBinderArray(&self, _arg_input: Option<&[Option<binder::SpIBinder>]>, _arg_repeated: &mut Option<Vec<Option<binder::SpIBinder>>>) -> binder::public_api::Result<Option<Vec<Option<binder::SpIBinder>>>> {
+ let _aidl_reply = self.binder.transact(transactions::ReverseNullableIBinderArray, binder::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_aidl_data| {
+ _aidl_data.mark_sensitive();
+ _aidl_data.write(&_arg_input)?;
+ _aidl_data.write_slice_size(_arg_repeated.as_deref())?;
+ Ok(())
+ });
+ if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+ if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+ return _aidl_default_impl.ReverseNullableIBinderArray(_arg_input, _arg_repeated);
+ }
+ }
+ let _aidl_reply = _aidl_reply?;
+ let _aidl_status: binder::Status = _aidl_reply.read()?;
+ if !_aidl_status.is_ok() { return Err(_aidl_status); }
+ let _aidl_return: Option<Vec<Option<binder::SpIBinder>>> = _aidl_reply.read()?;
+ _aidl_reply.read_onto(_arg_repeated)?;
+ Ok(_aidl_return)
+ }
fn GetOldNameInterface(&self) -> binder::public_api::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>> {
let _aidl_reply = self.binder.transact(transactions::GetOldNameInterface, binder::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_aidl_data| {
_aidl_data.mark_sensitive();
@@ -1339,6 +1387,8 @@
fn FillOutStructuredParcelable(&self, _arg_parcel: &mut crate::mangled::_7_android_4_aidl_5_tests_20_StructuredParcelable) -> binder::public_api::Result<()> { self.0.FillOutStructuredParcelable(_arg_parcel) }
fn RepeatExtendableParcelable(&self, _arg_ep: &crate::mangled::_7_android_4_aidl_5_tests_9_extension_20_ExtendableParcelable, _arg_ep2: &mut crate::mangled::_7_android_4_aidl_5_tests_9_extension_20_ExtendableParcelable) -> binder::public_api::Result<()> { self.0.RepeatExtendableParcelable(_arg_ep, _arg_ep2) }
fn ReverseList(&self, _arg_list: &crate::mangled::_7_android_4_aidl_5_tests_13_RecursiveList) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_13_RecursiveList> { self.0.ReverseList(_arg_list) }
+ fn ReverseIBinderArray(&self, _arg_input: &[binder::SpIBinder], _arg_repeated: &mut Vec<Option<binder::SpIBinder>>) -> binder::public_api::Result<Vec<binder::SpIBinder>> { self.0.ReverseIBinderArray(_arg_input, _arg_repeated) }
+ fn ReverseNullableIBinderArray(&self, _arg_input: Option<&[Option<binder::SpIBinder>]>, _arg_repeated: &mut Option<Vec<Option<binder::SpIBinder>>>) -> binder::public_api::Result<Option<Vec<Option<binder::SpIBinder>>>> { self.0.ReverseNullableIBinderArray(_arg_input, _arg_repeated) }
fn GetOldNameInterface(&self) -> binder::public_api::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>> { self.0.GetOldNameInterface() }
fn GetNewNameInterface(&self) -> binder::public_api::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>> { self.0.GetNewNameInterface() }
fn GetCppJavaTests(&self) -> binder::public_api::Result<Option<binder::SpIBinder>> { self.0.GetCppJavaTests() }
@@ -1970,6 +2020,36 @@
}
Ok(())
}
+ transactions::ReverseIBinderArray => {
+ let _arg_input: Vec<binder::SpIBinder> = _aidl_data.read()?;
+ let mut _arg_repeated: Vec<Option<binder::SpIBinder>> = Default::default();
+ _aidl_data.resize_out_vec(&mut _arg_repeated)?;
+ let _aidl_return = _aidl_service.ReverseIBinderArray(&_arg_input, &mut _arg_repeated);
+ match &_aidl_return {
+ Ok(_aidl_return) => {
+ _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+ _aidl_reply.write(_aidl_return)?;
+ _aidl_reply.write(&_arg_repeated)?;
+ }
+ Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+ }
+ Ok(())
+ }
+ transactions::ReverseNullableIBinderArray => {
+ let _arg_input: Option<Vec<Option<binder::SpIBinder>>> = _aidl_data.read()?;
+ let mut _arg_repeated: Option<Vec<Option<binder::SpIBinder>>> = Default::default();
+ _aidl_data.resize_nullable_out_vec(&mut _arg_repeated)?;
+ let _aidl_return = _aidl_service.ReverseNullableIBinderArray(_arg_input.as_deref(), &mut _arg_repeated);
+ match &_aidl_return {
+ Ok(_aidl_return) => {
+ _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+ _aidl_reply.write(_aidl_return)?;
+ _aidl_reply.write(&_arg_repeated)?;
+ }
+ Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+ }
+ Ok(())
+ }
transactions::GetOldNameInterface => {
let _aidl_return = _aidl_service.GetOldNameInterface();
match &_aidl_return {
diff --git a/tests/java/src/android/aidl/service/TestServiceServer.java b/tests/java/src/android/aidl/service/TestServiceServer.java
index df46fe7..e15ec3e 100644
--- a/tests/java/src/android/aidl/service/TestServiceServer.java
+++ b/tests/java/src/android/aidl/service/TestServiceServer.java
@@ -462,7 +462,24 @@
}
return reversed;
}
-
+ @Override
+ public IBinder[] ReverseIBinderArray(IBinder[] input, IBinder[] repeated) {
+ IBinder[] reversed = new IBinder[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
+ @Override
+ public IBinder[] ReverseNullableIBinderArray(IBinder[] input, IBinder[] repeated) {
+ IBinder[] reversed = new IBinder[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
private static class MyOldName extends IOldName.Stub {
@Override
public String RealName() {
@@ -564,24 +581,6 @@
public void TakesAnIBinderList(List<IBinder> input) throws RemoteException {}
@Override
public void TakesANullableIBinderList(List<IBinder> input) throws RemoteException {}
- @Override
- public IBinder[] ReverseIBinderArray(IBinder[] input, IBinder[] repeated) {
- IBinder[] reversed = new IBinder[input.length];
- for (int i = 0; i < input.length; i++) {
- repeated[i] = input[i];
- reversed[i] = input[input.length - i - 1];
- }
- return reversed;
- }
- @Override
- public IBinder[] ReverseNullableIBinderArray(IBinder[] input, IBinder[] repeated) {
- IBinder[] reversed = new IBinder[input.length];
- for (int i = 0; i < input.length; i++) {
- repeated[i] = input[i];
- reversed[i] = input[input.length - i - 1];
- }
- return reversed;
- }
}
@Override
diff --git a/tests/java/src/android/aidl/tests/NullableTests.java b/tests/java/src/android/aidl/tests/NullableTests.java
index c894592..dc55698 100644
--- a/tests/java/src/android/aidl/tests/NullableTests.java
+++ b/tests/java/src/android/aidl/tests/NullableTests.java
@@ -96,11 +96,9 @@
@Test
public void testReverseIBinderArray() throws RemoteException {
- assumeTrue(mCppJavaTests != null);
-
IBinder[] input = {new Binder(), new Binder()};
IBinder[] repeated = new IBinder[input.length];
- IBinder[] reversed = mCppJavaTests.ReverseIBinderArray(input, repeated);
+ IBinder[] reversed = mService.ReverseIBinderArray(input, repeated);
assertThat(repeated, is(input));
assertThat(reversed.length, is(input.length));
@@ -112,11 +110,9 @@
@Test
public void testReverseNullableIBinderArray() throws RemoteException {
- assumeTrue(mCppJavaTests != null);
-
IBinder[] input = {new Binder(), null};
IBinder[] repeated = new IBinder[input.length];
- IBinder[] reversed = mCppJavaTests.ReverseNullableIBinderArray(input, repeated);
+ IBinder[] reversed = mService.ReverseNullableIBinderArray(input, repeated);
assertThat(repeated, is(input));
assertThat(reversed.length, is(input.length));
diff --git a/tests/rust/test_client.rs b/tests/rust/test_client.rs
index 54cacf7..ecef604 100644
--- a/tests/rust/test_client.rs
+++ b/tests/rust/test_client.rs
@@ -1015,4 +1015,37 @@
assert_eq!(ret, Ok(INestedService::Result::Result {
status: ParcelableWithNested::Status::Status::NOT_OK,
}));
-}
\ No newline at end of file
+}
+
+#[test]
+fn test_binder_array() {
+ let service = get_test_service();
+ let callback = service
+ .GetCallback(false)
+ .expect("error calling GetCallback")
+ .expect("expected Some from GetCallback");
+
+ let mut array = vec![service.as_binder(), callback.as_binder()];
+
+ // Java needs initial values here (can't resize arrays)
+ let mut repeated = vec![Default::default(); array.len()];
+
+ let result = service.ReverseIBinderArray(&array, &mut repeated);
+ assert_eq!(repeated.into_iter().collect::<Option<Vec<_>>>().as_ref(), Some(&array));
+ array.reverse();
+ assert_eq!(result, Ok(array));
+}
+
+#[test]
+fn test_nullable_binder_array() {
+ let service = get_test_service();
+ let mut array = vec![Some(service.as_binder()), None];
+
+ // Java needs initial values here (can't resize arrays)
+ let mut repeated = Some(vec![Default::default(); array.len()]);
+
+ let result = service.ReverseNullableIBinderArray(Some(&array[..]), &mut repeated);
+ assert_eq!(repeated.as_ref(), Some(&array));
+ array.reverse();
+ assert_eq!(result, Ok(Some(array)));
+ }
\ No newline at end of file
diff --git a/tests/rust/test_service.rs b/tests/rust/test_service.rs
index fcdc628..8f6770f 100644
--- a/tests/rust/test_service.rs
+++ b/tests/rust/test_service.rs
@@ -326,6 +326,25 @@
Ok(reversed.unwrap())
}
+ fn ReverseIBinderArray(
+ &self,
+ input: &[SpIBinder],
+ repeated: &mut Vec<Option<SpIBinder>>,
+ ) -> binder::Result<Vec<SpIBinder>> {
+ *repeated = input.iter().cloned().map(Some).collect();
+ Ok(input.iter().rev().cloned().collect())
+ }
+
+ fn ReverseNullableIBinderArray(
+ &self,
+ input: Option<&[Option<SpIBinder>]>,
+ repeated: &mut Option<Vec<Option<SpIBinder>>>,
+ ) -> binder::Result<Option<Vec<Option<SpIBinder>>>> {
+ let input = input.expect("input is null");
+ *repeated = Some(input.to_vec());
+ Ok(Some(input.iter().rev().cloned().collect()))
+ }
+
fn GetOldNameInterface(&self) -> binder::Result<binder::Strong<dyn IOldName::IOldName>> {
Ok(IOldName::BnOldName::new_binder(
OldName,