Treat confirmed Tethered networks as Cellular networks.
The updates are allowed based on the type of connection used to
download it from. For example, by default, no update is made over
Cellular networks even if the device is connected to a VPN over a
Cellular network to prevent huge charges on those connections.
Nevertheless, when the device is connected to a tethered network such
as an Android or iPhone sharing its Cellular connection over Wifi,
the connection type the device sees is a Wifi and thus will allow
the updates by default.
To prevent updates over tethered networks, this patch uses the
Tethering property expossed by shill to avoid those situations. If
the device is connected to a network that shill confirms to be a
tethered network, it will be treated as if the device is connected
to a Cellular network. This means that the updates will be allowed
based on the same settings that govern if the updates are allowed
over Cellular networks.
BUG=chromium:323010
TEST=Unit tests added to verify policy and property parsing.
Change-Id: I3a31c804465c9ed5c76b5d6156adda8e5e4e8a6d
Reviewed-on: https://chromium-review.googlesource.com/189524
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/connection_manager.h b/connection_manager.h
index 58307ff..b50782b 100644
--- a/connection_manager.h
+++ b/connection_manager.h
@@ -20,6 +20,13 @@
kNetUnknown
};
+enum class NetworkTethering {
+ kNotDetected = 0,
+ kSuspected,
+ kConfirmed,
+ kUnknown
+};
+
class SystemState;
// This class exposes a generic interface to the connection manager
@@ -32,19 +39,27 @@
explicit ConnectionManager(SystemState* system_state);
// Populates |out_type| with the type of the network connection
- // that we are currently connected. The dbus_iface is used to
- // query the real connection manager (e.g shill).
- virtual bool GetConnectionType(DBusWrapperInterface* dbus_iface,
- NetworkConnectionType* out_type) const;
+ // that we are currently connected and |out_tethering| with the estimate of
+ // whether that network is being tethered. The dbus_iface is used to query
+ // the real connection manager (e.g shill).
+ virtual bool GetConnectionProperties(DBusWrapperInterface* dbus_iface,
+ NetworkConnectionType* out_type,
+ NetworkTethering* out_tethering) const;
// Returns true if we're allowed to update the system when we're
- // connected to the internet through the given network connection type.
- virtual bool IsUpdateAllowedOver(NetworkConnectionType type) const;
+ // connected to the internet through the given network connection type and the
+ // given tethering state.
+ virtual bool IsUpdateAllowedOver(NetworkConnectionType type,
+ NetworkTethering tethering) const;
// Returns the string representation corresponding to the given
// connection type.
virtual const char* StringForConnectionType(NetworkConnectionType type) const;
+ // Returns the string representation corresponding to the given tethering
+ // state.
+ virtual const char* StringForTethering(NetworkTethering tethering) const;
+
private:
// The global context for update_engine
SystemState* system_state_;