Make UserTrackerImpl use UserSwitchObserver instead of broadcast.
UserTrackerImp was listening to ACTION_USER_SWITCHED broadcast to do stuff that makes changes on the screen for a user switch. But since the broadcast is async (there is no way to tell back the broadcaster that the reciver has finished it's work), many times those UI changes were happening "after" the switch, whereas they should be done "while" the switch is happening, i.e. when the screen is frozen and UserSwithingDialog is visible. In order to achive this, UserSwitchObserver's onUserSwitching method should be used to do things while the screen is frozen for the user switch. This CL makes UserTrackerImpl use UserSwitchObserver instead of ACTION_USER_SWITCHED and provides onUserChanging method (in addition to already existing onUserChanged method) to it's subscribers. So that the subscribers can decide when their code should run, during or after the switch. This CL also moves work done in UserRepository from onUserChanged to onUserChanging because user pillar shown on top right of the tablet's screen was updating after the user switch. Now it updates during the switch, while the screen is frozen. Bug: 249527131 Bug: 265068243 Test: Manual visual test by adding a 5s delay to ACTION_USER_SWITCHED broadcast to make the jank consistent, and verifying the jank is gone after the fix. Test: atest UserTrackerImplTest Test: atest UserTrackerImplReceiveTest Test: atest UserRepositoryImplTest Change-Id: Ica2be8cc434cea4bb526a51eeb8171765f461172 Merged-In: Ica2be8cc434cea4bb526a51eeb8171765f461172
Loading
Please register or sign in to comment