From 77a79f5d3bab69707f9612b0b26ab2baf2ee93a5 Mon Sep 17 00:00:00 2001 From: "yaoruozi1@huawei.com" Date: Fri, 29 Nov 2024 18:41:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=8E=BBthrow=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yaoruozi1@huawei.com --- .../include/service_reverse.h | 48 +- .../src/service_incremental_reverse.cpp | 62 ++- .../backup_kit_inner/src/service_reverse.cpp | 62 ++- .../backup_kit_inner/impl/i_service_reverse.h | 48 +- .../backup_sa/include/module_ipc/service.h | 32 ++ .../module_ipc/service_reverse_proxy.h | 48 +- services/backup_sa/src/module_ipc/service.cpp | 72 +-- .../src/module_ipc/service_incremental.cpp | 19 +- .../service_incremental_reverse_proxy.cpp | 163 +++--- .../src/module_ipc/service_reverse_proxy.cpp | 177 ++++--- .../backup_sa/src/module_ipc/sub_service.cpp | 481 +++++++++++++++++- .../src/module_ipc/svc_session_manager.cpp | 3 +- .../include/service_reverse_proxy_mock.h | 48 +- tests/mock/module_ipc/service_mock.cpp | 111 ++++ .../module_ipc/service_reverse_proxy_mock.cpp | 170 +++++-- .../include/service_reverse_mock.h | 48 +- .../backup_impl/service_reverse_stub_test.cpp | 88 ++-- .../module_ipc/service_incremental_test.cpp | 137 ++++- .../module_ipc/service_other_test.cpp | 24 +- .../backup_sa/module_ipc/sub_service_test.cpp | 50 +- 20 files changed, 1387 insertions(+), 504 deletions(-) diff --git a/frameworks/native/backup_kit_inner/include/service_reverse.h b/frameworks/native/backup_kit_inner/include/service_reverse.h index 3ecb58eab..1767a1c13 100644 --- a/frameworks/native/backup_kit_inner/include/service_reverse.h +++ b/frameworks/native/backup_kit_inner/include/service_reverse.h @@ -25,37 +25,37 @@ namespace OHOS::FileManagement::Backup { class ServiceReverse final : public ServiceReverseStub { public: - void BackupOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override; - void BackupOnBundleStarted(int32_t errCode, std::string bundleName) override; - void BackupOnResultReport(std::string result, std::string bundleName) override; - void BackupOnBundleFinished(int32_t errCode, std::string bundleName) override; - void BackupOnAllBundlesFinished(int32_t errCode) override; - void BackupOnProcessInfo(std::string bundleName, std::string processInfo) override; + ErrCode BackupOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override; + ErrCode BackupOnBundleStarted(int32_t errCode, std::string bundleName) override; + ErrCode BackupOnResultReport(std::string result, std::string bundleName) override; + ErrCode BackupOnBundleFinished(int32_t errCode, std::string bundleName) override; + ErrCode BackupOnAllBundlesFinished(int32_t errCode) override; + ErrCode BackupOnProcessInfo(std::string bundleName, std::string processInfo) override; - void RestoreOnBundleStarted(int32_t errCode, std::string bundleName) override; - void RestoreOnBundleFinished(int32_t errCode, std::string bundleName) override; - void RestoreOnAllBundlesFinished(int32_t errCode) override; - void RestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override; - void RestoreOnResultReport(std::string result, std::string bundleName, + ErrCode RestoreOnBundleStarted(int32_t errCode, std::string bundleName) override; + ErrCode RestoreOnBundleFinished(int32_t errCode, std::string bundleName) override; + ErrCode RestoreOnAllBundlesFinished(int32_t errCode) override; + ErrCode RestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override; + ErrCode RestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode = 0) override; - void RestoreOnProcessInfo(std::string bundleName, std::string processInfo) override; + ErrCode RestoreOnProcessInfo(std::string bundleName, std::string processInfo) override; - void IncrementalBackupOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, + ErrCode IncrementalBackupOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, int32_t errCode) override; - void IncrementalBackupOnBundleStarted(int32_t errCode, std::string bundleName) override; - void IncrementalBackupOnResultReport(std::string result, std::string bundleName) override; - void IncrementalBackupOnBundleFinished(int32_t errCode, std::string bundleName) override; - void IncrementalBackupOnAllBundlesFinished(int32_t errCode) override; - void IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) override; + ErrCode IncrementalBackupOnBundleStarted(int32_t errCode, std::string bundleName) override; + ErrCode IncrementalBackupOnResultReport(std::string result, std::string bundleName) override; + ErrCode IncrementalBackupOnBundleFinished(int32_t errCode, std::string bundleName) override; + ErrCode IncrementalBackupOnAllBundlesFinished(int32_t errCode) override; + ErrCode IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) override; - void IncrementalRestoreOnBundleStarted(int32_t errCode, std::string bundleName) override; - void IncrementalRestoreOnBundleFinished(int32_t errCode, std::string bundleName) override; - void IncrementalRestoreOnAllBundlesFinished(int32_t errCode) override; - void IncrementalRestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, + ErrCode IncrementalRestoreOnBundleStarted(int32_t errCode, std::string bundleName) override; + ErrCode IncrementalRestoreOnBundleFinished(int32_t errCode, std::string bundleName) override; + ErrCode IncrementalRestoreOnAllBundlesFinished(int32_t errCode) override; + ErrCode IncrementalRestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, int32_t errCode) override; - void IncrementalRestoreOnResultReport(std::string result, std::string bundleName, + ErrCode IncrementalRestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode = 0) override; - void IncrementalRestoreOnProcessInfo(std::string bundleName, std::string processInfo) override; + ErrCode IncrementalRestoreOnProcessInfo(std::string bundleName, std::string processInfo) override; public: ServiceReverse() = delete; diff --git a/frameworks/native/backup_kit_inner/src/service_incremental_reverse.cpp b/frameworks/native/backup_kit_inner/src/service_incremental_reverse.cpp index ba1e761c5..6d428b78e 100644 --- a/frameworks/native/backup_kit_inner/src/service_incremental_reverse.cpp +++ b/frameworks/native/backup_kit_inner/src/service_incremental_reverse.cpp @@ -22,128 +22,140 @@ namespace OHOS::FileManagement::Backup { using namespace std; -void ServiceReverse::IncrementalBackupOnFileReady(string bundleName, string fileName, int fd, int manifestFd, +ErrCode ServiceReverse::IncrementalBackupOnFileReady(string bundleName, string fileName, int fd, int manifestFd, int32_t errCode) { if (scenario_ != Scenario::BACKUP || !callbacksIncrementalBackup_.onFileReady) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } BFileInfo bFileInfo(bundleName, fileName, 0); callbacksIncrementalBackup_.onFileReady(bFileInfo, UniqueFd(fd), UniqueFd(manifestFd), errCode); + return BError(BError::Codes::OK); } -void ServiceReverse::IncrementalBackupOnBundleStarted(int32_t errCode, string bundleName) +ErrCode ServiceReverse::IncrementalBackupOnBundleStarted(int32_t errCode, string bundleName) { if (scenario_ != Scenario::BACKUP || !callbacksIncrementalBackup_.onBundleStarted) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksIncrementalBackup_.onBundleStarted(errCode, bundleName); + return BError(BError::Codes::OK); } -void ServiceReverse::IncrementalBackupOnResultReport(std::string result, std::string bundleName) +ErrCode ServiceReverse::IncrementalBackupOnResultReport(std::string result, std::string bundleName) { if (scenario_ != Scenario::BACKUP || !callbacksIncrementalBackup_.onResultReport) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksIncrementalBackup_.onResultReport(bundleName, result); + return BError(BError::Codes::OK); } -void ServiceReverse::IncrementalBackupOnBundleFinished(int32_t errCode, string bundleName) +ErrCode ServiceReverse::IncrementalBackupOnBundleFinished(int32_t errCode, string bundleName) { if (scenario_ != Scenario::BACKUP || !callbacksIncrementalBackup_.onBundleFinished) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } HILOGI("errCode = %{public}d, bundleName = %{public}s", errCode, bundleName.c_str()); callbacksIncrementalBackup_.onBundleFinished(errCode, bundleName); + return BError(BError::Codes::OK); } -void ServiceReverse::IncrementalBackupOnAllBundlesFinished(int32_t errCode) +ErrCode ServiceReverse::IncrementalBackupOnAllBundlesFinished(int32_t errCode) { HILOGI("errCode = %{public}d", errCode); if (scenario_ != Scenario::BACKUP || !callbacksIncrementalBackup_.onAllBundlesFinished) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksIncrementalBackup_.onAllBundlesFinished(errCode); + return BError(BError::Codes::OK); } -void ServiceReverse::IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) +ErrCode ServiceReverse::IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) { HILOGI("bundleName = %{public}s", bundleName.c_str()); if (scenario_ != Scenario::BACKUP || !callbacksIncrementalBackup_.onProcess) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksIncrementalBackup_.onProcess(bundleName, processInfo); + return BError(BError::Codes::OK); } -void ServiceReverse::IncrementalRestoreOnBundleStarted(int32_t errCode, string bundleName) +ErrCode ServiceReverse::IncrementalRestoreOnBundleStarted(int32_t errCode, string bundleName) { if (scenario_ != Scenario::RESTORE || !callbacksIncrementalRestore_.onBundleStarted) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksIncrementalRestore_.onBundleStarted(errCode, bundleName); + return BError(BError::Codes::OK); } -void ServiceReverse::IncrementalRestoreOnBundleFinished(int32_t errCode, string bundleName) +ErrCode ServiceReverse::IncrementalRestoreOnBundleFinished(int32_t errCode, string bundleName) { if (scenario_ != Scenario::RESTORE || !callbacksIncrementalRestore_.onBundleFinished) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } HILOGI("errCode = %{public}d, bundleName = %{public}s", errCode, bundleName.c_str()); callbacksIncrementalRestore_.onBundleFinished(errCode, bundleName); + return BError(BError::Codes::OK); } -void ServiceReverse::IncrementalRestoreOnAllBundlesFinished(int32_t errCode) +ErrCode ServiceReverse::IncrementalRestoreOnAllBundlesFinished(int32_t errCode) { HILOGI("errCode = %{public}d", errCode); if (scenario_ != Scenario::RESTORE || !callbacksIncrementalRestore_.onAllBundlesFinished) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksIncrementalRestore_.onAllBundlesFinished(errCode); + return BError(BError::Codes::OK); } -void ServiceReverse::IncrementalRestoreOnFileReady(string bundleName, string fileName, int fd, int manifestFd, +ErrCode ServiceReverse::IncrementalRestoreOnFileReady(string bundleName, string fileName, int fd, int manifestFd, int32_t errCode) { if (scenario_ != Scenario::RESTORE || !callbacksIncrementalRestore_.onFileReady) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } BFileInfo bFileInfo(bundleName, fileName, 0); callbacksIncrementalRestore_.onFileReady(bFileInfo, UniqueFd(fd), UniqueFd(manifestFd), errCode); + return BError(BError::Codes::OK); } -void ServiceReverse::IncrementalRestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode) +ErrCode ServiceReverse::IncrementalRestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode) { HILOGI("begin incremental restore on result report, bundleName:%{public}s", bundleName.c_str()); if (scenario_ != Scenario::RESTORE || !callbacksIncrementalRestore_.onResultReport) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksIncrementalRestore_.onResultReport(bundleName, result); if (scenario_ != Scenario::RESTORE || !callbacksIncrementalRestore_.onBundleFinished) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksIncrementalRestore_.onBundleFinished(errCode, bundleName); + return BError(BError::Codes::OK); } -void ServiceReverse::IncrementalRestoreOnProcessInfo(std::string bundleName, std::string processInfo) +ErrCode ServiceReverse::IncrementalRestoreOnProcessInfo(std::string bundleName, std::string processInfo) { HILOGI("begin incremental report processInfo, bundleName:%{public}s", bundleName.c_str()); if (scenario_ != Scenario::RESTORE || !callbacksIncrementalRestore_.onProcess) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksIncrementalRestore_.onProcess(bundleName, processInfo); + return BError(BError::Codes::OK); } ServiceReverse::ServiceReverse(BIncrementalBackupSession::Callbacks callbacks) diff --git a/frameworks/native/backup_kit_inner/src/service_reverse.cpp b/frameworks/native/backup_kit_inner/src/service_reverse.cpp index 6328cb70e..b0eff1b02 100644 --- a/frameworks/native/backup_kit_inner/src/service_reverse.cpp +++ b/frameworks/native/backup_kit_inner/src/service_reverse.cpp @@ -21,128 +21,140 @@ namespace OHOS::FileManagement::Backup { using namespace std; -void ServiceReverse::BackupOnFileReady(string bundleName, string fileName, int fd, int32_t errCode) +ErrCode ServiceReverse::BackupOnFileReady(string bundleName, string fileName, int fd, int32_t errCode) { if (scenario_ != Scenario::BACKUP || !callbacksBackup_.onFileReady) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } BFileInfo bFileInfo(bundleName, fileName, 0); callbacksBackup_.onFileReady(bFileInfo, UniqueFd(fd), errCode); + return BError(BError::Codes::OK); } -void ServiceReverse::BackupOnBundleStarted(int32_t errCode, string bundleName) +ErrCode ServiceReverse::BackupOnBundleStarted(int32_t errCode, string bundleName) { if (scenario_ != Scenario::BACKUP || !callbacksBackup_.onBundleStarted) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksBackup_.onBundleStarted(errCode, bundleName); + return BError(BError::Codes::OK); } -void ServiceReverse::BackupOnResultReport(std::string result, std::string bundleName) +ErrCode ServiceReverse::BackupOnResultReport(std::string result, std::string bundleName) { if (scenario_ != Scenario::BACKUP || !callbacksBackup_.onResultReport) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksBackup_.onResultReport(bundleName, result); + return BError(BError::Codes::OK); } -void ServiceReverse::BackupOnBundleFinished(int32_t errCode, string bundleName) +ErrCode ServiceReverse::BackupOnBundleFinished(int32_t errCode, string bundleName) { if (scenario_ != Scenario::BACKUP || !callbacksBackup_.onBundleFinished) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } HILOGI("errCode = %{public}d, bundleName = %{public}s", errCode, bundleName.c_str()); callbacksBackup_.onBundleFinished(errCode, bundleName); + return BError(BError::Codes::OK); } -void ServiceReverse::BackupOnAllBundlesFinished(int32_t errCode) +ErrCode ServiceReverse::BackupOnAllBundlesFinished(int32_t errCode) { HILOGI("errCode = %{public}d", errCode); if (scenario_ != Scenario::BACKUP || !callbacksBackup_.onAllBundlesFinished) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksBackup_.onAllBundlesFinished(errCode); + return BError(BError::Codes::OK); } -void ServiceReverse::BackupOnProcessInfo(std::string bundleName, std::string processInfo) +ErrCode ServiceReverse::BackupOnProcessInfo(std::string bundleName, std::string processInfo) { HILOGI("bundleName = %{public}s", bundleName.c_str()); if (scenario_ != Scenario::BACKUP || !callbacksBackup_.onProcess) { HILOGI("Error scenario or callback is nullptr"); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksBackup_.onProcess(bundleName, processInfo); + return BError(BError::Codes::OK); } -void ServiceReverse::RestoreOnBundleStarted(int32_t errCode, string bundleName) +ErrCode ServiceReverse::RestoreOnBundleStarted(int32_t errCode, string bundleName) { if (scenario_ != Scenario::RESTORE || !callbacksRestore_.onBundleStarted) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksRestore_.onBundleStarted(errCode, bundleName); + return BError(BError::Codes::OK); } -void ServiceReverse::RestoreOnBundleFinished(int32_t errCode, string bundleName) +ErrCode ServiceReverse::RestoreOnBundleFinished(int32_t errCode, string bundleName) { if (scenario_ != Scenario::RESTORE || !callbacksRestore_.onBundleFinished) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } HILOGI("errCode = %{public}d, bundleName = %{public}s", errCode, bundleName.c_str()); callbacksRestore_.onBundleFinished(errCode, bundleName); + return BError(BError::Codes::OK); } -void ServiceReverse::RestoreOnAllBundlesFinished(int32_t errCode) +ErrCode ServiceReverse::RestoreOnAllBundlesFinished(int32_t errCode) { HILOGI("errCode = %{public}d", errCode); if (scenario_ != Scenario::RESTORE || !callbacksRestore_.onAllBundlesFinished) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksRestore_.onAllBundlesFinished(errCode); + return BError(BError::Codes::OK); } -void ServiceReverse::RestoreOnFileReady(string bundleName, string fileName, int fd, int32_t errCode) +ErrCode ServiceReverse::RestoreOnFileReady(string bundleName, string fileName, int fd, int32_t errCode) { HILOGD("begin, bundleName is:%{public}s", bundleName.c_str()); if (scenario_ != Scenario::RESTORE || !callbacksRestore_.onFileReady) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } BFileInfo bFileInfo(bundleName, fileName, 0); callbacksRestore_.onFileReady(bFileInfo, UniqueFd(fd), errCode); + return BError(BError::Codes::OK); } -void ServiceReverse::RestoreOnResultReport(string result, std::string bundleName, ErrCode errCode) +ErrCode ServiceReverse::RestoreOnResultReport(string result, std::string bundleName, ErrCode errCode) { HILOGI("ServiceReverse RestoreOnResultReport bundle %{public}s begin with result: %{public}s", bundleName.c_str(), result.c_str()); if (scenario_ != Scenario::RESTORE || !callbacksRestore_.onResultReport) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksRestore_.onResultReport(bundleName, result); if (scenario_ != Scenario::RESTORE || !callbacksRestore_.onBundleFinished) { HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksRestore_.onBundleFinished(errCode, bundleName); + return BError(BError::Codes::OK); } -void ServiceReverse::RestoreOnProcessInfo(std::string bundleName, std::string processInfo) +ErrCode ServiceReverse::RestoreOnProcessInfo(std::string bundleName, std::string processInfo) { HILOGI("bundleName = %{public}s", bundleName.c_str()); if (scenario_ != Scenario::RESTORE || !callbacksRestore_.onProcess) { HILOGI("Error scenario or callback is nullptr"); - return; + return BError(BError::Codes::SA_INVAL_ARG); } callbacksRestore_.onProcess(bundleName, processInfo); + return BError(BError::Codes::OK); } ServiceReverse::ServiceReverse(BSessionBackup::Callbacks callbacks) diff --git a/interfaces/inner_api/native/backup_kit_inner/impl/i_service_reverse.h b/interfaces/inner_api/native/backup_kit_inner/impl/i_service_reverse.h index 52311dde5..7633a9405 100644 --- a/interfaces/inner_api/native/backup_kit_inner/impl/i_service_reverse.h +++ b/interfaces/inner_api/native/backup_kit_inner/impl/i_service_reverse.h @@ -33,39 +33,39 @@ public: public: virtual ~IServiceReverse() = default; - virtual void BackupOnBundleStarted(int32_t errCode, std::string bundleName) = 0; - virtual void BackupOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) = 0; - virtual void BackupOnResultReport(std::string result, std::string bundleName) = 0; - virtual void BackupOnBundleFinished(int32_t errCode, std::string bundleName) = 0; - virtual void BackupOnAllBundlesFinished(int32_t errCode) = 0; - virtual void BackupOnProcessInfo(std::string bundleName, std::string processInfo) = 0; + virtual ErrCode BackupOnBundleStarted(int32_t errCode, std::string bundleName) = 0; + virtual ErrCode BackupOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) = 0; + virtual ErrCode BackupOnResultReport(std::string result, std::string bundleName) = 0; + virtual ErrCode BackupOnBundleFinished(int32_t errCode, std::string bundleName) = 0; + virtual ErrCode BackupOnAllBundlesFinished(int32_t errCode) = 0; + virtual ErrCode BackupOnProcessInfo(std::string bundleName, std::string processInfo) = 0; - virtual void RestoreOnBundleStarted(int32_t errCode, std::string bundleName) = 0; - virtual void RestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) = 0; - virtual void RestoreOnResultReport(std::string result, std::string bundleName, + virtual ErrCode RestoreOnBundleStarted(int32_t errCode, std::string bundleName) = 0; + virtual ErrCode RestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) = 0; + virtual ErrCode RestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode = 0) = 0; - virtual void RestoreOnBundleFinished(int32_t errCode, std::string bundleName) = 0; - virtual void RestoreOnAllBundlesFinished(int32_t errCode) = 0; - virtual void RestoreOnProcessInfo(std::string bundleName, std::string processInfo) = 0; + virtual ErrCode RestoreOnBundleFinished(int32_t errCode, std::string bundleName) = 0; + virtual ErrCode RestoreOnAllBundlesFinished(int32_t errCode) = 0; + virtual ErrCode RestoreOnProcessInfo(std::string bundleName, std::string processInfo) = 0; - virtual void IncrementalBackupOnBundleStarted(int32_t errCode, std::string bundleName) = 0; - virtual void IncrementalBackupOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, + virtual ErrCode IncrementalBackupOnBundleStarted(int32_t errCode, std::string bundleName) = 0; + virtual ErrCode IncrementalBackupOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, int32_t errCode) = 0; - virtual void IncrementalBackupOnResultReport(std::string result, std::string bundleName) = 0; - virtual void IncrementalBackupOnBundleFinished(int32_t errCode, std::string bundleName) = 0; - virtual void IncrementalBackupOnAllBundlesFinished(int32_t errCode) = 0; - virtual void IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) = 0; + virtual ErrCode IncrementalBackupOnResultReport(std::string result, std::string bundleName) = 0; + virtual ErrCode IncrementalBackupOnBundleFinished(int32_t errCode, std::string bundleName) = 0; + virtual ErrCode IncrementalBackupOnAllBundlesFinished(int32_t errCode) = 0; + virtual ErrCode IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) = 0; - virtual void IncrementalRestoreOnBundleStarted(int32_t errCode, std::string bundleName) = 0; - virtual void IncrementalRestoreOnFileReady(std::string bundleName, + virtual ErrCode IncrementalRestoreOnBundleStarted(int32_t errCode, std::string bundleName) = 0; + virtual ErrCode IncrementalRestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, int32_t errCode) = 0; - virtual void IncrementalRestoreOnResultReport(std::string result, std::string bundleName, + virtual ErrCode IncrementalRestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode = 0) = 0; - virtual void IncrementalRestoreOnBundleFinished(int32_t errCode, std::string bundleName) = 0; - virtual void IncrementalRestoreOnAllBundlesFinished(int32_t errCode) = 0; - virtual void IncrementalRestoreOnProcessInfo(const std::string bundleName, const std::string processInfo) = 0; + virtual ErrCode IncrementalRestoreOnBundleFinished(int32_t errCode, std::string bundleName) = 0; + virtual ErrCode IncrementalRestoreOnAllBundlesFinished(int32_t errCode) = 0; + virtual ErrCode IncrementalRestoreOnProcessInfo(const std::string bundleName, const std::string processInfo) = 0; DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.FileManagement.Backup.IServiceReverse") }; diff --git a/services/backup_sa/include/module_ipc/service.h b/services/backup_sa/include/module_ipc/service.h index 1b92cc342..1700ab58c 100644 --- a/services/backup_sa/include/module_ipc/service.h +++ b/services/backup_sa/include/module_ipc/service.h @@ -559,6 +559,38 @@ private: void SetBundleIncDataInfo(const std::vector &bundlesToBackup, std::vector &supportBundleNames); + + ErrCode ReverseBackupOnBundleStarted(int32_t errCode, std::string bundleName); + ErrCode ReverseBackupOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode); + ErrCode ReverseBackupOnResultReport(std::string result, std::string bundleName); + ErrCode ReverseBackupOnBundleFinished(int32_t errCode, std::string bundleName); + ErrCode ReverseBackupOnAllBundlesFinished(int32_t errCode); + ErrCode ReverseBackupOnProcessInfo(std::string bundleName, std::string processInfo); + + ErrCode ReverseRestoreOnBundleStarted(int32_t errCode, std::string bundleName); + ErrCode ReverseRestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode); + ErrCode ReverseRestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode = 0); + ErrCode ReverseRestoreOnBundleFinished(int32_t errCode, std::string bundleName); + ErrCode ReverseRestoreOnAllBundlesFinished(int32_t errCode); + ErrCode ReverseRestoreOnProcessInfo(std::string bundleName, std::string processInfo); + + ErrCode ReverseIncBackupOnBundleStarted(int32_t errCode, std::string bundleName); + ErrCode ReverseIncBackupOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, + int32_t errCode); + ErrCode ReverseIncBackupOnResultReport(std::string result, std::string bundleName); + ErrCode ReverseIncBackupOnBundleFinished(int32_t errCode, std::string bundleName); + ErrCode ReverseIncBackupOnAllBundlesFinished(int32_t errCode); + ErrCode ReverseIncBackupOnProcessInfo(std::string bundleName, std::string processInfo); + + ErrCode ReverseIncRestoreOnBundleStarted(int32_t errCode, std::string bundleName); + ErrCode ReverseIncRestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, + int32_t errCode); + ErrCode ReverseIncRestoreOnResultReport(std::string result, std::string bundleName, + ErrCode errCode = 0); + ErrCode ReverseIncRestoreOnBundleFinished(int32_t errCode, std::string bundleName); + ErrCode ReverseIncRestoreOnAllBundlesFinished(int32_t errCode); + ErrCode ReverseIncRestoreOnProcessInfo(std::string bundleName, std::string processInfo); + private: static sptr instance_; static std::mutex instanceLock_; diff --git a/services/backup_sa/include/module_ipc/service_reverse_proxy.h b/services/backup_sa/include/module_ipc/service_reverse_proxy.h index 3e6667d8d..a6a199f42 100644 --- a/services/backup_sa/include/module_ipc/service_reverse_proxy.h +++ b/services/backup_sa/include/module_ipc/service_reverse_proxy.h @@ -22,37 +22,37 @@ namespace OHOS::FileManagement::Backup { class ServiceReverseProxy final : public IRemoteProxy, protected NoCopyable { public: - void BackupOnBundleStarted(int32_t errCode, std::string bundleName) override; - void BackupOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override; - void BackupOnResultReport(std::string result, std::string bundleName) override; - void BackupOnBundleFinished(int32_t errCode, std::string bundleName) override; - void BackupOnAllBundlesFinished(int32_t errCode) override; - void BackupOnProcessInfo(std::string bundleName, std::string processInfo) override; + ErrCode BackupOnBundleStarted(int32_t errCode, std::string bundleName) override; + ErrCode BackupOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override; + ErrCode BackupOnResultReport(std::string result, std::string bundleName) override; + ErrCode BackupOnBundleFinished(int32_t errCode, std::string bundleName) override; + ErrCode BackupOnAllBundlesFinished(int32_t errCode) override; + ErrCode BackupOnProcessInfo(std::string bundleName, std::string processInfo) override; - void RestoreOnBundleStarted(int32_t errCode, std::string bundleName) override; - void RestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override; - void RestoreOnResultReport(std::string result, std::string bundleName, + ErrCode RestoreOnBundleStarted(int32_t errCode, std::string bundleName) override; + ErrCode RestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override; + ErrCode RestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode = 0) override; - void RestoreOnBundleFinished(int32_t errCode, std::string bundleName) override; - void RestoreOnAllBundlesFinished(int32_t errCode) override; - void RestoreOnProcessInfo(std::string bundleName, std::string processInfo) override; + ErrCode RestoreOnBundleFinished(int32_t errCode, std::string bundleName) override; + ErrCode RestoreOnAllBundlesFinished(int32_t errCode) override; + ErrCode RestoreOnProcessInfo(std::string bundleName, std::string processInfo) override; - void IncrementalBackupOnBundleStarted(int32_t errCode, std::string bundleName) override; - void IncrementalBackupOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, + ErrCode IncrementalBackupOnBundleStarted(int32_t errCode, std::string bundleName) override; + ErrCode IncrementalBackupOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, int32_t errCode) override; - void IncrementalBackupOnResultReport(std::string result, std::string bundleName) override; - void IncrementalBackupOnBundleFinished(int32_t errCode, std::string bundleName) override; - void IncrementalBackupOnAllBundlesFinished(int32_t errCode) override; - void IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) override; + ErrCode IncrementalBackupOnResultReport(std::string result, std::string bundleName) override; + ErrCode IncrementalBackupOnBundleFinished(int32_t errCode, std::string bundleName) override; + ErrCode IncrementalBackupOnAllBundlesFinished(int32_t errCode) override; + ErrCode IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) override; - void IncrementalRestoreOnBundleStarted(int32_t errCode, std::string bundleName) override; - void IncrementalRestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, + ErrCode IncrementalRestoreOnBundleStarted(int32_t errCode, std::string bundleName) override; + ErrCode IncrementalRestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, int32_t errCode) override; - void IncrementalRestoreOnResultReport(std::string result, std::string bundleName, + ErrCode IncrementalRestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode = 0) override; - void IncrementalRestoreOnBundleFinished(int32_t errCode, std::string bundleName) override; - void IncrementalRestoreOnAllBundlesFinished(int32_t errCode) override; - void IncrementalRestoreOnProcessInfo(std::string bundleName, std::string processInfo) override; + ErrCode IncrementalRestoreOnBundleFinished(int32_t errCode, std::string bundleName) override; + ErrCode IncrementalRestoreOnAllBundlesFinished(int32_t errCode) override; + ErrCode IncrementalRestoreOnProcessInfo(std::string bundleName, std::string processInfo) override; public: explicit ServiceReverseProxy(const sptr &impl) : IRemoteProxy(impl) {} diff --git a/services/backup_sa/src/module_ipc/service.cpp b/services/backup_sa/src/module_ipc/service.cpp index 3f9f76ef4..78412891b 100644 --- a/services/backup_sa/src/module_ipc/service.cpp +++ b/services/backup_sa/src/module_ipc/service.cpp @@ -524,9 +524,9 @@ void Service::OnBundleStarted(BError error, sptr session, con IServiceReverse::Scenario scenario = session->GetScenario(); if (scenario == IServiceReverse::Scenario::RESTORE && BackupPara().GetBackupOverrideIncrementalRestore() && session->ValidRestoreDataType(RestoreTypeEnum::RESTORE_DATA_WAIT_SEND)) { - session->GetServiceReverseProxy()->IncrementalRestoreOnBundleStarted(error, bundleName); + ReverseIncRestoreOnBundleStarted(error, bundleName); } else if (scenario == IServiceReverse::Scenario::RESTORE) { - session->GetServiceReverseProxy()->RestoreOnBundleStarted(error, bundleName); + ReverseRestoreOnBundleStarted(error, bundleName); } BundleBeginRadarReport(bundleName, error.GetCode(), scenario); } @@ -885,15 +885,15 @@ ErrCode Service::ServiceResultReport(const std::string restoreRetInfo, callerName = VerifyCallerAndGetCallerName(); SendEndAppGalleryNotify(callerName); if (sennario == BackupRestoreScenario::FULL_RESTORE) { - session_->GetServiceReverseProxy()->RestoreOnResultReport(restoreRetInfo, callerName, errCode); + ReverseRestoreOnResultReport(restoreRetInfo, callerName, errCode); NotifyCloneBundleFinish(callerName, sennario); } else if (sennario == BackupRestoreScenario::INCREMENTAL_RESTORE) { - session_->GetServiceReverseProxy()->IncrementalRestoreOnResultReport(restoreRetInfo, callerName, errCode); + ReverseIncRestoreOnResultReport(restoreRetInfo, callerName, errCode); NotifyCloneBundleFinish(callerName, sennario); } else if (sennario == BackupRestoreScenario::FULL_BACKUP) { - session_->GetServiceReverseProxy()->BackupOnResultReport(restoreRetInfo, callerName); + ReverseBackupOnResultReport(restoreRetInfo, callerName); } else if (sennario == BackupRestoreScenario::INCREMENTAL_BACKUP) { - session_->GetServiceReverseProxy()->IncrementalBackupOnResultReport(restoreRetInfo, callerName); + ReverseIncBackupOnResultReport(restoreRetInfo, callerName); } return BError(BError::Codes::OK); } catch (const BError &e) { @@ -914,14 +914,14 @@ ErrCode Service::SAResultReport(const std::string bundleName, const std::string const ErrCode errCode, const BackupRestoreScenario sennario) { if (sennario == BackupRestoreScenario::FULL_RESTORE) { - session_->GetServiceReverseProxy()->RestoreOnResultReport(restoreRetInfo, bundleName); + ReverseRestoreOnResultReport(restoreRetInfo, bundleName); } else if (sennario == BackupRestoreScenario::INCREMENTAL_RESTORE) { - session_->GetServiceReverseProxy()->IncrementalRestoreOnResultReport(restoreRetInfo, bundleName); + ReverseIncRestoreOnResultReport(restoreRetInfo, bundleName); } else if (sennario == BackupRestoreScenario::FULL_BACKUP) { - session_->GetServiceReverseProxy()->BackupOnResultReport(restoreRetInfo, bundleName); - session_->GetServiceReverseProxy()->BackupOnBundleFinished(errCode, bundleName); + ReverseBackupOnResultReport(restoreRetInfo, bundleName); + ReverseBackupOnBundleFinished(errCode, bundleName); } else if (sennario == BackupRestoreScenario::INCREMENTAL_BACKUP) { - session_->GetServiceReverseProxy()->IncrementalBackupOnResultReport(restoreRetInfo, bundleName); + ReverseIncBackupOnResultReport(restoreRetInfo, bundleName); } if (sennario == BackupRestoreScenario::FULL_RESTORE || sennario == BackupRestoreScenario::INCREMENTAL_RESTORE) { BundleEndRadarReport(bundleName, errCode, IServiceReverse::Scenario::RESTORE); @@ -1021,7 +1021,7 @@ ErrCode Service::GetFileHandle(const string &bundleName, const string &fileName) AppRadar::GetInstance().RecordRestoreFuncRes(info, "Service::GetFileHandle", GetUserIdDefault(), BizStageRestore::BIZ_STAGE_GET_FILE_HANDLE_FAIL, errCode); } - session_->GetServiceReverseProxy()->RestoreOnFileReady(bundleName, fileName, move(fd), errCode); + ReverseRestoreOnFileReady(bundleName, fileName, move(fd), errCode); FileReadyRadarReport(bundleName, fileName, errCode, IServiceReverse::Scenario::RESTORE); } else { session_->SetExtFileNameRequest(bundleName, fileName); @@ -1118,7 +1118,7 @@ void Service::ExtStart(const string &bundleName) } if (scenario == IServiceReverse::Scenario::BACKUP) { auto ret = proxy->HandleBackup(session_->GetClearDataFlag(bundleName)); - session_->GetServiceReverseProxy()->BackupOnBundleStarted(ret, bundleName); + ReverseBackupOnBundleStarted(ret, bundleName); BundleBeginRadarReport(bundleName, ret, scenario); if (ret) { ClearSessionAndSchedInfo(bundleName); @@ -1130,13 +1130,13 @@ void Service::ExtStart(const string &bundleName) throw BError(BError::Codes::SA_INVAL_ARG, "Failed to scenario"); } auto ret = proxy->HandleRestore(session_->GetClearDataFlag(bundleName)); - session_->GetServiceReverseProxy()->RestoreOnBundleStarted(ret, bundleName); + ReverseRestoreOnBundleStarted(ret, bundleName); BundleBeginRadarReport(bundleName, ret, scenario); auto fileNameVec = session_->GetExtFileNameRequest(bundleName); for (auto &fileName : fileNameVec) { int32_t errCode = 0; UniqueFd fd = proxy->GetFileHandle(fileName, errCode); - session_->GetServiceReverseProxy()->RestoreOnFileReady(bundleName, fileName, move(fd), errCode); + ReverseRestoreOnFileReady(bundleName, fileName, move(fd), errCode); FileReadyRadarReport(bundleName, fileName, errCode, scenario); } } catch (...) { @@ -1166,21 +1166,21 @@ void Service::ReportOnExtConnectFailed(const IServiceReverse::Scenario scenario, return; } if (scenario == IServiceReverse::Scenario::BACKUP && session_->GetIsIncrementalBackup()) { - session_->GetServiceReverseProxy()->IncrementalBackupOnBundleStarted(ret, bundleName); + ReverseIncBackupOnBundleStarted(ret, bundleName); BundleBeginRadarReport(bundleName, ret, scenario); } else if (scenario == IServiceReverse::Scenario::RESTORE && BackupPara().GetBackupOverrideIncrementalRestore() && session_->ValidRestoreDataType(RestoreTypeEnum::RESTORE_DATA_WAIT_SEND)) { - session_->GetServiceReverseProxy()->IncrementalRestoreOnBundleStarted(ret, bundleName); + ReverseIncRestoreOnBundleStarted(ret, bundleName); BundleBeginRadarReport(bundleName, ret, scenario); DisposeErr disposeErr = AppGalleryDisposeProxy::GetInstance()->EndRestore(bundleName); HILOGI("ExtConnectFailed EndRestore, code=%{public}d, bundleName=%{public}s", disposeErr, bundleName.c_str()); } else if (scenario == IServiceReverse::Scenario::BACKUP) { - session_->GetServiceReverseProxy()->BackupOnBundleStarted(ret, bundleName); + ReverseBackupOnBundleStarted(ret, bundleName); BundleBeginRadarReport(bundleName, ret, scenario); } else if (scenario == IServiceReverse::Scenario::RESTORE) { - session_->GetServiceReverseProxy()->RestoreOnBundleStarted(ret, bundleName); + ReverseRestoreOnBundleStarted(ret, bundleName); BundleBeginRadarReport(bundleName, ret, scenario); DisposeErr disposeErr = AppGalleryDisposeProxy::GetInstance()->EndRestore(bundleName); HILOGI("ExtConnectFailed EndRestore, code=%{public}d, bundleName=%{public}s", disposeErr, @@ -1221,15 +1221,15 @@ void Service::NoticeClientFinish(const string &bundleName, ErrCode errCode) SendEndAppGalleryNotify(bundleName); auto scenario = session_->GetScenario(); if (scenario == IServiceReverse::Scenario::BACKUP && session_->GetIsIncrementalBackup()) { - session_->GetServiceReverseProxy()->IncrementalBackupOnBundleFinished(errCode, bundleName); + ReverseIncBackupOnBundleFinished(errCode, bundleName); } else if (scenario == IServiceReverse::Scenario::RESTORE && BackupPara().GetBackupOverrideIncrementalRestore() && session_->ValidRestoreDataType(RestoreTypeEnum::RESTORE_DATA_WAIT_SEND)) { - session_->GetServiceReverseProxy()->IncrementalRestoreOnBundleFinished(errCode, bundleName); + ReverseIncRestoreOnBundleFinished(errCode, bundleName); } else if (scenario == IServiceReverse::Scenario::BACKUP) { - session_->GetServiceReverseProxy()->BackupOnBundleFinished(errCode, bundleName); + ReverseBackupOnBundleFinished(errCode, bundleName); } else if (scenario == IServiceReverse::Scenario::RESTORE) { - session_->GetServiceReverseProxy()->RestoreOnBundleFinished(errCode, bundleName); + ReverseRestoreOnBundleFinished(errCode, bundleName); }; BundleEndRadarReport(bundleName, errCode, scenario); /* If all bundle ext process finish, notice client. */ @@ -1360,15 +1360,15 @@ void Service::OnAllBundlesFinished(ErrCode errCode) SessionDeactive(); } if (scenario == IServiceReverse::Scenario::BACKUP && session_->GetIsIncrementalBackup()) { - session_->GetServiceReverseProxy()->IncrementalBackupOnAllBundlesFinished(errCode); + ReverseIncBackupOnAllBundlesFinished(errCode); } else if (scenario == IServiceReverse::Scenario::RESTORE && BackupPara().GetBackupOverrideIncrementalRestore() && session_->ValidRestoreDataType(RestoreTypeEnum::RESTORE_DATA_WAIT_SEND)) { - session_->GetServiceReverseProxy()->IncrementalRestoreOnAllBundlesFinished(errCode); + ReverseIncRestoreOnAllBundlesFinished(errCode); } else if (scenario == IServiceReverse::Scenario::BACKUP) { - session_->GetServiceReverseProxy()->BackupOnAllBundlesFinished(errCode); + ReverseBackupOnAllBundlesFinished(errCode); } else if (scenario == IServiceReverse::Scenario::RESTORE) { - session_->GetServiceReverseProxy()->RestoreOnAllBundlesFinished(errCode); + ReverseRestoreOnAllBundlesFinished(errCode); } if (!BackupPara().GetBackupOverrideBackupSARelease()) { sched_->TryUnloadServiceTimer(true); @@ -1855,7 +1855,7 @@ ErrCode Service::BackupSA(std::string bundleName) } if (scenario == IServiceReverse::Scenario::BACKUP) { auto ret = saConnection->CallBackupSA(); - session_->GetServiceReverseProxy()->BackupOnBundleStarted(ret, bundleName); + ReverseBackupOnBundleStarted(ret, bundleName); BundleBeginRadarReport(bundleName, ret, scenario); if (ret) { HILOGI("BackupSA ret is %{public}d", ret); @@ -1864,7 +1864,7 @@ ErrCode Service::BackupSA(std::string bundleName) return BError(ret); } } else if (scenario == IServiceReverse::Scenario::RESTORE) { - session_->GetServiceReverseProxy()->IncrementalRestoreOnBundleStarted(BError(BError::Codes::OK), bundleName); + ReverseIncRestoreOnBundleStarted(BError(BError::Codes::OK), bundleName); } return BError(BError::Codes::OK); } @@ -1875,7 +1875,7 @@ void Service::OnSABackup(const std::string &bundleName, const int &fd, const std auto task = [bundleName, fd, result, errCode, this]() { HILOGI("OnSABackup bundleName: %{public}s, fd: %{public}d, result: %{public}s, err: %{public}d", bundleName.c_str(), fd, result.c_str(), errCode); - session_->GetServiceReverseProxy()->BackupOnFileReady(bundleName, "", move(fd), errCode); + ReverseBackupOnFileReady(bundleName, "", move(fd), errCode); FileReadyRadarReport(bundleName, "", errCode, IServiceReverse::Scenario::BACKUP); SAResultReport(bundleName, result, errCode, BackupRestoreScenario::FULL_BACKUP); }; @@ -1941,7 +1941,7 @@ void Service::NotifyCallerCurAppDone(ErrCode errCode, const std::string &callerN IServiceReverse::Scenario scenario = session_->GetScenario(); if (scenario == IServiceReverse::Scenario::BACKUP) { HILOGI("will notify clone data, scenario is Backup"); - session_->GetServiceReverseProxy()->BackupOnBundleFinished(errCode, callerName); + ReverseBackupOnBundleFinished(errCode, callerName); auto now = std::chrono::system_clock::now(); auto time = std::chrono::system_clock::to_time_t(now); auto ms = std::chrono::duration_cast(now.time_since_epoch()); @@ -1959,7 +1959,7 @@ void Service::NotifyCallerCurAppDone(ErrCode errCode, const std::string &callerN ); } else if (scenario == IServiceReverse::Scenario::RESTORE) { HILOGI("will notify clone data, scenario is Restore"); - session_->GetServiceReverseProxy()->RestoreOnBundleFinished(errCode, callerName); + ReverseRestoreOnBundleFinished(errCode, callerName); } BundleEndRadarReport(callerName, errCode, scenario); } @@ -1970,13 +1970,13 @@ ErrCode Service::ReportAppProcessInfo(const std::string processInfo, BackupResto try { string bundleName = VerifyCallerAndGetCallerName(); if (sennario == BackupRestoreScenario::FULL_RESTORE) { - session_->GetServiceReverseProxy()->RestoreOnProcessInfo(bundleName, processInfo); + ReverseRestoreOnProcessInfo(bundleName, processInfo); } else if (sennario == BackupRestoreScenario::INCREMENTAL_RESTORE) { - session_->GetServiceReverseProxy()->IncrementalRestoreOnProcessInfo(bundleName, processInfo); + ReverseIncRestoreOnProcessInfo(bundleName, processInfo); } else if (sennario == BackupRestoreScenario::FULL_BACKUP) { - session_->GetServiceReverseProxy()->BackupOnProcessInfo(bundleName, processInfo); + ReverseBackupOnProcessInfo(bundleName, processInfo); } else if (sennario == BackupRestoreScenario::INCREMENTAL_BACKUP) { - session_->GetServiceReverseProxy()->IncrementalBackupOnProcessInfo(bundleName, processInfo); + ReverseIncBackupOnProcessInfo(bundleName, processInfo); } return BError(BError::Codes::OK); } catch (const BError &e) { diff --git a/services/backup_sa/src/module_ipc/service_incremental.cpp b/services/backup_sa/src/module_ipc/service_incremental.cpp index 8583f06e2..cd26b7159 100644 --- a/services/backup_sa/src/module_ipc/service_incremental.cpp +++ b/services/backup_sa/src/module_ipc/service_incremental.cpp @@ -488,17 +488,15 @@ ErrCode Service::AppIncrementalFileReady(const std::string &fileName, UniqueFd f try { string callerName = VerifyCallerAndGetCallerName(); if (session_->GetScenario() == IServiceReverse::Scenario::RESTORE) { - session_->GetServiceReverseProxy()->IncrementalRestoreOnFileReady(callerName, fileName, move(fd), - move(manifestFd), errCode); + ErrCode ret = ReverseIncRestoreOnFileReady(callerName, fileName, move(fd), move(manifestFd), errCode); FileReadyRadarReport(callerName, fileName, errCode, IServiceReverse::Scenario::RESTORE); - return BError(BError::Codes::OK); + return ret; } if (fileName == BConstants::EXT_BACKUP_MANAGE) { fd = session_->OnBundleExtManageInfo(callerName, move(fd)); } HILOGD("reverse: Will notify IncrementalBackupOnFileReady"); - session_->GetServiceReverseProxy()->IncrementalBackupOnFileReady(callerName, fileName, move(fd), - move(manifestFd), errCode); + ErrCode ret = ReverseIncBackupOnFileReady(callerName, fileName, move(fd), move(manifestFd), errCode); FileReadyRadarReport(callerName, fileName, errCode, IServiceReverse::Scenario::BACKUP); AuditLog auditLog = { false, "Backup File Ready", "ADD", "", 1, "SUCCESS", "AppIncrementalFileReady", callerName, GetAnonyPath(fileName) }; @@ -516,8 +514,7 @@ ErrCode Service::AppIncrementalFileReady(const std::string &fileName, UniqueFd f session_->StopExtTimer(callerName); // 通知TOOL 备份完成 HILOGI("reverse: Will notify IncrementalBackupOnBundleFinished"); - session_->GetServiceReverseProxy()->IncrementalBackupOnBundleFinished(BError(BError::Codes::OK), - callerName); + ret = ReverseIncBackupOnBundleFinished(BError(BError::Codes::OK), callerName); BundleEndRadarReport(callerName, BError(BError::Codes::OK), IServiceReverse::Scenario::BACKUP); // 断开extension backUpConnection->DisconnectBackupExtAbility(); @@ -642,7 +639,7 @@ bool Service::IncrementalBackup(const string &bundleName) } if (scenario == IServiceReverse::Scenario::BACKUP && session_->GetIsIncrementalBackup()) { auto ret = proxy->IncrementalOnBackup(session_->GetClearDataFlag(bundleName)); - session_->GetServiceReverseProxy()->IncrementalBackupOnBundleStarted(ret, bundleName); + ReverseIncBackupOnBundleStarted(ret, bundleName); BundleBeginRadarReport(bundleName, ret, IServiceReverse::Scenario::BACKUP); if (ret) { ClearSessionAndSchedInfo(bundleName); @@ -652,7 +649,7 @@ bool Service::IncrementalBackup(const string &bundleName) } else if (scenario == IServiceReverse::Scenario::RESTORE && BackupPara().GetBackupOverrideIncrementalRestore() && session_->ValidRestoreDataType(RestoreTypeEnum::RESTORE_DATA_WAIT_SEND)) { auto ret = proxy->HandleRestore(session_->GetClearDataFlag(bundleName)); - session_->GetServiceReverseProxy()->IncrementalRestoreOnBundleStarted(ret, bundleName); + ReverseIncRestoreOnBundleStarted(ret, bundleName); BundleBeginRadarReport(bundleName, ret, IServiceReverse::Scenario::RESTORE); auto fileNameVec = session_->GetExtFileNameRequest(bundleName); for (auto &fileName : fileNameVec) { @@ -671,7 +668,7 @@ void Service::NotifyCallerCurAppIncrementDone(ErrCode errCode, const std::string IServiceReverse::Scenario scenario = session_->GetScenario(); if (scenario == IServiceReverse::Scenario::BACKUP) { HILOGI("will notify clone data, scenario is incremental backup"); - session_->GetServiceReverseProxy()->IncrementalBackupOnBundleFinished(errCode, callerName); + ReverseIncBackupOnBundleFinished(errCode, callerName); BundleEndRadarReport(callerName, errCode, scenario); auto now = std::chrono::system_clock::now(); auto time = std::chrono::system_clock::to_time_t(now); @@ -689,7 +686,7 @@ void Service::NotifyCallerCurAppIncrementDone(ErrCode errCode, const std::string } else if (scenario == IServiceReverse::Scenario::RESTORE) { HILOGI("will notify clone data, scenario is Restore"); SendEndAppGalleryNotify(callerName); - session_->GetServiceReverseProxy()->IncrementalRestoreOnBundleFinished(errCode, callerName); + ReverseIncRestoreOnBundleFinished(errCode, callerName); BundleEndRadarReport(callerName, errCode, scenario); } } diff --git a/services/backup_sa/src/module_ipc/service_incremental_reverse_proxy.cpp b/services/backup_sa/src/module_ipc/service_incremental_reverse_proxy.cpp index 39a525173..fbece745c 100644 --- a/services/backup_sa/src/module_ipc/service_incremental_reverse_proxy.cpp +++ b/services/backup_sa/src/module_ipc/service_incremental_reverse_proxy.cpp @@ -23,7 +23,7 @@ namespace OHOS::FileManagement::Backup { using namespace std; -void ServiceReverseProxy::IncrementalBackupOnFileReady(string bundleName, string fileName, int fd, int manifestFd, +ErrCode ServiceReverseProxy::IncrementalBackupOnFileReady(string bundleName, string fileName, int fd, int manifestFd, int32_t errCode) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); @@ -36,184 +36,220 @@ void ServiceReverseProxy::IncrementalBackupOnFileReady(string bundleName, string !data.WriteString(fileName) || !data.WriteBool(fdFlag) || (fdFlag == true && (!data.WriteFileDescriptor(fd) || !data.WriteFileDescriptor(manifestFd))) || !data.WriteInt32(errCode)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Incremental backup fileReady fail, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_INCREMENTAL_BACKUP_ON_FILE_READY), data, reply, option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + if (ret != ERR_OK) { + HILOGE("Incremental backup fileReady fail, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::IncrementalBackupOnBundleStarted(int32_t errCode, string bundleName) +ErrCode ServiceReverseProxy::IncrementalBackupOnBundleStarted(int32_t errCode, string bundleName) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteInt32(errCode) || !data.WriteString(bundleName)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Incremental backup on bundle start fail, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); }; MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_INCREMENTAL_BACKUP_ON_SUB_TASK_STARTED), data, reply, option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + if (ret != ERR_OK) { + HILOGE("Incremental backup on bundle start fail, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), + ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::IncrementalBackupOnResultReport(std::string result, std::string bundleName) +ErrCode ServiceReverseProxy::IncrementalBackupOnResultReport(std::string result, std::string bundleName) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteString(result) || !data.WriteString(bundleName)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Incremental backup on result report fail, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); }; MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_INCREMENTAL_BACKUP_ON_RESULT_REPORT), data, reply, option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + if (ret != ERR_OK) { + HILOGE("Incremental backup on result report fail, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), + ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::IncrementalBackupOnBundleFinished(int32_t errCode, string bundleName) +ErrCode ServiceReverseProxy::IncrementalBackupOnBundleFinished(int32_t errCode, string bundleName) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteInt32(errCode) || !data.WriteString(bundleName)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Incremental backup on bundle finish fail, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_INCREMENTAL_BACKUP_ON_SUB_TASK_FINISHED), data, reply, option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + if (ret != ERR_OK) { + HILOGE("Incremental backup on bundle finish fail, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), + ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::IncrementalBackupOnAllBundlesFinished(int32_t errCode) +ErrCode ServiceReverseProxy::IncrementalBackupOnAllBundlesFinished(int32_t errCode) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteInt32(errCode)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Incremental backup on all bundle finish fail, Ipc error"); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_INCREMENTAL_BACKUP_ON_TASK_FINISHED), data, reply, option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + if (ret != ERR_OK) { + HILOGE("Incremental backup on all bundle finish fail, ret:%{public}d", ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) +ErrCode ServiceReverseProxy::IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteString(bundleName) || !data.WriteString(processInfo)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Incremental backup on process fail, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_INCREMENTAL_BACKUP_ON_PROCESS_INFO), data, reply, option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + if (ret != ERR_OK) { + HILOGE("Incremental backup on process fail, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::IncrementalRestoreOnBundleStarted(int32_t errCode, string bundleName) +ErrCode ServiceReverseProxy::IncrementalRestoreOnBundleStarted(int32_t errCode, string bundleName) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteInt32(errCode) || !data.WriteString(bundleName)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Incremental restore on bundle start fail, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_INCREMENTAL_RESTORE_ON_SUB_TASK_STARTED), data, reply, option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + if (ret != ERR_OK) { + HILOGE("Incremental restore on bundle start fail, bundleName:%{public}s, ret:%{public}d", + bundleName.c_str(), ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::IncrementalRestoreOnBundleFinished(int32_t errCode, string bundleName) +ErrCode ServiceReverseProxy::IncrementalRestoreOnBundleFinished(int32_t errCode, string bundleName) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteInt32(errCode) || !data.WriteString(bundleName)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Incremental restore on bundle finish fail, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_INCREMENTAL_RESTORE_ON_SUB_TASK_FINISHED), data, reply, option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + if (ret != ERR_OK) { + HILOGE("Incremental restore on bundle finish fail, bundleName:%{public}s, ret:%{public}d", + bundleName.c_str(), ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::IncrementalRestoreOnAllBundlesFinished(int32_t errCode) +ErrCode ServiceReverseProxy::IncrementalRestoreOnAllBundlesFinished(int32_t errCode) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteInt32(errCode)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Incremental restore on all bundle finish fail, Ipc error"); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_INCREMENTAL_RESTORE_ON_TASK_FINISHED), data, reply, option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + if (ret != ERR_OK) { + HILOGE("Incremental restore on all bundle finish fail, ret:%{public}d", ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::IncrementalRestoreOnResultReport(std::string result, +ErrCode ServiceReverseProxy::IncrementalRestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteString(result) || !data.WriteString(bundleName) || !data.WriteInt32(errCode)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Incremental restore on result report fail, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_INCREMENTAL_RESTORE_ON_RESULT_REPORT), data, reply, option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + if (ret != ERR_OK) { + HILOGE("Incremental restore on result report fail, bundleName:%{public}s, ret:%{public}d", + bundleName.c_str(), ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::IncrementalRestoreOnFileReady(string bundleName, string fileName, int fd, int manifestFd, +ErrCode ServiceReverseProxy::IncrementalRestoreOnFileReady(string bundleName, string fileName, int fd, int manifestFd, int32_t errCode) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); @@ -223,34 +259,41 @@ void ServiceReverseProxy::IncrementalRestoreOnFileReady(string bundleName, strin !data.WriteString(fileName) || !data.WriteBool(fdFlag) || (fdFlag == true && (!data.WriteFileDescriptor(fd) || !data.WriteFileDescriptor(manifestFd))) || !data.WriteInt32(errCode)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Incremental restore on file ready fail, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_INCREMENTAL_RESTORE_ON_FILE_READY), data, reply, option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + if (ret != ERR_OK) { + HILOGE("Incremental restore on file ready fail, bundleName:%{public}s, ret:%{public}d", + bundleName.c_str(), ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::IncrementalRestoreOnProcessInfo(std::string bundleName, std::string processInfo) +ErrCode ServiceReverseProxy::IncrementalRestoreOnProcessInfo(std::string bundleName, std::string processInfo) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteString(bundleName) || !data.WriteString(processInfo)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Incremental restore on process fail, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_INCREMENTAL_RESTORE_ON_PROCESS_INFO), data, reply, option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + if (ret != ERR_OK) { + HILOGE("Incremental restore on process fail, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } } // namespace OHOS::FileManagement::Backup \ No newline at end of file diff --git a/services/backup_sa/src/module_ipc/service_reverse_proxy.cpp b/services/backup_sa/src/module_ipc/service_reverse_proxy.cpp index efe357b20..c0c863d49 100644 --- a/services/backup_sa/src/module_ipc/service_reverse_proxy.cpp +++ b/services/backup_sa/src/module_ipc/service_reverse_proxy.cpp @@ -22,220 +22,251 @@ namespace OHOS::FileManagement::Backup { using namespace std; -void ServiceReverseProxy::BackupOnFileReady(string bundleName, string fileName, int fd, int32_t errCode) +ErrCode ServiceReverseProxy::BackupOnFileReady(string bundleName, string fileName, int fd, int32_t errCode) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; bool fdFlag = fd < 0 ? false : true; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteString(bundleName) || !data.WriteString(fileName) || !data.WriteBool(fdFlag) || (fdFlag == true && !data.WriteFileDescriptor(fd)) || !data.WriteInt32(errCode)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Full backup on fileReady failed, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_BACKUP_ON_FILE_READY), data, reply, option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + if (ret != ERR_OK) { + HILOGE("Full backup on fileReady failed, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::BackupOnBundleStarted(int32_t errCode, string bundleName) +ErrCode ServiceReverseProxy::BackupOnBundleStarted(int32_t errCode, string bundleName) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteInt32(errCode) || !data.WriteString(bundleName)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Full backup on bundle start failed, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); }; MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( - static_cast(IServiceReverseInterfaceCode::SERVICER_BACKUP_ON_SUB_TASK_STARTED), data, reply, - option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + ErrCode ret = Remote()->SendRequest( + static_cast(IServiceReverseInterfaceCode::SERVICER_BACKUP_ON_SUB_TASK_STARTED), data, reply, option); + if (ret != ERR_OK) { + HILOGE("Full backup bundle start failed, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::BackupOnResultReport(std::string result, std::string bundleName) +ErrCode ServiceReverseProxy::BackupOnResultReport(std::string result, std::string bundleName) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteString(result) || !data.WriteString(bundleName)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Full backup on result report failed, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); }; MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( - static_cast(IServiceReverseInterfaceCode::SERVICER_BACKUP_ON_RESULT_REPORT), data, reply, - option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + ErrCode ret = Remote()->SendRequest( + static_cast(IServiceReverseInterfaceCode::SERVICER_BACKUP_ON_RESULT_REPORT), data, reply, option); + if (ret != ERR_OK) { + HILOGE("Full backup on result report failed, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::BackupOnBundleFinished(int32_t errCode, string bundleName) +ErrCode ServiceReverseProxy::BackupOnBundleFinished(int32_t errCode, string bundleName) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteInt32(errCode) || !data.WriteString(bundleName)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Full backup on bundle finished failed, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( - static_cast(IServiceReverseInterfaceCode::SERVICER_BACKUP_ON_SUB_TASK_FINISHED), data, reply, - option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + ErrCode ret = Remote()->SendRequest( + static_cast(IServiceReverseInterfaceCode::SERVICER_BACKUP_ON_SUB_TASK_FINISHED), data, reply, option); + if (ret != ERR_OK) { + HILOGE("Full backup on bundle finish failed, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::BackupOnAllBundlesFinished(int32_t errCode) +ErrCode ServiceReverseProxy::BackupOnAllBundlesFinished(int32_t errCode) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteInt32(errCode)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Full backup on all bundle finished failed, Ipc error"); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_BACKUP_ON_TASK_FINISHED), data, reply, option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + if (ret != ERR_OK) { + HILOGE("Full backup on all bundle finish failed, ret:%{public}d", ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::BackupOnProcessInfo(std::string bundleName, std::string processInfo) +ErrCode ServiceReverseProxy::BackupOnProcessInfo(std::string bundleName, std::string processInfo) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteString(bundleName) || !data.WriteString(processInfo)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Full backup on process failed, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_BACKUP_ON_PROCESS_INFO), data, reply, option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + if (ret != ERR_OK) { + HILOGE("Full backup on process failed, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::RestoreOnBundleStarted(int32_t errCode, string bundleName) +ErrCode ServiceReverseProxy::RestoreOnBundleStarted(int32_t errCode, string bundleName) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteInt32(errCode) || !data.WriteString(bundleName)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Full restore on bundle start failed, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( - static_cast(IServiceReverseInterfaceCode::SERVICER_RESTORE_ON_SUB_TASK_STARTED), data, reply, - option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + ErrCode ret = Remote()->SendRequest( + static_cast(IServiceReverseInterfaceCode::SERVICER_RESTORE_ON_SUB_TASK_STARTED), data, reply, option); + if (ret != ERR_OK) { + HILOGE("Full restore on bundle start failed, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::RestoreOnBundleFinished(int32_t errCode, string bundleName) +ErrCode ServiceReverseProxy::RestoreOnBundleFinished(int32_t errCode, string bundleName) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteInt32(errCode) || !data.WriteString(bundleName)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Full restore on bundle finish failed, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_RESTORE_ON_SUB_TASK_FINISHED), data, reply, - option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + option); + if (ret != ERR_OK) { + HILOGE("Full restore on bundle finished failed, bundleName:%{public}s, ret:%{public}d", + bundleName.c_str(), ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::RestoreOnAllBundlesFinished(int32_t errCode) +ErrCode ServiceReverseProxy::RestoreOnAllBundlesFinished(int32_t errCode) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteInt32(errCode)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Full restore on all bundle finish failed, Ipc error"); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( - static_cast(IServiceReverseInterfaceCode::SERVICER_RESTORE_ON_TASK_FINISHED), data, reply, - option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + ErrCode ret = Remote()->SendRequest( + static_cast(IServiceReverseInterfaceCode::SERVICER_RESTORE_ON_TASK_FINISHED), data, reply, option); + if (ret != ERR_OK) { + HILOGE("Full restore on all bundle finish failed, ret:%{public}d", ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::RestoreOnFileReady(string bundleName, string fileName, int fd, int32_t errCode) +ErrCode ServiceReverseProxy::RestoreOnFileReady(string bundleName, string fileName, int fd, int32_t errCode) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; bool fdFlag = fd < 0 ? false : true; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteString(bundleName) || !data.WriteString(fileName) || !data.WriteBool(fdFlag) || (fdFlag == true && !data.WriteFileDescriptor(fd)) || !data.WriteInt32(errCode)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Full restore on fileReady fail, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_RESTORE_ON_FILE_READY), data, reply, option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + if (ret != ERR_OK) { + HILOGE("Full restore on fileReady fail, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::RestoreOnResultReport(string result, std::string bundleName, ErrCode errCode) +ErrCode ServiceReverseProxy::RestoreOnResultReport(string result, std::string bundleName, ErrCode errCode) { HILOGI("ServiceReverseProxy::RestoreOnResultReport Begin with result: %s", result.c_str()); BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteString(result) || !data.WriteString(bundleName) || !data.WriteInt32(errCode)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Full restore on result report fail, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( - static_cast(IServiceReverseInterfaceCode::SERVICER_RESTORE_ON_RESULT_REPORT), data, reply, - option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + ErrCode ret = Remote()->SendRequest( + static_cast(IServiceReverseInterfaceCode::SERVICER_RESTORE_ON_RESULT_REPORT), data, reply, option); + if (ret != ERR_OK) { + HILOGE("Full restore on result report fail, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } -void ServiceReverseProxy::RestoreOnProcessInfo(std::string bundleName, std::string processInfo) +ErrCode ServiceReverseProxy::RestoreOnProcessInfo(std::string bundleName, std::string processInfo) { BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr"); MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteString(bundleName) || !data.WriteString(processInfo)) { - throw BError(BError::Codes::SA_BROKEN_IPC); + HILOGE("Full restore on process fail, Ipc error, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_BROKEN_IPC); } MessageParcel reply; MessageOption option; - if (int err = Remote()->SendRequest( + ErrCode ret = Remote()->SendRequest( static_cast(IServiceReverseInterfaceCode::SERVICER_RESTORE_ON_PROCESS_INFO), data, reply, option); - err != ERR_OK) { - throw BError(BError::Codes::SA_BROKEN_IPC, to_string(err)); + if (ret != ERR_OK) { + HILOGE("Full restore on process fail, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return BError(BError::Codes::SA_BROKEN_IPC); } + return BError(BError::Codes::OK); } } // namespace OHOS::FileManagement::Backup \ No newline at end of file diff --git a/services/backup_sa/src/module_ipc/sub_service.cpp b/services/backup_sa/src/module_ipc/sub_service.cpp index 8bbdf2482..4c88c2351 100644 --- a/services/backup_sa/src/module_ipc/sub_service.cpp +++ b/services/backup_sa/src/module_ipc/sub_service.cpp @@ -143,7 +143,7 @@ ErrCode Service::AppFileReady(const string &fileName, UniqueFd fd, int32_t errCo if (fileName == BConstants::EXT_BACKUP_MANAGE) { fd = session_->OnBundleExtManageInfo(callerName, move(fd)); } - session_->GetServiceReverseProxy()->BackupOnFileReady(callerName, fileName, move(fd), errCode); + ReverseBackupOnFileReady(callerName, fileName, move(fd), errCode); FileReadyRadarReport(callerName, fileName, errCode, session_->GetScenario()); AuditLog auditLog = { false, "Backup File Ready", "ADD", "", 1, "SUCCESS", "AppFileReady", callerName, GetAnonyPath(fileName) }; @@ -165,7 +165,7 @@ ErrCode Service::AppFileReady(const string &fileName, UniqueFd fd, int32_t errCo session_->StopFwkTimer(callerName); session_->StopExtTimer(callerName); // 通知TOOL 备份完成 - session_->GetServiceReverseProxy()->BackupOnBundleFinished(BError(BError::Codes::OK), callerName); + ReverseBackupOnBundleFinished(BError(BError::Codes::OK), callerName); BundleEndRadarReport(callerName, BError(BError::Codes::OK), session_->GetScenario()); // 断开extension backUpConnection->DisconnectBackupExtAbility(); @@ -313,11 +313,9 @@ std::vector Service::GetSupportBackupBundleNames(vectorGetServiceReverseProxy()->IncrementalBackupOnBundleStarted( - BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), bundleNameIndexInfo); + ReverseIncBackupOnBundleStarted(BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), bundleNameIndexInfo); } else { - session_->GetServiceReverseProxy()->BackupOnBundleStarted( - BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), bundleNameIndexInfo); + ReverseBackupOnBundleStarted(BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), bundleNameIndexInfo); } BundleBeginRadarReport(bundleNameIndexInfo, BError(BError::Codes::SA_FORBID_BACKUP_RESTORE).GetCode(), IServiceReverse::Scenario::BACKUP); @@ -356,12 +354,475 @@ void Service::HandleNotSupportBundleNames(const std::vector &srcBun } 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); + ReverseIncBackupOnBundleStarted(BError(BError::Codes::SA_BUNDLE_INFO_EMPTY), bundleName); } else { - session_->GetServiceReverseProxy()->BackupOnBundleStarted( - BError(BError::Codes::SA_BUNDLE_INFO_EMPTY), bundleName); + ReverseBackupOnBundleStarted(BError(BError::Codes::SA_BUNDLE_INFO_EMPTY), bundleName); } } } + +ErrCode Service::ReverseBackupOnBundleStarted(int32_t errCode, std::string bundleName) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->BackupOnBundleStarted(errCode, bundleName); + if (ret != ERR_OK) { + HILOGE("Error, bundleName is:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseBackupOnFileReady(std::string bundleName, std::string fileName, + int fd, int32_t errCode) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->BackupOnFileReady(bundleName, fileName, fd, errCode); + if (ret != ERR_OK) { + HILOGE("Error, bundleName is:%{public}s, fileName:%{public}s, ret:%{public}d", bundleName.c_str(), + GetAnonyPath(fileName).c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseBackupOnResultReport(std::string result, std::string bundleName) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->BackupOnResultReport(result, bundleName); + if (ret != ERR_OK) { + HILOGE("Error, bundleName is:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseBackupOnBundleFinished(int32_t errCode, std::string bundleName) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->BackupOnBundleFinished(errCode, bundleName); + if (ret != ERR_OK) { + HILOGE("Error, bundleName is:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseBackupOnAllBundlesFinished(int32_t errCode) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, errCode:%{public}d", errCode); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, errCode:%{public}d", errCode); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->BackupOnAllBundlesFinished(errCode); + if (ret != ERR_OK) { + HILOGE("Error, ret:%{public}d", ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseBackupOnProcessInfo(std::string bundleName, + std::string processInfo) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->BackupOnProcessInfo(bundleName, processInfo); + if (ret != ERR_OK) { + HILOGE("Error, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseRestoreOnBundleStarted(int32_t errCode, std::string bundleName) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->RestoreOnBundleStarted(errCode, bundleName); + if (ret != ERR_OK) { + HILOGE("Error, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseRestoreOnFileReady(std::string bundleName, std::string fileName, + int fd, int32_t errCode) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->RestoreOnFileReady(bundleName, fileName, fd, errCode); + if (ret != ERR_OK) { + HILOGE("Error, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseRestoreOnResultReport(std::string result, std::string bundleName, + ErrCode errCode) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->RestoreOnResultReport(result, bundleName, errCode); + if (ret != ERR_OK) { + HILOGE("Error, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseRestoreOnBundleFinished(int32_t errCode, std::string bundleName) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->RestoreOnBundleFinished(errCode, bundleName); + if (ret != ERR_OK) { + HILOGE("Error, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseRestoreOnAllBundlesFinished(int32_t errCode) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, errCode:%{public}d", errCode); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, errCode:%{public}d", errCode); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->RestoreOnAllBundlesFinished(errCode); + if (ret != ERR_OK) { + HILOGE("Error, errCode:%{public}d, ret:%{public}d", errCode, ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseRestoreOnProcessInfo(std::string bundleName, + std::string processInfo) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->RestoreOnProcessInfo(bundleName, processInfo); + if (ret != ERR_OK) { + HILOGE("Error, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +// 增量 +ErrCode Service::ReverseIncBackupOnBundleStarted(int32_t errCode, std::string bundleName) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->IncrementalBackupOnBundleStarted(errCode, bundleName); + if (ret != ERR_OK) { + HILOGE("Error, bundleName is:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncBackupOnFileReady(std::string bundleName, std::string fileName, + int fd, int manifestFd, int32_t errCode) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->IncrementalBackupOnFileReady(bundleName, fileName, fd, manifestFd, errCode); + if (ret != ERR_OK) { + HILOGE("Error, bundleName is:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncBackupOnResultReport(std::string result, std::string bundleName) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->IncrementalBackupOnResultReport(result, bundleName); + if (ret != ERR_OK) { + HILOGE("Error, bundleName is:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncBackupOnBundleFinished(int32_t errCode, std::string bundleName) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->IncrementalBackupOnBundleFinished(errCode, bundleName); + if (ret != ERR_OK) { + HILOGE("Error, bundleName is:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncBackupOnAllBundlesFinished(int32_t errCode) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, errCode:%{public}d", errCode); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, errCode:%{public}d", errCode); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->IncrementalBackupOnAllBundlesFinished(errCode); + if (ret != ERR_OK) { + HILOGE("Error, errCode is:%{public}d, ret:%{public}d", errCode, ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncBackupOnProcessInfo(std::string bundleName, std::string processInfo) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->IncrementalBackupOnProcessInfo(bundleName, processInfo); + if (ret != ERR_OK) { + HILOGE("Error, bundleName is:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncRestoreOnBundleStarted(int32_t errCode, std::string bundleName) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->IncrementalRestoreOnBundleStarted(errCode, bundleName); + if (ret != ERR_OK) { + HILOGE("Error, bundleName is:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncRestoreOnFileReady(std::string bundleName, std::string fileName, int fd, + int manifestFd, int32_t errCode) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->IncrementalRestoreOnFileReady(bundleName, fileName, fd, manifestFd, errCode); + if (ret != ERR_OK) { + HILOGE("Error, bundleName is:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncRestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->IncrementalRestoreOnResultReport(result, bundleName, errCode); + if (ret != ERR_OK) { + HILOGE("Error, bundleName is:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncRestoreOnBundleFinished(int32_t errCode, std::string bundleName) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->IncrementalRestoreOnBundleFinished(errCode, bundleName); + if (ret != ERR_OK) { + HILOGE("Error, bundleName is:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncRestoreOnAllBundlesFinished(int32_t errCode) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, errCode:%{public}d", errCode); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, errCode:%{public}d", errCode); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->IncrementalRestoreOnAllBundlesFinished(errCode); + if (ret != ERR_OK) { + HILOGE("Error, errCode is:%{public}d, ret:%{public}d", errCode, ret); + return ret; + } + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncRestoreOnProcessInfo(std::string bundleName, std::string processInfo) +{ + if (session_ == nullptr) { + HILOGE("Error, session is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto reverseProxy = session_->GetServiceReverseProxy(); + if (reverseProxy == nullptr) { + HILOGE("Error, reverse proxy is empty, bundleName:%{public}s", bundleName.c_str()); + return BError(BError::Codes::SA_INVAL_ARG); + } + auto ret = reverseProxy->IncrementalRestoreOnProcessInfo(bundleName, processInfo); + if (ret != ERR_OK) { + HILOGE("Error, bundleName is:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + return ret; + } + return BError(BError::Codes::OK); +} } \ 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 f47d3e151..5323334d2 100644 --- a/services/backup_sa/src/module_ipc/svc_session_manager.cpp +++ b/services/backup_sa/src/module_ipc/svc_session_manager.cpp @@ -142,7 +142,8 @@ sptr SvcSessionManager::GetServiceReverseProxy() { unique_lock lock(lock_); if (!impl_.clientProxy) { - throw BError(BError::Codes::SA_REFUSED_ACT, "Try to deactive an empty session"); + HILOGE("Get service reverse proxy failed, No caller token was specified"); + return nullptr; } return impl_.clientProxy; } diff --git a/tests/mock/module_ipc/include/service_reverse_proxy_mock.h b/tests/mock/module_ipc/include/service_reverse_proxy_mock.h index 8a74af4bd..ea86bb82c 100644 --- a/tests/mock/module_ipc/include/service_reverse_proxy_mock.h +++ b/tests/mock/module_ipc/include/service_reverse_proxy_mock.h @@ -25,30 +25,30 @@ namespace OHOS::FileManagement::Backup { class ServiceReverseProxyMock : public IRemoteProxy { public: MOCK_METHOD(int, SendRequest, (uint32_t, MessageParcel&, MessageParcel&, MessageOption&)); - MOCK_METHOD(void, BackupOnFileReady, (std::string, std::string, int, int32_t)); - MOCK_METHOD(void, BackupOnBundleStarted, (int32_t, std::string)); - MOCK_METHOD(void, BackupOnResultReport, (std::string, std::string));; - MOCK_METHOD(void, BackupOnBundleFinished, (int32_t, std::string)); - MOCK_METHOD(void, BackupOnAllBundlesFinished, (int32_t)); - MOCK_METHOD(void, BackupOnProcessInfo, (std::string, std::string)); - MOCK_METHOD(void, RestoreOnBundleStarted, (int32_t, std::string)); - MOCK_METHOD(void, RestoreOnBundleFinished, (int32_t, std::string)); - MOCK_METHOD(void, RestoreOnAllBundlesFinished, (int32_t)); - MOCK_METHOD(void, RestoreOnFileReady, (std::string, std::string, int, int32_t)); - MOCK_METHOD(void, RestoreOnResultReport, (std::string, std::string, ErrCode)); - MOCK_METHOD(void, RestoreOnProcessInfo, (std::string, std::string)); - MOCK_METHOD(void, IncrementalBackupOnFileReady, (std::string, std::string, int, int, int32_t)); - MOCK_METHOD(void, IncrementalBackupOnBundleStarted, (int32_t, std::string)); - MOCK_METHOD(void, IncrementalBackupOnResultReport, (std::string, std::string)); - MOCK_METHOD(void, IncrementalBackupOnBundleFinished, (int32_t, std::string)); - MOCK_METHOD(void, IncrementalBackupOnAllBundlesFinished, (int32_t)); - MOCK_METHOD(void, IncrementalBackupOnProcessInfo, (std::string, std::string)); - MOCK_METHOD(void, IncrementalRestoreOnBundleStarted, (int32_t, std::string)); - MOCK_METHOD(void, IncrementalRestoreOnBundleFinished, (int32_t, std::string)); - MOCK_METHOD(void, IncrementalRestoreOnAllBundlesFinished, (int32_t)); - MOCK_METHOD(void, IncrementalRestoreOnFileReady, (std::string, std::string, int, int, int32_t)); - MOCK_METHOD(void, IncrementalRestoreOnResultReport, (std::string, std::string, ErrCode));; - MOCK_METHOD(void, IncrementalRestoreOnProcessInfo, (std::string, std::string)); + MOCK_METHOD(ErrCode, BackupOnFileReady, (std::string, std::string, int, int32_t)); + MOCK_METHOD(ErrCode, BackupOnBundleStarted, (int32_t, std::string)); + MOCK_METHOD(ErrCode, BackupOnResultReport, (std::string, std::string));; + MOCK_METHOD(ErrCode, BackupOnBundleFinished, (int32_t, std::string)); + MOCK_METHOD(ErrCode, BackupOnAllBundlesFinished, (int32_t)); + MOCK_METHOD(ErrCode, BackupOnProcessInfo, (std::string, std::string)); + MOCK_METHOD(ErrCode, RestoreOnBundleStarted, (int32_t, std::string)); + MOCK_METHOD(ErrCode, RestoreOnBundleFinished, (int32_t, std::string)); + MOCK_METHOD(ErrCode, RestoreOnAllBundlesFinished, (int32_t)); + MOCK_METHOD(ErrCode, RestoreOnFileReady, (std::string, std::string, int, int32_t)); + MOCK_METHOD(ErrCode, RestoreOnResultReport, (std::string, std::string, ErrCode)); + MOCK_METHOD(ErrCode, RestoreOnProcessInfo, (std::string, std::string)); + MOCK_METHOD(ErrCode, IncrementalBackupOnFileReady, (std::string, std::string, int, int, int32_t)); + MOCK_METHOD(ErrCode, IncrementalBackupOnBundleStarted, (int32_t, std::string)); + MOCK_METHOD(ErrCode, IncrementalBackupOnResultReport, (std::string, std::string)); + MOCK_METHOD(ErrCode, IncrementalBackupOnBundleFinished, (int32_t, std::string)); + MOCK_METHOD(ErrCode, IncrementalBackupOnAllBundlesFinished, (int32_t)); + MOCK_METHOD(ErrCode, IncrementalBackupOnProcessInfo, (std::string, std::string)); + MOCK_METHOD(ErrCode, IncrementalRestoreOnBundleStarted, (int32_t, std::string)); + MOCK_METHOD(ErrCode, IncrementalRestoreOnBundleFinished, (int32_t, std::string)); + MOCK_METHOD(ErrCode, IncrementalRestoreOnAllBundlesFinished, (int32_t)); + MOCK_METHOD(ErrCode, IncrementalRestoreOnFileReady, (std::string, std::string, int, int, int32_t)); + MOCK_METHOD(ErrCode, IncrementalRestoreOnResultReport, (std::string, std::string, ErrCode));; + MOCK_METHOD(ErrCode, IncrementalRestoreOnProcessInfo, (std::string, std::string)); public: ServiceReverseProxyMock() : IRemoteProxy(nullptr) {} virtual ~ServiceReverseProxyMock() = default; diff --git a/tests/mock/module_ipc/service_mock.cpp b/tests/mock/module_ipc/service_mock.cpp index 4f6a1d0d1..8aea2dabf 100644 --- a/tests/mock/module_ipc/service_mock.cpp +++ b/tests/mock/module_ipc/service_mock.cpp @@ -300,4 +300,115 @@ std::vector Service::GetSupportBackupBundleNames(vector&, vector&, bool) {} void Service::SetBundleIncDataInfo(const std::vector&, std::vector&) {} + +ErrCode Service::ReverseBackupOnBundleStarted(int32_t errCode, std::string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseBackupOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseBackupOnResultReport(std::string result, std::string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseBackupOnBundleFinished(int32_t errCode, std::string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseBackupOnAllBundlesFinished(int32_t errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseBackupOnProcessInfo(std::string bundleName, std::string processInfo) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseRestoreOnBundleStarted(int32_t errCode, std::string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseRestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseRestoreOnBundleFinished(int32_t errCode, std::string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseRestoreOnAllBundlesFinished(int32_t errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseRestoreOnProcessInfo(std::string bundleName, std::string processInfo) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncBackupOnBundleStarted(int32_t errCode, std::string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncBackupOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, + int32_t errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncBackupOnResultReport(std::string result, std::string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncBackupOnBundleFinished(int32_t errCode, std::string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncBackupOnAllBundlesFinished(int32_t errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncBackupOnProcessInfo(std::string bundleName, std::string processInfo) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncRestoreOnBundleStarted(int32_t errCode, std::string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncRestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, + int32_t errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncRestoreOnBundleFinished(int32_t errCode, std::string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncRestoreOnAllBundlesFinished(int32_t errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ReverseIncRestoreOnProcessInfo(std::string bundleName, std::string processInfo){ + return BError(BError::Codes::OK); +} } // namespace OHOS::FileManagement::Backup diff --git a/tests/mock/module_ipc/service_reverse_proxy_mock.cpp b/tests/mock/module_ipc/service_reverse_proxy_mock.cpp index 1b224076d..fb62b6f8f 100644 --- a/tests/mock/module_ipc/service_reverse_proxy_mock.cpp +++ b/tests/mock/module_ipc/service_reverse_proxy_mock.cpp @@ -20,53 +20,125 @@ namespace OHOS::FileManagement::Backup { using namespace std; -void ServiceReverseProxy::BackupOnFileReady(string bundleName, string fileName, int fd, int32_t errCode) {} - -void ServiceReverseProxy::BackupOnBundleStarted(int32_t errCode, string bundleName) {} - -void ServiceReverseProxy::BackupOnResultReport(string result, std::string bundleName) {} - -void ServiceReverseProxy::BackupOnBundleFinished(int32_t errCode, string bundleName) {} - -void ServiceReverseProxy::BackupOnAllBundlesFinished(int32_t errCode) {} - -void ServiceReverseProxy::BackupOnProcessInfo(std::string bundleName, std::string processInfo) {} - -void ServiceReverseProxy::RestoreOnBundleStarted(int32_t errCode, string bundleName) {} - -void ServiceReverseProxy::RestoreOnBundleFinished(int32_t errCode, string bundleName) {} - -void ServiceReverseProxy::RestoreOnAllBundlesFinished(int32_t errCode) {} - -void ServiceReverseProxy::RestoreOnFileReady(string bundleName, string fileName, int fd, int32_t errCode) {} - -void ServiceReverseProxy::RestoreOnResultReport(string result, string bundleName, ErrCode errCode) {} - -void ServiceReverseProxy::RestoreOnProcessInfo(std::string bundleName, std::string processInfo) {} - -void ServiceReverseProxy::IncrementalBackupOnFileReady(string bundleName, string fileName, int fd, int manifestFd, - int32_t errCode) {} - -void ServiceReverseProxy::IncrementalBackupOnBundleStarted(int32_t errCode, string bundleName) {} - -void ServiceReverseProxy::IncrementalBackupOnResultReport(string result, std::string bundleName) {} - -void ServiceReverseProxy::IncrementalBackupOnBundleFinished(int32_t errCode, string bundleName) {} - -void ServiceReverseProxy::IncrementalBackupOnAllBundlesFinished(int32_t errCode) {} - -void ServiceReverseProxy::IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) {} - -void ServiceReverseProxy::IncrementalRestoreOnBundleStarted(int32_t errCode, string bundleName) {} - -void ServiceReverseProxy::IncrementalRestoreOnBundleFinished(int32_t errCode, string bundleName) {} - -void ServiceReverseProxy::IncrementalRestoreOnAllBundlesFinished(int32_t errCode) {} - -void ServiceReverseProxy::IncrementalRestoreOnFileReady(string bundleName, string fileName, int fd, int manifestFd, - int32_t errCode) {} - -void ServiceReverseProxy::IncrementalRestoreOnResultReport(string result, string bundleName, ErrCode errCode) {} - -void ServiceReverseProxy::IncrementalRestoreOnProcessInfo(std::string bundleName, std::string processInfo) {} +ErrCode ServiceReverseProxy::BackupOnFileReady(string bundleName, string fileName, int fd, int32_t errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::BackupOnBundleStarted(int32_t errCode, string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::BackupOnResultReport(string result, std::string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::BackupOnBundleFinished(int32_t errCode, string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::BackupOnAllBundlesFinished(int32_t errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::BackupOnProcessInfo(std::string bundleName, std::string processInfo) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::RestoreOnBundleStarted(int32_t errCode, string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::RestoreOnBundleFinished(int32_t errCode, string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::RestoreOnAllBundlesFinished(int32_t errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::RestoreOnFileReady(string bundleName, string fileName, int fd, int32_t errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::RestoreOnResultReport(string result, string bundleName, ErrCode errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::RestoreOnProcessInfo(std::string bundleName, std::string processInfo) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::IncrementalBackupOnFileReady(string bundleName, string fileName, int fd, int manifestFd, + int32_t errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::IncrementalBackupOnBundleStarted(int32_t errCode, string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::IncrementalBackupOnResultReport(string result, std::string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::IncrementalBackupOnBundleFinished(int32_t errCode, string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::IncrementalBackupOnAllBundlesFinished(int32_t errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::IncrementalRestoreOnBundleStarted(int32_t errCode, string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::IncrementalRestoreOnBundleFinished(int32_t errCode, string bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::IncrementalRestoreOnAllBundlesFinished(int32_t errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::IncrementalRestoreOnFileReady(string bundleName, string fileName, int fd, int manifestFd, + int32_t errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::IncrementalRestoreOnResultReport(string result, string bundleName, ErrCode errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode ServiceReverseProxy::IncrementalRestoreOnProcessInfo(std::string bundleName, std::string processInfo) +{ + return BError(BError::Codes::OK); +} } // namespace OHOS::FileManagement::Backup \ No newline at end of file diff --git a/tests/unittests/backup_api/backup_impl/include/service_reverse_mock.h b/tests/unittests/backup_api/backup_impl/include/service_reverse_mock.h index 7b1bf2f9b..f3478879c 100644 --- a/tests/unittests/backup_api/backup_impl/include/service_reverse_mock.h +++ b/tests/unittests/backup_api/backup_impl/include/service_reverse_mock.h @@ -36,35 +36,35 @@ public: code_ = code; return BError(BError::Codes::OK); } - void BackupOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override {} - void BackupOnBundleStarted(int32_t errCode, std::string bundleName) override {} - void BackupOnResultReport(std::string result, std::string bundleName) override {}; - void BackupOnBundleFinished(int32_t errCode, std::string bundleName) override {} - void BackupOnAllBundlesFinished(int32_t errCode) override {} - void BackupOnProcessInfo(std::string bundleName, std::string processInfo) override {} + ErrCode BackupOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override {} + ErrCode BackupOnBundleStarted(int32_t errCode, std::string bundleName) override {} + ErrCode BackupOnResultReport(std::string result, std::string bundleName) override {}; + ErrCode BackupOnBundleFinished(int32_t errCode, std::string bundleName) override {} + ErrCode BackupOnAllBundlesFinished(int32_t errCode) override {} + ErrCode BackupOnProcessInfo(std::string bundleName, std::string processInfo) override {} - void RestoreOnBundleStarted(int32_t errCode, std::string bundleName) override {} - void RestoreOnBundleFinished(int32_t errCode, std::string bundleName) override {} - void RestoreOnAllBundlesFinished(int32_t errCode) override {} - void RestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override {} - void RestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode) override {} - void RestoreOnProcessInfo(std::string bundleName, std::string processInfo) override {} + ErrCode RestoreOnBundleStarted(int32_t errCode, std::string bundleName) override {} + ErrCode RestoreOnBundleFinished(int32_t errCode, std::string bundleName) override {} + ErrCode RestoreOnAllBundlesFinished(int32_t errCode) override {} + ErrCode RestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override {} + ErrCode RestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode) override {} + ErrCode RestoreOnProcessInfo(std::string bundleName, std::string processInfo) override {} - void IncrementalBackupOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, + ErrCode IncrementalBackupOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, int32_t errCode) override {} - void IncrementalBackupOnBundleStarted(int32_t errCode, std::string bundleName) override {} - void IncrementalBackupOnResultReport(std::string result, std::string bundleName) override {} - void IncrementalBackupOnBundleFinished(int32_t errCode, std::string bundleName) override {} - void IncrementalBackupOnAllBundlesFinished(int32_t errCode) override {} - void IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) override {} + ErrCode IncrementalBackupOnBundleStarted(int32_t errCode, std::string bundleName) override {} + ErrCode IncrementalBackupOnResultReport(std::string result, std::string bundleName) override {} + ErrCode IncrementalBackupOnBundleFinished(int32_t errCode, std::string bundleName) override {} + ErrCode IncrementalBackupOnAllBundlesFinished(int32_t errCode) override {} + ErrCode IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) override {} - void IncrementalRestoreOnBundleStarted(int32_t errCode, std::string bundleName) override {} - void IncrementalRestoreOnBundleFinished(int32_t errCode, std::string bundleName) override {} - void IncrementalRestoreOnAllBundlesFinished(int32_t errCode) override {} - void IncrementalRestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, + ErrCode IncrementalRestoreOnBundleStarted(int32_t errCode, std::string bundleName) override {} + ErrCode IncrementalRestoreOnBundleFinished(int32_t errCode, std::string bundleName) override {} + ErrCode IncrementalRestoreOnAllBundlesFinished(int32_t errCode) override {} + ErrCode IncrementalRestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, int32_t errCode) override {} - void IncrementalRestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode) override {}; - void IncrementalRestoreOnProcessInfo(std::string bundleName, std::string processInfo) override {} + ErrCode IncrementalRestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode) override {}; + ErrCode IncrementalRestoreOnProcessInfo(std::string bundleName, std::string processInfo) override {} }; } // namespace OHOS::FileManagement::Backup #endif // MOCK_SERVICE_REVERSE_MOCK_H \ No newline at end of file diff --git a/tests/unittests/backup_api/backup_impl/service_reverse_stub_test.cpp b/tests/unittests/backup_api/backup_impl/service_reverse_stub_test.cpp index d5c75557c..c9a2db6b8 100644 --- a/tests/unittests/backup_api/backup_impl/service_reverse_stub_test.cpp +++ b/tests/unittests/backup_api/backup_impl/service_reverse_stub_test.cpp @@ -40,32 +40,32 @@ const string FILE_NAME_MANIFEST = "1.fr"; class MockServiceReverse final : public ServiceReverseStub { public: - MOCK_METHOD4(BackupOnFileReady, void(string bundleName, string fileName, int fd, int32_t errCode)); - MOCK_METHOD2(BackupOnBundleStarted, void(int32_t errCode, string bundleName)); - MOCK_METHOD2(BackupOnResultReport, void(string result, std::string bundleName)); - MOCK_METHOD2(BackupOnBundleFinished, void(int32_t errCode, string bundleName)); - MOCK_METHOD1(BackupOnAllBundlesFinished, void(int32_t errCode)); - MOCK_METHOD2(BackupOnProcessInfo, void(std::string bundleName, std::string processInfo)); - MOCK_METHOD2(RestoreOnBundleStarted, void(int32_t errCode, std::string bundleName)); - MOCK_METHOD2(RestoreOnBundleFinished, void(int32_t errCode, string bundleName)); - MOCK_METHOD1(RestoreOnAllBundlesFinished, void(int32_t errCode)); - MOCK_METHOD4(RestoreOnFileReady, void(string bundleName, string fileName, int fd, int32_t errCode)); - MOCK_METHOD3(RestoreOnResultReport, void(string result, string bundleName, ErrCode errCode)); - MOCK_METHOD2(RestoreOnProcessInfo, void(std::string bundleName, std::string processInfo)); + MOCK_METHOD4(BackupOnFileReady, ErrCode(string bundleName, string fileName, int fd, int32_t errCode)); + MOCK_METHOD2(BackupOnBundleStarted, ErrCode(int32_t errCode, string bundleName)); + MOCK_METHOD2(BackupOnResultReport, ErrCode(string result, std::string bundleName)); + MOCK_METHOD2(BackupOnBundleFinished, ErrCode(int32_t errCode, string bundleName)); + MOCK_METHOD1(BackupOnAllBundlesFinished, ErrCode(int32_t errCode)); + MOCK_METHOD2(BackupOnProcessInfo, ErrCode(std::string bundleName, std::string processInfo)); + MOCK_METHOD2(RestoreOnBundleStarted, ErrCode(int32_t errCode, std::string bundleName)); + MOCK_METHOD2(RestoreOnBundleFinished, ErrCode(int32_t errCode, string bundleName)); + MOCK_METHOD1(RestoreOnAllBundlesFinished, ErrCode(int32_t errCode)); + MOCK_METHOD4(RestoreOnFileReady, ErrCode(string bundleName, string fileName, int fd, int32_t errCode)); + MOCK_METHOD3(RestoreOnResultReport, ErrCode(string result, string bundleName, ErrCode errCode)); + MOCK_METHOD2(RestoreOnProcessInfo, ErrCode(std::string bundleName, std::string processInfo)); MOCK_METHOD5(IncrementalBackupOnFileReady, - void(string bundleName, string fileName, int fd, int manifestFd, int32_t errCode)); - MOCK_METHOD2(IncrementalBackupOnBundleStarted, void(int32_t errCode, string bundleName)); - MOCK_METHOD2(IncrementalBackupOnResultReport, void(string result, std::string bundleName)); - MOCK_METHOD2(IncrementalBackupOnBundleFinished, void(int32_t errCode, string bundleName)); - MOCK_METHOD1(IncrementalBackupOnAllBundlesFinished, void(int32_t errCode)); - MOCK_METHOD2(IncrementalBackupOnProcessInfo, void(std::string bundleName, std::string processInfo)); - MOCK_METHOD2(IncrementalRestoreOnBundleStarted, void(int32_t errCode, std::string bundleName)); - MOCK_METHOD2(IncrementalRestoreOnBundleFinished, void(int32_t errCode, string bundleName)); - MOCK_METHOD1(IncrementalRestoreOnAllBundlesFinished, void(int32_t errCode)); + ErrCode(string bundleName, string fileName, int fd, int manifestFd, int32_t errCode)); + MOCK_METHOD2(IncrementalBackupOnBundleStarted, ErrCode(int32_t errCode, string bundleName)); + MOCK_METHOD2(IncrementalBackupOnResultReport, ErrCode(string result, std::string bundleName)); + MOCK_METHOD2(IncrementalBackupOnBundleFinished, ErrCode(int32_t errCode, string bundleName)); + MOCK_METHOD1(IncrementalBackupOnAllBundlesFinished, ErrCode(int32_t errCode)); + MOCK_METHOD2(IncrementalBackupOnProcessInfo, ErrCode(std::string bundleName, std::string processInfo)); + MOCK_METHOD2(IncrementalRestoreOnBundleStarted, ErrCode(int32_t errCode, std::string bundleName)); + MOCK_METHOD2(IncrementalRestoreOnBundleFinished, ErrCode(int32_t errCode, string bundleName)); + MOCK_METHOD1(IncrementalRestoreOnAllBundlesFinished, ErrCode(int32_t errCode)); MOCK_METHOD5(IncrementalRestoreOnFileReady, - void(string bundleName, string fileName, int fd, int manifestFd, int32_t errCode)); - MOCK_METHOD3(IncrementalRestoreOnResultReport, void(string result, string bundleName, ErrCode errCode)); - MOCK_METHOD2(IncrementalRestoreOnProcessInfo, void(std::string bundleName, std::string processInfo)); + ErrCode(string bundleName, string fileName, int fd, int manifestFd, int32_t errCode)); + MOCK_METHOD3(IncrementalRestoreOnResultReport, ErrCode(string result, string bundleName, ErrCode errCode)); + MOCK_METHOD2(IncrementalRestoreOnProcessInfo, ErrCode(std::string bundleName, std::string processInfo)); }; class ServiceReverseStubTest : public testing::Test { @@ -90,7 +90,7 @@ HWTEST_F(ServiceReverseStubTest, SUB_backup_ServiceReverseStub_BackupOnFileReady GTEST_LOG_(INFO) << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_BackupOnFileReady_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, BackupOnFileReady(_, _, _, _)).WillOnce(Return()); + EXPECT_CALL(service, BackupOnFileReady(_, _, _, _)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -131,7 +131,7 @@ HWTEST_F(ServiceReverseStubTest, GTEST_LOG_(INFO) << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_BackupOnBundleStarted_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, BackupOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(service, BackupOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -167,7 +167,7 @@ HWTEST_F(ServiceReverseStubTest, GTEST_LOG_(INFO) << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_BackupOnResultReport_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, BackupOnResultReport(_, _)).WillOnce(Return()); + EXPECT_CALL(service, BackupOnResultReport(_, _)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -202,7 +202,7 @@ HWTEST_F(ServiceReverseStubTest, GTEST_LOG_(INFO) << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_BackupOnBundleFinished_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, BackupOnBundleFinished(_, _)).WillOnce(Return()); + EXPECT_CALL(service, BackupOnBundleFinished(_, _)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -238,7 +238,7 @@ HWTEST_F(ServiceReverseStubTest, GTEST_LOG_(INFO) << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_BackupOnAllBundlesFinished_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, BackupOnAllBundlesFinished(_)).WillOnce(Return()); + EXPECT_CALL(service, BackupOnAllBundlesFinished(_)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -273,7 +273,7 @@ HWTEST_F(ServiceReverseStubTest, GTEST_LOG_(INFO) << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_RestoreOnBundleStarted_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, RestoreOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(service, RestoreOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -309,7 +309,7 @@ HWTEST_F(ServiceReverseStubTest, GTEST_LOG_(INFO) << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_RestoreOnBundleFinished_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, RestoreOnBundleFinished(_, _)).WillOnce(Return()); + EXPECT_CALL(service, RestoreOnBundleFinished(_, _)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -345,7 +345,7 @@ HWTEST_F(ServiceReverseStubTest, GTEST_LOG_(INFO) << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_RestoreOnAllBundlesFinished_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, RestoreOnAllBundlesFinished(_)).WillOnce(Return()); + EXPECT_CALL(service, RestoreOnAllBundlesFinished(_)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -378,7 +378,7 @@ HWTEST_F(ServiceReverseStubTest, SUB_backup_ServiceReverseStub_RestoreOnFileRead GTEST_LOG_(INFO) << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_RestoreOnFileReady_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, RestoreOnFileReady(_, _, _, _)).WillOnce(Return()); + EXPECT_CALL(service, RestoreOnFileReady(_, _, _, _)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -460,7 +460,7 @@ HWTEST_F(ServiceReverseStubTest, GTEST_LOG_(INFO) << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_IncrementalBackupOnFileReady_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, IncrementalBackupOnFileReady(_, _, _, _, _)).WillOnce(Return()); + EXPECT_CALL(service, IncrementalBackupOnFileReady(_, _, _, _, _)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -506,7 +506,7 @@ HWTEST_F(ServiceReverseStubTest, << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_IncrementalBackupOnBundleStarted_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, IncrementalBackupOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(service, IncrementalBackupOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -545,7 +545,7 @@ HWTEST_F(ServiceReverseStubTest, << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_IncrementalBackupOnResultReport_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, IncrementalBackupOnResultReport(_, _)).WillOnce(Return()); + EXPECT_CALL(service, IncrementalBackupOnResultReport(_, _)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -583,7 +583,7 @@ HWTEST_F(ServiceReverseStubTest, << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_IncrementalBackupOnBundleFinished_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, IncrementalBackupOnBundleFinished(_, _)).WillOnce(Return()); + EXPECT_CALL(service, IncrementalBackupOnBundleFinished(_, _)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -623,7 +623,7 @@ HWTEST_F(ServiceReverseStubTest, << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_IncrementalBackupOnAllBundlesFinished_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, IncrementalBackupOnAllBundlesFinished(_)).WillOnce(Return()); + EXPECT_CALL(service, IncrementalBackupOnAllBundlesFinished(_)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -660,7 +660,7 @@ HWTEST_F(ServiceReverseStubTest, << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_IncrementalRestoreOnBundleStarted_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, IncrementalRestoreOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(service, IncrementalRestoreOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -699,7 +699,7 @@ HWTEST_F(ServiceReverseStubTest, << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_IncrementalRestoreOnBundleFinished_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, IncrementalRestoreOnBundleFinished(_, _)).WillOnce(Return()); + EXPECT_CALL(service, IncrementalRestoreOnBundleFinished(_, _)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -738,7 +738,7 @@ HWTEST_F(ServiceReverseStubTest, << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_IncrementalRestoreOnAllBundlesFinished_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, IncrementalRestoreOnAllBundlesFinished(_)).WillOnce(Return()); + EXPECT_CALL(service, IncrementalRestoreOnAllBundlesFinished(_)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -775,7 +775,7 @@ HWTEST_F(ServiceReverseStubTest, GTEST_LOG_(INFO) << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_IncrementalRestoreOnFileReady_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, IncrementalRestoreOnFileReady(_, _, _, _, _)).WillOnce(Return()); + EXPECT_CALL(service, IncrementalRestoreOnFileReady(_, _, _, _, _)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -820,7 +820,7 @@ HWTEST_F(ServiceReverseStubTest, << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_RestoreOnResultReport_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, RestoreOnResultReport(_, _, _)).WillOnce(Return()); + EXPECT_CALL(service, RestoreOnResultReport(_, _, _)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; @@ -860,7 +860,7 @@ HWTEST_F(ServiceReverseStubTest, << "ServiceReverseStubTest-begin SUB_backup_ServiceReverseStub_RestoreOnResultReport_0100"; try { MockServiceReverse service; - EXPECT_CALL(service, IncrementalRestoreOnResultReport(_, _, _)).WillOnce(Return()); + EXPECT_CALL(service, IncrementalRestoreOnResultReport(_, _, _)).WillOnce(Return(BError(BError::Codes::OK))); MessageParcel data; MessageParcel reply; MessageOption option; 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 9d43383b8..89439d937 100644 --- a/tests/unittests/backup_sa/module_ipc/service_incremental_test.cpp +++ b/tests/unittests/backup_sa/module_ipc/service_incremental_test.cpp @@ -251,6 +251,117 @@ std::vector Service::GetSupportBackupBundleNames(vectorAppendBundlesIncrementalBackupSession({}), BError(BError::Codes::OK).GetCode()); } catch (...) { EXPECT_TRUE(false); @@ -654,13 +765,13 @@ HWTEST_F(ServiceIncrementalTest, SUB_ServiceIncremental_AppIncrementalFileReady_ int32_t errCode = 0; EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalRestoreOnFileReady(_, _, _, _, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalRestoreOnFileReady(_, _, _, _, _)).WillOnce(Return(BError(BError::Codes::OK))); auto ret = service->AppIncrementalFileReady(fileName, UniqueFd(-1), UniqueFd(-1), errCode); EXPECT_EQ(ret, BError(BError::Codes::OK).GetCode()); EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::BACKUP)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalBackupOnFileReady(_, _, _, _, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalBackupOnFileReady(_, _, _, _, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*session, OnBundleFileReady(_, _)).WillOnce(Return(false)); ret = service->AppIncrementalFileReady(fileName, UniqueFd(-1), UniqueFd(-1), errCode); EXPECT_EQ(ret, BError(BError::Codes::OK).GetCode()); @@ -669,7 +780,7 @@ HWTEST_F(ServiceIncrementalTest, SUB_ServiceIncremental_AppIncrementalFileReady_ EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::BACKUP)); EXPECT_CALL(*session, OnBundleExtManageInfo(_, _)).WillOnce(Return(UniqueFd(-1))); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalBackupOnFileReady(_, _, _, _, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalBackupOnFileReady(_, _, _, _, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*session, OnBundleFileReady(_, _)).WillOnce(Return(false)); ret = service->AppIncrementalFileReady(fileName, UniqueFd(-1), UniqueFd(-1), errCode); EXPECT_EQ(ret, BError(BError::Codes::OK).GetCode()); @@ -697,7 +808,7 @@ HWTEST_F(ServiceIncrementalTest, SUB_ServiceIncremental_AppIncrementalFileReady_ int32_t errCode = 0; EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::BACKUP)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalBackupOnFileReady(_, _, _, _, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalBackupOnFileReady(_, _, _, _, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*session, OnBundleFileReady(_, _)).WillOnce(Return(true)); EXPECT_CALL(*session, GetExtConnection(_)).WillOnce(Return(connect)); EXPECT_CALL(*connect, GetBackupExtProxy()).WillOnce(Return(nullptr)); @@ -706,14 +817,14 @@ HWTEST_F(ServiceIncrementalTest, SUB_ServiceIncremental_AppIncrementalFileReady_ EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::BACKUP)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalBackupOnFileReady(_, _, _, _, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalBackupOnFileReady(_, _, _, _, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*session, OnBundleFileReady(_, _)).WillOnce(Return(true)); EXPECT_CALL(*session, GetExtConnection(_)).WillOnce(Return(connect)); EXPECT_CALL(*connect, GetBackupExtProxy()).WillOnce(Return(svcProxy)); EXPECT_CALL(*svcProxy, HandleClear()).WillOnce(Return(BError(BError::Codes::OK).GetCode())); EXPECT_CALL(*session, StopFwkTimer(_)).WillOnce(Return(true)); EXPECT_CALL(*session, StopExtTimer(_)).WillOnce(Return(true)); - EXPECT_CALL(*srProxy, IncrementalBackupOnBundleFinished(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalBackupOnBundleFinished(_, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*connect, DisconnectBackupExtAbility()).WillOnce(Return(BError(BError::Codes::OK).GetCode())); ret = service->AppIncrementalFileReady(fileName, UniqueFd(-1), UniqueFd(-1), errCode); EXPECT_EQ(ret, BError(BError::Codes::OK).GetCode()); @@ -856,7 +967,7 @@ HWTEST_F(ServiceIncrementalTest, SUB_ServiceIncremental_IncrementalBackup_0000, EXPECT_CALL(*session, GetClearDataFlag(_)).WillOnce(Return(false)); EXPECT_CALL(*svcProxy, IncrementalOnBackup(_)).WillOnce(Return(0)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalBackupOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalBackupOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); ret = service->IncrementalBackup(bundleName); EXPECT_TRUE(ret); @@ -867,7 +978,7 @@ HWTEST_F(ServiceIncrementalTest, SUB_ServiceIncremental_IncrementalBackup_0000, EXPECT_CALL(*session, GetClearDataFlag(_)).WillOnce(Return(false)); EXPECT_CALL(*svcProxy, IncrementalOnBackup(_)).WillOnce(Return(1)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalBackupOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalBackupOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); ret = service->IncrementalBackup(bundleName); EXPECT_TRUE(ret); @@ -922,7 +1033,7 @@ HWTEST_F(ServiceIncrementalTest, SUB_ServiceIncremental_IncrementalBackup_0100, EXPECT_CALL(*session, GetClearDataFlag(_)).WillOnce(Return(false)); EXPECT_CALL(*svcProxy, HandleRestore(_)).WillOnce(Return(BError(BError::Codes::OK).GetCode())); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalRestoreOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalRestoreOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*session, GetExtFileNameRequest(_)).WillOnce(Return(fileNameVec)); EXPECT_CALL(*svcProxy, GetIncrementalFileHandle(_)).WillOnce(Return(BError(BError::Codes::OK).GetCode())); ret = service->IncrementalBackup(bundleName); @@ -957,7 +1068,7 @@ HWTEST_F(ServiceIncrementalTest, SUB_ServiceIncremental_IncrementalBackup_0200, EXPECT_CALL(*session, GetClearDataFlag(_)).WillOnce(Return(false)); EXPECT_CALL(*svcProxy, HandleRestore(_)).WillOnce(Return(BError(BError::Codes::OK).GetCode())); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalRestoreOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalRestoreOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*session, GetExtFileNameRequest(_)).WillOnce(Return(fileNameVec)); EXPECT_CALL(*svcProxy, GetIncrementalFileHandle(_)) .WillOnce(Return(BError(BError::Codes::SA_INVAL_ARG).GetCode())); @@ -991,13 +1102,13 @@ HWTEST_F(ServiceIncrementalTest, SUB_ServiceIncremental_NotifyCallerCurAppIncrem EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::BACKUP)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalBackupOnBundleFinished(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalBackupOnBundleFinished(_, _)).WillOnce(Return(BError(BError::Codes::OK))); service->NotifyCallerCurAppIncrementDone(errCode, callerName); EXPECT_TRUE(true); EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalRestoreOnBundleFinished(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalRestoreOnBundleFinished(_, _)).WillOnce(Return(BError(BError::Codes::OK))); service->NotifyCallerCurAppIncrementDone(errCode, callerName); EXPECT_TRUE(true); } catch (...) { diff --git a/tests/unittests/backup_sa/module_ipc/service_other_test.cpp b/tests/unittests/backup_sa/module_ipc/service_other_test.cpp index e59fd30f2..264d80cc0 100644 --- a/tests/unittests/backup_sa/module_ipc/service_other_test.cpp +++ b/tests/unittests/backup_sa/module_ipc/service_other_test.cpp @@ -654,7 +654,7 @@ HWTEST_F(ServiceTest, SUB_Service_OnBundleStarted_0100, TestSize.Level1) EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE)); EXPECT_CALL(*param, GetBackupOverrideIncrementalRestore()).WillOnce(Return(false)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, RestoreOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, RestoreOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); service->OnBundleStarted(error, session_, bundleName); EXPECT_TRUE(true); @@ -662,7 +662,7 @@ HWTEST_F(ServiceTest, SUB_Service_OnBundleStarted_0100, TestSize.Level1) EXPECT_CALL(*param, GetBackupOverrideIncrementalRestore()).WillOnce(Return(true)); EXPECT_CALL(*session, ValidRestoreDataType(_)).WillOnce(Return(false)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, RestoreOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, RestoreOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); service->OnBundleStarted(error, session_, bundleName); EXPECT_TRUE(true); @@ -670,7 +670,7 @@ HWTEST_F(ServiceTest, SUB_Service_OnBundleStarted_0100, TestSize.Level1) EXPECT_CALL(*param, GetBackupOverrideIncrementalRestore()).WillOnce(Return(true)); EXPECT_CALL(*session, ValidRestoreDataType(_)).WillOnce(Return(true)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalRestoreOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalRestoreOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); service->OnBundleStarted(error, session_, bundleName); EXPECT_TRUE(true); } catch (...) { @@ -1608,7 +1608,7 @@ HWTEST_F(ServiceTest, SUB_Service_BackupSA_0000, TestSize.Level1) EXPECT_CALL(*session, GetSAExtConnection(_)).WillOnce(Return(sa)); EXPECT_CALL(*saConnect, CallBackupSA()).WillOnce(Return(BError(BError::Codes::OK).GetCode())); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, BackupOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, BackupOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); ret = service->BackupSA(bundleName); EXPECT_EQ(ret, BError(BError::Codes::OK).GetCode()); @@ -1618,7 +1618,7 @@ HWTEST_F(ServiceTest, SUB_Service_BackupSA_0000, TestSize.Level1) EXPECT_CALL(*session, GetSAExtConnection(_)).WillOnce(Return(sa)); EXPECT_CALL(*saConnect, CallBackupSA()).WillOnce(Return(BError(BError::Codes::SA_BOOT_EXT_FAIL).GetCode())); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, BackupOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, BackupOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*cdConfig, DeleteClearBundleRecord(_)).WillOnce(Return(false)); EXPECT_CALL(*saUtils, IsSABundleName(_)).WillOnce(Return(true)); EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(false)); @@ -1628,7 +1628,7 @@ HWTEST_F(ServiceTest, SUB_Service_BackupSA_0000, TestSize.Level1) EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE)); EXPECT_CALL(*session, GetSAExtConnection(_)).WillOnce(Return(sa)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalRestoreOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalRestoreOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); ret = service->BackupSA(bundleName); EXPECT_EQ(ret, BError(BError::Codes::OK).GetCode()); } catch (...) { @@ -1700,13 +1700,13 @@ HWTEST_F(ServiceTest, SUB_Service_NotifyCallerCurAppDone_0000, TestSize.Level1) EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::BACKUP)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, BackupOnBundleFinished(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, BackupOnBundleFinished(_, _)).WillOnce(Return(BError(BError::Codes::OK))); service->NotifyCallerCurAppDone(0, ""); EXPECT_TRUE(true); EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, RestoreOnBundleFinished(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, RestoreOnBundleFinished(_, _)).WillOnce(Return(BError(BError::Codes::OK))); service->NotifyCallerCurAppDone(0, ""); EXPECT_TRUE(true); } catch (...) { @@ -1735,7 +1735,7 @@ HWTEST_F(ServiceTest, SUB_Service_ReportAppProcessInfo_0000, TestSize.Level1) EXPECT_CALL(*token, GetHapTokenInfo(_, _)).WillOnce(Return(0)); EXPECT_CALL(*jsonUtil, BuildBundleNameIndexInfo(_, _)).WillOnce(Return("")); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, RestoreOnProcessInfo(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, RestoreOnProcessInfo(_, _)).WillOnce(Return(BError(BError::Codes::OK))); auto ret = service->ReportAppProcessInfo(processInfo, BackupRestoreScenario::FULL_RESTORE); EXPECT_EQ(ret, BError(BError::Codes::OK).GetCode()); @@ -1744,7 +1744,7 @@ HWTEST_F(ServiceTest, SUB_Service_ReportAppProcessInfo_0000, TestSize.Level1) EXPECT_CALL(*token, GetHapTokenInfo(_, _)).WillOnce(Return(0)); EXPECT_CALL(*jsonUtil, BuildBundleNameIndexInfo(_, _)).WillOnce(Return("")); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalRestoreOnProcessInfo(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalRestoreOnProcessInfo(_, _)).WillOnce(Return(BError(BError::Codes::OK))); ret = service->ReportAppProcessInfo(processInfo, BackupRestoreScenario::INCREMENTAL_RESTORE); EXPECT_EQ(ret, BError(BError::Codes::OK).GetCode()); @@ -1753,7 +1753,7 @@ HWTEST_F(ServiceTest, SUB_Service_ReportAppProcessInfo_0000, TestSize.Level1) EXPECT_CALL(*token, GetHapTokenInfo(_, _)).WillOnce(Return(0)); EXPECT_CALL(*jsonUtil, BuildBundleNameIndexInfo(_, _)).WillOnce(Return("")); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, BackupOnProcessInfo(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, BackupOnProcessInfo(_, _)).WillOnce(Return(BError(BError::Codes::OK))); ret = service->ReportAppProcessInfo(processInfo, BackupRestoreScenario::FULL_BACKUP); EXPECT_EQ(ret, BError(BError::Codes::OK).GetCode()); @@ -1762,7 +1762,7 @@ HWTEST_F(ServiceTest, SUB_Service_ReportAppProcessInfo_0000, TestSize.Level1) EXPECT_CALL(*token, GetHapTokenInfo(_, _)).WillOnce(Return(0)); EXPECT_CALL(*jsonUtil, BuildBundleNameIndexInfo(_, _)).WillOnce(Return("")); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalBackupOnProcessInfo(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalBackupOnProcessInfo(_, _)).WillOnce(Return(BError(BError::Codes::OK))); ret = service->ReportAppProcessInfo(processInfo, BackupRestoreScenario::INCREMENTAL_BACKUP); EXPECT_EQ(ret, BError(BError::Codes::OK).GetCode()); } catch (...) { diff --git a/tests/unittests/backup_sa/module_ipc/sub_service_test.cpp b/tests/unittests/backup_sa/module_ipc/sub_service_test.cpp index 80f110bdb..aa503ffe7 100644 --- a/tests/unittests/backup_sa/module_ipc/sub_service_test.cpp +++ b/tests/unittests/backup_sa/module_ipc/sub_service_test.cpp @@ -32,7 +32,7 @@ HWTEST_F(ServiceTest, SUB_Service_HandleCurGroupBackupInfos_0000, TestSize.Level map isClearDataFlags; EXPECT_CALL(*jsonUtil, BuildBundleNameIndexInfo(_, _)).WillOnce(Return("")); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, BackupOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, BackupOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*param, GetBackupDebugOverrideAccount()) .WillOnce(Return(make_pair(true, DEBUG_ID + 1))); EXPECT_CALL(*jsonUtil, FindBundleInfoByName(_, _, _, _)).WillOnce(Return(false)); @@ -75,7 +75,7 @@ HWTEST_F(ServiceTest, SUB_Service_ServiceResultReport_0000, TestSize.Level1) EXPECT_CALL(*token, GetHapTokenInfo(_, _)).WillOnce(Return(0)); EXPECT_CALL(*jsonUtil, BuildBundleNameIndexInfo(_, _)).WillOnce(Return("")); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, RestoreOnResultReport(_, _, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, RestoreOnResultReport(_, _, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*session, OnBundleFileReady(_, _)).WillOnce(Return(false)); EXPECT_CALL(*saUtils, IsSABundleName(_)).WillOnce(Return(true)); EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(false)); @@ -87,7 +87,7 @@ HWTEST_F(ServiceTest, SUB_Service_ServiceResultReport_0000, TestSize.Level1) EXPECT_CALL(*token, GetHapTokenInfo(_, _)).WillOnce(Return(0)); EXPECT_CALL(*jsonUtil, BuildBundleNameIndexInfo(_, _)).WillOnce(Return("")); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalRestoreOnResultReport(_, _, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalRestoreOnResultReport(_, _, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*session, OnBundleFileReady(_, _)).WillOnce(Return(false)); EXPECT_CALL(*saUtils, IsSABundleName(_)).WillOnce(Return(true)); EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(false)); @@ -100,7 +100,7 @@ HWTEST_F(ServiceTest, SUB_Service_ServiceResultReport_0000, TestSize.Level1) EXPECT_CALL(*jsonUtil, BuildBundleNameIndexInfo(_, _)).WillOnce(Return("")); EXPECT_CALL(*saUtils, IsSABundleName(_)).WillOnce(Return(true)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, BackupOnResultReport(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, BackupOnResultReport(_, _)).WillOnce(Return(BError(BError::Codes::OK))); ret = service->ServiceResultReport("", BackupRestoreScenario::FULL_BACKUP, 0); EXPECT_EQ(ret, BError(BError::Codes::OK).GetCode()); @@ -110,7 +110,7 @@ HWTEST_F(ServiceTest, SUB_Service_ServiceResultReport_0000, TestSize.Level1) EXPECT_CALL(*jsonUtil, BuildBundleNameIndexInfo(_, _)).WillOnce(Return("")); EXPECT_CALL(*saUtils, IsSABundleName(_)).WillOnce(Return(true)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalBackupOnResultReport(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalBackupOnResultReport(_, _)).WillOnce(Return(BError(BError::Codes::OK))); ret = service->ServiceResultReport("", BackupRestoreScenario::INCREMENTAL_BACKUP, 0); EXPECT_EQ(ret, BError(BError::Codes::OK).GetCode()); } catch (...) { @@ -134,29 +134,29 @@ HWTEST_F(ServiceTest, SUB_Service_SAResultReport_0000, TestSize.Level1) GTEST_LOG_(INFO) << "ServiceTest-begin SUB_Service_SAResultReport_0000"; try { EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, RestoreOnResultReport(_, _, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, RestoreOnResultReport(_, _, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*session, OnBundleFileReady(_, _)).WillOnce(Return(false)); EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(false)); auto ret = service->SAResultReport("", "", 0, BackupRestoreScenario::FULL_RESTORE); EXPECT_EQ(ret, BError(BError::Codes::OK).GetCode()); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalRestoreOnResultReport(_, _, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalRestoreOnResultReport(_, _, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*session, OnBundleFileReady(_, _)).WillOnce(Return(false)); EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(false)); ret = service->SAResultReport("", "", 0, BackupRestoreScenario::INCREMENTAL_RESTORE); EXPECT_EQ(ret, BError(BError::Codes::OK).GetCode()); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, BackupOnResultReport(_, _)).WillOnce(Return()); - EXPECT_CALL(*srProxy, BackupOnBundleFinished(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, BackupOnResultReport(_, _)).WillOnce(Return(BError(BError::Codes::OK))); + EXPECT_CALL(*srProxy, BackupOnBundleFinished(_, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*session, OnBundleFileReady(_, _)).WillOnce(Return(false)); EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(false)); ret = service->SAResultReport("", "", 0, BackupRestoreScenario::FULL_BACKUP); EXPECT_EQ(ret, BError(BError::Codes::OK).GetCode()); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalBackupOnResultReport(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalBackupOnResultReport(_, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*session, OnBundleFileReady(_, _)).WillOnce(Return(false)); EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(false)); ret = service->SAResultReport("", "", 0, BackupRestoreScenario::INCREMENTAL_BACKUP); @@ -305,7 +305,7 @@ HWTEST_F(ServiceTest, SUB_Service_GetFileHandle_0100, TestSize.Level1) EXPECT_CALL(*connect, GetBackupExtProxy()).WillOnce(Return(svcProxy)); EXPECT_CALL(*svcProxy, GetFileHandle(_, _)).WillOnce(Return(UniqueFd(-1))); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, RestoreOnFileReady(_, _, _, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, RestoreOnFileReady(_, _, _, _)).WillOnce(Return(BError(BError::Codes::OK))); auto ret = service->GetFileHandle(bundleName, fileName); EXPECT_EQ(ret, BError(BError::Codes::OK).GetCode()); @@ -321,7 +321,7 @@ HWTEST_F(ServiceTest, SUB_Service_GetFileHandle_0100, TestSize.Level1) .WillOnce(Return(make_pair(true, DEBUG_ID + 1))) .WillOnce(Return(make_pair(true, DEBUG_ID + 1))); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, RestoreOnFileReady(_, _, _, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, RestoreOnFileReady(_, _, _, _)).WillOnce(Return(BError(BError::Codes::OK))); ret = service->GetFileHandle(bundleName, fileName); EXPECT_EQ(ret, BError(BError::Codes::OK).GetCode()); } catch (...) { @@ -509,7 +509,7 @@ HWTEST_F(ServiceTest, SUB_Service_ExtStart_0100, TestSize.Level1) EXPECT_CALL(*session, GetClearDataFlag(_)).WillOnce(Return(false)); EXPECT_CALL(*svcProxy, HandleBackup(_)).WillOnce(Return(BError(BError::Codes::OK).GetCode())); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, BackupOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, BackupOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); service->ExtStart(callName); EXPECT_TRUE(true); @@ -522,7 +522,7 @@ HWTEST_F(ServiceTest, SUB_Service_ExtStart_0100, TestSize.Level1) EXPECT_CALL(*session, GetClearDataFlag(_)).WillOnce(Return(false)); EXPECT_CALL(*svcProxy, HandleBackup(_)).WillOnce(Return(BError(BError::Codes::SA_INVAL_ARG).GetCode())); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, BackupOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, BackupOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*param, GetBackupDebugOverrideAccount()) .WillOnce(Return(make_pair(true, DEBUG_ID + 1))); EXPECT_CALL(*cdConfig, DeleteClearBundleRecord(_)).WillOnce(Return(true)); @@ -538,7 +538,7 @@ HWTEST_F(ServiceTest, SUB_Service_ExtStart_0100, TestSize.Level1) EXPECT_CALL(*session, GetClearDataFlag(_)).WillOnce(Return(false)); EXPECT_CALL(*svcProxy, HandleRestore(_)).WillOnce(Return(BError(BError::Codes::SA_INVAL_ARG).GetCode())); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, RestoreOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, RestoreOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*param, GetBackupDebugOverrideAccount()) .WillOnce(Return(make_pair(true, DEBUG_ID + 1))); EXPECT_CALL(*session, GetExtFileNameRequest(_)).WillOnce(Return(fileNameVec)); @@ -602,20 +602,20 @@ HWTEST_F(ServiceTest, SUB_Service_ReportOnExtConnectFailed_0000, TestSize.Level1 EXPECT_CALL(*session, GetIsIncrementalBackup()).WillOnce(Return(true)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalBackupOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalBackupOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); service->ReportOnExtConnectFailed(IServiceReverse::Scenario::BACKUP, bundleName, 0); EXPECT_TRUE(true); EXPECT_CALL(*session, GetIsIncrementalBackup()).WillOnce(Return(false)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, BackupOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, BackupOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); service->ReportOnExtConnectFailed(IServiceReverse::Scenario::BACKUP, bundleName, 0); EXPECT_TRUE(true); EXPECT_CALL(*param, GetBackupOverrideIncrementalRestore()).WillOnce(Return(true)); EXPECT_CALL(*session, ValidRestoreDataType(_)).WillOnce(Return(true)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalRestoreOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalRestoreOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*gallery, EndRestore(_)).WillOnce(Return(DisposeErr::OK)); service->ReportOnExtConnectFailed(IServiceReverse::Scenario::RESTORE, bundleName, 0); EXPECT_TRUE(true); @@ -623,14 +623,14 @@ HWTEST_F(ServiceTest, SUB_Service_ReportOnExtConnectFailed_0000, TestSize.Level1 EXPECT_CALL(*param, GetBackupOverrideIncrementalRestore()).WillOnce(Return(true)); EXPECT_CALL(*session, ValidRestoreDataType(_)).WillOnce(Return(false)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, RestoreOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, RestoreOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*gallery, EndRestore(_)).WillOnce(Return(DisposeErr::OK)); service->ReportOnExtConnectFailed(IServiceReverse::Scenario::RESTORE, bundleName, 0); EXPECT_TRUE(true); EXPECT_CALL(*param, GetBackupOverrideIncrementalRestore()).WillOnce(Return(false)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, RestoreOnBundleStarted(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, RestoreOnBundleStarted(_, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*gallery, EndRestore(_)).WillOnce(Return(DisposeErr::OK)); service->ReportOnExtConnectFailed(IServiceReverse::Scenario::RESTORE, bundleName, 0); EXPECT_TRUE(true); @@ -665,7 +665,7 @@ HWTEST_F(ServiceTest, SUB_Service_NoticeClientFinish_0000, TestSize.Level1) EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::BACKUP)); EXPECT_CALL(*session, GetIsIncrementalBackup()).WillOnce(Return(true)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalBackupOnBundleFinished(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalBackupOnBundleFinished(_, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(false)); service->NoticeClientFinish(bundleName, 0); EXPECT_TRUE(true); @@ -675,7 +675,7 @@ HWTEST_F(ServiceTest, SUB_Service_NoticeClientFinish_0000, TestSize.Level1) EXPECT_CALL(*param, GetBackupOverrideIncrementalRestore()).WillOnce(Return(true)); EXPECT_CALL(*session, ValidRestoreDataType(_)).WillOnce(Return(true)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, IncrementalRestoreOnBundleFinished(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, IncrementalRestoreOnBundleFinished(_, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(false)); service->NoticeClientFinish(bundleName, 0); EXPECT_TRUE(true); @@ -684,7 +684,7 @@ HWTEST_F(ServiceTest, SUB_Service_NoticeClientFinish_0000, TestSize.Level1) EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::BACKUP)); EXPECT_CALL(*session, GetIsIncrementalBackup()).WillOnce(Return(false)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, BackupOnBundleFinished(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, BackupOnBundleFinished(_, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(false)); service->NoticeClientFinish(bundleName, 0); EXPECT_TRUE(true); @@ -714,7 +714,7 @@ HWTEST_F(ServiceTest, SUB_Service_NoticeClientFinish_0100, TestSize.Level1) EXPECT_CALL(*param, GetBackupOverrideIncrementalRestore()).WillOnce(Return(true)); EXPECT_CALL(*session, ValidRestoreDataType(_)).WillOnce(Return(false)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, RestoreOnBundleFinished(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, RestoreOnBundleFinished(_, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(false)); service->NoticeClientFinish(bundleName, 0); EXPECT_TRUE(true); @@ -723,7 +723,7 @@ HWTEST_F(ServiceTest, SUB_Service_NoticeClientFinish_0100, TestSize.Level1) EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE)); EXPECT_CALL(*param, GetBackupOverrideIncrementalRestore()).WillOnce(Return(false)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); - EXPECT_CALL(*srProxy, RestoreOnBundleFinished(_, _)).WillOnce(Return()); + EXPECT_CALL(*srProxy, RestoreOnBundleFinished(_, _)).WillOnce(Return(BError(BError::Codes::OK))); EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(false)); service->NoticeClientFinish(bundleName, 0); EXPECT_TRUE(true); -- Gitee