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

Commit d6d2c7eb authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Only prioritize critical input threads" into main

parents 7f347cc1 f53fa6b5
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -44,7 +44,8 @@ public:
    InputFilterThread(std::shared_ptr<IInputThreadCallback> callback) : mCallback(callback) {
    InputFilterThread(std::shared_ptr<IInputThreadCallback> callback) : mCallback(callback) {
        mLooper = sp<Looper>::make(/*allowNonCallbacks=*/false);
        mLooper = sp<Looper>::make(/*allowNonCallbacks=*/false);
        mThread = std::make_unique<InputThread>(
        mThread = std::make_unique<InputThread>(
                "InputFilter", [this]() { loopOnce(); }, [this]() { mLooper->wake(); });
                "InputFilter", [this]() { loopOnce(); }, [this]() { mLooper->wake(); },
                /*isInCriticalPath=*/false);
    }
    }


    ndk::ScopedAStatus finish() override {
    ndk::ScopedAStatus finish() override {
+4 −3
Original line number Original line Diff line number Diff line
@@ -45,11 +45,12 @@ private:


} // namespace
} // namespace


InputThread::InputThread(std::string name, std::function<void()> loop, std::function<void()> wake)
InputThread::InputThread(std::string name, std::function<void()> loop, std::function<void()> wake,
                         bool isInCriticalPath)
      : mName(name), mThreadWake(wake) {
      : mName(name), mThreadWake(wake) {
    mThread = sp<InputThreadImpl>::make(loop);
    mThread = sp<InputThreadImpl>::make(loop);
    mThread->run(mName.c_str(), ANDROID_PRIORITY_URGENT_DISPLAY);
    mThread->run(mName.c_str(), ANDROID_PRIORITY_URGENT_DISPLAY);
    if (input_flags::enable_input_policy_profile()) {
    if (input_flags::enable_input_policy_profile() && isInCriticalPath) {
        if (!applyInputEventProfile()) {
        if (!applyInputEventProfile()) {
            LOG(ERROR) << "Couldn't apply input policy profile for " << name;
            LOG(ERROR) << "Couldn't apply input policy profile for " << name;
        }
        }
+2 −1
Original line number Original line Diff line number Diff line
@@ -993,7 +993,8 @@ status_t InputDispatcher::start() {
        return ALREADY_EXISTS;
        return ALREADY_EXISTS;
    }
    }
    mThread = std::make_unique<InputThread>(
    mThread = std::make_unique<InputThread>(
            "InputDispatcher", [this]() { dispatchOnce(); }, [this]() { mLooper->wake(); });
            "InputDispatcher", [this]() { dispatchOnce(); }, [this]() { mLooper->wake(); },
            /*isInCriticalPath=*/true);
    return OK;
    return OK;
}
}


+1 −1
Original line number Original line Diff line number Diff line
@@ -41,7 +41,7 @@ ThreadedBackend<Backend>::ThreadedBackend(Backend&& innerBackend)
      : mBackend(std::move(innerBackend)),
      : mBackend(std::move(innerBackend)),
        mTracerThread(
        mTracerThread(
                "InputTracer", [this]() { threadLoop(); },
                "InputTracer", [this]() { threadLoop(); },
                [this]() { mThreadWakeCondition.notify_all(); }) {}
                [this]() { mThreadWakeCondition.notify_all(); }, /*isInCriticalPath=*/false) {}


template <typename Backend>
template <typename Backend>
ThreadedBackend<Backend>::~ThreadedBackend() {
ThreadedBackend<Backend>::~ThreadedBackend() {
+2 −2
Original line number Original line Diff line number Diff line
@@ -28,8 +28,8 @@ namespace android {
 */
 */
class InputThread {
class InputThread {
public:
public:
    explicit InputThread(std::string name, std::function<void()> loop,
    explicit InputThread(std::string name, std::function<void()> loop, std::function<void()> wake,
                         std::function<void()> wake = nullptr);
                         bool isInCriticalPath);
    virtual ~InputThread();
    virtual ~InputThread();


    bool isCallingThread();
    bool isCallingThread();
Loading