1 /*
2  * Copyright (c) 2021-2024 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 VIBRATOR_HDI_CONNECTION_H
17 #define VIBRATOR_HDI_CONNECTION_H
18 
19 #include "singleton.h"
20 
21 #include "i_vibrator_hdi_connection.h"
22 
23 namespace OHOS {
24 namespace Sensors {
25 class VibratorHdiConnection : public IVibratorHdiConnection, public Singleton<VibratorHdiConnection> {
26 public:
27     VibratorHdiConnection() = default;
~VibratorHdiConnection()28     virtual ~VibratorHdiConnection() {}
29     int32_t ConnectHdi() override;
30     int32_t StartOnce(uint32_t duration) override;
31     int32_t Start(const std::string &effectType) override;
32 #ifdef OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM
33     int32_t EnableCompositeEffect(const HdfCompositeEffect &hdfCompositeEffect) override;
34     bool IsVibratorRunning() override;
35 #endif // OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM
36     std::optional<HdfEffectInfo> GetEffectInfo(const std::string &effect) override;
37     int32_t Stop(HdfVibratorModeV1_2 mode) override;
38     int32_t DestroyHdiConnection() override;
39     int32_t GetDelayTime(int32_t mode, int32_t &delayTime) override;
40     int32_t GetVibratorCapacity(VibratorCapacity &capacity) override;
41     int32_t PlayPattern(const VibratePattern &pattern) override;
42     int32_t StartByIntensity(const std::string &effect, int32_t intensity) override;
43     int32_t GetAllWaveInfo(std::vector<HdfWaveInformation> &waveInfos) override;
44 
45 private:
46     DISALLOW_COPY_AND_MOVE(VibratorHdiConnection);
47     std::unique_ptr<IVibratorHdiConnection> iVibratorHdiConnection_ = nullptr;
48 };
49 }  // namespace Sensors
50 }  // namespace OHOS
51 #endif  // VIBRATOR_HDI_CONNECTION_H