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