Force stop a user before removing it in perf tests.
Removing users immediately after starting them was causing system
crashes on other parts of the Android. In removeUsers() it was waited
for ACTION_MEDIA_MOUNTED before removing started users. But it was
deciding whether a user has been started by checking if
ACTION_USER_STARTED broadcast was received for that user.
Depending on a broadcast was wrong because it might not have been
received in time. Changing that part with UM.isUserRunning API would
fix the issue but this time since the user might be started and
stopped multiple times during the tests, checking for
ACTION_MEDIA_MOUNTED was making the code too complicated since it
could be received multiple times.
This CL simply force stops the user before removing it to solve the
problem.
Bug: 262407660
Bug: 236229621
Bug: 233240023
Test: atest UserLifecycleTests
Change-Id: Ica715e88d88761d969d02c761ea845d5b82b17e9
2 files changed