1 /* 2 * Copyright (c) 2021-2025 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_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_MGR_HOST_IMPL_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_MGR_HOST_IMPL_H 18 19 #include <atomic> 20 21 #include "bundle_cache_mgr.h" 22 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL 23 #include "bundle_connect_ability_mgr.h" 24 #endif 25 #include "bundle_common_event_mgr.h" 26 #include "bundle_data_mgr.h" 27 #include "bundle_mgr_host.h" 28 #ifdef DISTRIBUTED_BUNDLE_FRAMEWORK 29 #include "distributed_bms_interface.h" 30 #endif 31 #include "event_report.h" 32 #include "inner_bundle_user_info.h" 33 34 namespace OHOS { 35 namespace AppExecFwk { 36 struct QueryEventInfo { 37 int32_t errCode = ERR_OK; 38 int64_t lastReportEventTime = 0; 39 int32_t funcId = 0; 40 int32_t uid = 0; 41 int32_t userId = -1; 42 int32_t appIndex = -1; 43 int32_t callingUid = -1; 44 int32_t flag = -1; 45 std::string bundleName = ""; 46 std::string callingAppId = ""; 47 std::string callingBundleName = ""; 48 49 bool operator==(const QueryEventInfo& other) const 50 { 51 return funcId == other.funcId && 52 uid == other.uid && 53 userId == other.userId && 54 appIndex == other.appIndex && 55 flag == other.flag && 56 bundleName == other.bundleName && 57 callingUid == other.callingUid && 58 callingAppId == other.callingAppId && 59 callingBundleName == other.callingBundleName; 60 } 61 }; 62 class BundleMgrHostImpl : public BundleMgrHost { 63 public: 64 BundleMgrHostImpl() = default; 65 virtual ~BundleMgrHostImpl() = default; 66 /** 67 * @brief Obtains the ApplicationInfo based on a given bundle name. 68 * @param appName Indicates the application bundle name to be queried. 69 * @param flag Indicates the flag used to specify information contained 70 * in the ApplicationInfo object that will be returned. 71 * @param userId Indicates the user ID. 72 * @param appInfo Indicates the obtained ApplicationInfo object. 73 * @return Returns true if the application is successfully obtained; returns false otherwise. 74 */ 75 virtual bool GetApplicationInfo( 76 const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo) override; 77 /** 78 * @brief Obtains the ApplicationInfo based on a given bundle name. 79 * @param appName Indicates the application bundle name to be queried. 80 * @param flags Indicates the flag used to specify information contained 81 * in the ApplicationInfo object that will be returned. 82 * @param userId Indicates the user ID. 83 * @param appInfo Indicates the obtained ApplicationInfo object. 84 * @return Returns true if the application is successfully obtained; returns false otherwise. 85 */ 86 virtual bool GetApplicationInfo( 87 const std::string &appName, int32_t flags, int32_t userId, ApplicationInfo &appInfo) override; 88 /** 89 * @brief Obtains the ApplicationInfo based on a given bundle name. 90 * @param appName Indicates the application bundle name to be queried. 91 * @param flags Indicates the flag used to specify information contained 92 * in the ApplicationInfo object that will be returned. 93 * @param userId Indicates the user ID. 94 * @param appInfo Indicates the obtained ApplicationInfo object. 95 * @return Returns ERR_OK if the application is successfully obtained; returns error code otherwise. 96 */ 97 virtual ErrCode GetApplicationInfoV9( 98 const std::string &appName, int32_t flags, int32_t userId, ApplicationInfo &appInfo) override; 99 /** 100 * @brief Obtains information about all installed applications of a specified user. 101 * @param flag Indicates the flag used to specify information contained 102 * in the ApplicationInfo objects that will be returned. 103 * @param userId Indicates the user ID. 104 * @param appInfos Indicates all of the obtained ApplicationInfo objects. 105 * @return Returns true if the applications is successfully obtained; returns false otherwise. 106 */ 107 virtual bool GetApplicationInfos( 108 const ApplicationFlag flag, const int userId, std::vector<ApplicationInfo> &appInfos) override; 109 /** 110 * @brief Obtains information about all installed applications of a specified user. 111 * @param flags Indicates the flag used to specify information contained 112 * in the ApplicationInfo objects that will be returned. 113 * @param userId Indicates the user ID. 114 * @param appInfos Indicates all of the obtained ApplicationInfo objects. 115 * @return Returns true if the applications is successfully obtained; returns false otherwise. 116 */ 117 virtual bool GetApplicationInfos( 118 int32_t flags, int32_t userId, std::vector<ApplicationInfo> &appInfos) override; 119 /** 120 * @brief Obtains information about all installed applications of a specified user. 121 * @param flags Indicates the flag used to specify information contained 122 * in the ApplicationInfo objects that will be returned. 123 * @param userId Indicates the user ID. 124 * @param appInfos Indicates all of the obtained ApplicationInfo objects. 125 * @return Returns ERR_OK if the applications is successfully obtained; returns error code otherwise. 126 */ 127 virtual ErrCode GetApplicationInfosV9( 128 int32_t flags, int32_t userId, std::vector<ApplicationInfo> &appInfos) override; 129 /** 130 * @brief Obtains the BundleInfo based on a given bundle name. 131 * @param bundleName Indicates the application bundle name to be queried. 132 * @param flag Indicates the information contained in the BundleInfo object to be returned. 133 * @param bundleInfo Indicates the obtained BundleInfo object. 134 * @param userId Indicates the user ID. 135 * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. 136 */ 137 virtual bool GetBundleInfo(const std::string &bundleName, 138 const BundleFlag flag, BundleInfo &bundleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override; 139 /** 140 * @brief Obtains the BundleInfo based on a given bundle name. 141 * @param bundleName Indicates the application bundle name to be queried. 142 * @param flags Indicates the information contained in the BundleInfo object to be returned. 143 * @param bundleInfo Indicates the obtained BundleInfo object. 144 * @param userId Indicates the user ID. 145 * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. 146 */ 147 virtual bool GetBundleInfo(const std::string &bundleName, 148 int32_t flags, BundleInfo &bundleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override; 149 /** 150 * @brief Obtains the BundleInfo based on a given bundle name. 151 * @param bundleName Indicates the application bundle name to be queried. 152 * @param flags Indicates the information contained in the BundleInfo object to be returned. 153 * @param bundleInfo Indicates the obtained BundleInfo object. 154 * @param userId Indicates the user ID. 155 * @return Returns ERR_OK if the BundleInfo is successfully obtained; returns error code otherwise. 156 */ 157 virtual ErrCode GetBundleInfoV9(const std::string &bundleName, 158 int32_t flags, BundleInfo &bundleInfo, int32_t userId) override; 159 /** 160 * @brief Batch obtains the BundleInfos based on a given bundle name list. 161 * @param bundleNames Indicates the application bundle name list to be queried. 162 * @param flags Indicates the information contained in the BundleInfo object to be returned. 163 * @param bundleInfos Indicates the obtained BundleInfos object. 164 * @param userId Indicates the user ID. 165 * @return Returns ERR_OK if the BundleInfo is successfully obtained; returns error code otherwise. 166 */ 167 virtual ErrCode BatchGetBundleInfo(const std::vector<std::string> &bundleNames, 168 int32_t flags, std::vector<BundleInfo> &bundleInfos, int32_t userId) override; 169 /** 170 * @brief Obtains the BundleInfo based on a given bundle name. 171 * @param flags Indicates the information contained in the BundleInfo object to be returned. 172 * @param bundleInfo Indicates the obtained BundleInfo object. 173 * @return Returns ERR_OK if the BundleInfo is successfully obtained; returns error code otherwise. 174 */ 175 virtual ErrCode GetBundleInfoForSelf(int32_t flags, BundleInfo &bundleInfo) override; 176 /** 177 * @brief Obtains the BundleInfo based on a given bundle name, which the calling app depends on. 178 * @param sharedBundleName Indicates the bundle name to be queried. 179 * @param sharedBundleInfo Indicates the obtained BundleInfo object. 180 * @param flag Indicates the flag, GetDependentBundleInfoFlag. 181 * @return Returns ERR_OK if the BundleInfo is successfully obtained; returns error code otherwise. 182 */ 183 virtual ErrCode GetDependentBundleInfo(const std::string &sharedBundleName, BundleInfo &sharedBundleInfo, 184 GetDependentBundleInfoFlag flag = GetDependentBundleInfoFlag::GET_APP_CROSS_HSP_BUNDLE_INFO) override; 185 /** 186 * @brief Obtains the BundlePackInfo based on a given bundle name. 187 * @param bundleName Indicates the application bundle name to be queried. 188 * @param flags Indicates the information contained in the BundleInfo object to be returned. 189 * @param BundlePackInfo Indicates the obtained BundlePackInfo object. 190 * @param userId Indicates the user ID. 191 * @return Returns ERR_OK if the BundlePackInfo is successfully obtained; returns other ErrCode otherwise. 192 */ 193 virtual ErrCode GetBundlePackInfo(const std::string &bundleName, const BundlePackFlag flag, 194 BundlePackInfo &bundlePackInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override; 195 196 /** 197 * @brief Obtains the BundlePackInfo based on a given bundle name. 198 * @param bundleName Indicates the application bundle name to be queried. 199 * @param flags Indicates the information contained in the BundleInfo object to be returned. 200 * @param BundlePackInfo Indicates the obtained BundlePackInfo object. 201 * @param userId Indicates the user ID. 202 * @return Returns ERR_OK if the BundlePackInfo is successfully obtained; returns other ErrCode otherwise. 203 */ 204 virtual ErrCode GetBundlePackInfo(const std::string &bundleName, int32_t flags, BundlePackInfo &bundlePackInfo, 205 int32_t userId = Constants::UNSPECIFIED_USERID) override; 206 207 /** 208 * @brief Obtains BundleInfo of all bundles available in the system. 209 * @param flag Indicates the flag used to specify information contained in the BundleInfo that will be returned. 210 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 211 * @param userId Indicates the user ID. 212 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 213 */ 214 virtual bool GetBundleInfos(const BundleFlag flag, 215 std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) override; 216 /** 217 * @brief Obtains BundleInfo of all bundles available in the system. 218 * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be returned. 219 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 220 * @param userId Indicates the user ID. 221 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 222 */ 223 virtual bool GetBundleInfos(int32_t flags, 224 std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) override; 225 /** 226 * @brief Obtains BundleInfo of all bundles available in the system. 227 * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be returned. 228 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 229 * @param userId Indicates the user ID. 230 * @return Returns ERR_OK if the BundleInfos is successfully obtained; returns error code otherwise. 231 */ 232 virtual ErrCode GetBundleInfosV9(int32_t flags, std::vector<BundleInfo> &bundleInfos, int32_t userId) override; 233 /** 234 * @brief Obtains the application UID based on the given bundle name and user ID. 235 * @param bundleName Indicates the bundle name of the application. 236 * @param userId Indicates the user ID. 237 * @return Returns the uid if successfully obtained; returns -1 otherwise. 238 */ 239 virtual bool GetBundleNameForUid(const int uid, std::string &bundleName) override; 240 /** 241 * @brief Obtains all bundle names of a specified application based on the given application UID. 242 * @param uid Indicates the uid. 243 * @param bundleNames Indicates the obtained bundle names. 244 * @return Returns true if the bundle names is successfully obtained; returns false otherwise. 245 */ 246 virtual bool GetBundlesForUid(const int uid, std::vector<std::string> &bundleNames) override; 247 /** 248 * @brief Obtains the formal name associated with the given UID. 249 * @param uid Indicates the uid. 250 * @param name Indicates the obtained formal name. 251 * @return Returns ERR_OK if execute success; returns errCode otherwise. 252 */ 253 virtual ErrCode GetNameForUid(const int uid, std::string &name) override; 254 /** 255 * @brief Obtains the formal name associated with the given UID. 256 * @param uid Indicates the uid. 257 * @param name Indicates the obtained formal bundleName. 258 * @param appIndex Indicates the obtained appIndex. 259 * @return Returns ERR_OK if execute success; returns errCode otherwise. 260 */ 261 virtual ErrCode GetNameAndIndexForUid(const int uid, std::string &bundleName, int32_t &appIndex) override; 262 /** 263 * @brief Obtains the appIdentifier and appIndex with the given access tokenId. 264 * @param accessTokenId Indicates the access tokenId of the application. 265 * @param appIdentifier Indicates the app identifier of the application. 266 * @param appIndex Indicates the app index of the application. 267 * @return Returns ERR_OK if execute success; returns errCode otherwise. 268 */ 269 virtual ErrCode GetAppIdentifierAndAppIndex(const uint32_t accessTokenId, 270 std::string &appIdentifier, int32_t &appIndex) override; 271 /** 272 * @brief Obtains the formal name associated with the given UID. 273 * @param uids Indicates the uid list. 274 * @param simpleAppInfo Indicates all of the obtained SimpleAppInfo objects. 275 * @return Returns ERR_OK if execute success; returns errCode otherwise. 276 */ 277 virtual ErrCode GetSimpleAppInfoForUid( 278 const std::vector<std::int32_t> &uids, std::vector<SimpleAppInfo> &simpleAppInfo) override; 279 /** 280 * @brief Obtains an array of all group IDs associated with a specified bundle. 281 * @param bundleName Indicates the bundle name. 282 * @param gids Indicates the group IDs associated with the specified bundle. 283 * @return Returns true if the gids is successfully obtained; returns false otherwise. 284 */ 285 virtual bool GetBundleGids(const std::string &bundleName, std::vector<int> &gids) override; 286 /** 287 * @brief Obtains an array of all group IDs associated with the given bundle name and UID. 288 * @param bundleName Indicates the bundle name. 289 * @param uid Indicates the uid. 290 * @param gids Indicates the group IDs associated with the specified bundle. 291 * @return Returns true if the gids is successfully obtained; returns false otherwise. 292 */ 293 virtual bool GetBundleGidsByUid(const std::string &bundleName, const int &uid, std::vector<int> &gids) override; 294 /** 295 * @brief Check whether the app is system app by it's UID. 296 * @param uid Indicates the uid. 297 * @return Returns true if the bundle is a system application; returns false otherwise. 298 */ 299 virtual bool CheckIsSystemAppByUid(const int uid) override; 300 /** 301 * @brief Obtains the BundleInfo of application bundles based on the specified metaData. 302 * @param metaData Indicates the metadata to get in the bundle. 303 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 304 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 305 */ 306 virtual bool GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos) override; 307 /** 308 * @brief Query the AbilityInfo by the given Want. 309 * @param want Indicates the information of the ability. 310 * @param abilityInfo Indicates the obtained AbilityInfo object. 311 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 312 */ 313 virtual bool QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo) override; 314 315 /** 316 * @brief Query the AbilityInfo by the given Want. 317 * @param want Indicates the information of the ability. 318 * @param abilityInfo Indicates the obtained AbilityInfo object. 319 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 320 */ 321 virtual bool QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, 322 AbilityInfo &abilityInfo, const sptr<IRemoteObject> &callBack) override; 323 324 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL 325 /** 326 * @brief Silent install by the given Want. 327 * @param want Indicates the information of the want. 328 * @param userId Indicates the user ID. 329 * @param callBack Indicates the callback to be invoked for return the operation result. 330 * @return Returns true if silent install successfully; returns false otherwise. 331 */ 332 virtual bool SilentInstall(const Want &want, int32_t userId, const sptr<IRemoteObject> &callBack) override; 333 334 virtual bool CheckAbilityEnableInstall( 335 const Want &want, int32_t missionId, int32_t userId, const sptr<IRemoteObject> &callback) override; 336 #endif 337 /** 338 * @brief Obtains the AbilityInfo based on a given bundle name through the proxy object. 339 * @param bundleName Indicates the application bundle name to be queried. 340 * @param abilityName Indicates the application ability name to be queried. 341 * @param abilityInfo Indicates the obtained AbilityInfo object. 342 * @return Returns true if the application is successfully obtained; returns false otherwise. 343 */ 344 virtual bool GetAbilityInfo( 345 const std::string &bundleName, const std::string &abilityName, AbilityInfo &abilityInfo) override; 346 /** 347 * @brief Obtains the AbilityInfo based on a given bundle name through the proxy object. 348 * @param bundleName Indicates the application bundle name to be queried. 349 * @param moduleName Indicates the module name to be queried. 350 * @param abilityName Indicates the application ability name to be queried. 351 * @param abilityInfo Indicates the obtained AbilityInfo object. 352 * @return Returns true if the application is successfully obtained; returns false otherwise. 353 */ 354 virtual bool GetAbilityInfo( 355 const std::string &bundleName, const std::string &moduleName, 356 const std::string &abilityName, AbilityInfo &abilityInfo) override; 357 /** 358 * @brief Query the AbilityInfo by the given Want. 359 * @param want Indicates the information of the ability. 360 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 361 * @param userId Indicates the user ID. 362 * @param abilityInfo Indicates the obtained AbilityInfo object. 363 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 364 */ 365 virtual bool QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo) override; 366 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL 367 /** 368 * @brief Upgrade atomic service 369 * @param want Indicates the information of the ability. 370 * @param userId Indicates the user ID. 371 */ 372 virtual void UpgradeAtomicService(const Want &want, int32_t userId) override; 373 374 virtual bool ProcessPreload(const Want &want) override; 375 #endif 376 /** 377 * @brief Query the AbilityInfo of list by the given Want. 378 * @param want Indicates the information of the ability. 379 * @param abilityInfos Indicates the obtained AbilityInfos object. 380 * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise. 381 */ 382 virtual bool QueryAbilityInfos(const Want &want, std::vector<AbilityInfo> &abilityInfos) override; 383 /** 384 * @brief Query the AbilityInfo of list by the given Want. 385 * @param want Indicates the information of the ability. 386 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 387 * @param userId Indicates the user ID. 388 * @param abilityInfos Indicates the obtained AbilityInfos object. 389 * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise. 390 */ 391 virtual bool QueryAbilityInfos( 392 const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) override; 393 /** 394 * @brief Query the AbilityInfo of list by the given Want. 395 * @param want Indicates the information of the ability. 396 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 397 * @param userId Indicates the user ID. 398 * @param abilityInfos Indicates the obtained AbilityInfos object. 399 * @return Returns ERR_OK if the AbilityInfos is successfully obtained; returns errCode otherwise. 400 */ 401 virtual ErrCode QueryAbilityInfosV9( 402 const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) override; 403 /** 404 * @brief Get the AbilityInfo of list by the given Uri. 405 * @param uri Indicates the information of the ability. 406 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 407 * @param abilityInfos Indicates the obtained AbilityInfos object. 408 * @return Returns ERR_OK if the AbilityInfos is successfully obtained; returns errCode otherwise. 409 */ 410 virtual ErrCode GetAbilityInfos( 411 const std::string &uri, uint32_t flags, std::vector<AbilityInfo> &abilityInfos) override; 412 /** 413 * @brief Batch query the AbilityInfo of list by the given Wants. 414 * @param wants Indicates the information of the abilities. 415 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 416 * @param userId Indicates the user ID. 417 * @param abilityInfos Indicates the obtained AbilityInfos object. 418 * @return Returns ERR_OK if the AbilityInfos is successfully obtained; returns errCode otherwise. 419 */ 420 virtual ErrCode BatchQueryAbilityInfos( 421 const std::vector<Want> &wants, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) override; 422 /** 423 * @brief Query the launcher AbilityInfo of list by the given Want. 424 * @param want Indicates the information of the ability. 425 * @param userId Indicates the user ID. 426 * @param abilityInfos Indicates the obtained AbilityInfos object. 427 * @return Returns ERR_OK if the AbilityInfos is successfully obtained; returns errCode otherwise. 428 */ 429 virtual ErrCode QueryLauncherAbilityInfos(const Want &want, 430 int32_t userId, std::vector<AbilityInfo> &abilityInfos) override; 431 /** 432 * @brief Public interface query the launcher AbilityInfo of list by the given Want. 433 * @param bundleName Indicates the bundle name. 434 * @param userId Indicates the user ID. 435 * @param abilityInfos Indicates the obtained AbilityInfos object. 436 * @return Returns ERR_OK if the AbilityInfos is successfully obtained; returns errCode otherwise. 437 */ 438 virtual ErrCode GetLauncherAbilityInfoSync(const std::string &bundleName, 439 int32_t userId, std::vector<AbilityInfo> &abilityInfos) override; 440 /** 441 * @brief Query the AbilityInfo of list of all service on launcher. 442 * @param userId Indicates the information of the user. 443 * @param abilityInfos Indicates the obtained AbilityInfos object. 444 * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise. 445 */ 446 virtual bool QueryAllAbilityInfos( 447 const Want &want, int32_t userId, std::vector<AbilityInfo> &abilityInfos) override; 448 /** 449 * @brief Query the AbilityInfo by ability.uri in config.json. 450 * @param abilityUri Indicates the uri of the ability. 451 * @param abilityInfo Indicates the obtained AbilityInfo object. 452 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 453 */ 454 virtual bool QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo) override; 455 /** 456 * @brief Query the AbilityInfo by ability.uri in config.json. 457 * @param abilityUri Indicates the uri of the ability. 458 * @param abilityInfos Indicates the obtained AbilityInfos object. 459 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 460 */ 461 virtual bool QueryAbilityInfosByUri( 462 const std::string &abilityUri, std::vector<AbilityInfo> &abilityInfos) override; 463 /** 464 * @brief Query the AbilityInfo by ability.uri in config.json through the proxy object. 465 * @param abilityUri Indicates the uri of the ability. 466 * @param userId Indicates the user ID. 467 * @param abilityInfo Indicates the obtained AbilityInfo object. 468 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 469 */ 470 virtual bool QueryAbilityInfoByUri( 471 const std::string &abilityUri, int32_t userId, AbilityInfo &abilityInfo) override; 472 /** 473 * @brief Obtains the BundleInfo of all keep-alive applications in the system. 474 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 475 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 476 */ 477 virtual bool QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos) override; 478 /** 479 * @brief Obtains the label of a specified ability. 480 * @param bundleName Indicates the bundle name. 481 * @param abilityName Indicates the ability name. 482 * @return Returns the label of the ability if exist; returns empty string otherwise. 483 */ 484 virtual std::string GetAbilityLabel(const std::string &bundleName, const std::string &abilityName) override; 485 /** 486 * @brief Obtains the label of a specified ability. 487 * @param bundleName Indicates the bundle name. 488 * @param moduleName Indicates the module name. 489 * @param abilityName Indicates the ability name. 490 * @param label Indicates the obtained label. 491 * @return Returns ERR_OK if called successfully; returns error code otherwise. 492 */ 493 virtual ErrCode GetAbilityLabel(const std::string &bundleName, const std::string &moduleName, 494 const std::string &abilityName, std::string &label) override; 495 /** 496 * @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP). 497 * @param hapFilePath Indicates the absolute file path of the HAP. 498 * @param flag Indicates the information contained in the BundleInfo object to be returned. 499 * @param bundleInfo Indicates the obtained BundleInfo object. 500 * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. 501 */ 502 virtual bool GetBundleArchiveInfo( 503 const std::string &hapFilePath, const BundleFlag flag, BundleInfo &bundleInfo) override; 504 /** 505 * @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP). 506 * @param hapFilePath Indicates the absolute file path of the HAP. 507 * @param flags Indicates the information contained in the BundleInfo object to be returned. 508 * @param bundleInfo Indicates the obtained BundleInfo object. 509 * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. 510 */ 511 virtual bool GetBundleArchiveInfo( 512 const std::string &hapFilePath, int32_t flags, BundleInfo &bundleInfo) override; 513 /** 514 * @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP). 515 * @param hapFilePath Indicates the absolute file path of the HAP. 516 * @param flags Indicates the information contained in the BundleInfo object to be returned. 517 * @param bundleInfo Indicates the obtained BundleInfo object. 518 * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise. 519 */ 520 virtual ErrCode GetBundleArchiveInfoV9( 521 const std::string &hapFilePath, int32_t flags, BundleInfo &bundleInfo) override; 522 /** 523 * @brief Obtain the HAP module info of a specific ability. 524 * @param abilityInfo Indicates the ability. 525 * @param hapModuleInfo Indicates the obtained HapModuleInfo object. 526 * @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise. 527 */ 528 virtual bool GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo) override; 529 /** 530 * @brief Obtain the HAP module info of a specific ability through the proxy object. 531 * @param abilityInfo Indicates the ability. 532 * @param userId Indicates the userId. 533 * @param hapModuleInfo Indicates the obtained HapModuleInfo object. 534 * @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise. 535 */ 536 virtual bool GetHapModuleInfo( 537 const AbilityInfo &abilityInfo, int32_t userId, HapModuleInfo &hapModuleInfo) override; 538 /** 539 * @brief Obtains the Want for starting the main ability of an application based on the given bundle name. 540 * @param bundleName Indicates the bundle name. 541 * @param want Indicates the obtained launch Want object. 542 * @param userId Indicates the userId. 543 * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise. 544 */ 545 virtual ErrCode GetLaunchWantForBundle( 546 const std::string &bundleName, Want &want, int32_t userId = Constants::UNSPECIFIED_USERID) override; 547 /** 548 * @brief Obtains detailed information about a specified permission. 549 * @param permissionName Indicates the name of the ohos permission. 550 * @param permissionDef Indicates the object containing detailed information about the given ohos permission. 551 * @return Returns true if the PermissionDef object is successfully obtained; returns false otherwise. 552 */ 553 virtual ErrCode GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef) override; 554 /** 555 * @brief Clears cache data of a specified size. 556 * @param cacheSize Indicates the size of the cache data is to be cleared. 557 * @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise. 558 */ 559 virtual ErrCode CleanBundleCacheFilesAutomatic(uint64_t cacheSize) override; 560 /** 561 * @brief Clears cache data of a specified application. 562 * @param bundleName Indicates the bundle name of the application whose cache data is to be cleared. 563 * @param cleanCacheCallback Indicates the callback to be invoked for returning the operation result. 564 * @param userId description the user id. 565 * @param appIndex Indicates the app index. 566 * @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise. 567 */ 568 virtual ErrCode CleanBundleCacheFiles( 569 const std::string &bundleName, const sptr<ICleanCacheCallback> cleanCacheCallback, 570 int32_t userId = Constants::UNSPECIFIED_USERID, int32_t appIndex = 0) override; 571 /** 572 * @brief Clears application running data of a specified application. 573 * @param bundleName Indicates the bundle name of the application whose data is to be cleared. 574 * @param userId Indicates the user id. 575 * @param appIndex Indicates the app index. 576 * @return Returns true if the data cleared successfully; returns false otherwise. 577 */ 578 virtual bool CleanBundleDataFiles(const std::string &bundleName, 579 const int userId = Constants::UNSPECIFIED_USERID, const int appIndex = 0, const int callerUid = -1) override; 580 /** 581 * @brief Register the specific bundle status callback. 582 * @param bundleStatusCallback Indicates the callback to be invoked for returning the bundle status changed result. 583 * @return Returns true if this function is successfully called; returns false otherwise. 584 */ 585 virtual bool RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override; 586 587 virtual bool RegisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback) override; 588 589 virtual bool UnregisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback) override; 590 /** 591 * @brief Clear the specific bundle status callback. 592 * @param bundleStatusCallback Indicates the callback to be cleared. 593 * @return Returns true if this function is successfully called; returns false otherwise. 594 */ 595 virtual bool ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override; 596 /** 597 * @brief Unregister all the callbacks of status changed. 598 * @return Returns true if this function is successfully called; returns false otherwise. 599 */ 600 virtual bool UnregisterBundleStatusCallback() override; 601 /** 602 * @brief Dump the bundle informations with specific flags. 603 * @param flag Indicates the information contained in the dump result. 604 * @param bundleName Indicates the bundle name if needed. 605 * @param userId Indicates the user ID. 606 * @param result Indicates the dump information result. 607 * @return Returns true if the dump result is successfully obtained; returns false otherwise. 608 */ 609 virtual bool DumpInfos( 610 const DumpFlag flag, const std::string &bundleName, int32_t userId, std::string &result) override; 611 /** 612 * @brief Compile the bundle informations with specific flags. 613 * @param bundleName Indicates the bundle name if needed. 614 * @param compileMode Indicates the mode name. 615 * @param isAllBundle Does it represent all bundlenames. 616 * @return Returns true if the compile result is successfully obtained; returns false otherwise. 617 */ 618 virtual ErrCode CompileProcessAOT(const std::string &bundleName, const std::string &compileMode, 619 bool isAllBundle, std::vector<std::string> &compileResults) override; 620 /** 621 * @brief Compile the bundle informations with specific flags. 622 * @param bundleName Indicates the bundle name if needed. 623 * @param isAllBundle Does it represent all bundlenames. 624 * @return Returns true if the compile result is successfully obtained; returns false otherwise. 625 */ 626 virtual ErrCode CompileReset(const std::string &bundleName, bool isAllBundle) override; 627 /** 628 * @brief Reset the bundle informations. 629 * @return Returns true if the reset result is successfully obtained; returns false otherwise. 630 */ 631 virtual ErrCode ResetAllAOT() override; 632 /** 633 * @brief copy ap file to /data/local/pgo. 634 * @param bundleName Indicates the bundle name if needed. 635 * @param isAllBundle Does it represent all bundlenames. 636 * @param result Indicates the copy ap information result. 637 * @return Returns ERR_OK if called successfully; returns error code otherwise. 638 */ 639 virtual ErrCode CopyAp(const std::string &bundleName, bool isAllBundle, std::vector<std::string> &results) override; 640 /** 641 * @brief Checks whether a specified application is enabled. 642 * @param bundleName Indicates the bundle name of the application. 643 * @param isEnable Indicates the application status is enabled. 644 * @return Returns result of the operation. 645 */ 646 virtual ErrCode IsApplicationEnabled(const std::string &bundleName, bool &isEnable) override; 647 /** 648 * @brief Checks whether a specified clone application is enabled. 649 * @param bundleName Indicates the bundle name of the application. 650 * @param appIndex Indicates the app index of clone applications. 651 * @param isEnable Indicates the application status is enabled. 652 * @return Returns result of the operation. 653 */ 654 virtual ErrCode IsCloneApplicationEnabled( 655 const std::string &bundleName, int32_t appIndex, bool &isEnable) override; 656 /** 657 * @brief Sets whether to enable a specified application. 658 * @param bundleName Indicates the bundle name of the application. 659 * @param isEnable Specifies whether to enable the application. 660 * The value true means to enable it, and the value false means to disable it. 661 * @param userId description the user id. 662 * @return Returns result of the operation. 663 */ 664 virtual ErrCode SetApplicationEnabled(const std::string &bundleName, bool isEnable, 665 int32_t userId = Constants::UNSPECIFIED_USERID) override; 666 /** 667 * @brief Sets whether to enable a specified clone application. 668 * @param bundleName Indicates the bundle name of the application. 669 * @param appIndex Indicates the app index of clone applications. 670 * @param isEnable Specifies whether to enable the application. 671 * The value true means to enable it, and the value false means to disable it. 672 * @param userId description the user id. 673 * @return Returns result of the operation. 674 */ 675 virtual ErrCode SetCloneApplicationEnabled(const std::string &bundleName, int32_t appIndex, bool isEnable, 676 int32_t userId = Constants::UNSPECIFIED_USERID) override; 677 /** 678 * @brief Sets whether to enable a specified ability through the proxy object. 679 * @param abilityInfo Indicates information about the ability to check. 680 * @param isEnable Indicates the ability status is enabled. 681 * @return Returns result of the operation. 682 */ 683 virtual ErrCode IsAbilityEnabled(const AbilityInfo &abilityInfo, bool &isEnable) override; 684 /** 685 * @brief Sets whether to enable a specified ability. 686 * @param abilityInfo Indicates information about the ability to check. 687 * @param appIndex Indicates the app index of clone applications. 688 * @param isEnable Indicates the ability status is enabled. 689 * @return Returns result of the operation. 690 */ 691 virtual ErrCode IsCloneAbilityEnabled(const AbilityInfo &abilityInfo, int32_t appIndex, bool &isEnable) override; 692 /** 693 * @brief Sets whether to enable a specified ability through the proxy object. 694 * @param abilityInfo Indicates information about the ability. 695 * @param isEnabled Specifies whether to enable the ability. 696 * The value true means to enable it, and the value false means to disable it. 697 * @param userId description the user id. 698 * @return Returns result of the operation. 699 */ 700 virtual ErrCode SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled, 701 int32_t userId = Constants::UNSPECIFIED_USERID) override; 702 /** 703 * @brief Sets whether to enable a specified ability through the proxy object. 704 * @param abilityInfo Indicates information about the ability. 705 * @param appIndex Indicates the app index of clone applications. 706 * @param isEnabled Specifies whether to enable the ability. 707 * The value true means to enable it, and the value false means to disable it. 708 * @param userId description the user id. 709 * @return Returns result of the operation. 710 */ 711 virtual ErrCode SetCloneAbilityEnabled(const AbilityInfo &abilityInfo, int32_t appIndex, bool isEnabled, 712 int32_t userId = Constants::UNSPECIFIED_USERID) override; 713 /** 714 * @brief Obtains the interface used to install and uninstall bundles. 715 * @return Returns a pointer to IBundleInstaller class if exist; returns nullptr otherwise. 716 */ 717 virtual sptr<IBundleInstaller> GetBundleInstaller() override; 718 /** 719 * @brief Obtains the interface used to create or delete user. 720 * @return Returns a pointer to IBundleUserMgr class if exist; returns nullptr otherwise. 721 */ 722 virtual sptr<IBundleUserMgr> GetBundleUserMgr() override; 723 /** 724 * @brief Obtains the IVerifyManager. 725 * @return Returns a pointer to IVerifyManager class if exist; returns nullptr otherwise. 726 */ 727 virtual sptr<IVerifyManager> GetVerifyManager() override; 728 /** 729 * @brief Obtains the FormInfo objects provided by all applications on the device. 730 * @param formInfos List of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the 731 * device. 732 * @return Returns true if this function is successfully called; returns false otherwise. 733 */ 734 virtual bool GetAllFormsInfo(std::vector<FormInfo> &formInfos) override; 735 /** 736 * @brief Obtains the FormInfo objects provided by a specified application on the device. 737 * @param bundleName Indicates the bundle name of the application. 738 * @param formInfos List of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the 739 * device. 740 * @return Returns true if this function is successfully called; returns false otherwise. 741 */ 742 virtual bool GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfos) override; 743 /** 744 * @brief Obtains the FormInfo objects provided by a specified module name. 745 * @param bundleName Indicates the bundle name of the application. 746 * @param moduleName Indicates the module name of the application. 747 * @param formInfos List of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the 748 * device. 749 * @return Returns true if this function is successfully called; returns false otherwise. 750 */ 751 virtual bool GetFormsInfoByModule( 752 const std::string &bundleName, const std::string &moduleName, std::vector<FormInfo> &formInfos) override; 753 /** 754 * @brief Obtains the ShortcutInfo objects provided by a specified application on the device. 755 * @param bundleName Indicates the bundle name of the application. 756 * @param shortcutInfos List of ShortcutInfo objects if obtained. 757 * @return Returns true if GetShortcutInfos successfully; returns false otherwise. 758 */ 759 virtual bool GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos) override; 760 761 /** 762 * @brief Obtains the ShortcutInfo objects provided by a specified application on the device. 763 * @param bundleName Indicates the bundle name of the application. 764 * @param shortcutInfos List of ShortcutInfo objects if obtained. 765 * @return Returns errCode of result. 766 */ 767 virtual ErrCode GetShortcutInfoV9(const std::string &bundleName, 768 std::vector<ShortcutInfo> &shortcutInfos, int32_t userId = Constants::UNSPECIFIED_USERID) override; 769 /** 770 * @brief Obtains the ShortcutInfo objects provided by a specified application on the device. 771 * @param bundleName Indicates the bundle name of the application. 772 * @param shortcutInfos List of ShortcutInfo objects if obtained. 773 * @param appIndex Indicates the app index of clone applications. 774 * @return Returns errCode of result. 775 */ 776 virtual ErrCode GetShortcutInfoByAppIndex(const std::string &bundleName, const int32_t appIndex, 777 std::vector<ShortcutInfo> &shortcutInfos) override; 778 /** 779 * @brief Obtains the CommonEventInfo objects provided by an event key on the device. 780 * @param eventKey Indicates the event of the subscribe. 781 * @param commonEventInfos List of CommonEventInfo objects if obtained. 782 * @return Returns true if this function is successfully called; returns false otherwise. 783 */ 784 virtual bool GetAllCommonEventInfo(const std::string &eventKey, 785 std::vector<CommonEventInfo> &commonEventInfos) override; 786 /** 787 * @brief Obtains the DistributedBundleInfo based on a given bundle name and networkId. 788 * @param networkId Indicates the networkId of remote device. 789 * @param bundleName Indicates the application bundle name to be queried. 790 * @param distributedBundleInfo Indicates the obtained DistributedBundleInfo object. 791 * @return Returns true if the DistributedBundleInfo is successfully obtained; returns false otherwise. 792 */ 793 virtual bool GetDistributedBundleInfo(const std::string &networkId, const std::string &bundleName, 794 DistributedBundleInfo &distributedBundleInfo) override; 795 /** 796 * @brief Get app privilege level. 797 * @param bundleName Indicates the bundle name of the app privilege level. 798 * @param userId Indicates the user id. 799 * @return Returns app privilege level. 800 */ 801 virtual std::string GetAppPrivilegeLevel( 802 const std::string &bundleName, int32_t userId = Constants::UNSPECIFIED_USERID) override; 803 /** 804 * @brief Query extension info. 805 * @param Want Indicates the information of extension info. 806 * @param flag Indicates the query flag which will fliter any specified stuff in the extension info. 807 * @param userId Indicates the userId in the system. 808 * @param extensionInfos Indicates the obtained extensions. 809 * @return Returns true if this function is successfully called; returns false otherwise. 810 */ 811 virtual bool QueryExtensionAbilityInfos(const Want &want, const int32_t &flag, const int32_t &userId, 812 std::vector<ExtensionAbilityInfo> &extensionInfos) override; 813 /** 814 * @brief Query extension info. 815 * @param Want Indicates the information of extension info. 816 * @param flag Indicates the query flag which will filter any specified stuff in the extension info. 817 * @param userId Indicates the userId in the system. 818 * @param extensionInfos Indicates the obtained extensions. 819 * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise. 820 */ 821 virtual ErrCode QueryExtensionAbilityInfosV9(const Want &want, int32_t flags, int32_t userId, 822 std::vector<ExtensionAbilityInfo> &extensionInfos) override; 823 /** 824 * @brief Query extension info. 825 * @param Want Indicates the information of extension info. 826 * @param extensionType Indicates the type of the extension. 827 * @param flag Indicates the query flag which will fliter any specified stuff in the extension info. 828 * @param userId Indicates the userId in the system. 829 * @param extensionInfos Indicates the obtained extensions. 830 * @return Returns true if this function is successfully called; returns false otherwise. 831 */ 832 virtual bool QueryExtensionAbilityInfos(const Want &want, const ExtensionAbilityType &extensionType, 833 const int32_t &flag, const int32_t &userId, std::vector<ExtensionAbilityInfo> &extensionInfos) override; 834 /** 835 * @brief Query extension info. 836 * @param Want Indicates the information of extension info. 837 * @param extensionType Indicates the type of the extension. 838 * @param flag Indicates the query flag which will filter any specified stuff in the extension info. 839 * @param userId Indicates the userId in the system. 840 * @param extensionInfos Indicates the obtained extensions. 841 * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise. 842 */ 843 virtual ErrCode QueryExtensionAbilityInfosV9(const Want &want, const ExtensionAbilityType &extensionType, 844 int32_t flags, int32_t userId, std::vector<ExtensionAbilityInfo> &extensionInfos) override; 845 /** 846 * @brief Process hidump. 847 * @param fd Indicates the fd. 848 * @param args Indicates the params. 849 * @return Returns the dump result. 850 */ 851 int Dump(int fd, const std::vector<std::u16string> &args) override; 852 853 virtual bool QueryExtensionAbilityInfos(const ExtensionAbilityType &extensionType, const int32_t &userId, 854 std::vector<ExtensionAbilityInfo> &extensionInfos) override; 855 856 virtual bool VerifyCallingPermission(const std::string &permission) override; 857 858 virtual sptr<IExtendResourceManager> GetExtendResourceManager() override; 859 860 virtual bool VerifySystemApi(int32_t beginApiVersion = Constants::INVALID_API_VERSION) override; 861 862 virtual bool QueryExtensionAbilityInfoByUri(const std::string &uri, int32_t userId, 863 ExtensionAbilityInfo &extensionAbilityInfo) override; 864 865 virtual std::string GetAppIdByBundleName(const std::string &bundleName, const int userId) override; 866 867 virtual std::string GetAppType(const std::string &bundleName) override; 868 869 virtual int32_t GetUidByBundleName(const std::string &bundleName, const int32_t userId) override; 870 871 virtual int32_t GetUidByBundleName(const std::string &bundleName, const int32_t userId, 872 int32_t appIndex) override; 873 874 virtual int GetUidByDebugBundleName(const std::string &bundleName, const int userId) override; 875 876 virtual bool ImplicitQueryInfoByPriority(const Want &want, int32_t flags, int32_t userId, 877 AbilityInfo &abilityInfo, ExtensionAbilityInfo &extensionInfo) override; 878 879 virtual bool ImplicitQueryInfos(const Want &want, int32_t flags, int32_t userId, bool withDefault, 880 std::vector<AbilityInfo> &abilityInfos, std::vector<ExtensionAbilityInfo> &extensionInfos, 881 bool &findDefaultApp) override; 882 883 /** 884 * @brief Obtains the value of isRemovable based on a given bundle name and module name. 885 * @param bundleName Indicates the bundle name to be queried. 886 * @param moduleName Indicates the module name to be queried. 887 * @param isRemovable Indicates the module whether is removable. 888 * @return Returns ERR_OK if the isRemovable is successfully obtained; returns other ErrCode otherwise. 889 */ 890 virtual ErrCode IsModuleRemovable(const std::string &bundleName, const std::string &moduleName, 891 bool &isRemovable) override; 892 /** 893 * @brief Sets whether to enable isRemovable based on a given bundle name and module name. 894 * @param bundleName Indicates the bundle name to be queried. 895 * @param moduleName Indicates the module name to be queried. 896 * @param isEnable Specifies whether to enable the isRemovable of InnerModuleInfo. 897 * The value true means to enable it, and the value false means to disable it 898 * @return Returns true if the isRemovable is successfully obtained; returns false otherwise. 899 */ 900 virtual bool SetModuleRemovable( 901 const std::string &bundleName, const std::string &moduleName, bool isEnable) override; 902 /** 903 * @brief Obtains the dependent module names. 904 * 905 * @param bundleName Indicates the bundle name to be queried. 906 * @param moduleName Indicates the module name to be queried. 907 * @param dependentModuleNames Indicates the obtained dependent module names. 908 * @return Returns true if this function is successfully called; returns false otherwise. 909 */ 910 virtual bool GetAllDependentModuleNames(const std::string &bundleName, const std::string &moduleName, 911 std::vector<std::string> &dependentModuleNames) override; 912 /** 913 * @brief Obtains the value of upgradeFlag based on a given bundle name and module name. 914 * @param bundleName Indicates the bundle name to be queried. 915 * @param moduleName Indicates the module name to be queried. 916 * @return Returns true if the upgradeFlag is successfully obtained; returns false otherwise. 917 */ 918 virtual bool GetModuleUpgradeFlag(const std::string &bundleName, const std::string &moduleName) override; 919 /** 920 * @brief Sets whether to enable upgradeFlag based on a given bundle name and module name. 921 * @param bundleName Indicates the bundle name to be queried. 922 * @param moduleName Indicates the module name to be queried. 923 * @param isEnable Specifies whether to enable the upgradeFlag of InnerModuleInfo. 924 * The value true means to enable it, and the value false means to disable it 925 * @return Returns ERR_OK if the UpgradeFlag is successfully obtained; returns other ErrCode otherwise. 926 */ 927 virtual ErrCode SetModuleUpgradeFlag( 928 const std::string &bundleName, const std::string &moduleName, int32_t upgradeFlag) override; 929 virtual ErrCode GetSandboxBundleInfo( 930 const std::string &bundleName, int32_t appIndex, int32_t userId, BundleInfo &info) override; 931 932 /** 933 * @brief Obtains sandbox data directory by bundleName and appIndex. 934 * @param bundleName Indicates the bundle name of the sandbox application to be install. 935 * @param appIndex Indicates application index of the sandbox application. 936 * @return Returns ERR_OK if the get sandbox data dir successfully; returns errcode otherwise. 937 */ 938 virtual ErrCode GetSandboxDataDir( 939 const std::string &bundleName, int32_t appIndex, std::string &sandboxDataDir) override; 940 941 virtual bool ObtainCallingBundleName(std::string &bundleName) override; 942 943 virtual bool GetBundleStats(const std::string &bundleName, int32_t userId, 944 std::vector<int64_t> &bundleStats, int32_t appIndex = 0, uint32_t statFlag = 0) override; 945 946 virtual ErrCode BatchGetBundleStats(const std::vector<std::string> &bundleNames, int32_t userId, 947 std::vector<BundleStorageStats> &bundleStats) override; 948 949 virtual bool GetAllBundleStats(int32_t userId, std::vector<int64_t> &bundleStats) override; 950 951 virtual ErrCode GetAllBundleCacheStat(const sptr<IProcessCacheCallback> processCacheCallback) override; 952 953 virtual ErrCode CleanAllBundleCache(const sptr<IProcessCacheCallback> processCacheCallback) override; 954 955 virtual ErrCode SetShortcutVisibleForSelf(const std::string &shortcutId, bool visible) override; 956 #ifdef BUNDLE_FRAMEWORK_DEFAULT_APP 957 virtual sptr<IDefaultApp> GetDefaultAppProxy() override; 958 #endif 959 960 #ifdef BUNDLE_FRAMEWORK_APP_CONTROL 961 virtual sptr<IAppControlMgr> GetAppControlProxy() override; 962 #endif 963 964 virtual sptr<IBundleMgrExt> GetBundleMgrExtProxy() override; 965 966 virtual ErrCode GetSandboxAbilityInfo(const Want &want, int32_t appIndex, int32_t flags, int32_t userId, 967 AbilityInfo &info) override; 968 virtual ErrCode GetSandboxExtAbilityInfos(const Want &want, int32_t appIndex, int32_t flags, int32_t userId, 969 std::vector<ExtensionAbilityInfo> &infos) override; 970 virtual ErrCode GetSandboxHapModuleInfo(const AbilityInfo &abilityInfo, int32_t appIndex, int32_t userId, 971 HapModuleInfo &info) override; 972 973 virtual ErrCode GetMediaData(const std::string &bundleName, const std::string &moduleName, 974 const std::string &abilityName, std::unique_ptr<uint8_t[]> &mediaDataPtr, size_t &len, int32_t userId) override; 975 976 virtual sptr<IQuickFixManager> GetQuickFixManagerProxy() override; 977 virtual std::string GetStringById(const std::string &bundleName, const std::string &moduleName, 978 uint32_t resId, int32_t userId, const std::string &localeInfo) override; 979 virtual std::string GetIconById(const std::string &bundleName, const std::string &moduleName, 980 uint32_t resId, uint32_t density, int32_t userId) override; 981 virtual ErrCode SetDebugMode(bool isDebug) override; 982 virtual sptr<IOverlayManager> GetOverlayManagerProxy() override; 983 virtual ErrCode GetAppProvisionInfo(const std::string &bundleName, int32_t userId, 984 AppProvisionInfo &appProvisionInfo) override; 985 virtual ErrCode GetProvisionMetadata(const std::string &bundleName, int32_t userId, 986 std::vector<Metadata> &provisionMetadatas) override; 987 virtual ErrCode GetBaseSharedBundleInfos(const std::string &bundleName, 988 std::vector<BaseSharedBundleInfo> &baseSharedBundleInfos, 989 GetDependentBundleInfoFlag flag = GetDependentBundleInfoFlag::GET_APP_CROSS_HSP_BUNDLE_INFO) override; 990 virtual ErrCode GetAllSharedBundleInfo(std::vector<SharedBundleInfo> &sharedBundles) override; 991 virtual ErrCode GetSharedBundleInfo(const std::string &bundleName, const std::string &moduleName, 992 std::vector<SharedBundleInfo> &sharedBundles) override; 993 virtual ErrCode GetSharedBundleInfoBySelf(const std::string &bundleName, 994 SharedBundleInfo &sharedBundleInfo) override; 995 virtual ErrCode GetSharedDependencies(const std::string &bundleName, const std::string &moduleName, 996 std::vector<Dependency> &dependencies) override; 997 virtual ErrCode GetProxyDataInfos(const std::string &bundleName, const std::string &moduleName, 998 std::vector<ProxyData> &proxyDatas, int32_t userId = Constants::UNSPECIFIED_USERID) override; 999 virtual ErrCode GetAllProxyDataInfos( 1000 std::vector<ProxyData> &proxyDatas, int32_t userId = Constants::UNSPECIFIED_USERID) override; 1001 virtual ErrCode GetSpecifiedDistributionType(const std::string &bundleName, 1002 std::string &specifiedDistributionType) override; 1003 virtual ErrCode BatchGetSpecifiedDistributionType(const std::vector<std::string> &bundleNames, 1004 std::vector<BundleDistributionType> &specifiedDistributionTypes) override; 1005 virtual ErrCode GetAdditionalInfo(const std::string &bundleName, 1006 std::string &additionalInfo) override; 1007 virtual ErrCode BatchGetAdditionalInfo(const std::vector<std::string> &bundleNames, 1008 std::vector<BundleAdditionalInfo> &additionalInfos) override; 1009 virtual ErrCode GetAdditionalInfoForAllUser(const std::string &bundleName, 1010 std::string &additionalInfo) override; 1011 virtual ErrCode SetExtNameOrMIMEToApp(const std::string &bundleName, const std::string &moduleName, 1012 const std::string &abilityName, const std::string &extName, const std::string &mimeType) override; 1013 virtual ErrCode DelExtNameOrMIMEToApp(const std::string &bundleName, const std::string &moduleName, 1014 const std::string &abilityName, const std::string &extName, const std::string &mimeType) override; 1015 virtual bool QueryDataGroupInfos(const std::string &bundleName, int32_t userId, 1016 std::vector<DataGroupInfo> &infos) override; 1017 virtual bool GetGroupDir(const std::string &dataGroupId, std::string &dir) override; 1018 virtual bool QueryAppGalleryBundleName(std::string &bundleName) override; 1019 virtual ErrCode ResetAOTCompileStatus(const std::string &bundleName, const std::string &moduleName, 1020 int32_t triggerMode) override; 1021 void SetBrokerServiceStatus(bool isServiceExisted); 1022 1023 /** 1024 * @brief Query extension info with type name. 1025 * @param Want Indicates the information of extension info. 1026 * @param extensionTypeName Indicates the type of the extension. 1027 * @param flag Indicates the query flag which will fliter any specified stuff in the extension info. 1028 * @param userId Indicates the userId in the system. 1029 * @param extensionInfos Indicates the obtained extensions. 1030 * @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise. 1031 */ 1032 virtual ErrCode QueryExtensionAbilityInfosWithTypeName(const Want &want, const std::string &extensionTypeName, 1033 const int32_t flag, const int32_t userId, std::vector<ExtensionAbilityInfo> &extensionInfos) override; 1034 1035 /** 1036 * @brief Query extension info only with type name. 1037 * @param extensionTypeName Indicates the type of the extension. 1038 * @param flag Indicates the query flag which will fliter any specified stuff in the extension info. 1039 * @param userId Indicates the userId in the system. 1040 * @param extensionInfos Indicates the obtained extensions. 1041 * @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise. 1042 */ 1043 virtual ErrCode QueryExtensionAbilityInfosOnlyWithTypeName(const std::string &extensionTypeName, 1044 const uint32_t flag, const int32_t userId, std::vector<ExtensionAbilityInfo> &extensionInfos) override; 1045 1046 virtual ErrCode GetJsonProfile(ProfileType profileType, const std::string &bundleName, 1047 const std::string &moduleName, std::string &profile, int32_t userId = Constants::UNSPECIFIED_USERID) override; 1048 1049 virtual sptr<IBundleResource> GetBundleResourceProxy() override; 1050 1051 virtual ErrCode GetRecoverableApplicationInfo( 1052 std::vector<RecoverableApplicationInfo> &recoverableApplicaitons) override; 1053 1054 virtual ErrCode GetUninstalledBundleInfo(const std::string bundleName, BundleInfo &bundleInfo) override; 1055 1056 virtual ErrCode SetAdditionalInfo(const std::string &bundleName, const std::string &additionalInfo) override; 1057 1058 virtual ErrCode CreateBundleDataDir(int32_t userId) override; 1059 1060 virtual ErrCode MigrateData( 1061 const std::vector<std::string> &sourcePaths, const std::string &destinationPath) override; 1062 1063 virtual ErrCode CreateBundleDataDirWithEl(int32_t userId, DataDirEl dirEl) override; 1064 1065 /** 1066 * @brief Check whether the link can be opened. 1067 * @param link Indicates the link to be opened. 1068 * @param canOpen Indicates whether the link can be opened. 1069 * @return Returns result of the operation. 1070 */ 1071 virtual ErrCode CanOpenLink( 1072 const std::string &link, bool &canOpen) override; 1073 1074 virtual ErrCode GetOdid(std::string &odid) override; 1075 1076 /** 1077 * @brief Get preinstalled application infos. 1078 * @param preinstalledApplicationInfos Indicates all of the obtained PreinstalledApplicationInfo objects. 1079 * @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise. 1080 */ 1081 virtual ErrCode GetAllPreinstalledApplicationInfos( 1082 std::vector<PreinstalledApplicationInfo> &preinstalledApplicationInfos) override; 1083 virtual ErrCode GetAllBundleInfoByDeveloperId(const std::string &developerId, 1084 std::vector<BundleInfo> &bundleInfos, int32_t userId) override; 1085 1086 virtual ErrCode GetDeveloperIds(const std::string &appDistributionType, 1087 std::vector<std::string> &developerIdList, int32_t userId) override; 1088 1089 virtual ErrCode SwitchUninstallState(const std::string &bundleName, const bool &state, 1090 bool isNeedSendNotify) override; 1091 1092 virtual ErrCode QueryAbilityInfoByContinueType(const std::string &bundleName, const std::string &continueType, 1093 AbilityInfo &abilityInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override; 1094 1095 virtual ErrCode QueryCloneAbilityInfo(const ElementName &element, 1096 int32_t flags, int32_t appIndex, AbilityInfo &abilityInfo, int32_t userId) override; 1097 1098 virtual ErrCode GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appIndex, 1099 BundleInfo &bundleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override; 1100 1101 virtual ErrCode GetCloneBundleInfoExt(const std::string &bundleName, uint32_t flags, int32_t appIndex, 1102 int32_t userId, BundleInfo &bundleInfo) override; 1103 1104 virtual ErrCode GetCloneAppIndexes(const std::string &bundleName, std::vector<int32_t> &appIndexes, 1105 int32_t userId = Constants::UNSPECIFIED_USERID) override; 1106 1107 virtual ErrCode GetLaunchWant(Want &want) override; 1108 1109 virtual ErrCode QueryCloneExtensionAbilityInfoWithAppIndex(const ElementName &elementName, int32_t flags, 1110 int32_t appIndex, ExtensionAbilityInfo &extensionAbilityInfo, 1111 int32_t userId = Constants::UNSPECIFIED_USERID) override; 1112 1113 virtual ErrCode GetSignatureInfoByBundleName(const std::string &bundleName, SignatureInfo &signatureInfo) override; 1114 1115 virtual ErrCode GetSignatureInfoByUid(const int32_t uid, SignatureInfo &signatureInfo) override; 1116 1117 virtual ErrCode AddDesktopShortcutInfo(const ShortcutInfo &shortcutInfo, int32_t userId) override; 1118 1119 virtual ErrCode DeleteDesktopShortcutInfo(const ShortcutInfo &shortcutInfo, int32_t userId) override; 1120 1121 virtual ErrCode GetAllDesktopShortcutInfo(int32_t userId, std::vector<ShortcutInfo> &shortcutInfos) override; 1122 1123 virtual ErrCode GetOdidByBundleName(const std::string &bundleName, std::string &odid) override; 1124 1125 virtual ErrCode UpdateAppEncryptedStatus(const std::string &bundleName, 1126 bool isExisted, int32_t appIndex = 0) override; 1127 virtual bool GreatOrEqualTargetAPIVersion(int32_t platformVersion, 1128 int32_t minorVersion, int32_t patchVersion) override; 1129 1130 /** 1131 * @brief Obtains continuable BundleInfo of all bundles available in the system. 1132 * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be returned. 1133 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 1134 * @param userId Indicates the user ID. 1135 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 1136 */ 1137 virtual bool GetBundleInfosForContinuation(int32_t flags, 1138 std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) override; 1139 1140 /** 1141 * @brief Get a list of application package names that continue the specified package name. 1142 * @param continueBundleName The package name that is being continued. 1143 * @param bundleNames Continue the list of specified package names. 1144 * @param userId Indicates the user ID. 1145 * @return Returns ERR_OK if successfully obtained; returns error code otherwise. 1146 */ 1147 virtual ErrCode GetContinueBundleNames(const std::string &continueBundleName, std::vector<std::string> &bundleNames, 1148 int32_t userId = Constants::UNSPECIFIED_USERID) override; 1149 1150 virtual ErrCode IsBundleInstalled(const std::string &bundleName, int32_t userId, 1151 int32_t appIndex, bool &isInstalled) override; 1152 1153 virtual ErrCode GetCompatibleDeviceTypeNative(std::string &deviceType) override; 1154 virtual ErrCode GetCompatibleDeviceType(const std::string &bundleName, std::string &deviceType) override; 1155 virtual ErrCode GetBundleNameByAppId(const std::string &appId, std::string &bundleName) override; 1156 virtual ErrCode GetAllPluginInfo(const std::string &hostBundleName, int32_t userId, 1157 std::vector<PluginBundleInfo> &pluginBundleInfos) override; 1158 virtual ErrCode GetPluginInfosForSelf(std::vector<PluginBundleInfo> &pluginBundleInfos) override; 1159 virtual ErrCode GetDirByBundleNameAndAppIndex(const std::string &bundleName, const int32_t appIndex, 1160 std::string &dataDir) override; 1161 virtual ErrCode GetAllBundleDirs(int32_t userId, std::vector<BundleDir> &bundleDirs) override; 1162 virtual ErrCode SetAppDistributionTypes(std::set<AppDistributionTypeEnum> &appDistributionTypeEnums) override; 1163 virtual ErrCode GetPluginAbilityInfo(const std::string &hostBundleName, const std::string &pluginBundleName, 1164 const std::string &pluginModuleName, const std::string &pluginAbilityName, 1165 const int32_t userId, AbilityInfo &abilityInfo) override; 1166 virtual ErrCode GetPluginHapModuleInfo(const std::string &hostBundleName, const std::string &pluginBundleName, 1167 const std::string &pluginModuleName, const int32_t userId, HapModuleInfo &hapModuleInfo) override; 1168 virtual ErrCode RegisterPluginEventCallback(const sptr<IBundleEventCallback> &pluginEventCallback) override; 1169 virtual ErrCode UnregisterPluginEventCallback(const sptr<IBundleEventCallback> &pluginEventCallback) override; 1170 virtual ErrCode GetAllShortcutInfoForSelf(std::vector<ShortcutInfo> &shortcutInfos) override; 1171 virtual ErrCode GetPluginInfo(const std::string &hostBundleName, const std::string &pluginBundleName, 1172 const int32_t userId, PluginBundleInfo &pluginBundleInfo) override; 1173 virtual ErrCode GetTestRunner(const std::string &bundleName, const std::string &moduleName, 1174 ModuleTestRunner &testRunner) override; 1175 1176 private: 1177 bool GetLabelByBundleName(const std::string &bundleName, int32_t userId, std::string &label); 1178 bool GetAllBundleLabel(int32_t userId, std::string &labels); 1179 ErrCode MigrateDataUserAuthentication(); 1180 ErrCode MigrateDataParameterCheck(std::vector<std::string> &sourcePaths, std::string &destinationPath); 1181 ErrCode CheckSandboxPath(std::vector<std::string> &sourcePaths, std::string &destinationPath); 1182 const std::shared_ptr<BundleDataMgr> GetDataMgrFromService(); 1183 #ifdef DISTRIBUTED_BUNDLE_FRAMEWORK 1184 const OHOS::sptr<IDistributedBms> GetDistributedBundleMgrService(); 1185 #endif 1186 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL 1187 const std::shared_ptr<BundleConnectAbilityMgr> GetConnectAbilityMgrFromService(); 1188 #endif 1189 bool GetBundleUserInfo( 1190 const std::string &bundleName, int32_t userId, InnerBundleUserInfo &innerBundleUserInfo); 1191 bool GetBundleUserInfos( 1192 const std::string &bundleName, std::vector<InnerBundleUserInfo> &innerBundleUserInfos); 1193 bool GetShortcutInfos( 1194 const std::string &bundleName, int32_t userId, std::vector<ShortcutInfo> &shortcutInfos); 1195 bool DumpAllBundleInfoNames(int32_t userId, std::string &result); 1196 bool DumpAllBundleInfoNamesByUserId(int32_t userId, std::string &result); 1197 bool DumpDebugBundleInfoNames(int32_t userId, std::string &result); 1198 bool DumpDebugBundleInfoNamesByUserId(int32_t userId, std::string &result); 1199 bool DumpBundleInfo(const std::string &bundleName, int32_t userId, std::string &result); 1200 bool DumpShortcutInfo(const std::string &bundleName, int32_t userId, std::string &result); 1201 std::set<int32_t> GetExistsCommonUserIs(); 1202 bool VerifyDependency(const std::string &sharedBundleName); 1203 void CleanBundleCacheTask(const std::string &bundleName, const sptr<ICleanCacheCallback> cleanCacheCallback, 1204 const std::shared_ptr<BundleDataMgr> &dataMgr, int32_t userId, int32_t appIndex = 0); 1205 ErrCode CleanBundleCacheFilesGetCleanSize(const std::string &bundleName, 1206 int32_t userId, uint64_t &cleanCacheSize); 1207 void CleanBundleCacheTaskGetCleanSize(const std::string &bundleName, 1208 int32_t userId, uint64_t &cleanCacheSize, int32_t callingUid, const std::string &callingBundleName); 1209 void NotifyBundleStatus(const NotifyBundleEvents &installRes); 1210 ErrCode GetBundleArchiveInfoBySandBoxPath( 1211 const std::string &hapFilePath, int32_t flags, BundleInfo &bundleInfo, bool fromV9 = false); 1212 bool IsPreInstallApp(const std::string &bundleName); 1213 bool GetPreferableBundleInfoFromHapPaths(const std::vector<std::string> &hapPaths, 1214 BundleInfo &bundleInfo); 1215 bool IsBundleExist(const std::string &bundleName); 1216 ErrCode ClearCache(const std::string &bundleName, const sptr<ICleanCacheCallback> cleanCacheCallback, 1217 int32_t userId, int32_t callingUid, const std::string &callingBundleName); 1218 void FilterAbilityInfos(std::vector<AbilityInfo> &abilityInfos); 1219 void SetProvisionInfoToInnerBundleInfo(const std::string &hapPath, InnerBundleInfo &info); 1220 bool CheckAppIndex(const std::string &bundleName, int32_t userId, int32_t appIndex); 1221 bool CheckCanSetEnable(const std::string &bundleName); 1222 bool IsAppLinking(int32_t flags) const; 1223 std::string GetCallerName(); 1224 void CallAbilityManager(int32_t resultCode, const Want &want, int32_t userId, const sptr<IRemoteObject> &callBack); 1225 bool GetPluginBundleInfo(const std::string &bundleName, const int32_t userId, 1226 std::unordered_map<std::string, PluginBundleInfo> &pluginBundleInfos); 1227 void AddPreinstalledApplicationInfo(PreInstallBundleInfo &preInstallBundleInfo, 1228 std::vector<PreinstalledApplicationInfo> &preinstalledApplicationInfos); 1229 void GetAbilityLabelInfo(std::vector<AbilityInfo> &abilityInfos); 1230 void GetApplicationLabelInfo(std::vector<AbilityInfo> &abilityInfos); 1231 bool GetLabelFromCache(const std::string &cacheKey, const std::string &abilityName, 1232 const std::unordered_map<std::string, std::vector<LauncherAbilityResourceInfo>> &resourceCache, 1233 std::string &label); 1234 bool SendQueryBundleInfoEvent(QueryEventInfo &query, int64_t intervalTime, bool reportNow); 1235 bool GetCallingInfo(int32_t callingUid, std::string &callingBundleName, std::string &callingAppId); 1236 1237 std::atomic<bool> isBrokerServiceExisted_ = false; 1238 }; 1239 } // namespace AppExecFwk 1240 } // namespace OHOS 1241 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_MGR_HOST_IMPL_H 1242