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

Commit 70c57c28 authored by Felipe Leme's avatar Felipe Leme
Browse files

Uses bw_happy_box and bw_penalty_box for Data Saver.

bw_penalty_box is a blacklist-based firewall chain used to determine
which UIDs do not have access to metered interfaces. It can be used
alone or with bw_happy_box, which is a whitelist-based chain: when
bw_happy_box is enabled, it's included in the bw_penalty_box chain.

Currently, NMPS and NMS uses just bw_penalty_box for both blacklist and
whitelist, so when Data Saver is turned on, it has to build a extensive
list of UIDs to be blacklisted, which can take seconds (since it makes
dozens of iptables, and which forks an iptables process)

This CL changes this behavior so it uses both chain (plus a new
bw_data_saver chain, which is added to the end of bw_happy_box), in
which case the Data Saver switch is much faster (around 120-160ms),
since it requires just 1 or 2 iptables calls (one to switch the
bw_data_saver rule, and another to whitelist the foreground app if it's
not whitelisted yet).

BUG: 27127112
BUG: 26685616

Change-Id: If10222aef9f49a924b07b978d4bdccdd92f9acdb
parent 43b5d980
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -57,6 +57,10 @@ public class NetworkPolicyManager {
    public static final int RULE_REJECT_METERED = 1;
    /** Reject traffic on all networks. */
    public static final int RULE_REJECT_ALL = 2;
    /** Allow traffic on metered networks. */
    public static final int RULE_ALLOW_METERED = 3;
    /** Temporarily allow traffic on metered networks because app is on foreground. */
    public static final int RULE_TEMPORARY_ALLOW_METERED = 4;

    public static final int FIREWALL_RULE_DEFAULT = 0;
    public static final int FIREWALL_RULE_ALLOW = 1;
+195 −50

File changed.

Preview size limit exceeded, changes collapsed.