From e0a93eab127a9c09ac63f719bd1abb794df749f8 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Fri, 1 Apr 2022 16:09:25 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9vibrator=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- .../hdi_connection/adpter/include/compatible_connection.h | 2 +- .../hdi_connection/adpter/src/compatible_connection.cpp | 2 +- .../interface/include/i_vibrator_hdi_connection.h | 2 +- .../hdi_connection/interface/src/vibrator_hdi_connection.cpp | 2 +- services/miscdevice_service/src/miscdevice_service.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/services/miscdevice_service/hdi_connection/adpter/include/compatible_connection.h b/services/miscdevice_service/hdi_connection/adpter/include/compatible_connection.h index d56efcb..f6e0652 100644 --- a/services/miscdevice_service/hdi_connection/adpter/include/compatible_connection.h +++ b/services/miscdevice_service/hdi_connection/adpter/include/compatible_connection.h @@ -30,7 +30,7 @@ public: int32_t StartOnce(uint32_t duration) override; - int32_t Start(const char *effectType) override; + int32_t Start(const std::string effectType) override; int32_t Stop(VibratorStopMode mode) override; diff --git a/services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp b/services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp index 18b5cd2..a174b7d 100644 --- a/services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp @@ -57,7 +57,7 @@ int32_t CompatibleConnection::StartOnce(uint32_t duration) return ERR_OK; } -int32_t CompatibleConnection::Start(const char *effectType) +int32_t CompatibleConnection::Start(const std::string effectType) { CALL_LOG_ENTER; if (std::find(vibratorEffect_.begin(), vibratorEffect_.end(), effectType) == vibratorEffect_.end()) { diff --git a/services/miscdevice_service/hdi_connection/interface/include/i_vibrator_hdi_connection.h b/services/miscdevice_service/hdi_connection/interface/include/i_vibrator_hdi_connection.h index aca818e..7ec9f06 100644 --- a/services/miscdevice_service/hdi_connection/interface/include/i_vibrator_hdi_connection.h +++ b/services/miscdevice_service/hdi_connection/interface/include/i_vibrator_hdi_connection.h @@ -35,7 +35,7 @@ public: virtual int32_t StartOnce(uint32_t duration) = 0; - virtual int32_t Start(const char *effectType) = 0; + virtual int32_t Start(const std::string effectType) = 0; virtual int32_t Stop(VibratorStopMode mode) = 0; diff --git a/services/miscdevice_service/hdi_connection/interface/src/vibrator_hdi_connection.cpp b/services/miscdevice_service/hdi_connection/interface/src/vibrator_hdi_connection.cpp index 7fb2cf1..211f7e8 100644 --- a/services/miscdevice_service/hdi_connection/interface/src/vibrator_hdi_connection.cpp +++ b/services/miscdevice_service/hdi_connection/interface/src/vibrator_hdi_connection.cpp @@ -53,7 +53,7 @@ int32_t VibratorHdiConnection::StartOnce(uint32_t duration) return ERR_OK; } -int32_t VibratorHdiConnection::Start(const char *effectType) +int32_t VibratorHdiConnection::Start(const std::string effectType) { int32_t ret = iVibratorHdiConnection_->Start(effectType); if (ret < 0) { diff --git a/services/miscdevice_service/src/miscdevice_service.cpp b/services/miscdevice_service/src/miscdevice_service.cpp index f6a8cc4..11c0d68 100644 --- a/services/miscdevice_service/src/miscdevice_service.cpp +++ b/services/miscdevice_service/src/miscdevice_service.cpp @@ -227,7 +227,7 @@ int32_t MiscdeviceService::PlayVibratorEffect(int32_t vibratorId, const std::str } if (!isLooping) { vibratorEffectMap_[vibratorId] = effect; - const char *effectType = (char *)effect.data(); + const string effectType = effect.data(); return vibratorHdiConnection_.Start(effectType); } std::unordered_map::iterator iter = hapticRingMap_.find(effect); -- Gitee From f243cab36aaba54fafe8ed1cd4616ed75f0a49be Mon Sep 17 00:00:00 2001 From: cff-gite Date: Fri, 1 Apr 2022 16:31:24 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9vibrator=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- .../hdi_connection/adpter/include/hdi_connection.h | 2 +- .../hdi_connection/adpter/src/compatible_connection.cpp | 2 +- .../hdi_connection/adpter/src/hdi_connection.cpp | 4 ++-- .../interface/include/i_vibrator_hdi_connection.h | 1 + .../interface/include/vibrator_hdi_connection.h | 3 ++- services/miscdevice_service/src/miscdevice_service.cpp | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/services/miscdevice_service/hdi_connection/adpter/include/hdi_connection.h b/services/miscdevice_service/hdi_connection/adpter/include/hdi_connection.h index 3cbf0df..a396ebc 100644 --- a/services/miscdevice_service/hdi_connection/adpter/include/hdi_connection.h +++ b/services/miscdevice_service/hdi_connection/adpter/include/hdi_connection.h @@ -31,7 +31,7 @@ public: int32_t StartOnce(uint32_t duration) override; - int32_t Start(const char *effectType) override; + int32_t Start(const std::string effectType) override; int32_t Stop(VibratorStopMode mode) override; diff --git a/services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp b/services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp index a174b7d..02f98dc 100644 --- a/services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp @@ -61,7 +61,7 @@ int32_t CompatibleConnection::Start(const std::string effectType) { CALL_LOG_ENTER; if (std::find(vibratorEffect_.begin(), vibratorEffect_.end(), effectType) == vibratorEffect_.end()) { - MISC_HILOGE("Not support %{public}s type", effectType); + MISC_HILOGE("Not support %{public}s type", effectType.c_str()); return VIBRATOR_ON_ERR; } if (!vibrateThread_.joinable()) { diff --git a/services/miscdevice_service/hdi_connection/adpter/src/hdi_connection.cpp b/services/miscdevice_service/hdi_connection/adpter/src/hdi_connection.cpp index aab4200..bfb48c2 100644 --- a/services/miscdevice_service/hdi_connection/adpter/src/hdi_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adpter/src/hdi_connection.cpp @@ -54,9 +54,9 @@ int32_t HdiConnection::StartOnce(uint32_t duration) return ERR_OK; } -int32_t HdiConnection::Start(const char *effectType) +int32_t HdiConnection::Start(const std::string effectType) { - if (effectType == nullptr) { + if (effectType.empty()) { MISC_HILOGE("effectType is null"); return VIBRATOR_ON_ERR; } diff --git a/services/miscdevice_service/hdi_connection/interface/include/i_vibrator_hdi_connection.h b/services/miscdevice_service/hdi_connection/interface/include/i_vibrator_hdi_connection.h index 7ec9f06..7a4ccca 100644 --- a/services/miscdevice_service/hdi_connection/interface/include/i_vibrator_hdi_connection.h +++ b/services/miscdevice_service/hdi_connection/interface/include/i_vibrator_hdi_connection.h @@ -17,6 +17,7 @@ #define I_VIBRATOR_HDI_CONNECTION_H #include #include +#include namespace OHOS { namespace Sensors { class IVibratorHdiConnection { diff --git a/services/miscdevice_service/hdi_connection/interface/include/vibrator_hdi_connection.h b/services/miscdevice_service/hdi_connection/interface/include/vibrator_hdi_connection.h index e61e9ac..663ed33 100644 --- a/services/miscdevice_service/hdi_connection/interface/include/vibrator_hdi_connection.h +++ b/services/miscdevice_service/hdi_connection/interface/include/vibrator_hdi_connection.h @@ -18,6 +18,7 @@ #include "i_vibrator_hdi_connection.h" #include "singleton.h" +#include namespace OHOS { namespace Sensors { @@ -31,7 +32,7 @@ public: int32_t StartOnce(uint32_t duration) override; - int32_t Start(const char *effectType) override; + int32_t Start(const std::string effectType) override; int32_t Stop(VibratorStopMode mode) override; diff --git a/services/miscdevice_service/src/miscdevice_service.cpp b/services/miscdevice_service/src/miscdevice_service.cpp index 11c0d68..c6864fe 100644 --- a/services/miscdevice_service/src/miscdevice_service.cpp +++ b/services/miscdevice_service/src/miscdevice_service.cpp @@ -227,7 +227,7 @@ int32_t MiscdeviceService::PlayVibratorEffect(int32_t vibratorId, const std::str } if (!isLooping) { vibratorEffectMap_[vibratorId] = effect; - const string effectType = effect.data(); + const std::string effectType = effect.data(); return vibratorHdiConnection_.Start(effectType); } std::unordered_map::iterator iter = hapticRingMap_.find(effect); -- Gitee From 6173997ae24b160987e973a564ad4ff24e65c60b Mon Sep 17 00:00:00 2001 From: cff-gite Date: Fri, 1 Apr 2022 16:42:57 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9vibrator=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- .../hdi_connection/interface/include/vibrator_hdi_connection.h | 1 - 1 file changed, 1 deletion(-) diff --git a/services/miscdevice_service/hdi_connection/interface/include/vibrator_hdi_connection.h b/services/miscdevice_service/hdi_connection/interface/include/vibrator_hdi_connection.h index 663ed33..d8bdcba 100644 --- a/services/miscdevice_service/hdi_connection/interface/include/vibrator_hdi_connection.h +++ b/services/miscdevice_service/hdi_connection/interface/include/vibrator_hdi_connection.h @@ -18,7 +18,6 @@ #include "i_vibrator_hdi_connection.h" #include "singleton.h" -#include namespace OHOS { namespace Sensors { -- Gitee From 4cd6528b9d8425219722ff458043110c9acf7bed Mon Sep 17 00:00:00 2001 From: cff-gite Date: Sat, 2 Apr 2022 16:56:15 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9vibrator=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- interfaces/native/vibrator/include/vibrator_agent.h | 6 +++++- interfaces/native/vibrator/src/vibrator_agent.cpp | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/interfaces/native/vibrator/include/vibrator_agent.h b/interfaces/native/vibrator/include/vibrator_agent.h index 2b68e5b..afb2ed8 100755 --- a/interfaces/native/vibrator/include/vibrator_agent.h +++ b/interfaces/native/vibrator/include/vibrator_agent.h @@ -31,6 +31,8 @@ #include #define VIBRATOR_AGENT_H +namespace OHOS { +namespace Sensors { #ifdef __cplusplus extern "C" { #endif @@ -112,4 +114,6 @@ int32_t StopVibrator(const char *mode); #endif /** @} */ -#endif // endif VIBRATOR_AGENT_H \ No newline at end of file +#endif // endif VIBRATOR_AGENT_H +} // namespace Sensors +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/native/vibrator/src/vibrator_agent.cpp b/interfaces/native/vibrator/src/vibrator_agent.cpp index fc0075b..f38e01b 100644 --- a/interfaces/native/vibrator/src/vibrator_agent.cpp +++ b/interfaces/native/vibrator/src/vibrator_agent.cpp @@ -17,6 +17,8 @@ #include "sensors_log_domain.h" #include "vibrator_service_client.h" +namespace OHOS { +namespace Sensors { using OHOS::HiviewDFX::HiLog; using OHOS::HiviewDFX::HiLogLabel; using OHOS::Sensors::VibratorServiceClient; @@ -78,4 +80,6 @@ int32_t StopVibrator(const char *mode) return OHOS::Sensors::ERROR; } return OHOS::Sensors::SUCCESS; -} \ No newline at end of file +} +} // namespace Sensors +} // namespace OHOS \ No newline at end of file -- Gitee From 5a9c9d167972fb67f785375b39d6284363c2f13e Mon Sep 17 00:00:00 2001 From: cff-gite Date: Sat, 2 Apr 2022 17:07:55 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9vibrator=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- interfaces/native/vibrator/include/vibrator_agent.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/interfaces/native/vibrator/include/vibrator_agent.h b/interfaces/native/vibrator/include/vibrator_agent.h index afb2ed8..c382677 100755 --- a/interfaces/native/vibrator/include/vibrator_agent.h +++ b/interfaces/native/vibrator/include/vibrator_agent.h @@ -31,12 +31,12 @@ #include #define VIBRATOR_AGENT_H -namespace OHOS { -namespace Sensors { #ifdef __cplusplus extern "C" { #endif +namespace OHOS { +namespace Sensors { /** * @brief Indicates the mode of stopping a one-shot vibration effect. * @@ -109,11 +109,11 @@ int32_t DisableLooping(); */ int32_t StopVibrator(const char *mode); +} // namespace Sensors +} // namespace OHOS #ifdef __cplusplus }; #endif /** @} */ -#endif // endif VIBRATOR_AGENT_H -} // namespace Sensors -} // namespace OHOS \ No newline at end of file +#endif // endif VIBRATOR_AGENT_H \ No newline at end of file -- Gitee From bbe31c33c91a37bd61039bc230e677c70b6f1b2b Mon Sep 17 00:00:00 2001 From: cff-gite Date: Sat, 2 Apr 2022 17:15:49 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9vibrator=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- interfaces/native/vibrator/include/vibrator_agent.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/native/vibrator/include/vibrator_agent.h b/interfaces/native/vibrator/include/vibrator_agent.h index c382677..fb9c6e5 100755 --- a/interfaces/native/vibrator/include/vibrator_agent.h +++ b/interfaces/native/vibrator/include/vibrator_agent.h @@ -109,8 +109,8 @@ int32_t DisableLooping(); */ int32_t StopVibrator(const char *mode); -} // namespace Sensors -} // namespace OHOS +} // namespace Sensors +} // namespace OHOS #ifdef __cplusplus }; #endif -- Gitee From d90a9617ac3c93b6ad9824dd85fbddafaf45bbf8 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Wed, 6 Apr 2022 09:20:59 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9vibrator=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- .../native/vibrator/src/vibrator_agent.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/interfaces/native/vibrator/src/vibrator_agent.cpp b/interfaces/native/vibrator/src/vibrator_agent.cpp index f38e01b..4de2ad8 100644 --- a/interfaces/native/vibrator/src/vibrator_agent.cpp +++ b/interfaces/native/vibrator/src/vibrator_agent.cpp @@ -46,40 +46,40 @@ int32_t StartVibrator(const char *effectId) int32_t ret = client.Vibrate(DEFAULT_VIBRATOR_ID, effectId, isLooping); if (ret != OHOS::ERR_OK) { MISC_HILOGE("vibrator effectId failed, ret: %{public}d", ret); - return OHOS::Sensors::ERROR; + return ERROR; } - return OHOS::Sensors::SUCCESS; + return SUCCESS; } int32_t StartVibratorOnce(uint32_t duration) { if (duration == 0) { MISC_HILOGE("duration is invalid"); - return OHOS::Sensors::ERROR; + return ERROR; } auto &client = VibratorServiceClient::GetInstance(); int32_t ret = client.Vibrate(DEFAULT_VIBRATOR_ID, duration); if (ret != OHOS::ERR_OK) { MISC_HILOGE("vibrator duration failed, ret: %{public}d", ret); - return OHOS::Sensors::ERROR; + return ERROR; } - return OHOS::Sensors::SUCCESS; + return SUCCESS; } int32_t StopVibrator(const char *mode) { - CHKPR(mode, OHOS::Sensors::ERROR); + CHKPR(mode, ERROR); if (strcmp(mode, "time") != 0 && strcmp(mode, "preset") != 0) { MISC_HILOGE("mode is invalid, mode is %{public}s", mode); - return OHOS::Sensors::ERROR; + return ERROR; } auto &client = VibratorServiceClient::GetInstance(); int32_t ret = client.Stop(DEFAULT_VIBRATOR_ID, mode); - if (ret != OHOS::ERR_OK) { + if (ret != ERR_OK) { MISC_HILOGE("client is failed, ret: %{public}d", ret); - return OHOS::Sensors::ERROR; + return ERROR; } - return OHOS::Sensors::SUCCESS; + return SUCCESS; } } // namespace Sensors } // namespace OHOS \ No newline at end of file -- Gitee From aa7e6b63112f71124fadbe9464628792fcf84062 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Wed, 6 Apr 2022 14:22:26 +0800 Subject: [PATCH 08/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9vibrator=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- interfaces/native/vibrator/include/vibrator_agent.h | 1 - 1 file changed, 1 deletion(-) diff --git a/interfaces/native/vibrator/include/vibrator_agent.h b/interfaces/native/vibrator/include/vibrator_agent.h index fb9c6e5..754d5b1 100755 --- a/interfaces/native/vibrator/include/vibrator_agent.h +++ b/interfaces/native/vibrator/include/vibrator_agent.h @@ -114,6 +114,5 @@ int32_t StopVibrator(const char *mode); #ifdef __cplusplus }; #endif - /** @} */ #endif // endif VIBRATOR_AGENT_H \ No newline at end of file -- Gitee From e62289d1d345bb40d4c2b17d8eb3f416a8a47977 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Wed, 6 Apr 2022 14:56:48 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9vibrator=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- interfaces/native/vibrator/include/vibrator_agent.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/interfaces/native/vibrator/include/vibrator_agent.h b/interfaces/native/vibrator/include/vibrator_agent.h index 754d5b1..f041fb5 100755 --- a/interfaces/native/vibrator/include/vibrator_agent.h +++ b/interfaces/native/vibrator/include/vibrator_agent.h @@ -44,7 +44,6 @@ namespace Sensors { */ const char *VIBRATOR_STOP_MODE_TIME = "time"; - /** * @brief Indicates the mode of stopping a preset vibration effect. * @@ -69,7 +68,6 @@ const char *VIBRATOR_STOP_MODE_PRESET = "preset"; */ int32_t StartVibrator(const char *effectId); - /** * @brief Controls this vibrator to perform a one-shot vibration at a given duration. * @@ -81,14 +79,12 @@ int32_t StartVibrator(const char *effectId); */ int32_t StartVibratorOnce(uint32_t duration); - /** * @brief Enables this vibrator to perform a periodic vibration. * @since 6 */ void EnableLooping(); - /** * @brief Disables this vibrator from performing a periodic vibration. * @@ -98,7 +94,6 @@ void EnableLooping(); */ int32_t DisableLooping(); - /** * @brief Stops the vibration of this vibrator. * -- Gitee From 84232f8942b33a139fd8d6891573104e7b6cf07d Mon Sep 17 00:00:00 2001 From: cff-gite Date: Wed, 6 Apr 2022 15:11:24 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9vibrator=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- interfaces/native/vibrator/include/vibrator_agent.h | 1 - 1 file changed, 1 deletion(-) diff --git a/interfaces/native/vibrator/include/vibrator_agent.h b/interfaces/native/vibrator/include/vibrator_agent.h index f041fb5..0cc5254 100755 --- a/interfaces/native/vibrator/include/vibrator_agent.h +++ b/interfaces/native/vibrator/include/vibrator_agent.h @@ -103,7 +103,6 @@ int32_t DisableLooping(); * @since 6 */ int32_t StopVibrator(const char *mode); - } // namespace Sensors } // namespace OHOS #ifdef __cplusplus -- Gitee From 429526c218b86745a0c3f32440f62691fe1ccdc8 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Wed, 6 Apr 2022 15:47:11 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9vibrator=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- interfaces/native/vibrator/src/vibrator_agent.cpp | 6 +++--- .../hdi_connection/adpter/src/hdi_connection.cpp | 4 ---- services/miscdevice_service/src/miscdevice_service.cpp | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/interfaces/native/vibrator/src/vibrator_agent.cpp b/interfaces/native/vibrator/src/vibrator_agent.cpp index 4de2ad8..6285721 100644 --- a/interfaces/native/vibrator/src/vibrator_agent.cpp +++ b/interfaces/native/vibrator/src/vibrator_agent.cpp @@ -40,11 +40,11 @@ int32_t DisableLooping() int32_t StartVibrator(const char *effectId) { - CHKPR(effectId, OHOS::Sensors::ERROR); + CHKPR(effectId, ERROR); bool isLooping = (g_loopingFlag == 1) ? true : false; auto &client = VibratorServiceClient::GetInstance(); int32_t ret = client.Vibrate(DEFAULT_VIBRATOR_ID, effectId, isLooping); - if (ret != OHOS::ERR_OK) { + if (ret != ERR_OK) { MISC_HILOGE("vibrator effectId failed, ret: %{public}d", ret); return ERROR; } @@ -59,7 +59,7 @@ int32_t StartVibratorOnce(uint32_t duration) } auto &client = VibratorServiceClient::GetInstance(); int32_t ret = client.Vibrate(DEFAULT_VIBRATOR_ID, duration); - if (ret != OHOS::ERR_OK) { + if (ret != ERR_OK) { MISC_HILOGE("vibrator duration failed, ret: %{public}d", ret); return ERROR; } diff --git a/services/miscdevice_service/hdi_connection/adpter/src/hdi_connection.cpp b/services/miscdevice_service/hdi_connection/adpter/src/hdi_connection.cpp index bfb48c2..7785fc7 100644 --- a/services/miscdevice_service/hdi_connection/adpter/src/hdi_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adpter/src/hdi_connection.cpp @@ -56,10 +56,6 @@ int32_t HdiConnection::StartOnce(uint32_t duration) int32_t HdiConnection::Start(const std::string effectType) { - if (effectType.empty()) { - MISC_HILOGE("effectType is null"); - return VIBRATOR_ON_ERR; - } int32_t ret = vibratorInterface_->Start(effectType); if (ret < 0) { MISC_HILOGE("Start failed"); diff --git a/services/miscdevice_service/src/miscdevice_service.cpp b/services/miscdevice_service/src/miscdevice_service.cpp index c6864fe..15176dc 100644 --- a/services/miscdevice_service/src/miscdevice_service.cpp +++ b/services/miscdevice_service/src/miscdevice_service.cpp @@ -227,7 +227,7 @@ int32_t MiscdeviceService::PlayVibratorEffect(int32_t vibratorId, const std::str } if (!isLooping) { vibratorEffectMap_[vibratorId] = effect; - const std::string effectType = effect.data(); + const std::string effectType = effect; return vibratorHdiConnection_.Start(effectType); } std::unordered_map::iterator iter = hapticRingMap_.find(effect); -- Gitee From bea74b7cc8cf14c3c5d42c69ce2226ce80131a9b Mon Sep 17 00:00:00 2001 From: cff-gite Date: Wed, 6 Apr 2022 19:20:45 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9vibrator=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- .../hdi_connection/adpter/include/compatible_connection.h | 2 +- .../hdi_connection/adpter/include/hdi_connection.h | 2 +- .../hdi_connection/adpter/src/compatible_connection.cpp | 2 +- .../hdi_connection/adpter/src/hdi_connection.cpp | 2 +- .../interface/include/i_vibrator_hdi_connection.h | 2 +- .../hdi_connection/interface/include/vibrator_hdi_connection.h | 2 +- .../hdi_connection/interface/src/vibrator_hdi_connection.cpp | 2 +- services/miscdevice_service/src/miscdevice_service.cpp | 3 +-- 8 files changed, 8 insertions(+), 9 deletions(-) diff --git a/services/miscdevice_service/hdi_connection/adpter/include/compatible_connection.h b/services/miscdevice_service/hdi_connection/adpter/include/compatible_connection.h index f6e0652..9cde81d 100644 --- a/services/miscdevice_service/hdi_connection/adpter/include/compatible_connection.h +++ b/services/miscdevice_service/hdi_connection/adpter/include/compatible_connection.h @@ -30,7 +30,7 @@ public: int32_t StartOnce(uint32_t duration) override; - int32_t Start(const std::string effectType) override; + int32_t Start(const std::string &effectType) override; int32_t Stop(VibratorStopMode mode) override; diff --git a/services/miscdevice_service/hdi_connection/adpter/include/hdi_connection.h b/services/miscdevice_service/hdi_connection/adpter/include/hdi_connection.h index a396ebc..b128f4a 100644 --- a/services/miscdevice_service/hdi_connection/adpter/include/hdi_connection.h +++ b/services/miscdevice_service/hdi_connection/adpter/include/hdi_connection.h @@ -31,7 +31,7 @@ public: int32_t StartOnce(uint32_t duration) override; - int32_t Start(const std::string effectType) override; + int32_t Start(const std::string &effectType) override; int32_t Stop(VibratorStopMode mode) override; diff --git a/services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp b/services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp index 02f98dc..26b1ad3 100644 --- a/services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp @@ -57,7 +57,7 @@ int32_t CompatibleConnection::StartOnce(uint32_t duration) return ERR_OK; } -int32_t CompatibleConnection::Start(const std::string effectType) +int32_t CompatibleConnection::Start(const std::string &effectType) { CALL_LOG_ENTER; if (std::find(vibratorEffect_.begin(), vibratorEffect_.end(), effectType) == vibratorEffect_.end()) { diff --git a/services/miscdevice_service/hdi_connection/adpter/src/hdi_connection.cpp b/services/miscdevice_service/hdi_connection/adpter/src/hdi_connection.cpp index 7785fc7..aa577bd 100644 --- a/services/miscdevice_service/hdi_connection/adpter/src/hdi_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adpter/src/hdi_connection.cpp @@ -54,7 +54,7 @@ int32_t HdiConnection::StartOnce(uint32_t duration) return ERR_OK; } -int32_t HdiConnection::Start(const std::string effectType) +int32_t HdiConnection::Start(const std::string &effectType) { int32_t ret = vibratorInterface_->Start(effectType); if (ret < 0) { diff --git a/services/miscdevice_service/hdi_connection/interface/include/i_vibrator_hdi_connection.h b/services/miscdevice_service/hdi_connection/interface/include/i_vibrator_hdi_connection.h index 7a4ccca..139e0a0 100644 --- a/services/miscdevice_service/hdi_connection/interface/include/i_vibrator_hdi_connection.h +++ b/services/miscdevice_service/hdi_connection/interface/include/i_vibrator_hdi_connection.h @@ -36,7 +36,7 @@ public: virtual int32_t StartOnce(uint32_t duration) = 0; - virtual int32_t Start(const std::string effectType) = 0; + virtual int32_t Start(const std::string &effectType) = 0; virtual int32_t Stop(VibratorStopMode mode) = 0; diff --git a/services/miscdevice_service/hdi_connection/interface/include/vibrator_hdi_connection.h b/services/miscdevice_service/hdi_connection/interface/include/vibrator_hdi_connection.h index d8bdcba..d9bd476 100644 --- a/services/miscdevice_service/hdi_connection/interface/include/vibrator_hdi_connection.h +++ b/services/miscdevice_service/hdi_connection/interface/include/vibrator_hdi_connection.h @@ -31,7 +31,7 @@ public: int32_t StartOnce(uint32_t duration) override; - int32_t Start(const std::string effectType) override; + int32_t Start(const std::string &effectType) override; int32_t Stop(VibratorStopMode mode) override; diff --git a/services/miscdevice_service/hdi_connection/interface/src/vibrator_hdi_connection.cpp b/services/miscdevice_service/hdi_connection/interface/src/vibrator_hdi_connection.cpp index 211f7e8..037f76f 100644 --- a/services/miscdevice_service/hdi_connection/interface/src/vibrator_hdi_connection.cpp +++ b/services/miscdevice_service/hdi_connection/interface/src/vibrator_hdi_connection.cpp @@ -53,7 +53,7 @@ int32_t VibratorHdiConnection::StartOnce(uint32_t duration) return ERR_OK; } -int32_t VibratorHdiConnection::Start(const std::string effectType) +int32_t VibratorHdiConnection::Start(const std::string &effectType) { int32_t ret = iVibratorHdiConnection_->Start(effectType); if (ret < 0) { diff --git a/services/miscdevice_service/src/miscdevice_service.cpp b/services/miscdevice_service/src/miscdevice_service.cpp index 15176dc..5dc2fdc 100644 --- a/services/miscdevice_service/src/miscdevice_service.cpp +++ b/services/miscdevice_service/src/miscdevice_service.cpp @@ -227,8 +227,7 @@ int32_t MiscdeviceService::PlayVibratorEffect(int32_t vibratorId, const std::str } if (!isLooping) { vibratorEffectMap_[vibratorId] = effect; - const std::string effectType = effect; - return vibratorHdiConnection_.Start(effectType); + return vibratorHdiConnection_.Start(effect); } std::unordered_map::iterator iter = hapticRingMap_.find(effect); if (iter == hapticRingMap_.end()) { -- Gitee From 53c398ab69763c0d6e8caa0bb5b0862ec9820e86 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Thu, 7 Apr 2022 09:35:14 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9vibrator=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- .../hdi_connection/adpter/src/hdi_connection.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/miscdevice_service/hdi_connection/adpter/src/hdi_connection.cpp b/services/miscdevice_service/hdi_connection/adpter/src/hdi_connection.cpp index aa577bd..06723c0 100644 --- a/services/miscdevice_service/hdi_connection/adpter/src/hdi_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adpter/src/hdi_connection.cpp @@ -56,6 +56,10 @@ int32_t HdiConnection::StartOnce(uint32_t duration) int32_t HdiConnection::Start(const std::string &effectType) { + if (effectType.empty()) { + MISC_HILOGE("effectType is null"); + return VIBRATOR_ON_ERR; + } int32_t ret = vibratorInterface_->Start(effectType); if (ret < 0) { MISC_HILOGE("Start failed"); -- Gitee