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_DATA_MGR_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_DATA_MGR_H 18 19 #include <atomic> 20 #include <cstdint> 21 #include <map> 22 #include <memory> 23 #include <mutex> 24 #include <optional> 25 #include <set> 26 #include <shared_mutex> 27 #include <string> 28 29 #include "bundle_dir.h" 30 #include "want.h" 31 32 #include "ability_info.h" 33 #include "aot/aot_args.h" 34 #include "application_info.h" 35 #include "app_provision_info.h" 36 #ifdef ABILITY_RUNTIME_ENABLE 37 #include "app_mgr_interface.h" 38 #include "running_process_info.h" 39 #endif 40 #include "bundle_data_storage_interface.h" 41 #include "bundle_event_callback_interface.h" 42 #include "bundle_promise.h" 43 #include "bundle_sandbox_app_helper.h" 44 #include "bundle_state_storage.h" 45 #include "bundle_status_callback_interface.h" 46 #include "common_event_data.h" 47 #include "ffrt.h" 48 #include "inner_bundle_clone_info.h" 49 #include "inner_bundle_info.h" 50 #include "inner_bundle_user_info.h" 51 #include "ipc/create_dir_param.h" 52 #include "module_info.h" 53 #include "preinstall_data_storage_interface.h" 54 #include "shortcut_data_storage_interface.h" 55 #ifdef GLOBAL_RESMGR_ENABLE 56 #include "resource_manager.h" 57 #endif 58 #ifdef BUNDLE_FRAMEWORK_DEFAULT_APP 59 #include "element.h" 60 #endif 61 #include "uninstall_data_mgr_storage_rdb.h" 62 #include "ohos_account_kits.h" 63 64 namespace OHOS { 65 namespace AppExecFwk { 66 enum class InstallState { 67 INSTALL_START = 1, 68 INSTALL_SUCCESS, 69 INSTALL_FAIL, 70 UNINSTALL_START, 71 UNINSTALL_SUCCESS, 72 UNINSTALL_FAIL, 73 UPDATING_START, 74 UPDATING_SUCCESS, 75 UPDATING_FAIL, 76 ROLL_BACK, 77 USER_CHANGE, 78 }; 79 80 class BundleDataMgr { 81 public: 82 using Want = OHOS::AAFwk::Want; 83 84 // init state transfer map data. 85 BundleDataMgr(); 86 virtual ~BundleDataMgr(); 87 88 /** 89 * @brief Boot query persistent storage. 90 * @return Returns true if this function is successfully called; returns false otherwise. 91 */ 92 bool LoadDataFromPersistentStorage(); 93 /** 94 * @brief Update internal state for whole bundle. 95 * @param bundleName Indicates the bundle name. 96 * @param state Indicates the install state to be set. 97 * @return Returns true if this function is successfully called; returns false otherwise. 98 */ 99 bool UpdateBundleInstallState(const std::string &bundleName, const InstallState state); 100 /** 101 * @brief Add new InnerBundleInfo. 102 * @param bundleName Indicates the bundle name. 103 * @param info Indicates the InnerBundleInfo object to be save. 104 * @return Returns true if this function is successfully called; returns false otherwise. 105 */ 106 bool AddInnerBundleInfo(const std::string &bundleName, InnerBundleInfo &info); 107 /** 108 * @brief Add new module info to an exist InnerBundleInfo. 109 * @param bundleName Indicates the bundle name. 110 * @param newInfo Indicates the new InnerBundleInfo object. 111 * @param oldInfo Indicates the old InnerBundleInfo object. 112 * @return Returns true if this function is successfully called; returns false otherwise. 113 */ 114 bool AddNewModuleInfo(const std::string &bundleName, const InnerBundleInfo &newInfo, InnerBundleInfo &oldInfo); 115 /** 116 * @brief Remove module info from an exist InnerBundleInfo. 117 * @param bundleName Indicates the bundle name. 118 * @param modulePackage Indicates the module Package. 119 * @param oldInfo Indicates the old InnerBundleInfo object. 120 * @return Returns true if this function is successfully called; returns false otherwise. 121 */ 122 bool RemoveModuleInfo(const std::string &bundleName, const std::string &modulePackage, InnerBundleInfo &oldInfo, 123 bool needSaveStorage = true); 124 125 bool RemoveHspModuleByVersionCode(int32_t versionCode, InnerBundleInfo &info); 126 /** 127 * @brief Update module info of an exist module. 128 * @param bundleName Indicates the bundle name. 129 * @param newInfo Indicates the new InnerBundleInfo object. 130 * @param oldInfo Indicates the old InnerBundleInfo object. 131 * @return Returns true if this function is successfully called; returns false otherwise. 132 */ 133 bool UpdateInnerBundleInfo(const std::string &bundleName, InnerBundleInfo &newInfo, InnerBundleInfo &oldInfo); 134 135 bool UpdateInnerBundleInfo(const InnerBundleInfo &innerBundleInfo, bool needSaveStorage = true); 136 /** 137 * @brief Get an InnerBundleInfo if exist (will change the status to DISABLED). 138 * @param bundleName Indicates the bundle name. 139 * @param info Indicates the obtained InnerBundleInfo object. 140 * @return Returns true if this function is successfully called; returns false otherwise. 141 */ 142 bool GetInnerBundleInfo(const std::string &bundleName, InnerBundleInfo &info); 143 /** 144 * @brief Generate UID and GID for a bundle. 145 * @param innerBundleUserInfo Indicates the InnerBundleUserInfo object. 146 * @return Returns true if this function is successfully called; returns false otherwise. 147 */ 148 bool GenerateUidAndGid(InnerBundleUserInfo &innerBundleUserInfo); 149 /** 150 * @brief Recycle uid and gid . 151 * @param info Indicates the InnerBundleInfo object. 152 */ 153 void RecycleUidAndGid(const InnerBundleInfo &info); 154 /** 155 * @brief Query the AbilityInfo by the given Want. 156 * @param want Indicates the information of the ability. 157 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 158 * @param userId Indicates the user ID. 159 * @param abilityInfo Indicates the obtained AbilityInfo object. 160 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 161 */ 162 bool QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo, 163 int32_t appIndex = 0) const; 164 /** 165 * @brief Query a AbilityInfo of list by the given Want. 166 * @param want Indicates the information of the ability. 167 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 168 * @param userId Indicates the user ID. 169 * @param abilityInfos Indicates the obtained AbilityInfo of list. 170 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 171 */ 172 bool QueryAbilityInfos( 173 const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) const; 174 /** 175 * @brief Query a AbilityInfo of list by the given Want. 176 * @param want Indicates the information of the ability. 177 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 178 * @param userId Indicates the user ID. 179 * @param abilityInfos Indicates the obtained AbilityInfo of list. 180 * @return Returns ERR_OK if the AbilityInfo is successfully obtained; returns errCode otherwise. 181 */ 182 ErrCode QueryAbilityInfosV9( 183 const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) const; 184 /** 185 * @brief Query a AbilityInfo of list by the given Want. 186 * @param want Indicates the information of the ability. 187 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 188 * @param userId Indicates the user ID. 189 * @param abilityInfos Indicates the obtained AbilityInfo of list. 190 * @return Returns ERR_OK if the AbilityInfo is successfully obtained; returns errCode otherwise. 191 */ 192 ErrCode BatchQueryAbilityInfos( 193 const std::vector<Want> &wants, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) const; 194 /** 195 * @brief Query Launcher AbilityInfo of list by the given Want. 196 * @param want Indicates the information of the ability. 197 * @param userId Indicates the user ID. 198 * @param abilityInfos Indicates the obtained AbilityInfo of list. 199 * @return Returns ERR_OK if the AbilityInfo is successfully obtained; returns errCode otherwise. 200 */ 201 ErrCode QueryLauncherAbilityInfos( 202 const Want &want, int32_t userId, std::vector<AbilityInfo> &abilityInfos) const; 203 /** 204 * @brief Query all match launcher ability infos by given wants. 205 * @param want Indicates the match infomation for abilities. 206 * @param info Indicates the bundleInfo. 207 * @param abilityInfo Indicates the obtained AbilityInfo of list. 208 * @param userId Indicates the user ID. 209 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 210 */ 211 void GetMatchLauncherAbilityInfos(const Want& want, const InnerBundleInfo& info, 212 std::vector<AbilityInfo>& abilityInfos, int64_t installTime, 213 int32_t userId = Constants::UNSPECIFIED_USERID) const; 214 /** 215 * @brief Query the AbilityInfo by ability.uri in config.json. 216 * @param abilityUri Indicates the uri of the ability. 217 * @param abilityInfos Indicates the obtained AbilityInfos object. 218 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 219 */ 220 bool QueryAbilityInfosByUri(const std::string &abilityUri, std::vector<AbilityInfo> &abilityInfos); 221 /** 222 * @brief Query the AbilityInfo by ability.uri in config.json. 223 * @param abilityUri Indicates the uri of the ability. 224 * @param userId Indicates the user ID. 225 * @param abilityInfo Indicates the obtained AbilityInfo object. 226 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 227 */ 228 bool QueryAbilityInfoByUri( 229 const std::string &abilityUri, int32_t userId, AbilityInfo &abilityInfo) const; 230 /** 231 * @brief Obtains the ApplicationInfo based on a given bundle name. 232 * @param appName Indicates the application bundle name to be queried. 233 * @param flags Indicates the flag used to specify information contained 234 * in the ApplicationInfo object that will be returned. 235 * @param userId Indicates the user ID. 236 * @param appInfo Indicates the obtained ApplicationInfo object. 237 * @return Returns true if the application is successfully obtained; returns false otherwise. 238 */ 239 bool GetApplicationInfo( 240 const std::string &appName, int32_t flags, const int userId, ApplicationInfo &appInfo) const; 241 /** 242 * @brief Obtains the ApplicationInfo based on a given bundle name. 243 * @param appName Indicates the application bundle name to be queried. 244 * @param flags Indicates the flag used to specify information contained 245 * in the ApplicationInfo object that will be returned. 246 * @param userId Indicates the user ID. 247 * @param appInfo Indicates the obtained ApplicationInfo object. 248 * @return Returns ERR_OK if the application is successfully obtained; returns error code otherwise. 249 */ 250 ErrCode GetApplicationInfoV9( 251 const std::string &appName, int32_t flags, int32_t userId, 252 ApplicationInfo &appInfo, const int32_t appIndex = 0) const; 253 /** 254 * @brief Obtains the ApplicationInfo based on a given bundle name. 255 * @param appName Indicates the application bundle name to be queried. 256 * @param flags Indicates the flag used to specify information contained 257 * in the ApplicationInfo object that will be returned. 258 * @param userId Indicates the user ID. 259 * @param appInfo Indicates the obtained ApplicationInfo object. 260 * @return Returns ERR_OK if the application is successfully obtained; returns error code otherwise. 261 */ 262 ErrCode GetApplicationInfoWithResponseId( 263 const std::string &appName, int32_t flags, int32_t &userId, ApplicationInfo &appInfo) const; 264 /** 265 * @brief Obtains information about all installed applications of a specified user. 266 * @param flags Indicates the flag used to specify information contained 267 * in the ApplicationInfo objects that will be returned. 268 * @param userId Indicates the user ID. 269 * @param appInfos Indicates all of the obtained ApplicationInfo objects. 270 * @return Returns true if the application is successfully obtained; returns false otherwise. 271 */ 272 bool GetApplicationInfos( 273 int32_t flags, const int userId, std::vector<ApplicationInfo> &appInfos) const; 274 /** 275 * @brief Obtains information about all installed applications of a specified user. 276 * @param flags Indicates the flag used to specify information contained 277 * in the ApplicationInfo objects that will be returned. 278 * @param userId Indicates the user ID. 279 * @param appInfos Indicates all of the obtained ApplicationInfo objects. 280 * @return Returns ERR_OK if the application is successfully obtained; returns error code otherwise. 281 */ 282 ErrCode GetApplicationInfosV9( 283 int32_t flags, int32_t userId, std::vector<ApplicationInfo> &appInfos) const; 284 /** 285 * @brief Obtains BundleInfo of all bundles available in the system. 286 * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be returned. 287 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 288 * @param userId Indicates the user ID. 289 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 290 */ 291 bool GetBundleInfos(int32_t flags, 292 std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) const; 293 /** 294 * @brief Obtains BundleInfo of all bundles available in the system. 295 * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be returned. 296 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 297 * @param userId Indicates the user ID. 298 * @return Returns ERR_OK if the BundleInfos is successfully obtained; returns error code otherwise. 299 */ 300 ErrCode GetBundleInfosV9(int32_t flags, std::vector<BundleInfo> &bundleInfos, int32_t userId) const; 301 /** 302 * @brief Obtains the BundleInfo based on a given bundle name. 303 * @param bundleName Indicates the application bundle name to be queried. 304 * @param flags Indicates the information contained in the BundleInfo object to be returned. 305 * @param bundleInfo Indicates the obtained BundleInfo object. 306 * @param userId Indicates the user ID. 307 * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. 308 */ 309 bool GetBundleInfo(const std::string &bundleName, int32_t flags, BundleInfo &bundleInfo, 310 int32_t userId = Constants::UNSPECIFIED_USERID) const; 311 /** 312 * @brief Obtains the BundleInfo based on a given bundle name. 313 * @param bundleName Indicates the application bundle name to be queried. 314 * @param flags Indicates the information contained in the BundleInfo object to be returned. 315 * @param bundleInfo Indicates the obtained BundleInfo object. 316 * @param userId Indicates the user ID. 317 * @param appIndex Indicates the app index. 318 * @return Returns ERR_OK if the BundleInfo is successfully obtained; returns error code otherwise. 319 */ 320 ErrCode GetBundleInfoV9(const std::string &bundleName, int32_t flags, BundleInfo &bundleInfo, 321 int32_t userId = Constants::UNSPECIFIED_USERID, int32_t appIndex = 0) const; 322 /** 323 * @brief Batch obtains the BundleInfos based on a given bundle name list. 324 * @param bundleNames Indicates the application bundle name list to be queried. 325 * @param flags Indicates the information contained in the BundleInfo object to be returned. 326 * @param bundleInfos Indicates the obtained BundleInfo list object. 327 * @param userId Indicates the user ID. 328 * @return Returns ERR_OK if the BundleInfo is successfully obtained; returns error code otherwise. 329 */ 330 void BatchGetBundleInfo(const std::vector<std::string> &bundleNames, int32_t flags, 331 std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) const; 332 /** 333 * @brief Obtains the BundlePackInfo based on a given bundle name. 334 * @param bundleName Indicates the application bundle name to be queried. 335 * @param flags Indicates the information contained in the BundleInfo object to be returned. 336 * @param BundlePackInfo Indicates the obtained BundlePackInfo object. 337 * @return Returns ERR_OK if the BundlePackInfo is successfully obtained; returns other ErrCode otherwise. 338 */ 339 ErrCode GetBundlePackInfo(const std::string &bundleName, int32_t flags, BundlePackInfo &bundleInfo, 340 int32_t userId = Constants::UNSPECIFIED_USERID) const; 341 /** 342 * @brief Obtains the BundleInfo of application bundles based on the specified metaData. 343 * @param metaData Indicates the metadata to get in the bundle. 344 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 345 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 346 */ 347 bool GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos) const; 348 /** 349 * @brief Obtains the bundle name of a specified application based on the given UID. 350 * @param uid Indicates the uid. 351 * @param bundleName Indicates the obtained bundle name. 352 * @return Returns true if the bundle name is successfully obtained; returns false otherwise. 353 */ 354 bool GetBundleNameForUid(const int32_t uid, std::string &bundleName) const; 355 /** 356 * @brief Obtains all bundle names of a specified application based on the given application UID. 357 * @param uid Indicates the uid. 358 * @param bundleNames Indicates the obtained bundle names. 359 * @return Returns true if the bundle names is successfully obtained; returns false otherwise. 360 */ 361 bool GetBundlesForUid(const int uid, std::vector<std::string> &bundleNames) const; 362 /** 363 * @brief Obtains the formal name associated with the given UID. 364 * @param uid Indicates the uid. 365 * @param name Indicates the obtained formal name. 366 * @return Returns ERR_OK if called successfully; returns error code otherwise. 367 */ 368 ErrCode GetNameForUid(const int uid, std::string &name) const; 369 /** 370 * @brief Obtains an array of all group IDs associated with a specified bundle. 371 * @param bundleName Indicates the bundle name. 372 * @param gids Indicates the group IDs associated with the specified bundle. 373 * @return Returns true if the gids is successfully obtained; returns false otherwise. 374 */ 375 bool GetBundleGids(const std::string &bundleName, std::vector<int> &gids) const; 376 /** 377 * @brief Obtains an array of all group IDs associated with the given bundle name and UID. 378 * @param bundleName Indicates the bundle name. 379 * @param uid Indicates the uid. 380 * @param gids Indicates the group IDs associated with the specified bundle. 381 * @return Returns true if the gids is successfully obtained; returns false otherwise. 382 */ 383 virtual bool GetBundleGidsByUid(const std::string &bundleName, const int &uid, std::vector<int> &gids) const; 384 /** 385 * @brief Obtains the BundleInfo of all keep-alive applications in the system. 386 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 387 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 388 */ 389 bool QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos) const; 390 /** 391 * @brief Obtains the label of a specified ability. 392 * @param bundleName Indicates the bundle name. 393 * @param moduleName Indicates the module name. 394 * @param abilityName Indicates the ability name. 395 * @param label Indicates the obtained label. 396 * @return Returns ERR_OK if the ability label is successfully obtained; returns errCode otherwise. 397 */ 398 ErrCode GetAbilityLabel(const std::string &bundleName, const std::string &moduleName, 399 const std::string &abilityName, std::string &label) const; 400 /** 401 * @brief Obtains the Want for starting the main ability of an application based on the given bundle name. 402 * @param bundleName Indicates the bundle name. 403 * @param want Indicates the obtained launch Want object. 404 * @param userId Indicates the user ID. 405 * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise. 406 */ 407 ErrCode GetLaunchWantForBundle( 408 const std::string &bundleName, Want &want, int32_t userId = Constants::UNSPECIFIED_USERID) const; 409 /** 410 * @brief Obtain the HAP module info of a specific ability. 411 * @param abilityInfo Indicates the ability. 412 * @param userId Indicates the user ID. 413 * @param hapModuleInfo Indicates the obtained HapModuleInfo object. 414 * @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise. 415 */ 416 bool GetHapModuleInfo(const AbilityInfo &abilityInfo, 417 HapModuleInfo &hapModuleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) const; 418 /** 419 * @brief Check whether the app is system app by it's UID. 420 * @param uid Indicates the uid. 421 * @return Returns true if the bundle is a system application; returns false otherwise. 422 */ 423 bool CheckIsSystemAppByUid(const int uid) const; 424 /** 425 * @brief Obtains all bundle names installed. 426 * @param bundleNames Indicates the bundle Names. 427 * @param userId Indicates the user ID. 428 * @return Returns true if have bundle installed; returns false otherwise. 429 */ 430 bool GetBundleList( 431 std::vector<std::string> &bundleNames, int32_t userId = Constants::UNSPECIFIED_USERID) const; 432 /** 433 * @brief Set the bundle status disable. 434 * @param bundleName Indicates the bundle name. 435 * @return Returns true if the bundle status successfully set; returns false otherwise. 436 */ 437 bool DisableBundle(const std::string &bundleName); 438 /** 439 * @brief Set the bundle status enable. 440 * @param bundleName Indicates the bundle name. 441 * @return Returns true if the bundle status successfully set; returns false otherwise. 442 */ 443 bool EnableBundle(const std::string &bundleName); 444 /** 445 * @brief Get whether the application status is enabled. 446 * @param bundleName Indicates the bundle name. 447 * @param isEnable Indicates the application status is enabled. 448 * @return Returns result of the operation. 449 */ 450 ErrCode IsApplicationEnabled(const std::string &bundleName, 451 int32_t appIndex, bool &isEnable, int32_t userId = Constants::UNSPECIFIED_USERID) const; 452 /** 453 * @brief Set the application status. 454 * @param bundleName Indicates the bundle name. 455 * @param isEnable Indicates the status to set. 456 * @param userId Indicates the user id. 457 * @return Returns result of the operation. 458 */ 459 ErrCode SetApplicationEnabled(const std::string &bundleName, int32_t appIndex, bool isEnable, 460 const std::string &caller, int32_t userId = Constants::UNSPECIFIED_USERID); 461 /** 462 * @brief Sets whether to enable a specified ability through the proxy object. 463 * @param abilityInfo Indicates information about the ability to check. 464 * @param isEnable Indicates the ability status is enabled. 465 * @return Returns result of the operation. 466 */ 467 ErrCode IsAbilityEnabled(const AbilityInfo &abilityInfo, int32_t appIndex, bool &isEnable) const; 468 /** 469 * @brief Sets whether to enable a specified ability through the proxy object. 470 * @param abilityInfo Indicates information about the ability. 471 * @param isEnabled Specifies whether to enable the ability. 472 * The value true means to enable it, and the value false means to disable it. 473 * @param userId Indicates the user id. 474 * @return Returns result of the operation. 475 */ 476 ErrCode SetAbilityEnabled(const AbilityInfo &abilityInfo, int32_t appIndex, bool isEnabled, 477 int32_t userId = Constants::UNSPECIFIED_USERID); 478 /** 479 * @brief Register the bundle status callback function. 480 * @param bundleStatusCallback Indicates the callback object that using for notifing the bundle status. 481 * @return Returns true if this function is successfully called; returns false otherwise. 482 */ 483 bool RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback); 484 485 bool RegisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback); 486 487 bool UnregisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback); 488 /** 489 * @brief Clear the specific bundle status callback. 490 * @param bundleStatusCallback Indicates the callback to be cleared. 491 * @return Returns true if this function is successfully called; returns false otherwise. 492 */ 493 bool ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback); 494 /** 495 * @brief Unregister all the callbacks of status changed. 496 * @return Returns true if this function is successfully called; returns false otherwise. 497 */ 498 bool UnregisterBundleStatusCallback(); 499 /** 500 * @brief Get a mutex for locking by bundle name. 501 * @param bundleName Indicates the bundle name. 502 * @return Returns a reference of mutex that for locing by bundle name. 503 */ 504 std::mutex &GetBundleMutex(const std::string &bundleName); 505 /** 506 * @brief Obtains the provision Id based on a given bundle name. 507 * @param bundleName Indicates the application bundle name to be queried. 508 * @param provisionId Indicates the provision Id to be returned. 509 * @return Returns true if the provision Id is successfully obtained; returns false otherwise. 510 */ 511 bool GetProvisionId(const std::string &bundleName, std::string &provisionId) const; 512 /** 513 * @brief Obtains the app feature based on a given bundle name. 514 * @param bundleName Indicates the application bundle name to be queried. 515 * @param provisionId Indicates the app feature to be returned. 516 * @return Returns true if the app feature is successfully obtained; returns false otherwise. 517 */ 518 bool GetAppFeature(const std::string &bundleName, std::string &appFeature) const; 519 /** 520 * @brief Set the flag that indicates whether initial user create successfully. 521 * @param flag Indicates the flag to be set. 522 * @return 523 */ 524 void SetInitialUserFlag(bool flag); 525 /** 526 * @brief Get a shared pointer to the IBundleDataStorage object. 527 * @return Returns the pointer of IBundleDataStorage object. 528 */ 529 std::shared_ptr<IBundleDataStorage> GetDataStorage() const; 530 /** 531 * @brief Obtains the FormInfo objects provided by all applications on the device. 532 * @param formInfos List of FormInfo objects if obtained; 533 * @return Returns true if this function is successfully called; returns false otherwise. 534 */ 535 bool GetAllFormsInfo(std::vector<FormInfo> &formInfos) const; 536 /** 537 * @brief Obtains the FormInfo objects provided by a specified application on the device. 538 * @param bundleName Indicates the bundle name of the application. 539 * @param formInfos List of FormInfo objects if obtained; 540 * @return Returns true if this function is successfully called; returns false otherwise. 541 */ 542 bool GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfos) const; 543 /** 544 * @brief Obtains the FormInfo objects provided by a specified module name. 545 * @param formInfos List of FormInfo objects if obtained; 546 * @param moduleName Indicates the module name of the application. 547 * @param bundleName Indicates the bundle name of the application. 548 * @return Returns true if this function is successfully called; returns false otherwise. 549 */ 550 bool GetFormsInfoByModule( 551 const std::string &bundleName, const std::string &moduleName, std::vector<FormInfo> &formInfos) const; 552 /** 553 * @brief Obtains the ShortcutInfo objects provided by a specified application on the device. 554 * @param bundleName Indicates the bundle name of the application. 555 * @param userId Indicates the user ID. 556 * @param shortcutInfos List of ShortcutInfo objects if obtained. 557 * @return Returns true if this function is successfully called; returns false otherwise. 558 */ 559 bool GetShortcutInfos( 560 const std::string &bundleName, int32_t userId, std::vector<ShortcutInfo> &shortcutInfos) const; 561 /** 562 * @brief Obtains the ShortcutInfo objects provided by a specified application on the device. 563 * @param bundleName Indicates the bundle name of the application. 564 * @param userId Indicates the user ID. 565 * @param shortcutInfos List of ShortcutInfo objects if obtained. 566 * @return Returns errcode of the result. 567 */ 568 ErrCode GetShortcutInfoV9( 569 const std::string &bundleName, int32_t userId, std::vector<ShortcutInfo> &shortcutInfos) const; 570 /** 571 * @brief Obtains the CommonEventInfo objects provided by an event key on the device. 572 * @param eventKey Indicates the event of the subscribe. 573 * @param commonEventInfos List of CommonEventInfo objects if obtained. 574 * @return Returns true if this function is successfully called; returns false otherwise. 575 */ 576 bool GetAllCommonEventInfo(const std::string &eventKey, std::vector<CommonEventInfo> &commonEventInfos) const; 577 /** 578 * @brief Obtains the PreInstallBundleInfo objects provided by bundleName. 579 * @param bundleName Indicates the bundle name of the application. 580 * @param preInstallBundleInfo Indicates information about the PreInstallBundleInfo. 581 * @return Returns true if this function is successfully called; returns false otherwise. 582 */ 583 bool GetPreInstallBundleInfo(const std::string &bundleName, PreInstallBundleInfo &preInstallBundleInfo); 584 /** 585 * @brief Save new PreInstallBundleInfo. 586 * @param bundleName Indicates the bundle name. 587 * @param preInstallBundleInfo Indicates the PreInstallBundleInfo object to be save. 588 * @return Returns true if this function is successfully called; returns false otherwise. 589 */ 590 bool SavePreInstallBundleInfo(const std::string &bundleName, const PreInstallBundleInfo &preInstallBundleInfo); 591 /** 592 * @brief Obtains the PreInstallBundleInfo objects provided by bundleName. 593 * @param preInstallBundleInfo Indicates information about the PreInstallBundleInfo. 594 * @return Returns true if this function is successfully called; returns false otherwise. 595 */ 596 bool LoadAllPreInstallBundleInfos(std::vector<PreInstallBundleInfo> &preInstallBundleInfos); 597 /** 598 * @brief Save new PreInstallBundleInfo. 599 * @param bundleName Indicates the bundle name. 600 * @param preInstallBundleInfo Indicates the PreInstallBundleInfo object to be save. 601 * @return Returns true if this function is successfully called; returns false otherwise. 602 */ 603 bool DeletePreInstallBundleInfo( 604 const std::string &bundleName, const PreInstallBundleInfo &preInstallBundleInfo); 605 /** 606 * @brief Save installation mark to datebase storage. 607 * @param info Indicates the innerBundleInfo of the bundle which needs to save installation mark. 608 * @return Returns true if this function is successfully called; returns false otherwise. 609 */ 610 bool SaveInnerBundleInfo(const InnerBundleInfo &info) const; 611 /** 612 * @brief GetInnerBundleUserInfoByUserId. 613 * @param bundleName Indicates the application bundle name to be queried. 614 * @param userId Indicates the user ID. 615 * @param innerBundleUserInfo Indicates the obtained InnerBundleUserInfo object. 616 * @return Returns true if the application is successfully obtained; returns false otherwise. 617 */ 618 bool GetInnerBundleUserInfoByUserId( 619 const std::string &bundleName, int32_t userId, InnerBundleUserInfo &innerBundleUserInfo) const; 620 /** 621 * @brief save all created users. 622 * @param userId Indicates the user ID. 623 */ 624 void AddUserId(int32_t userId); 625 /** 626 * @brief remove userId. 627 * @param userId Indicates the user ID. 628 */ 629 void RemoveUserId(int32_t userId); 630 /** 631 * @brief query users. 632 * @param userId Indicates the user ID. 633 * @return Returns true when query user success; returns false otherwise. 634 */ 635 bool HasUserId(int32_t userId) const; 636 /** 637 * @brief Get userId by calling uid. 638 * @return Returns userId. 639 */ 640 int32_t GetUserIdByCallingUid() const; 641 /** 642 * @brief Get all user. 643 * @return Returns all userId. 644 */ 645 std::set<int32_t> GetAllUser() const; 646 /** 647 * @brief Has initial user created. 648 * @return Returns initial user flag. 649 */ HasInitialUserCreated()650 bool HasInitialUserCreated() const 651 { 652 return initialUserFlag_; 653 } 654 /** 655 * @brief Set bundlePromise. 656 * @param bundlePromise Indicates the bundlePromise. 657 */ SetBundlePromise(const std::shared_ptr<BundlePromise> & bundlePromise)658 void SetBundlePromise(const std::shared_ptr<BundlePromise>& bundlePromise) 659 { 660 bundlePromise_ = bundlePromise; 661 } 662 /** 663 * @brief Get bundleUserInfos by bundleName. 664 * @param bundleName Indicates the application bundle name to be queried. 665 * @param innerBundleUserInfo Indicates the obtained InnerBundleUserInfo object. 666 * @return Returns true if the application is successfully obtained; returns false otherwise. 667 */ 668 bool GetInnerBundleUserInfos( 669 const std::string &bundleName, std::vector<InnerBundleUserInfo> &innerBundleUserInfos) const; 670 /** 671 * @brief Get app privilege level. 672 * @param bundleName Indicates the bundle name of the app privilege level. 673 * @param userId Indicates the user id. 674 * @return Returns app privilege level. 675 */ 676 std::string GetAppPrivilegeLevel( 677 const std::string &bundleName, int32_t userId = Constants::UNSPECIFIED_USERID); 678 /** 679 * @brief Query a ExtensionAbilityInfo of list by the given Want. 680 * @param want Indicates the information of the ability. 681 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 682 * @param userId Indicates the user ID. 683 * @param extensionInfos Indicates the obtained ExtensionAbilityInfo of list. 684 * @return Returns true if the ExtensionAbilityInfo is successfully obtained; returns false otherwise. 685 */ 686 bool QueryExtensionAbilityInfos(const Want &want, int32_t flags, int32_t userId, 687 std::vector<ExtensionAbilityInfo> &extensionInfos, int32_t appIndex = 0) const; 688 /** 689 * @brief Query a ExtensionAbilityInfo of list by the given Want. 690 * @param want Indicates the information of the ability. 691 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 692 * @param userId Indicates the user ID. 693 * @param extensionInfos Indicates the obtained ExtensionAbilityInfo of list. 694 * @return Returns ERR_OK if the ExtensionAbilityInfo is successfully obtained; returns errCode otherwise. 695 */ 696 ErrCode QueryExtensionAbilityInfosV9(const Want &want, int32_t flags, int32_t userId, 697 std::vector<ExtensionAbilityInfo> &extensionInfos, int32_t appIndex = 0) const; 698 699 /** 700 * @brief Query a ExtensionAbilityInfo without want. 701 * @param want Indicates the information of the ability. 702 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 703 * @param userId Indicates the user ID. 704 * @param extensionInfos Indicates the obtained ExtensionAbilityInfo of list. 705 * @return Returns ERR_OK if the ExtensionAbilityInfo is successfully obtained; returns errCode otherwise. 706 */ 707 ErrCode QueryExtensionAbilityInfos(uint32_t flags, int32_t userId, 708 std::vector<ExtensionAbilityInfo> &extensionInfos, int32_t appIndex = 0) const; 709 710 ErrCode QueryExtensionAbilityInfosByExtensionTypeName(const std::string &typeName, uint32_t flags, 711 int32_t userId, std::vector<ExtensionAbilityInfo> &extensionInfos, int32_t appIndex = 0) const; 712 /** 713 * @brief Obtains the PreInstallBundleInfo objects in Cache. 714 * @return Returns PreInstallBundleInfos. 715 */ 716 const std::vector<PreInstallBundleInfo> GetAllPreInstallBundleInfos(); 717 /** 718 * @brief Restore uid and gid . 719 * @return Returns true if this function is successfully called; returns false otherwise. 720 */ 721 bool RestoreUidAndGid(); 722 /** 723 * @brief Load all bundle state data from jsonDb . 724 * @return 725 */ 726 void LoadAllBundleStateDataFromJsonDb(); 727 728 bool QueryExtensionAbilityInfos(const ExtensionAbilityType &extensionType, const int32_t &userId, 729 std::vector<ExtensionAbilityInfo> &extensionInfos) const; 730 731 bool QueryExtensionAbilityInfoByUri(const std::string &uri, int32_t userId, 732 ExtensionAbilityInfo &extensionAbilityInfo) const; 733 734 bool AddInnerBundleUserInfo(const std::string &bundleName, const InnerBundleUserInfo& newUserInfo); 735 736 bool RemoveInnerBundleUserInfo(const std::string &bundleName, int32_t userId); 737 738 bool ImplicitQueryInfoByPriority(const Want &want, int32_t flags, int32_t userId, 739 AbilityInfo &abilityInfo, ExtensionAbilityInfo &extensionInfo) const; 740 741 bool ImplicitQueryInfos(const Want &want, int32_t flags, int32_t userId, bool withDefault, 742 std::vector<AbilityInfo> &abilityInfos, std::vector<ExtensionAbilityInfo> &extensionInfos, 743 bool &findDefaultApp); 744 bool UpateExtResources(const std::string &bundleName, 745 const std::vector<ExtendResourceInfo> &extendResourceInfos); 746 bool RemoveExtResources(const std::string &bundleName, 747 const std::vector<std::string> &moduleNames); 748 bool UpateCurDynamicIconModule( 749 const std::string &bundleName, const std::string &moduleName); 750 void CreateAppInstallDir(int32_t userId); 751 void RemoveAppInstallDir(int32_t userId); 752 753 /** 754 * @brief Sets whether to enable isRemovable based on given bundle name, module name and isEnable. 755 * @param bundleName Indicates the bundleName. 756 * @param moduleName Indicates the moduleName. 757 * @param isEnable Set module isRemovable is enable. 758 * @return Returns true if the module isRemovable is set success; returns false otherwise. 759 */ 760 bool SetModuleRemovable(const std::string &bundleName, const std::string &moduleName, bool isEnable); 761 /** 762 * @brief Get Module isRemovable by bundleName and moduleName. 763 * @param bundleName Indicates the application bundle name to be queried. 764 * @param moduleName Indicates the moduleName. 765 * @param isRemovable Indicates the module whether is removable. 766 * @return Returns ERR_OK if the module isRemovable is successfully obtained; returns other ErrCode otherwise. 767 */ 768 ErrCode IsModuleRemovable(const std::string &bundleName, const std::string &moduleName, bool &isRemovable) const; 769 770 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL 771 int64_t GetBundleSpaceSize(const std::string &bundleName) const; 772 int64_t GetBundleSpaceSize(const std::string &bundleName, int32_t userId) const; 773 int64_t GetAllFreeInstallBundleSpaceSize() const; 774 bool GetFreeInstallModules( 775 std::map<std::string, std::vector<std::string>> &freeInstallModules) const; 776 #endif 777 778 #ifdef ABILITY_RUNTIME_ENABLE 779 std::vector<int32_t> GetNoRunningBundleCloneIndexes(const sptr<IAppMgr> appMgrProxy, const std::string &bundleName, 780 const std::vector<int32_t> &cloneAppIndexes) const; 781 #endif 782 void GetBundleCacheInfos( 783 const int32_t userId, std::vector<std::tuple<std::string, std::vector<std::string>, 784 std::vector<int32_t>>> &validBundles, bool isClean = false) const; 785 void GetBundleCacheInfo( 786 std::function<std::vector<int32_t>(std::string&, std::vector<int32_t>&)> idxFilter, 787 const InnerBundleInfo &info, 788 std::vector<std::tuple<std::string, std::vector<std::string>, std::vector<int32_t>>> &validBundles, 789 const int32_t userId, bool isClean) const; 790 bool GetBundleStats(const std::string &bundleName, 791 const int32_t userId, std::vector<int64_t> &bundleStats, 792 const int32_t appIndex = 0, const uint32_t statFlag = 0) const; 793 void GetBundleModuleNames(const std::string &bundleName, std::vector<std::string> &moduleNameList) const; 794 bool GetAllBundleStats(const int32_t userId, std::vector<int64_t> &bundleStats) const; 795 bool HasUserInstallInBundle(const std::string &bundleName, const int32_t userId) const; 796 bool GetAllDependentModuleNames(const std::string &bundleName, const std::string &moduleName, 797 std::vector<std::string> &dependentModuleNames); 798 ErrCode SetModuleUpgradeFlag(const std::string &bundleName, const std::string &moduleName, int32_t upgradeFlag); 799 int32_t GetModuleUpgradeFlag(const std::string &bundleName, const std::string &moduleName) const; 800 /** 801 * @brief Get the Inner Bundle Info With Flags object 802 * @param bundleName Indicates the application bundle name to be queried. 803 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 804 * @param info Indicates the innerBundleInfo of the bundle. 805 * @param userId Indicates the user ID. 806 * @return Returns true if get inner bundle info is successfully obtained; returns false otherwise. 807 */ 808 bool GetInnerBundleInfoWithFlags(const std::string &bundleName, const int32_t flags, 809 InnerBundleInfo &info, int32_t userId = Constants::UNSPECIFIED_USERID, int32_t appIndex = 0) const; 810 bool GetInnerBundleInfoWithFlags(const std::string &bundleName, const int32_t flags, 811 int32_t userId = Constants::UNSPECIFIED_USERID, int32_t appIndex = 0) const; 812 bool GetInnerBundleInfoWithBundleFlagsAndLock(const std::string &bundleName, int32_t flags, 813 InnerBundleInfo &info, int32_t userId = Constants::UNSPECIFIED_USERID) const; 814 ErrCode GetInnerBundleInfoWithFlagsV9(const std::string &bundleName, int32_t flags, 815 InnerBundleInfo &info, int32_t userId = Constants::UNSPECIFIED_USERID, int32_t appIndex = 0) const; 816 ErrCode GetInnerBundleInfoWithBundleFlagsV9(const std::string &bundleName, int32_t flags, 817 InnerBundleInfo &info, int32_t userId = Constants::UNSPECIFIED_USERID, int32_t appIndex = 0) const; 818 std::shared_ptr<BundleSandboxAppHelper> GetSandboxAppHelper() const; 819 ErrCode GetBundleInfoForSelf(int32_t flags, BundleInfo &bundleInfo); 820 821 #ifdef BUNDLE_FRAMEWORK_DEFAULT_APP 822 bool QueryInfoAndSkillsByElement(int32_t userId, const Element& element, 823 AbilityInfo& abilityInfo, ExtensionAbilityInfo& extensionInfo, std::vector<Skill>& skills) const; 824 825 bool GetElement(int32_t userId, const ElementName& elementName, Element& element) const; 826 #endif 827 828 int32_t GetUserId(int32_t userId = Constants::UNSPECIFIED_USERID) const; 829 830 ErrCode GetMediaData(const std::string &bundleName, const std::string &moduleName, const std::string &abilityName, 831 std::unique_ptr<uint8_t[]> &mediaDataPtr, size_t &len, int32_t userId) const; 832 833 std::shared_mutex &GetStatusCallbackMutex(); 834 835 std::vector<sptr<IBundleStatusCallback>> GetCallBackList() const; 836 837 std::string GetStringById(const std::string &bundleName, const std::string &moduleName, 838 uint32_t resId, int32_t userId, const std::string &localeInfo); 839 840 std::string GetIconById( 841 const std::string &bundleName, const std::string &moduleName, uint32_t resId, uint32_t density, int32_t userId); 842 void UpdateRemovable(const std::string &bundleName, bool removable); 843 void UpdatePrivilegeCapability( 844 const std::string &bundleName, const ApplicationInfo &appInfo); 845 bool FetchInnerBundleInfo( 846 const std::string &bundleName, InnerBundleInfo &innerBundleInfo); 847 848 bool UpdateQuickFixInnerBundleInfo(const std::string &bundleName, const InnerBundleInfo &innerBundleInfo); 849 bool UpdateUninstallBundleInfo(const std::string &bundleName, const UninstallBundleInfo &uninstallBundleInfo); 850 bool GetUninstallBundleInfo(const std::string &bundleName, UninstallBundleInfo &uninstallBundleInfo); 851 bool DeleteUninstallBundleInfo(const std::string &bundleName, int32_t userId); 852 853 void NotifyBundleEventCallback(const EventFwk::CommonEventData &eventData) const; 854 GetAllInnerBundleInfos()855 const std::map<std::string, InnerBundleInfo> GetAllInnerBundleInfos() const 856 { 857 std::shared_lock<std::shared_mutex> lock(bundleInfoMutex_); 858 return bundleInfos_; 859 } 860 861 bool QueryOverlayInnerBundleInfo(const std::string &bundleName, InnerBundleInfo &info); 862 863 void SaveOverlayInfo(const std::string &bundleName, InnerBundleInfo &innerBundleInfo); 864 865 ErrCode GetAppProvisionInfo(const std::string &bundleName, int32_t userId, 866 AppProvisionInfo &appProvisionInfo); 867 868 virtual ErrCode GetProvisionMetadata(const std::string &bundleName, int32_t userId, 869 std::vector<Metadata> &provisionMetadatas) const; 870 871 ErrCode GetBaseSharedBundleInfos(const std::string &bundleName, 872 std::vector<BaseSharedBundleInfo> &baseSharedBundleInfos, 873 GetDependentBundleInfoFlag flag = GetDependentBundleInfoFlag::GET_APP_CROSS_HSP_BUNDLE_INFO) const; 874 875 bool GetBaseSharedBundleInfo(const Dependency &dependency, BaseSharedBundleInfo &baseSharedBundleInfo) const; 876 877 ErrCode GetAllSharedBundleInfo(std::vector<SharedBundleInfo> &sharedBundles) const; 878 879 ErrCode GetSharedBundleInfo(const std::string &bundleName, const std::string &moduleName, 880 std::vector<SharedBundleInfo> &sharedBundles); 881 882 bool DeleteSharedBundleInfo(const std::string &bundleName); 883 884 ErrCode GetSharedBundleInfoBySelf(const std::string &bundleName, SharedBundleInfo &sharedBundleInfo); 885 886 ErrCode GetSharedDependencies(const std::string &bundleName, const std::string &moduleName, 887 std::vector<Dependency> &dependencies); 888 889 bool CheckHspVersionIsRelied(int32_t versionCode, const InnerBundleInfo &info) const; 890 bool CheckHspBundleIsRelied(const std::string &hspBundleName) const; 891 bool IsPreInstallApp(const std::string &bundleName); 892 bool GetBundleType(const std::string &bundleName, BundleType &bundleType)const; 893 894 ErrCode GetSharedBundleInfo(const std::string &bundleName, int32_t flags, BundleInfo &bundleInfo); 895 ErrCode GetSpecifiedDistributionType(const std::string &bundleName, std::string &specifiedDistributionType); 896 ErrCode GetAdditionalInfo(const std::string &bundleName, std::string &additionalInfo); 897 898 ErrCode GetProxyDataInfos(const std::string &bundleName, const std::string &moduleName, int32_t userId, 899 std::vector<ProxyData> &proxyDatas) const; 900 901 ErrCode GetAllProxyDataInfos(int32_t userId, std::vector<ProxyData> &proxyDatas) const; 902 903 std::string GetBundleNameByAppId(const std::string &appId) const; 904 905 void SetAOTCompileStatus(const std::string &bundleName, const std::string &moduleName, 906 AOTCompileStatus aotCompileStatus, uint32_t versionCode); 907 void ResetAOTFlags(); 908 void ResetAOTFlagsCommand(const std::string &bundleName); 909 ErrCode ResetAOTCompileStatus(const std::string &bundleName, const std::string &moduleName, 910 int32_t triggerMode); 911 std::vector<std::string> GetAllBundleName() const; 912 bool IsBundleExist(const std::string &bundleName) const; 913 bool QueryInnerBundleInfo(const std::string &bundleName, InnerBundleInfo &info) const; 914 std::vector<int32_t> GetUserIds(const std::string &bundleName) const; 915 ErrCode SetExtNameOrMIMEToApp(const std::string &bundleName, const std::string &moduleName, 916 const std::string &abilityName, const std::string &extName, const std::string &mimeType); 917 ErrCode DelExtNameOrMIMEToApp(const std::string &bundleName, const std::string &moduleName, 918 const std::string &abilityName, const std::string &extName, const std::string &mimeType); 919 bool QueryAppGalleryAbilityName(std::string &bundleName, std::string &abilityName); 920 void ScanAllBundleGroupInfo(); 921 void HandleGroupIdAndIndex(const std::set<std::string> errorGroupIds, 922 std::map<int32_t, std::string> &indexMap, std::map<std::string, int32_t> &groupIdMap); 923 bool HandleErrorDataGroupInfos( 924 const std::map<std::string, int32_t> &groupIdMap, 925 const std::map<std::string, std::set<std::string>> &needProcessGroupInfoBundleNames); 926 bool QueryDataGroupInfos(const std::string &bundleName, int32_t userId, std::vector<DataGroupInfo> &infos) const; 927 bool GetGroupDir(const std::string &dataGroupId, std::string &dir, 928 int32_t userId = Constants::UNSPECIFIED_USERID) const; 929 void GenerateDataGroupUuidAndUid(DataGroupInfo &dataGroupInfo, int32_t userId, 930 std::unordered_set<int32_t> &uniqueIdSet) const; 931 void GenerateDataGroupInfos(const std::string &bundleName, 932 const std::unordered_set<std::string> &dataGroupIdList, int32_t userId); 933 void GetDataGroupIndexMap(std::map<std::string, std::pair<int32_t, std::string>> &dataGroupIndexMap, 934 std::unordered_set<int32_t> &uniqueIdSet) const; 935 bool IsShareDataGroupIdNoLock(const std::string &dataGroupId, int32_t userId) const; 936 void GenerateNewUserDataGroupInfos(const std::string &bundleName, int32_t userId); 937 void DeleteUserDataGroupInfos(const std::string &bundleName, int32_t userId, bool keepData); 938 bool IsDataGroupIdExistNoLock(const std::string &dataGroupId, int32_t userId) const; 939 void ProcessAllUserDataGroupInfosWhenBundleUpdate(InnerBundleInfo &innerBundleInfo); 940 void RemoveOldGroupDirs(const InnerBundleInfo &oldInfo) const; 941 void DeleteGroupDirsForException(const InnerBundleInfo &oldInfo, int32_t userId) const; 942 void CreateGroupDirIfNotExist(const DataGroupInfo &dataGroupInfo); 943 ErrCode GetJsonProfile(ProfileType profileType, const std::string &bundleName, const std::string &moduleName, 944 std::string &profile, int32_t userId) const; 945 ErrCode GetJsonProfileByExtractor(const std::string &hapPath, const std::string &profilePath, 946 std::string &profile) const; 947 bool GetOldAppIds(const std::string &bundleName, std::vector<std::string> &appIds) const; 948 ErrCode GetInnerBundleInfoByUid(const int32_t uid, InnerBundleInfo &innerBundleInfo) const; 949 ErrCode GetInnerBundleInfoAndIndexByUid(const int32_t uid, InnerBundleInfo &innerBundleInfo, 950 int32_t &appIndex) const; 951 std::string GetModuleNameByBundleAndAbility(const std::string& bundleName, const std::string& abilityName); 952 const std::vector<PreInstallBundleInfo> GetRecoverablePreInstallBundleInfos(); 953 ErrCode SetAdditionalInfo(const std::string& bundleName, const std::string& additionalInfo) const; 954 ErrCode GetAppServiceHspBundleInfo(const std::string &bundleName, BundleInfo &bundleInfo); 955 ErrCode CreateBundleDataDir(int32_t userId); 956 ErrCode CreateBundleDataDirWithEl(int32_t userId, DataDirEl dirEl); 957 void GenerateOdid(const std::string &developerId, std::string &odid) const; 958 ErrCode GetOdid(std::string &odid) const; 959 ErrCode GetOdidByBundleName(const std::string &bundleName, std::string &odid) const; 960 961 void UpdateIsPreInstallApp(const std::string &bundleName, bool isPreInstallApp); 962 963 /** 964 * @brief Check whether the link can be opened. 965 * @param link Indicates the link to be opened. 966 * @param canOpen Indicates whether the link can be opened. 967 * @return Returns result of the operation. 968 */ 969 ErrCode CanOpenLink( 970 const std::string &link, bool &canOpen) const; 971 ErrCode GetAllBundleInfoByDeveloperId(const std::string &developerId, 972 std::vector<BundleInfo> &bundleInfos, int32_t userId); 973 ErrCode GetDeveloperIds(const std::string &appDistributionType, 974 std::vector<std::string> &developerIdList, int32_t userId); 975 ErrCode SwitchUninstallState(const std::string &bundleName, const bool &state, const bool isNeedSendNotify); 976 977 ErrCode AddCloneBundle(const std::string &bundleName, const InnerBundleCloneInfo &attr); 978 ErrCode RemoveCloneBundle(const std::string &bundleName, const int32_t userId, int32_t appIndex); 979 ErrCode QueryAbilityInfoByContinueType(const std::string &bundleName, const std::string &continueType, 980 AbilityInfo &abilityInfo, int32_t userId, int32_t appIndex = 0) const; 981 ErrCode GetBundleNameAndIndexForUid(const int32_t uid, std::string &bundleName, int32_t &appIndex) const; 982 983 ErrCode QueryCloneAbilityInfo(const ElementName &element, int32_t flags, int32_t userId, 984 int32_t appIndex, AbilityInfo &abilityInfo) const; 985 ErrCode GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appIndex, 986 BundleInfo &bundleInfo, int32_t userId) const; 987 std::vector<int32_t> GetCloneAppIndexes(const std::string &bundleName, int32_t userId) const; 988 989 ErrCode ExplicitQueryExtensionInfoV9(const Want &want, int32_t flags, int32_t userId, 990 ExtensionAbilityInfo &extensionInfo, int32_t appIndex = 0) const; 991 992 void QueryAllCloneExtensionInfos(const Want &want, int32_t flags, int32_t userId, 993 std::vector<ExtensionAbilityInfo> &infos) const; 994 void QueryAllCloneExtensionInfosV9(const Want &want, int32_t flags, int32_t userId, 995 std::vector<ExtensionAbilityInfo> &infos) const; 996 997 ErrCode GetAppIdByBundleName(const std::string &bundleName, std::string &appId) const; 998 999 ErrCode GetSignatureInfoByBundleName(const std::string &bundleName, SignatureInfo &signatureInfo) const; 1000 1001 ErrCode AddDesktopShortcutInfo(const ShortcutInfo &shortcutInfo, int32_t userId); 1002 ErrCode DeleteDesktopShortcutInfo(const ShortcutInfo &shortcutInfo, int32_t userId); 1003 ErrCode GetAllDesktopShortcutInfo(int32_t userId, std::vector<ShortcutInfo> &shortcutInfos); 1004 ErrCode DeleteDesktopShortcutInfo(const std::string &bundleName); 1005 ErrCode DeleteDesktopShortcutInfo(const std::string &bundleName, int32_t userId, int32_t appIndex); 1006 1007 void GetBundleInfosForContinuation(std::vector<BundleInfo> &bundleInfos) const; 1008 1009 /** 1010 * @brief Get a list of application package names that continue the specified package name. 1011 * @param continueBundleName The package name that is being continued. 1012 * @param bundleNames Continue the list of specified package names. 1013 * @param userId Indicates the user ID. 1014 * @return Returns ERR_OK if successfully obtained; returns error code otherwise. 1015 */ 1016 ErrCode GetContinueBundleNames( 1017 const std::string &continueBundleName, std::vector<std::string> &bundleNames, int32_t userId); 1018 1019 ErrCode IsBundleInstalled(const std::string &bundleName, int32_t userId, int32_t appIndex, bool &isInstalled); 1020 void CreateEl5Dir(const std::vector<CreateDirParam> &el5Params); 1021 int32_t GetUidByBundleName(const std::string &bundleName, int32_t userId, int32_t appIndex) const; 1022 ErrCode GetBundleNameByAppId(const std::string &appId, std::string &bundleName); 1023 ErrCode GetDirForAtomicService(const std::string &bundleName, std::string &dataDir) const; 1024 ErrCode GetDirForAtomicServiceByUserId(const std::string &bundleName, int32_t userId, 1025 AccountSA::OhosAccountInfo &accountInfo, std::string &dataDir) const; 1026 std::string GetDirForApp(const std::string &bundleName, const int32_t appIndex) const; 1027 ErrCode GetDirByBundleNameAndAppIndex(const std::string &bundleName, const int32_t appIndex, 1028 std::string &dataDir) const; 1029 std::vector<int32_t> GetCloneAppIndexesByInnerBundleInfo(const InnerBundleInfo &innerBundleInfo, 1030 int32_t userId) const; 1031 ErrCode GetBundleDir(int32_t userId, BundleType type, AccountSA::OhosAccountInfo &accountInfo, 1032 BundleDir &bundleDir) const; 1033 ErrCode GetAllBundleDirs(int32_t userId, std::vector<BundleDir> &bundleDirs) const; 1034 1035 private: 1036 /** 1037 * @brief Init transferStates. 1038 * @return 1039 */ 1040 void InitStateTransferMap(); 1041 /** 1042 * @brief Determine whether to delete the data status. 1043 * @param state Indicates the InstallState object. 1044 * @return Returns true if state is INSTALL_FAIL,UNINSTALL_FAIL,UNINSTALL_SUCCESS,or UPDATING_FAIL; returns false 1045 * otherwise. 1046 */ 1047 bool IsDeleteDataState(const InstallState state) const; 1048 /** 1049 * @brief Determine whether it is disable. 1050 * @param state Indicates the InstallState object. 1051 * @return Returns true if install state is UPDATING_START or UNINSTALL_START; returns false otherwise. 1052 */ 1053 bool IsDisableState(const InstallState state) const; 1054 /** 1055 * @brief Delete bundle info if InstallState is not INSTALL_FAIL. 1056 * @param bundleName Indicates the bundle Names. 1057 * @param state Indicates the InstallState object. 1058 * @return Returns true if install state is UPDATING_START or UNINSTALL_START; returns false otherwise. 1059 */ 1060 void DeleteBundleInfo(const std::string &bundleName, const InstallState state); 1061 /** 1062 * @brief Determine whether app is installed. 1063 * @param bundleName Indicates the bundle Names. 1064 * @return Returns true if install state is INSTALL_SUCCESS; returns false otherwise. 1065 */ 1066 bool IsAppOrAbilityInstalled(const std::string &bundleName) const; 1067 /** 1068 * @brief Implicit query abilityInfos by the given Want. 1069 * @param want Indicates the information of the ability. 1070 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 1071 * @param userId Indicates the user ID. 1072 * @param abilityInfos Indicates the obtained AbilityInfo of list. 1073 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 1074 */ 1075 bool ImplicitQueryAbilityInfos(const Want &want, int32_t flags, int32_t userId, 1076 std::vector<AbilityInfo> &abilityInfos, int32_t appIndex = 0) const; 1077 ErrCode ImplicitQueryAbilityInfosV9(const Want &want, int32_t flags, int32_t userId, 1078 std::vector<AbilityInfo> &abilityInfos, int32_t appIndex = 0) const; 1079 bool CheckAbilityInfoFlagExist(int32_t flags, AbilityInfoFlag abilityInfoFlag) const; 1080 void GetMatchAbilityInfos(const Want &want, int32_t flags, const InnerBundleInfo &info, 1081 int32_t userId, std::vector<AbilityInfo> &abilityInfos, 1082 const std::vector<std::string> ¶mMimeTypes, int32_t appIndex = 0) const; 1083 void AddSkillUrisInfo(const std::vector<Skill> &skills, std::vector<SkillUriForAbilityAndExtension> &skillUris, 1084 std::optional<size_t> matchSkillIndex, std::optional<size_t> matchUriIndex) const; 1085 void GetMatchAbilityInfosV9(const Want &want, int32_t flags, const InnerBundleInfo &info, 1086 int32_t userId, std::vector<AbilityInfo> &abilityInfos, 1087 const std::vector<std::string> ¶mMimeTypes, int32_t appIndex = 0) const; 1088 bool ExplicitQueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo, 1089 int32_t appIndex = 0) const; 1090 ErrCode ExplicitQueryAbilityInfoV9(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo, 1091 int32_t appIndex = 0) const; 1092 bool GenerateBundleId(const std::string &bundleName, int32_t &bundleId); 1093 int32_t GetUserIdByUid(int32_t uid) const; 1094 bool GetAllBundleInfos(int32_t flags, std::vector<BundleInfo> &bundleInfos) const; 1095 ErrCode GetAllBundleInfosV9(int32_t flags, std::vector<BundleInfo> &bundleInfos) const; 1096 bool ExplicitQueryExtensionInfo(const Want &want, int32_t flags, int32_t userId, 1097 ExtensionAbilityInfo &extensionInfo, int32_t appIndex = 0) const; 1098 bool ImplicitQueryExtensionInfos(const Want &want, int32_t flags, int32_t userId, 1099 std::vector<ExtensionAbilityInfo> &extensionInfos, int32_t appIndex = 0) const; 1100 ErrCode ImplicitQueryExtensionInfosV9(const Want &want, int32_t flags, int32_t userId, 1101 std::vector<ExtensionAbilityInfo> &extensionInfos, int32_t appIndex = 0) const; 1102 void GetMatchExtensionInfos(const Want &want, int32_t flags, const int32_t &userId, const InnerBundleInfo &info, 1103 std::vector<ExtensionAbilityInfo> &einfos, int32_t appIndex = 0) const; 1104 void GetMatchExtensionInfosV9(const Want &want, int32_t flags, int32_t userId, const InnerBundleInfo &info, 1105 std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex = 0) const; 1106 void GetAllExtensionInfos(uint32_t flags, int32_t userId, const InnerBundleInfo &info, 1107 std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex = 0) const; 1108 void GetOneExtensionInfosByExtensionTypeName(const std::string &typeName, uint32_t flags, int32_t userId, 1109 const InnerBundleInfo &info, std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex = 0) const; 1110 bool MatchUtd(Skill &skill, const std::string &utd, int32_t count) const; 1111 bool MatchUtd(const std::string &skillUtd, const std::string &wantUtd) const; 1112 bool MatchTypeWithUtd(const std::string &mimeType, const std::string &wantUtd) const; 1113 std::vector<int32_t> GetCloneAppIndexesNoLock(const std::string &bundleName, int32_t userId) const; 1114 void GetCloneAppInfo(const InnerBundleInfo &info, int32_t userId, int32_t flags, 1115 std::vector<ApplicationInfo> &appInfos) const; 1116 void GetCloneAppInfoV9(const InnerBundleInfo &info, int32_t userId, int32_t flags, 1117 std::vector<ApplicationInfo> &appInfos) const; 1118 #ifdef GLOBAL_RESMGR_ENABLE 1119 std::shared_ptr<Global::Resource::ResourceManager> GetResourceManager(const std::string &bundleName, 1120 const std::string &moduleName, int32_t userId, const std::string &localeInfo = Constants::EMPTY_STRING) const; 1121 #endif 1122 1123 void FilterAbilityInfosByModuleName(const std::string &moduleName, std::vector<AbilityInfo> &abilityInfos) const; 1124 void CreateGroupDir(const InnerBundleInfo &innerBundleInfo, int32_t userId) const; 1125 void InnerCreateEl5Dir(const CreateDirParam &el5Param); 1126 void SetEl5DirPolicy(const CreateDirParam &el5Param); 1127 1128 void FilterExtensionAbilityInfosByModuleName(const std::string &moduleName, 1129 std::vector<ExtensionAbilityInfo> &extensionInfos) const; 1130 void CompatibleOldBundleStateInKvDb(); 1131 void ResetBundleStateData(); 1132 bool QueryAbilityInfoWithFlags(const std::optional<AbilityInfo> &option, int32_t flags, int32_t userId, 1133 const InnerBundleInfo &innerBundleInfo, AbilityInfo &info, int32_t appIndex = 0) const; 1134 ErrCode QueryAbilityInfoWithFlagsV9(const std::optional<AbilityInfo> &option, int32_t flags, int32_t userId, 1135 const InnerBundleInfo &innerBundleInfo, AbilityInfo &info, 1136 int32_t appIndex = 0) const; 1137 bool ImplicitQueryCurAbilityInfos(const Want &want, int32_t flags, int32_t userId, 1138 std::vector<AbilityInfo> &abilityInfos, int32_t appIndex) const; 1139 ErrCode ImplicitQueryCurAbilityInfosV9(const Want &want, int32_t flags, int32_t userId, 1140 std::vector<AbilityInfo> &abilityInfos, int32_t appIndex) const; 1141 void ImplicitQueryAllAbilityInfos(const Want &want, int32_t flags, int32_t userId, 1142 std::vector<AbilityInfo> &abilityInfos, int32_t appIndex) const; 1143 void ImplicitQueryAllAbilityInfosV9(const Want &want, int32_t flags, int32_t userId, 1144 std::vector<AbilityInfo> &abilityInfos, int32_t appIndex) const; 1145 bool ImplicitQueryCurExtensionInfos(const Want &want, int32_t flags, int32_t userId, 1146 std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex) const; 1147 ErrCode ImplicitQueryCurExtensionInfosV9(const Want &want, int32_t flags, int32_t userId, 1148 std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex) const; 1149 void ImplicitQueryAllExtensionInfos(const Want &want, int32_t flags, int32_t userId, 1150 std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex) const; 1151 void ImplicitQueryAllExtensionInfosV9(const Want &want, int32_t flags, int32_t userId, 1152 std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex) const; 1153 ErrCode ImplicitQueryAllExtensionInfos(uint32_t flags, int32_t userId, 1154 std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex, const std::string &typeName = "") const; 1155 void GetMatchLauncherAbilityInfosForCloneInfos(const InnerBundleInfo& info, const AbilityInfo &abilityInfo, 1156 const InnerBundleUserInfo &bundleUserInfo, std::vector<AbilityInfo>& abilityInfos) const; 1157 void ModifyApplicationInfoByCloneInfo(const InnerBundleCloneInfo &cloneInfo, 1158 ApplicationInfo &applicationInfo) const; 1159 void ModifyBundleInfoByCloneInfo(const InnerBundleCloneInfo &cloneInfo, BundleInfo &bundleInfo) const; 1160 void GetCloneBundleInfos(const InnerBundleInfo& info, int32_t flags, int32_t userId, 1161 BundleInfo &bundleInfo, std::vector<BundleInfo> &bundleInfos) const; 1162 void GetBundleNameAndIndexByName(const std::string &keyName, std::string &bundleName, int32_t &appIndex) const; 1163 void GetCloneAbilityInfos(std::vector<AbilityInfo> &abilityInfos, 1164 const ElementName &element, int32_t flags, int32_t userId) const; 1165 void GetCloneAbilityInfosV9(std::vector<AbilityInfo> &abilityInfos, 1166 const ElementName &element, int32_t flags, int32_t userId) const; 1167 ErrCode ExplicitQueryCloneAbilityInfo(const ElementName &element, int32_t flags, int32_t userId, 1168 int32_t appIndex, AbilityInfo &abilityInfo) const; 1169 ErrCode ExplicitQueryCloneAbilityInfoV9(const ElementName &element, int32_t flags, int32_t userId, 1170 int32_t appIndex, AbilityInfo &abilityInfo) const; 1171 void ImplicitQueryCloneAbilityInfos( 1172 const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) const; 1173 bool ImplicitQueryCurCloneAbilityInfos(const Want &want, int32_t flags, int32_t userId, 1174 std::vector<AbilityInfo> &abilityInfos) const; 1175 void ImplicitQueryAllCloneAbilityInfos(const Want &want, int32_t flags, int32_t userId, 1176 std::vector<AbilityInfo> &abilityInfos) const; 1177 void ImplicitQueryCloneAbilityInfosV9( 1178 const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) const; 1179 bool ImplicitQueryCurCloneAbilityInfosV9(const Want &want, int32_t flags, int32_t userId, 1180 std::vector<AbilityInfo> &abilityInfos) const; 1181 void ImplicitQueryAllCloneAbilityInfosV9(const Want &want, int32_t flags, int32_t userId, 1182 std::vector<AbilityInfo> &abilityInfos) const; 1183 bool ImplicitQueryCurCloneExtensionAbilityInfos(const Want &want, int32_t flags, int32_t userId, 1184 std::vector<ExtensionAbilityInfo> &abilityInfos) const; 1185 ErrCode ImplicitQueryCurCloneExtensionAbilityInfosV9(const Want &want, int32_t flags, int32_t userId, 1186 std::vector<ExtensionAbilityInfo> &abilityInfos) const; 1187 bool ImplicitQueryAllCloneExtensionAbilityInfos(const Want &want, int32_t flags, int32_t userId, 1188 std::vector<ExtensionAbilityInfo> &infos) const; 1189 ErrCode ImplicitQueryAllCloneExtensionAbilityInfosV9(const Want &want, int32_t flags, int32_t userId, 1190 std::vector<ExtensionAbilityInfo> &abilityInfos) const; 1191 ErrCode CheckInnerBundleInfoWithFlags( 1192 const InnerBundleInfo &innerBundleInfo, const int32_t flags, int32_t userId, int32_t appIndex = 0) const; 1193 ErrCode CheckInnerBundleInfoWithFlagsV9( 1194 const InnerBundleInfo &innerBundleInfo, const int32_t flags, int32_t userId, int32_t appIndex = 0) const; 1195 void AddAppDetailAbilityInfo(InnerBundleInfo &info) const; 1196 void GetAllLauncherAbility(const Want &want, std::vector<AbilityInfo> &abilityInfos, 1197 const int32_t userId, const int32_t requestUserId) const; 1198 ErrCode GetLauncherAbilityByBundleName(const Want &want, std::vector<AbilityInfo> &abilityInfos, 1199 const int32_t userId, const int32_t requestUserId) const; 1200 void ModifyLauncherAbilityInfo(bool isStage, AbilityInfo &abilityInfo) const; 1201 bool MatchPrivateType(const Want &want, const std::vector<std::string> &supportExtNames, 1202 const std::vector<std::string> &supportMimeTypes, const std::vector<std::string> ¶mMimeTypes) const; 1203 bool UpdateOverlayInfo(const InnerBundleInfo &newInfo, InnerBundleInfo &oldInfo); 1204 void ResetExternalOverlayModuleState(const std::string &bundleName, const std::string &modulePackage); 1205 void BuildExternalOverlayConnection(const std::string &moduleName, InnerBundleInfo &oldInfo, int32_t userId); 1206 void RemoveOverlayInfoAndConnection(const InnerBundleInfo &innerBundleInfo, const std::string &bundleName); 1207 ErrCode FindAbilityInfoInBundleInfo(const InnerBundleInfo &innerBundleInfo, const std::string &moduleName, 1208 const std::string &abilityName, AbilityInfo &abilityInfo) const; 1209 void RestoreSandboxUidAndGid(std::map<int32_t, std::string> &bundleIdMap); 1210 bool IsUpdateInnerBundleInfoSatisified(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo) const; 1211 ErrCode ProcessBundleMenu(BundleInfo& bundleInfo, int32_t flag, bool clearData) const; 1212 bool MatchShare(const Want &want, const std::vector<Skill> &skills) const; 1213 std::vector<Skill> FindSkillsContainShareAction(const std::vector<Skill> &skills) const; 1214 void EmplaceExtensionInfo(const InnerBundleInfo &info, const std::vector<Skill> &skills, 1215 ExtensionAbilityInfo &extensionInfo, int32_t flags, int32_t userId, std::vector<ExtensionAbilityInfo> &infos, 1216 std::optional<size_t> matchSkillIndex, std::optional<size_t> matchUriIndex, int32_t appIndex = 0) const; 1217 void EmplaceAbilityInfo(const InnerBundleInfo &info, const std::vector<Skill> &skills, AbilityInfo &abilityInfo, 1218 int32_t flags, int32_t userId, std::vector<AbilityInfo> &infos, 1219 std::optional<size_t> matchSkillIndex, std::optional<size_t> matchUriIndex, int32_t appIndex = 0) const; 1220 void AddAppHspBundleName(const BundleType type, const std::string &bundleName); 1221 void ConvertServiceHspToSharedBundleInfo(const InnerBundleInfo &innerBundleInfo, 1222 std::vector<BaseSharedBundleInfo> &baseSharedBundleInfos) const; 1223 void ProcessBundleRouterMap(BundleInfo& bundleInfo, int32_t flag) const; 1224 void ProcessAllowedAcls(const InnerBundleInfo &newInfo, InnerBundleInfo &oldInfo) const; 1225 void FilterAbilityInfosByAppLinking(const Want &want, int32_t flags, 1226 std::vector<AbilityInfo> &abilityInfos) const; 1227 void GetMultiLauncherAbilityInfo(const Want& want, 1228 const InnerBundleInfo& info, const InnerBundleUserInfo &bundleUserInfo, 1229 int64_t installTime, std::vector<AbilityInfo>& abilityInfos) const; 1230 void CreateNewDataGroupInfo(const std::string &groupId, const int32_t userId, 1231 const DataGroupInfo &oldDataGroupInfo, DataGroupInfo &newDataGroupInfo); 1232 1233 void PreProcessAnyUserFlag(const std::string &bundleName, int32_t& flags, int32_t &userId) const; 1234 void PostProcessAnyUserFlags(int32_t flags, int32_t userId, 1235 int32_t originalUserId, BundleInfo &bundleInfo, const InnerBundleInfo &innerBundleInfo) const; 1236 void GetExtensionAbilityInfoByTypeName(uint32_t flags, int32_t userId, 1237 std::vector<ExtensionAbilityInfo> &infos, const std::string &typeName) const; 1238 bool GetShortcutInfosByInnerBundleInfo( 1239 const InnerBundleInfo &info, std::vector<ShortcutInfo> &shortcutInfos) const; 1240 std::string TryGetRawDataByExtractor(const std::string &hapPath, const std::string &profileName, 1241 const AbilityInfo &abilityInfo) const; 1242 private: 1243 mutable std::shared_mutex bundleInfoMutex_; 1244 mutable std::mutex stateMutex_; 1245 mutable std::shared_mutex bundleIdMapMutex_; 1246 mutable std::shared_mutex callbackMutex_; 1247 mutable ffrt::mutex eventCallbackMutex_; 1248 mutable std::shared_mutex bundleMutex_; 1249 mutable std::mutex multiUserIdSetMutex_; 1250 bool initialUserFlag_ = false; 1251 int32_t baseAppUid_ = Constants::BASE_APP_UID; 1252 // using for locking by bundleName 1253 std::unordered_map<std::string, std::mutex> bundleMutexMap_; 1254 // using for generating bundleId 1255 // key:bundleId 1256 // value:bundleName 1257 std::map<int32_t, std::string> bundleIdMap_; 1258 // save all created users. 1259 std::set<int32_t> multiUserIdsSet_; 1260 // use vector because these functions using for IPC, the bundleName may duplicate 1261 std::vector<sptr<IBundleStatusCallback>> callbackList_; 1262 // common event callback 1263 std::vector<sptr<IBundleEventCallback>> eventCallbackList_; 1264 // all installed bundles 1265 // key:bundleName 1266 // value:innerbundleInfo 1267 std::map<std::string, InnerBundleInfo> bundleInfos_; 1268 // key:bundle name 1269 std::map<std::string, InstallState> installStates_; 1270 // current-status:previous-statue pair 1271 std::multimap<InstallState, InstallState> transferStates_; 1272 std::shared_ptr<IBundleDataStorage> dataStorage_; 1273 std::shared_ptr<IPreInstallDataStorage> preInstallDataStorage_; 1274 std::shared_ptr<BundleStateStorage> bundleStateStorage_; 1275 std::shared_ptr<BundlePromise> bundlePromise_ = nullptr; 1276 std::shared_ptr<BundleSandboxAppHelper> sandboxAppHelper_; 1277 mutable std::mutex hspBundleNameMutex_; 1278 std::set<std::string> appServiceHspBundleName_; 1279 std::shared_ptr<IShortcutDataStorage> shortcutStorage_; 1280 std::shared_ptr<UninstallDataMgrStorageRdb> uninstallDataMgr_; 1281 }; 1282 } // namespace AppExecFwk 1283 } // namespace OHOS 1284 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_DATA_MGR_H 1285