diff --git a/services/backup_sa/include/module_sched/sched_scheduler.h b/services/backup_sa/include/module_sched/sched_scheduler.h index 30415c6c14a4151f14be559572fce7b69ffd343a..88abe6bfb5e5dc2b6a8dcf21a9ff6a12ed344969 100644 --- a/services/backup_sa/include/module_sched/sched_scheduler.h +++ b/services/backup_sa/include/module_sched/sched_scheduler.h @@ -97,6 +97,13 @@ private: */ void InstallingState(const std::string &bundleName); + /** + * @brief failed task to sched + * + * @param bundleName + */ + void FailedTask(const std::string &bundleName); + private: mutable std::shared_mutex lock_; OHOS::ThreadPool threadPool_; diff --git a/services/backup_sa/src/module_ipc/service.cpp b/services/backup_sa/src/module_ipc/service.cpp index 116dd770756c445c364327b521da047212fb73e4..747accbae6eb9854ef605ab02eb78b298cf1ad4a 100644 --- a/services/backup_sa/src/module_ipc/service.cpp +++ b/services/backup_sa/src/module_ipc/service.cpp @@ -119,10 +119,10 @@ UniqueFd Service::GetLocalCapabilities() HILOGE("GetLocalCapabilities failed, errCode = %{public}d", e.GetCode()); return UniqueFd(-e.GetCode()); } catch (const exception &e) { - HILOGI("Catched an unexpected low-level exception %{public}s", e.what()); + HILOGE("Catched an unexpected low-level exception %{public}s", e.what()); return UniqueFd(-EPERM); } catch (...) { - HILOGI("Unexpected exception"); + HILOGE("Unexpected exception"); return UniqueFd(-EPERM); } } @@ -332,10 +332,10 @@ ErrCode Service::PublishFile(const BFileInfo &fileInfo) } catch (const BError &e) { return e.GetCode(); } catch (const exception &e) { - HILOGI("Catched an unexpected low-level exception %{public}s", e.what()); + HILOGE("Catched an unexpected low-level exception %{public}s", e.what()); return EPERM; } catch (...) { - HILOGI("Unexpected exception"); + HILOGE("Unexpected exception"); return EPERM; } } @@ -375,10 +375,10 @@ ErrCode Service::AppFileReady(const string &fileName, UniqueFd fd) } catch (const BError &e) { return e.GetCode(); // 任意异常产生,终止监听该任务 } catch (const exception &e) { - HILOGI("Catched an unexpected low-level exception %{public}s", e.what()); + HILOGE("Catched an unexpected low-level exception %{public}s", e.what()); return EPERM; } catch (...) { - HILOGI("Unexpected exception"); + HILOGE("Unexpected exception"); return EPERM; } } @@ -410,10 +410,10 @@ ErrCode Service::AppDone(ErrCode errCode) } catch (const BError &e) { return e.GetCode(); // 任意异常产生,终止监听该任务 } catch (const exception &e) { - HILOGI("Catched an unexpected low-level exception %{public}s", e.what()); + HILOGE("Catched an unexpected low-level exception %{public}s", e.what()); return EPERM; } catch (...) { - HILOGI("Unexpected exception"); + HILOGE("Unexpected exception"); return EPERM; } } @@ -421,7 +421,7 @@ ErrCode Service::AppDone(ErrCode errCode) ErrCode Service::LaunchBackupExtension(const BundleName &bundleName) { try { - HILOGE("begin %{public}s", bundleName.data()); + HILOGI("begin %{public}s", bundleName.data()); IServiceReverse::Scenario scenario = session_->GetScenario(); BConstants::ExtensionAction action; if (scenario == IServiceReverse::Scenario::BACKUP) { @@ -451,10 +451,10 @@ ErrCode Service::LaunchBackupExtension(const BundleName &bundleName) } catch (const BError &e) { return e.GetCode(); } catch (const exception &e) { - HILOGI("Catched an unexpected low-level exception %{public}s", e.what()); + HILOGE("Catched an unexpected low-level exception %{public}s", e.what()); return EPERM; } catch (...) { - HILOGI("Unexpected exception"); + HILOGE("Unexpected exception"); return EPERM; } } @@ -484,10 +484,10 @@ ErrCode Service::GetFileHandle(const string &bundleName, const string &fileName) } catch (const BError &e) { return e.GetCode(); } catch (const exception &e) { - HILOGI("Catched an unexpected low-level exception %{public}s", e.what()); + HILOGE("Catched an unexpected low-level exception %{public}s", e.what()); return EPERM; } catch (...) { - HILOGI("Unexpected exception"); + HILOGE("Unexpected exception"); return EPERM; } } @@ -513,10 +513,10 @@ void Service::OnBackupExtensionDied(const string &&bundleName, ErrCode ret) } catch (const BError &e) { return; } catch (const exception &e) { - HILOGI("Catched an unexpected low-level exception %{public}s", e.what()); + HILOGE("Catched an unexpected low-level exception %{public}s", e.what()); return; } catch (...) { - HILOGI("Unexpected exception"); + HILOGE("Unexpected exception"); return; } } @@ -524,7 +524,7 @@ void Service::OnBackupExtensionDied(const string &&bundleName, ErrCode ret) void Service::ExtStart(const string &bundleName) { try { - HILOGE("begin %{public}s", bundleName.data()); + HILOGI("begin %{public}s", bundleName.data()); IServiceReverse::Scenario scenario = session_->GetScenario(); auto backUpConnection = session_->GetExtConnection(bundleName); auto proxy = backUpConnection->GetBackupExtProxy(); @@ -563,10 +563,10 @@ void Service::ExtStart(const string &bundleName) } catch (const BError &e) { return; } catch (const exception &e) { - HILOGI("Catched an unexpected low-level exception %{public}s", e.what()); + HILOGE("Catched an unexpected low-level exception %{public}s", e.what()); return; } catch (...) { - HILOGI("Unexpected exception"); + HILOGE("Unexpected exception"); return; } } @@ -588,8 +588,10 @@ void Service::ExtConnectFailed(const string &bundleName, ErrCode ret) HILOGE("begin %{public}s", bundleName.data()); IServiceReverse::Scenario scenario = session_->GetScenario(); if (scenario == IServiceReverse::Scenario::BACKUP) { + HILOGE("Backup <%{public}s> Extension Process Failed", bundleName.data()); session_->GetServiceReverseProxy()->BackupOnBundleStarted(ret, bundleName); } else if (scenario == IServiceReverse::Scenario::RESTORE) { + HILOGE("Restore <%{public}s> Extension Process Failed", bundleName.data()); session_->GetServiceReverseProxy()->RestoreOnBundleStarted(ret, bundleName); } ClearSessionAndSchedInfo(bundleName); @@ -597,10 +599,10 @@ void Service::ExtConnectFailed(const string &bundleName, ErrCode ret) } catch (const BError &e) { return; } catch (const exception &e) { - HILOGI("Catched an unexpected low-level exception %{public}s", e.what()); + HILOGE("Catched an unexpected low-level exception %{public}s", e.what()); return; } catch (...) { - HILOGI("Unexpected exception"); + HILOGE("Unexpected exception"); return; } } @@ -638,17 +640,17 @@ void Service::ExtConnectDone(string bundleName) }; try { - HILOGE("begin %{public}s", bundleName.data()); + HILOGI("begin %{public}s", bundleName.data()); session_->BundleExtTimerStart(bundleName, timeoutCallback); session_->SetServiceSchedAction(bundleName, BConstants::ServiceSchedAction::RUNNING); sched_->Sched(bundleName); } catch (const BError &e) { return; } catch (const exception &e) { - HILOGI("Catched an unexpected low-level exception %{public}s", e.what()); + HILOGE("Catched an unexpected low-level exception %{public}s", e.what()); return; } catch (...) { - HILOGI("Unexpected exception"); + HILOGE("Unexpected exception"); return; } } @@ -662,10 +664,10 @@ void Service::ClearSessionAndSchedInfo(const string &bundleName) } catch (const BError &e) { return; } catch (const exception &e) { - HILOGI("Catched an unexpected low-level exception %{public}s", e.what()); + HILOGE("Catched an unexpected low-level exception %{public}s", e.what()); return; } catch (...) { - HILOGI("Unexpected exception"); + HILOGE("Unexpected exception"); return; } } 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 75712fb5f365eec3e465a8c84ebd9a2d5c1e95fa..acd08ff90cdd56868c51165514d6a458c4bbc6db 100644 --- a/services/backup_sa/src/module_ipc/svc_session_manager.cpp +++ b/services/backup_sa/src/module_ipc/svc_session_manager.cpp @@ -44,7 +44,7 @@ void SvcSessionManager::VerifyCallerAndScenario(uint32_t clientToken, IServiceRe if (impl_.clientToken != clientToken) { throw BError(BError::Codes::SA_REFUSED_ACT, "Caller mismatched"); } - HILOGE("Succeed to verify the caller"); + HILOGI("Succeed to verify the caller"); } void SvcSessionManager::Active(Impl newImpl) @@ -70,7 +70,7 @@ void SvcSessionManager::Deactive(const wptr &remoteInAction, bool { unique_lock lock(lock_); if (!impl_.clientToken || !impl_.clientProxy) { - HILOGI("Empty session"); + HILOGE("Empty session"); return; } if (!force && (!impl_.clientToken || !impl_.clientProxy)) { @@ -99,7 +99,7 @@ void SvcSessionManager::VerifyBundleName(string &bundleName) ss << "Could not find the " << bundleName << " from current session"; throw BError(BError::Codes::SA_REFUSED_ACT, ss.str()); } - HILOGE("Succeed to verify the bundleName"); + HILOGI("Succeed to verify the bundleName"); } sptr SvcSessionManager::GetServiceReverseProxy() @@ -179,7 +179,7 @@ UniqueFd SvcSessionManager::OnBunleExtManageInfo(const string &bundleName, Uniqu auto info = cache.GetExtManage(); for (auto &fileName : info) { - HILOGE("fileName %{public}s", fileName.data()); + HILOGI("fileName %{public}s", fileName.data()); OnBunleFileReady(bundleName, fileName); } @@ -262,7 +262,7 @@ void SvcSessionManager::InitClient(Impl &newImpl) } auto callback = [revPtr {reversePtr_}](const wptr &obj) { - HILOGI("Client died."); + HILOGE("Client died."); auto revPtrStrong = revPtr.promote(); if (!revPtrStrong) { diff --git a/services/backup_sa/src/module_sched/sched_scheduler.cpp b/services/backup_sa/src/module_sched/sched_scheduler.cpp index 696d3539ef6f7503c0e7f69fb16eec4ce847a69a..0515f7e45a99ca066043eaca710776af58f14dd5 100644 --- a/services/backup_sa/src/module_sched/sched_scheduler.cpp +++ b/services/backup_sa/src/module_sched/sched_scheduler.cpp @@ -50,17 +50,20 @@ void SchedScheduler::Sched(string bundleName) sessionPtr_->SetServiceSchedAction(bundleName, BConstants::ServiceSchedAction::INSTALLING); } } - HILOGE("Sched bundleName %{public}s", bundleName.data()); + HILOGI("Sched bundleName %{public}s", bundleName.data()); auto callStart = [schedPtr {wptr(this)}, bundleName]() { + auto ptr = schedPtr.promote(); try { - auto ptr = schedPtr.promote(); ptr->ExecutingQueueTasks(bundleName); } catch (const BError &e) { - HILOGE("%{public}s", e.what()); + HILOGE("%{public}d", e.GetCode()); + ptr->FailedTask(bundleName); } catch (const exception &e) { HILOGE("%{public}s", e.what()); + ptr->FailedTask(bundleName); } catch (...) { - HILOGE(""); + HILOGE("error occur"); + ptr->FailedTask(bundleName); } }; threadPool_.AddTask(callStart); @@ -68,7 +71,7 @@ void SchedScheduler::Sched(string bundleName) void SchedScheduler::ExecutingQueueTasks(const string &bundleName) { - HILOGE("start"); + HILOGI("start"); InstallingState(bundleName); BConstants::ServiceSchedAction action = sessionPtr_->GetServiceSchedAction(bundleName); if (action == BConstants::ServiceSchedAction::START) { @@ -224,4 +227,10 @@ void SchedScheduler::InstallSuccess(const std::string &bundleName, const int32_t HILOGE("RemoveDirectory failed"); } } + +void SchedScheduler::FailedTask(const string &bundleName) +{ + HILOGE("FailedTask bundleName = %{public}s", bundleName.data()); + reversePtr_->OnBackupExtensionDied(move(bundleName), BError(BError::Codes::SA_REFUSED_ACT)); +} }; // namespace OHOS::FileManagement::Backup