Merge "Added protections to RenderScript VTS class teardown."
diff --git a/radio/1.0/vts/functional/Android.bp b/radio/1.0/vts/functional/Android.bp
index 5403971..8cd823e 100644
--- a/radio/1.0/vts/functional/Android.bp
+++ b/radio/1.0/vts/functional/Android.bp
@@ -70,3 +70,38 @@
"-g",
],
}
+
+cc_library_static {
+ name: "RadioHidlHalUtilsBase",
+ srcs : [
+ "radio_hidl_hal_test.cpp",
+ "radio_response.cpp"
+ ],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libcutils",
+ "libhidlbase",
+ "libhidltransport",
+ "libnativehelper",
+ "libutils",
+ "android.hardware.radio@1.0",
+ ],
+ static_libs: ["VtsHalHidlTargetTestBase"],
+ cflags: [
+ "-O0",
+ "-g",
+ ],
+}
+
+cc_library_static {
+ name: "RadioVtsTestUtilBase",
+ srcs : [
+ "vts_test_util.cpp"
+ ],
+}
+
+cc_library_headers {
+ name: "radio.util.header@1.0",
+ export_include_dirs: ["."],
+}
\ No newline at end of file
diff --git a/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp b/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp
index 59881ef..3448494 100644
--- a/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp
+++ b/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <radio_hidl_hal_utils.h>
+#include <radio_hidl_hal_utils_v1_0.h>
int main(int argc, char** argv) {
::testing::AddGlobalTestEnvironment(new RadioHidlEnvironment);
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_cell_broadcast.cpp b/radio/1.0/vts/functional/radio_hidl_hal_cell_broadcast.cpp
index 3bf7c9d..44f69e2 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_cell_broadcast.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_cell_broadcast.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <radio_hidl_hal_utils.h>
+#include <radio_hidl_hal_utils_v1_0.h>
using namespace ::android::hardware::radio::V1_0;
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_data.cpp b/radio/1.0/vts/functional/radio_hidl_hal_data.cpp
index 108676b..35d97ee 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_data.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_data.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <radio_hidl_hal_utils.h>
+#include <radio_hidl_hal_utils_v1_0.h>
using namespace ::android::hardware::radio::V1_0;
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp b/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp
index a8857c3..8f01d8d 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <radio_hidl_hal_utils.h>
+#include <radio_hidl_hal_utils_v1_0.h>
/*
* Test IRadio.getIccCardStatus() for the response returned.
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_ims.cpp b/radio/1.0/vts/functional/radio_hidl_hal_ims.cpp
index ec99d42..75a1317 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_ims.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_ims.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <radio_hidl_hal_utils.h>
+#include <radio_hidl_hal_utils_v1_0.h>
using namespace ::android::hardware::radio::V1_0;
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp b/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp
index 29cb912..5d0824c 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <radio_hidl_hal_utils.h>
+#include <radio_hidl_hal_utils_v1_0.h>
/*
* Test IRadio.getSignalStrength() for the response returned.
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_sms.cpp b/radio/1.0/vts/functional/radio_hidl_hal_sms.cpp
index 698cf26..70469d2 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_sms.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_sms.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <radio_hidl_hal_utils.h>
+#include <radio_hidl_hal_utils_v1_0.h>
using namespace ::android::hardware::radio::V1_0;
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_stk.cpp b/radio/1.0/vts/functional/radio_hidl_hal_stk.cpp
index 4c76c45..1c21303 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_stk.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_stk.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <radio_hidl_hal_utils.h>
+#include <radio_hidl_hal_utils_v1_0.h>
using namespace ::android::hardware::radio::V1_0;
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_test.cpp b/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
index 1aa9d6c..5b9130e 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <radio_hidl_hal_utils.h>
+#include <radio_hidl_hal_utils_v1_0.h>
void RadioHidlTest::SetUp() {
radio =
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_utils.h b/radio/1.0/vts/functional/radio_hidl_hal_utils_v1_0.h
similarity index 99%
rename from radio/1.0/vts/functional/radio_hidl_hal_utils.h
rename to radio/1.0/vts/functional/radio_hidl_hal_utils_v1_0.h
index 3c46e79..3bd69ab 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_utils.h
+++ b/radio/1.0/vts/functional/radio_hidl_hal_utils_v1_0.h
@@ -26,7 +26,7 @@
#include <android/hardware/radio/1.0/IRadioResponse.h>
#include <android/hardware/radio/1.0/types.h>
-#include <vts_test_util.h>
+#include "vts_test_util.h"
using ::android::hardware::radio::V1_0::ActivityStatsInfo;
using ::android::hardware::radio::V1_0::AppType;
@@ -90,7 +90,7 @@
/* Callback class for radio response */
class RadioResponse : public IRadioResponse {
- private:
+ protected:
RadioHidlTest& parent;
public:
@@ -442,7 +442,7 @@
// The main test class for Radio HIDL.
class RadioHidlTest : public ::testing::VtsHalHidlTargetTestBase {
- private:
+ protected:
std::mutex mtx;
std::condition_variable cv;
int count;
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_voice.cpp b/radio/1.0/vts/functional/radio_hidl_hal_voice.cpp
index 95d00e3..e6036db 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_voice.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_voice.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <radio_hidl_hal_utils.h>
+#include <radio_hidl_hal_utils_v1_0.h>
/*
* Test IRadio.getCurrentCalls() for the response returned.
diff --git a/radio/1.0/vts/functional/radio_response.cpp b/radio/1.0/vts/functional/radio_response.cpp
index ef887eb..434d488 100644
--- a/radio/1.0/vts/functional/radio_response.cpp
+++ b/radio/1.0/vts/functional/radio_response.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <radio_hidl_hal_utils.h>
+#include <radio_hidl_hal_utils_v1_0.h>
CardStatus cardStatus;
diff --git a/radio/1.0/vts/functional/sap_hidl_hal_utils.h b/radio/1.0/vts/functional/sap_hidl_hal_utils.h
index fe93a4d..7126b06 100644
--- a/radio/1.0/vts/functional/sap_hidl_hal_utils.h
+++ b/radio/1.0/vts/functional/sap_hidl_hal_utils.h
@@ -25,7 +25,7 @@
#include <android/hardware/radio/1.0/ISapCallback.h>
#include <android/hardware/radio/1.0/types.h>
-#include <vts_test_util.h>
+#include "vts_test_util.h"
using namespace ::android::hardware::radio::V1_0;
diff --git a/radio/1.1/vts/Android.mk b/radio/1.1/vts/Android.mk
new file mode 100644
index 0000000..df5dac8
--- /dev/null
+++ b/radio/1.1/vts/Android.mk
@@ -0,0 +1,19 @@
+#
+# Copyright (C) 2016 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(call all-subdir-makefiles)
\ No newline at end of file
diff --git a/radio/1.1/vts/functional/Android.bp b/radio/1.1/vts/functional/Android.bp
new file mode 100644
index 0000000..59ef905
--- /dev/null
+++ b/radio/1.1/vts/functional/Android.bp
@@ -0,0 +1,46 @@
+//
+// Copyright (C) 2017 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.
+//
+
+cc_test {
+ name: "VtsHalRadioV1_1TargetTest",
+ defaults: ["hidl_defaults"],
+ srcs: ["radio_hidl_hal_api.cpp",
+ "radio_hidl_hal_test.cpp",
+ "radio_response.cpp",
+ "VtsHalRadioV1_1TargetTest.cpp"],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libcutils",
+ "libhidlbase",
+ "libhidltransport",
+ "libnativehelper",
+ "libutils",
+ "android.hardware.radio@1.1",
+ "android.hardware.radio@1.0",
+ ],
+ static_libs: ["VtsHalHidlTargetTestBase",
+ "RadioHidlHalUtilsBase",
+ "RadioVtsTestUtilBase"],
+ header_libs: [
+ "radio.util.header@1.0",
+ ],
+ cflags: [
+ "-O0",
+ "-g",
+ ],
+}
+
diff --git a/radio/1.1/vts/functional/VtsHalRadioV1_1TargetTest.cpp b/radio/1.1/vts/functional/VtsHalRadioV1_1TargetTest.cpp
new file mode 100644
index 0000000..09351c8
--- /dev/null
+++ b/radio/1.1/vts/functional/VtsHalRadioV1_1TargetTest.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2017 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 <radio_hidl_hal_utils_v1_1.h>
+
+int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(new RadioHidlEnvironment);
+ ::testing::InitGoogleTest(&argc, argv);
+
+ int status = RUN_ALL_TESTS();
+ LOG(INFO) << "Test result = " << status;
+
+ return status;
+}
\ No newline at end of file
diff --git a/radio/1.1/vts/functional/radio_hidl_hal_api.cpp b/radio/1.1/vts/functional/radio_hidl_hal_api.cpp
new file mode 100644
index 0000000..4f4fa6d
--- /dev/null
+++ b/radio/1.1/vts/functional/radio_hidl_hal_api.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2017 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 <radio_hidl_hal_utils_v1_1.h>
+
+/*
+ * Test IRadio.setSimCardPower() for the response returned.
+ */
+TEST_F(RadioHidlTest_v1_1, setSimCardPower_1_1) {
+ int serial = GetRandomSerialNumber();
+
+ radio_v1_1->setSimCardPower_1_1(serial, CardPowerState::POWER_DOWN);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_1->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp_v1_1->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp_v1_1->rspInfo.error == RadioError::NONE ||
+ radioRsp_v1_1->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED ||
+ radioRsp_v1_1->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
+ radioRsp_v1_1->rspInfo.error == RadioError::RADIO_NOT_AVAILABLE);
+ }
+}
diff --git a/radio/1.1/vts/functional/radio_hidl_hal_test.cpp b/radio/1.1/vts/functional/radio_hidl_hal_test.cpp
new file mode 100644
index 0000000..eb87549
--- /dev/null
+++ b/radio/1.1/vts/functional/radio_hidl_hal_test.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2017 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 <radio_hidl_hal_utils_v1_1.h>
+
+void RadioHidlTest_v1_1::SetUp() {
+ radio_v1_1 =
+ ::testing::VtsHalHidlTargetTestBase::getService<::android::hardware::radio::V1_1::IRadio>(
+ hidl_string(RADIO_SERVICE_NAME));
+ ASSERT_NE(radio_v1_1, nullptr);
+
+ radioRsp_v1_1 = new RadioResponse_v1_1(*this);
+ ASSERT_NE(radioRsp_v1_1, nullptr);
+
+ count = 0;
+
+ radioInd_v1_1 = NULL;
+ radio_v1_1->setResponseFunctions(radioRsp_v1_1, radioInd_v1_1);
+
+ int serial = GetRandomSerialNumber();
+ radio_v1_1->getIccCardStatus(serial);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_1->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp_v1_1->rspInfo.serial);
+ EXPECT_EQ(RadioError::NONE, radioRsp_v1_1->rspInfo.error);
+}
diff --git a/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h b/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h
new file mode 100644
index 0000000..ae72d8f
--- /dev/null
+++ b/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2017 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/hardware/radio/1.1/IRadio.h>
+#include <android/hardware/radio/1.1/IRadioIndication.h>
+#include <android/hardware/radio/1.1/IRadioResponse.h>
+#include <android/hardware/radio/1.1/types.h>
+
+#include "radio_hidl_hal_utils_v1_0.h"
+
+using namespace ::android::hardware::radio::V1_1;
+
+class RadioHidlTest_v1_1;
+
+/* Callback class for radio response v1_1*/
+class RadioResponse_v1_1 : public RadioResponse {
+ protected:
+ RadioHidlTest_v1_1& parent_v1_1;
+
+ public:
+ RadioResponse_v1_1(RadioHidlTest_v1_1& parent_v1_1);
+ virtual ~RadioResponse_v1_1() = default;
+
+ /* 1.1 Api */
+ Return<void> setCarrierInfoForImsiEncryptionResponse(const RadioResponseInfo& info);
+
+ Return<void> setSimCardPowerResponse_1_1(const RadioResponseInfo& info);
+
+ Return<void> startNetworkScanResponse(const RadioResponseInfo& info);
+
+ Return<void> stopNetworkScanResponse(const RadioResponseInfo& info);
+};
+
+// The main test class for Radio HIDL.
+class RadioHidlTest_v1_1 : public RadioHidlTest {
+ public:
+ virtual void SetUp() override;
+ sp<::android::hardware::radio::V1_1::IRadio> radio_v1_1;
+ sp<RadioResponse_v1_1> radioRsp_v1_1;
+ sp<::android::hardware::radio::V1_1::IRadioIndication> radioInd_v1_1;
+};
\ No newline at end of file
diff --git a/radio/1.1/vts/functional/radio_response.cpp b/radio/1.1/vts/functional/radio_response.cpp
new file mode 100644
index 0000000..5b64543
--- /dev/null
+++ b/radio/1.1/vts/functional/radio_response.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2017 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 <radio_hidl_hal_utils_v1_1.h>
+
+RadioResponse_v1_1::RadioResponse_v1_1(RadioHidlTest_v1_1& parent)
+ : RadioResponse(parent), parent_v1_1(parent) {}
+
+/* 1.1 Apis */
+Return<void> RadioResponse_v1_1::setCarrierInfoForImsiEncryptionResponse(
+ const RadioResponseInfo& /*info*/) {
+ return Void();
+}
+
+Return<void> RadioResponse_v1_1::setSimCardPowerResponse_1_1(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent_v1_1.notify();
+ return Void();
+}
+
+Return<void> RadioResponse_v1_1::startNetworkScanResponse(const RadioResponseInfo& /*info*/) {
+ return Void();
+}
+
+Return<void> RadioResponse_v1_1::stopNetworkScanResponse(const RadioResponseInfo& /*info*/) {
+ return Void();
+}
diff --git a/radio/Android.bp b/radio/Android.bp
index dbeca0c..0acb2ee 100644
--- a/radio/Android.bp
+++ b/radio/Android.bp
@@ -3,5 +3,6 @@
"1.0",
"1.0/vts/functional",
"1.1",
+ "1.1/vts/functional",
"deprecated/1.0",
]
diff --git a/tests/Android.bp b/tests/Android.bp
index 7b2b2d3..494b349 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -19,6 +19,8 @@
"memory/1.0/default",
"msgq/1.0",
"msgq/1.0/default",
+ "multithread/1.0",
+ "multithread/1.0/default",
"pointer/1.0",
"pointer/1.0/default",
"pointer/1.0/default/lib",
diff --git a/tests/multithread/1.0/Android.bp b/tests/multithread/1.0/Android.bp
new file mode 100644
index 0000000..c3782a0
--- /dev/null
+++ b/tests/multithread/1.0/Android.bp
@@ -0,0 +1,59 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+ name: "android.hardware.tests.multithread@1.0_hal",
+ srcs: [
+ "IMultithread.hal",
+ ],
+}
+
+genrule {
+ name: "android.hardware.tests.multithread@1.0_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.tests.multithread@1.0",
+ srcs: [
+ ":android.hardware.tests.multithread@1.0_hal",
+ ],
+ out: [
+ "android/hardware/tests/multithread/1.0/MultithreadAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.tests.multithread@1.0_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.tests.multithread@1.0",
+ srcs: [
+ ":android.hardware.tests.multithread@1.0_hal",
+ ],
+ out: [
+ "android/hardware/tests/multithread/1.0/IMultithread.h",
+ "android/hardware/tests/multithread/1.0/IHwMultithread.h",
+ "android/hardware/tests/multithread/1.0/BnHwMultithread.h",
+ "android/hardware/tests/multithread/1.0/BpHwMultithread.h",
+ "android/hardware/tests/multithread/1.0/BsMultithread.h",
+ ],
+}
+
+cc_library_shared {
+ name: "android.hardware.tests.multithread@1.0",
+ defaults: ["hidl-module-defaults"],
+ generated_sources: ["android.hardware.tests.multithread@1.0_genc++"],
+ generated_headers: ["android.hardware.tests.multithread@1.0_genc++_headers"],
+ export_generated_headers: ["android.hardware.tests.multithread@1.0_genc++_headers"],
+ vendor_available: true,
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ ],
+ export_shared_lib_headers: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ ],
+}
diff --git a/tests/multithread/1.0/Android.mk b/tests/multithread/1.0/Android.mk
new file mode 100644
index 0000000..f63381d
--- /dev/null
+++ b/tests/multithread/1.0/Android.mk
@@ -0,0 +1,76 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.tests.multithread-V1.0-java
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_JAVA_LIBRARIES := \
+ android.hidl.base-V1.0-java \
+
+
+#
+# Build IMultithread.hal
+#
+GEN := $(intermediates)/android/hardware/tests/multithread/V1_0/IMultithread.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IMultithread.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.tests.multithread@1.0::IMultithread
+
+$(GEN): $(LOCAL_PATH)/IMultithread.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.tests.multithread-V1.0-java-static
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android.hidl.base-V1.0-java-static \
+
+
+#
+# Build IMultithread.hal
+#
+GEN := $(intermediates)/android/hardware/tests/multithread/V1_0/IMultithread.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IMultithread.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.tests.multithread@1.0::IMultithread
+
+$(GEN): $(LOCAL_PATH)/IMultithread.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/multithread/1.0/IMultithread.hal b/tests/multithread/1.0/IMultithread.hal
new file mode 100644
index 0000000..19dc4f6
--- /dev/null
+++ b/tests/multithread/1.0/IMultithread.hal
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2017 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.tests.multithread@1.0;
+
+/**
+ * IMultithread tests configureRpcThreadpool
+ *
+ * Makes calls finish only when specific number of them are running in parallel
+ */
+interface IMultithread {
+ /**
+ * Sets up controller
+ * Must be called for each test
+ * @param maxThreads arg passed to configureRpcThreadpool
+ * Could not be decremented by future calls
+ * @param numThreads number of calls in parallel to finish
+ */
+ setNumThreads(int32_t maxThreads, int32_t numThreads);
+
+ /**
+ * Makes a new call
+ * @return noTimeout numThreads appeared in parallel before timeout
+ * Shall return the same value for one setNumThreads call
+ */
+ runNewThread() generates (bool noTimeout);
+};
diff --git a/tests/multithread/1.0/default/Android.bp b/tests/multithread/1.0/default/Android.bp
new file mode 100644
index 0000000..72b9e91
--- /dev/null
+++ b/tests/multithread/1.0/default/Android.bp
@@ -0,0 +1,17 @@
+cc_library_shared {
+ name: "android.hardware.tests.multithread@1.0-impl",
+ defaults: ["hidl_defaults"],
+ relative_install_path: "hw",
+ proprietary: true,
+ srcs: [
+ "Multithread.cpp",
+ ],
+ shared_libs: [
+ "libbase",
+ "libhidlbase",
+ "libhidltransport",
+ "liblog",
+ "libutils",
+ "android.hardware.tests.multithread@1.0",
+ ],
+}
diff --git a/tests/multithread/1.0/default/Multithread.cpp b/tests/multithread/1.0/default/Multithread.cpp
new file mode 100644
index 0000000..1fb267c
--- /dev/null
+++ b/tests/multithread/1.0/default/Multithread.cpp
@@ -0,0 +1,63 @@
+#define LOG_TAG "hidl_test"
+
+#include <android-base/logging.h>
+#include "Multithread.h"
+#include <inttypes.h>
+#include <thread>
+
+#include <hidl/HidlTransportSupport.h>
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace multithread {
+namespace V1_0 {
+namespace implementation {
+
+// Methods from ::android::hardware::tests::multithread::V1_0::IMultithread follow.
+Return<void> Multithread::setNumThreads(int32_t maxThreads, int32_t numThreads) {
+ LOG(INFO) << "SERVER(Multithread) setNumThreads("
+ << maxThreads << ", " << numThreads << ")";
+
+ LOG(INFO) << "SERVER(Multithread) call configureRpcThreadpool("
+ << maxThreads << ")";
+ ::android::hardware::configureRpcThreadpool(maxThreads, /*willjoin*/ false);
+
+ mNumThreads = numThreads;
+ mNoTimeout = true;
+
+ return Void();
+}
+
+Return<bool> Multithread::runNewThread() {
+ LOG(INFO) << "SERVER(Multithread) runNewThread()";
+
+ std::unique_lock<std::mutex> lk(mCvMutex);
+ --mNumThreads;
+
+ LOG(INFO) << "SERVER(Multithread) runNewThread()";
+ LOG(INFO) << mNumThreads << "threads left";
+
+ mCv.notify_all();
+ bool noTimeout = mCv.wait_for(lk, kTimeoutDuration,
+ [&] { return mNumThreads <= 0 || !mNoTimeout; });
+
+ if (!noTimeout) {
+ mNoTimeout = false;
+ mCv.notify_all();
+ }
+ return mNoTimeout;
+}
+
+IMultithread* HIDL_FETCH_IMultithread(const char* /* name */) {
+ return new Multithread();
+}
+
+decltype(Multithread::kTimeoutDuration) Multithread::kTimeoutDuration;
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace multithread
+} // namespace tests
+} // namespace hardware
+} // namespace android
diff --git a/tests/multithread/1.0/default/Multithread.h b/tests/multithread/1.0/default/Multithread.h
new file mode 100644
index 0000000..0d4a007
--- /dev/null
+++ b/tests/multithread/1.0/default/Multithread.h
@@ -0,0 +1,48 @@
+#ifndef ANDROID_HARDWARE_TESTS_MULTITHREAD_V1_0_MULTITHREAD_H
+#define ANDROID_HARDWARE_TESTS_MULTITHREAD_V1_0_MULTITHREAD_H
+
+#include <android/hardware/tests/multithread/1.0/IMultithread.h>
+#include <hidl/Status.h>
+
+#include <chrono>
+#include <condition_variable>
+#include <mutex>
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace multithread {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::tests::multithread::V1_0::IMultithread;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+
+using namespace std::chrono_literals;
+
+struct Multithread : public IMultithread {
+ // Methods from ::android::hardware::tests::multithread::V1_0::IMultithread follow.
+ virtual Return<void> setNumThreads(int32_t maxThreads, int32_t numThreads) override;
+ virtual Return<bool> runNewThread() override;
+
+ private:
+ int32_t mNumThreads;
+ bool mNoTimeout;
+
+ std::condition_variable mCv;
+ std::mutex mCvMutex;
+
+ static constexpr auto kTimeoutDuration = 100ms;
+};
+
+extern "C" IMultithread* HIDL_FETCH_IMultithread(const char* name);
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace multithread
+} // namespace tests
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_TESTS_MULTITHREAD_V1_0_MULTITHREAD_H