OSDN Git Service

Remove the ability to enable/disable the happy box.
authorLorenzo Colitti <lorenzo@google.com>
Fri, 18 Mar 2016 03:05:19 +0000 (12:05 +0900)
committerLorenzo Colitti <lorenzo@google.com>
Fri, 18 Mar 2016 03:05:19 +0000 (12:05 +0900)
This code is unused, and the plan is to have the happy box
enabled at all times.

Bug: 26685616
Bug: 27506285
Change-Id: Ie15b0775d535df7ca94547a7d8b8a5ed536e6dbd

server/BandwidthController.cpp
server/BandwidthController.h
server/CommandListener.cpp

index ae78d95..dcebb9f 100644 (file)
@@ -326,54 +326,6 @@ std::string BandwidthController::makeIptablesSpecialAppCmd(IptOp op, int uid, co
     return res;
 }
 
-int BandwidthController::enableHappyBox(void) {
-    char cmd[MAX_CMD_LEN];
-    int res = 0;
-
-    /*
-     * We tentatively delete before adding, which helps recovering
-     * from bad states (e.g. netd died).
-     */
-
-    /* Should not exist, but ignore result if already there. */
-    snprintf(cmd, sizeof(cmd), "-N bw_happy_box");
-    runIpxtablesCmd(cmd, IptJumpNoAdd);
-
-    /* Should be empty, but clear in case something was wrong. */
-    snprintf(cmd, sizeof(cmd), "-F bw_happy_box");
-    res |= runIpxtablesCmd(cmd, IptJumpNoAdd);
-
-    snprintf(cmd, sizeof(cmd), "-D bw_penalty_box -j bw_happy_box");
-    runIpxtablesCmd(cmd, IptJumpNoAdd);
-    snprintf(cmd, sizeof(cmd), "-A bw_penalty_box -j bw_happy_box");
-    res |= runIpxtablesCmd(cmd, IptJumpNoAdd);
-
-    /* Whitelist all system apps. */
-    snprintf(cmd, sizeof(cmd),
-            "-A bw_happy_box -m owner --uid-owner %d-%d -j RETURN", 0, MAX_SYSTEM_UID);
-    res |= runIpxtablesCmd(cmd, IptJumpNoAdd);
-
-    /* Reject. Defaulting to prot-unreachable */
-    snprintf(cmd, sizeof(cmd), "-A bw_happy_box -j REJECT");
-    res |= runIpxtablesCmd(cmd, IptJumpNoAdd);
-
-    return res;
-}
-
-int BandwidthController::disableHappyBox(void) {
-    char cmd[MAX_CMD_LEN];
-
-    /* Best effort */
-    snprintf(cmd, sizeof(cmd), "-D bw_penalty_box -j bw_happy_box");
-    runIpxtablesCmd(cmd, IptJumpNoAdd);
-    snprintf(cmd, sizeof(cmd), "-F bw_happy_box");
-    runIpxtablesCmd(cmd, IptJumpNoAdd);
-    snprintf(cmd, sizeof(cmd), "-X bw_happy_box");
-    runIpxtablesCmd(cmd, IptJumpNoAdd);
-
-    return 0;
-}
-
 int BandwidthController::addNaughtyApps(int numUids, char *appUids[]) {
     return manipulateNaughtyApps(numUids, appUids, SpecialAppOpAdd);
 }
index 51e9142..c653e2f 100644 (file)
@@ -64,8 +64,6 @@ public:
     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[]);
index 485e36f..968b415 100644 (file)
@@ -1033,25 +1033,6 @@ int CommandListener::BandwidthControlCmd::runCommand(SocketClient *cli, int argc
         sendGenericOkFail(cli, rc);
         return 0;
     }
-    if (!strcmp(argv[1], "happybox")) {
-        if (argc < 3) {
-            sendGenericSyntaxError(cli, "happybox (enable | disable)");
-            return 0;
-        }
-        if (!strcmp(argv[2], "enable")) {
-            int rc = gCtls->bandwidthCtrl.enableHappyBox();
-            sendGenericOkFail(cli, rc);
-            return 0;
-
-        }
-        if (!strcmp(argv[2], "disable")) {
-            int rc = gCtls->bandwidthCtrl.disableHappyBox();
-            sendGenericOkFail(cli, rc);
-            return 0;
-        }
-        sendGenericSyntaxError(cli, "happybox (enable | disable)");
-        return 0;
-    }
     if (!strcmp(argv[1], "addniceapps") || !strcmp(argv[1], "aha")) {
         if (argc < 3) {
             sendGenericSyntaxError(cli, "addniceapps <appUid> ...");