How to bundle storage permission with external storage manager permission

Viewed 197

I am working on a files app and after targeting to API-30, I need permissions for not just media store permission (WRITE_EXTERNAL_STORAGE), but also need to be an external storage manager (MANAGE_EXTERNAL_STORAGE). In order to do so, I have to show 2 different system dialogs to the customer. The first one is the media store permissions dialog:

Storage Permission Dialog

/* Code to show this permission */
ActivityCompat.requestPermissions(MainActivity.this,
                new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.MANAGE_EXTERNAL_STORAGE},
                1);

And then I have to show the following one to get external storage manager permissions:

enter image description here

/* Code to show this permission */
final Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
final Uri uri = Uri.fromParts("package", activity.getApplicationContext().getPackageName(), null);
intent.setData(uri);
activity.startActivity(intent);

Is there something in the android system that shows user a dialog that bundles all the storage permissions together, or any android system flow that can be launched that guides user throughout both permission together? Having two different flows seems like a terrible amount of redundant logic that needs to be owned by apps. I was not able to find something like that, so asking here if I missed anything.

1 Answers

Is there something in the android system that shows user a dialog that bundles all the storage permissions together

Not in terms of MANAGE_EXTERNAL_STORAGE, as that is not a runtime permission that you handle via requestPermissions(). READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE can be requested together using requestPermissions().

or any android system flow that can be launched that guides user throughout both permission together?

No, sorry.

Note that I have not tried holding MANAGE_EXTERNAL_STORAGE without WRITE_EXTERNAL_STORAGE. Perhaps WRITE_EXTERNAL_STORAGE is not needed if you hold MANAGE_EXTERNAL_STORAGE. The documentation suggests that this might be the case.

Having two different flows seems like a terrible amount of redundant logic that needs to be owned by apps

Very few apps should be asking the user to grant MANAGE_EXTERNAL_STORAGE. And apparently Google really wants users to think through whether they should be granting that permission to your app.

Related