Merge "Add VR 1.0 hal."
diff --git a/Android.bp b/Android.bp
index 9631063..a12524e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,12 +1,15 @@
 // This is an autogenerated file, do not edit.
 subdirs = [
     "audio/2.0",
+    "audio/2.0/default",
     "audio/common/2.0",
     "audio/effect/2.0",
     "benchmarks/msgq/1.0",
     "biometrics/fingerprint/2.1",
-    "gnss/1.0",
     "bluetooth/1.0",
+    "boot/1.0",
+    "example/extension/light/2.0",
+    "gnss/1.0",
     "graphics/allocator/2.0",
     "graphics/allocator/2.0/default",
     "graphics/composer/2.1",
@@ -30,10 +33,12 @@
     "tests/expression/1.0",
     "tests/foo/1.0",
     "tests/foo/1.0/default",
+    "tests/foo/1.0/default/lib",
     "tests/libhwbinder/1.0",
     "tests/msgq/1.0",
     "tests/pointer/1.0",
     "tests/pointer/1.0/default",
+    "tests/pointer/1.0/default/lib",
     "thermal/1.0",
     "thermal/1.0/default",
     "vehicle/2.0",
diff --git a/audio/2.0/default/Android.mk b/audio/2.0/default/Android.mk
new file mode 100644
index 0000000..a987b41
--- /dev/null
+++ b/audio/2.0/default/Android.mk
@@ -0,0 +1,41 @@
+#
+# Copyright (C) 2016 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.audio@2.0-service
+LOCAL_INIT_RC := android.hardware.audio@2.0-service.rc
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_SRC_FILES := \
+  service.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+  libhidl \
+  liblog \
+  libhwbinder \
+  libutils \
+  libhardware \
+  android.hardware.soundtrigger@2.0 \
+  android.hardware.audio.common@2.0
+
+ifeq ($(strip $(AUDIOSERVER_MULTILIB)),)
+LOCAL_MULTILIB := 32
+else
+LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
+endif
+
+include $(BUILD_EXECUTABLE)
diff --git a/audio/2.0/default/android.hardware.audio@2.0-service.rc b/audio/2.0/default/android.hardware.audio@2.0-service.rc
new file mode 100644
index 0000000..f9fecdb
--- /dev/null
+++ b/audio/2.0/default/android.hardware.audio@2.0-service.rc
@@ -0,0 +1,7 @@
+service audio-hal-2-0 /system/bin/hw/android.hardware.audio@2.0-service
+    class hal
+    user audioserver
+    # media gid needed for /dev/fm (radio) and for /data/misc/media (tee)
+    group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct
+    ioprio rt 4
+    writepid /dev/cpuset/foreground/tasks /dev/stune/foreground/tasks
diff --git a/audio/2.0/default/service.cpp b/audio/2.0/default/service.cpp
new file mode 100644
index 0000000..f254512
--- /dev/null
+++ b/audio/2.0/default/service.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2016 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 "soundtriggerhal"
+
+#include <hwbinder/IInterface.h>
+#include <hwbinder/IPCThreadState.h>
+#include <hwbinder/ProcessState.h>
+#include <hidl/IServiceManager.h>
+#include <utils/Errors.h>
+#include <utils/Log.h>
+#include <utils/Looper.h>
+#include <utils/StrongPointer.h>
+#include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
+
+using android::hardware::IPCThreadState;
+using android::hardware::ProcessState;
+using android::hardware::soundtrigger::V2_0::ISoundTriggerHw;
+
+int main(int /* argc */, char* /* argv */ []) {
+    android::sp<ISoundTriggerHw> service =
+            ISoundTriggerHw::getService("sound_trigger.primary", true /* getStub */);
+
+    service->registerAsService("sound_trigger.primary");
+
+    ProcessState::self()->setThreadPoolMaxThreadCount(0);
+    ProcessState::self()->startThreadPool();
+    IPCThreadState::self()->joinThreadPool();
+}
diff --git a/biometrics/fingerprint/2.1/IBiometricsFingerprint.hal b/biometrics/fingerprint/2.1/IBiometricsFingerprint.hal
index a9c3190..7494c58 100644
--- a/biometrics/fingerprint/2.1/IBiometricsFingerprint.hal
+++ b/biometrics/fingerprint/2.1/IBiometricsFingerprint.hal
@@ -143,7 +143,7 @@
       generates (bool isOk, int32_t debugErrno);
 
   /*
-   * Authenticates an operation identifed by operationId
+   * Authenticates an operation identified by operationId
    *
    * @param operationId operation id.
    * @param gid fingerprint group id.
diff --git a/biometrics/fingerprint/2.1/IBiometricsFingerprintClientCallback.hal b/biometrics/fingerprint/2.1/IBiometricsFingerprintClientCallback.hal
index 365e905..839bcd6 100644
--- a/biometrics/fingerprint/2.1/IBiometricsFingerprintClientCallback.hal
+++ b/biometrics/fingerprint/2.1/IBiometricsFingerprintClientCallback.hal
@@ -17,7 +17,7 @@
 package android.hardware.biometrics.fingerprint@2.1;
 
 interface IBiometricsFingerprintClientCallback {
-    /* This function is the response chanel for all messages
+    /* This function is the response channel for all messages
      * coming from the fingerprint HAL to the framework
      *
      * @param msg a union of message structures identified by
diff --git a/boot/1.0/Android.bp b/boot/1.0/Android.bp
new file mode 100644
index 0000000..98341ef
--- /dev/null
+++ b/boot/1.0/Android.bp
@@ -0,0 +1,46 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+    name: "android.hardware.boot@1.0_genc++",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.boot@1.0",
+    srcs: [
+        "types.hal",
+        "IBootControl.hal",
+    ],
+    out: [
+        "android/hardware/boot/1.0/types.cpp",
+        "android/hardware/boot/1.0/BootControlAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.boot@1.0_genc++_headers",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.boot@1.0",
+    srcs: [
+        "types.hal",
+        "IBootControl.hal",
+    ],
+    out: [
+        "android/hardware/boot/1.0/types.h",
+        "android/hardware/boot/1.0/IBootControl.h",
+        "android/hardware/boot/1.0/IHwBootControl.h",
+        "android/hardware/boot/1.0/BnBootControl.h",
+        "android/hardware/boot/1.0/BpBootControl.h",
+        "android/hardware/boot/1.0/BsBootControl.h",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.boot@1.0",
+    generated_sources: ["android.hardware.boot@1.0_genc++"],
+    generated_headers: ["android.hardware.boot@1.0_genc++_headers"],
+    export_generated_headers: ["android.hardware.boot@1.0_genc++_headers"],
+    shared_libs: [
+        "libhidl",
+        "libhwbinder",
+        "libutils",
+        "libcutils",
+    ],
+}
diff --git a/boot/1.0/Android.mk b/boot/1.0/Android.mk
new file mode 100644
index 0000000..bb19a79
--- /dev/null
+++ b/boot/1.0/Android.mk
@@ -0,0 +1,136 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.boot@1.0-java
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(local-generated-sources-dir)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+#
+# Build types.hal (BoolResult)
+#
+GEN := $(intermediates)/android/hardware/boot/1.0/BoolResult.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.boot@1.0::types.BoolResult
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (CommandResult)
+#
+GEN := $(intermediates)/android/hardware/boot/1.0/CommandResult.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.boot@1.0::types.CommandResult
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IBootControl.hal
+#
+GEN := $(intermediates)/android/hardware/boot/1.0/IBootControl.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IBootControl.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.boot@1.0::IBootControl
+
+$(GEN): $(LOCAL_PATH)/IBootControl.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.boot@1.0-java-static
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(local-generated-sources-dir)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+#
+# Build types.hal (BoolResult)
+#
+GEN := $(intermediates)/android/hardware/boot/1.0/BoolResult.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.boot@1.0::types.BoolResult
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (CommandResult)
+#
+GEN := $(intermediates)/android/hardware/boot/1.0/CommandResult.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.boot@1.0::types.CommandResult
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IBootControl.hal
+#
+GEN := $(intermediates)/android/hardware/boot/1.0/IBootControl.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IBootControl.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.boot@1.0::IBootControl
+
+$(GEN): $(LOCAL_PATH)/IBootControl.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/boot/1.0/IBootControl.hal b/boot/1.0/IBootControl.hal
new file mode 100644
index 0000000..2024f1f
--- /dev/null
+++ b/boot/1.0/IBootControl.hal
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2016 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.boot@1.0;
+
+/**
+ * The Boot Control HAL is designed to allow for managing sets of redundant
+ * partitions, called slots, that can be booted from independently. Slots
+ * are sets of partitions whose names differ only by a given suffix.
+ * They are identified here by a 0 indexed number and associated with their
+ * suffix, which is appended to the base name for any particular partition
+ * to find the one associated with that slot.
+ * The primary use of this set up is to allow for background updates while
+ * the device is running, and to provide a fallback in the event that the
+ * update fails.
+ */
+interface IBootControl {
+  /**
+   * getNumberSlots() returns the number of available slots.
+   * For instance, a system with a single set of partitions must return
+   * 1, a system with A/B must return 2, A/B/C -> 3 and so on. A system with
+   * less than two slots doesn't support background updates, for example if
+   * running from a virtual machine with only one copy of each partition for the
+   * purpose of testing.
+   */
+  getNumberSlots() generates (uint32_t numSlots);
+
+  /**
+   * getCurrentSlot() returns the slot number of that the current boot is booted
+   * from, for example slot number 0 (Slot A). It is assumed that if the current
+   * slot is A, then the block devices underlying B can be accessed directly
+   * without any risk of corruption.
+   * The returned value is always guaranteed to be strictly less than the
+   * value returned by getNumberSlots. Slots start at 0 and finish at
+   * getNumberSlots() - 1. The value returned here must match the suffix passed
+   * from the bootloader, regardless of which slot is active or successful.
+   */
+  getCurrentSlot() generates (Slot slot);
+
+  /**
+   * markBootSuccessful() marks the current slot as having booted successfully.
+   *
+   * Returns whether the command succeeded.
+   */
+  markBootSuccessful() generates (CommandResult error);
+
+  /**
+   * setActiveBootSlot() marks the slot passed in parameter as the active boot
+   * slot (see getCurrentSlot for an explanation of the "slot" parameter). This
+   * overrides any previous call to setSlotAsUnbootable.
+   * Returns whether the command succeeded.
+   */
+  setActiveBootSlot(Slot slot) generates (CommandResult error);
+
+  /**
+   * setSlotAsUnbootable() marks the slot passed in parameter as
+   * an unbootable. This can be used while updating the contents of the slot's
+   * partitions, so that the system must not attempt to boot a known bad set up.
+   * Returns whether the command succeeded.
+   */
+  setSlotAsUnbootable(Slot slot) generates (CommandResult error);
+
+  /**
+   * isSlotBootable() returns if the slot passed in parameter is bootable. Note
+   * that slots can be made unbootable by both the bootloader and by the OS
+   * using setSlotAsUnbootable.
+   * Returns TRUE if the slot is bootable, FALSE if it's not, and INVALID_SLOT
+   * if slot does not exist.
+   */
+  isSlotBootable(Slot slot) generates (BoolResult bootable);
+
+  /**
+   * isSlotMarkedSucessful() returns if the slot passed in parameter has been
+   * marked as successful using markBootSuccessful. Note that only the current
+   * slot can be marked as successful but any slot can be queried.
+   * Returns TRUE if the slot has been marked as successful, FALSE if it has
+   * not, and INVALID_SLOT if the slot does not exist.
+   */
+  isSlotMarkedSuccessful(Slot slot) generates (BoolResult successful);
+
+  /**
+   * getSuffix() returns the string suffix used by partitions that correspond to
+   * the slot number passed in as a parameter. The bootloader must pass the
+   * suffix of the currently active slot either through a kernel command line
+   * property at androidboot.slot_suffix, or the device tree at
+   * /firmware/android/slot_suffix.
+   * Returns the empty string "" if slot does not match an existing slot.
+   */
+  getSuffix(Slot slot) generates (string slotSuffix);
+};
+
diff --git a/boot/1.0/default/Android.mk b/boot/1.0/default/Android.mk
new file mode 100644
index 0000000..50fd1e4
--- /dev/null
+++ b/boot/1.0/default/Android.mk
@@ -0,0 +1,34 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.boot@1.0-impl
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_SRC_FILES := \
+    BootControl.cpp \
+
+LOCAL_SHARED_LIBRARIES := \
+    liblog \
+    libhidl \
+    libhwbinder \
+    libhardware \
+    libutils \
+    android.hardware.boot@1.0 \
+
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_MODULE := android.hardware.boot@1.0-service
+LOCAL_INIT_RC := android.hardware.boot@1.0-service.rc
+LOCAL_SRC_FILES := \
+    service.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+    liblog \
+    libhwbinder \
+    libhardware \
+    libhidl \
+    libutils \
+    android.hardware.boot@1.0 \
+
+include $(BUILD_EXECUTABLE)
diff --git a/boot/1.0/default/BootControl.cpp b/boot/1.0/default/BootControl.cpp
new file mode 100644
index 0000000..4c34168
--- /dev/null
+++ b/boot/1.0/default/BootControl.cpp
@@ -0,0 +1,98 @@
+#define LOG_TAG "android.hardware.boot@1.0-impl"
+#include <utils/Log.h>
+
+#include <hardware/hardware.h>
+#include <hardware/boot_control.h>
+#include "BootControl.h"
+
+namespace android {
+namespace hardware {
+namespace boot {
+namespace V1_0 {
+namespace implementation {
+
+BootControl::BootControl(boot_control_module_t *module) : mModule(module){
+}
+
+// Methods from ::android::hardware::boot::V1_0::IBootControl follow.
+Return<uint32_t> BootControl::getNumberSlots()  {
+    return mModule->getNumberSlots(mModule);
+}
+
+Return<uint32_t> BootControl::getCurrentSlot()  {
+    return mModule->getCurrentSlot(mModule);
+}
+
+Return<void> BootControl::markBootSuccessful(markBootSuccessful_cb _hidl_cb)  {
+    int ret = mModule->markBootSuccessful(mModule);
+    struct CommandResult cr;
+    cr.success = (ret == 0);
+    cr.errMsg = strerror(-ret);
+    _hidl_cb(cr);
+    return Void();
+}
+
+Return<void> BootControl::setActiveBootSlot(uint32_t slot, setActiveBootSlot_cb _hidl_cb)  {
+    int ret = mModule->setActiveBootSlot(mModule, slot);
+    struct CommandResult cr;
+    cr.success = (ret == 0);
+    cr.errMsg = strerror(-ret);
+    _hidl_cb(cr);
+    return Void();
+}
+
+Return<void> BootControl::setSlotAsUnbootable(uint32_t slot, setSlotAsUnbootable_cb _hidl_cb)  {
+    int ret = mModule->setSlotAsUnbootable(mModule, slot);
+    struct CommandResult cr;
+    cr.success = (ret == 0);
+    cr.errMsg = strerror(-ret);
+    _hidl_cb(cr);
+    return Void();
+}
+
+Return<BoolResult> BootControl::isSlotBootable(uint32_t slot)  {
+    int32_t ret = mModule->isSlotBootable(mModule, slot);
+    if (ret < 0) {
+        return BoolResult::INVALID_SLOT;
+    }
+    return ret ? BoolResult::TRUE : BoolResult::FALSE;
+}
+
+Return<BoolResult> BootControl::isSlotMarkedSuccessful(uint32_t slot)  {
+    int32_t ret = mModule->isSlotMarkedSuccessful(mModule, slot);
+    if (ret < 0) {
+        return BoolResult::INVALID_SLOT;
+    }
+    return ret ? BoolResult::TRUE : BoolResult::FALSE;
+}
+
+Return<void> BootControl::getSuffix(uint32_t slot, getSuffix_cb _hidl_cb)  {
+    hidl_string ans;
+    const char *suffix = mModule->getSuffix(mModule, slot);
+    if (suffix) {
+        ans = suffix;
+    }
+    _hidl_cb(ans);
+    return Void();
+}
+
+
+IBootControl* HIDL_FETCH_IBootControl(const char* hal) {
+    int ret = 0;
+    boot_control_module_t* module = NULL;
+    hw_module_t **hwm = reinterpret_cast<hw_module_t**>(&module);
+    ret = hw_get_module(hal, const_cast<const hw_module_t**>(hwm));
+    if (ret)
+    {
+        ALOGE("hw_get_module %s failed: %d", hal, ret);
+        return nullptr;
+    }
+    module->init(module);
+    return new BootControl(module);
+}
+
+} // namespace implementation
+}  // namespace V1_0
+}  // namespace boot
+}  // namespace hardware
+}  // namespace android
diff --git a/boot/1.0/default/BootControl.h b/boot/1.0/default/BootControl.h
new file mode 100644
index 0000000..73af4f4
--- /dev/null
+++ b/boot/1.0/default/BootControl.h
@@ -0,0 +1,46 @@
+#ifndef HIDL_GENERATED_android_hardware_boot_V1_0_BootControl_H_
+#define HIDL_GENERATED_android_hardware_boot_V1_0_BootControl_H_
+
+#include <android/hardware/boot/1.0/IBootControl.h>
+#include <hidl/Status.h>
+
+#include <hidl/MQDescriptor.h>
+namespace android {
+namespace hardware {
+namespace boot {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::boot::V1_0::BoolResult;
+using ::android::hardware::boot::V1_0::CommandResult;
+using ::android::hardware::boot::V1_0::IBootControl;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+struct BootControl : public IBootControl {
+    BootControl(boot_control_module_t* module);
+    // Methods from ::android::hardware::boot::V1_0::IBootControl follow.
+    Return<uint32_t> getNumberSlots()  override;
+    Return<uint32_t> getCurrentSlot()  override;
+    Return<void> markBootSuccessful(markBootSuccessful_cb _hidl_cb)  override;
+    Return<void> setActiveBootSlot(uint32_t slot, setActiveBootSlot_cb _hidl_cb)  override;
+    Return<void> setSlotAsUnbootable(uint32_t slot, setSlotAsUnbootable_cb _hidl_cb)  override;
+    Return<BoolResult> isSlotBootable(uint32_t slot)  override;
+    Return<BoolResult> isSlotMarkedSuccessful(uint32_t slot)  override;
+    Return<void> getSuffix(uint32_t slot, getSuffix_cb _hidl_cb)  override;
+private:
+    boot_control_module_t* mModule;
+};
+
+extern "C" IBootControl* HIDL_FETCH_IBootControl(const char* name);
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace boot
+}  // namespace hardware
+}  // namespace android
+
+#endif  // HIDL_GENERATED_android_hardware_boot_V1_0_BootControl_H_
diff --git a/boot/1.0/default/android.hardware.boot@1.0-service.rc b/boot/1.0/default/android.hardware.boot@1.0-service.rc
new file mode 100644
index 0000000..57c1aff
--- /dev/null
+++ b/boot/1.0/default/android.hardware.boot@1.0-service.rc
@@ -0,0 +1,4 @@
+service boot-hal-1-0 /system/bin/hw/android.hardware.boot@1.0-service
+    class hal
+    user system
+    group system readproc
diff --git a/boot/1.0/default/service.cpp b/boot/1.0/default/service.cpp
new file mode 100644
index 0000000..b059f9a
--- /dev/null
+++ b/boot/1.0/default/service.cpp
@@ -0,0 +1,44 @@
+#define LOG_TAG "android.hardware.boot@1.0-service"
+#include <utils/Log.h>
+
+#include <iostream>
+#include <unistd.h>
+
+#include <android/hardware/boot/1.0/IBootControl.h>
+
+#include <hidl/IServiceManager.h>
+#include <hwbinder/IPCThreadState.h>
+#include <hwbinder/ProcessState.h>
+#include <utils/Errors.h>
+#include <utils/StrongPointer.h>
+
+using android::sp;
+
+using android::hardware::IPCThreadState;
+using android::hardware::ProcessState;
+
+using ::android::hardware::boot::V1_0::IBootControl;
+
+int main (int /* argc */, char * /* argv */ []) {
+    ALOGI("Service is starting.");
+    const char instance[] = "bootctrl";
+    ALOGI("Retrieving default implementation of instance %s.",
+          instance);
+
+    sp<IBootControl> service = IBootControl::getService(instance, true /* getStub */);
+
+    if (service.get() == nullptr) {
+        ALOGE("IBootControl::getService returned NULL, exiting");
+        return -1;
+    }
+
+    LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
+
+    ALOGI("Registering instance %s.", instance);
+    service->registerAsService(instance);
+    ALOGI("Ready.");
+
+    ProcessState::self()->setThreadPoolMaxThreadCount(0);
+    ProcessState::self()->startThreadPool();
+    IPCThreadState::self()->joinThreadPool();
+}
diff --git a/boot/1.0/types.hal b/boot/1.0/types.hal
new file mode 100644
index 0000000..87f6109
--- /dev/null
+++ b/boot/1.0/types.hal
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2016 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.boot@1.0;
+
+/**
+ * A command result encapsulating whether the command succeeded and
+ * an error string.
+ */
+struct CommandResult {
+    bool success;
+    string errMsg;
+};
+
+/**
+ * An identifier for a slot number.
+ */
+typedef uint32_t Slot;
+
+/**
+ * A result encapsulating whether a function returned true, false or
+ * failed due to an invalid slot number
+ */
+enum BoolResult : int32_t {
+    FALSE = 0,
+    TRUE = 1,
+    INVALID_SLOT = -1
+};
diff --git a/example/extension/light/2.0/Android.bp b/example/extension/light/2.0/Android.bp
new file mode 100644
index 0000000..42f34f2
--- /dev/null
+++ b/example/extension/light/2.0/Android.bp
@@ -0,0 +1,47 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+    name: "android.hardware.example.extension.light@2.0_genc++",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.example.extension.light@2.0",
+    srcs: [
+        "types.hal",
+        "IExtLight.hal",
+    ],
+    out: [
+        "android/hardware/example/extension/light/2.0/types.cpp",
+        "android/hardware/example/extension/light/2.0/ExtLightAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.example.extension.light@2.0_genc++_headers",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.example.extension.light@2.0",
+    srcs: [
+        "types.hal",
+        "IExtLight.hal",
+    ],
+    out: [
+        "android/hardware/example/extension/light/2.0/types.h",
+        "android/hardware/example/extension/light/2.0/IExtLight.h",
+        "android/hardware/example/extension/light/2.0/IHwExtLight.h",
+        "android/hardware/example/extension/light/2.0/BnExtLight.h",
+        "android/hardware/example/extension/light/2.0/BpExtLight.h",
+        "android/hardware/example/extension/light/2.0/BsExtLight.h",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.example.extension.light@2.0",
+    generated_sources: ["android.hardware.example.extension.light@2.0_genc++"],
+    generated_headers: ["android.hardware.example.extension.light@2.0_genc++_headers"],
+    export_generated_headers: ["android.hardware.example.extension.light@2.0_genc++_headers"],
+    shared_libs: [
+        "libhidl",
+        "libhwbinder",
+        "libutils",
+        "libcutils",
+        "android.hardware.light@2.0",
+    ],
+}
diff --git a/example/extension/light/2.0/Android.mk b/example/extension/light/2.0/Android.mk
new file mode 100644
index 0000000..75157a8
--- /dev/null
+++ b/example/extension/light/2.0/Android.mk
@@ -0,0 +1,178 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.example.extension.light@2.0-java
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(local-generated-sources-dir)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_JAVA_LIBRARIES := \
+    android.hardware.light@2.0-java \
+
+
+#
+# Build types.hal (Default)
+#
+GEN := $(intermediates)/android/hardware/example/extension/light/2.0/Default.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.example.extension.light@2.0::types.Default
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (ExtBrightness)
+#
+GEN := $(intermediates)/android/hardware/example/extension/light/2.0/ExtBrightness.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.example.extension.light@2.0::types.ExtBrightness
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (ExtLightState)
+#
+GEN := $(intermediates)/android/hardware/example/extension/light/2.0/ExtLightState.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.example.extension.light@2.0::types.ExtLightState
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IExtLight.hal
+#
+GEN := $(intermediates)/android/hardware/example/extension/light/2.0/IExtLight.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IExtLight.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.example.extension.light@2.0::IExtLight
+
+$(GEN): $(LOCAL_PATH)/IExtLight.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.example.extension.light@2.0-java-static
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(local-generated-sources-dir)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    android.hardware.light@2.0-java-static \
+
+
+#
+# Build types.hal (Default)
+#
+GEN := $(intermediates)/android/hardware/example/extension/light/2.0/Default.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.example.extension.light@2.0::types.Default
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (ExtBrightness)
+#
+GEN := $(intermediates)/android/hardware/example/extension/light/2.0/ExtBrightness.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.example.extension.light@2.0::types.ExtBrightness
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (ExtLightState)
+#
+GEN := $(intermediates)/android/hardware/example/extension/light/2.0/ExtLightState.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.example.extension.light@2.0::types.ExtLightState
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IExtLight.hal
+#
+GEN := $(intermediates)/android/hardware/example/extension/light/2.0/IExtLight.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IExtLight.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.example.extension.light@2.0::IExtLight
+
+$(GEN): $(LOCAL_PATH)/IExtLight.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/example/extension/light/2.0/IExtLight.hal b/example/extension/light/2.0/IExtLight.hal
new file mode 100644
index 0000000..f12a272
--- /dev/null
+++ b/example/extension/light/2.0/IExtLight.hal
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+// Would normally be 'vendor.example.extension.light@2.0' however, this is
+// a google extension example. A vendor extension should also live in the
+// vendor partition.
+package android.hardware.example.extension.light@2.0;
+
+import android.hardware.light@2.0;
+
+interface IExtLight extends android.hardware.light@2.0::ILight {
+
+    /**
+     * Set the provided lights to the provided values.
+     *
+     * @param type logical light to set
+     * @param state describes what the light should look like.
+     * @return status result of applying state transformation.
+     */
+    setExtLight(Type type, ExtLightState state) generates (Status status);
+
+};
diff --git a/example/extension/light/2.0/default/Android.mk b/example/extension/light/2.0/default/Android.mk
new file mode 100644
index 0000000..fa68787
--- /dev/null
+++ b/example/extension/light/2.0/default/Android.mk
@@ -0,0 +1,17 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.example.extension.light@2.0-service
+LOCAL_INIT_RC := android.hardware.example.extension.light@2.0-service.rc
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_SRC_FILES := \
+    Light.cpp \
+
+LOCAL_SHARED_LIBRARIES := \
+    libhidl \
+    libhwbinder \
+    libutils \
+    android.hardware.light@2.0 \
+    android.hardware.example.extension.light@2.0 \
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/example/extension/light/2.0/default/Light.cpp b/example/extension/light/2.0/default/Light.cpp
new file mode 100644
index 0000000..d738a6d
--- /dev/null
+++ b/example/extension/light/2.0/default/Light.cpp
@@ -0,0 +1,56 @@
+#include "Light.h"
+
+namespace android {
+namespace hardware {
+namespace example {
+namespace extension {
+namespace light {
+namespace V2_0 {
+namespace implementation {
+
+// Methods from ::android::hardware::light::V2_0::ILight follow.
+Return<Status> Light::setLight(Type type, const LightState& state)  {
+    // Forward types for new methods.
+
+    ExtLightState extState {
+        .state = state,
+        .interpolationOmega =
+            static_cast<int32_t>(Default::INTERPOLATION_OMEGA),
+        .brightness = // ExtBrightness inherits from Brightness
+            static_cast<ExtBrightness>(state.brightnessMode)
+    };
+
+    return setExtLight(type, extState);
+}
+
+Return<void> Light::getSupportedTypes(getSupportedTypes_cb _hidl_cb)  {
+    // implement unchanged method as you would always
+    hidl_vec<Type> vec{};
+
+    // ******************************************************
+    // Note: awesome proprietary hardware implementation here
+    // ******************************************************
+
+    _hidl_cb(vec);
+
+    return Void();
+}
+
+// Methods from ::android::hardware::example::extension::light::V2_0::ILight follow.
+Return<Status> Light::setExtLight(Type /* type */,
+                                  const ExtLightState& /* state */)  {
+
+    // ******************************************************
+    // Note: awesome proprietary hardware implementation here
+    // ******************************************************
+
+    return Status::SUCCESS;
+}
+
+} // namespace implementation
+}  // namespace V2_0
+}  // namespace light
+}  // namespace extension
+}  // namespace example
+}  // namespace hardware
+}  // namespace android
diff --git a/example/extension/light/2.0/default/Light.h b/example/extension/light/2.0/default/Light.h
new file mode 100644
index 0000000..e09ec92
--- /dev/null
+++ b/example/extension/light/2.0/default/Light.h
@@ -0,0 +1,46 @@
+#ifndef HIDL_GENERATED_android_hardware_example_extension_light_V2_0_Light_H_
+#define HIDL_GENERATED_android_hardware_example_extension_light_V2_0_Light_H_
+
+#include <android/hardware/example/extension/light/2.0/IExtLight.h>
+#include <hidl/Status.h>
+
+#include <hidl/MQDescriptor.h>
+namespace android {
+namespace hardware {
+namespace example {
+namespace extension {
+namespace light {
+namespace V2_0 {
+namespace implementation {
+
+using ::android::hardware::example::extension::light::V2_0::ExtLightState;
+using ::android::hardware::example::extension::light::V2_0::IExtLight;
+using ::android::hardware::light::V2_0::ILight;
+using ::android::hardware::light::V2_0::LightState;
+using ::android::hardware::light::V2_0::Status;
+using ::android::hardware::light::V2_0::Type;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+struct Light : public IExtLight {
+    // Methods from ::android::hardware::light::V2_0::ILight follow.
+    Return<Status> setLight(Type type, const LightState& state)  override;
+    Return<void> getSupportedTypes(getSupportedTypes_cb _hidl_cb)  override;
+
+    // Methods from ::android::hardware::example::extension::light::V2_0::ILight follow.
+    Return<Status> setExtLight(Type type, const ExtLightState& state)  override;
+
+};
+
+}  // namespace implementation
+}  // namespace V2_0
+}  // namespace light
+}  // namespace extension
+}  // namespace example
+}  // namespace hardware
+}  // namespace android
+
+#endif  // HIDL_GENERATED_android_hardware_example_extension_light_V2_0_Light_H_
diff --git a/example/extension/light/2.0/default/android.hardware.example.extension.light@2.0-service.rc b/example/extension/light/2.0/default/android.hardware.example.extension.light@2.0-service.rc
new file mode 100644
index 0000000..8a90d81
--- /dev/null
+++ b/example/extension/light/2.0/default/android.hardware.example.extension.light@2.0-service.rc
@@ -0,0 +1,4 @@
+service light-ext-2-0 /system/bin/hw/android.hardware.example.extension.light@2.0-service
+    class hal
+    user system
+    group system readproc
\ No newline at end of file
diff --git a/example/extension/light/2.0/default/service.cpp b/example/extension/light/2.0/default/service.cpp
new file mode 100644
index 0000000..55121d9
--- /dev/null
+++ b/example/extension/light/2.0/default/service.cpp
@@ -0,0 +1,34 @@
+#define LOG_TAG "android.hardware.light@2.0-service"
+#include <utils/Log.h>
+
+// #include <iostream>
+// #include <unistd.h>
+
+// #include <hidl/IServiceManager.h>
+// #include <hwbinder/IPCThreadState.h>
+// #include <hwbinder/ProcessState.h>
+// #include <utils/Errors.h>
+// #include <utils/StrongPointer.h>
+
+#include "Light.h"
+
+using android::sp;
+
+// libhwbinder:
+using android::hardware::IPCThreadState;
+using android::hardware::ProcessState;
+
+// Generated HIDL files
+using android::hardware::light::V2_0::ILight;
+
+int main() {
+    const char instance[] = "light";
+
+    android::sp<ILight> service = new Light();
+
+    service->registerAsService(instance);
+
+    ProcessState::self()->setThreadPoolMaxThreadCount(0);
+    ProcessState::self()->startThreadPool();
+    IPCThreadState::self()->joinThreadPool();
+}
diff --git a/example/extension/light/2.0/types.hal b/example/extension/light/2.0/types.hal
new file mode 100644
index 0000000..5be41bb
--- /dev/null
+++ b/example/extension/light/2.0/types.hal
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2016 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.example.extension.light@2.0;
+
+import android.hardware.light@2.0;
+
+enum Default : int32_t {
+    // for calls to setLight from the framework that don't know about this
+    // extension or its requirements
+    INTERPOLATION_OMEGA = 2
+};
+
+/**
+ * One possibility is renaming an old type. Another possibility is taking
+ * advantages of the different namespaces.
+ */
+enum ExtBrightness : Brightness {
+    /**
+     * Say we're really going to use the phone as a heater.
+     */
+    EXTREME,
+
+    /**
+     * Sometimes at night, we need it to be day.
+     */
+     THE_SUN,
+};
+
+/**
+ * Structs can't inherit eachother in hidl. Use composition instead. In this
+ * case, I won't use inheritence because I want to replace Brightness with
+ * ExtBrightness.
+ */
+struct ExtLightState {
+    LightState state;
+
+    /**
+     * This is the secret sauce that will really make this extension shine.
+     * No other person has such a cool feature in their hals. Don't forget
+     * to describe all details of parameters. An interface is a contract, and
+     * specifying this contract to the letter is what allows that contracted
+     * to be maintained. :)
+     *
+     * So, this parameter represents the speed at which brightness is changed
+     * to the new value in the three dimensional space with coordinates RGB
+     * from the red, blue, and green.
+     */
+    int32_t interpolationOmega;
+
+    /**
+     * Include new values.
+     */
+    ExtBrightness brightness;
+};
diff --git a/graphics/allocator/2.0/default/Android.bp b/graphics/allocator/2.0/default/Android.bp
index 9a24773..8eac8f5 100644
--- a/graphics/allocator/2.0/default/Android.bp
+++ b/graphics/allocator/2.0/default/Android.bp
@@ -15,6 +15,21 @@
     ],
 }
 
+cc_binary {
+    name: "android.hardware.graphics.allocator@2.0-service",
+    relative_install_path: "hw",
+    srcs: ["service.cpp"],
+    init_rc: ["android.hardware.graphics.allocator@2.0-service.rc"],
+
+    shared_libs: [
+        "android.hardware.graphics.allocator@2.0",
+        "libhidl",
+        "libhwbinder",
+        "liblog",
+        "libutils",
+    ],
+}
+
 cc_library_static {
     name: "libgralloc1-adapter",
     srcs: ["gralloc1-adapter.c"],
diff --git a/graphics/allocator/2.0/default/android.hardware.graphics.allocator@2.0-service.rc b/graphics/allocator/2.0/default/android.hardware.graphics.allocator@2.0-service.rc
new file mode 100644
index 0000000..8bb0d85
--- /dev/null
+++ b/graphics/allocator/2.0/default/android.hardware.graphics.allocator@2.0-service.rc
@@ -0,0 +1,5 @@
+service gralloc-2-0 /system/bin/hw/android.hardware.graphics.allocator@2.0-service
+    class hal
+    user system
+    group graphics drmrpc readproc
+    onrestart restart surfaceflinger
diff --git a/graphics/allocator/2.0/default/service.cpp b/graphics/allocator/2.0/default/service.cpp
new file mode 100644
index 0000000..fd89aa8
--- /dev/null
+++ b/graphics/allocator/2.0/default/service.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2016 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 "GrallocService"
+
+#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
+#include <hwbinder/IPCThreadState.h>
+#include <hwbinder/ProcessState.h>
+#include <utils/StrongPointer.h>
+
+using android::sp;
+using android::hardware::IPCThreadState;
+using android::hardware::ProcessState;
+using android::hardware::graphics::allocator::V2_0::IAllocator;
+
+int main()
+{
+    const char instance[] = "gralloc";
+
+    ALOGI("Service is starting.");
+
+    sp<IAllocator> service = IAllocator::getService(instance,
+            true /* getStub */);
+    if (service == nullptr) {
+        ALOGI("getService returned NULL");
+        return -1;
+    }
+
+    LOG_FATAL_IF(service->isRemote(), "Service is REMOTE!");
+
+    service->registerAsService(instance);
+
+    ProcessState::self()->setThreadPoolMaxThreadCount(0);
+    ProcessState::self()->startThreadPool();
+    IPCThreadState::self()->joinThreadPool();
+
+    return 0;
+}
diff --git a/graphics/composer/2.1/default/Android.bp b/graphics/composer/2.1/default/Android.bp
index f91c9a2..6936347 100644
--- a/graphics/composer/2.1/default/Android.bp
+++ b/graphics/composer/2.1/default/Android.bp
@@ -14,3 +14,24 @@
         "libutils",
     ],
 }
