• 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_MGR_STUB_H
17 #define OHOS_ABILITY_RUNTIME_APP_MGR_STUB_H
18 
19 #include <map>
20 
21 #include "iremote_stub.h"
22 #include "nocopyable.h"
23 #include "string_ex.h"
24 #include "app_mgr_interface.h"
25 
26 namespace OHOS {
27 namespace AppExecFwk {
28 class AppMgrStub : public IRemoteStub<IAppMgr> {
29 public:
30     AppMgrStub();
31     virtual ~AppMgrStub();
32 
33     virtual int OnRemoteRequest(
34         uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
35 
36     /**
37      * Register application or process state observer.
38      * @param observer, ability token.
39      * @return Returns ERR_OK on success, others on failure.
40      */
41     virtual int32_t RegisterApplicationStateObserver(const sptr<IApplicationStateObserver> &observer,
42         const std::vector<std::string> &bundleNameList = {}) override;
43 
44     /**
45      * Unregister application or process state observer.
46      * @param observer, ability token.
47      * @return Returns ERR_OK on success, others on failure.
48      */
49     virtual int32_t UnregisterApplicationStateObserver(const sptr<IApplicationStateObserver> &observer) override;
50 
51     /**
52      * Get foreground applications.
53      * @param list, foreground apps.
54      * @return Returns ERR_OK on success, others on failure.
55      */
56     virtual int32_t GetForegroundApplications(std::vector<AppStateData> &list) override;
57 
58 private:
59     int32_t HandleAttachApplication(MessageParcel &data, MessageParcel &reply);
60     int32_t HandleApplicationForegrounded(MessageParcel &data, MessageParcel &reply);
61     int32_t HandleApplicationBackgrounded(MessageParcel &data, MessageParcel &reply);
62     int32_t HandleApplicationTerminated(MessageParcel &data, MessageParcel &reply);
63     int32_t HandleCheckPermission(MessageParcel &data, MessageParcel &reply);
64     int32_t HandleAbilityCleaned(MessageParcel &data, MessageParcel &reply);
65     int32_t HandleGetAmsMgr(MessageParcel &data, MessageParcel &reply);
66     int32_t HandleClearUpApplicationData(MessageParcel &data, MessageParcel &reply);
67     int32_t HandleGetAllRunningProcesses(MessageParcel &data, MessageParcel &reply);
68     int32_t HandleGetProcessRunningInfosByUserId(MessageParcel &data, MessageParcel &reply);
69     int32_t HandleGetProcessRunningInformation(MessageParcel &data, MessageParcel &reply);
70     int32_t HandleGetAllRenderProcesses(MessageParcel &data, MessageParcel &reply);
71     int32_t HandleAddAbilityStageDone(MessageParcel &data, MessageParcel &reply);
72     int32_t HandleNotifyMemoryLevel(MessageParcel &data, MessageParcel &reply);
73     int32_t HandleStartupResidentProcess(MessageParcel &data, MessageParcel &reply);
74     int32_t HandleRegisterApplicationStateObserver(MessageParcel &data, MessageParcel &reply);
75     int32_t HandleUnregisterApplicationStateObserver(MessageParcel &data, MessageParcel &reply);
76     int32_t HandleGetForegroundApplications(MessageParcel &data, MessageParcel &reply);
77     int32_t HandleStartUserTestProcess(MessageParcel &data, MessageParcel &reply);
78     int32_t HandleFinishUserTest(MessageParcel &data, MessageParcel &reply);
79     int32_t HandleScheduleAcceptWantDone(MessageParcel &data, MessageParcel &reply);
80     int32_t HandleGetAbilityRecordsByProcessID(MessageParcel &data, MessageParcel &reply);
81     int32_t HandlePreStartNWebSpawnProcess(MessageParcel &data, MessageParcel &reply);
82     int32_t HandleStartRenderProcess(MessageParcel &data, MessageParcel &reply);
83     int32_t HandleAttachRenderProcess(MessageParcel &data, MessageParcel &reply);
84     int32_t HandleGetRenderProcessTerminationStatus(MessageParcel &data, MessageParcel &reply);
85     int32_t HandleGetConfiguration(MessageParcel &data, MessageParcel &reply);
86     int32_t HandleUpdateConfiguration(MessageParcel &data, MessageParcel &reply);
87     int32_t HandleRegisterConfigurationObserver(MessageParcel &data, MessageParcel &reply);
88     int32_t HandleUnregisterConfigurationObserver(MessageParcel &data, MessageParcel &reply);
89     int32_t HandleDumpHeapMemory(MessageParcel &data, MessageParcel &reply);
90 #ifdef ABILITY_COMMAND_FOR_TEST
91     int32_t HandleBlockAppServiceDone(MessageParcel &data, MessageParcel &reply);
92 #endif
93     int32_t HandleGetAppRunningStateByBundleName(MessageParcel &data, MessageParcel &reply);
94     int32_t HandleNotifyLoadRepairPatch(MessageParcel &data, MessageParcel &reply);
95     int32_t HandleNotifyHotReloadPage(MessageParcel &data, MessageParcel &reply);
96     int32_t HandleNotifyUnLoadRepairPatch(MessageParcel &data, MessageParcel &reply);
97 #ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
98     int32_t HandleSetContinuousTaskProcess(MessageParcel &data, MessageParcel &reply);
99 #endif
100     int32_t HandleIsSharedBundleRunning(MessageParcel &data, MessageParcel &reply);
101     int32_t HandleStartNativeProcessForDebugger(MessageParcel &data, MessageParcel &reply);
102     int32_t HandleNotifyFault(MessageParcel &data, MessageParcel &reply);
103     int32_t HandleNotifyFaultBySA(MessageParcel &data, MessageParcel &reply);
104     int32_t HandleJudgeSandboxByPid(MessageParcel &data, MessageParcel &reply);
105     int32_t HandleGetBundleNameByPid(MessageParcel &data, MessageParcel &reply);
106     int32_t HandleGetProcessMemoryByPid(MessageParcel &data, MessageParcel &reply);
107     int32_t HandleGetRunningProcessInformation(MessageParcel &data, MessageParcel &reply);
108 
109     using AppMgrFunc = int32_t (AppMgrStub::*)(MessageParcel &data, MessageParcel &reply);
110     std::map<uint32_t, AppMgrFunc> memberFuncMap_;
111 
112     DISALLOW_COPY_AND_MOVE(AppMgrStub);
113 };
114 }  // namespace AppExecFwk
115 }  // namespace OHOS
116 #endif  // OHOS_ABILITY_RUNTIME_APP_MGR_STUB_H
117