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