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

Commit 71906aac authored by Yifan Hong's avatar Yifan Hong Committed by Iliyan Malchev
Browse files

android.frameworks.sensorservice@1.0: Looper thread SCHED_FIFO

Looper thread uses SCHED_FIFO with a priority 10.

Test: sensor works (sanity checks with camera app), logcat
      doesn't show SCHED_FIFO could not be used

b/34386025 [Treble] Identify and fix Binder usage by camera HALs that isn't NDK-based
b/35219747 [Treble] Figure out the new interface between camera and sensor
b/36651814 [QCOM Treble] [REDACTED] Camera HAL uses Binder
b/36651420 [QCOM Treble] [REDACTED] location daemon uses Binder

Change-Id: I0f236a77cccdc8d67a933daf7d5046947c82a3cf
parent 99dfb8a6
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();