Merge "Added the roaming flag for data call APIs"
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 962f6cd..212c8b1 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -48,3 +48,7 @@
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/hw/android.hardware*)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib64/hw/android.hardware*)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/init/android.hardware*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/hw/android.hardware.bluetooth*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/hw/android.hardware.bluetooth*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib64/hw/android.hardware.bluetooth*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/init/android.hardware.bluetooth*)
diff --git a/bluetooth/1.0/default/Android.bp b/bluetooth/1.0/default/Android.bp
index f82bc1f..fb20195 100644
--- a/bluetooth/1.0/default/Android.bp
+++ b/bluetooth/1.0/default/Android.bp
@@ -15,6 +15,7 @@
 
 cc_library_shared {
     name: "android.hardware.bluetooth@1.0-impl",
+    proprietary: true,
     relative_install_path: "hw",
     srcs: [
         "bluetooth_hci.cc",
@@ -26,7 +27,6 @@
         "libbase",
         "libcutils",
         "libhardware",
-        "libhwbinder",
         "libhidlbase",
         "libhidltransport",
         "liblog",
@@ -34,6 +34,7 @@
     ],
     static_libs: [
         "android.hardware.bluetooth-async",
+        "android.hardware.bluetooth-hci",
     ],
 }
 
@@ -51,6 +52,21 @@
     ],
 }
 
+cc_library_static {
+    name: "android.hardware.bluetooth-hci",
+    srcs: [
+        "hci_packetizer.cc",
+    ],
+    export_include_dirs: ["."],
+    shared_libs: [
+        "libbase",
+        "libcutils",
+        "libhidlbase",
+        "liblog",
+        "libutils",
+    ],
+}
+
 cc_test {
     name: "bluetooth-vendor-interface-unit-tests",
     srcs: [
diff --git a/bluetooth/1.0/default/Android.mk b/bluetooth/1.0/default/Android.mk
index 08bfb4e..7530925 100644
--- a/bluetooth/1.0/default/Android.mk
+++ b/bluetooth/1.0/default/Android.mk
@@ -17,6 +17,7 @@
 
 include $(CLEAR_VARS)
 LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_PROPRIETARY_MODULE := true
 LOCAL_MODULE := android.hardware.bluetooth@1.0-service
 LOCAL_INIT_RC := android.hardware.bluetooth@1.0-service.rc
 LOCAL_SRC_FILES := \
@@ -32,7 +33,6 @@
   libhardware \
 
 LOCAL_SHARED_LIBRARIES += \
-  libhwbinder \
   libhidlbase \
   libhidltransport \
   android.hardware.bluetooth@1.0 \
diff --git a/bluetooth/1.0/default/android.hardware.bluetooth@1.0-service.rc b/bluetooth/1.0/default/android.hardware.bluetooth@1.0-service.rc
index 8c5c02a..8545d2f 100644
--- a/bluetooth/1.0/default/android.hardware.bluetooth@1.0-service.rc
+++ b/bluetooth/1.0/default/android.hardware.bluetooth@1.0-service.rc
@@ -1,4 +1,4 @@
-service bluetooth-1-0 /system/bin/hw/android.hardware.bluetooth@1.0-service
+service bluetooth-1-0 /vendor/bin/hw/android.hardware.bluetooth@1.0-service
     class hal
     user bluetooth
     group bluetooth
diff --git a/bluetooth/1.0/default/hci_internals.h b/bluetooth/1.0/default/hci_internals.h
index d5714be..1e1f300 100644
--- a/bluetooth/1.0/default/hci_internals.h
+++ b/bluetooth/1.0/default/hci_internals.h
@@ -16,6 +16,8 @@
 
 #pragma once
 
+#include <stdlib.h>
+
 // HCI UART transport packet types (Volume 4, Part A, 2)
 enum HciPacketType {
   HCI_PACKET_TYPE_UNKNOWN = 0,
diff --git a/bluetooth/1.0/default/hci_packetizer.cc b/bluetooth/1.0/default/hci_packetizer.cc
new file mode 100644
index 0000000..1a50196
--- /dev/null
+++ b/bluetooth/1.0/default/hci_packetizer.cc
@@ -0,0 +1,115 @@
+//
+// Copyright 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "hci_packetizer.h"
+
+#define LOG_TAG "android.hardware.bluetooth.hci_packetizer"
+#include <android-base/logging.h>
+#include <cutils/properties.h>
+#include <utils/Log.h>
+
+#include <dlfcn.h>
+#include <fcntl.h>
+
+namespace {
+
+const size_t preamble_size_for_type[] = {
+    0, HCI_COMMAND_PREAMBLE_SIZE, HCI_ACL_PREAMBLE_SIZE, HCI_SCO_PREAMBLE_SIZE,
+    HCI_EVENT_PREAMBLE_SIZE};
+const size_t packet_length_offset_for_type[] = {
+    0, HCI_LENGTH_OFFSET_CMD, HCI_LENGTH_OFFSET_ACL, HCI_LENGTH_OFFSET_SCO,
+    HCI_LENGTH_OFFSET_EVT};
+
+size_t HciGetPacketLengthForType(HciPacketType type, const uint8_t* preamble) {
+  size_t offset = packet_length_offset_for_type[type];
+  if (type != HCI_PACKET_TYPE_ACL_DATA) return preamble[offset];
+  return (((preamble[offset + 1]) << 8) | preamble[offset]);
+}
+
+}  // namespace
+
+namespace android {
+namespace hardware {
+namespace bluetooth {
+namespace hci {
+
+HciPacketType HciPacketizer::GetPacketType() const {
+  return hci_packet_type_;
+}
+
+const hidl_vec<uint8_t>& HciPacketizer::GetPacket() const {
+  return hci_packet_;
+}
+
+void HciPacketizer::OnDataReady(int fd) {
+  switch (hci_parser_state_) {
+    case HCI_IDLE: {
+      uint8_t buffer[1] = {0};
+      size_t bytes_read = TEMP_FAILURE_RETRY(read(fd, buffer, 1));
+      CHECK(bytes_read == 1);
+      hci_packet_type_ = static_cast<HciPacketType>(buffer[0]);
+      CHECK(hci_packet_type_ >= HCI_PACKET_TYPE_ACL_DATA &&
+            hci_packet_type_ <= HCI_PACKET_TYPE_EVENT)
+          << "buffer[0] = " << static_cast<unsigned int>(buffer[0]);
+      hci_parser_state_ = HCI_TYPE_READY;
+      hci_packet_bytes_remaining_ = preamble_size_for_type[hci_packet_type_];
+      hci_packet_bytes_read_ = 0;
+      break;
+    }
+
+    case HCI_TYPE_READY: {
+      size_t bytes_read = TEMP_FAILURE_RETRY(
+          read(fd, hci_packet_preamble_ + hci_packet_bytes_read_,
+               hci_packet_bytes_remaining_));
+      CHECK(bytes_read > 0);
+      hci_packet_bytes_remaining_ -= bytes_read;
+      hci_packet_bytes_read_ += bytes_read;
+      if (hci_packet_bytes_remaining_ == 0) {
+        size_t packet_length =
+            HciGetPacketLengthForType(hci_packet_type_, hci_packet_preamble_);
+        hci_packet_.resize(preamble_size_for_type[hci_packet_type_] +
+                           packet_length);
+        memcpy(hci_packet_.data(), hci_packet_preamble_,
+               preamble_size_for_type[hci_packet_type_]);
+        hci_packet_bytes_remaining_ = packet_length;
+        hci_parser_state_ = HCI_PAYLOAD;
+        hci_packet_bytes_read_ = 0;
+      }
+      break;
+    }
+
+    case HCI_PAYLOAD: {
+      size_t bytes_read = TEMP_FAILURE_RETRY(
+          read(fd,
+               hci_packet_.data() + preamble_size_for_type[hci_packet_type_] +
+                   hci_packet_bytes_read_,
+               hci_packet_bytes_remaining_));
+      CHECK(bytes_read > 0);
+      hci_packet_bytes_remaining_ -= bytes_read;
+      hci_packet_bytes_read_ += bytes_read;
+      if (hci_packet_bytes_remaining_ == 0) {
+        hci_packet_ready_cb_();
+        hci_parser_state_ = HCI_IDLE;
+      }
+      break;
+    }
+  }
+}
+
+}  // namespace hci
+}  // namespace bluetooth
+}  // namespace hardware
+}  // namespace android
diff --git a/bluetooth/1.0/default/hci_packetizer.h b/bluetooth/1.0/default/hci_packetizer.h
new file mode 100644
index 0000000..e9c01dc
--- /dev/null
+++ b/bluetooth/1.0/default/hci_packetizer.h
@@ -0,0 +1,54 @@
+//
+// Copyright 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#pragma once
+
+#include <functional>
+
+#include <hidl/HidlSupport.h>
+
+#include "hci_internals.h"
+
+namespace android {
+namespace hardware {
+namespace bluetooth {
+namespace hci {
+
+using ::android::hardware::hidl_vec;
+using HciPacketReadyCallback = std::function<void(void)>;
+
+class HciPacketizer {
+ public:
+  HciPacketizer(HciPacketReadyCallback packet_cb) : hci_packet_ready_cb_(packet_cb) {};
+  void OnDataReady(int fd);
+  const hidl_vec<uint8_t>& GetPacket() const;
+  HciPacketType GetPacketType() const;
+
+ protected:
+  enum HciParserState { HCI_IDLE, HCI_TYPE_READY, HCI_PAYLOAD };
+  HciParserState hci_parser_state_{HCI_IDLE};
+  HciPacketType hci_packet_type_{HCI_PACKET_TYPE_UNKNOWN};
+  uint8_t hci_packet_preamble_[HCI_PREAMBLE_SIZE_MAX];
+  hidl_vec<uint8_t> hci_packet_;
+  size_t hci_packet_bytes_remaining_;
+  size_t hci_packet_bytes_read_;
+  HciPacketReadyCallback hci_packet_ready_cb_;
+};
+
+}  // namespace hci
+}  // namespace bluetooth
+}  // namespace hardware
+}  // namespace android
diff --git a/bluetooth/1.0/default/vendor_interface.cc b/bluetooth/1.0/default/vendor_interface.cc
index 7737dd2..3878129 100644
--- a/bluetooth/1.0/default/vendor_interface.cc
+++ b/bluetooth/1.0/default/vendor_interface.cc
@@ -51,19 +51,6 @@
 
 VendorInterface* g_vendor_interface = nullptr;
 
-const size_t preamble_size_for_type[] = {
-    0, HCI_COMMAND_PREAMBLE_SIZE, HCI_ACL_PREAMBLE_SIZE, HCI_SCO_PREAMBLE_SIZE,
-    HCI_EVENT_PREAMBLE_SIZE};
-const size_t packet_length_offset_for_type[] = {
-    0, HCI_LENGTH_OFFSET_CMD, HCI_LENGTH_OFFSET_ACL, HCI_LENGTH_OFFSET_SCO,
-    HCI_LENGTH_OFFSET_EVT};
-
-size_t HciGetPacketLengthForType(HciPacketType type, const uint8_t* preamble) {
-  size_t offset = packet_length_offset_for_type[type];
-  if (type != HCI_PACKET_TYPE_ACL_DATA) return preamble[offset];
-  return (((preamble[offset + 1]) << 8) | preamble[offset]);
-}
-
 HC_BT_HDR* WrapPacketAndCopy(uint16_t event, const hidl_vec<uint8_t>& data) {
   size_t packet_size = data.size() + sizeof(HC_BT_HDR);
   HC_BT_HDR* packet = reinterpret_cast<HC_BT_HDR*>(new uint8_t[packet_size]);
@@ -274,7 +261,7 @@
   ALOGI("%s UART fd: %d", __func__, uart_fd_);
 
   fd_watcher_.WatchFdForNonBlockingReads(uart_fd_,
-                                         [this](int fd) { OnDataReady(fd); });
+                                         [this](int fd) { hci_packetizer_.OnDataReady(fd); });
 
   // Initially, the power management is off.
   lpm_wake_deasserted = true;
@@ -370,72 +357,26 @@
   recent_activity_flag = false;
 }
 
-void VendorInterface::OnDataReady(int fd) {
-  switch (hci_parser_state_) {
-    case HCI_IDLE: {
-      uint8_t buffer[1] = {0};
-      size_t bytes_read = TEMP_FAILURE_RETRY(read(fd, buffer, 1));
-      CHECK(bytes_read == 1);
-      hci_packet_type_ = static_cast<HciPacketType>(buffer[0]);
-      // TODO(eisenbach): Check for workaround(s)
-      CHECK(hci_packet_type_ >= HCI_PACKET_TYPE_ACL_DATA &&
-            hci_packet_type_ <= HCI_PACKET_TYPE_EVENT)
-          << "buffer[0] = " << static_cast<unsigned int>(buffer[0]);
-      hci_parser_state_ = HCI_TYPE_READY;
-      hci_packet_bytes_remaining_ = preamble_size_for_type[hci_packet_type_];
-      hci_packet_bytes_read_ = 0;
-      break;
-    }
+void VendorInterface::OnPacketReady() {
+  VendorInterface::get()->HandleIncomingPacket();
+}
 
-    case HCI_TYPE_READY: {
-      size_t bytes_read = TEMP_FAILURE_RETRY(
-          read(fd, hci_packet_preamble_ + hci_packet_bytes_read_,
-               hci_packet_bytes_remaining_));
-      CHECK(bytes_read > 0);
-      hci_packet_bytes_remaining_ -= bytes_read;
-      hci_packet_bytes_read_ += bytes_read;
-      if (hci_packet_bytes_remaining_ == 0) {
-        size_t packet_length =
-            HciGetPacketLengthForType(hci_packet_type_, hci_packet_preamble_);
-        hci_packet_.resize(preamble_size_for_type[hci_packet_type_] +
-                           packet_length);
-        memcpy(hci_packet_.data(), hci_packet_preamble_,
-               preamble_size_for_type[hci_packet_type_]);
-        hci_packet_bytes_remaining_ = packet_length;
-        hci_parser_state_ = HCI_PAYLOAD;
-        hci_packet_bytes_read_ = 0;
-      }
-      break;
-    }
-
-    case HCI_PAYLOAD: {
-      size_t bytes_read = TEMP_FAILURE_RETRY(
-          read(fd,
-               hci_packet_.data() + preamble_size_for_type[hci_packet_type_] +
-                   hci_packet_bytes_read_,
-               hci_packet_bytes_remaining_));
-      CHECK(bytes_read > 0);
-      hci_packet_bytes_remaining_ -= bytes_read;
-      hci_packet_bytes_read_ += bytes_read;
-      if (hci_packet_bytes_remaining_ == 0) {
+void VendorInterface::HandleIncomingPacket() {
+  HciPacketType hci_packet_type = hci_packetizer_.GetPacketType();
+  hidl_vec<uint8_t> hci_packet = hci_packetizer_.GetPacket();
         if (internal_command.cb != nullptr &&
-            hci_packet_type_ == HCI_PACKET_TYPE_EVENT &&
-            internal_command_event_match(hci_packet_)) {
+            hci_packet_type == HCI_PACKET_TYPE_EVENT &&
+            internal_command_event_match(hci_packet)) {
           HC_BT_HDR* bt_hdr =
-              WrapPacketAndCopy(HCI_PACKET_TYPE_EVENT, hci_packet_);
+              WrapPacketAndCopy(HCI_PACKET_TYPE_EVENT, hci_packet);
 
           // The callbacks can send new commands, so don't zero after calling.
           tINT_CMD_CBACK saved_cb = internal_command.cb;
           internal_command.cb = nullptr;
           saved_cb(bt_hdr);
         } else {
-          packet_read_cb_(hci_packet_type_, hci_packet_);
+          packet_read_cb_(hci_packet_type, hci_packet);
         }
-        hci_parser_state_ = HCI_IDLE;
-      }
-      break;
-    }
-  }
 }
 
 }  // namespace implementation
diff --git a/bluetooth/1.0/default/vendor_interface.h b/bluetooth/1.0/default/vendor_interface.h
index 98357f5..8115640 100644
--- a/bluetooth/1.0/default/vendor_interface.h
+++ b/bluetooth/1.0/default/vendor_interface.h
@@ -20,7 +20,7 @@
 
 #include "async_fd_watcher.h"
 #include "bt_vendor_lib.h"
-#include "hci_internals.h"
+#include "hci_packetizer.h"
 
 namespace android {
 namespace hardware {
@@ -46,6 +46,8 @@
 
   void OnFirmwareConfigured(uint8_t result);
 
+  static void OnPacketReady();
+
  private:
   virtual ~VendorInterface() = default;
 
@@ -55,7 +57,7 @@
 
   void OnTimeout();
 
-  void OnDataReady(int fd);
+  void HandleIncomingPacket();
 
   void *lib_handle_;
   bt_vendor_interface_t *lib_interface_;
@@ -64,13 +66,7 @@
   PacketReadCallback packet_read_cb_;
   InitializeCompleteCallback initialize_complete_cb_;
 
-  enum HciParserState { HCI_IDLE, HCI_TYPE_READY, HCI_PAYLOAD };
-  HciParserState hci_parser_state_{HCI_IDLE};
-  HciPacketType hci_packet_type_{HCI_PACKET_TYPE_UNKNOWN};
-  uint8_t hci_packet_preamble_[HCI_PREAMBLE_SIZE_MAX];
-  hidl_vec<uint8_t> hci_packet_;
-  size_t hci_packet_bytes_remaining_;
-  size_t hci_packet_bytes_read_;
+  hci::HciPacketizer hci_packetizer_ {VendorInterface::OnPacketReady};
 
   FirmwareStartupTimer *firmware_startup_timer_;
 };
diff --git a/bluetooth/1.0/vts/functional/Android.bp b/bluetooth/1.0/vts/functional/Android.bp
index 2012c20..a57a55a 100644
--- a/bluetooth/1.0/vts/functional/Android.bp
+++ b/bluetooth/1.0/vts/functional/Android.bp
@@ -16,7 +16,6 @@
 
 cc_test {
     name: "VtsHalBluetoothV1_0TargetTest",
-    gtest: true,
     srcs: ["VtsHalBluetoothV1_0TargetTest.cpp"],
     shared_libs: [
         "libbase",
@@ -24,12 +23,11 @@
         "libcutils",
         "libhidlbase",
         "libhidltransport",
-        "libhwbinder",
         "libnativehelper",
         "libutils",
         "android.hardware.bluetooth@1.0",
     ],
-    static_libs: ["libgtest"],
+    static_libs: ["VtsHalHidlTargetBaseTest"],
     cflags: [
         "-O0",
         "-g",
diff --git a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
index 5a6c29a..ce15875 100644
--- a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
+++ b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
@@ -23,7 +23,7 @@
 #include <hardware/bluetooth.h>
 #include <utils/Log.h>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 #include <condition_variable>
 #include <mutex>
 #include <queue>
@@ -117,11 +117,11 @@
 };
 
 // The main test class for Bluetooth HIDL HAL.
-class BluetoothHidlTest : public ::testing::Test {
+class BluetoothHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
  public:
   virtual void SetUp() override {
     // currently test passthrough mode only
-    bluetooth = IBluetoothHci::getService();
+    bluetooth = testing::VtsHalHidlTargetBaseTest::getService<IBluetoothHci>();
     ASSERT_NE(bluetooth, nullptr);
     ALOGI("%s: getService() for bluetooth is %s", __func__,
           bluetooth->isRemote() ? "remote" : "local");
diff --git a/boot/1.0/default/Android.mk b/boot/1.0/default/Android.mk
index 99a6cf9..5e7ecb4 100644
--- a/boot/1.0/default/Android.mk
+++ b/boot/1.0/default/Android.mk
@@ -11,7 +11,6 @@
     liblog \
     libhidlbase \
     libhidltransport \
-    libhwbinder \
     libhardware \
     libutils \
     android.hardware.boot@1.0 \
@@ -28,7 +27,6 @@
 
 LOCAL_SHARED_LIBRARIES := \
     liblog \
-    libhwbinder \
     libhardware \
     libhidlbase \
     libhidltransport \
diff --git a/ir/1.0/default/Android.bp b/ir/1.0/default/Android.bp
index ed0b807..151a9af 100644
--- a/ir/1.0/default/Android.bp
+++ b/ir/1.0/default/Android.bp
@@ -21,7 +21,6 @@
         "libhidlbase",
         "libhidltransport",
         "libhardware",
-        "libhwbinder",
         "liblog",
         "libutils",
         "android.hardware.ir@1.0",
@@ -37,7 +36,6 @@
 
     shared_libs: [
         "liblog",
-        "libhwbinder",
         "libhardware",
         "libhidlbase",
         "libhidltransport",
diff --git a/ir/1.0/vts/functional/Android.bp b/ir/1.0/vts/functional/Android.bp
index 5689474..fe0a595 100644
--- a/ir/1.0/vts/functional/Android.bp
+++ b/ir/1.0/vts/functional/Android.bp
@@ -16,7 +16,6 @@
 
 cc_test {
     name: "VtsHalIrV1_0TargetTest",
-    gtest: true,
     srcs: ["VtsHalIrV1_0TargetTest.cpp"],
     shared_libs: [
         "libbase",
@@ -24,11 +23,10 @@
         "libcutils",
         "libhidlbase",
         "libhidltransport",
-        "libhwbinder",
         "libutils",
         "android.hardware.ir@1.0",
     ],
-    static_libs: ["libgtest"],
+    static_libs: ["VtsHalHidlTargetBaseTest"],
     cflags: [
         "-O0",
         "-g",
diff --git a/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp b/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp
index 08c7974..1dd0405 100644
--- a/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp
+++ b/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp
@@ -21,7 +21,7 @@
 #include <android/hardware/ir/1.0/IConsumerIr.h>
 #include <android/hardware/ir/1.0/types.h>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 #include <algorithm>
 
 using ::android::hardware::ir::V1_0::IConsumerIr;
@@ -31,10 +31,10 @@
 using ::android::sp;
 
 // The main test class for IR HIDL HAL.
-class ConsumerIrHidlTest : public ::testing::Test {
+class ConsumerIrHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
  public:
   virtual void SetUp() override {
-    ir = IConsumerIr::getService();
+    ir = testing::VtsHalHidlTargetBaseTest::getService<IConsumerIr>();
     ASSERT_NE(ir, nullptr);
   }
 
diff --git a/nfc/1.0/default/Android.bp b/nfc/1.0/default/Android.bp
index 02f5664..051ca54 100644
--- a/nfc/1.0/default/Android.bp
+++ b/nfc/1.0/default/Android.bp
@@ -7,7 +7,6 @@
         "liblog",
         "libcutils",
         "libhardware",
-        "libhwbinder",
         "libbase",
         "libcutils",
         "libutils",
diff --git a/nfc/1.0/default/Android.mk b/nfc/1.0/default/Android.mk
index fbb340f..2e1f17f 100644
--- a/nfc/1.0/default/Android.mk
+++ b/nfc/1.0/default/Android.mk
@@ -18,7 +18,6 @@
 	libhardware \
 
 LOCAL_SHARED_LIBRARIES += \
-	libhwbinder \
 	libhidlbase \
 	libhidltransport \
 	android.hardware.nfc@1.0 \
diff --git a/nfc/1.0/vts/functional/Android.bp b/nfc/1.0/vts/functional/Android.bp
index 080887f..0ab8dc5 100644
--- a/nfc/1.0/vts/functional/Android.bp
+++ b/nfc/1.0/vts/functional/Android.bp
@@ -16,7 +16,6 @@
 
 cc_test {
     name: "VtsHalNfcV1_0TargetTest",
-    gtest: true,
     srcs: ["VtsHalNfcV1_0TargetTest.cpp"],
     shared_libs: [
         "libbase",
@@ -24,12 +23,11 @@
         "libcutils",
         "libhidlbase",
         "libhidltransport",
-        "libhwbinder",
         "libnativehelper",
         "libutils",
         "android.hardware.nfc@1.0",
     ],
-    static_libs: ["libgtest"],
+    static_libs: ["VtsHalHidlTargetBaseTest"],
     cflags: [
         "-O0",
         "-g",
diff --git a/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp b/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
index a0c5f1a..ae21f9a 100644
--- a/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
+++ b/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
@@ -22,7 +22,7 @@
 #include <android/hardware/nfc/1.0/types.h>
 #include <hardware/nfc.h>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 #include <chrono>
 #include <condition_variable>
 #include <mutex>
@@ -56,10 +56,10 @@
 #define TIMEOUT_PERIOD 5
 
 // The main test class for NFC HIDL HAL.
-class NfcHidlTest : public ::testing::Test {
+class NfcHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
  public:
   virtual void SetUp() override {
-    nfc_ = INfc::getService();
+    nfc_ = testing::VtsHalHidlTargetBaseTest::getService<INfc>();
     ASSERT_NE(nfc_, nullptr);
 
     nfc_cb_ = new NfcClientCallback(*this);
diff --git a/radio/1.0/vts/functional/Android.bp b/radio/1.0/vts/functional/Android.bp
index 6615f03..10bd725 100644
--- a/radio/1.0/vts/functional/Android.bp
+++ b/radio/1.0/vts/functional/Android.bp
@@ -16,7 +16,6 @@
 
 cc_test {
     name: "VtsHalRadioV1_0TargetTest",
-    gtest: true,
     srcs: ["radio_hidl_hal_test.cpp",
            "radio_response.cpp",
            "radio_hidl_hal_icc.cpp",
@@ -27,12 +26,11 @@
         "libcutils",
         "libhidlbase",
         "libhidltransport",
-        "libhwbinder",
         "libnativehelper",
         "libutils",
         "android.hardware.radio@1.0",
     ],
-    static_libs: ["libgtest"],
+    static_libs: ["VtsHalHidlTargetBaseTest"],
     cflags: [
         "-O0",
         "-g",
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_test.cpp b/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
index 2a67954..d1ab06a 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
@@ -17,7 +17,7 @@
 #include<radio_hidl_hal_utils.h>
 
 void RadioHidlTest::SetUp() {
-    radio = IRadio::getService(hidl_string("rild"));
+    radio = testing::VtsHalHidlTargetBaseTest::getService<IRadio>(hidl_string("rild"));
     ASSERT_NE(radio, nullptr);
 
     radioRsp = new RadioResponse(*this);
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_utils.h b/radio/1.0/vts/functional/radio_hidl_hal_utils.h
index 23b6ffa..732d88e 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_utils.h
+++ b/radio/1.0/vts/functional/radio_hidl_hal_utils.h
@@ -16,7 +16,7 @@
 
 #include <android-base/logging.h>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 #include <chrono>
 #include <condition_variable>
 #include <mutex>
@@ -423,7 +423,7 @@
 };
 
 // The main test class for Radio HIDL.
-class RadioHidlTest : public ::testing::Test {
+class RadioHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
 private:
     std::mutex mtx;
     std::condition_variable cv;
diff --git a/renderscript/1.0/default/Android.bp b/renderscript/1.0/default/Android.bp
index 348f6af..564d6db 100644
--- a/renderscript/1.0/default/Android.bp
+++ b/renderscript/1.0/default/Android.bp
@@ -14,7 +14,6 @@
         "liblog",
         "libhidlbase",
         "libhidltransport",
-        "libhwbinder",
         "libutils",
         "android.hardware.renderscript@1.0",
         "android.hidl.base@1.0",
diff --git a/tests/bar/1.0/default/Android.bp b/tests/bar/1.0/default/Android.bp
index 2c79357..14506c5 100644
--- a/tests/bar/1.0/default/Android.bp
+++ b/tests/bar/1.0/default/Android.bp
@@ -14,7 +14,6 @@
         "libcutils",
         "libhidlbase",
         "libhidltransport",
-        "libhwbinder",
         "liblog",
         "libutils",
         "android.hardware.tests.foo@1.0",
diff --git a/tests/baz/1.0/IBaz.hal b/tests/baz/1.0/IBaz.hal
index 40e4024..e4eb145 100644
--- a/tests/baz/1.0/IBaz.hal
+++ b/tests/baz/1.0/IBaz.hal
@@ -21,6 +21,14 @@
 
 interface IBaz extends IBase {
 
+    enum BitField : uint8_t {
+        V0 = 1 << 0,
+        V1 = 1 << 1,
+        V2 = 1 << 2,
+        V3 = 1 << 3,
+        VALL = V0 | V1 | V2 | V3,
+    };
+
     enum SomeOtherEnum : uint8_t {
         bar = 66
     };
@@ -45,6 +53,21 @@
         vec<T> matrices;
     };
 
+    struct Quux {
+        string first;
+        string last;
+    };
+    struct Everything {
+        int8_t number;
+        int32_t anotherNumber;
+        string s;
+        vec<string> vs;
+        string[2][2] multidimArray;
+        string[3] sArray;
+        Quux anotherStruct;
+        bitfield<BitField> bf;
+    };
+
     @Fragile @NoReally(very="yes", array={"a","b","c"})
     oneway doThis(float param);
 
diff --git a/tests/foo/1.0/IFoo.hal b/tests/foo/1.0/IFoo.hal
index 76aefcf..a43b883 100644
--- a/tests/foo/1.0/IFoo.hal
+++ b/tests/foo/1.0/IFoo.hal
@@ -38,6 +38,7 @@
         V1 = 1 << 1,
         V2 = 1 << 2,
         V3 = 1 << 3,
+        VALL = V0 | V1 | V2 | V3,
     };
 
     struct Fumble {
diff --git a/tests/foo/1.0/default/Android.bp b/tests/foo/1.0/default/Android.bp
index f4a80d5..77e617c 100644
--- a/tests/foo/1.0/default/Android.bp
+++ b/tests/foo/1.0/default/Android.bp
@@ -14,7 +14,6 @@
         "libhidlbase",
         "libhidltransport",
         "libfootest",
-        "libhwbinder",
         "liblog",
         "libutils",
         "android.hardware.tests.foo@1.0",
diff --git a/tests/foo/1.0/default/lib/Android.bp b/tests/foo/1.0/default/lib/Android.bp
index 7873203..708cf43 100644
--- a/tests/foo/1.0/default/lib/Android.bp
+++ b/tests/foo/1.0/default/lib/Android.bp
@@ -7,7 +7,6 @@
     shared_libs: [
         "libhidlbase",
         "libhidltransport",
-        "libhwbinder",
         "android.hardware.tests.foo@1.0",
     ],
     local_include_dirs: ["include/hidl-test"],
diff --git a/tests/inheritance/1.0/default/Android.bp b/tests/inheritance/1.0/default/Android.bp
index 090c36e..a67dc09 100644
--- a/tests/inheritance/1.0/default/Android.bp
+++ b/tests/inheritance/1.0/default/Android.bp
@@ -14,7 +14,6 @@
         "libbase",
         "libhidlbase",
         "libhidltransport",
-        "libhwbinder",
         "liblog",
         "libutils",
         "android.hardware.tests.inheritance@1.0",
diff --git a/tests/libhwbinder/1.0/default/Android.bp b/tests/libhwbinder/1.0/default/Android.bp
index 0edabfc..6e8fbb1 100644
--- a/tests/libhwbinder/1.0/default/Android.bp
+++ b/tests/libhwbinder/1.0/default/Android.bp
@@ -10,7 +10,6 @@
         "libbase",
         "libhidlbase",
         "libhidltransport",
-        "libhwbinder",
         "liblog",
         "libutils",
         "android.hardware.tests.libhwbinder@1.0",
diff --git a/tests/memory/1.0/default/Android.bp b/tests/memory/1.0/default/Android.bp
index 14dc08d..40716da 100644
--- a/tests/memory/1.0/default/Android.bp
+++ b/tests/memory/1.0/default/Android.bp
@@ -22,7 +22,6 @@
     shared_libs: [
         "libhidlbase",
         "libhidltransport",
-        "libhwbinder",
         "libhidlmemory",
         "liblog",
         "libutils",
diff --git a/tests/pointer/1.0/default/Android.bp b/tests/pointer/1.0/default/Android.bp
index ab7f8fa..c4dc013 100644
--- a/tests/pointer/1.0/default/Android.bp
+++ b/tests/pointer/1.0/default/Android.bp
@@ -14,7 +14,6 @@
         "libhidlbase",
         "libhidltransport",
         "libpointertest",
-        "libhwbinder",
         "liblog",
         "libutils",
         "android.hardware.tests.pointer@1.0",
diff --git a/tests/pointer/1.0/default/lib/Android.bp b/tests/pointer/1.0/default/lib/Android.bp
index a7203c7..7737932 100644
--- a/tests/pointer/1.0/default/lib/Android.bp
+++ b/tests/pointer/1.0/default/lib/Android.bp
@@ -8,7 +8,6 @@
         "libbase",
         "libhidlbase",
         "libhidltransport",
-        "libhwbinder",
         "liblog",
         "android.hardware.tests.pointer@1.0",
     ],
diff --git a/wifi/1.0/default/Android.mk b/wifi/1.0/default/Android.mk
index 2d2d898..00e5f98 100644
--- a/wifi/1.0/default/Android.mk
+++ b/wifi/1.0/default/Android.mk
@@ -39,7 +39,6 @@
     libcutils \
     libhidlbase \
     libhidltransport \
-    libhwbinder \
     liblog \
     libnl \
     libutils \
diff --git a/wifi/1.0/default/hidl_struct_util.cpp b/wifi/1.0/default/hidl_struct_util.cpp
index c7b8c41..726f011 100644
--- a/wifi/1.0/default/hidl_struct_util.cpp
+++ b/wifi/1.0/default/hidl_struct_util.cpp
@@ -950,7 +950,7 @@
         hidl_request.baseConfigs.disableMatchExpirationIndication ? 0x2 : 0x0;
   legacy_request->recv_indication_cfg |=
         hidl_request.baseConfigs.disableFollowupReceivedIndication ? 0x4 : 0x0;
-  legacy_request->cipher_type = hidl_request.baseConfigs.supportedCipherTypes;
+  legacy_request->cipher_type = (unsigned int) hidl_request.baseConfigs.cipherType;
   legacy_request->pmk_len = hidl_request.baseConfigs.pmk.size();
   if (legacy_request->pmk_len > NAN_PMK_INFO_LEN) {
     LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: pmk_len too large";
@@ -973,6 +973,8 @@
   legacy_request->range_report = legacy_hal::NAN_DISABLE_RANGE_REPORT;
   legacy_request->publish_type = (legacy_hal::NanPublishType) hidl_request.publishType;
   legacy_request->tx_type = (legacy_hal::NanTxType) hidl_request.txType;
+  legacy_request->service_responder_policy = hidl_request.autoAcceptDataPathRequests ?
+        legacy_hal::NAN_SERVICE_ACCEPT_POLICY_ALL : legacy_hal::NAN_SERVICE_ACCEPT_POLICY_NONE;
 
   return true;
 }
@@ -1041,7 +1043,7 @@
         hidl_request.baseConfigs.disableMatchExpirationIndication ? 0x2 : 0x0;
   legacy_request->recv_indication_cfg |=
         hidl_request.baseConfigs.disableFollowupReceivedIndication ? 0x4 : 0x0;
-  legacy_request->cipher_type = hidl_request.baseConfigs.supportedCipherTypes;
+  legacy_request->cipher_type = (unsigned int) hidl_request.baseConfigs.cipherType;
   legacy_request->pmk_len = hidl_request.baseConfigs.pmk.size();
   if (legacy_request->pmk_len > NAN_PMK_INFO_LEN) {
     LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: pmk_len too large";
@@ -1230,14 +1232,15 @@
         legacy_hal::NAN_DP_CONFIG_SECURITY : legacy_hal::NAN_DP_CONFIG_NO_SECURITY;
   legacy_request->app_info.ndp_app_info_len = hidl_request.appInfo.size();
   if (legacy_request->app_info.ndp_app_info_len > NAN_DP_MAX_APP_INFO_LEN) {
-    LOG(ERROR) << "convertHidlNanDataPathInitiatorRequestToLegacy: ndp_app_info_len to large";
+    LOG(ERROR) << "convertHidlNanDataPathInitiatorRequestToLegacy: ndp_app_info_len too large";
     return false;
   }
   memcpy(legacy_request->app_info.ndp_app_info, hidl_request.appInfo.data(),
         legacy_request->app_info.ndp_app_info_len);
-  legacy_request->cipher_type = hidl_request.supportedCipherTypes;
+  legacy_request->cipher_type = (unsigned int) hidl_request.cipherType;
   legacy_request->pmk_len = hidl_request.pmk.size();
   if (legacy_request->pmk_len > NAN_PMK_INFO_LEN) {
+    LOG(ERROR) << "convertHidlNanDataPathInitiatorRequestToLegacy: pmk_len too large";
     return false;
   }
   memcpy(legacy_request->pmk, hidl_request.pmk.data(), legacy_request->pmk_len);
@@ -1267,7 +1270,7 @@
   }
   memcpy(legacy_request->app_info.ndp_app_info, hidl_request.appInfo.data(),
         legacy_request->app_info.ndp_app_info_len);
-  legacy_request->cipher_type = hidl_request.supportedCipherTypes;
+  legacy_request->cipher_type = (unsigned int) hidl_request.cipherType;
   legacy_request->pmk_len = hidl_request.pmk.size();
   if (legacy_request->pmk_len > NAN_PMK_INFO_LEN) {
     LOG(ERROR) << "convertHidlNanDataPathIndicationResponseToLegacy: pmk_len too large";
@@ -1337,7 +1340,7 @@
   hidl_ind->matchOccuredInBeaconFlag = legacy_ind.match_occured_flag == 1;
   hidl_ind->outOfResourceFlag = legacy_ind.out_of_resource_flag == 1;
   hidl_ind->rssiValue = legacy_ind.rssi_value;
-  hidl_ind->peerSupportedCipherTypes = legacy_ind.peer_cipher_type;
+  hidl_ind->peerCipherType = (NanCipherSuiteType) legacy_ind.peer_cipher_type;
   hidl_ind->peerRequiresSecurityEnabledInNdp =
         legacy_ind.peer_sdea_params.security_cfg == legacy_hal::NAN_DP_CONFIG_SECURITY;
   hidl_ind->peerRequiresRanging =
diff --git a/wifi/1.0/default/wifi_nan_iface.cpp b/wifi/1.0/default/wifi_nan_iface.cpp
index 68be2a7..6977fc0 100644
--- a/wifi/1.0/default/wifi_nan_iface.cpp
+++ b/wifi/1.0/default/wifi_nan_iface.cpp
@@ -166,6 +166,7 @@
             LOG(ERROR) << "Failed to invoke the callback";
           }
         }
+        break;
     }
     case legacy_hal::NAN_DP_END: {
         for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
diff --git a/wifi/1.0/types.hal b/wifi/1.0/types.hal
index a843ce8..3b2f25b 100644
--- a/wifi/1.0/types.hal
+++ b/wifi/1.0/types.hal
@@ -877,6 +877,7 @@
  * Cipher suite flags.
  */
 enum NanCipherSuiteType : uint32_t {
+  NONE = 0, // No (open) security
   SHARED_KEY_128_MASK = 1 << 0, // NCS-SK-128
   SHARED_KEY_256_MASK = 1 << 1  // NCS-SK-256
 };
@@ -991,13 +992,15 @@
    */
   bool disableFollowupReceivedIndication;
   /**
-   * Cipher types supported in data-paths constructed in the context of this discovery session.
+   * Cipher type for data-paths constructed in the context of this discovery session. Must be
+   * specified as |NanCipherSuiteType.NONE| if no |pmk| is provided.
    */
-  bitfield<NanCipherSuiteType> supportedCipherTypes;
+  NanCipherSuiteType cipherType;
   /**
    * Optional Pairwise Master Key (PMK) for data-paths constructed in the context of this discovery
    * session. A PMK can also be provided during the actual construction of the data-path (which
-   * allows for unique PMKs for each data-path).
+   * allows for unique PMKs for each data-path). The |cipherType| must be specified if a PMK is
+   * provided.
    * Max length: 32
    * Ref: IEEE 802.11i
    */
@@ -1059,6 +1062,13 @@
    * peer.
    */
   NanTxType txType;
+  /**
+   * Specifies whether data-path requests |IWifiNanIfaceEventCallback.eventDataPathRequest| (in
+   * the context of this discovery session) are automatically accepted (if true) - in which case
+   * the Responder must not call the |IWifiNanIface.respondToDataPathIndicationRequest| method and
+   * the device must automatically accept the data-path request and complete the negotiation.
+   */
+  bool autoAcceptDataPathRequests;
 };
 
 /**
@@ -1199,11 +1209,13 @@
    */
   vec<uint8_t> appInfo;
   /**
-   * Cipher types supported in data-paths constructed in the context of this discovery session.
+   * Cipher type for the data-path being requested. Must be specified as |NanCipherSuiteType.NONE|
+   * if no |pmk| is provided.
    */
-  bitfield<NanCipherSuiteType> supportedCipherTypes;
+  NanCipherSuiteType cipherType;
   /**
    * Pairwise Master Key (PMK) for the data-path being requested (if |securityRequired| is true).
+   * The |cipherType| must be specified if a PMK is provided.
    * Max length: 32
    * Ref: IEEE 802.11i
    */
@@ -1243,11 +1255,13 @@
    */
   vec<uint8_t> appInfo;
   /**
-   * Cipher types supported in data-paths constructed in the context of this discovery session.
+   * Cipher type for the data-path being negotiated. Must be specified as |NanCipherSuiteType.NONE|
+   * if no |pmk| is provided.
    */
-  bitfield<NanCipherSuiteType> supportedCipherTypes;
+  NanCipherSuiteType cipherType;
   /**
    * Pairwise Master Key (PMK) for the data-path being negotiated (if |securityRequired| is true).
+   * The |cipherType| must be specified if a PMK is provided.
    * Max length: 32
    */
   vec<uint8_t> pmk;
@@ -1374,13 +1388,14 @@
    */
   uint8_t rssiValue;
   /**
-   * Cipher types supported by the peer for data-paths constructed in the context of this discovery
-   * session.
+   * Cipher type for data-paths constructed in the context of this discovery session. Valid if
+   * |peerRequiresSecurityEnabledInNdp| is true.
    */
-  bitfield<NanCipherSuiteType> peerSupportedCipherTypes;
+  NanCipherSuiteType peerCipherType;
   /**
    * Indicates whether or not the peer requires security enabled in any data-path (NDP) constructed
-   * in the context of this discovery session.
+   * in the context of this discovery session. The |cipherType| specifies the cipher type for such
+   * data-paths.
    * NAN Spec: Service Discovery Extension Attribute (SDEA) / Control / Security Required
    */
   bool peerRequiresSecurityEnabledInNdp;
diff --git a/wifi/1.0/vts/functional/Android.bp b/wifi/1.0/vts/functional/Android.bp
index 01eeef5..de917c0 100644
--- a/wifi/1.0/vts/functional/Android.bp
+++ b/wifi/1.0/vts/functional/Android.bp
@@ -16,7 +16,6 @@
 
 cc_test {
     name: "VtsHalWifiV1_0TargetTest",
-    gtest: true,
     srcs: [
         "VtsHalWifiV1_0TargetTest.cpp",
         "wifi_ap_iface_hidl_test.cpp",
@@ -34,12 +33,11 @@
         "libcutils",
         "libhidlbase",
         "libhidltransport",
-        "libhwbinder",
         "libnativehelper",
         "libutils",
         "android.hardware.wifi@1.0",
     ],
-    static_libs: ["libgtest"],
+    static_libs: ["VtsHalHidlTargetBaseTest"],
     cflags: [
         "-O0",
         "-g",
diff --git a/wifi/1.0/vts/functional/VtsHalWifiV1_0TargetTest.cpp b/wifi/1.0/vts/functional/VtsHalWifiV1_0TargetTest.cpp
index b33b5eb..51512a1 100644
--- a/wifi/1.0/vts/functional/VtsHalWifiV1_0TargetTest.cpp
+++ b/wifi/1.0/vts/functional/VtsHalWifiV1_0TargetTest.cpp
@@ -16,7 +16,7 @@
 
 #include <android-base/logging.h>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 
 #include "wifi_hidl_test_utils.h"
 
diff --git a/wifi/1.0/vts/functional/wifi_ap_iface_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_ap_iface_hidl_test.cpp
index dc7b0b9..dd3df56 100644
--- a/wifi/1.0/vts/functional/wifi_ap_iface_hidl_test.cpp
+++ b/wifi/1.0/vts/functional/wifi_ap_iface_hidl_test.cpp
@@ -18,7 +18,7 @@
 
 #include <android/hardware/wifi/1.0/IWifiApIface.h>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 
 #include "wifi_hidl_test_utils.h"
 
@@ -28,7 +28,7 @@
 /**
  * Fixture to use for all AP Iface HIDL interface tests.
  */
-class WifiApIfaceHidlTest : public ::testing::Test {
+class WifiApIfaceHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
    public:
     virtual void SetUp() override {}
 
diff --git a/wifi/1.0/vts/functional/wifi_chip_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_chip_hidl_test.cpp
index b6ecd8b..3c2ba9a 100644
--- a/wifi/1.0/vts/functional/wifi_chip_hidl_test.cpp
+++ b/wifi/1.0/vts/functional/wifi_chip_hidl_test.cpp
@@ -18,7 +18,7 @@
 
 #include <android/hardware/wifi/1.0/IWifiChip.h>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 
 #include "wifi_hidl_test_utils.h"
 
@@ -28,7 +28,7 @@
 /**
  * Fixture to use for all Wifi chip HIDL interface tests.
  */
-class WifiChipHidlTest : public ::testing::Test {
+class WifiChipHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
    public:
     virtual void SetUp() override {}
 
diff --git a/wifi/1.0/vts/functional/wifi_hidl_call_util.h b/wifi/1.0/vts/functional/wifi_hidl_call_util.h
index 03200a0..4797423 100644
--- a/wifi/1.0/vts/functional/wifi_hidl_call_util.h
+++ b/wifi/1.0/vts/functional/wifi_hidl_call_util.h
@@ -21,7 +21,7 @@
 #include <type_traits>
 #include <utility>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 
 namespace {
 namespace detail {
diff --git a/wifi/1.0/vts/functional/wifi_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_hidl_test.cpp
index 3e350e5..2f4e01e 100644
--- a/wifi/1.0/vts/functional/wifi_hidl_test.cpp
+++ b/wifi/1.0/vts/functional/wifi_hidl_test.cpp
@@ -18,7 +18,7 @@
 
 #include <android/hardware/wifi/1.0/IWifi.h>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 
 #include "wifi_hidl_test_utils.h"
 
@@ -28,7 +28,7 @@
 /**
  * Fixture to use for all root Wifi HIDL interface tests.
  */
-class WifiHidlTest : public ::testing::Test {
+class WifiHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
    public:
     virtual void SetUp() override {}
 
diff --git a/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp b/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp
index 8f34a88..820a75d 100644
--- a/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp
+++ b/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 
 #include "wifi_hidl_call_util.h"
 #include "wifi_hidl_test_utils.h"
@@ -43,7 +43,7 @@
 void startFramework() { ASSERT_EQ(std::system("svc wifi enable"), 0); }
 
 sp<IWifi> getWifi() {
-    sp<IWifi> wifi = IWifi::getService();
+    sp<IWifi> wifi = testing::VtsHalHidlTargetBaseTest::getService<IWifi>();
     return wifi;
 }
 
diff --git a/wifi/1.0/vts/functional/wifi_nan_iface_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_nan_iface_hidl_test.cpp
index a8be48c..eb482c9 100644
--- a/wifi/1.0/vts/functional/wifi_nan_iface_hidl_test.cpp
+++ b/wifi/1.0/vts/functional/wifi_nan_iface_hidl_test.cpp
@@ -18,7 +18,7 @@
 
 #include <android/hardware/wifi/1.0/IWifiNanIface.h>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 
 #include "wifi_hidl_test_utils.h"
 
@@ -28,7 +28,7 @@
 /**
  * Fixture to use for all NAN Iface HIDL interface tests.
  */
-class WifiNanIfaceHidlTest : public ::testing::Test {
+class WifiNanIfaceHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
    public:
     virtual void SetUp() override {}
 
diff --git a/wifi/1.0/vts/functional/wifi_p2p_iface_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_p2p_iface_hidl_test.cpp
index e29226d..d53096c 100644
--- a/wifi/1.0/vts/functional/wifi_p2p_iface_hidl_test.cpp
+++ b/wifi/1.0/vts/functional/wifi_p2p_iface_hidl_test.cpp
@@ -18,7 +18,7 @@
 
 #include <android/hardware/wifi/1.0/IWifiP2pIface.h>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 
 #include "wifi_hidl_test_utils.h"
 
@@ -28,7 +28,7 @@
 /**
  * Fixture to use for all P2P Iface HIDL interface tests.
  */
-class WifiP2pIfaceHidlTest : public ::testing::Test {
+class WifiP2pIfaceHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
    public:
     virtual void SetUp() override {}
 
diff --git a/wifi/1.0/vts/functional/wifi_rtt_controller_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_rtt_controller_hidl_test.cpp
index 7aee761..4d08919 100644
--- a/wifi/1.0/vts/functional/wifi_rtt_controller_hidl_test.cpp
+++ b/wifi/1.0/vts/functional/wifi_rtt_controller_hidl_test.cpp
@@ -18,7 +18,7 @@
 
 #include <android/hardware/wifi/1.0/IWifiRttController.h>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 
 #include "wifi_hidl_test_utils.h"
 
@@ -28,7 +28,7 @@
 /**
  * Fixture to use for all RTT controller HIDL interface tests.
  */
-class WifiRttControllerHidlTest : public ::testing::Test {
+class WifiRttControllerHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
    public:
     virtual void SetUp() override {}
 
diff --git a/wifi/1.0/vts/functional/wifi_sta_iface_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_sta_iface_hidl_test.cpp
index 770763c..4457487 100644
--- a/wifi/1.0/vts/functional/wifi_sta_iface_hidl_test.cpp
+++ b/wifi/1.0/vts/functional/wifi_sta_iface_hidl_test.cpp
@@ -18,7 +18,7 @@
 
 #include <android/hardware/wifi/1.0/IWifiStaIface.h>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 
 #include "wifi_hidl_test_utils.h"
 
@@ -28,7 +28,7 @@
 /**
  * Fixture to use for all STA Iface HIDL interface tests.
  */
-class WifiStaIfaceHidlTest : public ::testing::Test {
+class WifiStaIfaceHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
    public:
     virtual void SetUp() override {}
 
diff --git a/wifi/supplicant/1.0/vts/functional/Android.mk b/wifi/supplicant/1.0/vts/functional/Android.mk
index 52fecc2..93e5250 100644
--- a/wifi/supplicant/1.0/vts/functional/Android.mk
+++ b/wifi/supplicant/1.0/vts/functional/Android.mk
@@ -31,13 +31,12 @@
     libcutils \
     libhidlbase \
     libhidltransport \
-    libhwbinder \
     liblog \
     libutils \
     libwifi-hal \
     libwifi-system
 LOCAL_STATIC_LIBRARIES := \
     libgmock \
-    libgtest
+    VtsHalHidlTargetBaseTest
 include $(BUILD_NATIVE_TEST)
 
diff --git a/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp b/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp
index 81a2947..802d11c 100644
--- a/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp
+++ b/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp
@@ -16,7 +16,7 @@
 
 #include <android-base/logging.h>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 
 #include "supplicant_hidl_test_utils.h"
 
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp
index 9922447..eb02445 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp
@@ -16,7 +16,7 @@
 
 #include <android-base/logging.h>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 
 #include "supplicant_hidl_test_utils.h"
 
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp
index 2f3405d..3f7ee1a 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp
@@ -15,7 +15,7 @@
  */
 
 #include <android-base/logging.h>
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 
 #include <hidl/HidlTransportSupport.h>
 #include <android/hidl/manager/1.0/IServiceManager.h>
@@ -174,7 +174,7 @@
 }
 
 sp<ISupplicant> getSupplicant() {
-    return ISupplicant::getService(kSupplicantServiceName);
+    return getService<ISupplicant>(kSupplicantServiceName);
 }
 
 sp<ISupplicantStaIface> getSupplicantStaIface() {
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
index 968d4c9..200845b 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
@@ -16,7 +16,7 @@
 
 #include <android-base/logging.h>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 
 #include "supplicant_hidl_test_utils.h"
 
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
index 45cc6bc..a1f5513 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
@@ -16,7 +16,7 @@
 
 #include <android-base/logging.h>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 
 #include "supplicant_hidl_test_utils.h"
 
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
index 8c42a22..e2572c2 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
@@ -16,7 +16,7 @@
 
 #include <android-base/logging.h>
 
-#include <gtest/gtest.h>
+#include <VtsHalHidlTargetBaseTest.h>
 
 #include "supplicant_hidl_test_utils.h"