1 /* 2 * Copyright (c) 2021 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 16 #ifndef HDI_CONNECTION_H 17 #define HDI_CONNECTION_H 18 19 #include "death_recipient_template.h" 20 #include "i_sensor_hdi_connection.h" 21 #include "sensor_basic_info.h" 22 23 namespace OHOS { 24 namespace Sensors { 25 class HdiConnection : public ISensorHdiConnection { 26 public: 27 HdiConnection() = default; ~HdiConnection()28 virtual ~HdiConnection() {} 29 int32_t ConnectHdi() override; 30 int32_t GetSensorList(std::vector<Sensor> &sensorList) override; 31 int32_t EnableSensor(int32_t sensorId) override; 32 int32_t DisableSensor(int32_t sensorId) override; 33 int32_t SetBatch(int32_t sensorId, int64_t samplingInterval, int64_t reportInterval) override; 34 int32_t SetMode(int32_t sensorId, int32_t mode) override; 35 int32_t RegisterDataReport(ReportDataCb cb, sptr<ReportDataCallback> reportDataCallback) override; 36 int32_t DestroyHdiConnection() override; 37 ReportDataCb GetReportDataCb(); 38 sptr<ReportDataCallback> GetReportDataCallback(); 39 void ProcessDeathObserver(const wptr<IRemoteObject> &object); 40 41 private: 42 DISALLOW_COPY_AND_MOVE(HdiConnection); 43 static ReportDataCb reportDataCb_; 44 static sptr<ReportDataCallback> reportDataCallback_; 45 sptr<IRemoteObject::DeathRecipient> hdiDeathObserver_ = nullptr; 46 void RegisterHdiDeathRecipient(); 47 void UnregisterHdiDeathRecipient(); 48 void Reconnect(); 49 void UpdateSensorBasicInfo(int32_t sensorId, int64_t samplingPeriodNs, int64_t maxReportDelayNs); 50 void SetSensorBasicInfoState(int32_t sensorId, bool state); 51 void DeleteSensorBasicInfoState(int32_t sensorId); 52 }; 53 } // namespace Sensors 54 } // namespace OHOS 55 #endif // HDI_CONNECTION_H