1 /*
2  * Copyright (c) 2022-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_INTERFACES_INNERKITS_RESSCHED_CLIENT_INCLUDE_IRES_SCHED_SERVICE_H
17 #define RESSCHED_INTERFACES_INNERKITS_RESSCHED_CLIENT_INCLUDE_IRES_SCHED_SERVICE_H
18 
19 #include "iremote_broker.h"
20 #include "nlohmann/json.hpp"
21 #include "res_type.h"
22 
23 namespace OHOS {
24 namespace ResourceSchedule {
25 class IResSchedService : public IRemoteBroker {
26 public:
27     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ResourceSchedule.ResSchedService");
28 
29     /**
30      * @brief Report resource data to the resource schedule service through inter-process communication.
31      *
32      * @param resType Indicates the resource type, all of the type have listed in res_type.h.
33      * @param value Indicates the value of the resource type, defined by the developers.
34      * @param payload Indicates the context info of the resource type event.
35      */
36     virtual void ReportData(uint32_t resType, int64_t value, const nlohmann::json& payload) = 0;
37 
38     /**
39      * @brief Report the synchronization event to the resource schedule service.
40      *
41      * @param resType Indicates the resource type, all of the type have listed in res_type.h.
42      * @param value Indicates the value of the resource type, defined by the developers.
43      * @param payload Indicates the context info of the resource type event.
44      * @param reply Indicates the return value of service processing.
45      */
46     virtual int32_t ReportSyncEvent(const uint32_t resType, const int64_t value, const nlohmann::json& payload,
47         nlohmann::json& reply) = 0;
48 
49     /**
50      * @brief Kill process with pid.
51      *
52      * @param payload Indicates the context info of the kill message.
53      */
54     virtual int32_t KillProcess(const nlohmann::json& payload) = 0;
55 
56     /**
57      * @brief Register systemload remote listener.
58      *
59      * @param notifier remote listener object
60      */
61     virtual void RegisterSystemloadNotifier(const sptr<IRemoteObject>& notifier) = 0;
62 
63     /**
64      * @brief Register event listener.
65      *
66      * @param listener remote listener object
67      * @param eventType the event type
68      * @param listenerGroup the listener group
69      */
70     virtual void RegisterEventListener(const sptr<IRemoteObject>& listener, uint32_t eventType,
71         uint32_t listenerGroup = ResType::EventListenerGroup::LISTENER_GROUP_COMMON) = 0;
72 
73     /**
74      * @brief UnRegister event listener.
75      *
76      * @param eventType the event type
77      * @param listenerGroup the listener group
78      */
79     virtual void UnRegisterEventListener(uint32_t eventType,
80         uint32_t listenerGroup = ResType::EventListenerGroup::LISTENER_GROUP_COMMON) = 0;
81 
82     /**
83      * @brief UnRegister systemload remote listener.
84      */
85     virtual void UnRegisterSystemloadNotifier() = 0;
86 
87     /**
88      * @brief client get systemload level.
89      */
90     virtual int32_t GetSystemloadLevel() = 0;
91 
92     /**
93      * @brief is allowed appliacation preload through resource scheduling services.
94      *
95      * @param bundleName bundleName of the application.
96      */
97     virtual bool IsAllowedAppPreload(const std::string& bundleName, int32_t preloadMode) = 0;
98 };
99 } // namespace ResourceSchedule
100 } // namespace OHOS
101 
102 #endif // RESSCHED_INTERFACES_INNERKITS_RESSCHED_CLIENT_INCLUDE_IRES_SCHED_SERVICE_H
103