+
+cc_binary {
+    name: "android.hardware.graphics.composer@2.1-service",
+    relative_install_path: "hw",
+    srcs: ["service.cpp", "Hwc.cpp"],
+    cppflags: ["-DBINDERIZED"],
+    init_rc: ["android.hardware.graphics.composer@2.1-service.rc"],
+
+    shared_libs: [
+        "android.hardware.graphics.allocator@2.0",
+        "android.hardware.graphics.composer@2.1",
+        "libbase",
+        "libbinder",
+        "libcutils",
+        "libhardware",
+        "libhidl",
+        "libhwbinder",
+        "liblog",
+        "libutils",
+    ],
+}
diff --git a/graphics/composer/2.1/default/Hwc.cpp b/graphics/composer/2.1/default/Hwc.cpp
index 09c62f0..d45a955 100644
--- a/graphics/composer/2.1/default/Hwc.cpp
+++ b/graphics/composer/2.1/default/Hwc.cpp
@@ -698,6 +698,14 @@
 Return<Error> HwcHal::destroyLayer(Display display, Layer layer)
 {
     auto error = mDispatch.destroyLayer(mDevice, display, layer);
+    if (error == HWC2_ERROR_NONE) {
+        std::lock_guard<std::mutex> lock(mDisplayMutex);
+
+        auto dpy = mDisplays.find(display);
+        dpy->second.LayerBuffers.erase(layer);
+        dpy->second.LayerSidebandStreams.erase(layer);
+    }
+
     return static_cast<Error>(error);
 }
 
