From 5a64e18497b26ca03801e88b46d936d4698cc01e Mon Sep 17 00:00:00 2001 From: chensihan Date: Mon, 26 May 2025 14:35:23 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=B2=BB=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chensihan --- tools/backup_tool/src/tools_op_backup.cpp | 6 +++--- .../src/tools_op_incremental_backup.cpp | 6 +++--- .../src/tools_op_incremental_restore.cpp | 12 ++++++------ .../src/tools_op_incremental_restore_async.cpp | 14 +++++++------- tools/backup_tool/src/tools_op_restore.cpp | 12 ++++++------ tools/backup_tool/src/tools_op_restore_async.cpp | 14 +++++++------- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/tools/backup_tool/src/tools_op_backup.cpp b/tools/backup_tool/src/tools_op_backup.cpp index 439760fd4..577ce7eae 100644 --- a/tools/backup_tool/src/tools_op_backup.cpp +++ b/tools/backup_tool/src/tools_op_backup.cpp @@ -226,7 +226,7 @@ static void BackupToolDirSoftlinkToBackupDir() static int32_t InitPathCapFile(const string &pathCapFile, vector bundleNames) { - StartTrace(HITRACE_TAG_FILEMANAGEMENT, "InitPathCapFile"); + StartTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT, "InitPathCapFile", ""); // SELinux backup_tool工具/data/文件夹下创建文件夹 SA服务因root用户的自定义标签无写入权限 此处调整为软链接形式 BackupToolDirSoftlinkToBackupDir(); @@ -259,7 +259,7 @@ static int32_t InitPathCapFile(const string &pathCapFile, vector bundleN .onProcess = bind(OnProcess, ctx, placeholders::_1, placeholders::_2)}); if (ctx->session_ == nullptr) { printf("Failed to init backup\n"); - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); return -EPERM; } ctx->SetBundleFinishedCount(bundleNames.size()); @@ -269,7 +269,7 @@ static int32_t InitPathCapFile(const string &pathCapFile, vector bundleN throw BError(BError::Codes::TOOL_INVAL_ARG, "backup append bundles error"); } ctx->Wait(); - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); ctx->session_->Release(); return 0; } diff --git a/tools/backup_tool/src/tools_op_incremental_backup.cpp b/tools/backup_tool/src/tools_op_incremental_backup.cpp index 2c8a95d36..d03700346 100644 --- a/tools/backup_tool/src/tools_op_incremental_backup.cpp +++ b/tools/backup_tool/src/tools_op_incremental_backup.cpp @@ -299,7 +299,7 @@ static int GetLocalCapabilitiesIncremental(shared_ptr ctx, static int32_t Init(const string &pathCapFile, const vector& bundleNames, const vector& times) { - StartTrace(HITRACE_TAG_FILEMANAGEMENT, "Init"); + StartTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT, "Init", ""); // SELinux backup_tool工具/data/文件夹下创建文件夹 SA服务因root用户的自定义标签无写入权限 此处调整为软链接形式 BackupToolDirSoftlinkToBackupDir(); @@ -319,7 +319,7 @@ static int32_t Init(const string &pathCapFile, const vector& bundleNames .onProcess = bind(OnProcess, ctx, placeholders::_1, placeholders::_2)}); if (ctx->session_ == nullptr) { printf("Failed to init backup\n"); - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); return -EPERM; } @@ -342,7 +342,7 @@ static int32_t Init(const string &pathCapFile, const vector& bundleNames ctx->SetBundleFinishedCount(bundleNames.size()); ctx->Wait(); - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); ctx->session_->Release(); return 0; } diff --git a/tools/backup_tool/src/tools_op_incremental_restore.cpp b/tools/backup_tool/src/tools_op_incremental_restore.cpp index 3fe368881..5f1c2eda9 100644 --- a/tools/backup_tool/src/tools_op_incremental_restore.cpp +++ b/tools/backup_tool/src/tools_op_incremental_restore.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -226,7 +226,7 @@ static void OnProcess(shared_ptr ctx, const std::string bundleNa static void RestoreApp(shared_ptr restore) { - StartTrace(HITRACE_TAG_FILEMANAGEMENT, "RestoreApp"); + StartTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT, "RestoreApp", ""); if (!restore || !restore->session_) { throw BError(BError::Codes::TOOL_INVAL_ARG, generic_category().message(errno)); } @@ -248,7 +248,7 @@ static void RestoreApp(shared_ptr restore) restore->UpdateBundleSendFiles(data.bundleName, fileName); } } - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); } static bool GetRealPath(string &path) @@ -281,7 +281,7 @@ static int32_t InitRestoreSession(shared_ptr ctx, .onProcess = bind(OnProcess, ctx, placeholders::_1, placeholders::_2)}); if (ctx->session_ == nullptr) { printf("Failed to init restore\n"); - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); return -EPERM; } @@ -298,7 +298,7 @@ static int32_t InitRestoreSession(shared_ptr ctx, static int32_t Init(const string &pathCapFile, vector bundleNames, bool depMode, vector times) { - StartTrace(HITRACE_TAG_FILEMANAGEMENT, "Init"); + StartTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT, "Init", ""); string realPath = pathCapFile; if (!GetRealPath(realPath)) { fprintf(stderr, "path to realpath error"); @@ -322,7 +322,7 @@ static int32_t Init(const string &pathCapFile, vector bundleNames, bool UniqueFd fileFd(open(realPath.data(), O_RDWR, S_IRWXU)); if (fileFd < 0) { fprintf(stderr, "Failed to open file error: %d %s\n", errno, strerror(errno)); - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); return -errno; } int result = ctx->session_->AppendBundles(move(fileFd), {bundleName}); diff --git a/tools/backup_tool/src/tools_op_incremental_restore_async.cpp b/tools/backup_tool/src/tools_op_incremental_restore_async.cpp index f39f53196..230393c81 100644 --- a/tools/backup_tool/src/tools_op_incremental_restore_async.cpp +++ b/tools/backup_tool/src/tools_op_incremental_restore_async.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -253,7 +253,7 @@ static void OnProcess(shared_ptr ctx, const std::string bundleName, con static void RestoreApp(shared_ptr restore, vector &bundleNames) { - StartTrace(HITRACE_TAG_FILEMANAGEMENT, "RestoreApp"); + StartTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT, "RestoreApp", ""); if (!restore || !restore->session_) { throw BError(BError::Codes::TOOL_INVAL_ARG, generic_category().message(errno)); } @@ -303,7 +303,7 @@ static void RestoreApp(shared_ptr restore, vectorsession_->GetFileHandle(bundleName, item.hashName); } } - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); } static int32_t ChangeBundleInfo(const string &pathCapFile, const vector &bundleNames, const string &type) @@ -312,7 +312,7 @@ static int32_t ChangeBundleInfo(const string &pathCapFile, const vector UniqueFd fd(open(pathCapFile.data(), O_RDWR, S_IRWXU)); if (fd < 0) { fprintf(stderr, "Failed to open file error: %d %s\n", errno, strerror(errno)); - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); return -errno; } BJsonCachedEntity cachedEntity(move(fd)); @@ -356,7 +356,7 @@ static int32_t AppendBundles(shared_ptr restore, UniqueFd fd(open(pathCapFile.data(), O_RDWR, S_IRWXU)); if (fd < 0) { fprintf(stderr, "Failed to open file error: %d %s\n", errno, strerror(errno)); - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); return -errno; } RestoreTypeEnum restoreType = RestoreTypeEnum::RESTORE_DATA_WAIT_SEND; @@ -388,7 +388,7 @@ static int32_t InitArg(const string &pathCapFile, const string &type, const string &userId) { - StartTrace(HITRACE_TAG_FILEMANAGEMENT, "Init"); + StartTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT, "Init", ""); BExcepUltils::VerifyPath(pathCapFile, false); if (ChangeBundleInfo(pathCapFile, bundleNames, type)) { @@ -411,7 +411,7 @@ static int32_t InitArg(const string &pathCapFile, .onProcess = bind(OnProcess, ctx, placeholders::_1, placeholders::_2)}); if (ctx->session_ == nullptr) { printf("Failed to init restore\n"); - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); return -EPERM; } ctx->SetBundleFinishedCount(bundleNames.size()); diff --git a/tools/backup_tool/src/tools_op_restore.cpp b/tools/backup_tool/src/tools_op_restore.cpp index 7649de29a..aa33da190 100644 --- a/tools/backup_tool/src/tools_op_restore.cpp +++ b/tools/backup_tool/src/tools_op_restore.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -204,7 +204,7 @@ static void OnProcess(shared_ptr ctx, const std::string bundleName, con static void RestoreApp(shared_ptr restore, vector &bundleNames, bool updateSendFiles) { - StartTrace(HITRACE_TAG_FILEMANAGEMENT, "RestoreApp"); + StartTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT, "RestoreApp", ""); if (!restore || !restore->session_) { throw BError(BError::Codes::TOOL_INVAL_ARG, generic_category().message(errno)); } @@ -233,7 +233,7 @@ static void RestoreApp(shared_ptr restore, vector &bundleNa } } } - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); } static bool GetRealPath(string &path) @@ -266,7 +266,7 @@ static int32_t InitRestoreSession(shared_ptr ctx) .onProcess = bind(OnProcess, ctx, placeholders::_1, placeholders::_2)}); if (ctx->session_ == nullptr) { printf("Failed to init restore\n"); - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); return -EPERM; } return 0; @@ -274,7 +274,7 @@ static int32_t InitRestoreSession(shared_ptr ctx) static int32_t InitPathCapFile(const string &pathCapFile, vector bundleNames, bool depMode) { - StartTrace(HITRACE_TAG_FILEMANAGEMENT, "Init"); + StartTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT, "Init", ""); string realPath = pathCapFile; if (!GetRealPath(realPath)) { fprintf(stderr, "path to realpath error"); @@ -299,7 +299,7 @@ static int32_t InitPathCapFile(const string &pathCapFile, vector bundleN UniqueFd fileFd(open(realPath.data(), O_RDWR, S_IRWXU)); if (fileFd < 0) { fprintf(stderr, "Failed to open file error: %d %s\n", errno, strerror(errno)); - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); return -errno; } int result = ctx->session_->AppendBundles(move(fileFd), {bundleName}); diff --git a/tools/backup_tool/src/tools_op_restore_async.cpp b/tools/backup_tool/src/tools_op_restore_async.cpp index c87462f69..f52f6a2d9 100644 --- a/tools/backup_tool/src/tools_op_restore_async.cpp +++ b/tools/backup_tool/src/tools_op_restore_async.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -246,7 +246,7 @@ static void AdapteCloneOptimize(const string &path) static void RestoreApp(shared_ptr restore, vector &bundleNames) { - StartTrace(HITRACE_TAG_FILEMANAGEMENT, "RestoreApp"); + StartTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT, "RestoreApp", ""); if (!restore || !restore->session_) { throw BError(BError::Codes::TOOL_INVAL_ARG, generic_category().message(errno)); } @@ -286,7 +286,7 @@ static void RestoreApp(shared_ptr restore, vector &bun restore->session_->GetFileHandle(bundleName, item.hashName); } } - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); } static int32_t ChangeBundleInfo(const string &pathCapFile, const vector &bundleNames, const string &type) @@ -295,7 +295,7 @@ static int32_t ChangeBundleInfo(const string &pathCapFile, const vector UniqueFd fd(open(pathCapFile.data(), O_RDWR, S_IRWXU)); if (fd < 0) { fprintf(stderr, "Failed to open file error: %d %s\n", errno, strerror(errno)); - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); return -errno; } BJsonCachedEntity cachedEntity(move(fd)); @@ -339,7 +339,7 @@ static int32_t AppendBundles(shared_ptr restore, UniqueFd fd(open(pathCapFile.data(), O_RDWR, S_IRWXU)); if (fd < 0) { fprintf(stderr, "Failed to open file error: %d %s\n", errno, strerror(errno)); - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); return -errno; } RestoreTypeEnum restoreType = RestoreTypeEnum::RESTORE_DATA_WAIT_SEND; @@ -371,7 +371,7 @@ static int32_t InitArg(const string &pathCapFile, const string &type, const string &userId) { - StartTrace(HITRACE_TAG_FILEMANAGEMENT, "Init"); + StartTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT, "Init", ""); BExcepUltils::VerifyPath(pathCapFile, false); if (ChangeBundleInfo(pathCapFile, bundleNames, type)) { @@ -394,7 +394,7 @@ static int32_t InitArg(const string &pathCapFile, .onProcess = bind(OnProcess, ctx, placeholders::_1, placeholders::_2)}); if (ctx->session_ == nullptr) { printf("Failed to init restore\n"); - FinishTrace(HITRACE_TAG_FILEMANAGEMENT); + FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_FILEMANAGEMENT); return -EPERM; } ctx->SetBundleFinishedCount(bundleNames.size()); -- Gitee From d31ec4738b2d26c43651e50431877ee10b477a75 Mon Sep 17 00:00:00 2001 From: chensihan Date: Thu, 29 May 2025 10:41:57 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=B2=BB=E7=90=86=20Sign?= =?UTF-8?q?ed-off-by:=20chensihan=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interfaces/innerkits/native/file_uri/src/file_uri.cpp | 1 + utils/include/b_hilog/filemgmt_libhilog.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/interfaces/innerkits/native/file_uri/src/file_uri.cpp b/interfaces/innerkits/native/file_uri/src/file_uri.cpp index 655e6dcb4..d13f58ab0 100644 --- a/interfaces/innerkits/native/file_uri/src/file_uri.cpp +++ b/interfaces/innerkits/native/file_uri/src/file_uri.cpp @@ -143,6 +143,7 @@ string FileUri::GetRealPath() realPath = pathShare + MODE_R + bundleName + sandboxPath; } } + LOGD("GetRealPath return path is ,%{private}s", realPath.c_str()); return realPath; } diff --git a/utils/include/b_hilog/filemgmt_libhilog.h b/utils/include/b_hilog/filemgmt_libhilog.h index 9e882f46b..e2de24305 100644 --- a/utils/include/b_hilog/filemgmt_libhilog.h +++ b/utils/include/b_hilog/filemgmt_libhilog.h @@ -22,7 +22,7 @@ namespace OHOS { #ifndef LOG_DOMAIN -#define LOG_DOMAIN 0xD001600 +#define LOG_DOMAIN 0xD004302 #endif #ifndef LOG_TAG -- Gitee From d825d1aafeaf6de6beb6d87ea0ac06703bcb179e Mon Sep 17 00:00:00 2001 From: chensihan Date: Thu, 29 May 2025 15:30:34 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=B2=BB=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chensihan --- utils/include/b_hilog/filemgmt_libhilog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/include/b_hilog/filemgmt_libhilog.h b/utils/include/b_hilog/filemgmt_libhilog.h index e2de24305..eed8d94d5 100644 --- a/utils/include/b_hilog/filemgmt_libhilog.h +++ b/utils/include/b_hilog/filemgmt_libhilog.h @@ -22,7 +22,7 @@ namespace OHOS { #ifndef LOG_DOMAIN -#define LOG_DOMAIN 0xD004302 +#define LOG_DOMAIN 0xD004303 #endif #ifndef LOG_TAG -- Gitee