Skip to content

Commit

Permalink
Fix permission request when one is already granted (#373)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aironefr authored Aug 12, 2021
1 parent 9517414 commit 613e8fa
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 613e8fa

Please sign in to comment.