Only disable update downloads over expensive connections, not all transfers.
Previous to this CL, all network traffic was disabled from the update engine
if an update wasn't allowed. Instead, in this CL, we switch to only disable
the update application portion (downloading and applying the payload). This
is done by moving the detection logic from the mechanism (the network fetcher)
to the user of said mechanism i.e. the omaha request/response actions.
I have done a little refactoring of the unittests to make this CL easier to
test and found 1 bug in the http_fetcher_unittests where we weren't sending
either the right URL or handling a server not existing correctly.
This CL comes with one caveat:
Technically in the previous impl if a download started over wifi then got
disconnected / retried and bounced to a different connection type that
we couldn't update over, we'd stop the update. This would no longer be true
here if the http_fetcher recovered seamlessly.
BUG=chromium:379832
TEST=Unittests
Change-Id: I6b1a76e4c030d4e384e8ba0b519424a35406aafb
Reviewed-on: https://chromium-review.googlesource.com/202435
Tested-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: Chris Sosa <sosa@chromium.org>
diff --git a/libcurl_http_fetcher.cc b/libcurl_http_fetcher.cc
index be5df41..1919466 100644
--- a/libcurl_http_fetcher.cc
+++ b/libcurl_http_fetcher.cc
@@ -13,7 +13,6 @@
#include "update_engine/certificate_checker.h"
#include "update_engine/hardware_interface.h"
-#include "update_engine/real_dbus_wrapper.h"
#include "update_engine/utils.h"
using google::protobuf::NewPermanentCallback;
@@ -37,25 +36,6 @@
CleanUp();
}
-// On error, returns false.
-bool LibcurlHttpFetcher::IsUpdateAllowedOverCurrentConnection() const {
- NetworkConnectionType type;
- NetworkTethering tethering;
- RealDBusWrapper dbus_iface;
- ConnectionManager* connection_manager = system_state_->connection_manager();
- if (!connection_manager->GetConnectionProperties(&dbus_iface,
- &type, &tethering)) {
- LOG(INFO) << "We could not determine our connection type. "
- << "Defaulting to allow updates.";
- return true;
- }
- bool is_allowed = connection_manager->IsUpdateAllowedOver(type, tethering);
- LOG(INFO) << "We are connected via "
- << connection_manager->StringForConnectionType(type)
- << ", Updates allowed: " << (is_allowed ? "Yes" : "No");
- return is_allowed;
-}
-
bool LibcurlHttpFetcher::GetProxyType(const std::string& proxy,
curl_proxytype* out_type) {
if (utils::StringHasPrefix(proxy, "socks5://") ||
@@ -161,15 +141,7 @@
CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_WRITEDATA, this), CURLE_OK);
CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_WRITEFUNCTION,
StaticLibcurlWrite), CURLE_OK);
-
- string url_to_use(url_);
- if (!IsUpdateAllowedOverCurrentConnection()) {
- LOG(INFO) << "Not initiating HTTP connection b/c updates are disabled "
- << "over this connection";
- url_to_use = ""; // Sabotage the URL
- }
-
- CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_URL, url_to_use.c_str()),
+ CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_URL, url_.c_str()),
CURLE_OK);
// If the connection drops under |low_speed_limit_bps_| (10
@@ -195,7 +167,7 @@
// Lock down the appropriate curl options for HTTP or HTTPS depending on
// the url.
if (GetSystemState()->hardware()->IsOfficialBuild()) {
- if (StartsWithASCII(url_to_use, "http://", false))
+ if (StartsWithASCII(url_, "http://", false))
SetCurlOptionsForHttp();
else
SetCurlOptionsForHttps();