1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ANDROID_SENSORS_HIDL_ENVIRONMENT_V1_0_H 18 #define ANDROID_SENSORS_HIDL_ENVIRONMENT_V1_0_H 19 20 #include "sensors-vts-utils/SensorsHidlEnvironmentBase.h" 21 22 #include <android/hardware/sensors/1.0/ISensors.h> 23 #include <android/hardware/sensors/1.0/types.h> 24 #include <utils/StrongPointer.h> 25 26 #include <atomic> 27 #include <memory> 28 29 using ::android::sp; 30 31 class SensorsHidlTest; 32 class SensorsHidlEnvironmentV1_0 33 : public SensorsHidlEnvironmentBase<::android::hardware::sensors::V1_0::Event> { 34 public: 35 void HidlTearDown() override; 36 37 using Event = ::android::hardware::sensors::V1_0::Event; SensorsHidlEnvironmentV1_0(const std::string & service_name)38 SensorsHidlEnvironmentV1_0(const std::string& service_name) 39 : SensorsHidlEnvironmentBase(service_name) {} 40 41 private: 42 friend SensorsHidlTest; 43 // sensors hidl service 44 sp<android::hardware::sensors::V1_0::ISensors> sensors; 45 46 bool resetHal() override; 47 void startPollingThread() override; 48 static void pollingThread(SensorsHidlEnvironmentV1_0* env, std::atomic_bool& stop); 49 50 GTEST_DISALLOW_COPY_AND_ASSIGN_(SensorsHidlEnvironmentV1_0); 51 }; 52 53 #endif // ANDROID_SENSORS_HIDL_ENVIRONMENT_V1_0_H