• 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 FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_MGR_STUB_H
17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_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) override;
42 
43     /**
44      * Unregister application or process state observer.
45      * @param observer, ability token.
46      * @return Returns ERR_OK on success, others on failure.
47      */
48     virtual int32_t UnregisterApplicationStateObserver(const sptr<IApplicationStateObserver> &observer) override;
49 
50     /**
51      * Get foreground applications.
52      * @param list, foreground apps.
53      * @return Returns ERR_OK on success, others on failure.
54      */
55     virtual int32_t GetForegroundApplications(std::vector<AppStateData> &list) override;
56 
57 private:
58     int32_t HandleAttachApplication(MessageParcel &data, MessageParcel &reply);
59     int32_t HandleApplicationForegrounded(MessageParcel &data, MessageParcel &reply);
60     int32_t HandleApplicationBackgrounded(MessageParcel &data, MessageParcel &reply);
61     int32_t HandleApplicationTerminated(MessageParcel &data, MessageParcel &reply);
62     int32_t HandleCheckPermission(MessageParcel &data, MessageParcel &reply);
63     int32_t HandleAbilityCleaned(MessageParcel &data, MessageParcel &reply);
64     int32_t HandleGetAmsMgr(MessageParcel &data, MessageParcel &reply);
65     int32_t HandleClearUpApplicationData(MessageParcel &data, MessageParcel &reply);
66     int32_t HandleGetAllRunningProcesses(MessageParcel &data, MessageParcel &reply);
67     int32_t HandleGetProcessRunningInfosByUserId(MessageParcel &data, MessageParcel &reply);
68     int32_t HandleGetSystemMemoryAttr(MessageParcel &data, MessageParcel &reply);
69     int32_t HandleAddAbilityStageDone(MessageParcel &data, MessageParcel &reply);
70     int32_t HandleStartupResidentProcess(MessageParcel &data, MessageParcel &reply);
71     int32_t HandleRegisterApplicationStateObserver(MessageParcel &data, MessageParcel &reply);
72     int32_t HandleUnregisterApplicationStateObserver(MessageParcel &data, MessageParcel &reply);
73     int32_t HandleGetForegroundApplications(MessageParcel &data, MessageParcel &reply);
74     int32_t HandleStartUserTestProcess(MessageParcel &data, MessageParcel &reply);
75     int32_t HandleFinishUserTest(MessageParcel &data, MessageParcel &reply);
76     int32_t HandleScheduleAcceptWantDone(MessageParcel &data, MessageParcel &reply);
77     int32_t HandleGetAbilityRecordsByProcessID(MessageParcel &data, MessageParcel &reply);
78     int32_t HandleStartRenderProcess(MessageParcel &data, MessageParcel &reply);
79     int32_t HandleAttachRenderProcess(MessageParcel &data, MessageParcel &reply);
80     int32_t HandleGetRenderProcessTerminationStatus(MessageParcel &data, MessageParcel &reply);
81     int32_t HandlePostANRTaskByProcessID(MessageParcel &data, MessageParcel &reply);
82 
83     using AppMgrFunc = int32_t (AppMgrStub::*)(MessageParcel &data, MessageParcel &reply);
84     std::map<uint32_t, AppMgrFunc> memberFuncMap_;
85 
86     DISALLOW_COPY_AND_MOVE(AppMgrStub);
87 };
88 }  // namespace AppExecFwk
89 }  // namespace OHOS
90 #endif  // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_MGR_STUB_H
91