• 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 "res_sched_service_proxy.h"
17 #include "ipc_types.h"                  // for NO_ERROR
18 #include "ipc_util.h"                   // for WRITE_PARCEL
19 #include "iremote_object.h"             // for IRemoteObject
20 #include "message_option.h"             // for MessageOption, MessageOption::TF_ASYNC
21 #include "message_parcel.h"             // for MessageParcel
22 #include "res_sched_log.h"              // for RESSCHED_LOGD, RESSCHED_LOGE
23 
24 namespace OHOS {
25 namespace ResourceSchedule {
ReportData(uint32_t resType,int64_t value,const nlohmann::json & payload)26 void ResSchedServiceProxy::ReportData(uint32_t resType, int64_t value, const nlohmann::json& payload)
27 {
28     int32_t error;
29     MessageParcel data;
30     MessageParcel reply;
31     MessageOption option = { MessageOption::TF_ASYNC };
32     WRITE_PARCEL(data, InterfaceToken, ResSchedServiceProxy::GetDescriptor(), , ResSchedServiceProxy);
33     WRITE_PARCEL(data, Uint32, resType, , ResSchedServiceProxy);
34     WRITE_PARCEL(data, Int64, value, , ResSchedServiceProxy);
35     WRITE_PARCEL(data, String, payload.dump(), , ResSchedServiceProxy);
36     error = Remote()->SendRequest(IResSchedService::REPORT_DATA, data, reply, option);
37     if (error != NO_ERROR) {
38         RESSCHED_LOGE("Send request error: %{public}d", error);
39         return;
40     }
41     RESSCHED_LOGD("%{public}s, success.", __func__);
42 }
43 } // namespace ResourceSchedule
44 } // namespace OHOS
45