Make onBeforeUserSwitching calls synchronous.

Otherwise, it's not guaranteed we call
lockDeviceNowAndWaitForKeyguardShown after SystemUI's UserTrackerImpl
has updated their internal source of truth about the current user.
And this sometimes causes the keyguard not being shown in case switching
from a user that has their screen lock set to "None" to a user with
credentials (i.e. Pattern/Pin/Password). Becase the keyguard would think
the current user was the previous user with their lock screen disabled,
and skip showing the keyguard, which is incorrect.

This CL fixes that issue by waiting for onBeforeUserSwitching calls to
complete before moving on.

Bug: 369294724
Bug: 331853529
Bug: 360838273

Test: atest UserTrackerImplTest
Test: atest UserControllerTest
Flag: EXEMPT bugfix
Change-Id: Ibb9b757f1385cb74d5f69d9ce3453ef2e9f4c71e
1 file changed