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