• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 VIBRATION_PRIORITY_MANAGER_H
17 #define VIBRATION_PRIORITY_MANAGER_H
18 
19 #include <cstdint>
20 #include <cstring>
21 #include <memory>
22 #include <vector>
23 
24 #include "singleton.h"
25 
26 #include "json_parser.h"
27 #include "vibrator_infos.h"
28 #include "vibrator_thread.h"
29 
30 namespace OHOS {
31 namespace Sensors {
32 enum VibrateStatus {
33     VIBRATION = 0,
34     IGNORE_BACKGROUND = 1,
35     IGNORE_LOW_POWER = 2,
36     IGNORE_GLOBAL_SETTINGS = 3,
37     IGNORE_RINGTONE = 4,
38     IGNORE_REPEAT = 5,
39     IGNORE_ALARM = 6,
40     IGNORE_UNKNOWN = 7,
41 };
42 
43 class VibrationPriorityManager {
44     DECLARE_DELAYED_SINGLETON(VibrationPriorityManager);
45 public:
46     DISALLOW_COPY_AND_MOVE(VibrationPriorityManager);
47     VibrateStatus ShouldIgnoreVibrate(const VibrateInfo &vibrateInfo, std::shared_ptr<VibratorThread> vibratorThread);
48 
49 private:
50     bool IsCurrentVibrate(std::shared_ptr<VibratorThread> vibratorThread) const;
51     bool IsLoopVibrate(const VibrateInfo &vibrateInfo) const;
52     VibrateStatus ShouldIgnoreVibrate(const VibrateInfo &vibrateInfo, VibrateInfo currentVibrateInfo) const;
53 };
54 #define PriorityManager DelayedSingleton<VibrationPriorityManager>::GetInstance()
55 }  // namespace Sensors
56 }  // namespace OHOS
57 #endif  // VIBRATION_PRIORITY_MANAGER_H