KeyHandler: Use VibrationEffect
The method vibrate(long milliseconds) was deprecated in API level 26
(https://developer.android.com/reference/android/os/Vibrator?hl=en#vibrate(long))
Change-Id: Icf937393b4b1031a46e4c122ff2f71d2a5353779
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 0d36683..df91423 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2,7 +2,7 @@
<!--
/**
* Copyright 2016, The CyanogenMod Project
- * Copyright 2017-2019, The LineageOS Project
+ * Copyright 2017-2020, The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@
<uses-permission android:name="android.permission.BIND_DEVICE_ADMIN" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_SEARCH_INDEXABLES" />
+ <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="lineageos.permission.MANAGE_REMOTE_PREFERENCES" />
diff --git a/src/org/lineageos/lineageparts/gestures/KeyHandler.java b/src/org/lineageos/lineageparts/gestures/KeyHandler.java
index 24026af..a6387bf 100644
--- a/src/org/lineageos/lineageparts/gestures/KeyHandler.java
+++ b/src/org/lineageos/lineageparts/gestures/KeyHandler.java
@@ -1,6 +1,6 @@
/**
* Copyright (C) 2016 The CyanogenMod project
- * 2017 The LineageOS Project
+ * 2017-2020 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,6 +42,7 @@
import android.os.PowerManager.WakeLock;
import android.os.SystemClock;
import android.os.UserHandle;
+import android.os.VibrationEffect;
import android.os.Vibrator;
import android.provider.Settings;
import android.util.Log;
@@ -385,7 +386,8 @@
final boolean enabled = LineageSettings.System.getInt(mContext.getContentResolver(),
LineageSettings.System.TOUCHSCREEN_GESTURE_HAPTIC_FEEDBACK, 1) != 0;
if (enabled) {
- mVibrator.vibrate(50);
+ mVibrator.vibrate(VibrationEffect.createOneShot(50,
+ VibrationEffect.DEFAULT_AMPLITUDE));
}
}
}