Reduce synchronized lock scope.

The lock was introduced earlier to prevent race conditions between
setting the visibility and configuration. However, holding the lock
for the entire method leads to an increase in the frame time.

This changelist reduces the scope of the lock to cover the core
logic where this condition applies.

Change-Id: Ia97b3680f730264c10ff5067e4f21180cfb2202e
Fixes: 67010772
Test: go/wm-smoke
1 file changed