• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 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_MGR_PROXY_H
17 #define OHOS_ABILITY_RUNTIME_APP_MGR_PROXY_H
18 
19 #include "app_jsheap_mem_info.h"
20 #include "app_cjheap_mem_info.h"
21 #include "app_malloc_info.h"
22 #include "app_mgr_interface.h"
23 #include "bundle_info.h"
24 #include "iremote_proxy.h"
25 #include "memory_level_info.h"
26 #include "running_process_info.h"
27 #include "want.h"
28 
29 namespace OHOS {
30 namespace AppExecFwk {
31 class AppMgrProxy : public IRemoteProxy<IAppMgr> {
32 public:
33     explicit AppMgrProxy(const sptr<IRemoteObject> &impl);
34     virtual ~AppMgrProxy() = default;
35 
36     /**
37      * AttachApplication, call AttachApplication() through proxy object,
38      * get all the information needed to start the Application (data related to the Application ).
39      *
40      * @param app, information needed to start the Application.
41      * @return
42      */
43     virtual void AttachApplication(const sptr<IRemoteObject> &obj) override;
44 
45     /**
46      * Preload application.
47      *
48      * @param bundleName The bundle name of the application to preload.
49      * @param userId Indicates the user identification.
50      * @param preloadMode Preload application mode.
51      * @param appIndex The index of application clone.
52      * @return Returns ERR_OK on success, others on failure.
53      */
54     virtual int32_t PreloadApplication(const std::string &bundleName, int32_t userId,
55         AppExecFwk::PreloadMode preloadMode, int32_t appIndex = 0) override;
56 
57     /**
58      * Launch Application Finished
59      * @param recordId id of the app record
60      */
61     virtual void PreloadModuleFinished(const int32_t recordId) override;
62 
63     /**
64      * ApplicationForegrounded, call ApplicationForegrounded() through proxy object,
65      * set the application to Foreground State.
66      *
67      * @param recordId, a unique record that identifies this Application from others.
68      * @return
69      */
70     virtual void ApplicationForegrounded(const int32_t recordId) override;
71 
72     /**
73      * ApplicationBackgrounded, call ApplicationBackgrounded() through proxy object,
74      * set the application to Backgrounded State.
75      *
76      * @param recordId, a unique record that identifies this Application from others.
77      * @return
78      */
79     virtual void ApplicationBackgrounded(const int32_t recordId) override;
80 
81     /**
82      * ApplicationTerminated, call ApplicationTerminated() through proxy object,
83      * terminate the application.
84      *
85      * @param recordId, a unique record that identifies this Application from others.
86      * @return
87      */
88     virtual void ApplicationTerminated(const int32_t recordId) override;
89 
90     /**
91      * AbilityCleaned,call through AbilityCleaned() proxy project, clean Ability record.
92      *
93      * @param token, a unique record that identifies AbilityCleaned from others.
94      * @return
95      */
96     virtual void AbilityCleaned(const sptr<IRemoteObject> &token) override;
97 
98     /**
99      * GetAmsMgr, call GetAmsMgr() through proxy object, get AMS interface instance.
100      *
101      * @return sptr<IAmsMgr>, return to AMS interface instance.
102      */
103     virtual sptr<IAmsMgr> GetAmsMgr() override;
104 
105     /**
106      * ClearUpApplicationData, call ClearUpApplicationData() through proxy project,
107      * clear the application data.
108      *
109      * @param bundleName, bundle name in Application record.
110      * @param appCloneIndex the app clone id.
111      * @param userId the user id.
112      * @return ErrCode
113      */
114     virtual int32_t ClearUpApplicationData(const std::string &bundleName, int32_t appCloneIndex,
115         int32_t userId = -1) override;
116 
117     /**
118      * ClearUpApplicationData, call ClearUpApplicationData() through proxy project,
119      * clear the application data.
120      *
121      * @param bundleName, bundle name in Application record.
122      * @return
123      */
124     virtual int32_t ClearUpApplicationDataBySelf(int32_t userId = -1) override;
125 
126     /**
127      * GetAllRunningProcesses, call GetAllRunningProcesses() through proxy project.
128      * Obtains information about application processes that are running on the device.
129      *
130      * @param info, app name in Application record.
131      * @return ERR_OK ,return back success,others fail.
132      */
133     virtual int32_t GetAllRunningProcesses(std::vector<RunningProcessInfo> &info) override;
134 
135     /**
136      * GetALLRunningMultiAppInfo, call GetALLRunningMultiAppInfo() through proxy project.
137      * Obtains information about multiapp that are running on the device.
138      *
139      * @param info, app name in multiappinfo.
140      * @return ERR_OK ,return back success,others fail.
141      */
142     virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName,
143         RunningMultiAppInfo &info) override;
144 
145     /**
146      * GetAllRunningInstanceKeysBySelf, call GetAllRunningInstanceKeysBySelf() through proxy project.
147      * Obtains running instance keys of multi-instance app that are running on the device.
148      *
149      * @param instanceKeys, output instance keys of the multi-instance app.
150      * @return ERR_OK ,return back success,others fail.
151      */
152     virtual int32_t GetAllRunningInstanceKeysBySelf(std::vector<std::string> &instanceKeys) override;
153 
154     /**
155      * GetAllRunningInstanceKeysByBundleName, call GetAllRunningInstanceKeysByBundleName() through proxy project.
156      * Obtains running instance keys of multi-instance app that are running on the device.
157      *
158      * @param bundlename, bundle name in Application record.
159      * @param instanceKeys, output instance keys of the multi-instance app.
160      * @param userId, user id.
161      * @return ERR_OK ,return back success,others fail.
162      */
163     virtual int32_t GetAllRunningInstanceKeysByBundleName(const std::string &bundleName,
164         std::vector<std::string> &instanceKeys, int32_t userId = -1) override;
165 
166     /**
167      * GetRunningProcessesByBundleType, call GetRunningProcessesByBundleType() through proxy project.
168      * Obtains information about application processes by bundle type that are running on the device.
169      *
170      * @param bundleType, bundle type of the processes
171      * @param info, app name in Application record.
172      * @return ERR_OK ,return back success,others fail.
173      */
174     virtual int GetRunningProcessesByBundleType(const BundleType bundleType,
175         std::vector<RunningProcessInfo> &info) override;
176 
177     /**
178      * GetAllRenderProcesses, call GetAllRenderProcesses() through proxy project.
179      * Obtains information about render processes that are running on the device.
180      *
181      * @param info, render process info.
182      * @return ERR_OK, return back success, others fail.
183      */
184     virtual int32_t GetAllRenderProcesses(std::vector<RenderProcessInfo> &info) override;
185 
186     /**
187      * GetAllChildrenProcesses, call GetAllChildrenProcesses() through proxy project.
188      * Obtains information about children processes that are running on the device.
189      *
190      * @param info, child process info.
191      * @return ERR_OK, return back success, others fail.
192      */
193     virtual int GetAllChildrenProcesses(std::vector<ChildProcessInfo> &info) override;
194 
195     /**
196      * JudgeSandboxByPid, call JudgeSandboxByPid() through proxy project.
197      * Obtains information about application processes that are running on the device.
198      *
199      * @param pid, the pid of current app running record.
200      * @param isSandbox, current app is or not a sandbox.
201      * @return ERR_OK ,return back success,others fail.
202      */
203     virtual int32_t JudgeSandboxByPid(pid_t pid, bool &isSandbox) override;
204 
205     /**
206      * IsTerminatingByPid, call IsTerminatingByPid() through proxy project.
207      * Obtains information about application processes that are running on the device.
208      *
209      * @param pid, the pid of current app running record.
210      * @param isTerminating, current app is or not terminating.
211      * @return ERR_OK, return back success, others fail.
212      */
213     virtual int32_t IsTerminatingByPid(pid_t pid, bool &isTerminating) override;
214 
215     /**
216      * GetProcessRunningInfosByUserId, call GetProcessRunningInfosByUserId() through proxy project.
217      * Obtains information about application processes that are running on the device.
218      *
219      * @param info, app name in Application record.
220      * @return ERR_OK ,return back success,others fail.
221      */
222     virtual int32_t GetProcessRunningInfosByUserId(std::vector<RunningProcessInfo> &info, int32_t userId) override;
223 
224     /**
225      * GetProcessRunningInformation, call GetProcessRunningInformation() through proxy project.
226      * Obtains information about current application process which is running on the device.
227      *
228      * @param info, app name in Application record.
229      * @return ERR_OK ,return back success,others fail.
230      */
231     virtual int32_t GetProcessRunningInformation(RunningProcessInfo &info) override;
232 
233     /**
234      * NotifyMemoryLevel, call NotifyMemoryLevel() through proxy project.
235      * Notify abilities background the current memory level.
236      *
237      * @param level, the current memory level
238      * @return ERR_OK ,return back success,others fail.
239      */
240     virtual int32_t NotifyMemoryLevel(int32_t level) override;
241 
242     /**
243      * NotifyProcMemoryLevel, call NotifyMemoryLevel() through proxy project.
244      * Notify abilities the current memory level.
245      *
246      * @param procLevelMap ,<pid, level> map;
247      * @return ERR_OK ,return back success,others fail.
248      */
249     virtual int32_t NotifyProcMemoryLevel(const std::map<pid_t, MemoryLevel> &procLevelMap) override;
250 
251     /**
252      * DumpHeapMemory, call DumpHeapMemory() through proxy project.
253      * Get the application's memory allocation info.
254      *
255      * @param pid, pid input.
256      * @param mallocInfo, dynamic storage information output.
257      * @return ERR_OK ,return back success,others fail.
258      */
259     virtual int32_t DumpHeapMemory(const int32_t pid, OHOS::AppExecFwk::MallocInfo &mallocInfo) override;
260 
261     /**
262      * DumpJsHeapMemory, call DumpJsHeapMemory() through proxy project.
263      * triggerGC and dump the application's jsheap memory info.
264      *
265      * @param info, pid tid needGc needSnapshot
266      * @return ERR_OK ,return back success, others fail.
267      */
268     virtual int32_t DumpJsHeapMemory(OHOS::AppExecFwk::JsHeapDumpInfo &info) override;
269 
270     /**
271      * DumpCjHeapMemory, call DumpCjHeapMemory() through proxy project.
272      * triggerGC and dump the application's cjheap memory info.
273      *
274      * @param info, pid needGc needSnapshot
275      * @return ERR_OK ,return back success, others fail.
276      */
277     virtual int32_t DumpCjHeapMemory(OHOS::AppExecFwk::CjHeapDumpInfo &info) override;
278 
279     /**
280      * Notify that the ability stage has been updated
281      * @param recordId, the app record.
282      */
283     virtual void AddAbilityStageDone(const int32_t recordId) override;
284 
285     /**
286      * Start a resident process
287      */
288     virtual void StartupResidentProcess(const std::vector<AppExecFwk::BundleInfo> &bundleInfos) override;
289 
290     /**
291      * Register application or process state observer.
292      * @param observer, ability token.
293      * @return Returns ERR_OK on success, others on failure.
294      */
295     virtual int32_t RegisterApplicationStateObserver(const sptr<IApplicationStateObserver> &observer,
296         const std::vector<std::string> &bundleNameList = {}) override;
297 
298     /**
299      * Unregister application or process state observer.
300      * @param observer, ability token.
301      * @return Returns ERR_OK on success, others on failure.
302      */
303     virtual int32_t UnregisterApplicationStateObserver(const sptr<IApplicationStateObserver> &observer) override;
304 
305     /**
306      * Register application or process state observer.
307      * @param observer, Is ability foreground state observer
308      * @return Returns ERR_OK on success, others on failure.
309      */
310     int32_t RegisterAbilityForegroundStateObserver(const sptr<IAbilityForegroundStateObserver> &observer) override;
311 
312     /**
313      * Unregister application or process state observer.
314      * @param observer, Is ability foreground state observer
315      * @return Returns ERR_OK on success, others on failure.
316      */
317     int32_t UnregisterAbilityForegroundStateObserver(const sptr<IAbilityForegroundStateObserver> &observer) override;
318 
319     /**
320      * Get foreground applications.
321      * @param list, foreground apps.
322      * @return Returns ERR_OK on success, others on failure.
323      */
324     virtual int32_t GetForegroundApplications(std::vector<AppStateData> &list) override;
325 
326     /**
327      * Start user test process.
328      * @param want, want object.
329      * @param observer, test observer remote object.
330      * @param bundleInfo, bundle info.
331      * @param userId the user id.
332      * @return Returns ERR_OK on success, others on failure.
333      */
334     virtual int StartUserTestProcess(const AAFwk::Want &want, const sptr<IRemoteObject> &observer,
335         const BundleInfo &bundleInfo, int32_t userId) override;
336 
337     /**
338      * @brief Finish user test.
339      * @param msg user test message.
340      * @param resultCode user test result Code.
341      * @param bundleName user test bundleName.
342      *
343      * @return Returns ERR_OK on success, others on failure.
344      */
345     virtual int FinishUserTest(
346         const std::string &msg, const int64_t &resultCode, const std::string &bundleName) override;
347 
348     /**
349      * Schedule accept want done.
350      *
351      * @param recordId Application record.
352      * @param want Want.
353      * @param flag flag get from OnAcceptWant.
354      */
355     virtual void ScheduleAcceptWantDone(
356         const int32_t recordId, const AAFwk::Want &want, const std::string &flag) override;
357 
358     virtual void ScheduleNewProcessRequestDone(
359         const int32_t recordId, const AAFwk::Want &want, const std::string &flag) override;
360 
361     /**
362      *  Get the token of ability records by process ID.
363      *
364      * @param pid The process id.
365      * @param tokens The token of ability records.
366      * @return Returns true on success, others on failure.
367      */
368     virtual int GetAbilityRecordsByProcessID(const int pid, std::vector<sptr<IRemoteObject>> &tokens) override;
369 
370     /**
371      * Prestart nwebspawn process.
372      *
373      * @return Returns ERR_OK on success, others on failure.
374      */
375     virtual int PreStartNWebSpawnProcess() override;
376 
377     /**
378      * Start nweb render process, called by nweb host.
379      *
380      * @param renderParam, params passed to renderProcess.
381      * @param ipcFd, ipc file descriptor for web browser and render process.
382      * @param sharedFd, shared memory file descriptor.
383      * @param crashFd, crash signal file descriptor.
384      * @param renderPid, created render pid.
385      * @param isGPU, is or not GPU process
386      * @return Returns ERR_OK on success, others on failure.
387      */
388     virtual int StartRenderProcess(const std::string &renderParam,
389                                    int32_t ipcFd, int32_t sharedFd,
390                                    int32_t crashFd, pid_t &renderPid, bool isGPU = false) override;
391 
392     /**
393      * Render process call this to attach app manager service.
394      *
395      * @param renderApp, information needed to start the Application.
396      */
397     virtual void AttachRenderProcess(const sptr<IRemoteObject> &renderApp) override;
398 
399     /**
400      * Get render process termination status, called by nweb host.
401      *
402      * @param renderPid, target render pid.
403      * @param status, termination status of the render process.
404      * @return Returns ERR_OK on success, others on failure.
405      */
406     virtual int GetRenderProcessTerminationStatus(pid_t renderPid, int &status) override;
407 
408     /**
409      * Notify Fault Data
410      *
411      * @param faultData the fault data.
412      * @return Returns ERR_OK on success, others on failure.
413      */
414     virtual int32_t NotifyAppFault(const FaultData &faultData) override;
415 
416     /**
417      * Notify App Fault Data By SA
418      *
419      * @param faultData the fault data notified by SA.
420      * @return Returns ERR_OK on success, others on failure.
421      */
422     virtual int32_t NotifyAppFaultBySA(const AppFaultDataBySA &faultData) override;
423 
424     /**
425      * Set Appfreeze Detect Filter
426      *
427      * @param pid the process pid.
428      * @return Returns true on success, others on failure.
429      */
430     virtual bool SetAppFreezeFilter(int32_t pid) override;
431 
432     virtual int32_t GetConfiguration(Configuration& config) override;
433 
434     virtual int32_t UpdateConfiguration(const Configuration &config, const int32_t userId = -1) override;
435 
436     /**
437      * UpdateConfigurationForBackgroundApp
438      * @param appInfos Background application information.
439      * @param policy Update policy.
440      * @param userId configuration for the user
441      * @return Returns ERR_OK on success, others on failure.
442      */
443     virtual int32_t UpdateConfigurationForBackgroundApp(const std::vector<BackgroundAppInfo> &appInfos,
444         const AppExecFwk::ConfigurationPolicy &policy, const int32_t userId = -1) override;
445 
446     virtual int32_t UpdateConfigurationByBundleName(const Configuration &config, const std::string &name,
447         int32_t appIndex = 0) override;
448 
449     virtual int32_t RegisterConfigurationObserver(const sptr<IConfigurationObserver> &observer) override;
450 
451     virtual int32_t UnregisterConfigurationObserver(const sptr<IConfigurationObserver> &observer) override;
452 
453     /**
454      * @brief Get the running state of application by bundle name.
455      *
456      * @param bundleName Bundle name
457      * @return Returns true if process is running, false if process isn't running.
458      */
459     bool GetAppRunningStateByBundleName(const std::string &bundleName) override;
460 
461     /**
462      * @brief Notify application load patch.
463      *
464      * @param bundleName Bundle name
465      * @param callback called when LoadPatch finished.
466      * @return Returns ERR_OK on success, error code on failure.
467      */
468     int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) override;
469 
470     int32_t NotifyHotReloadPage(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) override;
471 
472     int32_t NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) override;
473 
474 #ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
475     int32_t SetContinuousTaskProcess(int32_t pid, bool isContinuousTask) override;
476 #endif
477 
478     /**
479      * @brief Check whether the shared bundle is running.
480      *
481      * @param bundleName Shared bundle name.
482      * @param versionCode Shared bundle version code.
483      * @return Returns the shared bundle running result. The result is true if running, false otherwise.
484      */
485     virtual bool IsSharedBundleRunning(const std::string &bundleName, uint32_t versionCode) override;
486 
487     /**
488      * start native process for debugger.
489      *
490      * @param want param to start a process.
491      */
492     virtual int32_t StartNativeProcessForDebugger(const AAFwk::Want &want) override;
493 
494     /**
495      * Get bundleName by pid.
496      *
497      * @param pid process id.
498      * @param bundleName Output parameters, return bundleName.
499      * @param uid Output parameters, return userId.
500      * @return Returns ERR_OK on success, others on failure.
501      */
502     virtual int32_t GetBundleNameByPid(const int pid, std::string &bundleName, int32_t &uid) override;
503 
504     /**
505      * Get running process information by pid.
506      *
507      * @param pid process id.
508      * @param info Output parameters, return runningProcessInfo.
509      * @return Returns ERR_OK on success, others on failure.
510      */
511     virtual int32_t GetRunningProcessInfoByPid(const pid_t pid, OHOS::AppExecFwk::RunningProcessInfo &info) override;
512 
513     /**
514      * Get running process information by child process pid.
515      *
516      * @param childPid child process id.
517      * @param info Output parameters, return runningProcessInfo.
518      * @return Returns ERR_OK on success, others on failure.
519      */
520     virtual int32_t GetRunningProcessInfoByChildProcessPid(const pid_t childPid,
521         OHOS::AppExecFwk::RunningProcessInfo &info) override;
522 
523     /**
524      * get memorySize by pid.
525      *
526      * @param pid process id.
527      * @param memorySize Output parameters, return memorySize in KB.
528      * @return Returns ERR_OK on success, others on failure.
529      */
530     virtual int32_t GetProcessMemoryByPid(const int32_t pid, int32_t &memorySize) override;
531 
532     /**
533      * get application processes information list by bundleName.
534      *
535      * @param bundleName Bundle name.
536      * @param userId user Id in Application record.
537      * @param info Output parameters, return running process info list.
538      * @return Returns ERR_OK on success, others on failure.
539      */
540     virtual int32_t GetRunningProcessInformation(
541         const std::string &bundleName, int32_t userId, std::vector<RunningProcessInfo> &info) override;
542 
543     /**
544      * @brief Notify AbilityManagerService the page show.
545      * @param token Ability identify.
546      * @param pageStateData The data of ability's page state.
547      * @return Returns ERR_OK on success, others on failure.
548      */
549     virtual int32_t NotifyPageShow(const sptr<IRemoteObject> &token, const PageStateData &pageStateData) override;
550 
551     /**
552      * @brief Notify AbilityManagerService the page hide.
553      * @param token Ability identify.
554      * @param pageStateData The data of ability's page state.
555      * @return Returns ERR_OK on success, others on failure.
556      */
557     virtual int32_t NotifyPageHide(const sptr<IRemoteObject> &token, const PageStateData &pageStateData) override;
558 
559     /**
560      * @brief Notify NativeEngine GC of status change.
561      *
562      * @param state GC state
563      * @param pid pid
564      * @return Returns ERR_OK on success, others on failure.
565      */
566     virtual int32_t ChangeAppGcState(pid_t pid, int32_t state, uint64_t tid = 0) override;
567 
568     /**
569      * Register appRunning status listener.
570      *
571      * @param listener Running status listener.
572      * @return Returns ERR_OK on success, others on failure.
573      */
574     int32_t RegisterAppRunningStatusListener(const sptr<IRemoteObject> &listener) override;
575 
576     /**
577      * Unregister appRunning status listener.
578      *
579      * @param listener Running status listener.
580      * @return Returns ERR_OK on success, others on failure.
581      */
582     int32_t UnregisterAppRunningStatusListener(const sptr<IRemoteObject> &listener) override;
583 
584     /**
585      * Register application foreground state observer.
586      * @param observer, app Is app foreground state observer
587      * @return Returns ERR_OK on success, others on failure.
588      */
589     int32_t RegisterAppForegroundStateObserver(const sptr<IAppForegroundStateObserver> &observer) override;
590 
591     /**
592      * Unregister application foreground state observer.
593      * @param observer, app Is app foreground state observer
594      * @return Returns ERR_OK on success, others on failure.
595      */
596     int32_t UnregisterAppForegroundStateObserver(const sptr<IAppForegroundStateObserver> &observer) override;
597 
598     /**
599      * Check whether the bundle is running.
600      *
601      * @param bundleName Indicates the bundle name of the bundle.
602      * @param isRunning Obtain the running status of the application, the result is true if running, false otherwise.
603      * @return Return ERR_OK if success, others fail.
604      */
605     int32_t IsApplicationRunning(const std::string &bundleName, bool &isRunning) override;
606 
607     /**
608      * Check whether the bundle is running.
609      *
610      * @param bundleName Indicates the bundle name of the bundle.
611      * @param appCloneIndex the appindex of the bundle.
612      * @param isRunning Obtain the running status of the application, the result is true if running, false otherwise.
613      * @return Return ERR_OK if success, others fail.
614      */
615     int32_t IsAppRunning(const std::string &bundleName, int32_t appCloneIndex, bool &isRunning) override;
616 
617     /**
618      * Check whether the process of the application under the specified user exists.
619      *
620      * @param bundleName Indicates the bundle name of the bundle.
621      * @param userId the userId of the bundle.
622      * @param isRunning Obtain the running status of the application, the result is true if running, false otherwise.
623      * @return Return ERR_OK if success, others fail.
624      */
625     int32_t IsAppRunningByBundleNameAndUserId(const std::string &bundleName, int32_t userId, bool &isRunning) override;
626 
627 #ifdef SUPPORT_CHILD_PROCESS
628     /**
629      * Start child process, called by ChildProcessManager.
630      *
631      * @param childPid Created child process pid.
632      * @param request Child process start request params.
633      * @return Returns ERR_OK on success, others on failure.
634      */
635     int32_t StartChildProcess(pid_t &childPid, const ChildProcessRequest &request) override;
636 
637     /**
638      * Get child process record for self.
639      *
640      * @return child process info.
641      */
642     int32_t GetChildProcessInfoForSelf(ChildProcessInfo &info) override;
643 
644     /**
645      * Attach child process scheduler to app manager service.
646      *
647      * @param childScheduler scheduler of child process.
648      */
649     void AttachChildProcess(const sptr<IRemoteObject> &childScheduler) override;
650 
651     /**
652      * Exit child process, called by itself.
653      */
654     void ExitChildProcessSafely() override;
655 #endif // SUPPORT_CHILD_PROCESS
656 
657     /**
658      * Register native child exit callback to notify.
659      * @param notify, Callback used to notify caller the info of native child exit.
660      * @return Returns ERR_OK on success, others on failure.
661      */
662     int32_t RegisterNativeChildExitNotify(const sptr<INativeChildNotify> notify) override;
663 
664     /**
665      * Unregister native child exit callback to notify.
666      * @param notify, Callback used to notify caller the info of native child exit.
667      * @return Returns ERR_OK on success, others on failure.
668      */
669     int32_t UnregisterNativeChildExitNotify(const sptr<INativeChildNotify> notify) override;
670 
671     /**
672      * Whether the current application process is the last surviving process.
673      *
674      * @return Returns true is final application process, others return false.
675      */
676     bool IsFinalAppProcess() override;
677 
678     /**
679      * Register render state observer.
680      * @param observer Render process state observer.
681      * @return Returns ERR_OK on success, others on failure.
682      */
683     virtual int32_t RegisterRenderStateObserver(const sptr<IRenderStateObserver> &observer) override;
684 
685     /**
686      * Unregister render state observer.
687      * @param observer Render process state observer.
688      * @return Returns ERR_OK on success, others on failure.
689      */
690     virtual int32_t UnregisterRenderStateObserver(const sptr<IRenderStateObserver> &observer) override;
691 
692     /**
693      * Register KIA interceptor.
694      * @param interceptor KIA interceptor.
695      * @return Returns ERR_OK on success, others on failure.
696      */
697     virtual int32_t RegisterKiaInterceptor(const sptr<IKiaInterceptor> &interceptor) override;
698 
699     /**
700      * Check if the given pid is a KIA process.
701      * @param pid process id.
702      * @return Returns true if it is a KIA process, false otherwise.
703      */
704     virtual int32_t CheckIsKiaProcess(pid_t pid, bool &isKia) override;
705 
706     /**
707      * Update render state.
708      * @param renderPid Render pid.
709      * @param state foreground or background state.
710      * @return Returns ERR_OK on success, others on failure.
711      */
712     virtual int32_t UpdateRenderState(pid_t renderPid, int32_t state) override;
713 
714     /**
715      * @brief mark a process which is going restart.
716      * @param uid the uid of the process.
717      * @param instanceKey the instance key of the process.
718      *
719      * @return Returns ERR_OK on success, others on failure.
720      */
721     int32_t SignRestartAppFlag(int32_t uid, const std::string &instanceKey) override;
722 
723     /**
724      * Get appRunningUniqueId by pid.
725      * @param pid pid.
726      * @param appRunningUniqueId appRunningUniqueId.
727      * @return Returns ERR_OK on success, others on failure.
728      */
729     int32_t GetAppRunningUniqueIdByPid(pid_t pid, std::string &appRunningUniqueId) override;
730 
731     /*
732      * Get all uiextension root host process id, need apply permission ohos.permission.GET_RUNNING_INFO.
733      * If specified pid mismatch UIExtensionAbility type, return empty vector.
734      * @param pid Process id.
735      * @param hostPids All host process id.
736      * @return Returns 0 on success, others on failure.
737      */
738     int32_t GetAllUIExtensionRootHostPid(pid_t pid, std::vector<pid_t> &hostPids) override;
739 
740     /**
741      * Get all uiextension provider process id, need apply permission ohos.permission.GET_RUNNING_INFO.
742      * If specified hostPid didn't start any UIExtensionAbility, return empty vector.
743      * @param hostPid Host process id.
744      * @param providerPids All provider process id started by specified hostPid.
745      * @return Returns 0 on success, others on failure.
746      */
747     int32_t GetAllUIExtensionProviderPid(pid_t hostPid, std::vector<pid_t> &providerPids) override;
748 
749     /**
750      * @brief Notify memory size state changed: LOW_MEMORY, MEMORY_RECOVERY, REQUIRE_BIG_MEMORY, NO_REQUIRE_BIG_MEMORY.
751      * @param memorySizeState Indicates the memory size state.
752      * @return Returns ERR_OK on success, others on failure.
753      */
754     virtual int32_t NotifyMemorySizeStateChanged(int32_t memorySizeState) override;
755 
756     /**
757      * Set application assertion pause state.
758      *
759      * @param flag assertion pause state.
760      */
761     void SetAppAssertionPauseState(bool flag) override;
762 
763     /**
764      * @brief set support process cache by self
765      */
766     int32_t SetSupportedProcessCacheSelf(bool isSupport) override;
767 
768     int32_t SetSupportedProcessCache(int32_t pid, bool isSupport) override;
769 
770     int32_t IsProcessCacheSupported(int32_t pid, bool &isSupported) override;
771 
772     int32_t SetProcessCacheEnable(int32_t pid, bool enable) override;
773 
774     /**
775      * set browser channel for caller
776      */
777     virtual void SaveBrowserChannel(sptr<IRemoteObject> browser) override;
778 
779     /**
780      * Check caller is test ability
781      *
782      * @param pid, the pid of ability.
783      * @return Returns ERR_OK is test ability, others is not test ability.
784      */
785     int32_t CheckCallingIsUserTestMode(const pid_t pid, bool &isUserTest) override;
786 
787 #ifdef SUPPORT_CHILD_PROCESS
788     /**
789      * Start native child process, callde by ChildProcessManager.
790      * @param libName lib file name to be load in child process
791      * @param childProcessCount current started child process count
792      * @param callback callback for notify start result
793      * @return Returns ERR_OK on success, others on failure.
794      */
795     int32_t CreateNativeChildProcess(const std::string &libName, int32_t childProcessCount,
796         const sptr<IRemoteObject> &callback, const std::string &customProcessName) override;
797 #endif // SUPPORT_CHILD_PROCESS
798 
799     /**
800      * Notify that the process depends on web by itself.
801      */
802     virtual int32_t NotifyProcessDependedOnWeb() override;
803 
804     /**
805      * Kill process depended on web by sa.
806      */
807     virtual void KillProcessDependedOnWeb() override;
808 
809     /**
810      * Restart resident process depended on web.
811      */
812     virtual void RestartResidentProcessDependedOnWeb() override;
813 
814     /**
815      * Get pids of processes which belong to specific bundle name and support process cache feature.
816      * @param bundleName bundle name.
817      * @param pidList pid list of processes that support process cache..
818      * @return Returns ERR_OK on success, others on failure.
819      */
820     virtual int32_t GetSupportedProcessCachePids(const std::string &bundleName,
821         std::vector<int32_t> &pidList) override;
822 
823     virtual int32_t KillAppSelfWithInstanceKey(const std::string &instanceKey, bool clearPageStack,
824         const std::string& reason) override;
825 
826     virtual void UpdateInstanceKeyBySpecifiedId(int32_t specifiedId, std::string &instanceKey) override;
827 
828     int32_t IsSpecifiedModuleLoaded(const AAFwk::Want &want, const AbilityInfo &abilityInfo, bool &result,
829         bool &isDebug) override;
830 
831     /**
832      * UpdateProcessMemoryState, call UpdateProcessMemoryState() through proxy object,
833      * update process rss and pss value.
834      *
835      * @param procMemStates, the memory states of all apps.
836      * @return ERR_OK, return back success, others fail.
837      */
838     virtual int32_t UpdateProcessMemoryState(const std::vector<ProcessMemoryState> &procMemState) override;
839 
840     /**
841      * Launch ability when reuseDelegatorWindow is true.
842      *
843      * @param token Ability identify.
844      * @return Returns ERR_OK on success, others on failure.
845      */
846     int32_t LaunchAbility(sptr<IRemoteObject> token) override;
847 
848     /**
849      * Elevate the current process to be a candidate master process.
850      *
851      * @param isInsertToHead Whether insert current process to the head of candidate master process list.
852      * @return Return ERR_OK if success, others fail.
853      */
854     int32_t PromoteCurrentToCandidateMasterProcess(bool isInsertToHead) override;
855 
856     virtual int32_t QueryRunningSharedBundles(pid_t pid, std::map<std::string, uint32_t> &sharedBundles) override;
857 
858     /**
859      * Revoke current process as a candidate master process.
860      *
861      * @return Return ERR_OK if success, others fail.
862      */
863     int32_t DemoteCurrentFromCandidateMasterProcess() override;
864 
865 private:
866     bool SendTransactCmd(AppMgrInterfaceCode code, MessageParcel &data, MessageParcel &reply);
867     bool WriteInterfaceToken(MessageParcel &data);
868     int32_t SendRequest(AppMgrInterfaceCode code, MessageParcel &data, MessageParcel &reply,
869         MessageOption& option);
870     template<typename T>
871     int GetParcelableInfos(MessageParcel &reply, std::vector<T> &parcelableInfos);
872     static inline BrokerDelegator<AppMgrProxy> delegator_;
873 };
874 }  // namespace AppExecFwk
875 }  // namespace OHOS
876 #endif  // OHOS_ABILITY_RUNTIME_APP_MGR_PROXY_H
877