1 /*
2  * Copyright (c) 2024 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_EXECUTOR_INTERFACES_INNERKITS_RESSCHED_EXECUTOR_CLIENT_INCLUDE_IRES_SCHED_EXE_SERVICE_H
17 #define RESSCHED_EXECUTOR_INTERFACES_INNERKITS_RESSCHED_EXECUTOR_CLIENT_INCLUDE_IRES_SCHED_EXE_SERVICE_H
18 
19 #include "iremote_broker.h"
20 #include "nlohmann/json.hpp"
21 
22 namespace OHOS {
23 namespace ResourceSchedule {
24 class IResSchedExeService : public IRemoteBroker {
25 public:
26     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ResourceSchedule.ResSchedExeService");
27 
28     /**
29      * @brief Send request sync to the ressched_executor through inter-process communication.
30      *
31      * @param resType Indicates the resource type, all of the type have listed in res_exe_type.h.
32      * @param value Indicates the value of the resource type, defined by the developers.
33      * @param payload Indicates the context info of the resource type event.
34      * @param reply Indicates the context info of the ipc reply.
35      * @return function result
36      */
37     virtual int32_t SendRequestSync(uint32_t resType, int64_t value,
38         const nlohmann::json& payload, nlohmann::json& reply) = 0;
39 
40     /**
41      * @brief Send request async to the ressched_executor through inter-process communication.
42      *
43      * @param resType Indicates the resource type, all of the type have listed in res_exe_type.h.
44      * @param value Indicates the value of the resource type, defined by the developers.
45      * @param payload Indicates the context info of the resource type event.
46      */
47     virtual void SendRequestAsync(uint32_t resType, int64_t value, const nlohmann::json& payload) = 0;
48 
49     /**
50      * @brief Send kill process request async to the ressched_executor.
51      *
52      * @param pid the pid whiche will be killed.
53      */
54     virtual int32_t KillProcess(pid_t pid) = 0;
55 };
56 } // namespace ResourceSchedule
57 } // namespace OHOS
58 
59 #endif // RESSCHED_EXECUTOR_INTERFACES_INNERKITS_RESSCHED_EXECUTOR_CLIENT_INCLUDE_IRES_SCHED_EXE_SERVICE_H
60