We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4566 - Hot-plugging Bluetooth controller causes force-quit on Android
Summary: Hot-plugging Bluetooth controller causes force-quit on Android
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: joystick (show other bugs)
Version: HG 2.0
Hardware: All Android (All)
: P2 normal
Assignee: Sylvain
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-27 16:07 UTC by Anthony @ POW Games
Modified: 2019-04-24 19:54 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anthony @ POW Games 2019-03-27 16:07:38 UTC
Since the HIDAPI was introduced, turning a paired Bluetooth controller on or off will cause a force-quit on Android. A quick glance over Logcat and I saw this:

D/hidapi: Initializing Bluetooth
D/hidapi: Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH

Do we need to add another permission to AndroidManifest.xml?
Comment 1 Sylvain 2019-04-02 07:02:58 UTC
Not sure but is it working correctly when you add this very permission ?
Comment 2 Sam Lantinga 2019-04-17 03:13:05 UTC
This sounds like Android is restarting the application due to a configuration change:
https://developer.android.com/guide/topics/manifest/activity-element.html#config

The default AndroidManifest.xml has this, can you try adding other values to see if one of those is triggering?
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
Comment 3 Anthony @ POW Games 2019-04-24 18:35:36 UTC
Adding bluetooth permission = no change.

I tried adding different configChanges and sure enough, "navigation" worked! Now bluetooth controllers hot-plug nicely. So shall we add it as a default to the AndroidManifest.xml?

Funny that this is how this activity is described:

"navigation" The navigation type (trackball/dpad) has changed. (This should never normally happen.)
Comment 4 Anthony @ POW Games 2019-04-24 18:38:22 UTC
I think the reason behind this is because the bluetooth game controller I was testing doubles-up as a keyboard, which probably comes with a DPAD? It's a MOCUTE-032X_B63-88CE
Comment 5 Sam Lantinga 2019-04-24 19:54:36 UTC
Added to the default manifest, thanks!
https://hg.libsdl.org/SDL/rev/f926c8070a2a