Added: Add support for MANAGE_EXTERNAL_STORAGE when targeting targetSdkVersion 30

Termux will now automatically request legacy `WRITE_EXTERNAL_STORAGE` or `MANAGE_EXTERNAL_STORAGE` permissions if targeting targetSdkVersion `30` (android `11`) and running on sdk `30` (android `11`) and higher when `termux-setup-storage` is run.

Functions have been added to `PermissionUtils` to automatically check and request either permission depending on app `targetSdkVersion` and android version. Functions have been added to `PackagUtils` to get `requestLegacyExternalStorage` value from app manifest if added. If legacy storage is possible, then it must be set to `true`. Check `PermissionUtils.checkAndRequestLegacyOrManageExternalStoragePermission()`, `PermissionUtils.isLegacyExternalStoragePossible()` and `PermissionUtils.checkIfHasRequestedLegacyExternalStorage()` for details.
This commit is contained in:
agnostic-apollo
2021-10-21 23:16:06 +05:00
parent 32dd7eab03
commit 9eeb2babd7
5 changed files with 352 additions and 21 deletions

View File

@@ -41,6 +41,7 @@
<string name="error_failed_to_request_permissions">Failed to request permissions with request code %1$d: %2$s</string>
<string name="error_attempted_to_check_for_permissions_not_requested">Attempted to check for permissions that have not been requested in app manifest: %1$s</string>
<string name="error_attempted_to_ask_for_permissions_not_requested">Attempted to ask for permissions that have not been requested in app manifest: %1$s</string>
<string name="error_has_not_requested_legacy_external_storage">The \"%1$s\" package is targeting targetSdkVersion %2$d and is running on android sdk %3$d but has not set requestLegacyExternalStorage to true in app manifest"</string>
@@ -101,6 +102,9 @@
<string name="action_cancel">Cancel</string>
<string name="action_save_to_file">Save To File</string>
<string name="msg_storage_permission_granted_on_request">"The storage permission granted by user on request"</string>
<string name="msg_storage_permission_not_granted_on_request">"The storage permission not granted by user on request"</string>
<!-- Launcher Icons -->