Bluetooth: Export AsyncFdWatcher for reuse

Test: Bluetooth starts/stops
Change-Id: I1dcd8684fd150b5eb27c75e5d7803070009e0bf5
diff --git a/bluetooth/1.0/default/Android.bp b/bluetooth/1.0/default/Android.bp
index 4af079e..f82bc1f 100644
--- a/bluetooth/1.0/default/Android.bp
+++ b/bluetooth/1.0/default/Android.bp
@@ -17,7 +17,6 @@
     name: "android.hardware.bluetooth@1.0-impl",
     relative_install_path: "hw",
     srcs: [
-        "async_fd_watcher.cc",
         "bluetooth_hci.cc",
         "bluetooth_address.cc",
         "vendor_interface.cc",
@@ -33,12 +32,28 @@
         "liblog",
         "libutils",
     ],
+    static_libs: [
+        "android.hardware.bluetooth-async",
+    ],
+}
+
+cc_library_static {
+    name: "android.hardware.bluetooth-async",
+    srcs: [
+        "async_fd_watcher.cc",
+    ],
+    export_include_dirs: ["."],
+    shared_libs: [
+        "libbase",
+        "libcutils",
+        "liblog",
+        "libutils",
+    ],
 }
 
 cc_test {
     name: "bluetooth-vendor-interface-unit-tests",
     srcs: [
-        "async_fd_watcher.cc",
         "test/async_fd_watcher_unittest.cc",
     ],
     local_include_dirs: [
@@ -48,6 +63,9 @@
         "libbase",
         "liblog",
     ],
+    static_libs: [
+        "android.hardware.bluetooth-async",
+    ],
 }
 
 cc_test_host {
diff --git a/bluetooth/1.0/default/async_fd_watcher.cc b/bluetooth/1.0/default/async_fd_watcher.cc
index 161a74a..a88aa27 100644
--- a/bluetooth/1.0/default/async_fd_watcher.cc
+++ b/bluetooth/1.0/default/async_fd_watcher.cc
@@ -29,8 +29,7 @@
 namespace android {
 namespace hardware {
 namespace bluetooth {
-namespace V1_0 {
-namespace implementation {
+namespace async {
 
 int AsyncFdWatcher::WatchFdForNonBlockingReads(
     int file_descriptor, const ReadCallback& on_read_fd_ready_callback) {
@@ -167,8 +166,7 @@
   }
 }
 
-} // namespace implementation
-} // namespace V1_0
+} // namespace async
 } // namespace bluetooth
 } // namespace hardware
 } // namespace android
diff --git a/bluetooth/1.0/default/async_fd_watcher.h b/bluetooth/1.0/default/async_fd_watcher.h
index d6e112f..3f7ff54 100644
--- a/bluetooth/1.0/default/async_fd_watcher.h
+++ b/bluetooth/1.0/default/async_fd_watcher.h
@@ -22,8 +22,7 @@
 namespace android {
 namespace hardware {
 namespace bluetooth {
-namespace V1_0 {
-namespace implementation {
+namespace async {
 
 using ReadCallback = std::function<void(int)>;
 using TimeoutCallback = std::function<void(void)>;
@@ -62,8 +61,7 @@
 };
 
 
-} // namespace implementation
-} // namespace V1_0
+} // namespace async
 } // namespace bluetooth
 } // namespace hardware
 } // namespace android
diff --git a/bluetooth/1.0/default/test/async_fd_watcher_unittest.cc b/bluetooth/1.0/default/test/async_fd_watcher_unittest.cc
index 49ea44a..a7f5bda 100644
--- a/bluetooth/1.0/default/test/async_fd_watcher_unittest.cc
+++ b/bluetooth/1.0/default/test/async_fd_watcher_unittest.cc
@@ -33,6 +33,8 @@
 namespace V1_0 {
 namespace implementation {
 
+using android::hardware::bluetooth::async::AsyncFdWatcher;
+
 class AsyncFdWatcherSocketTest : public ::testing::Test {
  public:
   static const uint16_t kPort = 6111;
diff --git a/bluetooth/1.0/default/vendor_interface.h b/bluetooth/1.0/default/vendor_interface.h
index ce5769c..98357f5 100644
--- a/bluetooth/1.0/default/vendor_interface.h
+++ b/bluetooth/1.0/default/vendor_interface.h
@@ -59,7 +59,7 @@
 
   void *lib_handle_;
   bt_vendor_interface_t *lib_interface_;
-  AsyncFdWatcher fd_watcher_;
+  async::AsyncFdWatcher fd_watcher_;
   int uart_fd_;
   PacketReadCallback packet_read_cb_;
   InitializeCompleteCallback initialize_complete_cb_;