From 5123b8fc8c9309fbb34e65608255c36a4496646b Mon Sep 17 00:00:00 2001 From: Peter Sanford Date: Wed, 22 Nov 2023 11:04:21 -0600 Subject: [PATCH] Fix write file permission check for sdk > 31 It looks like we don't need to perform this check to write to the downloads directory on new versions of android. Fixes #37 --- .../main/java/io/sanford/wormholewilliam/WriteFilePerm.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/io/sanford/wormholewilliam/WriteFilePerm.java b/android/src/main/java/io/sanford/wormholewilliam/WriteFilePerm.java index 3651834..76f3cc9 100644 --- a/android/src/main/java/io/sanford/wormholewilliam/WriteFilePerm.java +++ b/android/src/main/java/io/sanford/wormholewilliam/WriteFilePerm.java @@ -6,6 +6,7 @@ import android.app.FragmentTransaction; import android.content.Context; import android.content.pm.PackageManager; +import android.os.Build; import android.os.Handler; import android.util.Log; import android.view.View; @@ -37,7 +38,7 @@ public void run() { @Override public void onAttach(Context ctx) { super.onAttach(ctx); Log.d("wormhole", "WriteFilePerm: onAttach()"); - if (ctx.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.R && ctx.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST); } else { permissionResult(true);