Avoid ImageWallpaper IllegalStateException

It's possible that WallpaperService calls surface.release() between
lockCanvas and unlockCanvasAndPost, which gives the exception from
b/337287154 (IllegalStateException: surface has already been released).

To avoid that, we use a second lock that synchronizes the drawing and
the onSurfaceDestroyed method. This makes sure that we are done drawing
(or haven't started drawing) when we exit onSurfaceDestroyed().

Flag: aconfig com.android.systemui.fix_image_wallpaper_crash_surface_already_released DEVELOPMENT
Bug: 337287154
Test: treehugger
Test: crash cluster will be monitored
Change-Id: I3579e928fa9a115ecad7fa1e9fc4f15a0dc5ea68
2 files changed