• 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 CONCURRENT_TASK_SERVICES_CONCURRENTSEVICE_INCLUDE_CONCURRENT_TASK_CONTROLLER_INTERFACE_H
17 #define CONCURRENT_TASK_SERVICES_CONCURRENTSEVICE_INCLUDE_CONCURRENT_TASK_CONTROLLER_INTERFACE_H
18 
19 #include <mutex>
20 
21 #include "concurrent_task_type.h"
22 #include "concurrent_task_idl_types.h"
23 #include "func_loader.h"
24 #include "qos_policy.h"
25 
26 namespace OHOS {
27 namespace ConcurrentTask {
28 using ReportDataFunc = void (*)(
29     uint32_t resType, int64_t value, const std::unordered_map<std::string, std::string>& payload);
30 using ReportSceneInfoFunc = void (*)(uint32_t type, const std::unordered_map<std::string, std::string>& payload);
31 using QueryIntervalFunc = void (*)(int queryItem, IntervalReply& queryRs);
32 using QueryDeadlineFunc = void (*)(
33     int queryItem, DeadlineReply& ddlReply, const std::unordered_map<std::string, std::string>& payload);
34 using SetAudioDeadlineFunc = void (*)(int queryItem, int tid, int grpId, IntervalReply& queryRs);
35 using RequestAuthFunc = void (*)(const std::unordered_map<std::string, std::string>& payload);
36 using InitFunc = void (*)();
37 using ReleaseFunc = void (*)();
38 using CreateNewRtgGrpFunc = int (*)(int prioType, int rtNum);
39 
40 class TaskControllerInterface {
41 public:
42     static TaskControllerInterface& GetInstance();
43     TaskControllerInterface();
44     virtual ~TaskControllerInterface() = default;
45     void RequestAuth(const std::unordered_map<std::string, std::string>& payload);
46     void ReportData(uint32_t resType, int64_t value, const std::unordered_map<std::string, std::string>& payload);
47     void ReportSceneInfo(uint32_t type, const std::unordered_map<std::string, std::string>& payload);
48     void QueryInterval(int queryItem, IntervalReply& queryRs);
49     void QueryDeadline(
50         int queryItem, DeadlineReply& ddlReply, const std::unordered_map<std::string, std::string>& payload);
51     void SetAudioDeadline(int queryItem, int tid, int grpId, IntervalReply& queryRs);
52     void Init();
53     void Release();
54 
55 private:
56     bool LoadFunc();
57     FuncLoader funcLoader_;
58     std::mutex funcLoaderLock_;
59     bool inited_ = false;
60     QosPolicy qosPolicy_;
61 
62     ReportDataFunc reportDataFunc_ = nullptr;
63     ReportSceneInfoFunc reportSceneInfoFunc_ = nullptr;
64     QueryIntervalFunc queryIntervalFunc_ = nullptr;
65     QueryDeadlineFunc queryDeadlineFunc_ = nullptr;
66     SetAudioDeadlineFunc setAudioDeadlineFunc_ = nullptr;
67     RequestAuthFunc requestAuthFunc_ = nullptr;
68     InitFunc initFunc_ = nullptr;
69     ReleaseFunc releaseFunc_ = nullptr;
70 };
71 } // namespace ConcurrentTask
72 } // namespace OHOS
73 
74 #endif