• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 HandleAddAbilityStageDone(MessageParcel &data, MessageParcel &reply);
71     int32_t HandleNotifyMemoryLevel(MessageParcel &data, MessageParcel &reply);
72     int32_t HandleStartupResidentProcess(MessageParcel &data, MessageParcel &reply);
73     int32_t HandleRegisterApplicationStateObserver(MessageParcel &data, MessageParcel &reply);
74     int32_t HandleUnregisterApplicationStateObserver(MessageParcel &data, MessageParcel &reply);
75     int32_t HandleGetForegroundApplications(MessageParcel &data, MessageParcel &reply);
76     int32_t HandleStartUserTestProcess(MessageParcel &data, MessageParcel &reply);
77     int32_t HandleFinishUserTest(MessageParcel &data, MessageParcel &reply);
78     int32_t HandleScheduleAcceptWantDone(MessageParcel &data, MessageParcel &reply);
79     int32_t HandleGetAbilityRecordsByProcessID(MessageParcel &data, MessageParcel &reply);
80     int32_t HandlePreStartNWebSpawnProcess(MessageParcel &data, MessageParcel &reply);
81     int32_t HandleStartRenderProcess(MessageParcel &data, MessageParcel &reply);
82     int32_t HandleAttachRenderProcess(MessageParcel &data, MessageParcel &reply);
83     int32_t HandleGetRenderProcessTerminationStatus(MessageParcel &data, MessageParcel &reply);
84     int32_t HandleGetConfiguration(MessageParcel &data, MessageParcel &reply);
85     int32_t HandleUpdateConfiguration(MessageParcel &data, MessageParcel &reply);
86     int32_t HandleRegisterConfigurationObserver(MessageParcel &data, MessageParcel &reply);
87     int32_t HandleUnregisterConfigurationObserver(MessageParcel &data, MessageParcel &reply);
88 #ifdef ABILITY_COMMAND_FOR_TEST
89     int32_t HandleBlockAppServiceDone(MessageParcel &data, MessageParcel &reply);
90 #endif
91     int32_t HandleGetAppRunningStateByBundleName(MessageParcel &data, MessageParcel &reply);
92     int32_t HandleNotifyLoadRepairPatch(MessageParcel &data, MessageParcel &reply);
93     int32_t HandleNotifyHotReloadPage(MessageParcel &data, MessageParcel &reply);
94     int32_t HandleNotifyUnLoadRepairPatch(MessageParcel &data, MessageParcel &reply);
95 #ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
96     int32_t HandleSetContinuousTaskProcess(MessageParcel &data, MessageParcel &reply);
97 #endif
98 
99     using AppMgrFunc = int32_t (AppMgrStub::*)(MessageParcel &data, MessageParcel &reply);
100     std::map<uint32_t, AppMgrFunc> memberFuncMap_;
101 
102     DISALLOW_COPY_AND_MOVE(AppMgrStub);
103 };
104 }  // namespace AppExecFwk
105 }  // namespace OHOS
106 #endif  // OHOS_ABILITY_RUNTIME_APP_MGR_STUB_H
107