What Allows an App in Android to Upload Data Without Asking
The majority of apps that crave shared storage access can follow the best practices for sharing media files and sharing non-media files. Nonetheless, some apps have a core use case that requires wide access of files on a device, but cannot do and then efficiently using the privacy-friendly storage best practices. Android provides a special app access chosen All files admission for these situations.
For example, an anti-virus app's primary employ example might require regular scanning of many files across different directories. If this scanning requires repeated user interactions to select directories using the system file picker, it may provide a poor user experience. Other use cases—such as file manager apps, fill-in and restore apps, and document management apps—may crave similar considerations.
Asking All files admission
An app can request All files admission from the user by doing the following:
- Declare the
MANAGE_EXTERNAL_STORAGEpermission in the manifest. - Apply the
ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSIONintent action to direct users to a system settings page where they tin enable the post-obit option for your app: Allow access to manage all files.
To determine whether your app has been granted the MANAGE_EXTERNAL_STORAGE permission, call Environment.isExternalStorageManager().
Operations that MANAGE_EXTERNAL_STORAGE allows
The MANAGE_EXTERNAL_STORAGE permission grants the following:
-
Read and write access to all files within shared storage.
-
Admission to the contents of the
MediaStore.Filestable. -
Access to the root directory of both the USB on-the-become (OTG) bulldoze and the SD card.
-
Write access to all internal storage directories, except for
/Android/data/,/sdcard/Android, and most subdirectories of/sdcard/Android. This write access includes straight file path access.Apps that are granted this permission still cannot admission the app-specific directories that belong to other apps because these directories appear as subdirectories of
Android/data/on a storage volume.
When an app has the MANAGE_EXTERNAL_STORAGE permission, it can admission these boosted files and directories using either the MediaStore API or direct file paths. When yous use the Storage Admission Framework, however, yous tin only admission a file or directory if you could do then without having the MANAGE_EXTERNAL_STORAGE permission.
Invoke another app's storage management activity
On Android 12 (API level 31) and higher, apps that take both the MANAGE_EXTERNAL_STORAGE permission and the QUERY_ALL_PACKAGES permission—such as file direction apps—can employ the getManageSpaceActivityIntent() to send users to another app's custom space management activity.
The getManageSpaceActivityIntent() method takes in a package name and a request code, and information technology returns one of the following:
- A
PendingIntent, if the app with the specified package name has defined a custom "manage infinite" activity. The file management app that chosen thegetManageSpaceActivityIntent()method tin can then invoke the returned intent to ship users to the custom activity. -
nothing, if the app with the specified package name doesn't ascertain a "manage space" activity.
Enable MANAGE_EXTERNAL_STORAGE for testing
To explore how the MANAGE_EXTERNAL_STORAGE permission affects your app, you can enable the permission for testing purposes. To exercise so, run the following command on the motorcar that's connected to your test device:
adb beat appops set --uid PACKAGE_NAME MANAGE_EXTERNAL_STORAGE allow
Google Play notice
This section provides a notice for developers who publish apps on Google Play.
To limit broad access to shared storage, the Google Play store has updated its policy to evaluate apps that target Android 11 (API level 30) or higher and request "All files access" through the MANAGE_EXTERNAL_STORAGE permission. This policy takes effect in May 2021.
When your app targets Android 11 or higher, and it declares the MANAGE_EXTERNAL_STORAGE permission, Android Studio shows the lint alarm that appears in figure 1. This warning reminds you lot that "the Google Play store has a policy that limits usage of" the permission.
MANAGE_EXTERNAL_STORAGE permission. You should request the MANAGE_EXTERNAL_STORAGE permission just when your app cannot effectively make utilise of the more privacy-friendly APIs, such as Storage Access Framework or the Media Shop API. Additionally, the app's usage of the permission must fall within permitted uses, and must be directly tied to the core functionality of the app. If your app includes a apply case that's similar to the following examples, information technology's likely to be immune to request the MANAGE_EXTERNAL_STORAGE permission:
- File managers
- Fill-in and restore apps
- Anti-virus apps
- Document direction apps
- On-device file search
- Disk and file encryption
- Device-to-device data migration
Source: https://developer.android.com/training/data-storage/manage-all-files
0 Response to "What Allows an App in Android to Upload Data Without Asking"
Post a Comment