diff --git a/graphics/composer/2.1/default/android.hardware.graphics.composer@2.1-service.rc b/graphics/composer/2.1/default/android.hardware.graphics.composer@2.1-service.rc
new file mode 100644
index 0000000..fc21d59
--- /dev/null
+++ b/graphics/composer/2.1/default/android.hardware.graphics.composer@2.1-service.rc
@@ -0,0 +1,5 @@
+service hwcomposer-2-1 /system/bin/hw/android.hardware.graphics.composer@2.1-service
+    class hal
+    user system
+    group graphics drmrpc readproc
+    onrestart restart surfaceflinger
diff --git a/graphics/composer/2.1/default/service.cpp b/graphics/composer/2.1/default/service.cpp
new file mode 100644
index 0000000..0384a53
--- /dev/null
+++ b/graphics/composer/2.1/default/service.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2016 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 "HWComposerService"
+
+#include <binder/ProcessState.h>
+#include <hwbinder/IPCThreadState.h>
+#include <hwbinder/ProcessState.h>
+#include <utils/StrongPointer.h>
+#include "Hwc.h"
+
+using android::sp;
+using android::hardware::IPCThreadState;
+using android::hardware::ProcessState;
+using android::hardware::graphics::composer::V2_1::IComposer;
+using android::hardware::graphics::composer::V2_1::implementation::HIDL_FETCH_IComposer;
+
+int main()
+{
+    const char instance[] = "hwcomposer";
+
+    ALOGI("Service is starting.");
+
+    sp<IComposer> service = HIDL_FETCH_IComposer(instance);
+    if (service == nullptr) {
+        ALOGI("getService returned NULL");
+        return -1;
+    }
+
+    LOG_FATAL_IF(service->isRemote(), "Service is REMOTE!");
+
+    service->registerAsService(instance);
+
+    // the conventional HAL might start binder services
+    android::ProcessState::self()->setThreadPoolMaxThreadCount(4);
+    android::ProcessState::self()->startThreadPool();
+
+    ProcessState::self()->setThreadPoolMaxThreadCount(0);
+    ProcessState::self()->startThreadPool();
+    IPCThreadState::self()->joinThreadPool();
+
+    return 0;
+}
diff --git a/memtrack/1.0/IMemtrack.hal b/memtrack/1.0/IMemtrack.hal
index 064f2fe..ae9d960 100644
--- a/memtrack/1.0/IMemtrack.hal
+++ b/memtrack/1.0/IMemtrack.hal
@@ -57,7 +57,7 @@
      * GRAPHICS is requested and not when GL
      * is requested.
      *
-     * @param pid process for which memory infromation is requested
+     * @param pid process for which memory information is requested
      * @param type memory type that information is being requested about
      * @return records vector of MemtrackRecord containing memory information
      * @return retval SUCCESS on success, TYPE_NOT_FOUND if the type is not
diff --git a/nfc/1.0/default/service.cpp b/nfc/1.0/default/service.cpp
index e70388d..32f9c28 100644
--- a/nfc/1.0/default/service.cpp
+++ b/nfc/1.0/default/service.cpp
@@ -1,44 +1,13 @@
 #define LOG_TAG "android.hardware.nfc@1.0-service"
-#include <utils/Log.h>
-
-#include <iostream>
-#include <unistd.h>
 
 #include <android/hardware/nfc/1.0/INfc.h>
 
-#include <hidl/IServiceManager.h>
-#include <hwbinder/IPCThreadState.h>
-#include <hwbinder/ProcessState.h>
-#include <utils/Errors.h>
-#include <utils/StrongPointer.h>
-
-using android::sp;
-
-// libhwbinder:
-using android::hardware::IPCThreadState;
-using android::hardware::ProcessState;
+#include <hidl/LegacySupport.h>
 
 // Generated HIDL files
 using android::hardware::nfc::V1_0::INfc;
+using android::hardware::defaultPassthroughServiceImplementation;
 
 int main() {
-    ALOGI("Service is starting.");
-    const char instance[] = "nfc_nci";
-    ALOGI("Retrieving default implementation of instance %s.",
-          instance);
-    android::sp<INfc> service = INfc::getService(instance, true /* getStub */);
-    if (service.get() == nullptr) {
-        ALOGE("INfc::getService returned NULL, exiting");
-        return -1;
-    }
-    ALOGI("Default implementation using %s is %s",
-          instance, (service->isRemote() ? "REMOTE" : "LOCAL"));
-    LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
-    ALOGI("Registering instance %s.", instance);
-    service->registerAsService(instance);
-    ALOGI("Ready.");
-
-    ProcessState::self()->setThreadPoolMaxThreadCount(0);
-    ProcessState::self()->startThreadPool();
-    IPCThreadState::self()->joinThreadPool();
+    return defaultPassthroughServiceImplementation<INfc>("nfc_nci");
 }
diff --git a/nfc/1.0/vts/Nfc.vts b/nfc/1.0/vts/Nfc.vts
index 8c18653..1f50698 100644
--- a/nfc/1.0/vts/Nfc.vts
+++ b/nfc/1.0/vts/Nfc.vts
@@ -1,7 +1,6 @@
 component_class: HAL_HIDL
 component_type_version: 1.0
 component_name: "INfc"
-component_type: NFC
 
 package: "android.hardware.nfc"
 
diff --git a/nfc/1.0/vts/NfcClientCallback.vts b/nfc/1.0/vts/NfcClientCallback.vts
index e468935..e2a3e5b 100644
--- a/nfc/1.0/vts/NfcClientCallback.vts
+++ b/nfc/1.0/vts/NfcClientCallback.vts
@@ -1,7 +1,6 @@
 component_class: HAL_HIDL
 component_type_version: 1.0
 component_name: "INfcClientCallback"
-component_type: NFC
 
 package: "android.hardware.nfc"
 
diff --git a/nfc/1.0/vts/types.vts b/nfc/1.0/vts/types.vts
index f56ddf1..969a8af 100644
--- a/nfc/1.0/vts/types.vts
+++ b/nfc/1.0/vts/types.vts
@@ -1,7 +1,6 @@
 component_class: HAL_HIDL
 component_type_version: 1.0
 component_name: "types"
-component_type: NFC
 
 package: "android.hardware.nfc"
 
