SF: fix binder thread priority
Add setMinSchedulerPolicy to all binder interfaces SF exposes.
It was missing from gui::ISurfaceComposer and
gui::IDisplayEventConnection.
Test: presubmit
Bug: 299378819
Change-Id: Ia0d99efa5a3bc58625c320d4df3c08bb597d2e38
diff --git a/services/surfaceflinger/Scheduler/EventThread.cpp b/services/surfaceflinger/Scheduler/EventThread.cpp
index edab7ec..9a55c94 100644
--- a/services/surfaceflinger/Scheduler/EventThread.cpp
+++ b/services/surfaceflinger/Scheduler/EventThread.cpp
@@ -38,6 +38,7 @@
#include <cutils/sched_policy.h>
#include <gui/DisplayEventReceiver.h>
+#include <gui/SchedulingPolicy.h>
#include <utils/Errors.h>
#include <utils/Trace.h>
@@ -218,6 +219,10 @@
return binder::Status::ok();
}
+binder::Status EventThreadConnection::getSchedulingPolicy(gui::SchedulingPolicy* outPolicy) {
+ return gui::getSchedulingPolicy(outPolicy);
+}
+
status_t EventThreadConnection::postEvent(const DisplayEventReceiver::Event& event) {
constexpr auto toStatus = [](ssize_t size) {
return size < 0 ? status_t(size) : status_t(NO_ERROR);
@@ -300,9 +305,14 @@
sp<EventThreadConnection> EventThread::createEventConnection(
EventRegistrationFlags eventRegistration) const {
- return sp<EventThreadConnection>::make(const_cast<EventThread*>(this),
- IPCThreadState::self()->getCallingUid(),
- eventRegistration);
+ auto connection = sp<EventThreadConnection>::make(const_cast<EventThread*>(this),
+ IPCThreadState::self()->getCallingUid(),
+ eventRegistration);
+ if (flags::misc1()) {
+ const int policy = SCHED_FIFO;
+ connection->setMinSchedulerPolicy(policy, sched_get_priority_min(policy));
+ }
+ return connection;
}
status_t EventThread::registerDisplayEventConnection(const sp<EventThreadConnection>& connection) {