• 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 #include "concurrent_task_service_proxy.h"
17 #include "concurrent_task_log.h"
18 #include "concurrent_task_errors.h"
19 
20 namespace OHOS {
21 namespace ConcurrentTask {
ReportData(uint32_t resType,int64_t value,const Json::Value & payload)22 void ConcurrentTaskServiceProxy::ReportData(uint32_t resType, int64_t value, const Json::Value& payload)
23 {
24     int32_t error;
25     MessageParcel data;
26     MessageParcel reply;
27     MessageOption option = { MessageOption::TF_ASYNC };
28     if (!data.WriteInterfaceToken(ConcurrentTaskServiceProxy::GetDescriptor())) {
29         return;
30     }
31     if (!data.WriteUint32(resType)) {
32         return;
33     }
34     if (!data.WriteInt64(value)) {
35         return;
36     }
37     if (!data.WriteString(payload.toStyledString())) {
38         return;
39     }
40     uint32_t code = static_cast<uint32_t>(ConcurrentTaskInterfaceCode::REPORT_DATA);
41     error = Remote()->SendRequest(code, data, reply, option);
42     if (error != NO_ERROR) {
43         CONCUR_LOGE("Send request error: %{public}d", error);
44         return;
45     }
46     CONCUR_LOGD("ConcurrentTaskServiceProxy::ReportData success.");
47 }
48 
QueryInterval(int queryItem,IntervalReply & queryRs)49 void ConcurrentTaskServiceProxy::QueryInterval(int queryItem, IntervalReply& queryRs)
50 {
51     int32_t error;
52     MessageParcel data;
53     MessageParcel reply;
54     MessageOption option = { MessageOption::TF_SYNC };
55     queryRs.rtgId = -1;
56     queryRs.paramA = -1;
57     queryRs.paramB = -1;
58     queryRs.paramC = -1;
59     if (!data.WriteInterfaceToken(ConcurrentTaskServiceProxy::GetDescriptor())) {
60         return;
61     }
62     if (!data.WriteInt64(queryItem)) {
63         return;
64     }
65 
66     uint32_t code = static_cast<uint32_t>(ConcurrentTaskInterfaceCode::QUERY_INTERVAL);
67     error = Remote()->SendRequest(code, data, reply, option);
68     if (error != NO_ERROR) {
69         CONCUR_LOGE("QueryInterval error: %{public}d", error);
70         return;
71     }
72     if (!reply.ReadInt32(queryRs.rtgId)) {
73         return;
74     }
75     if (!reply.ReadInt32(queryRs.paramA)) {
76         return;
77     }
78     if (!reply.ReadInt32(queryRs.paramB)) {
79         return;
80     }
81     if (!reply.ReadInt32(queryRs.paramC)) {
82         return;
83     }
84     return;
85 }
86 } // namespace ConcurrentTask
87 } // namespace OHOS