diff --git a/services/bundlemgr/include/bundle_service_constants.h b/services/bundlemgr/include/bundle_service_constants.h index d0bd0b24f162106398c4dfb3596220b69729fa1a..97008399f08ef8855e958a1188c68e30ddb9f53c 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 b52b3d1147d825f043fbcdae2beee79c622bac43..3ca20848016eb60faaafa5a8a6fe36f09469b908 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 f62d5dae3225417a19e2988171b2fc09e4b4f48d..e64a657e42bec8c16fd9e864eed487d0fdde8696 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)) {