OSDN Git Service

Uses bw_happy_box and bw_penalty_box for Data Saver.
authorFelipe Leme <felipeal@google.com>
Tue, 29 Mar 2016 17:45:13 +0000 (10:45 -0700)
committerFelipe Leme <felipeal@google.com>
Wed, 30 Mar 2016 21:54:58 +0000 (14:54 -0700)
commit70c57c2810eb5004ac6487921bfdf0880f818e3c
tree66b15c8fdf205c5abbdf297786e3c5436f4f9fc6
parent43b5d980d89f4badfe89008febf5fcd6e1ae9d49
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
core/java/android/net/NetworkPolicyManager.java
services/core/java/com/android/server/net/NetworkPolicyManagerService.java