From 50d08c686c5bfdeb677e5a25039971ceafe704e9 Mon Sep 17 00:00:00 2001 From: renxinyao Date: Mon, 9 Oct 2023 03:34:10 +0000 Subject: [PATCH 01/12] =?UTF-8?q?PC=E4=BF=AE=E6=94=B9=E7=9A=84=E9=9C=80?= =?UTF-8?q?=E6=B1=82=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inner_api/vibrator/vibrator_agent_type.h | 66 +++++++++ .../adapter/src/compatible_connection.cpp | 6 + .../vibrator/native/vibrator_agent_test.cpp | 138 ++++++++++++++++++ 3 files changed, 210 insertions(+) diff --git a/interfaces/inner_api/vibrator/vibrator_agent_type.h b/interfaces/inner_api/vibrator/vibrator_agent_type.h index b4021c4..23a706a 100644 --- a/interfaces/inner_api/vibrator/vibrator_agent_type.h +++ b/interfaces/inner_api/vibrator/vibrator_agent_type.h @@ -48,6 +48,72 @@ const char *VIBRATOR_TYPE_CHARGING = "haptic.charging"; */ const char *VIBRATOR_TYPE_LONG_PRESS_HEAVY = "haptic.long_press.heavy"; +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * @brief Describes the vibration effect of the vibrator when long pressed the search box. + * + * @since 11 + */ +const char *VIBRATOR_TYPE_LONG_PRESS_THE_SEARCH_BOX = "haptic.long_press.light"; + +/** + * @brief Describes the vibration effect of the vibrator when long pressed the text box. + * + * @since 11 + */ +const char *VIBRATOR_TYPE_LONG_PRESS_THE_TEXT_BOX = "haptic.long_press.light"; + +/** + * @brief Describes the vibration effect of the vibrator when text selection cursor movement. + * + * @since 11 + */ +const char *VIBRATOR_TYPE_TEXT_SELECTION_CURSOR_MOVEMENT = "haptic.slide.light"; + +/** + * @brief Describes the vibration effect of the vibrator when time adjustment. + * + * @since 11 + */ +const char *VIBRATOR_TYPE_TIME_ADJUSTMENT = "TimePicker"; + +/** + * @brief Describes the vibration effect of the vibrator when description file letter index. + * + * @since 11 + */ +const char *VIBRATOR_TYPE_DESCRIPTION_FILE_LETTER_INDEX = "haptic.slide.light"; + +/** + * @brief Describes the vibration effect of the vibrator when pull-to-refresh. + * + * @since 11 + */ +const char *VIBRATOR_TYPE_PULL_TO_REFRESH = "haptic.threshold"; + +/** + * @brief Describes the vibration effect of the vibrator when scroll bar. + * + * @since 11 + */ +const char *VIBRATOR_TYPE_SCROLL_BAR = "haptic.long_press.light"; + +/** + * @brief Describes the vibration effect of the vibrator when left slide delete. + * + * @since 11 + */ +const char *VIBRATOR_TYPE_LEFT_SLIDE_DELETE = "haptic.threshold"; + +/** + * @brief Describes the vibration effect of the vibrator when drag. + * + * @since 11 + */ +const char *VIBRATOR_TYPE_DRAG = "haptic.long_press.medium"; +//////////////////////////////////////////////////////////////////////////////////////////////////// + /** * @brief Enumerates vibration usages. * diff --git a/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp b/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp index 401dc02..5c7681d 100644 --- a/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp @@ -31,6 +31,11 @@ std::unordered_map g_vibratorEffect = { {"haptic.default.effect", 804}, {"haptic.fail", 60}, {"haptic.charging", 100}, + {"haptic.long_press.light", 80}, + {"haptic.slide.light", 80}, + {"TimePicker", 100}, + {"haptic.threshold", 60}, + {"haptic.long_press.medium", 80}, {"haptic.long_press.heavy", 80} }; HdfVibratorMode g_vibrateMode; @@ -65,6 +70,7 @@ int32_t CompatibleConnection::Start(const std::string &effectType) return VIBRATOR_ON_ERR; } duration_ = g_vibratorEffect[effectType]; + // why???joinable():一会查一下 if (!vibrateThread_.joinable()) { std::thread senocdDataThread(CompatibleConnection::VibrateProcess); vibrateThread_ = std::move(senocdDataThread); diff --git a/test/unittest/vibrator/native/vibrator_agent_test.cpp b/test/unittest/vibrator/native/vibrator_agent_test.cpp index 7e56058..541bc51 100644 --- a/test/unittest/vibrator/native/vibrator_agent_test.cpp +++ b/test/unittest/vibrator/native/vibrator_agent_test.cpp @@ -790,5 +790,143 @@ HWTEST_F(VibratorAgentTest, IsSupportEffect_006, TestSize.Level1) MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_LONG_PRESS_HEAVY); } } + +//////////////////////////////////////////////////////////////////////////////////////////////////// +HWTEST_F(VibratorAgentTest, IsSupportEffect_007, TestSize.Level1) +{ + CALL_LOG_ENTER; + bool state { false }; + int32_t ret = IsSupportEffect(VIBRATOR_TYPE_LONG_PRESS_THE_SEARCH_BOX, &state); + ASSERT_EQ(ret, 0); + if (state) { + ret = StartVibrator(VIBRATOR_TYPE_LONG_PRESS_THE_SEARCH_BOX); + ASSERT_EQ(ret, 0); + Cancel(); + } else { + MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_LONG_PRESS_THE_SEARCH_BOX); + } +} + +HWTEST_F(VibratorAgentTest, IsSupportEffect_008, TestSize.Level1) +{ + CALL_LOG_ENTER; + bool state { false }; + int32_t ret = IsSupportEffect(VIBRATOR_TYPE_LONG_PRESS_THE_TEXT_BOX, &state); + ASSERT_EQ(ret, 0); + if (state) { + ret = StartVibrator(VIBRATOR_TYPE_LONG_PRESS_THE_TEXT_BOX); + ASSERT_EQ(ret, 0); + Cancel(); + } else { + MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_LONG_PRESS_THE_TEXT_BOX); + } +} + +HWTEST_F(VibratorAgentTest, IsSupportEffect_009, TestSize.Level1) +{ + CALL_LOG_ENTER; + bool state { false }; + int32_t ret = IsSupportEffect(VIBRATOR_TYPE_TEXT_SELECTION_CURSOR_MOVEMENT, &state); + ASSERT_EQ(ret, 0); + if (state) { + ret = StartVibrator(VIBRATOR_TYPE_TEXT_SELECTION_CURSOR_MOVEMENT); + ASSERT_EQ(ret, 0); + Cancel(); + } else { + MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_TEXT_SELECTION_CURSOR_MOVEMENT); + } +} + +HWTEST_F(VibratorAgentTest, IsSupportEffect_010, TestSize.Level1) +{ + CALL_LOG_ENTER; + bool state { false }; + int32_t ret = IsSupportEffect(VIBRATOR_TYPE_TIME_ADJUSTMENT, &state); + ASSERT_EQ(ret, 0); + if (state) { + ret = StartVibrator(VIBRATOR_TYPE_TIME_ADJUSTMENT); + ASSERT_EQ(ret, 0); + Cancel(); + } else { + MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_TIME_ADJUSTMENT); + } +} + +HWTEST_F(VibratorAgentTest, IsSupportEffect_011, TestSize.Level1) +{ + CALL_LOG_ENTER; + bool state { false }; + int32_t ret = IsSupportEffect(VIBRATOR_TYPE_DESCRIPTION_FILE_LETTER_INDEX, &state); + ASSERT_EQ(ret, 0); + if (state) { + ret = StartVibrator(VIBRATOR_TYPE_DESCRIPTION_FILE_LETTER_INDEX); + ASSERT_EQ(ret, 0); + Cancel(); + } else { + MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_DESCRIPTION_FILE_LETTER_INDEX); + } +} + +HWTEST_F(VibratorAgentTest, IsSupportEffect_012, TestSize.Level1) +{ + CALL_LOG_ENTER; + bool state { false }; + int32_t ret = IsSupportEffect(VIBRATOR_TYPE_PULL_TO_REFRESH, &state); + ASSERT_EQ(ret, 0); + if (state) { + ret = StartVibrator(VIBRATOR_TYPE_PULL_TO_REFRESH); + ASSERT_EQ(ret, 0); + Cancel(); + } else { + MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_PULL_TO_REFRESH); + } +} + +HWTEST_F(VibratorAgentTest, IsSupportEffect_013, TestSize.Level1) +{ + CALL_LOG_ENTER; + bool state { false }; + int32_t ret = IsSupportEffect(VIBRATOR_TYPE_SCROLL_BAR, &state); + ASSERT_EQ(ret, 0); + if (state) { + ret = StartVibrator(VIBRATOR_TYPE_SCROLL_BAR); + ASSERT_EQ(ret, 0); + Cancel(); + } else { + MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_SCROLL_BAR); + } +} + +HWTEST_F(VibratorAgentTest, IsSupportEffect_014, TestSize.Level1) +{ + CALL_LOG_ENTER; + bool state { false }; + int32_t ret = IsSupportEffect(VIBRATOR_TYPE_LEFT_SLIDE_DELETE, &state); + ASSERT_EQ(ret, 0); + if (state) { + ret = StartVibrator(VIBRATOR_TYPE_LEFT_SLIDE_DELETE); + ASSERT_EQ(ret, 0); + Cancel(); + } else { + MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_LEFT_SLIDE_DELETE); + } +} + +HWTEST_F(VibratorAgentTest, IsSupportEffect_015, TestSize.Level1) +{ + CALL_LOG_ENTER; + bool state { false }; + int32_t ret = IsSupportEffect(VIBRATOR_TYPE_DRAG, &state); + ASSERT_EQ(ret, 0); + if (state) { + ret = StartVibrator(VIBRATOR_TYPE_DRAG); + ASSERT_EQ(ret, 0); + Cancel(); + } else { + MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_DRAG); + } +} +//////////////////////////////////////////////////////////////////////////////////////////////////// + } // namespace Sensors } // namespace OHOS -- Gitee From 32df32a80f72c85cecc73acdcfee6e9ecacdd9dd Mon Sep 17 00:00:00 2001 From: renxinyao Date: Mon, 9 Oct 2023 05:01:42 +0000 Subject: [PATCH 02/12] =?UTF-8?q?=E9=9C=80=E6=B1=82=E7=9A=84code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interfaces/inner_api/vibrator/vibrator_agent_type.h | 3 --- test/unittest/vibrator/native/vibrator_agent_test.cpp | 2 -- 2 files changed, 5 deletions(-) diff --git a/interfaces/inner_api/vibrator/vibrator_agent_type.h b/interfaces/inner_api/vibrator/vibrator_agent_type.h index 23a706a..6147ded 100644 --- a/interfaces/inner_api/vibrator/vibrator_agent_type.h +++ b/interfaces/inner_api/vibrator/vibrator_agent_type.h @@ -48,8 +48,6 @@ const char *VIBRATOR_TYPE_CHARGING = "haptic.charging"; */ const char *VIBRATOR_TYPE_LONG_PRESS_HEAVY = "haptic.long_press.heavy"; -//////////////////////////////////////////////////////////////////////////////////////////////////// - /** * @brief Describes the vibration effect of the vibrator when long pressed the search box. * @@ -112,7 +110,6 @@ const char *VIBRATOR_TYPE_LEFT_SLIDE_DELETE = "haptic.threshold"; * @since 11 */ const char *VIBRATOR_TYPE_DRAG = "haptic.long_press.medium"; -//////////////////////////////////////////////////////////////////////////////////////////////////// /** * @brief Enumerates vibration usages. diff --git a/test/unittest/vibrator/native/vibrator_agent_test.cpp b/test/unittest/vibrator/native/vibrator_agent_test.cpp index 541bc51..815d52d 100644 --- a/test/unittest/vibrator/native/vibrator_agent_test.cpp +++ b/test/unittest/vibrator/native/vibrator_agent_test.cpp @@ -791,7 +791,6 @@ HWTEST_F(VibratorAgentTest, IsSupportEffect_006, TestSize.Level1) } } -//////////////////////////////////////////////////////////////////////////////////////////////////// HWTEST_F(VibratorAgentTest, IsSupportEffect_007, TestSize.Level1) { CALL_LOG_ENTER; @@ -926,7 +925,6 @@ HWTEST_F(VibratorAgentTest, IsSupportEffect_015, TestSize.Level1) MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_DRAG); } } -//////////////////////////////////////////////////////////////////////////////////////////////////// } // namespace Sensors } // namespace OHOS -- Gitee From ebeaad735e64804b4f2835ebbf68863e25eeb314 Mon Sep 17 00:00:00 2001 From: renxinyao Date: Tue, 10 Oct 2023 03:32:41 +0000 Subject: [PATCH 03/12] the code of vibrator effecID need --- .../inner_api/vibrator/vibrator_agent_type.h | 51 ++-------- .../adapter/src/compatible_connection.cpp | 6 +- .../vibrator/native/vibrator_agent_test.cpp | 99 +++---------------- 3 files changed, 22 insertions(+), 134 deletions(-) diff --git a/interfaces/inner_api/vibrator/vibrator_agent_type.h b/interfaces/inner_api/vibrator/vibrator_agent_type.h index 6147ded..85b0256 100644 --- a/interfaces/inner_api/vibrator/vibrator_agent_type.h +++ b/interfaces/inner_api/vibrator/vibrator_agent_type.h @@ -49,67 +49,32 @@ const char *VIBRATOR_TYPE_CHARGING = "haptic.charging"; const char *VIBRATOR_TYPE_LONG_PRESS_HEAVY = "haptic.long_press.heavy"; /** - * @brief Describes the vibration effect of the vibrator when long pressed the search box. + * @brief Describes the vibration effect of the vibrator when long pressed the light. * * @since 11 */ -const char *VIBRATOR_TYPE_LONG_PRESS_THE_SEARCH_BOX = "haptic.long_press.light"; +const char *VIBRATOR_TYPE_LONG_PRESS_LIGHT = "haptic.long_press.light"; /** - * @brief Describes the vibration effect of the vibrator when long pressed the text box. + * @brief Describes the vibration effect of the vibrator when long pressed the medium. * * @since 11 */ -const char *VIBRATOR_TYPE_LONG_PRESS_THE_TEXT_BOX = "haptic.long_press.light"; +const char *VIBRATOR_TYPE_LONG_PRESS_MEDIUM = "haptic.long_press.medium"; /** - * @brief Describes the vibration effect of the vibrator when text selection cursor movement. + * @brief Describes the vibration effect of the vibrator when slide light. * * @since 11 */ -const char *VIBRATOR_TYPE_TEXT_SELECTION_CURSOR_MOVEMENT = "haptic.slide.light"; +const char *VIBRATOR_TYPE_SLIDE_LIGHT = "haptic.slide.light"; /** - * @brief Describes the vibration effect of the vibrator when time adjustment. + * @brief Describes the vibration effect of the vibrator when threshold. * * @since 11 */ -const char *VIBRATOR_TYPE_TIME_ADJUSTMENT = "TimePicker"; - -/** - * @brief Describes the vibration effect of the vibrator when description file letter index. - * - * @since 11 - */ -const char *VIBRATOR_TYPE_DESCRIPTION_FILE_LETTER_INDEX = "haptic.slide.light"; - -/** - * @brief Describes the vibration effect of the vibrator when pull-to-refresh. - * - * @since 11 - */ -const char *VIBRATOR_TYPE_PULL_TO_REFRESH = "haptic.threshold"; - -/** - * @brief Describes the vibration effect of the vibrator when scroll bar. - * - * @since 11 - */ -const char *VIBRATOR_TYPE_SCROLL_BAR = "haptic.long_press.light"; - -/** - * @brief Describes the vibration effect of the vibrator when left slide delete. - * - * @since 11 - */ -const char *VIBRATOR_TYPE_LEFT_SLIDE_DELETE = "haptic.threshold"; - -/** - * @brief Describes the vibration effect of the vibrator when drag. - * - * @since 11 - */ -const char *VIBRATOR_TYPE_DRAG = "haptic.long_press.medium"; +const char *VIBRATOR_TYPE_threshold = "haptic.threshold"; /** * @brief Enumerates vibration usages. diff --git a/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp b/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp index 5c7681d..990cfc3 100644 --- a/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp @@ -31,10 +31,9 @@ std::unordered_map g_vibratorEffect = { {"haptic.default.effect", 804}, {"haptic.fail", 60}, {"haptic.charging", 100}, - {"haptic.long_press.light", 80}, - {"haptic.slide.light", 80}, - {"TimePicker", 100}, {"haptic.threshold", 60}, + {"haptic.slide.light", 80}, + {"haptic.long_press.light", 80}, {"haptic.long_press.medium", 80}, {"haptic.long_press.heavy", 80} }; @@ -70,7 +69,6 @@ int32_t CompatibleConnection::Start(const std::string &effectType) return VIBRATOR_ON_ERR; } duration_ = g_vibratorEffect[effectType]; - // why???joinable():一会查一下 if (!vibrateThread_.joinable()) { std::thread senocdDataThread(CompatibleConnection::VibrateProcess); vibrateThread_ = std::move(senocdDataThread); diff --git a/test/unittest/vibrator/native/vibrator_agent_test.cpp b/test/unittest/vibrator/native/vibrator_agent_test.cpp index 815d52d..dabf48c 100644 --- a/test/unittest/vibrator/native/vibrator_agent_test.cpp +++ b/test/unittest/vibrator/native/vibrator_agent_test.cpp @@ -795,14 +795,14 @@ HWTEST_F(VibratorAgentTest, IsSupportEffect_007, TestSize.Level1) { CALL_LOG_ENTER; bool state { false }; - int32_t ret = IsSupportEffect(VIBRATOR_TYPE_LONG_PRESS_THE_SEARCH_BOX, &state); + int32_t ret = IsSupportEffect(VIBRATOR_TYPE_LONG_PRESS_LIGHT, &state); ASSERT_EQ(ret, 0); if (state) { - ret = StartVibrator(VIBRATOR_TYPE_LONG_PRESS_THE_SEARCH_BOX); + ret = StartVibrator(VIBRATOR_TYPE_LONG_PRESS_LIGHT); ASSERT_EQ(ret, 0); Cancel(); } else { - MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_LONG_PRESS_THE_SEARCH_BOX); + MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_LONG_PRESS_LIGHT); } } @@ -810,14 +810,14 @@ HWTEST_F(VibratorAgentTest, IsSupportEffect_008, TestSize.Level1) { CALL_LOG_ENTER; bool state { false }; - int32_t ret = IsSupportEffect(VIBRATOR_TYPE_LONG_PRESS_THE_TEXT_BOX, &state); + int32_t ret = IsSupportEffect(VIBRATOR_TYPE_LONG_PRESS_MEDIUM, &state); ASSERT_EQ(ret, 0); if (state) { - ret = StartVibrator(VIBRATOR_TYPE_LONG_PRESS_THE_TEXT_BOX); + ret = StartVibrator(VIBRATOR_TYPE_LONG_PRESS_MEDIUM); ASSERT_EQ(ret, 0); Cancel(); } else { - MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_LONG_PRESS_THE_TEXT_BOX); + MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_LONG_PRESS_MEDIUM); } } @@ -825,14 +825,14 @@ HWTEST_F(VibratorAgentTest, IsSupportEffect_009, TestSize.Level1) { CALL_LOG_ENTER; bool state { false }; - int32_t ret = IsSupportEffect(VIBRATOR_TYPE_TEXT_SELECTION_CURSOR_MOVEMENT, &state); + int32_t ret = IsSupportEffect(VIBRATOR_TYPE_SLIDE_LIGHT, &state); ASSERT_EQ(ret, 0); if (state) { - ret = StartVibrator(VIBRATOR_TYPE_TEXT_SELECTION_CURSOR_MOVEMENT); + ret = StartVibrator(VIBRATOR_TYPE_SLIDE_LIGHT); ASSERT_EQ(ret, 0); Cancel(); } else { - MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_TEXT_SELECTION_CURSOR_MOVEMENT); + MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_SLIDE_LIGHT); } } @@ -840,89 +840,14 @@ HWTEST_F(VibratorAgentTest, IsSupportEffect_010, TestSize.Level1) { CALL_LOG_ENTER; bool state { false }; - int32_t ret = IsSupportEffect(VIBRATOR_TYPE_TIME_ADJUSTMENT, &state); + int32_t ret = IsSupportEffect(VIBRATOR_TYPE_threshold, &state); ASSERT_EQ(ret, 0); if (state) { - ret = StartVibrator(VIBRATOR_TYPE_TIME_ADJUSTMENT); + ret = StartVibrator(VIBRATOR_TYPE_threshold); ASSERT_EQ(ret, 0); Cancel(); } else { - MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_TIME_ADJUSTMENT); - } -} - -HWTEST_F(VibratorAgentTest, IsSupportEffect_011, TestSize.Level1) -{ - CALL_LOG_ENTER; - bool state { false }; - int32_t ret = IsSupportEffect(VIBRATOR_TYPE_DESCRIPTION_FILE_LETTER_INDEX, &state); - ASSERT_EQ(ret, 0); - if (state) { - ret = StartVibrator(VIBRATOR_TYPE_DESCRIPTION_FILE_LETTER_INDEX); - ASSERT_EQ(ret, 0); - Cancel(); - } else { - MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_DESCRIPTION_FILE_LETTER_INDEX); - } -} - -HWTEST_F(VibratorAgentTest, IsSupportEffect_012, TestSize.Level1) -{ - CALL_LOG_ENTER; - bool state { false }; - int32_t ret = IsSupportEffect(VIBRATOR_TYPE_PULL_TO_REFRESH, &state); - ASSERT_EQ(ret, 0); - if (state) { - ret = StartVibrator(VIBRATOR_TYPE_PULL_TO_REFRESH); - ASSERT_EQ(ret, 0); - Cancel(); - } else { - MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_PULL_TO_REFRESH); - } -} - -HWTEST_F(VibratorAgentTest, IsSupportEffect_013, TestSize.Level1) -{ - CALL_LOG_ENTER; - bool state { false }; - int32_t ret = IsSupportEffect(VIBRATOR_TYPE_SCROLL_BAR, &state); - ASSERT_EQ(ret, 0); - if (state) { - ret = StartVibrator(VIBRATOR_TYPE_SCROLL_BAR); - ASSERT_EQ(ret, 0); - Cancel(); - } else { - MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_SCROLL_BAR); - } -} - -HWTEST_F(VibratorAgentTest, IsSupportEffect_014, TestSize.Level1) -{ - CALL_LOG_ENTER; - bool state { false }; - int32_t ret = IsSupportEffect(VIBRATOR_TYPE_LEFT_SLIDE_DELETE, &state); - ASSERT_EQ(ret, 0); - if (state) { - ret = StartVibrator(VIBRATOR_TYPE_LEFT_SLIDE_DELETE); - ASSERT_EQ(ret, 0); - Cancel(); - } else { - MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_LEFT_SLIDE_DELETE); - } -} - -HWTEST_F(VibratorAgentTest, IsSupportEffect_015, TestSize.Level1) -{ - CALL_LOG_ENTER; - bool state { false }; - int32_t ret = IsSupportEffect(VIBRATOR_TYPE_DRAG, &state); - ASSERT_EQ(ret, 0); - if (state) { - ret = StartVibrator(VIBRATOR_TYPE_DRAG); - ASSERT_EQ(ret, 0); - Cancel(); - } else { - MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_DRAG); + MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_threshold); } } -- Gitee From 11cc9252cf6cc11851e379fcc7be35bceaff7349 Mon Sep 17 00:00:00 2001 From: renxinyao Date: Tue, 10 Oct 2023 03:40:28 +0000 Subject: [PATCH 04/12] =?UTF-8?q?=E5=AD=97=E6=AF=8D=E5=A4=A7=E5=B0=8F?= =?UTF-8?q?=E5=86=99=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interfaces/inner_api/vibrator/vibrator_agent_type.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/inner_api/vibrator/vibrator_agent_type.h b/interfaces/inner_api/vibrator/vibrator_agent_type.h index 85b0256..6061782 100644 --- a/interfaces/inner_api/vibrator/vibrator_agent_type.h +++ b/interfaces/inner_api/vibrator/vibrator_agent_type.h @@ -74,7 +74,7 @@ const char *VIBRATOR_TYPE_SLIDE_LIGHT = "haptic.slide.light"; * * @since 11 */ -const char *VIBRATOR_TYPE_threshold = "haptic.threshold"; +const char *VIBRATOR_TYPE_THRESHOID = "haptic.threshold"; /** * @brief Enumerates vibration usages. -- Gitee From 1f516957771c033952c87e19ea15a1055b1ab9f4 Mon Sep 17 00:00:00 2001 From: renxinyao Date: Tue, 10 Oct 2023 03:47:09 +0000 Subject: [PATCH 05/12] change the advice --- interfaces/inner_api/vibrator/vibrator_agent_type.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/interfaces/inner_api/vibrator/vibrator_agent_type.h b/interfaces/inner_api/vibrator/vibrator_agent_type.h index 6061782..f029d68 100644 --- a/interfaces/inner_api/vibrator/vibrator_agent_type.h +++ b/interfaces/inner_api/vibrator/vibrator_agent_type.h @@ -46,24 +46,24 @@ const char *VIBRATOR_TYPE_CHARGING = "haptic.charging"; * * @since 11 */ -const char *VIBRATOR_TYPE_LONG_PRESS_HEAVY = "haptic.long_press.heavy"; +const char *VIBRATOR_TYPE_LONG_PRESS_LIGHT = "haptic.long_press.light"; /** - * @brief Describes the vibration effect of the vibrator when long pressed the light. + * @brief Describes the vibration effect of the vibrator when long pressed. * * @since 11 */ -const char *VIBRATOR_TYPE_LONG_PRESS_LIGHT = "haptic.long_press.light"; +const char *VIBRATOR_TYPE_LONG_PRESS_MEDIUM = "haptic.long_press.medium"; /** - * @brief Describes the vibration effect of the vibrator when long pressed the medium. + * @brief Describes the vibration effect of the vibrator when long pressed. * * @since 11 */ -const char *VIBRATOR_TYPE_LONG_PRESS_MEDIUM = "haptic.long_press.medium"; +const char *VIBRATOR_TYPE_LONG_PRESS_HEAVY = "haptic.long_press.heavy"; /** - * @brief Describes the vibration effect of the vibrator when slide light. + * @brief Describes the vibration effect of the vibrator when slide. * * @since 11 */ -- Gitee From 2cd71c83de7d97a93f77c6e3a872b8533a40a0f6 Mon Sep 17 00:00:00 2001 From: renxinyao Date: Tue, 10 Oct 2023 03:48:54 +0000 Subject: [PATCH 06/12] change the advice --- interfaces/inner_api/vibrator/vibrator_agent_type.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/inner_api/vibrator/vibrator_agent_type.h b/interfaces/inner_api/vibrator/vibrator_agent_type.h index f029d68..8db23c2 100644 --- a/interfaces/inner_api/vibrator/vibrator_agent_type.h +++ b/interfaces/inner_api/vibrator/vibrator_agent_type.h @@ -70,7 +70,7 @@ const char *VIBRATOR_TYPE_LONG_PRESS_HEAVY = "haptic.long_press.heavy"; const char *VIBRATOR_TYPE_SLIDE_LIGHT = "haptic.slide.light"; /** - * @brief Describes the vibration effect of the vibrator when threshold. + * @brief Describes the vibration effect of the vibrator when the threshold is reached. * * @since 11 */ -- Gitee From c545d94ef19dd9d09a92b81e5dfca2329328200c Mon Sep 17 00:00:00 2001 From: renxinyao Date: Tue, 10 Oct 2023 03:52:40 +0000 Subject: [PATCH 07/12] change the big and small --- test/unittest/vibrator/native/vibrator_agent_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unittest/vibrator/native/vibrator_agent_test.cpp b/test/unittest/vibrator/native/vibrator_agent_test.cpp index dabf48c..46c648a 100644 --- a/test/unittest/vibrator/native/vibrator_agent_test.cpp +++ b/test/unittest/vibrator/native/vibrator_agent_test.cpp @@ -840,14 +840,14 @@ HWTEST_F(VibratorAgentTest, IsSupportEffect_010, TestSize.Level1) { CALL_LOG_ENTER; bool state { false }; - int32_t ret = IsSupportEffect(VIBRATOR_TYPE_threshold, &state); + int32_t ret = IsSupportEffect(VIBRATOR_TYPE_THRESHOID, &state); ASSERT_EQ(ret, 0); if (state) { - ret = StartVibrator(VIBRATOR_TYPE_threshold); + ret = StartVibrator(VIBRATOR_TYPE_THRESHOID); ASSERT_EQ(ret, 0); Cancel(); } else { - MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_threshold); + MISC_HILOGI("Do not support %{public}s", VIBRATOR_TYPE_THRESHOID); } } -- Gitee From dca2664494eb7488040fc2cf555d69a1e7ed8241 Mon Sep 17 00:00:00 2001 From: renxinyao Date: Wed, 11 Oct 2023 02:27:43 +0000 Subject: [PATCH 08/12] Log --- frameworks/native/vibrator/vibrator_agent.cpp | 2 ++ .../hdi_connection/adapter/src/hdi_connection.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/frameworks/native/vibrator/vibrator_agent.cpp b/frameworks/native/vibrator/vibrator_agent.cpp index 988d3da..9215e2b 100644 --- a/frameworks/native/vibrator/vibrator_agent.cpp +++ b/frameworks/native/vibrator/vibrator_agent.cpp @@ -64,6 +64,7 @@ bool SetLoopCount(int32_t count) int32_t StartVibrator(const char *effectId) { + MISC_HILOGD("************************the begin time of StartVibrator***************************"); CHKPR(effectId, PARAMETER_ERROR); auto &client = VibratorServiceClient::GetInstance(); int32_t ret = client.Vibrate(DEFAULT_VIBRATOR_ID, effectId, g_loopCount, g_usage); @@ -99,6 +100,7 @@ bool IsSupportVibratorCustom() int32_t PlayVibratorCustom(int32_t fd, int64_t offset, int64_t length) { + MISC_HILOGD("************************the begin time of PlayVibratorCustom***************************"); #ifdef OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM if (fd < 0 || offset < 0 || length <= 0) { MISC_HILOGE("Input parameter invalid, fd:%{public}d, offset:%{public}lld, length:%{public}lld", diff --git a/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp b/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp index 5fad723..9f4d057 100644 --- a/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp @@ -76,6 +76,7 @@ int32_t HdiConnection::Start(const std::string &effectType) MISC_HILOGE("Start failed"); return ret; } + MISC_HILOGD("************************the end time of Start***************************"); return ERR_OK; } @@ -94,6 +95,7 @@ int32_t HdiConnection::EnableCompositeEffect(const HdfCompositeEffect &hdfCompos MISC_HILOGE("EnableCompositeEffect failed"); return ret; } + MISC_HILOGD("************************the end time of EnableCompositeEffect***************************"); return ERR_OK; } -- Gitee From df7162736b35f5c1e599c151bd8450bd92fa3e34 Mon Sep 17 00:00:00 2001 From: renxinyao Date: Wed, 11 Oct 2023 03:53:57 +0000 Subject: [PATCH 09/12] change th Log for advice --- frameworks/native/vibrator/vibrator_agent.cpp | 4 ++-- .../hdi_connection/adapter/src/hdi_connection.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frameworks/native/vibrator/vibrator_agent.cpp b/frameworks/native/vibrator/vibrator_agent.cpp index 9215e2b..054b78f 100644 --- a/frameworks/native/vibrator/vibrator_agent.cpp +++ b/frameworks/native/vibrator/vibrator_agent.cpp @@ -64,7 +64,7 @@ bool SetLoopCount(int32_t count) int32_t StartVibrator(const char *effectId) { - MISC_HILOGD("************************the begin time of StartVibrator***************************"); + MISC_HILOGI("Time delay measurement:start time"); CHKPR(effectId, PARAMETER_ERROR); auto &client = VibratorServiceClient::GetInstance(); int32_t ret = client.Vibrate(DEFAULT_VIBRATOR_ID, effectId, g_loopCount, g_usage); @@ -100,8 +100,8 @@ bool IsSupportVibratorCustom() int32_t PlayVibratorCustom(int32_t fd, int64_t offset, int64_t length) { - MISC_HILOGD("************************the begin time of PlayVibratorCustom***************************"); #ifdef OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM + MISC_HILOGI("Time delay measurement:start time"); if (fd < 0 || offset < 0 || length <= 0) { MISC_HILOGE("Input parameter invalid, fd:%{public}d, offset:%{public}lld, length:%{public}lld", fd, static_cast(offset), static_cast(length)); diff --git a/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp b/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp index 9f4d057..9d92a6f 100644 --- a/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp @@ -76,7 +76,7 @@ int32_t HdiConnection::Start(const std::string &effectType) MISC_HILOGE("Start failed"); return ret; } - MISC_HILOGD("************************the end time of Start***************************"); + MISC_HILOGI("Time delay measurement:end time"); return ERR_OK; } @@ -95,7 +95,7 @@ int32_t HdiConnection::EnableCompositeEffect(const HdfCompositeEffect &hdfCompos MISC_HILOGE("EnableCompositeEffect failed"); return ret; } - MISC_HILOGD("************************the end time of EnableCompositeEffect***************************"); + MISC_HILOGI("Time delay measurement:end time"); return ERR_OK; } -- Gitee From b93cf3096533994738b30ba6b5ee10248e3b2136 Mon Sep 17 00:00:00 2001 From: renxinyao Date: Wed, 11 Oct 2023 03:59:40 +0000 Subject: [PATCH 10/12] change th Log for advice --- .../hdi_connection/adapter/src/hdi_connection.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp b/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp index 9d92a6f..fd76e29 100644 --- a/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp @@ -64,6 +64,7 @@ int32_t HdiConnection::StartOnce(uint32_t duration) int32_t HdiConnection::Start(const std::string &effectType) { + MISC_HILOGI("Time delay measurement:end time"); if (effectType.empty()) { MISC_HILOGE("effectType is null"); return VIBRATOR_ON_ERR; @@ -76,13 +77,13 @@ int32_t HdiConnection::Start(const std::string &effectType) MISC_HILOGE("Start failed"); return ret; } - MISC_HILOGI("Time delay measurement:end time"); return ERR_OK; } #ifdef OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM int32_t HdiConnection::EnableCompositeEffect(const HdfCompositeEffect &hdfCompositeEffect) { + MISC_HILOGI("Time delay measurement:end time"); if (hdfCompositeEffect.compositeEffects.empty()) { MISC_HILOGE("compositeEffects is empty"); return VIBRATOR_ON_ERR; -- Gitee From 83e77f29989a35162cdae8189c2c71b9ceb453c5 Mon Sep 17 00:00:00 2001 From: renxinyao Date: Wed, 11 Oct 2023 04:38:21 +0000 Subject: [PATCH 11/12] change the time of sustain --- .../hdi_connection/adapter/src/compatible_connection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp b/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp index 990cfc3..2dc8854 100644 --- a/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp @@ -31,8 +31,8 @@ std::unordered_map g_vibratorEffect = { {"haptic.default.effect", 804}, {"haptic.fail", 60}, {"haptic.charging", 100}, - {"haptic.threshold", 60}, - {"haptic.slide.light", 80}, + {"haptic.threshold", 42}, + {"haptic.slide.light", 10}, {"haptic.long_press.light", 80}, {"haptic.long_press.medium", 80}, {"haptic.long_press.heavy", 80} -- Gitee From 31d012e9f21d6f91c644c07269a65e4167e2922b Mon Sep 17 00:00:00 2001 From: renxinyao Date: Wed, 11 Oct 2023 04:47:01 +0000 Subject: [PATCH 12/12] add the Log for advice --- .../hdi_connection/adapter/src/hdi_connection.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp b/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp index fd76e29..839e890 100644 --- a/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp @@ -69,6 +69,7 @@ int32_t HdiConnection::Start(const std::string &effectType) MISC_HILOGE("effectType is null"); return VIBRATOR_ON_ERR; } + MISC_HILOGI("Time delay measurement:end time"); CHKPR(vibratorInterface_, ERR_INVALID_VALUE); int32_t ret = vibratorInterface_->Start(effectType); if (ret < 0) { -- Gitee