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:
authorRoman Kuznetsov <r.kuznetsow@gmail.com>2018-03-04 16:28:04 +0300
committerAleksandr Zatsepin <alexzatsepin@users.noreply.github.com>2018-03-06 16:38:20 +0300
commit40e13cd2e6de32a1fa0618bbc72926568758d23d (patch)
tree1a78c8c2d520f3f967745f8cb6bae8fecc420a2f /local_ads
parent14639daad8bd4dcff4abafe5c00c6b06b3cae629 (diff)
Added support of 3G awareness in core platform
Diffstat (limited to 'local_ads')
-rw-r--r--local_ads/statistics.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/local_ads/statistics.cpp b/local_ads/statistics.cpp
index e23952df38..2d2510f005 100644
--- a/local_ads/statistics.cpp
+++ b/local_ads/statistics.cpp
@@ -3,6 +3,7 @@
#include "local_ads/file_helpers.hpp"
#include "platform/http_client.hpp"
+#include "platform/network_policy.hpp"
#include "platform/platform.hpp"
#include "coding/file_name_utils.hpp"
@@ -220,6 +221,16 @@ std::vector<uint8_t> SerializeForServer(std::list<local_ads::Event> const & even
deflate(buffer.get(), strlen(buffer.get()), std::back_inserter(result));
return result;
}
+
+bool CanUpload()
+{
+ auto const connectionStatus = GetPlatform().ConnectionStatus();
+ if (connectionStatus == Platform::EConnectionType::CONNECTION_WIFI)
+ return true;
+
+ return connectionStatus == Platform::EConnectionType::CONNECTION_WWAN &&
+ platform::GetCurrentNetworkPolicy().CanUse();
+}
} // namespace
namespace local_ads
@@ -364,8 +375,7 @@ void Statistics::ProcessEvents(std::list<Event> & events)
void Statistics::SendToServer()
{
- auto const connectionStatus = GetPlatform().ConnectionStatus();
- if (connectionStatus == Platform::EConnectionType::CONNECTION_WIFI)
+ if (CanUpload())
{
for (auto it = m_metadataCache.begin(); it != m_metadataCache.end(); ++it)
{