diff --git a/audio/BUILD.gn b/audio/BUILD.gn index db6af342880cd493e5400f697ad465b80cf13c64..5bfa248c134c2b4de627508fa7be00d70aa151f2 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.gni b/audio/audio.gni index f81ec932e4a6e54f5c2ef0b2372fded0ad575a59..1e9ce047caed05035331e0a433286734cac0fece 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 -} diff --git a/audio/audio_dfx/BUILD.gn b/audio/audio_dfx/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c67cafd60e9db6944f1d21cf57b75b7fe2c32067 --- /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 9f98333cbce7bf76277947bbde0b119339412144..5ef3e73e5104f8e532dbfd1535f758a300132b42 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 f5de19aded186ccbba98e955012bdf6840902ae3..b74f29343f4dbe26dd3632a5d6df47d9d37571a8 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 6c1e59e207cb77b1b6eab2b3333d288e2bdefc35..dec0eb4de44d19a771abff945666e981e0b4bc51 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 4c95ecd33d6f5fba85b17eecb9f98413e98cdb4b..c89aba08686513d92304db19b1721854e82f4dcd 100644 --- a/audio/effect/model/src/effect_control.c +++ b/audio/effect/model/src/effect_control.c @@ -21,40 +21,54 @@ #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" +#include #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}" PRIu64 " 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 +99,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}" PRIu64 " 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/effect/model/src/effect_model.c b/audio/effect/model/src/effect_model.c index 1a7cd15ced9f7dc2ee030e63a2bfb4ac0d1f55ac..3c1c24d7ca1f3495c2c8227620e086b30696154e 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,37 +381,46 @@ 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__); - 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__); - return HDF_FAILURE; + goto EXIT; } *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__); + goto EXIT; + } 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__); + goto EXIT; + } - ret = CreateEffectController(info, contoller, contollerId, ctrlOps); - if (ret != HDF_SUCCESS) { + if (CreateEffectController(info, contoller, contollerId, ctrlOps) != HDF_SUCCESS) { DeleteEffectLibrary(info->libName); - 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) @@ -427,7 +429,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 +448,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,12 +461,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; } @@ -525,3 +532,4 @@ void EffectModelImplRelease(struct IEffectModel *instance) OsalMemFree(service); service = NULL; } + diff --git a/audio/effect/test/unittest/BUILD.gn b/audio/effect/test/unittest/BUILD.gn index 7047eb5dd97843f55f58fe493aa1adfd74c532d7..b81a4cdd1b0d6ddfee4a86c160f24fd9b76728d2 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/hdi_service/primary_impl/BUILD.gn b/audio/hdi_service/primary_impl/BUILD.gn index 5ba456508bec677a1a244339e63b5af6ee9729b1..ac854d423604f7f25fb804633e965c1b0ba16e42 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 c7a0448df13a157204bbe489c91166353d685b2b..1666645495fa8fe51197b2ab07bb9e72c1186149 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 bcf1a6a84c352e1eb3e8d335a5b9c3cd56ec2f52..3d8bb3cfc76d2992c0a3b4119ec399408ba9a341 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 329947ac9df5fb46c98155d36f062e2aed1db17b..5e2e98330ee2969ff276c6ce3ba7e66395ca8c2e 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 d7add3a3a429be256297e417a72181bae5b9b9a2..1ccda5ed193fd971a26ca7ba73ec0392fc36e6c1 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 c40bb5660cf381023602846e38982c83fa55bcfe..40ca5e1186ec4cce04c7b340a7dc54301bad08c3 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 diff --git a/audio/interfaces/sound/v1_0/audio_types_vdi.h b/audio/interfaces/sound/v1_0/audio_types_vdi.h index 5ab8583f31243f9a2b3e88e555de9dfdf2bda7c3..9033c5b3a3b754273d6a55789a343f565c4bf9dd 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, }; 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 d33588cbe43ffee645fbf1a8ab95c0335e74f296..2a560c288773554ddd272cf7bcfaa649907e6253 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 6a251e186d03ece86adc0f0697ecc2370c0b1988..814cad7ac9da5e6c40aa5fb06e6b338b7101a4ff 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 b66d3b5d55d7b4b8c88267b6f6aa703e33f88d2d..c4ab5a0fbeeb18ae5d1265be3014266eb5d0f313 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 2071dfaf9fcd8fb8610a49346e1c86a4a0c4726c..d0c5a38ef6f515a1e62c6a4fcd35417e2c1626f4 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/fuzztest/audio_hdi_fuzzer/audiorender_fuzzer/BUILD.gn b/audio/test/fuzztest/audio_hdi_fuzzer/audiorender_fuzzer/BUILD.gn index 317ab795c634d89d962dd3070f37755a3e0800f1..31b716312d9735f6a0de6f6f182d5f973da54531 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/systemtest/adm/audio_adm_interface/BUILD.gn b/audio/test/systemtest/adm/audio_adm_interface/BUILD.gn index 39e350d37de5694b8f37a8fffde0aef49e7ef6aa..77f9c18eeb4ea42ce0172d8d9754b73235e9ae83 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/common/hdi_service_common/include/hdi_service_common.h b/audio/test/systemtest/common/hdi_service_common/include/hdi_service_common.h index 925fa68c82dcf14060c006f50f2b9fda3659d1b9..8636f0c3a0ba5538fdf8ea9fa56aee08d5eb4f3a 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; diff --git a/audio/test/systemtest/hdi_service/common/adapter/BUILD.gn b/audio/test/systemtest/hdi_service/common/adapter/BUILD.gn index 408466c2a26bc5781c5eec7404ff176630cac16a..ec70c711560e1673653d0ec3d64168ee2a0b56fe 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 6bd269616b120a1532e1d08f866295ccfea4b2d7..16f6a12280e77f4b55b46769018093f73f08ed88 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 25d8e19f230dabdd4f6d6d7e43ec5f833c1eca5a..a55038c008be2eb52b7dadb30e21e070cb2e8187 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 2f1279e2f7c3b226d4cc16a7ed3a1d7a0a531e33..82c314ead2d41f88f5c78765f6197c974d74c364 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 74896bc8b1961b7b846b2f88a202dcd282c33190..a51db3f4f757135e82ce6ffc2d1591884bf0d964 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 0c2076f233458e101ec245c8e139748cccb27ce7..5e4d59b56301ed8cc8834fe7bbde950561c85845 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 172b03521a5f0990c02890e8269cf6cac6efcb5f..8757eaca48672708e2214ef1cddba048ebac0a87 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 cda33447811aef475f233b60ae77b33c901729b9..d80a4a4168bdf3225ff4edb6e7256a51ad28a934 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 3efdc95c47fdc553da04f3d1efc10a98f48eb882..b71880de19cc47df78d8a898161d0b273fb074f0 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 ab9e28c253c0cf04aad6c9a817a79c3179246aa6..0755f2020b559e7495ae2ea3c569f6fff73bb81c 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 9e67deef6647f231c7f9f04f744cc8fe546318b3..e523b0c44f887d5980f1ed35b10e9179c2b255dd 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 8c0896424c18fe26974042022677e2b78cdf3eea..35ac9ec3f595f82681d68e89ac25ae7c635531e7 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 4a2e870b67f20e109902612f05159745c93f1fd9..cd5a961975ee0425dbc2c672b5928e954c25ead8 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/audio/test/unittest/common/BUILD.gn b/audio/test/unittest/common/BUILD.gn index 35209a7fca7b804d9c9139591432a41f049101f9..72f7ebf2d09462f0a5a1b109215537e03d4e62d2 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/battery/interfaces/hdi_service/test/systemtest/BUILD.gn b/battery/interfaces/hdi_service/test/systemtest/BUILD.gn index 4ec5cbb8b94e10b8d953ece90a0d8d2a04b42fa3..11b409afa178915843b4180f8523e23739f85bdf 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 2602658cb56a07f70374232ca4edab45d9afd9de..4c29e8786c2abc7da816bb3575e01cb1434dc14b 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/camera/hdi_service/v1_0/BUILD.gn b/camera/hdi_service/v1_0/BUILD.gn index d08c46f781fefaf5dbb359039a879f237b6e4d8a..10fc249b2dae82639b5f8711ea3d5975544da9c0 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 e172a982ec77c4bf362129d90c53bf25207dcc43..35681ed904558b9b4a89b666a2c524e71a3a7d20 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 76bd2b3dc1ed4f85b5ebbaa47a254eefeddf005b..9c5cd6c601ecb281735eb988dfe08d7fae0b77aa 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 6c88eeee9dbc8f2bf481a712d8e005672d113c09..45c9714efc94fa8dbfd9982006021ff91493f61c 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/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 9242f7343c2a0cee7dbd3e071361f363341190c4..cd8289d0a0a5d09ec1fb49e460e0617ff42645ca 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/buffer_manager/BUILD.gn b/camera/vdi_base/usb_camera/buffer_manager/BUILD.gn index bc6c13e0898dd9d747a7426a4041dcbd6f68197e..fd53cd521e6d0166f805f0a64f39359bdd1c01ae 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 73031228c3ddd5096bcdda694abadd35f37bcb3c..867f8c39d7a8d286c1f152181e96f7f70ecd1287 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/pipeline_core/src/node/exif_node.cpp b/camera/vdi_base/usb_camera/pipeline_core/src/node/exif_node.cpp index f0b40eeedf5738ec4ab248258e33e6f3f63d85ce..554ebe3c2fab3cc1e3e1b509201f63148cf22c96 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 1d0c7c8eef023ee9da3eb7171caa9ae1543d8209..e689d452373aa60f09dbc35838d10f2cbd02df8a 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 7b8ae4397b2162ef33e0a2621b5a12daf3a848cc..029da78fdf1dcf36375ef1143f0d2cb5c026925b 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) { diff --git a/camera/vdi_base/usb_camera/vdi_impl/BUILD.gn b/camera/vdi_base/usb_camera/vdi_impl/BUILD.gn index afea5554f994a6931b6df9c0ddc15135c65f7e9a..7e0d2add4c4ff4cea67914fe274377588ca092d5 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", ] diff --git a/codec/interfaces/include/codec_omx_ext.h b/codec/interfaces/include/codec_omx_ext.h index 5f1a1dcde72de26a2ed4e9357321f7a01bf7c612..fcac3306d53b47e513bb11b37ccc97a47b1f73cb 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; /** diff --git a/codec/test/unittest/hdi_image/BUILD.gn b/codec/test/unittest/hdi_image/BUILD.gn index 0124a1584af19bbc5d9b9643ce30ec2c62fad472..bff843691b3bbd7d0ba16c22a66adcd5602892b0 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" ] 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 5f1d9ab06c9beadd008f5088c10b7f09eff90ef9..2e829aca8572b6f275c4c1d7115501a114dcdc86 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); diff --git a/codec/test/unittest/hdi_omx/BUILD.gn b/codec/test/unittest/hdi_omx/BUILD.gn index 0a9c54f1ba9358ef54f6491d32850447a46c105b..7bd8688e050ae2bc13ef39989dd6fc9949c384e0 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", diff --git a/codec/test/unittest/idl_omx/BUILD.gn b/codec/test/unittest/idl_omx/BUILD.gn index 0ef42d6c70d3de48a15192af7f8aea37b784d857..2cb0b75c11f8e4b0ee97ff0f909c4ecbfb1e5687 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", diff --git a/display/buffer/test/benchmarktest/BUILD.gn b/display/buffer/test/benchmarktest/BUILD.gn index d804dc80f12b6fe91357481d78c824147e5ab3c8..763c1f576c47d872ab8d39126fe80070f6734e3a 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 b46e9c440a6566722d582b0a7bf4150e0a8d5ce9..1c7b33c164f710624502b822cb251820dcf691e8 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/buffer/test/unittest/BUILD.gn b/display/buffer/test/unittest/BUILD.gn index 226a881d4f7c87da670b028dea867fd58f25f698..35e8c4d6143b8631c74db7a65062d003d011caed 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/moduletest/BUILD.gn b/display/composer/test/moduletest/BUILD.gn index a9609e38423f5e8e44bcf31db72ec2041b2787f6..719b5e1aa144b53af0bae9372f8931c1e5029eb5 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/display/composer/test/unittest/BUILD.gn b/display/composer/test/unittest/BUILD.gn index 5fe10bdbef10e97f5d2ca564216cf7b5e12464e4..e521b1a3fcda6ed32016d8c52692d4ba801c1e3b 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/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 d8701ac21749fb39453e9e75fb0547238140f54f..d64580cf818ac70506ccfc2b42f22c406737333d 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 c326f9a0641b996252effc6a1ca0c5b04a162566..1cf6faa97cc75554fb7344a89a0322741b43cc6f 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 bed1ee515941203ce5f5a1c1e03b0a1a586e578f..820a5ac73c09f2f21b8a0e97477d6691c503ddfd 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 7defa0350a55538a8ac70fc7a82f43e680628029..ebe2ecd11e8def229061b430a10b8da9824fa8e7 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 94ac8b5ad77380d5fd5ac1a57f0fa20529e50966..7b62ffb95d734a0d510eb9fe456085de7ba2dd09 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 c8e41689a6ce14de602041cf675fbf293533a0d8..697816b9a46290cf246db0bfed4835ffa584a273 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 78ec7561873d5fafff51a16cf984652f374f432b..1874bf02de86c64b17a8692a304b9b1ebe9e35e2 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 = [ ":*" ] 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 bfdfed86d69bdb5cf250559e707666f4abc50818..17c7abcd43524b850812625c1fcaf7f01cf3123d 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 380520f7ad3532c32f5842b37ec86d3979650ebd..5817cd12b4c6ee475e78b02910c27a24a577be6e 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 7778f43a7aa319c09e9f66dd353cd72f3beca27d..642e2437ccdc677d238b0c931e77d537aff89b73 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 11d185ac8629b9a4b46ebf19935592b0b65bf443..996ff2d5daa3e54d45f547eaa721fb9dd2c05929 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; } @@ -311,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); @@ -428,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; } 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 8a1c16ba16b227c9b7b7515fee10f5311f12f78a..ab25229aa44bb70bb85a61f0a7c8a89af7b742a7 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() 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 20da89e8b8a6de4580d0830e838bd8afdcd67011..ee0c516ae60d78a852cfc1701f60dec951f57685 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 33527a7c808121df04528e15655d61409d58ac52..b3568029beea1e3520de50650fcf99fb18dcd4d3 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 = [ ":*" ] diff --git a/huks/test/unittest/BUILD.gn b/huks/test/unittest/BUILD.gn index 4e843d1d52ab710935ec87844a90692a79dd98de..a0805500d0bdff49bf12633e39d113398aea2c9a 100755 --- a/huks/test/unittest/BUILD.gn +++ b/huks/test/unittest/BUILD.gn @@ -14,7 +14,8 @@ 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 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 7a926ffc33d88343f396e0896e35e0b6bff6c6af..74e47ba000407d873d10aa21a9ec613b6274823a 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 bfcfb16eaec0088e42e5836590e552a50c733789..7d2b682a7610dae5b1013abcea6d0165fcf1e492 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 b969659eeeeadfc1d59d62942a4f13065c3166eb..9a2e1d60fccf0bdfb1b5536f384ad57b882b5581 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 c7085f3ced6968384ed4173ad60d2415c0f5788a..41bb80dd36366128c09da9501cb55b18652a1ea6 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/test/benchmarktest/BUILD.gn b/input/test/benchmarktest/BUILD.gn index 91a25514d97b89c43a48b87cfcdba5af8ac53512..938673c97021dab7968f5e6c605f3d59b09c6b58 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", diff --git a/input/test/unittest/BUILD.gn b/input/test/unittest/BUILD.gn index 6c6a94caadd0c98081cd92bb735bcaf5b05fa216..04bdb11395f8701d46b7764bc98e55391573fec3 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 35088eed54647b9543bab38121b1fdad7aa30a42..91af9642018bb6abc92230237ecaf230a682f02b 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 4db579771dbbf844a6d84616856fa689eeed67f8..7167f7fd913fac253fbf135c004de00c3667a17d 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 d05304052f13b795ead4478d95783b53126f7e26..53087fc15649a6ba4c20e195158104b661d631c7 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 = [ diff --git a/input/udriver/src/input_device_manager.cpp b/input/udriver/src/input_device_manager.cpp index 08055d94f30803fb2442ebc65cee459cfaf37b96..81792a17024cde24cde88fef4010027007d88ac1 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; } diff --git a/intelligent_voice/hdi_service/engine/BUILD.gn b/intelligent_voice/hdi_service/engine/BUILD.gn index f81cd2efb56f58ade2de477fb21e99c612fcc13d..ec2f068014b6a466e3ef30a26db85e4bea76086e 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 0000000000000000000000000000000000000000..e5a4fdb94da53b3007fad0264a0c95753454bc33 --- /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 48f91bcb6908947f4d73a2cae6a7d5cabab05e5a..1700fc1af0686f676c80040fa9d7e7d7cc4880da 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 0000000000000000000000000000000000000000..4b689e3f04166ce7a6410ea8f8c500acd5792eb9 --- /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 diff --git a/light/test/unittest/BUILD.gn b/light/test/unittest/BUILD.gn index 09c37bb3b975d1c8eeab009481181a2429d0b0ed..785182915b75470c584b0e52c1a2b66ee252d395 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 fa620cc2a16ddcd79f0dba41dc8304eff4c63038..be9c0adb3c3aa7eaec3f66b3a5e816862d3f0916 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/memorytracker/test/BUILD.gn b/memorytracker/test/BUILD.gn index 83068c01b67773b205702b47bdabdee445ce94b1..1067c3509fa85d8bc7f44a2ad69288d9262d0e72 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 diff --git a/motion/hdi_service/motion_if_service.cpp b/motion/hdi_service/motion_if_service.cpp index d4e17329942037d0d506d611af7f9c6362d1246c..c8bb7945d225f9d8d726ee57bb15e8828b07d1bb 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/motion/test/unittest/hdi/BUILD.gn b/motion/test/unittest/hdi/BUILD.gn index b6376c828dd32bd772d3409188914507c52ca184..3f4782fab80f575bb0bb526724b826b76a634aa9 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/nfc/bundle.json b/nfc/bundle.json index 381bf0f7b61b57945575f80f58a97e0ea80c1436..6a1e986f38cc0a72cc87070d7e8f76f8323a424a 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 951912879e05c18124eab7ec4ac95e6382315557..c4d85efa06358ec1530e5ff2864148f722e8df1c 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 0523548549247b64c97823775a2154dff19521cc..e89dbce860b43a059ac41a92368a6fc7f13ae205 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,39 +31,40 @@ #endif #define LOG_DOMAIN 0xD000306 -std::mutex g_openMutex; + using namespace std; namespace OHOS { namespace HDI { namespace Nfc { -static string GetNfcHalSoName(const std::string &chipType) +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) { - string nfcHalSoName = NFC_HAL_SO_PREFIX + chipType + NFC_HAL_SO_SUFFIX; - return nfcHalSoName; + 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__); + } } -int NfcVendorAdaptions::GetNfcStatus(void) +static void WriteBootloaderHiSysEvent(uint16_t errorCode) { - 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())); + 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); +} - 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; +static string GetNfcHalSoName(const std::string &chipType) +{ + string nfcHalSoName = NFC_HAL_SO_PREFIX + chipType + NFC_HAL_SO_SUFFIX; + return nfcHalSoName; } string NfcVendorAdaptions::GetChipType(void) @@ -80,13 +82,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; } @@ -110,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; @@ -137,7 +187,6 @@ void NfcVendorAdaptions::ResetNfcInterface(void) nfcHalInf.nfcHalMinClose = nullptr; nfcExtHandle = nullptr; nfcExtInf.getNfcChipType = nullptr; - nfcExtInf.getNfcStatus = nullptr; nfcExtInf.getNfcHalFuncNameSuffix = nullptr; } @@ -156,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; @@ -173,11 +231,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 eeb31e5b0b0386276c27fa51535a4507fc408550..296f50fecbdcd119afe97d77be1c826db989a3a2 100644 --- a/nfc/vendor_adaptor/nfc_vendor_adaptions.h +++ b/nfc/vendor_adaptor/nfc_vendor_adaptions.h @@ -29,7 +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_GET_NFC_STATUS_FUNC_NAME = "GetNfcStatus"; +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"; @@ -48,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; @@ -61,8 +66,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 +87,8 @@ struct NfcExtInterface { const char* (*getNfcChipType)(void); const char* (*getNfcHalFuncNameSuffix)(const char* chipType); void (*checkFirmwareUpdate)(void); - int (*getNfcStatus)(void); + void (*updateNfcOpenStatus)(const char* nfcStatus, int len); + int (*checkNfcBootloaderStatus)(void); }; class NfcVendorAdaptions : public INfcVendor { @@ -113,8 +118,9 @@ 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 UpdateNfcOpenStatus(const std::string &status); + bool CheckNfcBootloaderStatus(void); void *nfcHalHandle; // handle of nfc hal so NfcHalInterface nfcHalInf; diff --git a/partitionslot/test/BUILD.gn b/partitionslot/test/BUILD.gn index 7f27e4319c8903402421c3f4237370801d26472e..408e012ec8cac5f1a999bec76fbc869edee024e3 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 = [ diff --git a/power/interfaces/hdi_service/src/hibernate.cpp b/power/interfaces/hdi_service/src/hibernate.cpp index 910ca680e99ff6dba24f2d1a79a73efd29d171e1..1efa3c35f3ee22deb60871081812507ac80045a3 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(); diff --git a/power/interfaces/hdi_service/src/power_interface_impl.cpp b/power/interfaces/hdi_service/src/power_interface_impl.cpp index a961f948b61eb60819946da518621b0c483301f5..c4acde0fc907a34c7e6b49488a015c8c942e680f 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", info.type); 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", info.type); 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 f798eb45eb37852514592b1f50320f6150379211..a7af74757892f709b47f16baeb3bdff14b19f69f 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_; diff --git a/power/test/unittest/BUILD.gn b/power/test/unittest/BUILD.gn index 469e6a1d0fff960a878981dd6c514f59ba0c88dd..f47756c44060edb18fde44f86efd0926556ece68 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/ril/interfaces/hdi_service/include/ril_impl.h b/ril/interfaces/hdi_service/include/ril_impl.h index 9fd3c70981774861790382dbbf2db1fc117d6fcc..a7381f841ae02e92ae92d78075aa22b75c48ddf1 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 7aa866ac995e969223d6494a8e02e91d72b418fb..0df257ca2344a308fff220ed163e5cbb82ab04ef 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) { diff --git a/sensor/chipset/gas/gas_bme688_driver.c b/sensor/chipset/gas/gas_bme688_driver.c index 73a2bd9f69910d2c56ab8d129c80321037cec84e..33bcbfe00281cfabc0ed064cfe28575d9050fe5b 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 0b7fcafff073a5d46560ab1d59af61b0677637a8..2bc132b765ac361d57bb0aa8f8b4f4955f56e422 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; diff --git a/sensor/hdi_service/sensor_clients_manager.cpp b/sensor/hdi_service/sensor_clients_manager.cpp index 4b2f0dd37e68e7f93401da65516830ad86368431..6804581eac6fbb767d1a3252e4ca27426558ac0a 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()) { @@ -327,7 +328,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 5a2db5902da3c987620c52f138dbd771422ff2fd..6ff95592fcc6fc82cf3d5d85ffb283c41409c571 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; } diff --git a/sensor/test/unittest/BUILD.gn b/sensor/test/unittest/BUILD.gn index 34e01f9800010e6ff055032ac441e9216b112f70..001cc2e2bdbe189414a1cfad04ceb87b237c6292 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 30f940c7b3584feda5ad1e49acadaad07b32d8f8..d585874dfa366a9e47f5b76149fe38e1796879dc 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 e14ee29cab6994115488f0de8d3f4f0ba91ca547..3e38927ecf55c7d80dae25f0cd616a589cbc9fca 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/thermal/etc/thermal.para.dac b/thermal/etc/thermal.para.dac index 194919aba3dbf8306914641cc48c443b39eb986e..d16d0c7626789133eefaa546338c74e58f6ae23c 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" diff --git a/thermal/test/unittest/BUILD.gn b/thermal/test/unittest/BUILD.gn index 294d5a2224ca64d013411c6f7997779843272ab3..f5915865f27753858324f2e2bd927ccfc72ccc33 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 diff --git a/usb/bundle.json b/usb/bundle.json index 9fe12df80c3684667d30b1fdbd4d56f1a9962c12..0e60cbfd8cca4d2ef21381a97f632caac01857be 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/ddk/device/src/adapter_if.c b/usb/ddk/device/src/adapter_if.c index a2f742bb272e58e0c4d8bfcbd87e09ce659b7a7d..d8f471acb2f274cd318d48a824628b3b17cc97ae 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/linux_adapter.c b/usb/ddk/host/src/linux_adapter.c index 4844163828dec2be9e7b4815320c636ef77433fa..194dbe4dbd664cf65969b03442dfeed51750e952 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 3d30a2cf99b3f6db441fa05b58744489d685cec8..0940f43c6824d99333ccd2783db674ff15abf0c2 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 { @@ -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; diff --git a/usb/ddk/host/src/usb_raw_api_library.c b/usb/ddk/host/src/usb_raw_api_library.c index 79610e54a9809ef20f5cafd30f9d53ceea1a443a..896ca1254a44ecaf922b1f7639e3cf4a750daa46 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; @@ -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 == NULL) { 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) { 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 c2176e03b1601f3114a5a33acb7da41faf221175..130c1f4e5b5463754de7356763397bda40e64c58 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) { diff --git a/usb/gadget/function/acm/cdcacm.c b/usb/gadget/function/acm/cdcacm.c index 676f8ce8fb49babb9bf26c5d50badcf10c9caaf6..e9fed999e9788102dac76a05c0293d050940a934 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 542055b2b90c922bda16d94dc6efc3f5fdbc4576..a66b28143cb45da2075a4416634fde4b533cee50 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; } @@ -836,6 +849,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 +915,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,6 +947,7 @@ 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; } @@ -997,6 +1013,7 @@ ERR: static int32_t EcmRelease(struct HdfDeviceObject *device) { + HDF_LOGD("%{public}s: enter", __func__); struct UsbEcmDevice *ecm = NULL; if (device == NULL) { @@ -1016,6 +1033,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/gadget/function/mtp/src/usbfn_mtp_impl.cpp b/usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp index 035d0ba60cd7e17b65286dedf3fa5e1bb451610c..1549cba8f61afa36e3ea534f534ce9b0aec03c06 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/hdi_service/include/usb_device_impl.h b/usb/hdi_service/include/usb_device_impl.h index 8af49af5d155dba6da412eba6200a0ab79057a06..6e047584979c3529b729d55747647151d661e1ab 100644 --- a/usb/hdi_service/include/usb_device_impl.h +++ b/usb/hdi_service/include/usb_device_impl.h @@ -61,12 +61,12 @@ 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_; static V1_2::UsbdLoadService loadUsbService_; static V1_2::UsbdLoadService loadHdfEdm_; - OsalMutex lockSetFunc_; }; } // namespace v2_0 } // namespace Usb diff --git a/usb/hdi_service/include/usb_port_impl.h b/usb/hdi_service/include/usb_port_impl.h index db04c144b8aa3ca7ba2ea108c4541a38e0b9c700..4ebe87bbd2a213e95d9c4040273620412098c8dc 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/include/usbd_function.h b/usb/hdi_service/include/usbd_function.h index b0b44fded20712c19936457d4dea4f1e095e6f51..be8e67f1a09d8b0a0c27824d9a4ca38af0890d8c 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) @@ -78,6 +80,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 +111,10 @@ private: static int32_t UsbdRegisterDevice(const std::string &serviceName); static int32_t InitMtp(); static int32_t ReleaseMtp(); + static int32_t UsbdInnerSetFunction(uint32_t funcs); static uint32_t currentFuncs_; + static OsalMutex setFunctionLock_; }; } // namespace V1_2 } // namespace Usb diff --git a/usb/hdi_service/src/usb_device_impl.cpp b/usb/hdi_service/src/usb_device_impl.cpp index de722c0fb9dfbf3d437bbce0c72ab4e46c67d730..02adbd29e83e83774d8dc823ab331e299cbaf943 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; @@ -58,7 +69,7 @@ extern "C" IUsbDeviceInterface *UsbDeviceInterfaceImplGetInstance(void) UsbDeviceImpl::UsbDeviceImpl() { - OsalMutexInit(&lockSetFunc_); + V1_2::UsbdFunction::UsbdInitLock(); if (OHOS::system::GetBoolParameter("const.security.developermode.state", true)) { loadUsbService_.LoadService(); } @@ -66,7 +77,7 @@ UsbDeviceImpl::UsbDeviceImpl() UsbDeviceImpl::~UsbDeviceImpl() { - OsalMutexDestroy(&lockSetFunc_); + V1_2::UsbdFunction::UsbdDestroyLock(); } int32_t UsbDeviceImpl::GetCurrentFunctions(int32_t &funcs) @@ -79,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; } @@ -277,9 +285,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_impl.cpp b/usb/hdi_service/src/usb_impl.cpp index 324124cf73dd35e6e355fc3464178488952f72cc..bf3227c8aec357b3d1c06ed41367d04281645303 100644 --- a/usb/hdi_service/src/usb_impl.cpp +++ b/usb/hdi_service/src/usb_impl.cpp @@ -97,6 +97,7 @@ 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 +105,7 @@ UsbImpl::UsbImpl() : session_(nullptr), device_(nullptr) UsbImpl::~UsbImpl() { + V1_2::UsbdFunction::UsbdDestroyLock(); UsbdReleaseDevices(); } @@ -2194,14 +2196,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/usb_port_impl.cpp b/usb/hdi_service/src/usb_port_impl.cpp index 5b68d87f9f4e57ca21cd32a75fe1db550a440990..fdac92c631ee45b8a593f4dca648e38cafaaff65 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; } diff --git a/usb/hdi_service/src/usbd_accessory.cpp b/usb/hdi_service/src/usbd_accessory.cpp index 8412a6d3f5333fe39575c180fb2029b45e4840c6..95377915d314a44475f93a74249f739680663e9f 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,7 +203,7 @@ 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); accFd = 0; @@ -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_function.cpp b/usb/hdi_service/src/usbd_function.cpp index fa9c539961d2cf05dcfdc930d7d4dedb92d80570..e278c57df2bc56122dc355f91ad627deaec8ac39 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() { @@ -584,7 +585,17 @@ int32_t UsbdFunction::UsbdSetKernelFunction(int32_t kfuns, int32_t funcs) } } -int32_t UsbdFunction::UsbdSetFunction(uint32_t funcs) +void UsbdFunction::UsbdInitLock() +{ + OsalMutexInit(&setFunctionLock_); +} + +void UsbdFunction::UsbdDestroyLock() +{ + OsalMutexDestroy(&setFunctionLock_); +} + +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) { @@ -636,6 +647,14 @@ int32_t UsbdFunction::UsbdSetFunction(uint32_t funcs) return HDF_SUCCESS; } +int32_t UsbdFunction::UsbdSetFunction(uint32_t funcs) +{ + OsalMutexLock(&setFunctionLock_); + int32_t ret = UsbdInnerSetFunction(funcs); + OsalMutexUnlock(&setFunctionLock_); + return ret; +} + int32_t UsbdFunction::UsbdGetFunction(void) { return currentFuncs_; diff --git a/usb/hdi_service/src/usbd_port.cpp b/usb/hdi_service/src/usbd_port.cpp index 04d92e675379c222521234a806f0f66e8f533c30..983391152c56a93383a004fcb6909d07b38a8cec 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()); @@ -251,6 +253,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 +277,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/include/libusb_adapter.h b/usb/libusb_adapter/include/libusb_adapter.h index 241b229e0f155f127cfab80739478b3e73117220..34c278d179e86943395b29fc278926af50a89a12 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); + 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); @@ -257,6 +259,8 @@ private: libusb_hotplug_callback_handle hotplug_handle_; static std::list> subscribers_; static sptr libUsbSaSubscriber_; + std::mutex openedFdsMutex_; + 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 df2a12410da50752de4895b4d460461447efd7c8..79106de672fda6359dcfb35731d767a043f658be 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); } @@ -278,6 +277,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 = 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); + } 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,11 +312,12 @@ 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)) { + CloseOpenedFd(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); } } @@ -400,32 +415,32 @@ 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) { + 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 { + 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; @@ -1161,6 +1176,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); @@ -1330,7 +1346,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; } @@ -1466,11 +1481,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); @@ -1478,7 +1494,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 +1804,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); @@ -2018,6 +2035,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; } @@ -2863,6 +2881,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); diff --git a/usb/sample/host/src/usbhost_nosdk_speed.c b/usb/sample/host/src/usbhost_nosdk_speed.c index e29bebb1fb9e443eb6d9b85048968c5d637f8e01..73ba3c138cb28a8f7bf257b6595022424b9dc9ed 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/BUILD.gn b/usb/serial/BUILD.gn index 2d09aaec5569387c10712fd051638606c372216a..0785376d96c4a453bd00c50033dfd14b6a1baed7 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" ] } diff --git a/usb/serial/include/libusb_serial.h b/usb/serial/include/libusb_serial.h index 9017d52f18ca15cbd5671de34e13a3d4ebca54f5..9c7c0245bd3323fde8493030bb6377be2141e252 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; @@ -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/include/linux_serial.h b/usb/serial/include/linux_serial.h index 531f899c3616c54236cef210fd1ea8e0fed4bc3d..2aeacc5b4385c35f68957d3fd0781985e0936e4b 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 diff --git a/usb/serial/include/serial_impl.h b/usb/serial/include/serial_impl.h index 89c078ff14f2bde2a12d0433fc25e0136bbcdc77..4f741be4a0567504c5cce6d1dbbd873f55561a5b 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 diff --git a/usb/serial/src/libusb_serial.cpp b/usb/serial/src/libusb_serial.cpp index abd0233360b0ce45b2d0777ba4b33e5325305c63..1e61cd7fba14facdb040115f95e380e6b833df08 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; @@ -242,7 +243,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; @@ -314,7 +315,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 +390,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 && @@ -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) { @@ -617,34 +619,35 @@ 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); + 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; + } + busnumFd = open(realpathStr, O_RDONLY); if (busnumFd < 0) { HDF_LOGE("%{public}s : open file failed. ret = %{public}s", __func__, strerror(errno)); - close(busnumFd); 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); + fdsan_close_with_tag(busnumFd, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); 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; } + 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)); 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; } diff --git a/usb/serial/src/linux_serial.cpp b/usb/serial/src/linux_serial.cpp index af97d8a4710e1b0950da15397aeaaf97e2c8e4e6..f598f51c78f0788bc48453fba0d4540da5b34047 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,19 +215,29 @@ 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) { 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)); - tcgetattr(serialPortList_[index].fd, &options_); + if (tcgetattr(serialPortList_[index].fd, &options_) = -1) { + 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; + } options_.c_lflag &= ~ICANON; options_.c_lflag &= ~ECHO; - tcsetattr(serialPortList_[index].fd, TCSANOW, &options_); - + if (tcsetattr(serialPortList_[index].fd, TCSANOW, &options_) = -1) { + 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; + } return HDF_SUCCESS; } @@ -248,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; } @@ -315,7 +327,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 +376,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 +408,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 +453,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 +486,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; diff --git a/usb/serial/src/serial_impl.cpp b/usb/serial/src/serial_impl.cpp index 0be12b7cf2e6d1c8c73a161e080a8e4229a1921e..98e58d70a94d13cd9e6e493bddd85dbe925155ce 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); } diff --git a/usb/test/unittest/BUILD.gn b/usb/test/unittest/BUILD.gn index 933d416fec19b1d2fa92ba33f9ab2f36af08e201..ee7e65dd0d254254dbf19a13e4f3ac5654196c4c 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 fc85e414515f3a50b4daa88337a3372026829893..b38b640621940256db570be18bc0635def701f7a 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 d89fdb5ce375084ee7391962df63b43af5a1e6be..f66b50f0b99fa1cb06bf7bd78f5fef73d6a3d1d9 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 59d273633020b9a39a54fa4a75340faedb988c41..da1eab00106e67119cd1c327b87ec48ffdf4275c 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 6a00b0063724acd470ee06b97b76b4504e929d61..7bfedd5de5337ca457a7eaf7686fec7b5a9a93f7 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 5c8ff42e4ec2bfc691c871c410ba149bfc9e78be..63aa1a361c2e955e4738aced513f940d5b51ca0f 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 = [ ":*" ] diff --git a/usb/test/unittest/passthrough/BUILD.gn b/usb/test/unittest/passthrough/BUILD.gn index ad66172390f5662b57c35b43c71fa501845ababe..02c45745fad714137d78571db4fbd800d1b92933 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 = [ ":*" ] diff --git a/usb/usb.gni b/usb/usb.gni index 1858e6ddd5fcc9c0ae9746b8dca3d04acf567695..c4d0eaec5ce03e7ee7bddd1ff00dd114361f97b4 100644 --- a/usb/usb.gni +++ b/usb/usb.gni @@ -17,22 +17,24 @@ 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 +} +declare_args() { 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 } diff --git a/user_auth/test/unittest/attribute_test/BUILD.gn b/user_auth/test/unittest/attribute_test/BUILD.gn index 5f9a47dc7609a5f2a10329ea7fac66c31c156271..6e836587fe7fe6766c949b71c0866bb58722fc35 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 25a8f6ae6c6fd4035d9e69e650c734dfefff51f1..adf72987dc7b868de21afc2259b650f26b88b7d0 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 b2b00edbc69b6539dd8ff82cf8a8550f72a6cdde..118df1058800a8add4922e32399887de30782282 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 e9276fe70d96a5f5816ae7b5d2a58300b7ed2b9e..1303c2c7014a291e6c6247e2168d8ba904f46bd4 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 5697743b40f5aa279e05a5f0e1f80d22c641fab3..5ab901502c8d621a3031560b95f0d52752c139d1 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 02e29aeccadb78c359421710ff558432b513d737..2732887a2b4c9a6c86040db6638a567eef1610ca 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 41df9a9bf2822b166483366bbeead1b52c75a777..92fab93f3a96429cfd913059dac2f9d6698f2007 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" ] diff --git a/vibrator/test/benchmarktest/BUILD.gn b/vibrator/test/benchmarktest/BUILD.gn index de7c572c6b59a2d96eb9602415dea3a24e8ea266..ec98a02b02f3e6841732290c434010de54ee9e3d 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/BUILD.gn b/vibrator/test/unittest/BUILD.gn index bfc1a832e066de375b6243621ae4aacb5c44eeda..7582371cd466f1f06c47af675b7e763a5ed76e9a 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 1d7ebd9095e20611bf88fbf082bf8071250623ae..ca19cdf534f646f0e55f33b8c6ebeb4f20c14edd 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 = [ @@ -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", diff --git a/wlan/chip/wifi_hal/common.cpp b/wlan/chip/wifi_hal/common.cpp index 314e17775a311339f7252dc34ba9c2c95f9c84ec..eaf3894aad5bae4b2d24e30752ee919f81059d15 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 835dd23111ce2743eb4c6c61999a3529b2416226..fee135058229fa7c5ab78ea804e2fdae3f9e86e4 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"); 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 bc7858dd0963c379a3d355003d8605c2363fd7a8..7f27eed0bdde474ffe82f74a493c5619261c724f 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; } 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 641ec768ad33fbaa8cfb3199b6a09f88b4de9442..bfeee41383c0bed904e8a4aa7c08c75dd3d3112d 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 febee0683bd5f2824f9b7574181f52c0551c6a8d..d64a29a3495ae884d44f468d28edfff6dbd8e0ec 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 };