From: Michal Bistyga Date: Fri, 15 Sep 2017 09:46:00 +0000 (+0200) Subject: [Download] Checking if device is connected before X-Git-Tag: submit/tizen_3.0/20170921.132449~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F86%2F150386%2F4;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [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 --- 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);