Android: Silence deprecation warnings in ControllerInterface

We have to use the deprecated APIs when running on old devices.
This commit is contained in:
JosJuice
2026-07-05 10:38:44 +02:00
parent f5d225691e
commit 424269ed4b
@@ -160,6 +160,7 @@ object ControllerInterface {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
DolphinVibratorManagerPassthrough(device.vibratorManager)
} else {
@Suppress("DEPRECATION")
DolphinVibratorManagerCompat(device.vibrator)
}
}
@@ -174,6 +175,7 @@ object ControllerInterface {
return DolphinVibratorManagerPassthrough(vibratorManager)
}
}
@Suppress("DEPRECATION")
val vibrator = DolphinApplication.getAppContext()
.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
return DolphinVibratorManagerCompat(vibrator)
@@ -190,11 +192,13 @@ object ControllerInterface {
} else {
val attributes = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_MEDIA).build()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
@Suppress("DEPRECATION")
vibrator.vibrate(
VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE),
attributes
)
} else {
@Suppress("DEPRECATION")
vibrator.vibrate(100, attributes)
}
}