1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef DEVICE_STATUS_SENSOR_MANAGER_H 16 #define DEVICE_STATUS_SENSOR_MANAGER_H 17 18 #include <atomic> 19 20 #include "sensor_agent.h" 21 #include "sensor_agent_type.h" 22 23 namespace OHOS { 24 namespace Msdp { 25 namespace DeviceStatus { 26 class SensorManager { 27 public: 28 // forbid copy and default constuctor 29 SensorManager() = delete; 30 SensorManager(const SensorManager &) = delete; 31 virtual ~SensorManager(); 32 SensorManager& operator =(const SensorManager &) = delete; 33 SensorManager(const int32_t sensorTypeId, const int32_t sensorSamplingInterval); 34 void SetCallback(RecordSensorCallback callback); 35 static bool IsSupportedSensor(const int32_t sensorTypeId); 36 int32_t StartSensor(); 37 int32_t StopSensor(); 38 bool GetRunningStatus(); 39 private: 40 SensorUser sensorUser_; 41 int32_t sensorTypeId_; 42 int32_t sensorSamplingInterval_ = 0; 43 std::atomic_bool isRunning_ = false; 44 }; 45 } // namespace DeviceStatus 46 } // namespace Msdp 47 } // namespace OHOS 48 #endif