From 4c3b470ec0db04bfa607f23c5401b0d7c47f76d1 Mon Sep 17 00:00:00 2001 From: Davide Giacometti Date: Mon, 13 Feb 2023 17:29:26 +0100 Subject: [PATCH] [Runner]Improve metered network detection (#24030) --- src/runner/UpdateUtils.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/runner/UpdateUtils.cpp b/src/runner/UpdateUtils.cpp index 672cc7e2dd..8d46ced78c 100644 --- a/src/runner/UpdateUtils.cpp +++ b/src/runner/UpdateUtils.cpp @@ -88,7 +88,26 @@ bool IsMeteredConnection() { using namespace winrt::Windows::Networking::Connectivity; ConnectionProfile internetConnectionProfile = NetworkInformation::GetInternetConnectionProfile(); - return internetConnectionProfile && internetConnectionProfile.IsWwanConnectionProfile(); + if (!internetConnectionProfile) + { + return false; + } + + if (internetConnectionProfile.IsWwanConnectionProfile()) + { + return true; + } + + ConnectionCost connectionCost = internetConnectionProfile.GetConnectionCost(); + if (connectionCost.Roaming() + || connectionCost.OverDataLimit() + || connectionCost.NetworkCostType() == NetworkCostType::Fixed + || connectionCost.NetworkCostType() == NetworkCostType::Variable) + { + return true; + } + + return false; } void ProcessNewVersionInfo(const github_version_info& version_info,