Loading services/core/java/com/android/server/net/NetworkPolicyLogger.java +4 −4 Original line number Diff line number Diff line Loading @@ -338,8 +338,8 @@ public class NetworkPolicyLogger { return "App idle state of uid " + uid + ": " + idle; } private static String getAppIdleWlChangedLog(int uid, boolean isWhitelisted) { return "App idle whitelist state of uid " + uid + ": " + isWhitelisted; private static String getAppIdleWlChangedLog(int uid, boolean isAllowlisted) { return "App idle whitelist state of uid " + uid + ": " + isAllowlisted; } private static String getParoleStateChanged(boolean paroleOn) { Loading Loading @@ -519,14 +519,14 @@ public class NetworkPolicyLogger { data.timeStamp = System.currentTimeMillis(); } public void appIdleWlChanged(int uid, boolean isWhitelisted) { public void appIdleWlChanged(int uid, boolean isAllowlisted) { final Data data = getNextSlot(); if (data == null) return; data.reset(); data.type = EVENT_APP_IDLE_WL_CHANGED; data.ifield1 = uid; data.bfield1 = isWhitelisted; data.bfield1 = isAllowlisted; data.timeStamp = System.currentTimeMillis(); } Loading services/core/java/com/android/server/net/NetworkPolicyManagerService.java +28 −28 Original line number Diff line number Diff line Loading @@ -362,7 +362,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { private static final String TAG_NETWORK_POLICY = "network-policy"; private static final String TAG_UID_POLICY = "uid-policy"; private static final String TAG_APP_POLICY = "app-policy"; private static final String TAG_WHITELIST = "whitelist"; private static final String TAG_ALLOWLIST = "whitelist"; private static final String TAG_RESTRICT_BACKGROUND = "restrict-background"; private static final String TAG_REVOKED_RESTRICT_BACKGROUND = "revoked-restrict-background"; private static final String TAG_XML_UTILS_INT_ARRAY = "int-array"; Loading Loading @@ -856,7 +856,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } @GuardedBy("mUidRulesFirstLock") private void updatePowerSaveWhitelistUL() { private void updatePowerSaveAllowlistUL() { int[] whitelist = mPowerWhitelistManager.getWhitelistedAppIds(/* includingIdle */ false); mPowerSaveWhitelistExceptIdleAppIds.clear(); for (int uid : whitelist) { Loading Loading @@ -947,7 +947,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { synchronized (mUidRulesFirstLock) { synchronized (mNetworkPoliciesSecondLock) { updatePowerSaveWhitelistUL(); updatePowerSaveAllowlistUL(); mPowerManagerInternal = LocalServices.getService(PowerManagerInternal.class); mPowerManagerInternal.registerLowPowerModeObserver( new PowerManagerInternal.LowPowerModeListener() { Loading Loading @@ -1189,7 +1189,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { public void onReceive(Context context, Intent intent) { // on background handler thread, and POWER_SAVE_WHITELIST_CHANGED is protected synchronized (mUidRulesFirstLock) { updatePowerSaveWhitelistUL(); updatePowerSaveAllowlistUL(); updateRulesForRestrictPowerUL(); updateRulesForAppIdleUL(); } Loading Loading @@ -2679,7 +2679,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } else { Slog.w(TAG, "unable to apply policy to UID " + uid + "; ignoring"); } } else if (TAG_WHITELIST.equals(tag)) { } else if (TAG_ALLOWLIST.equals(tag)) { insideAllowlist = true; } else if (TAG_RESTRICT_BACKGROUND.equals(tag) && insideAllowlist) { final int uid = readIntAttribute(in, ATTR_UID); Loading @@ -2689,7 +2689,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { mRestrictBackgroundAllowlistRevokedUids.put(uid, true); } } else if (type == END_TAG) { if (TAG_WHITELIST.equals(tag)) { if (TAG_ALLOWLIST.equals(tag)) { insideAllowlist = false; } Loading Loading @@ -2865,7 +2865,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { out.endTag(null, TAG_POLICY_LIST); // write all allowlists out.startTag(null, TAG_WHITELIST); out.startTag(null, TAG_ALLOWLIST); // revoked restrict background allowlist int size = mRestrictBackgroundAllowlistRevokedUids.size(); Loading @@ -2876,7 +2876,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { out.endTag(null, TAG_REVOKED_RESTRICT_BACKGROUND); } out.endTag(null, TAG_WHITELIST); out.endTag(null, TAG_ALLOWLIST); out.endDocument(); Loading Loading @@ -4356,7 +4356,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { void updateRulesForPowerSaveUL() { Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "updateRulesForPowerSaveUL"); try { updateRulesForWhitelistedPowerSaveUL(mRestrictPower, FIREWALL_CHAIN_POWERSAVE, updateRulesForAllowlistedPowerSaveUL(mRestrictPower, FIREWALL_CHAIN_POWERSAVE, mUidFirewallPowerSaveRules); } finally { Trace.traceEnd(Trace.TRACE_TAG_NETWORK); Loading @@ -4365,14 +4365,14 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { @GuardedBy("mUidRulesFirstLock") void updateRuleForRestrictPowerUL(int uid) { updateRulesForWhitelistedPowerSaveUL(uid, mRestrictPower, FIREWALL_CHAIN_POWERSAVE); updateRulesForAllowlistedPowerSaveUL(uid, mRestrictPower, FIREWALL_CHAIN_POWERSAVE); } @GuardedBy("mUidRulesFirstLock") void updateRulesForDeviceIdleUL() { Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "updateRulesForDeviceIdleUL"); try { updateRulesForWhitelistedPowerSaveUL(mDeviceIdleMode, FIREWALL_CHAIN_DOZABLE, updateRulesForAllowlistedPowerSaveUL(mDeviceIdleMode, FIREWALL_CHAIN_DOZABLE, mUidFirewallDozableRules); } finally { Trace.traceEnd(Trace.TRACE_TAG_NETWORK); Loading @@ -4381,26 +4381,26 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { @GuardedBy("mUidRulesFirstLock") void updateRuleForDeviceIdleUL(int uid) { updateRulesForWhitelistedPowerSaveUL(uid, mDeviceIdleMode, FIREWALL_CHAIN_DOZABLE); updateRulesForAllowlistedPowerSaveUL(uid, mDeviceIdleMode, FIREWALL_CHAIN_DOZABLE); } // NOTE: since both fw_dozable and fw_powersave uses the same map // (mPowerSaveTempWhitelistAppIds) for allowlisting, we can reuse their logic in this method. @GuardedBy("mUidRulesFirstLock") private void updateRulesForWhitelistedPowerSaveUL(boolean enabled, int chain, private void updateRulesForAllowlistedPowerSaveUL(boolean enabled, int chain, SparseIntArray rules) { if (enabled) { // Sync the whitelists before enabling the chain. We don't care about the rules if // Sync the allowlists before enabling the chain. We don't care about the rules if // we are disabling the chain. final SparseIntArray uidRules = rules; uidRules.clear(); final List<UserInfo> users = mUserManager.getUsers(); for (int ui = users.size() - 1; ui >= 0; ui--) { UserInfo user = users.get(ui); updateRulesForWhitelistedAppIds(uidRules, mPowerSaveTempWhitelistAppIds, user.id); updateRulesForWhitelistedAppIds(uidRules, mPowerSaveWhitelistAppIds, user.id); updateRulesForAllowlistedAppIds(uidRules, mPowerSaveTempWhitelistAppIds, user.id); updateRulesForAllowlistedAppIds(uidRules, mPowerSaveWhitelistAppIds, user.id); if (chain == FIREWALL_CHAIN_POWERSAVE) { updateRulesForWhitelistedAppIds(uidRules, updateRulesForAllowlistedAppIds(uidRules, mPowerSaveWhitelistExceptIdleAppIds, user.id); } } Loading @@ -4415,7 +4415,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } } private void updateRulesForWhitelistedAppIds(final SparseIntArray uidRules, private void updateRulesForAllowlistedAppIds(final SparseIntArray uidRules, final SparseBooleanArray whitelistedAppIds, int userId) { for (int i = whitelistedAppIds.size() - 1; i >= 0; --i) { if (whitelistedAppIds.valueAt(i)) { Loading Loading @@ -4476,12 +4476,12 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { * allowlisted. */ @GuardedBy("mUidRulesFirstLock") private boolean isWhitelistedFromPowerSaveUL(int uid, boolean deviceIdleMode) { private boolean isAllowlistedFromPowerSaveUL(int uid, boolean deviceIdleMode) { final int appId = UserHandle.getAppId(uid); boolean isWhitelisted = mPowerSaveTempWhitelistAppIds.get(appId) || mPowerSaveWhitelistAppIds.get(appId); if (!deviceIdleMode) { isWhitelisted = isWhitelisted || isWhitelistedFromPowerSaveExceptIdleUL(uid); isWhitelisted = isWhitelisted || isAllowlistedFromPowerSaveExceptIdleUL(uid); } return isWhitelisted; } Loading @@ -4491,7 +4491,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { * (eg: Battery Saver and app idle). */ @GuardedBy("mUidRulesFirstLock") private boolean isWhitelistedFromPowerSaveExceptIdleUL(int uid) { private boolean isAllowlistedFromPowerSaveExceptIdleUL(int uid) { final int appId = UserHandle.getAppId(uid); return mPowerSaveWhitelistExceptIdleAppIds.get(appId); } Loading @@ -4507,9 +4507,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { // NOTE: since both fw_dozable and fw_powersave uses the same map // (mPowerSaveTempWhitelistAppIds) for allowlisting, we can reuse their logic in this method. @GuardedBy("mUidRulesFirstLock") private void updateRulesForWhitelistedPowerSaveUL(int uid, boolean enabled, int chain) { private void updateRulesForAllowlistedPowerSaveUL(int uid, boolean enabled, int chain) { if (enabled) { final boolean isWhitelisted = isWhitelistedFromPowerSaveUL(uid, final boolean isWhitelisted = isAllowlistedFromPowerSaveUL(uid, chain == FIREWALL_CHAIN_DOZABLE); if (isWhitelisted || isUidForegroundOnRestrictPowerUL(uid)) { setUidFirewallRuleUL(chain, uid, FIREWALL_RULE_ALLOW); Loading Loading @@ -4767,7 +4767,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } @GuardedBy("mUidRulesFirstLock") private void updateRulesForTempWhitelistChangeUL(int appId) { private void updateRulesForTempAllowlistChangeUL(int appId) { final List<UserInfo> users = mUserManager.getUsers(); final int numUsers = users.size(); for (int i = 0; i < numUsers; i++) { Loading Loading @@ -5158,7 +5158,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { final boolean isForeground = isUidForegroundOnRestrictPowerUL(uid); final boolean isTop = isUidTop(uid); final boolean isWhitelisted = isWhitelistedFromPowerSaveUL(uid, mDeviceIdleMode); final boolean isWhitelisted = isAllowlistedFromPowerSaveUL(uid, mDeviceIdleMode); final int oldEffectiveBlockedReasons; final int newEffectiveBlockedReasons; Loading @@ -5181,9 +5181,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { newAllowedReasons |= (isSystem(uid) ? ALLOWED_REASON_SYSTEM : 0); newAllowedReasons |= (isForeground ? ALLOWED_REASON_FOREGROUND : 0); newAllowedReasons |= (isTop ? ALLOWED_REASON_TOP : 0); newAllowedReasons |= (isWhitelistedFromPowerSaveUL(uid, true) newAllowedReasons |= (isAllowlistedFromPowerSaveUL(uid, true) ? ALLOWED_REASON_POWER_SAVE_ALLOWLIST : 0); newAllowedReasons |= (isWhitelistedFromPowerSaveExceptIdleUL(uid) newAllowedReasons |= (isAllowlistedFromPowerSaveExceptIdleUL(uid) ? ALLOWED_REASON_POWER_SAVE_EXCEPT_IDLE_ALLOWLIST : 0); newAllowedReasons |= (uidBlockedState.allowedReasons & ALLOWED_REASON_RESTRICTED_MODE_PERMISSIONS); Loading Loading @@ -6095,7 +6095,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } else { mPowerSaveTempWhitelistAppIds.delete(appId); } updateRulesForTempWhitelistChangeUL(appId); updateRulesForTempAllowlistChangeUL(appId); } } Loading services/core/java/com/android/server/net/NetworkPolicyManagerShellCommand.java +21 −21 Original line number Diff line number Diff line Loading @@ -154,13 +154,13 @@ class NetworkPolicyManagerShellCommand extends ShellCommand { } switch(type) { case "app-idle-whitelist": return listAppIdleWhitelist(); return listAppIdleAllowlist(); case "wifi-networks": return listWifiNetworks(); case "restrict-background-whitelist": return listRestrictBackgroundWhitelist(); return listRestrictBackgroundAllowlist(); case "restrict-background-blacklist": return listRestrictBackgroundBlacklist(); return listRestrictBackgroundDenylist(); } pw.println("Error: unknown list type '" + type + "'"); return -1; Loading @@ -175,11 +175,11 @@ class NetworkPolicyManagerShellCommand extends ShellCommand { } switch(type) { case "restrict-background-whitelist": return addRestrictBackgroundWhitelist(); return addRestrictBackgroundAllowlist(); case "restrict-background-blacklist": return addRestrictBackgroundBlacklist(); return addRestrictBackgroundDenylist(); case "app-idle-whitelist": return addAppIdleWhitelist(); return addAppIdleAllowlist(); } pw.println("Error: unknown add type '" + type + "'"); return -1; Loading @@ -194,11 +194,11 @@ class NetworkPolicyManagerShellCommand extends ShellCommand { } switch(type) { case "restrict-background-whitelist": return removeRestrictBackgroundWhitelist(); return removeRestrictBackgroundAllowlist(); case "restrict-background-blacklist": return removeRestrictBackgroundBlacklist(); return removeRestrictBackgroundDenylist(); case "app-idle-whitelist": return removeAppIdleWhitelist(); return removeAppIdleAllowlist(); } pw.println("Error: unknown remove type '" + type + "'"); return -1; Loading Loading @@ -241,17 +241,17 @@ class NetworkPolicyManagerShellCommand extends ShellCommand { return 0; } private int listRestrictBackgroundWhitelist() throws RemoteException { private int listRestrictBackgroundAllowlist() throws RemoteException { return listUidPolicies("Restrict background whitelisted UIDs", POLICY_ALLOW_METERED_BACKGROUND); } private int listRestrictBackgroundBlacklist() throws RemoteException { private int listRestrictBackgroundDenylist() throws RemoteException { return listUidPolicies("Restrict background blacklisted UIDs", POLICY_REJECT_METERED_BACKGROUND); } private int listAppIdleWhitelist() throws RemoteException { private int listAppIdleAllowlist() throws RemoteException { final PrintWriter pw = getOutPrintWriter(); final int[] uids = mInterface.getAppIdleWhitelist(); return listUidList("App Idle whitelisted UIDs", uids); Loading Loading @@ -311,23 +311,23 @@ class NetworkPolicyManagerShellCommand extends ShellCommand { return 0; } private int addRestrictBackgroundWhitelist() throws RemoteException { private int addRestrictBackgroundAllowlist() throws RemoteException { return setUidPolicy(POLICY_ALLOW_METERED_BACKGROUND); } private int removeRestrictBackgroundWhitelist() throws RemoteException { private int removeRestrictBackgroundAllowlist() throws RemoteException { return resetUidPolicy("not whitelisted", POLICY_ALLOW_METERED_BACKGROUND); } private int addRestrictBackgroundBlacklist() throws RemoteException { private int addRestrictBackgroundDenylist() throws RemoteException { return setUidPolicy(POLICY_REJECT_METERED_BACKGROUND); } private int removeRestrictBackgroundBlacklist() throws RemoteException { private int removeRestrictBackgroundDenylist() throws RemoteException { return resetUidPolicy("not blacklisted", POLICY_REJECT_METERED_BACKGROUND); } private int setAppIdleWhitelist(boolean isWhitelisted) { private int setAppIdleAllowlist(boolean isWhitelisted) { final int uid = getUidFromNextArg(); if (uid < 0) { return uid; Loading @@ -336,12 +336,12 @@ class NetworkPolicyManagerShellCommand extends ShellCommand { return 0; } private int addAppIdleWhitelist() throws RemoteException { return setAppIdleWhitelist(true); private int addAppIdleAllowlist() throws RemoteException { return setAppIdleAllowlist(true); } private int removeAppIdleWhitelist() throws RemoteException { return setAppIdleWhitelist(false); private int removeAppIdleAllowlist() throws RemoteException { return setAppIdleAllowlist(false); } private int listWifiNetworks() { Loading Loading
services/core/java/com/android/server/net/NetworkPolicyLogger.java +4 −4 Original line number Diff line number Diff line Loading @@ -338,8 +338,8 @@ public class NetworkPolicyLogger { return "App idle state of uid " + uid + ": " + idle; } private static String getAppIdleWlChangedLog(int uid, boolean isWhitelisted) { return "App idle whitelist state of uid " + uid + ": " + isWhitelisted; private static String getAppIdleWlChangedLog(int uid, boolean isAllowlisted) { return "App idle whitelist state of uid " + uid + ": " + isAllowlisted; } private static String getParoleStateChanged(boolean paroleOn) { Loading Loading @@ -519,14 +519,14 @@ public class NetworkPolicyLogger { data.timeStamp = System.currentTimeMillis(); } public void appIdleWlChanged(int uid, boolean isWhitelisted) { public void appIdleWlChanged(int uid, boolean isAllowlisted) { final Data data = getNextSlot(); if (data == null) return; data.reset(); data.type = EVENT_APP_IDLE_WL_CHANGED; data.ifield1 = uid; data.bfield1 = isWhitelisted; data.bfield1 = isAllowlisted; data.timeStamp = System.currentTimeMillis(); } Loading
services/core/java/com/android/server/net/NetworkPolicyManagerService.java +28 −28 Original line number Diff line number Diff line Loading @@ -362,7 +362,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { private static final String TAG_NETWORK_POLICY = "network-policy"; private static final String TAG_UID_POLICY = "uid-policy"; private static final String TAG_APP_POLICY = "app-policy"; private static final String TAG_WHITELIST = "whitelist"; private static final String TAG_ALLOWLIST = "whitelist"; private static final String TAG_RESTRICT_BACKGROUND = "restrict-background"; private static final String TAG_REVOKED_RESTRICT_BACKGROUND = "revoked-restrict-background"; private static final String TAG_XML_UTILS_INT_ARRAY = "int-array"; Loading Loading @@ -856,7 +856,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } @GuardedBy("mUidRulesFirstLock") private void updatePowerSaveWhitelistUL() { private void updatePowerSaveAllowlistUL() { int[] whitelist = mPowerWhitelistManager.getWhitelistedAppIds(/* includingIdle */ false); mPowerSaveWhitelistExceptIdleAppIds.clear(); for (int uid : whitelist) { Loading Loading @@ -947,7 +947,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { synchronized (mUidRulesFirstLock) { synchronized (mNetworkPoliciesSecondLock) { updatePowerSaveWhitelistUL(); updatePowerSaveAllowlistUL(); mPowerManagerInternal = LocalServices.getService(PowerManagerInternal.class); mPowerManagerInternal.registerLowPowerModeObserver( new PowerManagerInternal.LowPowerModeListener() { Loading Loading @@ -1189,7 +1189,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { public void onReceive(Context context, Intent intent) { // on background handler thread, and POWER_SAVE_WHITELIST_CHANGED is protected synchronized (mUidRulesFirstLock) { updatePowerSaveWhitelistUL(); updatePowerSaveAllowlistUL(); updateRulesForRestrictPowerUL(); updateRulesForAppIdleUL(); } Loading Loading @@ -2679,7 +2679,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } else { Slog.w(TAG, "unable to apply policy to UID " + uid + "; ignoring"); } } else if (TAG_WHITELIST.equals(tag)) { } else if (TAG_ALLOWLIST.equals(tag)) { insideAllowlist = true; } else if (TAG_RESTRICT_BACKGROUND.equals(tag) && insideAllowlist) { final int uid = readIntAttribute(in, ATTR_UID); Loading @@ -2689,7 +2689,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { mRestrictBackgroundAllowlistRevokedUids.put(uid, true); } } else if (type == END_TAG) { if (TAG_WHITELIST.equals(tag)) { if (TAG_ALLOWLIST.equals(tag)) { insideAllowlist = false; } Loading Loading @@ -2865,7 +2865,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { out.endTag(null, TAG_POLICY_LIST); // write all allowlists out.startTag(null, TAG_WHITELIST); out.startTag(null, TAG_ALLOWLIST); // revoked restrict background allowlist int size = mRestrictBackgroundAllowlistRevokedUids.size(); Loading @@ -2876,7 +2876,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { out.endTag(null, TAG_REVOKED_RESTRICT_BACKGROUND); } out.endTag(null, TAG_WHITELIST); out.endTag(null, TAG_ALLOWLIST); out.endDocument(); Loading Loading @@ -4356,7 +4356,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { void updateRulesForPowerSaveUL() { Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "updateRulesForPowerSaveUL"); try { updateRulesForWhitelistedPowerSaveUL(mRestrictPower, FIREWALL_CHAIN_POWERSAVE, updateRulesForAllowlistedPowerSaveUL(mRestrictPower, FIREWALL_CHAIN_POWERSAVE, mUidFirewallPowerSaveRules); } finally { Trace.traceEnd(Trace.TRACE_TAG_NETWORK); Loading @@ -4365,14 +4365,14 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { @GuardedBy("mUidRulesFirstLock") void updateRuleForRestrictPowerUL(int uid) { updateRulesForWhitelistedPowerSaveUL(uid, mRestrictPower, FIREWALL_CHAIN_POWERSAVE); updateRulesForAllowlistedPowerSaveUL(uid, mRestrictPower, FIREWALL_CHAIN_POWERSAVE); } @GuardedBy("mUidRulesFirstLock") void updateRulesForDeviceIdleUL() { Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "updateRulesForDeviceIdleUL"); try { updateRulesForWhitelistedPowerSaveUL(mDeviceIdleMode, FIREWALL_CHAIN_DOZABLE, updateRulesForAllowlistedPowerSaveUL(mDeviceIdleMode, FIREWALL_CHAIN_DOZABLE, mUidFirewallDozableRules); } finally { Trace.traceEnd(Trace.TRACE_TAG_NETWORK); Loading @@ -4381,26 +4381,26 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { @GuardedBy("mUidRulesFirstLock") void updateRuleForDeviceIdleUL(int uid) { updateRulesForWhitelistedPowerSaveUL(uid, mDeviceIdleMode, FIREWALL_CHAIN_DOZABLE); updateRulesForAllowlistedPowerSaveUL(uid, mDeviceIdleMode, FIREWALL_CHAIN_DOZABLE); } // NOTE: since both fw_dozable and fw_powersave uses the same map // (mPowerSaveTempWhitelistAppIds) for allowlisting, we can reuse their logic in this method. @GuardedBy("mUidRulesFirstLock") private void updateRulesForWhitelistedPowerSaveUL(boolean enabled, int chain, private void updateRulesForAllowlistedPowerSaveUL(boolean enabled, int chain, SparseIntArray rules) { if (enabled) { // Sync the whitelists before enabling the chain. We don't care about the rules if // Sync the allowlists before enabling the chain. We don't care about the rules if // we are disabling the chain. final SparseIntArray uidRules = rules; uidRules.clear(); final List<UserInfo> users = mUserManager.getUsers(); for (int ui = users.size() - 1; ui >= 0; ui--) { UserInfo user = users.get(ui); updateRulesForWhitelistedAppIds(uidRules, mPowerSaveTempWhitelistAppIds, user.id); updateRulesForWhitelistedAppIds(uidRules, mPowerSaveWhitelistAppIds, user.id); updateRulesForAllowlistedAppIds(uidRules, mPowerSaveTempWhitelistAppIds, user.id); updateRulesForAllowlistedAppIds(uidRules, mPowerSaveWhitelistAppIds, user.id); if (chain == FIREWALL_CHAIN_POWERSAVE) { updateRulesForWhitelistedAppIds(uidRules, updateRulesForAllowlistedAppIds(uidRules, mPowerSaveWhitelistExceptIdleAppIds, user.id); } } Loading @@ -4415,7 +4415,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } } private void updateRulesForWhitelistedAppIds(final SparseIntArray uidRules, private void updateRulesForAllowlistedAppIds(final SparseIntArray uidRules, final SparseBooleanArray whitelistedAppIds, int userId) { for (int i = whitelistedAppIds.size() - 1; i >= 0; --i) { if (whitelistedAppIds.valueAt(i)) { Loading Loading @@ -4476,12 +4476,12 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { * allowlisted. */ @GuardedBy("mUidRulesFirstLock") private boolean isWhitelistedFromPowerSaveUL(int uid, boolean deviceIdleMode) { private boolean isAllowlistedFromPowerSaveUL(int uid, boolean deviceIdleMode) { final int appId = UserHandle.getAppId(uid); boolean isWhitelisted = mPowerSaveTempWhitelistAppIds.get(appId) || mPowerSaveWhitelistAppIds.get(appId); if (!deviceIdleMode) { isWhitelisted = isWhitelisted || isWhitelistedFromPowerSaveExceptIdleUL(uid); isWhitelisted = isWhitelisted || isAllowlistedFromPowerSaveExceptIdleUL(uid); } return isWhitelisted; } Loading @@ -4491,7 +4491,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { * (eg: Battery Saver and app idle). */ @GuardedBy("mUidRulesFirstLock") private boolean isWhitelistedFromPowerSaveExceptIdleUL(int uid) { private boolean isAllowlistedFromPowerSaveExceptIdleUL(int uid) { final int appId = UserHandle.getAppId(uid); return mPowerSaveWhitelistExceptIdleAppIds.get(appId); } Loading @@ -4507,9 +4507,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { // NOTE: since both fw_dozable and fw_powersave uses the same map // (mPowerSaveTempWhitelistAppIds) for allowlisting, we can reuse their logic in this method. @GuardedBy("mUidRulesFirstLock") private void updateRulesForWhitelistedPowerSaveUL(int uid, boolean enabled, int chain) { private void updateRulesForAllowlistedPowerSaveUL(int uid, boolean enabled, int chain) { if (enabled) { final boolean isWhitelisted = isWhitelistedFromPowerSaveUL(uid, final boolean isWhitelisted = isAllowlistedFromPowerSaveUL(uid, chain == FIREWALL_CHAIN_DOZABLE); if (isWhitelisted || isUidForegroundOnRestrictPowerUL(uid)) { setUidFirewallRuleUL(chain, uid, FIREWALL_RULE_ALLOW); Loading Loading @@ -4767,7 +4767,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } @GuardedBy("mUidRulesFirstLock") private void updateRulesForTempWhitelistChangeUL(int appId) { private void updateRulesForTempAllowlistChangeUL(int appId) { final List<UserInfo> users = mUserManager.getUsers(); final int numUsers = users.size(); for (int i = 0; i < numUsers; i++) { Loading Loading @@ -5158,7 +5158,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { final boolean isForeground = isUidForegroundOnRestrictPowerUL(uid); final boolean isTop = isUidTop(uid); final boolean isWhitelisted = isWhitelistedFromPowerSaveUL(uid, mDeviceIdleMode); final boolean isWhitelisted = isAllowlistedFromPowerSaveUL(uid, mDeviceIdleMode); final int oldEffectiveBlockedReasons; final int newEffectiveBlockedReasons; Loading @@ -5181,9 +5181,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { newAllowedReasons |= (isSystem(uid) ? ALLOWED_REASON_SYSTEM : 0); newAllowedReasons |= (isForeground ? ALLOWED_REASON_FOREGROUND : 0); newAllowedReasons |= (isTop ? ALLOWED_REASON_TOP : 0); newAllowedReasons |= (isWhitelistedFromPowerSaveUL(uid, true) newAllowedReasons |= (isAllowlistedFromPowerSaveUL(uid, true) ? ALLOWED_REASON_POWER_SAVE_ALLOWLIST : 0); newAllowedReasons |= (isWhitelistedFromPowerSaveExceptIdleUL(uid) newAllowedReasons |= (isAllowlistedFromPowerSaveExceptIdleUL(uid) ? ALLOWED_REASON_POWER_SAVE_EXCEPT_IDLE_ALLOWLIST : 0); newAllowedReasons |= (uidBlockedState.allowedReasons & ALLOWED_REASON_RESTRICTED_MODE_PERMISSIONS); Loading Loading @@ -6095,7 +6095,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } else { mPowerSaveTempWhitelistAppIds.delete(appId); } updateRulesForTempWhitelistChangeUL(appId); updateRulesForTempAllowlistChangeUL(appId); } } Loading
services/core/java/com/android/server/net/NetworkPolicyManagerShellCommand.java +21 −21 Original line number Diff line number Diff line Loading @@ -154,13 +154,13 @@ class NetworkPolicyManagerShellCommand extends ShellCommand { } switch(type) { case "app-idle-whitelist": return listAppIdleWhitelist(); return listAppIdleAllowlist(); case "wifi-networks": return listWifiNetworks(); case "restrict-background-whitelist": return listRestrictBackgroundWhitelist(); return listRestrictBackgroundAllowlist(); case "restrict-background-blacklist": return listRestrictBackgroundBlacklist(); return listRestrictBackgroundDenylist(); } pw.println("Error: unknown list type '" + type + "'"); return -1; Loading @@ -175,11 +175,11 @@ class NetworkPolicyManagerShellCommand extends ShellCommand { } switch(type) { case "restrict-background-whitelist": return addRestrictBackgroundWhitelist(); return addRestrictBackgroundAllowlist(); case "restrict-background-blacklist": return addRestrictBackgroundBlacklist(); return addRestrictBackgroundDenylist(); case "app-idle-whitelist": return addAppIdleWhitelist(); return addAppIdleAllowlist(); } pw.println("Error: unknown add type '" + type + "'"); return -1; Loading @@ -194,11 +194,11 @@ class NetworkPolicyManagerShellCommand extends ShellCommand { } switch(type) { case "restrict-background-whitelist": return removeRestrictBackgroundWhitelist(); return removeRestrictBackgroundAllowlist(); case "restrict-background-blacklist": return removeRestrictBackgroundBlacklist(); return removeRestrictBackgroundDenylist(); case "app-idle-whitelist": return removeAppIdleWhitelist(); return removeAppIdleAllowlist(); } pw.println("Error: unknown remove type '" + type + "'"); return -1; Loading Loading @@ -241,17 +241,17 @@ class NetworkPolicyManagerShellCommand extends ShellCommand { return 0; } private int listRestrictBackgroundWhitelist() throws RemoteException { private int listRestrictBackgroundAllowlist() throws RemoteException { return listUidPolicies("Restrict background whitelisted UIDs", POLICY_ALLOW_METERED_BACKGROUND); } private int listRestrictBackgroundBlacklist() throws RemoteException { private int listRestrictBackgroundDenylist() throws RemoteException { return listUidPolicies("Restrict background blacklisted UIDs", POLICY_REJECT_METERED_BACKGROUND); } private int listAppIdleWhitelist() throws RemoteException { private int listAppIdleAllowlist() throws RemoteException { final PrintWriter pw = getOutPrintWriter(); final int[] uids = mInterface.getAppIdleWhitelist(); return listUidList("App Idle whitelisted UIDs", uids); Loading Loading @@ -311,23 +311,23 @@ class NetworkPolicyManagerShellCommand extends ShellCommand { return 0; } private int addRestrictBackgroundWhitelist() throws RemoteException { private int addRestrictBackgroundAllowlist() throws RemoteException { return setUidPolicy(POLICY_ALLOW_METERED_BACKGROUND); } private int removeRestrictBackgroundWhitelist() throws RemoteException { private int removeRestrictBackgroundAllowlist() throws RemoteException { return resetUidPolicy("not whitelisted", POLICY_ALLOW_METERED_BACKGROUND); } private int addRestrictBackgroundBlacklist() throws RemoteException { private int addRestrictBackgroundDenylist() throws RemoteException { return setUidPolicy(POLICY_REJECT_METERED_BACKGROUND); } private int removeRestrictBackgroundBlacklist() throws RemoteException { private int removeRestrictBackgroundDenylist() throws RemoteException { return resetUidPolicy("not blacklisted", POLICY_REJECT_METERED_BACKGROUND); } private int setAppIdleWhitelist(boolean isWhitelisted) { private int setAppIdleAllowlist(boolean isWhitelisted) { final int uid = getUidFromNextArg(); if (uid < 0) { return uid; Loading @@ -336,12 +336,12 @@ class NetworkPolicyManagerShellCommand extends ShellCommand { return 0; } private int addAppIdleWhitelist() throws RemoteException { return setAppIdleWhitelist(true); private int addAppIdleAllowlist() throws RemoteException { return setAppIdleAllowlist(true); } private int removeAppIdleWhitelist() throws RemoteException { return setAppIdleWhitelist(false); private int removeAppIdleAllowlist() throws RemoteException { return setAppIdleAllowlist(false); } private int listWifiNetworks() { Loading