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 : public SensorsHidlEnvironmentBase { 33 public: 34 using Event = ::android::hardware::sensors::V1_0::Event; 35 // get the test environment singleton 36 static SensorsHidlEnvironmentV1_0* Instance() { 37 static SensorsHidlEnvironmentV1_0* instance = new SensorsHidlEnvironmentV1_0(); 38 return instance; 39 } 40 41 virtual void registerTestServices() override { 42 registerTestService<android::hardware::sensors::V1_0::ISensors>(); 43 } 44 45 private: 46 friend SensorsHidlTest; 47 // sensors hidl service 48 sp<android::hardware::sensors::V1_0::ISensors> sensors; 49 50 SensorsHidlEnvironmentV1_0() {} 51 52 bool resetHal() override; 53 void startPollingThread() override; 54 static void pollingThread(SensorsHidlEnvironmentV1_0* env, std::atomic_bool& stop); 55 56 GTEST_DISALLOW_COPY_AND_ASSIGN_(SensorsHidlEnvironmentV1_0); 57 }; 58 59 #endif // ANDROID_SENSORS_HIDL_ENVIRONMENT_V1_0_H