Implement auto-restart on display move

Some  apps cache density in a place independent from
activity lifecycle, so when they move between displays, it's not
refreshed to the latest value, which makes the UI too big/small
on the new display.

To fix this, this change introduces a new per-app override that
automatically restarts apps when they move between displays.

The existing restartProcessIfVisible() doesn't work as is in this
new scenario as in our case processes are restarted during
display move, where a lot of other changes happen such as config
changes and lifecycle events, so this change makes some
improvements in the function:
- Lifecycle events are async, so the checks of mState and
 mHaveState are removed.
- Visibility can be toggled while the transition for restart is
 in the transition queue, so the visibility check to
 startCollectOrQueue() is moved.

Flag: com.android.window.flags.enable_auto_restart_on_display_move
Bug: 427878712
Test: AppCompatDisplayCompatTests
Test: AppCompatDisplayOverridesTest
Change-Id: Iff520ea5ee864d6045673f0e6cc204a913662866
9 files changed