Merge pull request #51953 from mbrlabs/android-vibration

Check if vibration duration is > 0 on Android
This commit is contained in:
Fredia Huya-Kouadio 2021-08-21 09:25:13 -07:00 committed by GitHub
commit 2cfe0e5af0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -317,7 +317,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
@SuppressLint("MissingPermission") @SuppressLint("MissingPermission")
@Keep @Keep
private void vibrate(int durationMs) { private void vibrate(int durationMs) {
if (requestPermission("VIBRATE")) { if (durationMs > 0 && requestPermission("VIBRATE")) {
Vibrator v = (Vibrator)getContext().getSystemService(Context.VIBRATOR_SERVICE); Vibrator v = (Vibrator)getContext().getSystemService(Context.VIBRATOR_SERVICE);
if (v != null) { if (v != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {