From 1b34d67b7a3572b884398fafebacc23baac8853d Mon Sep 17 00:00:00 2001 From: Devin Moore Date: Wed, 8 Jul 2020 09:31:08 -0700 Subject: [PATCH] Adding AidlMQDescriptor and GrantorDescriptor Adding these two types to android.hardware.common for future use with Fast Message Queue in libfmq. Also adding to the mq_test_service to test them. Test: system/tools/hidl/tests/run_all_device_tests.sh Bug: 142326204 Change-Id: I424c4849c822436f58e40f206b09ffdf9baf260b --- .../hardware/common/GrantorDescriptor.aidl | 25 +++++++++++++ .../android/hardware/common/MQDescriptor.aidl | 25 +++++++++++++ .../hardware/common/GrantorDescriptor.aidl | 25 +++++++++++++ .../android/hardware/common/MQDescriptor.aidl | 35 +++++++++++++++++++ tests/msgq/1.0/default/Android.bp | 18 +++++++--- tests/msgq/1.0/default/mq_test_service.cpp | 20 ++++++++++- 6 files changed, 142 insertions(+), 6 deletions(-) create mode 100644 common/aidl/aidl_api/android.hardware.common/current/android/hardware/common/GrantorDescriptor.aidl create mode 100644 common/aidl/aidl_api/android.hardware.common/current/android/hardware/common/MQDescriptor.aidl create mode 100644 common/aidl/android/hardware/common/GrantorDescriptor.aidl create mode 100644 common/aidl/android/hardware/common/MQDescriptor.aidl diff --git a/common/aidl/aidl_api/android.hardware.common/current/android/hardware/common/GrantorDescriptor.aidl b/common/aidl/aidl_api/android.hardware.common/current/android/hardware/common/GrantorDescriptor.aidl new file mode 100644 index 0000000000..4a9ecd9ba6 --- /dev/null +++ b/common/aidl/aidl_api/android.hardware.common/current/android/hardware/common/GrantorDescriptor.aidl @@ -0,0 +1,25 @@ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL interface (or parcelable). Do not try to +// edit this file. It looks like you are doing that because you have modified +// an AIDL interface in a backward-incompatible way, e.g., deleting a function +// from an interface or a field from a parcelable and it broke the build. That +// breakage is intended. +// +// You must not make a backward incompatible changes to the AIDL files built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.common; +@VintfStability +parcelable GrantorDescriptor { + int flags; + int fdIndex; + int offset; + long extent; +} diff --git a/common/aidl/aidl_api/android.hardware.common/current/android/hardware/common/MQDescriptor.aidl b/common/aidl/aidl_api/android.hardware.common/current/android/hardware/common/MQDescriptor.aidl new file mode 100644 index 0000000000..c9fe1d7e8d --- /dev/null +++ b/common/aidl/aidl_api/android.hardware.common/current/android/hardware/common/MQDescriptor.aidl @@ -0,0 +1,25 @@ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL interface (or parcelable). Do not try to +// edit this file. It looks like you are doing that because you have modified +// an AIDL interface in a backward-incompatible way, e.g., deleting a function +// from an interface or a field from a parcelable and it broke the build. That +// breakage is intended. +// +// You must not make a backward incompatible changes to the AIDL files built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.common; +@VintfStability +parcelable MQDescriptor { + android.hardware.common.GrantorDescriptor[] grantors; + ParcelFileDescriptor fileDescriptor; + int quantum; + int flags; +} diff --git a/common/aidl/android/hardware/common/GrantorDescriptor.aidl b/common/aidl/android/hardware/common/GrantorDescriptor.aidl new file mode 100644 index 0000000000..442d7fa55c --- /dev/null +++ b/common/aidl/android/hardware/common/GrantorDescriptor.aidl @@ -0,0 +1,25 @@ +/* + * Copyright 2020 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.hardware.common; + +@VintfStability +parcelable GrantorDescriptor { + int flags; + int fdIndex; + int offset; + long extent; +} diff --git a/common/aidl/android/hardware/common/MQDescriptor.aidl b/common/aidl/android/hardware/common/MQDescriptor.aidl new file mode 100644 index 0000000000..1126a25e9e --- /dev/null +++ b/common/aidl/android/hardware/common/MQDescriptor.aidl @@ -0,0 +1,35 @@ +/* + * Copyright 2020 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.hardware.common; + +import android.hardware.common.GrantorDescriptor; + +@VintfStability +parcelable MQDescriptor { + /* + * Describes each of the grantors for the message queue. They are used to + * get the readptr, writeptr, dataptr, and the optional EventFlag word + * for blocking operations in the shared memory. + */ + GrantorDescriptor[] grantors; + /* File descriptor for shared memory used in the message queue */ + ParcelFileDescriptor fileDescriptor; + /* Size of each item, T, in bytes */ + int quantum; + /* EventFlag word for blocking operations */ + int flags; +} diff --git a/tests/msgq/1.0/default/Android.bp b/tests/msgq/1.0/default/Android.bp index e6408aa1aa..47b8df17b4 100644 --- a/tests/msgq/1.0/default/Android.bp +++ b/tests/msgq/1.0/default/Android.bp @@ -19,7 +19,7 @@ cc_library { relative_install_path: "hw", srcs: [ "TestMsgQ.cpp", - "BenchmarkMsgQ.cpp" + "BenchmarkMsgQ.cpp", ], shared_libs: [ "libbase", @@ -34,7 +34,7 @@ cc_library { // libs should be used on device. static_libs: [ "android.hardware.tests.msgq@1.0", - ] + ], } cc_test { @@ -49,7 +49,7 @@ cc_test { "libhidlbase", "liblog", "libutils", - "android.hardware.tests.msgq@1.0" + "android.hardware.tests.msgq@1.0", ], test_suites: ["general-tests"], } @@ -67,6 +67,7 @@ cc_test { "libhidlbase", "liblog", "libutils", + "libbinder_ndk", ], // Allow dlsym'ing self for statically linked passthrough implementations @@ -74,7 +75,14 @@ cc_test { // These are static libs only for testing purposes and portability. Shared // libs should be used on device. - static_libs: ["android.hardware.tests.msgq@1.0"], - whole_static_libs: ["android.hardware.tests.msgq@1.0-impl"], + static_libs: [ + "android.hardware.tests.msgq@1.0", + "android.fmq.test-ndk_platform", + "android.hardware.common-unstable-ndk_platform", + ], + whole_static_libs: [ + "android.hardware.tests.msgq@1.0-impl", + "android.fmq.test-impl", + ], test_suites: ["general-tests"], } diff --git a/tests/msgq/1.0/default/mq_test_service.cpp b/tests/msgq/1.0/default/mq_test_service.cpp index b921bfd34e..72ffe41b74 100644 --- a/tests/msgq/1.0/default/mq_test_service.cpp +++ b/tests/msgq/1.0/default/mq_test_service.cpp @@ -16,8 +16,14 @@ #define LOG_TAG "FMQ_UnitTests" +#include +#include +#include +#include #include +using aidl::android::fmq::test::TestAidlMsgQ; + #include using android::hardware::tests::msgq::V1_0::ITestMsgQ; @@ -25,5 +31,17 @@ using android::hardware::defaultPassthroughServiceImplementation; int main() { android::hardware::details::setTrebleTestingOverride(true); - return defaultPassthroughServiceImplementation(); + // Register AIDL service + ABinderProcess_startThreadPool(); + std::shared_ptr store = ndk::SharedRefBase::make(); + + const std::string instance = std::string() + TestAidlMsgQ::descriptor + "/default"; + LOG(INFO) << "instance: " << instance; + CHECK(AServiceManager_addService(store->asBinder().get(), instance.c_str()) == STATUS_OK); + + // Register HIDL service + CHECK(defaultPassthroughServiceImplementation() == android::OK); + ABinderProcess_joinThreadPool(); + + return EXIT_FAILURE; // should not reach }