From 88c243462acd9e41caab40916f8a4f2e61d29914 Mon Sep 17 00:00:00 2001 From: chensihan Date: Mon, 28 Oct 2024 10:31:52 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=90=8C=E6=AD=A5=20Sign?= =?UTF-8?q?ed-off-by:=20chensihan=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../native/backup_ext/include/ext_extension.h | 16 ++++++++-------- .../impl/b_incremental_restore_session.h | 1 - .../impl/b_incremental_session_restore_async.h | 11 +++++++---- .../b_session_restore_async_mock.cpp | 2 -- .../mock/backup_kit_inner/service_proxy_mock.cpp | 7 +++++-- tests/moduletests/backup_kit_inner/BUILD.gn | 6 ------ .../b_session_restore_async_test.cpp | 7 ------- .../backup_kit_inner/b_session_restore_test.cpp | 6 ------ .../backup_impl/include/i_service_mock.h | 2 +- utils/include/b_json/b_json_entity_caps.h | 11 +++++------ 10 files changed, 26 insertions(+), 43 deletions(-) diff --git a/frameworks/native/backup_ext/include/ext_extension.h b/frameworks/native/backup_ext/include/ext_extension.h index 2d9c56ba2..7002a49c3 100644 --- a/frameworks/native/backup_ext/include/ext_extension.h +++ b/frameworks/native/backup_ext/include/ext_extension.h @@ -217,30 +217,30 @@ private: void StartFwkTimer(bool &isFwkStart); /** - * @brief get increCallbackEx for execute onRestore with string param + * @brief get callbackEx for execute onRestore * - * @param errCode + * @param obj */ std::function IncreOnRestoreExCallback(wptr obj); /** * @brief get increCallback for execute onRestore with string param * - * @param errCode + * @param obj */ std::function IncreOnRestoreCallback(wptr obj); /** * @brief get callback for execute onRestore with string param * - * @param errCode + * @param obj */ std::function OnRestoreCallback(wptr obj); /** - * @brief get callbackEx for execute onRestore with string param + * @brief get increCallbackEx for execute onRestore with string param * - * @param errCode + * @param obj */ std::function OnRestoreExCallback(wptr obj); @@ -322,8 +322,8 @@ private: std::mutex onStartTimeLock_; AppRadar::DoRestoreInfo radarRestoreInfo_ { 0 }; OHOS::ThreadPool onProcessTaskPool_; - std::atomic isFirstCallOnProcess_ { false }; - std::atomic isExecAppDone_ { false }; + std::atomic isFirstCallOnProcess_ {false}; + std::atomic isExecAppDone_ {false}; BackupRestoreScenario curScenario_ { BackupRestoreScenario::FULL_BACKUP }; }; diff --git a/interfaces/inner_api/native/backup_kit_inner/impl/b_incremental_restore_session.h b/interfaces/inner_api/native/backup_kit_inner/impl/b_incremental_restore_session.h index 2a4d6c2ff..3a2e2ec5f 100644 --- a/interfaces/inner_api/native/backup_kit_inner/impl/b_incremental_restore_session.h +++ b/interfaces/inner_api/native/backup_kit_inner/impl/b_incremental_restore_session.h @@ -93,7 +93,6 @@ public: * * @param remoteCap 已打开的保存远端设备能力的Json文件。可使用GetLocalCapabilities方法获取 * @param bundlesToRestore 待恢复的应用清单 - * * @return ErrCode 规范错误码 */ ErrCode AppendBundles(UniqueFd remoteCap, std::vector bundlesToRestore); diff --git a/interfaces/inner_api/native/backup_kit_inner/impl/b_incremental_session_restore_async.h b/interfaces/inner_api/native/backup_kit_inner/impl/b_incremental_session_restore_async.h index 8405b9b88..fc705c6f6 100644 --- a/interfaces/inner_api/native/backup_kit_inner/impl/b_incremental_session_restore_async.h +++ b/interfaces/inner_api/native/backup_kit_inner/impl/b_incremental_session_restore_async.h @@ -79,12 +79,15 @@ public: * * @param remoteCap 已打开的保存远端设备能力的Json文件。可使用GetLocalCapabilities方法获取 * @param bundlesToRestore 待恢复的应用清单 + * @param detailInfos bundle的单双映射关系json串 * @param userId 用户ID * @return ErrCode 规范错误码 - */ - ErrCode AppendBundles(UniqueFd remoteCap, std::vector bundlesToRestore, - std::vector detailInfos, RestoreTypeEnum restoreType = RestoreTypeEnum::RESTORE_DATA_WAIT_SEND, - int32_t userId = DEFAULT_INVAL_VALUE); + */ + ErrCode AppendBundles(UniqueFd remoteCap, + std::vector bundlesToRestore, + std::vector detailInfos, + RestoreTypeEnum restoreType = RestoreTypeEnum::RESTORE_DATA_WAIT_SEND, + int32_t userId = DEFAULT_INVAL_VALUE); /** * @brief 用于追加待恢复应用 diff --git a/tests/mock/backup_kit_inner/b_session_restore_async_mock.cpp b/tests/mock/backup_kit_inner/b_session_restore_async_mock.cpp index b1b7b6b2b..9e680cd34 100644 --- a/tests/mock/backup_kit_inner/b_session_restore_async_mock.cpp +++ b/tests/mock/backup_kit_inner/b_session_restore_async_mock.cpp @@ -80,7 +80,6 @@ ErrCode BSessionRestoreAsync::AppendBundles(UniqueFd remoteCap, vector &bundleNames, - const vector &detailInfos, RestoreTypeEnum restoreType, int32_t userId) +ErrCode ServiceProxy::AppendBundlesRestoreSession(UniqueFd fd, + const vector &bundleNames, + RestoreTypeEnum restoreType, + int32_t userId) { return BError(BError::Codes::OK); } ErrCode ServiceProxy::AppendBundlesRestoreSession(UniqueFd fd, const vector &bundleNames, + const vector &detailInfos, RestoreTypeEnum restoreType, int32_t userId) { diff --git a/tests/moduletests/backup_kit_inner/BUILD.gn b/tests/moduletests/backup_kit_inner/BUILD.gn index 9d97e7834..c3fc260ee 100644 --- a/tests/moduletests/backup_kit_inner/BUILD.gn +++ b/tests/moduletests/backup_kit_inner/BUILD.gn @@ -44,12 +44,6 @@ ohos_unittest("b_session_test") { "${path_backup}/utils:backup_utils", ] - cflags = [ "--coverage" ] - - ldflags = [ "--coverage" ] - - cflags_cc = [ "--coverage" ] - external_deps = [ "c_utils:utils", "hilog:libhilog", diff --git a/tests/moduletests/backup_kit_inner/b_session_restore_async_test.cpp b/tests/moduletests/backup_kit_inner/b_session_restore_async_test.cpp index deb124f87..9d6d8e81a 100644 --- a/tests/moduletests/backup_kit_inner/b_session_restore_async_test.cpp +++ b/tests/moduletests/backup_kit_inner/b_session_restore_async_test.cpp @@ -54,11 +54,6 @@ static void OnBackupServiceDied() GTEST_LOG_(INFO) << "BSessionRestoreAsyncTest OnBackupServiceDied OK"; } -static void OnResultReport(std::string bundleName, std::string result) -{ - GTEST_LOG_(INFO) << "BSessionRestoreAsyncTest OnResultReport OK"; -} - class BSessionRestoreAsyncTest : public testing::Test { public: static void SetUpTestCase(void) {}; @@ -92,7 +87,6 @@ void BSessionRestoreAsyncTest::Init() callbacks_.onBundleFinished = OnBundleFinished; callbacks_.onAllBundlesFinished = OnAllBundlesFinished; callbacks_.onBackupServiceDied = OnBackupServiceDied; - callbacks_.onResultReport = OnResultReport; } /** @@ -115,7 +109,6 @@ HWTEST_F(BSessionRestoreAsyncTest, SUB_backup_b_session_restore_async_0100, test callbacks_.onBundleFinished(ErrCode(BError::Codes::OK), ""); callbacks_.onAllBundlesFinished(ErrCode(BError::Codes::OK)); callbacks_.onBackupServiceDied(); - callbacks_.onResultReport("", ""); } catch (...) { EXPECT_TRUE(false); GTEST_LOG_(INFO) << "BSessionRestoreAsyncTest-an exception occurred by Callbacks."; diff --git a/tests/moduletests/backup_kit_inner/b_session_restore_test.cpp b/tests/moduletests/backup_kit_inner/b_session_restore_test.cpp index b91a47683..1ab1115b1 100644 --- a/tests/moduletests/backup_kit_inner/b_session_restore_test.cpp +++ b/tests/moduletests/backup_kit_inner/b_session_restore_test.cpp @@ -55,11 +55,6 @@ static void OnBackupServiceDied() GTEST_LOG_(INFO) << "BSessionRestoreTest OnBackupServiceDied OK"; } -static void OnResultReport(std::string bundleName, const std::string result) -{ - GTEST_LOG_(INFO) << "BSessionRestoreAsyncTest OnResultReport OK"; -} - class BSessionRestoreTest : public testing::Test { public: static void SetUpTestCase(void) {}; @@ -93,7 +88,6 @@ void BSessionRestoreTest::Init() callbacks_.onBundleFinished = OnBundleFinished; callbacks_.onAllBundlesFinished = OnAllBundlesFinished; callbacks_.onBackupServiceDied = OnBackupServiceDied; - callbacks_.onResultReport = OnResultReport; } /** diff --git a/tests/unittests/backup_api/backup_impl/include/i_service_mock.h b/tests/unittests/backup_api/backup_impl/include/i_service_mock.h index ec2a2867f..a0da61edc 100644 --- a/tests/unittests/backup_api/backup_impl/include/i_service_mock.h +++ b/tests/unittests/backup_api/backup_impl/include/i_service_mock.h @@ -102,6 +102,7 @@ public: ErrCode AppendBundlesRestoreSession(UniqueFd fd, const std::vector &bundleNames, + const std::vector &detailInfos, RestoreTypeEnum restoreType, int32_t userId) override { @@ -110,7 +111,6 @@ public: ErrCode AppendBundlesRestoreSession(UniqueFd fd, const std::vector &bundleNames, - const std::vector &detailInfos, RestoreTypeEnum restoreType, int32_t userId) override { diff --git a/utils/include/b_json/b_json_entity_caps.h b/utils/include/b_json/b_json_entity_caps.h index e641077e0..74d092864 100644 --- a/utils/include/b_json/b_json_entity_caps.h +++ b/utils/include/b_json/b_json_entity_caps.h @@ -204,10 +204,6 @@ public: if (item.isMember("extraInfo") && item["extraInfo"].isObject()) { extraInfo = item["extraInfo"]; } - int64_t increSpaceOccupied = 0; - if (item.isMember("increSpaceOccupied") && item["increSpaceOccupied"].isInt64()) { - increSpaceOccupied = item["increSpaceOccupied"].asInt64(); - } bool fullBackupOnly = false; if (item.isMember("fullBackupOnly") && item["fullBackupOnly"].isBool()) { fullBackupOnly = item["fullBackupOnly"].asBool(); @@ -216,10 +212,13 @@ public: if (item.isMember("appIndex") && item["appIndex"].isInt()) { appIndex = item["appIndex"].asInt(); } + int64_t increSpaceOccupied = 0; + if (item.isMember("increSpaceOccupied") && item["increSpaceOccupied"].isInt64()) { + increSpaceOccupied = item["increSpaceOccupied"].asInt64(); + } bundleInfos.emplace_back(BundleInfo {item["name"].asString(), appIndex, item["versionCode"].asInt64(), item["versionName"].asString(), item["spaceOccupied"].asInt64(), - increSpaceOccupied, - item["allToBackup"].asBool(), fullBackupOnly, + increSpaceOccupied, item["allToBackup"].asBool(), fullBackupOnly, item["extensionName"].asString(), restoreDeps, supportScene, extraInfo}); } -- Gitee From 06d681f2e6d075b36ec7d059b5ea130731cf2532 Mon Sep 17 00:00:00 2001 From: chensihan Date: Wed, 30 Oct 2024 02:11:16 +0000 Subject: [PATCH 2/2] update frameworks/native/backup_ext/include/ext_extension.h. Signed-off-by: chensihan --- frameworks/native/backup_ext/include/ext_extension.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/native/backup_ext/include/ext_extension.h b/frameworks/native/backup_ext/include/ext_extension.h index 7002a49c3..f69da7d39 100644 --- a/frameworks/native/backup_ext/include/ext_extension.h +++ b/frameworks/native/backup_ext/include/ext_extension.h @@ -217,7 +217,7 @@ private: void StartFwkTimer(bool &isFwkStart); /** - * @brief get callbackEx for execute onRestore + * @brief get increCallbackEx for execute onRestore with string param * * @param obj */ @@ -238,7 +238,7 @@ private: std::function OnRestoreCallback(wptr obj); /** - * @brief get increCallbackEx for execute onRestore with string param + * @brief get callbackEx for execute onRestore with string param * * @param obj */ -- Gitee