From 0d7b5d3e809188c7e9164c3a4fda56918ca98136 Mon Sep 17 00:00:00 2001 From: xuyong Date: Sat, 8 Mar 2025 11:52:53 +0800 Subject: [PATCH 001/103] build: add direct dependency of hisysevent:libhisysevent Signed-off-by: xuyong --- camera/hdi_service/v1_0/BUILD.gn | 2 ++ camera/test/ut/buffer_manager/BUILD.gn | 1 + camera/vdi_base/common/buffer_manager/BUILD.gn | 1 + camera/vdi_base/common/pipeline_core/BUILD.gn | 1 + camera/vdi_base/usb_camera/buffer_manager/BUILD.gn | 1 + camera/vdi_base/usb_camera/pipeline_core/BUILD.gn | 1 + camera/vdi_base/usb_camera/vdi_impl/BUILD.gn | 2 ++ 7 files changed, 9 insertions(+) diff --git a/camera/hdi_service/v1_0/BUILD.gn b/camera/hdi_service/v1_0/BUILD.gn index d08c46f781..10fc249b2d 100644 --- a/camera/hdi_service/v1_0/BUILD.gn +++ b/camera/hdi_service/v1_0/BUILD.gn @@ -135,6 +135,7 @@ if (defined(ohos_lite)) { "hdf_core:libhdi", "hicollie:libhicollie", "hilog:libhilog", + "hisysevent:libhisysevent", ] } else { external_deps = [ "hilog:libhilog" ] @@ -180,6 +181,7 @@ if (defined(ohos_lite)) { "hdf_core:libhdi", "hicollie:libhicollie", "hilog:libhilog", + "hisysevent:libhisysevent", ] } else { external_deps = [ "hilog:libhilog" ] diff --git a/camera/test/ut/buffer_manager/BUILD.gn b/camera/test/ut/buffer_manager/BUILD.gn index e172a982ec..35681ed904 100644 --- a/camera/test/ut/buffer_manager/BUILD.gn +++ b/camera/test/ut/buffer_manager/BUILD.gn @@ -167,6 +167,7 @@ if (defined(ohos_lite)) { "drivers_interface_camera:libcamera_stub_1.0", "hdf_core:libhdf_utils", "hilog:libhilog", + "hisysevent:libhisysevent", "samgr:samgr_proxy", ] } else { diff --git a/camera/vdi_base/common/buffer_manager/BUILD.gn b/camera/vdi_base/common/buffer_manager/BUILD.gn index 76bd2b3dc1..9c5cd6c601 100644 --- a/camera/vdi_base/common/buffer_manager/BUILD.gn +++ b/camera/vdi_base/common/buffer_manager/BUILD.gn @@ -126,6 +126,7 @@ if (defined(ohos_lite)) { "graphic_surface:surface", "hdf_core:libhdf_utils", "hilog:libhilog", + "hisysevent:libhisysevent", ] } else { external_deps = [ "hilog:libhilog" ] diff --git a/camera/vdi_base/common/pipeline_core/BUILD.gn b/camera/vdi_base/common/pipeline_core/BUILD.gn index 6c88eeee9d..45c9714efc 100644 --- a/camera/vdi_base/common/pipeline_core/BUILD.gn +++ b/camera/vdi_base/common/pipeline_core/BUILD.gn @@ -155,6 +155,7 @@ ohos_shared_library("peripheral_camera_pipeline_core") { external_deps = [ "hdf_core:libhdf_utils", "hilog:libhilog", + "hisysevent:libhisysevent", ] } else { external_deps = [ "hilog:libhilog" ] diff --git a/camera/vdi_base/usb_camera/buffer_manager/BUILD.gn b/camera/vdi_base/usb_camera/buffer_manager/BUILD.gn index bc6c13e089..fd53cd521e 100644 --- a/camera/vdi_base/usb_camera/buffer_manager/BUILD.gn +++ b/camera/vdi_base/usb_camera/buffer_manager/BUILD.gn @@ -71,6 +71,7 @@ ohos_shared_library("usb_camera_buffer_manager") { "graphic_surface:surface", "hdf_core:libhdf_utils", "hilog:libhilog", + "hisysevent:libhisysevent", ] public_configs = [ ":buffer_manager_config" ] install_images = [ chipset_base_dir ] diff --git a/camera/vdi_base/usb_camera/pipeline_core/BUILD.gn b/camera/vdi_base/usb_camera/pipeline_core/BUILD.gn index 73031228c3..867f8c39d7 100644 --- a/camera/vdi_base/usb_camera/pipeline_core/BUILD.gn +++ b/camera/vdi_base/usb_camera/pipeline_core/BUILD.gn @@ -158,6 +158,7 @@ ohos_shared_library("usb_camera_pipeline_core") { "hdf_core:libhdf_host", "hdf_core:libhdf_utils", "hilog:libhilog", + "hisysevent:libhisysevent", "ipc:ipc_single", "libexif:libexif", "libjpeg-turbo:turbojpeg_static", diff --git a/camera/vdi_base/usb_camera/vdi_impl/BUILD.gn b/camera/vdi_base/usb_camera/vdi_impl/BUILD.gn index afea5554f9..7e0d2add4c 100644 --- a/camera/vdi_base/usb_camera/vdi_impl/BUILD.gn +++ b/camera/vdi_base/usb_camera/vdi_impl/BUILD.gn @@ -123,6 +123,7 @@ ohos_shared_library("camera_daemon") { "hdf_core:libhdf_utils", "hdf_core:libhdi", "hilog:libhilog", + "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_single", ] @@ -170,6 +171,7 @@ ohos_static_library("camera_daemon_static") { "hdf_core:libhdf_utils", "hdf_core:libhdi", "hilog:libhilog", + "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_single", ] -- Gitee From 93ffe26a94c4471dcb3ce0ad5b6de3163f9119e7 Mon Sep 17 00:00:00 2001 From: WangYusen Date: Sat, 8 Mar 2025 19:18:59 +0800 Subject: [PATCH 002/103] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A4=A7=E5=B1=8F?= =?UTF-8?q?=E5=BC=B9=E6=A1=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: WangYusen --- .../interfaces/hdi_service/service_common/wpa_p2p_cmd.c | 7 ++++++- .../interfaces/hdi_service/service_common/wpa_p2p_cmd.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_p2p_cmd.c b/wlan/wpa/interfaces/hdi_service/service_common/wpa_p2p_cmd.c index 641ec768ad..bfeee41383 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_p2p_cmd.c +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_p2p_cmd.c @@ -1566,12 +1566,17 @@ int32_t WpaInterfaceDeliverP2pData(struct IWpaInterface *self, const char *ifNam char buf[CMD_SIZE] = {0}; int32_t ret = 0; - if (ifName == NULL) { + if (ifName == NULL || carryData == NULL) { HDF_LOGE("%{public}s: input parameter invalid!", __func__); return HDF_ERR_INVALID_PARAM; } pthread_mutex_lock(GetInterfaceLock()); switch (cmdType) { + case P2P_REJECT: { + ret = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, + "IFNAME=%s P2P_REJECT %s", ifName, carryData); + break; + } case P2P_REMOVE_GROUP_CLIENT: { ret = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "IFNAME=%s P2P_REMOVE_CLIENT %s", ifName, carryData); diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_p2p_cmd.h b/wlan/wpa/interfaces/hdi_service/service_common/wpa_p2p_cmd.h index febee0683b..d64a29a349 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_p2p_cmd.h +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_p2p_cmd.h @@ -34,6 +34,7 @@ enum P2pWpsMethod { enum P2pRemoveGroupEvent { P2P_REMOVE_GROUP_CLIENT = 0, + P2P_REJECT, EVENT_MAX }; -- Gitee From 0e81ceb5328ef434def6c4a7e26b974edcb3eb90 Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Sat, 8 Mar 2025 20:46:56 +0800 Subject: [PATCH 003/103] networkslice Signed-off-by: zhangwuling1 --- ril/interfaces/hdi_service/include/ril_impl.h | 11 +++++- ril/interfaces/hdi_service/src/ril_impl.cpp | 38 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/ril/interfaces/hdi_service/include/ril_impl.h b/ril/interfaces/hdi_service/include/ril_impl.h index 9fd3c70981..a7381f841a 100644 --- a/ril/interfaces/hdi_service/include/ril_impl.h +++ b/ril/interfaces/hdi_service/include/ril_impl.h @@ -129,7 +129,16 @@ public: int32_t UnlockSimLock(int32_t slotId, int32_t serialId, int32_t lockType, const std::string &key) override; int32_t SendSimMatchedOperatorInfo( int32_t slotId, int32_t serialId, const NcfgOperatorInfo &ncfgOperatorInfo) override; - + int32_t SendUrspDecodeResult(int32_t slotId, int32_t serialId, + const UePolicyDecodeResult &uePolicyDecodeResult) override; + int32_t SendUePolicySectionIdentifier(int32_t slotId, int32_t serialId, + const UePolicySectionIdentifier &uePolicySectionIdentifier) override; + int32_t SendImsRsdList(int32_t slotId, int32_t serialId, const ImsRsdList &imsRsdList) override; + int32_t GetNetworkSliceAllowedNssai(int32_t slotId, int32_t serialId, + const SyncAllowedNssaiInfo &syncAllowedNssaiInfo) override; + int32_t GetNetworkSliceEhplmn(int32_t slotId, int32_t serialId) override; + int32_t ActivatePdpContextWithApnTypesforSlice(int32_t slotId, int32_t serialId, + const DataCallInfoWithApnTypesforSlice &dataCallInfo) override; // Network int32_t GetSignalStrength(int32_t slotId, int32_t serialId) override; int32_t GetCsRegStatus(int32_t slotId, int32_t serialId) override; diff --git a/ril/interfaces/hdi_service/src/ril_impl.cpp b/ril/interfaces/hdi_service/src/ril_impl.cpp index 7aa866ac99..0df257ca23 100644 --- a/ril/interfaces/hdi_service/src/ril_impl.cpp +++ b/ril/interfaces/hdi_service/src/ril_impl.cpp @@ -304,6 +304,44 @@ int32_t RilImpl::CleanAllConnections(int32_t slotId, int32_t serialId) return TaskSchedule(&Telephony::HRilManager::CleanAllConnections, slotId, serialId); } +int32_t RilImpl::SendUrspDecodeResult(int32_t slotId, + int32_t serialId, const UePolicyDecodeResult &uePolicyDecodeResult) +{ + HDF_LOGI("RilImpl::SendUrspDecodeResult"); + return TaskSchedule(&Telephony::HRilManager::SendUrspDecodeResult, + slotId, serialId, uePolicyDecodeResult); +} + +int32_t RilImpl::SendUePolicySectionIdentifier(int32_t slotId, int32_t serialId, + const UePolicySectionIdentifier &uePolicySectionIdentifier) +{ + return TaskSchedule(&Telephony::HRilManager::SendUePolicySectionIdentifier, + slotId, serialId, uePolicySectionIdentifier); +} + +int32_t RilImpl::SendImsRsdList(int32_t slotId, int32_t serialId, const ImsRsdList &imsRsdList) +{ + return TaskSchedule(&Telephony::HRilManager::SendImsRsdList, slotId, serialId, imsRsdList); +} + +int32_t RilImpl::GetNetworkSliceAllowedNssai(int32_t slotId, int32_t serialId, + const SyncAllowedNssaiInfo &syncAllowedNssaiInfo) +{ + return TaskSchedule(&Telephony::HRilManager::GetNetworkSliceAllowedNssai, slotId, serialId, syncAllowedNssaiInfo); +} + +int32_t RilImpl::GetNetworkSliceEhplmn(int32_t slotId, int32_t serialId) +{ + return TaskSchedule(&Telephony::HRilManager::GetNetworkSliceEhplmn, slotId, serialId); +} + +int32_t RilImpl::ActivatePdpContextWithApnTypesforSlice(int32_t slotId, int32_t serialId, + const DataCallInfoWithApnTypesforSlice &dataCallInfo) +{ + return TaskSchedule(&Telephony::HRilManager::ActivatePdpContextWithApnTypesforSlice, + slotId, serialId, dataCallInfo); +} + // Modem int32_t RilImpl::SetRadioState(int32_t slotId, int32_t serialId, int32_t fun, int32_t rst) { -- Gitee From 90074f07e2d493be977028686d55a21c6d8d19b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=AD=A6=E6=B5=B7?= Date: Fri, 14 Mar 2025 03:51:41 +0000 Subject: [PATCH 004/103] update audio/audio.gni. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许学海 --- audio/audio.gni | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/audio/audio.gni b/audio/audio.gni index f81ec932e4..1e9ce047ca 100644 --- a/audio/audio.gni +++ b/audio/audio.gni @@ -20,8 +20,8 @@ declare_args() { drivers_peripheral_audio_feature_double_pnp_detect = false drivers_peripheral_audio_feature_offload = false drivers_peripheral_audio_feature_multichannel = false - drivers_peripheral_audio_feature_hicollie_enable = false - drivers_peripheral_audio_feature_hitrace_enable = false + drivers_peripheral_audio_feature_hicollie_enable = true + drivers_peripheral_audio_feature_hitrace_enable = true drivers_peripheral_audio_feature_frame_ec = false } @@ -55,13 +55,3 @@ if (defined(global_parts_info) && !defined(global_parts_info.commonlibrary_c_utils)) { enable_c_utils = false } - -if (defined(global_parts_info) && - defined(global_parts_info.hiviewdfx_hicollie)) { - drivers_peripheral_audio_feature_hicollie_enable = true -} - -if (defined(global_parts_info) && - defined(global_parts_info.hiviewdfx_hitrace)) { - drivers_peripheral_audio_feature_hitrace_enable = true -} -- Gitee From cf8784c6d5a17a610bc4cadb60e4573434da10e0 Mon Sep 17 00:00:00 2001 From: Joshua Date: Fri, 14 Mar 2025 15:58:01 +0800 Subject: [PATCH 005/103] sqr mode Signed-off-by: Joshua --- codec/interfaces/include/codec_omx_ext.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/codec/interfaces/include/codec_omx_ext.h b/codec/interfaces/include/codec_omx_ext.h index 5f1a1dcde7..fcac3306d5 100644 --- a/codec/interfaces/include/codec_omx_ext.h +++ b/codec/interfaces/include/codec_omx_ext.h @@ -233,6 +233,18 @@ struct ControlRateConstantQuality { uint32_t qualityValue; /** Control rate constant quality */ }; +/** + * @brief Defines the StableControlRate. + */ +struct StableControlRate { + uint32_t size; /** Size of the structure */ + union OMX_VERSIONTYPE version; /** Component version */ + uint32_t portIndex; /** Port index */ + uint32_t sqrFactor; /** sqr Factor */ + uint32_t sMaxBitrate; /** Control max bitrate */ + uint32_t sTargetBitrate; /** Control bitrate */ +}; + /** * @brief Defines the PassthroughParam. */ @@ -343,6 +355,8 @@ enum OmxIndexCodecExType { OMX_IndexParamEnablePackInput, /** OMX_CONFIG_BOOLEANTYPE */ OMX_IndexParamSwitchGround, + /** ControlRateSQR */ + OMX_IndexParamControlRateSQR, }; /** @@ -351,6 +365,10 @@ enum OmxIndexCodecExType { typedef enum OmxVideoControlRateVendorExtType { /** constant bit rate mode with Rlambda */ OMX_Video_ControlRateConstantWithRlambda = OMX_Video_ControlRateVendorStartUnused + 0x1, + /** constant bit rate mode with CQ */ + OMX_Video_ControlRateConstantWithCQ, + /** stable bit rate mode with SQR */ + OMX_Video_ControlRateConstantWithSQR, } OmxVideoControlRateVendorExtType; /** -- Gitee From 885621ccbff53e798285aef7f7f6d1c08363f02f Mon Sep 17 00:00:00 2001 From: chen0088 Date: Fri, 14 Mar 2025 16:05:34 +0800 Subject: [PATCH 006/103] modify ut out paht Signed-off-by: chen0088 --- .../hdi_service/test/unittest/common/dcamera_device/BUILD.gn | 5 ++--- .../test/unittest/common/dstream_operator/BUILD.gn | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/distributed_camera/hdi_service/test/unittest/common/dcamera_device/BUILD.gn b/distributed_camera/hdi_service/test/unittest/common/dcamera_device/BUILD.gn index 20da89e8b8..ee0c516ae6 100644 --- a/distributed_camera/hdi_service/test/unittest/common/dcamera_device/BUILD.gn +++ b/distributed_camera/hdi_service/test/unittest/common/dcamera_device/BUILD.gn @@ -1,4 +1,4 @@ -# 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 @@ -15,8 +15,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("//drivers/peripheral/distributed_camera/distributedcamera.gni") -module_out_path = - "drivers_peripheral_distributed_camera/hdf_dcamera_device_test" +module_out_path = "drivers_peripheral_distributed_camera/drivers_peripheral_distributed_camera/hdf_dcamera_device_test" config("module_private_config") { visibility = [ ":*" ] diff --git a/distributed_camera/hdi_service/test/unittest/common/dstream_operator/BUILD.gn b/distributed_camera/hdi_service/test/unittest/common/dstream_operator/BUILD.gn index 33527a7c80..b3568029be 100644 --- a/distributed_camera/hdi_service/test/unittest/common/dstream_operator/BUILD.gn +++ b/distributed_camera/hdi_service/test/unittest/common/dstream_operator/BUILD.gn @@ -1,4 +1,4 @@ -# 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 @@ -15,8 +15,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("//drivers/peripheral/distributed_camera/distributedcamera.gni") -module_out_path = - "drivers_peripheral_distributed_camera/hdf_dstream_operator_test" +module_out_path = "drivers_peripheral_distributed_camera/drivers_peripheral_distributed_camera/hdf_dstream_operator_test" config("module_private_config") { visibility = [ ":*" ] -- Gitee From cd09f9e9f406c74c6f69fbeb4a62fce63e8c15ea Mon Sep 17 00:00:00 2001 From: luzhiye Date: Fri, 14 Mar 2025 16:44:37 +0800 Subject: [PATCH 007/103] =?UTF-8?q?TDD=E7=94=A8=E4=BE=8Bmodule=5Foutput=5F?= =?UTF-8?q?path=E9=83=A8=E4=BB=B6=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: luzhiye --- usb/test/unittest/BUILD.gn | 2 +- usb/test/unittest/ddk_service/BUILD.gn | 2 +- usb/test/unittest/device_sdk/BUILD.gn | 2 +- usb/test/unittest/hal/BUILD.gn | 2 +- usb/test/unittest/host_sdk/BUILD.gn | 2 +- usb/test/unittest/mock/BUILD.gn | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/usb/test/unittest/BUILD.gn b/usb/test/unittest/BUILD.gn index 933d416fec..ee7e65dd0d 100644 --- a/usb/test/unittest/BUILD.gn +++ b/usb/test/unittest/BUILD.gn @@ -40,7 +40,7 @@ if (defined(ohos_lite)) { import("//build/test.gni") import("./../../../../hdf_core/adapter/uhdf2/uhdf.gni") - module_output_path = "hdf/usb" + module_output_path = "drivers_peripheral_usb/drivers_peripheral_usb" ohos_unittest("usb_device_sdk_io_test") { module_out_path = module_output_path include_dirs = [ diff --git a/usb/test/unittest/ddk_service/BUILD.gn b/usb/test/unittest/ddk_service/BUILD.gn index fc85e41451..b38b640621 100644 --- a/usb/test/unittest/ddk_service/BUILD.gn +++ b/usb/test/unittest/ddk_service/BUILD.gn @@ -15,7 +15,7 @@ import("//build/config/sanitizers/sanitizers.gni") import("//build/test.gni") import("./../../../../../hdf_core/adapter/uhdf2/uhdf.gni") -module_output_path = "drivers_peripheral_usb/usb" +module_output_path = "drivers_peripheral_usb/drivers_peripheral_usb" ohos_unittest("usb_ddk_service_test") { include_dirs = [ "./../../../ddk_service/usb_service/include" ] diff --git a/usb/test/unittest/device_sdk/BUILD.gn b/usb/test/unittest/device_sdk/BUILD.gn index d89fdb5ce3..f66b50f0b9 100644 --- a/usb/test/unittest/device_sdk/BUILD.gn +++ b/usb/test/unittest/device_sdk/BUILD.gn @@ -48,7 +48,7 @@ if (defined(ohos_lite)) { ] } } else { - module_output_path = "hdf/usb" + module_output_path = "drivers_peripheral_usb/drivers_peripheral_usb" ohos_unittest("usb_device_sdk_if_test") { module_out_path = module_output_path include_dirs = [ diff --git a/usb/test/unittest/hal/BUILD.gn b/usb/test/unittest/hal/BUILD.gn index 59d2736330..da1eab0010 100755 --- a/usb/test/unittest/hal/BUILD.gn +++ b/usb/test/unittest/hal/BUILD.gn @@ -14,7 +14,7 @@ import("//build/test.gni") import("./../../../usb.gni") -module_output_path = "drivers_peripheral_usb/usb" +module_output_path = "drivers_peripheral_usb/drivers_peripheral_usb" config("module_private_config") { visibility = [ ":*" ] diff --git a/usb/test/unittest/host_sdk/BUILD.gn b/usb/test/unittest/host_sdk/BUILD.gn index 6a00b00637..7bfedd5de5 100644 --- a/usb/test/unittest/host_sdk/BUILD.gn +++ b/usb/test/unittest/host_sdk/BUILD.gn @@ -133,7 +133,7 @@ if (defined(ohos_lite)) { ] } } else { - module_output_path = "hdf/usb" + module_output_path = "drivers_peripheral_usb/drivers_peripheral_usb" ohos_unittest("usb_host_sdk_if_test") { module_out_path = module_output_path include_dirs = [ diff --git a/usb/test/unittest/mock/BUILD.gn b/usb/test/unittest/mock/BUILD.gn index 5c8ff42e4e..63aa1a361c 100644 --- a/usb/test/unittest/mock/BUILD.gn +++ b/usb/test/unittest/mock/BUILD.gn @@ -14,7 +14,7 @@ import("//build/test.gni") import("./../../../usb.gni") -module_output_path = "hdf/usb" +module_output_path = "drivers_peripheral_usb/drivers_peripheral_usb" config("module_private_config") { visibility = [ ":*" ] -- Gitee From 5ddb36ac68bf91f76a679d4c6cc52519d9023394 Mon Sep 17 00:00:00 2001 From: yanghang Date: Thu, 13 Mar 2025 17:30:34 +0800 Subject: [PATCH 008/103] fix: log Signed-off-by: yanghang --- .../hdi_service/src/power_interface_impl.cpp | 12 +++++++----- .../hdi_service/src/running_lock_counter.cpp | 7 ++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/power/interfaces/hdi_service/src/power_interface_impl.cpp b/power/interfaces/hdi_service/src/power_interface_impl.cpp index a961f948b6..92e0f8668a 100644 --- a/power/interfaces/hdi_service/src/power_interface_impl.cpp +++ b/power/interfaces/hdi_service/src/power_interface_impl.cpp @@ -163,7 +163,7 @@ int32_t PowerInterfaceImpl::UnRegisterRunningLockCallback() int32_t PowerInterfaceImpl::StartSuspend() { std::lock_guard lock(g_mutex); - HDF_LOGI("start suspend"); + HDF_LOGI("staS3"); g_suspendRetry = true; if (g_suspending) { g_powerState = PowerHdfState::INACTIVE; @@ -270,7 +270,7 @@ int32_t DoSuspend() HDF_LOGD("DoSuspend SaveStringToFd"); bool ret = SaveStringToFd(suspendStateFd, SUSPEND_STATE); if (!ret) { - HDF_LOGE("DoSuspend fail"); + HDF_LOGE("S3 FA"); waitTime_ = std::min(waitTime_ * WAIT_TIME_FACTOR, MAX_WAIT_TIME); return HDF_FAILURE; } @@ -297,7 +297,7 @@ void NotifyCallback(int code) int32_t PowerInterfaceImpl::StopSuspend() { - HDF_LOGI("stop suspend"); + HDF_LOGI("stpS3"); g_suspendRetry = false; g_powerState = PowerHdfState::AWAKE; return HDF_SUCCESS; @@ -468,7 +468,8 @@ int32_t PowerInterfaceImpl::UnholdRunningLock(const RunningLockInfo &info) int32_t PowerInterfaceImpl::HoldRunningLockExt(const RunningLockInfo &info, uint64_t lockid, const std::string &bundleName) { - HDF_LOGI("Background runningLock active, type=%{public}d name=%{public}s", info.type, info.name.c_str()); + // Background runningLock active + HDF_LOGI("BL active,T=%{public}d,N=%{public}s", info.type, info.name.c_str()); Power::PowerXCollie powerXcollie("Power_HoldRunningLockExt"); return RunningLockImpl::HoldLock(info, g_powerState, lockid, bundleName); } @@ -476,7 +477,8 @@ int32_t PowerInterfaceImpl::HoldRunningLockExt(const RunningLockInfo &info, int32_t PowerInterfaceImpl::UnholdRunningLockExt(const RunningLockInfo &info, uint64_t lockid, const std::string &bundleName) { - HDF_LOGI("Background runningLock inactive, type=%{public}d name=%{public}s", info.type, info.name.c_str()); + // Background runningLock inactive + HDF_LOGI("BL inactive,T=%{public}d,N=%{public}s", info.type, info.name.c_str()); Power::PowerXCollie powerXcollie("Power_UnholdRunningLockExt"); return RunningLockImpl::UnholdLock(info, lockid, bundleName); } diff --git a/power/interfaces/hdi_service/src/running_lock_counter.cpp b/power/interfaces/hdi_service/src/running_lock_counter.cpp index f798eb45eb..a7af747578 100644 --- a/power/interfaces/hdi_service/src/running_lock_counter.cpp +++ b/power/interfaces/hdi_service/src/running_lock_counter.cpp @@ -27,8 +27,8 @@ int32_t RunningLockCounter::Increase(const RunningLockInfo &info) auto iterator = runninglockInfos_.find(info.name); if (iterator != runninglockInfos_.end()) { if (info.timeoutMs < 0) { - HDF_LOGW("Lock counter increase failed, runninglock name=%{public}s is exist and timeout < 0", - info.name.c_str()); + // Lock counter increase failed, runninglock is exist and timeout < 0 + HDF_LOGW("LCIF,N=%{public}s exist", info.name.c_str()); return HDF_FAILURE; } iterator->second.timeoutMs = info.timeoutMs; @@ -46,7 +46,8 @@ int32_t RunningLockCounter::Decrease(const RunningLockInfo &info) { auto iterator = runninglockInfos_.find(info.name); if (iterator == runninglockInfos_.end()) { - HDF_LOGW("Runninglock name=%{public}s is not exist, no need to decrease lock counter", info.name.c_str()); + // Runninglock is not exist, no need to decrease lock counter + HDF_LOGW("RL N=%{public}s no exist", info.name.c_str()); return HDF_ERR_NOT_SUPPORT; } --counter_; -- Gitee From e01e9c1dc19361d058189324ce2bbeed398fed77 Mon Sep 17 00:00:00 2001 From: luzhiye Date: Mon, 17 Mar 2025 08:53:05 +0000 Subject: [PATCH 009/103] =?UTF-8?q?=E7=9B=B4=E9=80=9ATDD=E7=94=A8=E4=BE=8B?= =?UTF-8?q?module=5Foutput=5Fpath=E9=83=A8=E4=BB=B6=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: luzhiye --- usb/test/unittest/passthrough/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usb/test/unittest/passthrough/BUILD.gn b/usb/test/unittest/passthrough/BUILD.gn index ad66172390..02c45745fa 100644 --- a/usb/test/unittest/passthrough/BUILD.gn +++ b/usb/test/unittest/passthrough/BUILD.gn @@ -14,7 +14,7 @@ import("//build/test.gni") import("./../../../usb.gni") -module_output_path = "drivers_peripheral_usb/usb" +module_output_path = "drivers_peripheral_usb/drivers_peripheral_usb" config("module_private_config") { visibility = [ ":*" ] -- Gitee From 09c1fa89a008fa104d36acb89e84155fc6a7d254 Mon Sep 17 00:00:00 2001 From: w30042960 Date: Mon, 17 Mar 2025 15:44:41 +0800 Subject: [PATCH 010/103] modify outpath Signed-off-by: w30042960 --- .../audio/v1_0/test/unittest/audio_adapter_interface/BUILD.gn | 3 ++- .../audio/v1_0/test/unittest/audio_capture_extension/BUILD.gn | 3 ++- .../audio/v1_0/test/unittest/audio_capture_interface/BUILD.gn | 3 ++- .../audio/v1_0/test/unittest/audio_manager_interface/BUILD.gn | 3 ++- .../audio/v1_0/test/unittest/audio_render_extension/BUILD.gn | 3 ++- .../audio/v1_0/test/unittest/audio_render_interface/BUILD.gn | 3 ++- .../hdi_service/audio_ext/v1_0/test/unittest/BUILD.gn | 3 ++- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/BUILD.gn b/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/BUILD.gn index d8701ac217..d64580cf81 100644 --- a/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/BUILD.gn +++ b/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/BUILD.gn @@ -15,7 +15,8 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../../../../../distributedaudio.gni") -module_out_path = "distributed_audio/hdf_service/hdi_service/audio" +module_out_path = + "distributed_audio/distributed_audio/hdf_service/hdi_service/audio" config("module_private_config") { visibility = [ ":*" ] diff --git a/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_extension/BUILD.gn b/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_extension/BUILD.gn index c326f9a064..1cf6faa97c 100644 --- a/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_extension/BUILD.gn +++ b/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_extension/BUILD.gn @@ -16,7 +16,8 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../../../../../distributedaudio.gni") -module_out_path = "distributed_audio/hdf_service/hdi_service/audio" +module_out_path = + "distributed_audio/distributed_audio/hdf_service/hdi_service/audio" config("module_private_config") { visibility = [ ":*" ] diff --git a/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/BUILD.gn b/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/BUILD.gn index bed1ee5159..820a5ac73c 100644 --- a/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/BUILD.gn +++ b/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/BUILD.gn @@ -15,7 +15,8 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../../../../../distributedaudio.gni") -module_out_path = "distributed_audio/hdf_service/hdi_service/audio" +module_out_path = + "distributed_audio/distributed_audio/hdf_service/hdi_service/audio" config("module_private_config") { visibility = [ ":*" ] diff --git a/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/BUILD.gn b/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/BUILD.gn index 7defa0350a..ebe2ecd11e 100644 --- a/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/BUILD.gn +++ b/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/BUILD.gn @@ -15,7 +15,8 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../../../../../distributedaudio.gni") -module_out_path = "distributed_audio/hdf_service/hdi_service/audio" +module_out_path = + "distributed_audio/distributed_audio/hdf_service/hdi_service/audio" config("module_private_config") { visibility = [ ":*" ] diff --git a/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_extension/BUILD.gn b/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_extension/BUILD.gn index 94ac8b5ad7..7b62ffb95d 100644 --- a/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_extension/BUILD.gn +++ b/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_extension/BUILD.gn @@ -16,7 +16,8 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../../../../../distributedaudio.gni") -module_out_path = "distributed_audio/hdf_service/hdi_service/audio" +module_out_path = + "distributed_audio/distributed_audio/hdf_service/hdi_service/audio" config("module_private_config") { visibility = [ ":*" ] diff --git a/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/BUILD.gn b/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/BUILD.gn index c8e41689a6..697816b9a4 100644 --- a/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/BUILD.gn +++ b/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/BUILD.gn @@ -15,7 +15,8 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../../../../../distributedaudio.gni") -module_out_path = "distributed_audio/hdf_service/hdi_service/audio" +module_out_path = + "distributed_audio/distributed_audio/hdf_service/hdi_service/audio" config("module_private_config") { visibility = [ ":*" ] diff --git a/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/BUILD.gn b/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/BUILD.gn index 78ec756187..1874bf02de 100644 --- a/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/BUILD.gn +++ b/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/BUILD.gn @@ -15,7 +15,8 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../../../../distributedaudio.gni") -module_out_path = "distributed_audio/hdf_service/hdi_service/audio_ext" +module_out_path = + "distributed_audio/distributed_audio/hdf_service/hdi_service/audio_ext" config("module_private_config") { visibility = [ ":*" ] -- Gitee From 407bd0163ccca31b0ca8bbcf00d624c43e5a06a1 Mon Sep 17 00:00:00 2001 From: l60050612 Date: Mon, 17 Mar 2025 17:43:16 +0800 Subject: [PATCH 011/103] =?UTF-8?q?audio=E6=A8=A1=E5=9D=97=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E7=BC=96=E7=A0=81=E8=A7=84=E8=8C=83=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l60050612 --- .../audiocapture_fuzzer/audiocapture_fuzzer.cpp | 3 ++- .../fuzztest/audio_hdi_fuzzer/audiomanager_fuzzer/BUILD.gn | 6 +++++- .../audiomanager_fuzzer/audiomanager_fuzzer.cpp | 2 ++ .../audiooffloadrender_fuzzer/audiooffloadrender_fuzzer.cpp | 3 ++- .../common/hdi_service_common/include/hdi_service_common.h | 4 ++++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/audio/test/fuzztest/audio_hdi_fuzzer/audiocapture_fuzzer/audiocapture_fuzzer.cpp b/audio/test/fuzztest/audio_hdi_fuzzer/audiocapture_fuzzer/audiocapture_fuzzer.cpp index d33588cbe4..930ac8a347 100644 --- a/audio/test/fuzztest/audio_hdi_fuzzer/audiocapture_fuzzer/audiocapture_fuzzer.cpp +++ b/audio/test/fuzztest/audio_hdi_fuzzer/audiocapture_fuzzer/audiocapture_fuzzer.cpp @@ -41,7 +41,8 @@ static uint32_t Convert2Uint32(const uint8_t *ptr) * Move the 0th digit 24 to the left, the first digit 16 to the left, the second digit 8 to the left, * and the third digit no left */ - return (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]); + return (ptr[BUFFER_INDEX_ZERO] << PCM_24_BIT) | (ptr[BUFFER_INDEX_ONE] << PCM_16_BIT) | + (ptr[BUFFER_INDEX_TWO] << PCM_8_BIT) | (ptr[BUFFER_INDEX_THREE]); } static int32_t InitScene(const struct AudioSceneDescriptor *scene) diff --git a/audio/test/fuzztest/audio_hdi_fuzzer/audiomanager_fuzzer/BUILD.gn b/audio/test/fuzztest/audio_hdi_fuzzer/audiomanager_fuzzer/BUILD.gn index 6a251e186d..814cad7ac9 100644 --- a/audio/test/fuzztest/audio_hdi_fuzzer/audiomanager_fuzzer/BUILD.gn +++ b/audio/test/fuzztest/audio_hdi_fuzzer/audiomanager_fuzzer/BUILD.gn @@ -10,6 +10,7 @@ # 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. +hdf_test_path = "./../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -22,7 +23,10 @@ ohos_fuzztest("AudioManagerFuzzTest") { fuzz_config_file = "../audiomanager_fuzzer" sources = [ "audiomanager_fuzzer.cpp" ] - include_dirs = [ "include" ] + include_dirs = [ + "$hdf_test_path/systemtest/common/hdi_service_common/include/", + "include", + ] external_deps = [ "drivers_interface_audio:libaudio_proxy_4.0", "hdf_core:libhdf_utils", diff --git a/audio/test/fuzztest/audio_hdi_fuzzer/audiomanager_fuzzer/audiomanager_fuzzer.cpp b/audio/test/fuzztest/audio_hdi_fuzzer/audiomanager_fuzzer/audiomanager_fuzzer.cpp index b66d3b5d55..c4ab5a0fbe 100644 --- a/audio/test/fuzztest/audio_hdi_fuzzer/audiomanager_fuzzer/audiomanager_fuzzer.cpp +++ b/audio/test/fuzztest/audio_hdi_fuzzer/audiomanager_fuzzer/audiomanager_fuzzer.cpp @@ -15,6 +15,8 @@ #include "audiomanager_fuzzer.h" #include "v4_0/iaudio_manager.h" #include "v4_0/audio_types.h" +#include "hdi_service_common.h" + using namespace std; namespace OHOS { namespace Audio { diff --git a/audio/test/fuzztest/audio_hdi_fuzzer/audiooffloadrender_fuzzer/audiooffloadrender_fuzzer.cpp b/audio/test/fuzztest/audio_hdi_fuzzer/audiooffloadrender_fuzzer/audiooffloadrender_fuzzer.cpp index 2071dfaf9f..d0c5a38ef6 100644 --- a/audio/test/fuzztest/audio_hdi_fuzzer/audiooffloadrender_fuzzer/audiooffloadrender_fuzzer.cpp +++ b/audio/test/fuzztest/audio_hdi_fuzzer/audiooffloadrender_fuzzer/audiooffloadrender_fuzzer.cpp @@ -33,7 +33,8 @@ static uint32_t Convert2Uint32(const uint8_t *ptr) * Move the 0th digit 24 to the left, the first digit 16 to the left, the second digit 8 to the left, * and the third digit no left */ - return (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]); + return (ptr[BUFFER_INDEX_ZERO] << PCM_24_BIT) | (ptr[BUFFER_INDEX_ONE] << PCM_16_BIT) | + (ptr[BUFFER_INDEX_TWO] << PCM_8_BIT) | (ptr[BUFFER_INDEX_THREE]); } void RenderFucSwitch(struct IAudioRender *&render, uint32_t cmd, const uint8_t *&rawData, size_t size) diff --git a/audio/test/systemtest/common/hdi_service_common/include/hdi_service_common.h b/audio/test/systemtest/common/hdi_service_common/include/hdi_service_common.h index 925fa68c82..8636f0c3a0 100644 --- a/audio/test/systemtest/common/hdi_service_common/include/hdi_service_common.h +++ b/audio/test/systemtest/common/hdi_service_common/include/hdi_service_common.h @@ -84,6 +84,10 @@ constexpr int PCM_8_BIT = 8; constexpr int PCM_16_BIT = 16; constexpr int PCM_24_BIT = 24; constexpr int PCM_32_BIT = 32; +constexpr int BUFFER_INDEX_ZERO = 0; +constexpr int BUFFER_INDEX_ONE = 1; +constexpr int BUFFER_INDEX_TWO = 2; +constexpr int BUFFER_INDEX_THREE = 3; constexpr int SAMPLE_RATE_8000 = 8000; constexpr int SAMPLE_RATE_11025 = 11025; constexpr int SAMPLE_RATE_22050 = 22050; -- Gitee From 63b108f8f7f76c51d6d52fcf55acb7c41a4e3e1a Mon Sep 17 00:00:00 2001 From: l60050612 Date: Mon, 17 Mar 2025 10:40:11 +0000 Subject: [PATCH 012/103] update audio/test/fuzztest/audio_hdi_fuzzer/audiocapture_fuzzer/audiocapture_fuzzer.cpp. Signed-off-by: l60050612 --- .../audiocapture_fuzzer/audiocapture_fuzzer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/test/fuzztest/audio_hdi_fuzzer/audiocapture_fuzzer/audiocapture_fuzzer.cpp b/audio/test/fuzztest/audio_hdi_fuzzer/audiocapture_fuzzer/audiocapture_fuzzer.cpp index 930ac8a347..2a560c2887 100644 --- a/audio/test/fuzztest/audio_hdi_fuzzer/audiocapture_fuzzer/audiocapture_fuzzer.cpp +++ b/audio/test/fuzztest/audio_hdi_fuzzer/audiocapture_fuzzer/audiocapture_fuzzer.cpp @@ -42,7 +42,7 @@ static uint32_t Convert2Uint32(const uint8_t *ptr) * and the third digit no left */ return (ptr[BUFFER_INDEX_ZERO] << PCM_24_BIT) | (ptr[BUFFER_INDEX_ONE] << PCM_16_BIT) | - (ptr[BUFFER_INDEX_TWO] << PCM_8_BIT) | (ptr[BUFFER_INDEX_THREE]); + (ptr[BUFFER_INDEX_TWO] << PCM_8_BIT) | (ptr[BUFFER_INDEX_THREE]); } static int32_t InitScene(const struct AudioSceneDescriptor *scene) -- Gitee From 5183b8a3366261e8edb711253c65bb76e10616d0 Mon Sep 17 00:00:00 2001 From: luzhiye Date: Tue, 18 Mar 2025 15:03:55 +0800 Subject: [PATCH 013/103] =?UTF-8?q?=E5=AE=89=E5=85=A8=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=EF=BC=9Afor=E5=BE=AA=E7=8E=AF=E4=B8=AD=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E7=B1=BB=E5=9E=8B=E4=B8=8E=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=9E=84=E9=80=A0=E7=B1=BB=E5=9E=8B=E4=B8=8D=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: luzhiye --- usb/serial/src/libusb_serial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usb/serial/src/libusb_serial.cpp b/usb/serial/src/libusb_serial.cpp index abd0233360..d418c15b0a 100644 --- a/usb/serial/src/libusb_serial.cpp +++ b/usb/serial/src/libusb_serial.cpp @@ -242,7 +242,7 @@ int32_t LibusbSerial::SerialGetPortList(std::vector& portIds) HDF_LOGI("%{public}s: enter SerialGetPortList.", __func__); std::lock_guard lock(map_mutex_); portIds.clear(); - for (const std::pair& device : devices_) { + for (const auto& device : devices_) { SerialPort serialPort; libusb_device* dev = device.first; libusb_device_handle* handle = device.second.handle; -- Gitee From b68923e6678432642c6832569c0b60bbea2c2081 Mon Sep 17 00:00:00 2001 From: yangkan Date: Tue, 18 Mar 2025 15:58:23 +0800 Subject: [PATCH 014/103] =?UTF-8?q?sensor=E6=97=A5=E5=BF=97=E8=B6=85?= =?UTF-8?q?=E9=87=8F=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangkan --- motion/hdi_service/motion_if_service.cpp | 10 ++++++++-- sensor/hdi_service/sensor_clients_manager.cpp | 2 +- sensor/hdi_service/sensor_if_service.cpp | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/motion/hdi_service/motion_if_service.cpp b/motion/hdi_service/motion_if_service.cpp index d4e1732994..c8bb7945d2 100644 --- a/motion/hdi_service/motion_if_service.cpp +++ b/motion/hdi_service/motion_if_service.cpp @@ -81,7 +81,10 @@ int32_t MotionIfService::Init() int32_t MotionIfService::EnableMotion(int32_t motionType) { - HDF_LOGI("%{public}s: motionType is %{public}d", __func__, motionType); + if (motionType <= HDF_MOTION_TYPE_SECTION) { + HDF_LOGI("%{public}s: motionType is %{public}d", __func__, motionType); + } + if (motionVdiImpl_ == nullptr) { HDF_LOGE("%{public}s motionVdiImpl_ is nullptr", __func__); return HDF_FAILURE; @@ -104,7 +107,10 @@ int32_t MotionIfService::EnableMotion(int32_t motionType) int32_t MotionIfService::DisableMotion(int32_t motionType) { - HDF_LOGI("%{public}s: motionType is %{public}d", __func__, motionType); + if (motionType <= HDF_MOTION_TYPE_SECTION) { + HDF_LOGI("%{public}s: motionType is %{public}d", __func__, motionType); + } + if (motionVdiImpl_ == nullptr) { HDF_LOGE("%{public}s motionVdiImpl_ is nullptr", __func__); return HDF_FAILURE; diff --git a/sensor/hdi_service/sensor_clients_manager.cpp b/sensor/hdi_service/sensor_clients_manager.cpp index 4b2f0dd37e..ff32099e2e 100644 --- a/sensor/hdi_service/sensor_clients_manager.cpp +++ b/sensor/hdi_service/sensor_clients_manager.cpp @@ -327,7 +327,7 @@ bool SensorClientsManager::IsNeedCloseSensor(int sensorId, int serviceId) SENSOR_TRACE_PID; auto it = sensorUsed_.find(sensorId); if (it == sensorUsed_.end()) { - HDF_LOGE("%{public}s: sensor %{public}d has been disabled or not support", __func__, sensorId); + HDF_LOGD("%{public}s: sensor %{public}d has been disabled or not support", __func__, sensorId); return true; } sensorUsed_[sensorId].erase(serviceId); diff --git a/sensor/hdi_service/sensor_if_service.cpp b/sensor/hdi_service/sensor_if_service.cpp index 5a2db5902d..6ff95592fc 100644 --- a/sensor/hdi_service/sensor_if_service.cpp +++ b/sensor/hdi_service/sensor_if_service.cpp @@ -300,13 +300,13 @@ int32_t SensorIfService::SetDelay(int32_t sensorId, int64_t &samplingInterval, i if (it->sensorId == sensorId) { if (samplingInterval < it->minDelay) { samplingInterval = it->minDelay; - HDF_LOGI("%{public}s samplingInterval has been set minDelay %{public}s", __func__, + HDF_LOGD("%{public}s samplingInterval has been set minDelay %{public}s", __func__, std::to_string(samplingInterval).c_str()); return SENSOR_SUCCESS; } if (samplingInterval > it->maxDelay && it->maxDelay != REPORT_INTERVAL) { samplingInterval = it->maxDelay; - HDF_LOGI("%{public}s samplingInterval has been set maxDelay %{public}s", __func__, + HDF_LOGD("%{public}s samplingInterval has been set maxDelay %{public}s", __func__, std::to_string(samplingInterval).c_str()); return SENSOR_SUCCESS; } -- Gitee From 50817804cacb7c46da7612aad1140829930a0947 Mon Sep 17 00:00:00 2001 From: youshugen Date: Tue, 18 Mar 2025 16:15:56 +0800 Subject: [PATCH 015/103] fix: alarming improve Signed-off-by: youshugen --- battery/interfaces/hdi_service/test/systemtest/BUILD.gn | 2 +- battery/interfaces/hdi_service/test/unittest/BUILD.gn | 2 +- power/test/unittest/BUILD.gn | 2 +- thermal/test/unittest/BUILD.gn | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/battery/interfaces/hdi_service/test/systemtest/BUILD.gn b/battery/interfaces/hdi_service/test/systemtest/BUILD.gn index 4ec5cbb8b9..11b409afa1 100644 --- a/battery/interfaces/hdi_service/test/systemtest/BUILD.gn +++ b/battery/interfaces/hdi_service/test/systemtest/BUILD.gn @@ -14,7 +14,7 @@ import("//build/test.gni") import("../../../../battery.gni") -module_output_path = "drivers_peripheral_battery/battery" +module_output_path = "drivers_peripheral_battery/drivers_peripheral_battery" ############################################################################### config("module_private_config") { diff --git a/battery/interfaces/hdi_service/test/unittest/BUILD.gn b/battery/interfaces/hdi_service/test/unittest/BUILD.gn index 2602658cb5..4c29e8786c 100644 --- a/battery/interfaces/hdi_service/test/unittest/BUILD.gn +++ b/battery/interfaces/hdi_service/test/unittest/BUILD.gn @@ -13,7 +13,7 @@ import("//build/test.gni") import("../../../../battery.gni") -module_output_path = "drivers_peripheral_battery/battery" +module_output_path = "drivers_peripheral_battery/drivers_peripheral_battery" ############################################################################### config("module_private_config") { diff --git a/power/test/unittest/BUILD.gn b/power/test/unittest/BUILD.gn index 469e6a1d0f..f47756c440 100644 --- a/power/test/unittest/BUILD.gn +++ b/power/test/unittest/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../power.gni") -module_output_path = "drivers_peripheral_power/power" +module_output_path = "drivers_peripheral_power/drivers_peripheral_power" power_hdi_service_path = "../../interfaces/hdi_service" ohos_unittest("hdi_unittest_power") { diff --git a/thermal/test/unittest/BUILD.gn b/thermal/test/unittest/BUILD.gn index 294d5a2224..f5915865f2 100644 --- a/thermal/test/unittest/BUILD.gn +++ b/thermal/test/unittest/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../thermal.gni") -module_output_path = "drivers_peripheral_thermal/thermal" +module_output_path = "drivers_peripheral_thermal/drivers_peripheral_thermal" ohos_unittest("hdi_unittest_thermal") { module_out_path = module_output_path -- Gitee From 293346b119071d1b8a97106447ddcf34772e2d05 Mon Sep 17 00:00:00 2001 From: l60050612 Date: Tue, 18 Mar 2025 16:56:46 +0800 Subject: [PATCH 016/103] =?UTF-8?q?drivers=5Fperipheral=20Tdd=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l60050612 --- audio/effect/test/unittest/BUILD.gn | 2 +- audio/test/systemtest/adm/audio_adm_interface/BUILD.gn | 2 +- audio/test/systemtest/hdi_service/common/adapter/BUILD.gn | 2 +- audio/test/systemtest/hdi_service/common/capture/BUILD.gn | 2 +- audio/test/systemtest/hdi_service/common/manager/BUILD.gn | 2 +- audio/test/systemtest/hdi_service/common/render/BUILD.gn | 2 +- audio/test/systemtest/hdi_service/hdiperformace/BUILD.gn | 2 +- .../hdi_service/hispark_taurus_standard/capture/BUILD.gn | 2 +- .../hdi_service/hispark_taurus_standard/render/BUILD.gn | 2 +- audio/test/systemtest/hdi_service/rk3568/capture/BUILD.gn | 2 +- audio/test/systemtest/hdi_service/rk3568/render/BUILD.gn | 2 +- audio/test/systemtest/supportlibs/common/capture/BUILD.gn | 2 +- audio/test/systemtest/supportlibs/common/render/BUILD.gn | 2 +- .../systemtest/supportlibs/hardwaredependence/capture/BUILD.gn | 2 +- .../systemtest/supportlibs/hardwaredependence/render/BUILD.gn | 2 +- display/buffer/test/unittest/BUILD.gn | 2 +- display/composer/test/unittest/BUILD.gn | 2 +- light/test/unittest/BUILD.gn | 2 +- light/test/unittest/hdi/BUILD.gn | 2 +- motion/test/unittest/hdi/BUILD.gn | 2 +- sensor/test/unittest/BUILD.gn | 2 +- sensor/test/unittest/dump/BUILD.gn | 2 +- sensor/test/unittest/hdi/BUILD.gn | 2 +- vibrator/test/unittest/BUILD.gn | 2 +- vibrator/test/unittest/hdi/BUILD.gn | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/audio/effect/test/unittest/BUILD.gn b/audio/effect/test/unittest/BUILD.gn index 7047eb5dd9..b81a4cdd1b 100644 --- a/audio/effect/test/unittest/BUILD.gn +++ b/audio/effect/test/unittest/BUILD.gn @@ -15,7 +15,7 @@ import("//build/test.gni") import("./../../../audio.gni") ohos_unittest("hdf_effect_hdi_ut") { - module_out_path = "drivers_peripheral_audio/audio" + module_out_path = "drivers_peripheral_audio/drivers_peripheral_audio" sources = [ "effect_common.cpp", "effect_control_test.cpp", diff --git a/audio/test/systemtest/adm/audio_adm_interface/BUILD.gn b/audio/test/systemtest/adm/audio_adm_interface/BUILD.gn index 39e350d37d..77f9c18eeb 100644 --- a/audio/test/systemtest/adm/audio_adm_interface/BUILD.gn +++ b/audio/test/systemtest/adm/audio_adm_interface/BUILD.gn @@ -45,7 +45,7 @@ if (defined(ohos_lite)) { ] } } else { - module_output_path = "drivers_peripheral_audio/audio" + module_output_path = "drivers_peripheral_audio/drivers_peripheral_audio" ohos_systemtest("hdf_audio_adm_interface_test") { resource_config_file = "./../../../resource/ohos_test.xml" diff --git a/audio/test/systemtest/hdi_service/common/adapter/BUILD.gn b/audio/test/systemtest/hdi_service/common/adapter/BUILD.gn index 408466c2a2..ec70c71156 100644 --- a/audio/test/systemtest/hdi_service/common/adapter/BUILD.gn +++ b/audio/test/systemtest/hdi_service/common/adapter/BUILD.gn @@ -14,7 +14,7 @@ import("//build/test.gni") import("./../../../../../audio.gni") -module_output_path = "drivers_peripheral_audio/audio" +module_output_path = "drivers_peripheral_audio/drivers_peripheral_audio" ohos_systemtest("hdf_audio_idlhdi_adapter_test") { module_out_path = module_output_path diff --git a/audio/test/systemtest/hdi_service/common/capture/BUILD.gn b/audio/test/systemtest/hdi_service/common/capture/BUILD.gn index 6bd269616b..16f6a12280 100644 --- a/audio/test/systemtest/hdi_service/common/capture/BUILD.gn +++ b/audio/test/systemtest/hdi_service/common/capture/BUILD.gn @@ -17,7 +17,7 @@ if (!defined(ohos_lite)) { import("./../../../../../audio.gni") if (!defined(ohos_lite)) { - module_output_path = "drivers_peripheral_audio/audio" + module_output_path = "drivers_peripheral_audio/drivers_peripheral_audio" ohos_systemtest("hdf_audio_idlhdi_capture_test") { module_out_path = module_output_path diff --git a/audio/test/systemtest/hdi_service/common/manager/BUILD.gn b/audio/test/systemtest/hdi_service/common/manager/BUILD.gn index 25d8e19f23..a55038c008 100644 --- a/audio/test/systemtest/hdi_service/common/manager/BUILD.gn +++ b/audio/test/systemtest/hdi_service/common/manager/BUILD.gn @@ -17,7 +17,7 @@ if (!defined(ohos_lite)) { import("./../../../../../audio.gni") if (!defined(ohos_lite)) { - module_output_path = "drivers_peripheral_audio/audio" + module_output_path = "drivers_peripheral_audio/drivers_peripheral_audio" ohos_systemtest("hdf_audio_idlhdi_manager_test") { module_out_path = module_output_path diff --git a/audio/test/systemtest/hdi_service/common/render/BUILD.gn b/audio/test/systemtest/hdi_service/common/render/BUILD.gn index 2f1279e2f7..82c314ead2 100644 --- a/audio/test/systemtest/hdi_service/common/render/BUILD.gn +++ b/audio/test/systemtest/hdi_service/common/render/BUILD.gn @@ -16,7 +16,7 @@ hdf_audio_path = "./../../../../.." import("//build/test.gni") import("$hdf_audio_path/audio.gni") -module_output_path = "drivers_peripheral_audio/audio" +module_output_path = "drivers_peripheral_audio/drivers_peripheral_audio" ohos_systemtest("hdf_audio_idlhdi_render_test") { module_out_path = module_output_path diff --git a/audio/test/systemtest/hdi_service/hdiperformace/BUILD.gn b/audio/test/systemtest/hdi_service/hdiperformace/BUILD.gn index 74896bc8b1..a51db3f4f7 100644 --- a/audio/test/systemtest/hdi_service/hdiperformace/BUILD.gn +++ b/audio/test/systemtest/hdi_service/hdiperformace/BUILD.gn @@ -16,7 +16,7 @@ hdf_audio_path = "./../../../.." import("//build/test.gni") import("$hdf_audio_path/audio.gni") -module_output_path = "drivers_peripheral_audio/audio" +module_output_path = "drivers_peripheral_audio/drivers_peripheral_audio" ohos_systemtest("hdf_audio_idlhdi_performace_test") { module_out_path = module_output_path diff --git a/audio/test/systemtest/hdi_service/hispark_taurus_standard/capture/BUILD.gn b/audio/test/systemtest/hdi_service/hispark_taurus_standard/capture/BUILD.gn index 0c2076f233..5e4d59b563 100644 --- a/audio/test/systemtest/hdi_service/hispark_taurus_standard/capture/BUILD.gn +++ b/audio/test/systemtest/hdi_service/hispark_taurus_standard/capture/BUILD.gn @@ -14,7 +14,7 @@ import("//build/test.gni") import("./../../../../../audio.gni") -module_output_path = "drivers_peripheral_audio/audio" +module_output_path = "drivers_peripheral_audio/drivers_peripheral_audio" ohos_systemtest("hdf_audio_idlhdi_capture_hardware_dependence_test") { module_out_path = module_output_path diff --git a/audio/test/systemtest/hdi_service/hispark_taurus_standard/render/BUILD.gn b/audio/test/systemtest/hdi_service/hispark_taurus_standard/render/BUILD.gn index 172b03521a..8757eaca48 100644 --- a/audio/test/systemtest/hdi_service/hispark_taurus_standard/render/BUILD.gn +++ b/audio/test/systemtest/hdi_service/hispark_taurus_standard/render/BUILD.gn @@ -16,7 +16,7 @@ hdf_audio_path = "./../../../../.." import("//build/test.gni") import("$hdf_audio_path/audio.gni") -module_output_path = "drivers_peripheral_audio/audio" +module_output_path = "drivers_peripheral_audio/drivers_peripheral_audio" ohos_systemtest("hdf_audio_idlhdi_render_hardware_dependence_test") { module_out_path = module_output_path diff --git a/audio/test/systemtest/hdi_service/rk3568/capture/BUILD.gn b/audio/test/systemtest/hdi_service/rk3568/capture/BUILD.gn index cda3344781..d80a4a4168 100644 --- a/audio/test/systemtest/hdi_service/rk3568/capture/BUILD.gn +++ b/audio/test/systemtest/hdi_service/rk3568/capture/BUILD.gn @@ -14,7 +14,7 @@ import("//build/test.gni") import("./../../../../../audio.gni") -module_output_path = "drivers_peripheral_audio/audio" +module_output_path = "drivers_peripheral_audio/drivers_peripheral_audio" ohos_systemtest("hdf_audio_idlhdi_capture_hardware_dependence_test") { module_out_path = module_output_path diff --git a/audio/test/systemtest/hdi_service/rk3568/render/BUILD.gn b/audio/test/systemtest/hdi_service/rk3568/render/BUILD.gn index 3efdc95c47..b71880de19 100644 --- a/audio/test/systemtest/hdi_service/rk3568/render/BUILD.gn +++ b/audio/test/systemtest/hdi_service/rk3568/render/BUILD.gn @@ -16,7 +16,7 @@ hdf_audio_path = "./../../../../.." import("//build/test.gni") import("$hdf_audio_path/audio.gni") -module_output_path = "drivers_peripheral_audio/audio" +module_output_path = "drivers_peripheral_audio/drivers_peripheral_audio" ohos_systemtest("hdf_audio_idlhdi_render_hardware_dependence_test") { module_out_path = module_output_path diff --git a/audio/test/systemtest/supportlibs/common/capture/BUILD.gn b/audio/test/systemtest/supportlibs/common/capture/BUILD.gn index ab9e28c253..0755f2020b 100644 --- a/audio/test/systemtest/supportlibs/common/capture/BUILD.gn +++ b/audio/test/systemtest/supportlibs/common/capture/BUILD.gn @@ -52,7 +52,7 @@ if (defined(ohos_lite)) { ] } } else { - module_output_path = "drivers_peripheral_audio/audio" + module_output_path = "drivers_peripheral_audio/drivers_peripheral_audio" ohos_systemtest("hdf_audio_lib_capture_test") { module_out_path = module_output_path diff --git a/audio/test/systemtest/supportlibs/common/render/BUILD.gn b/audio/test/systemtest/supportlibs/common/render/BUILD.gn index 9e67deef66..e523b0c44f 100644 --- a/audio/test/systemtest/supportlibs/common/render/BUILD.gn +++ b/audio/test/systemtest/supportlibs/common/render/BUILD.gn @@ -53,7 +53,7 @@ if (defined(ohos_lite)) { ] } } else { - module_output_path = "drivers_peripheral_audio/audio" + module_output_path = "drivers_peripheral_audio/drivers_peripheral_audio" ohos_systemtest("hdf_audio_lib_render_test") { module_out_path = module_output_path diff --git a/audio/test/systemtest/supportlibs/hardwaredependence/capture/BUILD.gn b/audio/test/systemtest/supportlibs/hardwaredependence/capture/BUILD.gn index 8c0896424c..35ac9ec3f5 100644 --- a/audio/test/systemtest/supportlibs/hardwaredependence/capture/BUILD.gn +++ b/audio/test/systemtest/supportlibs/hardwaredependence/capture/BUILD.gn @@ -53,7 +53,7 @@ if (defined(ohos_lite)) { ] } } else { - module_output_path = "drivers_peripheral_audio/audio" + module_output_path = "drivers_peripheral_audio/drivers_peripheral_audio" ohos_systemtest("hdf_audio_lib_capture_hardwaredependence_test") { module_out_path = module_output_path diff --git a/audio/test/systemtest/supportlibs/hardwaredependence/render/BUILD.gn b/audio/test/systemtest/supportlibs/hardwaredependence/render/BUILD.gn index 4a2e870b67..cd5a961975 100644 --- a/audio/test/systemtest/supportlibs/hardwaredependence/render/BUILD.gn +++ b/audio/test/systemtest/supportlibs/hardwaredependence/render/BUILD.gn @@ -53,7 +53,7 @@ if (defined(ohos_lite)) { ] } } else { - module_output_path = "drivers_peripheral_audio/audio" + module_output_path = "drivers_peripheral_audio/drivers_peripheral_audio" ohos_systemtest("hdf_audio_lib_render_hardwaredependence_test") { module_out_path = module_output_path diff --git a/display/buffer/test/unittest/BUILD.gn b/display/buffer/test/unittest/BUILD.gn index 226a881d4f..35e8c4d614 100644 --- a/display/buffer/test/unittest/BUILD.gn +++ b/display/buffer/test/unittest/BUILD.gn @@ -14,7 +14,7 @@ import("//build/test.gni") import("./../../../display_config.gni") -module_output_path = "drivers_peripheral_display/buffer" +module_output_path = "drivers_peripheral_display/drivers_peripheral_display" ohos_unittest("hdf_disp_buffer_unittest") { defines = [] diff --git a/display/composer/test/unittest/BUILD.gn b/display/composer/test/unittest/BUILD.gn index 5fe10bdbef..e521b1a3fc 100644 --- a/display/composer/test/unittest/BUILD.gn +++ b/display/composer/test/unittest/BUILD.gn @@ -21,7 +21,7 @@ group("hdf_disp_composer_unittest") { ] } -module_output_path = "drivers_peripheral_display/composer" +module_output_path = "drivers_peripheral_display/drivers_peripheral_display" config("module_private_config") { visibility = [ ":*" ] diff --git a/light/test/unittest/BUILD.gn b/light/test/unittest/BUILD.gn index 09c37bb3b9..785182915b 100644 --- a/light/test/unittest/BUILD.gn +++ b/light/test/unittest/BUILD.gn @@ -51,7 +51,7 @@ if (defined(ohos_lite)) { external_deps = [ "hilog_lite:hilog_shared" ] } } else { - module_output_path = "drivers_peripheral_light/light" + module_output_path = "drivers_peripheral_light/drivers_peripheral_light" ohos_unittest("hdf_unittest_light") { module_out_path = module_output_path include_dirs = [] diff --git a/light/test/unittest/hdi/BUILD.gn b/light/test/unittest/hdi/BUILD.gn index fa620cc2a1..be9c0adb3c 100644 --- a/light/test/unittest/hdi/BUILD.gn +++ b/light/test/unittest/hdi/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../../light.gni") -module_output_path = "drivers_peripheral_light/light" +module_output_path = "drivers_peripheral_light/drivers_peripheral_light" ohos_unittest("hdf_unittest_hdi_light_common") { module_out_path = module_output_path include_dirs = [ "../../../interfaces/include" ] diff --git a/motion/test/unittest/hdi/BUILD.gn b/motion/test/unittest/hdi/BUILD.gn index b6376c828d..3f4782fab8 100644 --- a/motion/test/unittest/hdi/BUILD.gn +++ b/motion/test/unittest/hdi/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../../motion.gni") -module_output_path = "drivers_peripheral_motion/motion" +module_output_path = "drivers_peripheral_motion/drivers_peripheral_motion" ohos_unittest("hdi_unittest_motion") { module_out_path = module_output_path diff --git a/sensor/test/unittest/BUILD.gn b/sensor/test/unittest/BUILD.gn index 34e01f9800..001cc2e2bd 100644 --- a/sensor/test/unittest/BUILD.gn +++ b/sensor/test/unittest/BUILD.gn @@ -58,7 +58,7 @@ if (defined(ohos_lite)) { external_deps = [ "hilog_lite:hilog_shared" ] } } else { - module_output_path = "drivers_peripheral_sensor/sensor" + module_output_path = "drivers_peripheral_sensor/drivers_peripheral_sensor" ohos_unittest("hdf_unittest_sensor") { module_out_path = module_output_path include_dirs = [] diff --git a/sensor/test/unittest/dump/BUILD.gn b/sensor/test/unittest/dump/BUILD.gn index 30f940c7b3..d585874dfa 100644 --- a/sensor/test/unittest/dump/BUILD.gn +++ b/sensor/test/unittest/dump/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../../sensor.gni") -module_output_path = "drivers_peripheral_sensor/sensor" +module_output_path = "drivers_peripheral_sensor/drivers_peripheral_sensor" ohos_unittest("dump_unittest_sensor") { module_out_path = module_output_path diff --git a/sensor/test/unittest/hdi/BUILD.gn b/sensor/test/unittest/hdi/BUILD.gn index e14ee29cab..3e38927ecf 100644 --- a/sensor/test/unittest/hdi/BUILD.gn +++ b/sensor/test/unittest/hdi/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../../sensor.gni") -module_output_path = "drivers_peripheral_sensor/sensor" +module_output_path = "drivers_peripheral_sensor/drivers_peripheral_sensor" ohos_unittest("hdi_unittest_sensor") { module_out_path = module_output_path diff --git a/vibrator/test/unittest/BUILD.gn b/vibrator/test/unittest/BUILD.gn index bfc1a832e0..7582371cd4 100644 --- a/vibrator/test/unittest/BUILD.gn +++ b/vibrator/test/unittest/BUILD.gn @@ -51,7 +51,7 @@ if (defined(ohos_lite)) { external_deps = [ "hilog_lite:hilog_shared" ] } } else { - module_output_path = "hdf/vibrator" + module_output_path = "drivers_peripheral_vibrator/drivers_peripheral_vibrator" ohos_unittest("hdf_unittest_vibrator") { module_out_path = module_output_path include_dirs = [] diff --git a/vibrator/test/unittest/hdi/BUILD.gn b/vibrator/test/unittest/hdi/BUILD.gn index 1d7ebd9095..f3607717bd 100644 --- a/vibrator/test/unittest/hdi/BUILD.gn +++ b/vibrator/test/unittest/hdi/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../../vibrator.gni") -module_output_path = "hdf/vibrator" +module_output_path = "drivers_peripheral_vibrator/drivers_peripheral_vibrator" ohos_unittest("hdf_unittest_hdi_vibrator") { module_out_path = module_output_path include_dirs = [ -- Gitee From a34fe157a2c3438917eea73e78153ff7f34d5ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B6=E5=88=9D?= <1751382099@qq.com> Date: Tue, 18 Mar 2025 09:20:02 +0000 Subject: [PATCH 017/103] add thermal log param watch dac for other process MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 零初 <1751382099@qq.com> --- thermal/etc/thermal.para.dac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thermal/etc/thermal.para.dac b/thermal/etc/thermal.para.dac index 194919aba3..d16d0c7626 100644 --- a/thermal/etc/thermal.para.dac +++ b/thermal/etc/thermal.para.dac @@ -11,4 +11,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -persist.thermal.log.="power_host:power_host:500" +persist.thermal.log.="power_host:power_host:504" -- Gitee From 6f7ec74cad13a1adbb7d32aaf6833f0bd123b9d0 Mon Sep 17 00:00:00 2001 From: lvqiang214 Date: Tue, 11 Mar 2025 14:19:15 +0800 Subject: [PATCH 018/103] sync Signed-off-by: lvqiang214 --- intelligent_voice/hdi_service/engine/BUILD.gn | 2 ++ ...ibengine_manager_service_1_2.versionscript | 20 +++++++++++++++++++ .../hdi_service/trigger/BUILD.gn | 2 ++ ...btrigger_manager_service_1_1.versionscript | 20 +++++++++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 intelligent_voice/hdi_service/engine/libengine_manager_service_1_2.versionscript create mode 100644 intelligent_voice/hdi_service/trigger/libtrigger_manager_service_1_1.versionscript diff --git a/intelligent_voice/hdi_service/engine/BUILD.gn b/intelligent_voice/hdi_service/engine/BUILD.gn index f81cd2efb5..ec2f068014 100644 --- a/intelligent_voice/hdi_service/engine/BUILD.gn +++ b/intelligent_voice/hdi_service/engine/BUILD.gn @@ -42,6 +42,8 @@ ohos_shared_library("intell_voice_engine_manager_service_1.2") { ] } + version_script = "libengine_manager_service_1_2.versionscript" + install_enable = true install_images = [ chipset_base_dir ] subsystem_name = "hdf" diff --git a/intelligent_voice/hdi_service/engine/libengine_manager_service_1_2.versionscript b/intelligent_voice/hdi_service/engine/libengine_manager_service_1_2.versionscript new file mode 100644 index 0000000000..e5a4fdb94d --- /dev/null +++ b/intelligent_voice/hdi_service/engine/libengine_manager_service_1_2.versionscript @@ -0,0 +1,20 @@ +# Copyright (c) 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 +# +# 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. + +1.0 { + global: + IntellVoiceEngineManagerImplGetInstance; + IntellVoiceEngineManagerImplRelease; + local: + *; +}; \ No newline at end of file diff --git a/intelligent_voice/hdi_service/trigger/BUILD.gn b/intelligent_voice/hdi_service/trigger/BUILD.gn index 48f91bcb69..1700fc1af0 100644 --- a/intelligent_voice/hdi_service/trigger/BUILD.gn +++ b/intelligent_voice/hdi_service/trigger/BUILD.gn @@ -50,6 +50,8 @@ ohos_shared_library("intell_voice_trigger_manager_service_1.1") { ] } + version_script = "libtrigger_manager_service_1_1.versionscript" + install_enable = true install_images = [ chipset_base_dir ] subsystem_name = "hdf" diff --git a/intelligent_voice/hdi_service/trigger/libtrigger_manager_service_1_1.versionscript b/intelligent_voice/hdi_service/trigger/libtrigger_manager_service_1_1.versionscript new file mode 100644 index 0000000000..4b689e3f04 --- /dev/null +++ b/intelligent_voice/hdi_service/trigger/libtrigger_manager_service_1_1.versionscript @@ -0,0 +1,20 @@ +# Copyright (c) 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 +# +# 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. + +1.0 { + global: + IntellVoiceTriggerManagerImplGetInstance; + IntellVoiceTriggerManagerImplRelease; + local: + *; +}; \ No newline at end of file -- Gitee From 15bb29febada3e570168a161577f72e6f403ddb1 Mon Sep 17 00:00:00 2001 From: shilong Date: Tue, 18 Mar 2025 12:21:28 +0000 Subject: [PATCH 019/103] =?UTF-8?q?=E4=BF=AE=E6=94=B9module=5Foutput=5Fpat?= =?UTF-8?q?h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shilong --- input/test/unittest/BUILD.gn | 2 +- input/test/unittest/hdi/BUILD.gn | 2 +- input/test/unittest/hdi_passthrough_additional/BUILD.gn | 2 +- input/test/unittest/udriver/BUILD.gn | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/input/test/unittest/BUILD.gn b/input/test/unittest/BUILD.gn index 6c6a94caad..04bdb11395 100644 --- a/input/test/unittest/BUILD.gn +++ b/input/test/unittest/BUILD.gn @@ -58,7 +58,7 @@ if (defined(ohos_lite)) { ] } } else { - module_output_path = "drivers_peripheral_input/input" + module_output_path = "drivers_peripheral_input/drivers_peripheral_input" ohos_unittest("hdf_unittest_input") { module_out_path = module_output_path include_dirs = [ diff --git a/input/test/unittest/hdi/BUILD.gn b/input/test/unittest/hdi/BUILD.gn index 35088eed54..91af964201 100644 --- a/input/test/unittest/hdi/BUILD.gn +++ b/input/test/unittest/hdi/BUILD.gn @@ -14,7 +14,7 @@ import("//build/ohos.gni") import("//build/test.gni") -module_output_path = "drivers_peripheral_input/input" +module_output_path = "drivers_peripheral_input/drivers_peripheral_input" INPUT_ROOT_DIR = "./../../.." ohos_unittest("hdi_unittest_input") { diff --git a/input/test/unittest/hdi_passthrough_additional/BUILD.gn b/input/test/unittest/hdi_passthrough_additional/BUILD.gn index 4db579771d..7167f7fd91 100644 --- a/input/test/unittest/hdi_passthrough_additional/BUILD.gn +++ b/input/test/unittest/hdi_passthrough_additional/BUILD.gn @@ -14,7 +14,7 @@ import("//build/ohos.gni") import("//build/test.gni") -module_output_path = "drivers_peripheral_input/input" +module_output_path = "drivers_peripheral_input/drivers_peripheral_input" INPUT_ROOT_DIR = "./../../.." ohos_unittest("InputPassthroughAdditionalTest") { diff --git a/input/test/unittest/udriver/BUILD.gn b/input/test/unittest/udriver/BUILD.gn index d05304052f..53087fc156 100644 --- a/input/test/unittest/udriver/BUILD.gn +++ b/input/test/unittest/udriver/BUILD.gn @@ -14,7 +14,7 @@ import("//build/test.gni") hdi_input_base_path = "./../../.." -module_output_path = "drivers_peripheral_input/input" +module_output_path = "drivers_peripheral_input/drivers_peripheral_input" config("camhdi_impl_utest_config") { visibility = [ ":*" ] cflags_cc = [ -- Gitee From e8cbcbcc5092892f4a8af47518fb690470ab7c84 Mon Sep 17 00:00:00 2001 From: luzhiye Date: Tue, 18 Mar 2025 21:37:47 +0800 Subject: [PATCH 020/103] =?UTF-8?q?=E9=83=A8=E4=BB=B6=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=8C=96=E5=BC=B1=E8=80=A6=E5=90=88=E8=A7=A3=E8=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: luzhiye --- usb/bundle.json | 5 ++++- usb/usb.gni | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/usb/bundle.json b/usb/bundle.json index 9fe12df80c..78505bea6c 100644 --- a/usb/bundle.json +++ b/usb/bundle.json @@ -14,7 +14,10 @@ "subsystem": "hdf", "features": [ "drivers_peripheral_usb_feature_linux_native_model", - "drivers_peripheral_usb_feature_emulator_mode" + "drivers_peripheral_usb_feature_emulator_mode", + "drivers_peripheral_usb_feature_hiviewdfx_hisysevent" , + "drivers_peripheral_usb_feature_systemabilitymgr_samgr", + "drivers_peripheral_usb_feature_commonlibrary_c_utils" ], "hisysevent_config": [ "//drivers/peripheral/usb/hisysevent.yaml" diff --git a/usb/usb.gni b/usb/usb.gni index 1858e6ddd5..ced94dae22 100644 --- a/usb/usb.gni +++ b/usb/usb.gni @@ -17,22 +17,22 @@ usb_driver_part_name = "usb_driver" declare_args() { drivers_peripheral_usb_feature_linux_native_model = false drivers_peripheral_usb_feature_emulator_mode = false + drivers_peripheral_usb_feature_hiviewdfx_hisysevent = false + drivers_peripheral_usb_feature_systemabilitymgr_samgr = false + drivers_peripheral_usb_feature_commonlibrary_c_utils = false usb_hisysevent_enable = true - if (defined(global_parts_info) && - !defined(global_parts_info.hiviewdfx_hisysevent)) { + if (drivers_peripheral_usb_feature_hiviewdfx_hisysevent) { usb_hisysevent_enable = false } usb_samgr_enable = true - if (defined(global_parts_info) && - !defined(global_parts_info.systemabilitymgr_samgr)) { + if (drivers_peripheral_usb_feature_systemabilitymgr_samgr) { usb_samgr_enable = false } usb_c_utils_enable = true - if (defined(global_parts_info) && - !defined(global_parts_info.commonlibrary_c_utils)) { + if (drivers_peripheral_usb_feature_commonlibrary_c_utils) { usb_c_utils_enable = false } -- Gitee From a3030291ce286802fa735af210b51615802ede3d Mon Sep 17 00:00:00 2001 From: liaop11 Date: Wed, 19 Mar 2025 14:21:42 +0800 Subject: [PATCH 021/103] fix error code Signed-off-by: liaop11 --- usb/ddk/host/src/usb_interface_pool.c | 2 +- usb/ddk/host/src/usb_raw_api_library.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/usb/ddk/host/src/usb_interface_pool.c b/usb/ddk/host/src/usb_interface_pool.c index 3d30a2cf99..c603234fa2 100644 --- a/usb/ddk/host/src/usb_interface_pool.c +++ b/usb/ddk/host/src/usb_interface_pool.c @@ -504,7 +504,7 @@ static int32_t IfFillControlRequest( if (ret != EOK) { HDF_LOGE("%{public}s:%{public}d memcpy_s failed, ctrlReq.length = %{public}u", __func__, __LINE__, ctrlReq.length); - return ret; + return HDF_ERR_IO; } } } else { diff --git a/usb/ddk/host/src/usb_raw_api_library.c b/usb/ddk/host/src/usb_raw_api_library.c index 79610e54a9..8fa2ce8509 100644 --- a/usb/ddk/host/src/usb_raw_api_library.c +++ b/usb/ddk/host/src/usb_raw_api_library.c @@ -1062,7 +1062,7 @@ int32_t RawFillInterruptRequest(struct UsbHostRequest *request, const struct Usb if (UsbEndpointDirOut(fillRequestData->endPoint)) { if (memcpy_s(request->buffer, request->bufLen, fillRequestData->buffer, fillRequestData->length) != EOK) { HDF_LOGE("%{public}s:%{public}d memcpy_s failed!", __func__, __LINE__); - return HDF_FAILURE; + return HDF_ERR_IO; } } request->devHandle = (struct UsbDeviceHandle *)devHandle; -- Gitee From 3e21de9d5bed22a53b9147a3cadc8ca5d8031272 Mon Sep 17 00:00:00 2001 From: liaop11 Date: Wed, 19 Mar 2025 15:05:51 +0800 Subject: [PATCH 022/103] fix clean log Signed-off-by: liaop11 --- usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp | 10 +++++----- usb/libusb_adapter/src/libusb_adapter.cpp | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp b/usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp index 035d0ba60c..1549cba8f6 100755 --- a/usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp +++ b/usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp @@ -587,7 +587,7 @@ int32_t UsbfnMtpImpl::UsbMtpPortCancelRequest(struct UsbMtpPort *mtpPort) struct UsbFnRequest *queueReqTmp = nullptr; DLIST_FOR_EACH_ENTRY_SAFE(queueReq, queueReqTmp, queueHead, struct UsbFnRequest, list) { (void)UsbFnCancelRequest(queueReq); - HDF_LOGD("%{public}s:cancel read, req:%{public}p", __func__, queueReq); + HDF_LOGD("%{public}s:cancel read", __func__); } } DListHead *writeQueue = &(mtpPort->writeQueue); @@ -597,14 +597,14 @@ int32_t UsbfnMtpImpl::UsbMtpPortCancelRequest(struct UsbMtpPort *mtpPort) struct UsbFnRequest *queueReqTmp = nullptr; DLIST_FOR_EACH_ENTRY_SAFE(queueReq, queueReqTmp, writeQueue, struct UsbFnRequest, list) { (void)UsbFnCancelRequest(queueReq); - HDF_LOGD("%{public}s:cancel write, req:%{public}p", __func__, queueReq); + HDF_LOGD("%{public}s:cancel write", __func__); } } if (mtpPort->mtpDev != NULL && mtpPort->mtpDev->notifyReq != NULL) { struct UsbFnRequest *notifyReq = mtpPort->mtpDev->notifyReq; (void)UsbFnCancelRequest(notifyReq); - HDF_LOGD("%{public}s:cancel notifyReq, req:%{public}p", __func__, notifyReq); + HDF_LOGD("%{public}s:cancel notifyReq", __func__); } return HDF_SUCCESS; } @@ -667,7 +667,7 @@ int32_t UsbfnMtpImpl::UsbMtpDeviceClassRequest( struct UsbFnRequest *queueReqTmp = nullptr; DLIST_FOR_EACH_ENTRY_SAFE(queueReq, queueReqTmp, queueHead, struct UsbFnRequest, list) { (void)UsbFnCancelRequest(queueReq); - HDF_LOGD("%{public}s:cancel read, req:%{public}p", __func__, req); + HDF_LOGD("%{public}s:cancel read", __func__); } } DListHead *writeQueue = &(mtpDev->mtpPort->writeQueue); @@ -677,7 +677,7 @@ int32_t UsbfnMtpImpl::UsbMtpDeviceClassRequest( struct UsbFnRequest *queueReqTmp = nullptr; DLIST_FOR_EACH_ENTRY_SAFE(queueReq, queueReqTmp, writeQueue, struct UsbFnRequest, list) { (void)UsbFnCancelRequest(queueReq); - HDF_LOGD("%{public}s:cancel write, req:%{public}p", __func__, req); + HDF_LOGD("%{public}s:cancel write", __func__); } } HDF_LOGD("%{public}s:async post, readStart:%{public}d", __func__, mtpDev->mtpPort->readStarted); diff --git a/usb/libusb_adapter/src/libusb_adapter.cpp b/usb/libusb_adapter/src/libusb_adapter.cpp index df2a12410d..fe74a694da 100644 --- a/usb/libusb_adapter/src/libusb_adapter.cpp +++ b/usb/libusb_adapter/src/libusb_adapter.cpp @@ -1330,7 +1330,6 @@ unsigned char *LibusbAdapter::GetMmapFdAndBuffer(uint8_t busNumber, uint8_t busA HDF_LOGE("%{public}s: GetMmapBufferByFd failed", __func__); return nullptr; } - HDF_LOGD("%{public}s Get mmap fd: %{public}d and memBuf: %{public}p success", __func__, fd, memBuf); return memBuf; } -- Gitee From a7e4c05e0f839419aed33b248d8be9c5054857b8 Mon Sep 17 00:00:00 2001 From: shilong Date: Wed, 19 Mar 2025 07:22:57 +0000 Subject: [PATCH 023/103] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shilong --- usb/ddk/host/src/linux_adapter.c | 10 +++++----- usb/ddk/host/src/usb_interface_pool.c | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/usb/ddk/host/src/linux_adapter.c b/usb/ddk/host/src/linux_adapter.c index 4844163828..194dbe4dbd 100644 --- a/usb/ddk/host/src/linux_adapter.c +++ b/usb/ddk/host/src/linux_adapter.c @@ -173,16 +173,16 @@ static int32_t OsGetUsbFd(struct UsbDevice *dev, mode_t mode) return HDF_ERR_INVALID_PARAM; } - int32_t ret = GetMmapFd(dev); + char pathBuf[PATH_LEN] = {'\0'}; + int32_t ret = GetUsbDevicePath(dev, pathBuf, PATH_LEN); if (ret != HDF_SUCCESS) { - HDF_LOGE("%{public}s: get mmap fd failed:%{public}d", __func__, ret); + HDF_LOGE("%{public}s: get usb device path failed:%{public}d", __func__, ret); return ret; } - char pathBuf[PATH_LEN] = {'\0'}; - ret = GetUsbDevicePath(dev, pathBuf, PATH_LEN); + ret = GetMmapFd(dev); if (ret != HDF_SUCCESS) { - HDF_LOGE("%{public}s: get usb device path failed:%{public}d", __func__, ret); + HDF_LOGE("%{public}s: get mmap fd failed:%{public}d", __func__, ret); return ret; } diff --git a/usb/ddk/host/src/usb_interface_pool.c b/usb/ddk/host/src/usb_interface_pool.c index 3d30a2cf99..ccfccdf806 100644 --- a/usb/ddk/host/src/usb_interface_pool.c +++ b/usb/ddk/host/src/usb_interface_pool.c @@ -1733,9 +1733,11 @@ struct UsbRequest *UsbAllocRequestByAshmem( if (hostRequest == NULL) { HDF_LOGE("%{public}s: RawAllocRequest error", __func__); RawUsbMemFree(requestObj); + ifaceHdl->devHandle->isAshmem = false; return NULL; } hostRequest->devHandle = ifaceHdl->devHandle; + ifaceHdl->devHandle->isAshmem = false; ++g_usbRequestObjectId; g_usbRequestObjectId %= MAX_OBJECT_ID; -- Gitee From 44076d63a1404c982a5f5b6138de39b5c4bb3b5a Mon Sep 17 00:00:00 2001 From: 18191865724 Date: Wed, 19 Mar 2025 16:32:41 +0800 Subject: [PATCH 024/103] fix:UpdateFunctionStatus Signed-off-by: 18191865724 --- usb/hdi_service/include/usb_device_impl.h | 1 + usb/hdi_service/include/usb_port_impl.h | 1 - usb/hdi_service/src/usb_device_impl.cpp | 32 +++++++++++++++++++++++ usb/hdi_service/src/usb_port_impl.cpp | 32 ----------------------- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/usb/hdi_service/include/usb_device_impl.h b/usb/hdi_service/include/usb_device_impl.h index 8af49af5d1..84ef80f97f 100644 --- a/usb/hdi_service/include/usb_device_impl.h +++ b/usb/hdi_service/include/usb_device_impl.h @@ -61,6 +61,7 @@ public: private: static int32_t UsbdLoadServiceCallback(void *priv, uint32_t id, HdfSBuf *data); static int32_t UsbdPnpLoaderEventReceived(void *priv, uint32_t id, HdfSBuf *data); + static void UpdateFunctionStatus(void); static UsbdSubscriber subscribers_[MAX_SUBSCRIBER]; static bool isGadgetConnected_; static HdfDevEventlistener listenerForLoadService_; diff --git a/usb/hdi_service/include/usb_port_impl.h b/usb/hdi_service/include/usb_port_impl.h index db04c144b8..4ebe87bbd2 100644 --- a/usb/hdi_service/include/usb_port_impl.h +++ b/usb/hdi_service/include/usb_port_impl.h @@ -57,7 +57,6 @@ public: private: static int32_t UsbdPnpLoaderEventReceived(void *priv, uint32_t id, HdfSBuf *data); static int32_t UsbdLoadServiceCallback(void *priv, uint32_t id, HdfSBuf *data); - static void UpdateFunctionStatus(void); void ParsePortPath(); bool UsbPortImplInit(); static UsbdSubscriber subscribers_[MAX_SUBSCRIBER]; diff --git a/usb/hdi_service/src/usb_device_impl.cpp b/usb/hdi_service/src/usb_device_impl.cpp index de722c0fb9..ad9f1158a8 100644 --- a/usb/hdi_service/src/usb_device_impl.cpp +++ b/usb/hdi_service/src/usb_device_impl.cpp @@ -46,6 +46,17 @@ V1_2::UsbdLoadService UsbDeviceImpl::loadUsbService_ = {USB_SYSTEM_ABILITY_ID}; V1_2::UsbdLoadService UsbDeviceImpl::loadHdfEdm_ = {HDF_EXTERNAL_DEVICE_MANAGER_SA_ID}; UsbdSubscriber UsbDeviceImpl::subscribers_[MAX_SUBSCRIBER] = {{0}}; bool UsbDeviceImpl::isGadgetConnected_ = false; +constexpr uint32_t FUNCTION_VALUE_MAX_LEN = 32; +static const std::map configMap = { + {HDC_CONFIG_OFF, USB_FUNCTION_NONE}, + {HDC_CONFIG_HDC, USB_FUNCTION_HDC}, + {HDC_CONFIG_ON, USB_FUNCTION_HDC}, + {HDC_CONFIG_RNDIS, USB_FUNCTION_RNDIS}, + {HDC_CONFIG_STORAGE, USB_FUNCTION_STORAGE}, + {HDC_CONFIG_RNDIS_HDC, USB_FUNCTION_HDC + USB_FUNCTION_RNDIS}, + {HDC_CONFIG_STORAGE_HDC, USB_FUNCTION_HDC + USB_FUNCTION_STORAGE}, + {HDC_CONFIG_MANUFACTURE_HDC, USB_FUNCTION_MANUFACTURE} +}; extern "C" IUsbDeviceInterface *UsbDeviceInterfaceImplGetInstance(void) { using OHOS::HDI::Usb::V2_0::UsbDeviceImpl; @@ -277,9 +288,30 @@ int32_t UsbDeviceImpl::UsbdLoadServiceCallback(void *priv, uint32_t id, HdfSBuf return HDF_SUCCESS; } +void UsbDeviceImpl::UpdateFunctionStatus() +{ + HDF_LOGI("%{public}s: enter", __func__); + char cFunctionValue[FUNCTION_VALUE_MAX_LEN] = {0}; + int32_t ret = GetParameter(PERSIST_SYS_USB_CONFIG, "invalid", cFunctionValue, FUNCTION_VALUE_MAX_LEN); + if (ret <= 0) { + HDF_LOGE("%{public}s: GetParameter failed", __func__); + } + + std::string functionValue(cFunctionValue); + auto it = configMap.find(functionValue); + if (it != configMap.end()) { + HDF_LOGI("Function is %{public}s", functionValue.c_str()); + ret = V1_2::UsbdFunction::UsbdUpdateFunction(it->second); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%{public}s: UsbdUpdateFunction failed", __func__); + } + } +} + int32_t UsbDeviceImpl::UsbdEventHandle(void) { HDF_LOGI("%{public}s: enter", __func__); + UpdateFunctionStatus(); listenerForLoadService_.callBack = UsbdLoadServiceCallback; int32_t ret = DdkListenerMgrAdd(&listenerForLoadService_); if (ret != HDF_SUCCESS) { diff --git a/usb/hdi_service/src/usb_port_impl.cpp b/usb/hdi_service/src/usb_port_impl.cpp index 5b68d87f9f..fdac92c631 100644 --- a/usb/hdi_service/src/usb_port_impl.cpp +++ b/usb/hdi_service/src/usb_port_impl.cpp @@ -37,7 +37,6 @@ #define HDF_LOG_TAG UsbPortImpl using namespace OHOS::HiviewDFX; -constexpr uint32_t FUNCTION_VALUE_MAX_LEN = 32; namespace OHOS { namespace HDI { namespace Usb { @@ -45,16 +44,6 @@ namespace V2_0 { UsbdSubscriber UsbPortImpl::subscribers_[MAX_SUBSCRIBER] = {{0}}; bool UsbPortImpl::isGadgetConnected_ = false; std::vector usbPid_; -static const std::map configMap = { - {HDC_CONFIG_OFF, USB_FUNCTION_NONE}, - {HDC_CONFIG_HDC, USB_FUNCTION_HDC}, - {HDC_CONFIG_ON, USB_FUNCTION_HDC}, - {HDC_CONFIG_RNDIS, USB_FUNCTION_RNDIS}, - {HDC_CONFIG_STORAGE, USB_FUNCTION_STORAGE}, - {HDC_CONFIG_RNDIS_HDC, USB_FUNCTION_HDC + USB_FUNCTION_RNDIS}, - {HDC_CONFIG_STORAGE_HDC, USB_FUNCTION_HDC + USB_FUNCTION_STORAGE}, - {HDC_CONFIG_MANUFACTURE_HDC, USB_FUNCTION_MANUFACTURE} -}; extern "C" IUsbPortInterface *UsbPortInterfaceImplGetInstance(void) { using OHOS::HDI::Usb::V2_0::UsbPortImpl; @@ -249,30 +238,9 @@ void UsbPortImpl::ParsePortPath() return; } -void UsbPortImpl::UpdateFunctionStatus() -{ - HDF_LOGI("%{public}s: enter", __func__); - char cFunctionValue[FUNCTION_VALUE_MAX_LEN] = {0}; - int32_t ret = GetParameter(PERSIST_SYS_USB_CONFIG, "invalid", cFunctionValue, FUNCTION_VALUE_MAX_LEN); - if (ret <= 0) { - HDF_LOGE("%{public}s: GetParameter failed", __func__); - } - - std::string functionValue(cFunctionValue); - auto it = configMap.find(functionValue); - if (it != configMap.end()) { - HDF_LOGI("Function is %{public}s", functionValue.c_str()); - ret = V1_2::UsbdFunction::UsbdUpdateFunction(it->second); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%{public}s: UsbdUpdateFunction failed", __func__); - } - } -} - int32_t UsbPortImpl::UsbdEventHandle(const sptr &inst) { HDF_LOGI("%{public}s: enter", __func__); - UpdateFunctionStatus(); inst->ParsePortPath(); return HDF_SUCCESS; } -- Gitee From 6e4c991d3e23461ab8b5a952786d169f2173cd33 Mon Sep 17 00:00:00 2001 From: shenkang Date: Wed, 19 Mar 2025 17:05:02 +0800 Subject: [PATCH 025/103] fix:delete log of sense info Signed-off-by: shenkang --- .../scsi_service/src/scsi_ddk_service.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/usb/ddk_service/scsi_service/src/scsi_ddk_service.cpp b/usb/ddk_service/scsi_service/src/scsi_ddk_service.cpp index c2176e03b1..130c1f4e5b 100644 --- a/usb/ddk_service/scsi_service/src/scsi_ddk_service.cpp +++ b/usb/ddk_service/scsi_service/src/scsi_ddk_service.cpp @@ -26,8 +26,6 @@ #include #include #include -#include // for std::ostringstream -#include // for std::hex, std::dec, std::setw, std::setfill #include "ddk_sysfs_dev_node.h" #include "hdf_log.h" @@ -157,16 +155,6 @@ static inline uint32_t GetUint32(unsigned char *buf, int start) ); } -std::string BytesToHex(const uint8_t* data, size_t length) -{ - std::ostringstream oss; - oss << std::hex << std::setfill('0'); - for (size_t i = 0; i < length; ++i) { - oss << std::setw(TWO_BYTE) << static_cast(data[i]) << ' '; - } - return oss.str(); -} - static void BuildCdbForReadAndWrite(const ScsiPeripheralIORequest& request, unsigned char cdb[CDB_LENGTH_TEN], uint8_t operationCode) { @@ -564,8 +552,6 @@ int32_t ScsiDdkService::Read10(const ScsiPeripheralDevice& dev, HDF_LOGE("%{public}s: SendRequest failed, ret=%{public}d", __func__, ret); return ret; } - HDF_LOGD("%{public}s, bufferAddr=%{public}p, bufferData=[ %{public}s ]", __func__, buffer, - BytesToHex(reinterpret_cast(buffer), bufferSize).c_str()); UpdateResponseFromOsAdapter(response, resp); return HDF_SUCCESS; @@ -610,7 +596,6 @@ int32_t ScsiDdkService::Write10(const ScsiPeripheralDevice& dev, errno, dev.memMapFd, memMapSize); return SCSIPERIPHERAL_DDK_MEMORY_ERROR; } - HDF_LOGD("%{public}s: bufferAddr=%{public}p, bufferData=%{public}s", __func__, buffer, buffer); MemMapFinalizer memMapFinalizer(buffer, memMapSize); if (osAdapter_ == nullptr) { -- Gitee From 87f50b2058e4d4b8e80abfc5589f868f836ef638 Mon Sep 17 00:00:00 2001 From: dairan Date: Wed, 19 Mar 2025 09:45:47 +0000 Subject: [PATCH 026/103] update usb/serial/src/libusb_serial.cpp. Signed-off-by: dairan --- usb/serial/src/libusb_serial.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/usb/serial/src/libusb_serial.cpp b/usb/serial/src/libusb_serial.cpp index d418c15b0a..88ea408213 100644 --- a/usb/serial/src/libusb_serial.cpp +++ b/usb/serial/src/libusb_serial.cpp @@ -314,7 +314,7 @@ int32_t LibusbSerial::SerialRead(int32_t portId, std::vector& data, uin } ret = 0; ret = libusb_bulk_transfer(deviceHandleInfo.handle, - deviceHandleInfo.intputEndpointAddr, dataIn, size, &actualLength, timeout); + deviceHandleInfo.inputEndpointAddr, dataIn, size, &actualLength, timeout); if (ret < 0 && actualLength == 0) { libusb_release_interface(deviceHandleInfo.handle, deviceHandleInfo.interface); libusb_attach_kernel_driver(deviceHandleInfo.handle, deviceHandleInfo.interface); @@ -389,7 +389,7 @@ int LibusbSerial::GetEndPoint(DeviceHandleInfo *deviceHandleInfo) if ((endpoint->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) == LIBUSB_TRANSFER_TYPE_BULK && (endpoint->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN) { deviceHandleInfo->interface = j; - deviceHandleInfo->intputEndpointAddr = endpoint->bEndpointAddress; + deviceHandleInfo->inputEndpointAddr = endpoint->bEndpointAddress; endpointNum++; } if ((endpoint->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) == LIBUSB_TRANSFER_TYPE_BULK && @@ -620,31 +620,25 @@ bool CheckTtyDeviceInfo(std::string ttyUsbPath, libusb_device* device) busnumFd = open((ttyUsbPath + BUS_NUM_STR).c_str(), O_RDONLY); if (busnumFd < 0) { HDF_LOGE("%{public}s : open file failed. ret = %{public}s", __func__, strerror(errno)); - close(busnumFd); return false; } char busnumBuff[BUFFER_SIZE] = {'\0'}; ssize_t readBytes = read(busnumFd, busnumBuff, BUFFER_SIZE); + close(busnumFd); if (readBytes < 0) { - close(busnumFd); return false; } devnumFd = open((ttyUsbPath + DEV_NUM_STR).c_str(), O_RDONLY); if (devnumFd < 0) { HDF_LOGE("%{public}s : open file failed. ret = %{public}s", __func__, strerror(errno)); - close(devnumFd); - close(busnumFd); return false; } char devnumBuff[BUFFER_SIZE] = {'\0'}; readBytes = read(devnumFd, devnumBuff, BUFFER_SIZE); + close(devnumFd); if (readBytes < 0) { - close(busnumFd); - close(devnumFd); return false; } - close(devnumFd); - close(busnumFd); if (atoi(devnumBuff) == libusb_get_device_address(device) && atoi(busnumBuff) == libusb_get_bus_number(device)) { return true; } -- Gitee From 59369f5e4929ddb71ecadbf52bbac5d441662850 Mon Sep 17 00:00:00 2001 From: dairan Date: Wed, 19 Mar 2025 09:46:54 +0000 Subject: [PATCH 027/103] update usb/serial/include/libusb_serial.h. Signed-off-by: dairan --- usb/serial/include/libusb_serial.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usb/serial/include/libusb_serial.h b/usb/serial/include/libusb_serial.h index 9017d52f18..cd8b7d8fa1 100644 --- a/usb/serial/include/libusb_serial.h +++ b/usb/serial/include/libusb_serial.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 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 @@ -49,7 +49,7 @@ private: libusb_device_handle* handle; bool isOpen; uint8_t outputEndpointAddr; - uint8_t intputEndpointAddr; + uint8_t inputEndpointAddr; int32_t interface; } DeviceHandleInfo; -- Gitee From bfe13f8d5c41e2e1e95fdbbce3e776f0419f195c Mon Sep 17 00:00:00 2001 From: dairan Date: Wed, 19 Mar 2025 09:48:19 +0000 Subject: [PATCH 028/103] update usb/serial/src/serial_impl.cpp. Signed-off-by: dairan --- usb/serial/src/serial_impl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usb/serial/src/serial_impl.cpp b/usb/serial/src/serial_impl.cpp index 0be12b7cf2..98e58d70a9 100644 --- a/usb/serial/src/serial_impl.cpp +++ b/usb/serial/src/serial_impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 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 @@ -100,7 +100,7 @@ int32_t SerialImpl::SerialRead(int32_t portId, std::vector& data, uint3 int32_t ret = LibusbSerial::GetInstance().SerialRead(portId, data, size, timeout); #endif FinishTrace(HITRACE_TAG_HDF); - if (ret != HDF_SUCCESS) { + if (ret < HDF_SUCCESS) { HDF_LOGE("%{public}s:SerialRead failed, ret:%{public}d", __func__, ret); } @@ -116,7 +116,7 @@ int32_t SerialImpl::SerialWrite(int32_t portId, const std::vector& data int32_t ret = LibusbSerial::GetInstance().SerialWrite(portId, data, size, timeout); #endif FinishTrace(HITRACE_TAG_HDF); - if (ret != HDF_SUCCESS) { + if (ret < HDF_SUCCESS) { HDF_LOGE("%{public}s:SerialWrite failed, ret:%{public}d", __func__, ret); } -- Gitee From 8e8c086aa9647a9de1680c6249ab2f1700b35a50 Mon Sep 17 00:00:00 2001 From: dairan Date: Wed, 19 Mar 2025 09:49:18 +0000 Subject: [PATCH 029/103] update usb/serial/include/serial_impl.h. Signed-off-by: dairan --- usb/serial/include/serial_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usb/serial/include/serial_impl.h b/usb/serial/include/serial_impl.h index 89c078ff14..4f741be4a0 100644 --- a/usb/serial/include/serial_impl.h +++ b/usb/serial/include/serial_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 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 -- Gitee From 99f9bea8a635d256eb38675b6f976f442b8ab76c Mon Sep 17 00:00:00 2001 From: dairan Date: Wed, 19 Mar 2025 09:50:57 +0000 Subject: [PATCH 030/103] update usb/serial/include/linux_serial.h. Signed-off-by: dairan --- usb/serial/include/linux_serial.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usb/serial/include/linux_serial.h b/usb/serial/include/linux_serial.h index 531f899c36..2aeacc5b43 100644 --- a/usb/serial/include/linux_serial.h +++ b/usb/serial/include/linux_serial.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 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 -- Gitee From 5b19d14fd49b7a3bb6480e66cad6280298385adf Mon Sep 17 00:00:00 2001 From: dairan Date: Wed, 19 Mar 2025 09:52:40 +0000 Subject: [PATCH 031/103] update usb/serial/src/linux_serial.cpp. Signed-off-by: dairan --- usb/serial/src/linux_serial.cpp | 37 ++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/usb/serial/src/linux_serial.cpp b/usb/serial/src/linux_serial.cpp index af97d8a471..14b81af349 100644 --- a/usb/serial/src/linux_serial.cpp +++ b/usb/serial/src/linux_serial.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 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 @@ -85,10 +85,12 @@ BaudratePair g_baudratePairs[] = { LinuxSerial::LinuxSerial() { + HDF_LOGI("%{public}s: enter SerialUSBWrapper initialization.", __func__); } LinuxSerial::~LinuxSerial() { + HDF_LOGI("%{public}s: enter Destroying SerialUSBWrapper.", __func__); } LinuxSerial &LinuxSerial::GetInstance() @@ -129,7 +131,7 @@ tcflag_t LinuxSerial::GetDatabits(unsigned char dataBits) default: return HDF_FAILURE; } - return bit_temp; + return bit_temp; } tcflag_t LinuxSerial::GetParity(tcflag_t c_cflag, unsigned char parity) @@ -213,7 +215,7 @@ int32_t LinuxSerial::SerialOpen(int32_t portId) ret = snprintf_s(path, sizeof(path), sizeof(path)-1, "/dev/ttyUSB%d", portId); if (ret < 0) { HDF_LOGE("%{public}s: sprintf_s path failed, ret:%{public}d", __func__, ret); - return ret; + return HDF_FAILURE; } serialPortList_[index].fd = open(path, O_RDWR | O_NOCTTY | O_NDELAY); if (serialPortList_[index].fd <= 0) { @@ -221,11 +223,20 @@ int32_t LinuxSerial::SerialOpen(int32_t portId) return HDF_FAILURE; } - tcgetattr(serialPortList_[index].fd, &options_); + if (tcgetattr(serialPortList_[index].fd, &options_) = -1) { + close(serialPortList_[index].fd); + HDF_LOGE("%{public}s: get attribute failed %{public}d.", __func__, errno); + serialPortList_.erase(index); + return HDF_FAILURE; + } options_.c_lflag &= ~ICANON; options_.c_lflag &= ~ECHO; - tcsetattr(serialPortList_[index].fd, TCSANOW, &options_); - + if (tcsetattr(serialPortList_[index].fd, TCSANOW, &options_) = -1) { + close(serialPortList_[index].fd); + HDF_LOGE("%{public}s: set attribute failed %{public}d.", __func__, errno); + serialPortList_.erase(index); + return HDF_FAILURE; + } return HDF_SUCCESS; } @@ -315,7 +326,10 @@ int32_t LinuxSerial::SerialGetAttribute(int32_t portId, SerialAttribute& attribu if (fd < 0) { return ERR_CODE_DEVICENOTOPEN; } - tcgetattr(fd, &options_); + if (tcgetattr(fd, &options_) = -1) { + HDF_LOGE("%{public}s: get attribute failed %{public}d.", __func__, errno); + return HDF_FAILURE; + } for (const auto& pair : g_baudratePairs) { if (pair.second == cfgetispeed(&options_)) { @@ -361,7 +375,10 @@ int32_t LinuxSerial::SerialSetAttribute(int32_t portId, const SerialAttribute& a if (fd < 0) { return ERR_CODE_DEVICENOTOPEN; } - tcgetattr(fd, &options_); + if (tcgetattr(fd, &options_) = -1) { + HDF_LOGE("%{public}s: get attribute failed %{public}d.", __func__, errno); + return HDF_FAILURE; + } if (GetStopbits(options_.c_cflag, attribute.stopBits) < 0) { HDF_LOGE("%{public}s: stopBits set fail.", __func__); return GetStopbits(options_.c_cflag, attribute.stopBits); @@ -390,7 +407,7 @@ int32_t LinuxSerial::SerialSetAttribute(int32_t portId, const SerialAttribute& a while (retry-- > 0) { if (tcsetattr(fd, TCSANOW, &options_) == 0) { break; - } else if (errno != EINTR) { + } else { HDF_LOGE("%{public}s: tcsetattr failed.", __func__); } } @@ -435,7 +452,6 @@ void LinuxSerial::HandleDevListEntry(struct UsbPnpNotifyMatchInfoTable *device, serialPort.deviceInfo.devAddr = static_cast(device->devNum); serialPort.deviceInfo.vid = static_cast(devInfo->vendorId); serialPort.deviceInfo.pid = static_cast(devInfo->productId); - // serialPort.deviceInfo.serialNum = ""; auto it = std::find_if(serialPortList_.begin(), serialPortList_.end(), [&](const Serialfd& tempSerial) { return tempSerial.portId == serialPortId.portId; }); @@ -469,6 +485,7 @@ int32_t LinuxSerial::SerialGetPortList(std::vector& portIds) struct UsbDdkDeviceInfo *device = (struct UsbDdkDeviceInfo *)OsalMemCalloc(sizeof(struct UsbDdkDeviceInfo)); if (device == NULL) { HDF_LOGE("%{public}s: init device failed", __func__); + closedir(dir); return HDF_FAILURE; } int32_t status = HDF_SUCCESS; -- Gitee From aa0a877f78f8ef6c0dc9fc81f0a1d2bdbf52f7c1 Mon Sep 17 00:00:00 2001 From: liushiqiang Date: Wed, 19 Mar 2025 12:20:07 +0000 Subject: [PATCH 032/103] fix: usb passthrough crop so Signed-off-by: liushiqiang --- usb/hdi_service/BUILD.gn | 23 ++++++++++++++--------- usb/usb.gni | 2 ++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/usb/hdi_service/BUILD.gn b/usb/hdi_service/BUILD.gn index 91250fc527..abc993efa1 100644 --- a/usb/hdi_service/BUILD.gn +++ b/usb/hdi_service/BUILD.gn @@ -502,13 +502,18 @@ ohos_shared_library("libusb_device_driver") { } group("hdi_usb_service") { - deps = [ - ":libusb_device_driver", - ":libusb_device_interface_service_2.0", - ":libusb_driver", - ":libusb_host_interface_service_2.0", - ":libusb_interface_service_1.2", - ":libusb_port_driver", - ":libusb_port_interface_service_2.0", - ] + if (usb_drivers_pass_through) { + deps = [ + ":libusb_device_driver", + ":libusb_device_interface_service_2.0", + ":libusb_host_interface_service_2.0", + ":libusb_port_driver", + ":libusb_port_interface_service_2.0", + ] + } else { + deps = [ + ":libusb_driver", + ":libusb_interface_service_1.2", + ] + } } diff --git a/usb/usb.gni b/usb/usb.gni index 1858e6ddd5..2f85e31f57 100644 --- a/usb/usb.gni +++ b/usb/usb.gni @@ -40,4 +40,6 @@ declare_args() { if (defined(ohos_lite)) { libusb_enable = false } + + usb_drivers_pass_through = true } -- Gitee From 511906a7ea5224631b780a017bc7e41c639294a2 Mon Sep 17 00:00:00 2001 From: luzhiye Date: Thu, 20 Mar 2025 16:43:55 +0800 Subject: [PATCH 033/103] =?UTF-8?q?Serial=20=E5=AE=89=E5=85=A8=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: luzhiye --- usb/serial/include/libusb_serial.h | 2 +- usb/serial/src/libusb_serial.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/usb/serial/include/libusb_serial.h b/usb/serial/include/libusb_serial.h index 9017d52f18..cfb8ca7c9e 100644 --- a/usb/serial/include/libusb_serial.h +++ b/usb/serial/include/libusb_serial.h @@ -70,7 +70,7 @@ private: private: libusb_context* ctx_; - libusb_hotplug_callback_handle hotplug_handle_; + libusb_hotplug_callback_handle hotplug_handle_ = 0; // Map devices by libusb_device* std::unordered_map devices_; std::mutex map_mutex_; diff --git a/usb/serial/src/libusb_serial.cpp b/usb/serial/src/libusb_serial.cpp index d418c15b0a..6b3a16717d 100644 --- a/usb/serial/src/libusb_serial.cpp +++ b/usb/serial/src/libusb_serial.cpp @@ -617,7 +617,12 @@ bool CheckTtyDeviceInfo(std::string ttyUsbPath, libusb_device* device) HDF_LOGI("%{public}s : enter checkTtyDeviceInfo.", __func__); int busnumFd = 0; int devnumFd = 0; - busnumFd = open((ttyUsbPath + BUS_NUM_STR).c_str(), O_RDONLY); + std::string realpathStr; + if (realpath((ttyUsbPath + BUS_NUM_STR).c_str(), &realpathStr) == nullptr) { + HDF_LOGE("%{public}s : realpath failed. ret = %{public}s", __func__, strerror(errno)); + return false; + } + busnumFd = open(realpathStr.c_str(), O_RDONLY); if (busnumFd < 0) { HDF_LOGE("%{public}s : open file failed. ret = %{public}s", __func__, strerror(errno)); close(busnumFd); -- Gitee From 7d10cdcee1f1fbe4b09443c8555faa4b31922185 Mon Sep 17 00:00:00 2001 From: luzhiye Date: Thu, 20 Mar 2025 09:24:01 +0000 Subject: [PATCH 034/103] update usb/usb.gni. Signed-off-by: luzhiye --- usb/usb.gni | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/usb/usb.gni b/usb/usb.gni index ced94dae22..77609e7c22 100644 --- a/usb/usb.gni +++ b/usb/usb.gni @@ -21,23 +21,23 @@ declare_args() { drivers_peripheral_usb_feature_systemabilitymgr_samgr = false drivers_peripheral_usb_feature_commonlibrary_c_utils = false - usb_hisysevent_enable = true + usb_hisysevent_enable = false if (drivers_peripheral_usb_feature_hiviewdfx_hisysevent) { - usb_hisysevent_enable = false + usb_hisysevent_enable = true } - usb_samgr_enable = true + usb_samgr_enable = false if (drivers_peripheral_usb_feature_systemabilitymgr_samgr) { - usb_samgr_enable = false + usb_samgr_enable = true } - usb_c_utils_enable = true + usb_c_utils_enable = false if (drivers_peripheral_usb_feature_commonlibrary_c_utils) { - usb_c_utils_enable = false + usb_c_utils_enable = true } - libusb_enable = true + libusb_enable = false if (defined(ohos_lite)) { - libusb_enable = false + libusb_enable = true } } -- Gitee From 4ff4752f4a66e8518415a3d2736cc4b97f5f4682 Mon Sep 17 00:00:00 2001 From: luzhiye Date: Thu, 20 Mar 2025 11:25:51 +0000 Subject: [PATCH 035/103] update usb/serial/src/libusb_serial.cpp. Signed-off-by: luzhiye --- usb/serial/src/libusb_serial.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usb/serial/src/libusb_serial.cpp b/usb/serial/src/libusb_serial.cpp index 6b3a16717d..5b1e5372a9 100644 --- a/usb/serial/src/libusb_serial.cpp +++ b/usb/serial/src/libusb_serial.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "usbd_wrapper.h" #include "securec.h" @@ -617,8 +618,8 @@ bool CheckTtyDeviceInfo(std::string ttyUsbPath, libusb_device* device) HDF_LOGI("%{public}s : enter checkTtyDeviceInfo.", __func__); int busnumFd = 0; int devnumFd = 0; - std::string realpathStr; - if (realpath((ttyUsbPath + BUS_NUM_STR).c_str(), &realpathStr) == nullptr) { + char realpathStr[PATH_MAX] = {'\0'}; + if (realpath((ttyUsbPath + BUS_NUM_STR).c_str(), realpathStr) == nullptr) { HDF_LOGE("%{public}s : realpath failed. ret = %{public}s", __func__, strerror(errno)); return false; } -- Gitee From 1c8c0146e65ddc8c635164a2297b44c33e7d329f Mon Sep 17 00:00:00 2001 From: luzhiye Date: Thu, 20 Mar 2025 11:29:27 +0000 Subject: [PATCH 036/103] update usb/serial/src/libusb_serial.cpp. Signed-off-by: luzhiye --- usb/serial/src/libusb_serial.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/usb/serial/src/libusb_serial.cpp b/usb/serial/src/libusb_serial.cpp index 5b1e5372a9..7088604d2e 100644 --- a/usb/serial/src/libusb_serial.cpp +++ b/usb/serial/src/libusb_serial.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include "usbd_wrapper.h" #include "securec.h" -- Gitee From d3e82ef2ef4a1c5ed6b7f75dbc3cbda742733c8c Mon Sep 17 00:00:00 2001 From: luzhiye Date: Thu, 20 Mar 2025 11:59:49 +0000 Subject: [PATCH 037/103] update usb/serial/src/libusb_serial.cpp. Signed-off-by: luzhiye --- usb/serial/src/libusb_serial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usb/serial/src/libusb_serial.cpp b/usb/serial/src/libusb_serial.cpp index 7088604d2e..bc1cb75888 100644 --- a/usb/serial/src/libusb_serial.cpp +++ b/usb/serial/src/libusb_serial.cpp @@ -622,7 +622,7 @@ bool CheckTtyDeviceInfo(std::string ttyUsbPath, libusb_device* device) HDF_LOGE("%{public}s : realpath failed. ret = %{public}s", __func__, strerror(errno)); return false; } - busnumFd = open(realpathStr.c_str(), O_RDONLY); + busnumFd = open(realpathStr, O_RDONLY); if (busnumFd < 0) { HDF_LOGE("%{public}s : open file failed. ret = %{public}s", __func__, strerror(errno)); close(busnumFd); -- Gitee From c4da16da71b945bb07f1dd484fb1af5502a46d46 Mon Sep 17 00:00:00 2001 From: luzhiye Date: Thu, 20 Mar 2025 12:02:35 +0000 Subject: [PATCH 038/103] update usb/usb.gni. Signed-off-by: luzhiye --- usb/usb.gni | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/usb/usb.gni b/usb/usb.gni index 77609e7c22..752964659e 100644 --- a/usb/usb.gni +++ b/usb/usb.gni @@ -22,22 +22,22 @@ declare_args() { drivers_peripheral_usb_feature_commonlibrary_c_utils = false usb_hisysevent_enable = false - if (drivers_peripheral_usb_feature_hiviewdfx_hisysevent) { + if (!drivers_peripheral_usb_feature_hiviewdfx_hisysevent) { usb_hisysevent_enable = true } usb_samgr_enable = false - if (drivers_peripheral_usb_feature_systemabilitymgr_samgr) { + if (!drivers_peripheral_usb_feature_systemabilitymgr_samgr) { usb_samgr_enable = true } usb_c_utils_enable = false - if (drivers_peripheral_usb_feature_commonlibrary_c_utils) { + if (!drivers_peripheral_usb_feature_commonlibrary_c_utils) { usb_c_utils_enable = true } - libusb_enable = false + libusb_enable = true if (defined(ohos_lite)) { - libusb_enable = true + libusb_enable = false } } -- Gitee From 438596b80475fc17cd9cf8a077e7a71af58129e7 Mon Sep 17 00:00:00 2001 From: lin_c <1946558487@qq.com> Date: Thu, 20 Mar 2025 12:35:47 +0000 Subject: [PATCH 039/103] update codec/test/unittest/hdi_image/BUILD.gn. Signed-off-by: lin_c <1946558487@qq.com> --- codec/test/unittest/hdi_image/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codec/test/unittest/hdi_image/BUILD.gn b/codec/test/unittest/hdi_image/BUILD.gn index 0124a1584a..bff843691b 100644 --- a/codec/test/unittest/hdi_image/BUILD.gn +++ b/codec/test/unittest/hdi_image/BUILD.gn @@ -16,7 +16,7 @@ import("//build/test.gni") import("../../../codec.gni") ohos_unittest("codec_hdi_jpeg_test") { - module_out_path = "drivers_peripheral_codec/codec" + module_out_path = "drivers_peripheral_codec/drivers_peripheral_codec/codec" sources = [ "codec_hdi_jpeg_test.cpp" ] @@ -42,7 +42,7 @@ ohos_unittest("codec_hdi_jpeg_test") { } ohos_unittest("codec_hdi_heif_encode_test") { - module_out_path = "drivers_peripheral_codec/codec" + module_out_path = "drivers_peripheral_codec/drivers_peripheral_codec/codec" sources = [ "codec_hdi_heif_encode_test.cpp" ] -- Gitee From 0a388f3c54160dc8fe0f640ac232ea8f3cad0e8d Mon Sep 17 00:00:00 2001 From: lin_c <1946558487@qq.com> Date: Thu, 20 Mar 2025 14:25:11 +0000 Subject: [PATCH 040/103] update codec/test/unittest/hdi_omx/BUILD.gn. Signed-off-by: lin_c <1946558487@qq.com> --- codec/test/unittest/hdi_omx/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codec/test/unittest/hdi_omx/BUILD.gn b/codec/test/unittest/hdi_omx/BUILD.gn index 0a9c54f1ba..7bd8688e05 100644 --- a/codec/test/unittest/hdi_omx/BUILD.gn +++ b/codec/test/unittest/hdi_omx/BUILD.gn @@ -16,7 +16,7 @@ import("//build/test.gni") import("../../../codec.gni") ohos_unittest("codec_hdi_omx_test") { - module_out_path = "drivers_peripheral_codec/codec" + module_out_path = "drivers_peripheral_codec/drivers_peripheral_codec/codec" sources = [ "codec_hdi_manager_test.cpp", -- Gitee From 745bbb05cd41ac1abf4d2759fa1de2e7d6b95df3 Mon Sep 17 00:00:00 2001 From: lin_c <1946558487@qq.com> Date: Thu, 20 Mar 2025 14:26:08 +0000 Subject: [PATCH 041/103] update codec/test/unittest/idl_omx/BUILD.gn. Signed-off-by: lin_c <1946558487@qq.com> --- codec/test/unittest/idl_omx/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codec/test/unittest/idl_omx/BUILD.gn b/codec/test/unittest/idl_omx/BUILD.gn index 0ef42d6c70..2cb0b75c11 100644 --- a/codec/test/unittest/idl_omx/BUILD.gn +++ b/codec/test/unittest/idl_omx/BUILD.gn @@ -16,7 +16,7 @@ import("//build/test.gni") import("../../../codec.gni") ohos_unittest("codec_idl_omx_test") { - module_out_path = "drivers_peripheral_codec/codec" + module_out_path = "drivers_peripheral_codec/drivers_peripheral_codec/codec" include_dirs = [ "./", "../../../interfaces/include", -- Gitee From 4dfa9ec4e81148834eabc7450566b8a831aab050 Mon Sep 17 00:00:00 2001 From: JillFred Date: Fri, 21 Mar 2025 09:17:26 +0800 Subject: [PATCH 042/103] shield unsupported ut for rk Signed-off-by: JillFred --- codec/test/unittest/hdi_image/codec_hdi_heif_encode_test.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/codec/test/unittest/hdi_image/codec_hdi_heif_encode_test.cpp b/codec/test/unittest/hdi_image/codec_hdi_heif_encode_test.cpp index 5f1d9ab06c..2e829aca85 100644 --- a/codec/test/unittest/hdi_image/codec_hdi_heif_encode_test.cpp +++ b/codec/test/unittest/hdi_image/codec_hdi_heif_encode_test.cpp @@ -780,6 +780,7 @@ HWTEST_F(CodecHdiHeifEncodeTest, HdfCodecHdiDoHeifEncodeTest_025, TestSize.Level ASSERT_EQ(filledLen_, 0); } +#ifdef SUPPORT_HEIF static bool SetColorTypeAndProf(ImageItem &item) { PropWriter pw; @@ -847,6 +848,7 @@ HWTEST_F(CodecHdiHeifEncodeTest, HdfCodecHdiDoHeifEncodeTest_027, TestSize.Level ASSERT_EQ(ret, HDF_SUCCESS); ASSERT_TRUE(filledLen_ > 0); } +#endif static bool SetInValidProperties(ImageItem &item) { @@ -872,6 +874,7 @@ HWTEST_F(CodecHdiHeifEncodeTest, HdfCodecHdiDoHeifEncodeTest_028, TestSize.Level ASSERT_EQ(filledLen_, 0); } +#ifdef SUPPORT_HEIF static bool AddPropOnlyForTmap(PropWriter& pw) { MasteringDisplayColourVolume clrVol = { @@ -1041,7 +1044,6 @@ HWTEST_F(CodecHdiHeifEncodeTest, HdfCodecHdiDoHeifEncodeTest_032, TestSize.Level } // [PASS] check GetImageCapability can get heif encode capability -#ifdef SUPPORT_HEIF HWTEST_F(CodecHdiHeifEncodeTest, HdfCodecHdiDoHeifEncodeTest_033, TestSize.Level1) { ASSERT_TRUE(hdiHeifEncoder_ != nullptr); -- Gitee From c65a1c027df9d49e9d5146b39355fb1bda181c61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BB=B7=E5=BB=BA?= Date: Fri, 21 Mar 2025 15:32:15 +0800 Subject: [PATCH 043/103] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张廷建 --- .../pipeline_core/nodes/src/fork_node/fork_node.cpp | 13 ++++++------- .../usb_camera/pipeline_core/src/node/exif_node.cpp | 3 +-- .../usb_camera/pipeline_core/src/node/fork_node.cpp | 3 +-- .../pipeline_core/src/node/node_utils.cpp | 4 +--- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/camera/vdi_base/common/pipeline_core/nodes/src/fork_node/fork_node.cpp b/camera/vdi_base/common/pipeline_core/nodes/src/fork_node/fork_node.cpp index 9242f7343c..cd8289d0a0 100644 --- a/camera/vdi_base/common/pipeline_core/nodes/src/fork_node/fork_node.cpp +++ b/camera/vdi_base/common/pipeline_core/nodes/src/fork_node/fork_node.cpp @@ -35,8 +35,8 @@ RetCode ForkNode::Start(const int32_t streamId) std::unique_lock l(bufferMtx); stopForkThread_ = false; } - CAMERA_LOGI("ForkNode::Start streamId = %{public}d this:[%{public}p] streamRunning_ = %{public}d\n", - streamId, this, streamRunning_ ? 0 : 1); + CAMERA_LOGI("ForkNode::Start streamId = %{public}d streamRunning_ = %{public}d\n", + streamId, streamRunning_ ? 0 : 1); if (streamRunning_) { return RC_OK; } @@ -89,7 +89,7 @@ RetCode ForkNode::Stop(const int32_t streamId) std::unique_lock l(bufferMtx); stopForkThread_ = true; bqcv_.notify_all(); - CAMERA_LOGD("ForkNode Stop streamId:%{public}d bqcv_:%{public}p this:%{public}p", &bqcv_, this, streamId); + CAMERA_LOGD("ForkNode Stop streamId:%{public}d", streamId); } if (forkThread_ != nullptr) { @@ -147,7 +147,7 @@ void ForkNode::DeliverBuffer(std::shared_ptr& buffer) CAMERA_LOGE("frameSpec is null"); return; } - CAMERA_LOGD("ForkNode forkBuffer streamId:%{public}d this:%{public}p start", buffer->GetStreamId(), this); + CAMERA_LOGD("ForkNode forkBuffer streamId:%{public}d start", buffer->GetStreamId()); if (buffer->GetBufferStatus() == CAMERA_BUFFER_STATUS_OK && bufferPool_ != nullptr) { std::shared_ptr forkBuffer = bufferPool_->AcquireBuffer(0); if (forkBuffer != nullptr) { @@ -162,8 +162,7 @@ void ForkNode::DeliverBuffer(std::shared_ptr& buffer) CAMERA_LOGI("fork node deliver buffer streamid = %{public}d, in alone thread, index = %{public}d", forkBuffer->GetStreamId(), forkBuffer->GetIndex()); bqcv_.notify_one(); - CAMERA_LOGD("ForkNode forkBuffer bqcv_:%{public}p this:%{public}p streamId:%{public}d", - &bqcv_, this, forkBuffer->GetStreamId()); + CAMERA_LOGD("ForkNode forkBuffer streamId:%{public}d", forkBuffer->GetStreamId()); } else { CAMERA_LOGE("Deliver fork buffer, streamId[%{public}d], index[%{public}d], status = %{public}d", forkBuffer->GetStreamId(), forkBuffer->GetIndex(), forkBuffer->GetBufferStatus()); @@ -216,7 +215,7 @@ void ForkNode::DeliverBufferToNextNode() { { std::unique_lock l(bufferMtx); - CAMERA_LOGD("ForkNode DeliverBufferToNextNode bqcv_:%{public}p this:%{public}p", &bqcv_, this); + CAMERA_LOGD("ForkNode DeliverBufferToNextNode"); bqcv_.wait(l, [this] { CAMERA_LOGD("ForkNode DeliverBufferToNextNode stopForkThread_:%{public}d, bufferQueue_:%{public}d", stopForkThread_ ? 0 : 1, bufferQueue_.empty() ? 0 : 1); diff --git a/camera/vdi_base/usb_camera/pipeline_core/src/node/exif_node.cpp b/camera/vdi_base/usb_camera/pipeline_core/src/node/exif_node.cpp index f0b40eeedf..554ebe3c2f 100644 --- a/camera/vdi_base/usb_camera/pipeline_core/src/node/exif_node.cpp +++ b/camera/vdi_base/usb_camera/pipeline_core/src/node/exif_node.cpp @@ -68,8 +68,7 @@ void ExifNode::DeliverBuffer(std::shared_ptr &buffer) if (info.size != -1) { exifInfo.frame_size = info.size; ExifUtils::AddCustomExifInfo(exifInfo, buffer->GetVirAddress(), outPutBufferSize); - CAMERA_LOGI("%{public}s virAddress(%{public}p) and outPutBufferSize = (%{public}d)\n", - __FUNCTION__, buffer->GetVirAddress(), outPutBufferSize); + CAMERA_LOGI("%{public}s and outPutBufferSize = (%{public}d)\n", __FUNCTION__, outPutBufferSize); buffer->SetEsFrameSize(outPutBufferSize); } } diff --git a/camera/vdi_base/usb_camera/pipeline_core/src/node/fork_node.cpp b/camera/vdi_base/usb_camera/pipeline_core/src/node/fork_node.cpp index 1d0c7c8eef..e689d45237 100644 --- a/camera/vdi_base/usb_camera/pipeline_core/src/node/fork_node.cpp +++ b/camera/vdi_base/usb_camera/pipeline_core/src/node/fork_node.cpp @@ -108,8 +108,7 @@ static void CopyBufferToForkBuffer(std::shared_ptr& buffer, std::shared if (bufferAddr != nullptr) { forkBuffer->SetVirAddress(bufferAddr); forkBuffer->SetSize(bufferSize); - CAMERA_LOGI("PcForkNode::DeliverBuffer malloc sucess, Address = %{public}p, SbAddr = %{public}p", - forkBuffer->GetVirAddress(), forkBuffer->GetSuffaceBufferAddr()); + CAMERA_LOGI("PcForkNode::DeliverBuffer malloc sucess"); } else { CAMERA_LOGE("PcForkNode::DeliverBuffer malloc buffer fail"); return; diff --git a/camera/vdi_base/usb_camera/pipeline_core/src/node/node_utils.cpp b/camera/vdi_base/usb_camera/pipeline_core/src/node/node_utils.cpp index 7b8ae4397b..029da78fdf 100644 --- a/camera/vdi_base/usb_camera/pipeline_core/src/node/node_utils.cpp +++ b/camera/vdi_base/usb_camera/pipeline_core/src/node/node_utils.cpp @@ -58,9 +58,7 @@ int32_t NodeUtils::ImageFormatConvert(ImageBufferInfo &srcBufferInfo, ImageBuffe CAMERA_LOGI("====imageSize: %{public}d * %{public}d -> %{public}d * %{public}d, format: %{public}d -> %{public}d", srcBufferInfo.width, srcBufferInfo.height, dstBufferInfo.width, dstBufferInfo.height, srcBufferInfo.format, dstBufferInfo.format); - CAMERA_LOGI("====buffer: %{public}p [%{public}d] -> %{public}p [%{public}d]", - srcBufferInfo.bufferAddr, srcBufferInfo.bufferSize, - dstBufferInfo.bufferAddr, dstBufferInfo.bufferSize); + CAMERA_LOGI("====buffer: [%{public}d] -> [%{public}d]", srcBufferInfo.bufferSize, dstBufferInfo.bufferSize); AVFrame *pFrameSrc = av_frame_alloc(); if (pFrameSrc == nullptr) { -- Gitee From 93318706f86c1b9a389db7c2354c0d3be81d8861 Mon Sep 17 00:00:00 2001 From: luzhiye Date: Fri, 21 Mar 2025 08:15:25 +0000 Subject: [PATCH 044/103] update usb/usb.gni. Signed-off-by: luzhiye --- usb/usb.gni | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usb/usb.gni b/usb/usb.gni index 752964659e..b56572f1ff 100644 --- a/usb/usb.gni +++ b/usb/usb.gni @@ -20,7 +20,9 @@ declare_args() { drivers_peripheral_usb_feature_hiviewdfx_hisysevent = false drivers_peripheral_usb_feature_systemabilitymgr_samgr = false drivers_peripheral_usb_feature_commonlibrary_c_utils = false +} +declare_args() { usb_hisysevent_enable = false if (!drivers_peripheral_usb_feature_hiviewdfx_hisysevent) { usb_hisysevent_enable = true -- Gitee From da0827b1d4aa77feb46611d0c19341c1abac000a Mon Sep 17 00:00:00 2001 From: l60050612 Date: Wed, 19 Mar 2025 16:08:16 +0800 Subject: [PATCH 045/103] =?UTF-8?q?audio=E8=A7=A3=E5=86=B3crash=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=8A=A0=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l60050612 --- audio/effect/model/src/effect_model.c | 2 ++ .../vendor_interface/utils/audio_uhdf_log.h | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/audio/effect/model/src/effect_model.c b/audio/effect/model/src/effect_model.c index 1a7cd15ced..4b76b4d101 100644 --- a/audio/effect/model/src/effect_model.c +++ b/audio/effect/model/src/effect_model.c @@ -456,12 +456,14 @@ int32_t EffectModelDestroyEffectController(struct IEffectModel *self, const stru if (ctrlMgr->ctrlOps == NULL) { HDF_LOGE("%{public}s: controller has no options", __func__); + pthread_rwlock_unlock(&g_rwEffectLock); return HDF_FAILURE; } /* call the lib destroy method,then free controller manager */ lib->DestroyController(lib, ctrlMgr->ctrlOps); DeleteEffectLibrary(contollerId->libName); + pthread_rwlock_unlock(&g_rwEffectLock); HDF_LOGI("%{public}s: destroy effect succeed, libName = %{public}s", __func__, contollerId->libName); return HDF_SUCCESS; } diff --git a/audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h b/audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h index c40bb5660c..39b13fe53d 100644 --- a/audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h +++ b/audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h @@ -92,4 +92,14 @@ } \ } while (0) #endif + +#ifndef CHECK_RETURN_SUCCESS +#define CHECK_RETURN_SUCCESS(ret) \ + do { \ + if (ret != HDF_SUCCESS) { \ + AUDIO_FUNC_LOGE("fuction fail and return ret=%{public}d", ret); \ + return HDF_FAILURE; \ + } \ + } while (0) +#endif #endif -- Gitee From 2c7aa21753c74a6429d0bce8d7d917e570bcdf0d Mon Sep 17 00:00:00 2001 From: l60050612 Date: Fri, 21 Mar 2025 09:11:48 +0000 Subject: [PATCH 046/103] update audio/effect/model/src/effect_model.c. Signed-off-by: l60050612 --- audio/effect/model/src/effect_model.c | 59 +++++++++++++++------------ 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/audio/effect/model/src/effect_model.c b/audio/effect/model/src/effect_model.c index 4b76b4d101..bf4eac6a8f 100644 --- a/audio/effect/model/src/effect_model.c +++ b/audio/effect/model/src/effect_model.c @@ -145,11 +145,9 @@ static int32_t LoadEffectLibrary(const char *libName, struct EffectFactory **fac } uint8_t *libHandle = NULL; int32_t index = 0; - pthread_rwlock_wrlock(&g_rwEffectLock); for (int i = 0; i <= AUDIO_EFFECT_NUM_MAX; i++) { if (i == AUDIO_EFFECT_NUM_MAX) { HDF_LOGE("%{public}s: over effect max num", __func__); - pthread_rwlock_unlock(&g_rwEffectLock); return HDF_FAILURE; } if (g_libInfos[i] == NULL) { @@ -163,24 +161,20 @@ static int32_t LoadEffectLibrary(const char *libName, struct EffectFactory **fac *factLib = g_libInfos[i]->libEffect; *ctrlMgr = g_libInfos[i]->ctrlMgr; HDF_LOGI("%{public}s: %{public}s increase, cnt=[%{public}d]", __func__, libName, g_libInfos[i]->effectCnt); - pthread_rwlock_unlock(&g_rwEffectLock); return HDF_SUCCESS; } int32_t ret = LoadLibraryByName(libName, &libHandle, factLib); if (ret != HDF_SUCCESS || libHandle == NULL || *factLib == NULL) { HDF_LOGE("%{public}s: load lib fail, libName:[%{public}s]", __func__, libName); - pthread_rwlock_unlock(&g_rwEffectLock); return HDF_FAILURE; } g_libInfos[index] = AddEffectLibInfo(libName, libHandle, *factLib); if (g_libInfos[index] == NULL) { HDF_LOGE("%{public}s: AddEffectLibInfo fail", __func__); dlclose((void *)libHandle); - pthread_rwlock_unlock(&g_rwEffectLock); return HDF_FAILURE; } HDF_LOGI("%{public}s: %{public}s create, cnt=[%{public}d]", __func__, libName, g_libInfos[index]->effectCnt); - pthread_rwlock_unlock(&g_rwEffectLock); return HDF_SUCCESS; } @@ -190,11 +184,9 @@ static int32_t DeleteEffectLibrary(const char *libName) HDF_LOGE("%{public}s: invailid input params", __func__); return HDF_ERR_INVALID_PARAM; } - pthread_rwlock_wrlock(&g_rwEffectLock); for (int i = 0; i <= AUDIO_EFFECT_NUM_MAX; i++) { if (i == AUDIO_EFFECT_NUM_MAX) { HDF_LOGE("%{public}s: fail to destroy effect, can not find %{public}s", __func__, libName); - pthread_rwlock_unlock(&g_rwEffectLock); return HDF_FAILURE; } if (g_libInfos[i] == NULL || strcmp(g_libInfos[i]->libName, libName) != 0) { @@ -203,7 +195,6 @@ static int32_t DeleteEffectLibrary(const char *libName) if (g_libInfos[i]->effectCnt > 1) { g_libInfos[i]->effectCnt--; HDF_LOGI("%{public}s: %{public}s decrease, cnt=[%{public}d]", __func__, libName, g_libInfos[i]->effectCnt); - pthread_rwlock_unlock(&g_rwEffectLock); return HDF_SUCCESS; } dlclose((void*)g_libInfos[i]->libHandle); @@ -214,7 +205,6 @@ static int32_t DeleteEffectLibrary(const char *libName) break; } HDF_LOGI("%{public}s: %{public}s delete", __func__, libName); - pthread_rwlock_unlock(&g_rwEffectLock); return HDF_SUCCESS; } @@ -263,6 +253,7 @@ static int32_t EffectModelGetAllEffectDescriptors(struct IEffectModel *self, return HDF_FAILURE; } struct EffectControllerDescriptorVdi *descsVdi = (struct EffectControllerDescriptorVdi *)descs; + pthread_rwlock_wrlock(&g_rwEffectLock); for (i = 0; i < g_cfgDescs->effectNum; i++) { ret = LoadEffectLibrary(g_cfgDescs->effectCfgDescs[i].library, &factLib, &ctrlMgr); if (ret != HDF_SUCCESS || factLib == NULL) { @@ -286,6 +277,7 @@ static int32_t EffectModelGetAllEffectDescriptors(struct IEffectModel *self, } *descsLen = descNum; descs = (struct EffectControllerDescriptor *)descsVdi; + pthread_rwlock_unlock(&g_rwEffectLock); HDF_LOGD("%{public}s success", __func__); return HDF_SUCCESS; } @@ -306,23 +298,27 @@ static int32_t EffectModelGetEffectDescriptor(struct IEffectModel *self, const c if (strcmp(uuid, g_cfgDescs->effectCfgDescs[i].effectId) != 0) { continue; } - + pthread_rwlock_wrlock(&g_rwEffectLock); LoadEffectLibrary(g_cfgDescs->effectCfgDescs[i].library, &factLib, &ctrlMgr); if (factLib == NULL) { HDF_LOGE("%{public}s: GetEffectLibFromList fail!", __func__); + pthread_rwlock_unlock(&g_rwEffectLock); return HDF_FAILURE; } if (ConstructDescriptor(descVdi) != HDF_SUCCESS) { HDF_LOGE("%{public}s: ConstructDescriptor fail!", __func__); + pthread_rwlock_unlock(&g_rwEffectLock); return HDF_FAILURE; } if (factLib->GetDescriptor(factLib, uuid, descVdi) != HDF_SUCCESS) { DeleteEffectLibrary(g_cfgDescs->effectCfgDescs[i].library); HDF_LOGE("%{public}s: GetDescriptor fail!", __func__); + pthread_rwlock_unlock(&g_rwEffectLock); return HDF_FAILURE; } DeleteEffectLibrary(g_cfgDescs->effectCfgDescs[i].library); HDF_LOGD("%{public}s success", __func__); + pthread_rwlock_unlock(&g_rwEffectLock); return HDF_SUCCESS; } desc = (struct EffectControllerDescriptor *)descVdi; @@ -339,16 +335,13 @@ static int32_t CreateEffectController(const struct EffectInfo *info, struct IEff } struct ControllerManager *ctrlMgr = (struct ControllerManager *)OsalMemCalloc(sizeof(struct ControllerManager)); CHECK_NULL_PTR_RETURN_VALUE(ctrlMgr, HDF_FAILURE); - pthread_rwlock_rdlock(&g_rwEffectLock); struct AudioEffectLibInfo *libInfo = GetEffectLibInfoByName(info->libName); if (libInfo == NULL) { HDF_LOGE("%{public}s: GetEffectLibInfoByName failed", __func__); OsalMemFree(ctrlMgr); - pthread_rwlock_unlock(&g_rwEffectLock); return HDF_FAILURE; } libInfo->ctrlMgr = ctrlMgr; - pthread_rwlock_unlock(&g_rwEffectLock); ctrlMgr->ctrlOps = ctrlOps; ctrlMgr->libName = strdup(info->libName); if (ctrlMgr->libName == NULL) { @@ -388,10 +381,11 @@ static int32_t EffectModelCreateEffectController(struct IEffectModel *self, cons struct EffectFactory *lib = NULL; struct ControllerManager *ctrlMgr = NULL; struct IEffectControlVdi *ctrlOps = NULL; - + pthread_rwlock_wrlock(&g_rwEffectLock); int32_t ret = LoadEffectLibrary(info->libName, &lib, &ctrlMgr); if (ret != HDF_SUCCESS) { HDF_LOGE("%{public}s: LoadEffectLibrary fail", __func__); + pthread_rwlock_unlock(&g_rwEffectLock); return HDF_FAILURE; } if (ctrlMgr != NULL) { @@ -399,24 +393,35 @@ static int32_t EffectModelCreateEffectController(struct IEffectModel *self, cons contollerId->effectId = strdup(info->effectId); if (contollerId->libName == NULL || contollerId->effectId == NULL) { HDF_LOGE("%{public}s: strdup failed", __func__); + pthread_rwlock_unlock(&g_rwEffectLock); return HDF_FAILURE; } *contoller = &ctrlMgr->ctrlImpls; + pthread_rwlock_unlock(&g_rwEffectLock); return HDF_SUCCESS; } - CHECK_NULL_PTR_RETURN_VALUE(lib, HDF_FAILURE); - CHECK_NULL_PTR_RETURN_VALUE(lib->CreateController, HDF_FAILURE); + if (lib == NULL || lib->CreateController == NULL) { + HDF_LOGE("%{public}s: lib or lib->CreateController is null", __func__); + pthread_rwlock_unlock(&g_rwEffectLock); + return HDF_FAILURE; + } struct EffectInfoVdi *infoVdi = (struct EffectInfoVdi *)info; lib->CreateController(lib, infoVdi, &ctrlOps); - CHECK_NULL_PTR_RETURN_VALUE(ctrlOps, HDF_FAILURE); + if (ctrlOps == NULL) { + HDF_LOGE("%{public}s: ctrlOps is null", __func__); + pthread_rwlock_unlock(&g_rwEffectLock); + return HDF_FAILURE; + } ret = CreateEffectController(info, contoller, contollerId, ctrlOps); if (ret != HDF_SUCCESS) { DeleteEffectLibrary(info->libName); + pthread_rwlock_unlock(&g_rwEffectLock); return HDF_FAILURE; } - + + pthread_rwlock_unlock(&g_rwEffectLock); HDF_LOGI("%{public}s: create effect succeed, libName = %{public}s", __func__, info->libName); return HDF_SUCCESS; } @@ -427,7 +432,7 @@ int32_t EffectModelDestroyEffectController(struct IEffectModel *self, const stru HDF_LOGE("%{public}s: invailid input params", __func__); return HDF_ERR_INVALID_PARAM; } - pthread_rwlock_rdlock(&g_rwEffectLock); + pthread_rwlock_wrlock(&g_rwEffectLock); struct AudioEffectLibInfo *libInfo = GetEffectLibInfoByName(contollerId->libName); if (libInfo == NULL) { HDF_LOGE("%{public}s: GetEffectLibInfoByName failed", __func__); @@ -446,9 +451,12 @@ int32_t EffectModelDestroyEffectController(struct IEffectModel *self, const stru return HDF_FAILURE; } struct ControllerManager *ctrlMgr = libInfo->ctrlMgr; - pthread_rwlock_unlock(&g_rwEffectLock); - CHECK_NULL_PTR_RETURN_VALUE(ctrlMgr, HDF_FAILURE); - + if (ctrlMgr == NULL) { + HDF_LOGE("%{public}s: ctrlMgr is null", __func__); + pthread_rwlock_unlock(&g_rwEffectLock); + return HDF_FAILURE; + } + if (ctrlMgr->libName != NULL) { OsalMemFree(ctrlMgr->libName); ctrlMgr->libName = NULL; @@ -456,14 +464,14 @@ int32_t EffectModelDestroyEffectController(struct IEffectModel *self, const stru if (ctrlMgr->ctrlOps == NULL) { HDF_LOGE("%{public}s: controller has no options", __func__); - pthread_rwlock_unlock(&g_rwEffectLock); + pthread_rwlock_unlock(&g_rwEffectLock); return HDF_FAILURE; } /* call the lib destroy method,then free controller manager */ lib->DestroyController(lib, ctrlMgr->ctrlOps); DeleteEffectLibrary(contollerId->libName); - pthread_rwlock_unlock(&g_rwEffectLock); + pthread_rwlock_unlock(&g_rwEffectLock); HDF_LOGI("%{public}s: destroy effect succeed, libName = %{public}s", __func__, contollerId->libName); return HDF_SUCCESS; } @@ -527,3 +535,4 @@ void EffectModelImplRelease(struct IEffectModel *instance) OsalMemFree(service); service = NULL; } + -- Gitee From 1e2cafe2759b5540350485d0e19f1fa0cf34011a Mon Sep 17 00:00:00 2001 From: l60050612 Date: Fri, 21 Mar 2025 09:17:07 +0000 Subject: [PATCH 047/103] update audio/effect/model/src/effect_model.c. Signed-off-by: l60050612 --- audio/effect/model/src/effect_model.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/audio/effect/model/src/effect_model.c b/audio/effect/model/src/effect_model.c index bf4eac6a8f..1efc4a85c5 100644 --- a/audio/effect/model/src/effect_model.c +++ b/audio/effect/model/src/effect_model.c @@ -374,10 +374,7 @@ static int32_t EffectModelCreateEffectController(struct IEffectModel *self, cons HDF_LOGE("%{public}s: invailid input params", __func__); return HDF_ERR_INVALID_PARAM; } - if (IsSupplyEffect(info->libName) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: not support effect [%{public}s]", __func__, info->libName); - return HDF_FAILURE; - } + CHECK_RETURN_SUCCESS(IsSupplyEffect(info->libName)); struct EffectFactory *lib = NULL; struct ControllerManager *ctrlMgr = NULL; struct IEffectControlVdi *ctrlOps = NULL; -- Gitee From acb7f4b85b0ac7e7e7e27800a3c80f5becf1394f Mon Sep 17 00:00:00 2001 From: l60050612 Date: Fri, 21 Mar 2025 09:33:35 +0000 Subject: [PATCH 048/103] update audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h. Signed-off-by: l60050612 --- audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h b/audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h index 39b13fe53d..8603fe5f56 100644 --- a/audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h +++ b/audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h @@ -96,7 +96,7 @@ #ifndef CHECK_RETURN_SUCCESS #define CHECK_RETURN_SUCCESS(ret) \ do { \ - if (ret != HDF_SUCCESS) { \ + if ((ret) != HDF_SUCCESS) { \ AUDIO_FUNC_LOGE("fuction fail and return ret=%{public}d", ret); \ return HDF_FAILURE; \ } \ -- Gitee From 29e7758b38e4158a0bb89c2c3eaeddc9da1409f9 Mon Sep 17 00:00:00 2001 From: l60050612 Date: Fri, 21 Mar 2025 09:34:11 +0000 Subject: [PATCH 049/103] update audio/effect/model/src/effect_model.c. Signed-off-by: l60050612 --- audio/effect/model/src/effect_model.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/effect/model/src/effect_model.c b/audio/effect/model/src/effect_model.c index 1efc4a85c5..3ef9b8d724 100644 --- a/audio/effect/model/src/effect_model.c +++ b/audio/effect/model/src/effect_model.c @@ -409,7 +409,7 @@ static int32_t EffectModelCreateEffectController(struct IEffectModel *self, cons HDF_LOGE("%{public}s: ctrlOps is null", __func__); pthread_rwlock_unlock(&g_rwEffectLock); return HDF_FAILURE; - } + } ret = CreateEffectController(info, contoller, contollerId, ctrlOps); if (ret != HDF_SUCCESS) { -- Gitee From 568cded125b4241bd46ab6f7730a7c9839ec58f8 Mon Sep 17 00:00:00 2001 From: l60050612 Date: Fri, 21 Mar 2025 09:39:13 +0000 Subject: [PATCH 050/103] update audio/effect/model/src/effect_model.c. Signed-off-by: l60050612 --- audio/effect/model/src/effect_model.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/effect/model/src/effect_model.c b/audio/effect/model/src/effect_model.c index 3ef9b8d724..bb7b56b140 100644 --- a/audio/effect/model/src/effect_model.c +++ b/audio/effect/model/src/effect_model.c @@ -401,7 +401,7 @@ static int32_t EffectModelCreateEffectController(struct IEffectModel *self, cons HDF_LOGE("%{public}s: lib or lib->CreateController is null", __func__); pthread_rwlock_unlock(&g_rwEffectLock); return HDF_FAILURE; - } + } struct EffectInfoVdi *infoVdi = (struct EffectInfoVdi *)info; lib->CreateController(lib, infoVdi, &ctrlOps); -- Gitee From f1315a58e11b8a47816df81686e64c06df4c1638 Mon Sep 17 00:00:00 2001 From: l60050612 Date: Fri, 21 Mar 2025 10:10:22 +0000 Subject: [PATCH 051/103] update audio/effect/model/src/effect_model.c. Signed-off-by: l60050612 --- audio/effect/model/src/effect_model.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/audio/effect/model/src/effect_model.c b/audio/effect/model/src/effect_model.c index bb7b56b140..1bc463b5d5 100644 --- a/audio/effect/model/src/effect_model.c +++ b/audio/effect/model/src/effect_model.c @@ -374,7 +374,10 @@ static int32_t EffectModelCreateEffectController(struct IEffectModel *self, cons HDF_LOGE("%{public}s: invailid input params", __func__); return HDF_ERR_INVALID_PARAM; } - CHECK_RETURN_SUCCESS(IsSupplyEffect(info->libName)); + if (IsSupplyEffect(info->libName) != HDF_SUCCESS) { + HDF_LOGE("%{public}s: not support effect [%{public}s]", __func__, info->libName); + return HDF_FAILURE; + } struct EffectFactory *lib = NULL; struct ControllerManager *ctrlMgr = NULL; struct IEffectControlVdi *ctrlOps = NULL; @@ -382,16 +385,14 @@ static int32_t EffectModelCreateEffectController(struct IEffectModel *self, cons int32_t ret = LoadEffectLibrary(info->libName, &lib, &ctrlMgr); if (ret != HDF_SUCCESS) { HDF_LOGE("%{public}s: LoadEffectLibrary fail", __func__); - pthread_rwlock_unlock(&g_rwEffectLock); - return HDF_FAILURE; + goto EXIT; } if (ctrlMgr != NULL) { contollerId->libName = strdup(info->libName); contollerId->effectId = strdup(info->effectId); if (contollerId->libName == NULL || contollerId->effectId == NULL) { HDF_LOGE("%{public}s: strdup failed", __func__); - pthread_rwlock_unlock(&g_rwEffectLock); - return HDF_FAILURE; + goto EXIT; } *contoller = &ctrlMgr->ctrlImpls; pthread_rwlock_unlock(&g_rwEffectLock); @@ -399,28 +400,28 @@ static int32_t EffectModelCreateEffectController(struct IEffectModel *self, cons } if (lib == NULL || lib->CreateController == NULL) { HDF_LOGE("%{public}s: lib or lib->CreateController is null", __func__); - pthread_rwlock_unlock(&g_rwEffectLock); - return HDF_FAILURE; + goto EXIT; } struct EffectInfoVdi *infoVdi = (struct EffectInfoVdi *)info; lib->CreateController(lib, infoVdi, &ctrlOps); if (ctrlOps == NULL) { HDF_LOGE("%{public}s: ctrlOps is null", __func__); - pthread_rwlock_unlock(&g_rwEffectLock); - return HDF_FAILURE; + goto EXIT; } ret = CreateEffectController(info, contoller, contollerId, ctrlOps); if (ret != HDF_SUCCESS) { DeleteEffectLibrary(info->libName); - pthread_rwlock_unlock(&g_rwEffectLock); - return HDF_FAILURE; + goto EXIT; } pthread_rwlock_unlock(&g_rwEffectLock); HDF_LOGI("%{public}s: create effect succeed, libName = %{public}s", __func__, info->libName); return HDF_SUCCESS; +EXIT: + pthread_rwlock_unlock(&g_rwEffectLock); + return HDF_FAILURE; } int32_t EffectModelDestroyEffectController(struct IEffectModel *self, const struct ControllerId *contollerId) -- Gitee From ce8c55e6d37d93e3e3b578850584f8b15d5492ed Mon Sep 17 00:00:00 2001 From: l60050612 Date: Fri, 21 Mar 2025 10:46:02 +0000 Subject: [PATCH 052/103] update audio/effect/model/src/effect_model.c. Signed-off-by: l60050612 --- audio/effect/model/src/effect_model.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/effect/model/src/effect_model.c b/audio/effect/model/src/effect_model.c index 1bc463b5d5..22177405ae 100644 --- a/audio/effect/model/src/effect_model.c +++ b/audio/effect/model/src/effect_model.c @@ -421,7 +421,7 @@ static int32_t EffectModelCreateEffectController(struct IEffectModel *self, cons return HDF_SUCCESS; EXIT: pthread_rwlock_unlock(&g_rwEffectLock); - return HDF_FAILURE; + return HDF_FAILURE; } int32_t EffectModelDestroyEffectController(struct IEffectModel *self, const struct ControllerId *contollerId) -- Gitee From 088c776290496ad36d0a22a500b2a8244817f4f8 Mon Sep 17 00:00:00 2001 From: l60050612 Date: Fri, 21 Mar 2025 10:52:09 +0000 Subject: [PATCH 053/103] update audio/effect/model/src/effect_model.c. Signed-off-by: l60050612 --- audio/effect/model/src/effect_model.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/audio/effect/model/src/effect_model.c b/audio/effect/model/src/effect_model.c index 22177405ae..3c1c24d7ca 100644 --- a/audio/effect/model/src/effect_model.c +++ b/audio/effect/model/src/effect_model.c @@ -410,8 +410,7 @@ static int32_t EffectModelCreateEffectController(struct IEffectModel *self, cons goto EXIT; } - ret = CreateEffectController(info, contoller, contollerId, ctrlOps); - if (ret != HDF_SUCCESS) { + if (CreateEffectController(info, contoller, contollerId, ctrlOps) != HDF_SUCCESS) { DeleteEffectLibrary(info->libName); goto EXIT; } -- Gitee From eaa431603a3cef81ec0562bdfd420c32f8c2c46b Mon Sep 17 00:00:00 2001 From: l60050612 Date: Fri, 21 Mar 2025 10:55:34 +0000 Subject: [PATCH 054/103] update audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h. Signed-off-by: l60050612 --- .../vendor_interface/utils/audio_uhdf_log.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h b/audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h index 8603fe5f56..c40bb5660c 100644 --- a/audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h +++ b/audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h @@ -92,14 +92,4 @@ } \ } while (0) #endif - -#ifndef CHECK_RETURN_SUCCESS -#define CHECK_RETURN_SUCCESS(ret) \ - do { \ - if ((ret) != HDF_SUCCESS) { \ - AUDIO_FUNC_LOGE("fuction fail and return ret=%{public}d", ret); \ - return HDF_FAILURE; \ - } \ - } while (0) -#endif #endif -- Gitee From c143deae1fd93a5fd3f51a630e7bd61c8ea9db2c Mon Sep 17 00:00:00 2001 From: lwx1281857 Date: Sat, 22 Mar 2025 08:35:00 +0800 Subject: [PATCH 055/103] Description: Code optimization Feature or Bugfix: Bugfix Binary Source:No Signed-off-by: lwx1281857 --- partitionslot/test/BUILD.gn | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/partitionslot/test/BUILD.gn b/partitionslot/test/BUILD.gn index 7f27e4319c..408e012ec8 100644 --- a/partitionslot/test/BUILD.gn +++ b/partitionslot/test/BUILD.gn @@ -13,10 +13,9 @@ import("//build/test.gni") import("../../../../drivers/hdf_core/adapter/uhdf2/uhdf.gni") -module_output_path = "partitionslot/" - ohos_unittest("partitionslot_hdi_test") { - module_out_path = module_output_path + module_out_path = + "drivers_peripheral_partitionslot/drivers_peripheral_partition_slot" sources = [ "unittest/hdf_partitionslot_test.cpp" ] external_deps = [ -- Gitee From 57700d0debab72e988d1621614a5f22e7ce06422 Mon Sep 17 00:00:00 2001 From: yang-junfeng0621 Date: Sat, 22 Mar 2025 14:42:25 +0800 Subject: [PATCH 056/103] =?UTF-8?q?0322TDD=E8=A7=84=E8=8C=83=E6=95=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yang-junfeng0621 Change-Id: Id39462efd7598c02ed9206d4dd1b68006af9d0ca --- huks/test/unittest/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/huks/test/unittest/BUILD.gn b/huks/test/unittest/BUILD.gn index 4e843d1d52..38dc081092 100755 --- a/huks/test/unittest/BUILD.gn +++ b/huks/test/unittest/BUILD.gn @@ -14,7 +14,7 @@ import("//build/ohos.gni") import("//build/test.gni") -module_output_path = "drivers_peripheral_huks/huks_hdi_unittest" +module_output_path = "drivers_peripheral_huks/drivers_peripheral_huks/huks_hdi_unittest" ohos_unittest("huks_hdi_unittest") { module_out_path = module_output_path -- Gitee From 34334d22af838658d84827a0224e7e1ce57b4d86 Mon Sep 17 00:00:00 2001 From: liangqi Date: Sat, 22 Mar 2025 15:22:32 +0800 Subject: [PATCH 057/103] support FDSAN Signed-off-by: liangqi --- .../emit_event_manager/virtual_device.h | 1 + input/ddk_service/include/hid_ddk_service.h | 4 ++ .../src/emit_event_manager/virtual_device.cpp | 10 +++-- input/ddk_service/src/hid_ddk_service.cpp | 29 +++++++++---- input/udriver/src/input_device_manager.cpp | 41 ++++++++++++------- 5 files changed, 58 insertions(+), 27 deletions(-) diff --git a/input/ddk_service/include/emit_event_manager/virtual_device.h b/input/ddk_service/include/emit_event_manager/virtual_device.h index 7a926ffc33..74e47ba000 100644 --- a/input/ddk_service/include/emit_event_manager/virtual_device.h +++ b/input/ddk_service/include/emit_event_manager/virtual_device.h @@ -48,6 +48,7 @@ protected: virtual const std::vector &GetRepeats() const; virtual const std::vector &GetSwitches() const; bool SetAttribute(); + FILE *file_ {nullptr}; int32_t fd_ {-1}; const char * const deviceName_; const uint16_t busType_; diff --git a/input/ddk_service/include/hid_ddk_service.h b/input/ddk_service/include/hid_ddk_service.h index bfcfb16eae..7d2b682a76 100644 --- a/input/ddk_service/include/hid_ddk_service.h +++ b/input/ddk_service/include/hid_ddk_service.h @@ -18,6 +18,8 @@ #include "hid_adapter.h" #include "v1_1/ihid_ddk.h" +#include +#include namespace OHOS { namespace HDI { @@ -69,6 +71,8 @@ public: private: std::shared_ptr osAdapter_; + std::mutex fileDescriptorLock_; + std::unordered_map fileDescriptorMap_; }; } // V1_1 } // Ddk diff --git a/input/ddk_service/src/emit_event_manager/virtual_device.cpp b/input/ddk_service/src/emit_event_manager/virtual_device.cpp index b969659eee..9a2e1d60fc 100644 --- a/input/ddk_service/src/emit_event_manager/virtual_device.cpp +++ b/input/ddk_service/src/emit_event_manager/virtual_device.cpp @@ -75,18 +75,22 @@ VirtualDevice::~VirtualDevice() { if (fd_ >= 0) { ioctl(fd_, UI_DEV_DESTROY); - close(fd_); fd_ = -1; } + if (file_ != nullptr) { + fclose(file_); + file_ = nullptr; + } } bool VirtualDevice::SetUp() { - fd_ = open("/dev/uinput", O_WRONLY | O_NONBLOCK); - if (fd_ < 0) { + file_ = fopen("/dev/uinput", "wb"); + if (file_ == nullptr) { HDF_LOGE("%{public}s Failed to open uinput, errno=%{public}d", __func__, errno); return false; } + fd_ = fileno(file_); if (!SetAttribute()) { HDF_LOGE("%{public}s Failed to set attribute", __func__); diff --git a/input/ddk_service/src/hid_ddk_service.cpp b/input/ddk_service/src/hid_ddk_service.cpp index c7085f3ced..41bb80dd36 100644 --- a/input/ddk_service/src/hid_ddk_service.cpp +++ b/input/ddk_service/src/hid_ddk_service.cpp @@ -149,13 +149,16 @@ int32_t HidDdkService::Open(uint64_t deviceId, uint8_t interfaceIndex, HidDevice return HID_DDK_DEVICE_NOT_FOUND; } - int32_t fd = open(path.c_str(), O_RDWR); - if (fd < 0) { - HDF_LOGE("%{public}s open failed, path=%{public}s, errno=%{public}d", __func__, path.c_str(), errno); + FILE* file = fopen(path.c_str(), "r+"); + if (file == nullptr) { + HDF_LOGE("%{public}s fopen failed, path=%{public}s, errno=%{public}d", __func__, path.c_str(), errno); return HID_DDK_IO_ERROR; } - - dev.fd = fd; + dev.fd = fileno(file); + { + std::lock_guard lock(fileDescriptorLock_); + fileDescriptorMap_[dev.fd] = file; + } return HID_DDK_SUCCESS; } @@ -168,10 +171,18 @@ int32_t HidDdkService::Close(const HidDeviceHandle& dev) return HID_DDK_NO_PERM; } - int32_t ret = close(dev.fd); - if (ret == -1) { - HDF_LOGE("%{public}s close failed, errno=%{public}d", __func__, errno); - return HID_DDK_IO_ERROR; + { + std::lock_guard lock(fileDescriptorLock_); + if (fileDescriptorMap_.find(dev.fd) == fileDescriptorMap_.end()) { + HDF_LOGE("%{public}s file not found, fd=%{public}d", __func__, dev.fd); + return HID_DDK_IO_ERROR; + } + int32_t ret = fclose(fileDescriptorMap_[dev.fd]); + if (ret == EOF) { + HDF_LOGE("%{public}s fclose failed, errno=%{public}d", __func__, errno); + return HID_DDK_IO_ERROR; + } + fileDescriptorMap_.erase(dev.fd); } return HID_DDK_SUCCESS; diff --git a/input/udriver/src/input_device_manager.cpp b/input/udriver/src/input_device_manager.cpp index 08055d94f3..81792a1702 100644 --- a/input/udriver/src/input_device_manager.cpp +++ b/input/udriver/src/input_device_manager.cpp @@ -36,6 +36,7 @@ #include "securec.h" #define HDF_LOG_TAG InputDeviceHdiManager +#define DRIVERS_PERIPHERAL_INPUT_FDSAN_TAG 0xC02555 namespace OHOS { namespace Input { @@ -196,26 +197,32 @@ int32_t InputDeviceManager::OpenInputDevice(string devPath) devRealPath, errno, strerror(errno)); return INPUT_FAILURE; } + uint64_t ownerTag = fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, DRIVERS_PERIPHERAL_INPUT_FDSAN_TAG); + fdsan_exchange_owner_tag(nodeFd, 0, ownerTag); return nodeFd; } // close input device node RetStatus InputDeviceManager::CloseInputDevice(string devPath) { - for (auto &inputDev : inputDevList_) { - if (string(inputDev.second.devPathNode) == devPath) { - int32_t fd = inputDev.second.fd; - if (fd > 0) { - RemoveEpoll(mEpollId_, fd); - close(fd); - inputDev.second.fd = -1; - inputDev.second.status = INPUT_DEVICE_STATUS_CLOSED; - return INPUT_SUCCESS; - } - } + auto it = std::find_if(inputDevList_.begin(), inputDevList_.end(), [&devPath](const auto &inputDev) { + return string(inputDev.second.devPathNode) == devPath; + }); + if (it == inputDevList_.end()) { + return INPUT_FAILURE; } - // device list remove this node - return INPUT_FAILURE; + int32_t fd = it->second.fd; + if (fd <= 0) { + return INPUT_FAILURE; + } + + RemoveEpoll(mEpollId_, fd); + uint64_t ownerTag = fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, DRIVERS_PERIPHERAL_INPUT_FDSAN_TAG); + fdsan_close_with_tag(fd, ownerTag); + + it->second.fd = -1; + it->second.status = INPUT_DEVICE_STATUS_CLOSED; + return INPUT_SUCCESS; } int32_t InputDeviceManager::GetInputDeviceInfo(int32_t fd, InputDeviceInfo *detailInfo) @@ -318,7 +325,8 @@ int32_t InputDeviceManager::CreateInputDevListNode(InputDevListNode &inputDevNod auto sDevName = string(detailInfo->attrSet.devName); uint32_t type = GetInputDeviceTypeInfo(sDevName); if (type == INDEV_TYPE_UNKNOWN) { - close(fd); + uint64_t ownerTag = fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, DRIVERS_PERIPHERAL_INPUT_FDSAN_TAG); + fdsan_close_with_tag(fd, ownerTag); HDF_LOGE("%{public}s: input device type unknow: %{public}d", __func__, type); return CREATE_ERROR; } @@ -331,7 +339,8 @@ int32_t InputDeviceManager::CreateInputDevListNode(InputDevListNode &inputDevNod devPathNode.c_str(), devPathNode.length()) != EOK || memcpy_s(&inputDevNode.detailInfo, sizeof(InputDeviceInfo), detailInfo.get(), sizeof(InputDeviceInfo)) != EOK) { - close(fd); + uint64_t ownerTag = fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, DRIVERS_PERIPHERAL_INPUT_FDSAN_TAG); + fdsan_close_with_tag(fd, ownerTag); HDF_LOGE("%{public}s: memcpy_s failed, line: %{public}d", __func__, __LINE__); return MEMCPY_ERROR; } @@ -589,6 +598,8 @@ int32_t InputDeviceManager::InotifyEventHandler(int32_t epollFd, int32_t notifyF HDF_LOGE("%{public}s: open file failure: %{public}s", __func__, nodeRealPath); return INPUT_FAILURE; } + uint64_t ownerTag = fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, DRIVERS_PERIPHERAL_INPUT_FDSAN_TAG); + fdsan_exchange_owner_tag(tmpFd, 0, ownerTag); if (nodePath.find("event") == std::string::npos) { break; } -- Gitee From 86e25cb8226ef034e026c176f08f2a1740deb26d Mon Sep 17 00:00:00 2001 From: huangshengqing Date: Sat, 22 Mar 2025 20:56:09 +0800 Subject: [PATCH 058/103] verify param Signed-off-by: huangshengqing --- usb/ddk/host/src/usb_raw_api_library.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/usb/ddk/host/src/usb_raw_api_library.c b/usb/ddk/host/src/usb_raw_api_library.c index 8fa2ce8509..3adb3e45fc 100644 --- a/usb/ddk/host/src/usb_raw_api_library.c +++ b/usb/ddk/host/src/usb_raw_api_library.c @@ -1133,11 +1133,16 @@ int32_t RawSendControlRequest(struct UsbHostRequest *request, const struct UsbDe int32_t completed = 0; int32_t ret; - if (request == NULL || request->buffer == NULL || devHandle == NULL || requestData == NULL) { + if (request == NULL || request->buffer == NULL || devHandle == NULL || + requestData == NULL || requestData->data) { HDF_LOGE("%{public}s:%{public}d invalid param", __func__, __LINE__); return HDF_ERR_INVALID_PARAM; } + if (USB_RAW_CONTROL_SETUP_SIZE > (size_t)requestData->length) { + HDF_LOGE("%{public}s:%{public}d oversize", __func__, __LINE__); + return HDF_ERR_INVALID_PARAM; + } setup = request->buffer; RawFillControlSetup(setup, requestData); if ((requestData->requestType & USB_DDK_ENDPOINT_DIR_MASK) == USB_PIPE_DIRECTION_OUT) { -- Gitee From 3f4d6682aef8ec686b45c3e2fad6d498cd06750e Mon Sep 17 00:00:00 2001 From: huangshengqing Date: Sat, 22 Mar 2025 13:04:05 +0000 Subject: [PATCH 059/103] update usb/ddk/host/src/usb_raw_api_library.c. Signed-off-by: huangshengqing --- usb/ddk/host/src/usb_raw_api_library.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usb/ddk/host/src/usb_raw_api_library.c b/usb/ddk/host/src/usb_raw_api_library.c index 3adb3e45fc..896ca1254a 100644 --- a/usb/ddk/host/src/usb_raw_api_library.c +++ b/usb/ddk/host/src/usb_raw_api_library.c @@ -1134,7 +1134,7 @@ int32_t RawSendControlRequest(struct UsbHostRequest *request, const struct UsbDe int32_t ret; if (request == NULL || request->buffer == NULL || devHandle == NULL || - requestData == NULL || requestData->data) { + requestData == NULL || requestData->data == NULL) { HDF_LOGE("%{public}s:%{public}d invalid param", __func__, __LINE__); return HDF_ERR_INVALID_PARAM; } -- Gitee From 7dc380f429cac6551e64fa0907834903761527de Mon Sep 17 00:00:00 2001 From: parahaoer <884101054@qq.com> Date: Mon, 24 Mar 2025 10:44:22 +0800 Subject: [PATCH 060/103] accessory hal Signed-off-by: parahaoer <884101054@qq.com> --- audio/interfaces/sound/v1_0/audio_types_vdi.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/audio/interfaces/sound/v1_0/audio_types_vdi.h b/audio/interfaces/sound/v1_0/audio_types_vdi.h index 5ab8583f31..9033c5b3a3 100644 --- a/audio/interfaces/sound/v1_0/audio_types_vdi.h +++ b/audio/interfaces/sound/v1_0/audio_types_vdi.h @@ -52,6 +52,8 @@ enum AudioPortPinVdi { PIN_VDI_IN_BLUETOOTH_SCO_HEADSET = 1 << 27 | 1 << 4, PIN_VDI_IN_DAUDIO_DEFAULT = 1 << 27 | 1 << 5, PIN_VDI_IN_USB_HEADSET = 1 << 27 | 1 << 6, + PIN_VDI_IN_PENCIL = 1 << 27 | 1 << 7, + PIN_VDI_IN_UWB = 1 << 27 | 1 << 8, PIN_VDI_IN_BUTT, }; -- Gitee From 142d62ae510b07815369e400ce7866c87d3e7bc3 Mon Sep 17 00:00:00 2001 From: parahaoer <884101054@qq.com> Date: Mon, 24 Mar 2025 10:44:22 +0800 Subject: [PATCH 061/103] feat:add accessory hal Signed-off-by: parahaoer <884101054@qq.com> --- audio/interfaces/sound/v1_0/audio_types_vdi.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/audio/interfaces/sound/v1_0/audio_types_vdi.h b/audio/interfaces/sound/v1_0/audio_types_vdi.h index 5ab8583f31..9033c5b3a3 100644 --- a/audio/interfaces/sound/v1_0/audio_types_vdi.h +++ b/audio/interfaces/sound/v1_0/audio_types_vdi.h @@ -52,6 +52,8 @@ enum AudioPortPinVdi { PIN_VDI_IN_BLUETOOTH_SCO_HEADSET = 1 << 27 | 1 << 4, PIN_VDI_IN_DAUDIO_DEFAULT = 1 << 27 | 1 << 5, PIN_VDI_IN_USB_HEADSET = 1 << 27 | 1 << 6, + PIN_VDI_IN_PENCIL = 1 << 27 | 1 << 7, + PIN_VDI_IN_UWB = 1 << 27 | 1 << 8, PIN_VDI_IN_BUTT, }; -- Gitee From 3986713f6e16c85a461f0efd155a12401eed11c7 Mon Sep 17 00:00:00 2001 From: chen0088 Date: Wed, 19 Mar 2025 17:05:34 +0800 Subject: [PATCH 062/103] =?UTF-8?q?=E8=BF=9E=E7=BB=AD=E6=8B=8D=E7=85=A7?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chen0088 --- .../dcamera_device/dmetadata_processor.h | 3 +- .../dstream_operator/dstream_operator.h | 14 +++- .../src/dcamera_device/dcamera_device.cpp | 6 +- .../dcamera_device/dmetadata_processor.cpp | 16 +++- .../src/dstream_operator/dstream_operator.cpp | 81 +++++++++++++------ 5 files changed, 87 insertions(+), 33 deletions(-) diff --git a/distributed_camera/hdi_service/include/dcamera_device/dmetadata_processor.h b/distributed_camera/hdi_service/include/dcamera_device/dmetadata_processor.h index bfdfed86d6..17c7abcd43 100644 --- a/distributed_camera/hdi_service/include/dcamera_device/dmetadata_processor.h +++ b/distributed_camera/hdi_service/include/dcamera_device/dmetadata_processor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -96,6 +96,7 @@ private: constexpr static uint32_t EXTEND_PHOTO = 2; constexpr static int32_t EXTEND_EOF = -1; constexpr static uint32_t ADD_MODE = 3; + constexpr static uint32_t DEFAULT_EXTEND_SIZE = 1000; std::function)> resultCallback_; std::shared_ptr dCameraAbility_; std::string protocolVersion_; diff --git a/distributed_camera/hdi_service/include/dstream_operator/dstream_operator.h b/distributed_camera/hdi_service/include/dstream_operator/dstream_operator.h index 380520f7ad..5817cd12b4 100644 --- a/distributed_camera/hdi_service/include/dstream_operator/dstream_operator.h +++ b/distributed_camera/hdi_service/include/dstream_operator/dstream_operator.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -30,6 +30,9 @@ #include "v1_1/istream_operator.h" #include "v1_2/istream_operator.h" #include "v1_3/istream_operator.h" +#include "v1_0/istream_operator_callback.h" +#include "v1_2/istream_operator_callback.h" +#include "v1_3/istream_operator_callback.h" #include "v1_0/types.h" #include "v1_1/types.h" @@ -82,7 +85,9 @@ public: DCamRetCode ParseVideoFormats(cJSON* rootValue); DCamRetCode AcquireBuffer(int streamId, DCameraBuffer &buffer); DCamRetCode ShutterBuffer(int streamId, const DCameraBuffer &buffer); - DCamRetCode SetCallBack(OHOS::sptr const &callback); + DCamRetCode SetCallBack(OHOS::sptr const &callback); + DCamRetCode SetCallBack_V1_2(OHOS::sptr const &callback); + DCamRetCode SetCallBack_V1_3(OHOS::sptr const &callback); DCamRetCode SetDeviceCallback(function &errorCbk, function)> &resultCbk); void Release(); @@ -149,11 +154,14 @@ private: void InsertNotifyCaptureMap(int32_t captureId); void EraseNotifyCaptureMap(int32_t captureId); bool CheckInputInfo(); + DCamRetCode ParseFormats(cJSON* rootValue); private: constexpr static uint32_t JSON_ARRAY_MAX_SIZE = 1000; std::shared_ptr dMetadataProcessor_; - OHOS::sptr dcStreamOperatorCallback_; + OHOS::sptr dcStreamOperatorCallback_; + OHOS::sptr dcStreamOperatorCallback__V1_2; + OHOS::sptr dcStreamOperatorCallback__V1_3; function errorCallback_; DHBase dhBase_; diff --git a/distributed_camera/hdi_service/src/dcamera_device/dcamera_device.cpp b/distributed_camera/hdi_service/src/dcamera_device/dcamera_device.cpp index 7778f43a7a..642e2437cc 100644 --- a/distributed_camera/hdi_service/src/dcamera_device/dcamera_device.cpp +++ b/distributed_camera/hdi_service/src/dcamera_device/dcamera_device.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -147,7 +147,7 @@ int32_t DCameraDevice::GetStreamOperator_V1_2(const sptrSetCallBack(callbackObj); + DCamRetCode ret = dCameraStreamOperator_->SetCallBack_V1_2(callbackObj); if (ret != SUCCESS) { DHLOGE("Set stream operator callbackObj failed, ret=%{public}d.", ret); return MapToExternalRetCode(ret); @@ -170,7 +170,7 @@ int32_t DCameraDevice::GetStreamOperator_V1_3(const sptrSetCallBack(callbackObj); + DCamRetCode ret = dCameraStreamOperator_->SetCallBack_V1_3(callbackObj); if (ret != SUCCESS) { DHLOGE("Set stream operator callbackObj failed, ret=%{public}d.", ret); return MapToExternalRetCode(ret); diff --git a/distributed_camera/hdi_service/src/dcamera_device/dmetadata_processor.cpp b/distributed_camera/hdi_service/src/dcamera_device/dmetadata_processor.cpp index 11d185ac86..807d05adec 100644 --- a/distributed_camera/hdi_service/src/dcamera_device/dmetadata_processor.cpp +++ b/distributed_camera/hdi_service/src/dcamera_device/dmetadata_processor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-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,6 +226,20 @@ DCamRetCode DMetadataProcessor::InitDCameraDefaultAbilityKeys(const std::string const int32_t jpegThumbnailSizes[] = {0, 0, DEGREE_240, DEGREE_180}; AddAbilityEntry(OHOS_JPEG_AVAILABLE_THUMBNAIL_SIZES, jpegThumbnailSizes, (sizeof(jpegThumbnailSizes) / sizeof(jpegThumbnailSizes[0]))); + + std::vector streamDefault = {0}; + streamDefault.assign(DEFAULT_EXTEND_SIZE, 0); + AddAbilityEntry(OHOS_ABILITY_STREAM_AVAILABLE_BASIC_CONFIGURATIONS, streamDefault.data(), streamDefault.size()); + + AddAbilityEntry(OHOS_ABILITY_STREAM_AVAILABLE_EXTEND_CONFIGURATIONS, streamDefault.data(), streamDefault.size()); + + AddAbilityEntry(OHOS_SENSOR_INFO_MAX_FRAME_DURATION, &MAX_FRAME_DURATION, 1); + + const int32_t jpegMaxSizeDefault = MAX_SUPPORT_PREVIEW_WIDTH * MAX_SUPPORT_PREVIEW_HEIGHT; + AddAbilityEntry(OHOS_JPEG_MAX_SIZE, &jpegMaxSizeDefault, 1); + + const uint8_t connectionTypeDefault = OHOS_CAMERA_CONNECTION_TYPE_REMOTE; + AddAbilityEntry(OHOS_ABILITY_CAMERA_CONNECTION_TYPE, &connectionTypeDefault, 1); return SUCCESS; } diff --git a/distributed_camera/hdi_service/src/dstream_operator/dstream_operator.cpp b/distributed_camera/hdi_service/src/dstream_operator/dstream_operator.cpp index 8a1c16ba16..ab25229aa4 100644 --- a/distributed_camera/hdi_service/src/dstream_operator/dstream_operator.cpp +++ b/distributed_camera/hdi_service/src/dstream_operator/dstream_operator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -488,8 +488,8 @@ int32_t DStreamOperator::CancelCapture(int32_t captureId) EraseStreamCaptureBufferNum(std::make_pair(captureId, id)); EraseNotifyCaptureMap(id); } - if (dcStreamOperatorCallback_) { - dcStreamOperatorCallback_->OnCaptureEnded(captureId, info); + if (dcStreamOperatorCallback__V1_3) { + dcStreamOperatorCallback__V1_3->OnCaptureEnded(captureId, info); } EraseCaptureInfo(captureId); @@ -654,35 +654,44 @@ DCamRetCode DStreamOperator::InitOutputConfigurations(const DHBase &dhBase, cons return DCamRetCode::INVALID_ARGUMENT; } + if (ParseFormats(rootValue) != SUCCESS) { + cJSON_Delete(rootValue); + cJSON_Delete(srcRootValue); + return DCamRetCode::INVALID_ARGUMENT; + } + + if (!CheckInputInfo()) { + cJSON_Delete(rootValue); + cJSON_Delete(srcRootValue); + return DEVICE_NOT_INIT; + } + cJSON_Delete(rootValue); + cJSON_Delete(srcRootValue); + return SUCCESS; +} + +DCamRetCode DStreamOperator::ParseFormats(cJSON* rootValue) +{ + cJSON *modeValue = cJSON_GetObjectItemCaseSensitive(rootValue, std::to_string(currentOperMode_).c_str()); if (currentOperMode_ == 0) { if (ParsePhotoFormats(rootValue) != SUCCESS || ParsePreviewFormats(rootValue) != SUCCESS || ParseVideoFormats(rootValue) != SUCCESS) { - cJSON_Delete(rootValue); - cJSON_Delete(srcRootValue); + return DCamRetCode::INVALID_ARGUMENT; + } + } else if (currentOperMode_ != 0 && modeValue == nullptr) { + if (ParsePhotoFormats(rootValue) != SUCCESS || ParsePreviewFormats(rootValue) != SUCCESS || + ParseVideoFormats(rootValue) != SUCCESS) { return DCamRetCode::INVALID_ARGUMENT; } } else { - cJSON *modeValue = cJSON_GetObjectItemCaseSensitive(rootValue, std::to_string(currentOperMode_).c_str()); if (modeValue == nullptr || !cJSON_IsObject(modeValue)) { - cJSON_Delete(rootValue); - cJSON_Delete(srcRootValue); return DCamRetCode::INVALID_ARGUMENT; } if (ParsePhotoFormats(modeValue) != SUCCESS || ParsePreviewFormats(modeValue) != SUCCESS || ParseVideoFormats(modeValue) != SUCCESS) { - cJSON_Delete(rootValue); - cJSON_Delete(srcRootValue); return DCamRetCode::INVALID_ARGUMENT; } } - - if (!CheckInputInfo()) { - cJSON_Delete(rootValue); - cJSON_Delete(srcRootValue); - return DEVICE_NOT_INIT; - } - cJSON_Delete(rootValue); - cJSON_Delete(srcRootValue); return SUCCESS; } @@ -838,10 +847,10 @@ DCamRetCode DStreamOperator::ShutterBuffer(int streamId, const DCameraBuffer &bu auto iter = notifyCaptureStartedMap_.find(streamId); if (iter != notifyCaptureStartedMap_.end()) { - if (!iter->second && dcStreamOperatorCallback_ != nullptr) { + if (!iter->second && dcStreamOperatorCallback__V1_3 != nullptr) { vector tmpStreamIds; tmpStreamIds.push_back(streamId); - dcStreamOperatorCallback_->OnCaptureStarted(captureId, tmpStreamIds); + dcStreamOperatorCallback__V1_3->OnCaptureStarted(captureId, tmpStreamIds); iter->second = true; } } @@ -865,23 +874,35 @@ DCamRetCode DStreamOperator::ShutterBuffer(int streamId, const DCameraBuffer &bu bool enableShutter = FindEnableShutter(streamId); if (!enableShutter) { - if (dcStreamOperatorCallback_ == nullptr) { + if (dcStreamOperatorCallback__V1_3 == nullptr) { DHLOGE("DStreamOperator::ShutterBuffer failed, need shutter frame, but stream operator callback is null."); return DCamRetCode::FAILED; } std::vector streamIds; streamIds.push_back(streamId); - dcStreamOperatorCallback_->OnFrameShutter(captureId, streamIds, resultTimestamp); + dcStreamOperatorCallback__V1_3->OnFrameShutter(captureId, streamIds, resultTimestamp); } return DCamRetCode::SUCCESS; } -DCamRetCode DStreamOperator::SetCallBack(OHOS::sptr const &callback) +DCamRetCode DStreamOperator::SetCallBack(OHOS::sptr const &callback) { dcStreamOperatorCallback_ = callback; return SUCCESS; } +DCamRetCode DStreamOperator::SetCallBack_V1_2(OHOS::sptr const &callback) +{ + dcStreamOperatorCallback__V1_2 = callback; + return SUCCESS; +} + +DCamRetCode DStreamOperator::SetCallBack_V1_3(OHOS::sptr const &callback) +{ + dcStreamOperatorCallback__V1_3 = callback; + return SUCCESS; +} + DCamRetCode DStreamOperator::SetDeviceCallback( std::function &errorCbk, std::function)> &resultCbk) @@ -902,7 +923,7 @@ void DStreamOperator::SnapShotStreamOnCaptureEnded(int32_t captureId, int stream if (dcStreamInfo->type_ != DCStreamType::SNAPSHOT_FRAME) { return; } - if (dcStreamOperatorCallback_ == nullptr) { + if (dcStreamOperatorCallback__V1_3 == nullptr) { return; } std::vector info; @@ -910,7 +931,15 @@ void DStreamOperator::SnapShotStreamOnCaptureEnded(int32_t captureId, int stream tmp.frameCount_ = FindStreamCaptureBufferNum(std::make_pair(captureId, streamId)); tmp.streamId_ = streamId; info.push_back(tmp); - dcStreamOperatorCallback_->OnCaptureEnded(captureId, info); + dcStreamOperatorCallback__V1_3->OnCaptureEnded(captureId, info); + auto halCaptureInfo = FindCaptureInfoById(captureId); + if (captureId < 0 || halCaptureInfo == nullptr) { + DHLOGE("Input captureId %{public}d is not exist.", captureId); + return; + } + std::vector streamIds = halCaptureInfo->streamIds_; + uint64_t resultTimestamp = GetCurrentLocalTimeStamp(); + dcStreamOperatorCallback__V1_3->OnCaptureReady(captureId, streamIds, resultTimestamp); DHLOGD("snapshot stream successfully reported captureId = %{public}d streamId = %{public}d.", captureId, streamId); } @@ -936,6 +965,8 @@ void DStreamOperator::Release() cachedDCaptureInfoList_.clear(); notifyCaptureStartedMap_.clear(); dcStreamOperatorCallback_ = nullptr; + dcStreamOperatorCallback__V1_2 = nullptr; + dcStreamOperatorCallback__V1_3 = nullptr; } std::vector DStreamOperator::GetStreamIds() -- Gitee From a6f3807d7c97cf5ffc2b007f4602b8663424bdf1 Mon Sep 17 00:00:00 2001 From: huangshengqing Date: Mon, 24 Mar 2025 19:33:22 +0800 Subject: [PATCH 063/103] change getFd Signed-off-by: huangshengqing --- usb/libusb_adapter/include/libusb_adapter.h | 2 + usb/libusb_adapter/src/libusb_adapter.cpp | 49 +++++++++++++-------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/usb/libusb_adapter/include/libusb_adapter.h b/usb/libusb_adapter/include/libusb_adapter.h index 241b229e0f..b8975e68c1 100644 --- a/usb/libusb_adapter/include/libusb_adapter.h +++ b/usb/libusb_adapter/include/libusb_adapter.h @@ -257,6 +257,8 @@ private: libusb_hotplug_callback_handle hotplug_handle_; static std::list> subscribers_; static sptr libUsbSaSubscriber_; + std::mutex openFdsMutex_; + std::map, int32_t> openedFds_; }; } // namespace V1_2 } // namespace Usb diff --git a/usb/libusb_adapter/src/libusb_adapter.cpp b/usb/libusb_adapter/src/libusb_adapter.cpp index fe74a694da..e5050bc2d8 100644 --- a/usb/libusb_adapter/src/libusb_adapter.cpp +++ b/usb/libusb_adapter/src/libusb_adapter.cpp @@ -298,6 +298,20 @@ int32_t LibusbAdapter::CloseDevice(const UsbDev &dev) info->second.count--; HDF_LOGI("%{public}s Number of devices that are opened=%{public}d", __func__, info->second.count); if (info->second.count == 0 && (info->second.handle != nullptr)) { + { + std::lock_guard lock(openedFdsMutex_); + auto iter = openedFds_.find({dev.busNum, dev.devAddr}); + if (iter != openedFds_.end()) { + int32_t fd = iter->second; + if (fd != ) + int res = close(fd); + openedFds_.erase(iter); + HDF_LOGI("%{public}s:%{public}d close %{public}d ret = %{public}d", + __func__, __LINE__, iter->second, res); + } else { + HDF_LOGI("%{public}s:%{public}d not opened", __func__, __LINE__); + } + } { std::unique_lock lock(g_mapMutexUsbOpenFdMap); auto it = g_usbOpenFdMap.find(result); @@ -400,32 +414,31 @@ int32_t LibusbAdapter::GetDeviceFileDescriptor(const UsbDev &dev, int32_t &fd) HDF_LOGE("%{public}s: FindHandleByDev is failed, ret=%{public}d", __func__, ret); return HDF_FAILURE; } - uint32_t result = (static_cast(dev.busNum) << DISPLACEMENT_NUMBER) | - static_cast(dev.devAddr); - { - std::shared_lock lock(g_mapMutexUsbOpenFdMap); - auto info = g_usbOpenFdMap.find(result); - if (info != g_usbOpenFdMap.end()) { - fd = info->second; - HDF_LOGI("%{public}s open is already on, fd: %{public}d", __func__, info->second); - return HDF_SUCCESS; - } - } char path[LIBUSB_PATH_LENGTH] = {"\0"}; ret = sprintf_s(path, sizeof(path), "%s/%03u/%03u", USB_DEV_FS_PATH, dev.busNum, dev.devAddr); if (ret < 0) { HDF_LOGE("%{public}s: sprintf_s path failed, ret:%{public}d", __func__, ret); return ret; } - int32_t fileFd = open(path, O_RDWR); - if (fileFd < 0) { + int32_t fd = open(path, O_RDWR); + if (fd < 0) { HDF_LOGE("%{public}s: open device failed errno = %{public}d %{public}s", __func__, errno, strerror(errno)); return HDF_FAILURE; - } - fd = fileFd; - { - std::unique_lock lock(g_mapMutexUsbOpenFdMap); - g_usbOpenFdMap[result] = fd; + } else { + std::lock_guard lock(openedFdsMutex_); + auto iter = openedFds_.find({dev.busNum, dev.devAddr}); + if (iter != openedFds_.end()) { + int32_t oldFd = iter->second; + if (oldfd != fd) { + int res = close(oldFd); + HDF_LOGI("%{public}s:%{public}d close old %{public}d ret = %{public}d", + __func__, __LINE__, iter->second, res); + } + } else { + HDF_LOGI("%{public}s:%{public}d first time get fd", __func__, __LINE__); + } + openedFds_[{dev.busNum, dev.devAddr}] = fd; + HDF_LOGI("%{public}s:%{public}d opened %{public}d", __func__, __LINE__, fd); } HDF_LOGI("%{public}s leave", __func__); return HDF_SUCCESS; -- Gitee From 34b07af3746402826b4c0bc43bd3c9ffac14dc68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Mon, 24 Mar 2025 19:39:43 +0800 Subject: [PATCH 064/103] change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- usb/ddk/device/src/adapter_if.c | 6 ++++-- usb/ddk/host/src/ddk_device_manager.c | 6 ++++-- usb/ddk/host/src/ddk_sysfs_device.c | 3 ++- usb/ddk/host/src/ddk_uevent_handle.c | 8 ++++---- usb/ddk/host/src/linux_adapter.c | 11 ++++++++--- .../scsi_service/src/scsi_ddk_service.cpp | 6 ++++-- .../serial_service/src/usb_serial_ddk_service.cpp | 4 +++- usb/ddk_service/usb_service/src/usb_ddk_service.cpp | 8 ++++---- usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp | 4 ++-- usb/hdi_service/src/usb_impl.cpp | 6 +++--- usb/hdi_service/src/usbd_accessory.cpp | 10 ++++++---- usb/hdi_service/src/usbd_port.cpp | 6 ++++-- usb/libusb_adapter/src/libusb_adapter.cpp | 13 +++++++++---- usb/sample/host/src/usbhost_nosdk_speed.c | 3 ++- usb/serial/src/libusb_serial.cpp | 5 +++-- usb/serial/src/linux_serial.cpp | 7 ++++--- 16 files changed, 66 insertions(+), 40 deletions(-) diff --git a/usb/ddk/device/src/adapter_if.c b/usb/ddk/device/src/adapter_if.c index a2f742bb27..d8f471acb2 100644 --- a/usb/ddk/device/src/adapter_if.c +++ b/usb/ddk/device/src/adapter_if.c @@ -305,6 +305,7 @@ static int32_t UsbFnAdapterOpenFn(void) for (i = 0; i < OPEN_CNT; i++) { ep = open(USBFN_DEV, O_RDWR); if (ep > 0) { + fdsan_exchange_owner_tag(ep, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); break; } usleep(SLEEP_DELAY); @@ -320,7 +321,7 @@ static int32_t UsbFnAdapterClosefn(int32_t fd) if (fd <= 0) { return HDF_ERR_INVALID_PARAM; } - return close(fd); + return fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); } static int32_t UsbFnAdapterCreatInterface(const char *interfaceName, int32_t nameLen) @@ -402,6 +403,7 @@ static int32_t UsbFnAdapterOpenPipe(const char *interfaceName, int32_t epIndex) for (int32_t i = 0; i < OPEN_CNT; i++) { ep = open(epName, O_RDWR); if (ep > 0) { + fdsan_exchange_owner_tag(ep, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); break; } usleep(SLEEP_DELAY); @@ -419,7 +421,7 @@ static int32_t UsbFnAdapterClosePipe(int32_t ep) return HDF_ERR_INVALID_PARAM; } - return close(ep); + return fdsan_close_with_tag(ep, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); } static void GetHeaderStr(struct UsbFnStrings ** const strings, struct UsbFunctionfsStringsHead *headerStr) diff --git a/usb/ddk/host/src/ddk_device_manager.c b/usb/ddk/host/src/ddk_device_manager.c index 0c2396af84..9a033415b4 100644 --- a/usb/ddk/host/src/ddk_device_manager.c +++ b/usb/ddk/host/src/ddk_device_manager.c @@ -272,10 +272,11 @@ int32_t DdkDevMgrGetGadgetLinkStatusSafe(DdkDevMgrHandleGadget handle, void *pri HDF_LOGE("%{public}s: open %{public}s failed errno:%{public}d", __func__, g_gadgetStatePath, errno); return HDF_ERR_IO; } + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); char buf[STATE_STRING_LENGTH] = {0}; ssize_t numRead = read(fd, buf, STATE_STRING_LENGTH); - close(fd); + fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); if (numRead <= 0) { HDF_LOGE("%{public}s: read state failed errno:%{public}d", __func__, errno); return HDF_ERR_IO; @@ -309,10 +310,11 @@ bool DdkDevMgrGetGadgetLinkStatus() HDF_LOGE("%{public}s: open %{public}s failed errno:%{public}d", __func__, g_gadgetStatePath, errno); return false; } + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); char buf[STATE_STRING_LENGTH] = {0}; ssize_t numRead = read(fd, buf, STATE_STRING_LENGTH); - close(fd); + fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); if (numRead <= 0) { HDF_LOGE("%{public}s: read state failed errno:%{public}d", __func__, errno); return false; diff --git a/usb/ddk/host/src/ddk_sysfs_device.c b/usb/ddk/host/src/ddk_sysfs_device.c index 12ad8ec1eb..7d2e2e7404 100644 --- a/usb/ddk/host/src/ddk_sysfs_device.c +++ b/usb/ddk/host/src/ddk_sysfs_device.c @@ -69,6 +69,7 @@ static int32_t DdkSysfsReadProperty(const char *deviceDir, const char *propName, HDF_LOGE("%{public}s: open file failed path:%{public}s, errno:%{public}d", __func__, path, errno); return HDF_ERR_IO; } + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); int32_t ret = HDF_SUCCESS; do { @@ -98,7 +99,7 @@ static int32_t DdkSysfsReadProperty(const char *deviceDir, const char *propName, *value = res; } while (0); - close(fd); + fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return ret; } diff --git a/usb/ddk/host/src/ddk_uevent_handle.c b/usb/ddk/host/src/ddk_uevent_handle.c index 3cf1aaacba..d97b5bb04b 100644 --- a/usb/ddk/host/src/ddk_uevent_handle.c +++ b/usb/ddk/host/src/ddk_uevent_handle.c @@ -64,20 +64,20 @@ static int DdkUeventOpen(int *fd) int buffSize = UEVENT_SOCKET_BUFF_SIZE; if (setsockopt(socketfd, SOL_SOCKET, SO_RCVBUF, &buffSize, sizeof(buffSize)) != 0) { HDF_LOGE("%{public}s: setsockopt failed!", __func__); - close(socketfd); + fdsan_close_with_tag(socketfd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return HDF_FAILURE; } const int32_t on = 1; // turn on passcred if (setsockopt(socketfd, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)) != 0) { HDF_LOGE("setsockopt failed!"); - close(socketfd); + fdsan_close_with_tag(socketfd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return HDF_FAILURE; } if (bind(socketfd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { HDF_LOGE("%{public}s: bind socketfd failed!", __func__); - close(socketfd); + fdsan_close_with_tag(socketfd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return HDF_FAILURE; } *fd = socketfd; @@ -197,7 +197,7 @@ void *DdkUeventMain(void *param) } } while (true); - close(socketfd); + fdsan_close_with_tag(socketfd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return NULL; } diff --git a/usb/ddk/host/src/linux_adapter.c b/usb/ddk/host/src/linux_adapter.c index 194dbe4dbd..51745816c1 100644 --- a/usb/ddk/host/src/linux_adapter.c +++ b/usb/ddk/host/src/linux_adapter.c @@ -136,6 +136,7 @@ static int32_t GetMmapFd(struct UsbDevice *dev) HDF_LOGE("%{public}s: open error:%{public}s", __func__, path); return HDF_FAILURE; } + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); dev->devHandle->mmapFd = fd; return HDF_SUCCESS; } @@ -188,6 +189,7 @@ static int32_t OsGetUsbFd(struct UsbDevice *dev, mode_t mode) int32_t fd = open(pathBuf, mode | O_CLOEXEC); if (fd != HDF_FAILURE) { + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return fd; } HDF_LOGI("%{public}s: path: %{public}s, fd:%{public}d", __func__, pathBuf, fd); @@ -196,6 +198,7 @@ static int32_t OsGetUsbFd(struct UsbDevice *dev, mode_t mode) case ENOENT: fd = open(pathBuf, mode | O_CLOEXEC); if (fd != HDF_FAILURE) { + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return fd; } ret = HDF_DEV_ERR_NO_DEVICE; @@ -228,6 +231,7 @@ static int32_t AdapterGetUsbDeviceFd(struct UsbDevice *dev, mode_t mode) int32_t fd = open(pathBuf, mode | O_CLOEXEC); if (fd != HDF_FAILURE) { HDF_LOGI("%{public}s: path: %{public}s, fd: %{public}d", __func__, pathBuf, fd); + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return fd; } usleep(SLEEP_TIME); @@ -235,6 +239,7 @@ static int32_t AdapterGetUsbDeviceFd(struct UsbDevice *dev, mode_t mode) case ENOENT: fd = open(pathBuf, mode | O_CLOEXEC); if (fd != HDF_FAILURE) { + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return fd; } ret = HDF_DEV_ERR_NO_DEVICE; @@ -1054,9 +1059,9 @@ static void AdapterCloseDevice(struct UsbDeviceHandle *handle) } RawUsbMemFree(dev); - close(handle->fd); - close(handle->mmapFd); - HDF_LOGI("%{public}s:close fd:%{public}d", __func__, handle->fd); + fdsan_close_with_tag(handle->fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + fdsan_close_with_tag(handle->mmapFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + HDF_LOGI("%{public}s:close fd:%{public}d handle->mmapFd:%{public}d", __func__, handle->fd, handle->mmapFd); OsalMutexDestroy(&handle->lock); RawUsbMemFree(handle); handle = NULL; diff --git a/usb/ddk_service/scsi_service/src/scsi_ddk_service.cpp b/usb/ddk_service/scsi_service/src/scsi_ddk_service.cpp index 130c1f4e5b..6d886a13fc 100644 --- a/usb/ddk_service/scsi_service/src/scsi_ddk_service.cpp +++ b/usb/ddk_service/scsi_service/src/scsi_ddk_service.cpp @@ -264,6 +264,7 @@ int32_t ScsiDdkService::Open(uint64_t deviceId, uint8_t interfaceIndex, ScsiPeri HDF_LOGE("%{public}s open failed, path=%{public}s, errno=%{public}d", __func__, path.c_str(), errno); return SCSIPERIPHERAL_DDK_IO_ERROR; } + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); dev.devFd = fd; HDF_LOGD("Open success, dev.devFd=%{public}d, path.c_str()=%{public}s", dev.devFd, path.c_str()); @@ -304,7 +305,7 @@ int32_t ScsiDdkService::Close(const ScsiPeripheralDevice& dev) } int32_t ret = TrackTime([&]() { - return close(dev.devFd); + return fdsan_close_with_tag(dev.devFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); }, __func__); if (ret == -1) { HDF_LOGE("%{public}s close failed", __func__); @@ -312,7 +313,7 @@ int32_t ScsiDdkService::Close(const ScsiPeripheralDevice& dev) } ret = TrackTime([&]() { - return close(dev.memMapFd); + return fdsan_close_with_tag(dev.memMapFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); }, __func__); if (ret < 0) { HDF_LOGE("%{public}s: close failed, memMapFd=%{public}d, errno=%{public}d", __func__, dev.memMapFd, errno); @@ -727,6 +728,7 @@ int32_t ScsiDdkService::GetDeviceMemMapFd(uint16_t busNum, uint16_t devAddr, uin HDF_LOGE("%{public}s: open error, path=%{public}s, errno=%{public}d", __func__, path, errno); return SCSIPERIPHERAL_DDK_IO_ERROR; } + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); memMapFd = fd; HDF_LOGD("%{public}s: memMapFd:%{public}d", __func__, memMapFd); diff --git a/usb/ddk_service/serial_service/src/usb_serial_ddk_service.cpp b/usb/ddk_service/serial_service/src/usb_serial_ddk_service.cpp index 2eb228340e..2bed65ce8b 100644 --- a/usb/ddk_service/serial_service/src/usb_serial_ddk_service.cpp +++ b/usb/ddk_service/serial_service/src/usb_serial_ddk_service.cpp @@ -116,6 +116,7 @@ int32_t UsbSerialDdkService::Open(uint64_t deviceId, uint64_t interfaceIndex, HDF_LOGE("error %{public}d opening devNodePath: %{public}s\n", errno, strerror(errno)); return USB_SERIAL_DDK_IO_ERROR; } + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); dev.fd = static_cast(fd); return HDF_SUCCESS; } @@ -128,7 +129,8 @@ int32_t UsbSerialDdkService::Close(const OHOS::HDI::Usb::UsbSerialDdk::V1_0::Usb return USB_SERIAL_DDK_NO_PERM; } - int ret = close(static_cast(dev.fd)); + int ret = fdsan_close_with_tag(static_cast(dev.fd), + fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); if (ret != 0) { HDF_LOGE("Failed to close device: %{public}s.\n", strerror(errno)); if (errno == EBADF) { diff --git a/usb/ddk_service/usb_service/src/usb_ddk_service.cpp b/usb/ddk_service/usb_service/src/usb_ddk_service.cpp index fa42070fe4..848a3ef4d7 100644 --- a/usb/ddk_service/usb_service/src/usb_ddk_service.cpp +++ b/usb/ddk_service/usb_service/src/usb_ddk_service.cpp @@ -673,7 +673,7 @@ int32_t SubmitRequestWithAshmem(const UsbRequestPipe &pipe, const UsbAshmem &ash struct UsbRequest *request = UsbAllocRequestByAshmem(handleConvert, 0, ashmem.size, ashmem.ashmemFd); if (request == nullptr) { HDF_LOGE("%{public}s alloc request failed", __func__); - close(ashmem.ashmemFd); + fdsan_close_with_tag(ashmem.ashmemFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); pthread_rwlock_unlock(&g_rwLock); return HDF_DEV_ERR_NO_MEMORY; } @@ -695,7 +695,7 @@ int32_t SubmitRequestWithAshmem(const UsbRequestPipe &pipe, const UsbAshmem &ash transferredLength = request->compInfo.actualLength; FINISHED: (void)UsbFreeRequestByMmap(request); - close(ashmem.ashmemFd); + fdsan_close_with_tag(ashmem.ashmemFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); pthread_rwlock_unlock(&g_rwLock); return ret; } @@ -705,7 +705,7 @@ int32_t UsbDdkService::SendPipeRequestWithAshmem( { if (!DdkPermissionManager::VerifyPermission(PERMISSION_NAME)) { HDF_LOGE("%{public}s: no permission", __func__); - close(ashmem.ashmemFd); + fdsan_close_with_tag(ashmem.ashmemFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return HDF_ERR_NOPERM; } @@ -713,7 +713,7 @@ int32_t UsbDdkService::SendPipeRequestWithAshmem( int32_t ret = UsbDdkUnHash(pipe.interfaceHandle, handle); if (ret != HDF_SUCCESS) { HDF_LOGE("%{public}s unhash failed %{public}d", __func__, ret); - close(ashmem.ashmemFd); + fdsan_close_with_tag(ashmem.ashmemFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return ret; } #ifndef LIBUSB_ENABLE diff --git a/usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp b/usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp index 1549cba8f6..1713994d5b 100755 --- a/usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp +++ b/usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp @@ -1731,7 +1731,7 @@ int32_t UsbfnMtpImpl::ReceiveFile(const UsbFnMtpFileSlice &mfs) pthread_rwlock_rdlock(&mtpRunrwLock_); ON_SCOPE_EXIT(release) { pthread_rwlock_unlock(&mtpRunrwLock_); - close(mfs.fd); + fdsan_close_with_tag(mfs.fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); }; if (mtpPort_ == nullptr || mtpDev_ == nullptr || !mtpDev_->initFlag) { HDF_LOGE("%{public}s: no init", __func__); @@ -1890,7 +1890,7 @@ int32_t UsbfnMtpImpl::SendFile(const UsbFnMtpFileSlice &mfs) pthread_rwlock_rdlock(&mtpRunrwLock_); ON_SCOPE_EXIT(release) { pthread_rwlock_unlock(&mtpRunrwLock_); - close(mfs.fd); + fdsan_close_with_tag(mfs.fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); }; if (mtpPort_ == nullptr || mtpDev_ == nullptr || !mtpDev_->initFlag) { HDF_LOGE("%{public}s: no init", __func__); diff --git a/usb/hdi_service/src/usb_impl.cpp b/usb/hdi_service/src/usb_impl.cpp index 324124cf73..c8dd1ff991 100644 --- a/usb/hdi_service/src/usb_impl.cpp +++ b/usb/hdi_service/src/usb_impl.cpp @@ -775,7 +775,7 @@ int32_t UsbImpl::InitAsmBufferHandle(UsbdBufferHandle *handle, int32_t fd, int32 handle->cbflg = 0; lseek(fd, 0, SEEK_SET); handle->starAddr = static_cast(mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)); - close(fd); + fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); if (handle->starAddr == nullptr) { handle->fd = -1; handle->size = 0; @@ -926,7 +926,7 @@ void UsbImpl::UsbdCloseFd(UsbImpl *super, UsbPnpNotifyMatchInfoTable *infoTable) auto iter = super->openedFds_.find({infoTable->busNum, infoTable->devNum}); if (iter != super->openedFds_.end()) { int32_t fd = iter->second; - int res = close(fd); + int res = fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); super->openedFds_.erase(iter); HDF_LOGI("%{public}s:%{public}d close %{public}d ret = %{public}d", __func__, __LINE__, iter->second, res); @@ -1352,7 +1352,7 @@ int32_t UsbImpl::GetDeviceFileDescriptor(const UsbDev &dev, int32_t &fd) auto iter = openedFds_.find({dev.busNum, dev.devAddr}); if (iter != openedFds_.end()) { int32_t oldFd = iter->second; - int res = close(oldFd); + int res = fdsan_close_with_tag(oldFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); HDF_LOGI("%{public}s:%{public}d close old %{public}d ret = %{public}d", __func__, __LINE__, iter->second, res); } else { diff --git a/usb/hdi_service/src/usbd_accessory.cpp b/usb/hdi_service/src/usbd_accessory.cpp index 8412a6d3f5..86f280e4eb 100644 --- a/usb/hdi_service/src/usbd_accessory.cpp +++ b/usb/hdi_service/src/usbd_accessory.cpp @@ -169,6 +169,7 @@ int32_t UsbdAccessory::GetAccessoryInfo(std::vector &accessoryInfo) HDF_LOGE("%{public}s:%{public}d open failed", __func__, __LINE__); return HDF_ERR_NOT_SUPPORT; } + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); int32_t ret = HDF_FAILURE; std::string accInfoString; for (size_t i = 0; i < accStringList.size(); i++) { @@ -179,7 +180,7 @@ int32_t UsbdAccessory::GetAccessoryInfo(std::vector &accessoryInfo) } accessoryInfo.push_back(accInfoString); } - close(fd); + fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return HDF_SUCCESS; } @@ -194,6 +195,7 @@ int32_t UsbdAccessory::OpenAccessory(int32_t &fd) HDF_LOGE("%{public}s:%{public}d open failed", __func__, __LINE__); return HDF_ERR_NOT_SUPPORT; } + fdsan_exchange_owner_tag(accFd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); fd = accFd; return HDF_SUCCESS; } @@ -201,9 +203,9 @@ int32_t UsbdAccessory::OpenAccessory(int32_t &fd) int32_t UsbdAccessory::CloseAccessory(int32_t fd) { if (accFd > 0) { - close(accFd); + fdsan_close_with_tag(accFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); } - close(fd); + fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); accFd = 0; return HDF_SUCCESS; } @@ -211,7 +213,7 @@ int32_t UsbdAccessory::CloseAccessory(int32_t fd) void UsbdAccessory::HandleEvent(int32_t state) { if (state == ACT_DOWNDEVICE && accFd > 0) { - close(accFd); + fdsan_close_with_tag(accFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); accFd = 0; } } diff --git a/usb/hdi_service/src/usbd_port.cpp b/usb/hdi_service/src/usbd_port.cpp index 04d92e6753..4091cbc9c9 100644 --- a/usb/hdi_service/src/usbd_port.cpp +++ b/usb/hdi_service/src/usbd_port.cpp @@ -96,9 +96,10 @@ int32_t UsbdPort::WritePortFile(int32_t powerRole, int32_t dataRole, int32_t mod HDF_LOGE("%{public}s: file open error fd = %{public}d", __func__, fd); return HDF_FAILURE; } + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); int32_t ret = write(fd, modeStr.c_str(), len); - close(fd); + fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); if (ret < 0) { HDF_LOGE("%{public}s: write error", __func__); return HDF_FAILURE; @@ -113,10 +114,11 @@ int32_t UsbdPort::ReadPortFile(int32_t &powerRole, int32_t &dataRole, int32_t &m HDF_LOGE("%{public}s: file open error fd = %{public}d", __func__, fd); return HDF_FAILURE; } + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); char modeBuf[PATH_MAX] = {'\0'}; int32_t ret = read(fd, modeBuf, PATH_MAX - 1); - close(fd); + fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); if (ret < 0) { HDF_LOGE("%{public}s: read error: %{public}s", __func__, path_.c_str()); diff --git a/usb/libusb_adapter/src/libusb_adapter.cpp b/usb/libusb_adapter/src/libusb_adapter.cpp index fe74a694da..90a6225823 100644 --- a/usb/libusb_adapter/src/libusb_adapter.cpp +++ b/usb/libusb_adapter/src/libusb_adapter.cpp @@ -302,7 +302,7 @@ int32_t LibusbAdapter::CloseDevice(const UsbDev &dev) std::unique_lock lock(g_mapMutexUsbOpenFdMap); auto it = g_usbOpenFdMap.find(result); if (it != g_usbOpenFdMap.end()) { - close(it->second); + fdsan_close_with_tag(it->second, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); g_usbOpenFdMap.erase(it); } } @@ -422,6 +422,7 @@ int32_t LibusbAdapter::GetDeviceFileDescriptor(const UsbDev &dev, int32_t &fd) HDF_LOGE("%{public}s: open device failed errno = %{public}d %{public}s", __func__, errno, strerror(errno)); return HDF_FAILURE; } + fdsan_exchange_owner_tag(fileFd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); fd = fileFd; { std::unique_lock lock(g_mapMutexUsbOpenFdMap); @@ -1161,6 +1162,7 @@ int32_t LibusbAdapter::GetFileDescriptor(const UsbDev &dev, int32_t &fd) HDF_LOGE("%{public}s: open device failed errno = %{public}d %{public}s", __func__, errno, strerror(errno)); return HDF_FAILURE; } + fdsan_exchange_owner_tag(fileFd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); fd = fileFd; { std::unique_lock lock(g_mapMutexUsbOpenFdMap); @@ -1428,7 +1430,8 @@ int32_t LibusbAdapter::SendPipeRequestWithAshmem(const UsbDev &dev, unsigned cha } transferredLength = static_cast(actlength); CloseMmapBuffer(buffer, sendRequestAshmemParameter.ashmemSize); - close(sendRequestAshmemParameter.ashmemFd); + fdsan_close_with_tag(sendRequestAshmemParameter.ashmemFd, + fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return ret; } @@ -1465,11 +1468,12 @@ int32_t LibusbAdapter::GetRawDescriptor(const UsbDev &dev, std::vector __func__, ptrBuf, errno); return HDF_FAILURE; } + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); void *descriptors = nullptr; size_t descriptorsLength = 0; if (ReadDescriptors(fd, &descriptors, descriptorsLength) != HDF_SUCCESS) { HDF_LOGE("%{public}s: ReadDescriptors failed", __func__); - close(fd); + fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return HDF_FAILURE; } uint8_t *ptr = static_cast(descriptors); @@ -1477,7 +1481,7 @@ int32_t LibusbAdapter::GetRawDescriptor(const UsbDev &dev, std::vector descriptor.resize(length); std::copy(ptr, ptr + length, descriptor.begin()); FreeUsbDescriptorsMemory(descriptors); - close(fd); + fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); HDF_LOGI("%{public}s leave", __func__); return HDF_SUCCESS; } @@ -1788,6 +1792,7 @@ int32_t LibusbAdapter::GetDeviceMemMapFd(const UsbDev &dev, int &fd) return HDF_FAILURE; } fd = ret; + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); { std::unique_lock lock(g_mapMutexUsbOpenFdMap); g_usbOpenFdMap[result] = fd; diff --git a/usb/sample/host/src/usbhost_nosdk_speed.c b/usb/sample/host/src/usbhost_nosdk_speed.c index e29bebb1fb..73ba3c138c 100644 --- a/usb/sample/host/src/usbhost_nosdk_speed.c +++ b/usb/sample/host/src/usbhost_nosdk_speed.c @@ -66,7 +66,7 @@ static unsigned char g_endNum; static void CloseDevice(void) { if (g_fd > 0) { - close(g_fd); + fdsan_close_with_tag(g_fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); g_fd = 0; } return; @@ -89,6 +89,7 @@ static int32_t OpenDevice(void) if (g_fd < 0) { HDF_LOGE("%{public}s: open device failed errno = %{public}d %{public}s", __func__, errno, strerror(errno)); } + fdsan_exchange_owner_tag(g_fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return g_fd; } diff --git a/usb/serial/src/libusb_serial.cpp b/usb/serial/src/libusb_serial.cpp index adc2365490..1d7491325d 100644 --- a/usb/serial/src/libusb_serial.cpp +++ b/usb/serial/src/libusb_serial.cpp @@ -627,9 +627,10 @@ bool CheckTtyDeviceInfo(std::string ttyUsbPath, libusb_device* device) HDF_LOGE("%{public}s : open file failed. ret = %{public}s", __func__, strerror(errno)); return false; } + fdsan_exchange_owner_tag(busnumFd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); char busnumBuff[BUFFER_SIZE] = {'\0'}; ssize_t readBytes = read(busnumFd, busnumBuff, BUFFER_SIZE); - close(busnumFd); + fdsan_close_with_tag(busnumFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); if (readBytes < 0) { return false; } @@ -640,7 +641,7 @@ bool CheckTtyDeviceInfo(std::string ttyUsbPath, libusb_device* device) } char devnumBuff[BUFFER_SIZE] = {'\0'}; readBytes = read(devnumFd, devnumBuff, BUFFER_SIZE); - close(devnumFd); + fdsan_close_with_tag(devnumFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); if (readBytes < 0) { return false; } diff --git a/usb/serial/src/linux_serial.cpp b/usb/serial/src/linux_serial.cpp index 14b81af349..f598f51c78 100644 --- a/usb/serial/src/linux_serial.cpp +++ b/usb/serial/src/linux_serial.cpp @@ -222,9 +222,10 @@ int32_t LinuxSerial::SerialOpen(int32_t portId) HDF_LOGE("%{public}s: Unable to open serial port.", __func__); return HDF_FAILURE; } + fdsan_exchange_owner_tag(serialPortList_[index].fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); if (tcgetattr(serialPortList_[index].fd, &options_) = -1) { - close(serialPortList_[index].fd); + fdsan_close_with_tag(serialPortList_[index].fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); HDF_LOGE("%{public}s: get attribute failed %{public}d.", __func__, errno); serialPortList_.erase(index); return HDF_FAILURE; @@ -232,7 +233,7 @@ int32_t LinuxSerial::SerialOpen(int32_t portId) options_.c_lflag &= ~ICANON; options_.c_lflag &= ~ECHO; if (tcsetattr(serialPortList_[index].fd, TCSANOW, &options_) = -1) { - close(serialPortList_[index].fd); + fdsan_close_with_tag(serialPortList_[index].fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); HDF_LOGE("%{public}s: set attribute failed %{public}d.", __func__, errno); serialPortList_.erase(index); return HDF_FAILURE; @@ -259,7 +260,7 @@ int32_t LinuxSerial::SerialClose(int32_t portId) HDF_LOGE("%{public}s: fd not exist.", __func__); return HDF_FAILURE; } - close(serialPortList_[index].fd); + fdsan_close_with_tag(serialPortList_[index].fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); serialPortList_[index].fd = -1; return HDF_SUCCESS; } -- Gitee From f5aae58aa2e2f1b55ccf499a644d00219e8aab41 Mon Sep 17 00:00:00 2001 From: wujie Date: Mon, 24 Mar 2025 19:47:56 +0800 Subject: [PATCH 065/103] Signed-off-by: wujie revert GetNfcStatus function, sync dev code --- nfc/vendor_adaptor/nfc_vendor_adaptions.cpp | 33 +-------------------- nfc/vendor_adaptor/nfc_vendor_adaptions.h | 6 +--- 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/nfc/vendor_adaptor/nfc_vendor_adaptions.cpp b/nfc/vendor_adaptor/nfc_vendor_adaptions.cpp index 0523548549..32fa3c186c 100644 --- a/nfc/vendor_adaptor/nfc_vendor_adaptions.cpp +++ b/nfc/vendor_adaptor/nfc_vendor_adaptions.cpp @@ -41,30 +41,6 @@ static string GetNfcHalSoName(const std::string &chipType) return nfcHalSoName; } -int NfcVendorAdaptions::GetNfcStatus(void) -{ - int nfcStatus = NFC_STATUS_OPEN; - nfcExtHandle = dlopen(VENDOR_NFC_EXT_SERVICE_LIB.c_str(), RTLD_LAZY | RTLD_GLOBAL); - if (nfcExtHandle == nullptr) { - HDF_LOGE("%{public}s: fail to get nfc ext service handle.", __func__); - return NFC_STATUS_CLOSE; - } - nfcExtInf.getNfcStatus = reinterpret_cast - (dlsym(nfcExtHandle, EXT_GET_NFC_STATUS_FUNC_NAME.c_str())); - - if (nfcExtInf.getNfcStatus == nullptr) { - HDF_LOGE("%{public}s: fail to init func ptr.", __func__); - dlclose(nfcExtHandle); - nfcExtHandle = nullptr; - return NFC_STATUS_CLOSE; - } - nfcStatus = nfcExtInf.getNfcStatus(); - dlclose(nfcExtHandle); - nfcExtHandle = nullptr; - HDF_LOGE("%{public}s: status %{public}d.", __func__, nfcStatus); - return nfcStatus; -} - string NfcVendorAdaptions::GetChipType(void) { string nfcChipType = ""; @@ -80,13 +56,9 @@ string NfcVendorAdaptions::GetChipType(void) if (nfcExtInf.getNfcChipType == nullptr || nfcExtInf.getNfcHalFuncNameSuffix == nullptr) { HDF_LOGE("%{public}s: fail to init func ptr.", __func__); - dlclose(nfcExtHandle); - nfcExtHandle = nullptr; return nfcChipType; } nfcChipType = string(nfcExtInf.getNfcChipType()); - dlclose(nfcExtHandle); - nfcExtHandle = nullptr; return nfcChipType; } @@ -137,7 +109,6 @@ void NfcVendorAdaptions::ResetNfcInterface(void) nfcHalInf.nfcHalMinClose = nullptr; nfcExtHandle = nullptr; nfcExtInf.getNfcChipType = nullptr; - nfcExtInf.getNfcStatus = nullptr; nfcExtInf.getNfcHalFuncNameSuffix = nullptr; } @@ -173,11 +144,9 @@ void* NfcVendorAdaptions::DoHalPreOpen(void* arg) void NfcVendorAdaptions::HalPreOpen(void) { int ret = HDF_SUCCESS; - int nfcStatus = NFC_STATUS_OPEN; pthread_t pthread; HDF_LOGI("%{public}s: enter.", __func__); - nfcStatus = GetNfcStatus(); - if (!isNfcPreDone && (nfcStatus != NFC_STATUS_OPEN)) { + if (!isNfcPreDone) { ret = pthread_create(&pthread, nullptr, NfcVendorAdaptions::DoHalPreOpen, this); if (ret != HDF_SUCCESS) { HDF_LOGE("%{public}s: pthread_create is fail", __func__); diff --git a/nfc/vendor_adaptor/nfc_vendor_adaptions.h b/nfc/vendor_adaptor/nfc_vendor_adaptions.h index eeb31e5b0b..df1c6a1571 100644 --- a/nfc/vendor_adaptor/nfc_vendor_adaptions.h +++ b/nfc/vendor_adaptor/nfc_vendor_adaptions.h @@ -29,7 +29,6 @@ const std::string VENDOR_NFC_EXT_SERVICE_LIB = "libvendor_ext_nfc_service.z.so"; const std::string EXT_GET_CHIP_TYPE_FUNC_NAME = "GetChipType"; const std::string EXT_GET_SUFFIX_FUNC_NAME = "GetNfcHalFuncNameSuffix"; const std::string EXT_SET_FW_UPDATE_CONFIG_FUNC_NAME = "CheckFirmwareUpdate"; -const std::string EXT_GET_NFC_STATUS_FUNC_NAME = "GetNfcStatus"; const std::string HAL_OPEN_FUNC_NAME = "phNxpNciHal_open"; const std::string HAL_WRITE_FUNC_NAME = "phNxpNciHal_write"; @@ -61,8 +60,7 @@ const unsigned int VENDOR_IOCTL_OUTPUT_DATA_START_INDEX = 288; const unsigned int VENDOR_IOCTL_OUTPUT_DATA_LEN = 4128; const unsigned int VENDOR_IOCTL_TOTAL_LENGTH = VENDOR_IOCTL_INPUT_DATA_LEN + VENDOR_IOCTL_OUTPUT_DATA_LEN; const long VENDOR_GET_HISTORY_NCI_CMD = 112; -const int NFC_STATUS_OPEN = 0; -const int NFC_STATUS_CLOSE = 1; + struct NfcHalInterface { int (*nfcHalOpen)(NfcStackCallbackT *pCback, NfcStackDataCallbackT *pDataCback); int (*nfcHalWrite)(uint16_t dataLen, const uint8_t *pData); @@ -83,7 +81,6 @@ struct NfcExtInterface { const char* (*getNfcChipType)(void); const char* (*getNfcHalFuncNameSuffix)(const char* chipType); void (*checkFirmwareUpdate)(void); - int (*getNfcStatus)(void); }; class NfcVendorAdaptions : public INfcVendor { @@ -113,7 +110,6 @@ private: int8_t PreInitNfcHalInterfaces(std::string nfcHalSoName, std::string suffix); int8_t InitNfcHalInterfaces(std::string nfcHalSoName, std::string suffix); void CheckFirmwareUpdate(void); - int GetNfcStatus(void); int VendorGetHistoryNci(void *pData, uint16_t dataLen, std::vector &pRetVal); void *nfcHalHandle; // handle of nfc hal so -- Gitee From 1d9f0a254e38f968a68e8ea642b3c2e0d374524b Mon Sep 17 00:00:00 2001 From: kaiju Date: Mon, 24 Mar 2025 20:08:24 +0800 Subject: [PATCH 066/103] fix:module_out_path Signed-off-by: kaiju Change-Id: I6a79229e761837ddee47d967081939c88cda1d4b --- user_auth/test/unittest/attribute_test/BUILD.gn | 2 +- user_auth/test/unittest/base_test/BUILD.gn | 2 +- user_auth/test/unittest/co_auth/BUILD.gn | 2 +- user_auth/test/unittest/database/BUILD.gn | 2 +- user_auth/test/unittest/idm_test/BUILD.gn | 2 +- user_auth/test/unittest/service_test/BUILD.gn | 2 +- user_auth/test/unittest/user_auth_test/BUILD.gn | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/user_auth/test/unittest/attribute_test/BUILD.gn b/user_auth/test/unittest/attribute_test/BUILD.gn index 5f9a47dc76..6e836587fe 100644 --- a/user_auth/test/unittest/attribute_test/BUILD.gn +++ b/user_auth/test/unittest/attribute_test/BUILD.gn @@ -25,7 +25,7 @@ ohos_unittest("UserAuthAttributeTest") { blocklist = "../../../cfi_blocklist.txt" } branch_protector_ret = "pac_ret" - module_out_path = "useriam/user_auth_hdi" + module_out_path = "drivers_peripheral_user_auth/drivers_peripheral_user_auth" include_dirs = [ "../../../hdi_service/adaptor/inc", diff --git a/user_auth/test/unittest/base_test/BUILD.gn b/user_auth/test/unittest/base_test/BUILD.gn index 25a8f6ae6c..adf72987dc 100644 --- a/user_auth/test/unittest/base_test/BUILD.gn +++ b/user_auth/test/unittest/base_test/BUILD.gn @@ -24,7 +24,7 @@ ohos_unittest("UserAuthBaseTest") { debug = false } branch_protector_ret = "pac_ret" - module_out_path = "useriam/user_auth_hdi" + module_out_path = "drivers_peripheral_user_auth/drivers_peripheral_user_auth" cflags = [ "-DIAM_TEST_ENABLE" ] diff --git a/user_auth/test/unittest/co_auth/BUILD.gn b/user_auth/test/unittest/co_auth/BUILD.gn index b2b00edbc6..118df10588 100644 --- a/user_auth/test/unittest/co_auth/BUILD.gn +++ b/user_auth/test/unittest/co_auth/BUILD.gn @@ -24,7 +24,7 @@ ohos_unittest("UserAuthCoAuthTest") { debug = false } branch_protector_ret = "pac_ret" - module_out_path = "useriam/user_auth_hdi" + module_out_path = "drivers_peripheral_user_auth/drivers_peripheral_user_auth" cflags = [ "-DIAM_TEST_ENABLE" ] diff --git a/user_auth/test/unittest/database/BUILD.gn b/user_auth/test/unittest/database/BUILD.gn index e9276fe70d..1303c2c701 100644 --- a/user_auth/test/unittest/database/BUILD.gn +++ b/user_auth/test/unittest/database/BUILD.gn @@ -24,7 +24,7 @@ ohos_unittest("UserAuthDatabaseTest") { debug = false } branch_protector_ret = "pac_ret" - module_out_path = "useriam/user_auth_hdi" + module_out_path = "drivers_peripheral_user_auth/drivers_peripheral_user_auth" cflags = [ "-DIAM_TEST_ENABLE" ] diff --git a/user_auth/test/unittest/idm_test/BUILD.gn b/user_auth/test/unittest/idm_test/BUILD.gn index 5697743b40..5ab901502c 100644 --- a/user_auth/test/unittest/idm_test/BUILD.gn +++ b/user_auth/test/unittest/idm_test/BUILD.gn @@ -25,7 +25,7 @@ ohos_unittest("UserAuthIdmTest") { blocklist = "../../../cfi_blocklist.txt" } branch_protector_ret = "pac_ret" - module_out_path = "useriam/user_auth_hdi" + module_out_path = "drivers_peripheral_user_auth/drivers_peripheral_user_auth" cflags = [ "-DIAM_TEST_ENABLE" ] diff --git a/user_auth/test/unittest/service_test/BUILD.gn b/user_auth/test/unittest/service_test/BUILD.gn index 02e29aecca..2732887a2b 100644 --- a/user_auth/test/unittest/service_test/BUILD.gn +++ b/user_auth/test/unittest/service_test/BUILD.gn @@ -24,7 +24,7 @@ ohos_unittest("UserAuthHdiTest") { debug = false } branch_protector_ret = "pac_ret" - module_out_path = "useriam/user_auth_hdi" + module_out_path = "drivers_peripheral_user_auth/drivers_peripheral_user_auth" include_dirs = [ "inc", diff --git a/user_auth/test/unittest/user_auth_test/BUILD.gn b/user_auth/test/unittest/user_auth_test/BUILD.gn index 41df9a9bf2..92fab93f3a 100644 --- a/user_auth/test/unittest/user_auth_test/BUILD.gn +++ b/user_auth/test/unittest/user_auth_test/BUILD.gn @@ -25,7 +25,7 @@ ohos_unittest("UserAuthUserAuthTest") { blocklist = "../../../cfi_blocklist.txt" } branch_protector_ret = "pac_ret" - module_out_path = "useriam/user_auth_hdi" + module_out_path = "drivers_peripheral_user_auth/drivers_peripheral_user_auth" cflags = [ "-DIAM_TEST_ENABLE" ] -- Gitee From b0a4688c194cfe5bd2392c8a14252b4634d9d56d Mon Sep 17 00:00:00 2001 From: huangshengqing Date: Mon, 24 Mar 2025 20:32:30 +0800 Subject: [PATCH 067/103] add verify Signed-off-by: huangshengqing --- usb/libusb_adapter/include/libusb_adapter.h | 4 ++- usb/libusb_adapter/src/libusb_adapter.cpp | 30 +++++++++++---------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/usb/libusb_adapter/include/libusb_adapter.h b/usb/libusb_adapter/include/libusb_adapter.h index b8975e68c1..f579f3f127 100644 --- a/usb/libusb_adapter/include/libusb_adapter.h +++ b/usb/libusb_adapter/include/libusb_adapter.h @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -122,6 +123,7 @@ public: LibusbAdapter(); ~LibusbAdapter(); int32_t OpenDevice(const UsbDev &dev); + static void CloseOpenedFd(const UsbDev &dev); int32_t CloseDevice(const UsbDev &dev); int32_t ResetDevice(const UsbDev &dev); int32_t GetDeviceDescriptor(const UsbDev &dev, std::vector &descriptor); @@ -258,7 +260,7 @@ private: static std::list> subscribers_; static sptr libUsbSaSubscriber_; std::mutex openFdsMutex_; - std::map, int32_t> openedFds_; + std::map, int32_t> openedFds_; }; } // namespace V1_2 } // namespace Usb diff --git a/usb/libusb_adapter/src/libusb_adapter.cpp b/usb/libusb_adapter/src/libusb_adapter.cpp index e5050bc2d8..c40f98e152 100644 --- a/usb/libusb_adapter/src/libusb_adapter.cpp +++ b/usb/libusb_adapter/src/libusb_adapter.cpp @@ -278,6 +278,21 @@ int32_t LibusbAdapter::OpenDevice(const UsbDev &dev) return HDF_SUCCESS; } +void LibusbAdapter::CloseOpenedFd(const UsbDev &dev) +{ + std::lock_guard lock(openedFdsMutex_); + auto iter = openedFds_.find({dev.busNum, dev.devAddr}); + if (iter != openedFds_.end()) { + int32_t fd = iter->second; + int res = close(fd); + openedFds_.erase(iter); + HDF_LOGI("%{public}s:%{public}d close %{public}d ret = %{public}d", + __func__, __LINE__, iter->second, res); + } else { + HDF_LOGI("%{public}s:%{public}d not opened", __func__, __LINE__); + } +} + int32_t LibusbAdapter::CloseDevice(const UsbDev &dev) { HDF_LOGI("%{public}s enter", __func__); @@ -298,20 +313,7 @@ int32_t LibusbAdapter::CloseDevice(const UsbDev &dev) info->second.count--; HDF_LOGI("%{public}s Number of devices that are opened=%{public}d", __func__, info->second.count); if (info->second.count == 0 && (info->second.handle != nullptr)) { - { - std::lock_guard lock(openedFdsMutex_); - auto iter = openedFds_.find({dev.busNum, dev.devAddr}); - if (iter != openedFds_.end()) { - int32_t fd = iter->second; - if (fd != ) - int res = close(fd); - openedFds_.erase(iter); - HDF_LOGI("%{public}s:%{public}d close %{public}d ret = %{public}d", - __func__, __LINE__, iter->second, res); - } else { - HDF_LOGI("%{public}s:%{public}d not opened", __func__, __LINE__); - } - } + CloseOpenedFd(dev); { std::unique_lock lock(g_mapMutexUsbOpenFdMap); auto it = g_usbOpenFdMap.find(result); -- Gitee From bad65007a081400fbea4999c6fc8c9a122ac0ac4 Mon Sep 17 00:00:00 2001 From: huangshengqing Date: Mon, 24 Mar 2025 21:04:04 +0800 Subject: [PATCH 068/103] add change Signed-off-by: huangshengqing --- usb/libusb_adapter/include/libusb_adapter.h | 4 ++-- usb/libusb_adapter/src/libusb_adapter.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/usb/libusb_adapter/include/libusb_adapter.h b/usb/libusb_adapter/include/libusb_adapter.h index f579f3f127..34c278d179 100644 --- a/usb/libusb_adapter/include/libusb_adapter.h +++ b/usb/libusb_adapter/include/libusb_adapter.h @@ -123,7 +123,7 @@ public: LibusbAdapter(); ~LibusbAdapter(); int32_t OpenDevice(const UsbDev &dev); - static void CloseOpenedFd(const UsbDev &dev); + void CloseOpenedFd(const UsbDev &dev); int32_t CloseDevice(const UsbDev &dev); int32_t ResetDevice(const UsbDev &dev); int32_t GetDeviceDescriptor(const UsbDev &dev, std::vector &descriptor); @@ -259,7 +259,7 @@ private: libusb_hotplug_callback_handle hotplug_handle_; static std::list> subscribers_; static sptr libUsbSaSubscriber_; - std::mutex openFdsMutex_; + std::mutex openedFdsMutex_; std::map, int32_t> openedFds_; }; } // namespace V1_2 diff --git a/usb/libusb_adapter/src/libusb_adapter.cpp b/usb/libusb_adapter/src/libusb_adapter.cpp index c40f98e152..ddd0776ad0 100644 --- a/usb/libusb_adapter/src/libusb_adapter.cpp +++ b/usb/libusb_adapter/src/libusb_adapter.cpp @@ -422,7 +422,7 @@ int32_t LibusbAdapter::GetDeviceFileDescriptor(const UsbDev &dev, int32_t &fd) HDF_LOGE("%{public}s: sprintf_s path failed, ret:%{public}d", __func__, ret); return ret; } - int32_t fd = open(path, O_RDWR); + fd = open(path, O_RDWR); if (fd < 0) { HDF_LOGE("%{public}s: open device failed errno = %{public}d %{public}s", __func__, errno, strerror(errno)); return HDF_FAILURE; @@ -431,7 +431,7 @@ int32_t LibusbAdapter::GetDeviceFileDescriptor(const UsbDev &dev, int32_t &fd) auto iter = openedFds_.find({dev.busNum, dev.devAddr}); if (iter != openedFds_.end()) { int32_t oldFd = iter->second; - if (oldfd != fd) { + if (oldFd != fd) { int res = close(oldFd); HDF_LOGI("%{public}s:%{public}d close old %{public}d ret = %{public}d", __func__, __LINE__, iter->second, res); -- Gitee From f9ef3740dcb4b8aa0899125e2b8a9485fa792263 Mon Sep 17 00:00:00 2001 From: luzhiye Date: Mon, 24 Mar 2025 20:47:22 +0800 Subject: [PATCH 069/103] =?UTF-8?q?drivers=5Fperipheral=5Fusb=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E5=8C=96=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: luzhiye --- usb/bundle.json | 2 +- usb/usb.gni | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/usb/bundle.json b/usb/bundle.json index 78505bea6c..0e60cbfd8c 100644 --- a/usb/bundle.json +++ b/usb/bundle.json @@ -15,7 +15,7 @@ "features": [ "drivers_peripheral_usb_feature_linux_native_model", "drivers_peripheral_usb_feature_emulator_mode", - "drivers_peripheral_usb_feature_hiviewdfx_hisysevent" , + "drivers_peripheral_usb_feature_hiviewdfx_hisysevent", "drivers_peripheral_usb_feature_systemabilitymgr_samgr", "drivers_peripheral_usb_feature_commonlibrary_c_utils" ], diff --git a/usb/usb.gni b/usb/usb.gni index b56572f1ff..c4d0eaec5c 100644 --- a/usb/usb.gni +++ b/usb/usb.gni @@ -23,19 +23,19 @@ declare_args() { } declare_args() { - usb_hisysevent_enable = false + usb_hisysevent_enable = true if (!drivers_peripheral_usb_feature_hiviewdfx_hisysevent) { - usb_hisysevent_enable = true + usb_hisysevent_enable = false } - usb_samgr_enable = false + usb_samgr_enable = true if (!drivers_peripheral_usb_feature_systemabilitymgr_samgr) { - usb_samgr_enable = true + usb_samgr_enable = false } - usb_c_utils_enable = false + usb_c_utils_enable = true if (!drivers_peripheral_usb_feature_commonlibrary_c_utils) { - usb_c_utils_enable = true + usb_c_utils_enable = false } libusb_enable = true -- Gitee From 3a664feff5a9c55bac76a19088aa3856cdfdf7fa Mon Sep 17 00:00:00 2001 From: wujie Date: Mon, 24 Mar 2025 22:02:18 +0800 Subject: [PATCH 070/103] Signed-off-by: wujie add updateNfcOpenStatus and CheckNfcBootloaderStatus function Signed-off-by: wujie --- nfc/bundle.json | 3 +- nfc/vendor_adaptor/BUILD.gn | 1 + nfc/vendor_adaptor/nfc_vendor_adaptions.cpp | 107 ++++++++++++++++++-- nfc/vendor_adaptor/nfc_vendor_adaptions.h | 10 ++ 4 files changed, 110 insertions(+), 11 deletions(-) diff --git a/nfc/bundle.json b/nfc/bundle.json index 381bf0f7b6..6a1e986f38 100644 --- a/nfc/bundle.json +++ b/nfc/bundle.json @@ -19,7 +19,8 @@ "hdf_core", "hilog", "c_utils", - "drivers_interface_nfc" + "drivers_interface_nfc", + "hisysevent" ], "third_party": [] }, diff --git a/nfc/vendor_adaptor/BUILD.gn b/nfc/vendor_adaptor/BUILD.gn index 951912879e..c4d85efa06 100644 --- a/nfc/vendor_adaptor/BUILD.gn +++ b/nfc/vendor_adaptor/BUILD.gn @@ -23,6 +23,7 @@ ohos_shared_library("nfc_vendor_adaptor") { "drivers_interface_nfc:nfc_idl_headers", "hdf_core:libhdf_utils", "hilog:libhilog", + "hisysevent:libhisysevent", "ipc:ipc_single", ] diff --git a/nfc/vendor_adaptor/nfc_vendor_adaptions.cpp b/nfc/vendor_adaptor/nfc_vendor_adaptions.cpp index 32fa3c186c..e89dbce860 100644 --- a/nfc/vendor_adaptor/nfc_vendor_adaptions.cpp +++ b/nfc/vendor_adaptor/nfc_vendor_adaptions.cpp @@ -22,6 +22,7 @@ #include #include #include "securec.h" +#include "hisysevent.h" #define HDF_LOG_TAG hdf_nfc_dal @@ -30,11 +31,36 @@ #endif #define LOG_DOMAIN 0xD000306 -std::mutex g_openMutex; + using namespace std; namespace OHOS { namespace HDI { namespace Nfc { +std::mutex g_openMutex; +enum BootloaderRecoverStatus : uint16_t { + BOOTLOADER_STATUS_RECOVER_SUCCESS = 1, + BOOTLOADER_STATUS_RECOVER_FAILED, +}; +template +static void WriteEvent(const std::string& eventType, OHOS::HiviewDFX::HiSysEvent::EventType type, Types... args) +{ + int ret = HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::SECURE_ELEMENT, eventType, type, args...); + if (ret != 0) { + HDF_LOGE("Write event fail: %{public}s", eventType.c_str()); + } else { + HDF_LOGI("%{public}s success!", __func__); + } +} + +static void WriteBootloaderHiSysEvent(uint16_t errorCode) +{ + const uint8_t bootloaderStatusType = 200; /* 100 ~ 199 for CA to TA hisysevent */ + WriteEvent("ACCESS_SE_FAILED", OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + "CHANNEL_TYPE", bootloaderStatusType, + "ERROR_CODE", errorCode); + HDF_LOGI("%{public}s value:%{public}d", __func__, errorCode); +} + static string GetNfcHalSoName(const std::string &chipType) { string nfcHalSoName = NFC_HAL_SO_PREFIX + chipType + NFC_HAL_SO_SUFFIX; @@ -82,6 +108,58 @@ void NfcVendorAdaptions::CheckFirmwareUpdate(void) nfcExtHandle = nullptr; } +void NfcVendorAdaptions::UpdateNfcOpenStatus(const std::string &status) +{ + nfcExtHandle = dlopen(VENDOR_NFC_EXT_SERVICE_LIB.c_str(), RTLD_LAZY | RTLD_GLOBAL); + if (nfcExtHandle == nullptr) { + HDF_LOGE("%{public}s: fail to get nfc ext service handle.", __func__); + return; + } + nfcExtInf.updateNfcOpenStatus = reinterpret_cast + (dlsym(nfcExtHandle, EXT_UPDATE_NFC_OPEN_STATUS.c_str())); + if (nfcExtInf.updateNfcOpenStatus == nullptr) { + HDF_LOGE("%{public}s: fail to init func ptr.", __func__); + dlclose(nfcExtHandle); + nfcExtHandle = nullptr; + return; + } + nfcExtInf.updateNfcOpenStatus(status.c_str(), status.length()); + HDF_LOGI("%{public}s: status [%{public}s].", __func__, status.c_str()); + dlclose(nfcExtHandle); + nfcExtHandle = nullptr; +} + +/* +** true : NFC in bootloader status +** false : NFC in normal status +*/ +bool NfcVendorAdaptions::CheckNfcBootloaderStatus(void) +{ + nfcExtHandle = dlopen(VENDOR_NFC_EXT_SERVICE_LIB.c_str(), RTLD_LAZY | RTLD_GLOBAL); + if (nfcExtHandle == nullptr) { + HDF_LOGE("%{public}s: fail to get nfc ext service handle.", __func__); + return false; + } + nfcExtInf.checkNfcBootloaderStatus = reinterpret_cast + (dlsym(nfcExtHandle, EXT_CHECK_NFC_BOOTLOADER_STATUS.c_str())); + if (nfcExtInf.checkNfcBootloaderStatus == nullptr) { + HDF_LOGE("%{public}s: fail to init func ptr.", __func__); + dlclose(nfcExtHandle); + nfcExtHandle = nullptr; + return false; + } + if (nfcExtInf.checkNfcBootloaderStatus() == 0) { + dlclose(nfcExtHandle); + nfcExtHandle = nullptr; + HDF_LOGE("%{public}s: NFC in bootloader status", __func__); + return true; + } + dlclose(nfcExtHandle); + nfcExtHandle = nullptr; + HDF_LOGI("%{public}s: NFC in normal status", __func__); + return false; +} + string NfcVendorAdaptions::GetNfcHalFuncNameSuffix(const std::string &chipType) { string suffix = DEFAULT_FUNC_NAME_SUFFIX; @@ -127,15 +205,24 @@ void* NfcVendorAdaptions::DoHalPreOpen(void* arg) return nullptr; } std::lock_guard lock(g_openMutex); - status = mVendorAdapter->nfcHalInf.nfcHalMinOpen(true); - if (status != HDF_SUCCESS) { - HDF_LOGE("%{public}s: nfcHalMinOpen is fail", __func__); - return nullptr; - } - status = mVendorAdapter->nfcHalInf.nfcHalMinClose(); - if (status != HDF_SUCCESS) { - HDF_LOGE("%{public}s: nfcHalMinClose is fail", __func__); - return nullptr; + if (mVendorAdapter->CheckNfcBootloaderStatus()) { + mVendorAdapter->UpdateNfcOpenStatus(NFC_OPENING_STATUS); + status = mVendorAdapter->nfcHalInf.nfcHalMinOpen(true); + if (status != HDF_SUCCESS) { + HDF_LOGE("%{public}s: nfcHalMinOpen is fail", __func__); + mVendorAdapter->UpdateNfcOpenStatus(NFC_CLOSE_STATUS); + WriteBootloaderHiSysEvent(BOOTLOADER_STATUS_RECOVER_FAILED); + return nullptr; + } + status = mVendorAdapter->nfcHalInf.nfcHalMinClose(); + if (status != HDF_SUCCESS) { + HDF_LOGE("%{public}s: nfcHalMinClose is fail", __func__); + mVendorAdapter->UpdateNfcOpenStatus(NFC_OPEN_STATUS); + WriteBootloaderHiSysEvent(BOOTLOADER_STATUS_RECOVER_FAILED); + return nullptr; + } + mVendorAdapter->UpdateNfcOpenStatus(NFC_CLOSE_STATUS); + WriteBootloaderHiSysEvent(BOOTLOADER_STATUS_RECOVER_SUCCESS); } HDF_LOGI("%{public}s: exit.", __func__); return nullptr; diff --git a/nfc/vendor_adaptor/nfc_vendor_adaptions.h b/nfc/vendor_adaptor/nfc_vendor_adaptions.h index df1c6a1571..296f50fecb 100644 --- a/nfc/vendor_adaptor/nfc_vendor_adaptions.h +++ b/nfc/vendor_adaptor/nfc_vendor_adaptions.h @@ -29,6 +29,8 @@ const std::string VENDOR_NFC_EXT_SERVICE_LIB = "libvendor_ext_nfc_service.z.so"; const std::string EXT_GET_CHIP_TYPE_FUNC_NAME = "GetChipType"; const std::string EXT_GET_SUFFIX_FUNC_NAME = "GetNfcHalFuncNameSuffix"; const std::string EXT_SET_FW_UPDATE_CONFIG_FUNC_NAME = "CheckFirmwareUpdate"; +const std::string EXT_UPDATE_NFC_OPEN_STATUS = "UpdateNfcOpenStatus"; +const std::string EXT_CHECK_NFC_BOOTLOADER_STATUS = "CheckNfcBootloaderStatus"; const std::string HAL_OPEN_FUNC_NAME = "phNxpNciHal_open"; const std::string HAL_WRITE_FUNC_NAME = "phNxpNciHal_write"; @@ -47,6 +49,10 @@ const std::string DEFAULT_FUNC_NAME_SUFFIX = ""; const std::string NFC_HAL_SO_PREFIX = "libnfc_hal_impl_"; const std::string NFC_HAL_SO_SUFFIX = ".z.so"; +// 0:open 1:close 2:opening +const std::string NFC_OPEN_STATUS = "0"; +const std::string NFC_CLOSE_STATUS = "1"; +const std::string NFC_OPENING_STATUS = "2"; const unsigned int VENDOR_IOCTL_TOTAL_LEN = 256; const unsigned int VENDOR_IOCTL_INOUT_DATA_LEN = 128; const unsigned int VENDOR_IOCTL_OUTPUT_LEN_INDEX = 128; @@ -81,6 +87,8 @@ struct NfcExtInterface { const char* (*getNfcChipType)(void); const char* (*getNfcHalFuncNameSuffix)(const char* chipType); void (*checkFirmwareUpdate)(void); + void (*updateNfcOpenStatus)(const char* nfcStatus, int len); + int (*checkNfcBootloaderStatus)(void); }; class NfcVendorAdaptions : public INfcVendor { @@ -111,6 +119,8 @@ private: int8_t InitNfcHalInterfaces(std::string nfcHalSoName, std::string suffix); void CheckFirmwareUpdate(void); int VendorGetHistoryNci(void *pData, uint16_t dataLen, std::vector &pRetVal); + void UpdateNfcOpenStatus(const std::string &status); + bool CheckNfcBootloaderStatus(void); void *nfcHalHandle; // handle of nfc hal so NfcHalInterface nfcHalInf; -- Gitee From 03acc841e7385f463030e395ff4fbc3e99a83e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Wed, 26 Mar 2025 14:49:29 +0800 Subject: [PATCH 071/103] change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- usb/ddk/host/src/ddk_device_manager.c | 6 ++---- usb/ddk/host/src/ddk_sysfs_device.c | 3 +-- usb/ddk/host/src/ddk_uevent_handle.c | 8 ++++---- usb/ddk/host/src/linux_adapter.c | 11 +++-------- usb/ddk_service/scsi_service/src/scsi_ddk_service.cpp | 6 ++---- .../serial_service/src/usb_serial_ddk_service.cpp | 4 +--- usb/ddk_service/usb_service/src/usb_ddk_service.cpp | 8 ++++---- 7 files changed, 17 insertions(+), 29 deletions(-) diff --git a/usb/ddk/host/src/ddk_device_manager.c b/usb/ddk/host/src/ddk_device_manager.c index 9a033415b4..0c2396af84 100644 --- a/usb/ddk/host/src/ddk_device_manager.c +++ b/usb/ddk/host/src/ddk_device_manager.c @@ -272,11 +272,10 @@ int32_t DdkDevMgrGetGadgetLinkStatusSafe(DdkDevMgrHandleGadget handle, void *pri HDF_LOGE("%{public}s: open %{public}s failed errno:%{public}d", __func__, g_gadgetStatePath, errno); return HDF_ERR_IO; } - fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); char buf[STATE_STRING_LENGTH] = {0}; ssize_t numRead = read(fd, buf, STATE_STRING_LENGTH); - fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + close(fd); if (numRead <= 0) { HDF_LOGE("%{public}s: read state failed errno:%{public}d", __func__, errno); return HDF_ERR_IO; @@ -310,11 +309,10 @@ bool DdkDevMgrGetGadgetLinkStatus() HDF_LOGE("%{public}s: open %{public}s failed errno:%{public}d", __func__, g_gadgetStatePath, errno); return false; } - fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); char buf[STATE_STRING_LENGTH] = {0}; ssize_t numRead = read(fd, buf, STATE_STRING_LENGTH); - fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + close(fd); if (numRead <= 0) { HDF_LOGE("%{public}s: read state failed errno:%{public}d", __func__, errno); return false; diff --git a/usb/ddk/host/src/ddk_sysfs_device.c b/usb/ddk/host/src/ddk_sysfs_device.c index 7d2e2e7404..12ad8ec1eb 100644 --- a/usb/ddk/host/src/ddk_sysfs_device.c +++ b/usb/ddk/host/src/ddk_sysfs_device.c @@ -69,7 +69,6 @@ static int32_t DdkSysfsReadProperty(const char *deviceDir, const char *propName, HDF_LOGE("%{public}s: open file failed path:%{public}s, errno:%{public}d", __func__, path, errno); return HDF_ERR_IO; } - fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); int32_t ret = HDF_SUCCESS; do { @@ -99,7 +98,7 @@ static int32_t DdkSysfsReadProperty(const char *deviceDir, const char *propName, *value = res; } while (0); - fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + close(fd); return ret; } diff --git a/usb/ddk/host/src/ddk_uevent_handle.c b/usb/ddk/host/src/ddk_uevent_handle.c index d97b5bb04b..3cf1aaacba 100644 --- a/usb/ddk/host/src/ddk_uevent_handle.c +++ b/usb/ddk/host/src/ddk_uevent_handle.c @@ -64,20 +64,20 @@ static int DdkUeventOpen(int *fd) int buffSize = UEVENT_SOCKET_BUFF_SIZE; if (setsockopt(socketfd, SOL_SOCKET, SO_RCVBUF, &buffSize, sizeof(buffSize)) != 0) { HDF_LOGE("%{public}s: setsockopt failed!", __func__); - fdsan_close_with_tag(socketfd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + close(socketfd); return HDF_FAILURE; } const int32_t on = 1; // turn on passcred if (setsockopt(socketfd, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)) != 0) { HDF_LOGE("setsockopt failed!"); - fdsan_close_with_tag(socketfd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + close(socketfd); return HDF_FAILURE; } if (bind(socketfd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { HDF_LOGE("%{public}s: bind socketfd failed!", __func__); - fdsan_close_with_tag(socketfd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + close(socketfd); return HDF_FAILURE; } *fd = socketfd; @@ -197,7 +197,7 @@ void *DdkUeventMain(void *param) } } while (true); - fdsan_close_with_tag(socketfd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + close(socketfd); return NULL; } diff --git a/usb/ddk/host/src/linux_adapter.c b/usb/ddk/host/src/linux_adapter.c index 51745816c1..194dbe4dbd 100644 --- a/usb/ddk/host/src/linux_adapter.c +++ b/usb/ddk/host/src/linux_adapter.c @@ -136,7 +136,6 @@ static int32_t GetMmapFd(struct UsbDevice *dev) HDF_LOGE("%{public}s: open error:%{public}s", __func__, path); return HDF_FAILURE; } - fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); dev->devHandle->mmapFd = fd; return HDF_SUCCESS; } @@ -189,7 +188,6 @@ static int32_t OsGetUsbFd(struct UsbDevice *dev, mode_t mode) int32_t fd = open(pathBuf, mode | O_CLOEXEC); if (fd != HDF_FAILURE) { - fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return fd; } HDF_LOGI("%{public}s: path: %{public}s, fd:%{public}d", __func__, pathBuf, fd); @@ -198,7 +196,6 @@ static int32_t OsGetUsbFd(struct UsbDevice *dev, mode_t mode) case ENOENT: fd = open(pathBuf, mode | O_CLOEXEC); if (fd != HDF_FAILURE) { - fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return fd; } ret = HDF_DEV_ERR_NO_DEVICE; @@ -231,7 +228,6 @@ static int32_t AdapterGetUsbDeviceFd(struct UsbDevice *dev, mode_t mode) int32_t fd = open(pathBuf, mode | O_CLOEXEC); if (fd != HDF_FAILURE) { HDF_LOGI("%{public}s: path: %{public}s, fd: %{public}d", __func__, pathBuf, fd); - fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return fd; } usleep(SLEEP_TIME); @@ -239,7 +235,6 @@ static int32_t AdapterGetUsbDeviceFd(struct UsbDevice *dev, mode_t mode) case ENOENT: fd = open(pathBuf, mode | O_CLOEXEC); if (fd != HDF_FAILURE) { - fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return fd; } ret = HDF_DEV_ERR_NO_DEVICE; @@ -1059,9 +1054,9 @@ static void AdapterCloseDevice(struct UsbDeviceHandle *handle) } RawUsbMemFree(dev); - fdsan_close_with_tag(handle->fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); - fdsan_close_with_tag(handle->mmapFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); - HDF_LOGI("%{public}s:close fd:%{public}d handle->mmapFd:%{public}d", __func__, handle->fd, handle->mmapFd); + close(handle->fd); + close(handle->mmapFd); + HDF_LOGI("%{public}s:close fd:%{public}d", __func__, handle->fd); OsalMutexDestroy(&handle->lock); RawUsbMemFree(handle); handle = NULL; diff --git a/usb/ddk_service/scsi_service/src/scsi_ddk_service.cpp b/usb/ddk_service/scsi_service/src/scsi_ddk_service.cpp index 6d886a13fc..130c1f4e5b 100644 --- a/usb/ddk_service/scsi_service/src/scsi_ddk_service.cpp +++ b/usb/ddk_service/scsi_service/src/scsi_ddk_service.cpp @@ -264,7 +264,6 @@ int32_t ScsiDdkService::Open(uint64_t deviceId, uint8_t interfaceIndex, ScsiPeri HDF_LOGE("%{public}s open failed, path=%{public}s, errno=%{public}d", __func__, path.c_str(), errno); return SCSIPERIPHERAL_DDK_IO_ERROR; } - fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); dev.devFd = fd; HDF_LOGD("Open success, dev.devFd=%{public}d, path.c_str()=%{public}s", dev.devFd, path.c_str()); @@ -305,7 +304,7 @@ int32_t ScsiDdkService::Close(const ScsiPeripheralDevice& dev) } int32_t ret = TrackTime([&]() { - return fdsan_close_with_tag(dev.devFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + return close(dev.devFd); }, __func__); if (ret == -1) { HDF_LOGE("%{public}s close failed", __func__); @@ -313,7 +312,7 @@ int32_t ScsiDdkService::Close(const ScsiPeripheralDevice& dev) } ret = TrackTime([&]() { - return fdsan_close_with_tag(dev.memMapFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + return close(dev.memMapFd); }, __func__); if (ret < 0) { HDF_LOGE("%{public}s: close failed, memMapFd=%{public}d, errno=%{public}d", __func__, dev.memMapFd, errno); @@ -728,7 +727,6 @@ int32_t ScsiDdkService::GetDeviceMemMapFd(uint16_t busNum, uint16_t devAddr, uin HDF_LOGE("%{public}s: open error, path=%{public}s, errno=%{public}d", __func__, path, errno); return SCSIPERIPHERAL_DDK_IO_ERROR; } - fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); memMapFd = fd; HDF_LOGD("%{public}s: memMapFd:%{public}d", __func__, memMapFd); diff --git a/usb/ddk_service/serial_service/src/usb_serial_ddk_service.cpp b/usb/ddk_service/serial_service/src/usb_serial_ddk_service.cpp index 2bed65ce8b..2eb228340e 100644 --- a/usb/ddk_service/serial_service/src/usb_serial_ddk_service.cpp +++ b/usb/ddk_service/serial_service/src/usb_serial_ddk_service.cpp @@ -116,7 +116,6 @@ int32_t UsbSerialDdkService::Open(uint64_t deviceId, uint64_t interfaceIndex, HDF_LOGE("error %{public}d opening devNodePath: %{public}s\n", errno, strerror(errno)); return USB_SERIAL_DDK_IO_ERROR; } - fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); dev.fd = static_cast(fd); return HDF_SUCCESS; } @@ -129,8 +128,7 @@ int32_t UsbSerialDdkService::Close(const OHOS::HDI::Usb::UsbSerialDdk::V1_0::Usb return USB_SERIAL_DDK_NO_PERM; } - int ret = fdsan_close_with_tag(static_cast(dev.fd), - fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + int ret = close(static_cast(dev.fd)); if (ret != 0) { HDF_LOGE("Failed to close device: %{public}s.\n", strerror(errno)); if (errno == EBADF) { diff --git a/usb/ddk_service/usb_service/src/usb_ddk_service.cpp b/usb/ddk_service/usb_service/src/usb_ddk_service.cpp index 848a3ef4d7..fa42070fe4 100644 --- a/usb/ddk_service/usb_service/src/usb_ddk_service.cpp +++ b/usb/ddk_service/usb_service/src/usb_ddk_service.cpp @@ -673,7 +673,7 @@ int32_t SubmitRequestWithAshmem(const UsbRequestPipe &pipe, const UsbAshmem &ash struct UsbRequest *request = UsbAllocRequestByAshmem(handleConvert, 0, ashmem.size, ashmem.ashmemFd); if (request == nullptr) { HDF_LOGE("%{public}s alloc request failed", __func__); - fdsan_close_with_tag(ashmem.ashmemFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + close(ashmem.ashmemFd); pthread_rwlock_unlock(&g_rwLock); return HDF_DEV_ERR_NO_MEMORY; } @@ -695,7 +695,7 @@ int32_t SubmitRequestWithAshmem(const UsbRequestPipe &pipe, const UsbAshmem &ash transferredLength = request->compInfo.actualLength; FINISHED: (void)UsbFreeRequestByMmap(request); - fdsan_close_with_tag(ashmem.ashmemFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + close(ashmem.ashmemFd); pthread_rwlock_unlock(&g_rwLock); return ret; } @@ -705,7 +705,7 @@ int32_t UsbDdkService::SendPipeRequestWithAshmem( { if (!DdkPermissionManager::VerifyPermission(PERMISSION_NAME)) { HDF_LOGE("%{public}s: no permission", __func__); - fdsan_close_with_tag(ashmem.ashmemFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + close(ashmem.ashmemFd); return HDF_ERR_NOPERM; } @@ -713,7 +713,7 @@ int32_t UsbDdkService::SendPipeRequestWithAshmem( int32_t ret = UsbDdkUnHash(pipe.interfaceHandle, handle); if (ret != HDF_SUCCESS) { HDF_LOGE("%{public}s unhash failed %{public}d", __func__, ret); - fdsan_close_with_tag(ashmem.ashmemFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + close(ashmem.ashmemFd); return ret; } #ifndef LIBUSB_ENABLE -- Gitee From c703f2ebee107e0ed42e825195a06d5c9b0589d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Wed, 26 Mar 2025 15:04:51 +0800 Subject: [PATCH 072/103] change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- usb/libusb_adapter/src/libusb_adapter.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/usb/libusb_adapter/src/libusb_adapter.cpp b/usb/libusb_adapter/src/libusb_adapter.cpp index 7653b03360..d437a75ed8 100644 --- a/usb/libusb_adapter/src/libusb_adapter.cpp +++ b/usb/libusb_adapter/src/libusb_adapter.cpp @@ -284,7 +284,7 @@ void LibusbAdapter::CloseOpenedFd(const UsbDev &dev) auto iter = openedFds_.find({dev.busNum, dev.devAddr}); if (iter != openedFds_.end()) { int32_t fd = iter->second; - int res = close(fd); + int res = fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); openedFds_.erase(iter); HDF_LOGI("%{public}s:%{public}d close %{public}d ret = %{public}d", __func__, __LINE__, iter->second, res); @@ -427,6 +427,7 @@ int32_t LibusbAdapter::GetDeviceFileDescriptor(const UsbDev &dev, int32_t &fd) HDF_LOGE("%{public}s: open device failed errno = %{public}d %{public}s", __func__, errno, strerror(errno)); return HDF_FAILURE; } + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); fd = fileFd; { std::unique_lock lock(g_mapMutexUsbOpenFdMap); @@ -1166,6 +1167,7 @@ int32_t LibusbAdapter::GetFileDescriptor(const UsbDev &dev, int32_t &fd) HDF_LOGE("%{public}s: open device failed errno = %{public}d %{public}s", __func__, errno, strerror(errno)); return HDF_FAILURE; } + fdsan_exchange_owner_tag(fileFd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); fd = fileFd; { std::unique_lock lock(g_mapMutexUsbOpenFdMap); @@ -1433,7 +1435,8 @@ int32_t LibusbAdapter::SendPipeRequestWithAshmem(const UsbDev &dev, unsigned cha } transferredLength = static_cast(actlength); CloseMmapBuffer(buffer, sendRequestAshmemParameter.ashmemSize); - close(sendRequestAshmemParameter.ashmemFd); + fdsan_close_with_tag(sendRequestAshmemParameter.ashmemFd, + fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return ret; } @@ -1470,11 +1473,12 @@ int32_t LibusbAdapter::GetRawDescriptor(const UsbDev &dev, std::vector __func__, ptrBuf, errno); return HDF_FAILURE; } + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); void *descriptors = nullptr; size_t descriptorsLength = 0; if (ReadDescriptors(fd, &descriptors, descriptorsLength) != HDF_SUCCESS) { HDF_LOGE("%{public}s: ReadDescriptors failed", __func__); - close(fd); + fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); return HDF_FAILURE; } uint8_t *ptr = static_cast(descriptors); @@ -1482,7 +1486,7 @@ int32_t LibusbAdapter::GetRawDescriptor(const UsbDev &dev, std::vector descriptor.resize(length); std::copy(ptr, ptr + length, descriptor.begin()); FreeUsbDescriptorsMemory(descriptors); - close(fd); + fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); HDF_LOGI("%{public}s leave", __func__); return HDF_SUCCESS; } @@ -1792,6 +1796,7 @@ int32_t LibusbAdapter::GetDeviceMemMapFd(const UsbDev &dev, int &fd) HDF_LOGE("%{public}s: open error: ret=%{public}d", __func__, ret); return HDF_FAILURE; } + fdsan_exchange_owner_tag(ret, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); fd = ret; { std::unique_lock lock(g_mapMutexUsbOpenFdMap); -- Gitee From 1963b11c4f4d8b37e192d24210de9fd64186c9e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Wed, 26 Mar 2025 15:10:39 +0800 Subject: [PATCH 073/103] change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- usb/libusb_adapter/src/libusb_adapter.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/usb/libusb_adapter/src/libusb_adapter.cpp b/usb/libusb_adapter/src/libusb_adapter.cpp index d437a75ed8..db1b540dd5 100644 --- a/usb/libusb_adapter/src/libusb_adapter.cpp +++ b/usb/libusb_adapter/src/libusb_adapter.cpp @@ -426,12 +426,22 @@ int32_t LibusbAdapter::GetDeviceFileDescriptor(const UsbDev &dev, int32_t &fd) if (fd < 0) { HDF_LOGE("%{public}s: open device failed errno = %{public}d %{public}s", __func__, errno, strerror(errno)); return HDF_FAILURE; - } - fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); - fd = fileFd; - { - std::unique_lock lock(g_mapMutexUsbOpenFdMap); - g_usbOpenFdMap[result] = fd; + } else { + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + std::lock_guard lock(openedFdsMutex_); + auto iter = openedFds_.find({dev.busNum, dev.devAddr}); + if (iter != openedFds_.end()) { + int32_t oldFd = iter->second; + if (oldFd != fd) { + int res = fdsan_close_with_tag(oldFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + HDF_LOGI("%{public}s:%{public}d close old %{public}d ret = %{public}d", + __func__, __LINE__, iter->second, res); + } + } else { + HDF_LOGI("%{public}s:%{public}d first time get fd", __func__, __LINE__); + } + openedFds_[{dev.busNum, dev.devAddr}] = fd; + HDF_LOGI("%{public}s:%{public}d opened %{public}d", __func__, __LINE__, fd); } HDF_LOGI("%{public}s leave", __func__); return HDF_SUCCESS; -- Gitee From a52b5a1f878819ac0dcd27fffb803094a6de96b6 Mon Sep 17 00:00:00 2001 From: 18191865724 Date: Wed, 26 Mar 2025 17:08:25 +0800 Subject: [PATCH 074/103] fix:solve usb depend Signed-off-by: 18191865724 --- usb/hdi_service/BUILD.gn | 23 +++++++++-------------- usb/usb.gni | 2 -- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/usb/hdi_service/BUILD.gn b/usb/hdi_service/BUILD.gn index abc993efa1..91250fc527 100644 --- a/usb/hdi_service/BUILD.gn +++ b/usb/hdi_service/BUILD.gn @@ -502,18 +502,13 @@ ohos_shared_library("libusb_device_driver") { } group("hdi_usb_service") { - if (usb_drivers_pass_through) { - deps = [ - ":libusb_device_driver", - ":libusb_device_interface_service_2.0", - ":libusb_host_interface_service_2.0", - ":libusb_port_driver", - ":libusb_port_interface_service_2.0", - ] - } else { - deps = [ - ":libusb_driver", - ":libusb_interface_service_1.2", - ] - } + deps = [ + ":libusb_device_driver", + ":libusb_device_interface_service_2.0", + ":libusb_driver", + ":libusb_host_interface_service_2.0", + ":libusb_interface_service_1.2", + ":libusb_port_driver", + ":libusb_port_interface_service_2.0", + ] } diff --git a/usb/usb.gni b/usb/usb.gni index c02ee5dbaa..c4d0eaec5c 100644 --- a/usb/usb.gni +++ b/usb/usb.gni @@ -42,6 +42,4 @@ declare_args() { if (defined(ohos_lite)) { libusb_enable = false } - - usb_drivers_pass_through = true } -- Gitee From 5060188b69e5f5ffd2051f9b232fbaaf2ad00222 Mon Sep 17 00:00:00 2001 From: wuyuexiang Date: Wed, 26 Mar 2025 17:23:25 +0800 Subject: [PATCH 075/103] add callback to cancel transfer Signed-off-by: dairan --- usb/libusb_adapter/src/libusb_adapter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/usb/libusb_adapter/src/libusb_adapter.cpp b/usb/libusb_adapter/src/libusb_adapter.cpp index ddd0776ad0..5f2e25508a 100644 --- a/usb/libusb_adapter/src/libusb_adapter.cpp +++ b/usb/libusb_adapter/src/libusb_adapter.cpp @@ -2032,6 +2032,7 @@ void LIBUSB_CALL LibusbAdapter::HandleAsyncResult(struct libusb_transfer *transf // handle failed transfer if (transfer->status == LIBUSB_TRANSFER_CANCELLED) { HDF_LOGE("%{public}s: async transfer has been canceled", __func__); + FeedbackToBase(transfer); HandleAsyncFailure(transfer); return; } -- Gitee From ad4b51f95dd25ebfbe6aefd2a7d1b304ce2aa1a7 Mon Sep 17 00:00:00 2001 From: yangkan Date: Wed, 26 Mar 2025 17:38:29 +0800 Subject: [PATCH 076/103] =?UTF-8?q?=E5=AF=B9service=E6=AF=8F=E6=AC=A1?= =?UTF-8?q?=E6=89=93=E5=BC=80sensor=EF=BC=8C=E9=A6=96=E5=B8=A7=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangkan --- sensor/hdi_service/sensor_clients_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sensor/hdi_service/sensor_clients_manager.cpp b/sensor/hdi_service/sensor_clients_manager.cpp index ff32099e2e..6804581eac 100644 --- a/sensor/hdi_service/sensor_clients_manager.cpp +++ b/sensor/hdi_service/sensor_clients_manager.cpp @@ -212,7 +212,8 @@ void SensorClientsManager::UpdateClientPeriodCount(int sensorId, int64_t samplin std::string result = ""; for (auto &entry : clients_[groupId]) { auto &client = entry.second; - if (client.curCountMap_.find(sensorId) == client.curCountMap_.end()) { + if (client.curCountMap_.find(sensorId) == client.curCountMap_.end() || + static_cast(HdfRemoteGetCallingPid()) == entry.first) { client.curCountMap_[sensorId] = INIT_CUR_COUNT; } if (client.sensorConfigMap_.find(sensorId) != client.sensorConfigMap_.end()) { -- Gitee From 485ad66c109f7a177079df7c2e19eae530ca762b Mon Sep 17 00:00:00 2001 From: zhaoqi Date: Thu, 27 Mar 2025 11:21:31 +0800 Subject: [PATCH 077/103] =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhaoqi --- usb/libusb_adapter/src/libusb_adapter.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/usb/libusb_adapter/src/libusb_adapter.cpp b/usb/libusb_adapter/src/libusb_adapter.cpp index ddd0776ad0..177d25e98e 100644 --- a/usb/libusb_adapter/src/libusb_adapter.cpp +++ b/usb/libusb_adapter/src/libusb_adapter.cpp @@ -109,8 +109,7 @@ std::shared_ptr LibusbAdapter::GetInstance() LibusbAdapter::LibusbAdapter() { HDF_LOGI("%{public}s libusbadapter constructer", __func__); - LibUSBInit(); - if (!eventThread.joinable()) { + if ((LibUSBInit() == HDF_SUCCESS) && (!eventThread.joinable())) { isRunning = true; eventThread = std::thread(&LibusbAdapter::LibusbEventHandling, this); } -- Gitee From 6ac89c3d24401a096ccaadc82ab035aba83feb3f Mon Sep 17 00:00:00 2001 From: fengliucs Date: Thu, 27 Mar 2025 11:48:52 +0800 Subject: [PATCH 078/103] =?UTF-8?q?=E2=80=9C=E9=92=88=E5=AF=B9beta?= =?UTF-8?q?=E5=8D=95=E5=AF=B9DFX=E7=BB=B4=E6=B5=8B=E8=83=BD=E5=8A=9B?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E8=A1=A5=E9=BD=90=E5=92=8C=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fengliucs --- usb/gadget/function/acm/cdcacm.c | 33 +++++++++++++++++++++++ usb/gadget/function/ecm/cdcecm.c | 22 +++++++++++++++ usb/hdi_service/src/usbd_port.cpp | 2 ++ usb/libusb_adapter/src/libusb_adapter.cpp | 2 ++ 4 files changed, 59 insertions(+) diff --git a/usb/gadget/function/acm/cdcacm.c b/usb/gadget/function/acm/cdcacm.c index 676f8ce8fb..e9fed999e9 100644 --- a/usb/gadget/function/acm/cdcacm.c +++ b/usb/gadget/function/acm/cdcacm.c @@ -249,6 +249,7 @@ static int32_t SpeedReadThread(void *arg) struct OsalThread g_threadRead; static int32_t StartThreadReadSpeed(struct UsbSerial *port) { + HDF_LOGD("%{public}s: enter", __func__); int32_t ret; struct OsalThreadParam threadCfg; ret = memset_s(&threadCfg, sizeof(threadCfg), 0, sizeof(threadCfg)); @@ -272,6 +273,7 @@ static int32_t StartThreadReadSpeed(struct UsbSerial *port) HDF_LOGE("%{public}s:%{public}d OsalThreadStart failed, ret=%{public}d ", __func__, __LINE__, ret); return HDF_ERR_DEVICE_BUSY; } + HDF_LOGD("%{public}s: exit", __func__); return HDF_SUCCESS; } @@ -299,9 +301,11 @@ static int32_t UsbSerialGetTempReadSpeedInt(struct UsbSerial *port, struct HdfSB static int32_t UsbSerialReadSpeedDone(struct UsbSerial *port) { (void)port; + HDF_LOGI("%{public}s: enter", __func__); gettimeofday(&g_readTimeEnd, NULL); g_isReadDone = true; g_isStartRead = false; + HDF_LOGD("%{public}s: exit", __func__); return HDF_SUCCESS; } @@ -433,6 +437,7 @@ static void UsbSerialStopIo(struct UsbSerial *port) static int32_t UsbSerialAllocFifo(struct DataFifo *fifo, uint32_t size) { + HDF_LOGD("%{public}s: enter", __func__); if (!DataFifoIsInitialized(fifo)) { void *data = OsalMemAlloc(size); if (data == NULL) { @@ -441,11 +446,13 @@ static int32_t UsbSerialAllocFifo(struct DataFifo *fifo, uint32_t size) } DataFifoInit(fifo, size, data); } + HDF_LOGD("%{public}s: exit", __func__); return HDF_SUCCESS; } static int32_t UsbSerialOpen(struct UsbSerial *port) { + HDF_LOGD("%{public}s: enter", __func__); int32_t ret; if (port == NULL) { @@ -484,11 +491,13 @@ static int32_t UsbSerialOpen(struct UsbSerial *port) OUT: OsalMutexUnlock(&port->lock); + HDF_LOGD("%{public}s: exit", __func__); return HDF_SUCCESS; } static int32_t UsbSerialClose(struct UsbSerial *port) { + HDF_LOGD("%{public}s: enter", __func__); struct UsbAcmDevice *acm = NULL; if (port == NULL) { @@ -510,6 +519,7 @@ static int32_t UsbSerialClose(struct UsbSerial *port) port->startDelayed = false; OsalMutexUnlock(&port->lock); + HDF_LOGD("%{public}s: exit", __func__); return HDF_SUCCESS; } @@ -601,6 +611,7 @@ static int32_t SpeedThread(void *arg) struct OsalThread g_thread; static int32_t StartThreadSpeed(struct UsbSerial *port) { + HDF_LOGD("%{public}s: enter", __func__); struct OsalThreadParam threadCfg; int32_t ret = memset_s(&threadCfg, sizeof(threadCfg), 0, sizeof(threadCfg)); if (ret != EOK) { @@ -622,6 +633,7 @@ static int32_t StartThreadSpeed(struct UsbSerial *port) HDF_LOGE("%{public}s:%{public}d OsalThreadStart failed, ret=%{public}d ", __func__, __LINE__, ret); return HDF_ERR_DEVICE_BUSY; } + HDF_LOGD("%{public}s: exit", __func__); return 0; } @@ -651,6 +663,7 @@ static int32_t UsbSerialSpeedDone(struct UsbSerial *port) (void)port; gettimeofday(&g_timeEnd, NULL); g_isWriteDone = true; + HDF_LOGI("%{public}s: Serial speed done success", __func__); return HDF_SUCCESS; } @@ -662,6 +675,7 @@ static int32_t UsbSerialSpeed(struct UsbSerial *port) static int32_t UsbSerialRead(struct UsbSerial *port, struct HdfSBuf *reply) { + HDF_LOGD("%{public}s: enter", __func__); uint32_t len, fifoLen; int32_t ret = HDF_SUCCESS; uint8_t *buf = NULL; @@ -703,11 +717,13 @@ OUT: } OsalMemFree(buf); OsalMutexUnlock(&port->lock); + HDF_LOGD("%{public}s: exit", __func__); return ret; } static int32_t UsbSerialWrite(struct UsbSerial *port, struct HdfSBuf *data) { + HDF_LOGD("%{public}s: enter", __func__); int32_t size; const char *tmp = NULL; @@ -741,21 +757,25 @@ static int32_t UsbSerialWrite(struct UsbSerial *port, struct HdfSBuf *data) } OsalMutexUnlock(&port->lock); OsalMemFree(buf); + HDF_LOGD("%{public}s: exit", __func__); return size; } static int32_t UsbSerialGetBaudrate(struct UsbSerial *port, struct HdfSBuf *reply) { + HDF_LOGD("%{public}s: enter", __func__); uint32_t baudRate = LE32_TO_CPU(port->lineCoding.dwDTERate); if (!HdfSbufWriteBuffer(reply, &baudRate, sizeof(baudRate))) { HDF_LOGE("%{public}s: sbuf write buffer failed", __func__); return HDF_ERR_IO; } + HDF_LOGD("%{public}s: exit", __func__); return HDF_SUCCESS; } static int32_t UsbSerialSetBaudrate(struct UsbSerial *port, struct HdfSBuf *data) { + HDF_LOGD("%{public}s: enter", __func__); uint32_t size; uint32_t *baudRate = NULL; @@ -767,11 +787,13 @@ static int32_t UsbSerialSetBaudrate(struct UsbSerial *port, struct HdfSBuf *data if (port->acm) { port->acm->lineCoding.dwDTERate = CPU_TO_LE32(*baudRate); } + HDF_LOGD("%{public}s: exit", __func__); return HDF_SUCCESS; } static int32_t UsbSerialGetProp(struct UsbAcmDevice *acmDevice, struct HdfSBuf *data, struct HdfSBuf *reply) { + HDF_LOGD("%{public}s: enter", __func__); struct UsbFnInterface *intf = acmDevice->ctrlIface.fn; const char *propName = NULL; char propValue[USB_MAX_PACKET_SIZE] = {0}; @@ -779,30 +801,36 @@ static int32_t UsbSerialGetProp(struct UsbAcmDevice *acmDevice, struct HdfSBuf * propName = HdfSbufReadString(data); if (propName == NULL) { + HDF_LOGE("%{public}s: sbuf read buffer failed.", __func__); return HDF_ERR_IO; } ret = UsbFnGetInterfaceProp(intf, propName, propValue); if (ret) { + HDF_LOGE("%{public}s: get interface face prop failed.", __func__); return HDF_ERR_IO; } if (!HdfSbufWriteString(reply, propValue)) { HDF_LOGE("%{public}s:failed to write result", __func__); return HDF_ERR_IO; } + HDF_LOGD("%{public}s: exit", __func__); return HDF_SUCCESS; } static int32_t UsbSerialSetProp(struct UsbAcmDevice *acmDevice, struct HdfSBuf *data) { + HDF_LOGD("%{public}s: enter", __func__); struct UsbFnInterface *intf = acmDevice->ctrlIface.fn; char tmp[USB_MAX_PACKET_SIZE] = {0}; const char *propName = HdfSbufReadString(data); if (propName == NULL) { + HDF_LOGE("%{public}s: sbuf read buffer failed.", __func__); return HDF_ERR_IO; } const char *propValue = HdfSbufReadString(data); if (propValue == NULL) { + HDF_LOGE("%{public}s: sbuf read buffer failed.", __func__); return HDF_ERR_IO; } (void)memset_s(&tmp, sizeof(tmp), 0, sizeof(tmp)); @@ -816,6 +844,7 @@ static int32_t UsbSerialSetProp(struct UsbAcmDevice *acmDevice, struct HdfSBuf * HDF_LOGE("%{public}s: UsbFnInterfaceSetProp failed", __func__); return HDF_ERR_IO; } + HDF_LOGD("%{public}s: exit", __func__); return HDF_SUCCESS; } @@ -839,6 +868,7 @@ static int32_t UsbSerialRegistPropASet(const struct UsbFnInterface *intf, const static int32_t UsbSerialRegistProp(struct UsbAcmDevice *acmDevice, struct HdfSBuf *data) { + HDF_LOGI("%{public}s: enter", __func__); struct UsbFnInterface *intf = acmDevice->ctrlIface.fn; struct UsbFnRegistInfo registInfo; int32_t ret; @@ -860,12 +890,14 @@ static int32_t UsbSerialRegistProp(struct UsbAcmDevice *acmDevice, struct HdfSBu HDF_LOGE("%{public}s: UsbFnInterfaceSetProp failed", __func__); return HDF_ERR_IO; } + HDF_LOGI("%{public}s: exit", __func__); return HDF_SUCCESS; } static int32_t AcmSerialCmd( struct UsbAcmDevice *acm, int32_t cmd, struct UsbSerial *port, struct HdfSBuf *data, struct HdfSBuf *reply) { + HDF_LOGI("%{public}s: cmd is %{public}d", __func__, cmd); switch (cmd) { case USB_SERIAL_OPEN: return UsbSerialOpen(port); @@ -904,6 +936,7 @@ static int32_t AcmSerialCmd( default: return HDF_ERR_NOT_SUPPORT; } + HDF_LOGI("%{public}s: exit", __func__); return HDF_SUCCESS; } diff --git a/usb/gadget/function/ecm/cdcecm.c b/usb/gadget/function/ecm/cdcecm.c index 542055b2b9..7bb5262c5a 100644 --- a/usb/gadget/function/ecm/cdcecm.c +++ b/usb/gadget/function/ecm/cdcecm.c @@ -312,9 +312,11 @@ static int32_t UsbEcmAllocFifo(struct DataFifo *fifo, uint32_t size) static int32_t UsbEcmOpen(struct UsbEcm *port) { + HDF_LOGD("%{public}s: enter", __func__); int32_t ret; if (port == NULL) { + HDF_LOGE("%{public}s: port is null", __func__); return HDF_ERR_INVALID_PARAM; } @@ -348,12 +350,15 @@ static int32_t UsbEcmOpen(struct UsbEcm *port) OUT: OsalMutexUnlock(&port->lock); + HDF_LOGD("%{public}s: exit", __func__); return HDF_SUCCESS; } static int32_t UsbEcmClose(struct UsbEcm *port) { + HDF_LOGD("%{public}s: enter", __func__); if (port == NULL) { + HDF_LOGE("%{public}s: port is null", __func__); return HDF_ERR_INVALID_PARAM; } @@ -371,11 +376,13 @@ static int32_t UsbEcmClose(struct UsbEcm *port) OUT: OsalMutexUnlock(&port->lock); + HDF_LOGD("%{public}s: exit", __func__); return HDF_SUCCESS; } static int32_t UsbEcmRead(struct UsbEcm *port, struct HdfSBuf *reply) { + HDF_LOGI("%{public}s: enter", __func__); uint32_t len; int32_t ret = HDF_SUCCESS; uint8_t *buf = NULL; @@ -384,6 +391,7 @@ static int32_t UsbEcmRead(struct UsbEcm *port, struct HdfSBuf *reply) if (DataFifoIsEmpty(&port->readFifo)) { OsalMutexUnlock(&port->lockReadFifo); OsalMutexUnlock(&port->lock); + HDF_LOGI("%{public}s: data fifl is empty", __func__); return 0; } @@ -417,11 +425,13 @@ OUT: } OsalMemFree(buf); OsalMutexUnlock(&port->lock); + HDF_LOGD("%{public}s: exit", __func__); return ret; } static int32_t UsbEcmWrite(struct UsbEcm *port, struct HdfSBuf *data) { + HDF_LOGD("%{public}s: enter", __func__); uint32_t size = 0; uint8_t *buf = NULL; @@ -435,11 +445,14 @@ static int32_t UsbEcmWrite(struct UsbEcm *port, struct HdfSBuf *data) OsalMutexLock(&port->lockWriteFifo); size = DataFifoWrite(&port->writeFifo, buf, size); OsalMutexUnlock(&port->lockWriteFifo); + } else { + HDF_LOGE("%{public}s: buf is null", __func__); } if (port->ecm) { UsbEcmStartTx(port); } OsalMutexUnlock(&port->lock); + HDF_LOGD("%{public}s: exit", __func__); return HDF_SUCCESS; } @@ -561,6 +574,7 @@ static int32_t EcmSetup(const struct UsbEcmDevice *ecm, const struct UsbFnCtrlRe static int32_t EcmDeviceDispatch( struct HdfDeviceIoClient *client, int32_t cmd, struct HdfSBuf *data, struct HdfSBuf *reply) { + HDF_LOGI("%{public}s: enter, cmd is %{public}d", __func__, cmd); struct UsbEcmDevice *ecm = NULL; struct UsbEcm *port = NULL; int32_t ret; @@ -610,6 +624,7 @@ static int32_t EcmDeviceDispatch( break; } OsalMutexUnlock(&port->lockRW); + HDF_LOGI("%{public}s: exit", __func__); return ret; } @@ -836,6 +851,7 @@ static int32_t EcmReleaseFuncDevice(struct UsbEcmDevice *ecm) UsbFnCloseInterface(ecm->ctrlIface.handle); (void)UsbFnCloseInterface(ecm->dataIface.handle); (void)UsbFnStopRecvInterfaceEvent(ecm->ctrlIface.fn); + HDF_LOGD("%{public}s: ecn was released heres", __func__); return ret; } @@ -901,6 +917,7 @@ static void UsbEcmFree(struct UsbEcmDevice *ecm) /* HdfDriverEntry implementations */ static int32_t EcmDriverBind(struct HdfDeviceObject *device) { + HDF_LOGD("%{public}s: enter", __func__); struct UsbEcmDevice *ecm = NULL; if (device == NULL) { @@ -932,11 +949,13 @@ static int32_t EcmDriverBind(struct HdfDeviceObject *device) if (ecm->device->service) { ecm->device->service->Dispatch = EcmDeviceDispatch; } + HDF_LOGD("%{public}s: exit", __func__); return HDF_SUCCESS; } static int32_t EcmInit(struct HdfDeviceObject *device) { + HDF_LOGD("%{public}s: enter", __func__); struct UsbEcmDevice *ecm = NULL; struct DeviceResourceIface *iface = NULL; int32_t ret; @@ -988,6 +1007,7 @@ static int32_t EcmInit(struct HdfDeviceObject *device) goto ERR; } ecm->initFlag = true; + HDF_LOGD("%{public}s: exit", __func__); return ret; ERR: UsbEcmFree(ecm); @@ -997,6 +1017,7 @@ ERR: static int32_t EcmRelease(struct HdfDeviceObject *device) { + HDF_LOGD("%{public}s: enter", __func__); struct UsbEcmDevice *ecm = NULL; if (device == NULL) { @@ -1016,6 +1037,7 @@ static int32_t EcmRelease(struct HdfDeviceObject *device) UsbEcmFree(ecm); (void)EcmReleaseFuncDevice(ecm); ecm->initFlag = false; + HDF_LOGD("%{public}s: exit", __func__); return HDF_SUCCESS; } diff --git a/usb/hdi_service/src/usbd_port.cpp b/usb/hdi_service/src/usbd_port.cpp index 04d92e6753..c47359fe6a 100644 --- a/usb/hdi_service/src/usbd_port.cpp +++ b/usb/hdi_service/src/usbd_port.cpp @@ -251,6 +251,7 @@ int32_t UsbdPort::UpdatePort(int32_t mode, const sptr &subscrib int32_t UsbdPort::UpdateUsbPort(int32_t mode, const sptr &subscriber) { + HDF_LOGD("%{public}s enter, mode is %{public}d", __func__, mode); switch (mode) { case PORT_MODE_HOST: currentPortInfo_.powerRole = POWER_ROLE_SOURCE; @@ -274,6 +275,7 @@ int32_t UsbdPort::UpdateUsbPort(int32_t mode, const sptr currentPortInfos_ = {currentPortInfo_.portId, currentPortInfo_.powerRole, currentPortInfo_.dataRole, currentPortInfo_.mode}; subscriber->PortChangedEvent(currentPortInfos_); + HDF_LOGD("%{public}s exit", __func__); return HDF_SUCCESS; } } // namespace V1_2 diff --git a/usb/libusb_adapter/src/libusb_adapter.cpp b/usb/libusb_adapter/src/libusb_adapter.cpp index ddd0776ad0..9c2dceeda7 100644 --- a/usb/libusb_adapter/src/libusb_adapter.cpp +++ b/usb/libusb_adapter/src/libusb_adapter.cpp @@ -2877,6 +2877,8 @@ int32_t LibusbAdapter::SetSubscriber(sptr subscriber) libusb_exit(g_libusb_context); g_libusb_context = nullptr; return HDF_FAILURE; + } else { + HDF_LOGD("%{public}s: register hotplug callback success.", __func__); } } GetCurrentDeviceList(g_libusb_context, subscriber); -- Gitee From 030377cbbee2b3a1341782573d2f13a7178c339c Mon Sep 17 00:00:00 2001 From: fengliucs Date: Thu, 27 Mar 2025 14:27:08 +0800 Subject: [PATCH 079/103] =?UTF-8?q?=E2=80=9C=E9=92=88=E5=AF=B9beta?= =?UTF-8?q?=E5=8D=95=E5=AF=B9DFX=E7=BB=B4=E6=B5=8B=E8=83=BD=E5=8A=9B?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E8=A1=A5=E9=BD=90=E5=92=8C=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fengliucs --- usb/gadget/function/ecm/cdcecm.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/usb/gadget/function/ecm/cdcecm.c b/usb/gadget/function/ecm/cdcecm.c index 7bb5262c5a..a66b28143c 100644 --- a/usb/gadget/function/ecm/cdcecm.c +++ b/usb/gadget/function/ecm/cdcecm.c @@ -574,7 +574,6 @@ static int32_t EcmSetup(const struct UsbEcmDevice *ecm, const struct UsbFnCtrlRe static int32_t EcmDeviceDispatch( struct HdfDeviceIoClient *client, int32_t cmd, struct HdfSBuf *data, struct HdfSBuf *reply) { - HDF_LOGI("%{public}s: enter, cmd is %{public}d", __func__, cmd); struct UsbEcmDevice *ecm = NULL; struct UsbEcm *port = NULL; int32_t ret; @@ -624,7 +623,6 @@ static int32_t EcmDeviceDispatch( break; } OsalMutexUnlock(&port->lockRW); - HDF_LOGI("%{public}s: exit", __func__); return ret; } @@ -955,7 +953,6 @@ static int32_t EcmDriverBind(struct HdfDeviceObject *device) static int32_t EcmInit(struct HdfDeviceObject *device) { - HDF_LOGD("%{public}s: enter", __func__); struct UsbEcmDevice *ecm = NULL; struct DeviceResourceIface *iface = NULL; int32_t ret; @@ -1007,7 +1004,6 @@ static int32_t EcmInit(struct HdfDeviceObject *device) goto ERR; } ecm->initFlag = true; - HDF_LOGD("%{public}s: exit", __func__); return ret; ERR: UsbEcmFree(ecm); -- Gitee From 1ebf789c29f88cd34ebb16ac0592003c6d14c2ea Mon Sep 17 00:00:00 2001 From: guochengying <346447065@qq.com> Date: Thu, 27 Mar 2025 16:34:38 +0800 Subject: [PATCH 080/103] fix: fix mkswap Signed-off-by: guochengying <346447065@qq.com> --- power/interfaces/hdi_service/src/hibernate.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/power/interfaces/hdi_service/src/hibernate.cpp b/power/interfaces/hdi_service/src/hibernate.cpp index 910ca680e9..1efa3c35f3 100644 --- a/power/interfaces/hdi_service/src/hibernate.cpp +++ b/power/interfaces/hdi_service/src/hibernate.cpp @@ -150,12 +150,13 @@ void Hibernate::InitSwap() if (ret != HDF_SUCCESS) { return; } - ret = MkSwap(); - if (ret != HDF_SUCCESS) { - HDF_LOGI("init swap failed"); - RemoveSwapFile(); - return; - } + } + + ret = MkSwap(); + if (ret != HDF_SUCCESS) { + HDF_LOGI("init swap failed"); + RemoveSwapFile(); + return; } ret = WriteOffsetAndResume(); -- Gitee From 844f0ddc5056a70ffacf97e99bd89751aeea8069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Thu, 27 Mar 2025 19:31:14 +0800 Subject: [PATCH 081/103] change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp | 4 ++-- usb/hdi_service/src/usb_impl.cpp | 6 +++--- usb/hdi_service/src/usbd_accessory.cpp | 2 +- usb/libusb_adapter/src/libusb_adapter.cpp | 3 +-- usb/serial/src/libusb_serial.cpp | 1 + 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp b/usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp index 1713994d5b..1549cba8f6 100755 --- a/usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp +++ b/usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp @@ -1731,7 +1731,7 @@ int32_t UsbfnMtpImpl::ReceiveFile(const UsbFnMtpFileSlice &mfs) pthread_rwlock_rdlock(&mtpRunrwLock_); ON_SCOPE_EXIT(release) { pthread_rwlock_unlock(&mtpRunrwLock_); - fdsan_close_with_tag(mfs.fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + close(mfs.fd); }; if (mtpPort_ == nullptr || mtpDev_ == nullptr || !mtpDev_->initFlag) { HDF_LOGE("%{public}s: no init", __func__); @@ -1890,7 +1890,7 @@ int32_t UsbfnMtpImpl::SendFile(const UsbFnMtpFileSlice &mfs) pthread_rwlock_rdlock(&mtpRunrwLock_); ON_SCOPE_EXIT(release) { pthread_rwlock_unlock(&mtpRunrwLock_); - fdsan_close_with_tag(mfs.fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + close(mfs.fd); }; if (mtpPort_ == nullptr || mtpDev_ == nullptr || !mtpDev_->initFlag) { HDF_LOGE("%{public}s: no init", __func__); diff --git a/usb/hdi_service/src/usb_impl.cpp b/usb/hdi_service/src/usb_impl.cpp index c8dd1ff991..324124cf73 100644 --- a/usb/hdi_service/src/usb_impl.cpp +++ b/usb/hdi_service/src/usb_impl.cpp @@ -775,7 +775,7 @@ int32_t UsbImpl::InitAsmBufferHandle(UsbdBufferHandle *handle, int32_t fd, int32 handle->cbflg = 0; lseek(fd, 0, SEEK_SET); handle->starAddr = static_cast(mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)); - fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + close(fd); if (handle->starAddr == nullptr) { handle->fd = -1; handle->size = 0; @@ -926,7 +926,7 @@ void UsbImpl::UsbdCloseFd(UsbImpl *super, UsbPnpNotifyMatchInfoTable *infoTable) auto iter = super->openedFds_.find({infoTable->busNum, infoTable->devNum}); if (iter != super->openedFds_.end()) { int32_t fd = iter->second; - int res = fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + int res = close(fd); super->openedFds_.erase(iter); HDF_LOGI("%{public}s:%{public}d close %{public}d ret = %{public}d", __func__, __LINE__, iter->second, res); @@ -1352,7 +1352,7 @@ int32_t UsbImpl::GetDeviceFileDescriptor(const UsbDev &dev, int32_t &fd) auto iter = openedFds_.find({dev.busNum, dev.devAddr}); if (iter != openedFds_.end()) { int32_t oldFd = iter->second; - int res = fdsan_close_with_tag(oldFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + int res = close(oldFd); HDF_LOGI("%{public}s:%{public}d close old %{public}d ret = %{public}d", __func__, __LINE__, iter->second, res); } else { diff --git a/usb/hdi_service/src/usbd_accessory.cpp b/usb/hdi_service/src/usbd_accessory.cpp index 86f280e4eb..95377915d3 100644 --- a/usb/hdi_service/src/usbd_accessory.cpp +++ b/usb/hdi_service/src/usbd_accessory.cpp @@ -205,7 +205,7 @@ int32_t UsbdAccessory::CloseAccessory(int32_t fd) if (accFd > 0) { fdsan_close_with_tag(accFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); } - fdsan_close_with_tag(fd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + close(fd); accFd = 0; return HDF_SUCCESS; } diff --git a/usb/libusb_adapter/src/libusb_adapter.cpp b/usb/libusb_adapter/src/libusb_adapter.cpp index db1b540dd5..52511ffb6a 100644 --- a/usb/libusb_adapter/src/libusb_adapter.cpp +++ b/usb/libusb_adapter/src/libusb_adapter.cpp @@ -1445,8 +1445,7 @@ int32_t LibusbAdapter::SendPipeRequestWithAshmem(const UsbDev &dev, unsigned cha } transferredLength = static_cast(actlength); CloseMmapBuffer(buffer, sendRequestAshmemParameter.ashmemSize); - fdsan_close_with_tag(sendRequestAshmemParameter.ashmemFd, - fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + close(sendRequestAshmemParameter.ashmemFd); return ret; } diff --git a/usb/serial/src/libusb_serial.cpp b/usb/serial/src/libusb_serial.cpp index 1d7491325d..37016a1cc3 100644 --- a/usb/serial/src/libusb_serial.cpp +++ b/usb/serial/src/libusb_serial.cpp @@ -639,6 +639,7 @@ bool CheckTtyDeviceInfo(std::string ttyUsbPath, libusb_device* device) HDF_LOGE("%{public}s : open file failed. ret = %{public}s", __func__, strerror(errno)); return false; } + fdsan_exchange_owner_tag(devnumFd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); char devnumBuff[BUFFER_SIZE] = {'\0'}; readBytes = read(devnumFd, devnumBuff, BUFFER_SIZE); fdsan_close_with_tag(devnumFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); -- Gitee From cffc4e1c21dbe09d476f45081cf58d1580c893fd Mon Sep 17 00:00:00 2001 From: fengye Date: Thu, 27 Mar 2025 13:08:24 +0000 Subject: [PATCH 082/103] fix: chba uses independent wpa config Signed-off-by: fengye --- .../interfaces/hdi_service/service_common/wpa_common_cmd_ext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd_ext.c b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd_ext.c index bc7858dd09..7f27eed0bd 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd_ext.c +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd_ext.c @@ -308,7 +308,7 @@ int32_t WpaInterfaceAddWpaIface(struct IWpaInterface *self, const char *ifName, } else if (strncmp(ifName, "chba0", strlen("chba0")) == 0) { if (strcpy_s(addInterface.name, sizeof(addInterface.name) - 1, ifName) != EOK || strcpy_s(addInterface.confName, sizeof(addInterface.confName) - 1, - CONFIG_ROOR_DIR"/wpa_supplicant/p2p_supplicant.conf") != EOK) { + CONFIG_ROOR_DIR"/wpa_supplicant/chba_supplicant.conf") != EOK) { pthread_mutex_unlock(GetInterfaceLock()); return HDF_FAILURE; } -- Gitee From c738c454933e2205c13bf95169176d27fa5e439b Mon Sep 17 00:00:00 2001 From: dairan Date: Fri, 28 Mar 2025 03:37:24 +0000 Subject: [PATCH 083/103] update: change hotPlug thread name Signed-off-by: dairan --- usb/serial/src/libusb_serial.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usb/serial/src/libusb_serial.cpp b/usb/serial/src/libusb_serial.cpp index adc2365490..43408ae115 100644 --- a/usb/serial/src/libusb_serial.cpp +++ b/usb/serial/src/libusb_serial.cpp @@ -60,6 +60,7 @@ static const std::string DEV_NUM_STR = "/devnum"; static const std::string DEV_FILENAME_PREFIX = "ttyUSB"; static const std::string DEV_PATH_PREFIX = "/sys/bus/usb-serial/devices"; static const std::string TTYUSB_PATH = "/sys/class/tty"; +static const std::string THREAD_NAME = "serialHotPlug"; namespace fs = std::filesystem; @@ -587,6 +588,7 @@ void LibusbSerial::HandleDeviceRemoval(libusb_device* device) void LibusbSerial::EventHandlingThread() { HDF_LOGI("%{public}s: enter Event handling thread.", __func__); + pthread_setname_np(pthread_self(), THREAD_NAME.c_str()); while (running_) { int ret = libusb_handle_events_completed(ctx_, nullptr); if (ret != LIBUSB_SUCCESS) { -- Gitee From 784059664f60d36bbd42ce5f5b776eca3409a904 Mon Sep 17 00:00:00 2001 From: huyu Date: Fri, 28 Mar 2025 18:28:41 +0800 Subject: [PATCH 084/103] =?UTF-8?q?=E6=89=93=E5=8D=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyu --- wlan/chip/wifi_hal/common.cpp | 3 +-- wlan/chip/wifi_hal/wifi_logger.cpp | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/wlan/chip/wifi_hal/common.cpp b/wlan/chip/wifi_hal/common.cpp index 314e17775a..eaf3894aad 100644 --- a/wlan/chip/wifi_hal/common.cpp +++ b/wlan/chip/wifi_hal/common.cpp @@ -97,8 +97,7 @@ WifiError WifiRegisterHandler(wifiHandle handle, int cmd, nl_recvmsg_msg_cb_t fu info->eventCb[info->numEventCb].vendorSubcmd = 0; info->eventCb[info->numEventCb].cbFunc = func; info->eventCb[info->numEventCb].cbArg = arg; - HDF_LOGD("Successfully added event handler %{public}p:%{public}p for command %{public}d at %{public}d", - arg, func, cmd, info->numEventCb); + HDF_LOGD("Successfully added event handler for command %{public}d at %{public}d", cmd, info->numEventCb); info->numEventCb++; result = HAL_SUCCESS; } diff --git a/wlan/chip/wifi_hal/wifi_logger.cpp b/wlan/chip/wifi_hal/wifi_logger.cpp index 835dd23111..fee1350582 100644 --- a/wlan/chip/wifi_hal/wifi_logger.cpp +++ b/wlan/chip/wifi_hal/wifi_logger.cpp @@ -121,8 +121,7 @@ public: if (*mHandler.onVendorHalRestart) { (*mHandler.onVendorHalRestart)(mBuff); - HDF_LOGI("Hang event received. Trigger SSR handler:%p", - mHandler.onVendorHalRestart); + HDF_LOGI("Hang event received."); } else { HDF_LOGI("No Restart handler registered"); } @@ -255,8 +254,7 @@ exit: cmd->ReleaseRef(); } if (info->restartHandler.onVendorHalRestart) { - HDF_LOGI("Trigger ssr handler registered handler:%p", - info->restartHandler.onVendorHalRestart); + HDF_LOGI("Trigger ssr handler registered handler"); (info->restartHandler.onVendorHalRestart)(errorStr); } else { HDF_LOGI("No trigger ssr handler registered"); -- Gitee From 491c78f354dd5d2ae5895cfb431acf1c99c7da22 Mon Sep 17 00:00:00 2001 From: m00911899 Date: Thu, 27 Mar 2025 23:05:43 +0800 Subject: [PATCH 085/103] modify the outpath of test Signed-off-by: m00911899 Change-Id: I0327512738e1383c959928409a4c150dc24bb5d9 --- memorytracker/test/BUILD.gn | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/memorytracker/test/BUILD.gn b/memorytracker/test/BUILD.gn index 83068c01b6..1067c3509f 100644 --- a/memorytracker/test/BUILD.gn +++ b/memorytracker/test/BUILD.gn @@ -15,7 +15,8 @@ import("//build/ohos.gni") import("//build/ohos_var.gni") import("//build/test.gni") -module_output_path = "memorytrackertest/" +module_output_path = + "drivers_peripheral_memorytracker/drivers_peripheral_memorytracker" declare_args() { drivers_peripheral_memorytracker_is_implemented = false -- Gitee From b7249ce36b696cbcb3b647dd12e9f2b3e379a613 Mon Sep 17 00:00:00 2001 From: wangyikai Date: Fri, 28 Mar 2025 19:15:10 +0800 Subject: [PATCH 086/103] =?UTF-8?q?=E3=80=90hdf=E9=A9=B1=E5=8A=A8=E3=80=91?= =?UTF-8?q?TOP=E9=97=AE=E9=A2=98=E9=80=86=E5=90=91=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyikai --- audio/BUILD.gn | 2 + audio/audio_dfx/BUILD.gn | 48 ++++++++++ .../include/audio_dfx.h} | 12 +-- .../src/audio_dfx.cpp} | 11 +-- audio/effect/model/BUILD.gn | 3 + audio/effect/model/src/effect_control.c | 89 ++++++++++++------- audio/hdi_service/primary_impl/BUILD.gn | 13 +-- .../primary_impl/vdi_src/audio_adapter_vdi.c | 6 +- .../primary_impl/vdi_src/audio_capture_vdi.c | 2 +- .../primary_impl/vdi_src/audio_manager_vdi.c | 8 +- .../primary_impl/vdi_src/audio_render_vdi.c | 2 +- .../vendor_interface/utils/audio_uhdf_log.h | 12 +++ 12 files changed, 147 insertions(+), 61 deletions(-) create mode 100644 audio/audio_dfx/BUILD.gn rename audio/{hdi_service/primary_impl/vdi_src/audio_dfx_vdi.h => audio_dfx/include/audio_dfx.h} (77%) rename audio/{hdi_service/primary_impl/vdi_src/audio_dfx_vdi.cpp => audio_dfx/src/audio_dfx.cpp} (84%) diff --git a/audio/BUILD.gn b/audio/BUILD.gn index db6af34288..5bfa248c13 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -24,6 +24,8 @@ group("hdi_audio") { } deps += [ "hdi_service:idl_audio" ] } + + deps += [ "audio_dfx:libaudio_dfx_static" ] } config("drivers_peripheral_audio_header") { diff --git a/audio/audio_dfx/BUILD.gn b/audio/audio_dfx/BUILD.gn new file mode 100644 index 0000000000..c67cafd60e --- /dev/null +++ b/audio/audio_dfx/BUILD.gn @@ -0,0 +1,48 @@ +# Copyright (c) 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 +# +# 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. + +import("//build/ohos.gni") +import("../audio.gni") + +config("drivers_peripheral_audio_dfx_header") { + include_dirs = [ "include" ] +} + +ohos_static_library("libaudio_dfx_static") { + external_deps = [] + defines = [] + + if (enable_c_utils) { + external_deps += [ "c_utils:utils" ] + } + + if (!drivers_peripheral_audio_feature_community) { + if (drivers_peripheral_audio_feature_hitrace_enable) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "AUDIO_HITRACE_ENABLE" ] + } + + if (drivers_peripheral_audio_feature_hicollie_enable) { + external_deps += [ "hicollie:libhicollie" ] + defines += [ "AUDIO_HICOLLIE_ENABLE" ] + } + } + + public_configs = [ ":drivers_peripheral_audio_dfx_header" ] + include_dirs = [ "include" ] + + sources = [ "src/audio_dfx.cpp" ] + + part_name = "drivers_peripheral_audio" + subsystem_name = "hdf" +} diff --git a/audio/hdi_service/primary_impl/vdi_src/audio_dfx_vdi.h b/audio/audio_dfx/include/audio_dfx.h similarity index 77% rename from audio/hdi_service/primary_impl/vdi_src/audio_dfx_vdi.h rename to audio/audio_dfx/include/audio_dfx.h index 9f98333cbc..5ef3e73e51 100644 --- a/audio/hdi_service/primary_impl/vdi_src/audio_dfx_vdi.h +++ b/audio/audio_dfx/include/audio_dfx.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 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 @@ -13,10 +13,10 @@ * limitations under the License. */ -#ifndef AUDIO_DFX_VDI_H -#define AUDIO_DFX_VDI_H -#include "audio_types_vdi.h" +#ifndef AUDIO_DFX_H +#define AUDIO_DFX_H +#include #ifdef __cplusplus extern "C" { #endif @@ -25,8 +25,8 @@ void HdfAudioStartTrace(const char* value, int valueLen); void HdfAudioFinishTrace(void); int32_t SetTimer(const char* name); void CancelTimer(int32_t id); -void SetMaxWorkThreadNum(int32_t count); + #ifdef __cplusplus } #endif -#endif /* AUDIO_DFX_VDI_H */ \ No newline at end of file +#endif /* AUDIO_DFX_H */ \ No newline at end of file diff --git a/audio/hdi_service/primary_impl/vdi_src/audio_dfx_vdi.cpp b/audio/audio_dfx/src/audio_dfx.cpp similarity index 84% rename from audio/hdi_service/primary_impl/vdi_src/audio_dfx_vdi.cpp rename to audio/audio_dfx/src/audio_dfx.cpp index f5de19aded..b74f29343f 100644 --- a/audio/hdi_service/primary_impl/vdi_src/audio_dfx_vdi.cpp +++ b/audio/audio_dfx/src/audio_dfx.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 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 @@ -12,8 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "ipc_skeleton.h" -#include "audio_dfx_vdi.h" + +#include "audio_dfx.h" #ifdef AUDIO_HITRACE_ENABLE #include #endif @@ -62,9 +62,4 @@ void CancelTimer(int32_t id) #else (void)id; #endif -} - -void SetMaxWorkThreadNum(int32_t count) -{ - OHOS::IPCSkeleton::GetInstance().SetMaxWorkThreadNum(count); } \ No newline at end of file diff --git a/audio/effect/model/BUILD.gn b/audio/effect/model/BUILD.gn index 6c1e59e207..dec0eb4de4 100644 --- a/audio/effect/model/BUILD.gn +++ b/audio/effect/model/BUILD.gn @@ -29,6 +29,7 @@ if (!defined(ohos_lite)) { "$hdf_audio_path/interfaces/effect", "../config/include/", "$hdf_audio_path/hdi_service/vendor_interface/utils", + "$hdf_audio_path/hdi_service/primary_impl/vdi_src", ] defines = [] @@ -52,6 +53,8 @@ if (!defined(ohos_lite)) { "cJSON:cjson", ] + deps = [ "$hdf_audio_path/audio_dfx:libaudio_dfx_static" ] + install_images = [ chipset_base_dir ] subsystem_name = "hdf" part_name = "drivers_peripheral_audio" diff --git a/audio/effect/model/src/effect_control.c b/audio/effect/model/src/effect_control.c index 4c95ecd33d..9f21faf511 100644 --- a/audio/effect/model/src/effect_control.c +++ b/audio/effect/model/src/effect_control.c @@ -21,40 +21,53 @@ #include "v1_0/ieffect_control_vdi.h" #include "audio_uhdf_log.h" #include "osal_mem.h" +#include "osal_time.h" #include "effect_core.h" +#include "audio_dfx.h" #define HDF_LOG_TAG HDF_AUDIO_EFFECT int32_t EffectControlEffectProcess(struct IEffectControl *self, const struct AudioEffectBuffer *input, struct AudioEffectBuffer *output) { - if (self == NULL || input == NULL || output == NULL) { - HDF_LOGE("%{public}s: invailid input params", __func__); - return HDF_ERR_INVALID_PARAM; - } + CHECK_TRUE_RETURN_RET_LOG(self == NULL || input == NULL || output == NULL, HDF_ERR_INVALID_PARAM, + "%{public}s: invailid input params", __func__); struct ControllerManager *manager = (struct ControllerManager *)self; - if (manager->ctrlOps == NULL || manager->ctrlOps->EffectProcess == NULL) { - HDF_LOGE("%{public}s: controller has no options", __func__); - return HDF_FAILURE; - } + CHECK_TRUE_RETURN_RET_LOG(manager->ctrlOps == NULL || manager->ctrlOps->EffectProcess == NULL, + HDF_FAILURE, "%{public}s: controller has no options", __func__); if (strcmp(manager->libName, "libmock_effect_lib") != 0) { output->frameCount = input->frameCount; output->datatag = input->datatag; output->rawDataLen = input->rawDataLen; output->rawData = (int8_t *)OsalMemCalloc(sizeof(int8_t) * output->rawDataLen); - if (output->rawData == NULL) { - HDF_LOGE("%{public}s: OsalMemCalloc fail", __func__); - return HDF_FAILURE; - } + CHECK_TRUE_RETURN_RET_LOG(output->rawData == NULL, HDF_FAILURE, + "%{public}s: OsalMemCalloc fail", __func__); } struct AudioEffectBufferVdi *inputVdi = (struct AudioEffectBufferVdi *)input; struct AudioEffectBufferVdi *outputVdi = (struct AudioEffectBufferVdi *)output; + + OsalTimespec start; + OsalTimespec end; + OsalTimespec diff; + int res = OsalGetTime(&start); + CHECK_TRUE_RETURN_RET_LOG(HDF_SUCCESS != res, HDF_FAILURE, "OsalGetTime start failed."); + + HdfAudioStartTrace("Hdi:Audio:EffectProcess", 0); int32_t ret = manager->ctrlOps->EffectProcess(manager->ctrlOps, inputVdi, outputVdi); - if (ret != HDF_SUCCESS) { - HDF_LOGE("AudioEffectProcess failed, ret=%{public}d", ret); - return ret; - } + HdfAudioFinishTrace(); + + res = OsalGetTime(&end); + CHECK_TRUE_RETURN_RET_LOG(HDF_SUCCESS != res, HDF_FAILURE, "OsalGetTime end failed."); + + res = OsalDiffTime(&start, &end, &diff); + CHECK_TRUE_RETURN_RET_LOG(HDF_SUCCESS != res, HDF_FAILURE, "OsalDiffTime failed."); + + HDF_LOGI("EffectProcess cost time %{public}llu us", + (HDF_KILO_UNIT * HDF_KILO_UNIT) * diff.sec + diff.usec); + + CHECK_TRUE_RETURN_RET_LOG(ret != HDF_SUCCESS, ret, + "AudioEffectProcess failed, ret=%{public}d", ret); output = (struct AudioEffectBuffer *)outputVdi; return ret; @@ -85,26 +98,38 @@ int32_t EffectControlSendCommand(struct IEffectControl *self, enum EffectCommand int32_t EffectGetOwnDescriptor(struct IEffectControl *self, struct EffectControllerDescriptor *desc) { - if (self == NULL || desc == NULL) { - HDF_LOGE("%{public}s: invailid input params", __func__); - return HDF_ERR_INVALID_PARAM; - } + CHECK_TRUE_RETURN_RET_LOG(self == NULL || desc == NULL, HDF_ERR_INVALID_PARAM, + "%{public}s: invailid input params", __func__); struct ControllerManager *manager = (struct ControllerManager *)self; - if (manager->ctrlOps == NULL || manager->ctrlOps->GetEffectDescriptor == NULL) { - HDF_LOGE("%{public}s: controller has no options", __func__); - return HDF_FAILURE; - } + CHECK_TRUE_RETURN_RET_LOG(manager->ctrlOps == NULL || manager->ctrlOps->GetEffectDescriptor == NULL, + HDF_FAILURE, "%{public}s: controller has no options", __func__); + struct EffectControllerDescriptorVdi *descVdi = (struct EffectControllerDescriptorVdi *)desc; - if (ConstructDescriptor(descVdi) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: ConstructDescriptor fail!", __func__); - return HDF_FAILURE; - } + CHECK_TRUE_RETURN_RET_LOG(ConstructDescriptor(descVdi) != HDF_SUCCESS, HDF_FAILURE, + "%{public}s: ConstructDescriptor fail!", __func__); + + OsalTimespec start; + OsalTimespec end; + OsalTimespec diff; + int res = OsalGetTime(&start); + CHECK_TRUE_RETURN_RET_LOG(HDF_SUCCESS != res, HDF_FAILURE, "OsalGetTime start failed."); + + HdfAudioStartTrace("Hdi:Audio:GetEffectDescriptor", 0); int32_t ret = manager->ctrlOps->GetEffectDescriptor(manager->ctrlOps, descVdi); - if (ret != HDF_SUCCESS) { - HDF_LOGE("EffectGetOwnDescriptor failed, ret=%{public}d", ret); - return ret; - } + HdfAudioFinishTrace(); + + res = OsalGetTime(&end); + CHECK_TRUE_RETURN_RET_LOG(HDF_SUCCESS != res, HDF_FAILURE, "OsalGetTime end failed."); + + res = OsalDiffTime(&start, &end, &diff); + CHECK_TRUE_RETURN_RET_LOG(HDF_SUCCESS != res, HDF_FAILURE, "OsalDiffTime failed."); + + HDF_LOGI("GetEffectDescriptor cost time %{public}llu us", + (HDF_KILO_UNIT * HDF_KILO_UNIT) * diff.sec + diff.usec); + + CHECK_TRUE_RETURN_RET_LOG(ret != HDF_SUCCESS, ret, + "EffectGetOwnDescriptor failed, ret=%{public}d", ret); desc = (struct EffectControllerDescriptor *)descVdi; return ret; diff --git a/audio/hdi_service/primary_impl/BUILD.gn b/audio/hdi_service/primary_impl/BUILD.gn index 5ba456508b..ac854d4236 100644 --- a/audio/hdi_service/primary_impl/BUILD.gn +++ b/audio/hdi_service/primary_impl/BUILD.gn @@ -44,11 +44,12 @@ ohos_shared_library("audio_primary_impl_vendor") { "vdi_src/audio_adapter_vdi.c", "vdi_src/audio_capture_vdi.c", "vdi_src/audio_common_vdi.c", - "vdi_src/audio_dfx_vdi.cpp", "vdi_src/audio_manager_vdi.c", "vdi_src/audio_render_vdi.c", ] + deps = [ "$hdf_audio_path/audio_dfx:libaudio_dfx_static" ] + include_dirs = [ "$hdf_audio_path/interfaces/sound/v1_0", "$hdf_hdi_service_path/vendor_interface/utils", @@ -83,16 +84,6 @@ ohos_shared_library("audio_primary_impl_vendor") { external_deps += [ "bounds_checking_function:libsec_shared" ] - if (drivers_peripheral_audio_feature_hitrace_enable) { - external_deps += [ "hitrace:hitrace_meter" ] - defines += [ "AUDIO_HITRACE_ENABLE" ] - } - - if (drivers_peripheral_audio_feature_hicollie_enable) { - external_deps += [ "hicollie:libhicollie" ] - defines += [ "AUDIO_HICOLLIE_ENABLE" ] - } - install_images = [ chipset_base_dir ] subsystem_name = "hdf" part_name = "drivers_peripheral_audio" diff --git a/audio/hdi_service/primary_impl/vdi_src/audio_adapter_vdi.c b/audio/hdi_service/primary_impl/vdi_src/audio_adapter_vdi.c index c7a0448df1..1666645495 100644 --- a/audio/hdi_service/primary_impl/vdi_src/audio_adapter_vdi.c +++ b/audio/hdi_service/primary_impl/vdi_src/audio_adapter_vdi.c @@ -23,7 +23,7 @@ #include "audio_capture_vdi.h" #include "audio_common_vdi.h" #include "audio_render_vdi.h" -#include "audio_dfx_vdi.h" +#include "audio_dfx.h" #include "v4_0/iaudio_callback.h" #include "stub_collector.h" @@ -116,7 +116,11 @@ static int32_t AudioInitAllPortsVdi(struct IAudioAdapter *adapter) ret = HDF_ERR_INVALID_PARAM; goto EXIT; } + + HdfAudioStartTrace("Hdi:Audio:InitAllPorts", 0); ret = vdiAdapter->InitAllPorts(vdiAdapter); + HdfAudioFinishTrace(); + if (ret != HDF_SUCCESS) { AUDIO_FUNC_LOGE("audio vdiAdapter InitAllPorts fail, ret=%{public}d", ret); ret = HDF_FAILURE; diff --git a/audio/hdi_service/primary_impl/vdi_src/audio_capture_vdi.c b/audio/hdi_service/primary_impl/vdi_src/audio_capture_vdi.c index bcf1a6a84c..3d8bb3cfc7 100644 --- a/audio/hdi_service/primary_impl/vdi_src/audio_capture_vdi.c +++ b/audio/hdi_service/primary_impl/vdi_src/audio_capture_vdi.c @@ -21,7 +21,7 @@ #include #include "audio_uhdf_log.h" #include "audio_common_vdi.h" -#include "audio_dfx_vdi.h" +#include "audio_dfx.h" #include "stub_collector.h" #define HDF_LOG_TAG HDF_AUDIO_PRIMARY_IMPL diff --git a/audio/hdi_service/primary_impl/vdi_src/audio_manager_vdi.c b/audio/hdi_service/primary_impl/vdi_src/audio_manager_vdi.c index 329947ac9d..5e2e98330e 100644 --- a/audio/hdi_service/primary_impl/vdi_src/audio_manager_vdi.c +++ b/audio/hdi_service/primary_impl/vdi_src/audio_manager_vdi.c @@ -20,13 +20,14 @@ #include #include "audio_uhdf_log.h" #include "audio_adapter_vdi.h" -#include "audio_dfx_vdi.h" +#include "audio_dfx.h" #include "v4_0/iaudio_adapter.h" #define HDF_LOG_TAG HDF_AUDIO_PRIMARY_IMPL static int32_t THREAD_POOL_COUNT = 32; static pthread_mutex_t g_managerMutex; +void SetMaxWorkThreadNum(int32_t); typedef struct IAudioManagerVdi* (*AudioManagerCreateIfInstanceVdi)(void); struct AudioManagerPrivVdi { @@ -559,4 +560,9 @@ int32_t AudioManagerDestroyIfInstance(struct IAudioManager *manager) int32_t ret = ReleaseAudioManagerVendorObject(manager); pthread_mutex_destroy(&g_managerMutex); return ret; +} + +void SetMaxWorkThreadNum(int32_t count) +{ + OHOS::IPCSkeleton::GetInstance().SetMaxWorkThreadNum(count); } \ No newline at end of file diff --git a/audio/hdi_service/primary_impl/vdi_src/audio_render_vdi.c b/audio/hdi_service/primary_impl/vdi_src/audio_render_vdi.c index d7add3a3a4..1ccda5ed19 100644 --- a/audio/hdi_service/primary_impl/vdi_src/audio_render_vdi.c +++ b/audio/hdi_service/primary_impl/vdi_src/audio_render_vdi.c @@ -22,7 +22,7 @@ #include "osal_mem.h" #include "securec.h" #include "audio_common_vdi.h" -#include "audio_dfx_vdi.h" +#include "audio_dfx.h" #include "stub_collector.h" #define HDF_LOG_TAG HDF_AUDIO_PRIMARY_IMPL diff --git a/audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h b/audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h index c40bb5660c..40ca5e1186 100644 --- a/audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h +++ b/audio/hdi_service/vendor_interface/utils/audio_uhdf_log.h @@ -92,4 +92,16 @@ } \ } while (0) #endif + +#ifdef CHECK_TRUE_RETURN_RET_LOG +#undef CHECK_TRUE_RETURN_RET_LOG #endif +#define CHECK_TRUE_RETURN_RET_LOG(cond, ret, fmt, ...) \ + do { \ + if ((cond)) { \ + HDF_LOGE(fmt, ##__VA_ARGS__); \ + return ret; \ + } \ + } while (0) + +#endif \ No newline at end of file -- Gitee From ef05d156def96b5188ace98b4b76161cc921b3ac Mon Sep 17 00:00:00 2001 From: wangyikai Date: Sat, 29 Mar 2025 10:22:38 +0800 Subject: [PATCH 087/103] =?UTF-8?q?=E3=80=90hdf=E9=A9=B1=E5=8A=A8=E3=80=91?= =?UTF-8?q?TOP=E9=97=AE=E9=A2=98=E9=80=86=E5=90=91=E6=94=B9=E8=BF=9B,=20?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=A0=87=E5=87=86=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyikai --- audio/effect/model/src/effect_control.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/audio/effect/model/src/effect_control.c b/audio/effect/model/src/effect_control.c index 9f21faf511..c89aba0868 100644 --- a/audio/effect/model/src/effect_control.c +++ b/audio/effect/model/src/effect_control.c @@ -24,6 +24,7 @@ #include "osal_time.h" #include "effect_core.h" #include "audio_dfx.h" +#include #define HDF_LOG_TAG HDF_AUDIO_EFFECT @@ -63,7 +64,7 @@ int32_t EffectControlEffectProcess(struct IEffectControl *self, const struct Aud res = OsalDiffTime(&start, &end, &diff); CHECK_TRUE_RETURN_RET_LOG(HDF_SUCCESS != res, HDF_FAILURE, "OsalDiffTime failed."); - HDF_LOGI("EffectProcess cost time %{public}llu us", + HDF_LOGI("EffectProcess cost time %{public}" PRIu64 " us", (HDF_KILO_UNIT * HDF_KILO_UNIT) * diff.sec + diff.usec); CHECK_TRUE_RETURN_RET_LOG(ret != HDF_SUCCESS, ret, @@ -125,7 +126,7 @@ int32_t EffectGetOwnDescriptor(struct IEffectControl *self, struct EffectControl res = OsalDiffTime(&start, &end, &diff); CHECK_TRUE_RETURN_RET_LOG(HDF_SUCCESS != res, HDF_FAILURE, "OsalDiffTime failed."); - HDF_LOGI("GetEffectDescriptor cost time %{public}llu us", + HDF_LOGI("GetEffectDescriptor cost time %{public}" PRIu64 " us", (HDF_KILO_UNIT * HDF_KILO_UNIT) * diff.sec + diff.usec); CHECK_TRUE_RETURN_RET_LOG(ret != HDF_SUCCESS, ret, -- Gitee From 4df6402f146c7e7b148e42bef5c95cd7eff66350 Mon Sep 17 00:00:00 2001 From: luzhiye Date: Sat, 29 Mar 2025 15:08:21 +0800 Subject: [PATCH 088/103] =?UTF-8?q?serial=E9=83=A8=E4=BB=B6=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: luzhiye --- usb/serial/BUILD.gn | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/usb/serial/BUILD.gn b/usb/serial/BUILD.gn index 2d09aaec55..0785376d96 100644 --- a/usb/serial/BUILD.gn +++ b/usb/serial/BUILD.gn @@ -110,6 +110,15 @@ ohos_shared_library("libusbhost_acm_rawapi") { "hdf_core:libhdf_utils", "hilog:libhilog", ] + if (usb_hisysevent_enable) { + external_deps += [ "hisysevent:libhisysevent" ] + + if (defined(defines)) { + defines += [ "USB_ENABLE_HISYSEVENT" ] + } else { + defines = [ "USB_ENABLE_HISYSEVENT" ] + } + } if (usb_c_utils_enable) { external_deps += [ "c_utils:utils" ] } -- Gitee From 8e4ff5fcc80544b4d3222e17ee438baf8b05ffed Mon Sep 17 00:00:00 2001 From: huangshengqing Date: Sat, 29 Mar 2025 16:07:32 +0800 Subject: [PATCH 089/103] add lock Signed-off-by: huangshengqing --- usb/hdi_service/include/usbd_function.h | 1 + usb/hdi_service/src/usb_device_impl.cpp | 3 --- usb/hdi_service/src/usb_impl.cpp | 3 --- usb/hdi_service/src/usbd_function.cpp | 10 +++++++++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/usb/hdi_service/include/usbd_function.h b/usb/hdi_service/include/usbd_function.h index b0b44fded2..31dc3ba141 100644 --- a/usb/hdi_service/include/usbd_function.h +++ b/usb/hdi_service/include/usbd_function.h @@ -78,6 +78,7 @@ class UsbdFunction { public: UsbdFunction() = default; ~UsbdFunction() = default; + static int32_t UsbdInnerSetFunction(uint32_t funcs); static int32_t UsbdSetFunction(uint32_t funcs); static int32_t UsbdGetFunction(); static int32_t UsbdUpdateFunction(uint32_t funcs); diff --git a/usb/hdi_service/src/usb_device_impl.cpp b/usb/hdi_service/src/usb_device_impl.cpp index ad9f1158a8..118fc93c2e 100644 --- a/usb/hdi_service/src/usb_device_impl.cpp +++ b/usb/hdi_service/src/usb_device_impl.cpp @@ -90,14 +90,11 @@ int32_t UsbDeviceImpl::GetCurrentFunctions(int32_t &funcs) int32_t UsbDeviceImpl::SetCurrentFunctions(int32_t funcs) { HDF_LOGI("%{public}s: enter", __func__); - OsalMutexLock(&lockSetFunc_); int32_t ret = V1_2::UsbdFunction::UsbdSetFunction(funcs); if (ret != HDF_SUCCESS) { HDF_LOGE("%{public}s:UsbdSetFunction failed, ret:%{public}d", __func__, ret); - OsalMutexUnlock(&lockSetFunc_); return ret; } - OsalMutexUnlock(&lockSetFunc_); return HDF_SUCCESS; } diff --git a/usb/hdi_service/src/usb_impl.cpp b/usb/hdi_service/src/usb_impl.cpp index 324124cf73..d06e0d07a1 100644 --- a/usb/hdi_service/src/usb_impl.cpp +++ b/usb/hdi_service/src/usb_impl.cpp @@ -2194,14 +2194,11 @@ int32_t UsbImpl::GetCurrentFunctions(int32_t &funcs) int32_t UsbImpl::SetCurrentFunctions(int32_t funcs) { - OsalMutexLock(&lock_); int32_t ret = UsbdFunction::UsbdSetFunction(funcs); if (ret != HDF_SUCCESS) { HDF_LOGE("%{public}s:UsbdSetFunction failed, ret:%{public}d", __func__, ret); - OsalMutexUnlock(&lock_); return ret; } - OsalMutexUnlock(&lock_); return HDF_SUCCESS; } diff --git a/usb/hdi_service/src/usbd_function.cpp b/usb/hdi_service/src/usbd_function.cpp index fa9c539961..376cf43afe 100644 --- a/usb/hdi_service/src/usbd_function.cpp +++ b/usb/hdi_service/src/usbd_function.cpp @@ -584,7 +584,7 @@ int32_t UsbdFunction::UsbdSetKernelFunction(int32_t kfuns, int32_t funcs) } } -int32_t UsbdFunction::UsbdSetFunction(uint32_t funcs) +int32_t UsbdInnerSetFunction(uint32_t funcs); { HDF_LOGI("%{public}s: UsbdSetFunction funcs=%{public}d", __func__, funcs); if ((funcs | USB_FUNCTION_SUPPORT) != USB_FUNCTION_SUPPORT) { @@ -636,6 +636,14 @@ int32_t UsbdFunction::UsbdSetFunction(uint32_t funcs) return HDF_SUCCESS; } +int32_t UsbdFunction::UsbdSetFunction(uint32_t funcs) +{ + OsalMutexLock(&lock_); + int ret = UsbdInnerSetFunction(funcs); + OsalMutexUnLock(&lock_); + return ret; +} + int32_t UsbdFunction::UsbdGetFunction(void) { return currentFuncs_; -- Gitee From 3f8d194331748df79d52ad3c8333c933723a3b33 Mon Sep 17 00:00:00 2001 From: huangshengqing Date: Sat, 29 Mar 2025 17:09:31 +0800 Subject: [PATCH 090/103] add Signed-off-by: huangshengqing --- usb/hdi_service/include/usbd_function.h | 1 + usb/hdi_service/src/usbd_function.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/usb/hdi_service/include/usbd_function.h b/usb/hdi_service/include/usbd_function.h index 31dc3ba141..c650eb2eaa 100644 --- a/usb/hdi_service/include/usbd_function.h +++ b/usb/hdi_service/include/usbd_function.h @@ -110,6 +110,7 @@ private: static int32_t ReleaseMtp(); static uint32_t currentFuncs_; + OsalMutex setFunctionLock_; }; } // namespace V1_2 } // namespace Usb diff --git a/usb/hdi_service/src/usbd_function.cpp b/usb/hdi_service/src/usbd_function.cpp index 376cf43afe..ab082764d4 100644 --- a/usb/hdi_service/src/usbd_function.cpp +++ b/usb/hdi_service/src/usbd_function.cpp @@ -584,7 +584,7 @@ int32_t UsbdFunction::UsbdSetKernelFunction(int32_t kfuns, int32_t funcs) } } -int32_t UsbdInnerSetFunction(uint32_t funcs); +int32_t UsbdInnerSetFunction(uint32_t funcs) { HDF_LOGI("%{public}s: UsbdSetFunction funcs=%{public}d", __func__, funcs); if ((funcs | USB_FUNCTION_SUPPORT) != USB_FUNCTION_SUPPORT) { @@ -638,9 +638,9 @@ int32_t UsbdInnerSetFunction(uint32_t funcs); int32_t UsbdFunction::UsbdSetFunction(uint32_t funcs) { - OsalMutexLock(&lock_); + OsalMutexLock(&setFunctionLock_); int ret = UsbdInnerSetFunction(funcs); - OsalMutexUnLock(&lock_); + OsalMutexUnLock(&setFunctionLock_); return ret; } -- Gitee From 51f8de231719ff52bb9a8966618bc023e68888ee Mon Sep 17 00:00:00 2001 From: huangshengqing Date: Sat, 29 Mar 2025 17:34:24 +0800 Subject: [PATCH 091/103] add Signed-off-by: huangshengqing --- usb/hdi_service/include/usbd_function.h | 2 ++ usb/hdi_service/src/usb_device_impl.cpp | 6 ++++-- usb/hdi_service/src/usbd_function.cpp | 10 ++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/usb/hdi_service/include/usbd_function.h b/usb/hdi_service/include/usbd_function.h index c650eb2eaa..62b61b2415 100644 --- a/usb/hdi_service/include/usbd_function.h +++ b/usb/hdi_service/include/usbd_function.h @@ -78,6 +78,8 @@ class UsbdFunction { public: UsbdFunction() = default; ~UsbdFunction() = default; + void UsbdInitLock(); + void UsbdDestroyLock(); static int32_t UsbdInnerSetFunction(uint32_t funcs); static int32_t UsbdSetFunction(uint32_t funcs); static int32_t UsbdGetFunction(); diff --git a/usb/hdi_service/src/usb_device_impl.cpp b/usb/hdi_service/src/usb_device_impl.cpp index 118fc93c2e..822cb619e2 100644 --- a/usb/hdi_service/src/usb_device_impl.cpp +++ b/usb/hdi_service/src/usb_device_impl.cpp @@ -69,7 +69,8 @@ extern "C" IUsbDeviceInterface *UsbDeviceInterfaceImplGetInstance(void) UsbDeviceImpl::UsbDeviceImpl() { - OsalMutexInit(&lockSetFunc_); + V1_2::UsbdFunction::UsbdInitLock(); + // OsalMutexInit(&lockSetFunc_); if (OHOS::system::GetBoolParameter("const.security.developermode.state", true)) { loadUsbService_.LoadService(); } @@ -77,7 +78,8 @@ UsbDeviceImpl::UsbDeviceImpl() UsbDeviceImpl::~UsbDeviceImpl() { - OsalMutexDestroy(&lockSetFunc_); + V1_2::UsbdFunction::UsbdDestroyLock(); + // OsalMutexDestroy(&lockSetFunc_); } int32_t UsbDeviceImpl::GetCurrentFunctions(int32_t &funcs) diff --git a/usb/hdi_service/src/usbd_function.cpp b/usb/hdi_service/src/usbd_function.cpp index ab082764d4..716b2d32e2 100644 --- a/usb/hdi_service/src/usbd_function.cpp +++ b/usb/hdi_service/src/usbd_function.cpp @@ -584,6 +584,16 @@ int32_t UsbdFunction::UsbdSetKernelFunction(int32_t kfuns, int32_t funcs) } } +void UsbdInitLock() +{ + OsalMutexInit(setFunctionLock_); +} + +void UsbdDestroyLock() +{ + OsalMutexDestroy(setFunctionLock_); +} + int32_t UsbdInnerSetFunction(uint32_t funcs) { HDF_LOGI("%{public}s: UsbdSetFunction funcs=%{public}d", __func__, funcs); -- Gitee From 8631af0d2e8b7dbca94b536a18eba5f64c47c60f Mon Sep 17 00:00:00 2001 From: huangshengqing Date: Mon, 31 Mar 2025 10:48:11 +0800 Subject: [PATCH 092/103] new Signed-off-by: huangshengqing --- usb/hdi_service/include/usb_device_impl.h | 1 - usb/hdi_service/include/usbd_function.h | 6 +++--- usb/hdi_service/src/usbd_function.cpp | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/usb/hdi_service/include/usb_device_impl.h b/usb/hdi_service/include/usb_device_impl.h index 84ef80f97f..6e04758497 100644 --- a/usb/hdi_service/include/usb_device_impl.h +++ b/usb/hdi_service/include/usb_device_impl.h @@ -67,7 +67,6 @@ private: static HdfDevEventlistener listenerForLoadService_; static V1_2::UsbdLoadService loadUsbService_; static V1_2::UsbdLoadService loadHdfEdm_; - OsalMutex lockSetFunc_; }; } // namespace v2_0 } // namespace Usb diff --git a/usb/hdi_service/include/usbd_function.h b/usb/hdi_service/include/usbd_function.h index 62b61b2415..1140ab0f10 100644 --- a/usb/hdi_service/include/usbd_function.h +++ b/usb/hdi_service/include/usbd_function.h @@ -78,8 +78,8 @@ class UsbdFunction { public: UsbdFunction() = default; ~UsbdFunction() = default; - void UsbdInitLock(); - void UsbdDestroyLock(); + static void UsbdInitLock(); + static void UsbdDestroyLock(); static int32_t UsbdInnerSetFunction(uint32_t funcs); static int32_t UsbdSetFunction(uint32_t funcs); static int32_t UsbdGetFunction(); @@ -112,7 +112,7 @@ private: static int32_t ReleaseMtp(); static uint32_t currentFuncs_; - OsalMutex setFunctionLock_; + static OsalMutex setFunctionLock_; }; } // namespace V1_2 } // namespace Usb diff --git a/usb/hdi_service/src/usbd_function.cpp b/usb/hdi_service/src/usbd_function.cpp index 716b2d32e2..a21a723981 100644 --- a/usb/hdi_service/src/usbd_function.cpp +++ b/usb/hdi_service/src/usbd_function.cpp @@ -649,7 +649,7 @@ int32_t UsbdInnerSetFunction(uint32_t funcs) int32_t UsbdFunction::UsbdSetFunction(uint32_t funcs) { OsalMutexLock(&setFunctionLock_); - int ret = UsbdInnerSetFunction(funcs); + int32_t ret = UsbdInnerSetFunction(funcs); OsalMutexUnLock(&setFunctionLock_); return ret; } -- Gitee From f12073298ab01d3d71ed6e0cc06323b3acb028bd Mon Sep 17 00:00:00 2001 From: huangshengqing Date: Mon, 31 Mar 2025 10:54:09 +0800 Subject: [PATCH 093/103] c Signed-off-by: huangshengqing --- usb/hdi_service/include/usbd_function.h | 6 +++--- usb/hdi_service/src/usb_device_impl.cpp | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/usb/hdi_service/include/usbd_function.h b/usb/hdi_service/include/usbd_function.h index 1140ab0f10..cddd31ca81 100644 --- a/usb/hdi_service/include/usbd_function.h +++ b/usb/hdi_service/include/usbd_function.h @@ -78,9 +78,6 @@ class UsbdFunction { public: UsbdFunction() = default; ~UsbdFunction() = default; - static void UsbdInitLock(); - static void UsbdDestroyLock(); - static int32_t UsbdInnerSetFunction(uint32_t funcs); static int32_t UsbdSetFunction(uint32_t funcs); static int32_t UsbdGetFunction(); static int32_t UsbdUpdateFunction(uint32_t funcs); @@ -110,6 +107,9 @@ private: static int32_t UsbdRegisterDevice(const std::string &serviceName); static int32_t InitMtp(); static int32_t ReleaseMtp(); + static void UsbdInitLock(); + static void UsbdDestroyLock(); + static int32_t UsbdInnerSetFunction(uint32_t funcs); static uint32_t currentFuncs_; static OsalMutex setFunctionLock_; diff --git a/usb/hdi_service/src/usb_device_impl.cpp b/usb/hdi_service/src/usb_device_impl.cpp index 822cb619e2..02adbd29e8 100644 --- a/usb/hdi_service/src/usb_device_impl.cpp +++ b/usb/hdi_service/src/usb_device_impl.cpp @@ -70,7 +70,6 @@ extern "C" IUsbDeviceInterface *UsbDeviceInterfaceImplGetInstance(void) UsbDeviceImpl::UsbDeviceImpl() { V1_2::UsbdFunction::UsbdInitLock(); - // OsalMutexInit(&lockSetFunc_); if (OHOS::system::GetBoolParameter("const.security.developermode.state", true)) { loadUsbService_.LoadService(); } @@ -79,7 +78,6 @@ UsbDeviceImpl::UsbDeviceImpl() UsbDeviceImpl::~UsbDeviceImpl() { V1_2::UsbdFunction::UsbdDestroyLock(); - // OsalMutexDestroy(&lockSetFunc_); } int32_t UsbDeviceImpl::GetCurrentFunctions(int32_t &funcs) -- Gitee From d8d19fa521d5f17c58e73cd2ff8565d7fa5531e0 Mon Sep 17 00:00:00 2001 From: huangshengqing Date: Mon, 31 Mar 2025 10:57:51 +0800 Subject: [PATCH 094/103] b Signed-off-by: huangshengqing --- usb/hdi_service/src/usb_impl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usb/hdi_service/src/usb_impl.cpp b/usb/hdi_service/src/usb_impl.cpp index d06e0d07a1..193c37f878 100644 --- a/usb/hdi_service/src/usb_impl.cpp +++ b/usb/hdi_service/src/usb_impl.cpp @@ -96,7 +96,7 @@ extern "C" IUsbInterface *UsbInterfaceImplGetInstance(void) UsbImpl::UsbImpl() : session_(nullptr), device_(nullptr) { HdfSListInit(&devList_); - OsalMutexInit(&lock_); + V1_2::UsbdFunction::UsbdInitLock(); if (OHOS::system::GetBoolParameter("const.security.developermode.state", true)) { loadUsbService_.LoadService(); } @@ -104,6 +104,7 @@ UsbImpl::UsbImpl() : session_(nullptr), device_(nullptr) UsbImpl::~UsbImpl() { + V1_2::UsbdFunction::UsbdDestroyLock(); UsbdReleaseDevices(); } -- Gitee From 2e6f0c8d777b567ef44fed3694c6b1de8dbc5183 Mon Sep 17 00:00:00 2001 From: huangshengqing Date: Mon, 31 Mar 2025 11:03:48 +0800 Subject: [PATCH 095/103] d Signed-off-by: huangshengqing --- usb/hdi_service/include/usbd_function.h | 4 ++-- usb/hdi_service/src/usb_impl.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/usb/hdi_service/include/usbd_function.h b/usb/hdi_service/include/usbd_function.h index cddd31ca81..5361fdca5d 100644 --- a/usb/hdi_service/include/usbd_function.h +++ b/usb/hdi_service/include/usbd_function.h @@ -78,6 +78,8 @@ class UsbdFunction { public: UsbdFunction() = default; ~UsbdFunction() = default; + static void UsbdInitLock(); + static void UsbdDestroyLock(); static int32_t UsbdSetFunction(uint32_t funcs); static int32_t UsbdGetFunction(); static int32_t UsbdUpdateFunction(uint32_t funcs); @@ -107,8 +109,6 @@ private: static int32_t UsbdRegisterDevice(const std::string &serviceName); static int32_t InitMtp(); static int32_t ReleaseMtp(); - static void UsbdInitLock(); - static void UsbdDestroyLock(); static int32_t UsbdInnerSetFunction(uint32_t funcs); static uint32_t currentFuncs_; diff --git a/usb/hdi_service/src/usb_impl.cpp b/usb/hdi_service/src/usb_impl.cpp index 193c37f878..bf3227c8ae 100644 --- a/usb/hdi_service/src/usb_impl.cpp +++ b/usb/hdi_service/src/usb_impl.cpp @@ -96,6 +96,7 @@ extern "C" IUsbInterface *UsbInterfaceImplGetInstance(void) UsbImpl::UsbImpl() : session_(nullptr), device_(nullptr) { HdfSListInit(&devList_); + OsalMutexInit(&lock_); V1_2::UsbdFunction::UsbdInitLock(); if (OHOS::system::GetBoolParameter("const.security.developermode.state", true)) { loadUsbService_.LoadService(); -- Gitee From 37745544a821319f826416379b7d98072945191a Mon Sep 17 00:00:00 2001 From: huangshengqing Date: Mon, 31 Mar 2025 11:57:25 +0800 Subject: [PATCH 096/103] e Signed-off-by: huangshengqing --- usb/hdi_service/include/usbd_function.h | 2 ++ usb/hdi_service/src/usbd_function.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/usb/hdi_service/include/usbd_function.h b/usb/hdi_service/include/usbd_function.h index 5361fdca5d..be8e67f1a0 100644 --- a/usb/hdi_service/include/usbd_function.h +++ b/usb/hdi_service/include/usbd_function.h @@ -19,6 +19,8 @@ #include #include +#include "osal_mutex.h" + #define USB_FUNCTION_NONE 0 #define USB_FUNCTION_ACM (1 << 0) #define USB_FUNCTION_ECM (1 << 1) diff --git a/usb/hdi_service/src/usbd_function.cpp b/usb/hdi_service/src/usbd_function.cpp index a21a723981..75c7e8955a 100644 --- a/usb/hdi_service/src/usbd_function.cpp +++ b/usb/hdi_service/src/usbd_function.cpp @@ -584,17 +584,17 @@ int32_t UsbdFunction::UsbdSetKernelFunction(int32_t kfuns, int32_t funcs) } } -void UsbdInitLock() +void UsbdFunction::UsbdInitLock() { - OsalMutexInit(setFunctionLock_); + OsalMutexInit(&setFunctionLock_); } -void UsbdDestroyLock() +void UsbdFunction::UsbdDestroyLock() { - OsalMutexDestroy(setFunctionLock_); + OsalMutexDestroy(&setFunctionLock_); } -int32_t UsbdInnerSetFunction(uint32_t funcs) +int32_t UsbdFunction::UsbdInnerSetFunction(uint32_t funcs) { HDF_LOGI("%{public}s: UsbdSetFunction funcs=%{public}d", __func__, funcs); if ((funcs | USB_FUNCTION_SUPPORT) != USB_FUNCTION_SUPPORT) { -- Gitee From 2a4f7a4d00d2b3a18924d2662280796faa13f770 Mon Sep 17 00:00:00 2001 From: huangshengqing Date: Mon, 31 Mar 2025 12:23:37 +0800 Subject: [PATCH 097/103] f Signed-off-by: huangshengqing --- usb/hdi_service/src/usbd_function.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/usb/hdi_service/src/usbd_function.cpp b/usb/hdi_service/src/usbd_function.cpp index 75c7e8955a..746203f7c7 100644 --- a/usb/hdi_service/src/usbd_function.cpp +++ b/usb/hdi_service/src/usbd_function.cpp @@ -56,6 +56,7 @@ static std::string MTP_PTP_SERVICE_NAME {"usbfn_mtp_interface_service"}; static void *g_libHandle = nullptr; static GetMtpImplFunc g_getMtpImpl = nullptr; +OsalMutex UsbdFunction::setFunctionLock_; static void InitGetMtpImpl() { -- Gitee From 6a85ae0e62f13491180303ab5def77712404bc0d Mon Sep 17 00:00:00 2001 From: huangshengqing Date: Mon, 31 Mar 2025 04:51:25 +0000 Subject: [PATCH 098/103] update usb/hdi_service/src/usbd_function.cpp. Signed-off-by: huangshengqing --- usb/hdi_service/src/usbd_function.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usb/hdi_service/src/usbd_function.cpp b/usb/hdi_service/src/usbd_function.cpp index 746203f7c7..e278c57df2 100644 --- a/usb/hdi_service/src/usbd_function.cpp +++ b/usb/hdi_service/src/usbd_function.cpp @@ -651,7 +651,7 @@ int32_t UsbdFunction::UsbdSetFunction(uint32_t funcs) { OsalMutexLock(&setFunctionLock_); int32_t ret = UsbdInnerSetFunction(funcs); - OsalMutexUnLock(&setFunctionLock_); + OsalMutexUnlock(&setFunctionLock_); return ret; } -- Gitee From 60d01b253b0345d6ebe2b6eed971c971f6a3b09c Mon Sep 17 00:00:00 2001 From: yanghang Date: Mon, 31 Mar 2025 14:22:09 +0800 Subject: [PATCH 099/103] fix: Optimize log volume Signed-off-by: yanghang --- power/interfaces/hdi_service/src/power_interface_impl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/power/interfaces/hdi_service/src/power_interface_impl.cpp b/power/interfaces/hdi_service/src/power_interface_impl.cpp index 92e0f8668a..c4acde0fc9 100644 --- a/power/interfaces/hdi_service/src/power_interface_impl.cpp +++ b/power/interfaces/hdi_service/src/power_interface_impl.cpp @@ -469,7 +469,7 @@ int32_t PowerInterfaceImpl::HoldRunningLockExt(const RunningLockInfo &info, uint64_t lockid, const std::string &bundleName) { // Background runningLock active - HDF_LOGI("BL active,T=%{public}d,N=%{public}s", info.type, info.name.c_str()); + HDF_LOGI("BL active,T=%{public}d", info.type); Power::PowerXCollie powerXcollie("Power_HoldRunningLockExt"); return RunningLockImpl::HoldLock(info, g_powerState, lockid, bundleName); } @@ -478,7 +478,7 @@ int32_t PowerInterfaceImpl::UnholdRunningLockExt(const RunningLockInfo &info, uint64_t lockid, const std::string &bundleName) { // Background runningLock inactive - HDF_LOGI("BL inactive,T=%{public}d,N=%{public}s", info.type, info.name.c_str()); + HDF_LOGI("BL inactive,T=%{public}d", info.type); Power::PowerXCollie powerXcollie("Power_UnholdRunningLockExt"); return RunningLockImpl::UnholdLock(info, lockid, bundleName); } -- Gitee From dd904a3c8bebfc4a51cfb871054be90f5c948213 Mon Sep 17 00:00:00 2001 From: l60050612 Date: Mon, 31 Mar 2025 15:05:13 +0800 Subject: [PATCH 100/103] =?UTF-8?q?drivers=5Fperipheral=20tdd=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l60050612 --- .../test/fuzztest/audio_hdi_fuzzer/audiorender_fuzzer/BUILD.gn | 2 +- audio/test/unittest/common/BUILD.gn | 2 +- display/buffer/test/benchmarktest/BUILD.gn | 2 +- display/buffer/test/moduletest/BUILD.gn | 2 +- display/composer/test/moduletest/BUILD.gn | 2 +- vibrator/test/benchmarktest/BUILD.gn | 2 +- vibrator/test/unittest/hdi/BUILD.gn | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/audio/test/fuzztest/audio_hdi_fuzzer/audiorender_fuzzer/BUILD.gn b/audio/test/fuzztest/audio_hdi_fuzzer/audiorender_fuzzer/BUILD.gn index 317ab795c6..31b716312d 100644 --- a/audio/test/fuzztest/audio_hdi_fuzzer/audiorender_fuzzer/BUILD.gn +++ b/audio/test/fuzztest/audio_hdi_fuzzer/audiorender_fuzzer/BUILD.gn @@ -18,7 +18,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("./../../../../audio.gni") -module_output_path = "drivers_peripheral_audio/audio" +module_output_path = "drivers_peripheral_audio/drivers_peripheral_audio" ohos_fuzztest("AudioRenderFuzzTest") { module_out_path = module_output_path diff --git a/audio/test/unittest/common/BUILD.gn b/audio/test/unittest/common/BUILD.gn index 35209a7fca..72f7ebf2d0 100644 --- a/audio/test/unittest/common/BUILD.gn +++ b/audio/test/unittest/common/BUILD.gn @@ -15,7 +15,7 @@ import("//build/test.gni") import("./../../../audio.gni") ohos_unittest("audio_ut_common_test") { - module_out_path = "drivers_peripheral_audio/audio" + module_out_path = "drivers_peripheral_audio/drivers_peripheral_audio" sources = [ "adapter/audio_adapter_common_test.cpp", "capture/audio_capture_common_test.cpp", diff --git a/display/buffer/test/benchmarktest/BUILD.gn b/display/buffer/test/benchmarktest/BUILD.gn index d804dc80f1..763c1f576c 100644 --- a/display/buffer/test/benchmarktest/BUILD.gn +++ b/display/buffer/test/benchmarktest/BUILD.gn @@ -14,7 +14,7 @@ import("//build/ohos.gni") import("//build/test.gni") -module_output_path = "drivers_peripheral_display/display" +module_output_path = "drivers_peripheral_display/drivers_peripheral_display" ohos_benchmarktest("hdf_display_buffer_benchmarktest") { module_out_path = module_output_path diff --git a/display/buffer/test/moduletest/BUILD.gn b/display/buffer/test/moduletest/BUILD.gn index b46e9c440a..1c7b33c164 100644 --- a/display/buffer/test/moduletest/BUILD.gn +++ b/display/buffer/test/moduletest/BUILD.gn @@ -14,7 +14,7 @@ import("//build/test.gni") import("./../../../display_config.gni") -module_output_path = "drivers_peripheral_display/buffer" +module_output_path = "drivers_peripheral_display/drivers_peripheral_display" ohos_moduletest("hdf_disp_buffer_moduletest") { defines = [] diff --git a/display/composer/test/moduletest/BUILD.gn b/display/composer/test/moduletest/BUILD.gn index a9609e3842..719b5e1aa1 100644 --- a/display/composer/test/moduletest/BUILD.gn +++ b/display/composer/test/moduletest/BUILD.gn @@ -19,7 +19,7 @@ group("hdf_disp_composer_moduletest") { deps = [ ":composer_mt" ] } -module_output_path = "drivers_peripheral_display/composer" +module_output_path = "drivers_peripheral_display/drivers_peripheral_display" config("module_private_config") { visibility = [ ":*" ] diff --git a/vibrator/test/benchmarktest/BUILD.gn b/vibrator/test/benchmarktest/BUILD.gn index de7c572c6b..ec98a02b02 100644 --- a/vibrator/test/benchmarktest/BUILD.gn +++ b/vibrator/test/benchmarktest/BUILD.gn @@ -16,7 +16,7 @@ import("//build/ohos_var.gni") import("//build/test.gni") import("../../vibrator.gni") -module_output_path = "drivers_peripheral_vibrator/vibrator" +module_output_path = "drivers_peripheral_vibrator/drivers_peripheral_vibrator" ohos_benchmarktest("hdf_vibrator_benchmark_test") { module_out_path = module_output_path include_dirs = [] diff --git a/vibrator/test/unittest/hdi/BUILD.gn b/vibrator/test/unittest/hdi/BUILD.gn index f3607717bd..ca19cdf534 100644 --- a/vibrator/test/unittest/hdi/BUILD.gn +++ b/vibrator/test/unittest/hdi/BUILD.gn @@ -49,7 +49,7 @@ ohos_unittest("hdf_unittest_hdi_vibrator") { } ohos_unittest("hdi_unittest_vibrator") { - module_out_path = "drivers_peripheral_vibrator/vibrator" + module_out_path = "drivers_peripheral_vibrator/drivers_peripheral_vibrator" include_dirs = [ "../../../interfaces/include", "../../../utils/include", -- Gitee From 1e51813ea8c2ed0a7865c9a7e0f0f5c2d49bd41e Mon Sep 17 00:00:00 2001 From: shilong Date: Mon, 31 Mar 2025 08:58:42 +0000 Subject: [PATCH 101/103] =?UTF-8?q?tdd=E7=94=A8=E4=BE=8B=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shilong --- input/test/benchmarktest/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input/test/benchmarktest/BUILD.gn b/input/test/benchmarktest/BUILD.gn index 91a25514d9..938673c970 100644 --- a/input/test/benchmarktest/BUILD.gn +++ b/input/test/benchmarktest/BUILD.gn @@ -17,7 +17,7 @@ import("//build/test.gni") INPUT_ROOT_DIR = "./../.." ohos_benchmarktest("hdf_input_benchmark_test") { - module_out_path = "drivers_peripheral_input/input" + module_out_path = "drivers_peripheral_input/drivers_peripheral_input" include_dirs = [ "$INPUT_ROOT_DIR/hdi_service", "$INPUT_ROOT_DIR/interfaces/include", -- Gitee From 2ba56236600d357cd4d89234c0c46b2e5176f1d7 Mon Sep 17 00:00:00 2001 From: chen0088 Date: Mon, 31 Mar 2025 15:07:39 +0800 Subject: [PATCH 102/103] =?UTF-8?q?=E6=B7=BB=E5=8A=A0fuzz=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E9=98=B2=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chen0088 --- .../src/dcamera_device/dmetadata_processor.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/distributed_camera/hdi_service/src/dcamera_device/dmetadata_processor.cpp b/distributed_camera/hdi_service/src/dcamera_device/dmetadata_processor.cpp index 807d05adec..996ff2d5da 100644 --- a/distributed_camera/hdi_service/src/dcamera_device/dmetadata_processor.cpp +++ b/distributed_camera/hdi_service/src/dcamera_device/dmetadata_processor.cpp @@ -325,16 +325,20 @@ DCamRetCode DMetadataProcessor::InitDCameraOutputAbilityKeys(const std::string & void DMetadataProcessor::UpdateAbilityTag(std::vector &streamConfigs, std::vector &extendStreamConfigs) { - UpdateAbilityEntry(OHOS_ABILITY_STREAM_AVAILABLE_BASIC_CONFIGURATIONS, streamConfigs.data(), + int32_t ret = UpdateAbilityEntry(OHOS_ABILITY_STREAM_AVAILABLE_BASIC_CONFIGURATIONS, streamConfigs.data(), streamConfigs.size()); - UpdateAbilityEntry(OHOS_ABILITY_STREAM_AVAILABLE_EXTEND_CONFIGURATIONS, extendStreamConfigs.data(), + ret &= UpdateAbilityEntry(OHOS_ABILITY_STREAM_AVAILABLE_EXTEND_CONFIGURATIONS, extendStreamConfigs.data(), extendStreamConfigs.size()); - UpdateAbilityEntry(OHOS_SENSOR_INFO_MAX_FRAME_DURATION, &MAX_FRAME_DURATION, 1); + ret &= UpdateAbilityEntry(OHOS_SENSOR_INFO_MAX_FRAME_DURATION, &MAX_FRAME_DURATION, 1); const int32_t jpegMaxSize = maxPhotoResolution_.width_ * maxPhotoResolution_.height_; - UpdateAbilityEntry(OHOS_JPEG_MAX_SIZE, &jpegMaxSize, 1); + ret &= UpdateAbilityEntry(OHOS_JPEG_MAX_SIZE, &jpegMaxSize, 1); + if (ret == FAILED) { + DHLOGE("UpdateAbilityTag failed."); + return; + } const uint8_t connectionType = OHOS_CAMERA_CONNECTION_TYPE_REMOTE; UpdateAbilityEntry(OHOS_ABILITY_CAMERA_CONNECTION_TYPE, &connectionType, 1); @@ -442,6 +446,8 @@ DCamRetCode DMetadataProcessor::UpdateAbilityEntry(uint32_t tag, const void *dat DHLOGE("Update tag %{public}u failed.", tag); return FAILED; } + } else { + return FAILED; } return SUCCESS; } -- Gitee From 1d06275cd27794c9578f5977f71f8de99e105dce Mon Sep 17 00:00:00 2001 From: wenjunhu_28fe Date: Mon, 7 Apr 2025 06:27:31 -0700 Subject: [PATCH 103/103] bme688 fix code qulaity issue. Signed-off-by: wenjunhu_28fe --- sensor/chipset/gas/gas_bme688_driver.c | 283 +++++++++++++++++-------- sensor/chipset/gas/gas_bme688_driver.h | 10 + 2 files changed, 204 insertions(+), 89 deletions(-) diff --git a/sensor/chipset/gas/gas_bme688_driver.c b/sensor/chipset/gas/gas_bme688_driver.c index 73a2bd9f69..33bcbfe002 100644 --- a/sensor/chipset/gas/gas_bme688_driver.c +++ b/sensor/chipset/gas/gas_bme688_driver.c @@ -100,14 +100,14 @@ static int32_t BmeHalRegWriteOneByte(struct SensorCfgData *data, uint8_t rega, u g_regw_buffer[0] = (rega & 0xFF); do { g_regw_buffer[index + 1] = buffer; - index++; + index ++; } while (index < len); rc = WriteSensor(&data->busCfg, g_regw_buffer, (len + 1)); OsalUDelay(BME688_DELAY_10); if (rc != HDF_SUCCESS) { - HDF_LOGE("%s: [BME688] w reg:%d err", __func__, rega); + HDF_LOGE("%s: [BME688] w reg:%d err:%d", __func__, rega, rc); } return rc; @@ -128,7 +128,7 @@ static int32_t BmeHalRegWriteMulByte(struct SensorCfgData *data, uint8_t *rega, do { rc = BmeHalRegWriteOneByte(data, rega[index], buffer[index]); - index++; + index ++; } while (index < len); return rc; @@ -159,6 +159,9 @@ static int32_t Bme688HalReadSensorRawData(struct SensorCfgData *data, struct Gas uint8_t opMode = 0; int32_t ret = HDF_SUCCESS; + CHECK_NULL_PTR_RETURN_VALUE(data, HDF_ERR_INVALID_PARAM); + CHECK_NULL_PTR_RETURN_VALUE(rawData, HDF_ERR_INVALID_PARAM); + ret = Bme688GetOpMode(data, &opMode); if ((opMode & BME68X_MODE_MSK) == BME68X_SLEEP_MODE) { ret = Bme688GetData(data, &fieldData, BME68X_FORCED_MODE); @@ -192,22 +195,22 @@ static int32_t Bme688HalReadSensorRawData(struct SensorCfgData *data, struct Gas /// @brief basic register write function /// @param data Sensor configuration data structre pointer -/// @param rega register address -/// @param buffer value to write -/// @param len write len -/// @return HDF_SUCCESS if success, failed any error +/// @param rawData The raw data buffer need to read +/// @param timestamp timestamp when reading data +/// @return HDF_SUCCESS if success, failed any others error static int32_t ReadBme688RawData(struct SensorCfgData *data, struct GasData *rawData, int64_t *timestamp) { OsalTimespec time; uint8_t regv[GAS_PART_SUM] = {0}; int32_t ret = HDF_SUCCESS; - struct GasFieldData fieldData = { 0 }; struct GasCfg conf; struct bme688HeatrConf heatConf; (void)memset_s(&time, sizeof(time), 0, sizeof(time)); (void)memset_s(regv, sizeof(regv), 0, sizeof(regv)); CHECK_NULL_PTR_RETURN_VALUE(data, HDF_ERR_INVALID_PARAM); + CHECK_NULL_PTR_RETURN_VALUE(rawData, HDF_ERR_INVALID_PARAM); + CHECK_NULL_PTR_RETURN_VALUE(timestamp, HDF_ERR_INVALID_PARAM); if (OsalGetTime(&time) != HDF_SUCCESS) { HDF_LOGE("%s: Get time failed", __func__); @@ -240,7 +243,7 @@ static int32_t ReadBme688RawData(struct SensorCfgData *data, struct GasData *raw ret = Bme688SetOpMode(data, BME68X_FORCED_MODE); g_bme688State.workState = BME688_WORK_MODE_IDLE; } - + if (g_bme688State.workState == BME688_WORK_MODE_IDLE) { ret = Bme688HalReadSensorRawData(data, rawData); } @@ -251,9 +254,9 @@ static int32_t ReadBme688RawData(struct SensorCfgData *data, struct GasData *raw /* read bme688 sensor data */ static int32_t ReadBme688Data(struct SensorCfgData *cfg, struct SensorReportEvent *event) { - int32_t ret; + int32_t ret = HDF_SUCCESS; struct GasData rawData = {0}; - static int16_t tmp[GAS_DEP_PART_SUM]; + static int16_t tmp[GAS_DEP_PART_SUM] = {0}; CHECK_NULL_PTR_RETURN_VALUE(cfg, HDF_ERR_INVALID_PARAM); CHECK_NULL_PTR_RETURN_VALUE(event, HDF_ERR_INVALID_PARAM); @@ -298,8 +301,8 @@ static int32_t Bme688SoftReset(struct SensorCfgData *data) HDF_LOGE("%s: bme688 write command register failed", __func__); return HDF_FAILURE; } - // delay 5ms after reset - OsalMDelay(BME688_DELAY_5); + + OsalMDelay(BME688_DELAY_5); /* delay 5ms after reset */ return rc; } @@ -338,6 +341,7 @@ static int32_t Bme688ReadVariantId(struct SensorCfgData *data) } HDF_LOGI("%s: rc = %d, regv = 0x%x", __func__, rc, regv); g_bme688State.variantId = regv; + return rc; } @@ -440,7 +444,7 @@ static int32_t Bme688GetOpMode(struct SensorCfgData *data, uint8_t *opMode) static int32_t Bme688SetOpMode(struct SensorCfgData *data, const uint8_t opMode) { int32_t rc; - uint8_t tmpPowMode; + uint8_t tmpPowMode = 0; uint8_t powMode = 0; uint8_t regAddr = BME68X_REG_CTRL_MEAS; @@ -641,7 +645,7 @@ static uint8_t BmeHalCalcResHeat(struct SensorCfgData *data, uint16_t temp) static uint8_t BmeHalCalcGasWait(uint16_t dur) { uint8_t factor = 0; - uint8_t durVal; + uint8_t durVal = 0; if (dur > 0xfc0) { durVal = 0xff; @@ -660,7 +664,7 @@ static uint32_t Bme688GetMeasDur(struct SensorCfgData *data, const uint8_t opMod { int32_t ret = HDF_SUCCESS; uint32_t meas_dur = 0; /* Calculate in us */ - uint32_t meas_cycles; + uint32_t meas_cycles = 0; uint8_t os_to_meas_cycles[6] = { 0, 1, 2, 4, 8, 16 }; CHECK_NULL_PTR_RETURN_VALUE(gascfg, HDF_ERR_INVALID_PARAM); @@ -688,7 +692,6 @@ static uint32_t Bme688GetMeasDur(struct SensorCfgData *data, const uint8_t opMod return meas_dur; } - static int32_t BmeHalSetConfig(struct SensorCfgData *data, struct bme688HeatrConf *conf, uint8_t opMode, uint8_t *nbConv) { @@ -723,16 +726,15 @@ static int32_t Bme688SetHeatrConfig(struct SensorCfgData *data, struct bme688Hea { int32_t rc; uint8_t nb_conv = 0; - uint8_t hctrl, run_gas = 0; + uint8_t hctrl = 0; + uint8_t run_gas = 0; uint8_t ctrl_gas_data[2]; uint8_t ctrl_gas_addr[2] = { BME68X_REG_CTRL_GAS_0, BME68X_REG_CTRL_GAS_1 }; CHECK_NULL_PTR_RETURN_VALUE(conf, HDF_ERR_INVALID_PARAM); rc = Bme688SetOpMode(data, BME68X_SLEEP_MODE); - rc = BmeHalSetConfig(data, conf, opMode, &nb_conv); - rc = BmeHalRegRead(data, BME68X_REG_CTRL_GAS_0, ctrl_gas_data, 2); if (conf->enable == BME68X_ENABLE) { @@ -752,7 +754,6 @@ static int32_t Bme688SetHeatrConfig(struct SensorCfgData *data, struct bme688Hea ctrl_gas_data[1] = BME68X_SET_BITS(ctrl_gas_data[1], BME68X_RUN_GAS, run_gas); rc = BmeHalRegWriteMulByte(data, ctrl_gas_addr, ctrl_gas_data, 2); - return rc; } @@ -772,119 +773,221 @@ static int32_t BmeHalBoundaryCheck(struct SensorCfgData *data, uint8_t *value, u return rc; } -static int32_t Bme688SetConfig(struct SensorCfgData *data, struct GasCfg *gascfg) +static int32_t PerformBoundaryChecks(struct SensorCfgData *data, struct GasCfg *gascfg) { - int32_t rc = HDF_SUCCESS; - uint8_t odr20 = 0, odr3 = 1; - uint8_t currentOpMode; - - CHECK_NULL_PTR_RETURN_VALUE(gascfg, HDF_ERR_INVALID_PARAM); - - uint8_t regArray[BME68X_LEN_CONFIG] = {0x71, 0x72, 0x73, 0x74, 0x75}; - uint8_t dataArray[BME68X_LEN_CONFIG] = {0}; + int32_t rc; - rc = Bme688GetOpMode(data, ¤tOpMode); + rc = BmeHalBoundaryCheck(data, &gascfg->filter, BME68X_FILTER_SIZE_127); if (rc != HDF_SUCCESS) { - HDF_LOGE("%s: bme688 get operation mode failed", __func__); + return rc; } - rc = Bme688SetOpMode(data, BME68X_SLEEP_MODE); + rc = BmeHalBoundaryCheck(data, &gascfg->tempOs, BME68X_OS_16X); if (rc != HDF_SUCCESS) { - HDF_LOGE("%s: bme688 set sleep mode failed", __func__); + return rc; } - rc = BmeHalRegRead(data, regArray[0], dataArray, BME68X_LEN_CONFIG); + rc = BmeHalBoundaryCheck(data, &gascfg->presOs, BME68X_OS_16X); if (rc != HDF_SUCCESS) { - HDF_LOGE("%s, line : %d, bme688 read data array failed", __func__, __LINE__); + return rc; } - rc = BmeHalBoundaryCheck(data, &gascfg->filter, BME68X_FILTER_SIZE_127); - rc = BmeHalBoundaryCheck(data, &gascfg->tempOs, BME68X_OS_16X); - rc = BmeHalBoundaryCheck(data, &gascfg->presOs, BME68X_OS_16X); rc = BmeHalBoundaryCheck(data, &gascfg->humOs, BME68X_OS_16X); + if (rc != HDF_SUCCESS) { + return rc; + } + rc = BmeHalBoundaryCheck(data, &gascfg->odr, BME68X_ODR_NONE); if (rc != HDF_SUCCESS) { - HDF_LOGE("%s: bme688 boundary check failed", __func__); + return rc; } + return HDF_SUCCESS; +} + +static void ConfigureDataArray(uint8_t *dataArray, struct GasCfg *gascfg, uint8_t *odr20, uint8_t *odr3) +{ dataArray[4] = BME68X_SET_BITS(dataArray[4], BME68X_FILTER, gascfg->filter); dataArray[3] = BME68X_SET_BITS(dataArray[3], BME68X_OST, gascfg->tempOs); dataArray[3] = BME68X_SET_BITS(dataArray[3], BME68X_OSP, gascfg->presOs); dataArray[1] = BME68X_SET_BITS_POS_0(dataArray[1], BME68X_OSH, gascfg->humOs); + if (gascfg->odr != BME68X_ODR_NONE) { - odr20 = gascfg->odr; - odr3 = 0; + *odr20 = gascfg->odr; + *odr3 = 0; } - dataArray[4] = BME68X_SET_BITS(dataArray[4], BME68X_ODR20, odr20); - dataArray[0] = BME68X_SET_BITS(dataArray[0], BME68X_ODR3, odr3); + dataArray[4] = BME68X_SET_BITS(dataArray[4], BME68X_ODR20, *odr20); + dataArray[0] = BME68X_SET_BITS(dataArray[0], BME68X_ODR3, *odr3); +} - rc = BmeHalRegWriteMulByte(data, regArray, dataArray, BME68X_LEN_CONFIG); - if (rc != HDF_SUCCESS) { +static int32_t ReadAdditionalRegisters(struct SensorCfgData* data, struct GasFieldData* fieldData) +{ + int32_t rc = HDF_SUCCESS; + int32_t tempRc; + + tempRc = BmeHalRegRead(data, BME68X_REG_RES_HEAT0 + fieldData->gas_index, &fieldData->res_heat, 1); + rc |= tempRc; + + tempRc = BmeHalRegRead(data, BME68X_REG_IDAC_HEAT0 + fieldData->gas_index, &fieldData->idac, 1); + rc |= tempRc; + + tempRc = BmeHalRegRead(data, BME68X_REG_GAS_WAIT0 + fieldData->gas_index, &fieldData->gas_wait, 1); + rc |= tempRc; + + return rc; +} + +static int32_t Bme688SetConfigInternal(struct SensorCfgData *data, struct GasCfg *gascfg, + int32_t *rc, uint8_t odr20, uint8_t odr3) +{ + uint8_t regArray[BME68X_LEN_CONFIG]; + uint8_t dataArray[BME68X_LEN_CONFIG] = {0}; + uint8_t currentOpMode = 0; + + regArray[0] = 0x71; + regArray[1] = 0x72; + regArray[2] = 0x73; + regArray[3] = 0x74; + regArray[4] = 0x75; + + *rc = Bme688GetOpMode(data, ¤tOpMode); + if (*rc != HDF_SUCCESS) { + HDF_LOGE("%s: bme688 get operation mode failed", __func__); + return *rc; + } + + *rc = Bme688SetOpMode(data, BME68X_SLEEP_MODE); + if (*rc != HDF_SUCCESS) { + HDF_LOGE("%s: bme688 set sleep mode failed", __func__); + return *rc; + } + + *rc = BmeHalRegRead(data, regArray[0], dataArray, BME68X_LEN_CONFIG); + if (*rc != HDF_SUCCESS) { + HDF_LOGE("%s, line : %d, bme688 read data array failed", __func__, __LINE__); + return *rc; + } + + *rc = PerformBoundaryChecks(data, gascfg); + if (*rc != HDF_SUCCESS) { + HDF_LOGE("%s: bme688 boundary check failed", __func__); + return *rc; + } + + ConfigureDataArray(dataArray, gascfg, &odr20, &odr3); + + *rc = BmeHalRegWriteMulByte(data, regArray, dataArray, BME68X_LEN_CONFIG); + if (*rc != HDF_SUCCESS) { HDF_LOGE("%s: bme688 write config failed", __func__); + return *rc; } if (currentOpMode != BME68X_SLEEP_MODE) { - rc = Bme688SetOpMode(data, currentOpMode); + *rc = Bme688SetOpMode(data, currentOpMode); + if (*rc != HDF_SUCCESS) { + HDF_LOGE("%s: bme688 restore operation mode failed", __func__); + return *rc; + } } - return rc; + return *rc; } -static int32_t BmeHalReadFieldData(struct SensorCfgData *data, - uint8_t index, struct GasFieldData *fieldData) +static int32_t Bme688SetConfig(struct SensorCfgData *data, struct GasCfg *gascfg) { - uint8_t gas_range_l, gas_range_h, buff[BME68X_LEN_FIELD] = {0}; - uint32_t adc_temp, adc_pres, tries = BME688_TRY_TIMES, rc = HDF_SUCCESS; - uint16_t adc_gas_res_low, adc_gas_res_high, adc_hum; + int32_t rc; + uint8_t odr20; + uint8_t odr3; + + rc = HDF_SUCCESS; + odr20 = 0; + odr3 = 1; + + CHECK_NULL_PTR_RETURN_VALUE(gascfg, HDF_ERR_INVALID_PARAM); + + return Bme688SetConfigInternal(data, gascfg, &rc, odr20, odr3); +} + +static void ParseSensorData(const uint8_t* buff, struct GasFieldData* fieldData, struct Bme688GasRawData *gasRawdata) +{ + fieldData->status = buff[0] & BME68X_NEW_DATA_MSK; + fieldData->gas_index = buff[0] & BME68X_GAS_INDEX_MSK; + fieldData->meas_index = buff[1]; + gasRawData->adc_pres = ((uint32_t)buff[2] * 4096) | ((uint32_t)buff[3] * 16) | ((uint32_t)buff[4] / 16); + gasRawData->adc_temp = ((uint32_t)buff[5] * 4096) | ((uint32_t)buff[6] * 16) | ((uint32_t)buff[7] / 16); + gasRawData->adc_hum = ((uint32_t)buff[8] * 256) | (uint32_t)buff[9]; + gasRawData->adc_gas_res_low = ((uint32_t)buff[13] * 4) | ((uint32_t)buff[14] / 64); + gasRawData->adc_gas_res_high = ((uint32_t)buff[15] * 4) | ((uint32_t)buff[16] / 64); + gasRawData->gas_range_l = buff[14] & BME68X_GAS_RANGE_MSK; + gasRawData->gas_range_h = buff[16] & BME68X_GAS_RANGE_MSK; +} + +static void UpdateFieldDataStatus(struct GasFieldData* fieldData, uint8_t statusByte) +{ + fieldData->status |= statusByte & BME68X_GASM_VALID_MSK; + fieldData->status |= statusByte & BME68X_HEAT_STAB_MSK; +} + +static void CalculateGasResistance(struct SensorCfgData* data, struct GasFieldData* fieldData, + struct Bme688GasRawData *gasRawData) +{ + if (g_bme688State.variantId == BME68X_VARIANT_GAS_HIGH) { + fieldData->gas_resistance = BmeHalCalcGasResistanceHigh(gasRawData->adc_gas_res_high, + gasRawData->gas_range_h); + } else { + fieldData->gas_resistance = BmeHalCalcGasResistanceLow(data, + gasRawData->adc_gas_res_low, + gasRawData->gas_range_l); + } +} + +static int32_t BmeHalReadFieldData(struct SensorCfgData* data, uint8_t index, + struct GasFieldData* fieldData) +{ + uint8_t buff[BME68X_LEN_FIELD] = {0}; + uint32_t tries = BME688_TRY_TIMES; + uint32_t rc = HDF_SUCCESS; + struct Bme688GasRawData gasRaw; + CHECK_NULL_PTR_RETURN_VALUE(fieldData, HDF_ERR_INVALID_PARAM); - while ((tries) && (rc == HDF_SUCCESS)) { - rc = BmeHalRegRead(data, (uint8_t)(BME68X_REG_FIELD0 + index * BME68X_LEN_FIELD_OFFSET), - buff, (uint16_t)BME68X_LEN_FIELD); + (void)memset_s(&gasRaw, sizeof(gasRaw), 0, sizeof(gasRaw)); + + while (tries && (rc == HDF_SUCCESS)) { + rc = BmeHalRegRead(data, BME68X_REG_FIELD0 + index * BME68X_LEN_FIELD_OFFSET, buff, BME68X_LEN_FIELD); if (rc != HDF_SUCCESS) { - HDF_LOGE("%s: bme688 read data failed", __func__); + HDF_LOGE("%s: Read data failed", __func__); + break; } - fieldData->status = buff[0] & BME68X_NEW_DATA_MSK; - fieldData->gas_index = buff[0] & BME68X_GAS_INDEX_MSK; - fieldData->meas_index = buff[1]; - /* read the raw data from the sensor */ - adc_pres = (uint32_t)(((uint32_t)buff[2] * 4096) | ((uint32_t)buff[3] * 16) | ((uint32_t)buff[4] / 16)); - adc_temp = (uint32_t)(((uint32_t)buff[5] * 4096) | ((uint32_t)buff[6] * 16) | ((uint32_t)buff[7] / 16)); - adc_hum = (uint16_t)(((uint32_t)buff[8] * 256) | (uint32_t)buff[9]); - adc_gas_res_low = (uint16_t)((((uint32_t)buff[13]) * 4) | (((uint32_t)buff[14]) / 64)); - adc_gas_res_high = (uint16_t)((((uint32_t)buff[15]) * 4) | (((uint32_t)buff[16]) / 64)); - gas_range_l = buff[14] & BME68X_GAS_RANGE_MSK; - gas_range_h = buff[16] & BME68X_GAS_RANGE_MSK; + + ParseSensorData(buff, fieldData, &gasRaw); if (g_bme688State.variantId == BME68X_VARIANT_GAS_HIGH) { - fieldData->status |= buff[16] & BME68X_GASM_VALID_MSK; - fieldData->status |= buff[16] & BME68X_HEAT_STAB_MSK; + UpdateFieldDataStatus(fieldData, buff[16]); } else { - fieldData->status |= buff[14] & BME68X_GASM_VALID_MSK; - fieldData->status |= buff[14] & BME68X_HEAT_STAB_MSK; + UpdateFieldDataStatus(fieldData, buff[14]); } - if (fieldData->status & BME68X_NEW_DATA_MSK) { - rc = BmeHalRegRead(data, BME68X_REG_RES_HEAT0 + fieldData->gas_index, &fieldData->res_heat, 1); - rc |= BmeHalRegRead(data, BME68X_REG_IDAC_HEAT0 + fieldData->gas_index, &fieldData->idac, 1); - rc |= BmeHalRegRead(data, BME68X_REG_GAS_WAIT0 + fieldData->gas_index, &fieldData->gas_wait, 1); - if (rc != HDF_SUCCESS) { - HDF_LOGE("%s: bme688 read data failed", __func__); - } - fieldData->temperature = BmeHalCalcTemperature(data, adc_temp); - fieldData->pressure = BmeHalCalcPressure(data, adc_pres); - fieldData->humidity = BmeHalCalcHumidity(data, adc_hum); - if (g_bme688State.variantId == BME68X_VARIANT_GAS_HIGH) { - fieldData->gas_resistance = BmeHalCalcGasResistanceHigh(adc_gas_res_high, gas_range_h); - } else { - fieldData->gas_resistance = BmeHalCalcGasResistanceLow(data, adc_gas_res_low, gas_range_l); - } + if (!(fieldData->status & BME68X_NEW_DATA_MSK)) { + OsalMDelay(BME688_DELAY_10); + tries--; + continue; + } + + rc = ReadAdditionalRegisters(data, fieldData); + if (rc != HDF_SUCCESS) { + HDF_LOGE("%s: Read additional failed", __func__); break; } - OsalMDelay(BME688_DELAY_10); - tries--; + + fieldData->temperature = BmeHalCalcTemperature(data, gasRaw.adc_temp); + fieldData->pressure = BmeHalCalcPressure(data, gasRaw.adc_pres); + fieldData->humidity = BmeHalCalcHumidity(data, gasRaw.adc_hum); + CalculateGasResistance(data, fieldData, &gasRaw); + break; } + return rc; } @@ -987,6 +1090,7 @@ static int32_t Bme688InitDriver(struct HdfDeviceObject *device) ret = Bme688SoftReset(drvData->sensorCfg); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: bme688 dump data failed!", __func__); + return ret; } // validate chip id @@ -1034,3 +1138,4 @@ struct HdfDriverEntry g_gasBme688DevEntry = { }; HDF_INIT(g_gasBme688DevEntry); + diff --git a/sensor/chipset/gas/gas_bme688_driver.h b/sensor/chipset/gas/gas_bme688_driver.h index 0b7fcafff0..2bc132b765 100644 --- a/sensor/chipset/gas/gas_bme688_driver.h +++ b/sensor/chipset/gas/gas_bme688_driver.h @@ -282,6 +282,16 @@ struct bme688HeatrConf { uint16_t shared_heatr_dur; }; +struct Bme688GasRawData { + uint32_t adc_temp; + uint32_t adc_pres; + uint16_t adc_hum; + uint16_t adc_gas_res_low; + uint16_t adc_gas_res_high; + uint8_t gas_range_l; + uint8_t gas_range_h; +}; + struct Bme688Status { int8_t variantId; int8_t workState; -- Gitee