Skip to content

Commit

Permalink
KeyHandler: Use VibrationEffect
Browse files Browse the repository at this point in the history
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
Signed-off-by: Joey Huab <[email protected]>
  • Loading branch information
Ashwin4RC authored and AshutoshSundresh committed Apr 11, 2021
1 parent 2b8f1f7 commit 8e4be52
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.VIBRATE" />

<permission
android:name="com.android.touch.gestures.TRIGGER_SCREEN_OFF_GESTURE"
Expand Down
5 changes: 3 additions & 2 deletions src/com/android/touch/gestures/KeyHandler.java
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -349,7 +349,8 @@ private void doHapticFeedback() {
final boolean enabled = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.TOUCHSCREEN_GESTURE_HAPTIC_FEEDBACK, 1) != 0;
if (enabled) {
mVibrator.vibrate(VibrationEffect.get(VibrationEffect.EFFECT_HEAVY_CLICK));
mVibrator.vibrate(VibrationEffect.createOneShot(50,
VibrationEffect.DEFAULT_AMPLITUDE));
}
}
}
Expand Down

0 comments on commit 8e4be52

Please sign in to comment.