From f82cacef3b09e86eb54c53968d4dd826160e5b7f Mon Sep 17 00:00:00 2001 From: Michal Bistyga Date: Fri, 15 Sep 2017 11:46:00 +0200 Subject: [PATCH] [Download] Checking if device is connected before When wi-fi has been disconnected, plugins would throw not intuitive error description. It was especially important on XU3, where short disconnect occurs more often. [Verification] 100% TCT pass rate on TM1 Change-Id: I22712dd8e815ac810b8fec5549c370e91498ed85 Signed-off-by: Michal Bistyga --- src/download/download_instance.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/download/download_instance.cc b/src/download/download_instance.cc index dca989a4..68179a18 100755 --- a/src/download/download_instance.cc +++ b/src/download/download_instance.cc @@ -25,6 +25,7 @@ #include "common/logger.h" #include "common/typeutil.h" #include "common/filesystem/filesystem_provider.h" +#include "common/scope_exit.h" namespace extension { namespace download { @@ -522,6 +523,9 @@ void DownloadInstance::DownloadManagerStart connection_h connection = nullptr; connection_create(&connection); + SCOPE_EXIT { + connection_destroy(connection); + }; connection_cellular_state_e cell_state = CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE; connection_wifi_state_e wifi_state = CONNECTION_WIFI_STATE_DEACTIVATED; @@ -532,7 +536,12 @@ void DownloadInstance::DownloadManagerStart connection_type_e connection_type = CONNECTION_TYPE_DISCONNECTED; connection_get_type(connection, &connection_type); - connection_destroy(connection); + if (CONNECTION_TYPE_DISCONNECTED == connection_type) { + LogAndReportError( + common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, "Connection problem occured"), + &out, ("Connection type is disconnected")); + return; + } bool network_available = false; bool cell_available = (CONNECTION_CELLULAR_STATE_CONNECTED == cell_state); -- 2.34.1