Initialize IDLETIMER iptables rules for ipv6.

Bug: 12845905
Change-Id: I28f460766a29f0ca4386c8064ffe52c39f907084
diff --git a/IdletimerController.cpp b/IdletimerController.cpp
index 54b4edd..76b79a7 100644
--- a/IdletimerController.cpp
+++ b/IdletimerController.cpp
@@ -14,8 +14,6 @@
  * limitations under the License.
  */
 
-// #define LOG_NDEBUG 0
-
 /*
  * MODUS OPERANDI
  * --------------
@@ -95,6 +93,8 @@
  *
  */
 
+#define LOG_NDEBUG 0
+
 #include <stdlib.h>
 #include <errno.h>
 #include <sys/socket.h>
@@ -123,11 +123,27 @@
 }
 /* return 0 or non-zero */
 int IdletimerController::runIpxtablesCmd(int argc, const char **argv) {
-    int res;
+    int resIpv4, resIpv6;
 
-    res = android_fork_execvp(argc, (char **)argv, NULL, false, false);
-    ALOGV("runCmd() res=%d", res);
-    return res;
+    // Running for IPv4
+    argv[0] = IPTABLES_PATH;
+    resIpv4 = android_fork_execvp(argc, (char **)argv, NULL, false, false);
+
+    // Running for IPv6
+    argv[0] = IP6TABLES_PATH;
+    resIpv6 = android_fork_execvp(argc, (char **)argv, NULL, false, false);
+
+#if !LOG_NDEBUG
+    std::string full_cmd = argv[0];
+    argc--; argv++;
+    for (; argc; argc--, argv++) {
+        full_cmd += " ";
+        full_cmd += argv[0];
+    }
+    ALOGV("runCmd(%s) res_ipv4=%d, res_ipv6=%d", full_cmd.c_str(), resIpv4, resIpv6);
+#endif
+
+    return (resIpv4 == 0 && resIpv6 == 0) ? 0 : -1;
 }
 
 bool IdletimerController::setupIptablesHooks() {
@@ -137,7 +153,7 @@
 int IdletimerController::setDefaults() {
   int res;
   const char *cmd1[] = {
-      IPTABLES_PATH,
+      NULL, // To be filled inside runIpxtablesCmd
       "-t",
       "raw",
       "-F",
@@ -149,7 +165,7 @@
     return res;
 
   const char *cmd2[] = {
-      IPTABLES_PATH,
+      NULL, // To be filled inside runIpxtablesCmd
       "-t",
       "mangle",
       "-F",
@@ -179,7 +195,7 @@
   snprintf(timeout_str, sizeof(timeout_str), "%u", timeout);
 
   const char *cmd1[] = {
-      IPTABLES_PATH,
+      NULL, // To be filled inside runIpxtablesCmd
       "-t",
       "raw",
       (op == IptOpAdd) ? "-A" : "-D",
@@ -201,7 +217,7 @@
     return res;
 
   const char *cmd2[] = {
-      IPTABLES_PATH,
+      NULL, // To be filled inside runIpxtablesCmd
       "-t",
       "mangle",
       (op == IptOpAdd) ? "-A" : "-D",