Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): update max sdk version for write external storage #547

Merged
merged 1 commit into from
Sep 16, 2023

Conversation

bang9
Copy link
Contributor

@bang9 bang9 commented Sep 8, 2023

Hello, If the version of device is Android 10 or higher, no longer need the "write external storage" permission.

You can read more by following this link:
https://developer.android.com/about/versions/11/privacy/storage#permissions-target-11

Keep in mind that, on devices that run Android 10 (API level 29) or higher, your app can contribute to well-defined media collections such as MediaStore.Downloads without requesting any storage-related permissions. Learn more about how to request only the necessary permissions when working with media files in your app.

resolve #544

@bang9 bang9 changed the title fix: update max sdk version for write external storage fix(android): update max sdk version for write external storage Sep 8, 2023
@jforaker
Copy link

Confirmed that this library does not work on Android 11 and 12 without this change. Adding the patch below fixes it. Thanks for the tip @bang9

npx patch-package react-native-audio-recorder-player
diff --git a/node_modules/react-native-audio-recorder-player/android/src/main/java/com/dooboolab.audiorecorderplayer/RNAudioRecorderPlayerModule.kt b/node_modules/react-native-audio-recorder-player/android/src/main/java/com/dooboolab.audiorecorderplayer/RNAudioRecorderPlayerModule.kt
index 5cb9bbf..46d973a 100644
--- a/node_modules/react-native-audio-recorder-player/android/src/main/java/com/dooboolab.audiorecorderplayer/RNAudioRecorderPlayerModule.kt
+++ b/node_modules/react-native-audio-recorder-player/android/src/main/java/com/dooboolab.audiorecorderplayer/RNAudioRecorderPlayerModule.kt
@@ -38,9 +38,10 @@ 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) {
-                // TIRAMISU (33)
-                // https://github.com/hyochan/react-native-audio-recorder-player/issues/503
-                if (Build.VERSION.SDK_INT < 33 &&
+                // On devices that run Android 10 (API level 29) or higher
+                // your app can contribute to well-defined media collections such as MediaStore.Downloads without requesting any storage-related permissions
+                // https://developer.android.com/about/versions/11/privacy/storage#permissions-target-11
+                if (Build.VERSION.SDK_INT < 29 &&
                         (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(

@gulshan-4
Copy link

gulshan-4 commented Sep 14, 2023

Confirmed that this library does not work on Android 11 and 12 without this change. Adding the patch below fixes it. Thanks for the tip @bang9

npx patch-package react-native-audio-recorder-player
diff --git a/node_modules/react-native-audio-recorder-player/android/src/main/java/com/dooboolab.audiorecorderplayer/RNAudioRecorderPlayerModule.kt b/node_modules/react-native-audio-recorder-player/android/src/main/java/com/dooboolab.audiorecorderplayer/RNAudioRecorderPlayerModule.kt
index 5cb9bbf..46d973a 100644
--- a/node_modules/react-native-audio-recorder-player/android/src/main/java/com/dooboolab.audiorecorderplayer/RNAudioRecorderPlayerModule.kt
+++ b/node_modules/react-native-audio-recorder-player/android/src/main/java/com/dooboolab.audiorecorderplayer/RNAudioRecorderPlayerModule.kt
@@ -38,9 +38,10 @@ 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) {
-                // TIRAMISU (33)
-                // https://github.com/hyochan/react-native-audio-recorder-player/issues/503
-                if (Build.VERSION.SDK_INT < 33 &&
+                // On devices that run Android 10 (API level 29) or higher
+                // your app can contribute to well-defined media collections such as MediaStore.Downloads without requesting any storage-related permissions
+                // https://developer.android.com/about/versions/11/privacy/storage#permissions-target-11
+                if (Build.VERSION.SDK_INT < 29 &&
                         (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(

Does it work Now?

@gulshan-4
Copy link

Why is it not merged yet?

Copy link
Owner

@hyochan hyochan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bang9 Thank you for helping others out! 👍

@hyochan hyochan merged commit f9a74a7 into hyochan:main Sep 16, 2023
1 check passed
@bang9 bang9 deleted the patch-1 branch September 17, 2023 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android Wirte external storage permission is not required after Android version 10
4 participants