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

Method UsageStats

libs/platform/settings.cpp:343–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341}
342
343UsageStats::UsageStats()
344 : m_firstLaunch("US_FirstLaunch")
345 , m_lastBackground("US_LastBackground")
346 , m_totalForeground("US_TotalForeground")
347 , m_sessions("US_SessionsCount")
348 , m_ss(StringStorage::Instance())
349{
350 std::string str;
351 uint64_t val;
352 if (m_ss.GetValue(m_totalForeground, str) && FromString(str, val))
353 m_totalForegroundTime = val;
354
355 if (m_ss.GetValue(m_sessions, str) && FromString(str, val))
356 m_sessionsCount = val;
357
358 if (!m_ss.GetValue(m_firstLaunch, str))
359 {
360 auto const fileTime = Platform::GetFileCreationTime(GetPlatform().SettingsPathForFile(SETTINGS_FILE_NAME));
361 if (fileTime > 0)
362 {
363 // Check that file wasn't created on this first launch (1 hour threshold).
364 uint64_t const first = base::TimeTToSecondsSinceEpoch(fileTime);
365 uint64_t const curr = TimeSinceEpoch();
366 if (curr >= first + 3600 /* 1 hour */)
367 m_ss.SetValue(m_firstLaunch, ToString(first));
368 }
369 }
370}
371
372uint64_t UsageStats::TimeSinceEpoch()
373{

Callers

nothing calls this directly

Calls 6

TimeTToSecondsSinceEpochFunction · 0.85
SettingsPathForFileMethod · 0.80
SetValueMethod · 0.80
FromStringFunction · 0.50
ToStringFunction · 0.50
GetValueMethod · 0.45

Tested by

no test coverage detected