LeastAuthority / destiny

Destiny – Cross-platform Magic Wormhole graphical client
MIT License
249 stars 14 forks source link

Multiuser support for Android #231

Open donpui opened 1 year ago

donpui commented 1 year ago

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

donpui commented 1 year ago

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