[Runner]Improve metered network detection (#24030)

This commit is contained in:
Davide Giacometti 2023-02-13 17:29:26 +01:00 committed by GitHub
parent 8bcabe17e0
commit 4c3b470ec0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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,