diff --git a/frameworks/native/backup_ext/src/ext_backup.cpp b/frameworks/native/backup_ext/src/ext_backup.cpp index f49be75fe5999aad627b1c5269dd2adfcb156bb7..5d2bceaac18f6d2389c074f68f6865a307e93c39 100644 --- a/frameworks/native/backup_ext/src/ext_backup.cpp +++ b/frameworks/native/backup_ext/src/ext_backup.cpp @@ -92,6 +92,7 @@ void ExtBackup::OnCommand(const AAFwk::Want &want, bool restart, int startId) string ExtBackup::GetUsrConfig() const { + HILOGI("Begin."); vector config; AppExecFwk::BundleMgrClient client; BExcepUltils::BAssert(abilityInfo_, BError::Codes::EXT_BROKEN_FRAMEWORK, "Invalid abilityInfo_"); @@ -99,7 +100,7 @@ string ExtBackup::GetUsrConfig() const if (!client.GetProfileFromAbility(info, "ohos.extension.backup", config)) { throw BError(BError::Codes::EXT_INVAL_ARG, "Failed to invoke the GetProfileFromAbility method."); } - + HILOGI("End."); return config.empty() ? "" : config[0]; } diff --git a/frameworks/native/backup_ext/src/ext_extension.cpp b/frameworks/native/backup_ext/src/ext_extension.cpp index b9e53947846f6aa125a9b10bd39bbccc43feb3d3..597cf5bfb9c901b928137af95019d82c1aa3a55e 100644 --- a/frameworks/native/backup_ext/src/ext_extension.cpp +++ b/frameworks/native/backup_ext/src/ext_extension.cpp @@ -1471,7 +1471,7 @@ void BackupExtExtension::AsyncTaskOnIncrementalBackup(const mapAppIncrementalDone(BError(BError::Codes::EXT_INVAL_ARG).GetCode()); } }; - + HILOGI("AddTask start."); threadPool_.AddTask([task]() { try { task(); diff --git a/services/backup_sa/include/module_ipc/svc_session_manager.h b/services/backup_sa/include/module_ipc/svc_session_manager.h index 12c647180475236369ef15aa6ad3773214468aaa..a0bfa9aaf332f3304bf18d47623226a867117494 100644 --- a/services/backup_sa/include/module_ipc/svc_session_manager.h +++ b/services/backup_sa/include/module_ipc/svc_session_manager.h @@ -436,6 +436,8 @@ public: bool ValidRestoreDataType(RestoreTypeEnum restoreType); + bool IsServiceDied(); + private: /** * @brief 获取backup extension ability diff --git a/services/backup_sa/src/module_ipc/service.cpp b/services/backup_sa/src/module_ipc/service.cpp index 8442b27592f1bd5b0796fb26638b5f31f0cfc2e9..cec0345311030f84bac75fe4897fbd3af830cd6e 100644 --- a/services/backup_sa/src/module_ipc/service.cpp +++ b/services/backup_sa/src/module_ipc/service.cpp @@ -66,6 +66,7 @@ REGISTER_SYSTEM_ABILITY_BY_ID(Service, FILEMANAGEMENT_BACKUP_SERVICE_SA_ID, fals namespace { constexpr int32_t DEBUG_ID = 100; const static string COMMON_EVENT_TYPE = "broadcast"; +constexpr int32_t ERR_SERVICE_DIED = 29189; // ipc err: the app service died. const int32_t CONNECT_WAIT_TIME_S = 15; } // namespace @@ -767,7 +768,7 @@ void Service::ExtStart(const string &bundleName) if (scenario == IServiceReverse::Scenario::BACKUP) { auto ret = proxy->HandleBackup(); session_->GetServiceReverseProxy()->BackupOnBundleStarted(ret, bundleName); - if (ret) { + if (ret && ret != ERR_SERVICE_DIED) { ClearSessionAndSchedInfo(bundleName); } return; diff --git a/services/backup_sa/src/module_ipc/service_incremental.cpp b/services/backup_sa/src/module_ipc/service_incremental.cpp index cec2eeec1eaf6103dca4842f91ac479681b2d93f..cf1b20b20e8f3fd595d7622a4e5db2b50321ffda 100644 --- a/services/backup_sa/src/module_ipc/service_incremental.cpp +++ b/services/backup_sa/src/module_ipc/service_incremental.cpp @@ -50,6 +50,7 @@ using namespace std; namespace { constexpr int32_t DEBUG_ID = 100; +constexpr int32_t ERR_SERVICE_DIED = 29189; // ipc err: the app service died. } // namespace static inline int32_t GetUserIdDefault() @@ -70,6 +71,10 @@ ErrCode Service::Release() { HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); HILOGI("KILL"); + if (session_->IsServiceDied()) { + HILOGI("Session has been released."); + return BError(BError::Codes::OK); + } VerifyCaller(session_->GetScenario()); SessionDeactive(); return BError(BError::Codes::OK); @@ -348,7 +353,7 @@ bool Service::IncrementalBackup(const string &bundleName) UniqueFd lastManifestFd(session_->GetIncrementalManifestFd(bundleName)); auto ret = proxy->HandleIncrementalBackup(move(fdLocal), move(lastManifestFd)); session_->GetServiceReverseProxy()->IncrementalBackupOnBundleStarted(ret, bundleName); - if (ret) { + if (ret && ret != ERR_SERVICE_DIED) { ClearSessionAndSchedInfo(bundleName); } return true; 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 34c3b55b1ed62a5a8b6eef26bbed23824246a0f8..9dd65a751402c704a0e4581d890f2c63c7905fc8 100644 --- a/services/backup_sa/src/module_ipc/svc_session_manager.cpp +++ b/services/backup_sa/src/module_ipc/svc_session_manager.cpp @@ -706,4 +706,9 @@ bool SvcSessionManager::ValidRestoreDataType(RestoreTypeEnum restoreDataType) { return impl_.restoreDataType == restoreDataType; } + +bool SvcSessionManager::IsServiceDied() +{ + return impl_.clientProxy == nullptr; +} } // namespace OHOS::FileManagement::Backup diff --git a/tests/mock/module_ipc/svc_session_manager_mock.cpp b/tests/mock/module_ipc/svc_session_manager_mock.cpp index 69f45fd8d48593662c47251ea56a842d1fd8d85f..ea7354402117b3ec38eb9f47175f4bdaeb3e7679 100644 --- a/tests/mock/module_ipc/svc_session_manager_mock.cpp +++ b/tests/mock/module_ipc/svc_session_manager_mock.cpp @@ -352,4 +352,9 @@ int64_t SvcSessionManager::GetLastIncrementalTime(const string &bundleName) { return 0; } + +bool SvcSessionManager::IsServiceDied() +{ + return impl_.clientProxy == nullptr; +} } // namespace OHOS::FileManagement::Backup