destiny
destiny copied to clipboard
Multiuser support for Android
Fixing issue #192
Used native android function to get user device uniq number: https://developer.android.com/reference/android/os/UserManager#getSerialNumberForUser(android.os.UserHandle)
Couldn't find native flutter/dart plugin method. Path_provider PR for Android downloads is closed: https://github.com/flutter/plugins/pull/4559
Additionally jumped on interested bug, with get_it and setting download path. First time loading app worked, however, on second load (after app removed from process) it failed: get_it_impl.dart failed assertion instanceFactory.isReady
. Making wait while all registry values are collected, helped to solved and avoid app crash.
I haven't added any tests for download paths, as basically would need to mockup different users profiles: (requires either time either ideas, how to automate this case)
Simple testing scenario:
- Launch app, go to Settings, you should see destination /storage/emulated/0/Download
- Go to Android settings-> Add user or profile, mark Allow multiple
- Add Guest user and Switch to User
- Deploy app to Guest user and open it
- Go to Settings and check destination: /storage/emulated/10/Download Additionally, worth to close/kill app and launch again to check if it opens.
Code Review Checklist
- [x] Description accurately reflects what changes are being made.
- [x] Description explains why the changes are being made (or references an issue containing one).
- [x] The PR appropriately sized.
- [ ] New code has enough tests.
- [x] New code has enough documentation to answer "how do I use it?" and "what does it do?".
- [x] Existing documentation is up-to-date, if impacted.
@ewanas @wuan take a look to verify, especially kotlin code part. Maybe we you have better way how to improve with downloads directory.