Explicitly request read URI permission

This commit is contained in:
M66B 2022-06-25 14:22:31 +02:00
parent 73fb69008c
commit 5db35154df
7 changed files with 9 additions and 0 deletions

View File

@ -1752,6 +1752,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
private void onImportCertificate(Intent intent) {
Intent open = new Intent(Intent.ACTION_GET_CONTENT);
open.addCategory(Intent.CATEGORY_OPENABLE);
open.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
open.setType("*/*");
if (open.resolveActivity(getPackageManager()) == null) // system whitelisted
ToastEx.makeText(this, R.string.title_no_saf, Toast.LENGTH_LONG).show();
@ -1776,6 +1777,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
private static Intent getIntentImport() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setType("*/*");
return intent;
}

View File

@ -257,6 +257,7 @@ public class ActivitySignature extends ActivityBase {
private void onMenuSelectFile() {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setType("text/*");
Helper.openAdvanced(intent);
startActivityForResult(intent, REQUEST_FILE);

View File

@ -2596,6 +2596,7 @@ public class FragmentCompose extends FragmentBase {
private void onActionAttachment() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setType("*/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
PackageManager pm = getContext().getPackageManager();
@ -3041,6 +3042,7 @@ public class FragmentCompose extends FragmentBase {
Log.i("Using file picker");
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
if (intent.resolveActivity(pm) == null) // GET_CONTENT whitelisted

View File

@ -396,6 +396,7 @@ public class FragmentContacts extends FragmentBase {
} else {
Intent open = new Intent(Intent.ACTION_GET_CONTENT);
open.addCategory(Intent.CATEGORY_OPENABLE);
open.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
open.setType("*/*");
if (open.resolveActivity(pm) == null) // system whitelisted
ToastEx.makeText(context, R.string.title_no_saf, Toast.LENGTH_LONG).show();

View File

@ -360,6 +360,7 @@ public class FragmentOptionsEncryption extends FragmentBase
PackageManager pm = context.getPackageManager();
Intent open = new Intent(Intent.ACTION_GET_CONTENT);
open.addCategory(Intent.CATEGORY_OPENABLE);
open.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
open.setType("*/*");
if (open.resolveActivity(pm) == null) // system whitelisted
ToastEx.makeText(context, R.string.title_no_saf, Toast.LENGTH_LONG).show();

View File

@ -1175,6 +1175,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setType("*/*");
Intent choose = Helper.getChooser(v.getContext(), intent);
getActivity().startActivityForResult(choose, ActivitySetup.REQUEST_IMPORT_PROVIDERS);

View File

@ -307,6 +307,7 @@ public class FragmentRules extends FragmentBase {
private void onMenuImport() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setType("*/*");
startActivityForResult(intent, REQUEST_IMPORT);
}