1 /*
2  * Copyright (c) 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 RESSCHED_SCENE_RECOGNIZE_SCNEE_RECOGNIZER_MGR_H
17 #define RESSCHED_SCENE_RECOGNIZE_SCNEE_RECOGNIZER_MGR_H
18 
19 #include <string>
20 #include <unordered_map>
21 
22 #include "nlohmann/json.hpp"
23 #include "scene_recognizer_base.h"
24 #include "ffrt.h"
25 #include "ffrt_inner.h"
26 #include "single_instance.h"
27 
28 namespace OHOS {
29 namespace ResourceSchedule {
30 namespace RecognizeType {
31 enum : uint32_t {
32     CONTINUOUS_APP_INSTALL_RECOGNIZER,
33     SYSTEM_UPGRADE_SCENE_RECOGNIZER,
34     BACKGROUND_SENSITIVE_TASK_OVERLAPPING_SCENE_RECOGNIZER,
35     SLIDE_RECOGNIZER,
36 };
37 }
38 class SceneRecognizerMgr {
39     DECLARE_SINGLE_INSTANCE_BASE(SceneRecognizerMgr);
40 public:
41     SceneRecognizerMgr();
42     ~SceneRecognizerMgr();
43     void DispatchResource(uint32_t, int64_t value, const nlohmann::json& payload);
44     void SetListFlingTimeoutTime(int64_t value);
45     void SetListFlingEndTime(int64_t value);
46     void SetListFlingSpeedLimit(float value);
47     void SetSlideNormalDetectingTime(int64_t value);
48 private:
49     std::unordered_map<uint32_t, std::shared_ptr<SceneRecognizerBase>> sceneRecognizers_;
50     std::shared_ptr<ffrt::queue> ffrtQueue_;
51 };
52 } // namespace ResourceSchedule
53 } // namespace OHOS
54 #endif // RESSCHED_SCENE_RECOGNIZE_SCNEE_RECOGNIZER_MGR_H