Fix deadlock when transitioning to vr flinger

If we were unlucky with the timing when switching to vr flinger we would
sometimes deadlock. The vr dispatch thread would request the display
from surface flinger, locking mStateLock in the process. mStateLock was
being held by the surface flinger main thread, which was processing a
previous request to switch to vr flinger. The main thread was trying to
connect to the vr hardware composer service, which sent a request to the
vr dispatch thread as part of its initialization, leading to the
deadlock.

The deadlock is easily fixed by posting a message to request the vr
flinger switch to the surface flinger main thread, instead of doing it
on the vr dispatch thread.

Bug: 66916578

Test: Confirmed I can still get into/out of vr flinger on
Marlin. There's no longer code to acquire mStateLock in the vr dispatch
thread, so the deadlock is no longer possible.

Change-Id: I3de5476f698ed798f6b9afe927cc733f0f38c56e
1 file changed