diff --git a/services/backup_sa/include/module_ipc/service.h b/services/backup_sa/include/module_ipc/service.h index a4d2c69d6c36afd2447944efe53e42e16a305ef2..41106d44eaf8ef72c0eda1027122b5622e373272 100644 --- a/services/backup_sa/include/module_ipc/service.h +++ b/services/backup_sa/include/module_ipc/service.h @@ -549,10 +549,13 @@ private: void CreateDirIfNotExist(const std::string &path); std::vector GetSupportBackupBundleNames(vector &bundleInfos, - bool isIncBackup); + bool isIncBackup, const vector &srcBundleNames); void RefreshBundleDataSize(const vector &newBundleInfos, std::string bundleName, wptr ptr); + + void HandleNotSupportBundleNames(const std::vector &srcBundleNames, + std::vector &supportBundleNames, bool isIncBackup); private: static sptr instance_; static std::mutex instanceLock_; diff --git a/services/backup_sa/src/module_external/bms_adapter.cpp b/services/backup_sa/src/module_external/bms_adapter.cpp index 26af6e97077ea04eff0d692b0518abc2aefc2fd5..7f94e2c276495cd45c7ef120316abcf5e1c0935e 100644 --- a/services/backup_sa/src/module_external/bms_adapter.cpp +++ b/services/backup_sa/src/module_external/bms_adapter.cpp @@ -304,6 +304,7 @@ vector BundleMgrAdapter::GetBundleInfosForIncrement } if (!CreateIPCInteractionFiles(userId, bundleName, bundleNameTime.lastIncrementalTime, backupPara.includes, backupPara.excludes)) { + HILOGE("Create bundleInteraction dir failed, bundleName:%{public}s", bundleName.c_str()); continue; } bundleInfos.emplace_back(BJsonEntityCaps::BundleInfo {installedBundle.name, installedBundle.appIndex, diff --git a/services/backup_sa/src/module_ipc/service.cpp b/services/backup_sa/src/module_ipc/service.cpp index cf65822f407f8de2663803948002b2e3d54803fe..5b53f5796bee0fa5ffee4de80826ef9917c2036a 100644 --- a/services/backup_sa/src/module_ipc/service.cpp +++ b/services/backup_sa/src/module_ipc/service.cpp @@ -795,7 +795,7 @@ ErrCode Service::AppendBundlesBackupSession(const vector &bundleName VerifyCaller(IServiceReverse::Scenario::BACKUP); auto bundleDetails = MakeDetailList(bundleNames); auto backupInfos = BundleMgrAdapter::GetBundleInfosForAppend(bundleDetails, session_->GetSessionUserId()); - std::vector supportBackupNames = GetSupportBackupBundleNames(backupInfos, false); + std::vector supportBackupNames = GetSupportBackupBundleNames(backupInfos, false, bundleNames); session_->AppendBundles(supportBackupNames); SetCurrentBackupSessProperties(supportBackupNames, session_->GetSessionUserId(), backupInfos, false); OnStartSched(); @@ -837,7 +837,7 @@ ErrCode Service::AppendBundlesDetailsBackupSession(const vector &bun session_->GetSessionUserId(), isClearDataFlags); auto bundleDetails = MakeDetailList(bundleNames); auto backupInfos = BundleMgrAdapter::GetBundleInfosForAppend(bundleDetails, session_->GetSessionUserId()); - std::vector supportBackupNames = GetSupportBackupBundleNames(backupInfos, false); + std::vector supportBackupNames = GetSupportBackupBundleNames(backupInfos, false, bundleNames); session_->AppendBundles(supportBackupNames); HandleCurGroupBackupInfos(backupInfos, bundleNameDetailMap, isClearDataFlags); OnStartSched(); diff --git a/services/backup_sa/src/module_ipc/service_incremental.cpp b/services/backup_sa/src/module_ipc/service_incremental.cpp index c0f47df3f75bf2e60f33add20bba522a041c060c..79954999989c907099668a4a2ccbe96cdff69fa3 100644 --- a/services/backup_sa/src/module_ipc/service_incremental.cpp +++ b/services/backup_sa/src/module_ipc/service_incremental.cpp @@ -346,7 +346,7 @@ ErrCode Service::AppendBundlesIncrementalBackupSession(const std::vector bundleNames = GetBundleNameByDetails(bundlesToBackup); auto backupInfos = BundleMgrAdapter::GetBundleInfosForAppend(bundlesToBackup, session_->GetSessionUserId()); - std::vector supportBackupNames = GetSupportBackupBundleNames(backupInfos, true); + std::vector supportBackupNames = GetSupportBackupBundleNames(backupInfos, true, bundleNames); session_->AppendBundles(supportBackupNames); for (auto &bundleInfo : bundlesToBackup) { session_->SetIncrementalData(bundleInfo); @@ -385,7 +385,7 @@ ErrCode Service::AppendBundlesIncrementalBackupSession(const std::vectorGetSessionUserId(), isClearDataFlags); auto backupInfos = BundleMgrAdapter::GetBundleInfosForAppend(bundlesToBackup, session_->GetSessionUserId()); - std::vector supportBackupNames = GetSupportBackupBundleNames(backupInfos, true); + std::vector supportBackupNames = GetSupportBackupBundleNames(backupInfos, true, bundleNames); for (auto &bundleInfo : bundlesToBackup) { session_->SetIncrementalData(bundleInfo); } diff --git a/services/backup_sa/src/module_ipc/sub_service.cpp b/services/backup_sa/src/module_ipc/sub_service.cpp index b269ace2ad33fc04ff4e7fa3e319a6487cee19e3..3d066e9ffe61b9859bad9e8bba478d73eb3cbd2f 100644 --- a/services/backup_sa/src/module_ipc/sub_service.cpp +++ b/services/backup_sa/src/module_ipc/sub_service.cpp @@ -293,7 +293,7 @@ void Service::SetWant(AAFwk::Want &want, const BundleName &bundleName, const BCo } std::vector Service::GetSupportBackupBundleNames(vector &backupInfos, - bool isIncBackup) + bool isIncBackup, const std::vector &srcBundleNames) { HILOGI("Begin"); std::vector supportBackupNames; @@ -315,6 +315,7 @@ std::vector Service::GetSupportBackupBundleNames(vector &srcBundleNames, + std::vector &supportBundleNames, bool isIncBackup) +{ + for (auto bundleName : srcBundleNames) { + auto it = std::find(supportBundleNames.begin(), supportBundleNames.end(), bundleName); + if (it != supportBundleNames.end()) { + continue; + } + HILOGE("bundleName:%{public}s, can not find from supportBundleNames", bundleName.c_str()); + if (isIncBackup) { + session_->GetServiceReverseProxy()->IncrementalBackupOnBundleStarted( + BError(BError::Codes::SA_BUNDLE_INFO_EMPTY), bundleName); + } else { + session_->GetServiceReverseProxy()->BackupOnBundleStarted( + BError(BError::Codes::SA_BUNDLE_INFO_EMPTY), bundleName); + } + } +} } \ No newline at end of file diff --git a/tests/mock/module_ipc/service_mock.cpp b/tests/mock/module_ipc/service_mock.cpp index f7a4f876189181e35e525b41e8625cd79b212d6d..0c93ef7ff04a5c50ac4979ca0341e8faec78451b 100644 --- a/tests/mock/module_ipc/service_mock.cpp +++ b/tests/mock/module_ipc/service_mock.cpp @@ -290,8 +290,12 @@ void Service::CreateDirIfNotExist(const std::string &path) } void Service::StartRunningTimer(const std::string &bundleName) {} -std::vector Service::GetSupportBackupBundleNames(vector&, bool) + +std::vector Service::GetSupportBackupBundleNames(vector&, bool, + const vector&) { return {}; } + +void Service::HandleNotSupportBundleNames(const vector&, vector&, bool) {} } // 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 677feb583db0fdca9893fe240ec20c7b2101868d..218fa62c9abe3b7bc330531a7b1e07f06428c147 100644 --- a/tests/unittests/backup_sa/module_ipc/service_incremental_test.cpp +++ b/tests/unittests/backup_sa/module_ipc/service_incremental_test.cpp @@ -245,7 +245,9 @@ void Service::UpdateFailedBundles(const std::string &bundleName, BundleTaskInfo void Service::ClearFailedBundles() {} void Service::StartRunningTimer(const std::string &bundleName) {} -std::vector Service::GetSupportBackupBundleNames(vector&, bool) + +std::vector Service::GetSupportBackupBundleNames(vector&, bool, + const vector&) { return {}; }