Toggle dim according to progress of recents animation

The major problem when running recents animation:
 - Initial: canAffectSystemUiFlags=false by setTransientLaunch
 - Drag the app task a bit: canAffectSystemUiFlags=true
   by setRecentsAppBehindSystemBars
 - Drag the app task to original position to exit recents
   animation: canAffectSystemUiFlags=false
   by setRecentsAppBehindSystemBars

If canAffectSystemUiFlags is not true (default),
DisplayArea#prepareSurface will try to cancel dim. But if there is
a valid window to request dim, it will cause endless animation loop
between applyDim and resetDimStates and the dim is never visible.

The state can be corrected by resetting canAffectSystemUiFlags to
true when the transient(recents) transition is finished.

Also instead of searching canAffectSystemUiFlags on every
prepareSurface, it is more efficient to only check if a dimmer can
request to show according the status of a playing recents transition.
This would also fix ugly animation when swiping a translucent task
to home that the dimmer covers home during entire animation.

Also see:
 Reset dim in legacy: I6e275b778da4cb7aeda3b3483a14f5f9d2796e44
 Set flag with shell: I552eea738aed5566eb897bb9c68507e83ac43e1d

Fix: 286955271
Test: atest TransitionTests#testTransientLaunch

Change-Id: I5843abb925eb2466be34e1dcb96d4cfd83e4dc8a
6 files changed