From 1e7ff8f957166ac3c7f983f5f79f501598c1be2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 26 Jul 2025 16:21:48 +0800 Subject: [PATCH 001/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../BUILD.gn | 56 +++++++++ .../readme_zh.md | 41 +++++++ .../sensor_callback_impl.h | 96 ++++++++++++++++ .../sensor_data_volume_per_second_test.cpp | 107 ++++++++++++++++++ 4 files changed, 300 insertions(+) create mode 100644 sensor/test/unittest/sensor_data_volume_per_second_test/BUILD.gn create mode 100644 sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md create mode 100644 sensor/test/unittest/sensor_data_volume_per_second_test/sensor_callback_impl.h create mode 100644 sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/BUILD.gn b/sensor/test/unittest/sensor_data_volume_per_second_test/BUILD.gn new file mode 100644 index 0000000000..3c8c256a84 --- /dev/null +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/BUILD.gn @@ -0,0 +1,56 @@ +# 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("//build/test.gni") +import("../../../sensor.gni") + +module_output_path = "drivers_peripheral_sensor/drivers_peripheral_sensor" + +ohos_unittest("SensorDataVolumePerSecondTest") { + module_out_path = module_output_path + + include_dirs = [ + "../../../interfaces/include", + "../../../interfaces/v1_0", + "../../../utils/include", + ] + + sources = [ "sensor_data_volume_per_second_test.cpp" ] + + cflags = [ + "-Wall", + "-Wextra", + "-Werror", + "-fsigned-char", + "-fno-common", + "-fno-strict-aliasing", + ] + + if (is_standard_system) { + external_deps = [ + "drivers_interface_sensor:libsensor_proxy_3.0", + "hdf_core:libhdf_host", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_single", + ] + if (c_utils_enable) { + external_deps += [ "c_utils:utils" ] + } + } else { + external_deps = [ "hilog:libhilog" ] + } + external_deps += [ "ipc:ipc_single" ] +} \ No newline at end of file diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md new file mode 100644 index 0000000000..6a309709b8 --- /dev/null +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md @@ -0,0 +1,41 @@ +# sensorͻ1 + +> ģηsensor
+> 1ͨsetbatch(acc, 100Ƶ, )ķʽġ
+> 2ͨSetSdcSensor(acc, enable, 200ȲƵ)ķʽġ
+> ЧǣؼsetSaBatchӡɿõϱƵΪ100000000ϱƵΪ100/Σͨ־ؼOnDataEvent.*sensorType1sӡʱԼӡ۲ǷԤڡ + +--- + +## Ŀ¼ + +- [](#) +- [װ˵](#װ˵) +- [ʹʾ](#ʹʾ) +- [](#) +- [֤](#֤) + +--- + +## +**ͼ 1** Sensorģͼ +![ʾͼƬ](sensor_test.jpg) +--- + +## Ҫ죺 + +### 1. + +ú󣬷ŵͳһ·ڵǰ·ִ + +```bash +hdc target mount +hdc shell hilog -b D -D 0xD002516 +hdc file send SensorSetBatchTest /data/SensorSetBatchTest +hdc file send SensorSetSdcSensorTest /data/SensorSetSdcSensorTest +hdc shell chmod 777 /data/SensorSetBatchTest +hdc shell chmod 777 /data/SensorSetSdcSensorTest + +start cmd /k "hdc shell /data/SensorSetBatchTest" +start cmd /k "hdc shell /data/SensorSetSdcSensorTest" +parse \ No newline at end of file diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_callback_impl.h b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_callback_impl.h new file mode 100644 index 0000000000..6f01770d5f --- /dev/null +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_callback_impl.h @@ -0,0 +1,96 @@ +/* + * 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. + */ + +#ifndef OHOS_HDI_SENSOR_V3_0_SENSORCALLBACKIMPL_H +#define OHOS_HDI_SENSOR_V3_0_SENSORCALLBACKIMPL_H + +#include +#include "v3_0/isensor_callback.h" +#include "osal_mem.h" +#include +#include "sensor_uhdf_log.h" +#include "isensor_interface_vdi.h" + +#define HDF_LOG_TAG uhdf_sensor_testcase + +#define DATA_LEN 256 + +namespace OHOS { +namespace HDI { +namespace Sensor { +namespace V3_0 { +class SensorCallbackImpl : public ISensorCallback { +public: + virtual ~SensorCallbackImpl() {} + + int32_t OnDataEvent(const HdfSensorEvents& event) override + { + PrintData(event); + sensorDataCount++; + return HDF_SUCCESS; + } + + int32_t OnDataEventAsync(const std::vector& events) override + { + return HDF_SUCCESS; + } + + static int32_t sensorDataCount; + void PrintData(const HdfSensorEvents &event) + { + std::string st = {0}; + DataToStr(st, event); + printf("%s: %s\n", __func__, st.c_str()); + HDF_LOGI("%{public}s: testcase %{public}s\n", __func__, st.c_str()); + } + + void DataToStr(std::string &str, const HdfSensorEvents &event) + { + void *origin = OsalMemCalloc(sizeof(uint8_t) * (event.dataLen)); + if (origin == nullptr) { + printf("%s: OsalMemCalloc failed", __func__); + return; + } + + uint8_t *eventData = static_cast(origin); + std::copy(event.data.begin(), event.data.end(), eventData); + float *data = reinterpret_cast(eventData); + int32_t dataLen = event.dataLen; + int32_t dataDimension = static_cast(dataLen / sizeof(float)); + std::string dataStr = {0}; + char arrayStr[DATA_LEN] = {0}; + + for (int32_t i = 0; i < dataDimension; i++) { + if (sprintf_s(arrayStr + strlen(arrayStr), DATA_LEN, "[%f]", data[i]) < 0) { + printf("%s: sprintf_s failed", __func__); + OsalMemFree(origin); + return; + } + } + + dataStr = arrayStr; + str = "sensorHandle: " + SENSOR_HANDLE_TO_STRING(event.deviceSensorInfo) + ", ts: " + + std::to_string(event.timestamp / 1e9) + ", data: " + dataStr; + + OsalMemFree(origin); + return; + } +}; +} // V3_0 +} // Sensor +} // HDI +} // OHOS + +#endif // OHOS_HDI_SENSOR_V1_1_SENSORCALLBACKIMPL_H diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp new file mode 100644 index 0000000000..9b93d9ddb9 --- /dev/null +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp @@ -0,0 +1,107 @@ +/* + * 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. + */ + +#include +#include +#include +#include +#include +#include "hdf_base.h" +#include "osal_time.h" +#include "v3_0/isensor_interface.h" +#include "sensor_type.h" +#include "sensor_callback_impl.h" +#include "sensor_uhdf_log.h" +#include "sensor_trace.h" + +using namespace OHOS::HDI::Sensor::V3_0; +using namespace OHOS::HDI::Sensor; +using namespace testing::ext; +int32_t SensorCallbackImpl::sensorDataCount = 0; + +namespace { + sptr g_sensorInterface = nullptr; + sptr g_traditionalCallback = new SensorCallbackImpl(); + DeviceSensorInfo g_deviceSensorInfo = {-1, 1, 0, 1}; + int64_t g_samplingInterval = 10000000; // 10ms + int64_t g_testTime = 20000; // 20s + + class SensorSetBatchTest : public testing::Test { + public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); + }; + + void SensorSetBatchTest::SetUpTestCase() + { + g_sensorInterface = V3_0::ISensorInterface::Get(); + for (int i = 0; i < ::testing::GTEST_FLAG(command_line_flags).size(); i++) { + std::string flag = ::testing::GTEST_FLAG(command_line_flags)[i]; + + if (flag == "--sensorType" && i + 1 < ::testing::GTEST_FLAG(command_line_flags).size()) { + g_deviceSensorInfo.sensorType = std::atoi(::testing::GTEST_FLAG(command_line_flags)[i + 1].c_str()); + } else if (flag == "--samplingInterval" && i + 1 < ::testing::GTEST_FLAG(command_line_flags).size()) { + g_samplingInterval = std::atoi(::testing::GTEST_FLAG(command_line_flags)[i + 1].c_str()); + } + } + } + + void SensorSetBatchTest::TearDownTestCase() + { + } + + void SensorSetBatchTest::SetUp() + { + } + + void SensorSetBatchTest::TearDown() + { + } + + /** + * @tc.name: SensorSetBatchTest1 + * @tc.desc: Get a client and check whether the client is empty. + * @tc.type: FUNC + * @tc.require: #I4L3LF + */ + HWTEST_F(SensorSetBatchTest, SensorSetBatchTest1, TestSize.Level1) + { + int32_t ret = g_sensorInterface->Register(0, g_traditionalCallback); + EXPECT_EQ(ret, HDF_SUCCESS); + ret = g_sensorInterface->SetBatch(g_deviceSensorInfo, g_samplingInterval, 0); + printf("SetBatch({%s}, 100000000, 0)\r\n", SENSOR_HANDLE_TO_C_STR(g_deviceSensorInfo)); + EXPECT_EQ(ret, HDF_SUCCESS); + ret = g_sensorInterface->Enable(g_deviceSensorInfo); + EXPECT_EQ(ret, HDF_SUCCESS); + + for (int i = 0; i < g_testTime / 1000; i++) { + OsalMSleep(1000); + if (SensorCallbackImpl::sensorDataCount > 10 && SensorCallbackImpl::sensorDataCount < 30) { + printf("\033[32mas expected, 2000ms get sensor data count is %d\033[0m\r\n", + SensorCallbackImpl::sensorDataCount); + } else { + printf("\033[31m[ERROR] 2000ms get sensor data count is %d\033[0m\r\n", + SensorCallbackImpl::sensorDataCount); + } + } + + ret = g_sensorInterface->Disable(g_deviceSensorInfo); + EXPECT_EQ(ret, HDF_SUCCESS); + ret = g_sensorInterface->Unregister(0, g_traditionalCallback); + EXPECT_EQ(ret, HDF_SUCCESS); + } +} \ No newline at end of file -- Gitee From 88409fe37dce22166c5e0d5b3650e44215628644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 26 Jul 2025 16:28:40 +0800 Subject: [PATCH 002/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/test/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/sensor/test/BUILD.gn b/sensor/test/BUILD.gn index b041b8f069..810f80c658 100644 --- a/sensor/test/BUILD.gn +++ b/sensor/test/BUILD.gn @@ -38,6 +38,7 @@ if (defined(ohos_lite)) { "fuzztest:hdf_sensor_fuzztest", #"unittest/dump:dump_unittest_sensor", "unittest/hdi:hdi_unittest_sensor", + "unittest/sensor_data_volume_per_second_test:SensorDataVolumePerSecondTest", "unittest/sensor_test_five_clients:SensorTestFiveClients", "unittest/sensor_test_multi_clients:SensorTestMultiClients", "unittest/sensor_test_three_clients:SensorTestThreeClients", -- Gitee From b5cd792537a82a68c80ffe3845f9bf0466a2e984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 26 Jul 2025 16:55:18 +0800 Subject: [PATCH 003/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../test/unittest/sensor_data_volume_per_second_test/BUILD.gn | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/BUILD.gn b/sensor/test/unittest/sensor_data_volume_per_second_test/BUILD.gn index 3c8c256a84..f8c45387b9 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/BUILD.gn +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/BUILD.gn @@ -39,6 +39,8 @@ ohos_unittest("SensorDataVolumePerSecondTest") { if (is_standard_system) { external_deps = [ + "drivers_interface_sensor:libsensor_proxy_2.0", + "drivers_interface_sensor:libsensor_proxy_2.1", "drivers_interface_sensor:libsensor_proxy_3.0", "hdf_core:libhdf_host", "hdf_core:libhdf_utils", -- Gitee From d9a7edb8b96b720b61690f26b8cc34e9459db902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 26 Jul 2025 17:05:08 +0800 Subject: [PATCH 004/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../sensor_data_volume_per_second_test.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp index 9b93d9ddb9..f00a035cee 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp @@ -49,13 +49,11 @@ namespace { void SensorSetBatchTest::SetUpTestCase() { g_sensorInterface = V3_0::ISensorInterface::Get(); - for (int i = 0; i < ::testing::GTEST_FLAG(command_line_flags).size(); i++) { - std::string flag = ::testing::GTEST_FLAG(command_line_flags)[i]; - - if (flag == "--sensorType" && i + 1 < ::testing::GTEST_FLAG(command_line_flags).size()) { - g_deviceSensorInfo.sensorType = std::atoi(::testing::GTEST_FLAG(command_line_flags)[i + 1].c_str()); - } else if (flag == "--samplingInterval" && i + 1 < ::testing::GTEST_FLAG(command_line_flags).size()) { - g_samplingInterval = std::atoi(::testing::GTEST_FLAG(command_line_flags)[i + 1].c_str()); + for (int i = 1; i < __argc; ++i) { + if (std::strcmp(__argv[i], "--sensorType") == 0 && i + 1 < __argc) { + g_deviceSensorInfo.sensorType = std::atoi(__argv[i + 1]); + } else if (std::strcmp(__argv[i], "--samplingInterval") == 0 && i + 1 < __argc) { + g_samplingInterval = std::atoi(__argv[i + 1]); } } } -- Gitee From 5adce5df5d532540d4623af21f1ae0996870cfed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 26 Jul 2025 17:13:05 +0800 Subject: [PATCH 005/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../sensor_data_volume_per_second_test.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp index f00a035cee..2865461152 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp @@ -102,4 +102,9 @@ namespace { ret = g_sensorInterface->Unregister(0, g_traditionalCallback); EXPECT_EQ(ret, HDF_SUCCESS); } +} + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } \ No newline at end of file -- Gitee From 04cb13427dda9d49d0f0337d461072805b0d9423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 26 Jul 2025 17:15:20 +0800 Subject: [PATCH 006/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../sensor_data_volume_per_second_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp index 2865461152..e0a5935301 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include "hdf_base.h" -- Gitee From f0fa15212c82f6f893ff8321b2201fd0824b02a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 26 Jul 2025 17:20:42 +0800 Subject: [PATCH 007/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../sensor_data_volume_per_second_test.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp index e0a5935301..84b307e881 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp @@ -50,13 +50,17 @@ namespace { void SensorSetBatchTest::SetUpTestCase() { g_sensorInterface = V3_0::ISensorInterface::Get(); - for (int i = 1; i < __argc; ++i) { - if (std::strcmp(__argv[i], "--sensorType") == 0 && i + 1 < __argc) { - g_deviceSensorInfo.sensorType = std::atoi(__argv[i + 1]); - } else if (std::strcmp(__argv[i], "--samplingInterval") == 0 && i + 1 < __argc) { - g_samplingInterval = std::atoi(__argv[i + 1]); - } + const char* duration_env = std::getenv("TEST_DURATION"); + if (duration_env) { + g_duration = std::atoi(duration_env); // 转换为整数 } + // for (int i = 1; i < __argc; ++i) { + // if (std::strcmp(__argv[i], "--sensorType") == 0 && i + 1 < __argc) { + // g_deviceSensorInfo.sensorType = std::atoi(__argv[i + 1]); + // } else if (std::strcmp(__argv[i], "--samplingInterval") == 0 && i + 1 < __argc) { + // g_samplingInterval = std::atoi(__argv[i + 1]); + // } + // } } void SensorSetBatchTest::TearDownTestCase() -- Gitee From 94e3277217cd9c89521a9db879695baea9e130de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 26 Jul 2025 17:25:09 +0800 Subject: [PATCH 008/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../sensor_data_volume_per_second_test.cpp | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp index 84b307e881..aec699b17e 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp @@ -50,17 +50,14 @@ namespace { void SensorSetBatchTest::SetUpTestCase() { g_sensorInterface = V3_0::ISensorInterface::Get(); - const char* duration_env = std::getenv("TEST_DURATION"); - if (duration_env) { - g_duration = std::atoi(duration_env); // 转换为整数 + const char* testSensorType = std::getenv("testSensorType"); + if (testSensorType) { + g_deviceSensorInfo.sensorType = std::atoi(testSensorType); + } + const char* testSamplingInterval = std::getenv("testSamplingInterval"); + if (testSamplingInterval) { + g_samplingInterval = std::atoi(testSamplingInterval); } - // for (int i = 1; i < __argc; ++i) { - // if (std::strcmp(__argv[i], "--sensorType") == 0 && i + 1 < __argc) { - // g_deviceSensorInfo.sensorType = std::atoi(__argv[i + 1]); - // } else if (std::strcmp(__argv[i], "--samplingInterval") == 0 && i + 1 < __argc) { - // g_samplingInterval = std::atoi(__argv[i + 1]); - // } - // } } void SensorSetBatchTest::TearDownTestCase() @@ -107,9 +104,4 @@ namespace { ret = g_sensorInterface->Unregister(0, g_traditionalCallback); EXPECT_EQ(ret, HDF_SUCCESS); } -} - -int main(int argc, char **argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); } \ No newline at end of file -- Gitee From c774aafcb305e9ab7408e8ccce8a3fb2d4eeb949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 26 Jul 2025 17:27:44 +0800 Subject: [PATCH 009/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../readme_zh.md | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md index 6a309709b8..8bdd4525fd 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md @@ -1,41 +1,38 @@ -# sensorͻ1 +# sensor��ͻ�����������1 -> ģηsensor
-> 1ͨsetbatch(acc, 100Ƶ, )ķʽġ
-> 2ͨSetSdcSensor(acc, enable, 200ȲƵ)ķʽġ
-> ЧǣؼsetSaBatchӡɿõϱƵΪ100000000ϱƵΪ100/Σͨ־ؼOnDataEvent.*sensorType1sӡʱԼӡ۲ǷԤڡ +> ����������ģ���������η�����sensor�������
+> ����1��ͨ��setbatch(acc������, 100�������Ƶ��, ��������)�ķ�ʽ���ġ�
+> ����2��ͨ��SetSdcSensor(acc������, enable, 200���Ȳ���Ƶ��)�ķ�ʽ���ġ�
+> ����������Ч���ǣ������ؼ���setSaBatch��ӡ�ɿ������õ��ϱ�Ƶ��Ϊ100000000���������ϱ�Ƶ��Ϊ100����/�Σ�ͨ��������־�ؼ���OnDataEvent.*sensorType1s��ӡ��ʱ����Լ���ӡ�����۲��Ƿ����Ԥ�ڡ� --- ## Ŀ¼ -- [](#) -- [װ˵](#װ˵) -- [ʹʾ](#ʹʾ) -- [](#) -- [֤](#֤) +- [���](#���) +- [��װ˵��](#��װ˵��) +- [ʹ��ʾ��](#ʹ��ʾ��) +- [����](#����) +- [����֤](#����֤) --- -## -**ͼ 1** Sensorģͼ -![ʾͼƬ](sensor_test.jpg) +## ��� +**ͼ 1** Sensor��������ģ��ͼ +![ʾ��ͼƬ](sensor_test.jpg) --- -## Ҫ죺 +## ����������Ҫ�죺 -### 1. +### 1. �������� -ú󣬷ŵͳһ·ڵǰ·ִ +��������������ú󣬷ŵ�ͳһ·�����ڵ�ǰ·��ִ��������� ```bash hdc target mount hdc shell hilog -b D -D 0xD002516 -hdc file send SensorSetBatchTest /data/SensorSetBatchTest -hdc file send SensorSetSdcSensorTest /data/SensorSetSdcSensorTest -hdc shell chmod 777 /data/SensorSetBatchTest -hdc shell chmod 777 /data/SensorSetSdcSensorTest +hdc file send SensorDataVolumePerSecondTest /data/SensorDataVolumePerSecondTest +hdc shell chmod 777 /data/SensorDataVolumePerSecondTest -start cmd /k "hdc shell /data/SensorSetBatchTest" -start cmd /k "hdc shell /data/SensorSetSdcSensorTest" +start cmd /k "hdc shell 'testSensorType=1 testSamplingInterval=10000000 /data/SensorDataVolumePerSecondTest'" parse \ No newline at end of file -- Gitee From 271999a2645db4cc71af342f67f1c9e876540c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 26 Jul 2025 17:30:30 +0800 Subject: [PATCH 010/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../unittest/sensor_data_volume_per_second_test/readme_zh.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md index 8bdd4525fd..b1f7ef0b89 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md @@ -33,6 +33,7 @@ hdc target mount hdc shell hilog -b D -D 0xD002516 hdc file send SensorDataVolumePerSecondTest /data/SensorDataVolumePerSecondTest hdc shell chmod 777 /data/SensorDataVolumePerSecondTest - -start cmd /k "hdc shell 'testSensorType=1 testSamplingInterval=10000000 /data/SensorDataVolumePerSecondTest'" +hdc shell "export testSensorType=1" +hdc shell "export testSamplingInterval=10000000" +hdc shell "/data/SensorDataVolumePerSecondTest" parse \ No newline at end of file -- Gitee From ef3466ff1cb5a54b6134688c6b9163dc43c57a5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 26 Jul 2025 17:35:09 +0800 Subject: [PATCH 011/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../sensor_data_volume_per_second_test/readme_zh.md | 1 + .../sensor_callback_impl.h | 7 +++++-- .../sensor_data_volume_per_second_test.cpp | 8 ++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md index b1f7ef0b89..ff4b993286 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md @@ -35,5 +35,6 @@ hdc file send SensorDataVolumePerSecondTest /data/SensorDataVolumePerSecondTest hdc shell chmod 777 /data/SensorDataVolumePerSecondTest hdc shell "export testSensorType=1" hdc shell "export testSamplingInterval=10000000" +hdc shell "export testPrintDataFlag=false" hdc shell "/data/SensorDataVolumePerSecondTest" parse \ No newline at end of file diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_callback_impl.h b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_callback_impl.h index 6f01770d5f..6764396510 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_callback_impl.h +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_callback_impl.h @@ -48,12 +48,15 @@ public: } static int32_t sensorDataCount; + static bool printDataFlag; void PrintData(const HdfSensorEvents &event) { std::string st = {0}; DataToStr(st, event); - printf("%s: %s\n", __func__, st.c_str()); - HDF_LOGI("%{public}s: testcase %{public}s\n", __func__, st.c_str()); + if (printDataFlag) { + printf("%s: %s\n", __func__, st.c_str()); + HDF_LOGI("%{public}s: testcase %{public}s\n", __func__, st.c_str()); + } } void DataToStr(std::string &str, const HdfSensorEvents &event) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp index aec699b17e..c63e03aee1 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp @@ -31,6 +31,7 @@ using namespace OHOS::HDI::Sensor::V3_0; using namespace OHOS::HDI::Sensor; using namespace testing::ext; int32_t SensorCallbackImpl::sensorDataCount = 0; +bool SensorCallbackImpl::printDataFlag = false; namespace { sptr g_sensorInterface = nullptr; @@ -52,12 +53,19 @@ namespace { g_sensorInterface = V3_0::ISensorInterface::Get(); const char* testSensorType = std::getenv("testSensorType"); if (testSensorType) { + printf("testSensorType=%s\r\n", testSensorType); g_deviceSensorInfo.sensorType = std::atoi(testSensorType); } const char* testSamplingInterval = std::getenv("testSamplingInterval"); if (testSamplingInterval) { + printf("testSamplingInterval=%s\r\n", testSamplingInterval); g_samplingInterval = std::atoi(testSamplingInterval); } + const char* testPrintDataFlag = std::getenv("testPrintDataFlag"); + if (testPrintDataFlag) { + printf("testPrintDataFlag=%s\r\n", testPrintDataFlag); + SensorCallbackImpl::printDataFlag = std::atoi(testPrintDataFlag); + } } void SensorSetBatchTest::TearDownTestCase() -- Gitee From 1adc01382aab6410b445e2a29cdac3ae0c95a4fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 26 Jul 2025 17:38:38 +0800 Subject: [PATCH 012/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../sensor_data_volume_per_second_test/readme_zh.md | 1 + .../sensor_data_volume_per_second_test.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md index ff4b993286..74a8244709 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md @@ -36,5 +36,6 @@ hdc shell chmod 777 /data/SensorDataVolumePerSecondTest hdc shell "export testSensorType=1" hdc shell "export testSamplingInterval=10000000" hdc shell "export testPrintDataFlag=false" +hdc shell "export testTestTime=20" hdc shell "/data/SensorDataVolumePerSecondTest" parse \ No newline at end of file diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp index c63e03aee1..7c1311af7c 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp @@ -38,7 +38,7 @@ namespace { sptr g_traditionalCallback = new SensorCallbackImpl(); DeviceSensorInfo g_deviceSensorInfo = {-1, 1, 0, 1}; int64_t g_samplingInterval = 10000000; // 10ms - int64_t g_testTime = 20000; // 20s + int64_t g_testTime = 5; // 5s class SensorSetBatchTest : public testing::Test { public: @@ -66,6 +66,11 @@ namespace { printf("testPrintDataFlag=%s\r\n", testPrintDataFlag); SensorCallbackImpl::printDataFlag = std::atoi(testPrintDataFlag); } + const char* testTestTime = std::getenv("testTestTime"); + if (testTestTime) { + printf("testTestTime=%s\r\n", testTestTime); + g_testTime = std::atoi(testTestTime); + } } void SensorSetBatchTest::TearDownTestCase() -- Gitee From 5e8bd8010cef891e3ef9184244df5e2a2132fc42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Mon, 28 Jul 2025 09:53:10 +0800 Subject: [PATCH 013/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../sensor_data_volume_per_second_test/readme_zh.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md index 74a8244709..17de5fa86f 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md @@ -33,9 +33,10 @@ hdc target mount hdc shell hilog -b D -D 0xD002516 hdc file send SensorDataVolumePerSecondTest /data/SensorDataVolumePerSecondTest hdc shell chmod 777 /data/SensorDataVolumePerSecondTest -hdc shell "export testSensorType=1" -hdc shell "export testSamplingInterval=10000000" -hdc shell "export testPrintDataFlag=false" -hdc shell "export testTestTime=20" -hdc shell "/data/SensorDataVolumePerSecondTest" +hdc shell " +export testSensorType=1 +export testSamplingInterval=10000000 +export testPrintDataFlag=false +export testTestTime=20 +/data/SensorDataVolumePerSecondTest" parse \ No newline at end of file -- Gitee From 92c1b88572b1625029d967457c94fff1103c2261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Mon, 28 Jul 2025 09:57:53 +0800 Subject: [PATCH 014/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../sensor_data_volume_per_second_test/readme_zh.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md index 17de5fa86f..996344e91c 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md @@ -33,10 +33,5 @@ hdc target mount hdc shell hilog -b D -D 0xD002516 hdc file send SensorDataVolumePerSecondTest /data/SensorDataVolumePerSecondTest hdc shell chmod 777 /data/SensorDataVolumePerSecondTest -hdc shell " -export testSensorType=1 -export testSamplingInterval=10000000 -export testPrintDataFlag=false -export testTestTime=20 -/data/SensorDataVolumePerSecondTest" +hdc shell "export testSensorType=1;export testSamplingInterval=10000000;export testPrintDataFlag=false;export testTestTime=20;/data/SensorDataVolumePerSecondTest" parse \ No newline at end of file -- Gitee From 94f15ac35ed8172386304ff25a05427dfec96b84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Mon, 28 Jul 2025 10:05:35 +0800 Subject: [PATCH 015/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../readme_zh.md | 2 +- .../sensor_callback_impl.h | 1 + .../sensor_data_volume_per_second_test.cpp | 16 +++++++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md index 996344e91c..f4ea9119ce 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md @@ -33,5 +33,5 @@ hdc target mount hdc shell hilog -b D -D 0xD002516 hdc file send SensorDataVolumePerSecondTest /data/SensorDataVolumePerSecondTest hdc shell chmod 777 /data/SensorDataVolumePerSecondTest -hdc shell "export testSensorType=1;export testSamplingInterval=10000000;export testPrintDataFlag=false;export testTestTime=20;/data/SensorDataVolumePerSecondTest" +hdc shell "export testSensorType=1;export testSamplingInterval=10000000;export testPrintDataFlag=false;export testTestTime=20000;/data/SensorDataVolumePerSecondTest" parse \ No newline at end of file diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_callback_impl.h b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_callback_impl.h index 6764396510..116e7576bf 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_callback_impl.h +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_callback_impl.h @@ -48,6 +48,7 @@ public: } static int32_t sensorDataCount; + static int32_t sensorDataCountOld; static bool printDataFlag; void PrintData(const HdfSensorEvents &event) { diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp index 7c1311af7c..2cab09f2f4 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp @@ -31,6 +31,7 @@ using namespace OHOS::HDI::Sensor::V3_0; using namespace OHOS::HDI::Sensor; using namespace testing::ext; int32_t SensorCallbackImpl::sensorDataCount = 0; +int32_t SensorCallbackImpl::sensorDataCountOld = 0; bool SensorCallbackImpl::printDataFlag = false; namespace { @@ -101,14 +102,19 @@ namespace { ret = g_sensorInterface->Enable(g_deviceSensorInfo); EXPECT_EQ(ret, HDF_SUCCESS); + int32_t expectedMinCount = 1000 / (g_samplingInterval / 1000000) / 2; + int32_t expectedMaxCount = 1000 / (g_samplingInterval / 1000000) * 3 / 2; + for (int i = 0; i < g_testTime / 1000; i++) { OsalMSleep(1000); - if (SensorCallbackImpl::sensorDataCount > 10 && SensorCallbackImpl::sensorDataCount < 30) { - printf("\033[32mas expected, 2000ms get sensor data count is %d\033[0m\r\n", - SensorCallbackImpl::sensorDataCount); + int32_t countPerSecond = SensorCallbackImpl::sensorDataCount - SensorCallbackImpl::sensorDataCountOld; + SensorCallbackImpl::sensorDataCountOld = SensorCallbackImpl::sensorDataCount; + if (countPerSecond > expectedMinCount && countPerSecond < expectedMaxCount) { + printf("\033[32mas expected, 1000ms get sensor data count is %d, sensorDataCount is %d\033[0m\r\n", + countPerSecond, SensorCallbackImpl::sensorDataCount); } else { - printf("\033[31m[ERROR] 2000ms get sensor data count is %d\033[0m\r\n", - SensorCallbackImpl::sensorDataCount); + printf("\033[31m[ERROR] 1000ms get sensor data count is %d, sensorDataCount is %d\033[0m\r\n", + countPerSecond, SensorCallbackImpl::sensorDataCount); } } -- Gitee From 45bd8d93fcee9055420bbeee909e14c01417926c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Mon, 28 Jul 2025 10:12:29 +0800 Subject: [PATCH 016/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../unittest/sensor_data_volume_per_second_test/readme_zh.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md index f4ea9119ce..47707470fd 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md @@ -34,4 +34,4 @@ hdc shell hilog -b D -D 0xD002516 hdc file send SensorDataVolumePerSecondTest /data/SensorDataVolumePerSecondTest hdc shell chmod 777 /data/SensorDataVolumePerSecondTest hdc shell "export testSensorType=1;export testSamplingInterval=10000000;export testPrintDataFlag=false;export testTestTime=20000;/data/SensorDataVolumePerSecondTest" -parse \ No newline at end of file +pause \ No newline at end of file -- Gitee From be954b276e1f204a011d6ac6f4aba93dbce432c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Mon, 28 Jul 2025 10:23:30 +0800 Subject: [PATCH 017/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../sensor_data_volume_per_second_test.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp index 2cab09f2f4..ee7893bb2a 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp @@ -65,7 +65,11 @@ namespace { const char* testPrintDataFlag = std::getenv("testPrintDataFlag"); if (testPrintDataFlag) { printf("testPrintDataFlag=%s\r\n", testPrintDataFlag); - SensorCallbackImpl::printDataFlag = std::atoi(testPrintDataFlag); + if (std::strcmp(testPrintDataFlag, "true") == 0) { + SensorCallbackImpl::printDataFlag = true; + } else { + SensorCallbackImpl::printDataFlag = false; + } } const char* testTestTime = std::getenv("testTestTime"); if (testTestTime) { -- Gitee From f2d13ffec32ac17f96c8d25e804ef6f93c9331b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Mon, 28 Jul 2025 11:48:36 +0800 Subject: [PATCH 018/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../sensor_data_volume_per_second_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp index ee7893bb2a..9a9e4d2cdf 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp @@ -120,6 +120,7 @@ namespace { printf("\033[31m[ERROR] 1000ms get sensor data count is %d, sensorDataCount is %d\033[0m\r\n", countPerSecond, SensorCallbackImpl::sensorDataCount); } + fflush(stdout); } ret = g_sensorInterface->Disable(g_deviceSensorInfo); -- Gitee From 59378cb6a40f44719d087e875b5b4a0da6d64e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Mon, 28 Jul 2025 11:51:21 +0800 Subject: [PATCH 019/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../readme_zh.md | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md index 47707470fd..d811495ff6 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md @@ -1,32 +1,32 @@ -# sensor��ͻ�����������1 +# sensor多客户端能力测试2 -> ����������ģ���������η�����sensor�������
-> ����1��ͨ��setbatch(acc������, 100�������Ƶ��, ��������)�ķ�ʽ���ġ�
-> ����2��ͨ��SetSdcSensor(acc������, enable, 200���Ȳ���Ƶ��)�ķ�ʽ���ġ�
-> ����������Ч���ǣ������ؼ���setSaBatch��ӡ�ɿ������õ��ϱ�Ƶ��Ϊ100000000���������ϱ�Ƶ��Ϊ100����/�Σ�ͨ��������־�ؼ���OnDataEvent.*sensorType1s��ӡ��ʱ����Լ���ӡ�����۲��Ƿ����Ԥ�ڡ� +> 本测试用例模拟一个上游服务订阅sensor的情况,统计每秒收到数据个数,参数可以在cmd命令中修改。
+> 服务1,通过SetBatch(acc传感器, 10毫秒采样频率, 废弃参数)的方式订阅。
+> 最终期望的效果是:每秒时间内: +> 服务1,收到100帧数据,由于数据波动,在50-150之间可认为正常。 --- -## Ŀ¼ +## 目录 -- [���](#���) -- [��װ˵��](#��װ˵��) -- [ʹ��ʾ��](#ʹ��ʾ��) -- [����](#����) -- [����֤](#����֤) +- [简介](#简介) +- [安装说明](#安装说明) +- [使用示例](#使用示例) +- [贡献](#贡献) +- [许可证](#许可证) --- -## ��� -**ͼ 1** Sensor��������ģ��ͼ -![ʾ��ͼƬ](sensor_test.jpg) +## 简介 +**图 1** Sensor测试用例模拟图 +![示例图片](sensor_test.jpg) --- -## ����������Ҫ�죺 +## 运行用例的要领: -### 1. �������� +### 1. 编译用例 -��������������ú󣬷ŵ�ͳһ·�����ڵ�ǰ·��ִ��������� +将用例编译好后,放到统一路径,在当前路径执行如下命令: ```bash hdc target mount -- Gitee From f0aeded4d2a132d4225db80f692b7a751b80cb7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Mon, 28 Jul 2025 12:00:04 +0800 Subject: [PATCH 020/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../sensor_data_volume_per_second_test.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp index 9a9e4d2cdf..d08e3426ca 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp @@ -109,6 +109,9 @@ namespace { int32_t expectedMinCount = 1000 / (g_samplingInterval / 1000000) / 2; int32_t expectedMaxCount = 1000 / (g_samplingInterval / 1000000) * 3 / 2; + printf("expectedMinCount is %s, expectedMaxCount is %s\r\n", std::to_string(expectedMinCount).c_str(), + std::to_string(expectedMaxCount).c_str()); + for (int i = 0; i < g_testTime / 1000; i++) { OsalMSleep(1000); int32_t countPerSecond = SensorCallbackImpl::sensorDataCount - SensorCallbackImpl::sensorDataCountOld; -- Gitee From ff8dedb0d12f2abe35702d7b0241400190ab9eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Mon, 28 Jul 2025 07:27:00 +0000 Subject: [PATCH 021/100] update sensor/test/unittest/sensor_data_volume_per_second_test/BUILD.gn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../test/unittest/sensor_data_volume_per_second_test/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/BUILD.gn b/sensor/test/unittest/sensor_data_volume_per_second_test/BUILD.gn index f8c45387b9..4191ec2f7a 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/BUILD.gn +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../../sensor.gni") -module_output_path = "drivers_peripheral_sensor/drivers_peripheral_sensor" +module_output_path = "drivers_peripheral_sensor/drivers_peripheral_sensor/SensorDataVolumePerSecondTest" ohos_unittest("SensorDataVolumePerSecondTest") { module_out_path = module_output_path -- Gitee From 7c2f297c60095a9ff6c34bb4489f7d809e356dc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Mon, 28 Jul 2025 07:27:57 +0000 Subject: [PATCH 022/100] update sensor/test/unittest/sensor_test_five_clients/BUILD.gn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/test/unittest/sensor_test_five_clients/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensor/test/unittest/sensor_test_five_clients/BUILD.gn b/sensor/test/unittest/sensor_test_five_clients/BUILD.gn index e936716f4e..ad285d2240 100644 --- a/sensor/test/unittest/sensor_test_five_clients/BUILD.gn +++ b/sensor/test/unittest/sensor_test_five_clients/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../../sensor.gni") -module_output_path = "drivers_peripheral_sensor/drivers_peripheral_sensor" +module_output_path = "drivers_peripheral_sensor/drivers_peripheral_sensor/SensorTestFiveClients" group("SensorTestFiveClients") { deps = [] -- Gitee From 6928e66c631e515e7484c75c2ddd221ce8831e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Mon, 28 Jul 2025 07:28:16 +0000 Subject: [PATCH 023/100] update sensor/test/unittest/sensor_test_multi_clients/BUILD.gn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/test/unittest/sensor_test_multi_clients/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensor/test/unittest/sensor_test_multi_clients/BUILD.gn b/sensor/test/unittest/sensor_test_multi_clients/BUILD.gn index f43b8275a8..61496e9445 100644 --- a/sensor/test/unittest/sensor_test_multi_clients/BUILD.gn +++ b/sensor/test/unittest/sensor_test_multi_clients/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../../sensor.gni") -module_output_path = "drivers_peripheral_sensor/drivers_peripheral_sensor" +module_output_path = "drivers_peripheral_sensor/drivers_peripheral_sensor/SensorTestMultiClients" group("SensorTestMultiClients") { deps = [] -- Gitee From 34e2b2fdca5c48292b2027a91ba5294497316ee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Mon, 28 Jul 2025 07:28:33 +0000 Subject: [PATCH 024/100] update sensor/test/unittest/sensor_test_three_clients/BUILD.gn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/test/unittest/sensor_test_three_clients/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensor/test/unittest/sensor_test_three_clients/BUILD.gn b/sensor/test/unittest/sensor_test_three_clients/BUILD.gn index 1ee29a1da0..be26e5e45e 100644 --- a/sensor/test/unittest/sensor_test_three_clients/BUILD.gn +++ b/sensor/test/unittest/sensor_test_three_clients/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("../../../sensor.gni") -module_output_path = "drivers_peripheral_sensor/drivers_peripheral_sensor" +module_output_path = "drivers_peripheral_sensor/drivers_peripheral_sensor/SensorTestThreeClients" group("SensorTestThreeClients") { deps = [] -- Gitee From 4e1beba2d7a30dd11b419e47953d4e7c8ea7a884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Mon, 28 Jul 2025 07:30:59 +0000 Subject: [PATCH 025/100] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../sensor_data_volume_per_second_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp index d08e3426ca..4f399a4cc8 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp @@ -39,7 +39,7 @@ namespace { sptr g_traditionalCallback = new SensorCallbackImpl(); DeviceSensorInfo g_deviceSensorInfo = {-1, 1, 0, 1}; int64_t g_samplingInterval = 10000000; // 10ms - int64_t g_testTime = 5; // 5s + int64_t g_testTime = 5000; // 5s class SensorSetBatchTest : public testing::Test { public: -- Gitee From 4448d41aeef5585f2a613705b73369d3a3be9fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Tue, 29 Jul 2025 11:52:32 +0800 Subject: [PATCH 026/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../sensor_data_volume_per_second_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp index 4f399a4cc8..674cb68279 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/sensor_data_volume_per_second_test.cpp @@ -101,7 +101,8 @@ namespace { int32_t ret = g_sensorInterface->Register(0, g_traditionalCallback); EXPECT_EQ(ret, HDF_SUCCESS); ret = g_sensorInterface->SetBatch(g_deviceSensorInfo, g_samplingInterval, 0); - printf("SetBatch({%s}, 100000000, 0)\r\n", SENSOR_HANDLE_TO_C_STR(g_deviceSensorInfo)); + printf("SetBatch({%s}, %s, 0)\r\n", SENSOR_HANDLE_TO_C_STR(g_deviceSensorInfo), + std::to_string(g_samplingInterval).c_str()); EXPECT_EQ(ret, HDF_SUCCESS); ret = g_sensorInterface->Enable(g_deviceSensorInfo); EXPECT_EQ(ret, HDF_SUCCESS); -- Gitee From 213364f5fa16da3e23f4bb2d03cd06f2255c5ffe Mon Sep 17 00:00:00 2001 From: wanghongen Date: Wed, 13 Aug 2025 19:17:22 +0800 Subject: [PATCH 027/100] =?UTF-8?q?audio=E5=91=8A=E8=AD=A6=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wanghongen --- audio/hal/pathselect/src/audio_pathselect.c | 27 +++++---------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/audio/hal/pathselect/src/audio_pathselect.c b/audio/hal/pathselect/src/audio_pathselect.c index 08487a95dc..29f1315b2b 100644 --- a/audio/hal/pathselect/src/audio_pathselect.c +++ b/audio/hal/pathselect/src/audio_pathselect.c @@ -342,14 +342,16 @@ static int32_t SetMatchRenderOtherDevicePath( return HDF_SUCCESS; } -static int32_t ParseRenderDevice(const cJSON *cJsonObj, const struct AudioHwRenderParam *renderParam) +static int32_t AudioRenderParseDevice(struct AudioHwRenderParam *renderParam, cJSON *cJsonObj) { + int32_t ret; if (cJsonObj == NULL || renderParam == NULL) { AUDIO_FUNC_LOGE("param Is NULL"); return HDF_ERR_INVALID_PARAM; } - uint32_t pins = renderParam->renderMode.hwInfo.deviceDescript.pins; + + uint32_t tpins = pins & OUTPUT_MASK; if ((pins >> OUTPUT_OFFSET) != 0) { AUDIO_FUNC_LOGE("pins: %d, error!\n", pins); return HDF_FAILURE; @@ -360,17 +362,6 @@ static int32_t ParseRenderDevice(const cJSON *cJsonObj, const struct AudioHwRend return HDF_SUCCESS; } - return HDF_SUCCESS; -} - -static int32_t AudioRenderParseDevice(struct AudioHwRenderParam *renderParam, cJSON *cJsonObj) -{ - int32_t ret = ParseRenderDevice(cJsonObj, renderParam); - if (ret != HDF_SUCCESS) { - return ret; - } - uint32_t pins = renderParam->renderMode.hwInfo.deviceDescript.pins; - uint32_t tpins = pins & OUTPUT_MASK; switch (tpins) { case PIN_NONE: /* pins = 0, parse default value */ @@ -382,10 +373,7 @@ static int32_t AudioRenderParseDevice(struct AudioHwRenderParam *renderParam, cJ ret = SetMatchRenderDevicePath(tpins, renderParam, cJsonObj, SPEAKER, AUDIO_DEV_ON); #ifndef ALSA_LIB_MODE /* 2.close headphones */ - if (SetMatchRenderDevicePath(PIN_OUT_HEADSET, renderParam, cJsonObj, HEADPHONES, AUDIO_DEV_OFF) == - HDF_SUCCESS) { - ret = HDF_SUCCESS; - } + ret |= SetMatchRenderDevicePath(PIN_OUT_HEADSET, renderParam, cJsonObj, HEADPHONES, AUDIO_DEV_OFF); #endif break; case PIN_OUT_HEADSET: @@ -393,10 +381,7 @@ static int32_t AudioRenderParseDevice(struct AudioHwRenderParam *renderParam, cJ ret = SetMatchRenderDevicePath(tpins, renderParam, cJsonObj, HEADPHONES, AUDIO_DEV_ON); #ifndef ALSA_LIB_MODE /* 2、close speaker */ - if (SetMatchRenderDevicePath(PIN_OUT_SPEAKER, renderParam, cJsonObj, SPEAKER, AUDIO_DEV_OFF) == - HDF_SUCCESS) { - ret = HDF_SUCCESS; - } + ret |= SetMatchRenderDevicePath(PIN_OUT_SPEAKER, renderParam, cJsonObj, SPEAKER, AUDIO_DEV_OFF); #endif break; case PIN_OUT_EARPIECE: -- Gitee From 389cc3cdb7af668d38353d1003d4da4a85729a86 Mon Sep 17 00:00:00 2001 From: wanghongenaf Date: Thu, 14 Aug 2025 03:40:56 +0000 Subject: [PATCH 028/100] update audio/hal/pathselect/src/audio_pathselect.c. Signed-off-by: wanghongenaf --- audio/hal/pathselect/src/audio_pathselect.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/audio/hal/pathselect/src/audio_pathselect.c b/audio/hal/pathselect/src/audio_pathselect.c index 29f1315b2b..e70b5aebb6 100644 --- a/audio/hal/pathselect/src/audio_pathselect.c +++ b/audio/hal/pathselect/src/audio_pathselect.c @@ -373,7 +373,10 @@ static int32_t AudioRenderParseDevice(struct AudioHwRenderParam *renderParam, cJ ret = SetMatchRenderDevicePath(tpins, renderParam, cJsonObj, SPEAKER, AUDIO_DEV_ON); #ifndef ALSA_LIB_MODE /* 2.close headphones */ - ret |= SetMatchRenderDevicePath(PIN_OUT_HEADSET, renderParam, cJsonObj, HEADPHONES, AUDIO_DEV_OFF); + if (SetMatchRenderDevicePath(PIN_OUT_HEADSET, renderParam, cJsonObj, HEADPHONES, AUDIO_DEV_OFF) == + HDF_SUCCESS) { + ret = HDF_SUCCESS; + } #endif break; case PIN_OUT_HEADSET: @@ -381,7 +384,10 @@ static int32_t AudioRenderParseDevice(struct AudioHwRenderParam *renderParam, cJ ret = SetMatchRenderDevicePath(tpins, renderParam, cJsonObj, HEADPHONES, AUDIO_DEV_ON); #ifndef ALSA_LIB_MODE /* 2、close speaker */ - ret |= SetMatchRenderDevicePath(PIN_OUT_SPEAKER, renderParam, cJsonObj, SPEAKER, AUDIO_DEV_OFF); + if (SetMatchRenderDevicePath(PIN_OUT_SPEAKER, renderParam, cJsonObj, SPEAKER, AUDIO_DEV_OFF) == + HDF_SUCCESS) { + ret = HDF_SUCCESS; + } #endif break; case PIN_OUT_EARPIECE: -- Gitee From 54b0d261a8cdcb6e0105e9401dc044f2a33c5dba Mon Sep 17 00:00:00 2001 From: lx9512 <352753852@qq.com> Date: Fri, 15 Aug 2025 01:58:20 +0000 Subject: [PATCH 029/100] =?UTF-8?q?update=20wlan/chip/hdi=5Fservice/wifi?= =?UTF-8?q?=5Fhal.h.=20=E5=A2=9E=E5=8A=A0=E5=8C=BA=E5=88=86dfs=E4=BF=A1?= =?UTF-8?q?=E9=81=93=E7=9A=84=E6=89=AB=E6=8F=8F=E5=B8=A6=E5=AE=BD=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lx9512 <352753852@qq.com> --- wlan/chip/hdi_service/wifi_hal.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/wlan/chip/hdi_service/wifi_hal.h b/wlan/chip/hdi_service/wifi_hal.h index f24fea7b67..2ba8725fb5 100644 --- a/wlan/chip/hdi_service/wifi_hal.h +++ b/wlan/chip/hdi_service/wifi_hal.h @@ -68,6 +68,16 @@ enum Ieee80211Band { IEEE80211_NUM_BANDS }; +enum ScanBandType { + SCAN_BAND_UNSPECIFIED = 0, /* not specified */ + SCAN_BAND_24_GHZ = 1, /* 2.4 GHz band */ + SCAN_BAND_5_GHZ = 2, /* 5 GHz band without DFS channels */ + SCAN_BAND_BOTH = 3, /* both bands without DFS channels */ + SCAN_BAND_5_GHZ_DFS_ONLY = 4, /* 5 GHz band with DFS channels */ + SCAN_BAND_5_GHZ_WITH_DFS = 6, /* 5 GHz band with DFS channels */ + SCAN_BAND_BOTH_WITH_DFS = 7, /* both bands with DFS channels */ +}; + typedef struct { uint8_t associatedBssid[ETH_ADDR_LEN]; uint32_t associatedFreq; -- Gitee From e19694f4032e832db852b8c544d6398ad7f4d08f Mon Sep 17 00:00:00 2001 From: wanghongenaf Date: Fri, 15 Aug 2025 06:50:29 +0000 Subject: [PATCH 030/100] update audio/hal/pathselect/src/audio_pathselect.c. Signed-off-by: wanghongenaf --- audio/hal/pathselect/src/audio_pathselect.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/audio/hal/pathselect/src/audio_pathselect.c b/audio/hal/pathselect/src/audio_pathselect.c index e70b5aebb6..0fecf4ca7f 100644 --- a/audio/hal/pathselect/src/audio_pathselect.c +++ b/audio/hal/pathselect/src/audio_pathselect.c @@ -373,9 +373,9 @@ static int32_t AudioRenderParseDevice(struct AudioHwRenderParam *renderParam, cJ ret = SetMatchRenderDevicePath(tpins, renderParam, cJsonObj, SPEAKER, AUDIO_DEV_ON); #ifndef ALSA_LIB_MODE /* 2.close headphones */ - if (SetMatchRenderDevicePath(PIN_OUT_HEADSET, renderParam, cJsonObj, HEADPHONES, AUDIO_DEV_OFF) == + if (SetMatchRenderDevicePath(PIN_OUT_HEADSET, renderParam, cJsonObj, HEADPHONES, AUDIO_DEV_OFF) != HDF_SUCCESS) { - ret = HDF_SUCCESS; + ret = HDF_FAILURE; } #endif break; @@ -384,9 +384,9 @@ static int32_t AudioRenderParseDevice(struct AudioHwRenderParam *renderParam, cJ ret = SetMatchRenderDevicePath(tpins, renderParam, cJsonObj, HEADPHONES, AUDIO_DEV_ON); #ifndef ALSA_LIB_MODE /* 2、close speaker */ - if (SetMatchRenderDevicePath(PIN_OUT_SPEAKER, renderParam, cJsonObj, SPEAKER, AUDIO_DEV_OFF) == + if (SetMatchRenderDevicePath(PIN_OUT_SPEAKER, renderParam, cJsonObj, SPEAKER, AUDIO_DEV_OFF) != HDF_SUCCESS) { - ret = HDF_SUCCESS; + ret = HDF_FAILURE; } #endif break; -- Gitee From 40fe9aee3d4e629171ef4551b8a82c7cb99d3c3d Mon Sep 17 00:00:00 2001 From: chen0088 Date: Fri, 15 Aug 2025 17:54:49 +0800 Subject: [PATCH 031/100] add ut Signed-off-by: chen0088 --- .../common/dcamera_host/dcamera_host_test.cpp | 283 +++++++++++++++++- 1 file changed, 278 insertions(+), 5 deletions(-) diff --git a/distributed_camera/hdi_service/test/unittest/common/dcamera_host/dcamera_host_test.cpp b/distributed_camera/hdi_service/test/unittest/common/dcamera_host/dcamera_host_test.cpp index 9dfa45422b..ef95bb253a 100644 --- a/distributed_camera/hdi_service/test/unittest/common/dcamera_host/dcamera_host_test.cpp +++ b/distributed_camera/hdi_service/test/unittest/common/dcamera_host/dcamera_host_test.cpp @@ -20,6 +20,8 @@ #include "v1_0/icamera_device_callback.h" #include "v1_0/icamera_host_callback.h" #include "v1_2/icamera_host_callback.h" +#include "iremote_object.h" +#include "distributed_hardware_log.h" using namespace testing::ext; @@ -87,9 +89,68 @@ public: } }; +class MockIRemoteObject : public IRemoteObject { +public: + MockIRemoteObject() : IRemoteObject {u"MockIRemoteObject"} + { + } + + ~MockIRemoteObject() + { + } + + int32_t GetObjectRefCount() + { + return 0; + } + + int SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) + { + return 0; + } + + bool IsProxyObject() const + { + return true; + } + + bool CheckObjectLegality() const + { + return true; + } + + bool AddDeathRecipient(const sptr &recipient) + { + return true; + } + + bool RemoveDeathRecipient(const sptr &recipient) + { + return true; + } + + sptr AsInterface() + { + return nullptr; + } + + int Dump(int fd, const std::vector &args) + { + return 0; + } +}; + +class MockDeathRecipient : public IRemoteObject::DeathRecipient { +public: + void OnRemoteDied(const wptr &remote) + {} +}; + namespace { constexpr const char* TEST_DEVICE_ID = "bb536a637105409e904d4da83790a4a7"; const uint32_t ID_MAX_SIZE = 2 * DEVID_MAX_LENGTH; +const uint32_t ABILITYINFO_MAX_LENGTH = 50 * 1024 * 1024; +const size_t MAX_DCAMERAS_NUMBER = 32; } void DCameraHostTest::SetUpTestCase(void) @@ -157,11 +218,13 @@ HWTEST_F(DCameraHostTest, SetCallback_001, TestSize.Level1) */ HWTEST_F(DCameraHostTest, SetCallback_002, TestSize.Level1) { - sptr callback = new (std::nothrow) MockCameraHostCallback(); + sptr callback = sptr( + new (std::nothrow) MockCameraHostCallback()); int32_t ret = DCameraHost::GetInstance()->SetCallback(callback); EXPECT_EQ(ret, CamRetCode::NO_ERROR); - sptr callbackV1_2 = new (std::nothrow) MockCameraHostCallbackV12(); + sptr callbackV1_2 = sptr( + new (std::nothrow) MockCameraHostCallbackV12()); ret = DCameraHost::GetInstance()->SetCallback_V1_2(callbackV1_2); EXPECT_EQ(ret, CamRetCode::NO_ERROR); } @@ -228,7 +291,8 @@ HWTEST_F(DCameraHostTest, OpenCamera_001, TestSize.Level1) HWTEST_F(DCameraHostTest, OpenCamera_002, TestSize.Level1) { std::string nonExistentCameraId = "non_existent_camera"; - sptr mockCallback = new (std::nothrow) MockCameraDeviceCallback(); + sptr mockCallback = sptr( + new (std::nothrow) MockCameraDeviceCallback()); sptr device = nullptr; int32_t ret = DCameraHost::GetInstance()->OpenCamera(nonExistentCameraId, mockCallback, device); @@ -251,11 +315,20 @@ HWTEST_F(DCameraHostTest, AddDCameraDevice_001, TestSize.Level1) sourceCodecInfo, nullCallback); EXPECT_EQ(ret, DCamRetCode::INVALID_ARGUMENT); + std::vector cameraIds; + int32_t val = DCameraHost::GetInstance()->GetCameraIds(cameraIds); + EXPECT_EQ(val, CamRetCode::NO_ERROR); + std::string cameraId = "test001__test001"; - sptr mockCallback = new (std::nothrow) MockCameraDeviceCallback(); + std::vector cameraAbility; + val = DCameraHost::GetInstance()->GetCameraAbility(cameraId, cameraAbility); + EXPECT_EQ(val, CamRetCode::INVALID_ARGUMENT); + + sptr mockCallback = sptr( + new (std::nothrow) MockCameraDeviceCallback()); sptr device = nullptr; - int32_t val = DCameraHost::GetInstance()->OpenCamera(cameraId, mockCallback, device); + val = DCameraHost::GetInstance()->OpenCamera(cameraId, mockCallback, device); EXPECT_EQ(val, CamRetCode::INVALID_ARGUMENT); ret = DCameraHost::GetInstance()->RemoveDCameraDevice(invalidDhBase); @@ -346,5 +419,205 @@ HWTEST_F(DCameraHostTest, UnsupportedMethods_001, TestSize.Level1) ret = DCameraHost::GetInstance()->Prelaunch(config); EXPECT_EQ(ret, CamRetCode::METHOD_NOT_SUPPORTED); } + +/** + * @tc.name: AddDeviceParamCheck_001 + * @tc.desc: Verify AddDeviceParamCheck. + * @tc.type: FUNC + */ +HWTEST_F(DCameraHostTest, AddDeviceParamCheck_001, TestSize.Level1) +{ + DHBase dhBase = { "", "" }; + std::string sinkAbilityInfo = "test_sink_info"; + std::string sourceCodecInfo = "test_codec_info"; + sptr nullCallback = nullptr; + DCamRetCode ret = DCameraHost::GetInstance()->AddDeviceParamCheck(dhBase, sinkAbilityInfo, + sourceCodecInfo, nullCallback); + EXPECT_EQ(ret, DCamRetCode::INVALID_ARGUMENT); +} + +/** + * @tc.name: AddDeviceParamCheck_002 + * @tc.desc: Verify AddDeviceParamCheck. + * @tc.type: FUNC + */ +HWTEST_F(DCameraHostTest, AddDeviceParamCheck_002, TestSize.Level1) +{ + DHBase dhBase = { "test_device_id", "test_dh_id" }; + std::string sinkAbilityInfo = ""; + std::string sourceCodecInfo = ""; + sptr nullCallback = nullptr; + DCamRetCode ret = DCameraHost::GetInstance()->AddDeviceParamCheck(dhBase, sinkAbilityInfo, + sourceCodecInfo, nullCallback); + EXPECT_EQ(ret, DCamRetCode::INVALID_ARGUMENT); + + std::string longSinkInfo(ABILITYINFO_MAX_LENGTH + 1, 'a'); + ret = DCameraHost::GetInstance()->AddDeviceParamCheck(dhBase, longSinkInfo, + sourceCodecInfo, nullCallback); + EXPECT_EQ(ret, DCamRetCode::INVALID_ARGUMENT); + + sinkAbilityInfo = "test_sink_info"; + ret = DCameraHost::GetInstance()->AddDeviceParamCheck(dhBase, sinkAbilityInfo, + sourceCodecInfo, nullCallback); + EXPECT_EQ(ret, DCamRetCode::INVALID_ARGUMENT); + + std::string longCodecInfo(ABILITYINFO_MAX_LENGTH + 1, 'a'); + ret = DCameraHost::GetInstance()->AddDeviceParamCheck(dhBase, sinkAbilityInfo, + longCodecInfo, nullCallback); + EXPECT_EQ(ret, DCamRetCode::INVALID_ARGUMENT); +} + +/** + * @tc.name: AddDeviceParamCheck_003 + * @tc.desc: Verify AddDeviceParamCheck. + * @tc.type: FUNC + */ +HWTEST_F(DCameraHostTest, AddDeviceParamCheck_003, TestSize.Level1) +{ + DHBase dhBase = { "test_device_id", "test_dh_id" }; + std::string sinkAbilityInfo = "test_sink_info"; + std::string sourceCodecInfo = "test_codec_info"; + sptr nullCallback = nullptr; + for (size_t i = 0; i < MAX_DCAMERAS_NUMBER + 1; ++i) { + DCameraHost::GetInstance()->dCameraDeviceMap_["camera" + std::to_string(i)] = nullptr; + } + DCamRetCode ret = DCameraHost::GetInstance()->AddDeviceParamCheck(dhBase, sinkAbilityInfo, + sourceCodecInfo, nullCallback); + EXPECT_EQ(ret, DCamRetCode::INVALID_ARGUMENT); + DCameraHost::GetInstance()->dCameraDeviceMap_.clear(); +} + +/** + * @tc.name: AddDeviceParamCheck_004 + * @tc.desc: Verify AddDeviceParamCheck. + * @tc.type: FUNC + */ +HWTEST_F(DCameraHostTest, AddDeviceParamCheck_004, TestSize.Level1) +{ + DHBase dhBase = { "test_device_id", "test_dh_id" }; + std::string sinkAbilityInfo = "test_sink_info"; + std::string sourceCodecInfo = "test_codec_info"; + sptr nullCallback = nullptr; + DCamRetCode ret = DCameraHost::GetInstance()->AddDeviceParamCheck(dhBase, sinkAbilityInfo, + sourceCodecInfo, nullCallback); + EXPECT_EQ(ret, DCamRetCode::SUCCESS); + + DCameraHost::GetInstance()->NotifyDCameraStatus(dhBase, 0); +} + +/** + * @tc.name: AddClearRegisterRecipient_001 + * @tc.desc: Verify AddClearRegisterRecipient. + * @tc.type: FUNC + */ +HWTEST_F(DCameraHostTest, AddClearRegisterRecipient_001, TestSize.Level1) +{ + DHLOGI("AddClearRegisterRecipient_001"); + DHBase dhBase = { "test_device_id", "test_dh_id" }; + sptr remote = nullptr; + int32_t result = DCameraHost::GetInstance()->AddClearRegisterRecipient(remote, dhBase); + EXPECT_EQ(result, DCamRetCode::SUCCESS); +} + +/** + * @tc.name: AddClearRegisterRecipient_002 + * @tc.desc: Verify AddClearRegisterRecipient. + * @tc.type: FUNC + */ +HWTEST_F(DCameraHostTest, AddClearRegisterRecipient_002, TestSize.Level1) +{ + DHLOGI("AddClearRegisterRecipient_002"); + DHBase dhBase = { "test_device_id", "test_dh_id" }; + sptr remote = sptr(new (std::nothrow) MockIRemoteObject()); + ASSERT_NE(remote, nullptr); + int32_t result = DCameraHost::GetInstance()->AddClearRegisterRecipient(remote, dhBase); + EXPECT_EQ(result, DCamRetCode::SUCCESS); +} + +/** + * @tc.name: AddClearRegisterRecipient_003 + * @tc.desc: Verify AddClearRegisterRecipient. + * @tc.type: FUNC + */ +HWTEST_F(DCameraHostTest, AddClearRegisterRecipient_003, TestSize.Level1) +{ + DHLOGI("AddClearRegisterRecipient_003"); + DHBase dhBase = { "test_device_id", "test_dh_id" }; + sptr remote = sptr(new (std::nothrow) MockIRemoteObject()); + ASSERT_NE(remote, nullptr); + int32_t result = DCameraHost::GetInstance()->AddClearRegisterRecipient(remote, dhBase); + EXPECT_EQ(result, DCamRetCode::SUCCESS); +} + +/** + * @tc.name: RemoveClearRegisterRecipient_001 + * @tc.desc: Verify RemoveClearRegisterRecipient. + * @tc.type: FUNC + */ +HWTEST_F(DCameraHostTest, RemoveClearRegisterRecipient_001, TestSize.Level1) +{ + DHLOGI("RemoveClearRegisterRecipient_001"); + DHBase dhBase = { "test_device_id", "test_dh_id" }; + sptr remote = sptr(new (std::nothrow) MockIRemoteObject()); + ASSERT_NE(remote, nullptr); + int32_t result = DCameraHost::GetInstance()->AddClearRegisterRecipient(remote, dhBase); + + remote = nullptr; + result = DCameraHost::GetInstance()->RemoveClearRegisterRecipient(remote, dhBase); + EXPECT_EQ(result, DCamRetCode::SUCCESS); +} + +/** + * @tc.name: RemoveClearRegisterRecipient_002 + * @tc.desc: Verify RemoveClearRegisterRecipient. + * @tc.type: FUNC + */ +HWTEST_F(DCameraHostTest, RemoveClearRegisterRecipient_002, TestSize.Level1) +{ + DHLOGI("RemoveClearRegisterRecipient_002"); + DHBase dhBase = { "test_device_id", "test_dh_id" }; + sptr remote = sptr(new (std::nothrow) MockIRemoteObject()); + ASSERT_NE(remote, nullptr); + int32_t result = DCameraHost::GetInstance()->AddClearRegisterRecipient(remote, dhBase); + + sptr nullRemote = nullptr; + result = DCameraHost::GetInstance()->RemoveClearRegisterRecipient(nullRemote, dhBase); + EXPECT_EQ(result, DCamRetCode::SUCCESS); +} + +/** + * @tc.name: RemoveClearRegisterRecipient_003 + * @tc.desc: Verify RemoveClearRegisterRecipient. + * @tc.type: FUNC + */ +HWTEST_F(DCameraHostTest, RemoveClearRegisterRecipient_003, TestSize.Level1) +{ + DHLOGI("RemoveClearRegisterRecipient_003"); + DHBase dhBase = { "test_device_id", "test_dh_id" }; + sptr remote = sptr(new (std::nothrow) MockIRemoteObject()); + ASSERT_NE(remote, nullptr); + int32_t result = DCameraHost::GetInstance()->AddClearRegisterRecipient(remote, dhBase); + + result = DCameraHost::GetInstance()->RemoveClearRegisterRecipient(remote, dhBase); + EXPECT_EQ(result, DCamRetCode::SUCCESS); +} + +/** + * @tc.name: RemoveClearRegisterRecipient_004 + * @tc.desc: Verify RemoveClearRegisterRecipient. + * @tc.type: FUNC + */ +HWTEST_F(DCameraHostTest, RemoveClearRegisterRecipient_004, TestSize.Level1) +{ + DHLOGI("RemoveClearRegisterRecipient_004"); + DHBase dhBase = { "test_device_id", "test_dh_id" }; + sptr remote = sptr(new (std::nothrow) MockIRemoteObject()); + ASSERT_NE(remote, nullptr); + int32_t result = DCameraHost::GetInstance()->AddClearRegisterRecipient(remote, dhBase); + + DHBase dhBase2 = { "device_id", "dh_id" }; + result = DCameraHost::GetInstance()->RemoveClearRegisterRecipient(remote, dhBase2); + EXPECT_EQ(result, DCamRetCode::SUCCESS); +} } } \ No newline at end of file -- Gitee From 20fe7ae68a5a9fb0181bd6a2abb618a238b23838 Mon Sep 17 00:00:00 2001 From: yuzhiqiang_10 Date: Sat, 16 Aug 2025 15:13:35 +0800 Subject: [PATCH 032/100] port modify patch Signed-off-by: yuzhiqiang_10 --- usb/hdi_service/src/usbd_port.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/usb/hdi_service/src/usbd_port.cpp b/usb/hdi_service/src/usbd_port.cpp index 08b12e3c21..e42a018491 100644 --- a/usb/hdi_service/src/usbd_port.cpp +++ b/usb/hdi_service/src/usbd_port.cpp @@ -18,6 +18,7 @@ #include #include "hdf_base.h" #include "hdf_log.h" +#include "usbd_function.h" #include "usbd_wrapper.h" #include "usb_report_sys_event.h" #include "parameter.h" @@ -27,9 +28,6 @@ namespace HDI { namespace Usb { namespace V1_2 { -constexpr int32_t USB_FUNCTION_NONE = 0; -constexpr int32_t USB_FUNCTION_HDC = (1 << 2); -constexpr int32_t USB_FUNCTION_STORAGE = (1 << 9); constexpr uint32_t PERSIST_CONFIG_NAME_MAX_LEN = 32; UsbdPort &UsbdPort::GetInstance() -- Gitee From 348898c910c5998a08a6121732d6232bf0211654 Mon Sep 17 00:00:00 2001 From: wuminjie Date: Sun, 17 Aug 2025 11:44:01 +0800 Subject: [PATCH 033/100] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=B7=AE=E5=BC=82?= =?UTF-8?q?=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wuminjie --- camera/test/hdi/v1_3/BUILD.gn | 1 + .../v1_3/include/camera_front_uttest_v1_3.h | 1 + .../hdi/v1_3/src/camera_hdi_uttest_v1_3.cpp | 25 +++++++ camera/test/ut/v4l2/camera_fps_test.cpp | 6 +- camera/test/ut/v4l2/camera_stabili_test.cpp | 20 +++--- camera/test/ut/v4l2/camera_video_test.cpp | 40 +++++------ camera/test/ut/v4l2/double_preview_test.cpp | 12 ++-- camera/test/ut/v4l2/meta_data_test.cpp | 12 ++-- camera/test/ut/v4l2/usb_camera_test.cpp | 24 +++---- camera/test/ut/v4l2/usb_camera_test_mult.cpp | 6 +- .../buffer_adapter/lite/buffer_adapter.cpp | 8 +-- camera/vdi_base/common/pipeline_core/BUILD.gn | 2 - .../utils/selfkiller/camera_host_selfkiller.h | 2 +- .../pipeline_core/src/node/face_node.cpp | 70 +++++++++---------- .../pipeline_core/src/node/node_utils.cpp | 10 +-- .../v4l2/src/stream_operator/stream_base.cpp | 2 +- .../stream_tunnel/standard/stream_tunnel.cpp | 7 +- 17 files changed, 139 insertions(+), 109 deletions(-) diff --git a/camera/test/hdi/v1_3/BUILD.gn b/camera/test/hdi/v1_3/BUILD.gn index bb0d2bbf44..4ed869b8c8 100644 --- a/camera/test/hdi/v1_3/BUILD.gn +++ b/camera/test/hdi/v1_3/BUILD.gn @@ -64,6 +64,7 @@ ohos_unittest("camera_test_hdi_V1_3") { "//third_party/googletest:gmock_main", "//third_party/googletest:gtest", "//third_party/googletest:gtest_main", + "//base/startup/init/interfaces/innerkits:libbegetutil", ] defines = [ "CAMERA_UT_TEST" ] diff --git a/camera/test/hdi/v1_3/include/camera_front_uttest_v1_3.h b/camera/test/hdi/v1_3/include/camera_front_uttest_v1_3.h index 8f132c72db..8d29f003a8 100644 --- a/camera/test/hdi/v1_3/include/camera_front_uttest_v1_3.h +++ b/camera/test/hdi/v1_3/include/camera_front_uttest_v1_3.h @@ -16,6 +16,7 @@ #ifndef CAMERA_FRONT_UTTEST_V1_3_H #define CAMERA_FRONT_UTTEST_V1_3_H +#include "parameter.h" #include "hdi_common_v1_3.h" class CameraFrontUtTestV1_3 : public testing::Test { diff --git a/camera/test/hdi/v1_3/src/camera_hdi_uttest_v1_3.cpp b/camera/test/hdi/v1_3/src/camera_hdi_uttest_v1_3.cpp index 27cc4aed60..12210c9088 100644 --- a/camera/test/hdi/v1_3/src/camera_hdi_uttest_v1_3.cpp +++ b/camera/test/hdi/v1_3/src/camera_hdi_uttest_v1_3.cpp @@ -2292,4 +2292,29 @@ HWTEST_F(CameraHdiUtTestV1_3, Camera_Device_Hdi_V1_3_054, TestSize.Level1) CAMERA_LOGE("deferred video enhance is not supported"); printf("deferred video enhance is not supported\r\n"); } +} + +/** + * @tc.name:Camera_Device_Hdi_V1_3_055 + * @tc.desc:Camera_Device_Hdi_V1_3_055 + * @tc.size:MediumTest + * @tc.type:Function +*/ +HWTEST_F(CameraHdiUtTestV1_3, Camera_Device_Hdi_V1_3_055, TestSize.Level1) +{ + int32_t ret = cameraTest->DefferredImageExtTestInit(); + ASSERT_EQ(ret, 0); + int32_t status = SetParameter("vendor.camera.resourcecost.enable", "true"); + if (status != 0) { + HDF_LOGE("SetParameter error = %{public}d", status); + return; + } + OHOS::HDI::Camera::V1_3::CameraDeviceResourceCost resourceCost; + cameraTest->rc = cameraTest->serviceV1_3->GetResourceCost(cameraTest->cameraIds[0], resourceCost); + EXPECT_EQ(cameraTest->rc, HDI::Camera::V1_0::NO_ERROR); + status = SetParameter("vendor.camera.resourcecost.enable", "false"); + if (status != 0) { + HDF_LOGE("SetParameter error = %{public}d", status); + return; + } } \ No newline at end of file diff --git a/camera/test/ut/v4l2/camera_fps_test.cpp b/camera/test/ut/v4l2/camera_fps_test.cpp index 30b2dedf28..4d9145a094 100644 --- a/camera/test/ut/v4l2/camera_fps_test.cpp +++ b/camera/test/ut/v4l2/camera_fps_test.cpp @@ -82,10 +82,10 @@ static HWTEST_F(CameraFpsTest, camera_fps_001, TestSize.Level1) cameraBase_->StartStream(cameraBase_->intents); // updateSettings - constexpr uint32_t itemCapacity = 100; - constexpr uint32_t dataCapacity = 2000; + constexpr uint32_t ITEM_CAPACITY = 100; + constexpr uint32_t DATA_CAPACITY = 2000; std::shared_ptr meta = std::make_shared( - itemCapacity, dataCapacity); + ITEM_CAPACITY, DATA_CAPACITY); std::vector fpsRange; fpsRange.push_back(fpsRange_[0]); fpsRange.push_back(fpsRange_[1]); diff --git a/camera/test/ut/v4l2/camera_stabili_test.cpp b/camera/test/ut/v4l2/camera_stabili_test.cpp index 96334131a6..1bf2c26aea 100644 --- a/camera/test/ut/v4l2/camera_stabili_test.cpp +++ b/camera/test/ut/v4l2/camera_stabili_test.cpp @@ -75,13 +75,13 @@ static HWTEST_F(CameraStabiliTest, camera_stabili_001, TestSize.Level1) cameraBase_->StartStream(cameraBase_->intents); // updateSettings - constexpr uint32_t itemCapacity = 100; - constexpr uint32_t dataCapacity = 2000; - constexpr uint32_t dataCount = 1; + constexpr uint32_t ITEM_CAPACITY = 100; + constexpr uint32_t DATA_CAPACITY = 2000; + constexpr uint32_t DATA_COUNT = 1; std::shared_ptr meta = std::make_shared( - itemCapacity, dataCapacity); + ITEM_CAPACITY, DATA_CAPACITY); uint8_t videoStabiliMode = videoStabilizationAvailableModes_[0]; - meta->addEntry(OHOS_CONTROL_VIDEO_STABILIZATION_MODE, &videoStabiliMode, dataCount); + meta->addEntry(OHOS_CONTROL_VIDEO_STABILIZATION_MODE, &videoStabiliMode, DATA_COUNT); const int32_t deviceStreamId = cameraBase_->STREAM_ID_VIDEO; meta->addEntry(OHOS_CAMERA_STREAM_ID, &deviceStreamId, 1); std::vector setting; @@ -133,13 +133,13 @@ static HWTEST_F(CameraStabiliTest, camera_stabili_002, TestSize.Level1) cameraBase_->StartCapture(cameraBase_->STREAM_ID_VIDEO, cameraBase_->CAPTURE_ID_VIDEO, false, true); // updateSettings - constexpr uint32_t itemCapacity = 100; - constexpr uint32_t dataCapacity = 2000; - constexpr uint32_t dataCount = 1; + constexpr uint32_t ITEM_CAPACITY = 100; + constexpr uint32_t DATA_CAPACITY = 2000; + constexpr uint32_t DATA_COUNT = 1; std::shared_ptr meta = std::make_shared( - itemCapacity, dataCapacity); + ITEM_CAPACITY, DATA_CAPACITY); uint8_t videoStabiliMode = videoStabilizationAvailableModes_[0]; - meta->addEntry(OHOS_CONTROL_VIDEO_STABILIZATION_MODE, &videoStabiliMode, dataCount); + meta->addEntry(OHOS_CONTROL_VIDEO_STABILIZATION_MODE, &videoStabiliMode, DATA_COUNT); const int32_t deviceStreamId = cameraBase_->STREAM_ID_VIDEO; meta->addEntry(OHOS_CAMERA_STREAM_ID, &deviceStreamId, 1); std::vector setting; diff --git a/camera/test/ut/v4l2/camera_video_test.cpp b/camera/test/ut/v4l2/camera_video_test.cpp index 40160d3011..3b6feed82d 100644 --- a/camera/test/ut/v4l2/camera_video_test.cpp +++ b/camera/test/ut/v4l2/camera_video_test.cpp @@ -35,32 +35,32 @@ void CameraVideoTest::SetStreamInfo(StreamInfo &streamInfo, const std::shared_pt const int streamId, const StreamIntent intent) { sptr producer; - constexpr uint32_t dataSpace = 8; - constexpr uint32_t tunnelMode = 5; - constexpr uint32_t bufferQueueSize = 8; - constexpr uint32_t width = 1280; - constexpr uint32_t height = 960; + constexpr uint32_t DATA_SPACE = 8; + constexpr uint32_t TUNNEL_MODE = 5; + constexpr uint32_t BUFFER_QUEUE_SIZE = 8; + constexpr uint32_t WIDTH = 1280; + constexpr uint32_t HEIGHT = 960; if (intent == PREVIEW) { streamInfo.width_ = PREVIEW_WIDTH; streamInfo.height_ = PREVIEW_HEIGHT; } else if (intent == STILL_CAPTURE) { - streamInfo.width_ = width; - streamInfo.height_ = height; + streamInfo.width_ = WIDTH; + streamInfo.height_ = HEIGHT; streamInfo.encodeType_ = ENCODE_TYPE_JPEG; } else if (intent == VIDEO) { - streamInfo.width_ = width; - streamInfo.height_ = height; + streamInfo.width_ = WIDTH; + streamInfo.height_ = HEIGHT; streamInfo.encodeType_ = ENCODE_TYPE_H264; } streamInfo.format_ = PIXEL_FMT_RGBA_8888; streamInfo.streamId_ = streamId; - streamInfo.dataspace_ = dataSpace; + streamInfo.dataspace_ = DATA_SPACE; streamInfo.intent_ = intent; - streamInfo.tunneledMode_ = tunnelMode; + streamInfo.tunneledMode_ = TUNNEL_MODE; producer = streamCustomer->CreateProducer(); streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer); ASSERT_NE(streamInfo.bufferQueue_, nullptr); - streamInfo.bufferQueue_->producer_->SetQueueSize(bufferQueueSize); + streamInfo.bufferQueue_->producer_->SetQueueSize(BUFFER_QUEUE_SIZE); } void CameraVideoTest::CreateStream(int streamId, StreamIntent intent) @@ -144,9 +144,9 @@ void CameraVideoTest::StartCapture( void CameraVideoTest::StopStream(std::vector &captureIds, std::vector &streamIds) { - constexpr uint32_t timeForReceiveFrameOff = 1; - constexpr uint32_t timeForWaitImagePreview = 2; - sleep(timeForWaitImagePreview); + constexpr uint32_t TIME_FOR_RECEIVE_FRAME_OFF = 1; + constexpr uint32_t TIME_FOR_WAIT_IMAGE_PREVIEW = 2; + sleep(TIME_FOR_WAIT_IMAGE_PREVIEW); if (captureIds.size() > 0) { for (const auto &captureId : captureIds) { if (captureId == cameraBase_->CAPTURE_ID_PREVIEW) { @@ -155,7 +155,7 @@ void CameraVideoTest::StopStream(std::vector &captureIds, std::vector streamCustomerSnapshot_->ReceiveFrameOff(); } else if (captureId == cameraBase_->CAPTURE_ID_VIDEO) { streamCustomerVideo_->ReceiveFrameOff(); - sleep(timeForReceiveFrameOff); + sleep(TIME_FOR_RECEIVE_FRAME_OFF); } else { CAMERA_LOGE("StopStream ignore command."); } @@ -163,7 +163,7 @@ void CameraVideoTest::StopStream(std::vector &captureIds, std::vector for (auto &captureId : captureIds) { CamRetCode result = (CamRetCode)cameraBase_->streamOperator->CancelCapture(captureId); - sleep(timeForWaitImagePreview); + sleep(TIME_FOR_WAIT_IMAGE_PREVIEW); EXPECT_EQ(true, result == HDI::Camera::V1_0::NO_ERROR); if (result == HDI::Camera::V1_0::NO_ERROR) { CAMERA_LOGI("check Capture: CancelCapture success, captureId = %{public}d", captureId); @@ -173,7 +173,7 @@ void CameraVideoTest::StopStream(std::vector &captureIds, std::vector } } } - sleep(timeForReceiveFrameOff); + sleep(TIME_FOR_RECEIVE_FRAME_OFF); } /** * @tc.name: Video @@ -600,8 +600,8 @@ HWTEST_F(CameraVideoTest, camera_video_031, TestSize.Level1) captureInfo.enableShutterCallback_ = false; StartCapture(cameraBase_->STREAM_ID_CAPTURE, cameraBase_->CAPTURE_ID_CAPTURE, false, true, captureInfo); - constexpr uint32_t timeForWaitInitCaptureIds = 5; - sleep(timeForWaitInitCaptureIds); + constexpr uint32_t TIME_FOR_WAIT_INIT_CAPTUREIDS = 5; + sleep(TIME_FOR_WAIT_INIT_CAPTUREIDS); std::vector captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_VIDEO, cameraBase_->CAPTURE_ID_CAPTURE}; std::vector streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_VIDEO, diff --git a/camera/test/ut/v4l2/double_preview_test.cpp b/camera/test/ut/v4l2/double_preview_test.cpp index 26b60ef7d6..2357d2f21f 100644 --- a/camera/test/ut/v4l2/double_preview_test.cpp +++ b/camera/test/ut/v4l2/double_preview_test.cpp @@ -38,22 +38,22 @@ void DoublePreviewTest::SetStreamInfo(StreamInfo &streamInfo, const int streamId, const StreamIntent intent) { sptr producer; - constexpr uint32_t dataSpace = 8; // picture dataspace - constexpr uint32_t tunnelMode = 5; // tunnel mode - constexpr uint32_t bufferQueueSize = 8; // set bufferQueue size + constexpr uint32_t DATA_SPACE = 8; // picture dataspace + constexpr uint32_t TUNNEL_MODE = 5; // tunnel mode + constexpr uint32_t BUFFER_QUEUE_SIZE = 8; // set bufferQueue size if (intent == PREVIEW) { streamInfo.width_ = PREVIEW_WIDTH; streamInfo.height_ = PREVIEW_HEIGHT; streamInfo.format_ = PIXEL_FMT_RGBA_8888; } streamInfo.streamId_ = streamId; - streamInfo.dataspace_ = dataSpace; + streamInfo.dataspace_ = DATA_SPACE; streamInfo.intent_ = intent; - streamInfo.tunneledMode_ = tunnelMode; + streamInfo.tunneledMode_ = TUNNEL_MODE; producer = streamCustomer->CreateProducer(); streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer); ASSERT_NE(streamInfo.bufferQueue_, nullptr); - streamInfo.bufferQueue_->producer_->SetQueueSize(bufferQueueSize); + streamInfo.bufferQueue_->producer_->SetQueueSize(BUFFER_QUEUE_SIZE); } void DoublePreviewTest::CreateStream(int streamId, StreamIntent intent) diff --git a/camera/test/ut/v4l2/meta_data_test.cpp b/camera/test/ut/v4l2/meta_data_test.cpp index 02165a3689..f05bd3fa72 100644 --- a/camera/test/ut/v4l2/meta_data_test.cpp +++ b/camera/test/ut/v4l2/meta_data_test.cpp @@ -60,9 +60,9 @@ void MetaDataTest::SetStreamInfo(StreamInfo &streamInfo, const std::shared_ptr producer; - constexpr uint32_t dataSpace = 8; - constexpr uint32_t tunnelMode = 5; - constexpr uint32_t bufferQueueSize = 8; + constexpr uint32_t DATA_SPACE = 8; + constexpr uint32_t TUNNEL_MODE = 5; + constexpr uint32_t BUFFER_QUEUE_SIZE = 8; if (intent == STILL_CAPTURE) { streamInfo.encodeType_ = ENCODE_TYPE_JPEG; } else if (intent == VIDEO) { @@ -72,13 +72,13 @@ void MetaDataTest::SetStreamInfo(StreamInfo &streamInfo, const std::shared_ptrCreateProducer(); streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer); CHECK_IF_PTR_NULL_RETURN_VOID(streamInfo.bufferQueue_); - streamInfo.bufferQueue_->producer_->SetQueueSize(bufferQueueSize); + streamInfo.bufferQueue_->producer_->SetQueueSize(BUFFER_QUEUE_SIZE); } void MetaDataTest::CreateStream(int streamId, StreamIntent intent) diff --git a/camera/test/ut/v4l2/usb_camera_test.cpp b/camera/test/ut/v4l2/usb_camera_test.cpp index 54409e208b..6293059850 100644 --- a/camera/test/ut/v4l2/usb_camera_test.cpp +++ b/camera/test/ut/v4l2/usb_camera_test.cpp @@ -565,14 +565,14 @@ TEST_F(UtestUSBCameraTest, camera_usb_0020) cameraBase_->StartStream(cameraBase_->intents); // updateSettings - const uint32_t itemCapacity = 100; - const uint32_t dataCapacity = 2000; - const int32_t fpsValue = 10; + const uint32_t ITEM_CAPACITY = 100; + const uint32_t DATA_CAPACITY = 2000; + const int32_t FPS_VALUE = 10; std::shared_ptr meta = std::make_shared( - itemCapacity, dataCapacity); + ITEM_CAPACITY, DATA_CAPACITY); std::vector fpsRange; - fpsRange.push_back(fpsValue); - fpsRange.push_back(fpsValue); + fpsRange.push_back(FPS_VALUE); + fpsRange.push_back(FPS_VALUE); meta->addEntry(OHOS_CONTROL_FPS_RANGES, fpsRange.data(), fpsRange.size()); const int32_t DEVICE_STREAM_ID = 0; meta->addEntry(OHOS_CAMERA_STREAM_ID, &DEVICE_STREAM_ID, 1); @@ -889,14 +889,14 @@ TEST_F(UtestUSBCameraTest, camera_usb_0028) cameraBase_->StartStream(cameraBase_->intents); // updateSettings - const uint32_t itemCapacity = 100; - const uint32_t dataCapacity = 2000; - const int32_t fpsValue = 10; + const uint32_t ITEM_CAPACITY = 100; + const uint32_t DATA_CAPACITY = 2000; + const int32_t FPS_VALUE = 10; std::shared_ptr meta = std::make_shared( - itemCapacity, dataCapacity); + ITEM_CAPACITY, DATA_CAPACITY); std::vector fpsRange; - fpsRange.push_back(fpsValue); - fpsRange.push_back(fpsValue); + fpsRange.push_back(FPS_VALUE); + fpsRange.push_back(FPS_VALUE); meta->addEntry(OHOS_CONTROL_FPS_RANGES, fpsRange.data(), fpsRange.size()); const int32_t DEVICE_STREAM_ID = 0; meta->addEntry(OHOS_CAMERA_STREAM_ID, &DEVICE_STREAM_ID, 1); diff --git a/camera/test/ut/v4l2/usb_camera_test_mult.cpp b/camera/test/ut/v4l2/usb_camera_test_mult.cpp index aad966dc57..53c37a563b 100644 --- a/camera/test/ut/v4l2/usb_camera_test_mult.cpp +++ b/camera/test/ut/v4l2/usb_camera_test_mult.cpp @@ -249,8 +249,8 @@ void UtestUSBCameraTestMult::StartCapture(int streamId, int captureId, bool shut void UtestUSBCameraTestMult::StopStream(std::vector& captureIds, std::vector& streamIds) { - constexpr uint32_t timeForWaitCancelCapture = 2; - sleep(timeForWaitCancelCapture); + constexpr uint32_t TIME_FOR_WAIT_CANCEL_VAPTURE = 2; + sleep(TIME_FOR_WAIT_CANCEL_VAPTURE); if (captureIds.size() > 0) { for (auto &captureId : captureIds) { if (captureId == CAPTURE_ID_PREVIEW_DOUBLE) { @@ -266,7 +266,7 @@ void UtestUSBCameraTestMult::StopStream(std::vector& captureIds, std::vecto for (const auto &captureId : captureIds) { std::cout << "check Capture: CancelCapture success, captureId = " << captureId << std::endl; cameraBase_->rc = (CamRetCode)streamOperator_->CancelCapture(captureId); - sleep(timeForWaitCancelCapture); + sleep(TIME_FOR_WAIT_CANCEL_VAPTURE); EXPECT_EQ(true, cameraBase_->rc == HDI::Camera::V1_0::NO_ERROR); if (cameraBase_->rc == HDI::Camera::V1_0::NO_ERROR) { std::cout << "check Capture: CancelCapture success, captureId = " << captureId << std::endl; diff --git a/camera/vdi_base/common/buffer_manager/src/buffer_adapter/lite/buffer_adapter.cpp b/camera/vdi_base/common/buffer_manager/src/buffer_adapter/lite/buffer_adapter.cpp index 3ff3f7b09a..66c5091cc0 100644 --- a/camera/vdi_base/common/buffer_manager/src/buffer_adapter/lite/buffer_adapter.cpp +++ b/camera/vdi_base/common/buffer_manager/src/buffer_adapter/lite/buffer_adapter.cpp @@ -123,8 +123,8 @@ uint64_t BufferAdapter::CameraUsageToGrallocUsage(const uint64_t cameraUsage) { uint64_t grallocUsage = 0; uint64_t test = 1; - const uint32_t bitsPerByte = 8; // 8 bits per byte - for (uint32_t i = 0; i < sizeof(cameraUsage) * bitsPerByte; i++) { + const uint32_t BYTE = 8; // 8 bits per byte + for (uint32_t i = 0; i < sizeof(cameraUsage) * BYTE; i++) { switch (cameraUsage & (test << i)) { case CAMERA_USAGE_MEM_SHARE: grallocUsage |= BUFFER_CONSUMER_USAGE_SORTWARE; @@ -147,8 +147,8 @@ uint64_t BufferAdapter::GrallocUsageToCameraUsage(const uint64_t usage) { uint64_t cameraUsage = 0; uint64_t test = 1; - const uint32_t bitsPerByte = 8; // 8 bits per byte - for (uint32_t i = 0; i < sizeof(usage) * bitsPerByte; i++) { + const uint32_t BYTE = 8; // 8 bits per byte + for (uint32_t i = 0; i < sizeof(usage) * BYTE; i++) { switch (usage & (test << i)) { case BUFFER_CONSUMER_USAGE_SORTWARE: cameraUsage |= CAMERA_USAGE_MEM_SHARE; diff --git a/camera/vdi_base/common/pipeline_core/BUILD.gn b/camera/vdi_base/common/pipeline_core/BUILD.gn index 45c9714efc..3d95f0e867 100644 --- a/camera/vdi_base/common/pipeline_core/BUILD.gn +++ b/camera/vdi_base/common/pipeline_core/BUILD.gn @@ -169,8 +169,6 @@ ohos_shared_library("peripheral_camera_pipeline_core") { "ipc:ipc_single", ] - public_external_deps = [ "libjpeg-turbo:turbojpeg_static" ] - public_configs = [ ":pipe_config" ] install_images = [ chipset_base_dir ] subsystem_name = "hdf" diff --git a/camera/vdi_base/common/utils/selfkiller/camera_host_selfkiller.h b/camera/vdi_base/common/utils/selfkiller/camera_host_selfkiller.h index 542dc09a0d..392f71e6f7 100644 --- a/camera/vdi_base/common/utils/selfkiller/camera_host_selfkiller.h +++ b/camera/vdi_base/common/utils/selfkiller/camera_host_selfkiller.h @@ -16,7 +16,7 @@ #ifndef CAMERA_HOST_SELFKILL_H #define CAMERA_HOST_SELFKILL_H #include "thread" -#include "stdint.h" +#include "cstdint" #include "functional" #include "string" namespace OHOS::Camera { diff --git a/camera/vdi_base/usb_camera/pipeline_core/src/node/face_node.cpp b/camera/vdi_base/usb_camera/pipeline_core/src/node/face_node.cpp index 6e82d34d52..a0a337d0bb 100644 --- a/camera/vdi_base/usb_camera/pipeline_core/src/node/face_node.cpp +++ b/camera/vdi_base/usb_camera/pipeline_core/src/node/face_node.cpp @@ -108,36 +108,36 @@ RetCode FaceNode::GetCameraFaceRectangles(std::shared_ptr &metad { constexpr int32_t row = 3; constexpr int32_t col = 4; - constexpr float rectOneX = 0.0; // dummy data: faceRectangles data - constexpr float rectOneY = 0.0; - constexpr float rectOneWidth = 0.2; - constexpr float rectOneHeight = 0.3; + constexpr float rect_one_x = 0.0; // dummy data: faceRectangles data + constexpr float rect_one_y = 0.0; + constexpr float rect_one_width = 0.2; + constexpr float rect_one_height = 0.3; - constexpr float rectTwoX = 0.3; // dummy data: faceRectangles data - constexpr float rectTwoY = 0.3; - constexpr float rectTwoWidth = 0.2; - constexpr float rectTwoHeight = 0.3; + constexpr float rect_two_x = 0.3; // dummy data: faceRectangles data + constexpr float rect_two_y = 0.3; + constexpr float rect_two_width = 0.2; + constexpr float rect_two_height = 0.3; - constexpr float rectThreeX = 0.6; // dummy data: faceRectangles data - constexpr float rectThreeY = 0.6; - constexpr float rectThreeWidth = 0.2; - constexpr float rectThreeHeight = 0.3; + constexpr float rect_three_x = 0.6; // dummy data: faceRectangles data + constexpr float rect_three_y = 0.6; + constexpr float rect_three_width = 0.2; + constexpr float rect_three_height = 0.3; float faceRectangles[row][col]; - faceRectangles[INDEX_0][INDEX_0] = rectOneX; - faceRectangles[INDEX_0][INDEX_1] = rectOneY; - faceRectangles[INDEX_0][INDEX_2] = rectOneWidth; - faceRectangles[INDEX_0][INDEX_3] = rectOneHeight; - - faceRectangles[INDEX_1][INDEX_0] = rectTwoX; - faceRectangles[INDEX_1][INDEX_1] = rectTwoY; - faceRectangles[INDEX_1][INDEX_2] = rectTwoWidth; - faceRectangles[INDEX_1][INDEX_3] = rectTwoHeight; - - faceRectangles[INDEX_2][INDEX_0] = rectThreeX; - faceRectangles[INDEX_2][INDEX_1] = rectThreeY; - faceRectangles[INDEX_2][INDEX_2] = rectThreeWidth; - faceRectangles[INDEX_2][INDEX_3] = rectThreeHeight; + faceRectangles[INDEX_0][INDEX_0] = rect_one_x; + faceRectangles[INDEX_0][INDEX_1] = rect_one_y; + faceRectangles[INDEX_0][INDEX_2] = rect_one_width; + faceRectangles[INDEX_0][INDEX_3] = rect_one_height; + + faceRectangles[INDEX_1][INDEX_0] = rect_two_x; + faceRectangles[INDEX_1][INDEX_1] = rect_two_y; + faceRectangles[INDEX_1][INDEX_2] = rect_two_width; + faceRectangles[INDEX_1][INDEX_3] = rect_two_height; + + faceRectangles[INDEX_2][INDEX_0] = rect_three_x; + faceRectangles[INDEX_2][INDEX_1] = rect_three_y; + faceRectangles[INDEX_2][INDEX_2] = rect_three_width; + faceRectangles[INDEX_2][INDEX_3] = rect_three_height; metadata->addEntry(OHOS_STATISTICS_FACE_RECTANGLES, static_cast(&faceRectangles[0]), row * col); return RC_OK; @@ -146,12 +146,12 @@ RetCode FaceNode::GetCameraFaceRectangles(std::shared_ptr &metad RetCode FaceNode::GetCameraFaceIds(std::shared_ptr &metadata) { std::vector vFaceIds; - constexpr int32_t idZero = 0; - constexpr int32_t idOne = 1; - constexpr int32_t idTwo = 2; - vFaceIds.push_back(idZero); - vFaceIds.push_back(idOne); - vFaceIds.push_back(idTwo); + constexpr int32_t id_zero = 0; + constexpr int32_t id_one = 1; + constexpr int32_t id_two = 2; + vFaceIds.push_back(id_zero); + vFaceIds.push_back(id_one); + vFaceIds.push_back(id_two); metadata->addEntry(OHOS_STATISTICS_FACE_IDS, vFaceIds.data(), vFaceIds.size()); return RC_OK; } @@ -195,10 +195,10 @@ RetCode FaceNode::CopyBuffer(uint8_t *sourceBuffer, std::shared_ptr& ou RetCode FaceNode::CreateMetadataInfo() { - const int entryCapacity = 30; // 30:entry capacity - const int dataCapacity = 2000; // 2000:data capacity + const int ENTRY_CAPACITY = 30; // 30:entry capacity + const int DATA_CAPCITY = 2000; // 2000:data capacity std::unique_lock lock(mLock_); - metaData_ = std::make_shared(entryCapacity, dataCapacity); + metaData_ = std::make_shared(ENTRY_CAPACITY, DATA_CAPCITY); RetCode result = GetFaceDetectMetaData(metaData_); if (result != RC_OK) { CAMERA_LOGE("GetFaceDetectMetaData failed\n"); 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 b88d976c60..f7e8c815f1 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 @@ -145,7 +145,7 @@ void NodeUtils::BufferScaleFormatTransform(std::shared_ptr& buffer, voi } } -static void AddStrideToNV21(uint8_t* buffer, uint8_t* bufferMAX, int width, int height, int newStride) +static void AddStrideToNV21(uint8_t* buffer, uint8_t* bufferMax, int width, int height, int newStride) { const int yPlaneSize = width * height; const int uvPlaneSize = yPlaneSize / 2; @@ -160,12 +160,12 @@ static void AddStrideToNV21(uint8_t* buffer, uint8_t* bufferMAX, int width, int for (int y = (height / 2) - 1; y >= 0; --y) { uint8_t* src = buffer + yPlaneSize + y * width; uint8_t* dst = buffer + newYPlaneSize + y * newStride; - if (memmove_s(dst, bufferMAX - dst, src, width) != 0) { + if (memmove_s(dst, bufferMax - dst, src, width) != 0) { CAMERA_LOGE("AddStrideToNV21 memmove_s Fail 1"); return; } if (newStride > width) { - if (memset_s(dst + width, bufferMAX - (dst + width), 0, newStride - width)) { + if (memset_s(dst + width, bufferMax - (dst + width), 0, newStride - width)) { CAMERA_LOGE("AddStrideToNV21 memset_s Fail 1"); return; } @@ -176,12 +176,12 @@ static void AddStrideToNV21(uint8_t* buffer, uint8_t* bufferMAX, int width, int for (int y = height - 1; y >= 0; --y) { uint8_t* src = buffer + y * width; uint8_t* dst = buffer + y * newStride; - if (memmove_s(dst, bufferMAX - dst, src, width) != 0) { + if (memmove_s(dst, bufferMax - dst, src, width) != 0) { CAMERA_LOGE("AddStrideToNV21 memmove_s Fail 2"); return; } if (newStride > width) { - if (memset_s(dst + width, bufferMAX - (dst + width), 0, newStride - width)) { + if (memset_s(dst + width, bufferMax - (dst + width), 0, newStride - width)) { CAMERA_LOGE("AddStrideToNV21 memset_s Fail 2"); return; } diff --git a/camera/vdi_base/v4l2/src/stream_operator/stream_base.cpp b/camera/vdi_base/v4l2/src/stream_operator/stream_base.cpp index f66a2b393a..6ab001d97b 100644 --- a/camera/vdi_base/v4l2/src/stream_operator/stream_base.cpp +++ b/camera/vdi_base/v4l2/src/stream_operator/stream_base.cpp @@ -66,7 +66,7 @@ RetCode StreamBase::ConfigStream(StreamConfiguration& config) if (tunnel_ != nullptr) { streamConfig_.tunnelMode = true; } - streamConfig_.bufferCount = static_cast(GetBufferCount()); + streamConfig_.bufferCount = static_cast(GetBufferCount()); streamConfig_.maxBatchCaptureCount = 1; streamConfig_.maxCaptureCount = 1; // get device cappability to override configuration diff --git a/camera/vdi_base/v4l2/src/stream_operator/stream_tunnel/standard/stream_tunnel.cpp b/camera/vdi_base/v4l2/src/stream_operator/stream_tunnel/standard/stream_tunnel.cpp index 389ce66721..8f9ae78f3f 100644 --- a/camera/vdi_base/v4l2/src/stream_operator/stream_tunnel/standard/stream_tunnel.cpp +++ b/camera/vdi_base/v4l2/src/stream_operator/stream_tunnel/standard/stream_tunnel.cpp @@ -71,6 +71,10 @@ std::shared_ptr StreamTunnel::GetBuffer() int32_t timtCount = 0; OHOS::SurfaceError sfError = OHOS::SURFACE_ERROR_OK; auto tmpConfig = requestConfig_; + if (tmpConfig.format = PIXEL_FMT_BLOB) { + tmpConfig.width = BLOB_MAX_SIZE; + tmpConfig.height = 1; + } do { sfError = bufferQueue_->RequestBuffer(sb, fence, tmpConfig); if (sfError == OHOS::SURFACE_ERROR_NO_BUFFER) { @@ -137,7 +141,8 @@ static void PrepareBufferBeforeFlush(const std::shared_ptr& buffer, con CAMERA_LOGI("copy data from cb to sb, size = %{public}d", sb->GetSize()); auto ret = memcpy_s(sb->GetVirAddr(), sb->GetSize(), buffer->GetVirAddress(), availableSize); if (ret != 0) { - CAMERA_LOGE("PrepareBufferBeforeFlush memcpy_s fail, error = %{public}d", ret); + CAMERA_LOGE("PrepareBufferBeforeFlush memcpy_s fail, error = %{public}d,\ + sb->GetSize() = %{public}d, buffer->GetSize() = %{public}d", ret, sb->GetSize(), buffer->GetSize()); } } buffer->SetIsValidDataInSurfaceBuffer(false); -- Gitee From 5834d12753e5690d0f3c992ca419b4fcc7a4d3cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=8F=E6=9D=B0?= Date: Sun, 17 Aug 2025 09:21:30 +0000 Subject: [PATCH 034/100] update camera/vdi_base/v4l2/src/stream_operator/stream_tunnel/standard/stream_tunnel.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴敏杰 --- .../stream_operator/stream_tunnel/standard/stream_tunnel.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/camera/vdi_base/v4l2/src/stream_operator/stream_tunnel/standard/stream_tunnel.cpp b/camera/vdi_base/v4l2/src/stream_operator/stream_tunnel/standard/stream_tunnel.cpp index 8f9ae78f3f..59919b23cd 100644 --- a/camera/vdi_base/v4l2/src/stream_operator/stream_tunnel/standard/stream_tunnel.cpp +++ b/camera/vdi_base/v4l2/src/stream_operator/stream_tunnel/standard/stream_tunnel.cpp @@ -71,10 +71,6 @@ std::shared_ptr StreamTunnel::GetBuffer() int32_t timtCount = 0; OHOS::SurfaceError sfError = OHOS::SURFACE_ERROR_OK; auto tmpConfig = requestConfig_; - if (tmpConfig.format = PIXEL_FMT_BLOB) { - tmpConfig.width = BLOB_MAX_SIZE; - tmpConfig.height = 1; - } do { sfError = bufferQueue_->RequestBuffer(sb, fence, tmpConfig); if (sfError == OHOS::SURFACE_ERROR_NO_BUFFER) { -- Gitee From 7314cadab9dc8852f542629b4e82ae4c46736890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=8F=E6=9D=B0?= Date: Sun, 17 Aug 2025 09:22:16 +0000 Subject: [PATCH 035/100] update camera/vdi_base/v4l2/src/stream_operator/stream_tunnel/standard/stream_tunnel.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴敏杰 --- .../stream_operator/stream_tunnel/standard/stream_tunnel.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/camera/vdi_base/v4l2/src/stream_operator/stream_tunnel/standard/stream_tunnel.cpp b/camera/vdi_base/v4l2/src/stream_operator/stream_tunnel/standard/stream_tunnel.cpp index 59919b23cd..389ce66721 100644 --- a/camera/vdi_base/v4l2/src/stream_operator/stream_tunnel/standard/stream_tunnel.cpp +++ b/camera/vdi_base/v4l2/src/stream_operator/stream_tunnel/standard/stream_tunnel.cpp @@ -137,8 +137,7 @@ static void PrepareBufferBeforeFlush(const std::shared_ptr& buffer, con CAMERA_LOGI("copy data from cb to sb, size = %{public}d", sb->GetSize()); auto ret = memcpy_s(sb->GetVirAddr(), sb->GetSize(), buffer->GetVirAddress(), availableSize); if (ret != 0) { - CAMERA_LOGE("PrepareBufferBeforeFlush memcpy_s fail, error = %{public}d,\ - sb->GetSize() = %{public}d, buffer->GetSize() = %{public}d", ret, sb->GetSize(), buffer->GetSize()); + CAMERA_LOGE("PrepareBufferBeforeFlush memcpy_s fail, error = %{public}d", ret); } } buffer->SetIsValidDataInSurfaceBuffer(false); -- Gitee From 28da8e547c39b01049c34693b53c69d1a079fd27 Mon Sep 17 00:00:00 2001 From: benlau Date: Sun, 17 Aug 2025 17:33:08 +0800 Subject: [PATCH 036/100] fix crash Signed-off-by: benlau --- ethernet/eth_client/BUILD.gn | 1 + ethernet/eth_interfaces/hdi_service/BUILD.gn | 7 +++--- .../hdi_service/libethernet_hdi_service.map | 23 +++++++++++++++++++ .../hdi_service/service_common/hdi_wpa_hal.c | 2 +- .../hdi_service/service_common/hdi_wpa_hal.h | 2 +- .../service_common/wpa_common_cmd.c | 2 +- 6 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 ethernet/eth_interfaces/hdi_service/libethernet_hdi_service.map diff --git a/ethernet/eth_client/BUILD.gn b/ethernet/eth_client/BUILD.gn index bd4675bb4b..b00fc0cc9d 100644 --- a/ethernet/eth_client/BUILD.gn +++ b/ethernet/eth_client/BUILD.gn @@ -39,6 +39,7 @@ if (defined(ohos_lite)) { "-fno-strict-aliasing", "-Wno-format", "-Wno-format-extra-args", + "-fstack-protector-strong", ] subsystem_name = "hdf" diff --git a/ethernet/eth_interfaces/hdi_service/BUILD.gn b/ethernet/eth_interfaces/hdi_service/BUILD.gn index d8c3788c90..53a8df3c09 100644 --- a/ethernet/eth_interfaces/hdi_service/BUILD.gn +++ b/ethernet/eth_interfaces/hdi_service/BUILD.gn @@ -46,10 +46,7 @@ if (is_standard_system) { "-fsigned-char", "-fno-common", "-fno-strict-aliasing", - "-DCONFIG_CTRL_IFACE", - "-DCONFIG_P2P", - "-DCONFIG_WEP", - "-DCONFIG_WPS", + "-fstack-protector-strong", ] cflags += [ "-fdata-sections", @@ -75,6 +72,7 @@ if (is_standard_system) { install_images = [ chipset_base_dir, ] + version_script = "libethernet_hdi_service.map" subsystem_name = "hdf" part_name = "drivers_peripheral_ethernet" } @@ -103,6 +101,7 @@ if (is_standard_system) { "-fsigned-char", "-fno-common", "-fno-strict-aliasing", + "-fstack-protector-strong", ] cflags += [ "-fdata-sections", diff --git a/ethernet/eth_interfaces/hdi_service/libethernet_hdi_service.map b/ethernet/eth_interfaces/hdi_service/libethernet_hdi_service.map new file mode 100644 index 0000000000..30945a5bc5 --- /dev/null +++ b/ethernet/eth_interfaces/hdi_service/libethernet_hdi_service.map @@ -0,0 +1,23 @@ +# 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: + EthernetImplGetInstance; + HdfEthernetStubDriver; + HdfEthernetDriverInit; + HdfEthernetDriverBind; + HdfEthernetDriverRelease; + local: + *; +}; diff --git a/ethernet/eth_interfaces/hdi_service/service_common/hdi_wpa_hal.c b/ethernet/eth_interfaces/hdi_service/service_common/hdi_wpa_hal.c index c948bf0d8d..30c9d5448e 100644 --- a/ethernet/eth_interfaces/hdi_service/service_common/hdi_wpa_hal.c +++ b/ethernet/eth_interfaces/hdi_service/service_common/hdi_wpa_hal.c @@ -161,7 +161,7 @@ static void WpaCliClose(EthWpaInstance *p) return; } -static int WpaCliTerminate(void) +static int WpaCliTerminate(EthWpaInstance *p) { HDF_LOGI("enter WpaCliTerminate."); char cmd[WPA_CMD_BUF_LEN] = {0}; diff --git a/ethernet/eth_interfaces/hdi_service/service_common/hdi_wpa_hal.h b/ethernet/eth_interfaces/hdi_service/service_common/hdi_wpa_hal.h index 2e1fa0e40f..9ddf1b976a 100644 --- a/ethernet/eth_interfaces/hdi_service/service_common/hdi_wpa_hal.h +++ b/ethernet/eth_interfaces/hdi_service/service_common/hdi_wpa_hal.h @@ -40,7 +40,7 @@ struct EthWpaInstance { pthread_t tid; int (*wpaCliConnect)(EthWpaInstance *p); void (*wpaCliClose)(EthWpaInstance *p); - int (*wpaCliTerminate)(); + int (*wpaCliTerminate)(EthWpaInstance *p); int (*wpaCliCmdSetNetwork)(EthWpaInstance *p, const char *ifName, const char *name, const char *value); int (*wpaCliCmdStaShellCmd)(EthWpaInstance *p, const char *ifName, const char *params); }; diff --git a/ethernet/eth_interfaces/hdi_service/service_common/wpa_common_cmd.c b/ethernet/eth_interfaces/hdi_service/service_common/wpa_common_cmd.c index c4ef40c6a8..c6534c012b 100644 --- a/ethernet/eth_interfaces/hdi_service/service_common/wpa_common_cmd.c +++ b/ethernet/eth_interfaces/hdi_service/service_common/wpa_common_cmd.c @@ -225,7 +225,7 @@ static int32_t StopWpaSupplicant(void) HDF_LOGE("%{public}s: Get wpa global interface failed!", __func__); return HDF_FAILURE; } - int ret = pWpaInstance->wpaCliTerminate(); + int ret = pWpaInstance->wpaCliTerminate(pWpaInstance); HDF_LOGI("%{public}s: wpaCliTerminate ret = %{public}d", __func__, ret); return HDF_SUCCESS; } -- Gitee From 3f9858a8c2c96ea9c8d89fdaa8a2135b2f0790ab Mon Sep 17 00:00:00 2001 From: lx9512 <352753852@qq.com> Date: Mon, 18 Aug 2025 08:25:58 +0000 Subject: [PATCH 037/100] update wlan/chip/wifi_hal/gscan.cpp. Signed-off-by: lx9512 <352753852@qq.com> --- wlan/chip/wifi_hal/gscan.cpp | 58 +++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/wlan/chip/wifi_hal/gscan.cpp b/wlan/chip/wifi_hal/gscan.cpp index 2933093673..12694fa127 100644 --- a/wlan/chip/wifi_hal/gscan.cpp +++ b/wlan/chip/wifi_hal/gscan.cpp @@ -57,6 +57,37 @@ public: return ret; } + void AddFreqs(bool& isDfsChannel, uint32_t& freq) + { + switch (mBand) { + case SCAN_BAND_24_GHZ: + if (freq > LOW_LITMIT_FREQ_2_4G && freq < HIGH_LIMIT_FREQ_2_4G) { + mFreqs.push_back(freq); + } + break; + case SCAN_BAND_5_GHZ: + if (isDfsChannel) { + break; + } + if (freq > LOW_LIMIT_FREQ_5G && freq < HIGH_LIMIT_FREQ_5G) { + mFreqs.push_back(freq); + } + break; + case SCAN_BAND_5_GHZ_DFS_ONLY: + if (isDfsChannel && freq > LOW_LIMIT_FREQ_5G && freq < HIGH_LIMIT_FREQ_5G) { + mFreqs.push_back(freq); + } + break; + case SCAN_BAND_5_GHZ_WITH_DFS: + if (freq > LOW_LIMIT_FREQ_5G && freq < HIGH_LIMIT_FREQ_5G) { + mFreqs.push_back(freq); + } + break; + default: + break; + } + } + void GetCenterFreq(struct nlattr *bands) { struct nlattr *attrFreq[NL80211_FREQUENCY_ATTR_MAX + 1]; @@ -68,6 +99,7 @@ public: static struct nla_policy freqPolicy[NL80211_FREQUENCY_ATTR_MAX + 1]; freqPolicy[NL80211_FREQUENCY_ATTR_FREQ].type = NLA_U32; freqPolicy[NL80211_FREQUENCY_ATTR_MAX_TX_POWER].type = NLA_U32; + enum nl80211_dfs_state dfs_state; nla_for_each_nested(nlFreq, bands, i) { data = nla_data(nlFreq); @@ -79,21 +111,14 @@ public: if (attrFreq[NL80211_FREQUENCY_ATTR_DISABLED] != nullptr) { continue; } - freq = nla_get_u32(attrFreq[NL80211_FREQUENCY_ATTR_FREQ]); - switch (mBand) { - case NL80211_BAND_2GHZ: - if (freq > LOW_LITMIT_FREQ_2_4G && freq < HIGH_LIMIT_FREQ_2_4G) { - mFreqs.push_back(freq); - } - break; - case NL80211_BAND_5GHZ: - if (freq > LOW_LIMIT_FREQ_5G && freq < HIGH_LIMIT_FREQ_5G) { - mFreqs.push_back(freq); - } - break; - default: - break; + bool isDfsChannel = false; + if (attrFreq[NL80211_FREQUENCY_ATTR_DFS_STATE] != nullptr) { + dfs_state = static_cast( + nla_get_u32(attrFreq[NL80211_FREQUENCY_ATTR_DFS_STATE])); + isDfsChannel = (dfs_state == NL80211_DFS_USABLE || dfs_state == NL80211_DFS_AVAILABLE); } + freq = nla_get_u32(attrFreq[NL80211_FREQUENCY_ATTR_FREQ]); + AddFreqs(isDfsChannel, freq); } } @@ -140,10 +165,7 @@ WifiError VendorHalGetChannelsInBand(wifiInterfaceHandle handle, HDF_LOGE("Handle is null"); return HAL_INVALID_ARGS; } - if (band > 0 && band <= IEEE80211_NUM_BANDS) { - band = band - 1; - } - if (band >= IEEE80211_NUM_BANDS) { + if (band > SCAN_BAND_BOTH_WITH_DFS || band <= SCAN_BAND_UNSPECIFIED) { HDF_LOGE("Invalid input parameter, band = %{public}d", band); return HAL_INVALID_ARGS; } -- Gitee From adee958eb8bd39adaf9d8509b3e8ace761a0522e Mon Sep 17 00:00:00 2001 From: lx9512 <352753852@qq.com> Date: Mon, 18 Aug 2025 09:44:24 +0000 Subject: [PATCH 038/100] update wlan/chip/wifi_hal/gscan.cpp. Signed-off-by: lx9512 <352753852@qq.com> --- wlan/chip/wifi_hal/gscan.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wlan/chip/wifi_hal/gscan.cpp b/wlan/chip/wifi_hal/gscan.cpp index 12694fa127..7f1196565c 100644 --- a/wlan/chip/wifi_hal/gscan.cpp +++ b/wlan/chip/wifi_hal/gscan.cpp @@ -99,7 +99,7 @@ public: static struct nla_policy freqPolicy[NL80211_FREQUENCY_ATTR_MAX + 1]; freqPolicy[NL80211_FREQUENCY_ATTR_FREQ].type = NLA_U32; freqPolicy[NL80211_FREQUENCY_ATTR_MAX_TX_POWER].type = NLA_U32; - enum nl80211_dfs_state dfs_state; + enum nl80211_dfs_state dfsState; nla_for_each_nested(nlFreq, bands, i) { data = nla_data(nlFreq); @@ -113,9 +113,9 @@ public: } bool isDfsChannel = false; if (attrFreq[NL80211_FREQUENCY_ATTR_DFS_STATE] != nullptr) { - dfs_state = static_cast( + dfsState = static_cast( nla_get_u32(attrFreq[NL80211_FREQUENCY_ATTR_DFS_STATE])); - isDfsChannel = (dfs_state == NL80211_DFS_USABLE || dfs_state == NL80211_DFS_AVAILABLE); + isDfsChannel = (dfsState == NL80211_DFS_USABLE || dfsState == NL80211_DFS_AVAILABLE); } freq = nla_get_u32(attrFreq[NL80211_FREQUENCY_ATTR_FREQ]); AddFreqs(isDfsChannel, freq); -- Gitee From 6a5f5ea8291b51471d95f1e9ba0fbaf231bf23a0 Mon Sep 17 00:00:00 2001 From: lin_c <1946558487@qq.com> Date: Tue, 19 Aug 2025 08:22:39 +0000 Subject: [PATCH 039/100] update codec/test/benchmarktest/BUILD.gn. Signed-off-by: lin_c <1946558487@qq.com> --- codec/test/benchmarktest/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codec/test/benchmarktest/BUILD.gn b/codec/test/benchmarktest/BUILD.gn index c77a6c953c..add94daa73 100644 --- a/codec/test/benchmarktest/BUILD.gn +++ b/codec/test/benchmarktest/BUILD.gn @@ -16,7 +16,7 @@ import("//build/test.gni") import("../../codec.gni") ohos_benchmarktest("hdf_codec_benchmark_test") { - module_out_path = "drivers_peripheral_codec/codec" + module_out_path = "drivers_peripheral_codec/drivers_peripheral_codec" include_dirs = [ "./include", "../../interfaces/include", -- Gitee From 48c4173794a111154bcc2468b062026e5054316d Mon Sep 17 00:00:00 2001 From: lin_c <1946558487@qq.com> Date: Tue, 19 Aug 2025 08:23:44 +0000 Subject: [PATCH 040/100] update codec/test/unittest/hdi_image/BUILD.gn. Signed-off-by: lin_c <1946558487@qq.com> --- codec/test/unittest/hdi_image/BUILD.gn | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codec/test/unittest/hdi_image/BUILD.gn b/codec/test/unittest/hdi_image/BUILD.gn index 487432eb23..43e25f5383 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/drivers_peripheral_codec/codec" + module_out_path = "drivers_peripheral_codec/drivers_peripheral_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/drivers_peripheral_codec/codec" + module_out_path = "drivers_peripheral_codec/drivers_peripheral_codec" sources = [ "codec_hdi_heif_encode_test.cpp" ] @@ -74,7 +74,7 @@ ohos_unittest("codec_hdi_heif_encode_test") { } ohos_unittest("codec_hdi_heif_decode_test") { - module_out_path = "drivers_peripheral_codec/codec" + module_out_path = "drivers_peripheral_codec/drivers_peripheral_codec" sources = [ "codec_hdi_heif_decode_test.cpp" ] -- Gitee From 88a7f199f6720b5f00fa69ae9e12ea1843f3f202 Mon Sep 17 00:00:00 2001 From: lin_c <1946558487@qq.com> Date: Tue, 19 Aug 2025 08:24:27 +0000 Subject: [PATCH 041/100] update codec/test/unittest/idl_omx/BUILD.gn. Signed-off-by: lin_c <1946558487@qq.com> --- codec/test/unittest/idl_omx/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codec/test/unittest/idl_omx/BUILD.gn b/codec/test/unittest/idl_omx/BUILD.gn index 25b2e8cf9b..03a8ffad75 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/drivers_peripheral_codec/codec" + module_out_path = "drivers_peripheral_codec/drivers_peripheral_codec" include_dirs = [ "./", "../../../interfaces/include", -- Gitee From a3ce3a357c6c70fc128da47c4126627be8a52e5a Mon Sep 17 00:00:00 2001 From: xuxuehai Date: Tue, 19 Aug 2025 19:24:24 +0800 Subject: [PATCH 042/100] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuxuehai --- usb/gadget/function/mtp/include/usbfn_mtp_impl.h | 2 +- usb/libusb_adapter/include/libusb_adapter.h | 3 +-- usb/libusb_adapter/src/libusb_adapter.cpp | 16 +++++++++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/usb/gadget/function/mtp/include/usbfn_mtp_impl.h b/usb/gadget/function/mtp/include/usbfn_mtp_impl.h index b85a8189fd..7a0ba0a78c 100644 --- a/usb/gadget/function/mtp/include/usbfn_mtp_impl.h +++ b/usb/gadget/function/mtp/include/usbfn_mtp_impl.h @@ -260,7 +260,7 @@ private: static sem_t asyncReq_; static pthread_rwlock_t mtpRunrwLock_; std::vector vectorSplited_; - uint32_t writeActualLen_; + uint32_t writeActualLen_ = 0; }; } // namespace V1_0 } // namespace Mtp diff --git a/usb/libusb_adapter/include/libusb_adapter.h b/usb/libusb_adapter/include/libusb_adapter.h index dba12720c6..041c54dbc8 100644 --- a/usb/libusb_adapter/include/libusb_adapter.h +++ b/usb/libusb_adapter/include/libusb_adapter.h @@ -192,6 +192,7 @@ public: int32_t GetRawDescriptor(const UsbDev &dev, std::vector &descriptor); int32_t GetCurrentInterfaceSetting(const UsbDev &dev, uint8_t &settingIndex); int32_t GetDeviceMemMapFd(const UsbDev &dev, int &fd); + int32_t GetDevices(std::vector &devices); int32_t SetSubscriber(sptr subscriber); int32_t RemoveSubscriber(sptr subscriber); void ReportUsbdRecognitionFailSysEvent(const std::string &operationType, int32_t code, @@ -201,7 +202,6 @@ public: int32_t AsyncSubmitTransfer(const UsbDev &dev, const V1_2::USBTransferInfo &info, const sptr &cb, const sptr &ashmem); int32_t AsyncCancelTransfer(const UsbDev &dev, const int32_t endpoint); - int32_t GetDevices(std::vector &devices); /* Bulk Transfer */ int32_t BulkRead(const UsbDev &dev, const UsbPipe &pipe, const sptr &ashmem); @@ -246,7 +246,6 @@ private: int32_t GetCurrentConfiguration(libusb_device_handle *handle, int32_t ¤tConfig); int32_t RemoveInterfaceFromMap(const UsbDev &dev, libusb_device_handle *devHandle, uint8_t interfaceId); bool IsInterfaceIdByUsbDev(const UsbDev &dev, const uint8_t intfId); - /* Async Transfer */ void TransferInit(const UsbDev &dev); void TransferRelease(const UsbDev &dev); diff --git a/usb/libusb_adapter/src/libusb_adapter.cpp b/usb/libusb_adapter/src/libusb_adapter.cpp index 478c47a550..e8f992df23 100644 --- a/usb/libusb_adapter/src/libusb_adapter.cpp +++ b/usb/libusb_adapter/src/libusb_adapter.cpp @@ -85,6 +85,7 @@ constexpr const char* USB_DEV_FS_PATH = "/dev/bus/usb"; constexpr const char* LIBUSB_DEVICE_MMAP_PATH = "/data/service/el1/public/usb/"; constexpr uint32_t MIN_NUM_OF_ISO_PACKAGE = 1; constexpr uint32_t SHIFT_32 = 32; +constexpr unsigned int USB_CTRL_SET_TIMEOUT = 5000 const uint8_t INVALID_NUM = 222; static libusb_context *g_libusb_context = nullptr; static std::shared_ptr g_LibusbAdapter = std::make_shared(); @@ -108,7 +109,6 @@ std::shared_mutex g_mapMutexUsbOpenFdMap; std::shared_mutex g_mapMutexHandleMap; static LibusbAsyncManager g_asyncManager; static LibusbBulkManager g_bulkManager; -#define USB_CTRL_SET_TIMEOUT 5000 static uint64_t ToDdkDeviceId(int32_t busNum, int32_t devNum) { @@ -277,7 +277,6 @@ int32_t LibusbAdapter::OpenDevice(const UsbDev &dev) ReportUsbdRecognitionFailSysEvent("OpenDevice", ret, "GetUsbDevice failed"); return HDF_DEV_ERR_NO_DEVICE; } - libusb_device_handle* devHandle = nullptr; uint32_t result = (static_cast(dev.busNum) << DISPLACEMENT_NUMBER) | static_cast(dev.devAddr); @@ -1223,6 +1222,10 @@ int32_t LibusbAdapter::GetFileDescriptor(const UsbDev &dev, int32_t &fd) int32_t LibusbAdapter::GetDeviceSpeed(const UsbDev &dev, uint8_t &speed) { HDF_LOGI("%{public}s enter", __func__); + if (g_libusb_context == nullptr) { + HDF_LOGE("%{public}s: g_libusb_context is nullptr", __func__); + return HDF_FAILURE; + } libusb_device *device = nullptr; int32_t ret = GetUsbDevice(dev, &device); if (ret != HDF_SUCCESS || device == nullptr) { @@ -2029,8 +2032,12 @@ void LibusbAdapter::LibusbEventHandling() if (rc != LIBUSB_SUCCESS) { HDF_LOGE("%{public}s: libusb handle events failed: %{public}d", __func__, rc); } + } else { + HDF_LOGE("%{public}s: g_libusb_context is nullptr", __func__); + break; } } + HDF_LOGI("%{public}s: libusb event handling thread ended.", __func__); } int32_t LibusbAdapter::FillAndSubmitTransfer(LibusbAsyncTransfer *asyncTransfer, libusb_device_handle *devHandle, @@ -2195,7 +2202,6 @@ void LibusbAdapter::DeleteTransferFromList(LibusbAsyncTransfer *asyncTransfer) } HDF_LOGI("%{public}s: enter delete transfer from list, bus num: %{public}d, dev addr: %{public}d", __func__, asyncTransfer->busNum, asyncTransfer->devAddr); - std::lock_guard managerLock(g_asyncManager.transferVecLock); LibusbAsyncWrapper *asyncWrapper = GetAsyncWrapper({asyncTransfer->busNum, asyncTransfer->devAddr}); if (asyncWrapper == nullptr) { @@ -2382,11 +2388,11 @@ int32_t LibusbAdapter::WriteAshmem(const sptr &ashmem, int32_t length, u int32_t LibusbAdapter::GetDevices(std::vector &devices) { HDF_LOGD("%{public}s: enter", __func__); + libusb_device **devs = nullptr; if (g_libusb_context == nullptr) { HDF_LOGE("%{public}s: g_libusb_context is nullptr", __func__); return HDF_FAILURE; } - libusb_device **devs = nullptr; ssize_t count = libusb_get_device_list(g_libusb_context, &devs); HDF_LOGI("%{public}s: libusb_get_device_list return count: %{public}zu", __func__, count); for (ssize_t i = 0; i < count; ++i) { @@ -3089,7 +3095,7 @@ int32_t LibusbAdapter::LoadUsbSaCallback(libusb_context* ctx, libusb_device* dev HDF_LOGI("%{public}s: enter.", __func__); if (event == LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED) { if (libUsbSaSubscriber_ == nullptr) { - HDF_LOGE("%{public}s: libUsbSaSubscriber is nullptr", __func__); + HDF_LOGI("%{public}s: libUsbSaSubscriber is nullptr", __func__); return HDF_FAILURE; } libUsbSaSubscriber_->LoadUsbSa(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED); -- Gitee From 941359d10cbbd27087f2d7080d9387488de401e8 Mon Sep 17 00:00:00 2001 From: xuxuehai Date: Tue, 19 Aug 2025 21:11:29 +0800 Subject: [PATCH 043/100] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuxuehai --- usb/libusb_adapter/src/libusb_adapter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usb/libusb_adapter/src/libusb_adapter.cpp b/usb/libusb_adapter/src/libusb_adapter.cpp index e8f992df23..1f816ffc5c 100644 --- a/usb/libusb_adapter/src/libusb_adapter.cpp +++ b/usb/libusb_adapter/src/libusb_adapter.cpp @@ -85,7 +85,7 @@ constexpr const char* USB_DEV_FS_PATH = "/dev/bus/usb"; constexpr const char* LIBUSB_DEVICE_MMAP_PATH = "/data/service/el1/public/usb/"; constexpr uint32_t MIN_NUM_OF_ISO_PACKAGE = 1; constexpr uint32_t SHIFT_32 = 32; -constexpr unsigned int USB_CTRL_SET_TIMEOUT = 5000 +constexpr unsigned int USB_CTRL_SET_TIMEOUT = 5000; const uint8_t INVALID_NUM = 222; static libusb_context *g_libusb_context = nullptr; static std::shared_ptr g_LibusbAdapter = std::make_shared(); -- Gitee From 37aa3590961b22a37a92906d7a2f07a928b11bf3 Mon Sep 17 00:00:00 2001 From: Anduin1109 Date: Wed, 20 Aug 2025 09:46:51 +0800 Subject: [PATCH 044/100] avoid UAF in linux_adapter Signed-off-by: Anduin1109 --- usb/ddk/host/src/linux_adapter.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/usb/ddk/host/src/linux_adapter.c b/usb/ddk/host/src/linux_adapter.c index c0b2cfec36..bd0135da13 100644 --- a/usb/ddk/host/src/linux_adapter.c +++ b/usb/ddk/host/src/linux_adapter.c @@ -24,6 +24,7 @@ #define HDF_LOG_TAG USB_LINUX_ADAPTER #define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define IS_VALID_ADDR(x) ((uint64_t)(x) & 0xfc00000000000000 == 0 ? true : false) #define PATH_LEN 50 #define DESC_READ_LEN 256 @@ -1530,7 +1531,6 @@ static int32_t AdapterUrbCompleteHandle(const struct UsbDeviceHandle *devHandle) struct UsbAdapterUrb *urb = NULL; struct UsbHostRequest *request = NULL; int32_t ret; - if (devHandle == NULL || devHandle->dev == NULL) { HDF_LOGE("%{public}s:%{public}d invalid parameter", __func__, __LINE__); return HDF_ERR_INVALID_PARAM; @@ -1544,10 +1544,8 @@ static int32_t AdapterUrbCompleteHandle(const struct UsbDeviceHandle *devHandle) if (errno == ENODEV) { return HDF_DEV_ERR_NO_DEVICE; } - return HDF_ERR_IO; } - if (urb == NULL || urb->userContext == NULL) { HDF_LOGE("%{public}s:%{public}d urb is NULL or userContext is NULL", __func__, __LINE__); return HDF_ERR_IO; @@ -1559,6 +1557,11 @@ static int32_t AdapterUrbCompleteHandle(const struct UsbDeviceHandle *devHandle) HDF_LOGE("%{public}s:%{public}d reap discardurb", __func__, __LINE__); return HDF_FAILURE; } + if (!IS_VALID_ADDR(urb) || !IS_VALID_ADDR(request)) { + HDF_LOGE("%{public}s:%{public}d urb or request is freed"); + return HDF_ERR_IO; + } + switch (request->requestType) { case USB_REQUEST_TYPE_CONTROL: ret = OsControlCompletion(request, urb); @@ -1576,7 +1579,6 @@ static int32_t AdapterUrbCompleteHandle(const struct UsbDeviceHandle *devHandle) ret = HDF_FAILURE; break; } - return ret; } -- Gitee From 678792c2e9356d4d61834a842184980cac685267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Wed, 20 Aug 2025 10:07:17 +0800 Subject: [PATCH 045/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- light/test/BUILD.gn | 2 -- sensor/hal/src/sensor_channel.c | 2 ++ sensor/hal/src/sensor_controller.c | 1 - sensor/hdi_service/sensor_if_service.cpp | 6 +----- sensor/hdi_service_3.0/sensor_if_service.cpp | 2 ++ sensor/interfaces/include/sensor_type.h | 1 + sensor/interfaces/v1_0/isensor_interface_vdi.h | 6 ++++-- vibrator/hdi_service_2.0/vibrator_if_service.cpp | 2 +- vibrator/test/unittest/hdi/hdf_vibrator_hdi_test.cpp | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/light/test/BUILD.gn b/light/test/BUILD.gn index fff868c2cc..b8e35c9eda 100644 --- a/light/test/BUILD.gn +++ b/light/test/BUILD.gn @@ -45,8 +45,6 @@ if (defined(ohos_lite)) { "unittest/hdi:hdf_unittest_hdi_light", "unittest/hdi:hdf_unittest_hdi_light_common", ] - } else { - deps += [ "unittest/hdi:hdi_unittest_light" ] } } } diff --git a/sensor/hal/src/sensor_channel.c b/sensor/hal/src/sensor_channel.c index 74a7b2fe9a..5d56f78989 100644 --- a/sensor/hal/src/sensor_channel.c +++ b/sensor/hal/src/sensor_channel.c @@ -27,6 +27,7 @@ #define ACCEL_ACCURACY ((HDI_SENSOR_GRAVITY) / (HDI_SENSOR_UNITS) / (HDI_SENSOR_UNITS)) #define GYRO_ACCURACY ((1 / (HDI_SENSOR_FLOAT_UNITS)) * ((HDI_SENSOR_PI) / (HDI_SENSOR_SEMICIRCLE))) #define BAROMETER_BAROMETER_ACCURACY (1 / (HDI_SENSOR_FLOAT_HUN_UNITS)) +#define DEPTH_DEPTH_ACCURACY (1 / (HDI_SENSOR_FLOAT_HUN_UNITS)) #define BAROMETER_TEMPERATURE_ACCURACY (1 / (HDI_SENSOR_FLOAT_TEN_UNITS)) #define MAGNETIC_ACCURACY (1 / (HDI_SENSOR_FLOAT_UNITS)) #define ALS_ACCURACY (1 / (HDI_SENSOR_FLOAT_UNITS)) @@ -52,6 +53,7 @@ static struct SensorCovertCoff g_sensorCovertCoff[] = { { SENSOR_TYPE_PROXIMITY, SENSOR_TYPE_MAX, DATA_X, { PROXIMITY_ACCURACY } }, { SENSOR_TYPE_TEMPERATURE, SENSOR_TYPE_MAX, DATA_X, { TEMPERATURE_ACCURACY } }, { SENSOR_TYPE_HUMIDITY, SENSOR_TYPE_MAX, DATA_X, { HUMIDITY_ACCURACY } }, + { SENSOR_TYPE_DEPTH, SENSOR_TYPE_MAX, DATA_XY, { DEPTH_DEPTH_ACCURACY, BAROMETER_TEMPERATURE_ACCURACY } }, }; static struct SensorDumpDate g_dumpDate = { 0 }; diff --git a/sensor/hal/src/sensor_controller.c b/sensor/hal/src/sensor_controller.c index 34741622f6..61f5fd1ae9 100644 --- a/sensor/hal/src/sensor_controller.c +++ b/sensor/hal/src/sensor_controller.c @@ -441,7 +441,6 @@ static int32_t ReadData(int32_t sensorId, struct SensorEvents *event) HdfSbufRecycle(msg); return SENSOR_FAILURE; } - CHECK_NULL_PTR_RETURN_VALUE(reply, SENSOR_NULL_PTR); if (!HdfSbufWriteInt32(msg, sensorId)) { HDF_LOGE("%{public}s: Sensor write id failed", __func__); diff --git a/sensor/hdi_service/sensor_if_service.cpp b/sensor/hdi_service/sensor_if_service.cpp index f8e40d5940..caff02fbf2 100644 --- a/sensor/hdi_service/sensor_if_service.cpp +++ b/sensor/hdi_service/sensor_if_service.cpp @@ -731,13 +731,9 @@ void SensorIfService::VoteInterval(int32_t sensorId, uint32_t serviceId, int64_t if (enabled) { sdcIntervalMap[sensorId][serviceId] = samplingInterval; } else { - samplingInterval = 0; sdcIntervalMap[sensorId].erase(serviceId); } for (auto it = sdcIntervalMap[sensorId].begin(); it != sdcIntervalMap[sensorId].end(); ++it) { - if (samplingInterval == 0) { - samplingInterval = it->second; - } samplingInterval = samplingInterval < it->second ? samplingInterval : it->second; } HDF_LOGI("%{public}s: samplingInterval is %{public}s", __func__, std::to_string(samplingInterval).c_str()); @@ -762,8 +758,8 @@ int32_t SensorIfService::SetSdcSensor(int32_t sensorId, bool enabled, int32_t ra } int64_t samplingInterval = rateLevel == REPORT_INTERVAL ? REPORT_INTERVAL : COMMON_REPORT_FREQUENCY / rateLevel; int64_t reportInterval = REPORT_INTERVAL; - VoteInterval(sensorId, serviceId, samplingInterval, enabled); VoteEnable(sensorId, serviceId, enabled); + VoteInterval(sensorId, serviceId, samplingInterval, enabled); if (enabled) { ret = SetBatchSenior(serviceId, sensorId, SDC, samplingInterval, reportInterval); if (ret != SENSOR_SUCCESS) { diff --git a/sensor/hdi_service_3.0/sensor_if_service.cpp b/sensor/hdi_service_3.0/sensor_if_service.cpp index 25397784de..768c695d36 100644 --- a/sensor/hdi_service_3.0/sensor_if_service.cpp +++ b/sensor/hdi_service_3.0/sensor_if_service.cpp @@ -80,7 +80,9 @@ int32_t SensorIfService::GetSensorVdiImplV1_1() { struct OHOS::HDI::Sensor::V1_1::WrapperSensorVdi *wrapperSensorVdi = nullptr; uint32_t version = 0; + HDF_LOGI("%{public}s: start HdfLoadVdi(%{public}s)", __func__, HDI_SENSOR_VDI_LIBNAME); vdi_ = HdfLoadVdi(HDI_SENSOR_VDI_LIBNAME); + HDF_LOGI("%{public}s: finish HdfLoadVdi(%{public}s)", __func__, HDI_SENSOR_VDI_LIBNAME); if (vdi_ == nullptr || vdi_->vdiBase == nullptr) { HDF_LOGE("%{public}s: load sensor vdi failed", __func__); return HDF_FAILURE; diff --git a/sensor/interfaces/include/sensor_type.h b/sensor/interfaces/include/sensor_type.h index 623be3a1e6..e3a531c6e2 100644 --- a/sensor/interfaces/include/sensor_type.h +++ b/sensor/interfaces/include/sensor_type.h @@ -90,6 +90,7 @@ enum SensorTypeTag { SENSOR_TYPE_AMBIENT_LIGHT1 = 16, /**< Secondary ambient light sensor*/ SENSOR_TYPE_HALL1 = 17, /**< Secondary hall effect sensor */ SENSOR_TYPE_PROXIMITY1 = 18, /**< Secondary proximity sensor */ + SENSOR_TYPE_DEPTH = 19, /**< Depth sensor */ SENSOR_TYPE_MEDICAL_BEGIN = 128, /**< The begin of medical sensorId enumeration value range */ SENSOR_TYPE_MEDICAL_END = 160, /**< The end of medical sensorId enumeration value range */ SENSOR_TYPE_PHYSICAL_MAX = 255, /**< Maximum type of a physical sensor */ diff --git a/sensor/interfaces/v1_0/isensor_interface_vdi.h b/sensor/interfaces/v1_0/isensor_interface_vdi.h index 4f6a6fd404..1366c1233b 100644 --- a/sensor/interfaces/v1_0/isensor_interface_vdi.h +++ b/sensor/interfaces/v1_0/isensor_interface_vdi.h @@ -61,7 +61,6 @@ namespace std { return h1 ^ h2 ^ h3 ^ h4; #else std::size_t h2 = std::hash{}(obj.sensorType); - return h2; #endif } @@ -79,8 +78,11 @@ namespace OHOS { namespace HDI { namespace Sensor { namespace V1_1 { - +#ifdef TV_FLAG +#define HDI_SENSOR_VDI_LIBNAME "libhdi_product_sensor_impl.z.so" +#else #define HDI_SENSOR_VDI_LIBNAME "libhdi_sensor_impl.z.so" +#endif struct HdfSensorInformationVdi { std::string sensorName; diff --git a/vibrator/hdi_service_2.0/vibrator_if_service.cpp b/vibrator/hdi_service_2.0/vibrator_if_service.cpp index 296b4b05b8..6e40c88323 100644 --- a/vibrator/hdi_service_2.0/vibrator_if_service.cpp +++ b/vibrator/hdi_service_2.0/vibrator_if_service.cpp @@ -656,7 +656,7 @@ int32_t VibratorIfService::PlayPackageBySession( default: hapticEventVdi.type = VDI_UNKNOWN; HDF_LOGE("%{public}s: unknown event type %{public}d", __func__, event.type); - continue; + break; } hapticEventVdi.time = event.time; hapticEventVdi.duration = event.duration; diff --git a/vibrator/test/unittest/hdi/hdf_vibrator_hdi_test.cpp b/vibrator/test/unittest/hdi/hdf_vibrator_hdi_test.cpp index ee0d07103d..29e432521c 100644 --- a/vibrator/test/unittest/hdi/hdf_vibrator_hdi_test.cpp +++ b/vibrator/test/unittest/hdi/hdf_vibrator_hdi_test.cpp @@ -40,7 +40,7 @@ namespace { V1_2::HapticPaket g_pkg = {434, 1, {{V1_2::CONTINUOUS, 0, 149, 100, 50, 0, 4, {{0, 0, 0}, {1, 1, 0}, {32, 1, -39}, {149, 0, -39}}}}}; V1_2::HapticPaket g_pkg1 = {434, 1, {{V1_2::TRANSIENT, 0, 149, 100, 50, 0, 4, - {{0, 0, 0}, {1, 1, 0}, {32, 1, -39}, {149, 0, -39}}}}}; + {{0, 0, 0}, {1, 1, 0}, {32, 1, -39}, {149, 0, -39}}}}}}; int32_t g_vibratorId = 0; std::vector g_info; constexpr int32_t MIN_DURATION = 0; -- Gitee From b70f203c5a34132ac7c68b67ba171d59d0f36767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Wed, 20 Aug 2025 10:27:07 +0800 Subject: [PATCH 046/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hal/src/sensor_controller.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sensor/hal/src/sensor_controller.c b/sensor/hal/src/sensor_controller.c index 61f5fd1ae9..dd2db89487 100644 --- a/sensor/hal/src/sensor_controller.c +++ b/sensor/hal/src/sensor_controller.c @@ -436,11 +436,7 @@ static int32_t ReadData(int32_t sensorId, struct SensorEvents *event) struct HdfSBuf *msg = HdfSbufObtainDefaultSize(); CHECK_NULL_PTR_RETURN_VALUE(msg, SENSOR_NULL_PTR); struct HdfSBuf *reply = HdfSbufObtain(HDF_SENSOR_EVENT_MAX_SIZE); - if (reply == NULL) { - HDF_LOGE("%s: Sensor write id fail!", __func__); - HdfSbufRecycle(msg); - return SENSOR_FAILURE; - } + CHECK_NULL_PTR_RETURN_VALUE(reply, SENSOR_NULL_PTR); if (!HdfSbufWriteInt32(msg, sensorId)) { HDF_LOGE("%{public}s: Sensor write id failed", __func__); -- Gitee From 2d51a9476ba21485a74292d972b13c4beaa73ce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Wed, 20 Aug 2025 10:31:42 +0800 Subject: [PATCH 047/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hal/src/sensor_controller.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sensor/hal/src/sensor_controller.c b/sensor/hal/src/sensor_controller.c index dd2db89487..61f5fd1ae9 100644 --- a/sensor/hal/src/sensor_controller.c +++ b/sensor/hal/src/sensor_controller.c @@ -436,7 +436,11 @@ static int32_t ReadData(int32_t sensorId, struct SensorEvents *event) struct HdfSBuf *msg = HdfSbufObtainDefaultSize(); CHECK_NULL_PTR_RETURN_VALUE(msg, SENSOR_NULL_PTR); struct HdfSBuf *reply = HdfSbufObtain(HDF_SENSOR_EVENT_MAX_SIZE); - CHECK_NULL_PTR_RETURN_VALUE(reply, SENSOR_NULL_PTR); + if (reply == NULL) { + HDF_LOGE("%s: Sensor write id fail!", __func__); + HdfSbufRecycle(msg); + return SENSOR_FAILURE; + } if (!HdfSbufWriteInt32(msg, sensorId)) { HDF_LOGE("%{public}s: Sensor write id failed", __func__); -- Gitee From 96368a5c8e24a9e9d243eda2bbf77c29ccb4bf22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Wed, 20 Aug 2025 10:35:44 +0800 Subject: [PATCH 048/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- vibrator/test/unittest/hdi/hdf_vibrator_hdi_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vibrator/test/unittest/hdi/hdf_vibrator_hdi_test.cpp b/vibrator/test/unittest/hdi/hdf_vibrator_hdi_test.cpp index 29e432521c..ee0d07103d 100644 --- a/vibrator/test/unittest/hdi/hdf_vibrator_hdi_test.cpp +++ b/vibrator/test/unittest/hdi/hdf_vibrator_hdi_test.cpp @@ -40,7 +40,7 @@ namespace { V1_2::HapticPaket g_pkg = {434, 1, {{V1_2::CONTINUOUS, 0, 149, 100, 50, 0, 4, {{0, 0, 0}, {1, 1, 0}, {32, 1, -39}, {149, 0, -39}}}}}; V1_2::HapticPaket g_pkg1 = {434, 1, {{V1_2::TRANSIENT, 0, 149, 100, 50, 0, 4, - {{0, 0, 0}, {1, 1, 0}, {32, 1, -39}, {149, 0, -39}}}}}}; + {{0, 0, 0}, {1, 1, 0}, {32, 1, -39}, {149, 0, -39}}}}}; int32_t g_vibratorId = 0; std::vector g_info; constexpr int32_t MIN_DURATION = 0; -- Gitee From 96c77ff549ce0fca6981a8fa805078990bc617bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Wed, 20 Aug 2025 10:36:11 +0800 Subject: [PATCH 049/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- vibrator/test/unittest/hdi/hdi_unittest_vibrator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vibrator/test/unittest/hdi/hdi_unittest_vibrator.cpp b/vibrator/test/unittest/hdi/hdi_unittest_vibrator.cpp index b08de2a71a..9135f53f93 100644 --- a/vibrator/test/unittest/hdi/hdi_unittest_vibrator.cpp +++ b/vibrator/test/unittest/hdi/hdi_unittest_vibrator.cpp @@ -41,7 +41,7 @@ namespace { V2_0::HapticPaket g_hapticPaket = {434, 1, {{V2_0::TRANSIENT, 0, 149, 100, 50, 0, 4, {{0, 0, 0}, {1, 1, 0}, {32, 1, -39}, {149, 0, -39}}}}}; V2_0::VibratorPackage g_vibPackage = {434, 149, {{434, 1, {{V2_0::TRANSIENT, 0, 149, 100, 50, 0, 4, - {{0, 0, 0}, {1, 1, 0}, {32, 1, -39}, {149, 0, -39}}}}}}; + {{0, 0, 0}, {1, 1, 0}, {32, 1, -39}, {149, 0, -39}}}}}}}; int32_t g_intensity = 60; int32_t g_sessionId = 1 ; std::vector g_info; -- Gitee From 400c0734bad8ba59048e3195c9c2af1960254f45 Mon Sep 17 00:00:00 2001 From: Anduin1109 Date: Wed, 20 Aug 2025 10:37:08 +0800 Subject: [PATCH 050/100] avoid UAF in CompleteHandle Signed-off-by: Anduin1109 --- usb/ddk/host/src/linux_adapter.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/usb/ddk/host/src/linux_adapter.c b/usb/ddk/host/src/linux_adapter.c index bd0135da13..5ad0c04cbf 100644 --- a/usb/ddk/host/src/linux_adapter.c +++ b/usb/ddk/host/src/linux_adapter.c @@ -24,7 +24,6 @@ #define HDF_LOG_TAG USB_LINUX_ADAPTER #define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define IS_VALID_ADDR(x) ((uint64_t)(x) & 0xfc00000000000000 == 0 ? true : false) #define PATH_LEN 50 #define DESC_READ_LEN 256 @@ -33,6 +32,13 @@ #define USB_DEVICE_MMAP_PATH "/data/service/el1/public/usb/" #define MAX_RETRY_TIMES 10 +static bool IsInvalidAddress(void *ptr) { + if (((uint64_t)(ptr) & 0xfc00000000000000) != 0) { + return true; + } + return false; +} + static void *OsAdapterRealloc(void *ptr, size_t oldSize, size_t newSize) { void *mem = RawUsbMemAlloc(newSize); @@ -1546,22 +1552,17 @@ static int32_t AdapterUrbCompleteHandle(const struct UsbDeviceHandle *devHandle) } return HDF_ERR_IO; } - if (urb == NULL || urb->userContext == NULL) { - HDF_LOGE("%{public}s:%{public}d urb is NULL or userContext is NULL", __func__, __LINE__); - return HDF_ERR_IO; + if (urb == NULL || urb->userContext == NULL || IsInvalidAddress(urb) || IsInvalidAddress(urb->userContext)) { + HDF_LOGE("%{public}s:%{public}d urb or userContext is invalid", __func__, __LINE__); + return HDF_ERR_IO; } - - request = urb->userContext; if (devHandle->dev->discardFailedUrb == (void *)urb) { devHandle->dev->discardFailedUrb = NULL; HDF_LOGE("%{public}s:%{public}d reap discardurb", __func__, __LINE__); return HDF_FAILURE; } - if (!IS_VALID_ADDR(urb) || !IS_VALID_ADDR(request)) { - HDF_LOGE("%{public}s:%{public}d urb or request is freed"); - return HDF_ERR_IO; - } + request = urb->userContext; switch (request->requestType) { case USB_REQUEST_TYPE_CONTROL: ret = OsControlCompletion(request, urb); -- Gitee From 9affacc2d9ecdb89cd78e8926b4caa89a63c6cc6 Mon Sep 17 00:00:00 2001 From: Anduin1109 Date: Wed, 20 Aug 2025 10:38:23 +0800 Subject: [PATCH 051/100] avoid UAF in CompleteHandle Signed-off-by: Anduin1109 --- usb/ddk/host/src/linux_adapter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usb/ddk/host/src/linux_adapter.c b/usb/ddk/host/src/linux_adapter.c index 5ad0c04cbf..545e5ce325 100644 --- a/usb/ddk/host/src/linux_adapter.c +++ b/usb/ddk/host/src/linux_adapter.c @@ -1553,8 +1553,8 @@ static int32_t AdapterUrbCompleteHandle(const struct UsbDeviceHandle *devHandle) return HDF_ERR_IO; } if (urb == NULL || urb->userContext == NULL || IsInvalidAddress(urb) || IsInvalidAddress(urb->userContext)) { - HDF_LOGE("%{public}s:%{public}d urb or userContext is invalid", __func__, __LINE__); - return HDF_ERR_IO; + HDF_LOGE("%{public}s:%{public}d urb or userContext is invalid", __func__, __LINE__); + return HDF_ERR_IO; } if (devHandle->dev->discardFailedUrb == (void *)urb) { devHandle->dev->discardFailedUrb = NULL; -- Gitee From 7ce16a5dba98a0b4ff32c8581e34e523fd104316 Mon Sep 17 00:00:00 2001 From: Anduin1109 Date: Wed, 20 Aug 2025 10:45:16 +0800 Subject: [PATCH 052/100] avoid UAF in CompleteHandle Signed-off-by: Anduin1109 --- usb/ddk/host/src/linux_adapter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usb/ddk/host/src/linux_adapter.c b/usb/ddk/host/src/linux_adapter.c index 545e5ce325..f4c8ca1f9d 100644 --- a/usb/ddk/host/src/linux_adapter.c +++ b/usb/ddk/host/src/linux_adapter.c @@ -32,7 +32,8 @@ #define USB_DEVICE_MMAP_PATH "/data/service/el1/public/usb/" #define MAX_RETRY_TIMES 10 -static bool IsInvalidAddress(void *ptr) { +static bool IsInvalidAddress(void *ptr) +{ if (((uint64_t)(ptr) & 0xfc00000000000000) != 0) { return true; } -- Gitee From a8e9d55435d31148d087360b30d504c1ba9f8fd1 Mon Sep 17 00:00:00 2001 From: byndyx Date: Tue, 19 Aug 2025 19:50:01 +0800 Subject: [PATCH 053/100] mutex Signed-off-by: byndyx --- .../include/audio_adapter_interface_impl.h | 3 +- .../v1_0/src/audio_adapter_interface_impl.cpp | 56 ++++++++++--------- .../src/audio_adapter_interface_impl_test.cpp | 4 ++ 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h b/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h index cb7e4e76ec..a7f7410698 100644 --- a/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h +++ b/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h @@ -149,7 +149,8 @@ private: bool GetSpkStatus(const uint32_t streamId); sptr GetRenderCallback(const uint32_t renderId); void DeleteRenderCallback(const uint32_t renderId); - + void HandleSPKEvent(const uint32_t streamId, bool spkStatus, const DAudioEvent &event); + void HandleMICEvent(bool micStatus, const DAudioEvent &event); private: static constexpr uint32_t WAIT_MILLISECONDS = 8000; static constexpr int32_t TYPE_CONDITION = 11; diff --git a/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp b/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp index da548bc4a9..9e702d7739 100644 --- a/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp +++ b/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp @@ -1098,41 +1098,47 @@ int32_t AudioAdapterInterfaceImpl::ConvertMsg2Code(const std::string &msg) } } +void AudioAdapterInterfaceImpl::HandleSPKEvent(const uint32_t streamId, bool spkStatus, const DAudioEvent &event) +{ + std::unique_lock lck(spkWaitMutex_); + DHLOGI("spk notify_all start."); + if (event.content == HDF_EVENT_RESULT_SUCCESS) { + SetSpkStatus(streamId, spkStatus); + } + errCode_ = ConvertMsg2Code(event.content); + spkNotifyFlag_ = true; + spkWaitCond_.notify_all(); + DHLOGI("spk notify_all end."); +} + +void AudioAdapterInterfaceImpl::HandleMICEvent(bool micStatus, const DAudioEvent &event) +{ + std::unique_lock lck(micWaitMutex_); + DHLOGI("mic notify_all start."); + if (event.content == HDF_EVENT_RESULT_SUCCESS) { + isMicOpened_ = micStatus; + } + errCode_ = ConvertMsg2Code(event.content); + micNotifyFlag_ = true; + micWaitCond_.notify_all(); + DHLOGI("mic notify_all end."); +} + int32_t AudioAdapterInterfaceImpl::HandleSANotifyEvent(const uint32_t streamId, const DAudioEvent &event) { - DHLOGD("Notify event type %{public}d, event content: %{public}s.", event.type, event.content.c_str()); + DHLOGI("Notify event type %{public}d, event content: %{public}s.", event.type, event.content.c_str()); switch (event.type) { case HDF_AUDIO_EVENT_OPEN_SPK_RESULT: - if (event.content == HDF_EVENT_RESULT_SUCCESS) { - SetSpkStatus(streamId, true); - } - errCode_ = ConvertMsg2Code(event.content); - spkNotifyFlag_ = true; - spkWaitCond_.notify_all(); + HandleSPKEvent(streamId, true, event); break; case HDF_AUDIO_EVENT_CLOSE_SPK_RESULT: - if (event.content == HDF_EVENT_RESULT_SUCCESS) { - SetSpkStatus(streamId, false); - } - errCode_ = ConvertMsg2Code(event.content); - spkNotifyFlag_ = true; - spkWaitCond_.notify_all(); + HandleSPKEvent(streamId, false, event); break; case HDF_AUDIO_EVENT_OPEN_MIC_RESULT: - if (event.content == HDF_EVENT_RESULT_SUCCESS) { - isMicOpened_ = true; - } - errCode_ = ConvertMsg2Code(event.content); - micNotifyFlag_ = true; - micWaitCond_.notify_all(); + HandleMICEvent(true, event); break; case HDF_AUDIO_EVENT_CLOSE_MIC_RESULT: - if (event.content == HDF_EVENT_RESULT_SUCCESS) { - isMicOpened_ = false; - } - errCode_ = ConvertMsg2Code(event.content); - micNotifyFlag_ = true; - micWaitCond_.notify_all(); + HandleMICEvent(false, event); break; case HDF_AUDIO_EVENT_SPK_DUMP: SetDumpFlag(true); diff --git a/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/src/audio_adapter_interface_impl_test.cpp b/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/src/audio_adapter_interface_impl_test.cpp index 0d569a45c7..339ce7f4d3 100644 --- a/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/src/audio_adapter_interface_impl_test.cpp +++ b/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/src/audio_adapter_interface_impl_test.cpp @@ -1300,6 +1300,8 @@ HWTEST_F(AudioAdapterInterfaceImpTest, HandleSANotifyEvent_001, TestSize.Level1) DAudioEvent event = {HDF_AUDIO_EVENT_OPEN_SPK_RESULT, "RENDER_STATE_CHANGE_EVENT"}; uint32_t streamId = 0; + AdapterTest_->HandleSPKEvent(streamId, true, event); + AdapterTest_->HandleMICEvent(true, event); EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(streamId, event)); } @@ -1316,6 +1318,8 @@ HWTEST_F(AudioAdapterInterfaceImpTest, HandleSANotifyEvent_002, TestSize.Level1) DAudioEvent event = {HDF_AUDIO_EVENT_OPEN_SPK_RESULT, HDF_EVENT_RESULT_SUCCESS}; uint32_t streamId = 0; + AdapterTest_->HandleSPKEvent(streamId, true, event); + AdapterTest_->HandleMICEvent(true, event); EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(streamId, event)); } -- Gitee From 1f62ad299e7afbddeb2cd33cb4fc8f5b47e8a496 Mon Sep 17 00:00:00 2001 From: liujiabinit Date: Wed, 20 Aug 2025 10:19:02 +0800 Subject: [PATCH 054/100] display composor add tunnel HDI interface Signed-off-by: liujiabinit --- .../include/display_composer_service.h | 7 ++ .../src/display_composer_service.cpp | 88 +++++++++++++++++++ .../composer/test/common/hdi_test_display.cpp | 2 +- .../fuzztest/common/display_common_fuzzer.h | 2 +- 4 files changed, 97 insertions(+), 2 deletions(-) diff --git a/display/composer/hdi_service/include/display_composer_service.h b/display/composer/hdi_service/include/display_composer_service.h index 595c39e06d..7b569dff60 100644 --- a/display/composer/hdi_service/include/display_composer_service.h +++ b/display/composer/hdi_service/include/display_composer_service.h @@ -88,6 +88,13 @@ public: const std::vector>& inHandles) override; int32_t GetDisplayIdentificationData(uint32_t devId, uint8_t& portId, std::vector& edidData) override; int32_t RegHwcEventCallback(const sptr& cb) override; + int32_t GetSupportLayerType(uint32_t devId, std::vector& types) override; + int32_t SetTunnelLayerId(uint32_t devId, uint32_t layerId, uint64_t tunnelId) override; + int32_t SetTunnelLayerProperty(uint32_t devId, uint32_t layerId, uint32_t property) override; + int32_t SetTunnelLayerPosition(uint32_t devId, uint64_t tunnelId, int32_t x, int32_t y) override; + int32_t SetTunnelLayerBuffer(uint32_t devId, uint64_t tunnelId, + const sptr& inHandle, const sptr& acquireFence) override; + int32_t CommitTunnelLayer(uint32_t devId, uint64_t tunnelId, sptr& releaseFence) override; private: void HidumperInit(); diff --git a/display/composer/hdi_service/src/display_composer_service.cpp b/display/composer/hdi_service/src/display_composer_service.cpp index 16dfcdaa1b..fb540a033d 100644 --- a/display/composer/hdi_service/src/display_composer_service.cpp +++ b/display/composer/hdi_service/src/display_composer_service.cpp @@ -267,6 +267,16 @@ void DisplayComposerService::LoadVdiFuncPart3() reinterpret_cast(dlsym(libHandle_, "GetDisplayIdentificationData")); vdiAdapter_->RegHwcEventCallback = reinterpret_cast(dlsym(libHandle_, "RegHwcEventCallback")); + vdiAdapter_->GetSupportLayerType = + reinterpret_cast(dlsym(libHandle_, "GetSupportLayerType")); + vdiAdapter_->SetTunnelLayerId = reinterpret_cast(dlsym(libHandle_, "SetTunnelLayerId")); + vdiAdapter_->SetTunnelLayerProperty = + reinterpret_cast(dlsym(libHandle_, "SetTunnelLayerProperty")); + vdiAdapter_->SetTunnelLayerPosition = + reinterpret_cast(dlsym(libHandle_, "SetTunnelLayerPosition")); + vdiAdapter_->SetTunnelLayerBuffer = + reinterpret_cast(dlsym(libHandle_, "SetTunnelLayerBuffer")); + vdiAdapter_->CommitTunnelLayer = reinterpret_cast(dlsym(libHandle_, "CommitTunnelLayer")); } void DisplayComposerService::HidumperInit() @@ -822,6 +832,84 @@ int32_t DisplayComposerService::SetLayerPerFrameParameter(uint32_t devId, uint32 return ret; } +int32_t DisplayComposerService::GetSupportLayerType(uint32_t devId, std::vector& types) +{ + DISPLAY_TRACE; + CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE); + CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->GetSupportLayerType, HDF_ERR_NOT_SUPPORT); + int32_t ret = vdiAdapter_->GetSupportLayerType(devId, types); + DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_ERR_NOT_SUPPORT); + DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, + DISPLAY_LOGE("%{public}s fail", __func__)); + return ret; +} + +int32_t DisplayComposerService::SetTunnelLayerId(uint32_t devId, uint32_t layerId, uint64_t tunnelId) +{ + DISPLAY_TRACE; + CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE); + CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetTunnelLayerId, HDF_ERR_NOT_SUPPORT); + int32_t ret = vdiAdapter_->SetTunnelLayerId(devId, layerId, tunnelId); + DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_ERR_NOT_SUPPORT); + DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, + DISPLAY_LOGE("%{public}s fail", __func__)); + return ret; +} + +int32_t DisplayComposerService::SetTunnelLayerProperty(uint32_t devId, uint32_t layerId, uint32_t property) +{ + DISPLAY_TRACE; + CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE); + CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetTunnelLayerProperty, HDF_ERR_NOT_SUPPORT); + int32_t ret = vdiAdapter_->SetTunnelLayerProperty(devId, layerId, property); + DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_ERR_NOT_SUPPORT); + DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, + DISPLAY_LOGE("%{public}s fail", __func__)); + return ret; +} + +int32_t DisplayComposerService::SetTunnelLayerPosition(uint32_t devId, uint64_t tunnelId, int32_t x, int32_t y) +{ + DISPLAY_TRACE; + CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE); + CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetTunnelLayerPosition, HDF_ERR_NOT_SUPPORT); + int32_t ret = vdiAdapter_->SetTunnelLayerPosition(devId, tunnelId, x, y); + DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_ERR_NOT_SUPPORT); + DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, + DISPLAY_LOGE("%{public}s fail", __func__)); + return ret; +} + +int32_t DisplayComposerService::SetTunnelLayerBuffer( + uint32_t devId, uint64_t tunnelId, const sptr& inHandle, const sptr& acquireFence) +{ + DISPLAY_TRACE; + CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE); + CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetTunnelLayerBuffer, HDF_ERR_NOT_SUPPORT); + CHECK_NULLPOINTER_RETURN_VALUE(acquireFence, HDF_FAILURE); + int32_t inFence = acquireFence->GetFd(); + int32_t ret = vdiAdapter_->SetTunnelLayerBuffer(devId, tunnelId, inHandle->GetBufferHandle(), inFence); + DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_ERR_NOT_SUPPORT); + DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, + DISPLAY_LOGE("%{public}s fail", __func__)); + return ret; +} + +int32_t DisplayComposerService::CommitTunnelLayer(uint32_t devId, uint64_t tunnelId, + sptr& releaseFence) +{ + DISPLAY_TRACE; + int32_t outFence; + CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE); + CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->CommitTunnelLayer, HDF_ERR_NOT_SUPPORT); + int32_t ret = vdiAdapter_->CommitTunnelLayer(devId, tunnelId, outFence); + DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_ERR_NOT_SUPPORT); + DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, + DISPLAY_LOGE("%{public}s fail", __func__)); + releaseFence->Init(outFence); + return ret; +} + int32_t DisplayComposerService::GetSupportedLayerPerFrameParameterKey(std::vector& keys) { DISPLAY_TRACE; diff --git a/display/composer/test/common/hdi_test_display.cpp b/display/composer/test/common/hdi_test_display.cpp index c992f02791..8ca01e2b2e 100644 --- a/display/composer/test/common/hdi_test_display.cpp +++ b/display/composer/test/common/hdi_test_display.cpp @@ -105,7 +105,7 @@ std::shared_ptr HdiTestDisplay::CreateHdiTestLayer(uint32_t w, uin { const int32_t BPP = 32; - LayerInfo info = {w, h, LAYER_TYPE_GRAPHIC, BPP, Composer::V1_0::PIXEL_FMT_RGBA_8888}; + LayerInfo info = {w, h, Composer::V1_0::LAYER_TYPE_GRAPHIC, BPP, Composer::V1_0::PIXEL_FMT_RGBA_8888}; return CreateHdiTestLayer(info); } diff --git a/display/composer/test/fuzztest/common/display_common_fuzzer.h b/display/composer/test/fuzztest/common/display_common_fuzzer.h index 5aaa238ac3..99b748f6e2 100644 --- a/display/composer/test/fuzztest/common/display_common_fuzzer.h +++ b/display/composer/test/fuzztest/common/display_common_fuzzer.h @@ -78,7 +78,7 @@ const BufferUsage CONVERT_TABLE_USAGE[] = { }; -const LayerType CONVERT_TABLE_LAYER_TYPE[] = { +const Composer::V1_0::LayerType CONVERT_TABLE_LAYER_TYPE[] = { LAYER_TYPE_GRAPHIC, LAYER_TYPE_OVERLAY, LAYER_TYPE_SDIEBAND, LAYER_TYPE_CURSOR, LAYER_TYPE_BUTT, -- Gitee From 43652d8bf7188461ca131bc5b5d34c1f9d4a2989 Mon Sep 17 00:00:00 2001 From: Anduin1109 Date: Wed, 20 Aug 2025 12:02:26 +0800 Subject: [PATCH 055/100] modify usb fuzz Signed-off-by: Anduin1109 --- .../UsbSubscriberTest/UsbSubscriberV2Test.cpp | 33 +++++++ .../UsbSubscriberTest/UsbSubscriberV2Test.h | 42 +++++++++ .../usbdeviceauthorize_fuzzer/BUILD.gn | 63 ++++++++++++++ .../usbdeviceauthorize_fuzzer/corpus/init | 14 +++ .../usbdeviceauthorize_fuzzer/project.xml | 25 ++++++ .../usbdeviceauthorize_fuzzer.cpp | 66 ++++++++++++++ .../usbdeviceauthorize_fuzzer.h | 21 +++++ .../usbgetdevicespeed_fuzzer.cpp | 8 ++ .../usbinterfaceauthorize_fuzzer/BUILD.gn | 63 ++++++++++++++ .../usbinterfaceauthorize_fuzzer/corpus/init | 14 +++ .../usbinterfaceauthorize_fuzzer/project.xml | 25 ++++++ .../usbinterfaceauthorize_fuzzer.cpp | 85 +++++++++++++++++++ .../usbinterfaceauthorize_fuzzer.h | 21 +++++ 13 files changed, 480 insertions(+) create mode 100644 usb/test/UsbSubscriberTest/UsbSubscriberV2Test.cpp create mode 100644 usb/test/UsbSubscriberTest/UsbSubscriberV2Test.h create mode 100644 usb/test/fuzztest/usbdeviceauthorize_fuzzer/BUILD.gn create mode 100644 usb/test/fuzztest/usbdeviceauthorize_fuzzer/corpus/init create mode 100644 usb/test/fuzztest/usbdeviceauthorize_fuzzer/project.xml create mode 100644 usb/test/fuzztest/usbdeviceauthorize_fuzzer/usbdeviceauthorize_fuzzer.cpp create mode 100644 usb/test/fuzztest/usbdeviceauthorize_fuzzer/usbdeviceauthorize_fuzzer.h create mode 100644 usb/test/fuzztest/usbinterfaceauthorize_fuzzer/BUILD.gn create mode 100644 usb/test/fuzztest/usbinterfaceauthorize_fuzzer/corpus/init create mode 100644 usb/test/fuzztest/usbinterfaceauthorize_fuzzer/project.xml create mode 100644 usb/test/fuzztest/usbinterfaceauthorize_fuzzer/usbinterfaceauthorize_fuzzer.cpp create mode 100644 usb/test/fuzztest/usbinterfaceauthorize_fuzzer/usbinterfaceauthorize_fuzzer.h diff --git a/usb/test/UsbSubscriberTest/UsbSubscriberV2Test.cpp b/usb/test/UsbSubscriberTest/UsbSubscriberV2Test.cpp new file mode 100644 index 0000000000..22adb33146 --- /dev/null +++ b/usb/test/UsbSubscriberTest/UsbSubscriberV2Test.cpp @@ -0,0 +1,33 @@ +/* + * 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. + */ + +#include "UsbSubscriberV2Test.h" +#include "hdf_log.h" +#include "usbd_type.h" + +namespace OHOS { +namespace USB { +int32_t UsbSubscriberTest::DeviceEvent(const USBDeviceInfo &info) +{ + if (info.status == ACT_UPDEVICE || info.status == ACT_DOWNDEVICE) { + return 0; + } + busNum_ = info.busNum; + devAddr_ = info.devNum; + HDF_LOGI("%{public}s: busNum is %{public}d, devAddr is %{public}d", __func__, busNum_, devAddr_); + return 0; +} +} // namespace USB +} // namespace OHOS diff --git a/usb/test/UsbSubscriberTest/UsbSubscriberV2Test.h b/usb/test/UsbSubscriberTest/UsbSubscriberV2Test.h new file mode 100644 index 0000000000..e70751898e --- /dev/null +++ b/usb/test/UsbSubscriberTest/UsbSubscriberV2Test.h @@ -0,0 +1,42 @@ +/* + * 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. + */ + +#ifndef USBSUBSCRIBERTEST_H +#define USBSUBSCRIBERTEST_H + +#include "v2_0/iusbd_subscriber.h" + +using OHOS::HDI::Usb::V2_0::PortInfo; +using OHOS::HDI::Usb::V2_0::USBDeviceInfo; + +namespace OHOS { +namespace USB { +class UsbSubscriberTest : public OHOS::HDI::Usb::V2_0::IUsbdSubscriber { +public: + UsbSubscriberTest() = default; + ~UsbSubscriberTest() = default; + int32_t DeviceEvent(const USBDeviceInfo &info) override; + int32_t PortChangedEvent(const PortInfo &info) override + { + return 0; + }; + + int32_t busNum_ = 0; + int32_t devAddr_ = 0; +}; +} // namespace USB +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/usb/test/fuzztest/usbdeviceauthorize_fuzzer/BUILD.gn b/usb/test/fuzztest/usbdeviceauthorize_fuzzer/BUILD.gn new file mode 100644 index 0000000000..fe1ca5197d --- /dev/null +++ b/usb/test/fuzztest/usbdeviceauthorize_fuzzer/BUILD.gn @@ -0,0 +1,63 @@ +# 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/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("./../fuzztest.gni") +module_output_path = "drivers_peripheral_usb/drivers_peripheral_usb" + +ohos_fuzztest("UsbDeviceAuthorizeFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = "./../usbdeviceauthorize_fuzzer" + + include_dirs = [ + "../usbdeviceauthorize_fuzzer", + "../../UsbSubscriberTest", + "./../../../hdi_service/include", + ] + + deps = [ + "../../../hdi_service:libusb_device_interface_service_2.0", + "../../../hdi_service:libusb_host_interface_service_2.0", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_usb:libusb_proxy_2.0", + "hdf_core:libhdf_utils", + "hdf_core:libhdi", + "hilog:libhilog", + "ipc:ipc_single", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "../../UsbSubscriberTest/UsbSubscriberV2Test.cpp", + "../usbcommonfunction_fuzzer/usbcommonfunction_fuzzer.cpp", + "usbdeviceauthorize_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":UsbDeviceAuthorizeFuzzTest" ] +} diff --git a/usb/test/fuzztest/usbdeviceauthorize_fuzzer/corpus/init b/usb/test/fuzztest/usbdeviceauthorize_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/usb/test/fuzztest/usbdeviceauthorize_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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. + +FUZZ \ No newline at end of file diff --git a/usb/test/fuzztest/usbdeviceauthorize_fuzzer/project.xml b/usb/test/fuzztest/usbdeviceauthorize_fuzzer/project.xml new file mode 100644 index 0000000000..f3c3ecc686 --- /dev/null +++ b/usb/test/fuzztest/usbdeviceauthorize_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 120 + + 2048 + + \ No newline at end of file diff --git a/usb/test/fuzztest/usbdeviceauthorize_fuzzer/usbdeviceauthorize_fuzzer.cpp b/usb/test/fuzztest/usbdeviceauthorize_fuzzer/usbdeviceauthorize_fuzzer.cpp new file mode 100644 index 0000000000..04eeb005fa --- /dev/null +++ b/usb/test/fuzztest/usbdeviceauthorize_fuzzer/usbdeviceauthorize_fuzzer.cpp @@ -0,0 +1,66 @@ +/* + * 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. + */ + +#include "usbdeviceauthorize_fuzzer.h" +#include +#include "hdf_log.h" +#include "securec.h" +#include "UsbSubscriberV2Test.h" +#include "v2_0/iusb_host_interface.h" +#include "v2_0/iusb_device_interface.h" +#include "v2_0/usb_types.h" + +using namespace OHOS; +using namespace OHOS::HDI::Usb::V2_0; + +namespace OHOS { +namespace USB { +struct Parameters { + uint8_t busNum; + uint8_t devAddr; + bool authorized; +} + +bool UsbDeviceAuthorizeFuzzTest(const uint8_t *data, size_t size) +{ + (void)size; + + sptr usbDeviceInterface_ = nullptr; + usbDeviceInterface_ = HDI::Usb::V2_0::IUsbDeviceInterface::Get(); + if (usbDeviceInterface_ == nullptr) { + HDF_LOGE("%{public}s:IUsbDeviceInterface_::Get() failed.", __func__); + return false; + } + + Parameters param; + if (memcpy_s((void *)¶m, sizeof(param), data, sizeof(param)) != EOK) { + HDF_LOGE("%{public}s: memcpy_s failed", __func__); + return false; + } + + auto ret = usbDeviceInterface_->UsbDeviceAuthorize(param.busNum, param.devAddr, param.authorized); + if (ret == HDF_SUCCESS) { + HDF_LOGI("%{public}s: device authorize succeed", __func__); + } + return true; +} +} // namespace USB +} // namespace OHOS + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::USB::UsbDeviceAuthorizeFuzzTest(data, size); + return 0; +} diff --git a/usb/test/fuzztest/usbdeviceauthorize_fuzzer/usbdeviceauthorize_fuzzer.h b/usb/test/fuzztest/usbdeviceauthorize_fuzzer/usbdeviceauthorize_fuzzer.h new file mode 100644 index 0000000000..0fd1cabb07 --- /dev/null +++ b/usb/test/fuzztest/usbdeviceauthorize_fuzzer/usbdeviceauthorize_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef USBDEVICEAUTHORIZE_FUZZER_H +#define USBDEVICEAUTHORIZE_FUZZER_H + +#define FUZZ_PROJECT_NAME "usbdeviceauthorize_fuzzer" + +#endif diff --git a/usb/test/fuzztest/usbgetdevicespeed_fuzzer/usbgetdevicespeed_fuzzer.cpp b/usb/test/fuzztest/usbgetdevicespeed_fuzzer/usbgetdevicespeed_fuzzer.cpp index 6010627bdf..a354dcec64 100644 --- a/usb/test/fuzztest/usbgetdevicespeed_fuzzer/usbgetdevicespeed_fuzzer.cpp +++ b/usb/test/fuzztest/usbgetdevicespeed_fuzzer/usbgetdevicespeed_fuzzer.cpp @@ -33,6 +33,14 @@ bool UsbGetDeviceSpeedFuzzTest(const uint8_t *data, size_t size) HDF_LOGE("%{public}s: UsbFuzzTestHostModeInit failed", __func__); return false; } + unsigned seed = 0; + if (size < sizeof(unsigned)) { + errno_t ret = memcpy_s(&seed, sizeof(unsigned), data, sizeof(unsigned)); + if (ret != UEC_OK) { + return false; + } + srand(seed); + } uint8_t speed; ret = usbInterface->GetDeviceSpeed(dev, speed); diff --git a/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/BUILD.gn b/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/BUILD.gn new file mode 100644 index 0000000000..42f470c97c --- /dev/null +++ b/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/BUILD.gn @@ -0,0 +1,63 @@ +# 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/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("./../fuzztest.gni") +module_output_path = "drivers_peripheral_usb/drivers_peripheral_usb" + +ohos_fuzztest("UsbInterfaceAuthorizeFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = "./../usbinterfaceauthorize_fuzzer" + + include_dirs = [ + "../usbinterfaceauthorize_fuzzer", + "../../UsbSubscriberTest", + "./../../../hdi_service/include", + ] + + deps = [ + "../../../hdi_service:libusb_device_interface_service_2.0", + "../../../hdi_service:libusb_host_interface_service_2.0", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_usb:libusb_proxy_2.0", + "hdf_core:libhdf_utils", + "hdf_core:libhdi", + "hilog:libhilog", + "ipc:ipc_single", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "../../UsbSubscriberTest/UsbSubscriberV2Test.cpp", + "../usbcommonfunction_fuzzer/usbcommonfunction_fuzzer.cpp", + "usbinterfaceauthorize_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":UsbInterfaceAuthorizeFuzzTest" ] +} diff --git a/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/corpus/init b/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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. + +FUZZ \ No newline at end of file diff --git a/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/project.xml b/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/project.xml new file mode 100644 index 0000000000..f3c3ecc686 --- /dev/null +++ b/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 120 + + 2048 + + \ No newline at end of file diff --git a/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/usbinterfaceauthorize_fuzzer.cpp b/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/usbinterfaceauthorize_fuzzer.cpp new file mode 100644 index 0000000000..1effdc3708 --- /dev/null +++ b/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/usbinterfaceauthorize_fuzzer.cpp @@ -0,0 +1,85 @@ +/* + * 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. + */ + +#include "usbdeviceauthorize_fuzzer.h" +#include +#include "hdf_log.h" +#include "securec.h" +#include "UsbSubscriberV2Test.h" +#include "v2_0/iusb_host_interface.h" +#include "v2_0/iusb_device_interface.h" +#include "v2_0/usb_types.h" + +using namespace OHOS; +using namespace OHOS::HDI::Usb::V2_0; + +namespace OHOS { +namespace USB { +struct Parameters { + uint8_t configId; + uint8_t interfaceId; + bool authorized; +} + +bool UsbInterfaceAuthorizeFuzzTest(const uint8_t *data, size_t size) +{ + (void)size; + + sptr usbHostInterface_ = nullptr; + usbHostInterface_ = HDI::Usb::V2_0::IUsbHostInterface::Get(); + if (usbHostInterface_ == nullptr) { + HDF_LOGE("%{public}s:IUsbHostInterface_::Get() failed.", __func__); + return false; + } + sptr usbDeviceInterface_ = nullptr; + usbDeviceInterface_ = HDI::Usb::V2_0::IUsbDeviceInterface::Get(); + if (usbDeviceInterface_ == nullptr) { + HDF_LOGE("%{public}s:IUsbDeviceInterface_::Get() failed.", __func__); + return false; + } + sptr subscriber_ = nullptr; + subscriber_ = new OHOS::USB::UsbSubscriberTest(); + if (usbHostInterface_->BindUsbdHostSubscriber(subscriber_) != HDF_SUCCESS) { + HDF_LOGE("%{public}s: bind usbd host subscriber_ failed", __func__); + return false; + } + UsbDev dev = {subscriber_->busNum_, subscriber_->devAddr_}; + + Parameters param; + if (memcpy_s((void *)¶m, sizeof(param), data, sizeof(param)) != EOK) { + HDF_LOGE("%{public}s: memcpy_s failed", __func__); + return false; + } + auto ret = usbDeviceInterface_->UsbInterfaceAuthorize( + dev, param.configId, param.interfaceId, param.authorized); + + if (ret == HDF_SUCCESS) { + HDF_LOGI("%{public}s: interface authorize succeed", __func__); + } + ret = usbHostInterface_->UnbindUsbdHostSubscriber(subscriber_); + if (ret != 0) { + HDF_LOGE("%{public}s: unbind usbd host subscriber_ failed", __func__); + return false; + } + return true; +} +} // namespace USB +} // namespace OHOS + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::USB::UsbInterfaceAuthorizeFuzzTest(data, size); + return 0; +} diff --git a/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/usbinterfaceauthorize_fuzzer.h b/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/usbinterfaceauthorize_fuzzer.h new file mode 100644 index 0000000000..a1ed3e15e2 --- /dev/null +++ b/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/usbinterfaceauthorize_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef USBINTERFACEAUTHORIZE_FUZZER_H +#define USBINTERFACEAUTHORIZE_FUZZER_H + +#define FUZZ_PROJECT_NAME "usbinterfaceauthorize_fuzzer" + +#endif -- Gitee From a17cb61ece464657a2939993e078d41a0a20c226 Mon Sep 17 00:00:00 2001 From: Anduin1109 Date: Wed, 20 Aug 2025 12:13:36 +0800 Subject: [PATCH 056/100] modify usb fuzz Signed-off-by: Anduin1109 --- .../usbinterfaceauthorize_fuzzer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/usbinterfaceauthorize_fuzzer.cpp b/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/usbinterfaceauthorize_fuzzer.cpp index 1effdc3708..46859e2dd1 100644 --- a/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/usbinterfaceauthorize_fuzzer.cpp +++ b/usb/test/fuzztest/usbinterfaceauthorize_fuzzer/usbinterfaceauthorize_fuzzer.cpp @@ -64,10 +64,10 @@ bool UsbInterfaceAuthorizeFuzzTest(const uint8_t *data, size_t size) } auto ret = usbDeviceInterface_->UsbInterfaceAuthorize( dev, param.configId, param.interfaceId, param.authorized); - if (ret == HDF_SUCCESS) { HDF_LOGI("%{public}s: interface authorize succeed", __func__); } + ret = usbHostInterface_->UnbindUsbdHostSubscriber(subscriber_); if (ret != 0) { HDF_LOGE("%{public}s: unbind usbd host subscriber_ failed", __func__); -- Gitee From a30e06c63b93597dda92309c4d88ae6c30de6329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Wed, 20 Aug 2025 15:03:01 +0800 Subject: [PATCH 057/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../test/unittest/sensor_data_volume_per_second_test/BUILD.gn | 2 -- 1 file changed, 2 deletions(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/BUILD.gn b/sensor/test/unittest/sensor_data_volume_per_second_test/BUILD.gn index 4191ec2f7a..8f4554cb1f 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/BUILD.gn +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/BUILD.gn @@ -39,8 +39,6 @@ ohos_unittest("SensorDataVolumePerSecondTest") { if (is_standard_system) { external_deps = [ - "drivers_interface_sensor:libsensor_proxy_2.0", - "drivers_interface_sensor:libsensor_proxy_2.1", "drivers_interface_sensor:libsensor_proxy_3.0", "hdf_core:libhdf_host", "hdf_core:libhdf_utils", -- Gitee From 761f54046c3183dc1ab2e486a6002655e4a10689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Wed, 20 Aug 2025 15:04:39 +0800 Subject: [PATCH 058/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../unittest/sensor_data_volume_per_second_test/readme_zh.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md index d811495ff6..5e9beb1498 100644 --- a/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md +++ b/sensor/test/unittest/sensor_data_volume_per_second_test/readme_zh.md @@ -2,8 +2,9 @@ > 本测试用例模拟一个上游服务订阅sensor的情况,统计每秒收到数据个数,参数可以在cmd命令中修改。
> 服务1,通过SetBatch(acc传感器, 10毫秒采样频率, 废弃参数)的方式订阅。
-> 最终期望的效果是:每秒时间内: -> 服务1,收到100帧数据,由于数据波动,在50-150之间可认为正常。 +> 最终期望的效果是:每秒时间内:
+> 服务1,收到100帧数据,由于数据波动,在50-150之间可认为正常。
+> 修改脚本中的testSensorType、testSamplingInterval、testPrintDataFlag等参数可以控制测试的传感器类型,频率,和是否逐帧打印数据。
--- -- Gitee From 77a5e591506102b0003ae5fd3efaa6e2efecff4c Mon Sep 17 00:00:00 2001 From: Sxs Date: Thu, 21 Aug 2025 02:15:30 +0000 Subject: [PATCH 059/100] codec HDI mutex fix Signed-off-by: Sxs --- codec/hal/idl_service/src/component_node.cpp | 28 +++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/codec/hal/idl_service/src/component_node.cpp b/codec/hal/idl_service/src/component_node.cpp index ec2cd275a7..341e5c7ce3 100644 --- a/codec/hal/idl_service/src/component_node.cpp +++ b/codec/hal/idl_service/src/component_node.cpp @@ -438,19 +438,23 @@ int32_t ComponentNode::AllocateBuffer(uint32_t portIndex, OmxCodecBuffer &buffer int32_t ComponentNode::FreeBuffer(uint32_t portIndex, const OmxCodecBuffer &buffer) { - std::unique_lock poolLock(poolMutex_); - uint32_t bufferId = buffer.bufferId; - auto iter = std::find_if(bufferPool_.begin(), bufferPool_.end(), [bufferId, portIndex](const BufferInfo& info) { - return info.bufferId == bufferId && info.portIndex == portIndex; - }); - if (iter == bufferPool_.end()) { - CODEC_LOGE("Can not find buffer, port=%{public}u, id=%{public}u", portIndex, bufferId); - return OMX_ErrorBadParameter; + sptr codecBuffer = nullptr; + { + std::unique_lock poolLock(poolMutex_); + uint32_t bufferId = buffer.bufferId; + auto iter = std::find_if(bufferPool_.begin(), bufferPool_.end(), [bufferId, portIndex](const BufferInfo& info) { + return info.bufferId == bufferId && info.portIndex == portIndex; + }); + if (iter == bufferPool_.end()) { + CODEC_LOGE("Can not find buffer, port=%{public}u, id=%{public}u", portIndex, bufferId); + return OMX_ErrorBadParameter; + } + codecBuffer = iter->icodecBuf; + bufferPool_.erase(iter); + } + if (codecBuffer != nullptr) { + codecBuffer->FreeBuffer(); } - sptr codecBuffer = iter->icodecBuf; - CHECK_AND_RETURN_RET_LOG(codecBuffer != nullptr, OMX_ErrorBadParameter, "codecBuffer is null"); - codecBuffer->FreeBuffer(); - bufferPool_.erase(iter); return 0; } -- Gitee From e9433462c72ce6b59a4d18ed2cbc1da8df1beb59 Mon Sep 17 00:00:00 2001 From: lin_c <1946558487@qq.com> Date: Thu, 21 Aug 2025 02:30:59 +0000 Subject: [PATCH 060/100] update codec/test/benchmarktest/BUILD.gn. Signed-off-by: lin_c <1946558487@qq.com> --- codec/test/benchmarktest/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codec/test/benchmarktest/BUILD.gn b/codec/test/benchmarktest/BUILD.gn index add94daa73..ed3efe732d 100644 --- a/codec/test/benchmarktest/BUILD.gn +++ b/codec/test/benchmarktest/BUILD.gn @@ -33,7 +33,7 @@ ohos_benchmarktest("hdf_codec_benchmark_test") { "drivers_interface_codec:libcodec_proxy_4.0", "drivers_interface_display:libdisplay_buffer_hdi_impl", "drivers_interface_display:libdisplay_buffer_proxy_1.0", - "drivers_interface_display:libdisplay_composer_hdi_impl_1.2", + "drivers_interface_display:libdisplay_composer_hdi_impl_1.3", "drivers_interface_display:libdisplay_composer_proxy_1.0", "graphic_surface:buffer_handle", "hdf_core:libhdf_host", -- Gitee From 339312ca05aef7e09c1dcf82c3e62775d0d3774f Mon Sep 17 00:00:00 2001 From: lin_c <1946558487@qq.com> Date: Thu, 21 Aug 2025 02:34:09 +0000 Subject: [PATCH 061/100] update codec/test/demo/heif/BUILD.gn. Signed-off-by: lin_c <1946558487@qq.com> --- codec/test/demo/heif/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codec/test/demo/heif/BUILD.gn b/codec/test/demo/heif/BUILD.gn index 962809e7be..0403fff6ad 100644 --- a/codec/test/demo/heif/BUILD.gn +++ b/codec/test/demo/heif/BUILD.gn @@ -33,7 +33,7 @@ ohos_executable("codec_heif_encode") { "drivers_interface_display:libdisplay_composer_proxy_1.1", "drivers_interface_display:libdisplay_composer_proxy_1.2", "drivers_interface_display:libdisplay_buffer_hdi_impl_v1_2", - "drivers_interface_display:libdisplay_composer_hdi_impl_1.2", + "drivers_interface_display:libdisplay_composer_hdi_impl_1.3", "hdf_core:libhdf_host", "hdf_core:libhdf_ipc_adapter", "hdf_core:libhdf_utils", @@ -69,7 +69,7 @@ ohos_executable("codec_heif_decode") { "drivers_interface_display:libdisplay_composer_proxy_1.1", "drivers_interface_display:libdisplay_composer_proxy_1.2", "drivers_interface_display:libdisplay_buffer_hdi_impl_v1_2", - "drivers_interface_display:libdisplay_composer_hdi_impl_1.2", + "drivers_interface_display:libdisplay_composer_hdi_impl_1.3", "drivers_interface_display:libdisplay_commontype_proxy_2.0", "hdf_core:libhdf_host", "hdf_core:libhdf_ipc_adapter", -- Gitee From d5b1ac8999bb0bfe66fb925e5c1f7fd4b822be13 Mon Sep 17 00:00:00 2001 From: lin_c <1946558487@qq.com> Date: Thu, 21 Aug 2025 02:35:15 +0000 Subject: [PATCH 062/100] update codec/test/demo/idl/BUILD.gn. Signed-off-by: lin_c <1946558487@qq.com> --- codec/test/demo/idl/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codec/test/demo/idl/BUILD.gn b/codec/test/demo/idl/BUILD.gn index e09326a0b4..e75bb46ca3 100644 --- a/codec/test/demo/idl/BUILD.gn +++ b/codec/test/demo/idl/BUILD.gn @@ -31,7 +31,7 @@ ohos_executable("codec_idl_omx_decode") { "drivers_interface_codec:libcodec_proxy_4.0", "drivers_interface_display:libdisplay_buffer_hdi_impl", "drivers_interface_display:libdisplay_buffer_proxy_1.0", - "drivers_interface_display:libdisplay_composer_hdi_impl_1.2", + "drivers_interface_display:libdisplay_composer_hdi_impl_1.3", "drivers_interface_display:libdisplay_composer_proxy_1.0", "graphic_surface:buffer_handle", "hdf_core:libhdf_host", @@ -69,7 +69,7 @@ ohos_executable("codec_idl_omx_encode") { "drivers_interface_codec:libcodec_proxy_4.0", "drivers_interface_display:libdisplay_buffer_hdi_impl", "drivers_interface_display:libdisplay_buffer_proxy_1.0", - "drivers_interface_display:libdisplay_composer_hdi_impl_1.2", + "drivers_interface_display:libdisplay_composer_hdi_impl_1.3", "drivers_interface_display:libdisplay_composer_proxy_1.0", "graphic_surface:buffer_handle", "hdf_core:libhdf_host", -- Gitee From 6b395ea39efb0b5ed4c8f2fcfceb67d60dd71522 Mon Sep 17 00:00:00 2001 From: lin_c <1946558487@qq.com> Date: Thu, 21 Aug 2025 02:35:41 +0000 Subject: [PATCH 063/100] update codec/test/demo/jpeg/BUILD.gn. Signed-off-by: lin_c <1946558487@qq.com> --- codec/test/demo/jpeg/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codec/test/demo/jpeg/BUILD.gn b/codec/test/demo/jpeg/BUILD.gn index 4aa5111327..3dd3a4e6e2 100644 --- a/codec/test/demo/jpeg/BUILD.gn +++ b/codec/test/demo/jpeg/BUILD.gn @@ -33,7 +33,7 @@ ohos_executable("codec_jpeg_decode") { "drivers_interface_codec:libimage_proxy_2.1", "drivers_interface_display:libdisplay_buffer_hdi_impl", "drivers_interface_display:libdisplay_buffer_proxy_1.0", - "drivers_interface_display:libdisplay_composer_hdi_impl_1.2", + "drivers_interface_display:libdisplay_composer_hdi_impl_1.3", "drivers_interface_display:libdisplay_composer_proxy_1.0", "graphic_surface:buffer_handle", "hdf_core:libhdf_host", -- Gitee From a1b5f179bff0a8f40411e86722f8647d9ade157d Mon Sep 17 00:00:00 2001 From: lin_c <1946558487@qq.com> Date: Thu, 21 Aug 2025 02:37:05 +0000 Subject: [PATCH 064/100] update codec/test/fuzztest/image_fuzzer/imagedoheifdecode_fuzzer/BUILD.gn. Signed-off-by: lin_c <1946558487@qq.com> --- .../fuzztest/image_fuzzer/imagedoheifdecode_fuzzer/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codec/test/fuzztest/image_fuzzer/imagedoheifdecode_fuzzer/BUILD.gn b/codec/test/fuzztest/image_fuzzer/imagedoheifdecode_fuzzer/BUILD.gn index 665cef4247..5586f57f64 100644 --- a/codec/test/fuzztest/image_fuzzer/imagedoheifdecode_fuzzer/BUILD.gn +++ b/codec/test/fuzztest/image_fuzzer/imagedoheifdecode_fuzzer/BUILD.gn @@ -35,7 +35,7 @@ ohos_fuzztest("ImageDoHeifDecodeFuzzTest") { "drivers_interface_display:libdisplay_composer_proxy_1.1", "drivers_interface_display:libdisplay_composer_proxy_1.2", "drivers_interface_display:libdisplay_buffer_hdi_impl_v1_2", - "drivers_interface_display:libdisplay_composer_hdi_impl_1.2", + "drivers_interface_display:libdisplay_composer_hdi_impl_1.3", "hdf_core:libhdf_host", "hdf_core:libhdf_ipc_adapter", "hdf_core:libhdf_utils", -- Gitee From 82797b60724c4205a49b77a58e41ee577630fd5c Mon Sep 17 00:00:00 2001 From: lin_c <1946558487@qq.com> Date: Thu, 21 Aug 2025 02:38:03 +0000 Subject: [PATCH 065/100] update codec/test/fuzztest/image_fuzzer/imagedoheifencode_fuzzer/BUILD.gn. Signed-off-by: lin_c <1946558487@qq.com> --- .../fuzztest/image_fuzzer/imagedoheifencode_fuzzer/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codec/test/fuzztest/image_fuzzer/imagedoheifencode_fuzzer/BUILD.gn b/codec/test/fuzztest/image_fuzzer/imagedoheifencode_fuzzer/BUILD.gn index e16c6bca86..17d28e17c2 100644 --- a/codec/test/fuzztest/image_fuzzer/imagedoheifencode_fuzzer/BUILD.gn +++ b/codec/test/fuzztest/image_fuzzer/imagedoheifencode_fuzzer/BUILD.gn @@ -35,7 +35,7 @@ ohos_fuzztest("ImageDoHeifEncodeFuzzTest") { "drivers_interface_display:libdisplay_composer_proxy_1.1", "drivers_interface_display:libdisplay_composer_proxy_1.2", "drivers_interface_display:libdisplay_buffer_hdi_impl_v1_2", - "drivers_interface_display:libdisplay_composer_hdi_impl_1.2", + "drivers_interface_display:libdisplay_composer_hdi_impl_1.3", "hdf_core:libhdf_host", "hdf_core:libhdf_ipc_adapter", "hdf_core:libhdf_utils", -- Gitee From 02c0e7616a4242bd06f1a1afe8e5c5041b66e0b3 Mon Sep 17 00:00:00 2001 From: lin_c <1946558487@qq.com> Date: Thu, 21 Aug 2025 02:38:46 +0000 Subject: [PATCH 066/100] update codec/test/unittest/hdi_image/BUILD.gn. Signed-off-by: lin_c <1946558487@qq.com> --- codec/test/unittest/hdi_image/BUILD.gn | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codec/test/unittest/hdi_image/BUILD.gn b/codec/test/unittest/hdi_image/BUILD.gn index 43e25f5383..115c314340 100644 --- a/codec/test/unittest/hdi_image/BUILD.gn +++ b/codec/test/unittest/hdi_image/BUILD.gn @@ -26,7 +26,7 @@ ohos_unittest("codec_hdi_jpeg_test") { "drivers_interface_codec:libimage_proxy_2.1", "drivers_interface_display:libdisplay_buffer_hdi_impl", "drivers_interface_display:libdisplay_buffer_proxy_1.0", - "drivers_interface_display:libdisplay_composer_hdi_impl_1.2", + "drivers_interface_display:libdisplay_composer_hdi_impl_1.3", "drivers_interface_display:libdisplay_composer_proxy_1.0", "graphic_surface:buffer_handle", "hdf_core:libhdf_host", @@ -56,7 +56,7 @@ ohos_unittest("codec_hdi_heif_encode_test") { "drivers_interface_display:libdisplay_composer_proxy_1.1", "drivers_interface_display:libdisplay_composer_proxy_1.2", "drivers_interface_display:libdisplay_buffer_hdi_impl_v1_2", - "drivers_interface_display:libdisplay_composer_hdi_impl_1.2", + "drivers_interface_display:libdisplay_composer_hdi_impl_1.3", "hdf_core:libhdf_host", "hdf_core:libhdf_ipc_adapter", "hdf_core:libhdf_utils", @@ -88,7 +88,7 @@ ohos_unittest("codec_hdi_heif_decode_test") { "drivers_interface_display:libdisplay_composer_proxy_1.1", "drivers_interface_display:libdisplay_composer_proxy_1.2", "drivers_interface_display:libdisplay_buffer_hdi_impl_v1_2", - "drivers_interface_display:libdisplay_composer_hdi_impl_1.2", + "drivers_interface_display:libdisplay_composer_hdi_impl_1.3", "hdf_core:libhdf_host", "hdf_core:libhdf_ipc_adapter", "hdf_core:libhdf_utils", -- Gitee From a61f337409d36f67fdd18a80e0b0729d77804ccb Mon Sep 17 00:00:00 2001 From: lin_c <1946558487@qq.com> Date: Thu, 21 Aug 2025 02:39:11 +0000 Subject: [PATCH 067/100] update codec/test/unittest/idl_omx/BUILD.gn. Signed-off-by: lin_c <1946558487@qq.com> --- codec/test/unittest/idl_omx/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codec/test/unittest/idl_omx/BUILD.gn b/codec/test/unittest/idl_omx/BUILD.gn index 03a8ffad75..9ede4c653c 100644 --- a/codec/test/unittest/idl_omx/BUILD.gn +++ b/codec/test/unittest/idl_omx/BUILD.gn @@ -35,7 +35,7 @@ ohos_unittest("codec_idl_omx_test") { "drivers_interface_codec:libcodec_proxy_4.0", "drivers_interface_display:libdisplay_buffer_hdi_impl", "drivers_interface_display:libdisplay_buffer_proxy_1.0", - "drivers_interface_display:libdisplay_composer_hdi_impl_1.2", + "drivers_interface_display:libdisplay_composer_hdi_impl_1.3", "drivers_interface_display:libdisplay_composer_proxy_1.0", "graphic_surface:buffer_handle", "hdf_core:libhdf_host", -- Gitee From cba48b13d140dd3e1e114327c4ca7d4a1acb0002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=8F=E6=9D=B0?= Date: Thu, 21 Aug 2025 08:30:39 +0000 Subject: [PATCH 068/100] d MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴敏杰 --- camera/test/mpi/src/adapter_test.cpp | 1 + camera/test/ut/v4l2/adapter_test.cpp | 1 + camera/test/ut/v4l2/buffer_manager_test.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/camera/test/mpi/src/adapter_test.cpp b/camera/test/mpi/src/adapter_test.cpp index baaf5262b1..bfb9973970 100644 --- a/camera/test/mpi/src/adapter_test.cpp +++ b/camera/test/mpi/src/adapter_test.cpp @@ -51,4 +51,5 @@ HWTEST_F(AdapterTest, Camera_Adapter_0001, TestSize.Level0) Test_->streamIds = {Test_->streamId_preview}; Test_->StopStream(Test_->captureIds, Test_->streamIds); Test_->StopConsumer(Test_->intents); + EXPECT_NE(Test_, nullptr); } \ No newline at end of file diff --git a/camera/test/ut/v4l2/adapter_test.cpp b/camera/test/ut/v4l2/adapter_test.cpp index b1745d42f7..367856e918 100644 --- a/camera/test/ut/v4l2/adapter_test.cpp +++ b/camera/test/ut/v4l2/adapter_test.cpp @@ -51,4 +51,5 @@ TEST_F(UtestAdapterTest, camera_adapter_0001) cameraBase->captureIds = {cameraBase->CAPTURE_ID_PREVIEW}; cameraBase->streamIds = {cameraBase->STREAM_ID_PREVIEW}; cameraBase->StopStream(cameraBase->captureIds, cameraBase->streamIds); + EXPECT_NE(cameraBase, nullptr); } \ No newline at end of file diff --git a/camera/test/ut/v4l2/buffer_manager_test.cpp b/camera/test/ut/v4l2/buffer_manager_test.cpp index 2b81ed1f21..0e7b91ed8a 100644 --- a/camera/test/ut/v4l2/buffer_manager_test.cpp +++ b/camera/test/ut/v4l2/buffer_manager_test.cpp @@ -53,4 +53,5 @@ TEST_F(UtestBufferManagerTest, camera_buffer_0001) cameraBase->captureIds = {cameraBase->CAPTURE_ID_PREVIEW}; cameraBase->streamIds = {cameraBase->STREAM_ID_PREVIEW}; cameraBase->StopStream(cameraBase->captureIds, cameraBase->streamIds); + EXPECT_NE(cameraBase, nullptr); } \ No newline at end of file -- Gitee From 2e4ece296fd382405a991cef1f5b13658d3e0079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=8F=E6=9D=B0?= Date: Thu, 21 Aug 2025 08:31:20 +0000 Subject: [PATCH 069/100] d MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴敏杰 --- camera/test/mpi/src/buffer_manager_test.cpp | 1 + camera/test/ut/v4l2/camera_capture_test.cpp | 3 +++ camera/test/ut/v4l2/camera_preview_test.cpp | 3 +++ 3 files changed, 7 insertions(+) diff --git a/camera/test/mpi/src/buffer_manager_test.cpp b/camera/test/mpi/src/buffer_manager_test.cpp index 44bedae1b7..5226e4b603 100644 --- a/camera/test/mpi/src/buffer_manager_test.cpp +++ b/camera/test/mpi/src/buffer_manager_test.cpp @@ -53,4 +53,5 @@ HWTEST_F(BufferManagerTest, Camera_Buffer_0001, TestSize.Level0) Test_->streamIds = {Test_->streamId_preview}; Test_->StopStream(Test_->captureIds, Test_->streamIds); Test_->StopConsumer(Test_->intents); + EXPECT_NE(Test_, nullptr); } diff --git a/camera/test/ut/v4l2/camera_capture_test.cpp b/camera/test/ut/v4l2/camera_capture_test.cpp index 47ac216787..d8b7f00a2b 100644 --- a/camera/test/ut/v4l2/camera_capture_test.cpp +++ b/camera/test/ut/v4l2/camera_capture_test.cpp @@ -52,6 +52,7 @@ HWTEST_F(CameraCaptureTest, camera_capture_001, TestSize.Level1) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_CAPTURE}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_CAPTURE}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); + EXPECT_NE(cameraBase, nullptr); } /** @@ -129,6 +130,7 @@ HWTEST_F(CameraCaptureTest, camera_capture_003, TestSize.Level1) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_CAPTURE}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_CAPTURE}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); + EXPECT_NE(cameraBase, nullptr); } /** @@ -169,6 +171,7 @@ HWTEST_F(CameraCaptureTest, camera_capture_004, TestSize.Level1) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_VIDEO}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_VIDEO}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); + EXPECT_NE(cameraBase, nullptr); } /** diff --git a/camera/test/ut/v4l2/camera_preview_test.cpp b/camera/test/ut/v4l2/camera_preview_test.cpp index e1aebf4156..6988a390c2 100644 --- a/camera/test/ut/v4l2/camera_preview_test.cpp +++ b/camera/test/ut/v4l2/camera_preview_test.cpp @@ -251,6 +251,7 @@ HWTEST_F(CameraPreviewTest, camera_preview_032, TestSize.Level2) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_VIDEO}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_VIDEO}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); + EXPECT_NE(cameraBase, nullptr); } /** @@ -275,6 +276,7 @@ HWTEST_F(CameraPreviewTest, camera_preview_033, TestSize.Level2) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_CAPTURE}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_CAPTURE}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); + EXPECT_NE(cameraBase, nullptr); } /** @@ -897,6 +899,7 @@ HWTEST_F(CameraPreviewTest, camera_preview_075, TestSize.Level2) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); + EXPECT_NE(cameraBase, nullptr); } /** -- Gitee From fa60bcd3689271cc92e0fa007e0336f79c3a3497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=8F=E6=9D=B0?= Date: Thu, 21 Aug 2025 08:31:28 +0000 Subject: [PATCH 070/100] d MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴敏杰 --- camera/test/mpi/src/device_manager_test.cpp | 1 + camera/test/mpi/src/hdi_host_test.cpp | 2 +- camera/test/ut/v4l2/device_manager_test.cpp | 1 + camera/test/ut/v4l2/hdfcamera_facedetect.cpp | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/camera/test/mpi/src/device_manager_test.cpp b/camera/test/mpi/src/device_manager_test.cpp index 4087039e33..218256cb13 100644 --- a/camera/test/mpi/src/device_manager_test.cpp +++ b/camera/test/mpi/src/device_manager_test.cpp @@ -52,4 +52,5 @@ HWTEST_F(DeviceManagerTest, Camera_Device_0001, TestSize.Level2) Test_->streamIds = {Test_->streamId_preview}; Test_->StopStream(Test_->captureIds, Test_->streamIds); Test_->StopConsumer(Test_->intents); + EXPECT_NE(Test_, nullptr); } \ No newline at end of file diff --git a/camera/test/mpi/src/hdi_host_test.cpp b/camera/test/mpi/src/hdi_host_test.cpp index 6bfb90af7c..80c0a7f9d1 100644 --- a/camera/test/mpi/src/hdi_host_test.cpp +++ b/camera/test/mpi/src/hdi_host_test.cpp @@ -119,7 +119,7 @@ HWTEST_F(HdiHostTest, Camera_Hdi_0030, TestSize.Level0) EXPECT_EQ(Test_->rc, Camera::NO_ERROR); if (Test_->rc != Camera::NO_ERROR || Test_->cameraDevice == nullptr) { std::cout << "==========[test log]Check hdi_host: OpenCamera failed." << std::endl; - return; + GTEST_SKIP(); } std::cout << "==========[test log]Check hdi_host: OpenCamera success." << std::endl; } diff --git a/camera/test/ut/v4l2/device_manager_test.cpp b/camera/test/ut/v4l2/device_manager_test.cpp index 21fea4205b..9ce86fbaf4 100644 --- a/camera/test/ut/v4l2/device_manager_test.cpp +++ b/camera/test/ut/v4l2/device_manager_test.cpp @@ -50,4 +50,5 @@ TEST_F(UtestDeviceManagerTest, camera_devMan_0001) cameraBase->captureIds = {cameraBase->CAPTURE_ID_PREVIEW}; cameraBase->streamIds = {cameraBase->STREAM_ID_PREVIEW}; cameraBase->StopStream(cameraBase->captureIds, cameraBase->streamIds); + EXPECT_NE(cameraBase, nullptr); } \ No newline at end of file diff --git a/camera/test/ut/v4l2/hdfcamera_facedetect.cpp b/camera/test/ut/v4l2/hdfcamera_facedetect.cpp index 36299e3f13..a72ae885bc 100644 --- a/camera/test/ut/v4l2/hdfcamera_facedetect.cpp +++ b/camera/test/ut/v4l2/hdfcamera_facedetect.cpp @@ -122,4 +122,5 @@ static HWTEST_F(HdfCameraFaceDetect, CameraFaceDetect_002, TestSize.Level1) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_ANALYZE}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_ANALYZE}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); + EXPECT_NE(cameraBase, nullptr); } \ No newline at end of file -- Gitee From 2b5a0bd330b02478d4a01c5d767669fe818b633a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=8F=E6=9D=B0?= Date: Thu, 21 Aug 2025 08:31:53 +0000 Subject: [PATCH 071/100] d MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴敏杰 --- camera/test/ut/v4l2/camera_video_test.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/camera/test/ut/v4l2/camera_video_test.cpp b/camera/test/ut/v4l2/camera_video_test.cpp index 3b6feed82d..79136e13dd 100644 --- a/camera/test/ut/v4l2/camera_video_test.cpp +++ b/camera/test/ut/v4l2/camera_video_test.cpp @@ -197,6 +197,7 @@ HWTEST_F(CameraVideoTest, camera_video_001, TestSize.Level1) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_VIDEO}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_VIDEO}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); + EXPECT_NE(cameraBase, nullptr); } /** @@ -353,6 +354,7 @@ HWTEST_F(CameraVideoTest, camera_video_005, TestSize.Level1) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_VIDEO}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_VIDEO}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); + EXPECT_NE(cameraBase, nullptr); } /** @@ -378,6 +380,7 @@ HWTEST_F(CameraVideoTest, camera_video_010, TestSize.Level2) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_VIDEO}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_VIDEO}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); + EXPECT_NE(cameraBase, nullptr); } } @@ -407,6 +410,7 @@ HWTEST_F(CameraVideoTest, camera_video_011, TestSize.Level2) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_VIDEO}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_VIDEO}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); + EXPECT_NE(cameraBase, nullptr); } } -- Gitee From 4f17a488e974d3b5079499c2e66fce2bcf628138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=8F=E6=9D=B0?= Date: Thu, 21 Aug 2025 09:14:14 +0000 Subject: [PATCH 072/100] d MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴敏杰 --- camera/test/hdi/v1_3/src/camera_hdi_uttest_v1_3.cpp | 4 ++-- camera/test/hdi/v1_3/src/camera_professional_uttest_v1_3.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/camera/test/hdi/v1_3/src/camera_hdi_uttest_v1_3.cpp b/camera/test/hdi/v1_3/src/camera_hdi_uttest_v1_3.cpp index 12210c9088..ad1f2dc189 100644 --- a/camera/test/hdi/v1_3/src/camera_hdi_uttest_v1_3.cpp +++ b/camera/test/hdi/v1_3/src/camera_hdi_uttest_v1_3.cpp @@ -2307,7 +2307,7 @@ HWTEST_F(CameraHdiUtTestV1_3, Camera_Device_Hdi_V1_3_055, TestSize.Level1) int32_t status = SetParameter("vendor.camera.resourcecost.enable", "true"); if (status != 0) { HDF_LOGE("SetParameter error = %{public}d", status); - return; + GTEST_SKIP(); } OHOS::HDI::Camera::V1_3::CameraDeviceResourceCost resourceCost; cameraTest->rc = cameraTest->serviceV1_3->GetResourceCost(cameraTest->cameraIds[0], resourceCost); @@ -2315,6 +2315,6 @@ HWTEST_F(CameraHdiUtTestV1_3, Camera_Device_Hdi_V1_3_055, TestSize.Level1) status = SetParameter("vendor.camera.resourcecost.enable", "false"); if (status != 0) { HDF_LOGE("SetParameter error = %{public}d", status); - return; + GTEST_SKIP(); } } \ No newline at end of file diff --git a/camera/test/hdi/v1_3/src/camera_professional_uttest_v1_3.cpp b/camera/test/hdi/v1_3/src/camera_professional_uttest_v1_3.cpp index 8f6374dfb5..333464f5dd 100644 --- a/camera/test/hdi/v1_3/src/camera_professional_uttest_v1_3.cpp +++ b/camera/test/hdi/v1_3/src/camera_professional_uttest_v1_3.cpp @@ -434,7 +434,7 @@ HWTEST_F(CameraProfessionalUtTestV1_3, Camera_Professional_Hdi_V1_3_008, TestSiz } } else { printf("get tag failed.\n"); - return; + GTEST_SKIP(); } for (uint8_t i = 0;i < entry.count;i++) { -- Gitee From c3ab2baa2b9629f7944a5d4b76b627b369eb4ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=8F=E6=9D=B0?= Date: Thu, 21 Aug 2025 09:44:16 +0000 Subject: [PATCH 073/100] d MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴敏杰 --- camera/test/ut/v4l2/camera_capture_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/camera/test/ut/v4l2/camera_capture_test.cpp b/camera/test/ut/v4l2/camera_capture_test.cpp index d8b7f00a2b..fd1fa6ce2e 100644 --- a/camera/test/ut/v4l2/camera_capture_test.cpp +++ b/camera/test/ut/v4l2/camera_capture_test.cpp @@ -52,7 +52,7 @@ HWTEST_F(CameraCaptureTest, camera_capture_001, TestSize.Level1) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_CAPTURE}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_CAPTURE}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); - EXPECT_NE(cameraBase, nullptr); + EXPECT_NE(cameraBase_, nullptr); } /** @@ -130,7 +130,7 @@ HWTEST_F(CameraCaptureTest, camera_capture_003, TestSize.Level1) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_CAPTURE}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_CAPTURE}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); - EXPECT_NE(cameraBase, nullptr); + EXPECT_NE(cameraBase_, nullptr); } /** @@ -171,7 +171,7 @@ HWTEST_F(CameraCaptureTest, camera_capture_004, TestSize.Level1) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_VIDEO}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_VIDEO}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); - EXPECT_NE(cameraBase, nullptr); + EXPECT_NE(cameraBase_, nullptr); } /** -- Gitee From f1b57a7644549e0e14a8d42e8d33ff7d25c3f1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=8F=E6=9D=B0?= Date: Thu, 21 Aug 2025 09:47:15 +0000 Subject: [PATCH 074/100] d MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴敏杰 --- camera/test/ut/v4l2/camera_preview_test.cpp | 6 +++--- camera/test/ut/v4l2/camera_video_test.cpp | 8 ++++---- camera/test/ut/v4l2/device_manager_test.cpp | 2 +- camera/test/ut/v4l2/hdfcamera_facedetect.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/camera/test/ut/v4l2/camera_preview_test.cpp b/camera/test/ut/v4l2/camera_preview_test.cpp index 6988a390c2..74c00ffd4e 100644 --- a/camera/test/ut/v4l2/camera_preview_test.cpp +++ b/camera/test/ut/v4l2/camera_preview_test.cpp @@ -251,7 +251,7 @@ HWTEST_F(CameraPreviewTest, camera_preview_032, TestSize.Level2) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_VIDEO}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_VIDEO}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); - EXPECT_NE(cameraBase, nullptr); + EXPECT_NE(cameraBase_, nullptr); } /** @@ -276,7 +276,7 @@ HWTEST_F(CameraPreviewTest, camera_preview_033, TestSize.Level2) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_CAPTURE}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_CAPTURE}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); - EXPECT_NE(cameraBase, nullptr); + EXPECT_NE(cameraBase_, nullptr); } /** @@ -899,7 +899,7 @@ HWTEST_F(CameraPreviewTest, camera_preview_075, TestSize.Level2) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); - EXPECT_NE(cameraBase, nullptr); + EXPECT_NE(cameraBase_, nullptr); } /** diff --git a/camera/test/ut/v4l2/camera_video_test.cpp b/camera/test/ut/v4l2/camera_video_test.cpp index 79136e13dd..59250754df 100644 --- a/camera/test/ut/v4l2/camera_video_test.cpp +++ b/camera/test/ut/v4l2/camera_video_test.cpp @@ -197,7 +197,7 @@ HWTEST_F(CameraVideoTest, camera_video_001, TestSize.Level1) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_VIDEO}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_VIDEO}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); - EXPECT_NE(cameraBase, nullptr); + EXPECT_NE(cameraBase_, nullptr); } /** @@ -354,7 +354,7 @@ HWTEST_F(CameraVideoTest, camera_video_005, TestSize.Level1) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_VIDEO}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_VIDEO}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); - EXPECT_NE(cameraBase, nullptr); + EXPECT_NE(cameraBase_, nullptr); } /** @@ -380,7 +380,7 @@ HWTEST_F(CameraVideoTest, camera_video_010, TestSize.Level2) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_VIDEO}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_VIDEO}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); - EXPECT_NE(cameraBase, nullptr); + EXPECT_NE(cameraBase_, nullptr); } } @@ -410,7 +410,7 @@ HWTEST_F(CameraVideoTest, camera_video_011, TestSize.Level2) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_VIDEO}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_VIDEO}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); - EXPECT_NE(cameraBase, nullptr); + EXPECT_NE(cameraBase_, nullptr); } } diff --git a/camera/test/ut/v4l2/device_manager_test.cpp b/camera/test/ut/v4l2/device_manager_test.cpp index 9ce86fbaf4..2e290a8572 100644 --- a/camera/test/ut/v4l2/device_manager_test.cpp +++ b/camera/test/ut/v4l2/device_manager_test.cpp @@ -50,5 +50,5 @@ TEST_F(UtestDeviceManagerTest, camera_devMan_0001) cameraBase->captureIds = {cameraBase->CAPTURE_ID_PREVIEW}; cameraBase->streamIds = {cameraBase->STREAM_ID_PREVIEW}; cameraBase->StopStream(cameraBase->captureIds, cameraBase->streamIds); - EXPECT_NE(cameraBase, nullptr); + EXPECT_NE(cameraBase_, nullptr); } \ No newline at end of file diff --git a/camera/test/ut/v4l2/hdfcamera_facedetect.cpp b/camera/test/ut/v4l2/hdfcamera_facedetect.cpp index a72ae885bc..cbba907da3 100644 --- a/camera/test/ut/v4l2/hdfcamera_facedetect.cpp +++ b/camera/test/ut/v4l2/hdfcamera_facedetect.cpp @@ -122,5 +122,5 @@ static HWTEST_F(HdfCameraFaceDetect, CameraFaceDetect_002, TestSize.Level1) cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_ANALYZE}; cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_ANALYZE}; cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds); - EXPECT_NE(cameraBase, nullptr); + EXPECT_NE(cameraBase_, nullptr); } \ No newline at end of file -- Gitee From 4cbe38f7a2255dcdee3a82cceef7abfed03161ba Mon Sep 17 00:00:00 2001 From: hejiaogirl Date: Thu, 21 Aug 2025 18:08:58 +0800 Subject: [PATCH 075/100] fix : change user max num Signed-off-by: hejiaogirl Change-Id: Iaf716ab135e0d006351e4d30e80f82e738a6a596 --- user_auth/hdi_service/database/inc/idm_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_auth/hdi_service/database/inc/idm_common.h b/user_auth/hdi_service/database/inc/idm_common.h index 05a8abd7c0..e0f75c51d5 100644 --- a/user_auth/hdi_service/database/inc/idm_common.h +++ b/user_auth/hdi_service/database/inc/idm_common.h @@ -23,7 +23,7 @@ extern "C" { #endif -#define MAX_USER 5 +#define MAX_USER 32 #define MAX_CREDENTIAL 100 #define ROOT_SECRET_LEN 32 #define NO_CHECK_PIN_EXPIRED_PERIOD 0 -- Gitee From a913fc3d46d9724078ffd3b79e18e0b063865c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Thu, 21 Aug 2025 19:26:37 +0800 Subject: [PATCH 076/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../hdi_service_3.0/sensor_callback_vdi.cpp | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index 4650fbe639..ae3b229ccb 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -202,8 +202,25 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, //Check if the current record time exceeds one second if (std::chrono::duration_cast(currentTime - lastRecordTime).count() >= ONE_SECOND) { int64_t perSecondCount = currentDataCount - lastDataCount; - - lastRecordTime += std::chrono::milliseconds(ONE_SECOND); + auto currentSeconds = std::chrono::duration_cast(currentTime); + // 将 currentSeconds 转换为 std::time_t(即秒部分的时间戳) + std::time_t currentTimeT = currentSeconds.count(); + + // 获取毫秒部分 + auto milliseconds = std::chrono::duration_cast(currentSeconds) % 1000; + + // 转换为当地时间 + std::tm* localTime = std::localtime(¤tTimeT); + + // 构造格式化的时间字符串 + std::ostringstream timeStream; + timeStream << std::put_time(localTime, "%Y-%m-%d %H:%M:%S") + << "." + << std::setw(3) << std::setfill('0') << milliseconds.count(); // 毫秒部分 + + // 打印日志,使用 HDF_LOGI + HDF_LOGI("%{public}s: current time: %{public}s", __func__, timeStream.str().c_str()); + lastRecordTime = currentSeconds; lastDataCount = currentDataCount; if (perSecondCount >= targetCount - acceptablError && perSecondCount <= targetCount + acceptablError) { -- Gitee From 85f2df32af4c2f22484500d1469ade8cd7d12c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Thu, 21 Aug 2025 20:18:37 +0800 Subject: [PATCH 077/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- .../hdi_service_3.0/sensor_callback_vdi.cpp | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index ae3b229ccb..9b49e10ac7 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -203,23 +203,11 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, if (std::chrono::duration_cast(currentTime - lastRecordTime).count() >= ONE_SECOND) { int64_t perSecondCount = currentDataCount - lastDataCount; auto currentSeconds = std::chrono::duration_cast(currentTime); - // 将 currentSeconds 转换为 std::time_t(即秒部分的时间戳) - std::time_t currentTimeT = currentSeconds.count(); - - // 获取毫秒部分 - auto milliseconds = std::chrono::duration_cast(currentSeconds) % 1000; - - // 转换为当地时间 - std::tm* localTime = std::localtime(¤tTimeT); - - // 构造格式化的时间字符串 - std::ostringstream timeStream; - timeStream << std::put_time(localTime, "%Y-%m-%d %H:%M:%S") - << "." - << std::setw(3) << std::setfill('0') << milliseconds.count(); // 毫秒部分 - - // 打印日志,使用 HDF_LOGI - HDF_LOGI("%{public}s: current time: %{public}s", __func__, timeStream.str().c_str()); + + int64_t c1 = std::chrono::duration_cast(currentTime).count(); + int64_t c2 = std::chrono::duration_cast(currentSeconds).count(); + HDF_LOGI("%{public}s: c1 = %{public}s c2 = %{public}s", __func__, std::to_string(c1).c_str(), std::to_string(c2).c_str()); + lastRecordTime = currentSeconds; lastDataCount = currentDataCount; -- Gitee From 6be7d2fa00350c3ca4e11bc2c92e128ad320de08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Thu, 21 Aug 2025 20:44:09 +0800 Subject: [PATCH 078/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index 9b49e10ac7..cafc149b8e 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -202,10 +202,10 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, //Check if the current record time exceeds one second if (std::chrono::duration_cast(currentTime - lastRecordTime).count() >= ONE_SECOND) { int64_t perSecondCount = currentDataCount - lastDataCount; - auto currentSeconds = std::chrono::duration_cast(currentTime); + auto currentSeconds = std::chrono::time_point_cast(currentTime); - int64_t c1 = std::chrono::duration_cast(currentTime).count(); - int64_t c2 = std::chrono::duration_cast(currentSeconds).count(); + int64_t c1 = currentTime.time_since_epoch().count(); + int64_t c2 = std::chrono::duration_cast(currentSeconds).time_since_epoch().count(); HDF_LOGI("%{public}s: c1 = %{public}s c2 = %{public}s", __func__, std::to_string(c1).c_str(), std::to_string(c2).c_str()); lastRecordTime = currentSeconds; -- Gitee From dc16911f655323b2de057426e757f5b957b7e586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Thu, 21 Aug 2025 20:45:35 +0800 Subject: [PATCH 079/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index cafc149b8e..02a9b44de3 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -205,7 +205,7 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, auto currentSeconds = std::chrono::time_point_cast(currentTime); int64_t c1 = currentTime.time_since_epoch().count(); - int64_t c2 = std::chrono::duration_cast(currentSeconds).time_since_epoch().count(); + int64_t c2 = std::chrono::duration_cast(currentSeconds.time_since_epoch()).count(); HDF_LOGI("%{public}s: c1 = %{public}s c2 = %{public}s", __func__, std::to_string(c1).c_str(), std::to_string(c2).c_str()); lastRecordTime = currentSeconds; -- Gitee From ac4bf60af1b8ab57cba98e80d6634d7654a5b3c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Fri, 22 Aug 2025 10:38:37 +0800 Subject: [PATCH 080/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index 02a9b44de3..f081e3bfe9 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -203,9 +203,10 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, if (std::chrono::duration_cast(currentTime - lastRecordTime).count() >= ONE_SECOND) { int64_t perSecondCount = currentDataCount - lastDataCount; auto currentSeconds = std::chrono::time_point_cast(currentTime); + auto currentSeconds2 = std::chrono::time_point_cast(currentSeconds); int64_t c1 = currentTime.time_since_epoch().count(); - int64_t c2 = std::chrono::duration_cast(currentSeconds.time_since_epoch()).count(); + int64_t c2 = currentSeconds2.time_since_epoch().count(); HDF_LOGI("%{public}s: c1 = %{public}s c2 = %{public}s", __func__, std::to_string(c1).c_str(), std::to_string(c2).c_str()); lastRecordTime = currentSeconds; -- Gitee From 131758afcdc6d5f7aef8cf6d609214f3cd46c29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Fri, 22 Aug 2025 10:46:15 +0800 Subject: [PATCH 081/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index f081e3bfe9..fca593548b 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -211,9 +211,10 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, lastRecordTime = currentSeconds; lastDataCount = currentDataCount; + HDF_LOGI("%{public}s: lastRecordTime = %{public}s", __func__, std::to_string(lastRecordTime.time_since_epoch().count()).c_str()); if (perSecondCount >= targetCount - acceptablError && perSecondCount <= targetCount + acceptablError) { - return; // Skip logging if the count is within acceptable range + // return; // Skip logging if the count is within acceptable range } HDF_LOGE("%{public}s: %{public}s perSecondCount %{public}s targetCount %{public}s~%{public}s samplingInterval " "%{public}s", __func__, SENSOR_HANDLE_TO_C_STR(sensorHandle), std::to_string(perSecondCount).c_str(), -- Gitee From eefdbe3e0f124032cd40384d4f1a3882b5be072c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Fri, 22 Aug 2025 10:52:16 +0800 Subject: [PATCH 082/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index fca593548b..a00318d143 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -202,15 +202,10 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, //Check if the current record time exceeds one second if (std::chrono::duration_cast(currentTime - lastRecordTime).count() >= ONE_SECOND) { int64_t perSecondCount = currentDataCount - lastDataCount; - auto currentSeconds = std::chrono::time_point_cast(currentTime); - auto currentSeconds2 = std::chrono::time_point_cast(currentSeconds); - int64_t c1 = currentTime.time_since_epoch().count(); - int64_t c2 = currentSeconds2.time_since_epoch().count(); - HDF_LOGI("%{public}s: c1 = %{public}s c2 = %{public}s", __func__, std::to_string(c1).c_str(), std::to_string(c2).c_str()); - - lastRecordTime = currentSeconds; + lastRecordTime = std::chrono::time_point_cast(currentTime); lastDataCount = currentDataCount; + HDF_LOGI("%{public}s: lastRecordTime = %{public}s", __func__, std::to_string(lastRecordTime.time_since_epoch().count()).c_str()); if (perSecondCount >= targetCount - acceptablError && perSecondCount <= targetCount + acceptablError) { -- Gitee From baf0ee9b3e67e9b9771e52119182089b728292a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Fri, 22 Aug 2025 10:57:16 +0800 Subject: [PATCH 083/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index a00318d143..4c85b2f412 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -206,7 +206,11 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, lastRecordTime = std::chrono::time_point_cast(currentTime); lastDataCount = currentDataCount; - HDF_LOGI("%{public}s: lastRecordTime = %{public}s", __func__, std::to_string(lastRecordTime.time_since_epoch().count()).c_str()); + HDF_LOGI("%{public}s: lastRecordTime = %{public}s currentTime = %{public}s duration = %{public}lld", + __func__, + std::to_string(lastRecordTime.time_since_epoch().count()).c_str(), + std::to_string(currentTime.time_since_epoch().count()).c_str()), + std::chrono::duration_cast(currentTime - lastRecordTime).count(); if (perSecondCount >= targetCount - acceptablError && perSecondCount <= targetCount + acceptablError) { // return; // Skip logging if the count is within acceptable range -- Gitee From 3518dbb93bba2ef2bc1dbd62203dbdfa44095e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Fri, 22 Aug 2025 10:59:06 +0800 Subject: [PATCH 084/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index 4c85b2f412..ffbd1a4210 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -209,8 +209,8 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, HDF_LOGI("%{public}s: lastRecordTime = %{public}s currentTime = %{public}s duration = %{public}lld", __func__, std::to_string(lastRecordTime.time_since_epoch().count()).c_str(), - std::to_string(currentTime.time_since_epoch().count()).c_str()), - std::chrono::duration_cast(currentTime - lastRecordTime).count(); + std::to_string(currentTime.time_since_epoch().count()).c_str(), + std::chrono::duration_cast(currentTime - lastRecordTime).count()); if (perSecondCount >= targetCount - acceptablError && perSecondCount <= targetCount + acceptablError) { // return; // Skip logging if the count is within acceptable range -- Gitee From d338f336523f72e9b2de9116056cdb8aab47c731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Fri, 22 Aug 2025 11:03:35 +0800 Subject: [PATCH 085/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index ffbd1a4210..35937fc83c 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -200,17 +200,23 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, } //Check if the current record time exceeds one second - if (std::chrono::duration_cast(currentTime - lastRecordTime).count() >= ONE_SECOND) { + int64_t duration = std::chrono::duration_cast(currentTime - lastRecordTime).count(); + if (duration >= ONE_SECOND) { int64_t perSecondCount = currentDataCount - lastDataCount; + HDF_LOGI("%{public}s: 111lastRecordTime = %{public}s currentTime = %{public}s duration = %{public}lld", + __func__, + std::to_string(lastRecordTime.time_since_epoch().count()).c_str(), + std::to_string(currentTime.time_since_epoch().count()).c_str(), + duration); lastRecordTime = std::chrono::time_point_cast(currentTime); lastDataCount = currentDataCount; - HDF_LOGI("%{public}s: lastRecordTime = %{public}s currentTime = %{public}s duration = %{public}lld", + HDF_LOGI("%{public}s: 222lastRecordTime = %{public}s currentTime = %{public}s duration = %{public}lld", __func__, std::to_string(lastRecordTime.time_since_epoch().count()).c_str(), std::to_string(currentTime.time_since_epoch().count()).c_str(), - std::chrono::duration_cast(currentTime - lastRecordTime).count()); + duration); if (perSecondCount >= targetCount - acceptablError && perSecondCount <= targetCount + acceptablError) { // return; // Skip logging if the count is within acceptable range -- Gitee From 3692611c8da68e7bbaa015e71a9df99a14efa539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Fri, 22 Aug 2025 11:04:13 +0800 Subject: [PATCH 086/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index 35937fc83c..3fec10334a 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -200,7 +200,7 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, } //Check if the current record time exceeds one second - int64_t duration = std::chrono::duration_cast(currentTime - lastRecordTime).count(); + auto duration = std::chrono::duration_cast(currentTime - lastRecordTime).count(); if (duration >= ONE_SECOND) { int64_t perSecondCount = currentDataCount - lastDataCount; -- Gitee From bcc7b2ddcbeb4790f8c712e7a2a156f53c1c0393 Mon Sep 17 00:00:00 2001 From: fengliucs Date: Fri, 22 Aug 2025 11:07:31 +0800 Subject: [PATCH 087/100] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmtp/ptp=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E9=AB=98=E6=A6=82=E7=8E=87=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9B=98=E7=AC=A6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fengliucs --- usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp b/usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp index e6e206bd00..f236555d34 100755 --- a/usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp +++ b/usb/gadget/function/mtp/src/usbfn_mtp_impl.cpp @@ -1225,10 +1225,15 @@ int32_t UsbfnMtpImpl::Start() pthread_rwlock_wrlock(&mtpRunrwLock_); std::lock_guard guard(startMutex_); + int32_t ret = UsbMtpPortInitIo(); + if (ret != HDF_SUCCESS) { + pthread_rwlock_unlock(&mtpRunrwLock_); + HDF_LOGE("%{public}s: request failed: %{public}d", __func__, ret); + return ret; + } mtpDev_->mtpState = MTP_STATE_READY; mtpPort_->startDelayed = true; mtpPort_->isActive = true; - int32_t ret = UsbMtpPortInitIo(); pthread_rwlock_unlock(&mtpRunrwLock_); HDF_LOGI("%{public}s: end", __func__); return ret; -- Gitee From 56c75177f412eb908af822c84b7e241de3055776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Fri, 22 Aug 2025 11:16:26 +0800 Subject: [PATCH 088/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index 3fec10334a..55db8735ef 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -204,16 +204,16 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, if (duration >= ONE_SECOND) { int64_t perSecondCount = currentDataCount - lastDataCount; - HDF_LOGI("%{public}s: 111lastRecordTime = %{public}s currentTime = %{public}s duration = %{public}lld", - __func__, + HDF_LOGI("%{public}s:%{public}s 111lastRecordTime = %{public}s currentTime = %{public}s duration = %{public}lld", + __func__, SENSOR_HANDLE_TO_C_STR(sensorHandle), std::to_string(lastRecordTime.time_since_epoch().count()).c_str(), std::to_string(currentTime.time_since_epoch().count()).c_str(), duration); lastRecordTime = std::chrono::time_point_cast(currentTime); lastDataCount = currentDataCount; - HDF_LOGI("%{public}s: 222lastRecordTime = %{public}s currentTime = %{public}s duration = %{public}lld", - __func__, + HDF_LOGI("%{public}s:%{public}s 222lastRecordTime = %{public}s currentTime = %{public}s duration = %{public}lld", + __func__, SENSOR_HANDLE_TO_C_STR(sensorHandle), std::to_string(lastRecordTime.time_since_epoch().count()).c_str(), std::to_string(currentTime.time_since_epoch().count()).c_str(), duration); -- Gitee From d44e4c26ecb1861e9e5b77d3fbd6d8a1a2a2426a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Fri, 22 Aug 2025 11:22:41 +0800 Subject: [PATCH 089/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index 55db8735ef..7aff026948 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -203,12 +203,6 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, auto duration = std::chrono::duration_cast(currentTime - lastRecordTime).count(); if (duration >= ONE_SECOND) { int64_t perSecondCount = currentDataCount - lastDataCount; - - HDF_LOGI("%{public}s:%{public}s 111lastRecordTime = %{public}s currentTime = %{public}s duration = %{public}lld", - __func__, SENSOR_HANDLE_TO_C_STR(sensorHandle), - std::to_string(lastRecordTime.time_since_epoch().count()).c_str(), - std::to_string(currentTime.time_since_epoch().count()).c_str(), - duration); lastRecordTime = std::chrono::time_point_cast(currentTime); lastDataCount = currentDataCount; -- Gitee From 06ebe37c879afd7acb1520507a2b5eed623e0a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Fri, 22 Aug 2025 15:11:50 +0800 Subject: [PATCH 090/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index 7aff026948..5a54ac437d 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -206,14 +206,8 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, lastRecordTime = std::chrono::time_point_cast(currentTime); lastDataCount = currentDataCount; - HDF_LOGI("%{public}s:%{public}s 222lastRecordTime = %{public}s currentTime = %{public}s duration = %{public}lld", - __func__, SENSOR_HANDLE_TO_C_STR(sensorHandle), - std::to_string(lastRecordTime.time_since_epoch().count()).c_str(), - std::to_string(currentTime.time_since_epoch().count()).c_str(), - duration); - if (perSecondCount >= targetCount - acceptablError && perSecondCount <= targetCount + acceptablError) { - // return; // Skip logging if the count is within acceptable range + return; // Skip logging if the count is within acceptable range } HDF_LOGE("%{public}s: %{public}s perSecondCount %{public}s targetCount %{public}s~%{public}s samplingInterval " "%{public}s", __func__, SENSOR_HANDLE_TO_C_STR(sensorHandle), std::to_string(perSecondCount).c_str(), -- Gitee From 51c1a6cc90690fddc2d43d7dd841b22a73743567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Fri, 22 Aug 2025 15:12:13 +0800 Subject: [PATCH 091/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index 5a54ac437d..684b09d759 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -200,8 +200,7 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, } //Check if the current record time exceeds one second - auto duration = std::chrono::duration_cast(currentTime - lastRecordTime).count(); - if (duration >= ONE_SECOND) { + if (std::chrono::duration_cast(currentTime - lastRecordTime).count() >= ONE_SECOND) { int64_t perSecondCount = currentDataCount - lastDataCount; lastRecordTime = std::chrono::time_point_cast(currentTime); lastDataCount = currentDataCount; -- Gitee From fafb680bac03c44c7e88f8d7e15bf0ffdd6dfdc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Fri, 22 Aug 2025 15:12:28 +0800 Subject: [PATCH 092/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index 684b09d759..6feb397ad3 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -202,6 +202,7 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, //Check if the current record time exceeds one second if (std::chrono::duration_cast(currentTime - lastRecordTime).count() >= ONE_SECOND) { int64_t perSecondCount = currentDataCount - lastDataCount; + lastRecordTime = std::chrono::time_point_cast(currentTime); lastDataCount = currentDataCount; -- Gitee From 279743c374ae76ebf4b7f48431ab4111bd598f1a Mon Sep 17 00:00:00 2001 From: hejiaogirl Date: Fri, 22 Aug 2025 17:22:17 +0800 Subject: [PATCH 093/100] fix : change user max num Signed-off-by: hejiaogirl Change-Id: I93f60c73c344a6189b014ce829abf5546a2ac3d2 --- user_auth/hdi_service/database/inc/idm_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_auth/hdi_service/database/inc/idm_common.h b/user_auth/hdi_service/database/inc/idm_common.h index e0f75c51d5..05a8abd7c0 100644 --- a/user_auth/hdi_service/database/inc/idm_common.h +++ b/user_auth/hdi_service/database/inc/idm_common.h @@ -23,7 +23,7 @@ extern "C" { #endif -#define MAX_USER 32 +#define MAX_USER 5 #define MAX_CREDENTIAL 100 #define ROOT_SECRET_LEN 32 #define NO_CHECK_PIN_EXPIRED_PERIOD 0 -- Gitee From 8a1eb369fd14fa9b342f73008ee3d002cd5e6dda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 23 Aug 2025 16:53:24 +0800 Subject: [PATCH 094/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index 6feb397ad3..a69a8a9248 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -200,17 +200,21 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, } //Check if the current record time exceeds one second - if (std::chrono::duration_cast(currentTime - lastRecordTime).count() >= ONE_SECOND) { - int64_t perSecondCount = currentDataCount - lastDataCount; + auto duration = std::chrono::duration_cast(currentTime - lastRecordTime).count(); + if (duration >= ONE_SECOND) { + int64_t durationCount = currentDataCount - lastDataCount; + int64_t perSecondCount = durationSensorCount / (duration / ONE_SECOND); - lastRecordTime = std::chrono::time_point_cast(currentTime); + lastRecordTime = currentTime; lastDataCount = currentDataCount; if (perSecondCount >= targetCount - acceptablError && perSecondCount <= targetCount + acceptablError) { return; // Skip logging if the count is within acceptable range } - HDF_LOGE("%{public}s: %{public}s perSecondCount %{public}s targetCount %{public}s~%{public}s samplingInterval " - "%{public}s", __func__, SENSOR_HANDLE_TO_C_STR(sensorHandle), std::to_string(perSecondCount).c_str(), + HDF_LOGE("%{public}s: %{public}s duration %{public}s durationCount %{public}s perSecondCount %{public}s " + "targetCount %{public}s~%{public}s samplingInterval %{public}s", + __func__, SENSOR_HANDLE_TO_C_STR(sensorHandle), std::to_string(duration).c_str(), + std::to_string(durationCount).c_str(), std::to_string(perSecondCount).c_str(), std::to_string(targetCount - acceptablError).c_str(), std::to_string(targetCount + acceptablError).c_str(), std::to_string(samplingInterval / ONE_MILLION).c_str()); } -- Gitee From 58c8889f12ff16ec6e9ede19e2f2259cbc33cbed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 23 Aug 2025 16:54:09 +0800 Subject: [PATCH 095/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index a69a8a9248..9aa9b4370f 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -203,7 +203,7 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, auto duration = std::chrono::duration_cast(currentTime - lastRecordTime).count(); if (duration >= ONE_SECOND) { int64_t durationCount = currentDataCount - lastDataCount; - int64_t perSecondCount = durationSensorCount / (duration / ONE_SECOND); + int64_t perSecondCount = durationCount / (duration / ONE_SECOND); lastRecordTime = currentTime; lastDataCount = currentDataCount; -- Gitee From 62db0a112321bb6923bc335cab6ebc384ececa58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 23 Aug 2025 17:01:59 +0800 Subject: [PATCH 096/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index 9aa9b4370f..d3e05d0a4d 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -32,6 +32,7 @@ namespace { constexpr int64_t DEFAULT_ACCEPTABLE_ERROR = 2; constexpr double COMMON_REPORT_FREQUENCY = 1000000000.0; constexpr int32_t ONE_SECOND = 1000; + constexpr int32_t TWO_SECOND = 2000; static std::unordered_map firstTimestampMap_; static std::unordered_map lastTimestampMap_; const std::vector NEED_PRINT_COUNT_SENSOR = { @@ -208,6 +209,9 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, lastRecordTime = currentTime; lastDataCount = currentDataCount; + if (duration > TWO_SECOND) { + return; // Skip logging if the duration exceeds two seconds + } if (perSecondCount >= targetCount - acceptablError && perSecondCount <= targetCount + acceptablError) { return; // Skip logging if the count is within acceptable range } -- Gitee From d6a38e2c1477a11dd3b6f734d7119013a6e852dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 23 Aug 2025 17:11:01 +0800 Subject: [PATCH 097/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index d3e05d0a4d..14bd14cfd4 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -204,7 +204,7 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, auto duration = std::chrono::duration_cast(currentTime - lastRecordTime).count(); if (duration >= ONE_SECOND) { int64_t durationCount = currentDataCount - lastDataCount; - int64_t perSecondCount = durationCount / (duration / ONE_SECOND); + int64_t perSecondCount = (int64_t)((double)durationCount / ((double)duration / (double)ONE_SECOND)); lastRecordTime = currentTime; lastDataCount = currentDataCount; -- Gitee From d1e62fce226ffcc21bb572d1361e51ec412878c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 23 Aug 2025 17:19:55 +0800 Subject: [PATCH 098/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_callback_vdi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index 14bd14cfd4..1023cdc87f 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -204,7 +204,7 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, auto duration = std::chrono::duration_cast(currentTime - lastRecordTime).count(); if (duration >= ONE_SECOND) { int64_t durationCount = currentDataCount - lastDataCount; - int64_t perSecondCount = (int64_t)((double)durationCount / ((double)duration / (double)ONE_SECOND)); + int64_t perSecondCount = std::ceil((double)durationCount / ((double)duration / (double)ONE_SECOND)); lastRecordTime = currentTime; lastDataCount = currentDataCount; -- Gitee From 0af54c44ca13a4c3525212fc4c05aa4e5acfd5d9 Mon Sep 17 00:00:00 2001 From: wenxiaolin Date: Sat, 23 Aug 2025 01:19:05 +0800 Subject: [PATCH 099/100] add CFI check for nfc & secure_element Signed-off-by: wenxiaolin --- nfc/hdi_service/BUILD.gn | 2 ++ secure_element/hdi_service/BUILD.gn | 1 + secure_element/secure_element_ca_proxy/BUILD.gn | 1 + secure_element/sim_hdi_service/BUILD.gn | 2 ++ secure_element/vendor_adaptor/BUILD.gn | 1 + secure_element/vendor_sim_adaptor/BUILD.gn | 1 + 6 files changed, 8 insertions(+) diff --git a/nfc/hdi_service/BUILD.gn b/nfc/hdi_service/BUILD.gn index 80c104df2c..b8582d214e 100644 --- a/nfc/hdi_service/BUILD.gn +++ b/nfc/hdi_service/BUILD.gn @@ -19,6 +19,7 @@ ohos_shared_library("libnfc_interface_service_1.1") { "//drivers/peripheral/nfc/vendor_adaptor", ] sources = [ "nfc_impl.cpp" ] + branch_protector_ret = "pac_ret" public_deps = [ "//drivers/peripheral/nfc/vendor_adaptor:nfc_vendor_adaptor" ] cflags = [] @@ -59,6 +60,7 @@ ohos_shared_library("nfc_hdi_driver") { "hilog:libhilog", "ipc:ipc_single", ] + branch_protector_ret = "pac_ret" shlib_type = "hdi" install_images = [ chipset_base_dir ] diff --git a/secure_element/hdi_service/BUILD.gn b/secure_element/hdi_service/BUILD.gn index e2fef47b54..e56eabee31 100644 --- a/secure_element/hdi_service/BUILD.gn +++ b/secure_element/hdi_service/BUILD.gn @@ -36,6 +36,7 @@ ohos_shared_library("libsecure_element_interface_service_1.0") { ohos_shared_library("se_hdi_driver") { sources = [ "se_interface_driver.cpp" ] + branch_protector_ret = "pac_ret" deps = [] diff --git a/secure_element/secure_element_ca_proxy/BUILD.gn b/secure_element/secure_element_ca_proxy/BUILD.gn index a282f76d0c..aaf35a8db9 100644 --- a/secure_element/secure_element_ca_proxy/BUILD.gn +++ b/secure_element/secure_element_ca_proxy/BUILD.gn @@ -20,6 +20,7 @@ config("exported_ca_header") { ohos_shared_library("secure_element_ca_proxy") { include_dirs = [] sources = [ "secure_element_ca_proxy.cpp" ] + branch_protector_ret = "pac_ret" external_deps = [ "c_utils:utils", diff --git a/secure_element/sim_hdi_service/BUILD.gn b/secure_element/sim_hdi_service/BUILD.gn index 4c78b14ac6..ac1f364bea 100644 --- a/secure_element/sim_hdi_service/BUILD.gn +++ b/secure_element/sim_hdi_service/BUILD.gn @@ -18,6 +18,7 @@ ohos_shared_library("libsim_secure_element_interface_service_1.0") { include_dirs = [ "../vendor_sim_adaptor" ] sources = [ "secure_element_interface_service.cpp" ] public_deps = [ "../vendor_sim_adaptor:sim_se_vendor_adaptor" ] + branch_protector_ret = "pac_ret" cflags = [] @@ -38,6 +39,7 @@ ohos_shared_library("sim_se_hdi_driver") { include_dirs = [ "../vendor_sim_adaptor" ] sources = [ "secure_element_interface_driver.cpp" ] public_deps = [ "../vendor_sim_adaptor:sim_se_vendor_adaptor" ] + branch_protector_ret = "pac_ret" deps = [ ":libsim_secure_element_interface_service_1.0" ] diff --git a/secure_element/vendor_adaptor/BUILD.gn b/secure_element/vendor_adaptor/BUILD.gn index ae45664ce3..82f2656cab 100644 --- a/secure_element/vendor_adaptor/BUILD.gn +++ b/secure_element/vendor_adaptor/BUILD.gn @@ -16,6 +16,7 @@ import("../secure_element.gni") ohos_shared_library("se_vendor_adaptor") { sources = [ "se_vendor_adaptions.cpp" ] + branch_protector_ret = "pac_ret" public_deps = [] diff --git a/secure_element/vendor_sim_adaptor/BUILD.gn b/secure_element/vendor_sim_adaptor/BUILD.gn index 1c5f42c01c..ee3dc38223 100644 --- a/secure_element/vendor_sim_adaptor/BUILD.gn +++ b/secure_element/vendor_sim_adaptor/BUILD.gn @@ -16,6 +16,7 @@ import("../secure_element.gni") ohos_shared_library("sim_se_vendor_adaptor") { sources = [ "se_vendor_adaptions.cpp" ] + branch_protector_ret = "pac_ret" public_deps = [] -- Gitee From 4869273ae169ecc9ab5ad85eb01c063acb477bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Tue, 26 Aug 2025 20:05:10 +0800 Subject: [PATCH 100/100] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- sensor/hdi_service_3.0/sensor_client_info.cpp | 2 +- sensor/hdi_service_3.0/sensor_client_info.h | 2 +- sensor/hdi_service_3.0/sensor_clients_manager.cpp | 14 +++++++------- sensor/hdi_service_3.0/sensor_if_service.cpp | 10 ++++++---- sensor/hdi_service_3.0/sensor_if_service.h | 2 +- sensor/test/common/src/sensor_callback_impl.cpp | 4 ++-- usb/hdi_service/src/usb_device_impl.cpp | 2 +- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/sensor/hdi_service_3.0/sensor_client_info.cpp b/sensor/hdi_service_3.0/sensor_client_info.cpp index 83ddaa51f0..fcebf6722a 100644 --- a/sensor/hdi_service_3.0/sensor_client_info.cpp +++ b/sensor/hdi_service_3.0/sensor_client_info.cpp @@ -36,7 +36,7 @@ SensorClientInfo::~SensorClientInfo() void SensorClientInfo::SetReportDataCb(const sptr &callbackObj) { - callbackV3_0 = callbackObj; + callbackObj_ = callbackObj; } void SensorClientInfo::PrintClientMapInfo(int32_t serviceId, SensorHandle sensorHandle) diff --git a/sensor/hdi_service_3.0/sensor_client_info.h b/sensor/hdi_service_3.0/sensor_client_info.h index 5ba4449fea..8be576aa72 100644 --- a/sensor/hdi_service_3.0/sensor_client_info.h +++ b/sensor/hdi_service_3.0/sensor_client_info.h @@ -36,7 +36,7 @@ public: std::unordered_map periodCountMap_; std::unordered_map curCountMap_; void PrintClientMapInfo(int32_t serviceId, SensorHandle sensorHandle); - sptr callbackV3_0; + sptr callbackObj_; bool oneway = false; }; diff --git a/sensor/hdi_service_3.0/sensor_clients_manager.cpp b/sensor/hdi_service_3.0/sensor_clients_manager.cpp index 524a5c69c8..f5381860a1 100644 --- a/sensor/hdi_service_3.0/sensor_clients_manager.cpp +++ b/sensor/hdi_service_3.0/sensor_clients_manager.cpp @@ -103,7 +103,7 @@ int SensorClientsManager::GetServiceId(int groupId, const sptr &i SENSOR_TRACE_PID; std::unique_lock lock(clientsMutex_); for (auto &iter : clients_[groupId]) { - if (OHOS::HDI::hdi_objcast(iter.second.callbackV3_0) == iRemoteObject) { + if (OHOS::HDI::hdi_objcast(iter.second.callbackObj_) == iRemoteObject) { return iter.first; } } @@ -121,7 +121,7 @@ void SensorClientsManager::ReportDataCbRegister(int groupId, int serviceId, return; } SensorClientInfo sensorClientInfo; - sensorClientInfo.callbackV3_0 = callbackObj; + sensorClientInfo.callbackObj_ = callbackObj; sensorClientInfo.oneway = oneway; clients_[groupId].emplace(serviceId, sensorClientInfo); HDF_LOGD("%{public}s: service %{public}d insert the callback", __func__, serviceId); @@ -129,7 +129,7 @@ void SensorClientsManager::ReportDataCbRegister(int groupId, int serviceId, } auto it = clients_[groupId].find(serviceId); - it -> second.callbackV3_0 = callbackObj; + it -> second.callbackObj_ = callbackObj; it -> second.oneway = oneway; HDF_LOGD("%{public}s: service %{public}d update the callback", __func__, serviceId); @@ -548,7 +548,7 @@ std::string SensorClientsManager::ReportEachClient(const V3_0::HdfSensorEvents& sensorInfoId.sensorHandle = sensorHandle; sensorInfoId.serviceId = serviceId; - sptr callbackV3_0 = nullptr; + sptr callbackObj = nullptr; { std::unique_lock lock(clientsMutex_); if (clients_.find(groupId)->second.find(serviceId) == clients_.find(groupId)->second.end()) { @@ -559,9 +559,9 @@ std::string SensorClientsManager::ReportEachClient(const V3_0::HdfSensorEvents& continue; } sensorInfoId.oneway = sensorClientInfo.oneway; - callbackV3_0 = sensorClientInfo.callbackV3_0; + callbackObj = sensorClientInfo.callbackObj_; - if (callbackV3_0 == nullptr) { + if (callbackObj == nullptr) { HDF_LOGD("%{public}s the callback of %{public}d is nullptr", __func__, serviceId); continue; } @@ -569,7 +569,7 @@ std::string SensorClientsManager::ReportEachClient(const V3_0::HdfSensorEvents& HITRACE_METER_FMT(HITRACE_TAG_HDF, "%s: serviceId %d, sensorHandle %s", __func__, serviceId, SENSOR_HANDLE_TO_C_STR(event.deviceSensorInfo)); - HdiReportData(callbackV3_0, event, result, sensorInfoId); + HdiReportData(callbackObj, event, result, sensorInfoId); } return result; } diff --git a/sensor/hdi_service_3.0/sensor_if_service.cpp b/sensor/hdi_service_3.0/sensor_if_service.cpp index 768c695d36..6d4b4532a2 100644 --- a/sensor/hdi_service_3.0/sensor_if_service.cpp +++ b/sensor/hdi_service_3.0/sensor_if_service.cpp @@ -37,7 +37,6 @@ enum BatchSeniorMode { }; #define HDF_LOG_TAG hdi -#define DEFAULT_SENSOR(sensorId) {0, sensorId, 0, 0} namespace OHOS { namespace HDI { @@ -52,7 +51,7 @@ namespace { SensorIfService::SensorIfService() { - int32_t ret = GetSensorVdiImplV1_1(); + int32_t ret = GetSensorVdiImpl(); if (ret != HDF_SUCCESS) { HDF_LOGE("%{public}s: get sensor vdi instance failed", __func__); } @@ -76,7 +75,7 @@ void SensorIfService::RegisteDumpHost() return; } -int32_t SensorIfService::GetSensorVdiImplV1_1() +int32_t SensorIfService::GetSensorVdiImpl() { struct OHOS::HDI::Sensor::V1_1::WrapperSensorVdi *wrapperSensorVdi = nullptr; uint32_t version = 0; @@ -921,7 +920,10 @@ int32_t SensorIfService::SetSdcSensor(const OHOS::HDI::Sensor::V3_0::DeviceSenso int64_t SensorIfService::CalculateSamplingInterval(int32_t rateLevel) { - return rateLevel == REPORT_INTERVAL ? REPORT_INTERVAL : COMMON_REPORT_FREQUENCY / rateLevel; + if (rateLevel == 0) { + return REPORT_INTERVAL; + } + return COMMON_REPORT_FREQUENCY / rateLevel; } int32_t SensorIfService::EnableSdcSensor(uint32_t serviceId, const SensorHandle& sensorHandle, diff --git a/sensor/hdi_service_3.0/sensor_if_service.h b/sensor/hdi_service_3.0/sensor_if_service.h index 03cb09cd09..2b515bd755 100644 --- a/sensor/hdi_service_3.0/sensor_if_service.h +++ b/sensor/hdi_service_3.0/sensor_if_service.h @@ -71,7 +71,7 @@ class SensorIfService : public V3_0::ISensorInterface { std::vector& info) override; int32_t RegSensorPlugCallBack(const sptr& callbackObj) override; int32_t UnRegSensorPlugCallBack(const sptr& callbackObj) override; - int32_t GetSensorVdiImplV1_1(); + int32_t GetSensorVdiImpl(); void OnRemoteDied(const wptr &object); std::mutex sensorServiceMutex_; private: diff --git a/sensor/test/common/src/sensor_callback_impl.cpp b/sensor/test/common/src/sensor_callback_impl.cpp index 2dbd40f95c..d70f2c7534 100644 --- a/sensor/test/common/src/sensor_callback_impl.cpp +++ b/sensor/test/common/src/sensor_callback_impl.cpp @@ -66,7 +66,7 @@ namespace { {SENSOR_TYPE_TEMPERATURE, "tenperature", 1, 1, g_temperatureRange} }; - constexpr int32_t g_listNum = sizeof(g_sensorList) / sizeof(g_sensorList[0]); + constexpr int32_t LIST_NUM = sizeof(g_sensorList) / sizeof(g_sensorList[0]); constexpr float EPSINON = 1e-6; void SensorDataVerification(const float &data, const struct SensorDevelopmentList &sensorNode) @@ -109,7 +109,7 @@ int32_t SensorCallbackImpl::OnDataEvent(const HdfSensorEvents& event) HDF_LOGI("%{public}s: event info: sensorId = %{public}d, option = %{public}d, mode = %{public}d\n\r", __func__, event.deviceSensorInfo.sensorType, event.option, event.mode); - for (int32_t i = 0; i < g_listNum; ++i) { + for (int32_t i = 0; i < LIST_NUM; ++i) { if (event.deviceSensorInfo.sensorType == g_sensorList[i].sensorTypeId) { float *data = reinterpret_cast(eventData); SensorDataVerification(*data, g_sensorList[i]); diff --git a/usb/hdi_service/src/usb_device_impl.cpp b/usb/hdi_service/src/usb_device_impl.cpp index b7f5252958..56c009cb5b 100644 --- a/usb/hdi_service/src/usb_device_impl.cpp +++ b/usb/hdi_service/src/usb_device_impl.cpp @@ -37,7 +37,7 @@ #define HDF_LOG_TAG UsbDeviceImpl namespace { -constexpr const char* EDM_SYSTEM_CAPABILITY = "const.SystemCapability.Driver.ExternalDevice"; +constexpr const char* EDM_SYSTEM_CAPABILITY = "const.SystemCapability.Driver.ExternalDevice"; } using namespace OHOS::HiviewDFX; namespace OHOS { -- Gitee