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_BASE_BUNDLE_INSTALLER_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BASE_BUNDLE_INSTALLER_H 18 19 #include <map> 20 #include <unordered_map> 21 #include <string> 22 23 #include "nocopyable.h" 24 25 #include "access_token.h" 26 #include "bundle_app_spawn_client.h" 27 #include "bundle_common_event_mgr.h" 28 #include "bundle_data_mgr.h" 29 #include "bundle_install_checker.h" 30 #include "event_report.h" 31 #include "hap_token_info.h" 32 #include "install_param.h" 33 #include "installer_bundle_tmp_info.h" 34 #include "quick_fix/appqf_info.h" 35 #include "shared_bundle_installer.h" 36 37 #ifdef APP_DOMAIN_VERIFY_ENABLED 38 #include "app_domain_verify_mgr_client.h" 39 #endif 40 41 namespace OHOS { 42 namespace AppExecFwk { 43 class BaseBundleInstaller { 44 public: 45 BaseBundleInstaller(); 46 virtual ~BaseBundleInstaller(); 47 void SetCallingUid(int32_t callingUid); 48 49 protected: 50 bool otaInstall_ = false; 51 enum class InstallerState : uint8_t { 52 INSTALL_START, 53 INSTALL_BUNDLE_CHECKED = 5, 54 INSTALL_SYSCAP_CHECKED = 10, 55 INSTALL_SIGNATURE_CHECKED = 15, 56 INSTALL_PARSED = 20, 57 INSTALL_HAP_HASH_PARAM_CHECKED = 25, 58 INSTALL_OVERLAY_CHECKED = 30, 59 INSTALL_VERSION_AND_BUNDLENAME_CHECKED = 35, 60 INSTALL_NATIVE_SO_CHECKED = 40, 61 INSTALL_PROXY_DATA_CHECKED = 45, 62 INSTALL_REMOVE_SANDBOX_APP = 50, 63 INSTALL_EXTRACTED = 60, 64 INSTALL_INFO_SAVED = 80, 65 INSTALL_RENAMED = 90, 66 INSTALL_SUCCESS = 100, 67 INSTALL_FAILED, 68 }; 69 70 enum SingletonState { 71 DEFAULT, 72 SINGLETON_TO_NON = 1, 73 NON_TO_SINGLETON = 2, 74 }; 75 76 struct SharedBundleRollBackInfo { 77 std::vector<std::string> newDirs; // record newly created directories, delete when rollback 78 std::vector<std::string> newBundles; // record newly installed bundle, uninstall when rollback 79 std::unordered_map<std::string, InnerBundleInfo> backupBundles; // record initial InnerBundleInfo 80 }; 81 82 /** 83 * @brief The main function for system and normal bundle install. 84 * @param bundlePath Indicates the path for storing the HAP file of the application 85 * to install or update. 86 * @param installParam Indicates the install parameters. 87 * @param appType Indicates the application type. 88 * @return Returns ERR_OK if the application install successfully; returns error code otherwise. 89 */ 90 ErrCode InstallBundle( 91 const std::string &bundlePath, const InstallParam &installParam, const Constants::AppType appType); 92 /** 93 * @brief The main function for system and normal bundle install. 94 * @param bundlePaths Indicates the paths for storing the HAP file sof the application 95 * to install or update. 96 * @param installParam Indicates the install parameters. 97 * @param appType Indicates the application type. 98 * @return Returns ERR_OK if the application install successfully; returns error code otherwise. 99 */ 100 ErrCode InstallBundle(const std::vector<std::string> &bundlePaths, const InstallParam &installParam, 101 const Constants::AppType appType); 102 /** 103 * @brief The main function for uninstall a bundle. 104 * @param bundleName Indicates the bundle name of the application to uninstall. 105 * @param installParam Indicates the uninstall parameters. 106 * @return Returns ERR_OK if the application uninstall successfully; returns error code otherwise. 107 */ 108 ErrCode UninstallBundle(const std::string &bundleName, const InstallParam &installParam); 109 /** 110 * @brief The main function for uninstall a module in a specific bundle. 111 * @param bundleName Indicates the bundle name of the application to uninstall. 112 * @param modulePackage Indicates the module package of the module to uninstall. 113 * @param installParam Indicates the uninstall parameters. 114 * @return Returns ERR_OK if the application uninstall successfully; returns error code otherwise. 115 */ 116 ErrCode UninstallBundle( 117 const std::string &bundleName, const std::string &modulePackage, const InstallParam &installParam); 118 /** 119 * @brief The main function for uninstall a bundle by uninstallParam. 120 * @param uninstallParam Indicates the input of uninstallParam. 121 * @return Returns ERR_OK if the application uninstall successfully; returns error code otherwise. 122 */ 123 ErrCode CheckUninstallInnerBundleInfo(const InnerBundleInfo &info, const std::string &bundleName); 124 ErrCode UninstallBundleByUninstallParam(const UninstallParam &uninstallParam); 125 /** 126 * @brief Update the installer state. 127 * @attention This function changes the base class state only. 128 * @param state Indicates the state to be updated to. 129 * @return 130 */ 131 virtual void UpdateInstallerState(const InstallerState state); 132 /** 133 * @brief Get the installer state. 134 * @return The current state of the installer object. 135 */ GetInstallerState()136 inline InstallerState GetInstallerState() 137 { 138 return state_; 139 } 140 /** 141 * @brief Get the installer state. 142 * @param state Indicates the state to be updated to. 143 * @return 144 */ SetInstallerState(InstallerState state)145 inline void SetInstallerState(InstallerState state) 146 { 147 state_ = state; 148 } 149 GetCurrentBundleName()150 std::string GetCurrentBundleName() const 151 { 152 return bundleName_; 153 } 154 /** 155 * @brief The main function for bundle install by bundleName. 156 * @param bundleName Indicates the bundleName of the application to install. 157 * @param installParam Indicates the install parameters. 158 * @return Returns ERR_OK if the application install successfully; returns error code otherwise. 159 */ 160 ErrCode Recover(const std::string &bundleName, const InstallParam &installParam); 161 /** 162 * @brief The main function for bundle install by bundleName. 163 * @param bundleName Indicates the bundleName of the application to install. 164 * @param installParam Indicates the install parameters. 165 * @return Returns ERR_OK if the application install successfully; returns error code otherwise. 166 */ 167 ErrCode InstallBundleByBundleName(const std::string &bundleName, const InstallParam &installParam); 168 /** 169 * @brief Reset install properties. 170 */ 171 void ResetInstallProperties(); 172 /** 173 * @brief Reset install properties. 174 * @param isBootScene Indicates the event occurs in the boot phase. 175 */ MarkPreBundleSyeEventBootTag(bool isBootScene)176 void MarkPreBundleSyeEventBootTag(bool isBootScene) 177 { 178 sysEventInfo_.preBundleScene = 179 isBootScene ? InstallScene::BOOT : InstallScene::REBOOT; 180 } 181 182 bool NotifyAllBundleStatus(); 183 184 std::string GetCheckResultMsg() const; 185 186 void SetCheckResultMsg(const std::string checkResultMsg) const; 187 188 void SetVerifyPermissionResult(const Security::AccessToken::HapInfoCheckResult &checkResult); 189 190 ErrCode RollbackHmpUserInfo(const std::string &bundleName); 191 192 ErrCode RollbackHmpCommonInfo(const std::string &bundleName); 193 194 bool HasDriverExtensionAbility(const std::string &bundleName); 195 196 bool IsEnterpriseForAllUser(const InstallParam &installParam, const std::string &bundleName); 197 198 private: 199 /** 200 * @brief The real procedure for system and normal bundle install. 201 * @param bundlePath Indicates the path for storing the HAP file of the application 202 * to install or update. 203 * @param installParam Indicates the install parameters. 204 * @param appType Indicates the application type. 205 * @param uid Indicates the uid of the application. 206 * @param isRecover Indicates whether this is a recovery scenario. 207 * @return Returns ERR_OK if the bundle install successfully; returns error code otherwise. 208 */ 209 ErrCode ProcessBundleInstall(const std::vector<std::string> &bundlePaths, const InstallParam &installParam, 210 const Constants::AppType appType, int32_t &uid, bool isRecover = false); 211 212 ErrCode InnerProcessBundleInstall(std::unordered_map<std::string, InnerBundleInfo> &newInfos, 213 InnerBundleInfo &oldInfo, const InstallParam &installParam, int32_t &uid); 214 215 /** 216 * @brief The real procedure function for uninstall a bundle. 217 * @param bundleName Indicates the bundle name of the application to uninstall. 218 * @param installParam Indicates the uninstall parameters. 219 * @param uid Indicates the uid of the application. 220 * @return Returns ERR_OK if the bundle uninstall successfully; returns error code otherwise. 221 */ 222 ErrCode ProcessBundleUninstall(const std::string &bundleName, const InstallParam &installParam, int32_t &uid); 223 /** 224 * @brief The real procedure for uninstall a module in a specific bundle. 225 * @param bundleName Indicates the bundle name of the application to uninstall. 226 * @param modulePackage Indicates the module package of the module to uninstall. 227 * @param installParam Indicates the uninstall parameters. 228 * @param uid Indicates the uid of the application. 229 * @return Returns ERR_OK if the module uninstall successfully; returns error code otherwise. 230 */ 231 ErrCode ProcessBundleUninstall(const std::string &bundleName, const std::string &modulePackage, 232 const InstallParam &installParam, int32_t &uid); 233 /** 234 * @brief The process of installing a new bundle. 235 * @param info Indicates the InnerBundleInfo parsed from the config.json in the HAP package. 236 * @param uid Indicates the uid of the application. 237 * @return Returns ERR_OK if the new bundle install successfully; returns error code otherwise. 238 */ 239 ErrCode ProcessBundleInstallStatus(InnerBundleInfo &info, int32_t &uid); 240 /** 241 * @brief The process of installing a native bundle. 242 * @param info Indicates the InnerBundleInfo parsed from the config.json in the HAP package. 243 * @param uid Indicates the uid of the application. 244 * @return Returns ERR_OK if the native bundle install successfully; returns error code otherwise. 245 */ 246 ErrCode ProcessBundleInstallNative(InnerBundleInfo &info, int32_t &userId); 247 /** 248 * @brief The process of uninstalling a native bundle. 249 * @param info Indicates the InnerBundleInfo parsed from the config.json in the HAP package. 250 * @param uid Indicates the uid of the application. 251 * @param bundleName Indicates the bundleName of the application. 252 * @return Returns ERR_OK if the native bundle uninstall successfully; returns error code otherwise. 253 */ 254 ErrCode ProcessBundleUnInstallNative(InnerBundleInfo &info, int32_t &userId, std::string bundleName); 255 /** 256 * @brief The process of updating an exist bundle. 257 * @param oldInfo Indicates the exist InnerBundleInfo object get from the database. 258 * @param newInfo Indicates the InnerBundleInfo object parsed from the config.json in the HAP package. 259 * @param isReplace Indicates whether there is the replace flag in the install flag. 260 * @return Returns ERR_OK if the bundle updating successfully; returns error code otherwise. 261 */ 262 ErrCode ProcessBundleUpdateStatus(InnerBundleInfo &oldInfo, 263 InnerBundleInfo &newInfo, bool isReplace, bool killProcess = true); 264 /** 265 * @brief Remove a whole bundle. 266 * @param info Indicates the InnerBundleInfo object of a bundle. 267 * @param isKeepData Indicates that whether to save data. 268 * @return Returns ERR_OK if the bundle removed successfully; returns error code otherwise. 269 */ 270 ErrCode RemoveBundle(InnerBundleInfo &info, bool isKeepData, const bool async = false); 271 /** 272 * @brief Create the code and data directories of a bundle. 273 * @param info Indicates the InnerBundleInfo object of a bundle. 274 * @return Returns ERR_OK if the bundle directories created successfully; returns error code otherwise. 275 */ 276 ErrCode CreateBundleAndDataDir(InnerBundleInfo &info) const; 277 /** 278 * @brief Extract the code to temporilay directory and rename it. 279 * @param info Indicates the InnerBundleInfo object of a bundle. 280 * @param modulePath normal files decompression path. 281 * @return Returns ERR_OK if the bundle extract and renamed successfully; returns error code otherwise. 282 */ 283 ErrCode ExtractModule(InnerBundleInfo &info, const std::string &modulePath); 284 /** 285 * @brief Remove the code and data directories of a bundle. 286 * @param info Indicates the InnerBundleInfo object of a bundle. 287 * @param isKeepData Indicates that whether to save data. 288 * @return Returns ERR_OK if the bundle directories removed successfully; returns error code otherwise. 289 */ 290 ErrCode RemoveBundleAndDataDir(const InnerBundleInfo &info, bool isKeepData, const bool async = false); 291 /** 292 * @brief Remove the code and data directories of a module in a bundle. 293 * @param info Indicates the InnerBundleInfo object of a bundle. 294 * @param modulePackage Indicates the module to be removed. 295 * @param userId Indicates the userId. 296 * @param isKeepData Indicates that whether to save data. 297 * @return Returns ERR_OK if the bundle directories removed successfully; returns error code otherwise. 298 */ 299 ErrCode RemoveModuleAndDataDir(const InnerBundleInfo &info, 300 const std::string &modulePackage, int32_t userId, bool isKeepData) const; 301 /** 302 * @brief Remove the current installing module directory. 303 * @param info Indicates the InnerBundleInfo object of a bundle under installing. 304 * @return Returns ERR_OK if the module directory removed successfully; returns error code otherwise. 305 */ 306 ErrCode RemoveModuleDir(const std::string &modulePath) const; 307 /** 308 * @brief Extract files of the current installing module package. 309 * @param info Indicates the InnerBundleInfo object of a bundle under installing. 310 * @param modulePath normal files decompression path. 311 * @param targetSoPath so files decompression path. 312 * @param cpuAbi cpuAbi. 313 * @return Returns ERR_OK if the module files extraced successfully; returns error code otherwise. 314 */ 315 ErrCode ExtractModuleFiles(const InnerBundleInfo &info, const std::string &modulePath, 316 const std::string &targetSoPath, const std::string &cpuAbi); 317 /** 318 * @brief Rename the directory of current installing module package. 319 * @param info Indicates the InnerBundleInfo object of a bundle under installing. 320 * @return Returns ERR_OK if the module directory renamed successfully; returns error code otherwise. 321 */ 322 ErrCode RenameModuleDir(const InnerBundleInfo &info) const; 323 /** 324 * @brief The process of install a new module package. 325 * @param newInfo Indicates the InnerBundleInfo object parsed from the config.json in the HAP package. 326 * @param oldInfo Indicates the exist InnerBundleInfo object get from the database. 327 * @return Returns ERR_OK if the new module install successfully; returns error code otherwise. 328 */ 329 ErrCode ProcessNewModuleInstall(InnerBundleInfo &newInfo, InnerBundleInfo &oldInfo); 330 /** 331 * @brief The process of updating an exist module package. 332 * @param newInfo Indicates the InnerBundleInfo object parsed from the config.json in the HAP package. 333 * @param oldInfo Indicates the exist InnerBundleInfo object get from the database. 334 * @return Returns ERR_OK if the module updating successfully; returns error code otherwise. 335 */ 336 ErrCode ProcessModuleUpdate(InnerBundleInfo &newInfo, 337 InnerBundleInfo &oldInfo, bool isReplace, bool killProcess = true); 338 /** 339 * @brief The real procedure for bundle install by bundleName. 340 * @param bundleName Indicates the bundleName the application to install. 341 * @param installParam Indicates the install parameters. 342 * @param uid Indicates the uid of the application. 343 * @return Returns ERR_OK if the bundle install successfully; returns error code otherwise. 344 */ 345 ErrCode ProcessRecover( 346 const std::string &bundleName, const InstallParam &installParam, int32_t &uid); 347 /** 348 * @brief The real procedure for bundle install by bundleName. 349 * @param bundleName Indicates the bundleName the application to install. 350 * @param installParam Indicates the install parameters. 351 * @param uid Indicates the uid of the application. 352 * @return Returns ERR_OK if the bundle install successfully; returns error code otherwise. 353 */ 354 ErrCode ProcessInstallBundleByBundleName( 355 const std::string &bundleName, const InstallParam &installParam, int32_t &uid); 356 /** 357 * @brief The real procedure for bundle install by bundleName. 358 * @param bundleName Indicates the bundleName the application to install. 359 * @param installParam Indicates the install parameters. 360 * @param uid Indicates the uid of the application. 361 * @return Returns ERR_OK if the bundle install successfully; returns error code otherwise. 362 */ 363 ErrCode InnerProcessInstallByPreInstallInfo( 364 const std::string &bundleName, const InstallParam &installParam, int32_t &uid); 365 /** 366 * @brief Check syscap. 367 * @param bundlePaths Indicates the file paths of all HAP packages. 368 * @return Returns ERR_OK if the syscap satisfy; returns error code otherwise. 369 */ 370 ErrCode CheckSysCap(const std::vector<std::string> &bundlePaths); 371 /** 372 * @brief Check signature info of multiple haps. 373 * @param bundlePaths Indicates the file paths of all HAP packages. 374 * @param installParam Indicates the install parameters. 375 * @param hapVerifyRes Indicates the signature info. 376 * @return Returns ERR_OK if the every hap has signature info and all haps have same signature info. 377 */ 378 ErrCode CheckMultipleHapsSignInfo( 379 const std::vector<std::string> &bundlePaths, 380 const InstallParam &installParam, 381 std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes); 382 /** 383 * @brief To parse hap files and to obtain innerBundleInfo of each hap. 384 * @param bundlePaths Indicates the file paths of all HAP packages. 385 * @param installParam Indicates the install parameters. 386 * @param appType Indicates the app type of the hap. 387 * @param hapVerifyRes Indicates all signature info of all haps. 388 * @param infos Indicates the innerBundleinfo of each hap. 389 * @return Returns ERR_OK if each hap is parsed successfully; returns error code otherwise. 390 */ 391 ErrCode ParseHapFiles( 392 const std::vector<std::string> &bundlePaths, 393 const InstallParam &installParam, 394 const Constants::AppType appType, 395 std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes, 396 std::unordered_map<std::string, InnerBundleInfo> &infos); 397 398 ErrCode CheckShellInstall(std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes); 399 400 #ifdef X86_EMULATOR_MODE 401 ErrCode CheckShellInstallForEmulator(std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes); 402 #endif 403 404 ErrCode CheckShellInstallInOobe(); 405 406 ErrCode CheckInstallCondition(std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes, 407 std::unordered_map<std::string, InnerBundleInfo> &infos, bool isSysCapValid); 408 409 ErrCode CheckInstallPermission(const InstallParam &installParam, 410 std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes); 411 /** 412 * @brief To check dependency whether or not exists. 413 * @param infos Indicates all innerBundleInfo for all haps need to be installed. 414 * @param sharedBundleInstaller Cross-app shared bundle installer 415 * @return Returns ERR_OK if haps checking successfully; returns error code otherwise. 416 */ 417 ErrCode CheckDependency(std::unordered_map<std::string, InnerBundleInfo> &infos, 418 const SharedBundleInstaller &sharedBundleInstaller); 419 420 /** 421 * @brief To check the hap hash param. 422 * @param infos .Indicates all innerBundleInfo for all haps need to be installed. 423 * @param hashParams .Indicates all hashParams in installParam. 424 * @return Returns ERR_OK if haps checking successfully; returns error code otherwise. 425 */ 426 ErrCode CheckHapHashParams( 427 std::unordered_map<std::string, InnerBundleInfo> &infos, 428 std::map<std::string, std::string> hashParams); 429 /** 430 * @brief To check the version code and bundleName in all haps. 431 * @param infos .Indicates all innerBundleInfo for all haps need to be installed. 432 * @return Returns ERR_OK if haps checking successfully; returns error code otherwise. 433 */ 434 ErrCode CheckAppLabelInfo(const std::unordered_map<std::string, InnerBundleInfo> &infos); 435 436 /** 437 * @brief send notify to start install applicaiton 438 * @param installParam Indicates the install parameters. 439 * @param infos .Indicates all innerBundleInfo for all haps need to be installed. 440 */ 441 void SendStartInstallNotify(const InstallParam &installParam, 442 const std::unordered_map<std::string, InnerBundleInfo> &infos); 443 444 ErrCode CheckSharedBundleLabelInfo(std::unordered_map<std::string, InnerBundleInfo> &infos); 445 /** 446 * @brief To check native file in all haps. 447 * @param infos .Indicates all innerBundleInfo for all haps need to be installed. 448 * @return Returns ERR_OK if haps checking successfully; returns error code otherwise. 449 */ 450 ErrCode CheckMultiNativeFile( 451 std::unordered_map<std::string, InnerBundleInfo> &infos); 452 /** 453 * @brief To roll back when the installation is failed. 454 * @param infos .Indicates the innerBundleInfo needs to be roll back. 455 * @param oldInfo Indicates the original innerBundleInfo of the bundle. 456 * @return Returns ERR_OK if roll back successfully; returns error code otherwise. 457 */ 458 void RollBack(const InnerBundleInfo &info, InnerBundleInfo &oldInfo); 459 /** 460 * @brief To check the version code and bundleName in all haps. 461 * @param newInfos .Indicates all innerBundleInfo for all haps need to be rolled back. 462 * @param oldInfo Indicates the original innerBundleInfo of the bundle. 463 * @return Returns ERR_OK if roll back successfully; returns error code otherwise. 464 */ 465 void RollBack(const std::unordered_map<std::string, InnerBundleInfo> &newInfos, InnerBundleInfo &oldInfo); 466 /** 467 * @brief To remove innerBundleInfo or moduleInfo of the corresponding haps. 468 * @param bundleName Indicates the bundle name of the bundle which needs to be removed innerBundleInfo or 469 * moudleInfo. 470 * @param packageName Indicates the package name of the hap which needs to be removed the moduleInfo. 471 * @return Returns ERR_OK if the removing is successful; returns error code otherwise. 472 */ 473 void RemoveInfo(const std::string &bundleName, const std::string &packageName); 474 /** 475 * @brief To roll back the moduleInfo of the corresponding haps. 476 * @param bundleName Indicates the bundle name of the bundle which needs to be rolled back the moudleInfo. 477 * @param oldInfo Indicates the original innerBundleInfo of the bundle. 478 * @return Returns ERR_OK if the rollback is successful; returns error code otherwise. 479 */ 480 void RollBackModuleInfo(const std::string &bundleName, InnerBundleInfo &oldInfo); 481 /** 482 * @brief To obtain the innerBundleInfo of the corresponding hap. 483 * @param info Indicates the innerBundleInfo obtained. 484 * @param isAppExist Indicates if the innerBundleInfo is existed or not. 485 * @return Returns ERR_OK if the innerBundleInfo is obtained successfully; returns error code otherwise. 486 */ 487 bool GetInnerBundleInfoWithDisable(InnerBundleInfo &info, bool &isAppExist); 488 /** 489 * @brief To check whether the version code is compatible for application or not. 490 * @param oldInfo Indicates the original innerBundleInfo of the bundle. 491 * @return Returns ERR_OK if version code is checked successfully; returns error code otherwise. 492 */ 493 ErrCode CheckVersionCompatibility(const InnerBundleInfo &oldInfo); 494 /** 495 * @brief To check whether the version code is compatible for application or not. 496 * @param oldInfo Indicates the original innerBundleInfo of the bundle. 497 * @return Returns ERR_OK if version code is checked successfully; returns error code otherwise. 498 */ 499 ErrCode CheckVersionCompatibilityForApplication(const InnerBundleInfo &oldInfo); 500 /** 501 * @brief To check whether the version code is compatible for openharmony service or not. 502 * @param info Indicates the original innerBundleInfo of the bundle. 503 * @return Returns ERR_OK if version code is checked successfully; returns error code otherwise. 504 */ 505 ErrCode CheckVersionCompatibilityForHmService(const InnerBundleInfo &oldInfo); 506 /** 507 * @brief To uninstall lower version feature haps. 508 * @param info Indicates the innerBundleInfo of the bundle. 509 * @param packageVec Indicates the array of package names of the high version entry or feature hap. 510 * @return Returns ERR_OK if uninstall successfully; returns error code otherwise. 511 */ 512 ErrCode UninstallLowerVersionFeature(const std::vector<std::string> &packageVec, bool killProcess = false); 513 /** 514 * @brief To get userId. 515 * @param installParam Indicates the installParam of the bundle. 516 * @return Returns userId. 517 */ 518 int32_t GetUserId(const int32_t &userId) const; 519 /** 520 * @brief Remove bundle user data. 521 * @param innerBundleInfo Indicates the innerBundleInfo of the bundle. 522 * @param needRemoveData Indicates need remove data or not. 523 * @return Returns BundleUserMgr. 524 */ 525 ErrCode RemoveBundleUserData( 526 InnerBundleInfo &innerBundleInfo, bool needRemoveData = true, const bool async = false); 527 /** 528 * @brief Create bundle user data. 529 * @param innerBundleInfo Indicates the bundle type of the application. 530 * @return Returns ERR_OK if result is ok; returns error code otherwise. 531 */ 532 ErrCode CreateBundleUserData(InnerBundleInfo &innerBundleInfo); 533 void AddBundleStatus(const NotifyBundleEvents &installRes); 534 ErrCode CheckInstallationFree(const InnerBundleInfo &innerBundleInfo, 535 const std::unordered_map<std::string, InnerBundleInfo> &infos) const; 536 537 bool UninstallAppControl(const std::string &appId, int32_t userId); 538 539 ErrCode InstallNormalAppControl(const std::string &installAppId, int32_t userId, bool isPreInstallApp = false); 540 541 ErrCode CreateBundleCodeDir(InnerBundleInfo &info) const; 542 ErrCode CreateBundleDataDir(InnerBundleInfo &info) const; 543 ErrCode RemoveBundleCodeDir(const InnerBundleInfo &info) const; 544 ErrCode RemoveBundleDataDir( 545 const InnerBundleInfo &info, bool forException = false, const bool async = false); 546 void RemoveEmptyDirs(const std::unordered_map<std::string, InnerBundleInfo> &infos) const; 547 std::string GetModuleNames(const std::unordered_map<std::string, InnerBundleInfo> &infos) const; 548 ErrCode UpdateHapToken(bool needUpdate, InnerBundleInfo &newInfo); 549 ErrCode SetDirApl(const InnerBundleInfo &info); 550 ErrCode SetDirApl( 551 int32_t userId, const std::string &bundleName, const std::string &CloneBundleName, 552 const std::string &appPrivilegeLevel, bool isPreInstallApp, const std::string &appProvisionType); 553 /** 554 * @brief Check to set isRemovable true when install. 555 * @param newInfos Indicates all innerBundleInfo for all haps need to be installed. 556 * @param oldInfo Indicates the original innerBundleInfo of the bundle. 557 * @param userId Indicates the userId. 558 * @param isFreeInstallFlag Indicates whether is FREE_INSTALL flag. 559 * @param isAppExist Indicates whether app is exist. 560 * @return 561 */ 562 void CheckEnableRemovable(std::unordered_map<std::string, InnerBundleInfo> &newInfos, 563 InnerBundleInfo &oldInfo, int32_t &userId, bool isFreeInstallFlag, bool isAppExist); 564 /** 565 * @brief Save oldInfo isRemovable to newInfo isRemovable. 566 * @param newModuleInfo Indicates the old innerModuleInfo of the bundle.. 567 * @param oldInfo Indicates the old innerBundleInfo of the bundle. 568 * @param existModule Indicates whether module is exist. 569 * @return 570 */ 571 void SaveOldRemovableInfo(InnerModuleInfo &newModuleInfo, InnerBundleInfo &oldInfo, bool existModule); 572 /** 573 * @brief Save hap path to records. 574 * @param isPreInstallApp Indicates isPreInstallApp or not. 575 * @param infos Indicates all innerBundleInfo for all haps need to be installed. 576 * @return 577 */ 578 void SaveHapPathToRecords( 579 bool isPreInstallApp, const std::unordered_map<std::string, InnerBundleInfo> &infos); 580 void OnSingletonChange(bool killProcess); 581 void RestoreHaps(const std::vector<std::string> &bundlePaths, const InstallParam &installParam); 582 bool AllowSingletonChange(const std::string &bundleName); 583 void MarkPreInstallState(const std::string &bundleName, bool isUninstalled); 584 ErrCode UninstallAllSandboxApps(const std::string &bundleName, int32_t userId = Constants::INVALID_USERID); 585 ErrCode CheckAppLabel(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo) const; 586 bool CheckReleaseTypeIsCompatible(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo) const; 587 void SendBundleSystemEvent(const std::string &bundleName, BundleEventType bundleEventType, 588 const InstallParam &installParam, InstallScene preBundleScene, ErrCode errCode); 589 ErrCode CheckNativeFileWithOldInfo( 590 const InnerBundleInfo &oldInfo, std::unordered_map<std::string, InnerBundleInfo> &newInfos); 591 bool HasAllOldModuleUpdate( 592 const InnerBundleInfo &oldInfo, const std::unordered_map<std::string, InnerBundleInfo> &newInfos); 593 ErrCode CheckArkNativeFileWithOldInfo( 594 const InnerBundleInfo &oldInfo, std::unordered_map<std::string, InnerBundleInfo> &newInfos); 595 ErrCode CheckNativeSoWithOldInfo( 596 const InnerBundleInfo &oldInfo, std::unordered_map<std::string, InnerBundleInfo> &newInfos); 597 ErrCode NotifyBundleStatus(const NotifyBundleEvents &installRes); 598 void AddNotifyBundleEvents(const NotifyBundleEvents ¬ifyBundleEvents); 599 void ProcessHqfInfo(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo); 600 ErrCode ProcessDiffFiles(const AppqfInfo &appQfInfo, const std::string &nativeLibraryPath, 601 const std::string &cpuAbi) const; 602 ErrCode ProcessDeployedHqfInfo(const std::string &nativeLibraryPath, 603 const std::string &cpuAbi, const InnerBundleInfo &newInfo, const AppQuickFix &appQuickFix); 604 ErrCode ProcessDeployingHqfInfo( 605 const std::string &nativeLibraryPath, const std::string &cpuAbi, const InnerBundleInfo &newInfo) const; 606 ErrCode UpdateLibAttrs(const InnerBundleInfo &newInfo, 607 const std::string &cpuAbi, const std::string &nativeLibraryPath, AppqfInfo &appQfInfo) const; 608 bool CheckHapLibsWithPatchLibs( 609 const std::string &nativeLibraryPath, const std::string &hqfLibraryPath) const; 610 ErrCode ExtractArkNativeFile(InnerBundleInfo &info, const std::string &modulePath); 611 ErrCode DeleteOldArkNativeFile(const InnerBundleInfo &oldInfo); 612 int32_t GetConfirmUserId( 613 const int32_t &userId, std::unordered_map<std::string, InnerBundleInfo> &newInfos); 614 ErrCode CheckUserId(const int32_t &userId) const; 615 ErrCode CreateArkProfile( 616 const std::string &bundleName, int32_t userId, int32_t uid, int32_t gid) const; 617 ErrCode DeleteArkProfile(const std::string &bundleName, int32_t userId) const; 618 bool RemoveDataPreloadHapFiles(const std::string &bundleName) const; 619 bool IsDataPreloadHap(const std::string &path) const; 620 ErrCode ExtractArkProfileFile(const std::string &modulePath, const std::string &bundleName, 621 int32_t userId) const; 622 ErrCode ExtractAllArkProfileFile(const InnerBundleInfo &oldInfo, bool checkRepeat = false) const; 623 ErrCode CopyPgoFileToArkProfileDir(const std::string &moduleName, const std::string &modulePath, 624 const std::string &bundleName, int32_t userId) const; 625 ErrCode CopyPgoFile(const std::string &moduleName, const std::string &pgoPath, 626 const std::string &bundleName, int32_t userId) const; 627 ErrCode CheckOverlayInstallation(std::unordered_map<std::string, InnerBundleInfo> &newInfos, int32_t userId); 628 ErrCode CheckOverlayUpdate(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo, int32_t userId) const; 629 NotifyType GetNotifyType(); 630 void KillRelatedProcessIfArkWeb(bool isOta); 631 ErrCode CheckAppService( 632 const InnerBundleInfo &newInfo, const InnerBundleInfo &oldInfo, bool isAppExist); 633 ErrCode CheckSingleton(const InnerBundleInfo &newInfo, const int32_t userId); 634 void GetCallingEventInfo(EventInfo &eventInfo); 635 void GetInstallEventInfo(EventInfo &eventInfo); 636 void GetInstallEventInfo(const InnerBundleInfo &bundleInfo, EventInfo &eventInfo); 637 ErrCode CheckArkProfileDir(const InnerBundleInfo &newInfo, const InnerBundleInfo &oldInfo) const; 638 ErrCode ProcessAsanDirectory(InnerBundleInfo &info) const; 639 ErrCode CleanAsanDirectory(InnerBundleInfo &info) const; 640 void AddAppProvisionInfo(const std::string &bundleName, 641 const Security::Verify::ProvisionInfo &provisionInfo, const InstallParam &installParam) const; 642 void UpdateRouterInfo(); 643 void DeleteRouterInfo(const std::string &bundleName, const std::string &moduleName = ""); 644 ErrCode UninstallHspBundle(std::string &uninstallDir, const std::string &bundleName); 645 ErrCode UninstallHspVersion(std::string &uninstallDir, int32_t versionCode, InnerBundleInfo &info); 646 ErrCode CheckProxyDatas(const std::unordered_map<std::string, InnerBundleInfo> &newInfos); 647 bool CheckDuplicateProxyData(const std::unordered_map<std::string, InnerBundleInfo> &newInfos); 648 bool CheckDuplicateProxyData(const InnerBundleInfo &newInfo, const InnerBundleInfo &oldInfo); 649 bool CheckDuplicateProxyData(const std::vector<ProxyData> &proxyDatas); 650 bool CheckApiInfo(const std::unordered_map<std::string, InnerBundleInfo> &infos); 651 ErrCode InnerProcessNativeLibs(InnerBundleInfo &info, const std::string &modulePath); 652 ErrCode CheckSoEncryption(InnerBundleInfo &info, const std::string &cpuAbi, const std::string &targetSoPath); 653 bool ExtractSoFiles(const std::string &soPath, const std::string &cpuAbi) const; 654 void ProcessOldNativeLibraryPath(const std::unordered_map<std::string, InnerBundleInfo> &newInfos, 655 uint32_t oldVersionCode, const std::string &oldNativeLibraryPath) const; 656 void ProcessAOT(bool isOTA, const std::unordered_map<std::string, InnerBundleInfo> &infos) const; 657 void RemoveOldHapIfOTA(const InstallParam &installParam, 658 const std::unordered_map<std::string, InnerBundleInfo> &newInfos, const InnerBundleInfo &oldInfo); 659 ErrCode CopyHapsToSecurityDir(const InstallParam &installParam, std::vector<std::string> &bundlePaths); 660 ErrCode ParseHapPaths(const InstallParam &installParam, const std::vector<std::string> &inBundlePaths, 661 std::vector<std::string> &parsedPaths); 662 ErrCode RenameAllTempDir(const std::unordered_map<std::string, InnerBundleInfo> &newInfos) const; 663 ErrCode FindSignatureFileDir(const std::string &moduleName, std::string &signatureFileDir); 664 ErrCode MoveFileToRealInstallationDir(const std::unordered_map<std::string, InnerBundleInfo> &infos); 665 std::string GetTempHapPath(const InnerBundleInfo &info); 666 ErrCode SaveHapToInstallPath(const std::unordered_map<std::string, InnerBundleInfo> &infos, 667 const InnerBundleInfo &oldInfo); 668 ErrCode CheckHapEncryption(const std::unordered_map<std::string, InnerBundleInfo> &infos, 669 const InnerBundleInfo &oldInfo, bool isHapCopied = true); 670 void UpdateEncryptionStatus(const std::unordered_map<std::string, InnerBundleInfo> &infos, 671 const InnerBundleInfo &oldInfo, InnerBundleInfo &newInfo); 672 bool IsBundleEncrypted(const std::unordered_map<std::string, InnerBundleInfo> &infos, 673 const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo); 674 void UpdateAppInstallControlled(int32_t userId); 675 ErrCode MoveSoFileToRealInstallationDir(const std::unordered_map<std::string, InnerBundleInfo> &infos, 676 bool needDeleteOldLibraryPath); 677 ErrCode FinalProcessHapAndSoForBundleUpdate(const std::unordered_map<std::string, InnerBundleInfo> &infos, 678 bool needCopyHapToInstallPath, bool needDeleteOldLibraryPath); 679 void GetDataGroupIds(const std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes, 680 std::unordered_set<std::string> &groupIds); 681 void GenerateNewUserDataGroupInfos(InnerBundleInfo &info) const; 682 void RemoveOldGroupDirs(const InnerBundleInfo &oldInfo); 683 ErrCode RemoveDataGroupDirs(const std::string &bundleName, int32_t userId, bool isKeepData = false) const; 684 void DeleteGroupDirsForException(const InnerBundleInfo &oldInfo) const; 685 ErrCode CreateDataGroupDirs( 686 const std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes, const InnerBundleInfo &oldInfo); 687 bool NeedDeleteOldNativeLib( 688 const std::unordered_map<std::string, InnerBundleInfo> &newInfos, 689 const InnerBundleInfo &oldInfo); 690 ErrCode UninstallBundleFromBmsExtension(const std::string &bundleName); 691 ErrCode CheckBundleInBmsExtension(const std::string &bundleName, int32_t userId); 692 ErrCode CheckMDMUpdateBundleForSelf(const InstallParam &installParam, InnerBundleInfo &oldInfo, 693 const std::unordered_map<std::string, InnerBundleInfo> &newInfos, bool isAppExist); 694 void ExtractResourceFiles(const InnerBundleInfo &info, const std::string &targetPath) const; 695 void RemoveTempSoDir(const std::string &tempSoDir); 696 bool CheckAppIdentifier(const std::string &oldAppIdentifier, const std::string &newAppIdentifier, 697 const std::string &oldAppId, const std::string &newAppId); 698 ErrCode InstallEntryMoudleFirst(std::unordered_map<std::string, InnerBundleInfo> &newInfos, 699 InnerBundleInfo &bundleInfo, const InnerBundleUserInfo &innerBundleUserInfo, const InstallParam &installParam); 700 void ProcessQuickFixWhenInstallNewModule(const InstallParam &installParam, 701 const std::unordered_map<std::string, InnerBundleInfo> &newInfos); 702 bool ExtractEncryptedSoFiles(const InnerBundleInfo &info, const std::string &tmpSoPath, int32_t uid) const; 703 void SetOldAppIsEncrypted(const InnerBundleInfo &oldInfo); 704 bool UpdateEncryptedStatus(const InnerBundleInfo &oldInfo); 705 bool DeleteEncryptedStatus(const std::string &bundleName, int32_t uid); 706 void ProcessEncryptedKeyExisted(int32_t res, uint32_t type, 707 const std::vector<CodeProtectBundleInfo> &infos); 708 ErrCode VerifyCodeSignatureForNativeFiles(InnerBundleInfo &info, const std::string &cpuAbi, 709 const std::string &targetSoPath, const std::string &signatureFileDir) const; 710 ErrCode VerifyCodeSignatureForHap(const std::unordered_map<std::string, InnerBundleInfo> &infos, 711 const std::string &srcHapPath, const std::string &realHapPath); 712 ErrCode DeliveryProfileToCodeSign() const; 713 ErrCode RemoveProfileFromCodeSign(const std::string &bundleName) const; 714 ErrCode ExtractResFileDir(const std::string &modulePath) const; 715 ErrCode ExtractHnpFileDir(const std::string &cpuAbi, const std::string &hnpPackageInfoString, 716 const std::string &modulePath) const; 717 void DeleteOldNativeLibraryPath() const; 718 std::string GetRealSoPath(const std::string &bundleName, const std::string &nativeLibraryPath, 719 bool isNeedDeleteOldPath) const; 720 void RemoveTempPathOnlyUsedForSo(const InnerBundleInfo &innerBundleInfo) const; 721 void GenerateOdid(std::unordered_map<std::string, InnerBundleInfo> &infos, 722 const std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes) const; 723 void SetAppDistributionType(const std::unordered_map<std::string, InnerBundleInfo> &infos); 724 ErrCode CreateShaderCache(const std::string &bundleName, int32_t uid, int32_t gid) const; 725 ErrCode DeleteShaderCache(const std::string &bundleName) const; 726 ErrCode CleanShaderCache(const InnerBundleInfo &oldInfo, const std::string &bundleName) const; 727 void CreateCloudShader(const std::string &bundleName, int32_t uid, int32_t gid) const; 728 ErrCode DeleteCloudShader(const std::string &bundleName) const; 729 bool VerifyActivationLock() const; 730 bool VerifyActivationLockToken() const; 731 std::vector<std::string> GenerateScreenLockProtectionDir(const std::string &bundleName) const; 732 void CreateScreenLockProtectionDir(); 733 void CreateEl5AndSetPolicy(InnerBundleInfo &info); 734 void DeleteScreenLockProtectionDir(const std::string bundleName) const; 735 void DeleteEncryptionKeyId(const InnerBundleUserInfo &userInfo, bool isKeepData) const; 736 #ifdef APP_DOMAIN_VERIFY_ENABLED 737 void PrepareSkillUri(const std::vector<Skill> &skills, std::vector<AppDomainVerify::SkillUri> &skillUris) const; 738 #endif 739 void PrepareBundleDirQuota(const std::string &bundleName, const int32_t uid, 740 const std::string &bundleDataDirPath, const int32_t limitSize) const; 741 void VerifyDomain(); 742 void ClearDomainVerifyStatus(const std::string &appIdentifier, const std::string &bundleName) const; 743 bool IsRdDevice() const; 744 void SetAtomicServiceModuleUpgrade(const InnerBundleInfo &oldInfo); 745 void UpdateExtensionSandboxInfo(std::unordered_map<std::string, InnerBundleInfo> &newInfos, 746 const std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes); 747 void GetValidDataGroupIds(const std::vector<std::string> &extensionDataGroupIds, 748 const std::vector<std::string> &bundleDataGroupIds, std::vector<std::string> &validGroupIds) const; 749 void GetExtensionDirsChange(std::unordered_map<std::string, InnerBundleInfo> &newInfos, 750 const InnerBundleInfo &oldInfo); 751 void GetCreateExtensionDirs(std::unordered_map<std::string, InnerBundleInfo> &newInfos); 752 void GetRemoveExtensionDirs( 753 std::unordered_map<std::string, InnerBundleInfo> &newInfos, const InnerBundleInfo &oldInfo); 754 void CreateExtensionDataDir(InnerBundleInfo &info) const; 755 void RemoveCreatedExtensionDirsForException() const; 756 void RemoveOldExtensionDirs() const; 757 ErrCode InnerProcessUpdateHapToken(const bool isOldSystemApp); 758 bool InitDataMgr(); 759 std::string GetInstallSource(const InstallParam &installParam) const; 760 void SetApplicationFlagsAndInstallSource(std::unordered_map<std::string, InnerBundleInfo> &infos, 761 const InstallParam &installParam) const; 762 bool IsAppInBlocklist(const std::string &bundleName, const int32_t userId) const; 763 bool CheckWhetherCanBeUninstalled(const std::string &bundleName, const std::string &appIdentifier) const; 764 void CheckSystemFreeSizeAndClean() const; 765 void CheckBundleNameAndStratAbility(const std::string &bundleName, const std::string &appIdentifier) const; 766 void GetUninstallBundleInfo(bool isKeepData, int32_t userId, 767 const InnerBundleInfo &oldInfo, UninstallBundleInfo &uninstallBundleInfo); 768 bool CheckInstallOnKeepData(const std::string &bundleName, bool isOTA, 769 const std::unordered_map<std::string, InnerBundleInfo> &infos); 770 void SaveUninstallBundleInfo(const std::string bundleName, bool isKeepData, 771 const UninstallBundleInfo &uninstallBundleInfo); 772 void DeleteUninstallBundleInfo(const std::string &bundleName); 773 void SetFirstInstallTime(const std::string &bundleName, const int64_t &time, InnerBundleInfo &info); 774 bool SaveFirstInstallBundleInfo(const std::string &bundleName, const int32_t userId, 775 bool isPreInstallApp, const InnerBundleUserInfo &innerBundleUserInfo); 776 ErrCode MarkInstallFinish(); 777 bool IsArkWeb(const std::string &bundleName) const; 778 void UninstallDebugAppSandbox(const std::string &bundleName, const int32_t uid, 779 const InnerBundleInfo& innerBundleInfo); 780 ErrCode CheckAppDistributionType(); 781 #ifdef WEBVIEW_ENABLE 782 ErrCode VerifyArkWebInstall(); 783 #endif 784 785 bool SetDisposedRuleWhenBundleUpdateStart(const std::unordered_map<std::string, InnerBundleInfo> &infos, 786 const InnerBundleInfo &oldBundleInfo, bool isPreInstallApp); 787 788 bool DeleteDisposedRuleWhenBundleUpdateEnd(const InnerBundleInfo &oldBundleInfo); 789 790 bool SetDisposedRuleWhenBundleUninstallStart(const std::string &bundleName, 791 const std::string &appId, bool isMultiUser); 792 bool DeleteDisposedRuleWhenBundleUninstallEnd(const std::string &bundleName, 793 const std::string &appId, bool isMultiUser); 794 bool AddAppGalleryHapToTempPath(const bool isPreInstallApp, 795 const std::unordered_map<std::string, InnerBundleInfo> &infos); 796 bool DeleteAppGalleryHapFromTempPath(); 797 void ProcessAddResourceInfo(const InstallParam &installParam, const std::string &bundleName, int32_t userId); 798 bool GetTempBundleInfo(InnerBundleInfo &info) const; 799 bool InitTempBundleFromCache(InnerBundleInfo &info, bool &isAppExist, std::string bundleName = ""); 800 ErrCode UpdateAppEncryptedStatus(const std::string &bundleName, bool isExisted, int32_t appIndex); 801 void CheckPreBundle(const std::unordered_map<std::string, InnerBundleInfo> &newInfos, 802 const InstallParam &installParam, bool isRecover); 803 ErrCode CheckShellCanInstallPreApp(const std::unordered_map<std::string, InnerBundleInfo> &newInfos); 804 bool DeleteUninstallBundleInfoFromDb(const std::string &bundleName); 805 806 bool RecoverHapToken(const std::string &bundleName, const int32_t userId, 807 Security::AccessToken::AccessTokenIDEx& accessTokenIdEx, const InnerBundleInfo &innerBundleInfo); 808 std::string GetAssetAccessGroups(const std::string &bundleName); 809 std::string GetDeveloperId(const std::string &bundleName); 810 void GetModuleNames(const std::string &bundleName, std::vector<std::string> &moduleNames); 811 void UpdateKillApplicationProcess(const InnerBundleInfo &innerBundleInfo); 812 ErrCode CheckPreAppAllowHdcInstall(const InstallParam &installParam, 813 const std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes); 814 void CheckPreBundleRecoverResult(ErrCode &result); 815 816 bool IsAllowEnterPrise(); 817 void MarkIsForceUninstall(const std::string &bundleName, bool isForceUninstalled); 818 bool CheckCanInstallPreBundle(const std::string &bundleName, const int32_t userId); 819 820 bool isAppExist_ = false; 821 bool isContainEntry_ = false; 822 bool isAppService_ = false; 823 // value is packageName for uninstalling 824 bool isFeatureNeedUninstall_ = false; 825 // for quick fix 826 bool needDeleteQuickFixInfo_ = false; 827 bool hasInstalledInUser_ = false; 828 bool isModuleUpdate_ = false; 829 bool isEntryInstalled_ = false; 830 bool isEnterpriseBundle_ = false; 831 bool isInternaltestingBundle_ = false; 832 // When it is true, it means that the same bundleName and same userId was uninstalled with keepData before 833 bool existBeforeKeepDataApp_ = false; 834 bool copyHapToInstallPath_ = false; 835 bool needSetDisposeRule_ = false; 836 bool needDeleteAppTempPath_ = false; 837 InstallerState state_ = InstallerState::INSTALL_START; 838 uint32_t versionCode_ = 0; 839 uint32_t accessTokenId_ = 0; 840 uint32_t oldApplicationReservedFlag_ = 0; 841 842 int32_t userId_ = Constants::INVALID_USERID; 843 int32_t overlayType_ = NON_OVERLAY_TYPE; 844 int32_t atomicServiceModuleUpgrade_ = 0; 845 SingletonState singletonState_ = SingletonState::DEFAULT; 846 BundleType bundleType_ = BundleType::APP; 847 std::string bundleName_; 848 std::string moduleTmpDir_; 849 std::string modulePath_; 850 std::string baseDataPath_; 851 std::string modulePackage_; 852 std::string mainAbility_; 853 std::string moduleName_; 854 std::string uninstallBundleAppId_; 855 std::string entryModuleName_ = ""; 856 std::string appDistributionType_; 857 std::string appIdentifier_ = ""; 858 std::unique_ptr<BundleInstallChecker> bundleInstallChecker_ = nullptr; 859 std::shared_ptr<BundleDataMgr> dataMgr_ = nullptr; // this pointer will get when public functions called 860 // key is package name, value is boolean 861 std::unordered_map<std::string, bool> installedModules_; 862 std::vector<std::string> uninstallModuleVec_; 863 std::map<std::string, std::string> hapPathRecords_; 864 // utilizing for code-signature 865 std::map<std::string, std::string> verifyCodeParams_; 866 std::vector<std::string> toDeleteTempHapPath_; 867 std::vector<NotifyBundleEvents> bundleEvents_; 868 // key is the temp path of hap or hsp 869 // value is the signature file path 870 std::map<std::string, std::string> signatureFileMap_; 871 std::vector<std::string> bundlePaths_; 872 std::unordered_map<std::string, std::string> signatureFileTmpMap_; 873 // utilize for install entry firstly from multi-installation 874 std::map<std::string, std::string> pgoParams_; 875 std::map<std::string, std::string> targetSoPathMap_; 876 // indicates sandboxd dirs need to create by extension 877 std::vector<std::string> newExtensionDirs_; 878 // indicates sandboxd dirs need to create by extension 879 std::vector<std::string> createExtensionDirs_; 880 // indicates sandboxd dirs need to remove by extension 881 std::vector<std::string> removeExtensionDirs_; 882 // used to record system event infos 883 EventInfo sysEventInfo_; 884 Security::Verify::HapVerifyResult verifyRes_; 885 InstallerBundleTempInfo tempInfo_; 886 // indicates whether the application has been restored to the preinstall 887 bool isPreBundleRecovered_ = false; 888 889 DISALLOW_COPY_AND_MOVE(BaseBundleInstaller); 890 891 #define CHECK_RESULT(errcode, errmsg) \ 892 do { \ 893 if ((errcode) != ERR_OK) { \ 894 APP_LOGE(errmsg, errcode); \ 895 return errcode; \ 896 } \ 897 } while (0) 898 899 #define CHECK_RESULT_WITH_ROLLBACK(errcode, errmsg, newInfos, oldInfo) \ 900 do { \ 901 if ((errcode) == ERR_APPEXECFWK_INSTALL_SINGLETON_NOT_SAME || \ 902 (errcode) == ERR_APPEXECFWK_INSTALL_ZERO_USER_WITH_NO_SINGLETON) { \ 903 APP_LOGE(errmsg, errcode); \ 904 return errcode; \ 905 } \ 906 \ 907 if ((errcode) != ERR_OK) { \ 908 APP_LOGE(errmsg, errcode); \ 909 RollBack(newInfos, oldInfo); \ 910 return errcode; \ 911 } \ 912 } while (0) 913 }; 914 } // namespace AppExecFwk 915 } // namespace OHOS 916 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BASE_BUNDLE_INSTALLER_H 917