From 8aed58840574958c39857907cf82bde5257c02cf Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 18 Apr 2021 16:09:36 +0200 Subject: [PATCH] ensure vibration future is canceled when scheduling a new one --- .../eu/siacs/conversations/services/NotificationService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index a4eec7fb1..6ccd2b74f 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -410,12 +410,16 @@ public class NotificationService { Log.d(Config.LOGTAG,"do not ring or vibrate because interruption filter has been set to "+currentInterruptionFilter); return; } + final ScheduledFuture currentVibrationFuture = this.vibrationFuture; this.vibrationFuture = SCHEDULED_EXECUTOR_SERVICE.scheduleAtFixedRate( new VibrationRunnable(), 0, 3, TimeUnit.SECONDS ); + if (currentVibrationFuture != null) { + currentVibrationFuture.cancel(true); + } final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mXmppConnectionService); final Resources resources = mXmppConnectionService.getResources(); final String ringtonePreference = preferences.getString("call_ringtone", resources.getString(R.string.incoming_call_ringtone));