Release SurfaceControlViewHost used to render workspace preview when fragment is destroyed before the clean up callback is returned

When wallpaper requests launcher to render workspace preview through content provider call, Launcher returns a callback to release the SurfaceControlViewHost used to host this preview as part of the return result. In the current implementation, Wallpaper calls this clean up method when the fragment of the SurfaceView is destroyed. However this can happen before the content provider call is returned when the user fast switches between wallpaper and grid tabs. The solution here is to flag "needsToCleanUp" in the workspace surface callback and call clean up upon the return of the content provider call if the fragment is already destroyed at that point.

Test: fast switching between wallpaper and grid tabs, no matter how fast I switch and how long I do that, the phone no long becomes slow
Bug: 155365052
Change-Id: Ibd688ed9ff8491b1be0222a798daecb69c2e488f
2 files changed