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