BandwidthController: add support for "nice apps" and the "happy box"
* ndc bandwidth happybox (enable | disable)
- enable
. creates a an empty happy_box chain which rejects all traffic from all UIDs by default.
. Uses the penalty_box as a hook. Any costly_interface automatically gets the happy_box as it has a penalty_box.
. any app UID not in the happy_box will be treated as if it was in the penalty_box (i.e. addnaughtyapps)
. penalty_box (addnaughtyapps) still applies.
- disable
. removes the happy box.
* ndc bandwidth addniceapps <appUid> ...
- similar to addnaughtyapps, but for the happy_box
* ndc bandwidth removeniceapps <appUid> ...
- similar to removenaughtyapps, but for the happy_box
Bug: 6212480
Change-Id: I1f10e8c6fa1b230c7b3bb070d88508e437589705
diff --git a/BandwidthController.h b/BandwidthController.h
index b76ee0a..3953e26 100644
--- a/BandwidthController.h
+++ b/BandwidthController.h
@@ -64,8 +64,12 @@
int getInterfaceQuota(const char *iface, int64_t *bytes);
int removeInterfaceQuota(const char *iface);
+ int enableHappyBox(void);
+ int disableHappyBox(void);
int addNaughtyApps(int numUids, char *appUids[]);
int removeNaughtyApps(int numUids, char *appUids[]);
+ int addNiceApps(int numUids, char *appUids[]);
+ int removeNiceApps(int numUids, char *appUids[]);
int setGlobalAlert(int64_t bytes);
int removeGlobalAlert(void);
@@ -120,6 +124,7 @@
std::list<int /*appUid*/> &specialAppUids,
IptJumpOp jumpHandling, SpecialAppOp appOp);
int manipulateNaughtyApps(int numUids, char *appStrUids[], SpecialAppOp appOp);
+ int manipulateNiceApps(int numUids, char *appStrUids[], SpecialAppOp appOp);
int prepCostlyIface(const char *ifn, QuotaType quotaType);
int cleanupCostlyIface(const char *ifn, QuotaType quotaType);
@@ -177,6 +182,7 @@
std::list<QuotaInfo> quotaIfaces;
std::list<int /*appUid*/> naughtyAppUids;
+ std::list<int /*appUid*/> niceAppUids;
private:
static const char *IPT_FLUSH_COMMANDS[];