[Android] Fix the hasAllAccess method for Android versions between 23 and 29

Nicolas Pomepuy git at videolan.org
Mon Nov 25 11:07:02 UTC 2024


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Nov 14 13:35:49 2024 +0100| [532226718ccf6daa7e50a6a01422a6303c14df20] | committer: Duncan McNamara

Fix the hasAllAccess method for Android versions between 23 and 29

> https://code.videolan.org/videolan/vlc-android/commit/532226718ccf6daa7e50a6a01422a6303c14df20
---

 application/vlc-android/src/org/videolan/vlc/util/Permissions.kt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/util/Permissions.kt b/application/vlc-android/src/org/videolan/vlc/util/Permissions.kt
index 0f2452f8d5..d213c3e7dc 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/Permissions.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/Permissions.kt
@@ -181,7 +181,10 @@ object Permissions {
      * @param context: the context to check with
      * @return true if the app has been granted the whole permissions including [Manifest.permission.MANAGE_EXTERNAL_STORAGE]
      */
-    fun hasAllAccess(context: Context) = !Intent(android.provider.Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, Uri.fromParts(SCHEME_PACKAGE, context.packageName, null)).isCallable(context) || isExternalStorageManager()
+    fun hasAllAccess(context: Context) =
+        Build.VERSION.SDK_INT < Build.VERSION_CODES.M
+                || (Build.VERSION.SDK_INT < Build.VERSION_CODES.R && canReadStorage(context))
+                || isExternalStorageManager()
 
     fun canCheckBluetoothDevices(context: Context): Boolean {
         return ContextCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED



More information about the Android mailing list