MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / checkAutoLock

Method checkAutoLock

Telegram/SourceFiles/core/application.cpp:1335–1360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1333}
1334
1335void 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
1362void Application::checkAutoLockIn(crl::time time) {
1363 if (_autoLockTimer.isActive()) {

Callers 5

durationChangedMethod · 0.80
feedDifferenceMethod · 0.80
mtpNewSessionCreatedMethod · 0.80
mtpUpdateReceivedMethod · 0.80
updateOnlineMethod · 0.80

Calls 4

lastNonIdleTimeMethod · 0.95
hasLocalPasscodeMethod · 0.80
autoLockMethod · 0.80
cancelMethod · 0.45

Tested by

no test coverage detected