hwc2: add locks for callback functions

In case surfaceflinger is killed, the function pointer of
RegisterCallback will be null. If the system is still handling
callback function tasks, it could have the chance to access null
pointer and result in a crash. This change adds locks for
callback functions to ensure the tasks are finished then we can
assign null pointer via RegisterCallback.

Bug: 150223963
Test: no crash while surfaceflinger is killed
Merged-In: I3b29c2e17f3a8968348d0d0a29feaca287d4c72c
Change-Id: I3b29c2e17f3a8968348d0d0a29feaca287d4c72c
3 files changed