• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 OHOS_HDI_VIBRATOR_V2_0_VIBRAORINTERFACESERVICE_H
17 #define OHOS_HDI_VIBRATOR_V2_0_VIBRAORINTERFACESERVICE_H
18 
19 #include "v2_0/ivibrator_interface.h"
20 #include "v1_1/ivibrator_interface_vdi.h"
21 
22 namespace OHOS {
23 namespace HDI {
24 namespace Vibrator {
25 namespace V2_0 {
26 using namespace OHOS::HDI::Vibrator;
27 using namespace OHOS::HDI::Vibrator::V1_1;
28 
29 class VibratorIfService : public V2_0::IVibratorInterface  {
30 public:
31     //version 2.0
32     VibratorIfService();
33     ~VibratorIfService();
34     int32_t Init(void);
35     int32_t StartOnce(const OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo& deviceVibratorInfo,
36                       uint32_t duration) override;
37     int32_t Start(const OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo& deviceVibratorInfo,
38                   const std::string &effectType) override;
39     int32_t Stop(const OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo& deviceVibratorInfo,
40                  V2_0::HdfVibratorMode mode) override;
41     int32_t GetVibratorInfo(std::vector<V2_0::HdfVibratorInfo> &vibratorInfo) override;
42     int32_t GetDeviceVibratorInfo(const OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo& deviceVibratorInfo,
43                                   std::vector<HdfVibratorInfo> &vibratorInfo) override;
44     int32_t GetVibratorIdSingle(const OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo& deviceVibratorInfo,
45                                 std::vector<HdfVibratorInfo> &vibratorInfo) override;
46     int32_t EnableVibratorModulation(const OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo& deviceVibratorInfo,
47                                      uint32_t duration, uint16_t intensity, int16_t frequency) override;
48     int32_t EnableCompositeEffect(const OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo& deviceVibratorInfo,
49                                   const HdfCompositeEffect& effect) override;
50     int32_t GetEffectInfo(const OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo& deviceVibratorInfo,
51                           const std::string &effectType, V2_0::HdfEffectInfo &effectInfo) override;
52     int32_t IsVibratorRunning(const OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo& deviceVibratorInfo,
53                               bool& state) override;
54     int32_t PlayHapticPattern(const OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo& deviceVibratorInfo,
55                               const HapticPaket& pkg) override;
56     int32_t GetHapticCapacity(const OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo& deviceVibratorInfo,
57                               V2_0::HapticCapacity& hapticCapacity) override;
58     int32_t GetHapticStartUpTime(const OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo& deviceVibratorInfo,
59                                  int32_t mode, int32_t& startUpTime) override;
60     int32_t StartByIntensity(const OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo& deviceVibratorInfo,
61                              const std::string& effectType, uint16_t intensity) override;
62     int32_t GetAllWaveInfo(const OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo& deviceVibratorInfo,
63                            std::vector<HdfWaveInformation> &info) override;
64     int32_t RegVibratorPlugCallback(const sptr<IVibratorPlugCallback> &callbackObj) override;
65     int32_t UnRegVibratorPlugCallback(const sptr<IVibratorPlugCallback> &callbackObj) override;
66     int32_t PlayPatternBySessionId(
67         const OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo& deviceVibratorInfo,
68         uint32_t sessionId,
69         const OHOS::HDI::Vibrator::V2_0::HapticPaket &hapticPaket) override;
70     int32_t PlayPackageBySession(
71         const OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo& deviceVibratorInfo,
72         uint32_t sessionId,
73         const OHOS::HDI::Vibrator::V2_0::VibratorPackage& vibratorPackage) override;
74     int32_t StopVibrateBySessionId(
75         const OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo &deviceVibratorInfo,
76         uint32_t sessionId) override;
77     int32_t GetVibratorVdiImpl();
78 
79 private:
80     OHOS::HDI::Vibrator::V1_1::IVibratorInterfaceVdi *vibratorVdiImplV1_1_ = nullptr;
81     struct HdfVdiObject *vdi_ = nullptr;
82 };
83 } // V2_0
84 } // Vibrator
85 } // HDI
86 } // OHOS
87 
88 #endif // OHOS_HDI_VIBRATOR_V2_0_VIBRAORINTERFACESERVICE_H