diff --git a/soundtrigger/2.0/default/Android.mk b/soundtrigger/2.0/default/Android.mk
new file mode 100644
index 0000000..4ec64de
--- /dev/null
+++ b/soundtrigger/2.0/default/Android.mk
@@ -0,0 +1,42 @@
+#
+# Copyright (C) 2016 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.soundtrigger@2.0-impl
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_SRC_FILES := \
+    SoundTriggerHalImpl.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+        libhidl \
+        liblog \
+        libhwbinder \
+        libutils \
+        libhardware \
+        android.hardware.soundtrigger@2.0 \
+        android.hardware.audio.common@2.0
+
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
+
+ifeq ($(strip $(AUDIOSERVER_MULTILIB)),)
+LOCAL_MULTILIB := 32
+else
+LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
+endif
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp b/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp
new file mode 100644
index 0000000..1ae996a
--- /dev/null
+++ b/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp
@@ -0,0 +1,595 @@
+/*
+ * Copyright (C) 2016 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 "SoundTriggerHalImpl"
+//#define LOG_NDEBUG 0
+
+#include <utils/Log.h>
+#include "SoundTriggerHalImpl.h"
+
+
+namespace android {
+namespace hardware {
+namespace soundtrigger {
+namespace V2_0 {
+namespace implementation {
+
+// static
+void SoundTriggerHalImpl::soundModelCallback(struct sound_trigger_model_event *halEvent,
+                                               void *cookie)
+{
+    if (halEvent == NULL) {
+        ALOGW("soundModelCallback called with NULL event");
+        return;
+    }
+    sp<SoundModelClient> client =
+            wp<SoundModelClient>(static_cast<SoundModelClient *>(cookie)).promote();
+    if (client == 0) {
+        ALOGW("soundModelCallback called on stale client");
+        return;
+    }
+    if (halEvent->model != client->mHalHandle) {
+        ALOGW("soundModelCallback call with wrong handle %d on client with handle %d",
+              (int)halEvent->model, (int)client->mHalHandle);
+        return;
+    }
+
+    ISoundTriggerHwCallback::ModelEvent event;
+    convertSoundModelEventFromHal(&event, halEvent);
+    event.model = client->mId;
+
+    client->mCallback->soundModelCallback(event, client->mCookie);
+}
+
+// static
+void SoundTriggerHalImpl::recognitionCallback(struct sound_trigger_recognition_event *halEvent,
+                                               void *cookie)
+{
+    if (halEvent == NULL) {
+        ALOGW("recognitionCallback call NULL event");
+        return;
+    }
+    sp<SoundModelClient> client =
+            wp<SoundModelClient>(static_cast<SoundModelClient *>(cookie)).promote();
+    if (client == 0) {
+        ALOGW("soundModelCallback called on stale client");
+        return;
+    }
+
+    ISoundTriggerHwCallback::RecognitionEvent *event = convertRecognitionEventFromHal(halEvent);
+    event->model = client->mId;
+    if (halEvent->type == SOUND_MODEL_TYPE_KEYPHRASE) {
+        client->mCallback->phraseRecognitionCallback(
+                *(reinterpret_cast<ISoundTriggerHwCallback::PhraseRecognitionEvent *>(event)),
+                client->mCookie);
+    } else {
+        client->mCallback->recognitionCallback(*event, client->mCookie);
+    }
+    delete event;
+}
+
+
+
+// Methods from ::android::hardware::soundtrigger::V2_0::ISoundTriggerHw follow.
+Return<void> SoundTriggerHalImpl::getProperties(getProperties_cb _hidl_cb)
+{
+    ALOGV("getProperties() mHwDevice %p", mHwDevice);
+    int ret;
+    struct sound_trigger_properties halProperties;
+    ISoundTriggerHw::Properties properties;
+
+    if (mHwDevice == NULL) {
+        ret = -ENODEV;
+        goto exit;
+    }
+
+    ret = mHwDevice->get_properties(mHwDevice, &halProperties);
+
+    convertPropertiesFromHal(&properties, &halProperties);
+
+    ALOGV("getProperties implementor %s recognitionModes %08x",
+          properties.implementor.c_str(), properties.recognitionModes);
+
+exit:
+    _hidl_cb(ret, properties);
+    return Void();
+}
+
+int SoundTriggerHalImpl::doLoadSoundModel(const ISoundTriggerHw::SoundModel& soundModel,
+                                                 const sp<ISoundTriggerHwCallback>& callback,
+                                                 ISoundTriggerHwCallback::CallbackCookie cookie,
+                                                 uint32_t *modelId)
+{
+    int32_t ret = 0;
+    struct sound_trigger_sound_model *halSoundModel;
+    *modelId = 0;
+    sp<SoundModelClient> client;
+
+    ALOGV("doLoadSoundModel() data size %zu", soundModel.data.size());
+
+    if (mHwDevice == NULL) {
+        ret = -ENODEV;
+        goto exit;
+    }
+
+    halSoundModel = convertSoundModelToHal(&soundModel);
+    if (halSoundModel == NULL) {
+        ret = -EINVAL;
+        goto exit;
+    }
+
+    {
+        AutoMutex lock(mLock);
+        do {
+            *modelId = nextUniqueId();
+        } while (mClients.valueFor(*modelId) != 0 && *modelId != 0);
+    }
+    LOG_ALWAYS_FATAL_IF(*modelId == 0,
+                        "wrap around in sound model IDs, num loaded models %d", mClients.size());
+
+    client = new SoundModelClient(*modelId, callback, cookie);
+
+    ret = mHwDevice->load_sound_model(mHwDevice, halSoundModel, soundModelCallback,
+                                          client.get(), &client->mHalHandle);
+
+    free(halSoundModel);
+
+    if (ret != 0) {
+        goto exit;
+    }
+
+    {
+        AutoMutex lock(mLock);
+        mClients.add(*modelId, client);
+    }
+
+exit:
+    return ret;
+}
+
+Return<void> SoundTriggerHalImpl::loadSoundModel(const ISoundTriggerHw::SoundModel& soundModel,
+                                                 const sp<ISoundTriggerHwCallback>& callback,
+                                                 ISoundTriggerHwCallback::CallbackCookie cookie,
+                                                 loadSoundModel_cb _hidl_cb)
+{
+    uint32_t modelId = 0;
+    int32_t ret = doLoadSoundModel(soundModel, callback, cookie, &modelId);
+
+    _hidl_cb(ret, modelId);
+    return Void();
+}
+
+Return<void> SoundTriggerHalImpl::loadPhraseSoundModel(
+                                            const ISoundTriggerHw::PhraseSoundModel& soundModel,
+                                            const sp<ISoundTriggerHwCallback>& callback,
+                                            ISoundTriggerHwCallback::CallbackCookie cookie,
+                                            ISoundTriggerHw::loadPhraseSoundModel_cb _hidl_cb)
+{
+    uint32_t modelId = 0;
+    int32_t ret = doLoadSoundModel((const ISoundTriggerHw::SoundModel&)soundModel,
+                                   callback, cookie, &modelId);
+
+    _hidl_cb(ret, modelId);
+    return Void();
+}
+
+Return<int32_t> SoundTriggerHalImpl::unloadSoundModel(SoundModelHandle modelHandle)
+{
+    int32_t ret;
+    sp<SoundModelClient> client;
+
+    if (mHwDevice == NULL) {
+        ret = -ENODEV;
+        goto exit;
+    }
+
+    {
+        AutoMutex lock(mLock);
+        client = mClients.valueFor(modelHandle);
+        if (client == 0) {
+            ret = -ENOSYS;
+            goto exit;
+        }
+    }
+
+    ret = mHwDevice->unload_sound_model(mHwDevice, client->mHalHandle);
+
+    mClients.removeItem(modelHandle);
+
+exit:
+    return ret;
+}
+
+Return<int32_t> SoundTriggerHalImpl::startRecognition(SoundModelHandle modelHandle,
+                                           const ISoundTriggerHw::RecognitionConfig& config,
+                                           const sp<ISoundTriggerHwCallback>& callback __unused,
+                                           ISoundTriggerHwCallback::CallbackCookie cookie __unused)
+{
+    int32_t ret;
+    sp<SoundModelClient> client;
+    struct sound_trigger_recognition_config *halConfig;
+
+    if (mHwDevice == NULL) {
+        ret = -ENODEV;
+        goto exit;
+    }
+
+    {
+        AutoMutex lock(mLock);
+        client = mClients.valueFor(modelHandle);
+        if (client == 0) {
+            ret = -ENOSYS;
+            goto exit;
+        }
+    }
+
+
+    halConfig = convertRecognitionConfigToHal(&config);
+
+    if (halConfig == NULL) {
+        ret = -EINVAL;
+        goto exit;
+    }
+    ret = mHwDevice->start_recognition(mHwDevice, client->mHalHandle, halConfig,
+                                 recognitionCallback, client.get());
+
+    free(halConfig);
+
+exit:
+    return ret;
+}
+
+Return<int32_t> SoundTriggerHalImpl::stopRecognition(SoundModelHandle modelHandle)
+{
+    int32_t ret;
+    sp<SoundModelClient> client;
+    if (mHwDevice == NULL) {
+        ret = -ENODEV;
+        goto exit;
+    }
+
+    {
+        AutoMutex lock(mLock);
+        client = mClients.valueFor(modelHandle);
+        if (client == 0) {
+            ret = -ENOSYS;
+            goto exit;
+        }
+    }
+
+    ret = mHwDevice->stop_recognition(mHwDevice, client->mHalHandle);
+
+exit:
+    return ret;
+}
+
+Return<int32_t> SoundTriggerHalImpl::stopAllRecognitions()
+{
+    int32_t ret;
+    if (mHwDevice == NULL) {
+        ret = -ENODEV;
+        goto exit;
+    }
+
+    if (mHwDevice->common.version >= SOUND_TRIGGER_DEVICE_API_VERSION_1_1 &&
+            mHwDevice->stop_all_recognitions) {
+        ret = mHwDevice->stop_all_recognitions(mHwDevice);
+    } else {
+        ret = -ENOSYS;
+    }
+exit:
+    return ret;
+}
+
+SoundTriggerHalImpl::SoundTriggerHalImpl(const char *moduleName)
+    : mModuleName(moduleName), mNextModelId(1)
+{
+}
+
+void SoundTriggerHalImpl::onFirstRef()
+{
+    const hw_module_t *mod;
+    int rc;
+
+    if (mModuleName == NULL || strlen(mModuleName) == 0) {
+        mModuleName = "primary";
+    }
+    rc = hw_get_module_by_class(SOUND_TRIGGER_HARDWARE_MODULE_ID, mModuleName, &mod);
+    if (rc != 0) {
+        ALOGE("couldn't load sound trigger module %s.%s (%s)",
+              SOUND_TRIGGER_HARDWARE_MODULE_ID, mModuleName, strerror(-rc));
+        return;
+    }
+    rc = sound_trigger_hw_device_open(mod, &mHwDevice);
+    if (rc != 0) {
+        ALOGE("couldn't open sound trigger hw device in %s.%s (%s)",
+              SOUND_TRIGGER_HARDWARE_MODULE_ID, mModuleName, strerror(-rc));
+        mHwDevice = NULL;
+        return;
+    }
+    if (mHwDevice->common.version < SOUND_TRIGGER_DEVICE_API_VERSION_1_0 ||
+            mHwDevice->common.version > SOUND_TRIGGER_DEVICE_API_VERSION_CURRENT) {
+        ALOGE("wrong sound trigger hw device version %04x", mHwDevice->common.version);
+        sound_trigger_hw_device_close(mHwDevice);
+        mHwDevice = NULL;
+        return;
+    }
+
+    ALOGI("onFirstRef() mModuleName %s mHwDevice %p", mModuleName, mHwDevice);
+}
+
+SoundTriggerHalImpl::~SoundTriggerHalImpl()
+{
+    if (mHwDevice != NULL) {
+        sound_trigger_hw_device_close(mHwDevice);
+    }
+}
+
+uint32_t SoundTriggerHalImpl::nextUniqueId()
+{
+    return (uint32_t) atomic_fetch_add_explicit(&mNextModelId,
+                (uint_fast32_t) 1, memory_order_acq_rel);
+}
+
+void SoundTriggerHalImpl::convertUuidFromHal(Uuid *uuid,
+                                             const sound_trigger_uuid_t *halUuid)
+{
+    uuid->timeLow = halUuid->timeLow;
+    uuid->timeMid = halUuid->timeMid;
+    uuid->versionAndTimeHigh = halUuid->timeHiAndVersion;
+    uuid->variantAndClockSeqHigh = halUuid->clockSeq;
+    memcpy(&uuid->node[0], &halUuid->node[0], 6);
+}
+
+void SoundTriggerHalImpl::convertUuidToHal(sound_trigger_uuid_t *halUuid,
+                                           const Uuid *uuid)
+{
+    halUuid->timeLow = uuid->timeLow;
+    halUuid->timeMid = uuid->timeMid;
+    halUuid->timeHiAndVersion = uuid->versionAndTimeHigh;
+    halUuid->clockSeq = uuid->variantAndClockSeqHigh;
+    memcpy(&halUuid->node[0], &uuid->node[0], 6);
+}
+
+void SoundTriggerHalImpl::convertPropertiesFromHal(
+        ISoundTriggerHw::Properties *properties,
+        const struct sound_trigger_properties *halProperties)
+{
+    properties->implementor = halProperties->implementor;
+    properties->description = halProperties->description;
+    properties->version = halProperties->version;
+    convertUuidFromHal(&properties->uuid, &halProperties->uuid);
+    properties->maxSoundModels = halProperties->max_sound_models;
+    properties->maxKeyPhrases = halProperties->max_key_phrases;
+    properties->maxUsers = halProperties->max_users;
+    properties->recognitionModes = halProperties->recognition_modes;
+    properties->captureTransition = halProperties->capture_transition;
+    properties->maxBufferMs = halProperties->max_buffer_ms;
+    properties->concurrentCapture = halProperties->concurrent_capture;
+    properties->triggerInEvent = halProperties->trigger_in_event;
+    properties->powerConsumptionMw = halProperties->power_consumption_mw;
+
+}
+
+void SoundTriggerHalImpl::convertTriggerPhraseToHal(
+        struct sound_trigger_phrase *halTriggerPhrase,
+        const ISoundTriggerHw::Phrase *triggerPhrase)
+{
+    halTriggerPhrase->id = triggerPhrase->id;
+    halTriggerPhrase->recognition_mode = triggerPhrase->recognitionModes;
+    unsigned int i;
+    for (i = 0; i < triggerPhrase->users.size(); i++) {
+        halTriggerPhrase->users[i] = triggerPhrase->users[i];
+    }
+    halTriggerPhrase->num_users = i;
+
+    strlcpy(halTriggerPhrase->locale,
+            triggerPhrase->locale.c_str(), SOUND_TRIGGER_MAX_LOCALE_LEN);
+    strlcpy(halTriggerPhrase->text,
+            triggerPhrase->text.c_str(), SOUND_TRIGGER_MAX_STRING_LEN);
+}
+
+struct sound_trigger_sound_model *SoundTriggerHalImpl::convertSoundModelToHal(
+        const ISoundTriggerHw::SoundModel *soundModel)
+{
+    struct sound_trigger_sound_model *halModel = NULL;
+    if (soundModel->type == SoundModelType::KEYPHRASE) {
+        size_t allocSize =
+                sizeof(struct sound_trigger_phrase_sound_model) + soundModel->data.size();
+        struct sound_trigger_phrase_sound_model *halKeyPhraseModel =
+                static_cast<struct sound_trigger_phrase_sound_model *>(malloc(allocSize));
+        LOG_ALWAYS_FATAL_IF(halKeyPhraseModel == NULL,
+                        "malloc failed for size %zu in convertSoundModelToHal PHRASE", allocSize);
+
+        const ISoundTriggerHw::PhraseSoundModel *keyPhraseModel =
+                reinterpret_cast<const ISoundTriggerHw::PhraseSoundModel *>(soundModel);
+
+        size_t i;
+        for (i = 0; i < keyPhraseModel->phrases.size() && i < SOUND_TRIGGER_MAX_PHRASES; i++) {
+            convertTriggerPhraseToHal(&halKeyPhraseModel->phrases[i],
+                                      &keyPhraseModel->phrases[i]);
+        }
+        halKeyPhraseModel->num_phrases = (unsigned int)i;
+        halModel = reinterpret_cast<struct sound_trigger_sound_model *>(halKeyPhraseModel);
+        halModel->data_offset = sizeof(struct sound_trigger_phrase_sound_model);
+    } else {
+        size_t allocSize =
+                sizeof(struct sound_trigger_sound_model) + soundModel->data.size();
+        halModel = static_cast<struct sound_trigger_sound_model *>(malloc(allocSize));
+        LOG_ALWAYS_FATAL_IF(halModel == NULL,
+                            "malloc failed for size %zu in convertSoundModelToHal GENERIC",
+                            allocSize);
+
+        halModel->data_offset = sizeof(struct sound_trigger_sound_model);
+    }
+    halModel->type = (sound_trigger_sound_model_type_t)soundModel->type;
+    convertUuidToHal(&halModel->uuid, &soundModel->uuid);
+    convertUuidToHal(&halModel->vendor_uuid, &soundModel->vendorUuid);
+    halModel->data_size = soundModel->data.size();
+    uint8_t *dst = reinterpret_cast<uint8_t *>(halModel) + halModel->data_offset;
+    const uint8_t *src = reinterpret_cast<const uint8_t *>(&soundModel->data[0]);
+    memcpy(dst, src, soundModel->data.size());
+
+    return halModel;
+}
+
+void SoundTriggerHalImpl::convertPhraseRecognitionExtraToHal(
+        struct sound_trigger_phrase_recognition_extra *halExtra,
+        const PhraseRecognitionExtra *extra)
+{
+    halExtra->id = extra->id;
+    halExtra->recognition_modes = extra->recognitionModes;
+    halExtra->confidence_level = extra->confidenceLevel;
+
+    unsigned int i;
+    for (i = 0; i < extra->levels.size() && i < SOUND_TRIGGER_MAX_USERS; i++) {
+        halExtra->levels[i].user_id = extra->levels[i].userId;
+        halExtra->levels[i].level = extra->levels[i].levelPercent;
+    }
+    halExtra->num_levels = i;
+}
+
+struct sound_trigger_recognition_config *SoundTriggerHalImpl::convertRecognitionConfigToHal(
+        const ISoundTriggerHw::RecognitionConfig *config)
+{
+    size_t allocSize = sizeof(struct sound_trigger_recognition_config) + config->data.size();
+    struct sound_trigger_recognition_config *halConfig =
+            static_cast<struct sound_trigger_recognition_config *>(malloc(allocSize));
+
+    LOG_ALWAYS_FATAL_IF(halConfig == NULL,
+                        "malloc failed for size %zu in convertRecognitionConfigToHal",
+                        allocSize);
+
+    halConfig->capture_handle = (audio_io_handle_t)config->captureHandle;
+    halConfig->capture_device = (audio_devices_t)config->captureDevice;
+    halConfig->capture_requested = config->captureRequested;
+
+    unsigned int i;
+    for (i = 0; i < config->phrases.size() && i < SOUND_TRIGGER_MAX_PHRASES; i++) {
+        convertPhraseRecognitionExtraToHal(&halConfig->phrases[i],
+                                  &config->phrases[i]);
+    }
+    halConfig->num_phrases = i;
+
+    halConfig->data_offset = sizeof(struct sound_trigger_recognition_config);
+    halConfig->data_size = config->data.size();
+    uint8_t *dst = reinterpret_cast<uint8_t *>(halConfig) + halConfig->data_offset;
+    const uint8_t *src = reinterpret_cast<const uint8_t *>(&config->data[0]);
+    memcpy(dst, src, config->data.size());
+    return halConfig;
+}
+
+// static
+void SoundTriggerHalImpl::convertSoundModelEventFromHal(ISoundTriggerHwCallback::ModelEvent *event,
+                                                const struct sound_trigger_model_event *halEvent)
+{
+    event->status = (ISoundTriggerHwCallback::SoundModelStatus)halEvent->status;
+    // event->model to be remapped by called
+    event->data.setToExternal(
+            const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(halEvent)) + halEvent->data_offset,
+            halEvent->data_size);
+}
+
+// static
+ISoundTriggerHwCallback::RecognitionEvent *SoundTriggerHalImpl::convertRecognitionEventFromHal(
+                                            const struct sound_trigger_recognition_event *halEvent)
+{
+    ISoundTriggerHwCallback::RecognitionEvent * event;
+
+    if (halEvent->type == SOUND_MODEL_TYPE_KEYPHRASE) {
+        const struct sound_trigger_phrase_recognition_event *halPhraseEvent =
+                reinterpret_cast<const struct sound_trigger_phrase_recognition_event *>(halEvent);
+        ISoundTriggerHwCallback::PhraseRecognitionEvent *phraseEvent =
+                new ISoundTriggerHwCallback::PhraseRecognitionEvent();
+
+        PhraseRecognitionExtra *phraseExtras =
+                new PhraseRecognitionExtra[halPhraseEvent->num_phrases];
+        for (unsigned int i = 0; i < halPhraseEvent->num_phrases; i++) {
+            convertPhraseRecognitionExtraFromHal(&phraseExtras[i],
+                                                 &halPhraseEvent->phrase_extras[i]);
+        }
+        phraseEvent->phraseExtras.setToExternal(phraseExtras, halPhraseEvent->num_phrases);
+        // FIXME: transfer buffer ownership. should have a method for that in hidl_vec
+        phraseEvent->phraseExtras.resize(halPhraseEvent->num_phrases);
+        delete[] phraseExtras;
+        event = reinterpret_cast<ISoundTriggerHwCallback::RecognitionEvent *>(phraseEvent);
+    } else {
+        event = new ISoundTriggerHwCallback::RecognitionEvent();
+    }
+
+    event->status = static_cast<ISoundTriggerHwCallback::RecognitionStatus>(halEvent->status);
+    event->type = static_cast<SoundModelType>(halEvent->type);
+    // event->model to be remapped by called
+    event->captureAvailable = halEvent->capture_available;
+    event->captureSession = halEvent->capture_session;
+    event->captureDelayMs = halEvent->capture_delay_ms;
+    event->capturePreambleMs = halEvent->capture_preamble_ms;
+    event->triggerInData = halEvent->trigger_in_data;
+    event->audioConfig.sampleRateHz = halEvent->audio_config.sample_rate;
+    event->audioConfig.channelMask =
+            (audio::common::V2_0::AudioChannelMask)halEvent->audio_config.channel_mask;
+    event->audioConfig.format = (audio::common::V2_0::AudioFormat)halEvent->audio_config.format;
+    event->data.setToExternal(
+            const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(halEvent)) + halEvent->data_offset,
+            halEvent->data_size);
+
+    return event;
+}
+
+// static
+void SoundTriggerHalImpl::convertPhraseRecognitionExtraFromHal(
+        PhraseRecognitionExtra *extra,
+        const struct sound_trigger_phrase_recognition_extra *halExtra)
+{
+    extra->id = halExtra->id;
+    extra->recognitionModes = halExtra->recognition_modes;
+    extra->confidenceLevel = halExtra->confidence_level;
+
+    ConfidenceLevel *levels =
+            new ConfidenceLevel[halExtra->num_levels];
+    for (unsigned int i = 0; i < halExtra->num_levels; i++) {
+        levels[i].userId = halExtra->levels[i].user_id;
+        levels[i].levelPercent = halExtra->levels[i].level;
+    }
+    extra->levels.setToExternal(levels, halExtra->num_levels);
+    // FIXME: transfer buffer ownership. should have a method for that in hidl_vec
+    extra->levels.resize(halExtra->num_levels);
+    delete[] levels;
+}
+
+ISoundTriggerHw *HIDL_FETCH_ISoundTriggerHw(const char *name)
+{
+    if (name != NULL) {
+        if (strncmp(SOUND_TRIGGER_HARDWARE_MODULE_ID, name,
+                strlen(SOUND_TRIGGER_HARDWARE_MODULE_ID)) != 0) {
+            return NULL;
+        }
+        name = strchr(name, '.');
+        if (name == NULL) {
+            return NULL;
+        }
+        name++;
+    }
+    return new SoundTriggerHalImpl(name);
+}
+} // namespace implementation
+}  // namespace V2_0
+}  // namespace soundtrigger
+}  // namespace hardware
+}  // namespace android
+
+
+
diff --git a/soundtrigger/2.0/default/SoundTriggerHalImpl.h b/soundtrigger/2.0/default/SoundTriggerHalImpl.h
new file mode 100644
index 0000000..4e0d01d
--- /dev/null
+++ b/soundtrigger/2.0/default/SoundTriggerHalImpl.h
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2016 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_SOUNDTRIGGER_V2_0_IMPLEMENTATION_H
+#define ANDROID_HARDWARE_SOUNDTRIGGER_V2_0_IMPLEMENTATION_H
+
+#include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
+#include <android/hardware/soundtrigger/2.0/ISoundTriggerHwCallback.h>
+#include <hidl/Status.h>
+#include <utils/threads.h>
+#include <utils/KeyedVector.h>
+#include <system/sound_trigger.h>
+#include <hardware/sound_trigger.h>
+
+namespace android {
+namespace hardware {
+namespace soundtrigger {
+namespace V2_0 {
+namespace implementation {
+
+using ::android::hardware::audio::common::V2_0::Uuid;
+using ::android::hardware::soundtrigger::V2_0::ISoundTriggerHwCallback;
+
+
+class SoundTriggerHalImpl : public ISoundTriggerHw {
+public:
+        explicit SoundTriggerHalImpl(const char *moduleName = NULL);
+
+        // Methods from ::android::hardware::soundtrigger::V2_0::ISoundTriggerHw follow.
+        Return<void> getProperties(getProperties_cb _hidl_cb)  override;
+        Return<void> loadSoundModel(const ISoundTriggerHw::SoundModel& soundModel,
+                                    const sp<ISoundTriggerHwCallback>& callback,
+                                    ISoundTriggerHwCallback::CallbackCookie cookie,
+                                    loadSoundModel_cb _hidl_cb)  override;
+        Return<void> loadPhraseSoundModel(const ISoundTriggerHw::PhraseSoundModel& soundModel,
+                                    const sp<ISoundTriggerHwCallback>& callback,
+                                    ISoundTriggerHwCallback::CallbackCookie cookie,
+                                    loadPhraseSoundModel_cb _hidl_cb)  override;
+
+        Return<int32_t> unloadSoundModel(SoundModelHandle modelHandle)  override;
+        Return<int32_t> startRecognition(SoundModelHandle modelHandle,
+                                      const ISoundTriggerHw::RecognitionConfig& config,
+                                      const sp<ISoundTriggerHwCallback>& callback,
+                                      ISoundTriggerHwCallback::CallbackCookie cookie)  override;
+        Return<int32_t> stopRecognition(SoundModelHandle modelHandle)  override;
+        Return<int32_t> stopAllRecognitions()  override;
+
+        // RefBase
+        virtual     void        onFirstRef();
+
+        static void soundModelCallback(struct sound_trigger_model_event *halEvent,
+                                       void *cookie);
+        static void recognitionCallback(struct sound_trigger_recognition_event *halEvent,
+                                        void *cookie);
+
+private:
+
+        class SoundModelClient : public RefBase {
+        public:
+            SoundModelClient(uint32_t id, sp<ISoundTriggerHwCallback> callback,
+                             ISoundTriggerHwCallback::CallbackCookie cookie)
+                : mId(id), mCallback(callback), mCookie(cookie) {}
+            virtual ~SoundModelClient() {}
+
+            uint32_t mId;
+            sound_model_handle_t mHalHandle;
+            sp<ISoundTriggerHwCallback> mCallback;
+            ISoundTriggerHwCallback::CallbackCookie mCookie;
+        };
+
+        uint32_t nextUniqueId();
+        void convertUuidFromHal(Uuid *uuid,
+                                const sound_trigger_uuid_t *halUuid);
+        void convertUuidToHal(sound_trigger_uuid_t *halUuid,
+                              const Uuid *uuid);
+        void convertPropertiesFromHal(ISoundTriggerHw::Properties *properties,
+                                      const struct sound_trigger_properties *halProperties);
+        void convertTriggerPhraseToHal(struct sound_trigger_phrase *halTriggerPhrase,
+                                       const ISoundTriggerHw::Phrase *triggerPhrase);
+        // returned HAL sound model must be freed by caller
+        struct sound_trigger_sound_model *convertSoundModelToHal(
+                    const ISoundTriggerHw::SoundModel *soundModel);
+        void convertPhraseRecognitionExtraToHal(
+                struct sound_trigger_phrase_recognition_extra *halExtra,
+                const PhraseRecognitionExtra *extra);
+        // returned recognition config must be freed by caller
+        struct sound_trigger_recognition_config *convertRecognitionConfigToHal(
+                const ISoundTriggerHw::RecognitionConfig *config);
+
+
+        static void convertSoundModelEventFromHal(ISoundTriggerHwCallback::ModelEvent *event,
+                                            const struct sound_trigger_model_event *halEvent);
+        static ISoundTriggerHwCallback::RecognitionEvent *convertRecognitionEventFromHal(
+                                            const struct sound_trigger_recognition_event *halEvent);
+        static void convertPhraseRecognitionExtraFromHal(PhraseRecognitionExtra *extra,
+                                    const struct sound_trigger_phrase_recognition_extra *halExtra);
+
+        int doLoadSoundModel(const ISoundTriggerHw::SoundModel& soundModel,
+                             const sp<ISoundTriggerHwCallback>& callback,
+                             ISoundTriggerHwCallback::CallbackCookie cookie,
+                             uint32_t *modelId);
+
+        virtual             ~SoundTriggerHalImpl();
+
+        const char *                                        mModuleName;
+        struct sound_trigger_hw_device*                     mHwDevice;
+        volatile atomic_uint_fast32_t                       mNextModelId;
+        DefaultKeyedVector<int32_t, sp<SoundModelClient> >  mClients;
+        Mutex                                               mLock;
+};
+
+extern "C" ISoundTriggerHw *HIDL_FETCH_ISoundTriggerHw(const char *name);
+
+}  // namespace implementation
+}  // namespace V2_0
+}  // namespace soundtrigger
+}  // namespace hardware
+}  // namespace android
+
+#endif  // ANDROID_HARDWARE_SOUNDTRIGGER_V2_0_IMPLEMENTATION_H
+
diff --git a/tests/bar/1.0/default/Bar.cpp b/tests/bar/1.0/default/Bar.cpp
index 4433802..34ec087 100644
--- a/tests/bar/1.0/default/Bar.cpp
+++ b/tests/bar/1.0/default/Bar.cpp
@@ -21,10 +21,6 @@
     return mFoo->doThis(param);
 }
 
-Return<void> Bar::doThis(uint32_t param) {
-    return mFoo->doThis(param);
-}
-
 Return<int32_t> Bar::doThatAndReturnSomething(
         int64_t param) {
     return mFoo->doThatAndReturnSomething(param);
@@ -118,6 +114,22 @@
     return mFoo->sendVecVec(_hidl_cb);
 }
 
+Return<void> Bar::haveAVectorOfInterfaces(
+        const hidl_vec<sp<ISimple> > &in,
+        haveAVectorOfInterfaces_cb _hidl_cb) {
+    _hidl_cb(in);
+
+    return Void();
+}
+
+Return<void> Bar::haveAVectorOfGenericInterfaces(
+        const hidl_vec<sp<android::hardware::IBinder> > &in,
+        haveAVectorOfGenericInterfaces_cb _hidl_cb) {
+    _hidl_cb(in);
+
+    return Void();
+}
+
 // Methods from ::android::hardware::tests::bar::V1_0::IBar follow.
 Return<void> Bar::thisIsNew()  {
     ALOGI("SERVER(Bar) thisIsNew");
diff --git a/tests/bar/1.0/default/Bar.h b/tests/bar/1.0/default/Bar.h
index 58d9f9a..d2c2635 100644
--- a/tests/bar/1.0/default/Bar.h
+++ b/tests/bar/1.0/default/Bar.h
@@ -16,6 +16,7 @@
 using ::android::hardware::tests::foo::V1_0::Abc;
 using ::android::hardware::tests::foo::V1_0::IFoo;
 using ::android::hardware::tests::foo::V1_0::IFooCallback;
+using ::android::hardware::tests::foo::V1_0::ISimple;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
 using ::android::hardware::hidl_vec;
@@ -28,7 +29,6 @@
 
     // Methods from ::android::hardware::tests::foo::V1_0::IFoo follow.
     virtual Return<void> doThis(float param)  override;
-    virtual Return<void> doThis(uint32_t param)  override;
     virtual Return<int32_t> doThatAndReturnSomething(int64_t param)  override;
     virtual Return<double> doQuiteABit(int32_t a, int64_t b, float c, double d)  override;
     virtual Return<void> doSomethingElse(const hidl_array<int32_t, 15 /* 15 */>& param, doSomethingElse_cb _hidl_cb)  override;
