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

Commit adac97fa authored by Hsin-Yi Chen's avatar Hsin-Yi Chen
Browse files

Use CLOCK_BOOTTIME for default sensor implementation

The sensor implementation used to generate periodic signals according to
CLOCK_REALTIME. The clock can be adjusted by user or synchronization
service and results in wrong period. This commit changes it to
CLOCK_BOOTTIME which is monotonic.

Test: atest VtsHalSensorsV2_0TargetTest
Test: atest VtsHalSensorsV2_1TargetTest
Test: atest CtsSensorTestCases
Bug: 194030777
Change-Id: Iac39c93d6d2518b1abe8fc07fd695b9bb2cf30a5
parent 101c9db5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ void Sensor::run() {
            });
        } else {
            timespec curTime;
            clock_gettime(CLOCK_REALTIME, &curTime);
            clock_gettime(CLOCK_BOOTTIME, &curTime);
            int64_t now = (curTime.tv_sec * kNanosecondsInSeconds) + curTime.tv_nsec;
            int64_t nextSampleTime = mLastSampleTimeNs + mSamplingPeriodNs;

+1 −1
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ void Sensor::run() {
            });
        } else {
            timespec curTime;
            clock_gettime(CLOCK_REALTIME, &curTime);
            clock_gettime(CLOCK_BOOTTIME, &curTime);
            int64_t now = (curTime.tv_sec * kNanosecondsInSeconds) + curTime.tv_nsec;
            int64_t nextSampleTime = mLastSampleTimeNs + mSamplingPeriodNs;