netd: Netlink: Use KOBJECT_UEVENT instead of IDLETIMER

The initial idletimer support required using NETLINK_IDLETIMER
netlink socket type.
Instead we now just re-use the existing KOBJECT_UEVENT socket.

Change-Id: I951f2f29182c7cf7f29a054a0eabc88dc25f6d1f
diff --git a/NetlinkHandler.cpp b/NetlinkHandler.cpp
index a4f039c..9a0a844 100644
--- a/NetlinkHandler.cpp
+++ b/NetlinkHandler.cpp
@@ -52,6 +52,8 @@
         return;
     }
 
+    ALOGV("subsystem %s", subsys);
+
     if (!strcmp(subsys, "net")) {
         int action = evt->getAction();
         const char *iface = evt->findParam("INTERFACE");
@@ -68,19 +70,19 @@
         } else if (action == evt->NlActionLinkDown) {
             notifyInterfaceLinkChanged(iface, false);
         }
+
     } else if (!strcmp(subsys, "qlog")) {
         const char *alertName = evt->findParam("ALERT_NAME");
         const char *iface = evt->findParam("INTERFACE");
         notifyQuotaLimitReached(alertName, iface);
-    } else if (!strcmp(subsys, "idletimer")) {
+
+    } else if (!strcmp(subsys, "xt_idletimer")) {
         int action = evt->getAction();
         const char *iface = evt->findParam("INTERFACE");
+        const char *state = evt->findParam("STATE");
+        if (state)
+            notifyInterfaceActivity(iface, !strcmp("active", state));
 
-        if (action == evt->NlActionIfaceActive) {
-            notifyInterfaceActivity(iface, true);
-        } else if (action == evt->NlActionIfaceIdle) {
-            notifyInterfaceActivity(iface, false);
-        }
     }
 }
 
@@ -129,8 +131,8 @@
 void NetlinkHandler::notifyInterfaceActivity(const char *name, bool isActive) {
     char msg[255];
 
-    snprintf(msg, sizeof(msg), "Iface %s %s", isActive ? "active" : "idle", name);
-
+    snprintf(msg, sizeof(msg), "Iface %s %s", name, isActive ? "active" : "idle");
+    ALOGV("Broadcasting interface activity msg: %s", msg);
     mNm->getBroadcaster()->sendBroadcast(isActive ? ResponseCode::InterfaceActive
             : ResponseCode::InterfaceIdle,
             msg, false);
diff --git a/NetlinkManager.cpp b/NetlinkManager.cpp
index 2d8a4de..8e2bc69 100644
--- a/NetlinkManager.cpp
+++ b/NetlinkManager.cpp
@@ -34,7 +34,6 @@
 #include "NetlinkHandler.h"
 
 const int NetlinkManager::NFLOG_QUOTA_GROUP = 1;
-const int NetlinkManager::IDLETIMER_GROUP = 1;
 
 NetlinkManager *NetlinkManager::sInstance = NULL;
 
@@ -113,11 +112,6 @@
         // TODO: return -1 once the emulator gets a new kernel.
     }
 
-    if ((mIfaceIdleTimerHandler = setupSocket(&mIfaceIdleTimerSock, NETLINK_IDLETIMER,
-        IDLETIMER_GROUP, NetlinkListener::NETLINK_FORMAT_BINARY)) == NULL) {
-        // TODO: switch back to using NETLINK_NFLOG with a custom type.
-	ALOGE("Unable to open iface idletimer socket");
-    }
     return 0;
 }
 
@@ -159,18 +153,5 @@
         mQuotaSock = -1;
     }
 
-    if (mIfaceIdleTimerHandler) {
-        if (mIfaceIdleTimerHandler->stop()) {
-            ALOGE("Unable to stop iface IDLETIMER NetlinkHandler: %s", strerror(errno));
-            status = -1;
-        }
-
-        delete mIfaceIdleTimerHandler;
-        mIfaceIdleTimerHandler = NULL;
-
-        close(mIfaceIdleTimerSock);
-        mIfaceIdleTimerSock = -1;
-    }
-
     return status;
 }