Merge "Fixed enforceMeteredApnPolicy when Data Saver is on." into nyc-dev am: efd3a1749f am: 1411952a68
am: b5987d7993

* commit 'b5987d79937b2f1b0ec68c84371aea36f7e2b8a1':
  Fixed enforceMeteredApnPolicy when Data Saver is on.

Change-Id: If9e525f86b29960ed4dfdd6ca27bc5d0077454ae
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 389e045..9a80117 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -4069,7 +4069,8 @@
             synchronized(mRulesLock) {
                 uidRules = mUidRules.get(uid, RULE_ALLOW_ALL);
             }
-            if ((uidRules & RULE_ALLOW_ALL) == 0) {
+            if (mRestrictBackground && (uidRules & RULE_ALLOW_METERED) == 0
+                    && (uidRules & RULE_TEMPORARY_ALLOW_METERED) == 0) {
                 // we could silently fail or we can filter the available nets to only give
                 // them those they have access to.  Chose the more useful option.
                 networkCapabilities.addCapability(NET_CAPABILITY_NOT_METERED);