Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 76e523aa authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Update language to comply with Android’s inclusive language guidance.

See https://source.android.com/setup/contribute/respectful-code for reference

Leaving the power save whitelists as is for now. These will be handled
in a follow-up cl.

Bug: 161896447
Test: atest ./hostsidetests/net/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Test: atest ./services/tests/servicestests/src/com/android/server/net/NetworkPolicyManagerServiceTest.java
Change-Id: I5059d8362a02a7b4622c71fdf15297af87c5a3dd
parent 6117d617
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -287,8 +287,8 @@ interface INetworkManagementService
    /**
    /**
     * Control network activity of a UID over interfaces with a quota limit.
     * Control network activity of a UID over interfaces with a quota limit.
     */
     */
    void setUidMeteredNetworkBlacklist(int uid, boolean enable);
    void setUidMeteredNetworkDenylist(int uid, boolean enable);
    void setUidMeteredNetworkWhitelist(int uid, boolean enable);
    void setUidMeteredNetworkAllowlist(int uid, boolean enable);
    boolean setDataSaverModeEnabled(boolean enable);
    boolean setDataSaverModeEnabled(boolean enable);


    void setUidCleartextNetworkPolicy(int uid, int policy);
    void setUidCleartextNetworkPolicy(int uid, int policy);
+18 −18
Original line number Original line Diff line number Diff line
@@ -185,10 +185,10 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
    /** Set of interfaces with active alerts. */
    /** Set of interfaces with active alerts. */
    @GuardedBy("mQuotaLock")
    @GuardedBy("mQuotaLock")
    private HashMap<String, Long> mActiveAlerts = Maps.newHashMap();
    private HashMap<String, Long> mActiveAlerts = Maps.newHashMap();
    /** Set of UIDs blacklisted on metered networks. */
    /** Set of UIDs denylisted on metered networks. */
    @GuardedBy("mRulesLock")
    @GuardedBy("mRulesLock")
    private SparseBooleanArray mUidRejectOnMetered = new SparseBooleanArray();
    private SparseBooleanArray mUidRejectOnMetered = new SparseBooleanArray();
    /** Set of UIDs whitelisted on metered networks. */
    /** Set of UIDs allowlisted on metered networks. */
    @GuardedBy("mRulesLock")
    @GuardedBy("mRulesLock")
    private SparseBooleanArray mUidAllowOnMetered = new SparseBooleanArray();
    private SparseBooleanArray mUidAllowOnMetered = new SparseBooleanArray();
    /** Set of UIDs with cleartext penalties. */
    /** Set of UIDs with cleartext penalties. */
@@ -561,27 +561,27 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
            synchronized (mRulesLock) {
            synchronized (mRulesLock) {
                size = mUidRejectOnMetered.size();
                size = mUidRejectOnMetered.size();
                if (size > 0) {
                if (size > 0) {
                    if (DBG) Slog.d(TAG, "Pushing " + size + " UIDs to metered blacklist rules");
                    if (DBG) Slog.d(TAG, "Pushing " + size + " UIDs to metered denylist rules");
                    uidRejectOnQuota = mUidRejectOnMetered;
                    uidRejectOnQuota = mUidRejectOnMetered;
                    mUidRejectOnMetered = new SparseBooleanArray();
                    mUidRejectOnMetered = new SparseBooleanArray();
                }
                }


                size = mUidAllowOnMetered.size();
                size = mUidAllowOnMetered.size();
                if (size > 0) {
                if (size > 0) {
                    if (DBG) Slog.d(TAG, "Pushing " + size + " UIDs to metered whitelist rules");
                    if (DBG) Slog.d(TAG, "Pushing " + size + " UIDs to metered allowlist rules");
                    uidAcceptOnQuota = mUidAllowOnMetered;
                    uidAcceptOnQuota = mUidAllowOnMetered;
                    mUidAllowOnMetered = new SparseBooleanArray();
                    mUidAllowOnMetered = new SparseBooleanArray();
                }
                }
            }
            }
            if (uidRejectOnQuota != null) {
            if (uidRejectOnQuota != null) {
                for (int i = 0; i < uidRejectOnQuota.size(); i++) {
                for (int i = 0; i < uidRejectOnQuota.size(); i++) {
                    setUidMeteredNetworkBlacklist(uidRejectOnQuota.keyAt(i),
                    setUidMeteredNetworkDenylist(uidRejectOnQuota.keyAt(i),
                            uidRejectOnQuota.valueAt(i));
                            uidRejectOnQuota.valueAt(i));
                }
                }
            }
            }
            if (uidAcceptOnQuota != null) {
            if (uidAcceptOnQuota != null) {
                for (int i = 0; i < uidAcceptOnQuota.size(); i++) {
                for (int i = 0; i < uidAcceptOnQuota.size(); i++) {
                    setUidMeteredNetworkWhitelist(uidAcceptOnQuota.keyAt(i),
                    setUidMeteredNetworkAllowlist(uidAcceptOnQuota.keyAt(i),
                            uidAcceptOnQuota.valueAt(i));
                            uidAcceptOnQuota.valueAt(i));
                }
                }
            }
            }
