Fix UiAutomator state variable to prevent blocking when restarting UiAutomator