diff options
| author | 2020-04-23 19:04:22 -0700 | |
|---|---|---|
| committer | 2020-04-27 17:41:27 -0700 | |
| commit | 5690bde1e9192bc161ff6ae9fc80d8c4eaef6fd9 (patch) | |
| tree | 840c4ce1c5d00b75aa9a8a478ba580a7740f193b /services/surfaceflinger/SurfaceFlinger.cpp | |
| parent | 8e89c2ad0f2981f196307285d7d45b42c17356e4 (diff) | |
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
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 29434990f6..794e8a7a44 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -108,6 +108,7 @@ #include "LayerVector.h" #include "MonitoredProducer.h" #include "NativeWindowSurface.h" +#include "Promise.h" #include "RefreshRateOverlay.h" #include "RegionSamplingThread.h" #include "Scheduler/DispSync.h" @@ -1491,14 +1492,15 @@ status_t SurfaceFlinger::setDisplayBrightness(const sp<IBinder>& displayToken, f return BAD_VALUE; } - return schedule([=]() -> status_t { + return promise::chain(schedule([=] { if (const auto displayId = getPhysicalDisplayIdLocked(displayToken)) { return getHwComposer().setDisplayBrightness(*displayId, brightness); } else { ALOGE("%s: Invalid display token %p", __FUNCTION__, displayToken.get()); - return NAME_NOT_FOUND; + return promise::yield<status_t>(NAME_NOT_FOUND); } - }) + })) + .then([](std::future<status_t> task) { return task; }) .get(); } |