Skip to content
Snippets Groups Projects
Commit 07f8eac8 authored by Ken Chen's avatar Ken Chen Committed by Automerger Merge Worker
Browse files

Merge "Reference DataSaver setting from BPF map on V+ only" into main am: 86b95d40

parents c555dc32 86b95d40
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment