diff --git a/frameworks/native/backup_ext/src/ext_extension.cpp b/frameworks/native/backup_ext/src/ext_extension.cpp index b5fcb349fd98175e7e5876a412e0051920bc4d83..fb2ade8234b8e9c16a572baccf71ff07ea54fed0 100644 --- a/frameworks/native/backup_ext/src/ext_extension.cpp +++ b/frameworks/native/backup_ext/src/ext_extension.cpp @@ -75,15 +75,15 @@ static void RecordDoRestoreRes(const std::string &bundleName, const std::string AppRadar::DoRestoreInfo &restoreInfo) { std::stringstream ss; - ss << "\"bigFileNums\": " << restoreInfo.bigFileNum << ", "; - ss << "\"bigFileSize\": " << restoreInfo.bigFileSize << ", "; - ss << "\"RestoreBigFileTime\": " << restoreInfo.bigFileSpendTime << ", "; - ss << "\"unTarFileNums\": " << restoreInfo.tarFileNum << ", "; - ss << "\"unTarFileSize\": " << restoreInfo.tarFileSize << ", "; - ss << "\"unTarTime\": " << restoreInfo.tarFileSpendTime << ", "; - ss << "\"totalFileNum\": " << restoreInfo.bigFileNum + restoreInfo.tarFileNum << ", "; - ss << "\"totalFileSize\": " << restoreInfo.bigFileSize + restoreInfo.tarFileSize << ", "; - ss << "\"restoreAllFileTime\": " << restoreInfo.totalFileSpendTime; + ss << R"("bigFileNums": )" << restoreInfo.bigFileNum << ", "; + ss << R"("bigFileSize": )" << restoreInfo.bigFileSize << ", "; + ss << R"("RestoreBigFileTime": )" << restoreInfo.bigFileSpendTime << ", "; + ss << R"("unTarFileNums": )" << restoreInfo.tarFileNum << ", "; + ss << R"("unTarFileSize": )" << restoreInfo.tarFileSize << ", "; + ss << R"("unTarTime": )" << restoreInfo.tarFileSpendTime << ", "; + ss << R"("totalFileNum": )" << restoreInfo.bigFileNum + restoreInfo.tarFileNum << ", "; + ss << R"("totalFileSize": )" << restoreInfo.bigFileSize + restoreInfo.tarFileSize << ", "; + ss << R"("restoreAllFileTime": )" << restoreInfo.totalFileSpendTime; int32_t err = static_cast(BError::Codes::OK); AppRadar::Info info (bundleName, "", ss.str()); AppRadar::GetInstance().RecordRestoreFuncRes(info, func, AppRadar::GetInstance().GetUserId(), diff --git a/frameworks/native/backup_kit_inner/src/b_incremental_backup_session.cpp b/frameworks/native/backup_kit_inner/src/b_incremental_backup_session.cpp index cfaaf5ef5b51eba86f25e3e869a1a578992bcdf8..0d69e9ba8def6d05197e461e7c378f78d7a40858 100644 --- a/frameworks/native/backup_kit_inner/src/b_incremental_backup_session.cpp +++ b/frameworks/native/backup_kit_inner/src/b_incremental_backup_session.cpp @@ -54,7 +54,7 @@ unique_ptr BIncrementalBackupSession::Init(Callbacks } int32_t res = proxy->InitIncrementalBackupSession(sptr(new ServiceReverse(callbacks))); - if (res != 0) { + if (res != ERR_OK) { HILOGE("Failed to Backup because of %{public}d", res); AppRadar::Info info("", "", ""); AppRadar::GetInstance().RecordBackupFuncRes(info, "BIncrementalBackupSession::Init", @@ -97,8 +97,8 @@ ErrCode BIncrementalBackupSession::AppendBundles(vector bundle return BError(BError::Codes::SDK_BROKEN_IPC, "Failed to get backup service").GetCode(); } - int32_t res = proxy->AppendBundlesIncrementalBackupSession(bundlesToBackup); - if (res != 0) { + ErrCode res = proxy->AppendBundlesIncrementalBackupSession(bundlesToBackup); + if (res != ERR_OK) { std::string ss; for (const auto &bundle : bundlesToBackup) { ss += bundle.bundleName + ", "; @@ -119,7 +119,7 @@ ErrCode BIncrementalBackupSession::AppendBundles(vector bundle } int32_t res = proxy->AppendBundlesIncrementalBackupSession(bundlesToBackup, infos); - if (res != 0) { + if (res != ERR_OK) { std::string ss; for (const auto &bundle : bundlesToBackup) { ss += bundle.bundleName + ", "; diff --git a/frameworks/native/backup_kit_inner/src/b_incremental_restore_session.cpp b/frameworks/native/backup_kit_inner/src/b_incremental_restore_session.cpp index ed51e8cb9d9f36ff35ab1fa049558da2ae8f5bf2..0999dac1d385f0ed6add68593f2faf7d8274a6a7 100644 --- a/frameworks/native/backup_kit_inner/src/b_incremental_restore_session.cpp +++ b/frameworks/native/backup_kit_inner/src/b_incremental_restore_session.cpp @@ -53,12 +53,11 @@ unique_ptr BIncrementalRestoreSession::Init(Callback return nullptr; } int32_t res = proxy->InitRestoreSession(sptr(new ServiceReverse(callbacks))); - if (res != 0) { + if (res != ERR_OK) { HILOGE("Failed to Restore because of %{public}d", res); AppRadar::Info info ("", "", "create restore session failed"); AppRadar::GetInstance().RecordRestoreFuncRes(info, "BIncrementalRestoreSession::Init", - AppRadar::GetInstance().GetUserId(), - BizStageRestore::BIZ_STAGE_CREATE_RESTORE_SESSION_FAIL, res); + AppRadar::GetInstance().GetUserId(), BizStageRestore::BIZ_STAGE_CREATE_RESTORE_SESSION_FAIL, res); return nullptr; } @@ -104,7 +103,17 @@ ErrCode BIncrementalRestoreSession::AppendBundles(UniqueFd remoteCap, vectorAppendBundlesRestoreSession(move(remoteCap), bundlesToRestore); + ErrCode res = proxy->AppendBundlesRestoreSession(move(remoteCap), bundlesToRestore); + if (res != ERR_OK) { + std::string ss; + for (const auto &bundle : bundlesToRestore) { + ss += bundle + ", "; + } + AppRadar::Info info(ss.c_str(), "", ""); + AppRadar::GetInstance().RecordRestoreFuncRes(info, "BIncrementalRestoreSession::AppendBundles", + AppRadar::GetInstance().GetUserId(), BizStageRestore::BIZ_STAGE_APPEND_BUNDLES_FAIL, res); + } + return res; } ErrCode BIncrementalRestoreSession::AppendBundles(UniqueFd remoteCap, vector bundlesToRestore, @@ -114,8 +123,17 @@ ErrCode BIncrementalRestoreSession::AppendBundles(UniqueFd remoteCap, vectorAppendBundlesRestoreSession(move(remoteCap), bundlesToRestore, detailInfos); + ErrCode res = proxy->AppendBundlesRestoreSession(move(remoteCap), bundlesToRestore, detailInfos); + if (res != ERR_OK) { + std::string ss; + for (const auto &bundle : bundlesToRestore) { + ss += bundle + ", "; + } + AppRadar::Info info(ss.c_str(), "", "AppendBundles with infos"); + AppRadar::GetInstance().RecordRestoreFuncRes(info, "BIncrementalRestoreSession::AppendBundles", + AppRadar::GetInstance().GetUserId(), BizStageRestore::BIZ_STAGE_APPEND_BUNDLES_FAIL, res); + } + return res; } ErrCode BIncrementalRestoreSession::Release() diff --git a/frameworks/native/backup_kit_inner/src/b_incremental_session_restore_async.cpp b/frameworks/native/backup_kit_inner/src/b_incremental_session_restore_async.cpp index 75c7e3cbcd54dada7b498c614fd72659b24428a6..cb79d416cd0e807b4111af0f65cd331bfadb3ce0 100644 --- a/frameworks/native/backup_kit_inner/src/b_incremental_session_restore_async.cpp +++ b/frameworks/native/backup_kit_inner/src/b_incremental_session_restore_async.cpp @@ -61,12 +61,11 @@ shared_ptr BIncrementalSessionRestoreAsync::Ini .onResultReport = callbacks.onResultReport, .onBackupServiceDied = callbacks.onBackupServiceDied}; int32_t res = proxy->InitRestoreSession(sptr(new ServiceReverse(callbacksTmp))); - if (res != 0) { + if (res != ERR_OK) { HILOGE("Failed to Restore because of %{public}d", res); AppRadar::Info info ("", "", "create restore session failed"); AppRadar::GetInstance().RecordRestoreFuncRes(info, "BIncrementalSessionRestoreAsync::Init", - AppRadar::GetInstance().GetUserId(), - BizStageRestore::BIZ_STAGE_CREATE_RESTORE_SESSION_FAIL, res); + AppRadar::GetInstance().GetUserId(), BizStageRestore::BIZ_STAGE_CREATE_RESTORE_SESSION_FAIL, res); return nullptr; } @@ -107,8 +106,18 @@ ErrCode BIncrementalSessionRestoreAsync::AppendBundles(UniqueFd remoteCap, if (proxy == nullptr) { return BError(BError::Codes::SDK_BROKEN_IPC, "Failed to get backup service").GetCode(); } - return proxy->AppendBundlesRestoreSession(move(remoteCap), bundlesToRestore, detailInfos, restoreType, + ErrCode res = proxy->AppendBundlesRestoreSession(move(remoteCap), bundlesToRestore, detailInfos, restoreType, userId); + if (res != ERR_OK) { + std::string ss; + for (const auto &bundle : bundlesToRestore) { + ss += bundle + ", "; + } + AppRadar::Info info(ss.c_str(), "", "AppendBundles with infos"); + AppRadar::GetInstance().RecordRestoreFuncRes(info, "BIncrementalSessionRestoreAsync::AppendBundles", + AppRadar::GetInstance().GetUserId(), BizStageRestore::BIZ_STAGE_APPEND_BUNDLES_FAIL, res); + } + return res; } ErrCode BIncrementalSessionRestoreAsync::AppendBundles(UniqueFd remoteCap, @@ -120,8 +129,17 @@ ErrCode BIncrementalSessionRestoreAsync::AppendBundles(UniqueFd remoteCap, if (proxy == nullptr) { return BError(BError::Codes::SDK_BROKEN_IPC, "Failed to get backup service").GetCode(); } - - return proxy->AppendBundlesRestoreSession(move(remoteCap), bundlesToRestore, restoreType, userId); + ErrCode res = proxy->AppendBundlesRestoreSession(move(remoteCap), bundlesToRestore, restoreType, userId); + if (res != ERR_OK) { + std::string ss; + for (const auto &bundle : bundlesToRestore) { + ss += bundle + ", "; + } + AppRadar::Info info(ss.c_str(), "", ""); + AppRadar::GetInstance().RecordRestoreFuncRes(info, "BIncrementalSessionRestoreAsync::AppendBundles", + AppRadar::GetInstance().GetUserId(), BizStageRestore::BIZ_STAGE_APPEND_BUNDLES_FAIL, res); + } + return res; } ErrCode BIncrementalSessionRestoreAsync::Release() diff --git a/frameworks/native/backup_kit_inner/src/b_session_backup.cpp b/frameworks/native/backup_kit_inner/src/b_session_backup.cpp index f20285515766b6ea0c189b588ec5dd5d75b19864..5086262692d1999cb8711bcab191ab77926862f6 100644 --- a/frameworks/native/backup_kit_inner/src/b_session_backup.cpp +++ b/frameworks/native/backup_kit_inner/src/b_session_backup.cpp @@ -54,7 +54,7 @@ unique_ptr BSessionBackup::Init(Callbacks callbacks) } int32_t res = proxy->InitBackupSession(sptr(new ServiceReverse(callbacks))); - if (res != 0) { + if (res != ERR_OK) { HILOGE("Failed to Backup because of %{public}d", res); AppRadar::Info info("", "", ""); AppRadar::GetInstance().RecordBackupFuncRes(info, "BSessionBackup::Init", @@ -108,7 +108,7 @@ ErrCode BSessionBackup::AppendBundles(vector bundlesToBackup) } int32_t res = proxy->AppendBundlesBackupSession(bundlesToBackup); - if (res != 0) { + if (res != ERR_OK) { std::string ss; for (const auto &bundleName:bundlesToBackup) { ss += bundleName + ", "; @@ -128,12 +128,12 @@ ErrCode BSessionBackup::AppendBundles(vector bundlesToBackup, vector } int32_t res = proxy->AppendBundlesDetailsBackupSession(bundlesToBackup, detailInfos); - if (res != 0) { + if (res != ERR_OK) { std::string ss; for (const auto &bundleName:bundlesToBackup) { ss += bundleName + ", "; } - AppRadar::Info info(ss.c_str(), "", ""); + AppRadar::Info info(ss.c_str(), "", "AppendBundles with infos"); AppRadar::GetInstance().RecordBackupFuncRes(info, "BSessionBackup::AppendBundles", AppRadar::GetInstance().GetUserId(), BizStageBackup::BIZ_STAGE_APPEND_BUNDLES_FAIL, res); } diff --git a/frameworks/native/backup_kit_inner/src/b_session_restore.cpp b/frameworks/native/backup_kit_inner/src/b_session_restore.cpp index 0c37d260361e7e01f255690eb351f1004cc42362..9247c39ffe785d68ca37b484e4841a384dfce082 100644 --- a/frameworks/native/backup_kit_inner/src/b_session_restore.cpp +++ b/frameworks/native/backup_kit_inner/src/b_session_restore.cpp @@ -53,12 +53,11 @@ unique_ptr BSessionRestore::Init(Callbacks callbacks) return nullptr; } int32_t res = proxy->InitRestoreSession(new ServiceReverse(callbacks)); - if (res != 0) { + if (res != ERR_OK) { HILOGE("Failed to Restore because of %{public}d", res); AppRadar::Info info ("", "", "create restore session failed"); AppRadar::GetInstance().RecordRestoreFuncRes(info, "BSessionRestore::Init", - AppRadar::GetInstance().GetUserId(), - BizStageRestore::BIZ_STAGE_CREATE_RESTORE_SESSION_FAIL, res); + AppRadar::GetInstance().GetUserId(), BizStageRestore::BIZ_STAGE_CREATE_RESTORE_SESSION_FAIL, res); return nullptr; } @@ -106,7 +105,17 @@ ErrCode BSessionRestore::AppendBundles(UniqueFd remoteCap, vector bu if (proxy == nullptr) { return BError(BError::Codes::SDK_BROKEN_IPC, "Failed to get backup service").GetCode(); } - return proxy->AppendBundlesRestoreSession(move(remoteCap), bundlesToRestore, detailInfos); + ErrCode res = proxy->AppendBundlesRestoreSession(move(remoteCap), bundlesToRestore, detailInfos); + if (res != ERR_OK) { + std::string ss; + for (const auto &bundle : bundlesToRestore) { + ss += bundle + ", "; + } + AppRadar::Info info(ss.c_str(), "", "AppendBundles with infos"); + AppRadar::GetInstance().RecordRestoreFuncRes(info, "BSessionRestore::AppendBundles", + AppRadar::GetInstance().GetUserId(), BizStageRestore::BIZ_STAGE_APPEND_BUNDLES_FAIL, res); + } + return res; } ErrCode BSessionRestore::AppendBundles(UniqueFd remoteCap, vector bundlesToRestore) @@ -115,8 +124,17 @@ ErrCode BSessionRestore::AppendBundles(UniqueFd remoteCap, vector bu if (proxy == nullptr) { return BError(BError::Codes::SDK_BROKEN_IPC, "Failed to get backup service").GetCode(); } - - return proxy->AppendBundlesRestoreSession(move(remoteCap), bundlesToRestore); + ErrCode res = proxy->AppendBundlesRestoreSession(move(remoteCap), bundlesToRestore); + if (res != ERR_OK) { + std::string ss; + for (const auto &bundle : bundlesToRestore) { + ss += bundle + ", "; + } + AppRadar::Info info(ss.c_str(), "", ""); + AppRadar::GetInstance().RecordRestoreFuncRes(info, "BSessionRestore::AppendBundles", + AppRadar::GetInstance().GetUserId(), BizStageRestore::BIZ_STAGE_APPEND_BUNDLES_FAIL, res); + } + return res; } ErrCode BSessionRestore::Finish() diff --git a/frameworks/native/backup_kit_inner/src/b_session_restore_async.cpp b/frameworks/native/backup_kit_inner/src/b_session_restore_async.cpp index b3cea05e1fd1a036aa43eb8d86d6e5ec39c08ba7..12b82a250b54e5f06c6c6889b241bb1a83daf8cf 100644 --- a/frameworks/native/backup_kit_inner/src/b_session_restore_async.cpp +++ b/frameworks/native/backup_kit_inner/src/b_session_restore_async.cpp @@ -62,12 +62,11 @@ shared_ptr BSessionRestoreAsync::Init(Callbacks callbacks) .onBackupServiceDied = callbacks.onBackupServiceDied, .onProcess = callbacks.onProcess}; int32_t res = proxy->InitRestoreSession(sptr(new ServiceReverse(callbacksTmp))); - if (res != 0) { + if (res != ERR_OK) { HILOGE("Failed to Restore because of %{public}d", res); AppRadar::Info info ("", "", "create restore session failed"); AppRadar::GetInstance().RecordRestoreFuncRes(info, "BSessionRestoreAsync::Init", - AppRadar::GetInstance().GetUserId(), - BizStageRestore::BIZ_STAGE_CREATE_RESTORE_SESSION_FAIL, res); + AppRadar::GetInstance().GetUserId(), BizStageRestore::BIZ_STAGE_CREATE_RESTORE_SESSION_FAIL, res); return nullptr; } @@ -108,8 +107,18 @@ ErrCode BSessionRestoreAsync::AppendBundles(UniqueFd remoteCap, if (proxy == nullptr) { return BError(BError::Codes::SDK_BROKEN_IPC, "Failed to get backup service").GetCode(); } - return proxy->AppendBundlesRestoreSession(move(remoteCap), bundlesToRestore, detailInfos, restoreType, + ErrCode res = proxy->AppendBundlesRestoreSession(move(remoteCap), bundlesToRestore, detailInfos, restoreType, userId); + if (res != ERR_OK) { + std::string ss; + for (const auto &bundle : bundlesToRestore) { + ss += bundle + ", "; + } + AppRadar::Info info(ss.c_str(), "", "AppendBundles with infos"); + AppRadar::GetInstance().RecordRestoreFuncRes(info, "BSessionRestoreAsync::AppendBundles", + AppRadar::GetInstance().GetUserId(), BizStageRestore::BIZ_STAGE_APPEND_BUNDLES_FAIL, res); + } + return res; } ErrCode BSessionRestoreAsync::AppendBundles(UniqueFd remoteCap, @@ -122,7 +131,17 @@ ErrCode BSessionRestoreAsync::AppendBundles(UniqueFd remoteCap, return BError(BError::Codes::SDK_BROKEN_IPC, "Failed to get backup service").GetCode(); } - return proxy->AppendBundlesRestoreSession(move(remoteCap), bundlesToRestore, restoreType, userId); + ErrCode res = proxy->AppendBundlesRestoreSession(move(remoteCap), bundlesToRestore, restoreType, userId); + if (res != ERR_OK) { + std::string ss; + for (const auto &bundle : bundlesToRestore) { + ss += bundle + ", "; + } + AppRadar::Info info(ss.c_str(), "", ""); + AppRadar::GetInstance().RecordRestoreFuncRes(info, "BSessionRestoreAsync::AppendBundles", + AppRadar::GetInstance().GetUserId(), BizStageRestore::BIZ_STAGE_APPEND_BUNDLES_FAIL, res); + } + return res; } ErrCode BSessionRestoreAsync::Release() 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 ec842c43283f26fb25cf3bac5788038aeb5efb5e..ba1e761c5fd39867a97fe704e0efbfacb2b9d283 100644 --- a/frameworks/native/backup_kit_inner/src/service_incremental_reverse.cpp +++ b/frameworks/native/backup_kit_inner/src/service_incremental_reverse.cpp @@ -16,6 +16,7 @@ #include "service_reverse.h" #include "b_error/b_error.h" +#include "b_radar/b_radar.h" #include "filemgmt_libhilog.h" namespace OHOS::FileManagement::Backup { diff --git a/frameworks/native/backup_kit_inner/src/service_proxy.cpp b/frameworks/native/backup_kit_inner/src/service_proxy.cpp index f3e1854ba5319212d1e014e0f8e3da3982fe9abd..e05fb51381c173b4f8be2c2fa6348fe17f04bfbf 100644 --- a/frameworks/native/backup_kit_inner/src/service_proxy.cpp +++ b/frameworks/native/backup_kit_inner/src/service_proxy.cpp @@ -301,13 +301,6 @@ ErrCode ServiceProxy::AppendBundlesRestoreSession(UniqueFd fd, const vector(IServiceInterfaceCode::SERVICE_CMD_APPEND_BUNDLES_RESTORE_SESSION), data, reply, option); if (ret != NO_ERROR) { string str = "Failed to send out the request because of " + to_string(ret); - std::string ss; - for (const auto &bundleName : bundleNames) { - ss += bundleName + ", "; - } - AppRadar::Info info(ss.c_str(), "", str); - AppRadar::GetInstance().RecordRestoreFuncRes(info, "ServiceProxy::AppendBundlesRestoreSession", userId, - BizStageRestore::BIZ_STAGE_APPEND_BUNDLES_FAIL, ret); return BError(BError::Codes::SDK_INVAL_ARG, str.data()).GetCode(); } return reply.ReadInt32(); @@ -473,7 +459,7 @@ sptr ServiceProxy::GetInstance() AppRadar::Info info("", "", "\"reason\":\"Load backup sa timeout\""); AppRadar::GetInstance().RecordBackupFuncRes(info, "ServiceProxy::GetInstance", AppRadar::GetInstance().GetUserId(), BizStageBackup::BIZ_STAGE_BOOT_BACKUP_SA_FAIL, - static_cast(BError::Codes::SA_INVAL_ARG)); + BError(BError::Codes::SA_INVAL_ARG).GetCode()); return nullptr; } return serviceProxy_; diff --git a/services/backup_sa/include/module_ipc/service.h b/services/backup_sa/include/module_ipc/service.h index 828c311bc4106db63916f933fb08abec79a91afe..a093d680cfa80bc30a96622aab7520a885e5f56e 100644 --- a/services/backup_sa/include/module_ipc/service.h +++ b/services/backup_sa/include/module_ipc/service.h @@ -38,6 +38,11 @@ struct ExtensionMutexInfo { ExtensionMutexInfo(std::string bundleName_) : bundleName(bundleName_) {}; }; +struct BundleTaskInfo { + std::string reportTime; + ErrCode errCode; +}; + class Service : public SystemAbility, public ServiceStub, protected NoCopyable { DECLARE_SYSTEM_ABILITY(Service); @@ -262,7 +267,7 @@ public: * @param bundleName 应用名称 * */ - void ClearResidualBundleData(const std::string &bundleName); + ErrCode ClearResidualBundleData(const std::string &bundleName); /** * @brief 添加清理记录 @@ -517,6 +522,26 @@ private: void TimeoutRadarReport(IServiceReverse::Scenario scenario, std::string &bundleName); + void OnBundleStarted(BError error, sptr session, const BundleName &bundleName); + + void HandleExceptionOnAppendBundles(sptr session, const vector &appendBundleNames, + const vector &restoreBundleNames); + + void BundleBeginRadarReport(const std::string &bundleName, const ErrCode errCode, + const IServiceReverse::Scenario scenario); + + void BundleEndRadarReport(const std::string &bundleName, const ErrCode errCode, + const IServiceReverse::Scenario scenario); + + void FileReadyRadarReport(const std::string &bundleName, const std::string &fileName, const ErrCode errCode, + const IServiceReverse::Scenario scenario); + + void ExtensionConnectFailRadarReport(const std::string &bundleName, const ErrCode errCode, + const IServiceReverse::Scenario scenario); + + void UpdateFailedBundles(const std::string &bundleName, BundleTaskInfo taskInfo); + + void ClearFailedBundles(); void CreateDirIfNotExist(const std::string &path); private: static sptr instance_; @@ -538,8 +563,11 @@ private: OHOS::ThreadPool threadPool_; std::mutex extensionMutexLock_; + std::mutex failedBundlesLock_; public: std::map> backupExtMutexMap_; + std::map failedBundles_; + std::atomic successBundlesNum_ {0}; }; } // namespace OHOS::FileManagement::Backup diff --git a/services/backup_sa/src/module_app_gallery/app_gallery_dispose_proxy.cpp b/services/backup_sa/src/module_app_gallery/app_gallery_dispose_proxy.cpp index 5818f706143c1feaf465a52627a752668e0e27e5..0540db747a48c4907cf5c8f903770394075b1240 100644 --- a/services/backup_sa/src/module_app_gallery/app_gallery_dispose_proxy.cpp +++ b/services/backup_sa/src/module_app_gallery/app_gallery_dispose_proxy.cpp @@ -102,19 +102,19 @@ void RecordDoDisposeRes(const std::string &bundleName, switch (disposeOperation) { case AppGalleryDisposeProxy::DisposeOperation::START_BACKUP: AppRadar::GetInstance().RecordBackupFuncRes(info, "StartBackup", AppRadar::GetInstance().GetUserId(), - BizStageBackup::BIZ_STAGE_START_DISPOSE_FAIL, err); + BizStageBackup::BIZ_STAGE_START_DISPOSE, err); break; case AppGalleryDisposeProxy::DisposeOperation::END_BACKUP: AppRadar::GetInstance().RecordBackupFuncRes(info, "EndBackup", AppRadar::GetInstance().GetUserId(), - BizStageBackup::BIZ_STAGE_END_DISPOSE_FAIL, err); + BizStageBackup::BIZ_STAGE_END_DISPOSE, err); break; case AppGalleryDisposeProxy::DisposeOperation::START_RESTORE: AppRadar::GetInstance().RecordRestoreFuncRes(info, "StartRestore", AppRadar::GetInstance().GetUserId(), - BizStageRestore::BIZ_STAGE_START_DISPOSE_FAIL, err); + BizStageRestore::BIZ_STAGE_START_DISPOSE, err); break; case AppGalleryDisposeProxy::DisposeOperation::END_RESTORE: AppRadar::GetInstance().RecordRestoreFuncRes(info, "EndRestore", AppRadar::GetInstance().GetUserId(), - BizStageRestore::BIZ_STAGE_END_DISPOSE_FAIL, err); + BizStageRestore::BIZ_STAGE_END_DISPOSE, err); break; default: break; diff --git a/services/backup_sa/src/module_ipc/service.cpp b/services/backup_sa/src/module_ipc/service.cpp index c2af171df66e43e603487f3c3f03e57543ccac6d..5ac1aa771e1e238558fe5c6c87e3a4fb1645b453 100644 --- a/services/backup_sa/src/module_ipc/service.cpp +++ b/services/backup_sa/src/module_ipc/service.cpp @@ -51,6 +51,7 @@ #include "b_radar/b_radar.h" #include "b_resources/b_constants.h" #include "b_sa/b_sa_utils.h" +#include "b_utils/b_time.h" #include "bundle_mgr_client.h" #include "filemgmt_libhilog.h" #include "hisysevent.h" @@ -103,6 +104,112 @@ static inline int32_t GetUserIdDefault() return multiuser.userId; } +void OnStartResRadarReport(const IServiceReverse::Scenario scenario, + const std::vector &bundleNameList, int32_t stage) +{ + std::stringstream ss; + ss << "failedBundles:{"; + for (auto &bundleName : bundleNameList) { + ss << bundleName << ", "; + } + ss << "}"; + AppRadar::Info info("", "", ss.str()); + if (scenario == IServiceReverse::Scenario::RESTORE) { + AppRadar::GetInstance().RecordRestoreFuncRes(info, "Service::OnStart", GetUserIdDefault(), + static_cast(stage), ERR_OK); + } else if (scenario == IServiceReverse::Scenario::BACKUP) { + AppRadar::GetInstance().RecordBackupFuncRes(info, "Service::OnStart", GetUserIdDefault(), + static_cast(stage), ERR_OK); + } +} + +void Service::ClearFailedBundles() +{ + std::lock_guard lock(failedBundlesLock_); + failedBundles_.clear(); +} + +void Service::UpdateFailedBundles(const std::string &bundleName, BundleTaskInfo taskInfo) +{ + std::lock_guard lock(failedBundlesLock_); + failedBundles_[bundleName] = taskInfo; +} + +void Service::BundleBeginRadarReport(const std::string &bundleName, const ErrCode errCode, + const IServiceReverse::Scenario scenario) +{ + if (errCode == ERR_OK || errCode == BError(BError::Codes::SA_BOOT_EXT_FAIL).GetCode()) { + return; + } + BundleTaskInfo taskInfo; + taskInfo.reportTime = TimeUtils::GetCurrentTime(); + taskInfo.errCode = errCode; + UpdateFailedBundles(bundleName, taskInfo); + AppRadar::Info info(bundleName, "", ""); + if (scenario == IServiceReverse::Scenario::RESTORE) { + AppRadar::GetInstance().RecordRestoreFuncRes(info, "Service::BundleBeginRadarReport", + GetUserIdDefault(), BizStageRestore::BIZ_STAGE_APPEND_BUNDLES_FAIL, errCode); + } else if (scenario == IServiceReverse::Scenario::BACKUP) { + AppRadar::GetInstance().RecordBackupFuncRes(info, "Service::BundleBeginRadarReport", + GetUserIdDefault(), BizStageBackup::BIZ_STAGE_APPEND_BUNDLES_FAIL, errCode); + } +} + +void Service::BundleEndRadarReport(const std::string &bundleName, const ErrCode errCode, + const IServiceReverse::Scenario scenario) +{ + if (errCode == ERR_OK) { + successBundlesNum_++; + return; + } + BundleTaskInfo taskInfo; + taskInfo.reportTime = TimeUtils::GetCurrentTime(); + taskInfo.errCode = errCode; + UpdateFailedBundles(bundleName, taskInfo); + AppRadar::Info info(bundleName, "", ""); + if (scenario == IServiceReverse::Scenario::RESTORE) { + AppRadar::GetInstance().RecordRestoreFuncRes(info, "Service::BundleEndRadarReport", + GetUserIdDefault(), BizStageRestore::BIZ_STAGE_EXECU_FAIL, errCode); + } else if (scenario == IServiceReverse::Scenario::BACKUP) { + AppRadar::GetInstance().RecordBackupFuncRes(info, "Service::BundleEndRadarReport", + GetUserIdDefault(), BizStageBackup::BIZ_STAGE_EXECU_FAIL, errCode); + } +} + +void Service::FileReadyRadarReport(const std::string &bundleName, const std::string &fileName, const ErrCode errCode, + const IServiceReverse::Scenario scenario) +{ + if (errCode == ERR_OK) { + return; + } + std::string fileNameReport = std::string("fileName:\"") + GetAnonyPath(fileName) + "\""; + AppRadar::Info info(bundleName, "", fileNameReport); + if (scenario == IServiceReverse::Scenario::RESTORE) { + AppRadar::GetInstance().RecordRestoreFuncRes(info, "Service::FileReadyRadarReport", + GetUserIdDefault(), BizStageRestore::BIZ_STAGE_GET_FILE_HANDLE_FAIL, errCode); + } else if (scenario == IServiceReverse::Scenario::BACKUP) { + AppRadar::GetInstance().RecordBackupFuncRes(info, "Service::FileReadyRadarReport", + GetUserIdDefault(), BizStageBackup::BIZ_STAGE_DO_BACKUP, errCode); + } +} + +void Service::ExtensionConnectFailRadarReport(const std::string &bundleName, const ErrCode errCode, + const IServiceReverse::Scenario scenario) +{ + std::stringstream ss; + ss << "errCode:" << errCode; + AppRadar::Info info(bundleName, "", ss.str()); + if (scenario == IServiceReverse::Scenario::RESTORE) { + AppRadar::GetInstance().RecordRestoreFuncRes(info, "Service::ExtensionConnectFailRadarReport", + GetUserIdDefault(), BizStageRestore::BIZ_STAGE_CONNECT_EXTENSION_FAIL, + BError(BError::Codes::SA_BOOT_EXT_FAIL).GetCode()); + } else if (scenario == IServiceReverse::Scenario::BACKUP) { + AppRadar::GetInstance().RecordBackupFuncRes(info, "Service::ExtensionConnectFailRadarReport", + GetUserIdDefault(), BizStageBackup::BIZ_STAGE_CONNECT_EXTENSION_FAIL, + BError(BError::Codes::SA_BOOT_EXT_FAIL).GetCode()); + } +} + void Service::OnStart() { HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); @@ -116,6 +223,15 @@ void Service::OnStart() residualBundleNameList = clearRecorder_->GetAllClearBundleRecords(); } if (!bundleNameList.empty() || !residualBundleNameList.empty()) { + IServiceReverse::Scenario scenario = session_->GetScenario(); + if (!bundleNameList.empty()) { + OnStartResRadarReport(scenario, bundleNameList, + static_cast(BizStageBackup::BIZ_STAGE_ONSTART_DISPOSE)); + } + if (!residualBundleNameList.empty()) { + OnStartResRadarReport(scenario, residualBundleNameList, + static_cast(BizStageBackup::BIZ_STAGE_ONSTART_RESIDUAL)); + } SetOccupySession(true); session_->Active( { @@ -211,6 +327,9 @@ UniqueFd Service::GetLocalCapabilities() void Service::StopAll(const wptr &obj, bool force) { HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); + std::lock_guard lock(failedBundlesLock_); + failedBundles_.clear(); + successBundlesNum_ = 0; session_->Deactive(obj, force); } @@ -307,12 +426,17 @@ ErrCode Service::InitRestoreSession(sptr remote) HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); try { VerifyCaller(); - return session_->Active({ + ErrCode errCode = session_->Active({ .clientToken = IPCSkeleton::GetCallingTokenID(), .scenario = IServiceReverse::Scenario::RESTORE, .clientProxy = remote, .userId = GetUserIdDefault(), }); + if (errCode == 0) { + ClearFailedBundles(); + successBundlesNum_ = 0; + } + return errCode; } catch (const BError &e) { StopAll(nullptr, true); return e.GetCode(); @@ -333,12 +457,17 @@ ErrCode Service::InitBackupSession(sptr remote) int32_t oldSize = StorageMgrAdapter::UpdateMemPara(BConstants::BACKUP_VFS_CACHE_PRESSURE); HILOGE("InitBackupSession oldSize %{public}d", oldSize); session_->SetMemParaCurSize(oldSize); - return session_->Active({ + ErrCode errCode = session_->Active({ .clientToken = IPCSkeleton::GetCallingTokenID(), .scenario = IServiceReverse::Scenario::BACKUP, .clientProxy = remote, .userId = GetUserIdDefault(), }); + if (errCode == 0) { + ClearFailedBundles(); + successBundlesNum_ = 0; + } + return errCode; } catch (const BError &e) { StopAll(nullptr, true); return e.GetCode(); @@ -376,7 +505,7 @@ static bool SpecialVersion(const string &versionName) return false; } -static void OnBundleStarted(BError error, sptr session, const BundleName &bundleName) +void Service::OnBundleStarted(BError error, sptr session, const BundleName &bundleName) { IServiceReverse::Scenario scenario = session->GetScenario(); if (scenario == IServiceReverse::Scenario::RESTORE && BackupPara().GetBackupOverrideIncrementalRestore() && @@ -385,6 +514,7 @@ static void OnBundleStarted(BError error, sptr session, const } else if (scenario == IServiceReverse::Scenario::RESTORE) { session->GetServiceReverseProxy()->RestoreOnBundleStarted(error, bundleName); } + BundleBeginRadarReport(bundleName, error.GetCode(), scenario); } static vector GetRestoreBundleNames(UniqueFd fd, @@ -438,7 +568,7 @@ static vector GetRestoreBundleNames(UniqueFd fd, return restoreBundleInfos; } -static void HandleExceptionOnAppendBundles(sptr session, +void Service::HandleExceptionOnAppendBundles(sptr session, const vector &appendBundleNames, const vector &restoreBundleNames) { if (appendBundleNames.size() != restoreBundleNames.size()) { @@ -674,6 +804,8 @@ ErrCode Service::AppendBundlesBackupSession(const vector &bundleName if (info.allToBackup == false) { session_->GetServiceReverseProxy()->BackupOnBundleStarted( BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), bundleNameIndexInfo); + BundleBeginRadarReport(bundleNameIndexInfo, BError(BError::Codes::SA_FORBID_BACKUP_RESTORE).GetCode(), + IServiceReverse::Scenario::BACKUP); session_->RemoveExtInfo(bundleNameIndexInfo); } } @@ -747,6 +879,8 @@ void Service::HandleCurGroupBackupInfos(std::vector if (info.allToBackup == false) { session_->GetServiceReverseProxy()->BackupOnBundleStarted( BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), bundleNameIndexInfo); + BundleBeginRadarReport(bundleNameIndexInfo, BError(BError::Codes::SA_FORBID_BACKUP_RESTORE).GetCode(), + IServiceReverse::Scenario::BACKUP); session_->RemoveExtInfo(bundleNameIndexInfo); } BJsonUtil::BundleDetailInfo uniCastInfo; @@ -804,6 +938,12 @@ ErrCode Service::SAResultReport(const std::string bundleName, const std::string } else if (sennario == BackupRestoreScenario::INCREMENTAL_BACKUP) { session_->GetServiceReverseProxy()->IncrementalBackupOnResultReport(restoreRetInfo, bundleName); } + if (sennario == BackupRestoreScenario::FULL_RESTORE || sennario == BackupRestoreScenario::INCREMENTAL_RESTORE) { + BundleEndRadarReport(bundleName, errCode, IServiceReverse::Scenario::RESTORE); + } else if (sennario == BackupRestoreScenario::FULL_BACKUP || + sennario == BackupRestoreScenario::INCREMENTAL_BACKUP) { + BundleEndRadarReport(bundleName, errCode, IServiceReverse::Scenario::BACKUP); + } return SADone(errCode, bundleName); } @@ -894,6 +1034,7 @@ ErrCode Service::GetFileHandle(const string &bundleName, const string &fileName) BizStageRestore::BIZ_STAGE_GET_FILE_HANDLE_FAIL, errCode); } session_->GetServiceReverseProxy()->RestoreOnFileReady(bundleName, fileName, move(fd), errCode); + FileReadyRadarReport(bundleName, fileName, errCode, IServiceReverse::Scenario::RESTORE); } else { session_->SetExtFileNameRequest(bundleName, fileName); } @@ -918,15 +1059,6 @@ void Service::OnBackupExtensionDied(const string &&bundleName, bool isSecondCall OnAllBundlesFinished(BError(BError::Codes::OK)); return; } - int32_t errCode = BError(BError::Codes::EXT_ABILITY_DIED).GetCode(); - AppRadar::Info info (bundleName, "", ""); - if (session_->GetScenario() == IServiceReverse::Scenario::BACKUP) { - AppRadar::GetInstance().RecordBackupFuncRes(info, "Service::OnBackupExtensionDied", GetUserIdDefault(), - BizStageBackup::BIZ_STAGE_EXTENSION_ABNORMAL_EXIT, errCode); - } else if (session_->GetScenario() == IServiceReverse::Scenario::RESTORE) { - AppRadar::GetInstance().RecordRestoreFuncRes(info, "Service::OnBackupExtensionDied", GetUserIdDefault(), - BizStageRestore::BIZ_STAGE_EXTENSION_ABNORMAL_EXIT, errCode); - } try { string callName = move(bundleName); HILOGE("Backup <%{public}s> Extension Process Died", callName.c_str()); @@ -999,6 +1131,7 @@ void Service::ExtStart(const string &bundleName) if (scenario == IServiceReverse::Scenario::BACKUP) { auto ret = proxy->HandleBackup(session_->GetClearDataFlag(bundleName)); session_->GetServiceReverseProxy()->BackupOnBundleStarted(ret, bundleName); + BundleBeginRadarReport(bundleName, ret, scenario); if (ret) { ClearSessionAndSchedInfo(bundleName); NoticeClientFinish(bundleName, BError(BError::Codes::SA_INVAL_ARG)); @@ -1010,18 +1143,18 @@ void Service::ExtStart(const string &bundleName) } auto ret = proxy->HandleRestore(session_->GetClearDataFlag(bundleName)); session_->GetServiceReverseProxy()->RestoreOnBundleStarted(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); + FileReadyRadarReport(bundleName, fileName, errCode, scenario); } - return; } catch (...) { HILOGI("Unexpected exception, bundleName: %{public}s", bundleName.c_str()); ClearSessionAndSchedInfo(bundleName); NoticeClientFinish(bundleName, BError(BError::Codes::SA_INVAL_ARG)); - return; } } @@ -1046,18 +1179,21 @@ void Service::ReportOnExtConnectFailed(const IServiceReverse::Scenario scenario, } if (scenario == IServiceReverse::Scenario::BACKUP && session_->GetIsIncrementalBackup()) { session_->GetServiceReverseProxy()->IncrementalBackupOnBundleStarted(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); - + 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); + BundleBeginRadarReport(bundleName, ret, scenario); } else if (scenario == IServiceReverse::Scenario::RESTORE) { session_->GetServiceReverseProxy()->RestoreOnBundleStarted(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()); @@ -1074,14 +1210,6 @@ void Service::ExtConnectFailed(const string &bundleName, ErrCode ret) try { HILOGE("begin %{public}s", bundleName.data()); scenario = session_->GetScenario(); - AppRadar::Info info (bundleName, "", ""); - if (scenario == IServiceReverse::Scenario::BACKUP) { - AppRadar::GetInstance().RecordBackupFuncRes(info, "Service::ExtConnectFailed", GetUserIdDefault(), - BizStageBackup::BIZ_STAGE_CONNECT_EXTENSION_FAIL, ret); - } else if (scenario == IServiceReverse::Scenario::RESTORE) { - AppRadar::GetInstance().RecordRestoreFuncRes(info, "Service::ExtConnectFailed", GetUserIdDefault(), - BizStageRestore::BIZ_STAGE_CONNECT_EXTENSION_FAIL, ret); - } ReportOnExtConnectFailed(scenario, bundleName, ret); ClearSessionAndSchedInfo(bundleName); NoticeClientFinish(bundleName, BError(BError::Codes::EXT_ABILITY_DIED)); @@ -1114,6 +1242,7 @@ void Service::NoticeClientFinish(const string &bundleName, ErrCode errCode) } else if (scenario == IServiceReverse::Scenario::RESTORE) { session_->GetServiceReverseProxy()->RestoreOnBundleFinished(errCode, bundleName); }; + BundleEndRadarReport(bundleName, errCode, scenario); /* If all bundle ext process finish, notice client. */ OnAllBundlesFinished(BError(BError::Codes::OK)); } catch(const BError &e) { @@ -1458,10 +1587,10 @@ std::function Service::GetBackupInfoConnectDie }; } -void Service::ClearResidualBundleData(const std::string &bundleName) +ErrCode Service::ClearResidualBundleData(const std::string &bundleName) { if (session_ == nullptr) { - return; + return BError(BError::Codes::SA_INVAL_ARG); } auto backUpConnection = session_->GetExtConnection(bundleName); if (backUpConnection == nullptr) { @@ -1472,7 +1601,7 @@ void Service::ClearResidualBundleData(const std::string &bundleName) throw BError(BError::Codes::SA_INVAL_ARG, "Extension backup Proxy is empty"); } // 通知ext清理 - proxy->HandleClear(); + ErrCode res = proxy->HandleClear(); if (backUpConnection->IsExtAbilityConnected()) { backUpConnection->DisconnectBackupExtAbility(); } @@ -1481,6 +1610,7 @@ void Service::ClearResidualBundleData(const std::string &bundleName) if (session_->GetScenario() != IServiceReverse::Scenario::CLEAN) { OnAllBundlesFinished(BError(BError::Codes::OK)); } + return res; } ErrCode Service::GetBackupInfoCmdHandle(BundleName &bundleName, std::string &result) @@ -1723,6 +1853,7 @@ ErrCode Service::BackupSA(std::string bundleName) if (scenario == IServiceReverse::Scenario::BACKUP) { auto ret = saConnection->CallBackupSA(); session_->GetServiceReverseProxy()->BackupOnBundleStarted(ret, bundleName); + BundleBeginRadarReport(bundleName, ret, scenario); if (ret) { HILOGI("BackupSA ret is %{public}d", ret); ClearSessionAndSchedInfo(bundleName); @@ -1742,6 +1873,7 @@ void Service::OnSABackup(const std::string &bundleName, const int &fd, const std 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); + FileReadyRadarReport(bundleName, "", errCode, IServiceReverse::Scenario::BACKUP); SAResultReport(bundleName, result, errCode, BackupRestoreScenario::FULL_BACKUP); }; threadPool_.AddTask([task]() { @@ -1826,6 +1958,7 @@ void Service::NotifyCallerCurAppDone(ErrCode errCode, const std::string &callerN HILOGI("will notify clone data, scenario is Restore"); session_->GetServiceReverseProxy()->RestoreOnBundleFinished(errCode, callerName); } + BundleEndRadarReport(callerName, errCode, scenario); } ErrCode Service::ReportAppProcessInfo(const std::string processInfo, BackupRestoreScenario sennario) diff --git a/services/backup_sa/src/module_ipc/service_incremental.cpp b/services/backup_sa/src/module_ipc/service_incremental.cpp index 0d643218c829747456321387cca0a6beda86f49d..c889096769e9df482d2bef6f1cd9b6fe4c39eca4 100644 --- a/services/backup_sa/src/module_ipc/service_incremental.cpp +++ b/services/backup_sa/src/module_ipc/service_incremental.cpp @@ -275,11 +275,16 @@ ErrCode Service::InitIncrementalBackupSession(sptr remote) HILOGE("Init Incremental backup session error, session is empty"); return BError(BError::Codes::SA_INVAL_ARG); } - return session_->Active({.clientToken = IPCSkeleton::GetCallingTokenID(), - .scenario = IServiceReverse::Scenario::BACKUP, - .clientProxy = remote, - .userId = GetUserIdDefault(), - .isIncrementalBackup = true}); + ErrCode errCode = session_->Active({.clientToken = IPCSkeleton::GetCallingTokenID(), + .scenario = IServiceReverse::Scenario::BACKUP, + .clientProxy = remote, + .userId = GetUserIdDefault(), + .isIncrementalBackup = true}); + if (errCode == 0) { + ClearFailedBundles(); + successBundlesNum_ = 0; + } + return errCode; } catch (const BError &e) { StopAll(nullptr, true); return e.GetCode(); @@ -318,6 +323,8 @@ ErrCode Service::AppendBundlesIncrementalBackupSession(const std::vectorGetServiceReverseProxy()->IncrementalBackupOnBundleStarted( BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), bundleNameIndexInfo); + BundleBeginRadarReport(bundleNameIndexInfo, BError(BError::Codes::SA_FORBID_BACKUP_RESTORE).GetCode(), + IServiceReverse::Scenario::BACKUP); session_->RemoveExtInfo(bundleNameIndexInfo); } } @@ -390,6 +397,8 @@ void Service::HandleCurGroupIncBackupInfos(vector & if (info.allToBackup == false) { session_->GetServiceReverseProxy()->IncrementalBackupOnBundleStarted( BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), bundleNameIndexInfo); + BundleBeginRadarReport(bundleNameIndexInfo, BError(BError::Codes::SA_FORBID_BACKUP_RESTORE).GetCode(), + IServiceReverse::Scenario::BACKUP); session_->RemoveExtInfo(bundleNameIndexInfo); } BJsonUtil::BundleDetailInfo uniCastInfo; @@ -465,6 +474,7 @@ ErrCode Service::AppIncrementalFileReady(const std::string &fileName, UniqueFd f if (session_->GetScenario() == IServiceReverse::Scenario::RESTORE) { session_->GetServiceReverseProxy()->IncrementalRestoreOnFileReady(callerName, fileName, move(fd), move(manifestFd), errCode); + FileReadyRadarReport(callerName, fileName, errCode, IServiceReverse::Scenario::RESTORE); return BError(BError::Codes::OK); } if (fileName == BConstants::EXT_BACKUP_MANAGE) { @@ -473,6 +483,7 @@ ErrCode Service::AppIncrementalFileReady(const std::string &fileName, UniqueFd f HILOGD("reverse: Will notify IncrementalBackupOnFileReady"); session_->GetServiceReverseProxy()->IncrementalBackupOnFileReady(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) }; HiAudit::GetInstance(true).Write(auditLog); @@ -491,6 +502,7 @@ ErrCode Service::AppIncrementalFileReady(const std::string &fileName, UniqueFd f HILOGI("reverse: Will notify IncrementalBackupOnBundleFinished"); session_->GetServiceReverseProxy()->IncrementalBackupOnBundleFinished(BError(BError::Codes::OK), callerName); + BundleEndRadarReport(callerName, BError(BError::Codes::OK), IServiceReverse::Scenario::BACKUP); // 断开extension backUpConnection->DisconnectBackupExtAbility(); ClearSessionAndSchedInfo(callerName); @@ -573,8 +585,8 @@ ErrCode Service::GetIncrementalFileHandle(const std::string &bundleName, const s HILOGE("GetIncrementalFileHandle error, Extension backup Proxy is empty"); return BError(BError::Codes::SA_INVAL_ARG); } - int res = proxy->GetIncrementalFileHandle(fileName); - if (res) { + ErrCode res = proxy->GetIncrementalFileHandle(fileName); + if (res != ERR_OK) { HILOGE("Failed to extension file handle"); AppRadar::Info info (bundleName, "", ""); AppRadar::GetInstance().RecordRestoreFuncRes(info, "Service::GetIncrementalFileHandle", @@ -611,6 +623,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); + BundleBeginRadarReport(bundleName, ret, IServiceReverse::Scenario::BACKUP); if (ret) { ClearSessionAndSchedInfo(bundleName); NoticeClientFinish(bundleName, BError(BError::Codes::EXT_ABILITY_DIED)); @@ -620,6 +633,7 @@ bool Service::IncrementalBackup(const string &bundleName) session_->ValidRestoreDataType(RestoreTypeEnum::RESTORE_DATA_WAIT_SEND)) { auto ret = proxy->HandleRestore(session_->GetClearDataFlag(bundleName)); session_->GetServiceReverseProxy()->IncrementalRestoreOnBundleStarted(ret, bundleName); + BundleBeginRadarReport(bundleName, ret, IServiceReverse::Scenario::RESTORE); auto fileNameVec = session_->GetExtFileNameRequest(bundleName); for (auto &fileName : fileNameVec) { ret = proxy->GetIncrementalFileHandle(fileName); @@ -638,6 +652,7 @@ void Service::NotifyCallerCurAppIncrementDone(ErrCode errCode, const std::string if (scenario == IServiceReverse::Scenario::BACKUP) { HILOGI("will notify clone data, scenario is incremental backup"); session_->GetServiceReverseProxy()->IncrementalBackupOnBundleFinished(errCode, callerName); + BundleEndRadarReport(callerName, errCode, scenario); 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()); @@ -655,6 +670,7 @@ void Service::NotifyCallerCurAppIncrementDone(ErrCode errCode, const std::string HILOGI("will notify clone data, scenario is Restore"); SendEndAppGalleryNotify(callerName); session_->GetServiceReverseProxy()->IncrementalRestoreOnBundleFinished(errCode, callerName); + BundleEndRadarReport(callerName, errCode, scenario); } } diff --git a/services/backup_sa/src/module_ipc/sub_service.cpp b/services/backup_sa/src/module_ipc/sub_service.cpp index 2e85358892a75cf5745c1814d6f859a7981d6d29..7798384122ed85a689e818fda91e58724621282f 100644 --- a/services/backup_sa/src/module_ipc/sub_service.cpp +++ b/services/backup_sa/src/module_ipc/sub_service.cpp @@ -136,6 +136,7 @@ ErrCode Service::AppFileReady(const string &fileName, UniqueFd fd, int32_t errCo fd = session_->OnBundleExtManageInfo(callerName, move(fd)); } session_->GetServiceReverseProxy()->BackupOnFileReady(callerName, fileName, move(fd), errCode); + FileReadyRadarReport(callerName, fileName, errCode, session_->GetScenario()); AuditLog auditLog = { false, "Backup File Ready", "ADD", "", 1, "SUCCESS", "AppFileReady", callerName, GetAnonyPath(fileName) }; HiAudit::GetInstance(true).Write(auditLog); @@ -157,6 +158,7 @@ ErrCode Service::AppFileReady(const string &fileName, UniqueFd fd, int32_t errCo session_->StopExtTimer(callerName); // 通知TOOL 备份完成 session_->GetServiceReverseProxy()->BackupOnBundleFinished(BError(BError::Codes::OK), callerName); + BundleEndRadarReport(callerName, BError(BError::Codes::OK), session_->GetScenario()); // 断开extension backUpConnection->DisconnectBackupExtAbility(); ClearSessionAndSchedInfo(callerName); @@ -255,6 +257,7 @@ ErrCode Service::LaunchBackupExtension(const BundleName &bundleName) ErrCode ret = backUpConnection->ConnectBackupExtAbility(want, session_->GetSessionUserId()); if (ret) { HILOGE("ConnectBackupExtAbility faild, bundleName:%{public}s, ret:%{public}d", bundleName.c_str(), ret); + ExtensionConnectFailRadarReport(bundleName, ret, scenario); return BError(BError::Codes::SA_BOOT_EXT_FAIL); } return BError(BError::Codes::OK); 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 a809082f08d311e72ee0a65e59633cfba35ba251..f84668de14ea2615b8674c319430f1e8e10ec798 100644 --- a/services/backup_sa/src/module_ipc/svc_session_manager.cpp +++ b/services/backup_sa/src/module_ipc/svc_session_manager.cpp @@ -109,6 +109,14 @@ void SvcSessionManager::Deactive(const wptr &remoteInAction, bool } deathRecipient_ = nullptr; + AppRadar::Info info("", "", "deactive session success"); + if (impl_.scenario == IServiceReverse::Scenario::RESTORE) { + AppRadar::GetInstance().RecordRestoreFuncRes(info, "SvcSessionManager::Deactive", impl_.userId, + BizStageRestore::BIZ_STAGE_DEACTIVE_SESSION, ERR_OK); + } else if (impl_.scenario == IServiceReverse::Scenario::BACKUP) { + AppRadar::GetInstance().RecordBackupFuncRes(info, "SvcSessionManager::Deactive", impl_.userId, + BizStageBackup::BIZ_STAGE_DEACTIVE_SESSION, ERR_OK); + } HILOGI("Succeed to deactive a session"); impl_ = {}; extConnectNum_ = 0; @@ -368,15 +376,18 @@ void SvcSessionManager::InitClient(Impl &newImpl) HILOGW("It's curious that the backup sa dies before the backup client"); return; } - AppRadar::Info info ("", "", "client died"); - AppRadar::GetInstance().RecordDefaultFuncRes(info, "SvcSessionManager::InitClient", - AppRadar::GetInstance().GetUserId(), - BizStageBackup::BIZ_STAGE_CLIENT_ABNORMAL_EXIT, - BError(BError::Codes::SA_BROKEN_IPC).GetCode()); (void)revPtrStrong->SessionDeactive(); }; deathRecipient_ = sptr(new SvcDeathRecipient(callback)); remoteObj->AddDeathRecipient(deathRecipient_); + AppRadar::Info info("", "", "active session success"); + if (newImpl.scenario == IServiceReverse::Scenario::RESTORE) { + AppRadar::GetInstance().RecordRestoreFuncRes(info, "SvcSessionManager::InitClient", newImpl.userId, + BizStageRestore::BIZ_STAGE_ACTIVE_SESSION, ERR_OK); + } else if (newImpl.scenario == IServiceReverse::Scenario::BACKUP) { + AppRadar::GetInstance().RecordBackupFuncRes(info, "SvcSessionManager::InitClient", newImpl.userId, + BizStageBackup::BIZ_STAGE_ACTIVE_SESSION, ERR_OK); + } HILOGI("Succeed to active a session"); } diff --git a/services/backup_sa/src/module_sched/sched_scheduler.cpp b/services/backup_sa/src/module_sched/sched_scheduler.cpp index 8d85731b3f3e1d6d8cd2a5f723f7bfbe75b03525..efcfb24d6329383f4989b9eff341440a7ff4c6d6 100644 --- a/services/backup_sa/src/module_sched/sched_scheduler.cpp +++ b/services/backup_sa/src/module_sched/sched_scheduler.cpp @@ -29,6 +29,7 @@ #include "b_error/b_error.h" #include "b_ohos/startup/backup_para.h" +#include "b_radar/b_radar.h" #include "filemgmt_libhilog.h" #include "iservice_registry.h" #include "module_external/bms_adapter.h" diff --git a/tests/mock/module_ipc/service_mock.cpp b/tests/mock/module_ipc/service_mock.cpp index d2cc3ba158ff722e7a9d3b87f716f0f3c8fe3b77..9c1fc72f27a924bf05388162292b689c3d24ba21 100644 --- a/tests/mock/module_ipc/service_mock.cpp +++ b/tests/mock/module_ipc/service_mock.cpp @@ -250,8 +250,9 @@ void Service::OnSABackup(const std::string &bundleName, void Service::OnSARestore(const std::string &bundleName, const std::string &result, const ErrCode &errCode) {} -void Service::ClearResidualBundleData(const std::string &bundleName) +ErrCode Service::ClearResidualBundleData(const std::string &bundleName) { + return BError(BError::Codes::OK); } std::shared_ptr Service::GetExtensionMutex(const BundleName &bundleName) @@ -263,6 +264,27 @@ void Service::RemoveExtensionMutex(const BundleName &bundleName) { } +void Service::OnBundleStarted(BError error, sptr session, const BundleName &bundleName) {} + +void Service::HandleExceptionOnAppendBundles(sptr session, + const vector &appendBundleNames, const vector &restoreBundleNames) {} + +void Service::BundleBeginRadarReport(const std::string &bundleName, const ErrCode errCode, + const IServiceReverse::Scenario scenario) {} + +void Service::BundleEndRadarReport(const std::string &bundleName, const ErrCode errCode, + const IServiceReverse::Scenario scenario) {} + +void Service::FileReadyRadarReport(const std::string &bundleName, const std::string &fileName, const ErrCode errCode, + const IServiceReverse::Scenario scenario) {} + +void Service::ExtensionConnectFailRadarReport(const std::string &bundleName, const ErrCode errCode, + const IServiceReverse::Scenario scenario) {} + +void Service::UpdateFailedBundles(const std::string &bundleName, BundleTaskInfo taskInfo) {} + +void Service::ClearFailedBundles() {} + void Service::CreateDirIfNotExist(const std::string &path) { } 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 dff5599bc07d449216a3689a1e1284e2dda3a3f8..4cad2e71b188a10cdae89d4a675036c2a1857fc8 100644 --- a/tests/unittests/backup_sa/module_ipc/service_incremental_test.cpp +++ b/tests/unittests/backup_sa/module_ipc/service_incremental_test.cpp @@ -221,6 +221,27 @@ bool SvcRestoreDepsManager::UpdateToRestoreBundleMap(const string&, const string { return true; } + +void Service::OnBundleStarted(BError error, sptr session, const BundleName &bundleName) {} + +void Service::HandleExceptionOnAppendBundles(sptr session, + const vector &appendBundleNames, const vector &restoreBundleNames) {} + +void Service::BundleBeginRadarReport(const std::string &bundleName, const ErrCode errCode, + const IServiceReverse::Scenario scenario) {} + +void Service::BundleEndRadarReport(const std::string &bundleName, const ErrCode errCode, + const IServiceReverse::Scenario scenario) {} + +void Service::FileReadyRadarReport(const std::string &bundleName, const std::string &fileName, const ErrCode errCode, + const IServiceReverse::Scenario scenario) {} + +void Service::ExtensionConnectFailRadarReport(const std::string &bundleName, const ErrCode errCode, + const IServiceReverse::Scenario scenario) {} + +void Service::UpdateFailedBundles(const std::string &bundleName, BundleTaskInfo taskInfo) {} + +void Service::ClearFailedBundles() {} } // namespace OHOS::FileManagement::Backup namespace OHOS::FileManagement::Backup { 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 2d964a2f566f7ae379b3f67c51b7bb7d347dd513..eb841c48de38efda7851d91be4cbd7b93653ee1b 100644 --- a/tests/unittests/backup_sa/module_ipc/service_other_test.cpp +++ b/tests/unittests/backup_sa/module_ipc/service_other_test.cpp @@ -621,14 +621,14 @@ HWTEST_F(ServiceTest, SUB_Service_OnBundleStarted_0100, TestSize.Level1) sptr session_ = service->session_; BundleName bundleName; EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::UNDEFINED)); - OnBundleStarted(error, session_, bundleName); + service->OnBundleStarted(error, session_, bundleName); EXPECT_TRUE(true); 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()); - OnBundleStarted(error, session_, bundleName); + service->OnBundleStarted(error, session_, bundleName); EXPECT_TRUE(true); EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE)); @@ -636,7 +636,7 @@ HWTEST_F(ServiceTest, SUB_Service_OnBundleStarted_0100, TestSize.Level1) EXPECT_CALL(*session, ValidRestoreDataType(_)).WillOnce(Return(false)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); EXPECT_CALL(*srProxy, RestoreOnBundleStarted(_, _)).WillOnce(Return()); - OnBundleStarted(error, session_, bundleName); + service->OnBundleStarted(error, session_, bundleName); EXPECT_TRUE(true); EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE)); @@ -644,7 +644,7 @@ HWTEST_F(ServiceTest, SUB_Service_OnBundleStarted_0100, TestSize.Level1) EXPECT_CALL(*session, ValidRestoreDataType(_)).WillOnce(Return(true)); EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); EXPECT_CALL(*srProxy, IncrementalRestoreOnBundleStarted(_, _)).WillOnce(Return()); - OnBundleStarted(error, session_, bundleName); + service->OnBundleStarted(error, session_, bundleName); EXPECT_TRUE(true); } catch (...) { EXPECT_TRUE(false); @@ -694,12 +694,12 @@ HWTEST_F(ServiceTest, SUB_Service_HandleExceptionOnAppendBundles_0100, TestSize. vector appendBundleNames { "bundleName" }; vector restoreBundleNames; EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::UNDEFINED)); - HandleExceptionOnAppendBundles(service->session_, appendBundleNames, restoreBundleNames); + service->HandleExceptionOnAppendBundles(service->session_, appendBundleNames, restoreBundleNames); EXPECT_TRUE(true); restoreBundleNames.emplace_back("bundleName"); restoreBundleNames.emplace_back("bundleName2"); - HandleExceptionOnAppendBundles(service->session_, appendBundleNames, restoreBundleNames); + service->HandleExceptionOnAppendBundles(service->session_, appendBundleNames, restoreBundleNames); EXPECT_TRUE(true); } catch (...) { EXPECT_TRUE(false); @@ -765,6 +765,7 @@ HWTEST_F(ServiceTest, SUB_Service_AppendBundlesRestoreSession_0200, TestSize.Lev service->isOccupyingSession_.store(false); service->session_ = sptr(new SvcSessionManager(wptr(service))); EXPECT_CALL(*param, GetBackupDebugOverrideAccount()) + .WillOnce(Return(make_pair(true, DEBUG_ID + 1))) .WillOnce(Return(make_pair(true, DEBUG_ID + 1))); EXPECT_CALL(*skeleton, GetCallingTokenID()).WillOnce(Return(0)).WillOnce(Return(0)); EXPECT_CALL(*token, GetTokenType(_)).WillOnce(Return(Security::AccessToken::ATokenTypeEnum::TOKEN_SHELL)); diff --git a/tests/unittests/backup_sa/module_ipc/service_test.cpp b/tests/unittests/backup_sa/module_ipc/service_test.cpp index 7f7ef75eca9ed0b74ebad47b3b868f121e0427c5..6a83d2469ccc391a509daa8f928dab3fe88a63e0 100644 --- a/tests/unittests/backup_sa/module_ipc/service_test.cpp +++ b/tests/unittests/backup_sa/module_ipc/service_test.cpp @@ -1271,11 +1271,11 @@ HWTEST_F(ServiceTest, SUB_Service_OnBundleStarted_0100, testing::ext::TestSize.L wptr reversePtr(new Service(saID)); sptr session(new SvcSessionManager(reversePtr)); EXPECT_TRUE(servicePtr_ != nullptr); - OnBundleStarted(BError(BError::Codes::SA_INVAL_ARG), session, BUNDLE_NAME); + servicePtr_->OnBundleStarted(BError(BError::Codes::SA_INVAL_ARG), session, BUNDLE_NAME); SvcSessionManager::Impl impl_; impl_.clientToken = 1; impl_.scenario = IServiceReverse::Scenario::RESTORE; - OnBundleStarted(BError(BError::Codes::SA_INVAL_ARG), session, BUNDLE_NAME); + servicePtr_->OnBundleStarted(BError(BError::Codes::SA_INVAL_ARG), session, BUNDLE_NAME); } catch (...) { EXPECT_TRUE(false); GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by OnBundleStarted."; @@ -1302,14 +1302,14 @@ HWTEST_F(ServiceTest, SUB_Service_HandleExceptionOnAppendBundles_0100, testing:: vector appendBundleNames {"123456"}; vector restoreBundleNames {"abcdef"}; EXPECT_TRUE(servicePtr_ != nullptr); - HandleExceptionOnAppendBundles(session, appendBundleNames, restoreBundleNames); + servicePtr_->HandleExceptionOnAppendBundles(session, appendBundleNames, restoreBundleNames); appendBundleNames.push_back("789"); - HandleExceptionOnAppendBundles(session, appendBundleNames, restoreBundleNames); + servicePtr_->HandleExceptionOnAppendBundles(session, appendBundleNames, restoreBundleNames); restoreBundleNames.push_back("123456"); restoreBundleNames.push_back("123"); - HandleExceptionOnAppendBundles(session, appendBundleNames, restoreBundleNames); + servicePtr_->HandleExceptionOnAppendBundles(session, appendBundleNames, restoreBundleNames); } catch (...) { EXPECT_TRUE(false); GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by HandleExceptionOnAppendBundles."; 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 c83e50594d786e99ca1067c4ca35380709a7c0c4..a4453bce6cb0a9270acb7e4fcacb909148319dcf 100644 --- a/tests/unittests/backup_sa/module_ipc/sub_service_test.cpp +++ b/tests/unittests/backup_sa/module_ipc/sub_service_test.cpp @@ -210,7 +210,7 @@ HWTEST_F(ServiceTest, SUB_Service_LaunchBackupSAExtension_0000, TestSize.Level1) EXPECT_CALL(*session, GetBackupExtInfo(_)).WillOnce(Return("")); EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE)); - EXPECT_CALL(*saUtils, IsSABundleName(_)).WillOnce(Return(true)); + EXPECT_CALL(*saUtils, IsSABundleName(_)).WillOnce(Return(true)).WillOnce(Return(true)); EXPECT_CALL(*session, GetSAExtConnection(_)).WillOnce(Return(sa)); EXPECT_CALL(*saConnect, ConnectBackupSAExt(_, _, _)).WillOnce(Return(BError(BError::Codes::OK).GetCode())); ret = service->LaunchBackupSAExtension(bundleName); @@ -314,6 +314,7 @@ HWTEST_F(ServiceTest, SUB_Service_GetFileHandle_0100, TestSize.Level1) EXPECT_CALL(*connect, GetBackupExtProxy()).WillOnce(Return(svcProxy)); EXPECT_CALL(*svcProxy, GetFileHandle(_, _)).WillOnce(DoAll(SetArgReferee<1>(1), Return(UniqueFd(-1)))); EXPECT_CALL(*param, GetBackupDebugOverrideAccount()) + .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()); @@ -359,18 +360,6 @@ HWTEST_F(ServiceTest, SUB_Service_OnBackupExtensionDied_0000, TestSize.Level1) service->OnBackupExtensionDied("", false); EXPECT_TRUE(true); - EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::BACKUP)) - .WillOnce(Return(IServiceReverse::Scenario::UNDEFINED)) - .WillOnce(Return(IServiceReverse::Scenario::UNDEFINED)) - .WillOnce(Return(IServiceReverse::Scenario::UNDEFINED)); - EXPECT_CALL(*param, GetBackupDebugOverrideAccount()) - .WillOnce(Return(make_pair(true, DEBUG_ID + 1))); - EXPECT_CALL(*session, StopFwkTimer(_)).WillOnce(Return(true)); - EXPECT_CALL(*session, StopExtTimer(_)).WillOnce(Return(true)); - EXPECT_CALL(*session, GetExtConnection(_)).WillOnce(Return(nullptr)); - EXPECT_CALL(*cdConfig, DeleteClearBundleRecord(_)).WillOnce(Return(true)); - EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(false)); - service->OnBackupExtensionDied("", false); } catch (...) { EXPECT_TRUE(false); GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by OnBackupExtensionDied."; @@ -398,6 +387,7 @@ HWTEST_F(ServiceTest, SUB_Service_OnBackupExtensionDied_0100, TestSize.Level1) .WillOnce(Return(IServiceReverse::Scenario::UNDEFINED)) .WillOnce(Return(IServiceReverse::Scenario::UNDEFINED)); EXPECT_CALL(*param, GetBackupDebugOverrideAccount()) + .WillOnce(Return(make_pair(true, DEBUG_ID + 1))) .WillOnce(Return(make_pair(true, DEBUG_ID + 1))); EXPECT_CALL(*session, StopFwkTimer(_)).WillOnce(Return(true)); EXPECT_CALL(*session, StopExtTimer(_)).WillOnce(Return(true)); @@ -953,7 +943,9 @@ HWTEST_F(ServiceTest, SUB_Service_HandleRestoreDepsBundle_0000, TestSize.Level1) bundleInfos.clear(); bundleInfos = {{.name = "bundleName"}}; - EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE)); + EXPECT_CALL(*session, GetScenario()) + .WillOnce(Return(IServiceReverse::Scenario::RESTORE)) + .WillOnce(Return(IServiceReverse::Scenario::RESTORE)); EXPECT_CALL(*depManager, GetRestoreBundleMap()).WillOnce(Return(bundleMap)); EXPECT_CALL(*depManager, GetAllBundles()).WillOnce(Return(bundleInfos)); service->HandleRestoreDepsBundle(bundleName); diff --git a/utils/include/b_error/b_error.h b/utils/include/b_error/b_error.h index 4cded015bb8f53cc90a51bb1079b6bd0c7b398d0..3863761c7c09fd2713dacd438f0f477b1ce9945a 100644 --- a/utils/include/b_error/b_error.h +++ b/utils/include/b_error/b_error.h @@ -116,6 +116,7 @@ public: E_EXCEPTION = 13500007, E_UNPACKET = 13500008, E_BEF = 13500009, + E_TASKFAIL = 13500010, }; public: diff --git a/utils/include/b_radar/b_radar.h b/utils/include/b_radar/b_radar.h index 226e0ece4186c82ab359383a63d6cc96e86ba3ac..9bf798493280064a1cb7f702640ef55a75db7bf5 100644 --- a/utils/include/b_radar/b_radar.h +++ b/utils/include/b_radar/b_radar.h @@ -17,6 +17,7 @@ #define OHOS_FILEMGMT_BACKUP_B_RADAR_H #include #include +#include "i_service_reverse.h" namespace OHOS::FileManagement::Backup { enum class BizStageBackup : int32_t { @@ -26,15 +27,20 @@ enum class BizStageBackup : int32_t { BIZ_STAGE_CREATE_BACKUP_SESSION_FAIL, BIZ_STAGE_APPEND_BUNDLES_FAIL, BIZ_STAGE_CONNECT_EXTENSION_FAIL, - BIZ_STAGE_START_DISPOSE_FAIL, - BIZ_STAGE_EXTENSION_ABNORMAL_EXIT, + BIZ_STAGE_START_DISPOSE, + BIZ_STAGE_EXTENSION_ABNORMAL_EXIT_CLEAR_FAIL, BIZ_STAGE_GET_BACKUP_INFO_FAIL, BIZ_STAGE_ON_BACKUP, BIZ_STAGE_DO_BACKUP, BIZ_STAGE_CHECK_DATA_FAIL, - BIZ_STAGE_END_DISPOSE_FAIL, - BIZ_STAGE_CLIENT_ABNORMAL_EXIT, - BIZ_STAGE_PERMISSION_CHECK_FAIL + BIZ_STAGE_END_DISPOSE, + BIZ_STAGE_PERMISSION_CHECK_FAIL, + BIZ_STAGE_EXECU_FAIL, + BIZ_STAGE_ACTIVE_SESSION, + BIZ_STAGE_DEACTIVE_SESSION, + BIZ_STAGE_RELEASE, + BIZ_STAGE_ONSTART_DISPOSE, + BIZ_STAGE_ONSTART_RESIDUAL }; enum class BizStageRestore : int32_t { @@ -44,15 +50,20 @@ enum class BizStageRestore : int32_t { BIZ_STAGE_CREATE_RESTORE_SESSION_FAIL, BIZ_STAGE_APPEND_BUNDLES_FAIL, BIZ_STAGE_CONNECT_EXTENSION_FAIL, - BIZ_STAGE_START_DISPOSE_FAIL, - BIZ_STAGE_EXTENSION_ABNORMAL_EXIT, + BIZ_STAGE_START_DISPOSE, + BIZ_STAGE_EXTENSION_ABNORMAL_EXIT_CLEAR_FAIL, BIZ_STAGE_GET_FILE_HANDLE_FAIL, BIZ_STAGE_DO_RESTORE, BIZ_STAGE_CHECK_DATA_FAIL, BIZ_STAGE_ON_RESTORE, - BIZ_STAGE_END_DISPOSE_FAIL, - BIZ_STAGE_CLIENT_ABNORMAL_EXIT, - BIZ_STAGE_PERMISSION_CHECK_FAIL + BIZ_STAGE_END_DISPOSE, + BIZ_STAGE_PERMISSION_CHECK_FAIL, + BIZ_STAGE_EXECU_FAIL, + BIZ_STAGE_ACTIVE_SESSION, + BIZ_STAGE_DEACTIVE_SESSION, + BIZ_STAGE_RELEASE, + BIZ_STAGE_ONSTART_DISPOSE, + BIZ_STAGE_ONSTART_RESIDUAL }; class AppRadar { diff --git a/utils/include/b_resources/b_constants.h b/utils/include/b_resources/b_constants.h index 447cde28b8b02f1a7eff64ca4b5d276661f5de9c..548b7000c8f88875ab016ceb92722ebc4898c5f5 100644 --- a/utils/include/b_resources/b_constants.h +++ b/utils/include/b_resources/b_constants.h @@ -229,8 +229,11 @@ const std::string UNICAST_TYPE = "unicast"; // 雷达打点引用到的常量 constexpr int32_t MS_1000 = 1000; +constexpr int32_t MAX_TIME_COST = 900000; +constexpr int32_t MAX_INEXCLUDE_SIZE = 25; constexpr uint8_t INDEX = 3; static inline std::string FILE_BACKUP_RESTORE_EVENTS = "FILE_BACKUP_RESTORE_EVENTS"; +static inline std::string FILE_BACKUP_RESTORE_STATISTIC = "FILE_BACKUP_RESTORE_STATISTIC"; } // namespace OHOS::FileManagement::Backup::BConstants #endif // OHOS_FILEMGMT_BACKUP_B_CONSTANTS_H diff --git a/utils/src/b_radar/b_radar.cpp b/utils/src/b_radar/b_radar.cpp index 31ef80f3df37c713bea1937c7d336221d33aa92a..1316310e04abf32c7bff25ad0b6c17a10b8ca444 100644 --- a/utils/src/b_radar/b_radar.cpp +++ b/utils/src/b_radar/b_radar.cpp @@ -39,7 +39,7 @@ void AppRadar::RecordDefaultFuncRes(Info &info, const std::string &func, int32_t enum BizStageBackup bizStage, int32_t resultCode) { std::stringstream ss; - ss << "{\"result_info\": {" << info.resInfo << "}}"; + ss << R"("result_info": {)" << info.resInfo << "}}"; HiSysEventWrite( OHOS::HiviewDFX::HiSysEvent::Domain::FILEMANAGEMENT, BConstants::FILE_BACKUP_RESTORE_EVENTS, @@ -60,7 +60,7 @@ void AppRadar::RecordBackupFuncRes(Info &info, const std::string &func, int32_t enum BizStageBackup bizStage, int32_t resultCode) { std::stringstream ss; - ss << "{\"result_info\": {" << info.resInfo << "}}"; + ss << R"("result_info": {)" << info.resInfo << "}}"; HiSysEventWrite( OHOS::HiviewDFX::HiSysEvent::Domain::FILEMANAGEMENT, BConstants::FILE_BACKUP_RESTORE_EVENTS, @@ -81,7 +81,7 @@ void AppRadar::RecordRestoreFuncRes(Info &info, const std::string &func, int32_t enum BizStageRestore bizStage, int32_t resultCode) { std::stringstream ss; - ss << "{\"result_info\": {" << info.resInfo << "}}"; + ss << R"("result_info": {)" << info.resInfo << "}}"; HiSysEventWrite( OHOS::HiviewDFX::HiSysEvent::Domain::FILEMANAGEMENT, BConstants::FILE_BACKUP_RESTORE_EVENTS,