Merge "Make onBeforeUserSwitching calls synchronous." into main