Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorДобрый Ээх <bukharaev@gmail.com>2017-06-13 14:16:20 +0300
committerVladimir Byko-Ianko <bykoianko@gmail.com>2017-06-14 13:23:14 +0300
commit694ee6833acef58c3d2eade56c701daae9453459 (patch)
tree53e224360da1d2d364c798617b3cc77df3e8e59a /tracking
parentcc4e6c0a1e306cf456af609d027f07e804a6f825 (diff)
[tracking] Don't track if device is not charging
Diffstat (limited to 'tracking')
-rw-r--r--tracking/reporter.cpp17
-rw-r--r--tracking/reporter.hpp1
2 files changed, 18 insertions, 0 deletions
diff --git a/tracking/reporter.cpp b/tracking/reporter.cpp
index 36f145a56e..3bb5de54b1 100644
--- a/tracking/reporter.cpp
+++ b/tracking/reporter.cpp
@@ -1,8 +1,11 @@
#include "reporter.hpp"
#include "platform/location.hpp"
+#include "platform/platform.hpp"
#include "platform/socket.hpp"
+#include "3party/Alohalytics/src/alohalytics.h"
+
#include "base/logging.hpp"
#include "base/timer.hpp"
@@ -13,6 +16,7 @@ namespace
double constexpr kRequiredHorizontalAccuracy = 10.0;
double constexpr kMinDelaySeconds = 1.0;
double constexpr kReconnectDelaySeconds = 60.0;
+double constexpr kNotChargingEventPeriod = 5 * 60.0;
size_t constexpr kRealTimeBufferSize = 60;
} // namespace
@@ -53,6 +57,19 @@ void Reporter::AddLocation(location::GpsInfo const & info, traffic::SpeedGroup t
if (info.m_timestamp < m_lastGpsTime + kMinDelaySeconds)
return;
+ if (Platform::GetChargingStatus() != Platform::ChargingStatus::Plugged)
+ {
+ double const currentTime = my::Timer::LocalTime();
+ if (currentTime < m_lastNotChargingEvent + kNotChargingEventPeriod)
+ return;
+
+ alohalytics::Stats::Instance().LogEvent(
+ "Routing_DataSending_restricted",
+ {{"reason", "Device is not charging"}, {"mode", "vehicle"}});
+ m_lastNotChargingEvent = currentTime;
+ return;
+ }
+
m_lastGpsTime = info.m_timestamp;
m_input.push_back(
DataPoint(info.m_timestamp, ms::LatLon(info.m_latitude, info.m_longitude),
diff --git a/tracking/reporter.hpp b/tracking/reporter.hpp
index a8f63b935b..1ddd16d5b0 100644
--- a/tracking/reporter.hpp
+++ b/tracking/reporter.hpp
@@ -54,6 +54,7 @@ private:
milliseconds m_pushDelay;
bool m_wasConnected = false;
double m_lastConnectionAttempt = 0.0;
+ double m_lastNotChargingEvent = 0.0;
// Function to be called every |kPushDelayMs| in
// case no points were sent.
function<void()> m_idleFn;