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 #ifndef OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_COLLABORATOR_PROXY_H 16 #define OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_COLLABORATOR_PROXY_H 17 18 #include "iability_manager_collaborator.h" 19 #include "iremote_proxy.h" 20 21 namespace OHOS { 22 namespace AAFwk { 23 class AbilityManagerCollaboratorProxy : public IRemoteProxy<IAbilityManagerCollaborator> { 24 public: AbilityManagerCollaboratorProxy(const sptr<IRemoteObject> & impl)25 explicit AbilityManagerCollaboratorProxy(const sptr<IRemoteObject> &impl) 26 : IRemoteProxy<IAbilityManagerCollaborator>(impl) 27 {} 28 virtual ~AbilityManagerCollaboratorProxy() = default; 29 30 /** 31 * @brief Notify collaborator to StartAbility. 32 * @param AbilityInfo ability info from bms 33 * @param userId userId. 34 * @param want targert info, will modify by collaborator. 35 * @param accessTokenIDEx accessToken 36 * @return 0 when notify start ability success or else failed. 37 */ 38 virtual int32_t NotifyStartAbility(const AppExecFwk::AbilityInfo &abilityInfo, 39 int32_t userId, Want &want, uint64_t accessTokenIDEx, int32_t windowMode) override; 40 41 /** 42 * @brief Notify collaborator to app preload. 43 * @param bundleName bundlName. 44 * @return 0 means success or else failed. 45 */ 46 virtual int32_t NotifyPreloadAbility(const std::string &bundleName) override; 47 48 /** 49 * @brief Notify when mission is created. 50 * @param missionId missionId. 51 * @param want target info. 52 * @return 0 when notify mission created success or else failed. 53 */ 54 virtual int32_t NotifyMissionCreated(int32_t missionId, const Want &want) override; 55 56 /** 57 * @brief Notify when mission is created. 58 * @param sessionInfo sessionInfo. 59 * @return 0 when notify mission created success or else failed. 60 */ 61 virtual int32_t NotifyMissionCreated(const sptr<SessionInfo> &sessionInfo) override; 62 63 /** 64 * @brief Notify when start loading ability record. 65 * @param AbilityInfo ability info from bms. 66 * @param missionId missionId. 67 * @param want target info. 68 * @return 0 when notify load ability success or else failed. 69 */ 70 virtual int32_t NotifyLoadAbility(const AppExecFwk::AbilityInfo &abilityInfo, 71 int32_t missionId, const Want &want) override; 72 73 /** 74 * @brief Notify when start loading ability record. 75 * @param AbilityInfo ability info from bms. 76 * @param sessionInfo sessionInfo. 77 * @return 0 when notify load ability success or else failed. 78 */ 79 virtual int32_t NotifyLoadAbility( 80 const AppExecFwk::AbilityInfo &abilityInfo, const sptr<SessionInfo> &sessionInfo) override; 81 82 /** 83 * @brief Notify when notify app to background. 84 * @param missionId missionId. 85 * @return 0 when notify move mission to background success or else failed. 86 */ 87 virtual int32_t NotifyMoveMissionToBackground(int32_t missionId) override; 88 89 /** 90 * @brief Notify when notify app to foreground. 91 * @param missionId missionId. 92 * @return 0 when notify move mission to foreground success or else failed. 93 */ 94 virtual int32_t NotifyMoveMissionToForeground(int32_t missionId) override; 95 96 /** 97 * @brief Notify when notify ability is terminated, but mission is not cleared. 98 * @param missionId missionId. 99 * @return 0 when notify terminate mission success or else failed. 100 */ 101 virtual int32_t NotifyTerminateMission(int32_t missionId) override; 102 103 /** 104 * @brief Notify to broker when clear mission. 105 * @param missionId missionId. 106 * @return 0 when notify clear mission success or else failed. 107 */ 108 virtual int32_t NotifyClearMission(int32_t missionId) override; 109 110 /** 111 * @brief Notify to broker when clear mission. 112 * @param pid pid of shell process. 113 * @param type died type. 114 * @param reason addational message for died reason. 115 * @return 0 when notify remove shell process success or else failed. 116 */ 117 virtual int32_t NotifyRemoveShellProcess(int32_t pid, int32_t type, const std::string &reason) override; 118 119 /** 120 * @brief Update mission info to real element by broker. 121 * @param sessionInfo sessionInfo. 122 */ 123 virtual void UpdateMissionInfo(sptr<SessionInfo> &sessionInfo) override; 124 125 /** 126 * @brief Check the call permission from shell assistant. 127 * @param want target info. 128 * @return 0 when check permission success or else failed. 129 */ 130 virtual int32_t CheckCallAbilityPermission(const Want &want) override; 131 132 /** 133 * @brief Notify application update system environment changes. 134 * @param config System environment change parameters. 135 * @param userId userId Designation User ID. 136 * @return Return true to notify changes successfully, or false to failed. 137 */ 138 virtual bool UpdateConfiguration(const AppExecFwk::Configuration &config, int32_t userId) override; 139 140 /** 141 * @brief Open file by uri. 142 * @param uri The file uri. 143 * @param flag Want::FLAG_AUTH_READ_URI_PERMISSION or Want::FLAG_AUTH_WRITE_URI_PERMISSION. 144 * @return int The file descriptor. 145 */ 146 virtual int OpenFile(const Uri& uri, uint32_t flag, uint32_t tokenId) override; 147 148 /** 149 * @brief grant uri permission 150 * @param uriVec vector of uri 151 * @param flag Want::FLAG_AUTH_READ_URI_PERMISSION or Want::FLAG_AUTH_WRITE_URI_PERMISSION. 152 * @param targetTokenId the tokenId of target application. 153 * @param targetBundleName the bundleName of target application. 154 * @return 0 when on success or else failed. 155 */ 156 virtual int32_t GrantUriPermission(const std::vector<std::string> &uriVec, uint32_t flag, uint32_t targetTokenId, 157 const std::string &targetBundleName) override; 158 159 /** 160 * @brief revoke uri permission 161 * @param tokenId the tokenId of target application. 162 * @return 0 when on success or else failed. 163 */ 164 virtual int32_t RevokeUriPermission(uint32_t tokenId) override; 165 166 virtual void NotifyMissionBindPid(int32_t missionId, int32_t pid) override; 167 168 virtual int32_t CheckStaticCfgPermission(const Want &want, bool isImplicit) override; 169 170 /** 171 * @brief Update caller if need. 172 * @param want target info 173 * @return 0 when update caller successfully or else failed. 174 */ 175 virtual int32_t UpdateCallerIfNeed(Want &want) override; 176 177 /** 178 * @brief Update target if need. 179 * @param want target info 180 * @return 0 when update target successfully or else failed. 181 */ 182 virtual int32_t UpdateTargetIfNeed(Want &want) override; 183 184 /** 185 * @brief kill processes by bundleName. 186 * @param bundleName the bundleName of processes to be killed. 187 * @param userId the user id of processes to be killed. 188 * @return 0 when on success or else failed. 189 */ 190 virtual int32_t NotifyKillProcesses(const std::string &bundleName, int32_t userId) override; 191 private: 192 static inline BrokerDelegator<AbilityManagerCollaboratorProxy> delegator_; 193 int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 194 }; 195 } // namespace AAFWK 196 } // namespace OHOS 197 #endif // OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_COLLABORATOR_PROXY_H 198