destiny icon indicating copy to clipboard operation
destiny copied to clipboard

Multiuser support for Android

Open donpui opened this issue 2 years ago • 1 comments

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:

  1. Launch app, go to Settings, you should see destination /storage/emulated/0/Download
  2. Go to Android settings-> Add user or profile, mark Allow multiple
  3. Add Guest user and Switch to User
  4. Deploy app to Guest user and open it
  5. 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.

donpui avatar Jan 30 '23 06:01 donpui

@ewanas @wuan take a look to verify, especially kotlin code part. Maybe we you have better way how to improve with downloads directory.

donpui avatar Jan 30 '23 06:01 donpui