summaryrefslogtreecommitdiff
path: root/services/inputflinger/InputThread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'services/inputflinger/InputThread.cpp')
-rw-r--r--services/inputflinger/InputThread.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/services/inputflinger/InputThread.cpp b/services/inputflinger/InputThread.cpp
index e74f258168..449eb45b4b 100644
--- a/services/inputflinger/InputThread.cpp
+++ b/services/inputflinger/InputThread.cpp
@@ -16,8 +16,14 @@
#include "InputThread.h"
+#include <android-base/logging.h>
+#include <com_android_input_flags.h>
+#include <processgroup/processgroup.h>
+
namespace android {
+namespace input_flags = com::android::input::flags;
+
namespace {
// Implementation of Thread from libutils.
@@ -43,6 +49,11 @@ InputThread::InputThread(std::string name, std::function<void()> loop, std::func
: mName(name), mThreadWake(wake) {
mThread = sp<InputThreadImpl>::make(loop);
mThread->run(mName.c_str(), ANDROID_PRIORITY_URGENT_DISPLAY);
+ if (input_flags::enable_input_policy_profile()) {
+ if (!applyInputEventProfile()) {
+ LOG(ERROR) << "Couldn't apply input policy profile for " << name;
+ }
+ }
}
InputThread::~InputThread() {
@@ -63,4 +74,14 @@ bool InputThread::isCallingThread() {
#endif
}
+bool InputThread::applyInputEventProfile() {
+#if defined(__ANDROID__)
+ return SetTaskProfiles(mThread->getTid(), {"InputPolicy"});
+#else
+ // Since thread information is not available and there's no benefit of
+ // applying the task profile on host, return directly.
+ return true;
+#endif
+}
+
} // namespace android \ No newline at end of file