Fix default value for mUidState.get.

In updateRulesForWhitelistedPowerSaveUL, we are using
mUidState.get(uid). So if the uid didn't already exist, it will
give 0 which represents PROCESS_STATE_PERSISTENT and this is
inconsistent with it's other usages.

Bug: 35766310
Test: verified that apps coming to foreground, while the battery saver is on,
      have access to network.
Change-Id: I42a8455862e3a15e14825d9cf74e05a6f1dbe298
This commit is contained in:
Sudheer Shanka
2017-02-24 16:30:04 -08:00
parent 3b264fa2af
commit 12d2922a6e

View File

@@ -2608,8 +2608,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
// (mPowerSaveTempWhitelistAppIds) for whitelisting, we can reuse their logic in this method.
private void updateRulesForWhitelistedPowerSaveUL(int uid, boolean enabled, int chain) {
if (enabled) {
if (isWhitelistedBatterySaverUL(uid)
|| isProcStateAllowedWhileIdleOrPowerSaveMode(mUidState.get(uid))) {
if (isWhitelistedBatterySaverUL(uid) || isUidForegroundOnRestrictPowerUL(uid)) {
setUidFirewallRule(chain, uid, FIREWALL_RULE_ALLOW);
} else {
setUidFirewallRule(chain, uid, FIREWALL_RULE_DEFAULT);