diff --git a/miscdevice.gni b/miscdevice.gni index 7db0b940dc5570ba9a2952da03041fab8062b44b..f65c58ee73321e8ee853aa9791653cf4a894d8ce 100644 --- a/miscdevice.gni +++ b/miscdevice.gni @@ -16,6 +16,7 @@ import("//build/ohos.gni") declare_args() { miscdevice_feature_vibrator_custom = true miscdevice_feature_hiviewdfx_hisysevent = true + miscdevice_feature_hdf_drivers_interface_vibrator = true } print( @@ -27,6 +28,18 @@ FUZZ_MODULE_OUT_PATH = "miscdevice/miscdevice" miscdevice_default_defines = [] +if (!defined(global_parts_info) || + defined(global_parts_info.hdf_drivers_interface_vibrator)) { + miscdevice_feature_hdf_drivers_interface_vibrator = true + miscdevice_default_defines += [ "HDF_DRIVERS_INTERFACE_VIBRATOR" ] +} else { + miscdevice_feature_hdf_drivers_interface_vibrator = false +} + +if (!miscdevice_feature_hdf_drivers_interface_vibrator) { + miscdevice_feature_vibrator_custom = false +} + if (miscdevice_feature_vibrator_custom) { miscdevice_default_defines += [ "OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM" ] } diff --git a/services/miscdevice_service/BUILD.gn b/services/miscdevice_service/BUILD.gn index 0ffbfaff0fbb2ebd3533cd285f82883af3741a74..18187dbab829746239dad8428b6bbd82451c5e67 100644 --- a/services/miscdevice_service/BUILD.gn +++ b/services/miscdevice_service/BUILD.gn @@ -16,18 +16,13 @@ import("./../../miscdevice.gni") ohos_shared_library("libmiscdevice_service") { sources = [ - "haptic_matcher/src/custom_vibration_matcher.cpp", "hdi_connection/adapter/src/compatible_light_connection.cpp", - "hdi_connection/adapter/src/hdi_connection.cpp", "hdi_connection/interface/src/light_hdi_connection.cpp", - "hdi_connection/interface/src/vibrator_hdi_connection.cpp", "src/miscdevice_common_event_subscriber.cpp", "src/miscdevice_dump.cpp", "src/miscdevice_observer.cpp", "src/miscdevice_service.cpp", "src/miscdevice_service_stub.cpp", - "src/vibration_priority_manager.cpp", - "src/vibrator_thread.cpp", ] include_dirs = [ @@ -69,9 +64,6 @@ ohos_shared_library("libmiscdevice_service") { "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_consumer", - "drivers_interface_vibrator:libvibrator_proxy_1.1", - "drivers_interface_vibrator:libvibrator_proxy_1.2", - "drivers_interface_vibrator:libvibrator_proxy_1.3", "hilog:libhilog", "ipc:ipc_single", "json:nlohmann_json_static", @@ -97,6 +89,22 @@ ohos_shared_library("libmiscdevice_service") { external_deps += [ "drivers_interface_light:liblight_proxy_1.0" ] } + if (miscdevice_feature_hdf_drivers_interface_vibrator) { + sources += [ + "haptic_matcher/src/custom_vibration_matcher.cpp", + "hdi_connection/adapter/src/hdi_connection.cpp", + "hdi_connection/interface/src/vibrator_hdi_connection.cpp", + "src/vibration_priority_manager.cpp", + "src/vibrator_thread.cpp", + ] + + external_deps += [ + "drivers_interface_vibrator:libvibrator_proxy_1.1", + "drivers_interface_vibrator:libvibrator_proxy_1.2", + "drivers_interface_vibrator:libvibrator_proxy_1.3", + ] + } + if (miscdevice_feature_hiviewdfx_hisysevent) { external_deps += [ "hisysevent:libhisysevent" ] } @@ -113,18 +121,13 @@ ohos_shared_library("libmiscdevice_service") { ############################################################################# ohos_static_library("libmiscdevice_service_static") { sources = [ - "haptic_matcher/src/custom_vibration_matcher.cpp", "hdi_connection/adapter/src/compatible_light_connection.cpp", - "hdi_connection/adapter/src/hdi_connection.cpp", "hdi_connection/interface/src/light_hdi_connection.cpp", - "hdi_connection/interface/src/vibrator_hdi_connection.cpp", "src/miscdevice_common_event_subscriber.cpp", "src/miscdevice_dump.cpp", "src/miscdevice_observer.cpp", "src/miscdevice_service.cpp", "src/miscdevice_service_stub.cpp", - "src/vibration_priority_manager.cpp", - "src/vibrator_thread.cpp", ] include_dirs = [ @@ -166,9 +169,6 @@ ohos_static_library("libmiscdevice_service_static") { "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_consumer", - "drivers_interface_vibrator:libvibrator_proxy_1.1", - "drivers_interface_vibrator:libvibrator_proxy_1.2", - "drivers_interface_vibrator:libvibrator_proxy_1.3", "hilog:libhilog", "ipc:ipc_single", "json:nlohmann_json_static", @@ -194,6 +194,22 @@ ohos_static_library("libmiscdevice_service_static") { external_deps += [ "drivers_interface_light:liblight_proxy_1.0" ] } + if (miscdevice_feature_hdf_drivers_interface_vibrator) { + sources += [ + "haptic_matcher/src/custom_vibration_matcher.cpp", + "hdi_connection/adapter/src/hdi_connection.cpp", + "hdi_connection/interface/src/vibrator_hdi_connection.cpp", + "src/vibration_priority_manager.cpp", + "src/vibrator_thread.cpp", + ] + + external_deps += [ + "drivers_interface_vibrator:libvibrator_proxy_1.1", + "drivers_interface_vibrator:libvibrator_proxy_1.2", + "drivers_interface_vibrator:libvibrator_proxy_1.3", + ] + } + if (miscdevice_feature_hiviewdfx_hisysevent) { external_deps += [ "hisysevent:libhisysevent" ] } 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 ad11c9f4834bb4fc739e0d1b663ab132342a61df..d1aeb8764845e0d852657b95bd4e4e3459d8ead2 100644 --- a/services/miscdevice_service/hdi_connection/adapter/include/compatible_connection.h +++ b/services/miscdevice_service/hdi_connection/adapter/include/compatible_connection.h @@ -34,11 +34,15 @@ public: int32_t EnableCompositeEffect(const HdfCompositeEffect &hdfCompositeEffect) override; bool IsVibratorRunning() override; #endif // OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR std::optional GetEffectInfo(const std::string &effect) override; int32_t Stop(HdfVibratorModeV1_2 mode) override; +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR int32_t GetDelayTime(int32_t mode, int32_t &delayTime) override; +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR int32_t GetVibratorCapacity(VibratorCapacity &capacity) override; int32_t PlayPattern(const VibratePattern &pattern) override; +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR int32_t DestroyHdiConnection() override; int32_t StartByIntensity(const std::string &effect, int32_t intensity) override; int32_t GetAllWaveInfo(std::vector &waveInfos) 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 196488c71871fcb7fd91b12a62794cfa7f94e405..885f8d77f21f6bd266603b682c318624a5e5525f 100644 --- a/services/miscdevice_service/hdi_connection/adapter/include/hdi_connection.h +++ b/services/miscdevice_service/hdi_connection/adapter/include/hdi_connection.h @@ -16,7 +16,9 @@ #ifndef HDI_CONNECTION_H #define HDI_CONNECTION_H +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR #include "v1_3/vibrator_interface_proxy.h" +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR #include "death_recipient_template.h" #include "i_vibrator_hdi_connection.h" @@ -47,7 +49,9 @@ public: private: DISALLOW_COPY_AND_MOVE(HdiConnection); +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR sptr vibratorInterface_ = nullptr; +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR sptr hdiDeathObserver_ = nullptr; void RegisterHdiDeathRecipient(); void UnregisterHdiDeathRecipient(); 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 8a09d8607357d16a84da834914db423bddd61b2c..88b0b5c68ceefcc805946468ca758b4ea655a156 100644 --- a/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp @@ -43,9 +43,12 @@ std::unordered_map g_vibratorEffect = { {"haptic.effect.soft", 30}, {"haptic.effect.sharp", 20} }; +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR HdfVibratorModeV1_2 g_vibrateMode; constexpr int32_t VIBRATE_DELAY_TIME = 10; +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR } // namespace +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR int32_t CompatibleConnection::duration_ = 0; std::atomic_bool CompatibleConnection::isStop_ = true; @@ -211,6 +214,7 @@ int32_t CompatibleConnection::GetAllWaveInfo(std::vector &wa { return ERR_OK; } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR } // namespace Sensors } // namespace OHOS 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..e55c644d6bde2c9200872b89df83e361beb1b7be 100644 --- a/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp @@ -38,11 +38,13 @@ int32_t HdiConnection::ConnectHdi() CALL_LOG_ENTER; int32_t retry = 0; while (retry < GET_HDI_SERVICE_COUNT) { +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR vibratorInterface_ = IVibratorInterface::Get(); if (vibratorInterface_ != nullptr) { RegisterHdiDeathRecipient(); return ERR_OK; } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR retry++; MISC_HILOGW("Connect hdi service failed, retry:%{public}d", retry); std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_MS)); @@ -57,6 +59,7 @@ int32_t HdiConnection::ConnectHdi() int32_t HdiConnection::StartOnce(uint32_t duration) { +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR CHKPR(vibratorInterface_, ERR_INVALID_VALUE); int32_t ret = vibratorInterface_->StartOnce(duration); if (ret < 0) { @@ -67,6 +70,7 @@ int32_t HdiConnection::StartOnce(uint32_t duration) MISC_HILOGE("StartOnce failed"); return ret; } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR return ERR_OK; } @@ -77,6 +81,7 @@ int32_t HdiConnection::Start(const std::string &effectType) MISC_HILOGE("effectType is null"); return VIBRATOR_ON_ERR; } +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR CHKPR(vibratorInterface_, ERR_INVALID_VALUE); int32_t ret = vibratorInterface_->Start(effectType); if (ret < 0) { @@ -87,6 +92,7 @@ int32_t HdiConnection::Start(const std::string &effectType) MISC_HILOGE("Start failed"); return ret; } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR return ERR_OK; } @@ -120,6 +126,7 @@ bool HdiConnection::IsVibratorRunning() } #endif // OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR std::optional HdiConnection::GetEffectInfo(const std::string &effect) { if (vibratorInterface_ == nullptr) { @@ -153,9 +160,11 @@ int32_t HdiConnection::Stop(HdfVibratorModeV1_2 mode) } return ERR_OK; } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR int32_t HdiConnection::GetDelayTime(int32_t mode, int32_t &delayTime) { +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR CHKPR(vibratorInterface_, ERR_INVALID_VALUE); int32_t ret = vibratorInterface_->GetHapticStartUpTime(mode, delayTime); if (ret < 0) { @@ -166,11 +175,13 @@ int32_t HdiConnection::GetDelayTime(int32_t mode, int32_t &delayTime) MISC_HILOGE("GetDelayTime failed"); return ret; } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR return ERR_OK; } int32_t HdiConnection::GetVibratorCapacity(VibratorCapacity &capacity) { +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR CHKPR(vibratorInterface_, ERR_INVALID_VALUE); HapticCapacity hapticCapacity; int32_t ret = vibratorInterface_->GetHapticCapacity(hapticCapacity); @@ -186,11 +197,13 @@ int32_t HdiConnection::GetVibratorCapacity(VibratorCapacity &capacity) capacity.isSupportPresetMapping = hapticCapacity.isSupportPresetMapping; capacity.isSupportTimeDelay = hapticCapacity.isSupportTimeDelay; capacity.Dump(); +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR return ERR_OK; } int32_t HdiConnection::PlayPattern(const VibratePattern &pattern) { +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR CHKPR(vibratorInterface_, ERR_INVALID_VALUE); HapticPaket packet = {}; packet.time = pattern.startTime; @@ -224,6 +237,7 @@ int32_t HdiConnection::PlayPattern(const VibratePattern &pattern) MISC_HILOGE("PlayHapticPattern failed"); return ret; } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR return ERR_OK; } @@ -236,6 +250,7 @@ int32_t HdiConnection::DestroyHdiConnection() void HdiConnection::RegisterHdiDeathRecipient() { CALL_LOG_ENTER; +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR if (vibratorInterface_ == nullptr) { MISC_HILOGE("Connect v1_1 hdi failed"); return; @@ -245,16 +260,19 @@ void HdiConnection::RegisterHdiDeathRecipient() CHKPV(hdiDeathObserver_); } OHOS::HDI::hdi_objcast(vibratorInterface_)->AddDeathRecipient(hdiDeathObserver_); +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR } void HdiConnection::UnregisterHdiDeathRecipient() { CALL_LOG_ENTER; +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR if (vibratorInterface_ == nullptr || hdiDeathObserver_ == nullptr) { MISC_HILOGE("vibratorInterface_ or hdiDeathObserver_ is null"); return; } OHOS::HDI::hdi_objcast(vibratorInterface_)->RemoveDeathRecipient(hdiDeathObserver_); +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR } void HdiConnection::ProcessDeathObserver(const wptr &object) 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 340826df1019e715ced14a962352e801f4d16ef3..9fe97374f4ce8182d82dde1d2365eafbc5f9fbd6 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 @@ -21,12 +21,15 @@ #include #include +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR #include "v1_2/vibrator_types.h" #include "v1_3/ivibrator_interface.h" #include "vibrator_infos.h" +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR 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; @@ -49,6 +52,7 @@ using OHOS::HDI::Vibrator::V1_1::PrimitiveEffect; using OHOS::HDI::Vibrator::V1_1::CompositeEffect; using OHOS::HDI::Vibrator::V1_1::HdfCompositeEffect; #endif // OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR class IVibratorHdiConnection { public: IVibratorHdiConnection() = default; @@ -60,12 +64,16 @@ public: virtual int32_t EnableCompositeEffect(const HdfCompositeEffect &hdfCompositeEffect) = 0; virtual bool IsVibratorRunning() = 0; #endif // OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR virtual std::optional GetEffectInfo(const std::string &effect) = 0; virtual int32_t Stop(HdfVibratorModeV1_2 mode) = 0; +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR virtual int32_t DestroyHdiConnection() = 0; virtual int32_t GetDelayTime(int32_t mode, int32_t &delayTime) = 0; +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR virtual int32_t GetVibratorCapacity(VibratorCapacity &capacity) = 0; virtual int32_t PlayPattern(const VibratePattern &pattern) = 0; +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR virtual int32_t StartByIntensity(const std::string &effect, int32_t intensity) = 0; virtual int32_t GetAllWaveInfo(std::vector &waveInfos) = 0; diff --git a/services/miscdevice_service/include/miscdevice_service.h b/services/miscdevice_service/include/miscdevice_service.h index 07b0b54a276ca642e10f046eb29fa1cec74b5ce2..fd28b2981866a4c4bbc3571bd3c9d90540798d49 100644 --- a/services/miscdevice_service/include/miscdevice_service.h +++ b/services/miscdevice_service/include/miscdevice_service.h @@ -38,9 +38,11 @@ #include "miscdevice_delayed_sp_singleton.h" #include "miscdevice_dump.h" #include "miscdevice_service_stub.h" +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR #include "vibrator_hdi_connection.h" #include "vibrator_infos.h" #include "vibrator_thread.h" +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR namespace OHOS { namespace Sensors { @@ -63,6 +65,7 @@ public: bool IsLightAnimationValid(const LightAnimationIPC &animation); int32_t Dump(int32_t fd, const std::vector &args) override; void ProcessDeathObserver(const wptr &object); +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR virtual int32_t Vibrate(int32_t vibratorId, int32_t timeOut, int32_t usage, bool systemUsage) override; virtual int32_t PlayVibratorEffect(int32_t vibratorId, const std::string &effect, int32_t loopCount, int32_t usage, bool systemUsage) override; @@ -73,28 +76,39 @@ public: virtual int32_t StopVibrator(int32_t vibratorId) override; virtual int32_t StopVibrator(int32_t vibratorId, const std::string &mode) override; virtual int32_t IsSupportEffect(const std::string &effect, bool &state) override; +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR virtual std::vector GetLightList() override; virtual int32_t TurnOn(int32_t lightId, const LightColor &color, const LightAnimationIPC &animation) override; virtual int32_t TurnOff(int32_t lightId) override; +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR virtual int32_t PlayPattern(const VibratePattern &pattern, int32_t usage, bool systemUsage, const VibrateParameter ¶meter) override; virtual int32_t GetDelayTime(int32_t &delayTime) override; +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR virtual int32_t TransferClientRemoteObject(const sptr &vibratorServiceClient) override; virtual int32_t PlayPrimitiveEffect(int32_t vibratorId, const std::string &effect, int32_t intensity, int32_t usage, bool systemUsage, int32_t count) override; +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR virtual int32_t GetVibratorCapacity(VibratorCapacity &capacity) override; +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR private: DISALLOW_COPY_AND_MOVE(MiscdeviceService); +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR bool InitInterface(); +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR bool InitLightInterface(); std::string GetPackageName(AccessTokenID tokenId); +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR void StartVibrateThread(VibrateInfo info); void StopVibrateThread(); bool ShouldIgnoreVibrate(const VibrateInfo &info); +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR std::string GetCurrentTime(); +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR void MergeVibratorParmeters(const VibrateParameter ¶meter, VibratePackage &package); bool CheckVibratorParmeters(const VibrateParameter ¶meter); +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR bool InitLightList(); void RegisterClientDeathRecipient(sptr vibratorServiceClient, int32_t pid); void UnregisterClientDeathRecipient(sptr vibratorServiceClient); @@ -104,17 +118,23 @@ private: void OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override; int32_t SubscribeCommonEvent(const std::string &eventName, EventReceiver receiver); void OnReceiveEvent(const EventFwk::CommonEventData &data); +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR std::mutex isVibrationPriorityReadyMutex_; static bool isVibrationPriorityReady_; VibratorHdiConnection &vibratorHdiConnection_ = VibratorHdiConnection::GetInstance(); +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR LightHdiConnection &lightHdiConnection_ = LightHdiConnection::GetInstance(); bool lightExist_; +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR bool vibratorExist_; +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR std::vector lightInfos_; std::map miscDeviceIdMap_; MiscdeviceServiceState state_; +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR std::shared_ptr vibratorThread_ = nullptr; std::mutex vibratorThreadMutex_; +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR sptr clientDeathObserver_ = nullptr; std::mutex clientDeathObserverMutex_; std::map, int32_t> clientPidMap_; diff --git a/services/miscdevice_service/src/miscdevice_service.cpp b/services/miscdevice_service/src/miscdevice_service.cpp index 9a5510f158d855179798f2af9a0d760fc725d0c5..652e3215d013925f891c149c2705a660065fe249 100644 --- a/services/miscdevice_service/src/miscdevice_service.cpp +++ b/services/miscdevice_service/src/miscdevice_service.cpp @@ -27,7 +27,9 @@ #include "system_ability_definition.h" #include "sensors_errors.h" +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR #include "vibration_priority_manager.h" +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR #ifdef HDF_DRIVERS_INTERFACE_LIGHT #include "v1_0/light_interface_proxy.h" @@ -46,6 +48,7 @@ namespace OHOS { namespace Sensors { namespace { +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR auto g_miscdeviceService = MiscdeviceDelayedSpSingleton::GetInstance(); const bool G_REGISTER_RESULT = SystemAbility::MakeAndRegisterAbility(g_miscdeviceService.GetRefPtr()); constexpr int32_t MIN_VIBRATOR_TIME = 0; @@ -62,17 +65,23 @@ constexpr int32_t FREQUENCY_ADJUST_MIN = -100; constexpr int32_t FREQUENCY_ADJUST_MAX = 100; constexpr int32_t INVALID_PID = -1; constexpr int32_t VIBRATOR_ID = 0; +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR constexpr int32_t BASE_YEAR = 1900; constexpr int32_t BASE_MON = 1; constexpr int32_t CONVERSION_RATE = 1000; +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR VibratorCapacity g_capacity; +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR #ifdef OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM const std::string PHONE_TYPE = "phone"; #endif // OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM } // namespace +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR bool MiscdeviceService::isVibrationPriorityReady_ = false; +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR MiscdeviceService::MiscdeviceService() : SystemAbility(MISCDEVICE_SERVICE_ABILITY_ID, true), lightExist_(false), @@ -82,10 +91,21 @@ MiscdeviceService::MiscdeviceService() { MISC_HILOGD("Add SystemAbility"); } +#else +MiscdeviceService::MiscdeviceService() + : SystemAbility(MISCDEVICE_SERVICE_ABILITY_ID, true), + lightExist_(false), + state_(MiscdeviceServiceState::STATE_STOPPED) +{ + MISC_HILOGD("Add SystemAbility"); +} +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR MiscdeviceService::~MiscdeviceService() { +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR StopVibrateThread(); +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR } void MiscdeviceService::OnDump() @@ -135,6 +155,7 @@ void MiscdeviceService::OnAddSystemAbility(int32_t systemAbilityId, const std::s } case DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID: { MISC_HILOGI("Distributed kv data service start"); +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR std::lock_guard lock(isVibrationPriorityReadyMutex_); if (PriorityManager->Init()) { MISC_HILOGI("PriorityManager init"); @@ -142,6 +163,7 @@ void MiscdeviceService::OnAddSystemAbility(int32_t systemAbilityId, const std::s } else { MISC_HILOGE("PriorityManager init fail"); } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR break; } default: { @@ -157,6 +179,7 @@ void MiscdeviceService::OnReceiveEvent(const EventFwk::CommonEventData &data) std::string action = want.GetAction(); if (action == "usual.event.DATA_SHARE_READY") { MISC_HILOGI("On receive usual.event.DATA_SHARE_READY"); +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR std::lock_guard lock(isVibrationPriorityReadyMutex_); if (isVibrationPriorityReady_) { MISC_HILOGI("PriorityManager already init"); @@ -168,6 +191,7 @@ void MiscdeviceService::OnReceiveEvent(const EventFwk::CommonEventData &data) } else { MISC_HILOGE("PriorityManager init fail"); } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR } } @@ -178,27 +202,33 @@ void MiscdeviceService::OnStart() MISC_HILOGW("state_ already started"); return; } +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR if (!InitInterface()) { MISC_HILOGE("Init interface error"); } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR if (!InitLightInterface()) { MISC_HILOGE("InitLightInterface failed"); } +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR if (!SystemAbility::Publish(MiscdeviceDelayedSpSingleton::GetInstance())) { MISC_HILOGE("Publish MiscdeviceService failed"); return; } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR std::lock_guard lock(miscDeviceIdMapMutex_); auto ret = miscDeviceIdMap_.insert(std::make_pair(MiscdeviceDeviceId::LED, lightExist_)); if (!ret.second) { MISC_HILOGI("Light exist in miscDeviceIdMap_"); ret.first->second = lightExist_; } +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR ret = miscDeviceIdMap_.insert(std::make_pair(MiscdeviceDeviceId::VIBRATOR, vibratorExist_)); if (!ret.second) { MISC_HILOGI("Vibrator exist in miscDeviceIdMap_"); ret.first->second = vibratorExist_; } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR state_ = MiscdeviceServiceState::STATE_RUNNING; #ifdef MEMMGR_ENABLE AddSystemAbilityListener(MEMORY_MANAGER_SA_ID); @@ -213,9 +243,11 @@ void MiscdeviceService::OnStartFuzz() MISC_HILOGW("state_ already started"); return; } +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR if (!InitInterface()) { MISC_HILOGE("Init interface error"); } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR if (!InitLightInterface()) { MISC_HILOGE("InitLightInterface failed"); } @@ -225,14 +257,17 @@ void MiscdeviceService::OnStartFuzz() MISC_HILOGI("Light exist in miscDeviceIdMap_"); ret.first->second = lightExist_; } +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR ret = miscDeviceIdMap_.insert(std::make_pair(MiscdeviceDeviceId::VIBRATOR, vibratorExist_)); if (!ret.second) { MISC_HILOGI("Vibrator exist in miscDeviceIdMap_"); ret.first->second = vibratorExist_; } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR state_ = MiscdeviceServiceState::STATE_RUNNING; } +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR bool MiscdeviceService::InitInterface() { auto ret = vibratorHdiConnection_.ConnectHdi(); @@ -245,6 +280,7 @@ bool MiscdeviceService::InitInterface() } return true; } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR bool MiscdeviceService::InitLightInterface() { @@ -293,16 +329,19 @@ void MiscdeviceService::OnStop() return; } state_ = MiscdeviceServiceState::STATE_STOPPED; +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR int32_t ret = vibratorHdiConnection_.DestroyHdiConnection(); if (ret != ERR_OK) { MISC_HILOGE("Destroy hdi connection fail"); } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR #ifdef MEMMGR_ENABLE Memory::MemMgrClient::GetInstance().NotifyProcessStatus(getpid(), PROCESS_TYPE_SA, PROCESS_STATUS_DIED, MISCDEVICE_SERVICE_ABILITY_ID); #endif // MEMMGR_ENABLE } +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR bool MiscdeviceService::ShouldIgnoreVibrate(const VibrateInfo &info) { std::lock_guard lock(isVibrationPriorityReadyMutex_); @@ -467,6 +506,7 @@ int32_t MiscdeviceService::IsSupportEffect(const std::string &effect, bool &stat state = effectInfo->isSupportEffect; return NO_ERROR; } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR std::string MiscdeviceService::GetCurrentTime() { @@ -650,6 +690,7 @@ int32_t MiscdeviceService::Dump(int32_t fd, const std::vector &a return ERR_OK; } +#ifdef HDF_DRIVERS_INTERFACE_VIBRATOR int32_t MiscdeviceService::PlayPattern(const VibratePattern &pattern, int32_t usage, bool systemUsage, const VibrateParameter ¶meter) { @@ -900,5 +941,6 @@ int32_t MiscdeviceService::GetVibratorCapacity(VibratorCapacity &capacity) capacity = g_capacity; return ERR_OK; } +#endif // HDF_DRIVERS_INTERFACE_VIBRATOR } // namespace Sensors } // namespace OHOS diff --git a/test/fuzztest/service/getdelaytimestub_fuzzer/BUILD.gn b/test/fuzztest/service/getdelaytimestub_fuzzer/BUILD.gn index 21a97f33a463628b2d783d4eed13d39cf8f387b7..a54759c6c1f7ebab20ddceab8c8cf5831db5c2e5 100644 --- a/test/fuzztest/service/getdelaytimestub_fuzzer/BUILD.gn +++ b/test/fuzztest/service/getdelaytimestub_fuzzer/BUILD.gn @@ -55,7 +55,6 @@ ohos_fuzztest("GetDelayTimeStubFuzzTest") { "access_token:libtokensetproc_shared", "cJSON:cjson", "c_utils:utils", - "drivers_interface_vibrator:libvibrator_proxy_1.1", "hilog:libhilog", "ipc:ipc_single", "samgr:samgr_proxy", @@ -66,6 +65,10 @@ ohos_fuzztest("GetDelayTimeStubFuzzTest") { if (hdf_drivers_interface_light) { external_deps += [ "drivers_interface_light:liblight_proxy_1.0" ] } + + if (miscdevice_feature_hdf_drivers_interface_vibrator) { + external_deps += [ "drivers_interface_vibrator:libvibrator_proxy_1.1" ] + } } group("fuzztest") { diff --git a/test/fuzztest/service/getlightliststub_fuzzer/BUILD.gn b/test/fuzztest/service/getlightliststub_fuzzer/BUILD.gn index 98fc71511ca7a258b822477efb6c1d9e16db2b51..61a0903fc8522cc83bb3ccd6cac4ff7c16ade9d9 100644 --- a/test/fuzztest/service/getlightliststub_fuzzer/BUILD.gn +++ b/test/fuzztest/service/getlightliststub_fuzzer/BUILD.gn @@ -55,7 +55,6 @@ ohos_fuzztest("GetLightListStubFuzzTest") { "access_token:libtokensetproc_shared", "cJSON:cjson", "c_utils:utils", - "drivers_interface_vibrator:libvibrator_proxy_1.1", "hilog:libhilog", "ipc:ipc_single", "samgr:samgr_proxy", @@ -66,6 +65,10 @@ ohos_fuzztest("GetLightListStubFuzzTest") { if (hdf_drivers_interface_light) { external_deps += [ "drivers_interface_light:liblight_proxy_1.0" ] } + + if (miscdevice_feature_hdf_drivers_interface_vibrator) { + external_deps += [ "drivers_interface_vibrator:libvibrator_proxy_1.1" ] + } } group("fuzztest") { diff --git a/test/fuzztest/service/getvibratorcapacitystub_fuzzer/BUILD.gn b/test/fuzztest/service/getvibratorcapacitystub_fuzzer/BUILD.gn index 87189082fe176934a4e3bc0e2572ad7fd26561e2..8adaa03e1b3cabd2d0c2f5e73e45e02c2761fceb 100644 --- a/test/fuzztest/service/getvibratorcapacitystub_fuzzer/BUILD.gn +++ b/test/fuzztest/service/getvibratorcapacitystub_fuzzer/BUILD.gn @@ -55,7 +55,6 @@ ohos_fuzztest("GetVibratorCapacityStubFuzzTest") { "access_token:libtokensetproc_shared", "cJSON:cjson", "c_utils:utils", - "drivers_interface_vibrator:libvibrator_proxy_1.1", "hilog:libhilog", "ipc:ipc_single", "samgr:samgr_proxy", @@ -66,6 +65,10 @@ ohos_fuzztest("GetVibratorCapacityStubFuzzTest") { if (hdf_drivers_interface_light) { external_deps += [ "drivers_interface_light:liblight_proxy_1.0" ] } + + if (miscdevice_feature_hdf_drivers_interface_vibrator) { + external_deps += [ "drivers_interface_vibrator:libvibrator_proxy_1.1" ] + } } group("fuzztest") { diff --git a/test/fuzztest/service/issupporteffectstub_fuzzer/BUILD.gn b/test/fuzztest/service/issupporteffectstub_fuzzer/BUILD.gn index f9d151d8bb3d974c16faaa107e551444b4063faa..ca6be277b99f08593ad47a9ea5acf7fc0cdbe1cc 100644 --- a/test/fuzztest/service/issupporteffectstub_fuzzer/BUILD.gn +++ b/test/fuzztest/service/issupporteffectstub_fuzzer/BUILD.gn @@ -55,7 +55,6 @@ ohos_fuzztest("IsSupportEffectStubFuzzTest") { "access_token:libtokensetproc_shared", "cJSON:cjson", "c_utils:utils", - "drivers_interface_vibrator:libvibrator_proxy_1.1", "hilog:libhilog", "ipc:ipc_single", "samgr:samgr_proxy", @@ -66,6 +65,10 @@ ohos_fuzztest("IsSupportEffectStubFuzzTest") { if (hdf_drivers_interface_light) { external_deps += [ "drivers_interface_light:liblight_proxy_1.0" ] } + + if (miscdevice_feature_hdf_drivers_interface_vibrator) { + external_deps += [ "drivers_interface_vibrator:libvibrator_proxy_1.1" ] + } } group("fuzztest") { diff --git a/test/fuzztest/service/playpatternstub_fuzzer/BUILD.gn b/test/fuzztest/service/playpatternstub_fuzzer/BUILD.gn index 2a584d1dc91457edd45296a080de80efbf4f2edb..01b6fc972f4063cbdc0245114c172b7161278ea0 100644 --- a/test/fuzztest/service/playpatternstub_fuzzer/BUILD.gn +++ b/test/fuzztest/service/playpatternstub_fuzzer/BUILD.gn @@ -55,7 +55,6 @@ ohos_fuzztest("PlayPatternStubFuzzTest") { "access_token:libtokensetproc_shared", "cJSON:cjson", "c_utils:utils", - "drivers_interface_vibrator:libvibrator_proxy_1.1", "hilog:libhilog", "ipc:ipc_single", "samgr:samgr_proxy", @@ -66,6 +65,10 @@ ohos_fuzztest("PlayPatternStubFuzzTest") { if (hdf_drivers_interface_light) { external_deps += [ "drivers_interface_light:liblight_proxy_1.0" ] } + + if (miscdevice_feature_hdf_drivers_interface_vibrator) { + external_deps += [ "drivers_interface_vibrator:libvibrator_proxy_1.1" ] + } } group("fuzztest") { diff --git a/test/fuzztest/service/playprimitiveeffectstub_fuzzer/BUILD.gn b/test/fuzztest/service/playprimitiveeffectstub_fuzzer/BUILD.gn index 69ec08cf87b67d153465c3876fc036a9a32b3956..dc89839cc4e1187c66458bbe4fcfd9227e2d6bd6 100644 --- a/test/fuzztest/service/playprimitiveeffectstub_fuzzer/BUILD.gn +++ b/test/fuzztest/service/playprimitiveeffectstub_fuzzer/BUILD.gn @@ -55,7 +55,6 @@ ohos_fuzztest("PlayPrimitiveEffectStubFuzzTest") { "access_token:libtokensetproc_shared", "cJSON:cjson", "c_utils:utils", - "drivers_interface_vibrator:libvibrator_proxy_1.1", "hilog:libhilog", "ipc:ipc_single", "samgr:samgr_proxy", @@ -66,6 +65,10 @@ ohos_fuzztest("PlayPrimitiveEffectStubFuzzTest") { if (hdf_drivers_interface_light) { external_deps += [ "drivers_interface_light:liblight_proxy_1.0" ] } + + if (miscdevice_feature_hdf_drivers_interface_vibrator) { + external_deps += [ "drivers_interface_vibrator:libvibrator_proxy_1.1" ] + } } group("fuzztest") { diff --git a/test/fuzztest/service/playvibratorcustomstub_fuzzer/BUILD.gn b/test/fuzztest/service/playvibratorcustomstub_fuzzer/BUILD.gn index 8a039bfa49f5cf2154dad5ae74d21017443bdc8f..db56585eccd025b463e7326d4ff57961de7dcb5b 100644 --- a/test/fuzztest/service/playvibratorcustomstub_fuzzer/BUILD.gn +++ b/test/fuzztest/service/playvibratorcustomstub_fuzzer/BUILD.gn @@ -55,7 +55,6 @@ ohos_fuzztest("PlayVibratorCustomStubFuzzTest") { "access_token:libtokensetproc_shared", "cJSON:cjson", "c_utils:utils", - "drivers_interface_vibrator:libvibrator_proxy_1.1", "hilog:libhilog", "ipc:ipc_single", "samgr:samgr_proxy", @@ -66,6 +65,10 @@ ohos_fuzztest("PlayVibratorCustomStubFuzzTest") { if (hdf_drivers_interface_light) { external_deps += [ "drivers_interface_light:liblight_proxy_1.0" ] } + + if (miscdevice_feature_hdf_drivers_interface_vibrator) { + external_deps += [ "drivers_interface_vibrator:libvibrator_proxy_1.1" ] + } } group("fuzztest") { diff --git a/test/fuzztest/service/playvibratoreffectstub_fuzzer/BUILD.gn b/test/fuzztest/service/playvibratoreffectstub_fuzzer/BUILD.gn index f9260c16dfe5f276d8f13cd2f6d7cde1c3e8e9b9..2709e04e9b1067d7983fc4a8c677e97b280d4b68 100644 --- a/test/fuzztest/service/playvibratoreffectstub_fuzzer/BUILD.gn +++ b/test/fuzztest/service/playvibratoreffectstub_fuzzer/BUILD.gn @@ -55,7 +55,6 @@ ohos_fuzztest("PlayVibratorEffectStubFuzzTest") { "access_token:libtokensetproc_shared", "cJSON:cjson", "c_utils:utils", - "drivers_interface_vibrator:libvibrator_proxy_1.1", "hilog:libhilog", "ipc:ipc_single", "samgr:samgr_proxy", @@ -66,6 +65,10 @@ ohos_fuzztest("PlayVibratorEffectStubFuzzTest") { if (hdf_drivers_interface_light) { external_deps += [ "drivers_interface_light:liblight_proxy_1.0" ] } + + if (miscdevice_feature_hdf_drivers_interface_vibrator) { + external_deps += [ "drivers_interface_vibrator:libvibrator_proxy_1.1" ] + } } group("fuzztest") { diff --git a/test/fuzztest/service/stopvibratorallstub_fuzzer/BUILD.gn b/test/fuzztest/service/stopvibratorallstub_fuzzer/BUILD.gn index c9c9ebf92a583ece67dda45f06147b31d8fffdba..644f3a06cd75e90e21f8117024fd0e14a05c4f30 100644 --- a/test/fuzztest/service/stopvibratorallstub_fuzzer/BUILD.gn +++ b/test/fuzztest/service/stopvibratorallstub_fuzzer/BUILD.gn @@ -55,7 +55,6 @@ ohos_fuzztest("StopVibratorAllStubFuzzTest") { "access_token:libtokensetproc_shared", "cJSON:cjson", "c_utils:utils", - "drivers_interface_vibrator:libvibrator_proxy_1.1", "hilog:libhilog", "ipc:ipc_single", "samgr:samgr_proxy", @@ -66,6 +65,10 @@ ohos_fuzztest("StopVibratorAllStubFuzzTest") { if (hdf_drivers_interface_light) { external_deps += [ "drivers_interface_light:liblight_proxy_1.0" ] } + + if (miscdevice_feature_hdf_drivers_interface_vibrator) { + external_deps += [ "drivers_interface_vibrator:libvibrator_proxy_1.1" ] + } } group("fuzztest") { diff --git a/test/fuzztest/service/stopvibratorbymodestub_fuzzer/BUILD.gn b/test/fuzztest/service/stopvibratorbymodestub_fuzzer/BUILD.gn index 0a3abf1563681603390aae3f62e2f1bfdff216dd..06a772fd50596619f23c77914d60f9c0410a4d06 100644 --- a/test/fuzztest/service/stopvibratorbymodestub_fuzzer/BUILD.gn +++ b/test/fuzztest/service/stopvibratorbymodestub_fuzzer/BUILD.gn @@ -55,7 +55,6 @@ ohos_fuzztest("StopVibratorByModeStubFuzzTest") { "access_token:libtokensetproc_shared", "cJSON:cjson", "c_utils:utils", - "drivers_interface_vibrator:libvibrator_proxy_1.1", "hilog:libhilog", "ipc:ipc_single", "samgr:samgr_proxy", @@ -66,6 +65,10 @@ ohos_fuzztest("StopVibratorByModeStubFuzzTest") { if (hdf_drivers_interface_light) { external_deps += [ "drivers_interface_light:liblight_proxy_1.0" ] } + + if (miscdevice_feature_hdf_drivers_interface_vibrator) { + external_deps += [ "drivers_interface_vibrator:libvibrator_proxy_1.1" ] + } } group("fuzztest") { diff --git a/test/fuzztest/service/transferclientremoteobjectstub_fuzzer/BUILD.gn b/test/fuzztest/service/transferclientremoteobjectstub_fuzzer/BUILD.gn index 9afa0bd7f59349bb12dc33c9fe6f8f3c417cd97d..863971ac8cb1033877508cf8210774d4fc297187 100644 --- a/test/fuzztest/service/transferclientremoteobjectstub_fuzzer/BUILD.gn +++ b/test/fuzztest/service/transferclientremoteobjectstub_fuzzer/BUILD.gn @@ -54,7 +54,6 @@ ohos_fuzztest("TransferClientRemoteObjectStubFuzzTest") { "access_token:libtokensetproc_shared", "cJSON:cjson", "c_utils:utils", - "drivers_interface_vibrator:libvibrator_proxy_1.1", "hilog:libhilog", "ipc:ipc_single", "samgr:samgr_proxy", @@ -65,6 +64,10 @@ ohos_fuzztest("TransferClientRemoteObjectStubFuzzTest") { if (hdf_drivers_interface_light) { external_deps += [ "drivers_interface_light:liblight_proxy_1.0" ] } + + if (miscdevice_feature_hdf_drivers_interface_vibrator) { + external_deps += [ "drivers_interface_vibrator:libvibrator_proxy_1.1" ] + } } group("fuzztest") { diff --git a/test/fuzztest/service/turnoffstub_fuzzer/BUILD.gn b/test/fuzztest/service/turnoffstub_fuzzer/BUILD.gn index 326a39d94b0bc4cf9f224f24e049f4f7487d2923..f808c839012dee1288ee351d561fe7e9d5e0092f 100644 --- a/test/fuzztest/service/turnoffstub_fuzzer/BUILD.gn +++ b/test/fuzztest/service/turnoffstub_fuzzer/BUILD.gn @@ -54,7 +54,6 @@ ohos_fuzztest("TurnOffStubFuzzTest") { "access_token:libtokensetproc_shared", "cJSON:cjson", "c_utils:utils", - "drivers_interface_vibrator:libvibrator_proxy_1.1", "hilog:libhilog", "ipc:ipc_single", "samgr:samgr_proxy", @@ -65,6 +64,10 @@ ohos_fuzztest("TurnOffStubFuzzTest") { if (hdf_drivers_interface_light) { external_deps += [ "drivers_interface_light:liblight_proxy_1.0" ] } + + if (miscdevice_feature_hdf_drivers_interface_vibrator) { + external_deps += [ "drivers_interface_vibrator:libvibrator_proxy_1.1" ] + } } group("fuzztest") { diff --git a/test/fuzztest/service/turnonstub_fuzzer/BUILD.gn b/test/fuzztest/service/turnonstub_fuzzer/BUILD.gn index 99ee4b7315e25215b24b7bc5bcc62ed682a9c47f..d8e515bb88f2fb6f3630014539945d583526b17a 100644 --- a/test/fuzztest/service/turnonstub_fuzzer/BUILD.gn +++ b/test/fuzztest/service/turnonstub_fuzzer/BUILD.gn @@ -54,7 +54,6 @@ ohos_fuzztest("TurnOnStubFuzzTest") { "access_token:libtokensetproc_shared", "cJSON:cjson", "c_utils:utils", - "drivers_interface_vibrator:libvibrator_proxy_1.1", "hilog:libhilog", "ipc:ipc_single", "samgr:samgr_proxy", @@ -65,6 +64,10 @@ ohos_fuzztest("TurnOnStubFuzzTest") { if (hdf_drivers_interface_light) { external_deps += [ "drivers_interface_light:liblight_proxy_1.0" ] } + + if (miscdevice_feature_hdf_drivers_interface_vibrator) { + external_deps += [ "drivers_interface_vibrator:libvibrator_proxy_1.1" ] + } } group("fuzztest") { diff --git a/test/fuzztest/service/vibratestub_fuzzer/BUILD.gn b/test/fuzztest/service/vibratestub_fuzzer/BUILD.gn index 698efb1d1775887efda9a54818e75373b557ba74..d7c33838726bd1f1421621b4f5e66470c52abf6d 100644 --- a/test/fuzztest/service/vibratestub_fuzzer/BUILD.gn +++ b/test/fuzztest/service/vibratestub_fuzzer/BUILD.gn @@ -54,7 +54,6 @@ ohos_fuzztest("VibrateStubFuzzTest") { "access_token:libtokensetproc_shared", "cJSON:cjson", "c_utils:utils", - "drivers_interface_vibrator:libvibrator_proxy_1.1", "hilog:libhilog", "ipc:ipc_single", "samgr:samgr_proxy", @@ -65,6 +64,10 @@ ohos_fuzztest("VibrateStubFuzzTest") { if (hdf_drivers_interface_light) { external_deps += [ "drivers_interface_light:liblight_proxy_1.0" ] } + + if (miscdevice_feature_hdf_drivers_interface_vibrator) { + external_deps += [ "drivers_interface_vibrator:libvibrator_proxy_1.1" ] + } } group("fuzztest") { diff --git a/test/fuzztest/service/vibratoronremoterequest_fuzzer/BUILD.gn b/test/fuzztest/service/vibratoronremoterequest_fuzzer/BUILD.gn index 55ec05fb0bb6aabc310444b9aafd3b056c012a21..6f573f0dae01cc06a9204ad45e7954414a3c7123 100644 --- a/test/fuzztest/service/vibratoronremoterequest_fuzzer/BUILD.gn +++ b/test/fuzztest/service/vibratoronremoterequest_fuzzer/BUILD.gn @@ -55,7 +55,6 @@ ohos_fuzztest("VibratorOnRemoteRequestFuzzTest") { "access_token:libtokensetproc_shared", "cJSON:cjson", "c_utils:utils", - "drivers_interface_vibrator:libvibrator_proxy_1.1", "hilog:libhilog", "ipc:ipc_single", "samgr:samgr_proxy", @@ -66,6 +65,10 @@ ohos_fuzztest("VibratorOnRemoteRequestFuzzTest") { if (hdf_drivers_interface_light) { external_deps += [ "drivers_interface_light:liblight_proxy_1.0" ] } + + if (miscdevice_feature_hdf_drivers_interface_vibrator) { + external_deps += [ "drivers_interface_vibrator:libvibrator_proxy_1.1" ] + } } group("fuzztest") {