Bluetooth: Add a timeout in async_fd_watcher

Add a timeout to the select call and a callback.
Add unit tests for async_fd_watcher.

Test: unit tests pass
Change-Id: I0076fd52e79aac0d2a9fcceb90aae318d5f0757b
diff --git a/bluetooth/1.0/default/async_fd_watcher.h b/bluetooth/1.0/default/async_fd_watcher.h
index 1e4da8c..d6e112f 100644
--- a/bluetooth/1.0/default/async_fd_watcher.h
+++ b/bluetooth/1.0/default/async_fd_watcher.h
@@ -26,6 +26,7 @@
 namespace implementation {
 
 using ReadCallback = std::function<void(int)>;
+using TimeoutCallback = std::function<void(void)>;
 
 class AsyncFdWatcher {
  public:
@@ -34,6 +35,8 @@
 
   int WatchFdForNonBlockingReads(int file_descriptor,
                                  const ReadCallback& on_read_fd_ready_callback);
+  int ConfigureTimeout(const std::chrono::milliseconds timeout,
+                       const TimeoutCallback& on_timeout_callback);
   void StopWatchingFileDescriptor();
 
  private:
@@ -48,11 +51,14 @@
   std::atomic_bool running_{false};
   std::thread thread_;
   std::mutex internal_mutex_;
+  std::mutex timeout_mutex_;
 
   int read_fd_;
   int notification_listen_fd_;
   int notification_write_fd_;
   ReadCallback cb_;
+  TimeoutCallback timeout_cb_;
+  std::chrono::milliseconds timeout_ms_;
 };