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
diff --git a/tests/msgq/1.0/default/Android.bp b/tests/msgq/1.0/default/Android.bp
index e6408aa..47b8df1 100644
--- a/tests/msgq/1.0/default/Android.bp
+++ b/tests/msgq/1.0/default/Android.bp
@@ -19,7 +19,7 @@
     relative_install_path: "hw",
     srcs: [
         "TestMsgQ.cpp",
-        "BenchmarkMsgQ.cpp"
+        "BenchmarkMsgQ.cpp",
     ],
     shared_libs: [
         "libbase",
@@ -34,7 +34,7 @@
     // libs should be used on device.
     static_libs: [
         "android.hardware.tests.msgq@1.0",
-    ]
+    ],
 }
 
 cc_test {
@@ -49,7 +49,7 @@
         "libhidlbase",
         "liblog",
         "libutils",
-        "android.hardware.tests.msgq@1.0"
+        "android.hardware.tests.msgq@1.0",
     ],
     test_suites: ["general-tests"],
 }
@@ -67,6 +67,7 @@
         "libhidlbase",
         "liblog",
         "libutils",
+        "libbinder_ndk",
     ],
 
     // Allow dlsym'ing self for statically linked passthrough implementations
@@ -74,7 +75,14 @@
 
     // 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 b921bfd..72ffe41 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 <TestAidlMsgQ.h>
+#include <android-base/logging.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
 #include <android/hardware/tests/msgq/1.0/ITestMsgQ.h>
 
+using aidl::android::fmq::test::TestAidlMsgQ;
+
 #include <hidl/LegacySupport.h>
 
 using android::hardware::tests::msgq::V1_0::ITestMsgQ;
@@ -25,5 +31,17 @@
 
 int main() {
     android::hardware::details::setTrebleTestingOverride(true);
-    return defaultPassthroughServiceImplementation<ITestMsgQ>();
+    // Register AIDL service
+    ABinderProcess_startThreadPool();
+    std::shared_ptr<TestAidlMsgQ> store = ndk::SharedRefBase::make<TestAidlMsgQ>();
+
+    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<ITestMsgQ>() == android::OK);
+    ABinderProcess_joinThreadPool();
+
+    return EXIT_FAILURE;  // should not reach
 }