diff --git a/services/miscdevice_service/BUILD.gn b/services/miscdevice_service/BUILD.gn index 418469dd9c0466bd08abdacd3d71b229e0a754c4..499d2dc125fb796ab694388a92ea2683d3834126 100644 --- a/services/miscdevice_service/BUILD.gn +++ b/services/miscdevice_service/BUILD.gn @@ -102,9 +102,7 @@ ohos_shared_library("libmiscdevice_service") { sources += [ "hdi_connection/adapter/src/hdi_connection.cpp" ] external_deps += [ - "drivers_interface_vibrator:libvibrator_proxy_1.1", - "drivers_interface_vibrator:libvibrator_proxy_1.2", - "drivers_interface_vibrator:libvibrator_proxy_1.3", + "drivers_interface_vibrator:libvibrator_proxy_2.0", ] } @@ -216,9 +214,7 @@ ohos_static_library("libmiscdevice_service_static") { sources += [ "hdi_connection/adapter/src/hdi_connection.cpp" ] external_deps += [ - "drivers_interface_vibrator:libvibrator_proxy_1.1", - "drivers_interface_vibrator:libvibrator_proxy_1.2", - "drivers_interface_vibrator:libvibrator_proxy_1.3", + "drivers_interface_vibrator:libvibrator_proxy_2.0", ] } diff --git a/services/miscdevice_service/hdi_connection/adapter/include/compatible_connection.h b/services/miscdevice_service/hdi_connection/adapter/include/compatible_connection.h index 954c274c95999ea5a11d64167734e0f60fdb3bd6..139cb93c25741756d6cd392f5dfa8d44ab92256e 100644 --- a/services/miscdevice_service/hdi_connection/adapter/include/compatible_connection.h +++ b/services/miscdevice_service/hdi_connection/adapter/include/compatible_connection.h @@ -35,7 +35,7 @@ public: bool IsVibratorRunning() override; #endif // OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM std::optional GetEffectInfo(const std::string &effect) override; - int32_t Stop(HdfVibratorModeV1_2 mode) override; + int32_t Stop(HdfVibratorMode mode) override; #endif // HDF_DRIVERS_INTERFACE_VIBRATOR int32_t GetDelayTime(int32_t mode, int32_t &delayTime) override; int32_t GetVibratorCapacity(VibratorCapacity &capacity) override; diff --git a/services/miscdevice_service/hdi_connection/adapter/include/hdi_connection.h b/services/miscdevice_service/hdi_connection/adapter/include/hdi_connection.h index 0c4426f3bc44d18960982da4142338a75814a550..af38f76d2e02fd2f4e527bc04a6e179d23ab1034 100644 --- a/services/miscdevice_service/hdi_connection/adapter/include/hdi_connection.h +++ b/services/miscdevice_service/hdi_connection/adapter/include/hdi_connection.h @@ -17,14 +17,14 @@ #define HDI_CONNECTION_H #ifdef HDF_DRIVERS_INTERFACE_VIBRATOR -#include "v1_3/vibrator_interface_proxy.h" +#include "v2_0/vibrator_interface_proxy.h" #endif // HDF_DRIVERS_INTERFACE_VIBRATOR #include "death_recipient_template.h" #include "i_vibrator_hdi_connection.h" #ifdef HDF_DRIVERS_INTERFACE_VIBRATOR -using OHOS::HDI::Vibrator::V1_3::IVibratorInterface; +using OHOS::HDI::Vibrator::V2_0::IVibratorInterface; #endif // HDF_DRIVERS_INTERFACE_VIBRATOR namespace OHOS { namespace Sensors { @@ -41,7 +41,7 @@ public: bool IsVibratorRunning() override; #endif // OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM std::optional GetEffectInfo(const std::string &effect) override; - int32_t Stop(HdfVibratorModeV1_2 mode) override; + int32_t Stop(HdfVibratorMode mode) override; #endif // HDF_DRIVERS_INTERFACE_VIBRATOR int32_t GetDelayTime(int32_t mode, int32_t &delayTime) override; int32_t GetVibratorCapacity(VibratorCapacity &capacity) override; 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 ebecb241396ba09cc051336abddda5729e5a9ced..b2835eb8bc687d8f9d9914b4f8001b5a4a5214c3 100644 --- a/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp @@ -43,7 +43,7 @@ std::unordered_map g_vibratorEffect = { {"haptic.notice.warning", 2200} }; #ifdef HDF_DRIVERS_INTERFACE_VIBRATOR -HdfVibratorModeV1_2 g_vibrateMode; +HdfVibratorMode g_vibrateMode; #endif // HDF_DRIVERS_INTERFACE_VIBRATOR constexpr int32_t VIBRATE_DELAY_TIME = 10; } // namespace @@ -140,7 +140,7 @@ std::optional CompatibleConnection::GetEffectInfo(const std::stri return effectInfo; } -int32_t CompatibleConnection::Stop(HdfVibratorModeV1_2 mode) +int32_t CompatibleConnection::Stop(HdfVibratorMode mode) { CALL_LOG_ENTER; if (mode < 0 || mode >= HDF_VIBRATOR_MODE_BUTT) { 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 6d22d8046f0914ef2f260d2d2ab2a6f615c2051c..321987fc5a1d6a801f3b57d108dc1892b1653049 100644 --- a/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp @@ -58,7 +58,11 @@ int32_t HdiConnection::ConnectHdi() int32_t HdiConnection::StartOnce(uint32_t duration) { CHKPR(vibratorInterface_, ERR_INVALID_VALUE); - int32_t ret = vibratorInterface_->StartOnce(duration); + DeviceVibratorInfo deviceVibratorInfo = { + .deviceId = 0, + .vibratorId = 0 + }; + int32_t ret = vibratorInterface_->StartOnce(deviceVibratorInfo, duration); if (ret < 0) { #ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "VIBRATOR_HDF_SERVICE_EXCEPTION", @@ -78,7 +82,11 @@ int32_t HdiConnection::Start(const std::string &effectType) return VIBRATOR_ON_ERR; } CHKPR(vibratorInterface_, ERR_INVALID_VALUE); - int32_t ret = vibratorInterface_->Start(effectType); + DeviceVibratorInfo deviceVibratorInfo = { + .deviceId = 0, + .vibratorId = 0 + }; + int32_t ret = vibratorInterface_->Start(deviceVibratorInfo, effectType); if (ret < 0) { #ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "VIBRATOR_HDF_SERVICE_EXCEPTION", @@ -99,7 +107,11 @@ int32_t HdiConnection::EnableCompositeEffect(const HdfCompositeEffect &hdfCompos return VIBRATOR_ON_ERR; } CHKPR(vibratorInterface_, ERR_INVALID_VALUE); - int32_t ret = vibratorInterface_->EnableCompositeEffect(hdfCompositeEffect); + DeviceVibratorInfo deviceVibratorInfo = { + .deviceId = 0, + .vibratorId = 0 + }; + int32_t ret = vibratorInterface_->EnableCompositeEffect(deviceVibratorInfo, hdfCompositeEffect); if (ret < 0) { #ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "VIBRATOR_HDF_SERVICE_EXCEPTION", @@ -115,7 +127,11 @@ bool HdiConnection::IsVibratorRunning() { bool state = false; CHKPR(vibratorInterface_, false); - vibratorInterface_->IsVibratorRunning(state); + DeviceVibratorInfo deviceVibratorInfo = { + .deviceId = 0, + .vibratorId = 0 + }; + vibratorInterface_->IsVibratorRunning(deviceVibratorInfo, state); return state; } #endif // OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM @@ -127,7 +143,11 @@ std::optional HdiConnection::GetEffectInfo(const std::string &eff return std::nullopt; } HdfEffectInfo effectInfo; - int32_t ret = vibratorInterface_->GetEffectInfo(effect, effectInfo); + DeviceVibratorInfo deviceVibratorInfo = { + .deviceId = 0, + .vibratorId = 0 + }; + int32_t ret = vibratorInterface_->GetEffectInfo(deviceVibratorInfo, effect, effectInfo); if (ret < 0) { #ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "VIBRATOR_HDF_SERVICE_EXCEPTION", @@ -139,10 +159,14 @@ std::optional HdiConnection::GetEffectInfo(const std::string &eff return effectInfo; } -int32_t HdiConnection::Stop(HdfVibratorModeV1_2 mode) +int32_t HdiConnection::Stop(HdfVibratorMode mode) { CHKPR(vibratorInterface_, ERR_INVALID_VALUE); - int32_t ret = vibratorInterface_->StopV1_2(mode); + DeviceVibratorInfo deviceVibratorInfo = { + .deviceId = 0, + .vibratorId = 0 + }; + int32_t ret = vibratorInterface_->Stop(deviceVibratorInfo, mode); if (ret < 0) { #ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "VIBRATOR_HDF_SERVICE_EXCEPTION", @@ -157,7 +181,11 @@ int32_t HdiConnection::Stop(HdfVibratorModeV1_2 mode) int32_t HdiConnection::GetDelayTime(int32_t mode, int32_t &delayTime) { CHKPR(vibratorInterface_, ERR_INVALID_VALUE); - int32_t ret = vibratorInterface_->GetHapticStartUpTime(mode, delayTime); + DeviceVibratorInfo deviceVibratorInfo = { + .deviceId = 0, + .vibratorId = 0 + }; + int32_t ret = vibratorInterface_->GetHapticStartUpTime(deviceVibratorInfo, mode, delayTime); if (ret < 0) { #ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "VIBRATOR_HDF_SERVICE_EXCEPTION", @@ -173,7 +201,11 @@ int32_t HdiConnection::GetVibratorCapacity(VibratorCapacity &capacity) { CHKPR(vibratorInterface_, ERR_INVALID_VALUE); HapticCapacity hapticCapacity; - int32_t ret = vibratorInterface_->GetHapticCapacity(hapticCapacity); + DeviceVibratorInfo deviceVibratorInfo = { + .deviceId = 0, + .vibratorId = 0 + }; + int32_t ret = vibratorInterface_->GetHapticCapacity(deviceVibratorInfo, hapticCapacity); if (ret < 0) { #ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "VIBRATOR_HDF_SERVICE_EXCEPTION", @@ -215,7 +247,11 @@ int32_t HdiConnection::PlayPattern(const VibratePattern &pattern) } packet.events.emplace_back(hapticEvent); } - int32_t ret = vibratorInterface_->PlayHapticPattern(packet); + DeviceVibratorInfo deviceVibratorInfo = { + .deviceId = 0, + .vibratorId = 0 + }; + int32_t ret = vibratorInterface_->PlayHapticPattern(deviceVibratorInfo, packet); if (ret < 0) { #ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "VIBRATOR_HDF_SERVICE_EXCEPTION", @@ -289,7 +325,11 @@ int32_t HdiConnection::StartByIntensity(const std::string &effect, int32_t inten return VIBRATOR_ON_ERR; } CHKPR(vibratorInterface_, ERR_INVALID_VALUE); - int32_t ret = vibratorInterface_->StartByIntensity(effect, intensity); + DeviceVibratorInfo deviceVibratorInfo = { + .deviceId = 0, + .vibratorId = 0 + }; + int32_t ret = vibratorInterface_->StartByIntensity(deviceVibratorInfo, effect, intensity); if (ret < 0) { #ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "VIBRATOR_HDF_SERVICE_EXCEPTION", @@ -304,8 +344,11 @@ int32_t HdiConnection::StartByIntensity(const std::string &effect, int32_t inten int32_t HdiConnection::GetAllWaveInfo(std::vector &waveInfos) { CHKPR(vibratorInterface_, ERR_INVALID_VALUE); - int32_t vibratorId = 1; - int32_t ret = vibratorInterface_->GetAllWaveInfo(vibratorId, waveInfos); + DeviceVibratorInfo deviceVibratorInfo = { + .deviceId = 0, + .vibratorId = 1 + }; + int32_t ret = vibratorInterface_->GetAllWaveInfo(deviceVibratorInfo, waveInfos); if (ret != ERR_OK) { MISC_HILOGE("GetAllWaveInfo failed"); } 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 008b3dbc116653b03daf86675a4f3c5ef107edd1..5a39af61201ba81ec83a1267714a34ca8bd18116 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,34 +17,35 @@ #define I_VIBRATOR_HDI_CONNECTION_H #ifdef HDF_DRIVERS_INTERFACE_VIBRATOR -#include "v1_3/ivibrator_interface.h" +#include "v2_0/ivibrator_interface.h" #endif // HDF_DRIVERS_INTERFACE_VIBRATOR #include "vibrator_infos.h" namespace OHOS { namespace Sensors { #ifdef HDF_DRIVERS_INTERFACE_VIBRATOR -using OHOS::HDI::Vibrator::V1_2::HdfVibratorModeV1_2; -using OHOS::HDI::Vibrator::V1_2::HDF_VIBRATOR_MODE_ONCE; -using OHOS::HDI::Vibrator::V1_2::HDF_VIBRATOR_MODE_PRESET; -using OHOS::HDI::Vibrator::V1_2::HDF_VIBRATOR_MODE_HDHAPTIC; -using OHOS::HDI::Vibrator::V1_2::HDF_VIBRATOR_MODE_BUTT; -using OHOS::HDI::Vibrator::V1_2::CurvePoint; -using OHOS::HDI::Vibrator::V1_2::EVENT_TYPE; -using OHOS::HDI::Vibrator::V1_2::HapticCapacity; -using OHOS::HDI::Vibrator::V1_2::HapticPaket; -using OHOS::HDI::Vibrator::V1_2::HapticEvent; -using OHOS::HDI::Vibrator::V1_1::HdfEffectInfo; -using OHOS::HDI::Vibrator::V1_3::HdfWaveInformation; +using OHOS::HDI::Vibrator::V2_0::HdfVibratorMode; +using OHOS::HDI::Vibrator::V2_0::HDF_VIBRATOR_MODE_ONCE; +using OHOS::HDI::Vibrator::V2_0::HDF_VIBRATOR_MODE_PRESET; +using OHOS::HDI::Vibrator::V2_0::HDF_VIBRATOR_MODE_HDHAPTIC; +using OHOS::HDI::Vibrator::V2_0::HDF_VIBRATOR_MODE_BUTT; +using OHOS::HDI::Vibrator::V2_0::CurvePoint; +using OHOS::HDI::Vibrator::V2_0::DeviceVibratorInfo; +using OHOS::HDI::Vibrator::V2_0::EVENT_TYPE; +using OHOS::HDI::Vibrator::V2_0::HapticCapacity; +using OHOS::HDI::Vibrator::V2_0::HapticPaket; +using OHOS::HDI::Vibrator::V2_0::HapticEvent; +using OHOS::HDI::Vibrator::V2_0::HdfEffectInfo; +using OHOS::HDI::Vibrator::V2_0::HdfWaveInformation; #ifdef OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM -using OHOS::HDI::Vibrator::V1_1::HdfEffectType; -using OHOS::HDI::Vibrator::V1_1::HDF_EFFECT_TYPE_TIME; -using OHOS::HDI::Vibrator::V1_1::HDF_EFFECT_TYPE_PRIMITIVE; -using OHOS::HDI::Vibrator::V1_1::HDF_EFFECT_TYPE_BUTT; -using OHOS::HDI::Vibrator::V1_1::TimeEffect; -using OHOS::HDI::Vibrator::V1_1::PrimitiveEffect; -using OHOS::HDI::Vibrator::V1_1::CompositeEffect; -using OHOS::HDI::Vibrator::V1_1::HdfCompositeEffect; +using OHOS::HDI::Vibrator::V2_0::HdfEffectType; +using OHOS::HDI::Vibrator::V2_0::HDF_EFFECT_TYPE_TIME; +using OHOS::HDI::Vibrator::V2_0::HDF_EFFECT_TYPE_PRIMITIVE; +using OHOS::HDI::Vibrator::V2_0::HDF_EFFECT_TYPE_BUTT; +using OHOS::HDI::Vibrator::V2_0::TimeEffect; +using OHOS::HDI::Vibrator::V2_0::PrimitiveEffect; +using OHOS::HDI::Vibrator::V2_0::CompositeEffect; +using OHOS::HDI::Vibrator::V2_0::HdfCompositeEffect; #endif // OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM #endif // HDF_DRIVERS_INTERFACE_VIBRATOR class IVibratorHdiConnection { @@ -60,7 +61,7 @@ public: virtual bool IsVibratorRunning() = 0; #endif // OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM virtual std::optional GetEffectInfo(const std::string &effect) = 0; - virtual int32_t Stop(HdfVibratorModeV1_2 mode) = 0; + virtual int32_t Stop(HdfVibratorMode mode) = 0; #endif // HDF_DRIVERS_INTERFACE_VIBRATOR virtual int32_t DestroyHdiConnection() = 0; virtual int32_t GetDelayTime(int32_t mode, int32_t &delayTime) = 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 a604d2016174de254377ab5eff2944587a49ab73..e0c394063acb5c515af215c87b5f622cd83ad701 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 @@ -35,7 +35,7 @@ public: bool IsVibratorRunning() override; #endif // OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM std::optional GetEffectInfo(const std::string &effect) override; - int32_t Stop(HdfVibratorModeV1_2 mode) override; + int32_t Stop(HdfVibratorMode mode) override; #endif // HDF_DRIVERS_INTERFACE_VIBRATOR int32_t DestroyHdiConnection() override; int32_t GetDelayTime(int32_t mode, int32_t &delayTime) 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 a135b1c4b696da5feac1adadfae263f5be2ee9e4..c691f84cd941998953d2af725a019a522251e979 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 @@ -126,7 +126,7 @@ std::optional VibratorHdiConnection::GetEffectInfo(const std::str return ret; } -int32_t VibratorHdiConnection::Stop(HdfVibratorModeV1_2 mode) +int32_t VibratorHdiConnection::Stop(HdfVibratorMode mode) { CHKPR(iVibratorHdiConnection_, VIBRATOR_HDF_CONNECT_ERR); #ifdef HIVIEWDFX_HITRACE_ENABLE