Commit 4321cc75 authored by /e/ robot's avatar /e/ robot

Merge remote-tracking branch 'origin/lineage-16.0' into v1-pie

parents 8bfed61a 3476e978
Pipeline #23001 passed with stage
in 5 minutes and 51 seconds
......@@ -82,12 +82,15 @@ public class DataSaverBackend {
public void setIsWhitelisted(int uid, String packageName, boolean whitelisted) {
final int policy = whitelisted ? POLICY_ALLOW_METERED_BACKGROUND : POLICY_NONE;
mPolicyManager.setUidPolicy(uid, policy);
mUidPolicies.put(uid, policy);
if (whitelisted) {
mPolicyManager.addUidPolicy(uid, POLICY_ALLOW_METERED_BACKGROUND);
mMetricsFeatureProvider.action(
mContext, MetricsEvent.ACTION_DATA_SAVER_WHITELIST, packageName);
} else {
mPolicyManager.removeUidPolicy(uid, POLICY_ALLOW_METERED_BACKGROUND);
}
mPolicyManager.removeUidPolicy(uid, POLICY_REJECT_METERED_BACKGROUND);
}
public boolean isWhitelisted(int uid) {
......@@ -121,12 +124,15 @@ public class DataSaverBackend {
public void setIsBlacklisted(int uid, String packageName, boolean blacklisted) {
final int policy = blacklisted ? POLICY_REJECT_METERED_BACKGROUND : POLICY_NONE;
mPolicyManager.setUidPolicy(uid, policy);
mUidPolicies.put(uid, policy);
if (blacklisted) {
mPolicyManager.addUidPolicy(uid, POLICY_REJECT_METERED_BACKGROUND);
mMetricsFeatureProvider.action(
mContext, MetricsEvent.ACTION_DATA_SAVER_BLACKLIST, packageName);
} else {
mPolicyManager.removeUidPolicy(uid, POLICY_REJECT_METERED_BACKGROUND);
}
mPolicyManager.removeUidPolicy(uid, POLICY_ALLOW_METERED_BACKGROUND);
}
public boolean isBlacklisted(int uid) {
......@@ -164,6 +170,10 @@ public class DataSaverBackend {
loadWhitelist();
loadBlacklist();
// We only care about allow/reject metered background policy here.
newPolicy &= (POLICY_ALLOW_METERED_BACKGROUND
| POLICY_REJECT_METERED_BACKGROUND);
final int oldPolicy = mUidPolicies.get(uid, POLICY_NONE);
if (newPolicy == POLICY_NONE) {
mUidPolicies.delete(uid);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment