From a337d011e9458f99ec96f652b3d905806900182a Mon Sep 17 00:00:00 2001 From: "yaoruozi1@huawei.com" Date: Sat, 8 Feb 2025 16:45:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=8B=E9=9A=86=E5=8F=96=E6=B6=88=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yaoruozi1@huawei.com --- .../native/backup_ext/src/untar_file.cpp | 2 +- services/backup_sa/src/module_ipc/service.cpp | 65 +------------- .../backup_sa/src/module_ipc/sub_service.cpp | 84 +++++++++++++++++-- .../src/module_ipc/svc_session_manager.cpp | 1 + 4 files changed, 81 insertions(+), 71 deletions(-) diff --git a/frameworks/native/backup_ext/src/untar_file.cpp b/frameworks/native/backup_ext/src/untar_file.cpp index a2888357e..76181b091 100644 --- a/frameworks/native/backup_ext/src/untar_file.cpp +++ b/frameworks/native/backup_ext/src/untar_file.cpp @@ -578,7 +578,7 @@ FILE *UntarFile::CreateFile(string &filePath) } uint32_t len = filePath.length(); - HILOGE("Failed to open file %{public}d, %{public}s, err = %{public}d", len, + HILOGW("Failed to open file %{public}d, %{public}s, err = %{public}d, Will create dir", len, GetAnonyPath(filePath).c_str(), errno); size_t pos = filePath.rfind('/'); if (pos == string::npos) { diff --git a/services/backup_sa/src/module_ipc/service.cpp b/services/backup_sa/src/module_ipc/service.cpp index a92081330..b48c7a195 100644 --- a/services/backup_sa/src/module_ipc/service.cpp +++ b/services/backup_sa/src/module_ipc/service.cpp @@ -330,6 +330,7 @@ UniqueFd Service::GetLocalCapabilities() void Service::StopAll(const wptr &obj, bool force) { HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); + HILOGI("Begin Stop session"); std::lock_guard lock(failedBundlesLock_); uint32_t fail_cnt = failedBundles_.size(); uint32_t totalBundles = fail_cnt + successBundlesNum_.load(); @@ -964,6 +965,7 @@ ErrCode Service::ServiceResultReport(const std::string restoreRetInfo, } return BError(BError::Codes::OK); } catch (const BError &e) { + HILOGE("Service result report error"); HandleCurBundleEndWork(callerName, sennario); CallOnBundleEndByScenario(callerName, sennario, e.GetCode()); OnAllBundlesFinished(BError(BError::Codes::OK)); @@ -997,6 +999,7 @@ ErrCode Service::SAResultReport(const std::string bundleName, const std::string void Service::HandleCurBundleEndWork(std::string bundleName, const BackupRestoreScenario sennario) { + HILOGI("Begin"); try { if (sennario != BackupRestoreScenario::FULL_RESTORE && sennario != BackupRestoreScenario::INCREMENTAL_RESTORE) { @@ -1669,68 +1672,6 @@ ErrCode Service::GetBackupInfo(BundleName &bundleName, std::string &result) } } -ErrCode Service::StartExtTimer(bool &isExtStart) -{ - try { - HILOGI("Service::StartExtTimer begin."); - if (session_ == nullptr) { - HILOGE("StartExtTimer error, session_ is nullptr."); - isExtStart = false; - return BError(BError::Codes::SA_INVAL_ARG); - } - session_->IncreaseSessionCnt(__PRETTY_FUNCTION__); - string bundleName; - ErrCode ret = VerifyCallerAndGetCallerName(bundleName); - if (ret != ERR_OK) { - HILOGE("Start extension timer fail, get bundleName failed, ret:%{public}d", ret); - isExtStart = false; - session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); - return ret; - } - auto timeoutCallback = TimeOutCallback(wptr(this), bundleName); - session_->StopFwkTimer(bundleName); - isExtStart = session_->StartExtTimer(bundleName, timeoutCallback); - session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); - return BError(BError::Codes::OK); - } catch (...) { - HILOGE("Unexpected exception"); - isExtStart = false; - session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); - return EPERM; - } -} - -ErrCode Service::StartFwkTimer(bool &isFwkStart) -{ - try { - HILOGI("Service::StartFwkTimer begin."); - if (session_ == nullptr) { - HILOGE("StartFwkTimer error, session_ is nullptr."); - isFwkStart = false; - return BError(BError::Codes::SA_INVAL_ARG); - } - session_->IncreaseSessionCnt(__PRETTY_FUNCTION__); - std::string bundleName; - ErrCode ret = VerifyCallerAndGetCallerName(bundleName); - if (ret != ERR_OK) { - HILOGE("Start fwk timer fail, get bundleName failed, ret:%{public}d", ret); - isFwkStart = false; - session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); - return ret; - } - auto timeoutCallback = TimeOutCallback(wptr(this), bundleName); - session_->StopExtTimer(bundleName); - isFwkStart = session_->StartFwkTimer(bundleName, timeoutCallback); - session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); - return BError(BError::Codes::OK); - } catch (...) { - HILOGE("Unexpected exception"); - isFwkStart = false; - session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); - return EPERM; - } -} - ErrCode Service::AppendBundlesClearSession(const std::vector &bundleNames) { HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); diff --git a/services/backup_sa/src/module_ipc/sub_service.cpp b/services/backup_sa/src/module_ipc/sub_service.cpp index ac779fa9b..b679afd82 100644 --- a/services/backup_sa/src/module_ipc/sub_service.cpp +++ b/services/backup_sa/src/module_ipc/sub_service.cpp @@ -903,14 +903,20 @@ void Service::CallOnBundleEndByScenario(const std::string &bundleName, BackupRes HILOGE("Session is empty, bundleName:%{public}s", bundleName.c_str()); return; } - if (scenario == BackupRestoreScenario::FULL_RESTORE) { - session_->GetServiceReverseProxy()->RestoreOnBundleFinished(errCode, bundleName); - } else if (scenario == BackupRestoreScenario::INCREMENTAL_RESTORE) { - session_->GetServiceReverseProxy()->IncrementalRestoreOnBundleFinished(errCode, bundleName); - } else if (scenario == BackupRestoreScenario::FULL_BACKUP) { - session_->GetServiceReverseProxy()->BackupOnBundleFinished(errCode, bundleName); - } else if (scenario == BackupRestoreScenario::INCREMENTAL_BACKUP) { - session_->GetServiceReverseProxy()->IncrementalBackupOnBundleFinished(errCode, bundleName); + HILOGI("Begin"); + try { + if (scenario == BackupRestoreScenario::FULL_RESTORE) { + session_->GetServiceReverseProxy()->RestoreOnBundleFinished(errCode, bundleName); + } else if (scenario == BackupRestoreScenario::INCREMENTAL_RESTORE) { + session_->GetServiceReverseProxy()->IncrementalRestoreOnBundleFinished(errCode, bundleName); + } else if (scenario == BackupRestoreScenario::FULL_BACKUP) { + session_->GetServiceReverseProxy()->BackupOnBundleFinished(errCode, bundleName); + } else if (scenario == BackupRestoreScenario::INCREMENTAL_BACKUP) { + session_->GetServiceReverseProxy()->IncrementalBackupOnBundleFinished(errCode, bundleName); + } + } catch (const BError &e) { + HILOGE("Call onBundleFinished error, client is died"); + return; } } @@ -1144,4 +1150,66 @@ void Service::SendScannedInfo(const string&scannendInfos, sptrIncreaseSessionCnt(__PRETTY_FUNCTION__); + string bundleName; + ErrCode ret = VerifyCallerAndGetCallerName(bundleName); + if (ret != ERR_OK) { + HILOGE("Start extension timer fail, get bundleName failed, ret:%{public}d", ret); + isExtStart = false; + session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); + return ret; + } + auto timeoutCallback = TimeOutCallback(wptr(this), bundleName); + session_->StopFwkTimer(bundleName); + isExtStart = session_->StartExtTimer(bundleName, timeoutCallback); + session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); + return BError(BError::Codes::OK); + } catch (...) { + HILOGE("Unexpected exception"); + isExtStart = false; + session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); + return EPERM; + } +} + +ErrCode Service::StartFwkTimer(bool &isFwkStart) +{ + try { + HILOGI("Service::StartFwkTimer begin."); + if (session_ == nullptr) { + HILOGE("StartFwkTimer error, session_ is nullptr."); + isFwkStart = false; + return BError(BError::Codes::SA_INVAL_ARG); + } + session_->IncreaseSessionCnt(__PRETTY_FUNCTION__); + std::string bundleName; + ErrCode ret = VerifyCallerAndGetCallerName(bundleName); + if (ret != ERR_OK) { + HILOGE("Start fwk timer fail, get bundleName failed, ret:%{public}d", ret); + isFwkStart = false; + session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); + return ret; + } + auto timeoutCallback = TimeOutCallback(wptr(this), bundleName); + session_->StopExtTimer(bundleName); + isFwkStart = session_->StartFwkTimer(bundleName, timeoutCallback); + session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); + return BError(BError::Codes::OK); + } catch (...) { + HILOGE("Unexpected exception"); + isFwkStart = false; + session_->DecreaseSessionCnt(__PRETTY_FUNCTION__); + return EPERM; + } +} } \ 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 44002f2d4..ec982c0cc 100644 --- a/services/backup_sa/src/module_ipc/svc_session_manager.cpp +++ b/services/backup_sa/src/module_ipc/svc_session_manager.cpp @@ -107,6 +107,7 @@ ErrCode SvcSessionManager::Active(Impl newImpl, bool isOccupyingSession) ErrCode SvcSessionManager::Deactive(const wptr &remoteInAction, bool force) { unique_lock lock(lock_); + HILOGI("Begin Deactive session"); if (!impl_.clientToken) { HILOGE("Deactive session fail, caller token is invalid"); return BError(BError::Codes::SA_INVAL_ARG); -- Gitee