| 1333 | } |
| 1334 | |
| 1335 | void Application::checkAutoLock(crl::time lastNonIdleTime) { |
| 1336 | if (!_domain->local().hasLocalPasscode() |
| 1337 | || passcodeLocked() |
| 1338 | || !someSessionExists()) { |
| 1339 | _shouldLockAt = 0; |
| 1340 | _autoLockTimer.cancel(); |
| 1341 | return; |
| 1342 | } else if (!lastNonIdleTime) { |
| 1343 | lastNonIdleTime = this->lastNonIdleTime(); |
| 1344 | } |
| 1345 | |
| 1346 | checkLocalTime(); |
| 1347 | const auto now = crl::now(); |
| 1348 | const auto shouldLockInMs = settings().autoLock() * 1000LL; |
| 1349 | const auto checkTimeMs = now - lastNonIdleTime; |
| 1350 | if (checkTimeMs >= shouldLockInMs |
| 1351 | || (_shouldLockAt > 0 |
| 1352 | && now > _shouldLockAt + kAutoLockTimeoutLateMs)) { |
| 1353 | _shouldLockAt = 0; |
| 1354 | _autoLockTimer.cancel(); |
| 1355 | lockByPasscode(); |
| 1356 | } else { |
| 1357 | _shouldLockAt = now + (shouldLockInMs - checkTimeMs); |
| 1358 | _autoLockTimer.callOnce(shouldLockInMs - checkTimeMs); |
| 1359 | } |
| 1360 | } |
| 1361 | |
| 1362 | void Application::checkAutoLockIn(crl::time time) { |
| 1363 | if (_autoLockTimer.isActive()) { |
no test coverage detected