@@ -1307,14 +1307,14 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
        }
        }
    }
    }


    private void setUidOnMeteredNetworkList(int uid, boolean blacklist, boolean enable) {
    private void setUidOnMeteredNetworkList(int uid, boolean denylist, boolean enable) {
        NetworkStack.checkNetworkStackPermission(mContext);
        NetworkStack.checkNetworkStackPermission(mContext);


        synchronized (mQuotaLock) {
        synchronized (mQuotaLock) {
            boolean oldEnable;
            boolean oldEnable;
            SparseBooleanArray quotaList;
            SparseBooleanArray quotaList;
            synchronized (mRulesLock) {
            synchronized (mRulesLock) {
                quotaList = blacklist ? mUidRejectOnMetered : mUidAllowOnMetered;
                quotaList = denylist ? mUidRejectOnMetered : mUidAllowOnMetered;
                oldEnable = quotaList.get(uid, false);
                oldEnable = quotaList.get(uid, false);
            }
            }
            if (oldEnable == enable) {
            if (oldEnable == enable) {
@@ -1324,7 +1324,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub {


            Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "inetd bandwidth");
            Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "inetd bandwidth");
            try {
            try {
                if (blacklist) {
                if (denylist) {
                    if (enable) {
                    if (enable) {
                        mNetdService.bandwidthAddNaughtyApp(uid);
                        mNetdService.bandwidthAddNaughtyApp(uid);
                    } else {
                    } else {
@@ -1353,12 +1353,12 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
    }
    }


    @Override
    @Override
    public void setUidMeteredNetworkBlacklist(int uid, boolean enable) {
    public void setUidMeteredNetworkDenylist(int uid, boolean enable) {
        setUidOnMeteredNetworkList(uid, true, enable);
        setUidOnMeteredNetworkList(uid, true, enable);
    }
    }


    @Override
    @Override
    public void setUidMeteredNetworkWhitelist(int uid, boolean enable) {
    public void setUidMeteredNetworkAllowlist(int uid, boolean enable) {
        setUidOnMeteredNetworkList(uid, false, enable);
        setUidOnMeteredNetworkList(uid, false, enable);
    }
    }


@@ -1626,7 +1626,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
                    }
                    }
                }
                }
            }
            }
            // Normally, whitelist chains only contain deny rules, so numUids == exemptUids.length.
            // Normally, allowlist chains only contain deny rules, so numUids == exemptUids.length.
            // But the code does not guarantee this in any way, and at least in one case - if we add
            // But the code does not guarantee this in any way, and at least in one case - if we add
            // a UID rule to the firewall, and then disable the firewall - the chains can contain
            // a UID rule to the firewall, and then disable the firewall - the chains can contain
            // the wrong type of rule. In this case, don't close connections that we shouldn't.
            // the wrong type of rule. In this case, don't close connections that we shouldn't.
@@ -1691,7 +1691,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
            // Close any sockets that were opened by the affected UIDs. This has to be done after
            // Close any sockets that were opened by the affected UIDs. This has to be done after
            // disabling network connectivity, in case they react to the socket close by reopening
            // disabling network connectivity, in case they react to the socket close by reopening
            // the connection and race with the iptables commands that enable the firewall. All
            // the connection and race with the iptables commands that enable the firewall. All
            // whitelist and blacklist chains allow RSTs through.
            // allowlist and denylist chains allow RSTs through.
            if (enable) {
            if (enable) {
                closeSocketsForFirewallChainLocked(chain, chainName);
                closeSocketsForFirewallChainLocked(chain, chainName);
            }
            }
@@ -1828,7 +1828,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
            } else {
            } else {
                ruleName = "deny";
                ruleName = "deny";
            }
            }
        } else { // Blacklist mode
        } else { // Denylist mode
            if (rule == FIREWALL_RULE_DENY) {
            if (rule == FIREWALL_RULE_DENY) {
                ruleName = "deny";
                ruleName = "deny";
            } else {
            } else {
@@ -1913,8 +1913,8 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
            pw.print("Active alert ifaces: "); pw.println(mActiveAlerts.toString());
            pw.print("Active alert ifaces: "); pw.println(mActiveAlerts.toString());
            pw.print("Data saver mode: "); pw.println(mDataSaverMode);
            pw.print("Data saver mode: "); pw.println(mDataSaverMode);
            synchronized (mRulesLock) {
            synchronized (mRulesLock) {
                dumpUidRuleOnQuotaLocked(pw, "blacklist", mUidRejectOnMetered);
                dumpUidRuleOnQuotaLocked(pw, "denylist", mUidRejectOnMetered);
                dumpUidRuleOnQuotaLocked(pw, "whitelist", mUidAllowOnMetered);
                dumpUidRuleOnQuotaLocked(pw, "allowlist", mUidAllowOnMetered);
            }
            }
        }
        }


@@ -2179,9 +2179,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
            }
            }
        }
        }


        void setUidOnMeteredNetworkList(boolean blacklist, int uid, boolean enable) {
        void setUidOnMeteredNetworkList(boolean denylist, int uid, boolean enable) {
            synchronized (mRulesLock) {
            synchronized (mRulesLock) {
                if (blacklist) {
                if (denylist) {
                    mUidRejectOnMetered.put(uid, enable);
                    mUidRejectOnMetered.put(uid, enable);
                } else {
                } else {
                    mUidAllowOnMetered.put(uid, enable);
                    mUidAllowOnMetered.put(uid, enable);
+9 −9
Original line number Original line Diff line number Diff line
@@ -70,9 +70,9 @@ public class NetworkPolicyLogger {


    static final int NTWK_BLOCKED_POWER = 0;
    static final int NTWK_BLOCKED_POWER = 0;
    static final int NTWK_ALLOWED_NON_METERED = 1;
    static final int NTWK_ALLOWED_NON_METERED = 1;
    static final int NTWK_BLOCKED_BLACKLIST = 2;
    static final int NTWK_BLOCKED_DENYLIST = 2;
    static final int NTWK_ALLOWED_WHITELIST = 3;
    static final int NTWK_ALLOWED_ALLOWLIST = 3;
    static final int NTWK_ALLOWED_TMP_WHITELIST = 4;
    static final int NTWK_ALLOWED_TMP_ALLOWLIST = 4;
    static final int NTWK_BLOCKED_BG_RESTRICT = 5;
    static final int NTWK_BLOCKED_BG_RESTRICT = 5;
    static final int NTWK_ALLOWED_DEFAULT = 6;
    static final int NTWK_ALLOWED_DEFAULT = 6;
    static final int NTWK_ALLOWED_SYSTEM = 7;
    static final int NTWK_ALLOWED_SYSTEM = 7;
@@ -269,12 +269,12 @@ public class NetworkPolicyLogger {
                return "blocked by power restrictions";
                return "blocked by power restrictions";
            case NTWK_ALLOWED_NON_METERED:
            case NTWK_ALLOWED_NON_METERED:
                return "allowed on unmetered network";
                return "allowed on unmetered network";
            case NTWK_BLOCKED_BLACKLIST:
            case NTWK_BLOCKED_DENYLIST:
                return "blacklisted on metered network";
                return "denylisted on metered network";
            case NTWK_ALLOWED_WHITELIST:
            case NTWK_ALLOWED_ALLOWLIST:
                return "whitelisted on metered network";
                return "allowlisted on metered network";
            case NTWK_ALLOWED_TMP_WHITELIST:
            case NTWK_ALLOWED_TMP_ALLOWLIST:
                return "temporary whitelisted on metered network";
                return "temporary allowlisted on metered network";
            case NTWK_BLOCKED_BG_RESTRICT:
            case NTWK_BLOCKED_BG_RESTRICT:
                return "blocked when background is restricted";
                return "blocked when background is restricted";
            case NTWK_ALLOWED_DEFAULT:
            case NTWK_ALLOWED_DEFAULT:
+132 −132

File changed.

Preview size limit exceeded, changes collapsed.

+0 −0

File moved.

Loading