mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
Fix vibration for SDK >= 33
This commit is contained in:
parent
fb2e545101
commit
41ffb01394
1 changed files with 12 additions and 1 deletions
|
@ -18,6 +18,8 @@ import android.media.MediaPlayer;
|
|||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.VibrationAttributes;
|
||||
import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
import android.provider.Settings;
|
||||
import android.text.SpannableString;
|
||||
|
@ -357,7 +359,16 @@ public class VoIPPreNotificationService { // } extends Service implements AudioM
|
|||
} else if (vibrate == 3) {
|
||||
duration *= 2;
|
||||
}
|
||||
vibrator.vibrate(new long[]{0, duration, 500}, 0);
|
||||
long[] pattern = new long[]{0, duration, 500};
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
vibrator.vibrate(
|
||||
VibrationEffect.createWaveform(pattern, 0),
|
||||
new VibrationAttributes.Builder()
|
||||
.setUsage(VibrationAttributes.USAGE_RINGTONE) // required for background apps
|
||||
.build());
|
||||
} else {
|
||||
vibrator.vibrate(pattern, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue