From be4245d3d4129f7669a338ab7aee8583d97ce3dd Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Fri, 14 Jan 2022 14:56:42 +0800 Subject: [PATCH 1/3] Signed-off-by:hellohyh001 Signed-off-by: hellohyh001 --- bundle.json | 4 +- .../plugin/vibrator/src/vibrator_js.cpp | 4 +- services/miscdevice_service/BUILD.gn | 5 + .../adpter/include/compatible_connection.h | 48 ++++++++ .../adpter/include/hdi_direct_connection.h | 46 +++++++ .../adpter/src/compatible_connection.cpp | 115 ++++++++++++++++++ .../adpter/src/hdi_direct_connection.cpp | 83 +++++++++++++ .../include/i_vibrator_hdi_connection.h | 49 ++++++++ .../include/vibrator_hdi_connection.h | 46 +++++++ .../interface/src/vibrator_hdi_connection.cpp | 86 +++++++++++++ 10 files changed, 482 insertions(+), 4 deletions(-) create mode 100644 services/miscdevice_service/hdi_connection/adpter/include/compatible_connection.h create mode 100644 services/miscdevice_service/hdi_connection/adpter/include/hdi_direct_connection.h create mode 100644 services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp create mode 100644 services/miscdevice_service/hdi_connection/adpter/src/hdi_direct_connection.cpp create mode 100644 services/miscdevice_service/hdi_connection/interface/include/i_vibrator_hdi_connection.h create mode 100644 services/miscdevice_service/hdi_connection/interface/include/vibrator_hdi_connection.h create mode 100644 services/miscdevice_service/hdi_connection/interface/src/vibrator_hdi_connection.cpp diff --git a/bundle.json b/bundle.json index a5d570d..06f5dfd 100644 --- a/bundle.json +++ b/bundle.json @@ -9,8 +9,8 @@ "syscap": ["SystemCapability.Sensors.MiscDevice"], "features": [], "adapted_system_type": [ "standard" ], - "rom": "230KB", - "ram": "~4KB", + "rom": "1024KB", + "ram": "~4096KB", "deps": { "components": [ "libhilog", diff --git a/interfaces/plugin/vibrator/src/vibrator_js.cpp b/interfaces/plugin/vibrator/src/vibrator_js.cpp index a229901..6ef0f99 100644 --- a/interfaces/plugin/vibrator/src/vibrator_js.cpp +++ b/interfaces/plugin/vibrator/src/vibrator_js.cpp @@ -53,7 +53,7 @@ static napi_value Vibrate(napi_env env, napi_callback_info info) } else if (IsMatchType(args[0], napi_string, env)) { size_t bufLength = 0; napi_status status = napi_get_value_string_utf8(env, args[0], nullptr, 0, &bufLength); - if (bufLength <= 0) { + if (bufLength < 0) { HiLog::Error(LABEL, "%{public}s input parameter is invalid", __func__); return nullptr; } @@ -105,7 +105,7 @@ static napi_value Stop(napi_env env, napi_callback_info info) }; size_t bufLength = 0; napi_status status = napi_get_value_string_utf8(env, args[0], nullptr, 0, &bufLength); - if (bufLength <= 0) { + if (bufLength < 0) { HiLog::Error(LABEL, "%{public}s input parameter is invalid", __func__); return nullptr; } diff --git a/services/miscdevice_service/BUILD.gn b/services/miscdevice_service/BUILD.gn index 842c911..96f6e5e 100644 --- a/services/miscdevice_service/BUILD.gn +++ b/services/miscdevice_service/BUILD.gn @@ -16,6 +16,9 @@ import("//build/ohos.gni") SUBSYSTEM_DIR = "//base/sensors" ohos_shared_library("libmiscdevice_service") { sources = [ + "hdi_connection/adpter/src/compatible_connection.cpp", + "hdi_connection/adpter/src/hdi_direct_connection.cpp", + "hdi_connection/interface/src/vibrator_hdi_connection.cpp", "src/miscdevice_service.cpp", "src/miscdevice_service_impl.cpp", "src/miscdevice_service_stub.cpp", @@ -28,6 +31,8 @@ ohos_shared_library("libmiscdevice_service") { "$SUBSYSTEM_DIR/miscdevice/frameworks/native/miscdevice/include", "$SUBSYSTEM_DIR/miscdevice/utils/include", "//drivers/peripheral/misc/vibrator/interfaces/include", + "hdi_connection/adpter/include", + "hdi_connection/interface/include", ] cflags = [ "-Wno-error=inconsistent-missing-override" ] diff --git a/services/miscdevice_service/hdi_connection/adpter/include/compatible_connection.h b/services/miscdevice_service/hdi_connection/adpter/include/compatible_connection.h new file mode 100644 index 0000000..45e935c --- /dev/null +++ b/services/miscdevice_service/hdi_connection/adpter/include/compatible_connection.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2021 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 DIRECT_CONNECTION_H +#define DIRECT_CONNECTION_H +#include +#include +#include "i_vibrator_hdi_connection.h" +namespace OHOS { +namespace Sensors { +class CompatibleConnection : public IVibratorHdiConnection { +public: + CompatibleConnection() = default; + + virtual ~CompatibleConnection() {}; + + int32_t ConnectHdi() override; + + int32_t StartOnce(uint32_t duration) override; + + int32_t Start(const char *effectType) override; + + int32_t Stop(enum VibratorStopMode mode) override; + + int32_t DestroyHdiConnection() override; + +private: + DISALLOW_COPY_AND_MOVE(CompatibleConnection); + std::thread vibrateThread_; + static void VibrateProcess(); + static uint32_t duration_; + static std::atomic_bool isStop_; +}; +} // namespace Sensors +} // namespace OHOS +#endif // DIRECT_CONNECTION_H \ No newline at end of file diff --git a/services/miscdevice_service/hdi_connection/adpter/include/hdi_direct_connection.h b/services/miscdevice_service/hdi_connection/adpter/include/hdi_direct_connection.h new file mode 100644 index 0000000..f2ed36b --- /dev/null +++ b/services/miscdevice_service/hdi_connection/adpter/include/hdi_direct_connection.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021 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 HDI_DIRECT_CONNECTION_H +#define HDI_DIRECT_CONNECTION_H + +#include "i_vibrator_hdi_connection.h" +#include "vibrator_if.h" + +namespace OHOS { +namespace Sensors { +class HdiDirectConnection : public IVibratorHdiConnection { +public: + HdiDirectConnection() = default; + + virtual ~HdiDirectConnection() {}; + + int32_t ConnectHdi() override; + + int32_t StartOnce(uint32_t duration) override; + + int32_t Start(const char *effectType) override; + + int32_t Stop(enum VibratorStopMode mode) override; + + int32_t DestroyHdiConnection() override; + +private: + DISALLOW_COPY_AND_MOVE(HdiDirectConnection); + const struct VibratorInterface *vibratorInterface = nullptr; +}; +} // namespace Sensors +} // namespace OHOS +#endif // HDI_DIRECT_CONNECTION_H \ No newline at end of file diff --git a/services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp b/services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp new file mode 100644 index 0000000..493dd56 --- /dev/null +++ b/services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2021 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 "compatible_connection.h" +#include "sensors_errors.h" +#include "sensors_log_domain.h" + +namespace OHOS { +namespace Sensors { +using namespace OHOS::HiviewDFX; +namespace { +constexpr HiLogLabel LABEL = { LOG_CORE, SensorsLogDomain::SENSOR_SERVICE, "CompatibleConnection" }; +std::vector vibratorEffect_ = {"haptic.clock.timer"}; +IVibratorHdiConnection::VibratorStopMode vibrateMode_; +constexpr uint32_t MAX_VIBRATOR_TIME = 1800000; +constexpr uint32_t MIN_VIBRATOR_TIME = 0; +} +uint32_t CompatibleConnection::duration_ = -1; +std::atomic_bool CompatibleConnection::isStop_ = false; + +int32_t CompatibleConnection::ConnectHdi() +{ + HiLog::Info(LABEL, "%{public}s in", __func__); + return ERR_OK; +} + +int32_t CompatibleConnection::StartOnce(uint32_t duration) +{ + HiLog::Info(LABEL, "%{public}s in", __func__); + if (duration > MAX_VIBRATOR_TIME || duration <= MIN_VIBRATOR_TIME) { + HiLog::Error(LABEL, "%{public}s duration: %{public}d invalid", __func__, duration); + return -1; + } + duration_ = duration; + if (!vibrateThread_.joinable()) { + std::thread senocdDataThread(CompatibleConnection::VibrateProcess); + vibrateThread_ = std::move(senocdDataThread); + isStop_ = false; + } + vibrateMode_ = VIBRATOR_STOP_MODE_TIME; + return ERR_OK; +} + +int32_t CompatibleConnection::Start(const char *effectType) +{ + HiLog::Info(LABEL, "%{public}s in", __func__); + if (std::find(vibratorEffect_.begin(), vibratorEffect_.end(), effectType) == vibratorEffect_.end()) { + HiLog::Error(LABEL, "%{public}s not support %{public}s type", __func__, effectType); + return -1; + } + if (!vibrateThread_.joinable()) { + std::thread senocdDataThread(CompatibleConnection::VibrateProcess); + vibrateThread_ = std::move(senocdDataThread); + isStop_ = false; + } + vibrateMode_ = VIBRATOR_STOP_MODE_PRESET; + return ERR_OK; +} + +int32_t CompatibleConnection::Stop(enum VibratorStopMode mode) +{ + HiLog::Info(LABEL, "%{public}s in", __func__); + if (mode < 0 || mode >= VIBRATOR_STOP_MODE_INVALID) { + HiLog::Error(LABEL, "%{public}s mode: %{public}d invalid", __func__, mode); + return -1; + } + if (vibrateMode_ != mode) { + HiLog::Error(LABEL, "%{public}s should start vibrate first", __func__); + return -1; + } + if (vibrateThread_.joinable()) { + HiLog::Info(LABEL, "%{public}s stop vibrate thread", __func__); + isStop_ = true; + vibrateThread_.join(); + } + return ERR_OK; +} + +int32_t CompatibleConnection::DestroyHdiConnection() +{ + HiLog::Info(LABEL, "%{public}s in", __func__); + return ERR_OK; +} + +void CompatibleConnection::VibrateProcess() +{ + HiLog::Info(LABEL, "%{public}s in", __func__); + clock_t vibrateStartTime = clock(); + while (static_cast(clock() - vibrateStartTime) < duration_) { + if (isStop_) { + HiLog::Info(LABEL, "%{public}s thread should stop", __func__); + break; + } + } + HiLog::Info(LABEL, "%{public}s end", __func__); + return; +} +} // namespace Sensors +} // namespace OHOS diff --git a/services/miscdevice_service/hdi_connection/adpter/src/hdi_direct_connection.cpp b/services/miscdevice_service/hdi_connection/adpter/src/hdi_direct_connection.cpp new file mode 100644 index 0000000..15e3469 --- /dev/null +++ b/services/miscdevice_service/hdi_connection/adpter/src/hdi_direct_connection.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2021 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 "hdi_direct_connection.h" +#include "sensors_errors.h" +#include "sensors_log_domain.h" +#include "vibrator_type.h" + +namespace OHOS { +namespace Sensors { +using namespace OHOS::HiviewDFX; +namespace { +constexpr HiLogLabel LABEL = { LOG_CORE, SensorsLogDomain::SENSOR_SERVICE, "HdiDirectConnection" }; +} + +int32_t HdiDirectConnection::ConnectHdi() +{ + HiLog::Info(LABEL, "%{public}s in", __func__); + vibratorInterface = NewVibratorInterfaceInstance(); + if (vibratorInterface == nullptr) { + HiLog::Error(LABEL, "%{public}s failed, vibrator interface initialization failed", __func__); + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +int32_t HdiDirectConnection::StartOnce(uint32_t duration) +{ + int32_t ret = vibratorInterface->StartOnce(duration); + if (ret < 0) { + HiLog::Error(LABEL, "%{public}s failed", __func__); + return ret; + } + return ERR_OK; +} + +int32_t HdiDirectConnection::Start(const char *effectType) +{ + if (effectType == nullptr) { + HiLog::Error(LABEL, "%{public}s effectType is null", __func__); + return -1; + } + int32_t ret = vibratorInterface->Start(effectType); + if (ret < 0) { + HiLog::Error(LABEL, "%{public}s failed", __func__); + return ret; + } + return ERR_OK; +} + +int32_t HdiDirectConnection::Stop(enum VibratorStopMode mode) +{ + int32_t ret = vibratorInterface->Stop(static_cast(mode)); + if (ret < 0) { + HiLog::Error(LABEL, "%{public}s failed", __func__); + return ret; + } + return ERR_OK; +} + +int32_t HdiDirectConnection::DestroyHdiConnection() +{ + int32_t ret = FreeVibratorInterfaceInstance(); + if (ret < 0) { + HiLog::Error(LABEL, "%{public}s failed", __func__); + return ret; + } + return ERR_OK; +} +} // namespace Sensors +} // namespace OHOS 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 new file mode 100644 index 0000000..2fa64c8 --- /dev/null +++ b/services/miscdevice_service/hdi_connection/interface/include/i_vibrator_hdi_connection.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2021 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 I_VIBRATOR_HDI_CONNECTION_H +#define I_VIBRATOR_HDI_CONNECTION_H +#include +#include +namespace OHOS { +namespace Sensors { +class IVibratorHdiConnection { +public: + enum VibratorStopMode { + VIBRATOR_STOP_MODE_TIME = 0, /**< Indicates the one-shot vibration with the given duration. */ + VIBRATOR_STOP_MODE_PRESET = 1, /**< Indicates the periodic vibration with the preset effect. */ + VIBRATOR_STOP_MODE_INVALID /**< Indicates invalid the effect mode. */ + }; + + IVibratorHdiConnection() = default; + + virtual ~IVibratorHdiConnection() = default; + + virtual int32_t ConnectHdi() = 0; + + virtual int32_t StartOnce(uint32_t duration) = 0; + + virtual int32_t Start(const char *effectType) = 0; + + virtual int32_t Stop(enum VibratorStopMode mode) = 0; + + virtual int32_t DestroyHdiConnection() = 0; + +private: + DISALLOW_COPY_AND_MOVE(IVibratorHdiConnection); +}; +} // namespace Sensors +} // namespace OHOS +#endif // I_VIBRATOR_HDI_CONNECTION_H \ No newline at end of file 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 new file mode 100644 index 0000000..2b698da --- /dev/null +++ b/services/miscdevice_service/hdi_connection/interface/include/vibrator_hdi_connection.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021 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 VIBRATOR_HDI_CONNECTION_H +#define VIBRATOR_HDI_CONNECTION_H + +#include "i_vibrator_hdi_connection.h" +#include "singleton.h" + +namespace OHOS { +namespace Sensors { +class VibratorHdiConnection : public IVibratorHdiConnection , public Singleton { +public: + VibratorHdiConnection() = default; + + virtual ~VibratorHdiConnection() {} + + int32_t ConnectHdi() override; + + int32_t StartOnce(uint32_t duration) override; + + int32_t Start(const char *effectType) override; + + int32_t Stop(enum VibratorStopMode mode) override; + + int32_t DestroyHdiConnection() override; + +private: + DISALLOW_COPY_AND_MOVE(VibratorHdiConnection); + std::unique_ptr iVibratorHdiConnection_; +}; +} // namespace Sensors +} // namespace OHOS +#endif // VIBRATOR_HDI_CONNECTION_H \ No newline at end of file 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 new file mode 100644 index 0000000..a3565dd --- /dev/null +++ b/services/miscdevice_service/hdi_connection/interface/src/vibrator_hdi_connection.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2021 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 "vibrator_hdi_connection.h" + +#include "compatible_connection.h" +#include "hdi_direct_connection.h" +#include "sensors_errors.h" +#include "sensors_log_domain.h" + +namespace OHOS { +namespace Sensors { +using namespace OHOS::HiviewDFX; + +namespace { +constexpr HiLogLabel LABEL = { LOG_CORE, SensorsLogDomain::SENSOR_SERVICE, "VibratorHdiConnection" }; +} + +int32_t VibratorHdiConnection::ConnectHdi() +{ + iVibratorHdiConnection_ = std::make_unique(); + int32_t ret = iVibratorHdiConnection_->ConnectHdi(); + if (ret != 0) { + HiLog::Error(LABEL, "%{public}s hdi direct failed", __func__); + iVibratorHdiConnection_ = std::make_unique(); + ret = iVibratorHdiConnection_->ConnectHdi(); + } + if (ret != 0) { + HiLog::Error(LABEL, "%{public}s hdi connection failed", __func__); + return VIBRATOR_HDF_CONNECT_ERR; + } + return ERR_OK; +} + +int32_t VibratorHdiConnection::StartOnce(uint32_t duration) +{ + int32_t ret = iVibratorHdiConnection_->StartOnce(duration); + if (ret < 0) { + HiLog::Error(LABEL, "%{public}s failed", __func__); + return VIBRATOR_ON_ERR; + } + return ERR_OK; +} + +int32_t VibratorHdiConnection::Start(const char *effectType) +{ + int32_t ret = iVibratorHdiConnection_->Start(effectType); + if (ret < 0) { + HiLog::Error(LABEL, "%{public}s failed", __func__); + return VIBRATOR_ON_ERR; + } + return ERR_OK; +} + +int32_t VibratorHdiConnection::Stop(enum VibratorStopMode mode) +{ + int32_t ret = iVibratorHdiConnection_->Stop(mode); + if (ret < 0) { + HiLog::Error(LABEL, "%{public}s failed", __func__); + return VIBRATOR_OFF_ERR; + } + return ERR_OK; +} + +int32_t VibratorHdiConnection::DestroyHdiConnection() +{ + int32_t ret = iVibratorHdiConnection_->DestroyHdiConnection(); + if (ret < 0) { + HiLog::Error(LABEL, "%{public}s failed", __func__); + return VIBRATOR_HDF_CONNECT_ERR; + } + return ERR_OK; +} +} // namespace Sensors +} // namespace OHOS -- Gitee From c1546aa0ac9e02f311ee5908357e85ff74b7a54b Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Fri, 14 Jan 2022 15:45:31 +0800 Subject: [PATCH 2/3] Signed-off-by:hellohyh001 Signed-off-by: hellohyh001 --- .../hdi_connection/adpter/include/compatible_connection.h | 2 +- .../hdi_connection/adpter/include/hdi_direct_connection.h | 2 +- .../hdi_connection/adpter/src/compatible_connection.cpp | 4 ++-- .../hdi_connection/adpter/src/hdi_direct_connection.cpp | 2 +- .../interface/include/i_vibrator_hdi_connection.h | 2 +- .../interface/include/vibrator_hdi_connection.h | 4 ++-- 6 files changed, 8 insertions(+), 8 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 45e935c..d56efcb 100644 --- a/services/miscdevice_service/hdi_connection/adpter/include/compatible_connection.h +++ b/services/miscdevice_service/hdi_connection/adpter/include/compatible_connection.h @@ -32,7 +32,7 @@ public: int32_t Start(const char *effectType) override; - int32_t Stop(enum VibratorStopMode mode) override; + int32_t Stop(VibratorStopMode mode) override; int32_t DestroyHdiConnection() override; diff --git a/services/miscdevice_service/hdi_connection/adpter/include/hdi_direct_connection.h b/services/miscdevice_service/hdi_connection/adpter/include/hdi_direct_connection.h index f2ed36b..0dc4072 100644 --- a/services/miscdevice_service/hdi_connection/adpter/include/hdi_direct_connection.h +++ b/services/miscdevice_service/hdi_connection/adpter/include/hdi_direct_connection.h @@ -33,7 +33,7 @@ public: int32_t Start(const char *effectType) override; - int32_t Stop(enum VibratorStopMode mode) override; + int32_t Stop(VibratorStopMode mode) override; int32_t DestroyHdiConnection() 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 493dd56..138ba3d 100644 --- a/services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adpter/src/compatible_connection.cpp @@ -12,12 +12,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "compatible_connection.h" #include #include #include -#include "compatible_connection.h" #include "sensors_errors.h" #include "sensors_log_domain.h" @@ -73,7 +73,7 @@ int32_t CompatibleConnection::Start(const char *effectType) return ERR_OK; } -int32_t CompatibleConnection::Stop(enum VibratorStopMode mode) +int32_t CompatibleConnection::Stop(VibratorStopMode mode) { HiLog::Info(LABEL, "%{public}s in", __func__); if (mode < 0 || mode >= VIBRATOR_STOP_MODE_INVALID) { diff --git a/services/miscdevice_service/hdi_connection/adpter/src/hdi_direct_connection.cpp b/services/miscdevice_service/hdi_connection/adpter/src/hdi_direct_connection.cpp index 15e3469..62fe1ae 100644 --- a/services/miscdevice_service/hdi_connection/adpter/src/hdi_direct_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adpter/src/hdi_direct_connection.cpp @@ -60,7 +60,7 @@ int32_t HdiDirectConnection::Start(const char *effectType) return ERR_OK; } -int32_t HdiDirectConnection::Stop(enum VibratorStopMode mode) +int32_t HdiDirectConnection::Stop(VibratorStopMode mode) { int32_t ret = vibratorInterface->Stop(static_cast(mode)); 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 2fa64c8..aca818e 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 @@ -37,7 +37,7 @@ public: virtual int32_t Start(const char *effectType) = 0; - virtual int32_t Stop(enum VibratorStopMode mode) = 0; + virtual int32_t Stop(VibratorStopMode mode) = 0; virtual int32_t DestroyHdiConnection() = 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 2b698da..e61e9ac 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 @@ -21,7 +21,7 @@ namespace OHOS { namespace Sensors { -class VibratorHdiConnection : public IVibratorHdiConnection , public Singleton { +class VibratorHdiConnection : public IVibratorHdiConnection, public Singleton { public: VibratorHdiConnection() = default; @@ -33,7 +33,7 @@ public: int32_t Start(const char *effectType) override; - int32_t Stop(enum VibratorStopMode mode) override; + int32_t Stop(VibratorStopMode mode) override; int32_t DestroyHdiConnection() override; -- Gitee From 02d5c08b4bfa1f2c2e7740cbfdffb22c95f926d3 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Fri, 14 Jan 2022 16:35:01 +0800 Subject: [PATCH 3/3] Signed-off-by:hellohyh001 Signed-off-by: hellohyh001 --- .../hdi_connection/interface/src/vibrator_hdi_connection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a3565dd..be5f4a2 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 @@ -63,7 +63,7 @@ int32_t VibratorHdiConnection::Start(const char *effectType) return ERR_OK; } -int32_t VibratorHdiConnection::Stop(enum VibratorStopMode mode) +int32_t VibratorHdiConnection::Stop(VibratorStopMode mode) { int32_t ret = iVibratorHdiConnection_->Stop(mode); if (ret < 0) { -- Gitee