summaryrefslogtreecommitdiff
path: root/sensors/common/vts/utils/SensorsHidlEnvironmentBase.cpp
diff options
context:
space:
mode:
authorAnthony Stange <stange@google.com>2020-02-05 19:49:59 -0500
committerAnthony Stange <stange@google.com>2020-02-18 17:45:02 -0500
commita9a5eb411ea8f41d7e929ca1ddc46d762ce1e81b (patch)
treed71fbb6490e9ae5a734669b78e224ccac8161546 /sensors/common/vts/utils/SensorsHidlEnvironmentBase.cpp
parent535c63e672c8aa2ba0ba21e899dc6e72b09ca4f8 (diff)
Add VTS tests for Sensors HAL 2.1
Bug: 144139857 Test: atest VtsHalSensorsV2_0TargetTest VtsHalSensorsV2_1TargetTest Change-Id: If2b751929b8d89c9d381032f5e8424a24719b6bd
Diffstat (limited to 'sensors/common/vts/utils/SensorsHidlEnvironmentBase.cpp')
-rw-r--r--sensors/common/vts/utils/SensorsHidlEnvironmentBase.cpp69
1 files changed, 0 insertions, 69 deletions
diff --git a/sensors/common/vts/utils/SensorsHidlEnvironmentBase.cpp b/sensors/common/vts/utils/SensorsHidlEnvironmentBase.cpp
deleted file mode 100644
index fa0e2e9bf0..0000000000
--- a/sensors/common/vts/utils/SensorsHidlEnvironmentBase.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2018 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 "SensorsHidlEnvironmentBase.h"
-
-void SensorsHidlEnvironmentBase::HidlSetUp() {
- ASSERT_TRUE(resetHal()) << "could not get hidl service";
-
- mCollectionEnabled = false;
- startPollingThread();
-
- // In case framework just stopped for test and there is sensor events in the pipe,
- // wait some time for those events to be cleared to avoid them messing up the test.
- std::this_thread::sleep_for(std::chrono::seconds(3));
-}
-
-void SensorsHidlEnvironmentBase::HidlTearDown() {
- mStopThread = true;
- if (mPollThread.joinable()) {
- mPollThread.detach();
- }
-}
-
-void SensorsHidlEnvironmentBase::catEvents(std::vector<Event>* output) {
- std::lock_guard<std::mutex> lock(mEventsMutex);
- if (output) {
- output->insert(output->end(), mEvents.begin(), mEvents.end());
- }
- mEvents.clear();
-}
-
-void SensorsHidlEnvironmentBase::setCollection(bool enable) {
- std::lock_guard<std::mutex> lock(mEventsMutex);
- mCollectionEnabled = enable;
-}
-
-void SensorsHidlEnvironmentBase::addEvent(const Event& ev) {
- std::lock_guard<std::mutex> lock(mEventsMutex);
- if (mCollectionEnabled) {
- mEvents.push_back(ev);
- }
-
- if (mCallback != nullptr) {
- mCallback->onEvent(ev);
- }
-}
-
-void SensorsHidlEnvironmentBase::registerCallback(IEventCallback* callback) {
- std::lock_guard<std::mutex> lock(mEventsMutex);
- mCallback = callback;
-}
-
-void SensorsHidlEnvironmentBase::unregisterCallback() {
- std::lock_guard<std::mutex> lock(mEventsMutex);
- mCallback = nullptr;
-} \ No newline at end of file