diff --git a/frameworks/native/audio_haptic/audio_haptic_vibrator_impl.cpp b/frameworks/native/audio_haptic/audio_haptic_vibrator_impl.cpp index 28a674b0c4329f46ef6ec705caabb952d1c1b68b..7a7a41db9b6a5d7f50a85bc81861f9eea36df39d 100644 --- a/frameworks/native/audio_haptic/audio_haptic_vibrator_impl.cpp +++ b/frameworks/native/audio_haptic/audio_haptic_vibrator_impl.cpp @@ -45,6 +45,7 @@ constexpr int32_t NUM_ZERO = 0; constexpr int32_t NUM_ONE = 0; constexpr int32_t NUM_TWO = 0; constexpr int32_t NUM_THREE = 0; +constexpr int32_t PATTERNDURATION_TIME_MS = 800; //ms void CopyEvent(const VibratorEvent &strongEvent, VibratorEvent &weakEvent) { @@ -702,7 +703,7 @@ int32_t AudioHapticVibratorImpl::PlayVibrationPattern( // last pattern need to wait if (patternIndex == vibratorPkg->patternNum - 1) { - int32_t lastPatternDuration = vibratorPkg->patterns[patternIndex].patternDuration; + int32_t lastPatternDuration = vibratorPkg->patterns[patternIndex].patternDuration + PATTERNDURATION_TIME_MS; (void)vibrateCV_.wait_for(lock, std::chrono::milliseconds(lastPatternDuration), [this]() { return isStopped_ || isNeedRestart_; }); CHECK_AND_RETURN_RET_LOG(!isStopped_ && !isNeedRestart_, result, diff --git a/frameworks/native/system_sound_manager/system_sound_vibrator/system_sound_vibrator.cpp b/frameworks/native/system_sound_manager/system_sound_vibrator/system_sound_vibrator.cpp index d02d14882d3b412d9c75a5cfa8e471651ba9ac47..5a5f2cd7bc2116e442370a0923a680ebbcf3da35 100644 --- a/frameworks/native/system_sound_manager/system_sound_vibrator/system_sound_vibrator.cpp +++ b/frameworks/native/system_sound_manager/system_sound_vibrator/system_sound_vibrator.cpp @@ -33,6 +33,7 @@ constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_AUDIO_NAPI, namespace OHOS { namespace Media { const std::string PREFIX = "fd://"; +constexpr int32_t PATTERNDURATION_TIME_MS = 800; //ms #ifdef SUPPORT_VIBRATOR const std::unordered_map VIBRATOR_USAGE_MAP = { @@ -237,7 +238,8 @@ int32_t SystemSoundVibrator::VibrateLoopFunc(std::unique_lock &lock, "Failed to PlayPattern for NonSyncVibration. Error %{public}d", result); } // wait for the last pattern - int32_t lastPatternDuration = vibratorPkg->patterns[vibratorPkg->patternNum - 1].patternDuration; + int32_t lastPatternDuration = vibratorPkg->patterns[vibratorPkg->patternNum - 1].patternDuration + + PATTERNDURATION_TIME_MS; (void)g_vibrateCV.wait_for(lock, std::chrono::milliseconds(lastPatternDuration), []() { return !g_isRunning; }); CHECK_AND_RETURN_RET_LOG(g_isRunning, result, "RunVibrationPatterns: Stop() is call when waiting");