• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 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 #include "res_data.h"
28 
29 namespace OHOS {
30 namespace ResourceSchedule {
31 namespace RecognizeType {
32 enum : uint32_t {
33     CONTINUOUS_APP_INSTALL_RECOGNIZER,
34     SYSTEM_UPGRADE_SCENE_RECOGNIZER,
35     BACKGROUND_SENSITIVE_TASK_OVERLAPPING_SCENE_RECOGNIZER,
36     SLIDE_RECOGNIZER,
37 };
38 }
39 class SceneRecognizerMgr {
40     DECLARE_SINGLE_INSTANCE_BASE(SceneRecognizerMgr);
41 public:
42     SceneRecognizerMgr();
43     ~SceneRecognizerMgr();
44     void DispatchResource(const std::shared_ptr<ResData>& resData);
45     void SetListFlingTimeoutTime(int64_t value);
46     void SetListFlingEndTime(int64_t value);
47     void SetListFlingSpeedLimit(float value);
48     void SubmitTask(const std::function<void()>& task);
49 private:
50     std::unordered_map<uint32_t, std::shared_ptr<SceneRecognizerBase>> sceneRecognizers_;
51     std::shared_ptr<ffrt::queue> ffrtQueue_;
52 };
53 } // namespace ResourceSchedule
54 } // namespace OHOS
55 #endif // RESSCHED_SCENE_RECOGNIZE_SCNEE_RECOGNIZER_MGR_H