summaryrefslogtreecommitdiff
path: root/services/inputflinger/InputThread.cpp
diff options
context:
space:
mode:
author Xin Li <delphij@google.com> 2025-03-10 09:50:35 -0700
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2025-03-10 09:50:35 -0700
commit376c3cd45e7af8eeb8a4c13b4a01d65b44069c5d (patch)
treebe5796e7b3cc6383caf7987ab194e8d4a2ce9c20 /services/inputflinger/InputThread.cpp
parent67b445a490a71e01b870186315f54344b1f96466 (diff)
parent32ab7738564ffb5f327d2e70f7a8286584f7153f (diff)
Merge "Merge 25Q1 (ab/BP1A.250305.020) to AOSP main" into main
Diffstat (limited to 'services/inputflinger/InputThread.cpp')
-rw-r--r--services/inputflinger/InputThread.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/services/inputflinger/InputThread.cpp b/services/inputflinger/InputThread.cpp
index 449eb45b4b..7cf4e397f9 100644
--- a/services/inputflinger/InputThread.cpp
+++ b/services/inputflinger/InputThread.cpp
@@ -26,6 +26,16 @@ namespace input_flags = com::android::input::flags;
namespace {
+bool applyInputEventProfile(const Thread& thread) {
+#if defined(__ANDROID__)
+ return SetTaskProfiles(thread.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
+}
+
// Implementation of Thread from libutils.
class InputThreadImpl : public Thread {
public:
@@ -45,12 +55,13 @@ private:
} // namespace
-InputThread::InputThread(std::string name, std::function<void()> loop, std::function<void()> wake)
- : mName(name), mThreadWake(wake) {
+InputThread::InputThread(std::string name, std::function<void()> loop, std::function<void()> wake,
+ bool isInCriticalPath)
+ : 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()) {
+ mThread->run(name.c_str(), ANDROID_PRIORITY_URGENT_DISPLAY);
+ if (input_flags::enable_input_policy_profile() && isInCriticalPath) {
+ if (!applyInputEventProfile(*mThread)) {
LOG(ERROR) << "Couldn't apply input policy profile for " << name;
}
}
@@ -74,14 +85,4 @@ 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
+} // namespace android