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
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:46880bdb31bca108467a0ccb971aaad6aa46b5e1)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:064e5b8289be9bc79628be3fc9000b3dd624ec33)
Merged-In: Ibb9b757f1385cb74d5f69d9ce3453ef2e9f4c71e
Change-Id: Ibb9b757f1385cb74d5f69d9ce3453ef2e9f4c71e
1 file changed