[path_provider] Android: Support multiple external storage options.#966
[path_provider] Android: Support multiple external storage options.#966ened wants to merge 1 commit intoflutter:masterfrom
Conversation
|
@ened can we get this merged please? |
|
@dnfield can we get this merged please? |
|
Can we get any tests for this? /Cc @amirh |
|
This is great, thanks for the contribution! As we currently don't have a harness for testing the platform side of plugins, current and new features are not properly covered by tests. The test harness work is tracked in flutter/flutter#10824 and flutter/flutter#26080, your feedback on the testing work will be really appreciated (will it properly support the testing needs of this PR?) some design details should be available on flutter/flutter#10824 soon(contributions to that effort are welcomed!). Would you mind re-opening this PR with e2e tests once a test harness is ready? |
Most Android phones have, despite a single hardware storage, an internal/external partition layout.
Additionally, some phones support external SD cards for storing files.
Apps may store files onto the internal and external storage folders. For external storage, permissions can not be strongly enforced (hence Android's requirement for the WRITE_EXTERNAL_STORAGE permission) - yet if an App stores files into the app-specific folder, that folder can be cleaned up when an App is uninstalled.
The path_provider was missing 3 parts to work this out which have been addressed by the PR:
/storage/emulated/0is different than/storage/emulated/0/Android/data/.... Developers should by default use the latter because it should be cleaned up automatically by the Android system when an App is uninstalledMusic,Photos,Podcasts. Developers can now request this type in the API.Screenshot on Pixel 2:

Screenshot on Sony XZ performance w/ additional SD card inserted:
