1094332d3Sopenharmony_ci/* 2094332d3Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License. 5094332d3Sopenharmony_ci * You may obtain a copy of the License at 6094332d3Sopenharmony_ci * 7094332d3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8094332d3Sopenharmony_ci * 9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and 13094332d3Sopenharmony_ci * limitations under the License. 14094332d3Sopenharmony_ci */ 15094332d3Sopenharmony_ci 16094332d3Sopenharmony_ci#ifndef HDI_SENSOR_IF_SERVICE_H 17094332d3Sopenharmony_ci#define HDI_SENSOR_IF_SERVICE_H 18094332d3Sopenharmony_ci 19094332d3Sopenharmony_ci#include <map> 20094332d3Sopenharmony_ci#include "v2_0/isensor_interface.h" 21094332d3Sopenharmony_ci#include "isensor_interface_vdi.h" 22094332d3Sopenharmony_ci#include "sensor_callback_vdi.h" 23094332d3Sopenharmony_ci#include "sensor_client_info.h" 24094332d3Sopenharmony_ci#include "sensor_clients_manager.h" 25094332d3Sopenharmony_ci 26094332d3Sopenharmony_cinamespace OHOS { 27094332d3Sopenharmony_cinamespace HDI { 28094332d3Sopenharmony_cinamespace Sensor { 29094332d3Sopenharmony_cinamespace V2_0 { 30094332d3Sopenharmony_ci 31094332d3Sopenharmony_ciusing GroupIdCallBackMap = std::unordered_map<int32_t, std::vector<sptr<ISensorCallback>>>; 32094332d3Sopenharmony_ci 33094332d3Sopenharmony_ciclass SensorIfService : public ISensorInterface { 34094332d3Sopenharmony_cipublic: 35094332d3Sopenharmony_ci SensorIfService(); 36094332d3Sopenharmony_ci ~SensorIfService(); 37094332d3Sopenharmony_ci int32_t Init(void); 38094332d3Sopenharmony_ci int32_t GetAllSensorInfo(std::vector<HdfSensorInformation> &info) override; 39094332d3Sopenharmony_ci int32_t Enable(int32_t sensorId) override; 40094332d3Sopenharmony_ci int32_t Disable(int32_t sensorId) override; 41094332d3Sopenharmony_ci int32_t SetBatch(int32_t sensorId, int64_t samplingInterval, int64_t reportInterval) override; 42094332d3Sopenharmony_ci int32_t SetBatchSenior(int32_t serviceId, int32_t sensorId, int32_t mode, int64_t samplingInterval, 43094332d3Sopenharmony_ci int64_t reportInterval); 44094332d3Sopenharmony_ci int32_t SetMode(int32_t sensorId, int32_t mode) override; 45094332d3Sopenharmony_ci int32_t SetOption(int32_t sensorId, uint32_t option) override; 46094332d3Sopenharmony_ci int32_t Register(int32_t groupId, const sptr<ISensorCallback> &callbackObj) override; 47094332d3Sopenharmony_ci int32_t Unregister(int32_t groupId, const sptr<ISensorCallback> &callbackObj) override; 48094332d3Sopenharmony_ci int32_t ReadData(int32_t sensorId, std::vector<HdfSensorEvents> &event) override; 49094332d3Sopenharmony_ci int32_t SetSdcSensor(int32_t sensorId, bool enabled, int32_t rateLevel) override; 50094332d3Sopenharmony_ci int32_t GetSdcSensorInfo(std::vector<SdcSensorInfo>& sdcSensorInfo) override; 51094332d3Sopenharmony_ci int32_t GetSensorVdiImpl(); 52094332d3Sopenharmony_ci void OnRemoteDied(const wptr<IRemoteObject> &object); 53094332d3Sopenharmony_ci std::mutex sensorServiceMutex_; 54094332d3Sopenharmony_ciprivate: 55094332d3Sopenharmony_ci int32_t AddSensorDeathRecipient(const sptr<ISensorCallback> &callbackObj); 56094332d3Sopenharmony_ci int32_t RemoveSensorDeathRecipient(const sptr<ISensorCallback> &callbackObj); 57094332d3Sopenharmony_ci void RemoveDeathNotice(int32_t sensorType); 58094332d3Sopenharmony_ci int32_t AddCallbackMap(int32_t groupId, const sptr<ISensorCallback> &callbackObj); 59094332d3Sopenharmony_ci int32_t RemoveCallbackMap(int32_t groupId, int serviceId, const sptr<ISensorCallback> &callbackObj); 60094332d3Sopenharmony_ci sptr<SensorCallbackVdi> GetSensorCb(int32_t groupId, const sptr<ISensorCallback> &callbackObj, bool cbFlag); 61094332d3Sopenharmony_ci void RegisteDumpHost(); 62094332d3Sopenharmony_ci OHOS::HDI::Sensor::V1_1::ISensorInterfaceVdi *sensorVdiImpl_ = nullptr; 63094332d3Sopenharmony_ci struct HdfVdiObject *vdi_ = nullptr; 64094332d3Sopenharmony_ci GroupIdCallBackMap callbackMap = {}; 65094332d3Sopenharmony_ci sptr<SensorCallbackVdi> traditionalCb = nullptr; 66094332d3Sopenharmony_ci sptr<SensorCallbackVdi> medicalCb = nullptr; 67094332d3Sopenharmony_ci std::vector<HdfSensorInformation> hdfSensorInformations; 68094332d3Sopenharmony_ci int32_t SetDelay(int32_t sensorId, int64_t &samplingInterval, int64_t &reportInterval); 69094332d3Sopenharmony_ci}; 70094332d3Sopenharmony_ci} // V2_0 71094332d3Sopenharmony_ci} // Sensor 72094332d3Sopenharmony_ci} // HDI 73094332d3Sopenharmony_ci} // OHOS 74094332d3Sopenharmony_ci 75094332d3Sopenharmony_ci#endif // HDI_SENSOR_IF_SERVICE_H 76