ensure vibration future is canceled when scheduling a new one

This commit is contained in:
Daniel Gultsch 2021-04-18 16:09:36 +02:00
parent ea2acc2963
commit 8aed588405
1 changed files with 4 additions and 0 deletions

View File

@ -410,12 +410,16 @@ public class NotificationService {
Log.d(Config.LOGTAG,"do not ring or vibrate because interruption filter has been set to "+currentInterruptionFilter); Log.d(Config.LOGTAG,"do not ring or vibrate because interruption filter has been set to "+currentInterruptionFilter);
return; return;
} }
final ScheduledFuture<?> currentVibrationFuture = this.vibrationFuture;
this.vibrationFuture = SCHEDULED_EXECUTOR_SERVICE.scheduleAtFixedRate( this.vibrationFuture = SCHEDULED_EXECUTOR_SERVICE.scheduleAtFixedRate(
new VibrationRunnable(), new VibrationRunnable(),
0, 0,
3, 3,
TimeUnit.SECONDS TimeUnit.SECONDS
); );
if (currentVibrationFuture != null) {
currentVibrationFuture.cancel(true);
}
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mXmppConnectionService); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mXmppConnectionService);
final Resources resources = mXmppConnectionService.getResources(); final Resources resources = mXmppConnectionService.getResources();
final String ringtonePreference = preferences.getString("call_ringtone", resources.getString(R.string.incoming_call_ringtone)); final String ringtonePreference = preferences.getString("call_ringtone", resources.getString(R.string.incoming_call_ringtone));