@@ -49,6 +49,14 @@
     virtual Return<void> sendVec(const hidl_vec<uint8_t>& data, sendVec_cb _hidl_cb)  override;
     virtual Return<void> sendVecVec(sendVecVec_cb _hidl_cb)  override;
 
+    Return<void> haveAVectorOfInterfaces(
+            const hidl_vec<sp<ISimple> > &in,
+            haveAVectorOfInterfaces_cb _hidl_cb) override;
+
+    Return<void> haveAVectorOfGenericInterfaces(
+            const hidl_vec<sp<android::hardware::IBinder> > &in,
+            haveAVectorOfGenericInterfaces_cb _hidl_cb) override;
+
     // Methods from ::android::hardware::tests::bar::V1_0::IBar follow.
     Return<void> thisIsNew()  override;
 
diff --git a/tests/baz/1.0/IBase.hal b/tests/baz/1.0/IBase.hal
index 3f18d41..add4153 100644
--- a/tests/baz/1.0/IBase.hal
+++ b/tests/baz/1.0/IBase.hal
@@ -76,6 +76,9 @@
 
     someMethodWithVectorOfArray(VectorOfArray in) generates (VectorOfArray out);
 
+    someMethodTakingAVectorOfArray(vec<MacAddress> in)
+        generates (vec<MacAddress> out);
+
     transpose(StringMatrix5x3 in) generates (StringMatrix3x5 out);
     transpose2(ThreeStrings[5] in) generates (FiveStrings[3] out);
 };
