1 /* 2 * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_MGR_SERVICE_EVENT_HANDLER_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_MGR_SERVICE_EVENT_HANDLER_H 18 19 #include <list> 20 #include <map> 21 #include <unordered_set> 22 23 #include "bundle_constants.h" 24 #include "bundle_data_mgr.h" 25 #include "bundle_mgr_host_impl.h" 26 #include "common_event_manager.h" 27 #include "common_event_subscriber.h" 28 #include "common_event_support.h" 29 #include "pre_install_exception_mgr.h" 30 #include "pre_scan_info.h" 31 #include "nlohmann/json.hpp" 32 33 namespace OHOS { 34 namespace AppExecFwk { 35 class BundleMgrService; 36 enum class ScanMode : uint8_t; 37 enum class ResultMode : uint8_t; 38 39 enum class ResultCode : uint8_t { 40 RECOVER_OK = 0, 41 REINSTALL_OK, 42 NO_INSTALLED_DATA, 43 SYSTEM_ERROR, 44 }; 45 46 enum OTAFlag : uint32_t { 47 CHECK_ELDIR = 0x00000001, 48 CHECK_LOG_DIR = 0x00000010, 49 CHECK_FILE_MANAGER_DIR = 0x00000100, 50 CHECK_SHADER_CAHCE_DIR = 0x00000200, 51 CHECK_PREINSTALL_DATA = 0x00000400, 52 CHECK_CLOUD_SHADER_DIR = 0x00000800, 53 CHECK_BACK_UP_DIR = 0x00001000, 54 CHECK_RECOVERABLE_APPLICATION_INFO = 0x00002000, 55 CHECK_INSTALL_SOURCE = 0x00004000, 56 DELETE_DEPRECATED_ARK_PATHS = 0x00008000, 57 }; 58 59 enum class ScanResultCode : uint8_t { 60 SCAN_HAS_DATA_PARSE_SUCCESS, 61 SCAN_HAS_DATA_PARSE_FAILED, 62 SCAN_NO_DATA, 63 }; 64 65 enum class ModuleUpdateStatus : uint8_t { 66 DEFAULT = 1, 67 UPDATE = 2, 68 REVERT = 3 69 }; 70 71 struct HmpBundlePathInfo { 72 std::string bundleName; 73 std::string hmpName; 74 std::string bundleDir; 75 std::string hspDir; 76 }; 77 78 class BMSEventHandler { 79 public: 80 BMSEventHandler(); 81 ~BMSEventHandler(); 82 /** 83 * @brief Get preInstall root dir list, 84 * which the catalog of production has higher priority. 85 * @param rootDirList Indicates the root dir list. 86 * @return 87 */ 88 static void GetPreInstallRootDirList(std::vector<std::string> &rootDirList); 89 /** 90 * @brief Load all preInstall infos from proFile. 91 * @return Returns true if get the preInstall list successfully; returns false otherwise. 92 */ 93 static bool LoadPreInstallProFile(); 94 /** 95 * @brief Clear all preInstall infos cache. 96 * @return 97 */ 98 static void ClearPreInstallCache(); 99 /** 100 * @brief Get the preInstall capability. 101 * @param preBundleConfigInfo Indicates the preBundleConfigInfo. 102 * @return Returns true if get the preInstall capability successfully; returns false otherwise. 103 */ 104 static bool GetPreInstallCapability(PreBundleConfigInfo &preBundleConfigInfo); 105 /** 106 * @brief Check extension type name in the configuration file. 107 * @param extensionTypeName Indicates the extensionTypeName to check in the configuration file. 108 * @return Returns true if the extensionTypeName is in the configuration file; returns false otherwise. 109 */ 110 static bool CheckExtensionTypeInConfig(const std::string &extensionTypeName); 111 /** 112 * @brief Has preInstall profile or not. 113 * @return Returns result. 114 */ 115 static bool HasPreInstallProfile(); 116 /** 117 * @brief Bms start event. 118 * @return 119 */ 120 void BmsStartEvent(); 121 122 static void ProcessRebootQuickFixBundleInstall(const std::string &path, bool isOta); 123 124 static void ProcessRebootQuickFixUnInstallAndRecover(const std::string &path); 125 126 static void SavePreInstallException(const std::string &bundleDir); 127 128 static void ProcessSystemBundleInstall( 129 const PreScanInfo &preScanInfo, 130 Constants::AppType appType, 131 int32_t userId = Constants::UNSPECIFIED_USERID); 132 133 static bool CheckOtaFlag(OTAFlag flag, bool &result); 134 135 static bool UpdateOtaFlag(OTAFlag flag); 136 private: 137 /** 138 * @brief Before Bms start. 139 * @return 140 */ 141 void BeforeBmsStart(); 142 /** 143 * @brief On Bms starting. 144 * @return 145 */ 146 void OnBmsStarting(); 147 /** 148 * @brief After Bms start. 149 * @return 150 */ 151 void AfterBmsStart(); 152 /** 153 * @brief Load install infos from db. 154 * @return Returns true if load successfully; returns false otherwise. 155 */ 156 bool LoadInstallInfosFromDb(); 157 /** 158 * @brief Guard against install infos lossed strategy. 159 * @return Returns ResultCode for recover install infos. 160 */ 161 ResultCode GuardAgainstInstallInfosLossedStrategy(); 162 /** 163 * @brief Scan and analyze install infos. 164 * @param installInfos Indicates the install infos. 165 * @return 166 */ 167 void ScanAndAnalyzeInstallInfos( 168 std::map<std::string, std::vector<InnerBundleInfo>> &installInfos); 169 /** 170 * @brief Scan and analyze common install dir. 171 * @param installInfos Indicates the install infos. 172 * @return 173 */ 174 void ScanInstallDir( 175 std::map<std::string, std::vector<std::string>> &hapPathsMap); 176 /** 177 * @brief Get preInstall haps. 178 * @param bundleDirs Indicates preInstall hapPath. 179 * @return 180 */ 181 void GetPreInstallDir(std::vector<std::string> &bundleDirs); 182 /** 183 * @brief Analyze hap to InnerBundleInfo. 184 * @param isPreInstallApp Indicates is preInstallApp or not. 185 * @param hapPathsMap Indicates the hapPathsMap which will be analyzed. 186 * @param installInfos Indicates the install infos. 187 * @return 188 */ 189 void AnalyzeHaps( 190 bool isPreInstallApp, 191 const std::map<std::string, std::vector<std::string>> &hapPathsMap, 192 std::map<std::string, std::vector<InnerBundleInfo>> &installInfos); 193 /** 194 * @brief Analyze hap to InnerBundleInfo. 195 * @param isPreInstallApp Indicates is preInstallApp or not. 196 * @param bundleDirs Indicates the bundleDirs which will be analyzed. 197 * @param installInfos Indicates the install infos. 198 * @return 199 */ 200 void AnalyzeHaps( 201 bool isPreInstallApp, 202 const std::vector<std::string> &bundleDirs, 203 std::map<std::string, std::vector<InnerBundleInfo>> &installInfos); 204 /** 205 * @brief Get preBundle install dir. 206 * @param bundleDirs Indicates the bundleDirs. 207 * @return 208 */ 209 void GetPreBundleDir(std::list<std::string> &bundleDirs); 210 /** 211 * @brief Check scaned hapPath whether end with .hap. 212 * @param hapPaths Indicates the hapPaths. 213 * @return Returns the checked hapPaths. 214 */ 215 std::vector<std::string> CheckHapPaths(const std::vector<std::string> &hapPaths); 216 /** 217 * @brief Collect install infos from parse result. 218 * @param hapInfos Indicates the parse result. 219 * @param installInfos Indicates the saved installInfos. 220 * @return. 221 */ 222 void CollectInstallInfos( 223 const std::unordered_map<std::string, InnerBundleInfo> &hapInfos, 224 std::map<std::string, std::vector<InnerBundleInfo>> &installInfos); 225 /** 226 * @brief Scan and analyze userDatas. 227 * @param userMaps Indicates the userMaps to save userInfo. 228 * @return Returns ScanResultCode if Scan and analyze infos successfully; returns false otherwise. 229 */ 230 ScanResultCode ScanAndAnalyzeUserDatas( 231 std::map<std::string, std::vector<InnerBundleUserInfo>> &userMaps); 232 /** 233 * @brief Analyze userDatas. 234 * @param userId Indicates the userId. 235 * @param userDataDir Indicates the userDataDir. 236 * @param userDataBundleName Indicates the userDataBundleName. 237 * @param userMaps Indicates the userMaps to save userInfo. 238 * @return Returns true if analyze infos successfully; returns false otherwise. 239 */ 240 bool AnalyzeUserData( 241 int32_t userId, const std::string &userDataDir, const std::string &userDataBundleName, 242 std::map<std::string, std::vector<InnerBundleUserInfo>> &userMaps); 243 /** 244 * @brief ReInstall all Apps from installDir. 245 * @return Returns the ResultCode indicates the result of this action. 246 */ 247 ResultCode ReInstallAllInstallDirApps(); 248 /** 249 * @brief Combine install infos and userInfos. 250 * @param installInfos Indicates the installInfos. 251 * @param userInfoMaps Indicates the userInfoMaps. 252 * @return Returns true if combine infos successfully; returns false otherwise. 253 */ 254 bool CombineBundleInfoAndUserInfo( 255 const std::map<std::string, std::vector<InnerBundleInfo>> &installInfos, 256 const std::map<std::string, std::vector<InnerBundleUserInfo>> &userInfoMaps); 257 /** 258 * @brief Save recover info to cache. 259 * @param info Indicates the InnerBundleInfo. 260 * @return 261 */ 262 void SaveInstallInfoToCache(InnerBundleInfo &info); 263 /** 264 * @brief Scan dir by scanMode and resultMode, this function will perform 265 * scan through installd because installd has higher permissions. 266 * @param scanMode Indicates the scanMode, 267 * which maybe SUB_FILE_ALL SUB_FILE_DIR or SUB_FILE_FILE. 268 * @param resultMode Indicates the resultMode, 269 * which maybe ABSOLUTE_PATH or RELATIVE_PATH. 270 * @param resultList Indicates the scan resultList. 271 * @return Returns true if Scan successfully; returns false otherwise. 272 */ 273 bool ScanDir(const std::string& dir, ScanMode scanMode, 274 ResultMode resultMode, std::vector<std::string> &resultList); 275 /** 276 * @brief Bundle boot start event. 277 * @return 278 */ 279 void BundleBootStartEvent(); 280 /** 281 * @brief Bundle reboot start event. 282 * @return 283 */ 284 void BundleRebootStartEvent(); 285 /** 286 * @brief start boot scan. 287 * @param userId Indicates the userId. 288 * @return 289 */ 290 void OnBundleBootStart(int32_t userId = Constants::UNSPECIFIED_USERID); 291 /** 292 * @brief Process boot bundle install from scan. 293 * @param userId Indicates the userId. 294 * @return 295 */ 296 void ProcessBootBundleInstallFromScan(int32_t userId); 297 /** 298 * @brief Process bundle install by scanInfos. 299 * @param userId Indicates the userId. 300 * @return 301 */ 302 void InnerProcessBootPreBundleProFileInstall(int32_t userId); 303 /** 304 * @brief Install bundles by scanDir. 305 * @param scanDir Indicates the scanDir. 306 * @param appType Indicates the bundle type. 307 * @param userId Indicates userId. 308 * @return 309 */ 310 void ProcessSystemBundleInstall( 311 const std::string &scanDir, 312 Constants::AppType appType, 313 int32_t userId = Constants::UNSPECIFIED_USERID); 314 /** 315 * @brief Install system shared bundle. 316 * @param sharedBundlePath Indicates the path of shared bundle. 317 * @param appType Indicates the bundle type. 318 * @return 319 */ 320 void ProcessSystemSharedBundleInstall(const std::string &sharedBundlePath, Constants::AppType appType); 321 /** 322 * @brief start reboot scan. 323 * @return 324 */ 325 void OnBundleRebootStart(); 326 /** 327 * @brief Process reboot bundle. 328 * @return 329 */ 330 void ProcessRebootBundle(); 331 /** 332 * @brief Obtains the PreInstallBundleInfo objects. 333 * @return Returns true if this function is successfully called; returns false otherwise. 334 */ 335 bool LoadAllPreInstallBundleInfos(); 336 /** 337 * @brief Process reboot bundle install. 338 * @return 339 */ 340 void ProcessRebootBundleInstall(); 341 /** 342 * @brief Process reboot bundle install by scanInfos. 343 * @return 344 */ 345 void ProcessReBootPreBundleProFileInstall(); 346 /** 347 * @brief Process reboot bundle install from scan. 348 * @return 349 */ 350 void ProcessRebootBundleInstallFromScan(); 351 /** 352 * @brief Process reboot install bundles by bundleList. 353 * @param bundleList Indicates store bundle list. 354 * @param appType Indicates the bundle type. 355 * @return 356 */ 357 void InnerProcessRebootBundleInstall( 358 const std::list<std::string> &bundleList, Constants::AppType appType); 359 /** 360 * @brief Process reboot install shared bundles by bundleList. 361 * @param bundleList Indicates store bundle list. 362 * @param appType Indicates the bundle type. 363 * @return 364 */ 365 void InnerProcessRebootSharedBundleInstall(const std::list<std::string> &bundleList, Constants::AppType appType); 366 /** 367 * @brief Process reboot install system hsp by bundleList. 368 * @param scanPathList Indicates store bundle list. 369 * @return 370 */ 371 void InnerProcessRebootSystemHspInstall(const std::list<std::string> &scanPathList); 372 /** 373 * @brief Reboot uninstall system and system vendor bundles. 374 * @return 375 */ 376 void ProcessRebootBundleUninstall(); 377 /** 378 * @brief Reboot uninstall appFwkService bundles. 379 * @return 380 */ 381 void ProcessRebootAppServiceUninstall(); 382 /** 383 * @brief Get bundle dir by scan. 384 * @param bundleDirs Indicates the return bundleDirs. 385 * @return 386 */ 387 void GetBundleDirFromScan(std::list<std::string> &bundleDirs); 388 /** 389 * @brief Process scan dir. 390 * @param dir Indicates the dir. 391 * @param bundleDirs Indicates the return bundleDirs. 392 * @return 393 */ 394 static void ProcessScanDir(const std::string &dir, std::list<std::string> &bundleDirs); 395 /** 396 * @brief Process parse pre bundle profile. 397 * @param dir Indicates the dir. 398 * @return 399 */ 400 static void ParsePreBundleProFile(const std::string &dir); 401 /** 402 * @brief Set the flag indicates that all system and vendor applications installed. 403 * @return 404 */ 405 void CreateAppInstallDir() const; 406 void SetAllInstallFlag() const; 407 /** 408 * @brief Check and parse hap. 409 * @param hapFilePath Indicates the absolute file path of the HAP. 410 * @param isPreInstallApp Indicates the hap is preInstallApp or not. 411 * @param infos Indicates the obtained BundleInfo object. 412 * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. 413 */ 414 bool CheckAndParseHapFiles(const std::string &hapFilePath, 415 bool isPreInstallApp, std::unordered_map<std::string, InnerBundleInfo> &infos); 416 bool CheckAndParseHapFiles(const std::vector<std::string> &realPaths, 417 bool isPreInstallApp, std::unordered_map<std::string, InnerBundleInfo> &infos); 418 /** 419 * @brief Parse hap. 420 * @param hapFilePath Indicates the absolute file path of the HAP. 421 * @param infos Indicates the obtained BundleInfo object. 422 * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. 423 */ 424 static bool ParseHapFiles( 425 const std::string &hapFilePath, 426 std::unordered_map<std::string, InnerBundleInfo> &infos); 427 /** 428 * @brief OTA Install system app and system vendor bundles. 429 * @param filePaths Indicates the filePaths. 430 * @param appType Indicates the bundle type. 431 * @param removable Indicates whether it can be removed. 432 * @return Returns true if this function called successfully; returns false otherwise. 433 */ 434 bool OTAInstallSystemBundle( 435 const std::vector<std::string> &filePaths, 436 Constants::AppType appType, 437 bool removable); 438 439 /** 440 * @brief OTA Install system app and system vendor bundles. 441 * @param filePaths Indicates the filePaths. 442 * @param bundleName Indicates the bundleName. 443 * @param appType Indicates the bundle type. 444 * @param removable Indicates whether it can be removed. 445 * @return Returns true if this function called successfully; returns false otherwise. 446 */ 447 static bool OTAInstallSystemBundleNeedCheckUser( 448 const std::vector<std::string> &filePaths, 449 const std::string &bundleName, 450 Constants::AppType appType, 451 bool removable); 452 /** 453 * @brief OTA Install system app and system vendor bundles. 454 * @param filePaths Indicates the filePaths. 455 * @param bundleName Indicates the bundleName. 456 * @param appType Indicates the bundle type. 457 * @param removable Indicates whether it can be removed. 458 * @param userIds Indicates the user to which the app needs to be installed. 459 * @return Returns true if this function called successfully; returns false otherwise. 460 */ 461 static bool OTAInstallSystemBundleTargetUser( 462 const std::vector<std::string> &filePaths, 463 const std::string &bundleName, 464 Constants::AppType appType, 465 bool removable, 466 const std::vector<int32_t> &userIds); 467 /** 468 * @brief OTA Install system app and system vendor shared bundles. 469 * @param filePaths Indicates the filePaths. 470 * @param appType Indicates the bundle type. 471 * @param removable Indicates whether it can be removed. 472 * @return Returns true if this function called successfully; returns false otherwise. 473 */ 474 bool OTAInstallSystemSharedBundle( 475 const std::vector<std::string> &filePaths, 476 Constants::AppType appType, 477 bool removable); 478 /** 479 * @brief OTA Install system hsp. 480 * @param filePaths Indicates the filePaths. 481 * @return Returns ERR_OK if this function called successfully; returns false otherwise. 482 */ 483 ErrCode OTAInstallSystemHsp(const std::vector<std::string> &filePaths); 484 /** 485 * @brief version is the same, determine whether to update based on the buildHash 486 * @param oldInfo Indicates the old innerBundleInfo. 487 * @param newInfo Indicates the new innerBundleInfo. 488 * @return Returns true if need to update. 489 */ 490 bool IsNeedToUpdateSharedHspByHash(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo) const; 491 /** 492 * @brief Used to determine whether the module has been installed. If the installation has 493 * been uninstalled, OTA install and upgrade will not be allowed. 494 * @param bundleName Indicates the bundleName. 495 * @param bundlePath Indicates the bundlePath. 496 * @return Returns true if this function called successfully; returns false otherwise. 497 */ 498 bool HasModuleSavedInPreInstalledDb( 499 const std::string &bundleName, const std::string &bundlePath); 500 /** 501 * @brief Delete preInstallInfo to Db. 502 * @param bundleName Indicates the bundleName. 503 * @param bundlePath Indicates the bundlePath. 504 */ 505 void DeletePreInfoInDb( 506 const std::string &bundleName, const std::string &bundlePath, bool bundleLevel); 507 /** 508 * @brief Add parseInfos to map. 509 * @param bundleName Indicates the bundleName. 510 * @param infos Indicates the infos. 511 */ 512 void AddParseInfosToMap(const std::string &bundleName, 513 const std::unordered_map<std::string, InnerBundleInfo> &infos); 514 /** 515 * @brief Clear cache. 516 */ 517 void ClearCache(); 518 /** 519 * @brief Judge whether the preInstall app can be removable. 520 * @param path Indicates the path. 521 * @return Returns true if the preInstall is removable; returns false otherwise. 522 */ 523 bool IsPreInstallRemovable(const std::string &path); 524 525 void AddTasks(const std::map<int32_t, std::vector<PreScanInfo>, 526 std::greater<int32_t>> &taskMap, int32_t userId); 527 void AddTaskParallel( 528 int32_t taskPriority, const std::vector<PreScanInfo> &tasks, int32_t userId); 529 530 bool InnerMultiProcessBundleInstall( 531 const std::unordered_map<std::string, std::pair<std::string, bool>> &needInstallMap, 532 Constants::AppType appType); 533 534 void ProcessCheckAppDataDir(); 535 void InnerProcessCheckAppDataDir(); 536 537 void ProcessCheckAppLogDir(); 538 void InnerProcessCheckAppLogDir(); 539 void ProcessCheckAppFileManagerDir(); 540 void InnerProcessCheckAppFileManagerDir(); 541 void ProcessCheckPreinstallData(); 542 void InnerProcessCheckPreinstallData(); 543 void ProcessCheckShaderCacheDir(); 544 void InnerProcessCheckShaderCacheDir(); 545 void ProcessCheckCloudShaderDir(); 546 void InnerProcessCheckCloudShaderDir(); 547 void InnerProcessCheckCloudShaderCommonDir(const int32_t uid, const int32_t gid); 548 void ProcessNewBackupDir(); 549 void ProcessCheckRecoverableApplicationInfo(); 550 void InnerProcessCheckRecoverableApplicationInfo(); 551 void ProcessCheckInstallSource(); 552 void InnerProcessCheckInstallSource(); 553 std::string ConvertApplicationFlagToInstallSource(int32_t flag); 554 555 bool InnerProcessUninstallForExistPreBundle(const BundleInfo &installedInfo); 556 557 void PrepareBundleDirQuota(const std::string &bundleName, const int32_t uid, 558 const std::string &bundleDataDirPath, const int32_t limitSize) const; 559 void RefreshQuotaForAllUid(); 560 void InnerProcessStockBundleRouterInfo(); 561 562 bool InnerProcessUninstallModule(const BundleInfo &bundleInfo, 563 const std::unordered_map<std::string, InnerBundleInfo> &infos, bool &isDownGrade); 564 bool InnerProcessUninstallAppServiceModule(const InnerBundleInfo &innerBundleInfo, 565 const std::unordered_map<std::string, InnerBundleInfo> &infos, bool &isDownGrade); 566 567 bool IsSystemUpgrade(); 568 bool IsTestSystemUpgrade(); 569 bool IsSystemFingerprintChanged(); 570 std::string GetCurSystemFingerprint(); 571 static std::string GetOldSystemFingerprint(); 572 bool GetSystemParameter(const std::string &key, std::string &value); 573 void SaveSystemFingerprint(); 574 void HandlePreInstallException(); 575 static bool IsHapPathExist(const BundleInfo &bundleInfo); 576 static bool IsHspPathExist(const InnerBundleInfo &innerBundleInfo); 577 578 bool FetchInnerBundleInfo(const std::string &bundleName, InnerBundleInfo &innerBundleInfo); 579 void GetPreInstallDirFromLoadProFile(std::vector<std::string> &bundleDirs); 580 void GetPreInstallDirFromScan(std::vector<std::string> &bundleDirs); 581 582 void InnerProcessBootSystemHspInstall(); 583 void ProcessSystemHspInstall(const PreScanInfo &preScanInfo); 584 bool ProcessSystemHspInstall(const std::string &systemHspDir); 585 586 static void AddStockAppProvisionInfoByOTA(const std::string &bundleName, const std::string &filePath); 587 void UpdateAppDataSelinuxLabel(const std::string &bundleName, const std::string &apl, 588 bool isPreInstall, bool debug); 589 static bool IsQuickfixPatchApp(const std::string &bundleName, uint32_t versionCode); 590 bool HotPatchAppProcessing(const std::string &bundleName, uint32_t hasInstallVersionCode, uint32_t hapVersionCode, 591 std::vector<int32_t> &userIds); 592 static bool GetValueFromJson(nlohmann::json &jsonObject); 593 static void PatchSystemHspInstall(const std::string &path, bool isOta); 594 static void PatchSystemBundleInstall(const std::string &path, bool isOta); 595 void HandleOTACodeEncryption(); 596 void SaveCodeProtectFlag(); 597 #ifdef USE_PRE_BUNDLE_PROFILE 598 void UpdateRemovable(const std::string &bundleName, bool removable); 599 void UpdateAllPrivilegeCapability(); 600 void UpdatePrivilegeCapability(const PreBundleConfigInfo &preBundleConfigInfo); 601 bool MatchSignature(const PreBundleConfigInfo &configInfo, const std::string &signature); 602 bool MatchOldSignatures(const PreBundleConfigInfo &configInfo, const std::vector<std::string> &appSignatures); 603 void UpdateTrustedPrivilegeCapability(const PreBundleConfigInfo &preBundleConfigInfo); 604 #endif 605 void DeletePreInstallExceptionAppService(const std::string &bundleDir); 606 void SavePreInstallExceptionAppService(const std::string &bundleDir); 607 void HandlePreInstallAppServicePathsException(std::shared_ptr<PreInstallExceptionMgr> preInstallExceptionMgr, 608 const std::set<std::string> &exceptionAppServicePaths); 609 void HandlePreInstallAppPathsException( 610 std::shared_ptr<PreInstallExceptionMgr> preInstallExceptionMgr, const std::set<std::string> &exceptionPaths); 611 void HandlePreInstallAppServiceBundleNamesException(std::shared_ptr<PreInstallExceptionMgr> preInstallExceptionMgr, 612 const std::set<std::string> &exceptionAppServiceBundleNames); 613 void HandlePreInstallBundleNamesException(std::shared_ptr<PreInstallExceptionMgr> preInstallExceptionMgr, 614 const std::set<std::string> &exceptionBundleNames); 615 bool IsModuleUpdate(); 616 void HandleModuleUpdate(); 617 bool GetModuleUpdatePathList( 618 std::map<std::string, std::vector<std::string>> &moduleUpdateAppServiceMap, 619 std::map<std::string, std::vector<std::string>> &moduleUpdateNotAppServiceMap); 620 bool HandleInstallHmp( 621 const std::map<std::string, std::vector<std::string>> &moduleUpdateAppServiceMap, 622 const std::map<std::string, std::vector<std::string>> &moduleUpdateNotAppServiceMap); 623 bool HandleInstallModuleUpdateSystemHsp(const std::vector<std::string> &appDirList); 624 bool HandleInstallModuleUpdateNormalApp(const std::vector<std::string> &appDirList); 625 bool CheckIsModuleUpdate(const std::string &str); 626 bool CheckAppIsUpdatedByUser(const std::string& appDir); 627 void FilterModuleUpdate(const std::vector<std::string> &preInstallDirs, 628 std::map<std::string, std::vector<std::string>> &moduleUpdateMap, bool isAppService); 629 std::string GetBundleNameByPreInstallPath(const std::string& path); 630 bool GetRemovableInfo(const std::string& bundleDir); 631 void GetHmpList(std::vector<std::string> &hmpList, 632 std::map<std::string, std::vector<std::string>> &moduleUpdateAppServiceMap, 633 std::map<std::string, std::vector<std::string>> &moduleUpdateNotAppServiceMap); 634 void ModuleUpdateRollBack(); 635 void ProcessModuleUpdateSystemParameters(); 636 void HandleHmpUninstall(); 637 void SaveHmpBundlePathInfo(const std::string &hmpName, 638 const std::string &bundleName, const std::string bundlePath, bool isAppService); 639 void ListeningUserUnlocked() const; 640 void RemoveUnreservedSandbox() const; 641 void HandleSceneBoard() const; 642 static void InnerProcessStockBundleProvisionInfo(); 643 bool UpdateModuleByHash(const BundleInfo &oldBundleInfo, const InnerBundleInfo &newInfo) const; 644 bool IsNeedToUpdateSharedAppByHash(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo) const; 645 void CheckALLResourceInfo(); 646 // Used to add bundle resource Info that does not exist in rdb when OTA. 647 void static ProcessBundleResourceInfo(); 648 // scan all bundle data group info 649 void ProcessAllBundleDataGroupInfo(); 650 // Used to send update failed event 651 void SendBundleUpdateFailedEvent(const BundleInfo &bundleInfo); 652 void ProcessAppTmpPath(); 653 void UpdatePreinstallDB(const std::unordered_map<std::string, std::pair<std::string, bool>> &needInstallMap); 654 void UpdatePreinstallDBForNotUpdatedBundle(const std::string &bundleName, 655 const std::unordered_map<std::string, InnerBundleInfo> &innerBundleInfos); 656 void InnerProcessRebootUninstallWrongBundle(); 657 bool InnerCheckSingletonBundleUserInfo(const InnerBundleInfo &bundleInfo); 658 void ProcessCheckAppEl1Dir(); 659 void static ProcessCheckAppEl1DirTask(); 660 // check el2 data dir for all userids's bundleinfos 661 void CheckAndCreateShareFilesSubDataDirs(); 662 void CleanAllBundleShaderCache() const; 663 void CleanTempDir() const; 664 bool CheckIsBundleUpdatedByHapPath(const BundleInfo &bundleInfo); 665 void CheckBundleProvisionInfo(); 666 void CheckBundleCloneEl1ShaderCacheLocal(const std::string &bundleName, int32_t appIndex, 667 int32_t userId, int32_t uid); 668 void CleanBundleCloneEl1ShaderCacheLocal(const std::string &bundleName, int32_t appIndex, 669 int32_t userId); 670 void CheckAllBundleEl1ShaderCacheLocal(); 671 void CleanAllBundleEl1ShaderCacheLocal(); 672 // Used to mark Whether trigger OTA check 673 bool needRebootOta_ = false; 674 // Used to notify bundle scan status 675 bool needNotifyBundleScanStatus_ = false; 676 677 bool hasLoadAllPreInstallBundleInfosFromDb_ = false; 678 // Used to mark module update status depend on system parameter 679 ModuleUpdateStatus moduleUpdateStatus_ = ModuleUpdateStatus::DEFAULT; 680 // Used to save the information parsed by Hap in the scanned directory. 681 std::map<std::string, std::unordered_map<std::string, InnerBundleInfo>> hapParseInfoMap_; 682 // Used to save application information that already exists in the Db. 683 std::map<std::string, PreInstallBundleInfo> loadExistData_; 684 // Used to mark every hmp install result 685 std::map<std::string, bool> moduleUpdateInstallResults_; 686 // Used to indicates not appService bundleName in hmp 687 std::map<std::string, std::set<std::string>> moduleUpdateNormalApp_; 688 // Used to indicates appService bundleName in hmp 689 std::map<std::string, std::set<std::string>> moduleUpdateAppService_; 690 // key is bundleName, value is HmpBundlePathInfo 691 std::map<std::string, HmpBundlePathInfo> hmpBundlePathInfos_; 692 }; 693 } // namespace AppExecFwk 694 } // namespace OHOS 695 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_MGR_SERVICE_EVENT_HANDLER_H 696