From 48dd31444acd3b2c06970f4468bf54c6183bce67 Mon Sep 17 00:00:00 2001 From: daiyujia Date: Tue, 26 Aug 2025 19:30:33 +0800 Subject: [PATCH] =?UTF-8?q?IssueNo:#ICUW9Q=20Description:[5.1.0]=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E9=A2=84=E8=A3=85=E5=BA=94=E7=94=A8=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=AE=89=E8=A3=85=20Sig:bundleManager=20Feature=20or=20Bugfix:?= =?UTF-8?q?Bugfix=20Binary=20Source:No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: daiyujia Change-Id: I2b1ef1df9f781900c475fdf87ac9837efa8d2d8a --- .../bundlemgr/include/bundle_service_constants.h | 1 + .../src/bundle_mgr_service_event_handler.cpp | 12 ++++++++++++ services/bundlemgr/src/bundle_user_mgr_host_impl.cpp | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/services/bundlemgr/include/bundle_service_constants.h b/services/bundlemgr/include/bundle_service_constants.h index d0bd0b24f1..97008399f0 100644 --- a/services/bundlemgr/include/bundle_service_constants.h +++ b/services/bundlemgr/include/bundle_service_constants.h @@ -88,6 +88,7 @@ constexpr const char* BUNDLE_ASAN_LOG_DIR = "/data/local/app-logs"; constexpr const char* SCREEN_LOCK_FILE_DATA_PATH = "/data/app/el5"; constexpr const char* GALLERY_DOWNLOAD_PATH = "/app_install/"; constexpr const char* GALLERY_CLONE_PATH = "/app_clone/"; +constexpr const char* PRELOAD_APP_DIR = "/preload/app/"; constexpr int NOT_EXIST_USERID = -5; constexpr int PATH_MAX_SIZE = 256; constexpr int32_t API_VERSION_NINE = 9; diff --git a/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp b/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp index b52b3d1147..3ca2084801 100644 --- a/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp +++ b/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp @@ -117,6 +117,7 @@ constexpr const char* BUNDLE_SCAN_FINISH = "1"; constexpr const char* CODE_PROTECT_FLAG = "codeProtectFlag"; constexpr const char* CODE_PROTECT_FLAG_CHECKED = "checked"; constexpr int64_t TEN_MB = 1024 * 1024 * 10; //10MB +constexpr int32_t USER_ID_SIZE = 1; std::set installList_; std::set onDemandInstallList_; @@ -1991,6 +1992,11 @@ void BMSEventHandler::InnerProcessRebootBundleInstall( AddParseInfosToMap(bundleName, infos); auto mapIter = loadExistData_.find(bundleName); if (mapIter == loadExistData_.end()) { + if (scanPathIter.find(ServiceConstants::PRELOAD_APP_DIR) == 0 && + dataMgr->GetAllUser().size() > USER_ID_SIZE) { + LOG_NOFUNC_I(BMS_TAG_DEFAULT, "ota skip new preload app: %{public}s", scanPathIter.c_str()); + continue; + } LOG_NOFUNC_I(BMS_TAG_DEFAULT, "OTA Install new -n %{public}s by path:%{public}s", bundleName.c_str(), scanPathIter.c_str()); std::vector filePaths { scanPathIter }; @@ -2012,6 +2018,12 @@ void BMSEventHandler::InnerProcessRebootBundleInstall( bundleName.c_str()); continue; } + if (!hasBundleInstalled && scanPathIter.find(ServiceConstants::PRELOAD_APP_DIR) == 0 && + dataMgr->GetAllUser().size() > USER_ID_SIZE) { + LOG_NOFUNC_W(BMS_TAG_DEFAULT, "app(%{public}s) is new preload app and do not need OTA install", + bundleName.c_str()); + continue; + } std::vector currentBundleUserIds; if (HotPatchAppProcessing(bundleName, hasInstalledInfo.versionCode, hapVersionCode, currentBundleUserIds)) { LOG_I(BMS_TAG_DEFAULT, "OTA Install prefab bundle(%{public}s) by path(%{public}s) for hotPatch upgrade", diff --git a/services/bundlemgr/src/bundle_user_mgr_host_impl.cpp b/services/bundlemgr/src/bundle_user_mgr_host_impl.cpp index f62d5dae32..e64a657e42 100644 --- a/services/bundlemgr/src/bundle_user_mgr_host_impl.cpp +++ b/services/bundlemgr/src/bundle_user_mgr_host_impl.cpp @@ -254,6 +254,10 @@ bool BundleUserMgrHostImpl::GetAllPreInstallBundleInfos( if (needToSkipPreBundleInstall && !preInfo.GetBundlePaths().empty() && (preInfo.GetBundlePaths().front().find(PRELOAD_APP) == 0)) { APP_LOGI("-n %{public}s -u %{public}d skip install", preInfo.GetBundleName().c_str(), userId); + preInfo.SetIsUninstalled(true); + if (!dataMgr->SavePreInstallBundleInfo(preInfo.GetBundleName(), preInfo)) { + APP_LOGW("save pre bundle %{public}s failed", preInfo.GetBundleName().c_str()); + } continue; } if (SkipThirdPreloadAppInstallation(userId, preInfo)) { -- Gitee