Re-parent decor SurfaceControl to task's if detached.
In cases where the app process dies (e.g. crashes, explicitly killed,
etc.), it is possible that WindowDecorations, given they are part of
Shell process, will persist in limbo attached to a dead task leash. On a
new task launch with a new task SurfaceControl, since
WindowDecorViewModel still holds a reference to the old decoration (we
never get a onTaskClosed transition), it acts as if nothing is wrong and
updates the existing decoration accordingly, not knowing it is no longer
visible to the user.
This does a check when we get shell transition call and check its
taskSurface, and make sure it matches the one that the decoration has.
If it is no longer the same, we then reparent the decoration's
SurfaceControl to the new taskSurface.
Bug: 435090772
Test: Manual. Crash an app explicitly and then relaunch it, and see
window controls still showing.
Flag: EXEMPT bugfix
Change-Id: Iec1fdcfeec2fbaa14c6b8208ad8a095378787146
5 files changed