diff --git a/tests/foo/1.0/Android.bp b/tests/foo/1.0/Android.bp
index 1fbb7bd..e7bcad2 100644
--- a/tests/foo/1.0/Android.bp
+++ b/tests/foo/1.0/Android.bp
@@ -9,6 +9,7 @@
         "IFoo.hal",
         "IFooCallback.hal",
         "IMyTypes.hal",
+        "ISimple.hal",
         "ITheirTypes.hal",
     ],
     out: [
@@ -16,6 +17,7 @@
         "android/hardware/tests/foo/1.0/FooAll.cpp",
         "android/hardware/tests/foo/1.0/FooCallbackAll.cpp",
         "android/hardware/tests/foo/1.0/MyTypesAll.cpp",
+        "android/hardware/tests/foo/1.0/SimpleAll.cpp",
         "android/hardware/tests/foo/1.0/TheirTypesAll.cpp",
     ],
 }
@@ -29,6 +31,7 @@
         "IFoo.hal",
         "IFooCallback.hal",
         "IMyTypes.hal",
+        "ISimple.hal",
         "ITheirTypes.hal",
     ],
     out: [
@@ -48,6 +51,11 @@
         "android/hardware/tests/foo/1.0/BnMyTypes.h",
         "android/hardware/tests/foo/1.0/BpMyTypes.h",
         "android/hardware/tests/foo/1.0/BsMyTypes.h",
+        "android/hardware/tests/foo/1.0/ISimple.h",
+        "android/hardware/tests/foo/1.0/IHwSimple.h",
+        "android/hardware/tests/foo/1.0/BnSimple.h",
+        "android/hardware/tests/foo/1.0/BpSimple.h",
+        "android/hardware/tests/foo/1.0/BsSimple.h",
         "android/hardware/tests/foo/1.0/ITheirTypes.h",
         "android/hardware/tests/foo/1.0/IHwTheirTypes.h",
         "android/hardware/tests/foo/1.0/BnTheirTypes.h",
diff --git a/tests/foo/1.0/IFoo.hal b/tests/foo/1.0/IFoo.hal
index 614f1e4..2afaec1 100644
--- a/tests/foo/1.0/IFoo.hal
+++ b/tests/foo/1.0/IFoo.hal
@@ -18,6 +18,7 @@
 
 import IFooCallback;
 import IMyTypes.SomeStruct;
+import ISimple;
 import ITheirTypes.FloatArray;
 
 interface IFoo {
@@ -80,7 +81,6 @@
     };
 
     doThis(float param);
-    doThis(uint32_t param);
     doThatAndReturnSomething(int64_t param) generates (int32_t result);
     doQuiteABit(int32_t a, int64_t b, float c, double d) generates (double something);
     doSomethingElse(int32_t[15] param) generates (int32_t[32] something);
@@ -107,4 +107,9 @@
     sendVec(vec<uint8_t> data) generates (vec<uint8_t> data);
 
     sendVecVec() generates (vec<vec<uint8_t>> vecvec);
+
+    haveAVectorOfInterfaces(vec<ISimple> in) generates (vec<ISimple> out);
+
+    haveAVectorOfGenericInterfaces(vec<interface> in)
+        generates (vec<interface> out);
 };
diff --git a/tests/foo/1.0/ISimple.hal b/tests/foo/1.0/ISimple.hal
new file mode 100644
index 0000000..92e9d95
--- /dev/null
+++ b/tests/foo/1.0/ISimple.hal
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2016 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.tests.foo@1.0;
+
+interface ISimple {
+    getCookie() generates (int32_t cookie);
+};
diff --git a/tests/foo/1.0/default/Android.bp b/tests/foo/1.0/default/Android.bp
index a2acd14..185e5ea 100644
--- a/tests/foo/1.0/default/Android.bp
+++ b/tests/foo/1.0/default/Android.bp
@@ -6,13 +6,12 @@
     srcs: [
         "Foo.cpp",
         "FooCallback.cpp",
-        "MyTypes.cpp",
-        "TheirTypes.cpp",
     ],
 
     shared_libs: [
         "libbase",
         "libhidl",
+        "libfootest",
         "libhwbinder",
         "liblog",
         "libutils",
diff --git a/tests/foo/1.0/default/Foo.cpp b/tests/foo/1.0/default/Foo.cpp
index 81aa78b..235a12d 100644
--- a/tests/foo/1.0/default/Foo.cpp
+++ b/tests/foo/1.0/default/Foo.cpp
@@ -4,6 +4,7 @@
 #include "Foo.h"
 #include "FooCallback.h"
 #include <android-base/logging.h>
+#include <hidl-test/FooHelper.h>
 #include <inttypes.h>
 #include <utils/Timers.h>
 
@@ -21,11 +22,6 @@
     return Void();
 }
 
-Return<void> Foo::doThis(uint32_t param) {
-    ALOGI("SERVER(Foo) doThis (int) (%d)", param);
-    return Void();
-}
-
 Return<int32_t> Foo::doThatAndReturnSomething(
         int64_t param) {
     LOG(INFO) << "SERVER(Foo) doThatAndReturnSomething(" << param << ")";
@@ -113,7 +109,7 @@
 
         ALOGI("SERVER(Foo) callMe %p calling IFooCallback::heyItsYouIsntIt, " \
               "should block for %" PRId64 " seconds", cb.get(),
-              FooCallback::DELAY_S);
+              DELAY_S);
         c[1] = systemTime();
         bool answer = cb->heyItsYouIsntIt(cb);
         c[1] = systemTime() - c[1];
@@ -206,74 +202,6 @@
     return Void();
 }
 
-// NOTE: duplicated code in hidl_test
-using std::to_string;
-
-static std::string to_string(const IFoo::StringMatrix5x3 &M);
-static std::string to_string(const IFoo::StringMatrix3x5 &M);
-static std::string to_string(const hidl_string &s);
-
-template<typename T>
-static std::string to_string(const T *elems, size_t n) {
-    std::string out;
-    out = "[";
-    for (size_t i = 0; i < n; ++i) {
-        if (i > 0) {
-            out += ", ";
-        }
-        out += to_string(elems[i]);
-    }
-    out += "]";
-
-    return out;
-}
-
-template<typename T, size_t SIZE>
-static std::string to_string(const hidl_array<T, SIZE> &array) {
-    return to_string(&array[0], SIZE);
-}
-
-template<typename T, size_t SIZE1, size_t SIZE2>
-static std::string to_string(const hidl_array<T, SIZE1, SIZE2> &array) {
-    std::string out;
-    out = "[";
-    for (size_t i = 0; i < SIZE1; ++i) {
-        if (i > 0) {
-            out += ", ";
-        }
-
-        out += "[";
-        for (size_t j = 0; j < SIZE2; ++j) {
-            if (j > 0) {
-                out += ", ";
-            }
-
-            out += to_string(array[i][j]);
-        }
-        out += "]";
-    }
-    out += "]";
-
-    return out;
-}
-
-template<typename T>
-static std::string to_string(const hidl_vec<T> &vec) {
-    return to_string(&vec[0], vec.size());
-}
-
-static std::string to_string(const IFoo::StringMatrix5x3 &M) {
-    return to_string(M.s);
-}
-
-static std::string to_string(const IFoo::StringMatrix3x5 &M) {
-    return to_string(M.s);
-}
-
-static std::string to_string(const hidl_string &s) {
-    return std::string("'") + s.c_str() + "'";
-}
-
 Return<void> Foo::transposeMe(
         const hidl_array<float, 3, 5> &in, transposeMe_cb _cb) {
     ALOGI("SERVER(Foo) transposeMe(%s)", to_string(in).c_str());
@@ -291,48 +219,6 @@
 
     return Void();
 }
-// end duplicated code
-
-static std::string QuuxToString(const IFoo::Quux &val) {
-    std::string s;
-
-    s = "Quux(first='";
-    s += val.first.c_str();
-    s += "', last='";
-    s += val.last.c_str();
-    s += "')";
-
-    return s;
-}
-
-static std::string MultiDimensionalToString(const IFoo::MultiDimensional &val) {
-    std::string s;
-
-    s += "MultiDimensional(";
-
-    s += "quuxMatrix=[";
-
-    size_t k = 0;
-    for (size_t i = 0; i < 5; ++i) {
-        if (i > 0) {
-            s += ", ";
-        }
-
-        s += "[";
-        for (size_t j = 0; j < 3; ++j, ++k) {
-            if (j > 0) {
-                s += ", ";
-            }
-
-            s += QuuxToString(val.quuxMatrix[i][j]);
-        }
-    }
-    s += "]";
-
-    s += ")";
-
-    return s;
-}
 
 Return<void> Foo::callingDrWho(
         const MultiDimensional &in, callingDrWho_cb _hidl_cb) {
@@ -396,6 +282,21 @@
     return Void();
 }
 
