1 /*
2 * Copyright (c) 2022-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 #include "concurrent_task_service.h"
17 #include "concurrent_task_log.h"
18 #include "concurrent_task_controller_interface.h"
19
20 namespace OHOS {
21 namespace ConcurrentTask {
22
ReportData(uint32_t resType,int64_t value,const std::unordered_map<std::string,std::string> & payload)23 ErrCode ConcurrentTaskService::ReportData(
24 uint32_t resType, int64_t value, const std::unordered_map<std::string, std::string>& payload)
25 {
26 TaskControllerInterface::GetInstance().ReportData(resType, value, payload);
27 return ERR_OK;
28 }
29
ReportSceneInfo(uint32_t type,const std::unordered_map<std::string,std::string> & payload)30 ErrCode ConcurrentTaskService::ReportSceneInfo(
31 uint32_t type, const std::unordered_map<std::string, std::string>& payload)
32 {
33 TaskControllerInterface::GetInstance().ReportSceneInfo(type, payload);
34 return ERR_OK;
35 }
36
QueryInterval(int queryItem,IpcIntervalReply & IpcQueryRs)37 ErrCode ConcurrentTaskService::QueryInterval(int queryItem, IpcIntervalReply& IpcQueryRs)
38 {
39 IntervalReply queryRs = IpcToQueryRs(IpcQueryRs);
40 TaskControllerInterface::GetInstance().QueryInterval(queryItem, queryRs);
41 IpcQueryRs = QueryRsToIpc(queryRs);
42 return ERR_OK;
43 }
44
SetAudioDeadline(int queryItem,int tid,int grpId,IpcIntervalReply & IpcQueryRs)45 ErrCode ConcurrentTaskService::SetAudioDeadline(int queryItem, int tid, int grpId, IpcIntervalReply& IpcQueryRs)
46 {
47 IntervalReply queryRs = IpcToQueryRs(IpcQueryRs);
48 TaskControllerInterface::GetInstance().SetAudioDeadline(queryItem, tid, grpId, queryRs);
49 IpcQueryRs = QueryRsToIpc(queryRs);
50 return ERR_OK;
51 }
52
QueryDeadline(int queryItem,const IpcDeadlineReply & IpcDdlReply,const std::unordered_map<std::string,std::string> & payload)53 ErrCode ConcurrentTaskService::QueryDeadline(
54 int queryItem, const IpcDeadlineReply& IpcDdlReply, const std::unordered_map<std::string, std::string>& payload)
55 {
56 DeadlineReply queryRs = IpcToDdlReply(IpcDdlReply);
57 TaskControllerInterface::GetInstance().QueryDeadline(queryItem, queryRs, payload);
58 return ERR_OK;
59 }
60
RequestAuth(const std::unordered_map<std::string,std::string> & payload)61 ErrCode ConcurrentTaskService::RequestAuth(const std::unordered_map<std::string, std::string>& payload)
62 {
63 TaskControllerInterface::GetInstance().RequestAuth(payload);
64 return ERR_OK;
65 }
66
IpcToQueryRs(const IpcIntervalReply & IpcQueryRs)67 IntervalReply ConcurrentTaskService::IpcToQueryRs(const IpcIntervalReply& IpcQueryRs)
68 {
69 IntervalReply queryRs;
70 queryRs.rtgId = IpcQueryRs.rtgId;
71 queryRs.tid = IpcQueryRs.tid;
72 queryRs.paramA = IpcQueryRs.paramA;
73 queryRs.paramB = IpcQueryRs.paramB;
74 queryRs.bundleName = IpcQueryRs.bundleName;
75 return queryRs;
76 }
77
QueryRsToIpc(const IntervalReply & queryRs)78 IpcIntervalReply ConcurrentTaskService::QueryRsToIpc(const IntervalReply& queryRs)
79 {
80 IpcIntervalReply IpcQueryRs;
81 IpcQueryRs.rtgId = queryRs.rtgId;
82 IpcQueryRs.tid = queryRs.tid;
83 IpcQueryRs.paramA = queryRs.paramA;
84 IpcQueryRs.paramB = queryRs.paramB;
85 IpcQueryRs.bundleName = queryRs.bundleName;
86 return IpcQueryRs;
87 }
88
IpcToDdlReply(const IpcDeadlineReply & IpcDdlReply)89 DeadlineReply ConcurrentTaskService::IpcToDdlReply(const IpcDeadlineReply& IpcDdlReply)
90 {
91 DeadlineReply ddlReply;
92 ddlReply.setStatus = IpcDdlReply.setStatus;
93 return ddlReply;
94 }
95 } // namespace ConcurrentTask
96 } // namespace OHOS
97