From 7cba610964fe873760abbb87ae4374df90d73afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E4=BD=B3=E7=82=9C?= Date: Thu, 21 Aug 2025 20:24:42 +0800 Subject: [PATCH 1/2] clean code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 石佳炜 --- tests/mock/backup_ext/src/ext_extension_mock.cpp | 5 ----- tests/unittests/backup_sa/module_ipc/service_other_test.cpp | 2 +- tests/unittests/backup_sa/module_ipc/service_test.cpp | 3 +-- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/mock/backup_ext/src/ext_extension_mock.cpp b/tests/mock/backup_ext/src/ext_extension_mock.cpp index 712ce158d..6f72efde9 100644 --- a/tests/mock/backup_ext/src/ext_extension_mock.cpp +++ b/tests/mock/backup_ext/src/ext_extension_mock.cpp @@ -187,11 +187,6 @@ void BackupExtExtension::DoClearInner() BExtExtension::extExtension->DoClearInner(); } -ErrCode BackupExtExtension::CleanBundleTempDir() -{ - return BExtExtension::extExtension->CleanBundleTempDir(); -} - void BackupExtExtension::GetTarIncludes(const string &tarName, unordered_map &infos) { BExtExtension::extExtension->GetTarIncludes(tarName, infos); 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 a1253d5ea..5cace8b41 100644 --- a/tests/unittests/backup_sa/module_ipc/service_other_test.cpp +++ b/tests/unittests/backup_sa/module_ipc/service_other_test.cpp @@ -875,7 +875,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))); + .WillRepeatedly(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)); EXPECT_CALL(*skeleton, GetCallingUid()).WillOnce(Return(BConstants::SYSTEM_UID)); diff --git a/tests/unittests/backup_sa/module_ipc/service_test.cpp b/tests/unittests/backup_sa/module_ipc/service_test.cpp index f51d1fc6f..faeb4852c 100644 --- a/tests/unittests/backup_sa/module_ipc/service_test.cpp +++ b/tests/unittests/backup_sa/module_ipc/service_test.cpp @@ -729,8 +729,7 @@ HWTEST_F(ServiceTest, SUB_Service_GetFileHandle_0101, testing::ext::TestSize.Lev BackupExtInfo extInfo {}; auto callDied = [](const string &&bundleName, bool isCleanCalled) {}; auto callConnected = [](const string &&bundleName) {}; - string bundleNameIndexInfo = "123456"; - extInfo.backUpConnection = sptr(new SvcBackupConnection(callDied, callConnected, bundleNameIndexInfo)); + extInfo.backUpConnection = sptr(new SvcBackupConnection(callDied, callConnected, BUNDLE_NAME)); extInfo.schedAction = BConstants::ServiceSchedAction::RUNNING; impl_.backupExtNameMap[BUNDLE_NAME] = extInfo; EXPECT_TRUE(servicePtr_ != nullptr); -- Gitee From 3c241fa62d028e87190861e769e4703497d8b7d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E4=BD=B3=E7=82=9C?= Date: Fri, 22 Aug 2025 12:25:07 +0800 Subject: [PATCH 2/2] clean code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 石佳炜 --- .../native/backup_ext/src/ext_extension.cpp | 21 ------------------- .../backup_ext/src/sub_ext_extension.cpp | 21 +++++++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/frameworks/native/backup_ext/src/ext_extension.cpp b/frameworks/native/backup_ext/src/ext_extension.cpp index f931cbb44..7cf79a69f 100644 --- a/frameworks/native/backup_ext/src/ext_extension.cpp +++ b/frameworks/native/backup_ext/src/ext_extension.cpp @@ -2173,25 +2173,4 @@ ErrCode BackupExtExtension::IncrementalAllFileReady(const TarMap &pkgInfo, close(manifestFdval); return ret; } - -ErrCode BackupExtExtension::CleanBundleTempDir() -{ - HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); - HILOGI("BackupExtExtension::CleanBundleTempDir begin"); - if (extension_ == nullptr) { - HILOGE("Failed to CleanBundleTempDir, extension is nullptr"); - return BError(BError::Codes::EXT_INVAL_ARG, "Extension is nullptr").GetCode(); - } - if (extension_->GetExtensionAction() == BConstants::ExtensionAction::INVALID) { - return BError(BError::Codes::EXT_INVAL_ARG, "Action is invalid").GetCode(); - } - try { - VerifyCaller(); - DoClearInner(); - return ERR_OK; - } catch (...) { - HILOGE("Failed to CleanBundleTempDir"); - return BError(BError::Codes::EXT_BROKEN_IPC).GetCode(); - } -} } // namespace OHOS::FileManagement::Backup diff --git a/frameworks/native/backup_ext/src/sub_ext_extension.cpp b/frameworks/native/backup_ext/src/sub_ext_extension.cpp index 59203d07e..5b21fabdf 100644 --- a/frameworks/native/backup_ext/src/sub_ext_extension.cpp +++ b/frameworks/native/backup_ext/src/sub_ext_extension.cpp @@ -1727,6 +1727,27 @@ tuple BackupExtExtension::GetIncrementalBackupFileHandle() return {UniqueFd(BConstants::INVALID_FD_NUM), UniqueFd(BConstants::INVALID_FD_NUM)}; } +ErrCode BackupExtExtension::CleanBundleTempDir() +{ + HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); + HILOGI("BackupExtExtension::CleanBundleTempDir begin"); + if (extension_ == nullptr) { + HILOGE("Failed to CleanBundleTempDir, extension is nullptr"); + return BError(BError::Codes::EXT_INVAL_ARG, "Extension is nullptr").GetCode(); + } + if (extension_->GetExtensionAction() == BConstants::ExtensionAction::INVALID) { + return BError(BError::Codes::EXT_INVAL_ARG, "Action is invalid").GetCode(); + } + try { + VerifyCaller(); + DoClearInner(); + return ERR_OK; + } catch (...) { + HILOGE("Failed to CleanBundleTempDir"); + return BError(BError::Codes::EXT_BROKEN_IPC).GetCode(); + } +} + std::function BackupExtExtension::OnReleaseCallback(wptr obj) { HILOGI("Begin get HandleOnReleaseCallback"); -- Gitee