+Return<void> Foo::haveAVectorOfInterfaces(
+        const hidl_vec<sp<ISimple> > &in,
+        haveAVectorOfInterfaces_cb _hidl_cb) {
+    _hidl_cb(in);
+
+    return Void();
+}
+
+Return<void> Foo::haveAVectorOfGenericInterfaces(
+        const hidl_vec<sp<android::hardware::IBinder> > &in,
+        haveAVectorOfGenericInterfaces_cb _hidl_cb) {
+    _hidl_cb(in);
+
+    return Void();
+}
 
 IFoo* HIDL_FETCH_IFoo(const char* /* name */) {
     return new Foo();
diff --git a/tests/foo/1.0/default/Foo.h b/tests/foo/1.0/default/Foo.h
index 00a29f5..b3785d2 100644
--- a/tests/foo/1.0/default/Foo.h
+++ b/tests/foo/1.0/default/Foo.h
@@ -15,6 +15,7 @@
 using ::android::hardware::tests::foo::V1_0::Abc;
 using ::android::hardware::tests::foo::V1_0::IFoo;
 using ::android::hardware::tests::foo::V1_0::IFooCallback;
+using ::android::hardware::tests::foo::V1_0::ISimple;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
 using ::android::hardware::hidl_vec;
@@ -24,7 +25,6 @@
 struct Foo : public IFoo {
     // Methods from ::android::hardware::tests::foo::V1_0::IFoo follow.
     virtual Return<void> doThis(float param)  override;
-    virtual Return<void> doThis(uint32_t param)  override;
     virtual Return<int32_t> doThatAndReturnSomething(int64_t param)  override;
     virtual Return<double> doQuiteABit(int32_t a, int64_t b, float c, double d)  override;
     virtual Return<void> doSomethingElse(const hidl_array<int32_t, 15 /* 15 */>& param, doSomethingElse_cb _hidl_cb)  override;
@@ -45,6 +45,13 @@
     virtual Return<void> sendVec(const hidl_vec<uint8_t>& data, sendVec_cb _hidl_cb)  override;
     virtual Return<void> sendVecVec(sendVecVec_cb _hidl_cb)  override;
 
+    Return<void> haveAVectorOfInterfaces(
+            const hidl_vec<sp<ISimple> > &in,
+            haveAVectorOfInterfaces_cb _hidl_cb) override;
+
+    Return<void> haveAVectorOfGenericInterfaces(
+            const hidl_vec<sp<android::hardware::IBinder> > &in,
+            haveAVectorOfGenericInterfaces_cb _hidl_cb) override;
 };
 
 extern "C" IFoo* HIDL_FETCH_IFoo(const char* name);
diff --git a/tests/foo/1.0/default/FooCallback.cpp b/tests/foo/1.0/default/FooCallback.cpp
index 08d3ce0..e4704f2 100644
--- a/tests/foo/1.0/default/FooCallback.cpp
+++ b/tests/foo/1.0/default/FooCallback.cpp
@@ -1,6 +1,11 @@
+
+#define LOG_TAG "hidl_test"
+
 #include "FooCallback.h"
 #include <android-base/logging.h>
+#include <hidl-test/FooHelper.h>
 #include <inttypes.h>
+#include <utils/Timers.h>
 
 namespace android {
 namespace hardware {
@@ -9,68 +14,111 @@
 namespace V1_0 {
 namespace implementation {
 
+enum {
+    NOT_REPORTED = -1LL
+};
+
+FooCallback::FooCallback()
+        : mLock{}, mCond{} {
+    for (size_t i = 0; i < invokeInfo.size(); i++) {
+        invokeInfo[i].invoked = false;
+        invokeInfo[i].timeNs = NOT_REPORTED;
+        invokeInfo[i].callerBlockedNs = NOT_REPORTED;
+    }
+}
+
 Return<void> FooCallback::heyItsYou(
         const sp<IFooCallback> &_cb) {
     nsecs_t start = systemTime();
-    ALOGI("SERVER(FooCallback) heyItsYou cb = %p", _cb.get());
-    mLock.lock();
-    invokeInfo[0].invoked = true;
-    invokeInfo[0].timeNs = systemTime() - start;
-    mCond.signal();
-    mLock.unlock();
+    ALOGI("SERVER(FooCallback) 1: heyItsYou cb = %p", _cb.get());
+    nsecs_t end = systemTime();
+    {
+        Mutex::Autolock lock(mLock);
+        invokeInfo[0].invoked = true;
+        invokeInfo[0].timeNs = end - start;
+        mCond.signal();
+    }
+    ALOGI("SERVER(FooCallback) 2: heyItsYou returned");
     return Void();
 }
 
 Return<bool> FooCallback::heyItsYouIsntIt(const sp<IFooCallback> &_cb) {
     nsecs_t start = systemTime();
-    ALOGI("SERVER(FooCallback) heyItsYouIsntIt cb = %p sleeping for %" PRId64 " seconds", _cb.get(), DELAY_S);
+    ALOGI("SERVER(FooCallback) 3: heyItsYouIsntIt cb = %p sleeping for %" PRId64 " seconds", _cb.get(), DELAY_S);
     sleep(DELAY_S);
-    ALOGI("SERVER(FooCallback) heyItsYouIsntIt cb = %p responding", _cb.get());
-    mLock.lock();
-    invokeInfo[1].invoked = true;
-    invokeInfo[1].timeNs = systemTime() - start;
-    mCond.signal();
-    mLock.unlock();
+    ALOGI("SERVER(FooCallback) 4: heyItsYouIsntIt cb = %p responding", _cb.get());
+    nsecs_t end = systemTime();
+    {
+        Mutex::Autolock lock(mLock);
+        invokeInfo[1].invoked = true;
+        invokeInfo[1].timeNs = end - start;
+        mCond.signal();
+    }
+    ALOGI("SERVER(FooCallback) 5: heyItsYouIsntIt cb = %p responding", _cb.get());
     return true;
 }
 
 Return<void> FooCallback::heyItsTheMeaningOfLife(uint8_t tmol) {
     nsecs_t start = systemTime();
-    ALOGI("SERVER(FooCallback) heyItsTheMeaningOfLife = %d sleeping for %" PRId64 " seconds", tmol, DELAY_S);
+    ALOGI("SERVER(FooCallback) 6.1: heyItsTheMeaningOfLife = %d sleeping for %" PRId64 " seconds", tmol, DELAY_S);
     sleep(DELAY_S);
-    ALOGI("SERVER(FooCallback) heyItsTheMeaningOfLife = %d done sleeping", tmol);
-    mLock.lock();
-    invokeInfo[2].invoked = true;
-    invokeInfo[2].timeNs = systemTime() - start;
-    mCond.signal();
-    mLock.unlock();
+    ALOGI("SERVER(FooCallback) 6.2: heyItsTheMeaningOfLife = %d done sleeping", tmol);
+    nsecs_t end = systemTime();
+    {
+        Mutex::Autolock lock(mLock);
+        invokeInfo[2].invoked = true;
+        invokeInfo[2].timeNs = end - start;
+        mCond.signal();
+    }
+    ALOGI("SERVER(FooCallback) 6.3: heyItsTheMeaningOfLife returned");
     return Void();
 }
 
 Return<void> FooCallback::reportResults(int64_t ns, reportResults_cb cb) {
-    ALOGI("SERVER(FooCallback) reportResults(%" PRId64 " seconds)", nanoseconds_to_seconds(ns));
+    ALOGI("SERVER(FooCallback) 8.1: reportResults(%" PRId64 " seconds)", nanoseconds_to_seconds(ns));
     nsecs_t leftToWaitNs = ns;
-    mLock.lock();
-    while (!(invokeInfo[0].invoked && invokeInfo[1].invoked && invokeInfo[2].invoked) &&
-           leftToWaitNs > 0) {
-      nsecs_t start = systemTime();
-      ::android::status_t rc = mCond.waitRelative(mLock, leftToWaitNs);
-      if (rc != ::android::OK) {
-          ALOGI("SERVER(FooCallback)::reportResults(%" PRId64 " ns) Condition::waitRelative(%" PRId64 ") returned error (%d)", ns, leftToWaitNs, rc);
-          break;
-      }
-      ALOGI("SERVER(FooCallback)::reportResults(%" PRId64 " ns) Condition::waitRelative was signalled", ns);
-      leftToWaitNs -= systemTime() - start;
+    bool cond;
+    {
+        Mutex::Autolock lock(mLock);
+        while ((cond = ((!invokeInfo[0].invoked ||
+                !invokeInfo[1].invoked ||
+                !invokeInfo[2].invoked ||
+                invokeInfo[0].callerBlockedNs == NOT_REPORTED ||
+                invokeInfo[1].callerBlockedNs == NOT_REPORTED ||
+                invokeInfo[2].callerBlockedNs == NOT_REPORTED)   &&
+               leftToWaitNs > 0))) {
+            nsecs_t start = systemTime();
+            ::android::status_t rc = mCond.waitRelative(mLock, leftToWaitNs);
+            if (rc != ::android::OK) {
+                ALOGW("SERVER(FooCallback)::reportResults(%" PRId64 " ns) Condition::waitRelative(%" PRId64 ") returned error (%d)", ns, leftToWaitNs, rc);
+                if (rc == -ETIMEDOUT) {
+                    // time's up
+                    leftToWaitNs = -1;
+                }
+                break;
+            }
+            ALOGI("SERVER(FooCallback)::reportResults(%" PRId64 " ns) Condition::waitRelative was signalled", ns);
+            leftToWaitNs -= systemTime() - start;
+        }
     }
-    mLock.unlock();
+    ALOGI("SERVER(FooCallback) 8.2: reportResults returned;"
+            "invoked? %d, %d, %d; leftToWaitNs = %" PRId64 "; cond = %d",
+            invokeInfo[0].invoked, invokeInfo[1].invoked, invokeInfo[2].invoked,
+            leftToWaitNs, cond);
     cb(leftToWaitNs, invokeInfo);
     return Void();
 }
 
 Return<void> FooCallback::youBlockedMeFor(const hidl_array<int64_t, 3> &ns) {
-    for (size_t i = 0; i < 3; i++) {
-        invokeInfo[i].callerBlockedNs = ns[i];
+    ALOGI("SERVER(FooCallback) 7.1: youBlockedMeFor");
+    {
+        Mutex::Autolock lock(mLock);
+        for (size_t i = 0; i < 3; i++) {
+            invokeInfo[i].callerBlockedNs = ns[i];
+        }
+        mCond.signal();
     }
+    ALOGI("SERVER(FooCallback) 7.2: returned");
     return Void();
 }
 
diff --git a/tests/foo/1.0/default/FooCallback.h b/tests/foo/1.0/default/FooCallback.h
index 6c284ca..00233b5 100644
--- a/tests/foo/1.0/default/FooCallback.h
+++ b/tests/foo/1.0/default/FooCallback.h
@@ -6,7 +6,6 @@
 #include <hidl/MQDescriptor.h>
 
 #include <utils/Condition.h>
-#include <utils/Timers.h>
 namespace android {
 namespace hardware {
 namespace tests {
@@ -22,7 +21,7 @@
 using ::android::sp;
 
 struct FooCallback : public IFooCallback {
-    FooCallback() : mLock{}, mCond{} {}
+    FooCallback();
     // Methods from ::android::hardware::tests::foo::V1_0::IFooCallback follow.
     Return<void> heyItsYou(const sp<IFooCallback>& cb)  override;
     Return<bool> heyItsYouIsntIt(const sp<IFooCallback>& cb)  override;
@@ -30,11 +29,6 @@
     Return<void> reportResults(int64_t ns, reportResults_cb _hidl_cb)  override;
     Return<void> youBlockedMeFor(const hidl_array<int64_t, 3 /* 3 */>& callerBlockedInfo)  override;
 
-    static constexpr nsecs_t DELAY_S = 1;
-    static constexpr nsecs_t DELAY_NS = seconds_to_nanoseconds(DELAY_S);
-    static constexpr nsecs_t TOLERANCE_NS = milliseconds_to_nanoseconds(10);
-    static constexpr nsecs_t ONEWAY_TOLERANCE_NS = milliseconds_to_nanoseconds(1);
-
     hidl_array<InvokeInfo, 3> invokeInfo;
     Mutex mLock;
     Condition mCond;
diff --git a/tests/foo/1.0/default/MyTypes.cpp b/tests/foo/1.0/default/MyTypes.cpp
deleted file mode 100644
index 0d1a458..0000000
--- a/tests/foo/1.0/default/MyTypes.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "MyTypes.h"
-
-namespace android {
-namespace hardware {
-namespace tests {
-namespace foo {
-namespace V1_0 {
-namespace implementation {
-
-// Methods from ::android::hardware::tests::foo::V1_0::IMyTypes follow.
-
-IMyTypes* HIDL_FETCH_IMyTypes(const char* /* name */) {
-    return new MyTypes();
-}
-
-} // namespace implementation
-}  // namespace V1_0
-}  // namespace foo
-}  // namespace tests
-}  // namespace hardware
-}  // namespace android
diff --git a/tests/foo/1.0/default/MyTypes.h b/tests/foo/1.0/default/MyTypes.h
deleted file mode 100644
index 6e9a3e1..0000000
--- a/tests/foo/1.0/default/MyTypes.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef HIDL_GENERATED_android_hardware_tests_foo_V1_0_MyTypes_H_
-#define HIDL_GENERATED_android_hardware_tests_foo_V1_0_MyTypes_H_
-
-#include <android/hardware/tests/foo/1.0/IMyTypes.h>
-#include <hidl/Status.h>
-
-#include <hidl/MQDescriptor.h>
-namespace android {
-namespace hardware {
-namespace tests {
-namespace foo {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::tests::foo::V1_0::IMyTypes;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-struct MyTypes : public IMyTypes {
-    // Methods from ::android::hardware::tests::foo::V1_0::IMyTypes follow.
-
-};
-
-extern "C" IMyTypes* HIDL_FETCH_IMyTypes(const char* name);
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace foo
-}  // namespace tests
-}  // namespace hardware
-}  // namespace android
-
-#endif  // HIDL_GENERATED_android_hardware_tests_foo_V1_0_MyTypes_H_
diff --git a/tests/foo/1.0/default/TheirTypes.cpp b/tests/foo/1.0/default/TheirTypes.cpp
deleted file mode 100644
index 0f678f0..0000000
--- a/tests/foo/1.0/default/TheirTypes.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "TheirTypes.h"
-
-namespace android {
-namespace hardware {
-namespace tests {
-namespace foo {
-namespace V1_0 {
-namespace implementation {
-
-// Methods from ::android::hardware::tests::foo::V1_0::ITheirTypes follow.
-
-ITheirTypes* HIDL_FETCH_ITheirTypes(const char* /* name */) {
-    return new TheirTypes();
-}
-
-} // namespace implementation
-}  // namespace V1_0
-}  // namespace foo
-}  // namespace tests
-}  // namespace hardware
-}  // namespace android
diff --git a/tests/foo/1.0/default/TheirTypes.h b/tests/foo/1.0/default/TheirTypes.h
deleted file mode 100644
index 24ade70..0000000
--- a/tests/foo/1.0/default/TheirTypes.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef HIDL_GENERATED_android_hardware_tests_foo_V1_0_TheirTypes_H_
-#define HIDL_GENERATED_android_hardware_tests_foo_V1_0_TheirTypes_H_
-
-#include <android/hardware/tests/foo/1.0/ITheirTypes.h>
-#include <hidl/Status.h>
-
-#include <hidl/MQDescriptor.h>
-namespace android {
-namespace hardware {
-namespace tests {
-namespace foo {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::tests::foo::V1_0::ITheirTypes;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-struct TheirTypes : public ITheirTypes {
-    // Methods from ::android::hardware::tests::foo::V1_0::ITheirTypes follow.
-
-};
-
-extern "C" ITheirTypes* HIDL_FETCH_ITheirTypes(const char* name);
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace foo
-}  // namespace tests
-}  // namespace hardware
-}  // namespace android
-
-#endif  // HIDL_GENERATED_android_hardware_tests_foo_V1_0_TheirTypes_H_
diff --git a/tests/foo/1.0/default/lib/Android.bp b/tests/foo/1.0/default/lib/Android.bp
new file mode 100644
index 0000000..c7ad57e
--- /dev/null
+++ b/tests/foo/1.0/default/lib/Android.bp
@@ -0,0 +1,15 @@
+cc_library_shared {
+    name: "libfootest",
+    srcs: [
+        "FooHelper.cpp"
+    ],
+
+    shared_libs: [
+        "libhidl",
+        "libhwbinder",
+        "android.hardware.tests.foo@1.0",
+    ],
+    local_include_dirs: ["include/hidl-test"],
+    export_include_dirs: ["include"],
+
+}
diff --git a/tests/foo/1.0/default/lib/FooHelper.cpp b/tests/foo/1.0/default/lib/FooHelper.cpp
new file mode 100644
index 0000000..8c5ff94
--- /dev/null
+++ b/tests/foo/1.0/default/lib/FooHelper.cpp
@@ -0,0 +1,57 @@
+#include "FooHelper.h"
+
+namespace android {
+
+std::string to_string(const IFoo::StringMatrix5x3 &M) {
+    return to_string(M.s);
+}
+
+std::string to_string(const IFoo::StringMatrix3x5 &M) {
+    return to_string(M.s);
+}
+
+std::string to_string(const hidl_string &s) {
+    return std::string("'") + s.c_str() + "'";
+}
+
+std::string QuuxToString(const IFoo::Quux &val) {
+    std::string s;
+
+    s = "Quux(first='";
+    s += val.first.c_str();
+    s += "', last='";
+    s += val.last.c_str();
+    s += "')";
+
+    return s;
+}
+
+std::string MultiDimensionalToString(const IFoo::MultiDimensional &val) {
+    std::string s;
+
+    s += "MultiDimensional(";
+
+    s += "quuxMatrix=[";
+
+    size_t k = 0;
+    for (size_t i = 0; i < 5; ++i) {
+        if (i > 0) {
+            s += ", ";
+        }
+
+        s += "[";
+        for (size_t j = 0; j < 3; ++j, ++k) {
+            if (j > 0) {
+                s += ", ";
+            }
+
+            s += QuuxToString(val.quuxMatrix[i][j]);
+        }
+    }
+    s += "]";
+
+    s += ")";
+
+    return s;
+}
+} // namespace android
diff --git a/tests/foo/1.0/default/lib/include/hidl-test/FooHelper.h b/tests/foo/1.0/default/lib/include/hidl-test/FooHelper.h
new file mode 100644
index 0000000..09b0557
--- /dev/null
+++ b/tests/foo/1.0/default/lib/include/hidl-test/FooHelper.h
@@ -0,0 +1,79 @@
+#ifndef ANDROID_HIDL_TEST_FOO_HELPER_H
+#define ANDROID_HIDL_TEST_FOO_HELPER_H
+#include <string>
+#include <android/hardware/tests/foo/1.0/IFoo.h>
+#include <utils/Timers.h>
+
+namespace android {
+
+using std::to_string;
+using hardware::hidl_string;
+using hardware::hidl_vec;
+using hardware::hidl_array;
+using hardware::tests::foo::V1_0::IFoo;
+
+static constexpr nsecs_t DELAY_S = 1;
+static constexpr nsecs_t DELAY_NS = seconds_to_nanoseconds(DELAY_S);
+static constexpr nsecs_t TOLERANCE_NS = milliseconds_to_nanoseconds(10);
+static constexpr nsecs_t ONEWAY_TOLERANCE_NS = milliseconds_to_nanoseconds(1);
+
+std::string to_string(const IFoo::StringMatrix5x3 &M);
+std::string to_string(const IFoo::StringMatrix3x5 &M);
+// Add quotes around s. For testing purposes only.
+std::string to_string(const hidl_string &s);
+
+template<typename T>
+std::string to_string(const T *elems, size_t n) {
+    std::string out;
+    out = "[";
+    for (size_t i = 0; i < n; ++i) {
+        if (i > 0) {
+            out += ", ";
+        }
+        out += to_string(elems[i]);
+    }
+    out += "]";
+
+    return out;
+}
+
+template<typename T, size_t SIZE>
+std::string to_string(const hidl_array<T, SIZE> &array) {
+    return to_string(&array[0], SIZE);
+}
+
+template<typename T, size_t SIZE1, size_t SIZE2>
+std::string to_string(const hidl_array<T, SIZE1, SIZE2> &array) {
+    std::string out;
+    out = "[";
+    for (size_t i = 0; i < SIZE1; ++i) {
+        if (i > 0) {
+            out += ", ";
+        }
+
+        out += "[";
+        for (size_t j = 0; j < SIZE2; ++j) {
+            if (j > 0) {
+                out += ", ";
+            }
+
+            out += to_string(array[i][j]);
+        }
+        out += "]";
+    }
+    out += "]";
+
+    return out;
+}
+
+template<typename T>
+std::string to_string(const hidl_vec<T> &vec) {
+    return to_string(&vec[0], vec.size());
+}
+
+std::string QuuxToString(const IFoo::Quux &val);
+
+std::string MultiDimensionalToString(const IFoo::MultiDimensional &val);
+
+} // namespace android
+#endif // ANDROID_HIDL_TEST_TEST_HELPER_H
diff --git a/tests/pointer/1.0/default/Android.bp b/tests/pointer/1.0/default/Android.bp
index cee6c91..081b7aa 100644
--- a/tests/pointer/1.0/default/Android.bp
+++ b/tests/pointer/1.0/default/Android.bp
@@ -11,6 +11,7 @@
     shared_libs: [
         "libbase",
         "libhidl",
+        "libpointertest",
         "libhwbinder",
         "liblog",
         "libutils",
diff --git a/tests/pointer/1.0/default/Graph.cpp b/tests/pointer/1.0/default/Graph.cpp
index a43df81..5aa2243 100644
--- a/tests/pointer/1.0/default/Graph.cpp
+++ b/tests/pointer/1.0/default/Graph.cpp
@@ -1,5 +1,6 @@
 #include "Graph.h"
 #include <android-base/logging.h>
+#include <hidl-test/PointerHelper.h>
 
 #define PUSH_ERROR_IF(__cond__) if(__cond__) { errors.push_back(std::to_string(__LINE__) + ": " + #__cond__); }
 
@@ -10,38 +11,6 @@
 namespace V1_0 {
 namespace implementation {
 
-static void simpleGraph(IGraph::Graph& g) {
-    g.nodes.resize(2);
-    g.edges.resize(1);
-    g.nodes[0].data = 10;
-    g.nodes[1].data = 20;
-    g.edges[0].left = &g.nodes[0];
-    g.edges[0].right = &g.nodes[1];
-}
-
-static bool isSimpleGraph(const IGraph::Graph &g) {
-    if(g.nodes.size() != 2) return false;
-    if(g.edges.size() != 1) return false;
-    if(g.nodes[0].data != 10) return false;
-    if(g.nodes[1].data != 20) return false;
-    if(g.edges[0].left != &g.nodes[0]) return false;
-    if(g.edges[0].right != &g.nodes[1]) return false;
-    return true;
-}
-
-static void logSimpleGraph(const char *prefix, const IGraph::Graph& g) {
-    ALOGI("%s Graph %p, %d nodes, %d edges", prefix, &g, (int)g.nodes.size(), (int)g.edges.size());
-    std::ostringstream os;
-    for(size_t i = 0; i < g.nodes.size(); i++)
-      os << &g.nodes[i] << " = " << g.nodes[i].data << ", ";
-    ALOGI("%s Nodes: [%s]", prefix, os.str().c_str());
-    os.str("");
-    os.clear();
-    for(size_t i = 0; i < g.edges.size(); i++)
-      os << g.edges[i].left << " -> " << g.edges[i].right << ", ";
-    ALOGI("%s Edges: [%s]", prefix, os.str().c_str());
-}
-
 // Methods from ::android::hardware::tests::pointer::V1_0::IGraph follow.
 Return<void> Graph::passAGraph(const IGraph::Graph& g) {
     ALOGI("SERVER(Graph) passAGraph start.");
diff --git a/tests/pointer/1.0/default/lib/Android.bp b/tests/pointer/1.0/default/lib/Android.bp
new file mode 100644
index 0000000..efc61df
--- /dev/null
+++ b/tests/pointer/1.0/default/lib/Android.bp
@@ -0,0 +1,17 @@
+cc_library_shared {
+    name: "libpointertest",
+    srcs: [
+        "PointerHelper.cpp"
+    ],
+
+    shared_libs: [
+        "libbase",
+        "libhidl",
+        "libhwbinder",
+        "liblog",
+        "android.hardware.tests.pointer@1.0",
+    ],
+    local_include_dirs: ["include/hidl-test"],
+    export_include_dirs: ["include"],
+
+}
diff --git a/tests/pointer/1.0/default/lib/PointerHelper.cpp b/tests/pointer/1.0/default/lib/PointerHelper.cpp
new file mode 100644
index 0000000..ed7d49a
--- /dev/null
+++ b/tests/pointer/1.0/default/lib/PointerHelper.cpp
@@ -0,0 +1,37 @@
+#define LOG_TAG "hidl_test"
+#include <android-base/logging.h>
+#include "PointerHelper.h"
+namespace android {
+
+void simpleGraph(IGraph::Graph& g) {
+    g.nodes.resize(2);
+    g.edges.resize(1);
+    g.nodes[0].data = 10;
+    g.nodes[1].data = 20;
+    g.edges[0].left = &g.nodes[0];
+    g.edges[0].right = &g.nodes[1];
+}
+
+bool isSimpleGraph(const IGraph::Graph &g) {
+    if(g.nodes.size() != 2) return false;
+    if(g.edges.size() != 1) return false;
+    if(g.nodes[0].data != 10) return false;
+    if(g.nodes[1].data != 20) return false;
+    if(g.edges[0].left != &g.nodes[0]) return false;
+    if(g.edges[0].right != &g.nodes[1]) return false;
+    return true;
+}
+
+void logSimpleGraph(const char *prefix, const IGraph::Graph& g) {
+    ALOGI("%s Graph %p, %d nodes, %d edges", prefix, &g, (int)g.nodes.size(), (int)g.edges.size());
+    std::ostringstream os;
+    for(size_t i = 0; i < g.nodes.size(); i++)
+      os << &g.nodes[i] << " = " << g.nodes[i].data << ", ";
+    ALOGI("%s Nodes: [%s]", prefix, os.str().c_str());
+    os.str("");
+    os.clear();
+    for(size_t i = 0; i < g.edges.size(); i++)
+      os << g.edges[i].left << " -> " << g.edges[i].right << ", ";
+    ALOGI("%s Edges: [%s]", prefix, os.str().c_str());
+}
+} // namespace android
diff --git a/tests/pointer/1.0/default/lib/include/hidl-test/PointerHelper.h b/tests/pointer/1.0/default/lib/include/hidl-test/PointerHelper.h
new file mode 100644
index 0000000..cd2edcb
--- /dev/null
+++ b/tests/pointer/1.0/default/lib/include/hidl-test/PointerHelper.h
@@ -0,0 +1,15 @@
+#ifndef ANDROID_HIDL_TEST_POINTER_HELPER_H
+#define ANDROID_HIDL_TEST_POINTER_HELPER_H
+
+#include <android/hardware/tests/pointer/1.0/IGraph.h>
+
+using ::android::hardware::tests::pointer::V1_0::IGraph;
+
+namespace android {
+
+void simpleGraph(IGraph::Graph& g);
+bool isSimpleGraph(const IGraph::Graph &g);
+void logSimpleGraph(const char *prefix, const IGraph::Graph& g);
+
+} // namespace android
+#endif // ANDROID_HIDL_TEST_POINTER_HELPER_H
diff --git a/thermal/1.0/IThermal.hal b/thermal/1.0/IThermal.hal
index 4697f32..a60bc7d 100644
--- a/thermal/1.0/IThermal.hal
+++ b/thermal/1.0/IThermal.hal
@@ -56,11 +56,11 @@
      *         the status.debugMessage must be populated with the human-readable
      *         error message.
      * @return devices If status code is SUCCESS, it's filled with the current
-     *         cooling device information. The order of built-in coolling
+     *         cooling device information. The order of built-in cooling
      *         devices in the list must be kept the same regardless the number
      *         of calls to this method even if they go offline, if these devices
      *         exist on boot. The method always returns and never removes from
-     *         the list such coolling devices.
+     *         the list such cooling devices.
      *
      */
     getCoolingDevices()
diff --git a/vibrator/1.0/vts/Android.mk b/vibrator/1.0/vts/Android.mk
new file mode 100644
index 0000000..cb70548
--- /dev/null
+++ b/vibrator/1.0/vts/Android.mk
@@ -0,0 +1,55 @@
+#
+# Copyright (C) 2016 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)
+
+# build VTS driver for Vibrator v1.0.
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libvts_driver_hidl_vibrator@1.0
+
+LOCAL_SRC_FILES := \
+  Vibrator.vts \
+  types.vts \
+
+LOCAL_C_INCLUDES := \
+  android.hardware.vibrator@1.0 \
+  system/core/base/include \
+  system/core/include \
+
+LOCAL_SHARED_LIBRARIES += \
+  android.hardware.vibrator@1.0 \
+  libbase \
+  libutils \
+  libcutils \
+  liblog \
+  libhidl \
+  libhwbinder \
+  libprotobuf-cpp-full \
+  libvts_common \
+  libvts_datatype \
+  libvts_measurement \
+  libvts_multidevice_proto \
+
+LOCAL_CFLAGS += -DENABLE_TREBLE
+
+LOCAL_STATIC_LIBRARIES := \
+
+LOCAL_PROTOC_OPTIMIZE_TYPE := full
+
+LOCAL_MULTILIB := both
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/vibrator/1.0/vts/Vibrator.vts b/vibrator/1.0/vts/Vibrator.vts
new file mode 100644
index 0000000..f1ab053
--- /dev/null
+++ b/vibrator/1.0/vts/Vibrator.vts
@@ -0,0 +1,30 @@
+component_class: HAL_HIDL
+component_type_version: 1.0
+component_name: "IVibrator"
+
+package: "android.hardware.vibrator"
+
+import: "android.hardware.vibrator@1.0::types"
+
+interface: {
+    api: {
+        name: "on"
+        return_type_hidl: {
+            type: TYPE_ENUM
+            predefined_type: "Status"
+        }
+        arg: {
+            type: TYPE_SCALAR
+            scalar_type: "uint32_t"
+        }
+    }
+
+    api: {
+        name: "off"
+        return_type_hidl: {
+            type: TYPE_ENUM
+            predefined_type: "Status"
+        }
+    }
+
+}
diff --git a/vibrator/1.0/vts/types.vts b/vibrator/1.0/vts/types.vts
new file mode 100644
index 0000000..0eba051
--- /dev/null
+++ b/vibrator/1.0/vts/types.vts
@@ -0,0 +1,24 @@
+component_class: HAL_HIDL
+component_type_version: 1.0
+component_name: "types"
+
+package: "android.hardware.vibrator"
+
+
+attribute: {
+    name: "Status"
+    type: TYPE_ENUM
+    enum_value: {
+        scalar_type: "uint32_t"
+
+        enumerator: "OK"
+        scalar_value: {
+            uint32_t: 0
+        }
+        enumerator: "ERR"
+        scalar_value: {
+            uint32_t: 1
+        }
+    }
+}
+
diff --git a/wifi/1.0/default/service.cpp b/wifi/1.0/default/service.cpp
index 10ce1db..751e8f6 100644
--- a/wifi/1.0/default/service.cpp
+++ b/wifi/1.0/default/service.cpp
@@ -15,7 +15,6 @@
  */
 
 #include <android-base/logging.h>
-#include <hidl/IServiceManager.h>
 #include <hwbinder/IPCThreadState.h>
 #include <hwbinder/ProcessState.h>
 #include <utils/Looper.h>