From 2f0ddbcaf383b97bdc0a0c0dc3ef714249bb807f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Wed, 22 Jan 2025 17:01:18 +0800 Subject: [PATCH] c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- bundle.json | 1 + services/BUILD.gn | 1 + services/native/include/usb_trace.h | 22 +++++++++++++++++++ .../native/src/usb_function_switch_window.cpp | 2 ++ 4 files changed, 26 insertions(+) create mode 100644 services/native/include/usb_trace.h diff --git a/bundle.json b/bundle.json index bf58b047..a7ffe617 100644 --- a/bundle.json +++ b/bundle.json @@ -38,6 +38,7 @@ "data_share", "drivers_interface_usb", "drivers_peripheral_usb", + "hitrace", "init", "ipc", "safwk", diff --git a/services/BUILD.gn b/services/BUILD.gn index fb4d99eb..8917cb60 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -85,6 +85,7 @@ ohos_shared_library("usbservice") { "drivers_interface_usb:libusb_proxy_1.2", "drivers_peripheral_usb:libusb_interface_service_1.2", "hilog:libhilog", + "hitrace:hitrace_meter", "hisysevent:libhisysevent", "hitrace:hitrace_meter", "init:libbeget_proxy", diff --git a/services/native/include/usb_trace.h b/services/native/include/usb_trace.h new file mode 100644 index 00000000..9d936783 --- /dev/null +++ b/services/native/include/usb_trace.h @@ -0,0 +1,22 @@ +/* +* Copyright (c) 2023 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 +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef USB_TRACE_H +#define USB_TRACE_H + +#include "hitrace_meter.h" + +#define USB_TRACE HITRACE_METER_FMT(HITRACE_TAG_HDF, "%s", __func__) + +#endif // USB_TRACE_H diff --git a/services/native/src/usb_function_switch_window.cpp b/services/native/src/usb_function_switch_window.cpp index ea2ca732..7231737d 100644 --- a/services/native/src/usb_function_switch_window.cpp +++ b/services/native/src/usb_function_switch_window.cpp @@ -32,6 +32,7 @@ #include "os_account_manager.h" #include "usb_errors.h" #include "uri.h" +#include "usb_trace.h" #define DEFAULT_PARAM_VALUE "charge,mtp,ptp" using namespace OHOS::AppExecFwk; @@ -50,6 +51,7 @@ std::mutex UsbFunctionSwitchWindow::insMutex_; std::shared_ptr UsbFunctionSwitchWindow::GetInstance() { + USB_TRACE; std::lock_guard guard(insMutex_); if (instance_ == nullptr) { USB_HILOGI(MODULE_USB_SERVICE, "reset to new instance"); -- Gitee