SF: Modernize task scheduling API

Replace postMessageAsync and postMessageSync with schedule(<lambda>)
returning std::future<T>, where T is the return type of the lambda,
for an ergonomic and less error-prone API.

Rewrite the hand-rolled synchronization logic in captureScreenCommon.

Bug: 123715322
Bug: 134772048
Test: go/wm-smoke
Test: screencap
Test: libsurfaceflinger_unittest
Change-Id: I02dc4114b61fb175463941ab5890e3127dd57a11
9 files changed