fix: UAD crash when interacting with work profiles #448
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I finally had the opportunity to get my hands on an Android 12 phone to try to reproduce the crash reported by multiple people!
Here is the conclusion:
On recent Android devices, you can't interact with the user of the work profile. Any adb commands involving this user will fail with a
Shell does not have permission to access user ${user}
.The crash: when the option
affect all the users of the phone
was on, UAD changed the state of the packages (in UAD memory) for all users as soon as the adb command for the user 0 succeed (yeah not great). Obviously, since no packages for the work profiles user were loaded in memory, UAD crashed by trying to changing non-existent data.This pull request only fix the crash by preventing package state change in UAD before the associated command succeed (that sounds logic. I don't know why I didn't code this in the first place).
This means UAD will still try to mess up with the work profile user but without crashing or warning the user in the GUI it failed.
Next step: inform the user in the GUI.
Closes #413, #386, #377