Addressing test flakiness related to triggerBackEventByGesture

Avoid closing the VirtualInputDevice too soon, as this may result in
lost write events. The device must only be closed once the test has
finished.

Flag: EXEMPT bugfix
Bug: 417550660
Test: atest BackGestureInvokedTest BackNavigationLegacyGestureTest
OnBackInvokedCallbackGestureTest

Change-Id: I121c7d6a4480f2ce1de2772dd9285963665d2d6f
4 files changed