BinaryEye icon indicating copy to clipboard operation
BinaryEye copied to clipboard

Vibrate on scan not working on Android 13

Open jdohm opened this issue 2 years ago • 6 comments

The Option "Vibrate on detection" does not lead to a vibration on detection on Android 13. On an older device using Android 11, this setting works as expected.

I tried using this code:

fun Context.getVibrator(): Vibrator = if (beforeS) { @Suppress("DEPRECATION") getSystemService(Context.VIBRATOR_SERVICE) as Vibrator } else { (getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager).defaultVibrator }

instead of:

fun Context.getVibrator(): Vibrator = if (beforeS) { @Suppress("DEPRECATION") getSystemService(Context.VIBRATOR_SERVICE) as Vibrator } else { (getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager).defaultVibrator }

inside the Vibrator.kt, sadly that did not solve the problem.

Feel free to ask for tests or more information.

I'm not an Android developer, so the only other idea I had was to set the amplitude of the vibration to 255, but this did not change the behavior.

I tested on a Pixel 4a 5g and a Pixel 4a with Android 13, and on a Fairphone 4 with Android 11.

jdohm avatar Dec 18 '22 21:12 jdohm

Hm, this is strange 🤔 Thanks for filing an issue! 👍

Curiously it works on my Pixel 7 Pro with Android 13, which is the only device with Android 13 that I have at the moment, unfortunately. So I will have to do some research, and get my hands on more devices running Android 13 to track this down.

But I guess it may have something to do with the duration. Does it work when you increase the DURATION_IN_MS value to 500L in Vibrator.kt?

markusfisch avatar Dec 19 '22 09:12 markusfisch

changing the DURATION_IN_MS to 500L does change the behavior.

jdohm avatar Dec 20 '22 20:12 jdohm

Interesting! Thanks for testing this! 👍

I increased the duration to 250 ms for the next release (in 6a63bc4e061b3b9fbe157a835435fd652dac1469), which is hopefully enough (500 ms is quite a bit long I guess).

markusfisch avatar Dec 21 '22 17:12 markusfisch

Oh damn, my bad. Was supposed to say doesn't :(

jdohm avatar Dec 21 '22 21:12 jdohm

Ah, okay 😉 So it's not the duration 🙈

markusfisch avatar Dec 22 '22 08:12 markusfisch

On my Pixel 7 Pro (as already confirmed by Markus) but also on my Samsung Tab S6 on Android 13 it's working how it should be.

cyb3rko avatar May 16 '23 12:05 cyb3rko