Check UID's process state before restricting its network.

It is possible that an app which is in fg-service process state to be
considered idle. Since we don't want to block connectivity of apps in
the foreground state, we should check the uid process state in addition
to its idle state when deciding whether to block its network or not.

Test: atest com.android.cts.net.HostsideRestrictBackgroundNetworkTests#testAppIdleMetered_enabled

Signed-off-by: xiamengsen <xiamengsen@xiaomi.com>
Change-Id: If7e42605eb162abf6f88f03f28f7245659a7748c
This commit is contained in:
xiamengsen
2020-09-25 17:07:27 +08:00
committed by xiamengsen
parent 5d73cb9cb6
commit 42f3c9496e

View File

@@ -3867,7 +3867,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
// quick check: if this uid doesn't have INTERNET permission, it
// doesn't have network access anyway, so it is a waste to mess
// with it here.
if (hasInternetPermissionUL(uid)) {
if (hasInternetPermissionUL(uid) && !isUidForegroundOnRestrictPowerUL(uid)) {
uidRules.put(uid, FIREWALL_RULE_DENY);
}
}