diff --git a/services/backup_sa/include/module_ipc/service.h b/services/backup_sa/include/module_ipc/service.h index a093d680cfa80bc30a96622aab7520a885e5f56e..7cf4f70060ed9cb011236dc9001f32b3eac2c51c 100644 --- a/services/backup_sa/include/module_ipc/service.h +++ b/services/backup_sa/include/module_ipc/service.h @@ -419,9 +419,12 @@ private: * * @param bundleNames: bundleNames list * @param userId: userId + * @param backupBundleInfos: backupBundleInfos + * @param isIncBackup: isIncBackup * */ - void SetCurrentBackupSessProperties(const std::vector &bundleNames, int32_t userId); + void SetCurrentBackupSessProperties(const std::vector &bundleNames, int32_t userId, + std::vector &backupBundleInfos, bool isIncBackup); /** * @brief send userid to app @@ -526,10 +529,10 @@ private: void HandleExceptionOnAppendBundles(sptr session, const vector &appendBundleNames, const vector &restoreBundleNames); - + void BundleBeginRadarReport(const std::string &bundleName, const ErrCode errCode, const IServiceReverse::Scenario scenario); - + void BundleEndRadarReport(const std::string &bundleName, const ErrCode errCode, const IServiceReverse::Scenario scenario); @@ -538,11 +541,14 @@ private: void ExtensionConnectFailRadarReport(const std::string &bundleName, const ErrCode errCode, const IServiceReverse::Scenario scenario); - + void UpdateFailedBundles(const std::string &bundleName, BundleTaskInfo taskInfo); void ClearFailedBundles(); void CreateDirIfNotExist(const std::string &path); + + std::vector GetSupportBackupBundleNames(vector &bundleInfos, + bool isIncBackup); private: static sptr instance_; static std::mutex instanceLock_; diff --git a/services/backup_sa/src/module_ipc/service.cpp b/services/backup_sa/src/module_ipc/service.cpp index 5b07f1b0a702e06d13b3135df20f039b3d922328..f6091143e8e7a33a64c2034c9aa134c670f0c491 100644 --- a/services/backup_sa/src/module_ipc/service.cpp +++ b/services/backup_sa/src/module_ipc/service.cpp @@ -651,7 +651,7 @@ void Service::SetCurrentSessProperties(std::vector HILOGI("bundleName: %{public}s, extensionName: %{public}s", restoreInfo.name.c_str(), restoreInfo.extensionName.c_str()); std::string bundleNameIndexInfo = BJsonUtil::BuildBundleNameIndexInfo(restoreInfo.name, restoreInfo.appIndex); - if ((restoreInfo.allToBackup == false && !SpecialVersion(restoreInfo.versionName)) || + if ((!restoreInfo.allToBackup && !SpecialVersion(restoreInfo.versionName)) || (restoreInfo.extensionName.empty() && !SAUtils::IsSABundleName(restoreInfo.name))) { OnBundleStarted(BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), session_, bundleNameIndexInfo); session_->RemoveExtInfo(bundleNameIndexInfo); @@ -661,10 +661,10 @@ void Service::SetCurrentSessProperties(std::vector session_->SetBundleVersionCode(bundleNameIndexInfo, restoreInfo.versionCode); session_->SetBundleVersionName(bundleNameIndexInfo, restoreInfo.versionName); session_->SetBundleDataSize(bundleNameIndexInfo, restoreInfo.spaceOccupied); - session_->SetBackupExtName(bundleNameIndexInfo, restoreInfo.extensionName); if (BundleMgrAdapter::IsUser0BundleName(bundleNameIndexInfo, session_->GetSessionUserId())) { SendUserIdToApp(bundleNameIndexInfo, session_->GetSessionUserId()); } + session_->SetBackupExtName(bundleNameIndexInfo, restoreInfo.extensionName); } HILOGI("End"); } @@ -733,7 +733,7 @@ void Service::SetCurrentSessProperties(std::vector HILOGD("bundleName: %{public}s, extensionName: %{public}s", restoreInfo.name.c_str(), restoreInfo.extensionName.c_str()); std::string bundleNameIndexInfo = BJsonUtil::BuildBundleNameIndexInfo(restoreInfo.name, restoreInfo.appIndex); - if ((restoreInfo.allToBackup == false && !SpecialVersion(restoreInfo.versionName)) || + if ((!restoreInfo.allToBackup && !SpecialVersion(restoreInfo.versionName)) || (restoreInfo.extensionName.empty() && !SAUtils::IsSABundleName(restoreInfo.name))) { OnBundleStarted(BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), session_, bundleNameIndexInfo); session_->RemoveExtInfo(bundleNameIndexInfo); @@ -743,7 +743,6 @@ void Service::SetCurrentSessProperties(std::vector session_->SetBundleVersionCode(bundleNameIndexInfo, restoreInfo.versionCode); session_->SetBundleVersionName(bundleNameIndexInfo, restoreInfo.versionName); session_->SetBundleDataSize(bundleNameIndexInfo, restoreInfo.spaceOccupied); - session_->SetBackupExtName(bundleNameIndexInfo, restoreInfo.extensionName); auto iter = isClearDataFlags.find(bundleNameIndexInfo); if (iter != isClearDataFlags.end()) { session_->SetClearDataFlag(bundleNameIndexInfo, iter->second); @@ -763,25 +762,11 @@ void Service::SetCurrentSessProperties(std::vector HILOGI("current bundle, unicast info:%{public}s", GetAnonyString(uniCastInfo.detail).c_str()); session_->SetBackupExtInfo(bundleNameIndexInfo, uniCastInfo.detail); } + session_->SetBackupExtName(bundleNameIndexInfo, restoreInfo.extensionName); } HILOGI("End"); } -void Service::SetCurrentSessProperties(BJsonEntityCaps::BundleInfo &info, - std::map &isClearDataFlags, const std::string &bundleNameIndexInfo) -{ - if (session_ == nullptr) { - HILOGE("Set currrent session properties error, session is empty"); - return; - } - session_->SetBundleDataSize(bundleNameIndexInfo, info.spaceOccupied); - session_->SetBackupExtName(bundleNameIndexInfo, info.extensionName); - auto iter = isClearDataFlags.find(bundleNameIndexInfo); - if (iter != isClearDataFlags.end()) { - session_->SetClearDataFlag(bundleNameIndexInfo, iter->second); - } -} - ErrCode Service::AppendBundlesBackupSession(const vector &bundleNames) { HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); @@ -794,22 +779,9 @@ ErrCode Service::AppendBundlesBackupSession(const vector &bundleName VerifyCaller(IServiceReverse::Scenario::BACKUP); auto bundleDetails = MakeDetailList(bundleNames); auto backupInfos = BundleMgrAdapter::GetBundleInfosForAppend(bundleDetails, session_->GetSessionUserId()); - session_->AppendBundles(bundleNames); - for (auto info : backupInfos) { - HILOGI("Current backupInfo bundleName:%{public}s, extName:%{public}s, appIndex:%{public}d", - info.name.c_str(), info.extensionName.c_str(), info.appIndex); - std::string bundleNameIndexInfo = BJsonUtil::BuildBundleNameIndexInfo(info.name, info.appIndex); - session_->SetBundleDataSize(bundleNameIndexInfo, info.spaceOccupied); - session_->SetBackupExtName(bundleNameIndexInfo, info.extensionName); - if (info.allToBackup == false) { - session_->GetServiceReverseProxy()->BackupOnBundleStarted( - BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), bundleNameIndexInfo); - BundleBeginRadarReport(bundleNameIndexInfo, BError(BError::Codes::SA_FORBID_BACKUP_RESTORE).GetCode(), - IServiceReverse::Scenario::BACKUP); - session_->RemoveExtInfo(bundleNameIndexInfo); - } - } - SetCurrentBackupSessProperties(bundleNames, session_->GetSessionUserId()); + std::vector supportBackupNames = GetSupportBackupBundleNames(backupInfos, false); + session_->AppendBundles(supportBackupNames); + SetCurrentBackupSessProperties(supportBackupNames, session_->GetSessionUserId(), backupInfos, false); OnStartSched(); session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); return BError(BError::Codes::OK); @@ -849,7 +821,8 @@ ErrCode Service::AppendBundlesDetailsBackupSession(const vector &bun session_->GetSessionUserId(), isClearDataFlags); auto bundleDetails = MakeDetailList(bundleNames); auto backupInfos = BundleMgrAdapter::GetBundleInfosForAppend(bundleDetails, session_->GetSessionUserId()); - session_->AppendBundles(bundleNames); + std::vector supportBackupNames = GetSupportBackupBundleNames(backupInfos, false); + session_->AppendBundles(supportBackupNames); HandleCurGroupBackupInfos(backupInfos, bundleNameDetailMap, isClearDataFlags); OnStartSched(); session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); @@ -876,19 +849,13 @@ void Service::HandleCurGroupBackupInfos(std::vector info.name.c_str(), info.extensionName.c_str(), info.appIndex); std::string bundleNameIndexInfo = BJsonUtil::BuildBundleNameIndexInfo(info.name, info.appIndex); SetCurrentSessProperties(info, isClearDataFlags, bundleNameIndexInfo); - if (info.allToBackup == false) { - session_->GetServiceReverseProxy()->BackupOnBundleStarted( - BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), bundleNameIndexInfo); - BundleBeginRadarReport(bundleNameIndexInfo, BError(BError::Codes::SA_FORBID_BACKUP_RESTORE).GetCode(), - IServiceReverse::Scenario::BACKUP); - session_->RemoveExtInfo(bundleNameIndexInfo); - } BJsonUtil::BundleDetailInfo uniCastInfo; if (BJsonUtil::FindBundleInfoByName(bundleNameDetailMap, bundleNameIndexInfo, UNICAST_TYPE, uniCastInfo)) { HILOGI("current bundle:%{public}s, unicast info:%{public}s", bundleNameIndexInfo.c_str(), GetAnonyString(uniCastInfo.detail).c_str()); session_->SetBackupExtInfo(bundleNameIndexInfo, uniCastInfo.detail); } + session_->SetBackupExtName(bundleNameIndexInfo, info.extensionName); } } @@ -1303,7 +1270,9 @@ void Service::ClearSessionAndSchedInfo(const string &bundleName) StopAll(nullptr, true); return; } - sched_->Sched(); + for (int num = 0; num < BConstants::EXT_CONNECT_MAX_COUNT; num++) { + sched_->Sched(); + } } catch (const BError &e) { return; } catch (const exception &e) { @@ -1346,10 +1315,10 @@ void Service::HandleRestoreDepsBundle(const string &bundleName) session_->SetBundleVersionCode(bundleInfo.name, bundleInfo.versionCode); session_->SetBundleVersionName(bundleInfo.name, bundleInfo.versionName); session_->SetBundleDataSize(bundleInfo.name, bundleInfo.spaceOccupied); - session_->SetBackupExtName(bundleInfo.name, bundleInfo.extensionName); for (auto &fileName : info.fileNames_) { session_->SetExtFileNameRequest(bundleInfo.name, fileName); } + session_->SetBackupExtName(bundleInfo.name, bundleInfo.extensionName); } } HILOGI("End"); @@ -1689,13 +1658,13 @@ ErrCode Service::StartExtTimer(bool &isExtStart) { try { HILOGI("Service::StartExtTimer begin."); - session_->IncreaseSessionCnt(__PRETTY_FUNCTION__); - string bundleName = VerifyCallerAndGetCallerName(); if (session_ == nullptr) { HILOGE("StartExtTimer error, session_ is nullptr."); isExtStart = false; return BError(BError::Codes::SA_INVAL_ARG); } + session_->IncreaseSessionCnt(__PRETTY_FUNCTION__); + string bundleName = VerifyCallerAndGetCallerName(); auto timeoutCallback = TimeOutCallback(wptr(this), bundleName); session_->StopFwkTimer(bundleName); isExtStart = session_->StartExtTimer(bundleName, timeoutCallback); @@ -1713,13 +1682,13 @@ ErrCode Service::StartFwkTimer(bool &isFwkStart) { try { HILOGI("Service::StartFwkTimer begin."); - session_->IncreaseSessionCnt(__PRETTY_FUNCTION__); - string bundleName = VerifyCallerAndGetCallerName(); if (session_ == nullptr) { HILOGE("StartFwkTimer error, session_ is nullptr."); isFwkStart = false; return BError(BError::Codes::SA_INVAL_ARG); } + session_->IncreaseSessionCnt(__PRETTY_FUNCTION__); + string bundleName = VerifyCallerAndGetCallerName(); auto timeoutCallback = TimeOutCallback(wptr(this), bundleName); session_->StopExtTimer(bundleName); isFwkStart = session_->StartFwkTimer(bundleName, timeoutCallback); diff --git a/services/backup_sa/src/module_ipc/service_incremental.cpp b/services/backup_sa/src/module_ipc/service_incremental.cpp index c889096769e9df482d2bef6f1cd9b6fe4c39eca4..ed854aad28fedcb0aa1153caa8d89f61a78abaf9 100644 --- a/services/backup_sa/src/module_ipc/service_incremental.cpp +++ b/services/backup_sa/src/module_ipc/service_incremental.cpp @@ -313,25 +313,12 @@ ErrCode Service::AppendBundlesIncrementalBackupSession(const std::vector bundleNames = GetBundleNameByDetails(bundlesToBackup); auto backupInfos = BundleMgrAdapter::GetBundleInfosForAppend(bundlesToBackup, session_->GetSessionUserId()); - session_->AppendBundles(bundleNames); - for (auto info : backupInfos) { - HILOGI("Current backupInfo bundleName:%{public}s, index:%{public}d, extName:%{public}s", info.name.c_str(), - info.appIndex, info.extensionName.c_str()); - std::string bundleNameIndexInfo = BJsonUtil::BuildBundleNameIndexInfo(info.name, info.appIndex); - session_->SetBundleDataSize(bundleNameIndexInfo, info.increSpaceOccupied); - session_->SetBackupExtName(bundleNameIndexInfo, info.extensionName); - if (info.allToBackup == false) { - session_->GetServiceReverseProxy()->IncrementalBackupOnBundleStarted( - BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), bundleNameIndexInfo); - BundleBeginRadarReport(bundleNameIndexInfo, BError(BError::Codes::SA_FORBID_BACKUP_RESTORE).GetCode(), - IServiceReverse::Scenario::BACKUP); - session_->RemoveExtInfo(bundleNameIndexInfo); - } - } + std::vector supportBackupNames = GetSupportBackupBundleNames(backupInfos, true); + session_->AppendBundles(supportBackupNames); for (auto &bundleInfo : bundlesToBackup) { session_->SetIncrementalData(bundleInfo); } - SetCurrentBackupSessProperties(bundleNames, session_->GetSessionUserId()); + SetCurrentBackupSessProperties(supportBackupNames, session_->GetSessionUserId(), backupInfos, true); OnStartSched(); session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); return BError(BError::Codes::OK); @@ -365,11 +352,12 @@ ErrCode Service::AppendBundlesIncrementalBackupSession(const std::vectorGetSessionUserId(), isClearDataFlags); auto backupInfos = BundleMgrAdapter::GetBundleInfosForAppend(bundlesToBackup, session_->GetSessionUserId()); - session_->AppendBundles(bundleNames); - HandleCurGroupIncBackupInfos(backupInfos, bundleNameDetailMap, isClearDataFlags); + std::vector supportBackupNames = GetSupportBackupBundleNames(backupInfos, true); for (auto &bundleInfo : bundlesToBackup) { session_->SetIncrementalData(bundleInfo); } + session_->AppendBundles(supportBackupNames); + HandleCurGroupIncBackupInfos(backupInfos, bundleNameDetailMap, isClearDataFlags); OnStartSched(); session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); return BError(BError::Codes::OK); @@ -394,19 +382,13 @@ void Service::HandleCurGroupIncBackupInfos(vector & std::string bundleNameIndexInfo = BJsonUtil::BuildBundleNameIndexInfo(info.name, info.appIndex); SetCurrentSessProperties(info, isClearDataFlags, bundleNameIndexInfo); session_->SetBundleDataSize(bundleNameIndexInfo, info.increSpaceOccupied); - if (info.allToBackup == false) { - session_->GetServiceReverseProxy()->IncrementalBackupOnBundleStarted( - BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), bundleNameIndexInfo); - BundleBeginRadarReport(bundleNameIndexInfo, BError(BError::Codes::SA_FORBID_BACKUP_RESTORE).GetCode(), - IServiceReverse::Scenario::BACKUP); - session_->RemoveExtInfo(bundleNameIndexInfo); - } BJsonUtil::BundleDetailInfo uniCastInfo; if (BJsonUtil::FindBundleInfoByName(bundleNameDetailMap, bundleNameIndexInfo, UNICAST_TYPE, uniCastInfo)) { HILOGI("current bundle:%{public}s, unicast info:%{public}s", bundleNameIndexInfo.c_str(), GetAnonyString(uniCastInfo.detail).c_str()); session_->SetBackupExtInfo(bundleNameIndexInfo, uniCastInfo.detail); } + session_->SetBackupExtName(bundleNameIndexInfo, info.extensionName); } } @@ -680,25 +662,44 @@ void Service::SendUserIdToApp(string &bundleName, int32_t userId) HILOGI("session_ is nullptr"); return; } - HILOGI("SetCurrentBackupSessProperties bundleName : %{public}s", bundleName.c_str()); + HILOGI("Begin, bundleName: %{public}s", bundleName.c_str()); string detailInfo; if (!BJsonUtil::BuildBundleInfoJson(userId, detailInfo)) { - HILOGI("BuildBundleInfoJson failed, bundleName : %{public}s", bundleName.c_str()); + HILOGE("BuildBundleInfoJson failed, bundleName : %{public}s", bundleName.c_str()); return; } - HILOGI("current bundle, unicast info: %{public}s", GetAnonyString(detailInfo).c_str()); session_->SetBackupExtInfo(bundleName, detailInfo); + HILOGI("End, bundleName:%{public}s, unicast info:%{public}s", bundleName.c_str(), + GetAnonyString(detailInfo).c_str()); } -void Service::SetCurrentBackupSessProperties(const vector &bundleNames, int32_t userId) +void Service::SetCurrentBackupSessProperties(const vector &bundleNames, int32_t userId, + vector &backupBundleInfos, bool isIncBackup) { HILOGI("start SetCurrentBackupSessProperties"); + std::map bundleNameIndexBundleInfoMap; + for (auto &bundleInfo : backupBundleInfos) { + std::string bundleNameIndexInfo = BJsonUtil::BuildBundleNameIndexInfo(bundleInfo.name, bundleInfo.appIndex); + bundleNameIndexBundleInfoMap[bundleNameIndexInfo] = bundleInfo; + } for (auto item : bundleNames) { std::string bundleName = item; - if (!BundleMgrAdapter::IsUser0BundleName(bundleName, userId)) { + if (BundleMgrAdapter::IsUser0BundleName(bundleName, userId)) { + HILOGE("bundleName:%{public}s is zero user bundle", bundleName.c_str()); + SendUserIdToApp(bundleName, userId); + } + auto it = bundleNameIndexBundleInfoMap.find(bundleName); + if (it == bundleNameIndexBundleInfoMap.end()) { + HILOGE("Current bundleName can not find bundleInfo, bundleName:%{public}s", bundleName.c_str()); continue; } - SendUserIdToApp(bundleName, userId); + auto bundleInfo = it->second; + if (isIncBackup) { + session_->SetBundleDataSize(bundleName, bundleInfo.increSpaceOccupied); + } else { + session_->SetBundleDataSize(bundleName, bundleInfo.spaceOccupied); + } + session_->SetBackupExtName(bundleName, bundleInfo.extensionName); } HILOGI("end SetCurrentBackupSessProperties"); } diff --git a/services/backup_sa/src/module_ipc/sub_service.cpp b/services/backup_sa/src/module_ipc/sub_service.cpp index 7798384122ed85a689e818fda91e58724621282f..484c89a24f34c8ad98459e14ee8602a49abcc4a8 100644 --- a/services/backup_sa/src/module_ipc/sub_service.cpp +++ b/services/backup_sa/src/module_ipc/sub_service.cpp @@ -291,4 +291,47 @@ void Service::SetWant(AAFwk::Want &want, const BundleName &bundleName, const BCo want.SetParam(BConstants::EXTENSION_BACKUP_EXT_INFO_PARA, bundleExtInfo); want.SetParam(BConstants::EXTENSION_APP_CLONE_INDEX_PARA, bundleDetail.bundleIndex); } + +std::vector Service::GetSupportBackupBundleNames(vector &backupInfos, + bool isIncBackup) +{ + HILOGI("Begin"); + std::vector supportBackupNames; + for (auto info : backupInfos) { + HILOGI("Current backupInfo bundleName:%{public}s, index:%{public}d, extName:%{public}s", info.name.c_str(), + info.appIndex, info.extensionName.c_str()); + std::string bundleNameIndexInfo = BJsonUtil::BuildBundleNameIndexInfo(info.name, info.appIndex); + if (!info.allToBackup) { + if (isIncBackup) { + session_->GetServiceReverseProxy()->IncrementalBackupOnBundleStarted( + BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), bundleNameIndexInfo); + } else { + session_->GetServiceReverseProxy()->BackupOnBundleStarted( + BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), bundleNameIndexInfo); + } + BundleBeginRadarReport(bundleNameIndexInfo, BError(BError::Codes::SA_FORBID_BACKUP_RESTORE).GetCode(), + IServiceReverse::Scenario::BACKUP); + continue; + } + supportBackupNames.push_back(bundleNameIndexInfo); + } + HILOGI("End"); + return supportBackupNames; +} + +void Service::SetCurrentSessProperties(BJsonEntityCaps::BundleInfo &info, + std::map &isClearDataFlags, const std::string &bundleNameIndexInfo) +{ + HILOGI("Begin"); + if (session_ == nullptr) { + HILOGE("Set currrent session properties error, session is empty"); + return; + } + session_->SetBundleDataSize(bundleNameIndexInfo, info.spaceOccupied); + auto iter = isClearDataFlags.find(bundleNameIndexInfo); + if (iter != isClearDataFlags.end()) { + session_->SetClearDataFlag(bundleNameIndexInfo, iter->second); + } + HILOGI("End"); +} } \ No newline at end of file diff --git a/services/backup_sa/src/module_ipc/svc_session_manager.cpp b/services/backup_sa/src/module_ipc/svc_session_manager.cpp index f84668de14ea2615b8674c319430f1e8e10ec798..85ebde11e791b2fd3565e1d671fa7fe6c7f668be 100644 --- a/services/backup_sa/src/module_ipc/svc_session_manager.cpp +++ b/services/backup_sa/src/module_ipc/svc_session_manager.cpp @@ -433,12 +433,17 @@ bool SvcSessionManager::GetSchedBundleName(string &bundleName) { unique_lock lock(lock_); if (extConnectNum_ >= BConstants::EXT_CONNECT_MAX_COUNT) { + HILOGE("Sched bundle count is too many"); return false; } for (auto &&it : impl_.backupExtNameMap) { if (it.second.schedAction == BConstants::ServiceSchedAction::WAIT) { bundleName = it.first; + if (!SAUtils::IsSABundleName(bundleName) && it.second.backupExtName.empty()) { + HILOGE("Current bundle:%{public}s can not sched", bundleName.c_str()); + return false; + } it.second.schedAction = BConstants::ServiceSchedAction::START; extConnectNum_++; return true; diff --git a/services/backup_sa/src/module_sched/sched_scheduler.cpp b/services/backup_sa/src/module_sched/sched_scheduler.cpp index efcfb24d6329383f4989b9eff341440a7ff4c6d6..72f85aeac1383b3499ea22025e2b3c38b363ceb6 100644 --- a/services/backup_sa/src/module_sched/sched_scheduler.cpp +++ b/services/backup_sa/src/module_sched/sched_scheduler.cpp @@ -48,6 +48,7 @@ void SchedScheduler::Sched(string bundleName) return; } if (!sessionPtr_->GetSchedBundleName(bundleName)) { + HILOGE("Current bundle can not execute sched, bundleName:%{public}s", bundleName.c_str()); return; } } diff --git a/tests/mock/module_ipc/service_mock.cpp b/tests/mock/module_ipc/service_mock.cpp index 9c1fc72f27a924bf05388162292b689c3d24ba21..f0abbf7ffb81fc1975eea9b6c27236f5dc384ad4 100644 --- a/tests/mock/module_ipc/service_mock.cpp +++ b/tests/mock/module_ipc/service_mock.cpp @@ -288,4 +288,9 @@ void Service::ClearFailedBundles() {} void Service::CreateDirIfNotExist(const std::string &path) { } + +std::vector Service::GetSupportBackupBundleNames(vector&, bool) +{ + return {}; +} } // namespace OHOS::FileManagement::Backup diff --git a/tests/unittests/backup_sa/module_ipc/service_incremental_test.cpp b/tests/unittests/backup_sa/module_ipc/service_incremental_test.cpp index 4cad2e71b188a10cdae89d4a675036c2a1857fc8..237e5abb2f56f465494ea083b9be6bf093fae768 100644 --- a/tests/unittests/backup_sa/module_ipc/service_incremental_test.cpp +++ b/tests/unittests/backup_sa/module_ipc/service_incremental_test.cpp @@ -17,6 +17,7 @@ #include "backup_para_mock.h" #include "bms_adapter_mock.h" +#include "b_json/b_json_entity_caps.h" #include "b_jsonutil_mock.h" #include "ipc_skeleton_mock.h" #include "sa_backup_connection_mock.h" @@ -242,6 +243,11 @@ void Service::ExtensionConnectFailRadarReport(const std::string &bundleName, con void Service::UpdateFailedBundles(const std::string &bundleName, BundleTaskInfo taskInfo) {} void Service::ClearFailedBundles() {} + +std::vector Service::GetSupportBackupBundleNames(vector&, bool) +{ + return {}; +} } // namespace OHOS::FileManagement::Backup namespace OHOS::FileManagement::Backup { @@ -1048,14 +1054,18 @@ HWTEST_F(ServiceIncrementalTest, SUB_ServiceIncremental_SetCurrentBackupSessProp try { vector bundleNames { "bundleName" }; int32_t userId = 100; + vector bundleInfos; + BJsonEntityCaps::BundleInfo bundleInfo; + bundleInfo.name = "bundleName"; + bundleInfos.push_back(bundleInfo); auto session_ = service->session_; service->session_ = nullptr; EXPECT_CALL(*bms, IsUser0BundleName(_, _)).WillOnce(Return(false)); - service->SetCurrentBackupSessProperties(bundleNames, userId); + service->SetCurrentBackupSessProperties(bundleNames, userId, bundleInfos, true); EXPECT_TRUE(true); EXPECT_CALL(*bms, IsUser0BundleName(_, _)).WillOnce(Return(true)); - service->SetCurrentBackupSessProperties(bundleNames, userId); + service->SetCurrentBackupSessProperties(bundleNames, userId, bundleInfos, true); EXPECT_TRUE(true); service->session_ = session_; } catch (...) { diff --git a/tests/unittests/backup_sa/module_ipc/service_other_test.cpp b/tests/unittests/backup_sa/module_ipc/service_other_test.cpp index 83dc8310c967bf733ccc03a92400291f998356c2..45b2f72987df2225016332a761d91a01b65416b7 100644 --- a/tests/unittests/backup_sa/module_ipc/service_other_test.cpp +++ b/tests/unittests/backup_sa/module_ipc/service_other_test.cpp @@ -22,6 +22,7 @@ #include "bms_adapter_mock.h" #include "b_json_clear_data_config_mock.h" #include "b_json_service_disposal_config_mock.h" +#include "b_json/b_json_entity_caps.h" #include "b_jsonutil_mock.h" #include "b_sa_utils_mock.h" #include "ipc_skeleton_mock.h" @@ -110,7 +111,8 @@ void Service::NotifyCallerCurAppIncrementDone(ErrCode, const std::string&) {} void Service::SendUserIdToApp(string&, int32_t) {} -void Service::SetCurrentBackupSessProperties(const vector&, int32_t) {} +void Service::SetCurrentBackupSessProperties(const vector&, int32_t, + std::vector&, bool) {} std::shared_ptr Service::GetExtensionMutex(const BundleName &bundleName) {