1 /* 2 * Copyright (c) 2020-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 GRAPHIC_LITE_VIBRATOR_MANAGER_H 17 #define GRAPHIC_LITE_VIBRATOR_MANAGER_H 18 19 #include "graphic_config.h" 20 #if ENABLE_VIBRATOR 21 #include "components/ui_view_group.h" 22 namespace OHOS { 23 /** 24 * @brief Enumerates vibrator types. 25 * 26 * @since 5.0 27 * @version 3.0 28 */ 29 enum class VibratorType { VIBRATOR_TYPE_ONE, VIBRATOR_TYPE_TWO, VIBRATOR_TYPE_THREE }; 30 31 /** 32 * @brief vibrator function. 33 * 34 * @param vibratorType vibrator type. 35 */ 36 typedef void (*VibratorFunc)(VibratorType vibratorType); 37 38 class VibratorManager { 39 public: 40 /** 41 * @brief Get the VibratorManager's singleton. 42 * 43 * @return VibratorManager's singleton. 44 * @since 5.0 45 * @version 3.0 46 */ 47 static VibratorManager* GetInstance(); 48 RegisterVibratorFunc(VibratorFunc vibratorFunc)49 void RegisterVibratorFunc(VibratorFunc vibratorFunc) 50 { 51 GRAPHIC_LOGI("VibratorManager::RegisterVibratorFunc"); 52 vibratorFunc_ = vibratorFunc; 53 } 54 GetVibratorFunc()55 VibratorFunc GetVibratorFunc() 56 { 57 return vibratorFunc_; 58 } 59 60 private: VibratorManager()61 VibratorManager() {} ~VibratorManager()62 ~VibratorManager() {} 63 64 VibratorFunc vibratorFunc_ = nullptr; 65 }; 66 } // namespace OHOS 67 #endif 68 #endif // GRAPHIC_LITE_VIBRATOR_MANAGER_H