1 /* 2 * Copyright (c) 2021-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 FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_MGR_HOST_IMPL_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_MGR_HOST_IMPL_H 18 19 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL 20 #include "bundle_connect_ability_mgr.h" 21 #endif 22 #include "bundle_common_event_mgr.h" 23 #include "bundle_data_mgr.h" 24 #include "bundle_mgr_host.h" 25 #include "bundle_mgr_service_event_handler.h" 26 #ifdef DISTRIBUTED_BUNDLE_FRAMEWORK 27 #include "distributed_bms_interface.h" 28 #endif 29 #include "inner_bundle_user_info.h" 30 31 namespace OHOS { 32 namespace AppExecFwk { 33 class BundleMgrHostImpl : public BundleMgrHost { 34 public: BundleMgrHostImpl()35 BundleMgrHostImpl() 36 { 37 auto myRunner = EventRunner::Create(BUNDLE_MGR_THREAD); 38 handler_ = std::make_shared<BMSEventHandler>(myRunner); 39 } ~BundleMgrHostImpl()40 virtual ~BundleMgrHostImpl() {} 41 /** 42 * @brief Obtains the ApplicationInfo based on a given bundle name. 43 * @param appName Indicates the application bundle name to be queried. 44 * @param flag Indicates the flag used to specify information contained 45 * in the ApplicationInfo object that will be returned. 46 * @param userId Indicates the user ID. 47 * @param appInfo Indicates the obtained ApplicationInfo object. 48 * @return Returns true if the application is successfully obtained; returns false otherwise. 49 */ 50 virtual bool GetApplicationInfo( 51 const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo) override; 52 /** 53 * @brief Obtains the ApplicationInfo based on a given bundle name. 54 * @param appName Indicates the application bundle name to be queried. 55 * @param flags Indicates the flag used to specify information contained 56 * in the ApplicationInfo object that will be returned. 57 * @param userId Indicates the user ID. 58 * @param appInfo Indicates the obtained ApplicationInfo object. 59 * @return Returns true if the application is successfully obtained; returns false otherwise. 60 */ 61 virtual bool GetApplicationInfo( 62 const std::string &appName, int32_t flags, int32_t userId, ApplicationInfo &appInfo) override; 63 /** 64 * @brief Obtains the ApplicationInfo based on a given bundle name. 65 * @param appName Indicates the application bundle name to be queried. 66 * @param flags Indicates the flag used to specify information contained 67 * in the ApplicationInfo object that will be returned. 68 * @param userId Indicates the user ID. 69 * @param appInfo Indicates the obtained ApplicationInfo object. 70 * @return Returns ERR_OK if the application is successfully obtained; returns error code otherwise. 71 */ 72 virtual ErrCode GetApplicationInfoV9( 73 const std::string &appName, int32_t flags, int32_t userId, ApplicationInfo &appInfo) override; 74 /** 75 * @brief Obtains information about all installed applications of a specified user. 76 * @param flag Indicates the flag used to specify information contained 77 * in the ApplicationInfo objects that will be returned. 78 * @param userId Indicates the user ID. 79 * @param appInfos Indicates all of the obtained ApplicationInfo objects. 80 * @return Returns true if the applications is successfully obtained; returns false otherwise. 81 */ 82 virtual bool GetApplicationInfos( 83 const ApplicationFlag flag, const int userId, std::vector<ApplicationInfo> &appInfos) override; 84 /** 85 * @brief Obtains information about all installed applications of a specified user. 86 * @param flags Indicates the flag used to specify information contained 87 * in the ApplicationInfo objects that will be returned. 88 * @param userId Indicates the user ID. 89 * @param appInfos Indicates all of the obtained ApplicationInfo objects. 90 * @return Returns true if the applications is successfully obtained; returns false otherwise. 91 */ 92 virtual bool GetApplicationInfos( 93 int32_t flags, int32_t userId, std::vector<ApplicationInfo> &appInfos) override; 94 /** 95 * @brief Obtains information about all installed applications of a specified user. 96 * @param flags Indicates the flag used to specify information contained 97 * in the ApplicationInfo objects that will be returned. 98 * @param userId Indicates the user ID. 99 * @param appInfos Indicates all of the obtained ApplicationInfo objects. 100 * @return Returns ERR_OK if the applications is successfully obtained; returns error code otherwise. 101 */ 102 virtual ErrCode GetApplicationInfosV9( 103 int32_t flags, int32_t userId, std::vector<ApplicationInfo> &appInfos) override; 104 /** 105 * @brief Obtains the BundleInfo based on a given bundle name. 106 * @param bundleName Indicates the application bundle name to be queried. 107 * @param flag Indicates the information contained in the BundleInfo object to be returned. 108 * @param bundleInfo Indicates the obtained BundleInfo object. 109 * @param userId Indicates the user ID. 110 * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. 111 */ 112 virtual bool GetBundleInfo(const std::string &bundleName, 113 const BundleFlag flag, BundleInfo &bundleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override; 114 /** 115 * @brief Obtains the BundleInfo based on a given bundle name. 116 * @param bundleName Indicates the application bundle name to be queried. 117 * @param flags Indicates the information contained in the BundleInfo object to be returned. 118 * @param bundleInfo Indicates the obtained BundleInfo object. 119 * @param userId Indicates the user ID. 120 * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. 121 */ 122 virtual bool GetBundleInfo(const std::string &bundleName, 123 int32_t flags, BundleInfo &bundleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override; 124 /** 125 * @brief Obtains the BundleInfo based on a given bundle name. 126 * @param bundleName Indicates the application bundle name to be queried. 127 * @param flags Indicates the information contained in the BundleInfo object to be returned. 128 * @param bundleInfo Indicates the obtained BundleInfo object. 129 * @param userId Indicates the user ID. 130 * @return Returns ERR_OK if the BundleInfo is successfully obtained; returns error code otherwise. 131 */ 132 virtual ErrCode GetBundleInfoV9(const std::string &bundleName, 133 int32_t flags, BundleInfo &bundleInfo, int32_t userId) override; 134 /** 135 * @brief Obtains the BundleInfo based on a given bundle name. 136 * @param flags Indicates the information contained in the BundleInfo object to be returned. 137 * @param bundleInfo Indicates the obtained BundleInfo object. 138 * @return Returns ERR_OK if the BundleInfo is successfully obtained; returns error code otherwise. 139 */ 140 virtual ErrCode GetBundleInfoForSelf(int32_t flags, BundleInfo &bundleInfo) override; 141 /** 142 * @brief Obtains the BundlePackInfo based on a given bundle name. 143 * @param bundleName Indicates the application bundle name to be queried. 144 * @param flags Indicates the information contained in the BundleInfo object to be returned. 145 * @param BundlePackInfo Indicates the obtained BundlePackInfo object. 146 * @param userId Indicates the user ID. 147 * @return Returns ERR_OK if the BundlePackInfo is successfully obtained; returns other ErrCode otherwise. 148 */ 149 virtual ErrCode GetBundlePackInfo(const std::string &bundleName, const BundlePackFlag flag, 150 BundlePackInfo &bundlePackInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override; 151 152 /** 153 * @brief Obtains the BundlePackInfo based on a given bundle name. 154 * @param bundleName Indicates the application bundle name to be queried. 155 * @param flags Indicates the information contained in the BundleInfo object to be returned. 156 * @param BundlePackInfo Indicates the obtained BundlePackInfo object. 157 * @param userId Indicates the user ID. 158 * @return Returns ERR_OK if the BundlePackInfo is successfully obtained; returns other ErrCode otherwise. 159 */ 160 virtual ErrCode GetBundlePackInfo(const std::string &bundleName, int32_t flags, BundlePackInfo &bundlePackInfo, 161 int32_t userId = Constants::UNSPECIFIED_USERID) override; 162 163 /** 164 * @brief Obtains BundleInfo of all bundles available in the system. 165 * @param flag Indicates the flag used to specify information contained in the BundleInfo that will be returned. 166 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 167 * @param userId Indicates the user ID. 168 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 169 */ 170 virtual bool GetBundleInfos(const BundleFlag flag, 171 std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) override; 172 /** 173 * @brief Obtains BundleInfo of all bundles available in the system. 174 * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be returned. 175 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 176 * @param userId Indicates the user ID. 177 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 178 */ 179 virtual bool GetBundleInfos(int32_t flags, 180 std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) override; 181 /** 182 * @brief Obtains BundleInfo of all bundles available in the system. 183 * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be returned. 184 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 185 * @param userId Indicates the user ID. 186 * @return Returns ERR_OK if the BundleInfos is successfully obtained; returns error code otherwise. 187 */ 188 virtual ErrCode GetBundleInfosV9(int32_t flags, std::vector<BundleInfo> &bundleInfos, int32_t userId) override; 189 /** 190 * @brief Obtains the application UID based on the given bundle name and user ID. 191 * @param bundleName Indicates the bundle name of the application. 192 * @param userId Indicates the user ID. 193 * @return Returns the uid if successfully obtained; returns -1 otherwise. 194 */ 195 virtual bool GetBundleNameForUid(const int uid, std::string &bundleName) override; 196 /** 197 * @brief Obtains all bundle names of a specified application based on the given application UID. 198 * @param uid Indicates the uid. 199 * @param bundleNames Indicates the obtained bundle names. 200 * @return Returns true if the bundle names is successfully obtained; returns false otherwise. 201 */ 202 virtual bool GetBundlesForUid(const int uid, std::vector<std::string> &bundleNames) override; 203 /** 204 * @brief Obtains the formal name associated with the given UID. 205 * @param uid Indicates the uid. 206 * @param name Indicates the obtained formal name. 207 * @return Returns ERR_OK if execute success; returns errCode otherwise. 208 */ 209 virtual ErrCode GetNameForUid(const int uid, std::string &name) override; 210 /** 211 * @brief Obtains an array of all group IDs associated with a specified bundle. 212 * @param bundleName Indicates the bundle name. 213 * @param gids Indicates the group IDs associated with the specified bundle. 214 * @return Returns true if the gids is successfully obtained; returns false otherwise. 215 */ 216 virtual bool GetBundleGids(const std::string &bundleName, std::vector<int> &gids) override; 217 /** 218 * @brief Obtains an array of all group IDs associated with the given bundle name and UID. 219 * @param bundleName Indicates the bundle name. 220 * @param uid Indicates the uid. 221 * @param gids Indicates the group IDs associated with the specified bundle. 222 * @return Returns true if the gids is successfully obtained; returns false otherwise. 223 */ 224 virtual bool GetBundleGidsByUid(const std::string &bundleName, const int &uid, std::vector<int> &gids) override; 225 /** 226 * @brief Check whether the app is system app by it's UID. 227 * @param uid Indicates the uid. 228 * @return Returns true if the bundle is a system application; returns false otherwise. 229 */ 230 virtual bool CheckIsSystemAppByUid(const int uid) override; 231 /** 232 * @brief Obtains the BundleInfo of application bundles based on the specified metaData. 233 * @param metaData Indicates the metadata to get in the bundle. 234 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 235 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 236 */ 237 virtual bool GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos) override; 238 /** 239 * @brief Query the AbilityInfo by the given Want. 240 * @param want Indicates the information of the ability. 241 * @param abilityInfo Indicates the obtained AbilityInfo object. 242 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 243 */ 244 virtual bool QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo) override; 245 246 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL 247 /** 248 * @brief Query the AbilityInfo by the given Want. 249 * @param want Indicates the information of the ability. 250 * @param abilityInfo Indicates the obtained AbilityInfo object. 251 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 252 */ 253 virtual bool QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, 254 AbilityInfo &abilityInfo, const sptr<IRemoteObject> &callBack) override; 255 256 /** 257 * @brief Silent install by the given Want. 258 * @param want Indicates the information of the want. 259 * @param userId Indicates the user ID. 260 * @param callBack Indicates the callback to be invoked for return the operation result. 261 * @return Returns true if silent install successfully; returns false otherwise. 262 */ 263 virtual bool SilentInstall(const Want &want, int32_t userId, const sptr<IRemoteObject> &callBack) override; 264 265 virtual bool CheckAbilityEnableInstall( 266 const Want &want, int32_t missionId, int32_t userId, const sptr<IRemoteObject> &callback) override; 267 #endif 268 /** 269 * @brief Obtains the AbilityInfo based on a given bundle name through the proxy object. 270 * @param bundleName Indicates the application bundle name to be queried. 271 * @param abilityName Indicates the application ability name to be queried. 272 * @param abilityInfo Indicates the obtained AbilityInfo object. 273 * @return Returns true if the application is successfully obtained; returns false otherwise. 274 */ 275 virtual bool GetAbilityInfo( 276 const std::string &bundleName, const std::string &abilityName, AbilityInfo &abilityInfo) override; 277 /** 278 * @brief Obtains the AbilityInfo based on a given bundle name through the proxy object. 279 * @param bundleName Indicates the application bundle name to be queried. 280 * @param moduleName Indicates the module name to be queried. 281 * @param abilityName Indicates the application ability name to be queried. 282 * @param abilityInfo Indicates the obtained AbilityInfo object. 283 * @return Returns true if the application is successfully obtained; returns false otherwise. 284 */ 285 virtual bool GetAbilityInfo( 286 const std::string &bundleName, const std::string &moduleName, 287 const std::string &abilityName, AbilityInfo &abilityInfo) override; 288 /** 289 * @brief Query the AbilityInfo by the given Want. 290 * @param want Indicates the information of the ability. 291 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 292 * @param userId Indicates the user ID. 293 * @param abilityInfo Indicates the obtained AbilityInfo object. 294 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 295 */ 296 virtual bool QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo) override; 297 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL 298 /** 299 * @brief Upgrade atomic service 300 * @param want Indicates the information of the ability. 301 * @param userId Indicates the user ID. 302 */ 303 virtual void UpgradeAtomicService(const Want &want, int32_t userId) override; 304 305 virtual void ProcessPreload(const Want &want) override; 306 #endif 307 /** 308 * @brief Query the AbilityInfo of list by the given Want. 309 * @param want Indicates the information of the ability. 310 * @param abilityInfos Indicates the obtained AbilityInfos object. 311 * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise. 312 */ 313 virtual bool QueryAbilityInfos(const Want &want, std::vector<AbilityInfo> &abilityInfos) override; 314 /** 315 * @brief Query the AbilityInfo of list by the given Want. 316 * @param want Indicates the information of the ability. 317 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 318 * @param userId Indicates the user ID. 319 * @param abilityInfos Indicates the obtained AbilityInfos object. 320 * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise. 321 */ 322 virtual bool QueryAbilityInfos( 323 const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) override; 324 /** 325 * @brief Query the AbilityInfo of list by the given Want. 326 * @param want Indicates the information of the ability. 327 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 328 * @param userId Indicates the user ID. 329 * @param abilityInfos Indicates the obtained AbilityInfos object. 330 * @return Returns ERR_OK if the AbilityInfos is successfully obtained; returns errCode otherwise. 331 */ 332 virtual ErrCode QueryAbilityInfosV9( 333 const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) override; 334 /** 335 * @brief Query the AbilityInfo of list of all service on launcher. 336 * @param userId Indicates the information of the user. 337 * @param abilityInfos Indicates the obtained AbilityInfos object. 338 * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise. 339 */ 340 virtual bool QueryAllAbilityInfos( 341 const Want &want, int32_t userId, std::vector<AbilityInfo> &abilityInfos) override; 342 /** 343 * @brief Query the AbilityInfo by ability.uri in config.json. 344 * @param abilityUri Indicates the uri of the ability. 345 * @param abilityInfo Indicates the obtained AbilityInfo object. 346 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 347 */ 348 virtual bool QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo) override; 349 /** 350 * @brief Query the AbilityInfo by ability.uri in config.json. 351 * @param abilityUri Indicates the uri of the ability. 352 * @param abilityInfos Indicates the obtained AbilityInfos object. 353 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 354 */ 355 virtual bool QueryAbilityInfosByUri( 356 const std::string &abilityUri, std::vector<AbilityInfo> &abilityInfos) override; 357 /** 358 * @brief Query the AbilityInfo by ability.uri in config.json through the proxy object. 359 * @param abilityUri Indicates the uri of the ability. 360 * @param userId Indicates the user ID. 361 * @param abilityInfo Indicates the obtained AbilityInfo object. 362 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 363 */ 364 virtual bool QueryAbilityInfoByUri( 365 const std::string &abilityUri, int32_t userId, AbilityInfo &abilityInfo) override; 366 /** 367 * @brief Obtains the BundleInfo of all keep-alive applications in the system. 368 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 369 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 370 */ 371 virtual bool QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos) override; 372 /** 373 * @brief Obtains the label of a specified ability. 374 * @param bundleName Indicates the bundle name. 375 * @param abilityName Indicates the ability name. 376 * @return Returns the label of the ability if exist; returns empty string otherwise. 377 */ 378 virtual std::string GetAbilityLabel(const std::string &bundleName, const std::string &abilityName) override; 379 /** 380 * @brief Obtains the label of a specified ability. 381 * @param bundleName Indicates the bundle name. 382 * @param moduleName Indicates the module name. 383 * @param abilityName Indicates the ability name. 384 * @param label Indicates the obtained label. 385 * @return Returns ERR_OK if called successfully; returns error code otherwise. 386 */ 387 virtual ErrCode GetAbilityLabel(const std::string &bundleName, const std::string &moduleName, 388 const std::string &abilityName, std::string &label) override; 389 /** 390 * @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP). 391 * @param hapFilePath Indicates the absolute file path of the HAP. 392 * @param flag Indicates the information contained in the BundleInfo object to be returned. 393 * @param bundleInfo Indicates the obtained BundleInfo object. 394 * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. 395 */ 396 virtual bool GetBundleArchiveInfo( 397 const std::string &hapFilePath, const BundleFlag flag, BundleInfo &bundleInfo) override; 398 /** 399 * @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP). 400 * @param hapFilePath Indicates the absolute file path of the HAP. 401 * @param flags Indicates the information contained in the BundleInfo object to be returned. 402 * @param bundleInfo Indicates the obtained BundleInfo object. 403 * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. 404 */ 405 virtual bool GetBundleArchiveInfo( 406 const std::string &hapFilePath, int32_t flags, BundleInfo &bundleInfo) override; 407 /** 408 * @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP). 409 * @param hapFilePath Indicates the absolute file path of the HAP. 410 * @param flags Indicates the information contained in the BundleInfo object to be returned. 411 * @param bundleInfo Indicates the obtained BundleInfo object. 412 * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise. 413 */ 414 virtual ErrCode GetBundleArchiveInfoV9( 415 const std::string &hapFilePath, int32_t flags, BundleInfo &bundleInfo) override; 416 /** 417 * @brief Obtain the HAP module info of a specific ability. 418 * @param abilityInfo Indicates the ability. 419 * @param hapModuleInfo Indicates the obtained HapModuleInfo object. 420 * @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise. 421 */ 422 virtual bool GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo) override; 423 /** 424 * @brief Obtain the HAP module info of a specific ability through the proxy object. 425 * @param abilityInfo Indicates the ability. 426 * @param userId Indicates the userId. 427 * @param hapModuleInfo Indicates the obtained HapModuleInfo object. 428 * @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise. 429 */ 430 virtual bool GetHapModuleInfo( 431 const AbilityInfo &abilityInfo, int32_t userId, HapModuleInfo &hapModuleInfo) override; 432 /** 433 * @brief Obtains the Want for starting the main ability of an application based on the given bundle name. 434 * @param bundleName Indicates the bundle name. 435 * @param want Indicates the obtained launch Want object. 436 * @param userId Indicates the userId. 437 * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise. 438 */ 439 virtual ErrCode GetLaunchWantForBundle( 440 const std::string &bundleName, Want &want, int32_t userId = Constants::UNSPECIFIED_USERID) override; 441 /** 442 * @brief Checks whether the publickeys of two bundles are the same. 443 * @param firstBundleName Indicates the first bundle name. 444 * @param secondBundleName Indicates the second bundle name. 445 * @return Returns SIGNATURE_UNKNOWN_BUNDLE if at least one of the given bundles is not found; 446 * returns SIGNATURE_NOT_MATCHED if their publickeys are different; 447 * returns SIGNATURE_MATCHED if their publickeys are the same. 448 */ 449 virtual int CheckPublicKeys(const std::string &firstBundleName, const std::string &secondBundleName) override; 450 /** 451 * @brief Obtains detailed information about a specified permission. 452 * @param permissionName Indicates the name of the ohos permission. 453 * @param permissionDef Indicates the object containing detailed information about the given ohos permission. 454 * @return Returns true if the PermissionDef object is successfully obtained; returns false otherwise. 455 */ 456 virtual ErrCode GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef) override; 457 /** 458 * @brief Checks whether the system has a specified capability. 459 * @param capName Indicates the name of the system feature to check. 460 * @return Returns true if the given feature specified by name is available in the system; returns false otherwise. 461 */ 462 virtual bool HasSystemCapability(const std::string &capName) override; 463 /** 464 * @brief Obtains the capabilities that are available in the system. 465 * @param systemCaps Indicates the list of capabilities available in the system. 466 * @return Returns true if capabilities in the system are successfully obtained; returns false otherwise. 467 */ 468 virtual bool GetSystemAvailableCapabilities(std::vector<std::string> &systemCaps) override; 469 /** 470 * @brief Checks whether the current device has been started in safe mode. 471 * @return Returns true if the device is in safe mode; returns false otherwise. 472 */ 473 virtual bool IsSafeMode() override; 474 /** 475 * @brief Clears cache data of a specified application. 476 * @param bundleName Indicates the bundle name of the application whose cache data is to be cleared. 477 * @param cleanCacheCallback Indicates the callback to be invoked for returning the operation result. 478 * @param userId description the user id. 479 * @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise. 480 */ 481 virtual ErrCode CleanBundleCacheFiles( 482 const std::string &bundleName, const sptr<ICleanCacheCallback> &cleanCacheCallback, 483 int32_t userId = Constants::UNSPECIFIED_USERID) override; 484 /** 485 * @brief Clears application running data of a specified application. 486 * @param bundleName Indicates the bundle name of the application whose data is to be cleared. 487 * @param userId Indicates the user id. 488 * @return Returns true if the data cleared successfully; returns false otherwise. 489 */ 490 virtual bool CleanBundleDataFiles(const std::string &bundleName, 491 const int userId = Constants::UNSPECIFIED_USERID) override; 492 /** 493 * @brief Register the specific bundle status callback. 494 * @param bundleStatusCallback Indicates the callback to be invoked for returning the bundle status changed result. 495 * @return Returns true if this function is successfully called; returns false otherwise. 496 */ 497 virtual bool RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override; 498 499 virtual bool RegisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback) override; 500 501 virtual bool UnregisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback) override; 502 /** 503 * @brief Clear the specific bundle status callback. 504 * @param bundleStatusCallback Indicates the callback to be cleared. 505 * @return Returns true if this function is successfully called; returns false otherwise. 506 */ 507 virtual bool ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override; 508 /** 509 * @brief Unregister all the callbacks of status changed. 510 * @return Returns true if this function is successfully called; returns false otherwise. 511 */ 512 virtual bool UnregisterBundleStatusCallback() override; 513 /** 514 * @brief Dump the bundle informations with specific flags. 515 * @param flag Indicates the information contained in the dump result. 516 * @param bundleName Indicates the bundle name if needed. 517 * @param userId Indicates the user ID. 518 * @param result Indicates the dump information result. 519 * @return Returns true if the dump result is successfully obtained; returns false otherwise. 520 */ 521 virtual bool DumpInfos( 522 const DumpFlag flag, const std::string &bundleName, int32_t userId, std::string &result) override; 523 /** 524 * @brief Checks whether a specified application is enabled. 525 * @param bundleName Indicates the bundle name of the application. 526 * @param isEnable Indicates the application status is enabled. 527 * @return Returns result of the operation. 528 */ 529 virtual ErrCode IsApplicationEnabled(const std::string &bundleName, bool &isEnable) override; 530 /** 531 * @brief Sets whether to enable a specified application. 532 * @param bundleName Indicates the bundle name of the application. 533 * @param isEnable Specifies whether to enable the application. 534 * The value true means to enable it, and the value false means to disable it. 535 * @param userId description the user id. 536 * @return Returns result of the operation. 537 */ 538 virtual ErrCode SetApplicationEnabled(const std::string &bundleName, bool isEnable, 539 int32_t userId = Constants::UNSPECIFIED_USERID) override; 540 /** 541 * @brief Sets whether to enable a specified ability through the proxy object. 542 * @param abilityInfo Indicates information about the ability to check. 543 * @param isEnable Indicates the ability status is enabled. 544 * @return Returns result of the operation. 545 */ 546 virtual ErrCode IsAbilityEnabled(const AbilityInfo &abilityInfo, bool &isEnable) override; 547 /** 548 * @brief Sets whether to enable a specified ability through the proxy object. 549 * @param abilityInfo Indicates information about the ability. 550 * @param isEnabled Specifies whether to enable the ability. 551 * The value true means to enable it, and the value false means to disable it. 552 * @param userId description the user id. 553 * @return Returns result of the operation. 554 */ 555 virtual ErrCode SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled, 556 int32_t userId = Constants::UNSPECIFIED_USERID) override; 557 /** 558 * @brief Obtains the interface used to install and uninstall bundles. 559 * @return Returns a pointer to IBundleInstaller class if exist; returns nullptr otherwise. 560 */ 561 virtual sptr<IBundleInstaller> GetBundleInstaller() override; 562 /** 563 * @brief Obtains the interface used to create or delete user. 564 * @return Returns a pointer to IBundleUserMgr class if exist; returns nullptr otherwise. 565 */ 566 virtual sptr<IBundleUserMgr> GetBundleUserMgr() override; 567 /** 568 * @brief Obtains the FormInfo objects provided by all applications on the device. 569 * @param formInfos List of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the 570 * device. 571 * @return Returns true if this function is successfully called; returns false otherwise. 572 */ 573 virtual bool GetAllFormsInfo(std::vector<FormInfo> &formInfos) override; 574 /** 575 * @brief Obtains the FormInfo objects provided by a specified application on the device. 576 * @param bundleName Indicates the bundle name of the application. 577 * @param formInfos List of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the 578 * device. 579 * @return Returns true if this function is successfully called; returns false otherwise. 580 */ 581 virtual bool GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfos) override; 582 /** 583 * @brief Obtains the FormInfo objects provided by a specified module name. 584 * @param bundleName Indicates the bundle name of the application. 585 * @param moduleName Indicates the module name of the application. 586 * @param formInfos List of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the 587 * device. 588 * @return Returns true if this function is successfully called; returns false otherwise. 589 */ 590 virtual bool GetFormsInfoByModule( 591 const std::string &bundleName, const std::string &moduleName, std::vector<FormInfo> &formInfos) override; 592 /** 593 * @brief Obtains the ShortcutInfo objects provided by a specified application on the device. 594 * @param bundleName Indicates the bundle name of the application. 595 * @param shortcutInfos List of ShortcutInfo objects if obtained. 596 * @return Returns true if GetShortcutInfos successfully; returns false otherwise. 597 */ 598 virtual bool GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos) override; 599 600 /** 601 * @brief Obtains the ShortcutInfo objects provided by a specified application on the device. 602 * @param bundleName Indicates the bundle name of the application. 603 * @param shortcutInfos List of ShortcutInfo objects if obtained. 604 * @return Returns errCode of result. 605 */ 606 virtual ErrCode GetShortcutInfoV9(const std::string &bundleName, 607 std::vector<ShortcutInfo> &shortcutInfos) override; 608 /** 609 * @brief Obtains the CommonEventInfo objects provided by an event key on the device. 610 * @param eventKey Indicates the event of the subscribe. 611 * @param commonEventInfos List of CommonEventInfo objects if obtained. 612 * @return Returns true if this function is successfully called; returns false otherwise. 613 */ 614 virtual bool GetAllCommonEventInfo(const std::string &eventKey, 615 std::vector<CommonEventInfo> &commonEventInfos) override; 616 /** 617 * @brief Obtains the DistributedBundleInfo based on a given bundle name and networkId. 618 * @param networkId Indicates the networkId of remote device. 619 * @param bundleName Indicates the application bundle name to be queried. 620 * @param distributedBundleInfo Indicates the obtained DistributedBundleInfo object. 621 * @return Returns true if the DistributedBundleInfo is successfully obtained; returns false otherwise. 622 */ 623 virtual bool GetDistributedBundleInfo(const std::string &networkId, const std::string &bundleName, 624 DistributedBundleInfo &distributedBundleInfo) override; 625 /** 626 * @brief Get app privilege level. 627 * @param bundleName Indicates the bundle name of the app privilege level. 628 * @param userId Indicates the user id. 629 * @return Returns app privilege level. 630 */ 631 virtual std::string GetAppPrivilegeLevel( 632 const std::string &bundleName, int32_t userId = Constants::UNSPECIFIED_USERID) override; 633 /** 634 * @brief Query extension info. 635 * @param Want Indicates the information of extension info. 636 * @param flag Indicates the query flag which will fliter any specified stuff in the extension info. 637 * @param userId Indicates the userId in the system. 638 * @param extensionInfos Indicates the obtained extensions. 639 * @return Returns true if this function is successfully called; returns false otherwise. 640 */ 641 virtual bool QueryExtensionAbilityInfos(const Want &want, const int32_t &flag, const int32_t &userId, 642 std::vector<ExtensionAbilityInfo> &extensionInfos) override; 643 /** 644 * @brief Query extension info. 645 * @param Want Indicates the information of extension info. 646 * @param flag Indicates the query flag which will filter any specified stuff in the extension info. 647 * @param userId Indicates the userId in the system. 648 * @param extensionInfos Indicates the obtained extensions. 649 * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise. 650 */ 651 virtual ErrCode QueryExtensionAbilityInfosV9(const Want &want, int32_t flags, int32_t userId, 652 std::vector<ExtensionAbilityInfo> &extensionInfos) override; 653 /** 654 * @brief Query extension info. 655 * @param Want Indicates the information of extension info. 656 * @param extensionType Indicates the type of the extension. 657 * @param flag Indicates the query flag which will fliter any specified stuff in the extension info. 658 * @param userId Indicates the userId in the system. 659 * @param extensionInfos Indicates the obtained extensions. 660 * @return Returns true if this function is successfully called; returns false otherwise. 661 */ 662 virtual bool QueryExtensionAbilityInfos(const Want &want, const ExtensionAbilityType &extensionType, 663 const int32_t &flag, const int32_t &userId, std::vector<ExtensionAbilityInfo> &extensionInfos) override; 664 /** 665 * @brief Query extension info. 666 * @param Want Indicates the information of extension info. 667 * @param extensionType Indicates the type of the extension. 668 * @param flag Indicates the query flag which will filter any specified stuff in the extension info. 669 * @param userId Indicates the userId in the system. 670 * @param extensionInfos Indicates the obtained extensions. 671 * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise. 672 */ 673 virtual ErrCode QueryExtensionAbilityInfosV9(const Want &want, const ExtensionAbilityType &extensionType, 674 int32_t flags, int32_t userId, std::vector<ExtensionAbilityInfo> &extensionInfos) override; 675 /** 676 * @brief Process hidump. 677 * @param fd Indicates the fd. 678 * @param args Indicates the params. 679 * @return Returns the dump result. 680 */ 681 int Dump(int fd, const std::vector<std::u16string> &args) override; 682 683 virtual bool QueryExtensionAbilityInfos(const ExtensionAbilityType &extensionType, const int32_t &userId, 684 std::vector<ExtensionAbilityInfo> &extensionInfos) override; 685 686 virtual bool VerifyCallingPermission(const std::string &permission) override; 687 688 virtual bool VerifySystemApi(int32_t beginApiVersion = Constants::INVALID_API_VERSION) override; 689 690 virtual std::vector<std::string> GetAccessibleAppCodePaths(int32_t userId) override; 691 692 virtual bool QueryExtensionAbilityInfoByUri(const std::string &uri, int32_t userId, 693 ExtensionAbilityInfo &extensionAbilityInfo) override; 694 695 virtual std::string GetAppIdByBundleName(const std::string &bundleName, const int userId) override; 696 697 virtual std::string GetAppType(const std::string &bundleName) override; 698 699 virtual int GetUidByBundleName(const std::string &bundleName, const int userId) override; 700 701 virtual int GetUidByDebugBundleName(const std::string &bundleName, const int userId) override; 702 703 virtual bool ImplicitQueryInfoByPriority(const Want &want, int32_t flags, int32_t userId, 704 AbilityInfo &abilityInfo, ExtensionAbilityInfo &extensionInfo) override; 705 706 virtual bool ImplicitQueryInfos(const Want &want, int32_t flags, int32_t userId, 707 std::vector<AbilityInfo> &abilityInfos, std::vector<ExtensionAbilityInfo> &extensionInfos) override; 708 709 /** 710 * @brief Obtains the value of isRemovable based on a given bundle name and module name. 711 * @param bundleName Indicates the bundle name to be queried. 712 * @param moduleName Indicates the module name to be queried. 713 * @param isRemovable Indicates the module whether is removable. 714 * @return Returns ERR_OK if the isRemovable is successfully obtained; returns other ErrCode otherwise. 715 */ 716 virtual ErrCode IsModuleRemovable(const std::string &bundleName, const std::string &moduleName, 717 bool &isRemovable) override; 718 /** 719 * @brief Sets whether to enable isRemovable based on a given bundle name and module name. 720 * @param bundleName Indicates the bundle name to be queried. 721 * @param moduleName Indicates the module name to be queried. 722 * @param isEnable Specifies whether to enable the isRemovable of InnerModuleInfo. 723 * The value true means to enable it, and the value false means to disable it 724 * @return Returns true if the isRemovable is successfully obtained; returns false otherwise. 725 */ 726 virtual bool SetModuleRemovable( 727 const std::string &bundleName, const std::string &moduleName, bool isEnable) override; 728 /** 729 * @brief Obtains the dependent module names. 730 * 731 * @param bundleName Indicates the bundle name to be queried. 732 * @param moduleName Indicates the module name to be queried. 733 * @param dependentModuleNames Indicates the obtained dependent module names. 734 * @return Returns true if this function is successfully called; returns false otherwise. 735 */ 736 virtual bool GetAllDependentModuleNames(const std::string &bundleName, const std::string &moduleName, 737 std::vector<std::string> &dependentModuleNames) override; 738 /** 739 * @brief Obtains the value of upgradeFlag based on a given bundle name and module name. 740 * @param bundleName Indicates the bundle name to be queried. 741 * @param moduleName Indicates the module name to be queried. 742 * @return Returns true if the upgradeFlag is successfully obtained; returns false otherwise. 743 */ 744 virtual bool GetModuleUpgradeFlag(const std::string &bundleName, const std::string &moduleName) override; 745 /** 746 * @brief Sets whether to enable upgradeFlag based on a given bundle name and module name. 747 * @param bundleName Indicates the bundle name to be queried. 748 * @param moduleName Indicates the module name to be queried. 749 * @param isEnable Specifies whether to enable the upgradeFlag of InnerModuleInfo. 750 * The value true means to enable it, and the value false means to disable it 751 * @return Returns ERR_OK if the UpgradeFlag is successfully obtained; returns other ErrCode otherwise. 752 */ 753 virtual ErrCode SetModuleUpgradeFlag( 754 const std::string &bundleName, const std::string &moduleName, int32_t upgradeFlag) override; 755 virtual ErrCode GetSandboxBundleInfo( 756 const std::string &bundleName, int32_t appIndex, int32_t userId, BundleInfo &info) override; 757 758 virtual bool SetDisposedStatus(const std::string &bundleName, int32_t status) override; 759 760 virtual int32_t GetDisposedStatus(const std::string &bundleName) override; 761 762 virtual bool ObtainCallingBundleName(std::string &bundleName) override; 763 764 virtual bool GetBundleStats(const std::string &bundleName, int32_t userId, 765 std::vector<int64_t> &bundleStats) override; 766 767 #ifdef BUNDLE_FRAMEWORK_DEFAULT_APP 768 virtual sptr<IDefaultApp> GetDefaultAppProxy() override; 769 #endif 770 771 #ifdef BUNDLE_FRAMEWORK_APP_CONTROL 772 virtual sptr<IAppControlMgr> GetAppControlProxy() override; 773 #endif 774 775 virtual ErrCode GetSandboxAbilityInfo(const Want &want, int32_t appIndex, int32_t flags, int32_t userId, 776 AbilityInfo &info) override; 777 virtual ErrCode GetSandboxExtAbilityInfos(const Want &want, int32_t appIndex, int32_t flags, int32_t userId, 778 std::vector<ExtensionAbilityInfo> &infos) override; 779 virtual ErrCode GetSandboxHapModuleInfo(const AbilityInfo &abilityInfo, int32_t appIndex, int32_t userId, 780 HapModuleInfo &info) override; 781 782 virtual ErrCode GetMediaData(const std::string &bundleName, const std::string &moduleName, 783 const std::string &abilityName, std::unique_ptr<uint8_t[]> &mediaDataPtr, size_t &len, int32_t userId) override; 784 785 virtual sptr<IQuickFixManager> GetQuickFixManagerProxy() override; 786 virtual std::string GetStringById(const std::string &bundleName, const std::string &moduleName, 787 uint32_t resId, int32_t userId, const std::string &localeInfo) override; 788 virtual std::string GetIconById(const std::string &bundleName, const std::string &moduleName, 789 uint32_t resId, uint32_t density, int32_t userId) override; 790 virtual int32_t GetUdidByNetworkId(const std::string &networkId, std::string &udid) override; 791 virtual ErrCode SetDebugMode(bool isDebug) override; 792 virtual ErrCode GetProvisionMetadata(const std::string &bundleName, int32_t userId, 793 std::vector<Metadata> &provisionMetadatas) override; 794 795 private: 796 const std::shared_ptr<BundleDataMgr> GetDataMgrFromService(); 797 #ifdef DISTRIBUTED_BUNDLE_FRAMEWORK 798 const OHOS::sptr<IDistributedBms> GetDistributedBundleMgrService(); 799 #endif 800 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL 801 const std::shared_ptr<BundleConnectAbilityMgr> GetConnectAbilityMgrFromService(); 802 #endif 803 bool GetBundleUserInfo( 804 const std::string &bundleName, int32_t userId, InnerBundleUserInfo &innerBundleUserInfo); 805 bool GetBundleUserInfos( 806 const std::string &bundleName, std::vector<InnerBundleUserInfo> &innerBundleUserInfos); 807 bool GetShortcutInfos( 808 const std::string &bundleName, int32_t userId, std::vector<ShortcutInfo> &shortcutInfos); 809 bool DumpAllBundleInfoNames(int32_t userId, std::string &result); 810 bool DumpAllBundleInfoNamesByUserId(int32_t userId, std::string &result); 811 bool DumpBundleInfo(const std::string &bundleName, int32_t userId, std::string &result); 812 bool DumpShortcutInfo(const std::string &bundleName, int32_t userId, std::string &result); 813 std::set<int32_t> GetExistsCommonUserIs(); 814 bool VerifyQueryPermission(const std::string &queryBundleName); 815 bool VerifyPrivilegedPermission(const std::string &queryBundleName); 816 void CleanBundleCacheTask(const std::string &bundleName, const sptr<ICleanCacheCallback> &cleanCacheCallback, 817 const std::shared_ptr<BundleDataMgr> &dataMgr, int32_t userId); 818 void NotifyBundleStatus(const NotifyBundleEvents &installRes); 819 ErrCode GetBundleArchiveInfoBySandBoxPath( 820 const std::string &hapFilePath, int32_t flags, BundleInfo &bundleInfo, bool fromV9 = false); 821 822 private: 823 std::shared_ptr<BMSEventHandler> handler_; 824 const std::string BUNDLE_MGR_THREAD = "BundleMgrThread"; 825 }; 826 } // namespace AppExecFwk 827 } // namespace OHOS 828 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_MGR_HOST_IMPL_H 829