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 info info of mission. 135 */ 136 virtual void UpdateMissionInfo(InnerMissionInfoDto &info) = 0; 137 138 /** 139 * @brief Update mission info to real element by broker. 140 * @param sessionInfo sessionInfo. 141 */ 142 virtual void UpdateMissionInfo(sptr<SessionInfo> &sessionInfo) = 0; 143 144 /** 145 * @brief Check the call permission from shell assistant. 146 * @param want target info. 147 */ CheckCallAbilityPermission(const Want & want)148 virtual int32_t CheckCallAbilityPermission(const Want &want) 149 { 150 return -1; 151 } 152 153 /** 154 * @brief Notify application update system environment changes. 155 * @param config System environment change parameters. 156 * @param userId userId Designation User ID. 157 * @return Return true to notify changes successfully, or false to failed. 158 */ UpdateConfiguration(const AppExecFwk::Configuration & config,int32_t userId)159 virtual bool UpdateConfiguration(const AppExecFwk::Configuration &config, int32_t userId) 160 { 161 return true; 162 } 163 164 /** 165 * @brief Open file by uri. 166 * @param uri The file uri. 167 * @param flag Want::FLAG_AUTH_READ_URI_PERMISSION or Want::FLAG_AUTH_WRITE_URI_PERMISSION. 168 * @return int The file descriptor. 169 */ OpenFile(const Uri & uri,uint32_t flag)170 virtual int32_t OpenFile(const Uri& uri, uint32_t flag) 171 { 172 return -1; 173 } 174 NotifyMissionBindPid(int32_t missionId,int32_t pid)175 virtual void NotifyMissionBindPid(int32_t missionId, int32_t pid) 176 { 177 return; 178 } 179 CheckStaticCfgPermission(const Want & want,bool isImplicit)180 virtual int32_t CheckStaticCfgPermission(const Want &want, bool isImplicit) 181 { 182 return 0; 183 } 184 185 enum { 186 NOTIFY_START_ABILITY = 1, 187 NOTIFY_MISSION_CREATED, 188 NOTIFY_LOAD_ABILITY, 189 NOTIFY_MOVE_MISSION_TO_BACKGROUND, 190 NOTIFY_MOVE_MISSION_TO_FOREGROUND, 191 NOTIFY_TERMINATE_MISSION, 192 NOTIFY_CLEAR_MISSION, 193 NOTIFY_REMOVE_SHELL_PROCESS, 194 UPDATE_MISSION_INFO, 195 NOTIFY_MISSION_CREATED_BY_SCB, 196 NOTIFY_LOAD_ABILITY_BY_SCB, 197 UPDATE_MISSION_INFO_BY_SCB, 198 NOTIFY_PRELOAD_ABILITY, 199 CHECK_CALL_ABILITY_PERMISSION, 200 UPDATE_CONFIGURATION, 201 OPEN_FILE, 202 NOTIFY_MISSION_BIND_PID, 203 CHECK_STATIC_CFG_PERMISSION, 204 }; 205 }; 206 } // namespace AAFwk 207 } // namespace OHOS 208 #endif // OHOS_ABILITY_RUNTIME_IABILITY_MANAGER_COLLABORATOR_H