From 613e8fa333e738d91ebbc092ae6ab1ceb364f774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erwan=20Mathoni=C3=A8re?= Date: Thu, 12 Aug 2021 16:33:23 +0200 Subject: [PATCH] Fix permission request when one is already granted (#373) When `WRITE_EXTERNAL_STORAGE` is already granted but not `RECORD_AUDIO` (or vice-versa), `startRecorder` will stop asking permission for `RECORD_AUDIO` as today a "and" is used instead of a "or" condition. --- .../RNAudioRecorderPlayerModule.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/dooboolab.audiorecorderplayer/RNAudioRecorderPlayerModule.kt b/android/src/main/java/com/dooboolab.audiorecorderplayer/RNAudioRecorderPlayerModule.kt index 665d5c1c..8bd601ed 100644 --- a/android/src/main/java/com/dooboolab.audiorecorderplayer/RNAudioRecorderPlayerModule.kt +++ b/android/src/main/java/com/dooboolab.audiorecorderplayer/RNAudioRecorderPlayerModule.kt @@ -38,8 +38,8 @@ class RNAudioRecorderPlayerModule(private val reactContext: ReactApplicationCont fun startRecorder(path: String, audioSet: ReadableMap?, meteringEnabled: Boolean, promise: Promise) { try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && - ActivityCompat.checkSelfPermission(reactContext, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED && - ActivityCompat.checkSelfPermission(reactContext, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + (ActivityCompat.checkSelfPermission(reactContext, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED || + ActivityCompat.checkSelfPermission(reactContext, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)) { ActivityCompat.requestPermissions((currentActivity)!!, arrayOf( Manifest.permission.RECORD_AUDIO, Manifest.permission.WRITE_EXTERNAL_STORAGE), 0)