Ensure detached children aren't parented to new SurfaceControl

The previous CL called preserveSurfaces when detachChildren were called
to ensure a new SurfaceControl would get created. However, the check for
when reparenting old children to the new surface was incorrect so
children from the destroying surface would become children of the new
surface.

This was because mChildrenDetached was set to false when the new surface
was created. The children were reparented after the new surface was
created so mChildrenDetached would always be false.

Instead, add a flag to the WindowSurfaceController when children are
detached. This way we know which WindowSurfaceController has detached
children and shouldn't reparent its children to the new surface.

Test: Close and open apps with SV quickly. Child surfaces are cleaned up
Fixes: 155694905
Bug: 157439199
Change-Id: I5f20f159bdc86c90e972400cd356df771d926fcc
2 files changed