MCPcopy Create free account
hub / github.com/comaps/comaps / EnterBackground

Method EnterBackground

libs/platform/settings.cpp:383–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

381}
382
383void UsageStats::EnterBackground()
384{
385 uint64_t const currTime = TimeSinceEpoch();
386
387 // Safe check if something wrong with device's time.
388 ASSERT_GREATER_OR_EQUAL(currTime, m_enterForegroundTime, ());
389 if (currTime < m_enterForegroundTime)
390 return;
391
392 // Safe check if uninitialized. Possible when entering background on DownloadResourcesLegacyActivity.
393 // ASSERT(m_enterForegroundTime > 0, ());
394 if (m_enterForegroundTime == 0)
395 return;
396
397 // Save first launch.
398 std::string dummy;
399 if (!m_ss.GetValue(m_firstLaunch, dummy))
400 m_ss.SetValue(m_firstLaunch, ToString(m_enterForegroundTime));
401
402 // Save last background.
403 m_ss.SetValue(m_lastBackground, ToString(currTime));
404
405 // Aggregate foreground duration.
406 m_totalForegroundTime += (currTime - m_enterForegroundTime);
407 m_ss.SetValue(m_totalForeground, ToString(m_totalForegroundTime));
408
409 // Aggregate sessions count.
410 ++m_sessionsCount;
411 m_ss.SetValue(m_sessions, ToString(m_sessionsCount));
412}
413
414bool UsageStats::IsLoyalUser() const
415{

Callers

nothing calls this directly

Calls 3

SetValueMethod · 0.80
ToStringFunction · 0.50
GetValueMethod · 0.45

Tested by

no test coverage detected