adb: fdevent: extract Add/Del/SetTimeout.

Test: adb_test
Change-Id: Ibed301f8de73289837153fdfed370a681c24ac55
diff --git a/adb/fdevent/fdevent.cpp b/adb/fdevent/fdevent.cpp
index 26ebc49..28b8f37 100644
--- a/adb/fdevent/fdevent.cpp
+++ b/adb/fdevent/fdevent.cpp
@@ -83,6 +83,21 @@
     return result;
 }
 
+void fdevent_context::Add(fdevent* fde, unsigned events) {
+    Set(fde, (fde->state & FDE_EVENTMASK) | events);
+}
+
+void fdevent_context::Del(fdevent* fde, unsigned events) {
+    CHECK(!(events & FDE_TIMEOUT));
+    Set(fde, (fde->state & FDE_EVENTMASK) & ~events);
+}
+
+void fdevent_context::SetTimeout(fdevent* fde, std::optional<std::chrono::milliseconds> timeout) {
+    CheckMainThread();
+    fde->timeout = timeout;
+    fde->last_active = std::chrono::steady_clock::now();
+}
+
 void fdevent_context::CheckMainThread() {
     if (main_thread_id_) {
         CHECK_EQ(*main_thread_id_, android::base::GetThreadId());
diff --git a/adb/fdevent/fdevent.h b/adb/fdevent/fdevent.h
index 3a3682f..ccb0c92 100644
--- a/adb/fdevent/fdevent.h
+++ b/adb/fdevent/fdevent.h
@@ -70,14 +70,14 @@
   public:
     // Change which events should cause notifications.
     virtual void Set(fdevent* fde, unsigned events) = 0;
-    virtual void Add(fdevent* fde, unsigned events) = 0;
-    virtual void Del(fdevent* fde, unsigned events) = 0;
+    void Add(fdevent* fde, unsigned events);
+    void Del(fdevent* fde, unsigned events);
 
     // Set a timeout on an fdevent.
     // If no events are triggered by the timeout, an FDE_TIMEOUT will be generated.
     // Note timeouts are not defused automatically; if a timeout is set on an fdevent, it will
     // trigger repeatedly every |timeout| ms.
-    virtual void SetTimeout(fdevent* fde, std::optional<std::chrono::milliseconds> timeout) = 0;
+    void SetTimeout(fdevent* fde, std::optional<std::chrono::milliseconds> timeout);
 
     // Loop until TerminateLoop is called, handling events.
     // Implementations should call FlushRunQueue on every iteration, and check the value of
diff --git a/adb/fdevent/fdevent_poll.cpp b/adb/fdevent/fdevent_poll.cpp
index 59b6b93..75ea081 100644
--- a/adb/fdevent/fdevent_poll.cpp
+++ b/adb/fdevent/fdevent_poll.cpp
@@ -131,22 +131,6 @@
     }
 }
 
-void fdevent_context_poll::Add(fdevent* fde, unsigned events) {
-    Set(fde, (fde->state & FDE_EVENTMASK) | events);
-}
-
-void fdevent_context_poll::Del(fdevent* fde, unsigned events) {
-    CHECK(!(events & FDE_TIMEOUT));
-    Set(fde, (fde->state & FDE_EVENTMASK) & ~events);
-}
-
-void fdevent_context_poll::SetTimeout(fdevent* fde,
-                                      std::optional<std::chrono::milliseconds> timeout) {
-    CheckMainThread();
-    fde->timeout = timeout;
-    fde->last_active = std::chrono::steady_clock::now();
-}
-
 static std::string dump_pollfds(const std::vector<adb_pollfd>& pollfds) {
     std::string result;
     for (const auto& pollfd : pollfds) {
diff --git a/adb/fdevent/fdevent_poll.h b/adb/fdevent/fdevent_poll.h
index bffc873..db08301 100644
--- a/adb/fdevent/fdevent_poll.h
+++ b/adb/fdevent/fdevent_poll.h
@@ -52,9 +52,6 @@
     virtual void Unregister(fdevent* fde) final;
 
     virtual void Set(fdevent* fde, unsigned events) final;
-    virtual void Add(fdevent* fde, unsigned events) final;
-    virtual void Del(fdevent* fde, unsigned events) final;
-    virtual void SetTimeout(fdevent* fde, std::optional<std::chrono::milliseconds> timeout) final;
 
     virtual void Loop() final;