From 14bf532df3cb270f9492c2f6c05ec629e16936b3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 13 Feb 2020 16:10:52 -0800 Subject: [PATCH] Fixed opening audio on Android from the Steam Link shell activity --- .../main/java/org/libsdl/app/SDLActivity.java | 16 +++------------- src/audio/openslES/SDL_openslES.c | 1 + 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index 6ee101ee5..e143b519f 100644 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -1606,24 +1606,14 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh * This method is called by SDL using JNI. */ public static void requestPermission(String permission, int requestCode) { - if (mSingleton != null) { - mSingleton.checkPermission(permission, requestCode); - } else { - nativePermissionResult(requestCode, false); - } - } - - /** - * This can be overridden - */ - public void checkPermission(String permission, int requestCode) { if (Build.VERSION.SDK_INT < 23) { nativePermissionResult(requestCode, true); return; } - if (this.checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) { - this.requestPermissions(new String[]{permission}, requestCode); + Activity activity = (Activity)getContext(); + if (activity.checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) { + activity.requestPermissions(new String[]{permission}, requestCode); } else { nativePermissionResult(requestCode, true); } diff --git a/src/audio/openslES/SDL_openslES.c b/src/audio/openslES/SDL_openslES.c index 08189ddde..b4b55069c 100644 --- a/src/audio/openslES/SDL_openslES.c +++ b/src/audio/openslES/SDL_openslES.c @@ -234,6 +234,7 @@ openslES_CreatePCMRecorder(_THIS) int i; if (!Android_JNI_RequestPermission("android.permission.RECORD_AUDIO")) { + LOGE("This app doesn't have RECORD_AUDIO permission"); return SDL_SetError("This app doesn't have RECORD_AUDIO permission"); }