aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/aidl_test_client.cpp3
-rw-r--r--tests/aidl_test_client_versioned_interface.cpp63
-rw-r--r--tests/aidl_test_client_versioned_interface.h29
-rw-r--r--tests/aidl_test_service.cpp18
-rw-r--r--tests/versioned/android/aidl/versioned/tests/Foo.aidl21
-rw-r--r--tests/versioned/android/aidl/versioned/tests/IFooInterface.aidl23
6 files changed, 157 insertions, 0 deletions
diff --git a/tests/aidl_test_client.cpp b/tests/aidl_test_client.cpp
index f4850b00..f55178a3 100644
--- a/tests/aidl_test_client.cpp
+++ b/tests/aidl_test_client.cpp
@@ -30,6 +30,7 @@
#include "aidl_test_client_primitives.h"
#include "aidl_test_client_service_exceptions.h"
#include "aidl_test_client_utf8_strings.h"
+#include "aidl_test_client_versioned_interface.h"
// libutils:
using android::OK;
@@ -112,5 +113,7 @@ int main(int /* argc */, char * argv []) {
if (!client_tests::ConfirmDefaultImpl(service)) return 1;
+ if (!client_tests::ConfirmReadDataAfterParcelableWithNewField()) return 1;
+
return 0;
}
diff --git a/tests/aidl_test_client_versioned_interface.cpp b/tests/aidl_test_client_versioned_interface.cpp
new file mode 100644
index 00000000..205e2ace
--- /dev/null
+++ b/tests/aidl_test_client_versioned_interface.cpp
@@ -0,0 +1,63 @@
+/*
+ * 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 "aidl_test_client_versioned_interface.h"
+
+#include <iostream>
+
+#include <android/aidl/versioned/tests/IFooInterface.h>
+#include <binder/IServiceManager.h>
+#include <utils/StrongPointer.h>
+
+using std::cout;
+using std::endl;
+
+using android::OK;
+using android::sp;
+using android::aidl::versioned::tests::Foo;
+using android::aidl::versioned::tests::IFooInterface;
+
+namespace android {
+namespace aidl {
+namespace tests {
+namespace client {
+
+bool ConfirmReadDataAfterParcelableWithNewField() {
+ cout << "Confirming reading data after parcelable with new field." << endl;
+ sp<IFooInterface> versioned;
+ if (OK != android::getService(IFooInterface::descriptor, &versioned) || versioned == nullptr) {
+ // skip when IFooInterface is not available
+ return true;
+ }
+
+ Foo foo;
+ int32_t ret;
+ auto status = versioned->ignoreFooAndReturnInt(foo, 43, &ret);
+ if (!status.isOk()) {
+ cout << "failed to call ignoreFooAndRepeatInt(): " << endl;
+ return false;
+ }
+ if (ret != 43) {
+ cout << "IFooInterface::ignoreFooAndRepeatInt(foo, 43) should return 43, but got " << ret
+ << endl;
+ return false;
+ }
+ return true;
+}
+
+} // namespace client
+} // namespace tests
+} // namespace aidl
+} // namespace android \ No newline at end of file
diff --git a/tests/aidl_test_client_versioned_interface.h b/tests/aidl_test_client_versioned_interface.h
new file mode 100644
index 00000000..6aa86af0
--- /dev/null
+++ b/tests/aidl_test_client_versioned_interface.h
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+namespace android {
+namespace aidl {
+namespace tests {
+namespace client {
+
+bool ConfirmReadDataAfterParcelableWithNewField();
+
+} // namespace client
+} // namespace tests
+} // namespace aidl
+} // namespace android
diff --git a/tests/aidl_test_service.cpp b/tests/aidl_test_service.cpp
index 6bb8a632..9cb128d5 100644
--- a/tests/aidl_test_service.cpp
+++ b/tests/aidl_test_service.cpp
@@ -33,6 +33,8 @@
#include <utils/Looper.h>
#include <utils/StrongPointer.h>
+#include "android/aidl/versioned/tests/BnFooInterface.h"
+
#include "android/aidl/tests/BnTestService.h"
#include "android/aidl/tests/ITestService.h"
@@ -67,6 +69,8 @@ using android::aidl::tests::BnNamedCallback;
using android::aidl::tests::BnTestService;
using android::aidl::tests::INamedCallback;
using android::aidl::tests::SimpleParcelable;
+using android::aidl::versioned::tests::BnFooInterface;
+using android::aidl::versioned::tests::Foo;
using android::binder::Map;
using android::os::ParcelFileDescriptor;
using android::os::PersistableBundle;
@@ -485,8 +489,21 @@ class NativeService : public BnTestService {
map<String16, sp<INamedCallback>> service_map_;
};
+class FooInterface : public BnFooInterface {
+ public:
+ FooInterface() {}
+ virtual ~FooInterface() = default;
+
+ Status ignoreFooAndReturnInt(const Foo& foo, int32_t value, int32_t* ret) override {
+ (void)foo;
+ *ret = value;
+ return Status::ok();
+ }
+};
+
int Run() {
android::sp<NativeService> service = new NativeService;
+ android::sp<FooInterface> versioned = new FooInterface;
sp<Looper> looper(Looper::prepare(0 /* opts */));
int binder_fd = -1;
@@ -505,6 +522,7 @@ int Run() {
defaultServiceManager()->addService(service->getInterfaceDescriptor(),
service);
+ defaultServiceManager()->addService(versioned->getInterfaceDescriptor(), versioned);
ALOGI("Entering loop");
while (true) {
diff --git a/tests/versioned/android/aidl/versioned/tests/Foo.aidl b/tests/versioned/android/aidl/versioned/tests/Foo.aidl
new file mode 100644
index 00000000..a7a655b9
--- /dev/null
+++ b/tests/versioned/android/aidl/versioned/tests/Foo.aidl
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+package android.aidl.versioned.tests;
+
+parcelable Foo {
+ int intDefault42 = 42;
+} \ No newline at end of file
diff --git a/tests/versioned/android/aidl/versioned/tests/IFooInterface.aidl b/tests/versioned/android/aidl/versioned/tests/IFooInterface.aidl
new file mode 100644
index 00000000..59c38bc5
--- /dev/null
+++ b/tests/versioned/android/aidl/versioned/tests/IFooInterface.aidl
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+package android.aidl.versioned.tests;
+
+import android.aidl.versioned.tests.Foo;
+
+interface IFooInterface {
+ int ignoreFooAndReturnInt(in Foo foo, int value);
+} \ No newline at end of file