Merge "Reference DataSaver setting from BPF map on V+ only" into main
This commit is contained in:
commit
86b95d405e
1 changed files with 16 additions and 8 deletions
|
|
@ -62,16 +62,24 @@ base::Result<bool> DnsBpfHelper::isUidNetworkingBlocked(uid_t uid, bool metered)
|
|||
if (isBlockedByUidRules(enabledRules.value(), uidRules)) return true;
|
||||
|
||||
// For data saver.
|
||||
if (!metered) return false;
|
||||
// DataSaverEnabled map on V+ platforms is the only reliable source of information about the
|
||||
// current data saver status. While ConnectivityService offers two ways to update this map for U
|
||||
// and V+, the U- platform implementation can have delays, potentially leading to inaccurate
|
||||
// results. Conversely, the V+ platform implementation is synchronized with the actual data saver
|
||||
// state, making it a trustworthy source. Since this library primarily serves DNS resolvers,
|
||||
// relying solely on V+ data prevents erroneous blocking of DNS queries.
|
||||
if (android::modules::sdklevel::IsAtLeastV() && metered) {
|
||||
// The background data setting (PENALTY_BOX_MATCH) and unrestricted data usage setting
|
||||
// (HAPPY_BOX_MATCH) for individual apps override the system wide Data Saver setting.
|
||||
if (uidRules & PENALTY_BOX_MATCH) return true;
|
||||
if (uidRules & HAPPY_BOX_MATCH) return false;
|
||||
|
||||
// The background data setting (PENALTY_BOX_MATCH) and unrestricted data usage setting
|
||||
// (HAPPY_BOX_MATCH) for individual apps override the system wide Data Saver setting.
|
||||
if (uidRules & PENALTY_BOX_MATCH) return true;
|
||||
if (uidRules & HAPPY_BOX_MATCH) return false;
|
||||
auto dataSaverSetting = mDataSaverEnabledMap.readValue(DATA_SAVER_ENABLED_KEY);
|
||||
RETURN_IF_RESULT_NOT_OK(dataSaverSetting);
|
||||
return dataSaverSetting.value();
|
||||
}
|
||||
|
||||
auto dataSaverSetting = mDataSaverEnabledMap.readValue(DATA_SAVER_ENABLED_KEY);
|
||||
RETURN_IF_RESULT_NOT_OK(dataSaverSetting);
|
||||
return dataSaverSetting.value();
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
|
|
|
|||
Loading…
Reference in a new issue