• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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_IABILITY_MANAGER_COLLABORATOR_H
17 #define OHOS_ABILITY_RUNTIME_IABILITY_MANAGER_COLLABORATOR_H
18 
19 #include "ability_info.h"
20 #include "iremote_broker.h"
21 #include "iremote_object.h"
22 #include "mission_info.h"
23 #include "session_info.h"
24 #include "want.h"
25 
26 namespace OHOS {
27 namespace AppExecFwk {
28 class Configuration;
29 }
30 }
31 
32 namespace OHOS {
33 namespace AAFwk {
34 class SessionInfo;
35 
36 class IAbilityManagerCollaborator : public IRemoteBroker {
37 public:
38     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.IAbilityManagerCollaborator");
39 
40     /**
41      * @brief Notify collaborator to StartAbility.
42      * @param AbilityInfo ability info from bms
43      * @param userId userId.
44      * @param want targert info, will modify by collaborator.
45      * @param accessTokenIDEx accessToken
46      * @return 0 when notify start ability success or else failed.
47      */
48     virtual int32_t NotifyStartAbility(const AppExecFwk::AbilityInfo &abilityInfo,
49         int32_t userId, Want &want, uint64_t accessTokenIDEx) = 0;
50 
51     /**
52      * @brief Notify collaborator to app preload.
53      * @param bundleName bundlName.
54      * @return 0 means success or else failed.
55      */
NotifyPreloadAbility(const std::string & bundleName)56     virtual int32_t NotifyPreloadAbility(const std::string &bundleName)
57     {
58         return 0;
59     }
60 
61     /**
62      * @brief Notify when mission is created.
63      * @param missionId missionId.
64      * @param want target info.
65      * @return 0 when notify mission created success or else failed.
66      */
67     virtual int32_t NotifyMissionCreated(int32_t missionId, const Want &want) = 0;
68 
69     /**
70      * @brief Notify when mission is created.
71      * @param sessionInfo sessionInfo.
72      * @return 0 when notify mission created success or else failed.
73      */
74     virtual int32_t NotifyMissionCreated(const sptr<SessionInfo> &sessionInfo) = 0;
75 
76     /**
77      * @brief Notify when start loading ability record.
78      * @param AbilityInfo ability info from bms.
79      * @param missionId missionId.
80      * @param want target info.
81      * @return 0 when notify load ability success or else failed.
82     */
83     virtual int32_t NotifyLoadAbility(
84         const AppExecFwk::AbilityInfo &abilityInfo, int32_t missionId, const Want &want) = 0;
85 
86     /**
87      * @brief Notify when start loading ability record.
88      * @param AbilityInfo ability info from bms.
89      * @param sessionInfo sessionInfo.
90      * @return 0 when notify load ability success or else failed.
91     */
92     virtual int32_t NotifyLoadAbility(
93         const AppExecFwk::AbilityInfo &abilityInfo, const sptr<SessionInfo> &sessionInfo) = 0;
94 
95     /**
96      * @brief Notify when notify app to background.
97      * @param missionId missionId.
98      * @return 0 when notify move mission to background success or else failed.
99      */
100     virtual int32_t NotifyMoveMissionToBackground(int32_t missionId) = 0;
101 
102     /**
103      * @brief Notify when notify app to foreground.
104      * @param missionId missionId.
105      * @return 0 when notify move mission to foreground success or else failed.
106      */
107     virtual int32_t NotifyMoveMissionToForeground(int32_t missionId) = 0;
108 
109     /**
110      * @brief Notify when notify ability is terminated, but mission is not cleared.
111      * @param missionId missionId.
112      * @return 0 when notify terminate mission success or else failed.
113      */
114     virtual int32_t NotifyTerminateMission(int32_t missionId) = 0;
115 
116     /**
117      * @brief Notify to broker when clear mission.
118      * @param missionId missionId.
119      * @return 0 when notify clear mission success or else failed.
120      */
121     virtual int32_t NotifyClearMission(int32_t missionId) = 0;
122 
123     /**
124      * @brief Notify to broker when clear mission.
125      * @param pid pid of shell process.
126      * @param type died type.
127      * @param reason addational message for died reason.
128      * @return 0 when notify remove shell process success or else failed.
129      */
130     virtual int32_t NotifyRemoveShellProcess(int32_t pid, int32_t type, const std::string &reason) = 0;
131 
132     /**
133      * @brief Update mission info to real element by broker.
134      * @param sessionInfo sessionInfo.
135      */
136     virtual void UpdateMissionInfo(sptr<SessionInfo> &sessionInfo) = 0;
137 
138     /**
139      * @brief Check the call permission from shell assistant.
140      * @param want target info.
141      */
CheckCallAbilityPermission(const Want & want)142     virtual int32_t CheckCallAbilityPermission(const Want &want)
143     {
144         return -1;
145     }
146 
147     /**
148      * @brief Notify application update system environment changes.
149      * @param config System environment change parameters.
150      * @param userId userId Designation User ID.
151      * @return Return true to notify changes successfully, or false to failed.
152      */
UpdateConfiguration(const AppExecFwk::Configuration & config,int32_t userId)153     virtual bool UpdateConfiguration(const AppExecFwk::Configuration &config, int32_t userId)
154     {
155         return true;
156     }
157 
158     /**
159      * @brief Open file by uri.
160      * @param uri The file uri.
161      * @param flag Want::FLAG_AUTH_READ_URI_PERMISSION or Want::FLAG_AUTH_WRITE_URI_PERMISSION.
162      * @return int The file descriptor.
163      */
OpenFile(const Uri & uri,uint32_t flag)164     virtual int32_t OpenFile(const Uri& uri, uint32_t flag)
165     {
166         return -1;
167     }
168 
NotifyMissionBindPid(int32_t missionId,int32_t pid)169     virtual void NotifyMissionBindPid(int32_t missionId, int32_t pid)
170     {
171         return;
172     }
173 
CheckStaticCfgPermission(const Want & want,bool isImplicit)174     virtual int32_t CheckStaticCfgPermission(const Want &want, bool isImplicit)
175     {
176         return 0;
177     }
178 
179     /**
180      * @brief Update caller if need.
181      * @param want to start ability
182      * @return 0 when update caller successfully or else failed.
183      */
UpdateCallerIfNeed(Want & want)184     virtual int32_t UpdateCallerIfNeed(Want &want)
185     {
186         return 0;
187     }
188 
189     /**
190      * @brief Update target if need.
191      * @param want to start ability
192      * @return 0 when update target successfully or else failed.
193      */
UpdateTargetIfNeed(Want & want)194     virtual int32_t UpdateTargetIfNeed(Want &want)
195     {
196         return 0;
197     }
198 
199     enum {
200         NOTIFY_START_ABILITY = 1,
201         NOTIFY_MISSION_CREATED,
202         NOTIFY_LOAD_ABILITY,
203         NOTIFY_MOVE_MISSION_TO_BACKGROUND,
204         NOTIFY_MOVE_MISSION_TO_FOREGROUND,
205         NOTIFY_TERMINATE_MISSION,
206         NOTIFY_CLEAR_MISSION,
207         NOTIFY_REMOVE_SHELL_PROCESS,
208         NOTIFY_MISSION_CREATED_BY_SCB = 10,
209         NOTIFY_LOAD_ABILITY_BY_SCB,
210         UPDATE_MISSION_INFO_BY_SCB,
211         NOTIFY_PRELOAD_ABILITY,
212         CHECK_CALL_ABILITY_PERMISSION,
213         UPDATE_CONFIGURATION,
214         OPEN_FILE,
215         NOTIFY_MISSION_BIND_PID,
216         CHECK_STATIC_CFG_PERMISSION,
217         UPDATE_CALLER_IF_NEED,
218         UPDATE_TARGET_IF_NEED,
219     };
220 };
221 }  // namespace AAFwk
222 }  // namespace OHOS
223 #endif // OHOS_ABILITY_RUNTIME_IABILITY_MANAGER_COLLABORATOR_H