godot icon indicating copy to clipboard operation
godot copied to clipboard

Fix `Input.vibrate_handheld` on Android.

Open Alex2782 opened this issue 5 months ago • 5 comments

Fixes #103496

Catched the crash via try / catch.

			try {
                                 ....
                                 vibratorService.vibrate( .... )
                                 ....
			} catch (e: SecurityException) {
				Log.w(TAG, e)
			}

logcat
06-11 02:50:51.881 26791 26927 W Godot   : java.lang.SecurityException: vibrate: Neither user 10717 nor current process has android.permission.VIBRATE.
06-11 02:50:51.881 26791 26927 W Godot   :      at android.os.Parcel.createExceptionOrNull(Parcel.java:3023)
06-11 02:50:51.881 26791 26927 W Godot   :      at android.os.Parcel.createException(Parcel.java:3007)
06-11 02:50:51.881 26791 26927 W Godot   :      at android.os.Parcel.readException(Parcel.java:2990)
06-11 02:50:51.881 26791 26927 W Godot   :      at android.os.Parcel.readException(Parcel.java:2932)
06-11 02:50:51.881 26791 26927 W Godot   :      at android.os.IVibratorManagerService$Stub$Proxy.vibrate(IVibratorManagerService.java:438)
06-11 02:50:51.881 26791 26927 W Godot   :      at android.os.SystemVibratorManager.vibrate(SystemVibratorManager.java:140)
06-11 02:50:51.881 26791 26927 W Godot   :      at android.os.SystemVibrator.vibrate(SystemVibrator.java:218)
06-11 02:50:51.881 26791 26927 W Godot   :      at android.os.Vibrator.vibrate(Vibrator.java:513)
06-11 02:50:51.881 26791 26927 W Godot   :      at android.os.Vibrator.vibrate(Vibrator.java:464)
06-11 02:50:51.881 26791 26927 W Godot   :      at org.godotengine.godot.Godot.vibrate(Godot.kt:1017)
06-11 02:50:51.881 26791 26927 W Godot   :      at org.godotengine.godot.GodotLib.step(Native Method)
06-11 02:50:51.881 26791 26927 W Godot   :      at org.godotengine.godot.gl.GodotRenderer.onDrawFrame(GodotRenderer.java:61)
06-11 02:50:51.881 26791 26927 W Godot   :      at org.godotengine.godot.gl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1592)
06-11 02:50:51.881 26791 26927 W Godot   :      at org.godotengine.godot.gl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1294)
06-11 02:50:51.881 26791 26927 W Godot   : Caused by: android.os.RemoteException: Remote stack trace:
06-11 02:50:51.881 26791 26927 W Godot   :      at android.app.ContextImpl.enforce(ContextImpl.java:2359)
06-11 02:50:51.881 26791 26927 W Godot   :      at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:2387)
06-11 02:50:51.881 26791 26927 W Godot   :      at com.android.server.vibrator.VibratorManagerService.vibrateInternal(VibratorManagerService.java:447)
06-11 02:50:51.881 26791 26927 W Godot   :      at com.android.server.vibrator.VibratorManagerService.vibrate(VibratorManagerService.java:435)
06-11 02:50:51.881 26791 26927 W Godot   :      at android.os.IVibratorManagerService$Stub.onTransact(IVibratorManagerService.java:252)
06-11 02:50:51.881 26791 26927 W Godot   : 
06-11 02:50:51.881 26791 26927 V Godot   : OnGodotMainLoopStarted

Alex2782 avatar Jun 11 '25 01:06 Alex2782