hwc2: Wait for RegisterCallback() from SF before sending events.

Surfaceflinger registers callback functions to be called from
hwcomposer on specific events like hotplug, vsync and screen refresh.
since surfaceflinger and hwcomposer are two different processes that
can run asynchronously. This causes hwcomposer to send an event to
surfaceflinger before surfaceflinger registers callback and results
in undefined behavior. So wait for callbacks to get registered by
surfaceflinger and send an event to surfacelinger.

Change-Id: I288e4d7dde8179cb4a119cdedad2877344c06dae
CRs-Fixed: 2085392
5 files changed