SF: Defer setDisplayBrightness to Binder thread
setDisplayBrightness blocks for a long time so cannot run on the main
thread. Keep display lookup on the main thread, but return a deferred
future to the Binder thread and run it there.
Bug: 154202427
Bug: 123715322
Test: systrace with backdoor to set brightness
Change-Id: I88e60c95db5fdcaa1bf5ebb9711e3bf5ab6539a1
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h
index cfa2193..b7e9f3a 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.h
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.h
@@ -18,6 +18,7 @@
#define ANDROID_SF_HWCOMPOSER_H
#include <cstdint>
+#include <future>
#include <memory>
#include <mutex>
#include <optional>
@@ -163,7 +164,7 @@
DisplayedFrameStats* outStats) = 0;
// Sets the brightness of a display.
- virtual status_t setDisplayBrightness(DisplayId displayId, float brightness) = 0;
+ virtual std::future<status_t> setDisplayBrightness(DisplayId displayId, float brightness) = 0;
// Events handling ---------------------------------------------------------
@@ -305,7 +306,7 @@
uint8_t componentMask, uint64_t maxFrames) override;
status_t getDisplayedContentSample(DisplayId displayId, uint64_t maxFrames, uint64_t timestamp,
DisplayedFrameStats* outStats) override;
- status_t setDisplayBrightness(DisplayId displayId, float brightness) override;
+ std::future<status_t> setDisplayBrightness(DisplayId displayId, float brightness) override;
// Events handling ---------------------------------------------------------