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

Commit 8a64a9e7 authored by Yifan Hong's avatar Yifan Hong Committed by android-build-merger
Browse files

Merge "android.frameworks.sensorservice@1.0: Looper thread SCHED_FIFO" into oc-dev am: 6d62c84b

am: 7374d160

Change-Id: Ie266fe4018b189b0d257d9fee546f93671cf6d01
parents b8bb91d1 7374d160
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -22,12 +22,14 @@

#include "SensorManager.h"

#include <sched.h>

#include <thread>

#include "EventQueue.h"
#include "DirectReportChannel.h"
#include "utils.h"

#include <thread>

namespace android {
namespace frameworks {
namespace sensorservice {
@@ -131,6 +133,14 @@ sp<::android::Looper> SensorManager::getLooper() {
        std::condition_variable looperSet;

        std::thread{[&mutex = mLooperMutex, &looper = mLooper, &looperSet] {

            struct sched_param p = {0};
            p.sched_priority = 10;
            if (sched_setscheduler(0 /* current thread*/, SCHED_FIFO, &p) != 0) {
                LOG(WARNING) << "Could not use SCHED_FIFO for looper thread: "
                        << strerror(errno);
            }

            std::unique_lock<std::mutex> lock(mutex);
            looper = Looper::prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS /* opts */);
            lock.unlock();