• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 OHOS_ABILITY_RUNTIME_APP_SCHEDULER_PROXY_H
17 #define OHOS_ABILITY_RUNTIME_APP_SCHEDULER_PROXY_H
18 
19 #include "iremote_proxy.h"
20 #include "app_scheduler_interface.h"
21 #include "app_malloc_info.h"
22 
23 namespace OHOS {
24 namespace AppExecFwk {
25 class AppSchedulerProxy : public IRemoteProxy<IAppScheduler> {
26 public:
27     explicit AppSchedulerProxy(const sptr<IRemoteObject> &impl);
28     virtual ~AppSchedulerProxy() = default;
29 
30     /**
31      * ScheduleForegroundApplication, call ScheduleForegroundApplication() through proxy project,
32      * Notify application to switch to foreground.
33      *
34      * @return
35      */
36     virtual void ScheduleForegroundApplication() override;
37 
38     /**
39      * ScheduleBackgroundApplication, call ScheduleBackgroundApplication() through proxy project,
40      * Notify application to switch to background.
41      *
42      * @return
43      */
44     virtual void ScheduleBackgroundApplication() override;
45 
46     /**
47      * ScheduleTerminateApplication, call ScheduleTerminateApplication() through proxy project,
48      * Notify application to terminate.
49      *
50      * @return
51      */
52     virtual void ScheduleTerminateApplication() override;
53 
54     /**
55      * ScheduleShrinkMemory, call ScheduleShrinkMemory() through proxy project,
56      * Notifies the application of the memory seen.
57      *
58      * @param The memory value.
59      *
60      * @return
61      */
62     virtual void ScheduleShrinkMemory(const int32_t level) override;
63 
64     /**
65      * ScheduleLowMemory, call ScheduleLowMemory() through proxy project,
66      * Notify application to low memory.
67      *
68      * @return
69      */
70     virtual void ScheduleLowMemory() override;
71 
72     /**
73      * ScheduleMemoryLevel, call ScheduleMemoryLevel() through proxy project,
74      * Notify applications background the current memory level.
75      *
76      * @return
77      */
78     virtual void ScheduleMemoryLevel(int32_t level) override;
79 
80     /**
81      * ScheduleHeapMemory, call ScheduleHeapMemory() through proxy project,
82      * Get the application's memory allocation info.
83      *
84      * @param pid, pid input.
85      * @param mallocInfo, dynamic storage information output.
86      *
87      * @return
88      */
89     virtual void ScheduleHeapMemory(const int32_t pid, OHOS::AppExecFwk::MallocInfo &mallocInfo) override;
90 
91     /**
92      * ScheduleLaunchApplication, call ScheduleLaunchApplication() through proxy project,
93      * Notify application to launch application.
94      *
95      * @param The app data value.
96      *
97      * @return
98      */
99     virtual void ScheduleLaunchApplication(const AppLaunchData &launchData, const Configuration &config) override;
100 
101     /**
102      * ScheduleUpdateApplicationInfoInstalled, call ScheduleUpdateApplicationInfoInstalled() through proxy object,
103      * update the application info after new module installed.
104      *
105      * @param appInfo The latest application info obtained from bms for update abilityRuntimeContext.
106      *
107      * @return
108      */
109     virtual void ScheduleUpdateApplicationInfoInstalled(const ApplicationInfo &) override;
110 
111     /**
112      * Notify application to launch ability stage.
113      *
114      * @param The resident process data value.
115      */
116     virtual void ScheduleAbilityStage(const HapModuleInfo &abilityStage) override;
117 
118     /**
119      * ScheduleLaunchAbility, call ScheduleLaunchAbility() through proxy project,
120      * Notify application to launch ability.
121      *
122      * @param The ability info.
123      * @param The ability token.
124      * @param The ability want.
125      * @return
126      */
127     virtual void ScheduleLaunchAbility(const AbilityInfo &, const sptr<IRemoteObject> &,
128         const std::shared_ptr<AAFwk::Want> &want) override;
129 
130     /**
131      * ScheduleCleanAbility, call ScheduleCleanAbility() through proxy project,
132      * Notify application to clean ability.
133      *
134      * @param The ability token.
135      * @return
136      */
137     virtual void ScheduleCleanAbility(const sptr<IRemoteObject> &token) override;
138 
139     /**
140      * ScheduleProfileChanged, call ScheduleProfileChanged() through proxy project,
141      * Notify application to profile update.
142      *
143      * @param The profile data.
144      * @return
145      */
146     virtual void ScheduleProfileChanged(const Profile &profile) override;
147 
148     /**
149      * ScheduleConfigurationUpdated, call ScheduleConfigurationUpdated() through proxy project,
150      * Notify application to configuration update.
151      *
152      * @param The configuration data.
153      * @return
154      */
155     virtual void ScheduleConfigurationUpdated(const Configuration &config) override;
156 
157     /**
158      * ScheduleProcessSecurityExit, call ScheduleProcessSecurityExit() through proxy project,
159      * Notify application process exit safely.
160      *
161      * @return
162      */
163     virtual void ScheduleProcessSecurityExit() override;
164 
165     virtual void ScheduleAcceptWant(const AAFwk::Want &want, const std::string &moduleName) override;
166 
167     int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName,
168         const sptr<IQuickFixCallback> &callback, const int32_t recordId) override;
169 
170     int32_t ScheduleNotifyHotReloadPage(const sptr<IQuickFixCallback> &callback, const int32_t recordId) override;
171 
172     int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName,
173         const sptr<IQuickFixCallback> &callback, const int32_t recordId) override;
174 
175     int32_t ScheduleNotifyAppFault(const FaultData &faultData) override;
176 
177 private:
178     bool WriteInterfaceToken(MessageParcel &data);
179     void ScheduleMemoryCommon(const int32_t level, const uint32_t operation);
180     static inline BrokerDelegator<AppSchedulerProxy> delegator_;
181 };
182 }  // namespace AppExecFwk
183 }  // namespace OHOS
184 #endif  // OHOS_ABILITY_RUNTIME_APP_SCHEDULER_PROXY_H
185