Avoid sending two onSurfaceDestroyed() events
It has been observed that in some cases the onSurfaceDestroyed() event
could be sent twice, once from updateSurface and once from detach, while
onSurfaceCreated was only sent once. This is an issue since some
wallpapers (e.g. AndroidLiveWallpaperService subclasses) use
onSurfaceCreated and onSurfaceDestroyed to count the number of active
engines and pause or resume the wallpaper accordingly.
By creating a new flag mReportedSurfaceCreated, and setting it to true
right before onSurfaceCreated, and to false right before
onSurfaceDestroyed, and by checking its value before calling
onSurfaceDestroyed, we avoid calling onSurfaceDestroyed twice.
There is no need to add a check before calling onSurfaceCreated, the
mSurfaceCreated flag already avoids two consecutive onSurfaceCreated
calls.
Flag: com.android.window.flags.no_duplicate_surface_destroyed_events
Bug: 344461715
Test: treehugger, soak the flag and see if bug still exists
Change-Id: I0498d7689bd7636fb7c208f6fccdfba15df86440
2 files changed