Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f8fcb069 authored by Jerry Chang's avatar Jerry Chang Committed by Android (Google) Code Review
Browse files

Merge "Apply input event profile to mitigate input latency of input threads" into main

parents 35d16c1f 27db62fa
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -192,3 +192,12 @@ flag {
  description: "Prevents touchpad gesture changing window focus."
  bug: "364460018"
}

flag {
  name: "enable_input_policy_profile"
  namespace: "input"
  description: "Apply input policy profile for input threads."
  bug: "347122505"
  is_fixed_read_only: true
}
+1 −0
Original line number Diff line number Diff line
@@ -217,6 +217,7 @@ cc_defaults {
        "libcutils",
        "libinput",
        "liblog",
        "libprocessgroup",
        "libstatslog",
        "libutils",
    ],
+21 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ private:
    std::string mName;
    std::function<void()> mThreadWake;
    sp<Thread> mThread;
    bool applyInputEventProfile();
};

} // namespace android