AppWindowToken: Guard against null SurfaceControl in prepareSurfaces

It seems this code was written with the assumption that if prepareSurfaces
is called, then we must be attached to the hiearchy and we must have
a valid surface. As always though, the story runs deeper. We can actually
call AppWindowToken#prepareSurfaces within the scope of AppWindowToken#removeImmediately.
This transpires via these steps:
     1. AppWindowToken removes children.
     2. Child windowstate calls WMS#postWindowRemoveCleanupLocked
     3. WMS immediately performs surface placement.
     4. Surface placement leads to AppWindowToken#prepareSurfaces.

This means that prepareSurfaces can be called after we have set mSurfaceControl
to null but before the parent has removed us from its list, and that the assumption
that the control must be non-null in prepareSurfaces was false.

Bug: 123606376
Test: Makes one of them crash less
Change-Id: Ic2985cb6f2a31613de5942926b036fd24a91e68a
1 file changed