Permission denied when accessing /sdcard/nh_files due to Android 10 "scoped storage"
Issues with some Android 10 and 11 devices after flashing nethunter image:
- Scoped storage enforced, thus no access to storage outside own app folder (/data/data/com.offsec)
- Legacy storage support can be requested by app in Android 10 but no longer in 11
- I've added resquest for legacy storage to nethunter app
- I've added a fallback if that's not enough (runasroot)
- Legacy storage support works fine when nethunter-app is installed as user app
But:
- System apps are exempt from legacy storage access, even fallback solution fails
Impact:
- async file copy job fails and no config files, etc. will be copied to /sdcard/nh_files
- Kex or other apps that rely on config files do not work
- No db backup / restore
Workaround:
- Ship images with NetHunter app version -1
- Ask people to update NetHunter app (>= 202.2-pre2) first thing after reboot
- Updating makes app run in user app context
Solution:
- Move file location from /sdcard to /data/data/...
- Implement import / export feature using scoped store in nethunter-app to get files into, and out of, nethunter-app