diff options
author | 2024-06-19 11:38:29 +0000 | |
---|---|---|
committer | 2024-09-18 11:47:51 +0000 | |
commit | 27db62fa49f662c5e81ca72f08b7e70d932e7fc6 (patch) | |
tree | 4884b91826818a91cc3e3176ce289eb44f8446e8 /services/inputflinger/InputThread.cpp | |
parent | ca1fefc36925b29ef2c2ad4050334b1e16db33c7 (diff) |
Apply input event profile to mitigate input latency of input threads
Bug: 347122505
Flag: com.android.input.flags.enable_input_policy_profile
Test: check the priority and latency of input thread in Perffeto
Change-Id: I428b9e718eace0bc39f1965d98475eebe9d3aaa5
Diffstat (limited to 'services/inputflinger/InputThread.cpp')
-rw-r--r-- | services/inputflinger/InputThread.cpp | 21 |
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 |