diff --git a/services/backup_sa/include/module_ipc/service.h b/services/backup_sa/include/module_ipc/service.h index a76133ed90dbbe7aab3572d352bad83eacf86997..65a45b0c1e89ca6aa21202ff3d92dd3489c9f61c 100644 --- a/services/backup_sa/include/module_ipc/service.h +++ b/services/backup_sa/include/module_ipc/service.h @@ -272,6 +272,7 @@ public: session_ = sptr(new SvcSessionManager(wptr(this))); disposal_ = make_shared(); clearRecorder_ = make_shared(); + sched_ = sptr(new SchedScheduler(wptr(this), wptr(session_))); }; ~Service() override { @@ -376,7 +377,7 @@ private: std::vector &restoreBundleNames, RestoreTypeEnum restoreType); void SetCurrentSessProperties(BJsonEntityCaps::BundleInfo &info, std::map &isClearDataFlags); - + /** * @brief add useridinfo to current backup session * diff --git a/services/backup_sa/src/module_ipc/service.cpp b/services/backup_sa/src/module_ipc/service.cpp index c2272fafafd7ca27ef0f29d1a4f7f1237cba9832..003483b2a1eae67502c9542926eadc5163c0518a 100644 --- a/services/backup_sa/src/module_ipc/service.cpp +++ b/services/backup_sa/src/module_ipc/service.cpp @@ -126,8 +126,9 @@ void Service::OnStart() HILOGI("SA OnStart, cleaning up backup data"); } bool res = SystemAbility::Publish(sptr(this)); - sched_ = sptr(new SchedScheduler(wptr(this), wptr(session_))); - sched_->StartTimer(); + if (sched_ != nullptr) { + sched_->StartTimer(); + } ClearDisposalOnSaStart(); auto ret = AppendBundlesClearSession(residualBundleNameList); if (isOccupyingSession_.load() && ret) { @@ -649,6 +650,7 @@ vector Service::MakeDetailList(const vector &bundl } return bundleDetails; } + ErrCode Service::AppendBundlesBackupSession(const vector &bundleNames) { HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); @@ -662,8 +664,9 @@ ErrCode Service::AppendBundlesBackupSession(const vector &bundleName auto bundleDetails = MakeDetailList(bundleNames); auto backupInfos = BundleMgrAdapter::GetBundleInfosForAppend(bundleDetails, session_->GetSessionUserId()); session_->AppendBundles(bundleNames); - SetCurrentBackupSessProperties(bundleNames, session_->GetSessionUserId()); for (auto info : backupInfos) { + HILOGI("Current backupInfo bundleName:%{public}s, extName:%{public}s", info.name.c_str(), + info.extensionName.c_str()); session_->SetBundleDataSize(info.name, info.spaceOccupied); session_->SetBackupExtName(info.name, info.extensionName); if (info.allToBackup == false) { @@ -672,23 +675,24 @@ ErrCode Service::AppendBundlesBackupSession(const vector &bundleName session_->RemoveExtInfo(info.name); } } + SetCurrentBackupSessProperties(bundleNames, session_->GetSessionUserId()); OnStartSched(); session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); return BError(BError::Codes::OK); } catch (const BError &e) { + HILOGE("Failed, errCode = %{public}d", e.GetCode()); HandleExceptionOnAppendBundles(session_, bundleNames, {}); session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); - HILOGE("Failed, errCode = %{public}d", e.GetCode()); return e.GetCode(); } catch (const exception &e) { + HILOGE("Catched an unexpected low-level exception %{public}s", e.what()); HandleExceptionOnAppendBundles(session_, bundleNames, {}); session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); - HILOGE("Catched an unexpected low-level exception %{public}s", e.what()); return EPERM; } catch (...) { + HILOGE("Unexpected exception"); HandleExceptionOnAppendBundles(session_, bundleNames, {}); session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); - HILOGE("Unexpected exception"); return EPERM; } } diff --git a/services/backup_sa/src/module_ipc/service_incremental.cpp b/services/backup_sa/src/module_ipc/service_incremental.cpp index d88a39b11b64cf313cfb1c7f8a9830edddbf680f..c4c2b55b6a6010b84f7f8ed4effcb1c86ab230d6 100644 --- a/services/backup_sa/src/module_ipc/service_incremental.cpp +++ b/services/backup_sa/src/module_ipc/service_incremental.cpp @@ -271,8 +271,9 @@ ErrCode Service::AppendBundlesIncrementalBackupSession(const std::vectorGetSessionUserId()); session_->AppendBundles(bundleNames); - SetCurrentBackupSessProperties(bundleNames, session_->GetSessionUserId()); for (auto info : backupInfos) { + HILOGI("Current backupInfo bundleName:%{public}s, extName:%{public}s", info.name.c_str(), + info.extensionName.c_str()); session_->SetBundleDataSize(info.name, info.increSpaceOccupied); session_->SetBackupExtName(info.name, info.extensionName); if (info.allToBackup == false) { @@ -284,6 +285,7 @@ ErrCode Service::AppendBundlesIncrementalBackupSession(const std::vectorSetIncrementalData(bundleInfo); } + SetCurrentBackupSessProperties(bundleNames, session_->GetSessionUserId()); OnStartSched(); session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); return BError(BError::Codes::OK);