mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-25 14:09:10 +00:00
android: Remove blocking permission request code. Async only in SDL3!
(this actually still blocks at our internal points of usage, though, for replacement at a later time.)
This commit is contained in:
parent
af61cfd5e0
commit
bc984f78bf
12 changed files with 73 additions and 77 deletions
|
@ -1029,6 +1029,29 @@ JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceReportResponse
|
|||
extern "C"
|
||||
{
|
||||
|
||||
// !!! FIXME: make this non-blocking!
|
||||
static void SDLCALL AndroidRequestPermissionBlockingCallback(void *userdata, const char *permission, SDL_bool granted)
|
||||
{
|
||||
SDL_AtomicSet((SDL_AtomicInt *) userdata, granted ? 1 : -1);
|
||||
}
|
||||
|
||||
static SDL_bool RequestBluetoothPermissions(const char *permission)
|
||||
{
|
||||
// !!! FIXME: make this non-blocking!
|
||||
SDL_AtomicInt permission_response;
|
||||
SDL_AtomicSet(&permission_response, 0);
|
||||
if (SDL_AndroidRequestPermission(permission, AndroidRequestPermissionBlockingCallback, &permission_response) == -1) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
while (SDL_AtomicGet(&permission_response) == 0) {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
return SDL_AtomicGet(&permission_response) > 0;
|
||||
}
|
||||
|
||||
|
||||
int hid_init(void)
|
||||
{
|
||||
if ( !g_initialized && g_HIDDeviceManagerCallbackHandler )
|
||||
|
@ -1046,7 +1069,7 @@ int hid_init(void)
|
|||
bool init_bluetooth = false;
|
||||
if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_STEAM, SDL_FALSE)) {
|
||||
if (SDL_GetAndroidSDKVersion() < 31 ||
|
||||
Android_JNI_RequestPermission("android.permission.BLUETOOTH_CONNECT")) {
|
||||
RequestBluetoothPermissions("android.permission.BLUETOOTH_CONNECT")) {
|
||||
init_bluetooth = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue