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/audio/2.0/default/Android.mk b/audio/2.0/default/Android.mk
index a1ac61d..93f7ad0 100644
--- a/audio/2.0/default/Android.mk
+++ b/audio/2.0/default/Android.mk
@@ -69,7 +69,8 @@
     android.hardware.audio.common@2.0 \
     android.hardware.audio.effect@2.0 \
     android.hardware.soundtrigger@2.0 \
-    android.hardware.broadcastradio@1.0
+    android.hardware.broadcastradio@1.0 \
+    android.hardware.broadcastradio@1.1
 
 ifeq ($(strip $(AUDIOSERVER_MULTILIB)),)
 LOCAL_MULTILIB := 32
@@ -77,4 +78,8 @@
 LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
 endif
 
+ifeq ($(TARGET_USES_BCRADIO_FUTURE_FEATURES),true)
+LOCAL_CFLAGS += -DTARGET_USES_BCRADIO_FUTURE_FEATURES
+endif
+
 include $(BUILD_EXECUTABLE)
diff --git a/audio/2.0/default/service.cpp b/audio/2.0/default/service.cpp
index 935d556..f3a858a 100644
--- a/audio/2.0/default/service.cpp
+++ b/audio/2.0/default/service.cpp
@@ -22,6 +22,7 @@
 #include <android/hardware/audio/effect/2.0/IEffectsFactory.h>
 #include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
 #include <android/hardware/broadcastradio/1.0/IBroadcastRadioFactory.h>
+#include <android/hardware/broadcastradio/1.1/IBroadcastRadioFactory.h>
 
 using android::hardware::configureRpcThreadpool;
 using android::hardware::joinRpcThreadpool;
@@ -31,7 +32,13 @@
 using android::hardware::audio::V2_0::IDevicesFactory;
 using android::hardware::soundtrigger::V2_0::ISoundTriggerHw;
 using android::hardware::registerPassthroughServiceImplementation;
-using android::hardware::broadcastradio::V1_0::IBroadcastRadioFactory;
+namespace broadcastradio = android::hardware::broadcastradio;
+
+#ifdef TARGET_USES_BCRADIO_FUTURE_FEATURES
+static const bool useBroadcastRadioFutureFeatures = true;
+#else
+static const bool useBroadcastRadioFutureFeatures = false;
+#endif
 
 using android::OK;
 
@@ -45,7 +52,13 @@
     // Soundtrigger and FM radio might be not present.
     status = registerPassthroughServiceImplementation<ISoundTriggerHw>("sound_trigger.primary");
     ALOGE_IF(status != OK, "Error while registering soundtrigger service: %d", status);
-    status = registerPassthroughServiceImplementation<IBroadcastRadioFactory>();
+    if (useBroadcastRadioFutureFeatures) {
+        status = registerPassthroughServiceImplementation<
+            broadcastradio::V1_1::IBroadcastRadioFactory>();
+    } else {
+        status = registerPassthroughServiceImplementation<
+            broadcastradio::V1_0::IBroadcastRadioFactory>();
+    }
     ALOGE_IF(status != OK, "Error while registering fm radio service: %d", status);
     joinRpcThreadpool();
     return status;
diff --git a/automotive/vehicle/2.0/default/Android.mk b/automotive/vehicle/2.0/default/Android.mk
index fcfe3df..ba4a6cd 100644
--- a/automotive/vehicle/2.0/default/Android.mk
+++ b/automotive/vehicle/2.0/default/Android.mk
@@ -75,6 +75,8 @@
 LOCAL_MODULE:= $(vhal_v2_0)-default-impl-lib
 LOCAL_SRC_FILES:= \
     impl/vhal_v2_0/DefaultVehicleHal.cpp \
+    impl/vhal_v2_0/PipeComm.cpp \
+    impl/vhal_v2_0/SocketComm.cpp
 
 LOCAL_C_INCLUDES := \
     $(LOCAL_PATH)/impl/vhal_v2_0
@@ -86,6 +88,7 @@
     $(vhal_v2_0)-manager-lib \
 
 LOCAL_SHARED_LIBRARIES := \
+    libbase \
     libbinder \
     libhidlbase \
     libhidltransport \
@@ -98,6 +101,8 @@
 LOCAL_STATIC_LIBRARIES := \
     $(vhal_v2_0)-libproto-native \
 
+LOCAL_CFLAGS += -Wall -Wextra -Werror
+
 include $(BUILD_STATIC_LIBRARY)
 
 
@@ -146,6 +151,7 @@
     VehicleService.cpp
 
 LOCAL_SHARED_LIBRARIES := \
+    libbase \
     libbinder \
     libhidlbase \
     libhidltransport \
@@ -160,4 +166,6 @@
     $(vhal_v2_0)-default-impl-lib \
     $(vhal_v2_0)-libproto-native \
 
+LOCAL_CFLAGS += -Wall -Wextra -Werror
+
 include $(BUILD_EXECUTABLE)
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/CommBase.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/CommBase.h
new file mode 100644
index 0000000..6832ad3
--- /dev/null
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/CommBase.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 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.
+ */
+
+#ifndef android_hardware_automotive_vehicle_V2_0_impl_CommBase_H_
+#define android_hardware_automotive_vehicle_V2_0_impl_CommBase_H_
+
+#include <string>
+#include <vector>
+
+namespace android {
+namespace hardware {
+namespace automotive {
+namespace vehicle {
+namespace V2_0 {
+
+namespace impl {
+
+/**
+ * This is the communications base class.  It defines the interface used in DefaultVehicleHal to
+ * send and receive data to and from the emulator.
+ */
+class CommBase {
+public:
+    virtual ~CommBase() = default;
+
+    /**
+     * Closes a connection if it is open.
+     */
+    virtual void stop() {}
+
+    /**
+     * Creates a connection to the other side.
+     *
+     * @return int Returns fd or socket number if connection is successful.
+     *              Otherwise, returns -1 if no connection is availble.
+     */
+    virtual int connect() { return 0; }
+
+    /**
+     * Opens the communications channel.
+     *
+     * @return int Returns 0 if channel is opened, else -errno if failed.
+     */
+    virtual int open() = 0;
+
+    /**
+     * Blocking call to read data from the connection.
+     *
+     * @return std::vector<uint8_t> Serialized protobuf data received from emulator.  This will be
+     *              an empty vector if the connection was closed or some other error occurred.
+     */
+    virtual std::vector<uint8_t> read() = 0;
+
+    /**
+     * Transmits a string of data to the emulator.
+     *
+     * @param data Serialized protobuf data to transmit.
+     *
+     * @return int Number of bytes transmitted, or -1 if failed.
+     */
+    virtual int write(const std::vector<uint8_t>& data) = 0;
+};
+
+}  // impl
+
+}  // namespace V2_0
+}  // namespace vehicle
+}  // namespace automotive
+}  // namespace hardware
+}  // namespace android
+
+
+#endif  // android_hardware_automotive_vehicle_V2_0_impl_CommBase_H_
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.cpp
index f21e950..f020ba7 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.cpp
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.cpp
@@ -18,14 +18,14 @@
 #include <android/log.h>
 
 #include <algorithm>
-#include <netinet/in.h>
-#include <sys/socket.h>
+#include <android-base/properties.h>
+#include <cstdio>
 
 #include "DefaultVehicleHal.h"
+#include "PipeComm.h"
+#include "SocketComm.h"
 #include "VehicleHalProto.pb.h"
 
-#define DEBUG_SOCKET    (33452)
-
 namespace android {
 namespace hardware {
 namespace automotive {
@@ -184,34 +184,35 @@
 void DefaultVehicleHal::parseRxProtoBuf(std::vector<uint8_t>& msg) {
     emulator::EmulatorMessage rxMsg;
     emulator::EmulatorMessage respMsg;
-    std::string str(reinterpret_cast<const char*>(msg.data()), msg.size());
 
-    rxMsg.ParseFromString(str);
+    if (rxMsg.ParseFromArray(msg.data(), msg.size())) {
+        switch (rxMsg.msg_type()) {
+        case emulator::GET_CONFIG_CMD:
+            doGetConfig(rxMsg, respMsg);
+            break;
+        case emulator::GET_CONFIG_ALL_CMD:
+            doGetConfigAll(rxMsg, respMsg);
+            break;
+        case emulator::GET_PROPERTY_CMD:
+            doGetProperty(rxMsg, respMsg);
+            break;
+        case emulator::GET_PROPERTY_ALL_CMD:
+            doGetPropertyAll(rxMsg, respMsg);
+            break;
+        case emulator::SET_PROPERTY_CMD:
+            doSetProperty(rxMsg, respMsg);
+            break;
+        default:
+            ALOGW("%s: Unknown message received, type = %d", __FUNCTION__, rxMsg.msg_type());
+            respMsg.set_status(emulator::ERROR_UNIMPLEMENTED_CMD);
+            break;
+        }
 
-    switch (rxMsg.msg_type()) {
-    case emulator::GET_CONFIG_CMD:
-        doGetConfig(rxMsg, respMsg);
-        break;
-    case emulator::GET_CONFIG_ALL_CMD:
-        doGetConfigAll(rxMsg, respMsg);
-        break;
-    case emulator::GET_PROPERTY_CMD:
-        doGetProperty(rxMsg, respMsg);
-        break;
-    case emulator::GET_PROPERTY_ALL_CMD:
-        doGetPropertyAll(rxMsg, respMsg);
-        break;
-    case emulator::SET_PROPERTY_CMD:
-        doSetProperty(rxMsg, respMsg);
-        break;
-    default:
-        ALOGW("%s: Unknown message received, type = %d", __FUNCTION__, rxMsg.msg_type());
-        respMsg.set_status(emulator::ERROR_UNIMPLEMENTED_CMD);
-        break;
+        // Send the reply
+        txMsg(respMsg);
+    } else {
+        ALOGE("%s: ParseFromString() failed. msgSize=%d", __FUNCTION__, static_cast<int>(msg.size()));
     }
-
-    // Send the reply
-    txMsg(respMsg);
 }
 
 // Copies internal VehiclePropConfig data structure to protobuf VehiclePropConfig
@@ -306,94 +307,50 @@
     }
 }
 
-void DefaultVehicleHal::rxMsg(void) {
+void DefaultVehicleHal::rxMsg() {
     int  numBytes = 0;
-    int32_t msgSize;
-    do {
-        // This is a variable length message.
-        // Read the number of bytes to rx over the socket
-        numBytes = read(mCurSocket, &msgSize, sizeof(msgSize));
 
-        if (numBytes != sizeof(msgSize)) {
-            // This happens when connection is closed
-            ALOGD("%s: numBytes=%d, expected=4", __FUNCTION__, numBytes);
-            break;
-        }
+    while (mExit == 0) {
+        std::vector<uint8_t> msg = mComm->read();
 
-        std::vector<uint8_t> msg = std::vector<uint8_t>(msgSize);
-
-        numBytes = read(mCurSocket, msg.data(), msgSize);
-
-        if ((numBytes == msgSize) && (msgSize > 0)) {
+        if (msg.size() > 0) {
             // Received a message.
             parseRxProtoBuf(msg);
         } else {
             // This happens when connection is closed
-            ALOGD("%s: numBytes=%d, msgSize=%d", __FUNCTION__, numBytes, msgSize);
+            ALOGD("%s: numBytes=%d, msgSize=%d", __FUNCTION__, numBytes,
+                  static_cast<int32_t>(msg.size()));
             break;
         }
-    } while (mExit == 0);
+    }
 }
 
-void DefaultVehicleHal::rxThread(void) {
-    // Initialize the socket
-    {
-        int retVal;
-        struct sockaddr_in servAddr;
+void DefaultVehicleHal::rxThread() {
+    bool isEmulator = android::base::GetBoolProperty("ro.kernel.qemu", false);
 
-        mSocket = socket(AF_INET, SOCK_STREAM, 0);
-        if (mSocket < 0) {
-            ALOGE("%s: socket() failed, mSocket=%d, errno=%d", __FUNCTION__, mSocket, errno);
-            mSocket = -1;
-            return;
-        }
-
-        bzero(&servAddr, sizeof(servAddr));
-        servAddr.sin_family = AF_INET;
-        servAddr.sin_addr.s_addr = INADDR_ANY;
-        servAddr.sin_port = htons(DEBUG_SOCKET);
-
-        retVal = bind(mSocket, reinterpret_cast<struct sockaddr*>(&servAddr), sizeof(servAddr));
-        if(retVal < 0) {
-            ALOGE("%s: Error on binding: retVal=%d, errno=%d", __FUNCTION__, retVal, errno);
-            close(mSocket);
-            mSocket = -1;
-            return;
-        }
-
-        listen(mSocket, 1);
-
-        // Set the socket to be non-blocking so we can poll it continouously
-        fcntl(mSocket, F_SETFL, O_NONBLOCK);
+    if (isEmulator) {
+        // Initialize pipe to Emulator
+        mComm.reset(new PipeComm);
+    } else {
+        // Initialize socket over ADB
+        mComm.reset(new SocketComm);
     }
 
-    while (mExit == 0) {
-        struct sockaddr_in cliAddr;
-        socklen_t cliLen = sizeof(cliAddr);
-        int cSocket = accept(mSocket, reinterpret_cast<struct sockaddr*>(&cliAddr), &cliLen);
+    int retVal = mComm->open();
 
-        if (cSocket >= 0) {
-            {
-                std::lock_guard<std::mutex> lock(mTxMutex);
-                mCurSocket = cSocket;
+    if (retVal == 0) {
+        // Comms are properly opened
+        while (mExit == 0) {
+            retVal = mComm->connect();
+
+            if (retVal >= 0) {
+                rxMsg();
             }
-            ALOGD("%s: Incoming connection received on socket %d", __FUNCTION__, cSocket);
-            rxMsg();
-            ALOGD("%s: Connection terminated on socket %d", __FUNCTION__, cSocket);
-            {
-                std::lock_guard<std::mutex> lock(mTxMutex);
-                mCurSocket = -1;
-            }
+
+            // Check every 100ms for a new connection
+            std::this_thread::sleep_for(std::chrono::milliseconds(100));
         }
-
-        // TODO:  Use a blocking socket?
-        // Check every 100ms for a new socket connection
-        std::this_thread::sleep_for(std::chrono::milliseconds(100));
     }
-
-    // Shutdown the socket
-    close(mSocket);
-    mSocket = -1;
 }
 
 // This function sets the default value of a property if we are interested in setting it.
@@ -454,21 +411,15 @@
 
 // Transmit a reply back to the emulator
 void DefaultVehicleHal::txMsg(emulator::EmulatorMessage& txMsg) {
-    std::string msgString;
+    int numBytes = txMsg.ByteSize();
+    std::vector<uint8_t> msg(numBytes);
 
-    if (txMsg.SerializeToString(&msgString)) {
-        int32_t msgLen = msgString.length();
+    if (txMsg.SerializeToArray(msg.data(), msg.size())) {
         int retVal = 0;
 
-        // TODO:  Prepend the message length to the string without a copy
-        msgString.insert(0, reinterpret_cast<char*>(&msgLen), 4);
-
         // Send the message
-        {
-            std::lock_guard<std::mutex> lock(mTxMutex);
-            if (mCurSocket != -1) {
-                retVal = write(mCurSocket, msgString.data(), msgString.size());
-            }
+        if (mExit == 0) {
+            mComm->write(msg);
         }
 
         if (retVal < 0) {
@@ -553,9 +504,7 @@
 // Parse supported properties list and generate vector of property values to hold current values.
 void DefaultVehicleHal::onCreate() {
     // Initialize member variables
-    mCurSocket = -1;
     mExit = 0;
-    mSocket = -1;
 
     // Get the list of configurations supported by this HAL
     std::vector<VehiclePropConfig> configs = listProperties();
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.h
index 29e8a9f..b4ba8ba 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.h
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.h
@@ -23,6 +23,9 @@
 
 #include <utils/SystemClock.h>
 
+#include "CommBase.h"
+#include "VehicleHalProto.pb.h"
+
 #include <vhal_v2_0/VehicleHal.h>
 
 #include "DefaultConfig.h"
@@ -44,13 +47,7 @@
         mExit = 1;
 
         // Close emulator socket if it is open
-        {
-            std::lock_guard<std::mutex> lock(mTxMutex);
-            if (mCurSocket != -1) {
-                close(mCurSocket);
-                mCurSocket = -1;
-            }
-        }
+        mComm->stop();
 
         mThread.join();
     }
@@ -91,19 +88,17 @@
     void populateProtoVehiclePropValue(emulator::VehiclePropValue* protoVal,
                                        const VehiclePropValue* val);
     void setDefaultValue(VehiclePropValue* prop);
-    void rxMsg(void);
-    void rxThread(void);
+    void rxMsg();
+    void rxThread();
     void txMsg(emulator::EmulatorMessage& txMsg);
     StatusCode updateProperty(const VehiclePropValue& propValue);
 private:
     // TODO:  Use a hashtable to support indexing props
     std::vector<std::unique_ptr<VehiclePropValue>> mProps;
-    std::atomic<int> mCurSocket;
     std::atomic<int> mExit;
     std::mutex mPropsMutex;
-    int mSocket;
-    std::mutex mTxMutex;
     std::thread mThread;
+    std::unique_ptr<CommBase> mComm{nullptr};
 };
 
 }  // impl
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/PipeComm.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/PipeComm.cpp
new file mode 100644
index 0000000..6f219fa
--- /dev/null
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/PipeComm.cpp
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 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.
+ */
+
+#define LOG_TAG "PipeComm"
+
+#include <android/hardware/automotive/vehicle/2.0/IVehicle.h>
+#include <android/log.h>
+#include <system/qemu_pipe.h>
+
+#include "PipeComm.h"
+
+#define CAR_SERVICE_NAME "pipe:qemud:car"
+
+
+namespace android {
+namespace hardware {
+namespace automotive {
+namespace vehicle {
+namespace V2_0 {
+
+namespace impl {
+
+PipeComm::PipeComm() {
+    // Initialize member vars
+    mPipeFd = -1;
+}
+
+
+int PipeComm::open() {
+    int fd = qemu_pipe_open(CAR_SERVICE_NAME);
+
+    if (fd < 0) {
+        ALOGE("%s: Could not open connection to service: %s %d", __FUNCTION__, strerror(errno), fd);
+        return -errno;
+    }
+
+    ALOGI("%s: OPENED PIPE, fd=%d", __FUNCTION__, fd);
+    mPipeFd = fd;
+    return 0;
+}
+
+std::vector<uint8_t> PipeComm::read() {
+    static constexpr int MAX_RX_MSG_SZ = 2048;
+    std::vector<uint8_t> msg = std::vector<uint8_t>(MAX_RX_MSG_SZ);
+    int numBytes;
+
+    numBytes = qemu_pipe_frame_recv(mPipeFd, msg.data(), msg.size());
+
+    if (numBytes == MAX_RX_MSG_SZ) {
+        ALOGE("%s:  Received max size = %d", __FUNCTION__, MAX_RX_MSG_SZ);
+    } else if (numBytes > 0) {
+        msg.resize(numBytes);
+        return msg;
+    } else {
+        ALOGD("%s: Connection terminated on pipe %d, numBytes=%d", __FUNCTION__, mPipeFd, numBytes);
+        {
+            std::lock_guard<std::mutex> lock(mMutex);
+            mPipeFd = -1;
+        }
+    }
+
+    return std::vector<uint8_t>();
+}
+
+int PipeComm::write(const std::vector<uint8_t>& data) {
+    int retVal = 0;
+
+    {
+        std::lock_guard<std::mutex> lock(mMutex);
+        if (mPipeFd != -1) {
+            retVal = qemu_pipe_frame_send(mPipeFd, data.data(), data.size());
+        }
+    }
+
+    if (retVal < 0) {
+        retVal = -errno;
+        ALOGE("%s:  send_cmd: (fd=%d): ERROR: %s", __FUNCTION__, mPipeFd, strerror(errno));
+    }
+
+    return retVal;
+}
+
+
+}  // impl
+
+}  // namespace V2_0
+}  // namespace vehicle
+}  // namespace automotive
+}  // namespace hardware
+}  // namespace android
+
+
+
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/PipeComm.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/PipeComm.h
new file mode 100644
index 0000000..bcd32d0
--- /dev/null
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/PipeComm.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 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.
+ */
+
+#ifndef android_hardware_automotive_vehicle_V2_0_impl_PipeComm_H_
+#define android_hardware_automotive_vehicle_V2_0_impl_PipeComm_H_
+
+#include <mutex>
+#include <vector>
+#include "CommBase.h"
+
+namespace android {
+namespace hardware {
+namespace automotive {
+namespace vehicle {
+namespace V2_0 {
+
+namespace impl {
+
+/**
+ * PipeComm uses a qemu pipe interface to connect to the Goldfish Emulator.
+ */
+class PipeComm : public CommBase {
+public:
+    PipeComm();
+
+    /**
+     * Opens a pipe and begins listening.
+     *
+     * @return int Returns 0 on success.
+     */
+    int open() override;
+
+    /**
+     * Blocking call to read data from the connection.
+     *
+     * @return std::vector<uint8_t> Serialized protobuf data received from emulator.  This will be
+     *              an empty vector if the connection was closed or some other error occurred.
+     */
+    std::vector<uint8_t> read() override;
+
+    /**
+     * Transmits a string of data to the emulator.
+     *
+     * @param data Serialized protobuf data to transmit.
+     *
+     * @return int Number of bytes transmitted, or -1 if failed.
+     */
+    int write(const std::vector<uint8_t>& data) override;
+
+private:
+    std::mutex mMutex;
+    int mPipeFd;
+};
+
+}  // impl
+
+}  // namespace V2_0
+}  // namespace vehicle
+}  // namespace automotive
+}  // namespace hardware
+}  // namespace android
+
+
+#endif  // android_hardware_automotive_vehicle_V2_0_impl_PipeComm_H_
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/SocketComm.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/SocketComm.cpp
new file mode 100644
index 0000000..a3ef4b1
--- /dev/null
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/SocketComm.cpp
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 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.
+ */
+
+#define LOG_TAG "SocketComm"
+
+#include <android/hardware/automotive/vehicle/2.0/IVehicle.h>
+#include <android/log.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+
+#include "SocketComm.h"
+
+// Socket to use when communicating with Host PC
+static constexpr int DEBUG_SOCKET = 33452;
+
+namespace android {
+namespace hardware {
+namespace automotive {
+namespace vehicle {
+namespace V2_0 {
+
+namespace impl {
+
+SocketComm::SocketComm() {
+    // Initialize member vars
+    mCurSockFd = -1;
+    mExit      =  0;
+    mSockFd    = -1;
+}
+
+
+SocketComm::~SocketComm() {
+    stop();
+}
+
+int SocketComm::connect() {
+    sockaddr_in cliAddr;
+    socklen_t cliLen = sizeof(cliAddr);
+    int cSockFd = accept(mSockFd, reinterpret_cast<struct sockaddr*>(&cliAddr), &cliLen);
+
+    if (cSockFd >= 0) {
+        {
+            std::lock_guard<std::mutex> lock(mMutex);
+            mCurSockFd = cSockFd;
+        }
+        ALOGD("%s: Incoming connection received on socket %d", __FUNCTION__, cSockFd);
+    } else {
+        cSockFd = -1;
+    }
+
+    return cSockFd;
+}
+
+int SocketComm::open() {
+    int retVal;
+    struct sockaddr_in servAddr;
+
+    mSockFd = socket(AF_INET, SOCK_STREAM, 0);
+    if (mSockFd < 0) {
+        ALOGE("%s: socket() failed, mSockFd=%d, errno=%d", __FUNCTION__, mSockFd, errno);
+        mSockFd = -1;
+        return -errno;
+    }
+
+    memset(&servAddr, 0, sizeof(servAddr));
+    servAddr.sin_family = AF_INET;
+    servAddr.sin_addr.s_addr = INADDR_ANY;
+    servAddr.sin_port = htons(DEBUG_SOCKET);
+
+    retVal = bind(mSockFd, reinterpret_cast<struct sockaddr*>(&servAddr), sizeof(servAddr));
+    if(retVal < 0) {
+        ALOGE("%s: Error on binding: retVal=%d, errno=%d", __FUNCTION__, retVal, errno);
+        close(mSockFd);
+        mSockFd = -1;
+        return -errno;
+    }
+
+    listen(mSockFd, 1);
+
+    // Set the socket to be non-blocking so we can poll it continouously
+    fcntl(mSockFd, F_SETFL, O_NONBLOCK);
+
+    return 0;
+}
+
+std::vector<uint8_t> SocketComm::read() {
+    int32_t msgSize;
+    int numBytes = 0;
+
+    // This is a variable length message.
+    // Read the number of bytes to rx over the socket
+    numBytes = ::read(mCurSockFd, &msgSize, sizeof(msgSize));
+    msgSize = ntohl(msgSize);
+
+    if (numBytes != sizeof(msgSize)) {
+        // This happens when connection is closed
+        ALOGD("%s: numBytes=%d, expected=4", __FUNCTION__, numBytes);
+        ALOGD("%s: Connection terminated on socket %d", __FUNCTION__, mCurSockFd);
+        {
+            std::lock_guard<std::mutex> lock(mMutex);
+            mCurSockFd = -1;
+        }
+
+        return std::vector<uint8_t>();
+    }
+
+    std::vector<uint8_t> msg = std::vector<uint8_t>(msgSize);
+
+    numBytes = ::read(mCurSockFd, msg.data(), msgSize);
+
+    if ((numBytes == msgSize) && (msgSize > 0)) {
+        // Received a message.
+        return msg;
+    } else {
+        // This happens when connection is closed
+        ALOGD("%s: numBytes=%d, msgSize=%d", __FUNCTION__, numBytes, msgSize);
+        ALOGD("%s: Connection terminated on socket %d", __FUNCTION__, mCurSockFd);
+        {
+            std::lock_guard<std::mutex> lock(mMutex);
+            mCurSockFd = -1;
+        }
+
+        return std::vector<uint8_t>();
+    }
+}
+
+void SocketComm::stop() {
+    if (mExit == 0) {
+        std::lock_guard<std::mutex> lock(mMutex);
+        mExit = 1;
+
+        // Close emulator socket if it is open
+        if (mCurSockFd != -1) {
+            close(mCurSockFd);
+            mCurSockFd = -1;
+        }
+
+        if (mSockFd != -1) {
+            close(mSockFd);
+            mSockFd = -1;
+        }
+    }
+}
+
+int SocketComm::write(const std::vector<uint8_t>& data) {
+    static constexpr int MSG_HEADER_LEN = 4;
+    int retVal = 0;
+    union {
+        uint32_t msgLen;
+        uint8_t msgLenBytes[MSG_HEADER_LEN];
+    };
+
+    // Prepare header for the message
+    msgLen = static_cast<uint32_t>(data.size());
+    msgLen = htonl(msgLen);
+
+    std::lock_guard<std::mutex> lock(mMutex);
+    if (mCurSockFd != -1) {
+        retVal = ::write(mCurSockFd, msgLenBytes, MSG_HEADER_LEN);
+
+        if (retVal == MSG_HEADER_LEN) {
+            retVal = ::write(mCurSockFd, data.data(), data.size());
+        }
+    }
+
+    return retVal;
+}
+
+
+}  // impl
+
+}  // namespace V2_0
+}  // namespace vehicle
+}  // namespace automotive
+}  // namespace hardware
+}  // namespace android
+
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/SocketComm.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/SocketComm.h
new file mode 100644
index 0000000..12cfb29
--- /dev/null
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/SocketComm.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 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.
+ */
+
+#ifndef android_hardware_automotive_vehicle_V2_0_impl_SocketComm_H_
+#define android_hardware_automotive_vehicle_V2_0_impl_SocketComm_H_
+
+#include <mutex>
+#include <vector>
+#include "CommBase.h"
+
+namespace android {
+namespace hardware {
+namespace automotive {
+namespace vehicle {
+namespace V2_0 {
+
+namespace impl {
+
+/**
+ * SocketComm opens a socket via adb's TCP port forwarding to enable a Host PC to connect to
+ * the VehicleHAL.
+ */
+class SocketComm : public CommBase {
+public:
+    SocketComm();
+    virtual ~SocketComm();
+
+    /**
+     * Creates a connection to the other side.
+     *
+     * @return int Returns fd or socket number if connection is successful.
+     *              Otherwise, returns -1 if no connection is availble.
+     */
+    int connect() override;
+
+    /**
+     * Opens a socket and begins listening.
+     *
+     * @return int Returns 0 on success.
+     */
+    int open() override;
+
+    /**
+     * Blocking call to read data from the connection.
+     *
+     * @return std::vector<uint8_t> Serialized protobuf data received from emulator.  This will be
+     *              an empty vector if the connection was closed or some other error occurred.
+     */
+    std::vector<uint8_t> read() override;
+
+    /**
+     * Closes a connection if it is open.
+     */
+    void stop() override;
+
+    /**
+     * Transmits a string of data to the emulator.
+     *
+     * @param data Serialized protobuf data to transmit.
+     *
+     * @return int Number of bytes transmitted, or -1 if failed.
+     */
+    int write(const std::vector<uint8_t>& data) override;
+
+private:
+    int mCurSockFd;
+    std::atomic<int> mExit;
+    std::mutex mMutex;
+    int mSockFd;
+};
+
+}  // impl
+
+}  // namespace V2_0
+}  // namespace vehicle
+}  // namespace automotive
+}  // namespace hardware
+}  // namespace android
+
+
+#endif  // android_hardware_automotive_vehicle_V2_0_impl_SocketComm_H_
diff --git a/automotive/vehicle/2.1/default/Android.mk b/automotive/vehicle/2.1/default/Android.mk
index c9d13ea..3075956 100644
--- a/automotive/vehicle/2.1/default/Android.mk
+++ b/automotive/vehicle/2.1/default/Android.mk
@@ -70,6 +70,7 @@
     $(vhal_v2_0)-libproto-native
 
 LOCAL_SHARED_LIBRARIES := \
+    libbase \
     libbinder \
     libhidlbase \
     libhidltransport \
@@ -80,6 +81,8 @@
     $(vhal_v2_0) \
     $(vhal_v2_1) \
 
+LOCAL_CFLAGS += -Wall -Wextra -Werror
+
 include $(BUILD_STATIC_LIBRARY)
 
 ###############################################################################
@@ -103,6 +106,7 @@
     $(vhal_v2_1)-manager-lib \
 
 LOCAL_SHARED_LIBRARIES := \
+    libbase \
     libbinder \
     libhidlbase \
     libhidltransport \
@@ -113,4 +117,6 @@
     $(vhal_v2_0) \
     $(vhal_v2_1) \
 
+LOCAL_CFLAGS += -Wall -Wextra -Werror
+
 include $(BUILD_EXECUTABLE)
diff --git a/automotive/vehicle/2.1/default/service.cpp b/automotive/vehicle/2.1/default/service.cpp
index aaadf17..0844622 100644
--- a/automotive/vehicle/2.1/default/service.cpp
+++ b/automotive/vehicle/2.1/default/service.cpp
@@ -88,7 +88,7 @@
     Vehicle_V2_1 vehicle21(vehicleManager.get());
 
     ALOGI("Registering as service...");
-    vehicle21.registerAsService("Vehicle");
+    vehicle21.registerAsService();
 
     configureRpcThreadpool(1, true /* callerWillJoin */);
 
diff --git a/bluetooth/1.0/default/Android.bp b/bluetooth/1.0/default/Android.bp
index 2ae262c..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",
diff --git a/bluetooth/1.0/default/Android.mk b/bluetooth/1.0/default/Android.mk
index 5043fb9..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 := \
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/vts/functional/Android.bp b/bluetooth/1.0/vts/functional/Android.bp
index 939a07f..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",
@@ -28,7 +27,7 @@
         "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/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp b/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp
index da17514..28a913c 100644
--- a/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp
+++ b/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp
@@ -48,7 +48,7 @@
 using ::android::hardware::broadcastradio::V1_0::MetaData;
 
 
-// The main test class for Sound Trigger HIDL HAL.
+// The main test class for Broadcast Radio HIDL HAL.
 
 class BroadcastRadioHidlTest : public ::testing::Test {
  protected:
diff --git a/broadcastradio/1.1/Android.bp b/broadcastradio/1.1/Android.bp
new file mode 100644
index 0000000..c9a8b10
--- /dev/null
+++ b/broadcastradio/1.1/Android.bp
@@ -0,0 +1,76 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+    name: "android.hardware.broadcastradio@1.1_hal",
+    srcs: [
+        "types.hal",
+        "IBroadcastRadioFactory.hal",
+        "ITuner.hal",
+        "ITunerCallback.hal",
+    ],
+}
+
+genrule {
+    name: "android.hardware.broadcastradio@1.1_genc++",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.broadcastradio@1.1",
+    srcs: [
+        ":android.hardware.broadcastradio@1.1_hal",
+    ],
+    out: [
+        "android/hardware/broadcastradio/1.1/types.cpp",
+        "android/hardware/broadcastradio/1.1/BroadcastRadioFactoryAll.cpp",
+        "android/hardware/broadcastradio/1.1/TunerAll.cpp",
+        "android/hardware/broadcastradio/1.1/TunerCallbackAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.broadcastradio@1.1_genc++_headers",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.broadcastradio@1.1",
+    srcs: [
+        ":android.hardware.broadcastradio@1.1_hal",
+    ],
+    out: [
+        "android/hardware/broadcastradio/1.1/types.h",
+        "android/hardware/broadcastradio/1.1/IBroadcastRadioFactory.h",
+        "android/hardware/broadcastradio/1.1/IHwBroadcastRadioFactory.h",
+        "android/hardware/broadcastradio/1.1/BnHwBroadcastRadioFactory.h",
+        "android/hardware/broadcastradio/1.1/BpHwBroadcastRadioFactory.h",
+        "android/hardware/broadcastradio/1.1/BsBroadcastRadioFactory.h",
+        "android/hardware/broadcastradio/1.1/ITuner.h",
+        "android/hardware/broadcastradio/1.1/IHwTuner.h",
+        "android/hardware/broadcastradio/1.1/BnHwTuner.h",
+        "android/hardware/broadcastradio/1.1/BpHwTuner.h",
+        "android/hardware/broadcastradio/1.1/BsTuner.h",
+        "android/hardware/broadcastradio/1.1/ITunerCallback.h",
+        "android/hardware/broadcastradio/1.1/IHwTunerCallback.h",
+        "android/hardware/broadcastradio/1.1/BnHwTunerCallback.h",
+        "android/hardware/broadcastradio/1.1/BpHwTunerCallback.h",
+        "android/hardware/broadcastradio/1.1/BsTunerCallback.h",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.broadcastradio@1.1",
+    generated_sources: ["android.hardware.broadcastradio@1.1_genc++"],
+    generated_headers: ["android.hardware.broadcastradio@1.1_genc++_headers"],
+    export_generated_headers: ["android.hardware.broadcastradio@1.1_genc++_headers"],
+    shared_libs: [
+        "libhidlbase",
+        "libhidltransport",
+        "libhwbinder",
+        "liblog",
+        "libutils",
+        "libcutils",
+        "android.hardware.broadcastradio@1.0",
+    ],
+    export_shared_lib_headers: [
+        "libhidlbase",
+        "libhidltransport",
+        "libhwbinder",
+        "libutils",
+        "android.hardware.broadcastradio@1.0",
+    ],
+}
diff --git a/broadcastradio/1.1/Android.mk b/broadcastradio/1.1/Android.mk
new file mode 100644
index 0000000..0c4c55d
--- /dev/null
+++ b/broadcastradio/1.1/Android.mk
@@ -0,0 +1,19 @@
+#
+# Copyright (C) 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(call all-subdir-makefiles)
diff --git a/broadcastradio/1.1/IBroadcastRadioFactory.hal b/broadcastradio/1.1/IBroadcastRadioFactory.hal
new file mode 100644
index 0000000..fce1cc0
--- /dev/null
+++ b/broadcastradio/1.1/IBroadcastRadioFactory.hal
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 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.
+ */
+
+package android.hardware.broadcastradio@1.1;
+
+import @1.0::IBroadcastRadioFactory;
+
+/**
+ * To use 1.1 features you must cast specific interfaces after being returned from 1.0 HAL,
+ * for example V1_1::ITuner::castFrom() after retrieving it from IBroadcastRadio::openTuner().
+ * The 1.1 server must always return the 1.1 version of specific interface.
+ */
+interface IBroadcastRadioFactory extends @1.0::IBroadcastRadioFactory {
+};
diff --git a/broadcastradio/1.1/ITuner.hal b/broadcastradio/1.1/ITuner.hal
new file mode 100644
index 0000000..72b2847
--- /dev/null
+++ b/broadcastradio/1.1/ITuner.hal
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 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.
+ */
+
+package android.hardware.broadcastradio@1.1;
+
+import @1.0::ITuner;
+
+interface ITuner extends @1.0::ITuner {
+    /*
+     * Retrieve current station information.
+     * @return result OK if scan successfully started
+     *                NOT_INITIALIZED if another error occurs
+     * @return info Current program information.
+     */
+    getProgramInformation_1_1() generates(Result result, ProgramInfo info);
+};
diff --git a/broadcastradio/1.1/ITunerCallback.hal b/broadcastradio/1.1/ITunerCallback.hal
new file mode 100644
index 0000000..4af6b1f
--- /dev/null
+++ b/broadcastradio/1.1/ITunerCallback.hal
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 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.
+ */
+
+package android.hardware.broadcastradio@1.1;
+
+import @1.0::ITunerCallback;
+
+/**
+ * Some methods of @1.1::ITunerCallback are updated versions of those from @1.0:ITunerCallback.
+ * All 1.1 drivers should call both (eg. tuneComplete and tuneComplete_1_1), while 1.1 clients
+ * should ignore 1.0 ones, to avoid receiving a callback twice.
+ */
+interface ITunerCallback extends @1.0::ITunerCallback {
+    /*
+     * Method called by the HAL when a tuning operation completes
+     * following a step(), scan() or tune() command.
+     * @param result OK if tune succeeded or TIMEOUT in case of time out.
+     * @param info A ProgramInfo structure describing the tuned station.
+     */
+    oneway tuneComplete_1_1(Result result, ProgramInfo info);
+
+    /*
+     * Method called by the HAL when a frequency switch occurs.
+     * @param info A ProgramInfo structure describing the new tuned station.
+     */
+    oneway afSwitch_1_1(ProgramInfo info);
+};
diff --git a/broadcastradio/1.1/WARNING b/broadcastradio/1.1/WARNING
new file mode 100644
index 0000000..e867cfa
--- /dev/null
+++ b/broadcastradio/1.1/WARNING
@@ -0,0 +1 @@
+This is experimental interface, do not use it yet.
diff --git a/broadcastradio/1.1/default/Android.mk b/broadcastradio/1.1/default/Android.mk
new file mode 100644
index 0000000..bb32d50
--- /dev/null
+++ b/broadcastradio/1.1/default/Android.mk
@@ -0,0 +1,46 @@
+#
+# Copyright (C) 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.broadcastradio@1.1-impl
+LOCAL_PROPRIETARY_MODULE := true
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_CFLAGS += -Werror -Wall -Wextra
+LOCAL_SRC_FILES := \
+    BroadcastRadio.cpp \
+    BroadcastRadioFactory.cpp \
+    Tuner.cpp \
+    Utils.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+    libhidlbase \
+    libhidltransport \
+    libutils \
+    liblog \
+    libhardware \
+    android.hardware.broadcastradio@1.0 \
+    android.hardware.broadcastradio@1.1 \
+    libradio_metadata
+
+ifeq ($(strip $(AUDIOSERVER_MULTILIB)),)
+LOCAL_MULTILIB := 32
+else
+LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
+endif
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/broadcastradio/1.1/default/BroadcastRadio.cpp b/broadcastradio/1.1/default/BroadcastRadio.cpp
new file mode 100644
index 0000000..611267b
--- /dev/null
+++ b/broadcastradio/1.1/default/BroadcastRadio.cpp
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 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.
+ */
+#define LOG_TAG "BroadcastRadio"
+//#define LOG_NDEBUG 0
+
+#include <log/log.h>
+
+#include "BroadcastRadio.h"
+#include "Tuner.h"
+#include "Utils.h"
+
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_1 {
+namespace implementation {
+
+using ::android::sp;
+
+BroadcastRadio::BroadcastRadio(Class classId)
+        : mStatus(Result::NOT_INITIALIZED), mClassId(classId), mHwDevice(NULL)
+{
+}
+
+BroadcastRadio::~BroadcastRadio()
+{
+    if (mHwDevice != NULL) {
+        radio_hw_device_close(mHwDevice);
+    }
+}
+
+void BroadcastRadio::onFirstRef()
+{
+    const hw_module_t *mod;
+    int rc;
+    ALOGI("%s mClassId %d", __FUNCTION__, mClassId);
+
+    mHwDevice = NULL;
+    const char *classString = Utils::getClassString(mClassId);
+    if (classString == NULL) {
+        ALOGE("invalid class ID %d", mClassId);
+        mStatus = Result::INVALID_ARGUMENTS;
+        return;
+    }
+
+    ALOGI("%s RADIO_HARDWARE_MODULE_ID %s %s",
+            __FUNCTION__, RADIO_HARDWARE_MODULE_ID, classString);
+
+    rc = hw_get_module_by_class(RADIO_HARDWARE_MODULE_ID, classString, &mod);
+    if (rc != 0) {
+        ALOGE("couldn't load radio module %s.%s (%s)",
+                RADIO_HARDWARE_MODULE_ID, classString, strerror(-rc));
+        return;
+    }
+    rc = radio_hw_device_open(mod, &mHwDevice);
+    if (rc != 0) {
+        ALOGE("couldn't open radio hw device in %s.%s (%s)",
+                RADIO_HARDWARE_MODULE_ID, "primary", strerror(-rc));
+        mHwDevice = NULL;
+        return;
+    }
+    if (mHwDevice->common.version != RADIO_DEVICE_API_VERSION_CURRENT) {
+        ALOGE("wrong radio hw device version %04x", mHwDevice->common.version);
+        radio_hw_device_close(mHwDevice);
+        mHwDevice = NULL;
+    } else {
+        mStatus = Result::OK;
+    }
+}
+
+int BroadcastRadio::closeHalTuner(const struct radio_tuner *halTuner)
+{
+    ALOGV("%s", __FUNCTION__);
+    if (mHwDevice == NULL) {
+        return -ENODEV;
+    }
+    if (halTuner == 0) {
+        return -EINVAL;
+    }
+    return mHwDevice->close_tuner(mHwDevice, halTuner);
+}
+
+
+// Methods from ::android::hardware::broadcastradio::V1_0::IBroadcastRadio follow.
+Return<void> BroadcastRadio::getProperties(getProperties_cb _hidl_cb)
+{
+    int rc;
+    radio_hal_properties_t halProperties;
+    Properties properties;
+
+    if (mHwDevice == NULL) {
+        rc = -ENODEV;
+        goto exit;
+    }
+    rc = mHwDevice->get_properties(mHwDevice, &halProperties);
+    if (rc == 0) {
+        Utils::convertPropertiesFromHal(&properties, &halProperties);
+    }
+
+exit:
+    _hidl_cb(Utils::convertHalResult(rc), properties);
+    return Void();
+}
+
+Return<void> BroadcastRadio::openTuner(const BandConfig& config, bool audio,
+    const sp<V1_0::ITunerCallback>& callback, openTuner_cb _hidl_cb)
+{
+    sp<Tuner> tunerImpl = new Tuner(callback, this);
+
+    radio_hal_band_config_t halConfig;
+    const struct radio_tuner *halTuner;
+    Utils::convertBandConfigToHal(&halConfig, &config);
+    int rc = mHwDevice->open_tuner(mHwDevice, &halConfig, audio, Tuner::callback,
+            tunerImpl.get(), &halTuner);
+    if (rc == 0) {
+        tunerImpl->setHalTuner(halTuner);
+    }
+
+    _hidl_cb(Utils::convertHalResult(rc), tunerImpl);
+    return Void();
+}
+
+} // namespace implementation
+}  // namespace V1_1
+}  // namespace broadcastradio
+}  // namespace hardware
+}  // namespace android
diff --git a/broadcastradio/1.1/default/BroadcastRadio.h b/broadcastradio/1.1/default/BroadcastRadio.h
new file mode 100644
index 0000000..068979d
--- /dev/null
+++ b/broadcastradio/1.1/default/BroadcastRadio.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 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.
+ */
+#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIO_H
+#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIO_H
+
+#include <android/hardware/broadcastradio/1.0/IBroadcastRadio.h>
+#include <android/hardware/broadcastradio/1.1/types.h>
+#include <hardware/radio.h>
+
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_1 {
+namespace implementation {
+
+using V1_0::Class;
+using V1_0::BandConfig;
+using V1_0::Properties;
+
+struct BroadcastRadio : public V1_0::IBroadcastRadio {
+
+    BroadcastRadio(Class classId);
+
+    // Methods from ::android::hardware::broadcastradio::V1_0::IBroadcastRadio follow.
+    Return<void> getProperties(getProperties_cb _hidl_cb) override;
+    Return<void> openTuner(const BandConfig& config, bool audio,
+            const sp<V1_0::ITunerCallback>& callback, openTuner_cb _hidl_cb) override;
+
+    // RefBase
+    virtual void onFirstRef() override;
+
+    Result initCheck() { return mStatus; }
+    int closeHalTuner(const struct radio_tuner *halTuner);
+
+private:
+    virtual ~BroadcastRadio();
+
+    static const char * sClassModuleNames[];
+
+    Result convertHalResult(int rc);
+    void convertBandConfigFromHal(BandConfig *config,
+            const radio_hal_band_config_t *halConfig);
+    void convertPropertiesFromHal(Properties *properties,
+            const radio_hal_properties_t *halProperties);
+    void convertBandConfigToHal(radio_hal_band_config_t *halConfig,
+            const BandConfig *config);
+
+    Result mStatus;
+    Class mClassId;
+    struct radio_hw_device *mHwDevice;
+};
+
+}  // namespace implementation
+}  // namespace V1_1
+}  // namespace broadcastradio
+}  // namespace hardware
+}  // namespace android
+
+#endif  // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIO_H
diff --git a/broadcastradio/1.1/default/BroadcastRadioFactory.cpp b/broadcastradio/1.1/default/BroadcastRadioFactory.cpp
new file mode 100644
index 0000000..c8b6c39
--- /dev/null
+++ b/broadcastradio/1.1/default/BroadcastRadioFactory.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 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 "BroadcastRadioFactory.h"
+#include "BroadcastRadio.h"
+
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_1 {
+namespace implementation {
+
+// Methods from ::android::hardware::broadcastradio::V1_0::IBroadcastRadioFactory follow.
+Return<void> BroadcastRadioFactory::connectModule(Class classId, connectModule_cb _hidl_cb)  {
+    sp<BroadcastRadio> impl = new BroadcastRadio(classId);
+    Result retval = Result::NOT_INITIALIZED;
+    if (impl != 0) {
+        retval = impl->initCheck();
+    }
+    _hidl_cb(retval, impl);
+    return Void();
+}
+
+
+IBroadcastRadioFactory* HIDL_FETCH_IBroadcastRadioFactory(const char* /* name */) {
+    return new BroadcastRadioFactory();
+}
+
+}  // namespace implementation
+}  // namespace V1_1
+}  // namespace broadcastradio
+}  // namespace hardware
+}  // namespace android
diff --git a/broadcastradio/1.1/default/BroadcastRadioFactory.h b/broadcastradio/1.1/default/BroadcastRadioFactory.h
new file mode 100644
index 0000000..8eb8514
--- /dev/null
+++ b/broadcastradio/1.1/default/BroadcastRadioFactory.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 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.
+ */
+#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIOFACTORY_H
+#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIOFACTORY_H
+
+#include <android/hardware/broadcastradio/1.1/IBroadcastRadioFactory.h>
+#include <android/hardware/broadcastradio/1.1/types.h>
+
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_1 {
+namespace implementation {
+
+using V1_0::Class;
+
+struct BroadcastRadioFactory : public IBroadcastRadioFactory {
+    // Methods from ::android::hardware::broadcastradio::V1_0::IBroadcastRadioFactory follow.
+    Return<void> connectModule(Class classId, connectModule_cb _hidl_cb) override;
+};
+
+extern "C" IBroadcastRadioFactory* HIDL_FETCH_IBroadcastRadioFactory(const char* name);
+
+}  // namespace implementation
+}  // namespace V1_1
+}  // namespace broadcastradio
+}  // namespace hardware
+}  // namespace android
+
+#endif  // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIOFACTORY_H
diff --git a/broadcastradio/1.1/default/Tuner.cpp b/broadcastradio/1.1/default/Tuner.cpp
new file mode 100644
index 0000000..6258569
--- /dev/null
+++ b/broadcastradio/1.1/default/Tuner.cpp
@@ -0,0 +1,207 @@
+/*
+ * Copyright (C) 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.
+ */
+
+#define LOG_TAG "Tuner"
+//#define LOG_NDEBUG 0
+
+#include <log/log.h>
+
+#include "BroadcastRadio.h"
+#include "Tuner.h"
+#include "Utils.h"
+#include <system/RadioMetadataWrapper.h>
+
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_1 {
+namespace implementation {
+
+void Tuner::onCallback(radio_hal_event_t *halEvent)
+{
+    BandConfig config;
+    ProgramInfo info;
+    hidl_vec<MetaData> metadata;
+
+    if (mCallback != 0) {
+        switch(halEvent->type) {
+        case RADIO_EVENT_CONFIG:
+            Utils::convertBandConfigFromHal(&config, &halEvent->config);
+            mCallback->configChange(Utils::convertHalResult(halEvent->status), config);
+            break;
+        case RADIO_EVENT_ANTENNA:
+            mCallback->antennaStateChange(halEvent->on);
+            break;
+        case RADIO_EVENT_TUNED:
+            Utils::convertProgramInfoFromHal(&info, &halEvent->info);
+            if (mCallback1_1 != nullptr) {
+                mCallback1_1->tuneComplete_1_1(Utils::convertHalResult(halEvent->status), info);
+            }
+            mCallback->tuneComplete(Utils::convertHalResult(halEvent->status), info.base);
+            break;
+        case RADIO_EVENT_METADATA: {
+            uint32_t channel;
+            uint32_t sub_channel;
+            if (radio_metadata_get_channel(halEvent->metadata, &channel, &sub_channel) == 0) {
+                Utils::convertMetaDataFromHal(metadata, halEvent->metadata);
+                mCallback->newMetadata(channel, sub_channel, metadata);
+            }
+            } break;
+        case RADIO_EVENT_TA:
+            mCallback->trafficAnnouncement(halEvent->on);
+            break;
+        case RADIO_EVENT_AF_SWITCH:
+            Utils::convertProgramInfoFromHal(&info, &halEvent->info);
+            if (mCallback1_1 != nullptr) {
+                mCallback1_1->afSwitch_1_1(info);
+            }
+            mCallback->afSwitch(info.base);
+            break;
+        case RADIO_EVENT_EA:
+            mCallback->emergencyAnnouncement(halEvent->on);
+            break;
+        case RADIO_EVENT_HW_FAILURE:
+        default:
+            mCallback->hardwareFailure();
+            break;
+        }
+    }
+}
+
+//static
+void Tuner::callback(radio_hal_event_t *halEvent, void *cookie)
+{
+    wp<Tuner> weak(reinterpret_cast<Tuner*>(cookie));
+    sp<Tuner> tuner = weak.promote();
+    if (tuner == 0) return;
+    tuner->onCallback(halEvent);
+}
+
+Tuner::Tuner(const sp<V1_0::ITunerCallback>& callback, const wp<BroadcastRadio>& parentDevice)
+        : mHalTuner(NULL), mCallback(callback), mCallback1_1(ITunerCallback::castFrom(callback)),
+        mParentDevice(parentDevice)
+{
+    ALOGV("%s", __FUNCTION__);
+}
+
+
+Tuner::~Tuner()
+{
+    ALOGV("%s", __FUNCTION__);
+    const sp<BroadcastRadio> parentDevice = mParentDevice.promote();
+    if (parentDevice != 0) {
+        parentDevice->closeHalTuner(mHalTuner);
+    }
+}
+
+// Methods from ::android::hardware::broadcastradio::V1_1::ITuner follow.
+Return<Result> Tuner::setConfiguration(const BandConfig& config)  {
+    ALOGV("%s", __FUNCTION__);
+    if (mHalTuner == NULL) {
+        return Utils::convertHalResult(-ENODEV);
+    }
+    radio_hal_band_config_t halConfig;
+    Utils::convertBandConfigToHal(&halConfig, &config);
+    int rc = mHalTuner->set_configuration(mHalTuner, &halConfig);
+    return Utils::convertHalResult(rc);
+}
+
+Return<void> Tuner::getConfiguration(getConfiguration_cb _hidl_cb)  {
+    int rc;
+    radio_hal_band_config_t halConfig;
+    BandConfig config;
+
+    ALOGV("%s", __FUNCTION__);
+    if (mHalTuner == NULL) {
+        rc = -ENODEV;
+        goto exit;
+    }
+    rc = mHalTuner->get_configuration(mHalTuner, &halConfig);
+    if (rc == 0) {
+        Utils::convertBandConfigFromHal(&config, &halConfig);
+    }
+
+exit:
+    _hidl_cb(Utils::convertHalResult(rc), config);
+    return Void();
+}
+
+Return<Result> Tuner::scan(Direction direction, bool skipSubChannel)  {
+    if (mHalTuner == NULL) {
+        return Utils::convertHalResult(-ENODEV);
+    }
+    int rc = mHalTuner->scan(mHalTuner, static_cast<radio_direction_t>(direction), skipSubChannel);
+    return Utils::convertHalResult(rc);
+}
+
+Return<Result> Tuner::step(Direction direction, bool skipSubChannel)  {
+    if (mHalTuner == NULL) {
+        return Utils::convertHalResult(-ENODEV);
+    }
+    int rc = mHalTuner->step(mHalTuner, static_cast<radio_direction_t>(direction), skipSubChannel);
+    return Utils::convertHalResult(rc);
+}
+
+Return<Result> Tuner::tune(uint32_t channel, uint32_t subChannel)  {
+    if (mHalTuner == NULL) {
+        return Utils::convertHalResult(-ENODEV);
+    }
+    int rc = mHalTuner->tune(mHalTuner, channel, subChannel);
+    return Utils::convertHalResult(rc);
+}
+
+Return<Result> Tuner::cancel()  {
+    if (mHalTuner == NULL) {
+        return Utils::convertHalResult(-ENODEV);
+    }
+    int rc = mHalTuner->cancel(mHalTuner);
+    return Utils::convertHalResult(rc);
+}
+
+Return<void> Tuner::getProgramInformation(getProgramInformation_cb _hidl_cb)  {
+    ALOGV("%s", __FUNCTION__);
+    return getProgramInformation_1_1([&](Result result, const ProgramInfo& info) {
+        _hidl_cb(result, info.base);
+    });
+}
+
+Return<void> Tuner::getProgramInformation_1_1(getProgramInformation_1_1_cb _hidl_cb)  {
+    int rc;
+    radio_program_info_t halInfo;
+    RadioMetadataWrapper metadataWrapper(&halInfo.metadata);
+    ProgramInfo info;
+
+    ALOGV("%s", __FUNCTION__);
+    if (mHalTuner == NULL) {
+        rc = -ENODEV;
+        goto exit;
+    }
+
+    rc = mHalTuner->get_program_information(mHalTuner, &halInfo);
+    if (rc == 0) {
+        Utils::convertProgramInfoFromHal(&info, &halInfo);
+    }
+
+exit:
+    _hidl_cb(Utils::convertHalResult(rc), info);
+    return Void();
+}
+
+} // namespace implementation
+}  // namespace V1_1
+}  // namespace broadcastradio
+}  // namespace hardware
+}  // namespace android
diff --git a/broadcastradio/1.1/default/Tuner.h b/broadcastradio/1.1/default/Tuner.h
new file mode 100644
index 0000000..1f3dc7f
--- /dev/null
+++ b/broadcastradio/1.1/default/Tuner.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 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.
+ */
+#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_TUNER_H
+#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_TUNER_H
+
+#include <android/hardware/broadcastradio/1.1/ITuner.h>
+#include <android/hardware/broadcastradio/1.1/ITunerCallback.h>
+
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_1 {
+namespace implementation {
+
+using V1_0::Direction;
+
+struct BroadcastRadio;
+
+struct Tuner : public ITuner {
+
+    Tuner(const sp<V1_0::ITunerCallback>& callback, const wp<BroadcastRadio>& mParentDevice);
+
+    // Methods from ::android::hardware::broadcastradio::V1_1::ITuner follow.
+    Return<Result> setConfiguration(const BandConfig& config) override;
+    Return<void> getConfiguration(getConfiguration_cb _hidl_cb) override;
+    Return<Result> scan(Direction direction, bool skipSubChannel) override;
+    Return<Result> step(Direction direction, bool skipSubChannel) override;
+    Return<Result> tune(uint32_t channel, uint32_t subChannel) override;
+    Return<Result> cancel() override;
+    Return<void> getProgramInformation(getProgramInformation_cb _hidl_cb) override;
+    Return<void> getProgramInformation_1_1(getProgramInformation_1_1_cb _hidl_cb) override;
+
+    static void callback(radio_hal_event_t *halEvent, void *cookie);
+    void onCallback(radio_hal_event_t *halEvent);
+
+    void setHalTuner(const struct radio_tuner *halTuner) { mHalTuner = halTuner; }
+    const struct radio_tuner *getHalTuner() { return mHalTuner; }
+
+private:
+    ~Tuner();
+
+    const struct radio_tuner *mHalTuner;
+    const sp<V1_0::ITunerCallback> mCallback;
+    const sp<V1_1::ITunerCallback> mCallback1_1;
+    const wp<BroadcastRadio> mParentDevice;
+};
+
+
+}  // namespace implementation
+}  // namespace V1_1
+}  // namespace broadcastradio
+}  // namespace hardware
+}  // namespace android
+
+#endif  // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_TUNER_H
diff --git a/broadcastradio/1.1/default/Utils.cpp b/broadcastradio/1.1/default/Utils.cpp
new file mode 100644
index 0000000..6d4777d
--- /dev/null
+++ b/broadcastradio/1.1/default/Utils.cpp
@@ -0,0 +1,299 @@
+/*
+ * Copyright (C) 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.
+ */
+#define LOG_TAG "BroadcastRadioHalUtils"
+//#define LOG_NDEBUG 0
+
+#include <log/log.h>
+#include <system/radio_metadata.h>
+
+#include "Utils.h"
+
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_1 {
+namespace implementation {
+
+using V1_0::Band;
+using V1_0::Deemphasis;
+using V1_0::Direction;
+using V1_0::MetadataKey;
+using V1_0::MetadataType;
+using V1_0::Rds;
+
+const char *Utils::sClassModuleNames[] = {
+    RADIO_HARDWARE_MODULE_ID_FM, /* corresponds to RADIO_CLASS_AM_FM */
+    RADIO_HARDWARE_MODULE_ID_SAT,  /* corresponds to RADIO_CLASS_SAT */
+    RADIO_HARDWARE_MODULE_ID_DT,   /* corresponds to RADIO_CLASS_DT */
+};
+
+// make sure HIDL enum values are aligned with legacy values
+static_assert(RADIO_CLASS_AM_FM == static_cast<int>(Class::AM_FM),
+        "AM/FM class mismatch with legacy");
+static_assert(RADIO_CLASS_SAT == static_cast<int>(Class::SAT),
+        "SAT class mismatch with legacy");
+static_assert(RADIO_CLASS_DT == static_cast<int>(Class::DT),
+        "DT class mismatch with legacy");
+
+static_assert(RADIO_BAND_AM == static_cast<int>(Band::AM),
+        "AM band mismatch with legacy");
+static_assert(RADIO_BAND_FM == static_cast<int>(Band::FM),
+        "FM band mismatch with legacy");
+static_assert(RADIO_BAND_AM_HD == static_cast<int>(Band::AM_HD),
+        "AM HD band mismatch with legacy");
+static_assert(RADIO_BAND_FM_HD == static_cast<int>(Band::FM_HD),
+        "FM HD band mismatch with legacy");
+
+static_assert(RADIO_RDS_NONE == static_cast<int>(Rds::NONE),
+        "RDS NONE mismatch with legacy");
+static_assert(RADIO_RDS_WORLD == static_cast<int>(Rds::WORLD),
+        "RDS WORLD mismatch with legacy");
+static_assert(RADIO_RDS_US == static_cast<int>(Rds::US),
+        "RDS US mismatch with legacy");
+
+static_assert(RADIO_DEEMPHASIS_50 == static_cast<int>(Deemphasis::D50),
+        "De-emphasis 50 mismatch with legacy");
+static_assert(RADIO_DEEMPHASIS_75 == static_cast<int>(Deemphasis::D75),
+        "De-emphasis 75 mismatch with legacy");
+
+static_assert(RADIO_DIRECTION_UP == static_cast<int>(Direction::UP),
+        "Direction Up mismatch with legacy");
+static_assert(RADIO_DIRECTION_DOWN == static_cast<int>(Direction::DOWN),
+        "Direction Up mismatch with legacy");
+
+static_assert(RADIO_METADATA_TYPE_INVALID == static_cast<int>(MetadataType::INVALID),
+        "Metadata type INVALID mismatch with legacy");
+static_assert(RADIO_METADATA_TYPE_INT == static_cast<int>(MetadataType::INT),
+        "Metadata type INT mismatch with legacy");
+static_assert(RADIO_METADATA_TYPE_TEXT == static_cast<int>(MetadataType::TEXT),
+        "Metadata type TEXT mismatch with legacy");
+static_assert(RADIO_METADATA_TYPE_RAW == static_cast<int>(MetadataType::RAW),
+        "Metadata type RAW mismatch with legacy");
+static_assert(RADIO_METADATA_TYPE_CLOCK == static_cast<int>(MetadataType::CLOCK),
+        "Metadata type CLOCK mismatch with legacy");
+
+static_assert(RADIO_METADATA_KEY_INVALID == static_cast<int>(MetadataKey::INVALID),
+        "Metadata key INVALID mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_RDS_PI == static_cast<int>(MetadataKey::RDS_PI),
+        "Metadata key RDS_PI mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_RDS_PS == static_cast<int>(MetadataKey::RDS_PS),
+        "Metadata key RDS_PS mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_RDS_PTY == static_cast<int>(MetadataKey::RDS_PTY),
+        "Metadata key RDS_PTY mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_RBDS_PTY == static_cast<int>(MetadataKey::RBDS_PTY),
+        "Metadata key RBDS_PTY mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_RDS_RT == static_cast<int>(MetadataKey::RDS_RT),
+        "Metadata key RDS_RT mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_TITLE == static_cast<int>(MetadataKey::TITLE),
+        "Metadata key TITLE mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_ARTIST == static_cast<int>(MetadataKey::ARTIST),
+        "Metadata key ARTIST mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_ALBUM == static_cast<int>(MetadataKey::ALBUM),
+        "Metadata key ALBUM mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_GENRE == static_cast<int>(MetadataKey::GENRE),
+        "Metadata key GENRE mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_ICON == static_cast<int>(MetadataKey::ICON),
+        "Metadata key ICON mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_ART == static_cast<int>(MetadataKey::ART),
+        "Metadata key ART mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_CLOCK == static_cast<int>(MetadataKey::CLOCK),
+        "Metadata key CLOCK mismatch with legacy");
+
+
+//static
+const char * Utils::getClassString(Class ClassId)
+{
+    int id = static_cast<int>(ClassId);
+
+    if ((id < 0) ||
+            (id >= NELEM(sClassModuleNames))) {
+        ALOGE("invalid class ID %d", id);
+        return NULL;
+    }
+    return sClassModuleNames[id];
+}
+
+//static
+Result Utils::convertHalResult(int rc)
+{
+    switch (rc) {
+        case 0:
+            return Result::OK;
+        case -EINVAL:
+            return Result::INVALID_ARGUMENTS;
+        case -ENOSYS:
+            return Result::INVALID_STATE;
+        case -ETIMEDOUT:
+            return Result::TIMEOUT;
+        case -ENODEV:
+        default:
+            return Result::NOT_INITIALIZED;
+    }
+}
+
+//static
+void Utils::convertBandConfigFromHal(
+        BandConfig *config,
+        const radio_hal_band_config_t *halConfig)
+{
+
+    config->type = static_cast<Band>(halConfig->type);
+    config->antennaConnected = halConfig->antenna_connected;
+    config->lowerLimit = halConfig->lower_limit;
+    config->upperLimit = halConfig->upper_limit;
+    config->spacings.setToExternal(const_cast<unsigned int *>(&halConfig->spacings[0]),
+            halConfig->num_spacings * sizeof(uint32_t));
+    // FIXME: transfer buffer ownership. should have a method for that in hidl_vec
+    config->spacings.resize(halConfig->num_spacings);
+
+    if (config->type == Band::FM) {
+        config->ext.fm.deemphasis = static_cast<Deemphasis>(halConfig->fm.deemphasis);
+        config->ext.fm.stereo = halConfig->fm.stereo;
+        config->ext.fm.rds = static_cast<Rds>(halConfig->fm.rds);
+        config->ext.fm.ta = halConfig->fm.ta;
+        config->ext.fm.af = halConfig->fm.af;
+        config->ext.fm.ea = halConfig->fm.ea;
+    } else {
+        config->ext.am.stereo = halConfig->am.stereo;
+    }
+}
+
+//static
+void Utils::convertPropertiesFromHal(Properties *properties,
+        const radio_hal_properties_t *halProperties)
+{
+    properties->classId = static_cast<Class>(halProperties->class_id);
+    properties->implementor.setToExternal(halProperties->implementor, strlen(halProperties->implementor));
+    properties->product.setToExternal(halProperties->product, strlen(halProperties->product));
+    properties->version.setToExternal(halProperties->version, strlen(halProperties->version));
+    properties->serial.setToExternal(halProperties->serial, strlen(halProperties->serial));
+    properties->numTuners = halProperties->num_tuners;
+    properties->numAudioSources = halProperties->num_audio_sources;
+    properties->supportsCapture = halProperties->supports_capture;
+
+    BandConfig *bands =
+            new BandConfig[halProperties->num_bands];
+    for (size_t i = 0; i < halProperties->num_bands; i++) {
+        convertBandConfigFromHal(&bands[i], &halProperties->bands[i]);
+    }
+    properties->bands.setToExternal(bands, halProperties->num_bands);
+    // FIXME: transfer buffer ownership. should have a method for that in hidl_vec
+    properties->bands.resize(halProperties->num_bands);
+    delete[] bands;
+}
+
+//static
+void Utils::convertBandConfigToHal(radio_hal_band_config_t *halConfig, const BandConfig *config)
+{
+    halConfig->type = static_cast<radio_band_t>(config->type);
+    halConfig->antenna_connected = config->antennaConnected;
+    halConfig->lower_limit = config->lowerLimit;
+    halConfig->upper_limit = config->upperLimit;
+    halConfig->num_spacings = config->spacings.size();
+    if (halConfig->num_spacings > RADIO_NUM_SPACINGS_MAX) {
+        halConfig->num_spacings = RADIO_NUM_SPACINGS_MAX;
+    }
+    memcpy(halConfig->spacings, config->spacings.data(),
+           sizeof(uint32_t) * halConfig->num_spacings);
+
+    if (config->type == Band::FM) {
+        halConfig->fm.deemphasis = static_cast<radio_deemphasis_t>(config->ext.fm.deemphasis);
+        halConfig->fm.stereo = config->ext.fm.stereo;
+        halConfig->fm.rds = static_cast<radio_rds_t>(config->ext.fm.rds);
+        halConfig->fm.ta = config->ext.fm.ta;
+        halConfig->fm.af = config->ext.fm.af;
+        halConfig->fm.ea = config->ext.fm.ea;
+    } else {
+        halConfig->am.stereo = config->ext.am.stereo;
+    }
+}
+
+
+//static
+void Utils::convertProgramInfoFromHal(ProgramInfo *info, radio_program_info_t *halInfo)
+{
+    auto &info_1_1 = *info;
+    auto &info_1_0 = info->base;
+
+    info_1_0.channel = halInfo->channel;
+    info_1_0.subChannel = halInfo->sub_channel;
+    info_1_0.tuned = halInfo->tuned;
+    info_1_0.stereo = halInfo->stereo;
+    info_1_0.digital = halInfo->digital;
+    info_1_0.signalStrength = halInfo->signal_strength;
+    convertMetaDataFromHal(info_1_0.metadata, halInfo->metadata);
+    // TODO(b/34348946): add support for HAL 1.1 fields
+    info_1_1.digitalStatus = DigitalStatus::INVALID;
+}
+
+//static
+int Utils::convertMetaDataFromHal(hidl_vec<MetaData>& metadata, radio_metadata_t *halMetadata)
+{
+    if (halMetadata == NULL) {
+        ALOGE("Invalid argument: halMetadata is NULL");
+        return 0;
+    }
+
+    int count = radio_metadata_get_count(halMetadata);
+    if (count <= 0) {
+        return count;
+    }
+    MetaData *newMetadata = new MetaData[count];
+    int outCount = 0;
+    for (int i = 0; i < count; i++) {
+        radio_metadata_key_t key;
+        radio_metadata_type_t type;
+        void *value;
+        size_t size;
+        if (radio_metadata_get_at_index(halMetadata, i , &key, &type, &value, &size) != 0 ||
+                size == 0) {
+            continue;
+        }
+        switch (type) {
+            case RADIO_METADATA_TYPE_INT: {
+                newMetadata[outCount].intValue = *(static_cast<int32_t *>(value));
+            } break;
+            case RADIO_METADATA_TYPE_TEXT: {
+                newMetadata[outCount].stringValue = static_cast<char *>(value);
+            } break;
+            case RADIO_METADATA_TYPE_RAW: {
+                newMetadata[outCount].rawValue.setToExternal(static_cast<uint8_t *>(value), size);
+                // FIXME: transfer buffer ownership. should have a method for that in hidl_vec
+                newMetadata[outCount].rawValue.resize(size);
+            } break;
+            case RADIO_METADATA_TYPE_CLOCK: {
+                radio_metadata_clock_t *clock = static_cast<radio_metadata_clock_t *>(value);
+                newMetadata[outCount].clockValue.utcSecondsSinceEpoch =
+                        clock->utc_seconds_since_epoch;
+                newMetadata[outCount].clockValue.timezoneOffsetInMinutes =
+                        clock->timezone_offset_in_minutes;
+            } break;
+        }
+        newMetadata[outCount].type = static_cast<MetadataType>(type);
+        newMetadata[outCount].key = static_cast<MetadataKey>(key);
+        outCount++;
+    }
+    metadata.setToExternal(newMetadata, outCount);
+    // FIXME: transfer buffer ownership. should have a method for that in hidl_vec
+    metadata.resize(outCount);
+    return outCount;
+}
+
+}  // namespace implementation
+}  // namespace V1_1
+}  // namespace broadcastradio
+}  // namespace hardware
+}  // namespace android
diff --git a/broadcastradio/1.1/default/Utils.h b/broadcastradio/1.1/default/Utils.h
new file mode 100644
index 0000000..22902ba
--- /dev/null
+++ b/broadcastradio/1.1/default/Utils.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 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.
+ */
+#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_UTILS_H
+#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_UTILS_H
+
+#include <android/hardware/broadcastradio/1.1/types.h>
+#include <hardware/radio.h>
+
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_1 {
+namespace implementation {
+
+using V1_0::Class;
+using V1_0::BandConfig;
+using V1_0::MetaData;
+using V1_0::Properties;
+
+class Utils {
+public:
+    static const char * getClassString(Class ClassId);
+    static Result convertHalResult(int rc);
+    static void convertBandConfigFromHal(BandConfig *config,
+            const radio_hal_band_config_t *halConfig);
+    static void convertPropertiesFromHal(Properties *properties,
+            const radio_hal_properties_t *halProperties);
+    static void convertBandConfigToHal(radio_hal_band_config_t *halConfig,
+            const BandConfig *config);
+    static void convertProgramInfoFromHal(ProgramInfo *info,
+                                          radio_program_info_t *halInfo);
+    static int convertMetaDataFromHal(hidl_vec<MetaData>& metadata,
+                                       radio_metadata_t *halMetadata);
+private:
+    static const char * sClassModuleNames[];
+
+};
+
+}  // namespace implementation
+}  // namespace V1_1
+}  // namespace broadcastradio
+}  // namespace hardware
+}  // namespace android
+
+#endif  // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_UTILS_H
diff --git a/broadcastradio/1.1/types.hal b/broadcastradio/1.1/types.hal
new file mode 100644
index 0000000..38f4b39
--- /dev/null
+++ b/broadcastradio/1.1/types.hal
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+package android.hardware.broadcastradio@1.1;
+
+import @1.0::types;
+
+typedef @1.0::Result Result;
+
+enum DigitalStatus : int32_t {
+    INVALID     = -1,
+    UNAVAILABLE = 1,  // current program is analog-only
+    AVAILABLE   = 2,  // digital mode is available, but disabled
+    BUFFERING   = 3,  // digital mode is available and buffering has started
+    ACTIVE      = 4,  // digital mode is currently playing
+};
+
+/* Radio program information. Returned by the HAL with event RADIO_EVENT_TUNED.
+ * Contains information on currently tuned channel.
+ */
+struct ProgramInfo {
+    @1.0::ProgramInfo base;
+    DigitalStatus digitalStatus;
+};
diff --git a/broadcastradio/1.1/vts/Android.mk b/broadcastradio/1.1/vts/Android.mk
new file mode 100644
index 0000000..0c4c55d
--- /dev/null
+++ b/broadcastradio/1.1/vts/Android.mk
@@ -0,0 +1,19 @@
+#
+# Copyright (C) 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(call all-subdir-makefiles)
diff --git a/broadcastradio/1.1/vts/functional/Android.bp b/broadcastradio/1.1/vts/functional/Android.bp
new file mode 100644
index 0000000..e10ddab
--- /dev/null
+++ b/broadcastradio/1.1/vts/functional/Android.bp
@@ -0,0 +1,37 @@
+//
+// Copyright (C) 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.
+//
+
+cc_test {
+    name: "VtsHalBroadcastradioV1_1TargetTest",
+    gtest: true,
+    srcs: ["VtsHalBroadcastradioV1_1TargetTest.cpp"],
+    shared_libs: [
+        "libbase",
+        "liblog",
+        "libcutils",
+        "libhidlbase",
+        "libhidltransport",
+        "libnativehelper",
+        "libutils",
+        "android.hardware.broadcastradio@1.0",
+        "android.hardware.broadcastradio@1.1",
+    ],
+    static_libs: ["libgtest"],
+    cflags: [
+        "-O0",
+        "-g",
+    ],
+}
diff --git a/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp b/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp
new file mode 100644
index 0000000..873a10b
--- /dev/null
+++ b/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp
@@ -0,0 +1,476 @@
+/*
+ * Copyright (C) 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.
+ */
+
+#define LOG_TAG "BroadcastRadioHidlHalTest"
+#include <gtest/gtest.h>
+#include <android-base/logging.h>
+#include <cutils/native_handle.h>
+#include <cutils/properties.h>
+#include <hidl/HidlTransportSupport.h>
+#include <utils/threads.h>
+
+#include <android/hardware/broadcastradio/1.1/IBroadcastRadioFactory.h>
+#include <android/hardware/broadcastradio/1.0/IBroadcastRadio.h>
+#include <android/hardware/broadcastradio/1.1/ITuner.h>
+#include <android/hardware/broadcastradio/1.1/ITunerCallback.h>
+#include <android/hardware/broadcastradio/1.1/types.h>
+
+
+namespace V1_0 = ::android::hardware::broadcastradio::V1_0;
+
+using ::android::sp;
+using ::android::Mutex;
+using ::android::Condition;
+using ::android::hardware::Return;
+using ::android::hardware::Status;
+using ::android::hardware::Void;
+using ::android::hardware::broadcastradio::V1_0::BandConfig;
+using ::android::hardware::broadcastradio::V1_0::Class;
+using ::android::hardware::broadcastradio::V1_0::Direction;
+using ::android::hardware::broadcastradio::V1_0::IBroadcastRadio;
+using ::android::hardware::broadcastradio::V1_0::MetaData;
+using ::android::hardware::broadcastradio::V1_0::Properties;
+using ::android::hardware::broadcastradio::V1_1::IBroadcastRadioFactory;
+using ::android::hardware::broadcastradio::V1_1::ITuner;
+using ::android::hardware::broadcastradio::V1_1::ITunerCallback;
+using ::android::hardware::broadcastradio::V1_1::ProgramInfo;
+using ::android::hardware::broadcastradio::V1_1::Result;
+
+
+// The main test class for Broadcast Radio HIDL HAL.
+
+class BroadcastRadioHidlTest : public ::testing::Test {
+ protected:
+    virtual void SetUp() override {
+        bool getStub = false;
+        char getsubProperty[PROPERTY_VALUE_MAX];
+        if (property_get("vts.hidl.get_stub", getsubProperty, "") > 0) {
+            if (!strcmp(getsubProperty, "true") ||
+                    !strcmp(getsubProperty, "True") ||
+                    !strcmp(getsubProperty, "1")) {
+                getStub = true;
+            }
+        }
+        auto factory = IBroadcastRadioFactory::getService(getStub);
+        if (factory != 0) {
+            factory->connectModule(Class::AM_FM,
+                             [&](Result retval, const ::android::sp<IBroadcastRadio>& result) {
+                if (retval == Result::OK) {
+                  mRadio = IBroadcastRadio::castFrom(result);
+                }
+            });
+        }
+        mTunerCallback = new MyCallback(this);
+        ASSERT_NE(nullptr, mRadio.get());
+        ASSERT_EQ(!getStub, mRadio->isRemote());
+        ASSERT_NE(nullptr, mTunerCallback.get());
+    }
+
+    virtual void TearDown() override {
+        mTuner.clear();
+        mRadio.clear();
+    }
+
+    class MyCallback : public ITunerCallback {
+     public:
+
+        // ITunerCallback methods (see doc in ITunerCallback.hal)
+        virtual Return<void> hardwareFailure() {
+            ALOGI("%s", __FUNCTION__);
+            mParentTest->onHwFailureCallback();
+            return Void();
+        }
+
+        virtual Return<void> configChange(Result result, const BandConfig& config __unused) {
+            ALOGI("%s result %d", __FUNCTION__, result);
+            mParentTest->onResultCallback(result);
+            return Void();
+        }
+
+        virtual Return<void> tuneComplete(Result result __unused, const V1_0::ProgramInfo& info __unused) {
+            return Void();
+        }
+
+        virtual Return<void> tuneComplete_1_1(Result result, const ProgramInfo& info __unused) {
+            ALOGI("%s result %d", __FUNCTION__, result);
+            mParentTest->onResultCallback(result);
+            return Void();
+        }
+
+        virtual Return<void> afSwitch(const V1_0::ProgramInfo& info __unused) {
+            return Void();
+        }
+
+        virtual Return<void> afSwitch_1_1(const ProgramInfo& info __unused) {
+            return Void();
+        }
+
+        virtual Return<void> antennaStateChange(bool connected) {
+            ALOGI("%s connected %d", __FUNCTION__, connected);
+            return Void();
+        }
+
+        virtual Return<void> trafficAnnouncement(bool active) {
+            ALOGI("%s active %d", __FUNCTION__, active);
+            return Void();
+        }
+
+        virtual Return<void> emergencyAnnouncement(bool active) {
+            ALOGI("%s active %d", __FUNCTION__, active);
+            return Void();
+        }
+
+        virtual Return<void> newMetadata(uint32_t channel __unused, uint32_t subChannel __unused,
+                           const ::android::hardware::hidl_vec<MetaData>& metadata __unused) {
+            ALOGI("%s", __FUNCTION__);
+            return Void();
+        }
+
+                MyCallback(BroadcastRadioHidlTest *parentTest) : mParentTest(parentTest) {}
+
+     private:
+        // BroadcastRadioHidlTest instance to which callbacks will be notified.
+        BroadcastRadioHidlTest *mParentTest;
+    };
+
+
+    /**
+     * Method called by MyCallback when a callback with no status or boolean value is received
+     */
+    void onCallback() {
+        Mutex::Autolock _l(mLock);
+        onCallback_l();
+    }
+
+    /**
+     * Method called by MyCallback when hardwareFailure() callback is received
+     */
+    void onHwFailureCallback() {
+        Mutex::Autolock _l(mLock);
+        mHwFailure = true;
+        onCallback_l();
+    }
+
+    /**
+     * Method called by MyCallback when a callback with status is received
+     */
+    void onResultCallback(Result result) {
+        Mutex::Autolock _l(mLock);
+        mResultCallbackData = result;
+        onCallback_l();
+    }
+
+    /**
+     * Method called by MyCallback when a boolean indication is received
+     */
+    void onBoolCallback(bool result) {
+        Mutex::Autolock _l(mLock);
+        mBoolCallbackData = result;
+        onCallback_l();
+    }
+
+
+        BroadcastRadioHidlTest() :
+            mCallbackCalled(false), mBoolCallbackData(false),
+            mResultCallbackData(Result::OK), mHwFailure(false) {}
+
+    void onCallback_l() {
+        if (!mCallbackCalled) {
+            mCallbackCalled = true;
+            mCallbackCond.broadcast();
+        }
+    }
+
+
+    bool waitForCallback(nsecs_t reltime = 0) {
+        Mutex::Autolock _l(mLock);
+        nsecs_t endTime = systemTime() + reltime;
+        while (!mCallbackCalled) {
+            if (reltime == 0) {
+                mCallbackCond.wait(mLock);
+            } else {
+                nsecs_t now = systemTime();
+                if (now > endTime) {
+                    return false;
+                }
+                mCallbackCond.waitRelative(mLock, endTime - now);
+            }
+        }
+        return true;
+    }
+
+    bool getProperties();
+    bool openTuner();
+    bool checkAntenna();
+
+    static const nsecs_t kConfigCallbacktimeoutNs = seconds_to_nanoseconds(10);
+    static const nsecs_t kTuneCallbacktimeoutNs = seconds_to_nanoseconds(30);
+
+    sp<IBroadcastRadio> mRadio;
+    Properties mHalProperties;
+    sp<ITuner> mTuner;
+    sp<MyCallback> mTunerCallback;
+    Mutex mLock;
+    Condition mCallbackCond;
+    bool mCallbackCalled;
+    bool mBoolCallbackData;
+    Result mResultCallbackData;
+    bool mHwFailure;
+};
+
+// A class for test environment setup (kept since this file is a template).
+class BroadcastRadioHidlEnvironment : public ::testing::Environment {
+ public:
+    virtual void SetUp() {}
+    virtual void TearDown() {}
+};
+
+bool BroadcastRadioHidlTest::getProperties()
+{
+    if (mHalProperties.bands.size() == 0) {
+        Result halResult = Result::NOT_INITIALIZED;
+        Return<void> hidlReturn =
+                mRadio->getProperties([&](Result result, const Properties& properties) {
+                        halResult = result;
+                        if (result == Result::OK) {
+                            mHalProperties = properties;
+                        }
+                    });
+
+        EXPECT_TRUE(hidlReturn.isOk());
+        EXPECT_EQ(Result::OK, halResult);
+        EXPECT_EQ(Class::AM_FM, mHalProperties.classId);
+        EXPECT_GT(mHalProperties.numTuners, 0u);
+        EXPECT_GT(mHalProperties.bands.size(), 0u);
+    }
+    return mHalProperties.bands.size() > 0;
+}
+
+bool BroadcastRadioHidlTest::openTuner()
+{
+    if (!getProperties()) {
+        return false;
+    }
+    if (mTuner.get() == nullptr) {
+        Result halResult = Result::NOT_INITIALIZED;
+        auto hidlReturn = mRadio->openTuner(mHalProperties.bands[0], true, mTunerCallback,
+                [&](Result result, const sp<V1_0::ITuner>& tuner) {
+                    halResult = result;
+                    if (result == Result::OK) {
+                        mTuner = ITuner::castFrom(tuner);
+                    }
+                });
+        EXPECT_TRUE(hidlReturn.isOk());
+        EXPECT_EQ(Result::OK, halResult);
+        EXPECT_TRUE(waitForCallback(kConfigCallbacktimeoutNs));
+    }
+    EXPECT_NE(nullptr, mTuner.get());
+    return nullptr != mTuner.get();
+}
+
+bool BroadcastRadioHidlTest::checkAntenna()
+{
+    BandConfig halConfig;
+    Result halResult = Result::NOT_INITIALIZED;
+    Return<void> hidlReturn =
+            mTuner->getConfiguration([&](Result result, const BandConfig& config) {
+                halResult = result;
+                if (result == Result::OK) {
+                    halConfig = config;
+                }
+            });
+
+    return ((halResult == Result::OK) && (halConfig.antennaConnected == true));
+}
+
+
+/**
+ * Test IBroadcastRadio::getProperties() method
+ *
+ * Verifies that:
+ *  - the HAL implements the method
+ *  - the method returns 0 (no error)
+ *  - the implementation class is AM_FM
+ *  - the implementation supports at least one tuner
+ *  - the implementation supports at one band
+ */
+TEST_F(BroadcastRadioHidlTest, GetProperties) {
+    EXPECT_TRUE(getProperties());
+}
+
+/**
+ * Test IBroadcastRadio::openTuner() method
+ *
+ * Verifies that:
+ *  - the HAL implements the method
+ *  - the method returns 0 (no error) and a valid ITuner interface
+ */
+TEST_F(BroadcastRadioHidlTest, OpenTuner) {
+    EXPECT_TRUE(openTuner());
+}
+
+/**
+ * Test ITuner::setConfiguration() and getConfiguration methods
+ *
+ * Verifies that:
+ *  - the HAL implements both methods
+ *  - the methods return 0 (no error)
+ *  - the configuration callback is received within kConfigCallbacktimeoutNs ns
+ *  - the configuration read back from HAl has the same class Id
+ */
+TEST_F(BroadcastRadioHidlTest, SetAndGetConfiguration) {
+    ASSERT_TRUE(openTuner());
+    // test setConfiguration
+    mCallbackCalled = false;
+    Return<Result> hidlResult = mTuner->setConfiguration(mHalProperties.bands[0]);
+    EXPECT_TRUE(hidlResult.isOk());
+    EXPECT_EQ(Result::OK, hidlResult);
+    EXPECT_TRUE(waitForCallback(kConfigCallbacktimeoutNs));
+    EXPECT_EQ(Result::OK, mResultCallbackData);
+
+    // test getConfiguration
+    BandConfig halConfig;
+    Result halResult;
+    Return<void> hidlReturn =
+            mTuner->getConfiguration([&](Result result, const BandConfig& config) {
+                halResult = result;
+                if (result == Result::OK) {
+                    halConfig = config;
+                }
+            });
+    EXPECT_TRUE(hidlReturn.isOk());
+    EXPECT_EQ(Result::OK, halResult);
+    EXPECT_EQ(mHalProperties.bands[0].type, halConfig.type);
+}
+
+/**
+ * Test ITuner::scan
+ *
+ * Verifies that:
+ *  - the HAL implements the method
+ *  - the method returns 0 (no error)
+ *  - the tuned callback is received within kTuneCallbacktimeoutNs ns
+ */
+TEST_F(BroadcastRadioHidlTest, Scan) {
+    ASSERT_TRUE(openTuner());
+    ASSERT_TRUE(checkAntenna());
+    // test scan UP
+    mCallbackCalled = false;
+    Return<Result> hidlResult = mTuner->scan(Direction::UP, true);
+    EXPECT_TRUE(hidlResult.isOk());
+    EXPECT_EQ(Result::OK, hidlResult);
+    EXPECT_TRUE(waitForCallback(kTuneCallbacktimeoutNs));
+
+    // test scan DOWN
+    mCallbackCalled = false;
+    hidlResult = mTuner->scan(Direction::DOWN, true);
+    EXPECT_TRUE(hidlResult.isOk());
+    EXPECT_EQ(Result::OK, hidlResult);
+    EXPECT_TRUE(waitForCallback(kTuneCallbacktimeoutNs));
+}
+
+/**
+ * Test ITuner::step
+ *
+ * Verifies that:
+ *  - the HAL implements the method
+ *  - the method returns 0 (no error)
+ *  - the tuned callback is received within kTuneCallbacktimeoutNs ns
+ */
+TEST_F(BroadcastRadioHidlTest, Step) {
+    ASSERT_TRUE(openTuner());
+    ASSERT_TRUE(checkAntenna());
+    // test step UP
+    mCallbackCalled = false;
+    Return<Result> hidlResult = mTuner->step(Direction::UP, true);
+    EXPECT_TRUE(hidlResult.isOk());
+    EXPECT_EQ(Result::OK, hidlResult);
+    EXPECT_TRUE(waitForCallback(kTuneCallbacktimeoutNs));
+
+    // test step DOWN
+    mCallbackCalled = false;
+    hidlResult = mTuner->step(Direction::DOWN, true);
+    EXPECT_TRUE(hidlResult.isOk());
+    EXPECT_EQ(Result::OK, hidlResult);
+    EXPECT_TRUE(waitForCallback(kTuneCallbacktimeoutNs));
+}
+
+/**
+ * Test ITuner::tune,  getProgramInformation and cancel methods
+ *
+ * Verifies that:
+ *  - the HAL implements the methods
+ *  - the methods return 0 (no error)
+ *  - the tuned callback is received within kTuneCallbacktimeoutNs ns after tune()
+ */
+TEST_F(BroadcastRadioHidlTest, TuneAndGetProgramInformationAndCancel) {
+    ASSERT_TRUE(openTuner());
+    ASSERT_TRUE(checkAntenna());
+
+    // test tune
+    ASSERT_GT(mHalProperties.bands[0].spacings.size(), 0u);
+    ASSERT_GT(mHalProperties.bands[0].upperLimit, mHalProperties.bands[0].lowerLimit);
+
+    // test scan UP
+    uint32_t lowerLimit = mHalProperties.bands[0].lowerLimit;
+    uint32_t upperLimit = mHalProperties.bands[0].upperLimit;
+    uint32_t spacing = mHalProperties.bands[0].spacings[0];
+
+    uint32_t channel =
+            lowerLimit + (((upperLimit - lowerLimit) / 2 + spacing - 1) / spacing) * spacing;
+    mCallbackCalled = false;
+    mResultCallbackData = Result::NOT_INITIALIZED;
+    Return<Result> hidlResult = mTuner->tune(channel, 0);
+    EXPECT_TRUE(hidlResult.isOk());
+    EXPECT_EQ(Result::OK, hidlResult);
+    EXPECT_TRUE(waitForCallback(kTuneCallbacktimeoutNs));
+
+    // test getProgramInformation
+    ProgramInfo halInfo;
+    Result halResult = Result::NOT_INITIALIZED;
+    Return<void> hidlReturn = mTuner->getProgramInformation_1_1(
+        [&](Result result, const ProgramInfo& info) {
+            halResult = result;
+            if (result == Result::OK) {
+                halInfo = info;
+            }
+        });
+    EXPECT_TRUE(hidlReturn.isOk());
+    EXPECT_EQ(Result::OK, halResult);
+    auto &halInfo_1_1 = halInfo.base;
+    if (mResultCallbackData == Result::OK) {
+        EXPECT_TRUE(halInfo_1_1.tuned);
+        EXPECT_LE(halInfo_1_1.channel, upperLimit);
+        EXPECT_GE(halInfo_1_1.channel, lowerLimit);
+    } else {
+        EXPECT_EQ(false, halInfo_1_1.tuned);
+    }
+
+    // test cancel
+    mTuner->tune(lowerLimit, 0);
+    hidlResult = mTuner->cancel();
+    EXPECT_TRUE(hidlResult.isOk());
+    EXPECT_EQ(Result::OK, hidlResult);
+}
+
+
+int main(int argc, char** argv) {
+  ::testing::AddGlobalTestEnvironment(new BroadcastRadioHidlEnvironment);
+  ::testing::InitGoogleTest(&argc, argv);
+  int status = RUN_ALL_TESTS();
+  ALOGI("Test result = %d", status);
+  return status;
+}
diff --git a/broadcastradio/Android.bp b/broadcastradio/Android.bp
index 33f70eb..5cacbf3 100644
--- a/broadcastradio/Android.bp
+++ b/broadcastradio/Android.bp
@@ -2,4 +2,6 @@
 subdirs = [
     "1.0",
     "1.0/vts/functional",
+    "1.1",
+    "1.1/vts/functional",
 ]
diff --git a/configstore/utils/Android.bp b/configstore/utils/Android.bp
index 32053a7..09ab5b2 100644
--- a/configstore/utils/Android.bp
+++ b/configstore/utils/Android.bp
@@ -14,15 +14,13 @@
 // limitations under the License.
 //
 
-cc_library_static {
+cc_library_headers {
     name: "android.hardware.configstore-utils",
     export_include_dirs: ["include"],
-    srcs: [],
     shared_libs: [
-        "android.hardware.configstore@1.0",
+        "libhidlbase"
     ],
     export_shared_lib_headers: [
-        "android.hardware.configstore@1.0",
+        "libhidlbase"
     ],
 }
-
diff --git a/drm/1.0/default/DrmPlugin.cpp b/drm/1.0/default/DrmPlugin.cpp
index 1b2f90e..6f51e0e 100644
--- a/drm/1.0/default/DrmPlugin.cpp
+++ b/drm/1.0/default/DrmPlugin.cpp
@@ -321,6 +321,7 @@
 
     Return<void> DrmPlugin::setListener(const sp<IDrmPluginListener>& listener) {
         mListener = listener;
+        mLegacyPlugin->setListener(listener == NULL ? NULL : this);
         return Void();
     }
 
@@ -372,8 +373,10 @@
             break;
         }
         if (sendEvent) {
-            mListener->sendEvent(eventType, toHidlVec(*sessionId),
-                    toHidlVec(*data));
+            Vector<uint8_t> emptyVector;
+            mListener->sendEvent(eventType,
+                    toHidlVec(sessionId == NULL ? emptyVector: *sessionId),
+                    toHidlVec(data == NULL ? emptyVector: *data));
         }
     }
 
diff --git a/ir/1.0/vts/functional/Android.bp b/ir/1.0/vts/functional/Android.bp
index ac29996..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",
@@ -27,7 +26,7 @@
         "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/vts/functional/Android.bp b/nfc/1.0/vts/functional/Android.bp
index 23d83e5..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",
@@ -28,7 +27,7 @@
         "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/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp b/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp
index 6783961..7a34f00 100644
--- a/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp
+++ b/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp
@@ -19,6 +19,7 @@
 
 #include <cutils/properties.h>
 
+#include <android-base/unique_fd.h>
 #include <android/hardware/power/1.0/IPower.h>
 
 #include <gtest/gtest.h>
@@ -33,6 +34,7 @@
 using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::sp;
+using ::android::base::unique_fd;
 
 using std::vector;
 
@@ -69,23 +71,24 @@
 TEST_F(PowerHidlTest, TryDifferentGovernors) {
   Return<void> ret;
 
-  int fd1 = open(CPU_GOVERNOR_PATH, O_RDWR);
-  int fd2 = open(AVAILABLE_GOVERNORS_PATH, O_RDONLY);
+  unique_fd fd1(open(CPU_GOVERNOR_PATH, O_RDWR));
+  unique_fd fd2(open(AVAILABLE_GOVERNORS_PATH, O_RDONLY));
   if (fd1 < 0 || fd2 < 0) {
-      // Files don't exist, so skip the rest of the test case
-      SUCCEED();
+    // Files don't exist, so skip the rest of the test case
+    SUCCEED();
   }
 
   char old_governor[80];
   ASSERT_LE(0, read(fd1, old_governor, 80));
 
   char governors[1024];
-  ASSERT_LE(0, read(fd2, governors, 1024));
-  close(fd2);
+  unsigned len = read(fd2, governors, 1024);
+  ASSERT_LE(0, len);
+  governors[len] = '\0';
 
   char *saveptr;
-  char *name = strtok_r(governors, " ", &saveptr);
-  while (name && strlen(name) > 1) {
+  char *name = strtok_r(governors, " \n", &saveptr);
+  while (name) {
     ASSERT_LE(0, write(fd1, name, strlen(name)));
     ret = power->setInteractive(true);
     ASSERT_TRUE(ret.isOk());
@@ -99,11 +102,10 @@
     power->powerHint(PowerHint::LAUNCH, 1);
     power->powerHint(PowerHint::LAUNCH, 0);
 
-    name = strtok_r(NULL, " ", &saveptr);
+    name = strtok_r(NULL, " \n", &saveptr);
   }
 
   ASSERT_LE(0, write(fd1, old_governor, strlen(old_governor)));
-  close(fd1);
 }
 
 // Sanity check Power::powerHint on good and bad inputs.
diff --git a/radio/1.0/vts/functional/Android.bp b/radio/1.0/vts/functional/Android.bp
index 03434f4..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",
@@ -31,7 +30,7 @@
         "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/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/vr/1.0/default/Vr.cpp b/vr/1.0/default/Vr.cpp
index a0de998..345db99 100644
--- a/vr/1.0/default/Vr.cpp
+++ b/vr/1.0/default/Vr.cpp
@@ -42,16 +42,16 @@
     return Void();
 }
 
-IVr* HIDL_FETCH_IVr(const char *name) {
+IVr* HIDL_FETCH_IVr(const char * /*name*/) {
     vr_module_t *vr_module;
     const hw_module_t *hw_module = NULL;
 
-    int ret = hw_get_module(name, &hw_module);
+    int ret = hw_get_module(VR_HARDWARE_MODULE_ID, &hw_module);
     if (ret == 0) {
         return new Vr(reinterpret_cast<vr_module_t*>(
                 const_cast<hw_module_t*>(hw_module)));
     } else {
-        ALOGE("hw_get_module %s failed: %d", name, ret);
+        ALOGE("hw_get_module %s failed: %d", VR_HARDWARE_MODULE_ID, ret);
         return nullptr;
     }
 }
diff --git a/vr/1.0/default/service.cpp b/vr/1.0/default/service.cpp
index c27ceaf..22fb7d1 100644
--- a/vr/1.0/default/service.cpp
+++ b/vr/1.0/default/service.cpp
@@ -23,5 +23,5 @@
 using android::hardware::defaultPassthroughServiceImplementation;
 
 int main() {
-    return defaultPassthroughServiceImplementation<IVr>("vr");
+    return defaultPassthroughServiceImplementation<IVr>();
 }
diff --git a/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp b/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp
index 29888fd..c7ec076 100644
--- a/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp
+++ b/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp
@@ -26,13 +26,11 @@
 using ::android::hardware::Void;
 using ::android::sp;
 
-#define VR_SERVICE_NAME "vr"
-
 // The main test class for VR HIDL HAL.
 class VrHidlTest : public ::testing::Test {
  public:
   void SetUp() override {
-    vr = IVr::getService(VR_SERVICE_NAME);
+    vr = IVr::getService();
     ASSERT_NE(vr, nullptr);
   }
 
diff --git a/wifi/1.0/default/hidl_struct_util.cpp b/wifi/1.0/default/hidl_struct_util.cpp
index c7b8c41..c498206 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";
@@ -1041,7 +1041,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 +1230,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 +1268,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 +1338,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/types.hal b/wifi/1.0/types.hal
index a843ce8..5ffb55c 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
    */
@@ -1199,11 +1202,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 +1248,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 +1381,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 dc36139..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",
@@ -38,7 +37,7 @@
         "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 5d7c763..93e5250 100644
--- a/wifi/supplicant/1.0/vts/functional/Android.mk
+++ b/wifi/supplicant/1.0/vts/functional/Android.mk
@@ -37,6 +37,6 @@
     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"