Use timerfd to improve the accuracy of query timing

Timerfd can provide more accurate delayed callbacks than
Handler#postDelayed because it accounts for the time the device
spends in deep sleep. Using timerfd allows for more precise query
timing, which reduces the possibility of TTL expiration caused
by inaccurate delayed callbacks.

Bug: 366373064
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I980ec8fd43f63976ef5387bb57c7ed70a1b68d82
diff --git a/staticlibs/Android.bp b/staticlibs/Android.bp
index b5ee789..046b035 100644
--- a/staticlibs/Android.bp
+++ b/staticlibs/Android.bp
@@ -438,7 +438,10 @@
     srcs: [
         "device/com/android/net/module/util/FdEventsReader.java",
         "device/com/android/net/module/util/HandlerUtils.java",
+        "device/com/android/net/module/util/JniUtil.java",
         "device/com/android/net/module/util/SharedLog.java",
+        "device/com/android/net/module/util/TimerFdUtils.java",
+        "device/com/android/net/module/util/TimerFileDescriptor.java",
         "framework/com/android/net/module/util/ByteUtils.java",
         "framework/com/android/net/module/util/CollectionUtils.java",
         "framework/com/android/net/module/util/DnsUtils.java",
diff --git a/staticlibs/device/com/android/net/module/util/TimerFileDescriptor.java b/staticlibs/device/com/android/net/module/util/TimerFileDescriptor.java
index dbbccc5..a8c0f17 100644
--- a/staticlibs/device/com/android/net/module/util/TimerFileDescriptor.java
+++ b/staticlibs/device/com/android/net/module/util/TimerFileDescriptor.java
@@ -103,6 +103,13 @@
         public void post(Handler handler) {
             handler.sendMessage(mMessage);
         }
+
+        /**
+         * Get scheduled message
+         */
+        public Message getMessage() {
+            return mMessage;
+        }
     }
 
     /**