Merge "NFC HAL target-side test (template)"
diff --git a/Android.bp b/Android.bp
index b475d56..3c441bb 100644
--- a/Android.bp
+++ b/Android.bp
@@ -8,6 +8,7 @@
     "biometrics/fingerprint/2.1",
     "bluetooth/1.0",
     "boot/1.0",
+    "broadcastradio/1.0",
     "example/extension/light/2.0",
     "gnss/1.0",
     "graphics/allocator/2.0",
@@ -35,6 +36,7 @@
     "tests/foo/1.0/default",
     "tests/foo/1.0/default/lib",
     "tests/libhwbinder/1.0",
+    "tests/libhwbinder/1.0/default",
     "tests/msgq/1.0",
     "tests/pointer/1.0",
     "tests/pointer/1.0/default",
@@ -44,6 +46,8 @@
     "vehicle/2.0",
     "vibrator/1.0",
     "vibrator/1.0/default",
+    "vr/1.0",
+    "vr/1.0/default",
     "wifi/1.0",
     "wifi/supplicant/1.0",
 ]
diff --git a/benchmarks/msgq/1.0/Android.bp b/benchmarks/msgq/1.0/Android.bp
index 51841c2..b222cfb 100644
--- a/benchmarks/msgq/1.0/Android.bp
+++ b/benchmarks/msgq/1.0/Android.bp
@@ -39,4 +39,9 @@
         "libutils",
         "libcutils",
     ],
+export_shared_lib_headers: [
+    "libhidl",
+    "libhwbinder",
+    "libutils",
+    ],
 }
diff --git a/bluetooth/1.0/Android.bp b/bluetooth/1.0/Android.bp
index c5f898d..ef7f109 100644
--- a/bluetooth/1.0/Android.bp
+++ b/bluetooth/1.0/Android.bp
@@ -51,4 +51,9 @@
         "libutils",
         "libcutils",
     ],
+export_shared_lib_headers: [
+    "libhidl",
+    "libhwbinder",
+    "libutils",
+    ],
 }
diff --git a/boot/1.0/Android.bp b/boot/1.0/Android.bp
index 98341ef..dc30038 100644
--- a/boot/1.0/Android.bp
+++ b/boot/1.0/Android.bp
@@ -43,4 +43,9 @@
         "libutils",
         "libcutils",
     ],
+export_shared_lib_headers: [
+    "libhidl",
+    "libhwbinder",
+    "libutils",
+    ],
 }
diff --git a/boot/1.0/default/service.cpp b/boot/1.0/default/service.cpp
index b059f9a..a594db6 100644
--- a/boot/1.0/default/service.cpp
+++ b/boot/1.0/default/service.cpp
@@ -1,44 +1,11 @@
 #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;
+#include <hidl/LegacySupport.h>
 
 using ::android::hardware::boot::V1_0::IBootControl;
+using android::hardware::defaultPassthroughServiceImplementation;
 
 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();
+    return defaultPassthroughServiceImplementation<IBootControl>("bootctrl");
 }
diff --git a/broadcastradio/1.0/Android.bp b/broadcastradio/1.0/Android.bp
new file mode 100644
index 0000000..44af4aa
--- /dev/null
+++ b/broadcastradio/1.0/Android.bp
@@ -0,0 +1,70 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+    name: "android.hardware.broadcastradio@1.0_genc++",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.broadcastradio@1.0",
+    srcs: [
+        "types.hal",
+        "IBroadcastRadio.hal",
+        "IBroadcastRadioFactory.hal",
+        "ITuner.hal",
+        "ITunerCallback.hal",
+    ],
+    out: [
+        "android/hardware/broadcastradio/1.0/types.cpp",
+        "android/hardware/broadcastradio/1.0/BroadcastRadioAll.cpp",
+        "android/hardware/broadcastradio/1.0/BroadcastRadioFactoryAll.cpp",
+        "android/hardware/broadcastradio/1.0/TunerAll.cpp",
+        "android/hardware/broadcastradio/1.0/TunerCallbackAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.broadcastradio@1.0_genc++_headers",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.broadcastradio@1.0",
+    srcs: [
+        "types.hal",
+        "IBroadcastRadio.hal",
+        "IBroadcastRadioFactory.hal",
+        "ITuner.hal",
+        "ITunerCallback.hal",
+    ],
+    out: [
+        "android/hardware/broadcastradio/1.0/types.h",
+        "android/hardware/broadcastradio/1.0/IBroadcastRadio.h",
+        "android/hardware/broadcastradio/1.0/IHwBroadcastRadio.h",
+        "android/hardware/broadcastradio/1.0/BnBroadcastRadio.h",
+        "android/hardware/broadcastradio/1.0/BpBroadcastRadio.h",
+        "android/hardware/broadcastradio/1.0/BsBroadcastRadio.h",
+        "android/hardware/broadcastradio/1.0/IBroadcastRadioFactory.h",
+        "android/hardware/broadcastradio/1.0/IHwBroadcastRadioFactory.h",
+        "android/hardware/broadcastradio/1.0/BnBroadcastRadioFactory.h",
+        "android/hardware/broadcastradio/1.0/BpBroadcastRadioFactory.h",
+        "android/hardware/broadcastradio/1.0/BsBroadcastRadioFactory.h",
+        "android/hardware/broadcastradio/1.0/ITuner.h",
+        "android/hardware/broadcastradio/1.0/IHwTuner.h",
+        "android/hardware/broadcastradio/1.0/BnTuner.h",
+        "android/hardware/broadcastradio/1.0/BpTuner.h",
+        "android/hardware/broadcastradio/1.0/BsTuner.h",
+        "android/hardware/broadcastradio/1.0/ITunerCallback.h",
+        "android/hardware/broadcastradio/1.0/IHwTunerCallback.h",
+        "android/hardware/broadcastradio/1.0/BnTunerCallback.h",
+        "android/hardware/broadcastradio/1.0/BpTunerCallback.h",
+        "android/hardware/broadcastradio/1.0/BsTunerCallback.h",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.broadcastradio@1.0",
+    generated_sources: ["android.hardware.broadcastradio@1.0_genc++"],
+    generated_headers: ["android.hardware.broadcastradio@1.0_genc++_headers"],
+    export_generated_headers: ["android.hardware.broadcastradio@1.0_genc++_headers"],
+    shared_libs: [
+        "libhidl",
+        "libhwbinder",
+        "libutils",
+        "libcutils",
+    ],
+}
diff --git a/broadcastradio/1.0/IBroadcastRadio.hal b/broadcastradio/1.0/IBroadcastRadio.hal
new file mode 100644
index 0000000..c7fe62d
--- /dev/null
+++ b/broadcastradio/1.0/IBroadcastRadio.hal
@@ -0,0 +1,51 @@
+/*
+ * 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.broadcastradio@1.0;
+
+import ITunerCallback;
+import ITuner;
+
+interface IBroadcastRadio {
+
+    /*
+     * Retrieve implementation properties.
+     * @return result Operation completion status: OK in case of success,
+     *                NOT_INITIALIZED in case of initialization error.
+     * @return properties A Properties structure containing implementation
+     *                    description and capabilities.
+     */
+    getProperties() generates (Result result, Properties properties);
+
+    /*
+     * Open a tuner interface for the requested configuration.
+     * If no other tuner is opened, this will power on the radio hardware.
+     * The hardware must be powered down when all tuner interface are released.
+     * @param config A BandConfig struct containing the band configuration to apply
+     * @param audio True if this tuner must be used for live radio listening and
+     *              should be connected to the radio audio source.
+     * @param callback the callback interface
+     * @return result Operation completion status: OK in case of success,
+     *                INVALID_ARGUMENTS if configuration requested is invalid,
+     *                INVALID_STATE if called out of sequence
+     * @return tuner The interface to control the tuner
+     *
+     * Callback ITunerCallback.ConfigChanged MUST be called once the
+     * configuration is applied or a failure occurs or after a time out.
+     */
+    openTuner(BandConfig config, bool audio, ITunerCallback callback)
+                generates (Result result, ITuner tuner);
+};
diff --git a/broadcastradio/1.0/IBroadcastRadioFactory.hal b/broadcastradio/1.0/IBroadcastRadioFactory.hal
new file mode 100644
index 0000000..82a97c4
--- /dev/null
+++ b/broadcastradio/1.0/IBroadcastRadioFactory.hal
@@ -0,0 +1,36 @@
+/*
+ * 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.broadcastradio@1.0;
+
+import IBroadcastRadio;
+
+interface IBroadcastRadioFactory {
+
+    /*
+     * Connects to a broadcast radio HAL module for a given class
+     * (AM/FM, Satellite, DAB).
+     *
+     * @param classId Class of the module to connect to .
+     * @return retval operation completion status. Returns INVALID_ARGUMENTS
+     *         if there is no corresponding hardware module found,
+     *         NOT_INITIALIZED if an error occurred while opening the hardware
+     *         module.
+     * @return result the interface for the created module.
+     */
+    connectModule(Class classId)
+      generates (Result retval, IBroadcastRadio result);
+};
diff --git a/broadcastradio/1.0/ITuner.hal b/broadcastradio/1.0/ITuner.hal
new file mode 100644
index 0000000..5e2bffe
--- /dev/null
+++ b/broadcastradio/1.0/ITuner.hal
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.broadcastradio@1.0;
+
+import ITunerCallback;
+
+interface ITuner {
+
+    /*
+     * Apply current radio band configuration (band, range, channel spacing...).
+     * Automatically cancels pending scan, step or tune.
+     * ITunerCallback.configChange() method MUST be called once the
+     * configuration is applied or a failure occurs or after a time out.
+     * @param config The band configuration to apply.
+     * @return result OK if configuration could be applied
+     *                NOT_INITIALIZED in case of initialization error.
+     *                INVALID_ARGUMENTS if configuration requested is invalid
+     *
+     */
+    setConfiguration(BandConfig config) generates(Result result);
+
+    /*
+     * Retrieve current radio band configuration.
+     * @return result OK if valid configuration is returned,
+     *                NOT_INITIALIZED in case of initialization error.
+     * @param config Current band configuration
+     */
+    getConfiguration() generates(Result result, BandConfig config);
+
+    /*
+     * Start scanning up to next valid station.
+     * Shall be called only when a valid configuration has been applied.
+     * Automatically cancels pending scan, step or tune.
+     * ITunerCallback.tuneComplete() MUST be called once locked on a station
+     * or after a time out or full band scan if no station found.
+     * The status should indicate if a valid station is tuned or not.
+     * @param direction UP or DOWN.
+     * @param skipSubChannel valid for HD radio or digital radios only:
+     *                       ignore sub channels (e.g SPS for HD radio).
+     * @return result OK if scan successfully started
+     *                INVALID_STATE if called out of sequence
+     *                NOT_INITIALIZED if another error occurs
+     */
+    scan(Direction direction, bool skipSubChannel) generates(Result result);
+
+    /*
+     * Move one channel spacing up or down.
+     * Must be called when a valid configuration has been applied.
+     * Automatically cancels pending scan, step or tune.
+     * ITunerCallback.tuneComplete() MUST be called once locked on a station
+     * or after a time out or full band scan if no station found.
+     * The status should indicate if a valid station is tuned or not.
+     * @param direction UP or DOWN.
+     * @param skipSubChannel valid for HD radio or digital radios only:
+     *                       ignore sub channels (e.g SPS for HD radio).
+     * @return result OK if scan successfully started
+     *                INVALID_STATE if called out of sequence
+     *                NOT_INITIALIZED if another error occurs
+     */
+    step(Direction direction, bool skipSubChannel) generates(Result result);
+
+    /*
+     * Tune to specified channel.
+     * Must be called when a valid configuration has been applied.
+     * Automatically cancels pending scan, step or tune.
+     * ITunerCallback.tuneComplete() MUST be called once locked on a station
+     * or after a time out or full band scan if no station found.
+     * The status should indicate if a valid station is tuned or not.
+     * @param channel Channel to tune to. A frequency in kHz for AM/FM/HD Radio
+     *                bands.
+     * @param subChannel Valid for HD radio or digital radios only
+     *                   (e.g SPS number for HD radio)..
+     * @return result OK if scan successfully started
+     *                INVALID_ARGUMENTS if invalid arguments are passed
+     *                INVALID_STATE if called out of sequence
+     *                NOT_INITIALIZED if another error occurs
+     */
+    tune(uint32_t channel, uint32_t subChannel) generates(Result result);
+
+    /*
+     * Cancel a scan, step or tune operation.
+     * Shall be called only while a scan, step or tune operation is pending.
+     * ITunerCallback.tuneComplete() MUST NOT be sent by the HAL.
+     * @return result OK if scan successfully started
+     *                INVALID_STATE if called out of sequence
+     *                NOT_INITIALIZED if another error occurs
+     */
+    cancel() generates(Result result);
+
+    /*
+     * Retrieve current station information.
+     * @param withMetadata True if Metadata should be returned, false otherwise.
+     * @return result OK if scan successfully started
+     *                NOT_INITIALIZED if another error occurs
+     * @return info Current program information.
+     */
+    getProgramInformation(bool withMetadata)
+            generates(Result result, ProgramInfo info);
+};
diff --git a/broadcastradio/1.0/ITunerCallback.hal b/broadcastradio/1.0/ITunerCallback.hal
new file mode 100644
index 0000000..f805472
--- /dev/null
+++ b/broadcastradio/1.0/ITunerCallback.hal
@@ -0,0 +1,78 @@
+/*
+ * 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.broadcastradio@1.0;
+
+
+interface ITunerCallback {
+
+    /*
+     * Method called by the HAL when a HW failure occurs.
+     * The framework MUST close the ITuner interface and open a new one.
+     */
+    oneway hardwareFailure();
+
+    /*
+     * Method called by the HAL when a new configuration is applied
+     * in response to IDevice.openTuner() or ITuner.setConfiguration().
+     * @param result OK if the configuration has been applied,
+     *               INVALID_ARGUMENTS if not or TIMEOUT in case of time out.
+     * @param config A BandConfig structure describing the new configuration
+     *               applied.
+     */
+    oneway configChange(Result result, BandConfig config);
+
+    /*
+     * Method called by the HAL when a tuning operation completes
+     * following a step(), scan() or tune() command.
+     * @param result OK if tune succeeded or TIMEOUT in case of time out.
+     * @param info A ProgramInfo structure describing the tuned station.
+     */
+    oneway tuneComplete(Result result, ProgramInfo info);
+
+    /*
+     * Method called by the HAL when a frequency switch occurs.
+     * @param info A ProgramInfo structure describing the new tuned station.
+     */
+    oneway afSwitch(ProgramInfo info);
+
+    /*
+     * Method called by the HAL when the antenna connection state changes.
+     * @param connected True if the antenna is connected, false otherwise.
+     */
+    oneway antennaStateChange(bool connected);
+
+    /*
+     * Method called by the HAL when a traffic announcement starts or
+     * stops.
+     * @param active True if the announcement starts, false if it stops.
+     */
+    oneway trafficAnnouncement(bool active);
+
+    /*
+     * Method called by the HAL when an emergency announcement starts
+     * or stops.
+     * @param active True if the announcement starts, false if it stops.
+     */
+    oneway emergencyAnnouncement(bool active);
+
+    /*
+     * Method called by the HAL when metadata for current station
+     * are updated.
+     * @param metadatas A list of all updated metada.
+     */
+    oneway newMetadata(vec<MetaData>  metadatas);
+};
\ No newline at end of file
diff --git a/broadcastradio/1.0/types.hal b/broadcastradio/1.0/types.hal
new file mode 100644
index 0000000..c5b4411
--- /dev/null
+++ b/broadcastradio/1.0/types.hal
@@ -0,0 +1,216 @@
+/*
+ * 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.broadcastradio@1.0;
+
+enum Result {
+    OK,
+    NOT_INITIALIZED,
+    INVALID_ARGUMENTS,
+    INVALID_STATE,
+    TIMEOUT,
+};
+
+/*
+ * Radio hardware module class. A given radio hardware module HAL is of one
+ * class only. The platform can not have more than one hardware module of
+ * each class. Current version of the framework only supports RADIO_CLASS_AM_FM.
+ */
+enum Class : uint32_t {
+    /* FM (including HD radio) and AM */
+    AM_FM = 0,
+    /* Satellite Radio */
+    SAT   = 1,
+    /* Digital Radio (DAB) */
+    DT    = 2,
+};
+
+/* value for field "type" of radio band described in struct radio_hal_band_config */
+enum Band : uint32_t {
+    /* Amplitude Modulation band: LW, MW, SW */
+    AM     = 0,
+    /* Frequency Modulation band: FM */
+    FM     = 1,
+    /* FM HD Radio / DRM (IBOC) */
+    FM_HD  = 2,
+    /* AM HD Radio / DRM (IBOC) */
+    AM_HD  = 3,
+};
+
+/* RDS variant implemented. A struct FmBandConfig can list none or several. */
+enum Rds : uint32_t {
+    NONE   = 0,
+    WORLD  = (1<<0),
+    RDS_US = (1<<1),
+};
+
+
+/* FM deemphasis variant implemented.
+ * A struct FmBandConfig can list one or more. */
+enum Deemphasis : uint32_t {
+    D50   = (1<<0),
+    D75   = (1<<1),
+};
+
+/* Scanning direction for scan() and step() tuner APIs */
+enum Direction : uint32_t {
+    UP,
+    DOWN
+};
+
+/* Unique handle allocated to a radio module */
+typedef uint32_t Handle;
+
+
+/* Additional attributes for an FM band configuration */
+struct FmBandConfig {
+    /* deemphasis variant */
+    Deemphasis deemphasis;
+    /* stereo supported */
+    bool       stereo;
+    /* RDS variants supported */
+    Rds        rds;
+    /* Traffic Announcement supported */
+    bool       ta;
+    /* Alternate Frequency supported */
+    bool       af;
+    /* Emergency announcements supported */
+    bool       ea;
+};
+
+/* Additional attributes for an AM band configuration */
+struct AmBandConfig {
+    /* Stereo supported */
+    bool       stereo;
+};
+
+/* Radio band configuration. Describes a given band supported by the radio
+ * module. The HAL can expose only one band per type with the the maximum range
+ * supported and all options. The framework will derive the actual regions were
+ * this module can operate and expose separate band configurations for
+ * applications to chose from. */
+struct BandConfig {
+    Band type;
+    bool antennaConnected;
+    uint32_t lowerLimit;
+    uint32_t upperLimit;
+    vec<uint32_t> spacings;
+    union Ext {
+        FmBandConfig fm;
+        AmBandConfig am;
+    };
+};
+
+/* Exposes properties of a given hardware radio module.
+ * NOTE: current framework implementation supports only one audio source
+ * (num_audio_sources = 1). The source corresponds to AUDIO_DEVICE_IN_FM_TUNER.
+ * If more than one tuner is supported (num_tuners > 1), only one can be
+ * connected to the audio source. */
+struct Properties {
+    /* Class of this module. E.g AM_FM */
+    Class           classId;
+    /* implementor name */
+    string          implementor;
+    /* product name */
+    string          product;
+    /* product version */
+    string          version;
+    /* serial number (for subscription services) */
+    string          serial;
+    /* number of tuners controllable independently */
+    uint32_t        numTuners;
+    /* number of audio sources driven simultaneously */
+    uint32_t        numAudioSources;
+    /* the hardware supports capture of audio source from audio HAL */
+    bool            supportsCapture;
+    vec<BandConfig> bands; /* band descriptors */
+};
+
+enum MetadataType {
+    INVALID    = -1,
+    /* Signed 32 bit integer  */
+    INT        = 0,
+    /* String */
+    TEXT       = 1,
+    /* Raw binary data (icon or art)
+       This data must be transparent to the android framework */
+    RAW        = 2,
+    /* clock data, see MetaDataClock */
+    CLOCK      = 3,
+};
+
+enum MetadataKey {
+    INVALID      = -1,
+    /* RDS PI                 - string  */
+    RDS_PI       = 0,
+    /* RDS PS                 - string */
+    RDS_PS       = 1,
+    /* RDS PTY                - int32_t  */
+    RDS_PTY      = 2,
+    /* RBDS PTY               - int32_t  */
+    RBDS_PTY     = 3,
+    /* RDS RT                 - string  */
+    RDS_RT       = 4,
+    /* Song title             - string  */
+    TITLE        = 5,
+    /* Artist name            - string  */
+    ARTIST       = 6,
+    /* Album name             - string  */
+    ALBUM        = 7,
+    /* Musical genre          - string  */
+    GENRE        = 8,
+    /* Station icon           - raw  */
+    ICON         = 9,
+    /* Album art              - raw  */
+    ART          = 10,
+    /* Clock                  - MetaDataClock */
+    CLOCK        = 11,
+};
+
+struct MetaDataClock {
+     /* Seconds since epoch at GMT + 0. */
+    uint64_t utcSecondsSinceEpoch;
+    /* Minutes offset from the GMT. */
+    int32_t timezoneOffsetInMinutes;
+};
+
+struct MetaData {
+    MetadataType type;
+    MetadataKey key;
+    /* Value used for type MetadataType.INT */
+    int32_t intValue;
+    /* Value used for type MetadataType.CLOCK */
+    MetaDataClock  clockValue;
+    /* Value used for type MetadataType.TEXT */
+    string  stringValue;
+    /* Value used for type MetadataType.RAW */
+    vec<uint8_t> rawValue;
+};
+
+
+/* Radio program information. Returned by the HAL with event RADIO_EVENT_TUNED.
+ * Contains information on currently tuned channel.
+ */
+struct ProgramInfo {
+    uint32_t     channel;   /* current channel. (e.g kHz for band type AM_FM) */
+    uint32_t     subChannel; /* current sub channel. (FM_HD) */
+    bool         tuned;     /* tuned to a program or not */
+    bool         stereo;    /* program is stereo or not */
+    bool         digital;   /* digital program or not (e.g HD Radio program) */
+    uint32_t     signalStrength; /* signal strength from 0 to 100 */
+    vec<MetaData> metadata; /* non empty if meta data are present (e.g PTY, song title ...) */
+};
+
diff --git a/graphics/allocator/2.0/default/service.cpp b/graphics/allocator/2.0/default/service.cpp
index fd89aa8..525b342 100644
--- a/graphics/allocator/2.0/default/service.cpp
+++ b/graphics/allocator/2.0/default/service.cpp
@@ -14,38 +14,15 @@
  * limitations under the License.
  */
 
-#define LOG_TAG "GrallocService"
+#define LOG_TAG "android.hardware.graphics.allocator@2.0-service"
 
 #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;
+#include <hidl/LegacySupport.h>
+
 using android::hardware::graphics::allocator::V2_0::IAllocator;
+using android::hardware::defaultPassthroughServiceImplementation;
 
-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;
+int main() {
+    return defaultPassthroughServiceImplementation<IAllocator>("gralloc");
 }
diff --git a/light/2.0/default/service.cpp b/light/2.0/default/service.cpp
index e446878..b3848e9 100644
--- a/light/2.0/default/service.cpp
+++ b/light/2.0/default/service.cpp
@@ -1,46 +1,27 @@
-#define LOG_TAG "android.hardware.light@2.0-service"
-#include <utils/Log.h>
+/*
+ * 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.
+ */
 
-#include <iostream>
-#include <unistd.h>
+#define LOG_TAG "android.hardware.light@2.0-service"
 
 #include <android/hardware/light/2.0/ILight.h>
+#include <hidl/LegacySupport.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;
-
-// Generated HIDL files
 using android::hardware::light::V2_0::ILight;
+using android::hardware::defaultPassthroughServiceImplementation;
 
 int main() {
-    ALOGI("Service is starting.");
-    const char instance[] = "light";
-    ALOGI("Retrieving default implementation of instance %s.",
-          instance);
-
-    android::sp<ILight> service = ILight::getService(instance, true /* getStub */);
-
-    if (service.get() == nullptr) {
-        ALOGE("ILight::getService returned NULL, exiting");
-        return EXIT_FAILURE;
-    }
-
-    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<ILight>("light");
 }
diff --git a/memtrack/1.0/default/service.cpp b/memtrack/1.0/default/service.cpp
index 63ac695..f705b15 100644
--- a/memtrack/1.0/default/service.cpp
+++ b/memtrack/1.0/default/service.cpp
@@ -15,37 +15,13 @@
  */
 
 #define LOG_TAG "android.hardware.memtrack@1.0-service"
-#include <utils/Log.h>
-
-#include <iostream>
-#include <unistd.h>
 
 #include <android/hardware/memtrack/1.0/IMemtrack.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;
+#include <hidl/LegacySupport.h>
 
 using android::hardware::memtrack::V1_0::IMemtrack;
+using android::hardware::defaultPassthroughServiceImplementation;
 
 int main() {
-    const char instance[] = "memtrack";
-    android::sp<IMemtrack> service = IMemtrack::getService(instance, true);
-    if (service.get() == nullptr) {
-        ALOGE("IMemtrack::getService returned NULL, exiting");
-        return -1;
-    }
-    LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
-    service->registerAsService(instance);
-
-    ProcessState::self()->setThreadPoolMaxThreadCount(0);
-    ProcessState::self()->startThreadPool();
-    IPCThreadState::self()->joinThreadPool();
+    return defaultPassthroughServiceImplementation<IMemtrack>("memtrack");
 }
diff --git a/nfc/1.0/Android.bp b/nfc/1.0/Android.bp
index d9f197e..2b8f3af 100644
--- a/nfc/1.0/Android.bp
+++ b/nfc/1.0/Android.bp
@@ -51,4 +51,9 @@
         "libutils",
         "libcutils",
     ],
+export_shared_lib_headers: [
+    "libhidl",
+    "libhwbinder",
+    "libutils",
+    ],
 }
diff --git a/power/1.0/default/service.cpp b/power/1.0/default/service.cpp
index bad1adf..f77ff5b 100644
--- a/power/1.0/default/service.cpp
+++ b/power/1.0/default/service.cpp
@@ -15,37 +15,13 @@
  */
 
 #define LOG_TAG "android.hardware.power@1.0-service"
-#include <utils/Log.h>
-
-#include <iostream>
-#include <unistd.h>
 
 #include <android/hardware/power/1.0/IPower.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;
+#include <hidl/LegacySupport.h>
 
 using android::hardware::power::V1_0::IPower;
+using android::hardware::defaultPassthroughServiceImplementation;
 
 int main() {
-    const char instance[] = "power";
-    android::sp<IPower> service = IPower::getService(instance, true);
-    if (service.get() == nullptr) {
-        ALOGE("IPower::getService returned NULL, exiting");
-        return -1;
-    }
-    LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
-    service->registerAsService(instance);
-
-    ProcessState::self()->setThreadPoolMaxThreadCount(0);
-    ProcessState::self()->startThreadPool();
-    IPCThreadState::self()->joinThreadPool();
+    return defaultPassthroughServiceImplementation<IPower>("power");
 }
diff --git a/radio/1.0/Android.bp b/radio/1.0/Android.bp
index 682e12c..34eaf33 100644
--- a/radio/1.0/Android.bp
+++ b/radio/1.0/Android.bp
@@ -51,4 +51,9 @@
         "libutils",
         "libcutils",
     ],
+export_shared_lib_headers: [
+    "libhidl",
+    "libhwbinder",
+    "libutils",
+    ],
 }
diff --git a/sensors/1.0/default/service.cpp b/sensors/1.0/default/service.cpp
index da543ef..230ead3 100644
--- a/sensors/1.0/default/service.cpp
+++ b/sensors/1.0/default/service.cpp
@@ -14,38 +14,14 @@
  * limitations under the License.
  */
 
-#include <android-base/logging.h>
+#define LOG_TAG "android.hardware.nfc@1.0-service"
+
 #include <android/hardware/sensors/1.0/ISensors.h>
-#include <hwbinder/IPCThreadState.h>
-#include <hwbinder/ProcessState.h>
+#include <hidl/LegacySupport.h>
+
+using android::hardware::sensors::V1_0::ISensors;
+using android::hardware::defaultPassthroughServiceImplementation;
 
 int main() {
-    using android::hardware::sensors::V1_0::ISensors;
-    using android::sp;
-    using android::OK;
-    using namespace android::hardware;
-
-    LOG(INFO) << "Service is starting.";
-    sp<ISensors> sensors = ISensors::getService("sensors", true /* getStub */);
-
-    if (sensors.get() == nullptr) {
-        LOG(ERROR) << "ISensors::getService returned nullptr, exiting.";
-        return 1;
-    }
-
-    LOG(INFO) << "Default implementation using sensors is "
-              << (sensors->isRemote() ? "REMOTE" : "LOCAL");
-
-    CHECK(!sensors->isRemote());
-
-    LOG(INFO) << "Registering instance sensors.";
-    sensors->registerAsService("sensors");
-    LOG(INFO) << "Ready.";
-
-    ProcessState::self()->setThreadPoolMaxThreadCount(0);
-    ProcessState::self()->startThreadPool();
-    IPCThreadState::self()->joinThreadPool();
-
-    return 0;
+    return defaultPassthroughServiceImplementation<ISensors>("sensors");
 }
-
diff --git a/tests/bar/1.0/Android.bp b/tests/bar/1.0/Android.bp
index 617b08f..06db6d0 100644
--- a/tests/bar/1.0/Android.bp
+++ b/tests/bar/1.0/Android.bp
@@ -48,4 +48,9 @@
         "libcutils",
         "android.hardware.tests.foo@1.0",
     ],
+export_shared_lib_headers: [
+    "libhidl",
+    "libhwbinder",
+    "libutils",
+    ],
 }
diff --git a/tests/bar/1.0/default/Bar.cpp b/tests/bar/1.0/default/Bar.cpp
index 6da9eec..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);
diff --git a/tests/bar/1.0/default/Bar.h b/tests/bar/1.0/default/Bar.h
index ae18d93..d2c2635 100644
--- a/tests/bar/1.0/default/Bar.h
+++ b/tests/bar/1.0/default/Bar.h
@@ -29,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;
diff --git a/tests/baz/1.0/Android.bp b/tests/baz/1.0/Android.bp
index d3eefe5..64a8803 100644
--- a/tests/baz/1.0/Android.bp
+++ b/tests/baz/1.0/Android.bp
@@ -59,4 +59,9 @@
         "libutils",
         "libcutils",
     ],
+export_shared_lib_headers: [
+    "libhidl",
+    "libhwbinder",
+    "libutils",
+    ],
 }
diff --git a/tests/expression/1.0/Android.bp b/tests/expression/1.0/Android.bp
index 32d4682..2ad94fa 100644
--- a/tests/expression/1.0/Android.bp
+++ b/tests/expression/1.0/Android.bp
@@ -47,4 +47,9 @@
         "libutils",
         "libcutils",
     ],
+export_shared_lib_headers: [
+    "libhidl",
+    "libhwbinder",
+    "libutils",
+    ],
 }
diff --git a/tests/foo/1.0/Android.bp b/tests/foo/1.0/Android.bp
index e7bcad2..96133ac 100644
--- a/tests/foo/1.0/Android.bp
+++ b/tests/foo/1.0/Android.bp
@@ -75,4 +75,9 @@
         "libutils",
         "libcutils",
     ],
+export_shared_lib_headers: [
+    "libhidl",
+    "libhwbinder",
+    "libutils",
+    ],
 }
diff --git a/tests/foo/1.0/IFoo.hal b/tests/foo/1.0/IFoo.hal
index b6ef5c8..2afaec1 100644
--- a/tests/foo/1.0/IFoo.hal
+++ b/tests/foo/1.0/IFoo.hal
@@ -81,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);
diff --git a/tests/foo/1.0/default/Android.bp b/tests/foo/1.0/default/Android.bp
index 8571c87..185e5ea 100644
--- a/tests/foo/1.0/default/Android.bp
+++ b/tests/foo/1.0/default/Android.bp
@@ -6,8 +6,6 @@
     srcs: [
         "Foo.cpp",
         "FooCallback.cpp",
-        "MyTypes.cpp",
-        "TheirTypes.cpp",
     ],
 
     shared_libs: [
diff --git a/tests/foo/1.0/default/Foo.cpp b/tests/foo/1.0/default/Foo.cpp
index 4cfcfa2..f855f21 100644
--- a/tests/foo/1.0/default/Foo.cpp
+++ b/tests/foo/1.0/default/Foo.cpp
@@ -22,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 << ")";
@@ -73,10 +68,7 @@
         doStuffAndReturnAString_cb _cb) {
     ALOGI("SERVER(Foo) doStuffAndReturnAString");
 
-    hidl_string s;
-    s = "Hello, world";
-
-    _cb(s);
+    _cb("Hello, world");
 
     return Void();
 }
diff --git a/tests/foo/1.0/default/Foo.h b/tests/foo/1.0/default/Foo.h
index 804a6a3..b3785d2 100644
--- a/tests/foo/1.0/default/Foo.h
+++ b/tests/foo/1.0/default/Foo.h
@@ -25,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;
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/libhwbinder/1.0/Android.bp b/tests/libhwbinder/1.0/Android.bp
index 508de22..52a8186 100644
--- a/tests/libhwbinder/1.0/Android.bp
+++ b/tests/libhwbinder/1.0/Android.bp
@@ -39,4 +39,9 @@
         "libutils",
         "libcutils",
     ],
+export_shared_lib_headers: [
+    "libhidl",
+    "libhwbinder",
+    "libutils",
+    ],
 }
diff --git a/tests/libhwbinder/1.0/default/Android.bp b/tests/libhwbinder/1.0/default/Android.bp
new file mode 100644
index 0000000..91149e8
--- /dev/null
+++ b/tests/libhwbinder/1.0/default/Android.bp
@@ -0,0 +1,16 @@
+cc_library_shared {
+    name: "android.hardware.tests.libhwbinder@1.0-impl",
+    relative_install_path: "hw",
+    srcs: [
+        "Benchmark.cpp",
+    ],
+
+    shared_libs: [
+        "libbase",
+        "libhidl",
+        "libhwbinder",
+        "liblog",
+        "libutils",
+        "android.hardware.tests.libhwbinder@1.0",
+    ],
+}
\ No newline at end of file
diff --git a/tests/libhwbinder/1.0/default/Benchmark.cpp b/tests/libhwbinder/1.0/default/Benchmark.cpp
new file mode 100644
index 0000000..47b0ea0
--- /dev/null
+++ b/tests/libhwbinder/1.0/default/Benchmark.cpp
@@ -0,0 +1,28 @@
+#define LOG_TAG "libhwbinder_benchmark"
+
+#include "Benchmark.h"
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace libhwbinder {
+namespace V1_0 {
+namespace implementation {
+
+Return<void> Benchmark::sendVec(
+        const ::android::hardware::hidl_vec<uint8_t>& data,
+        sendVec_cb _hidl_cb) {
+    _hidl_cb(data);
+    return Void();
+}
+
+IBenchmark* HIDL_FETCH_IBenchmark(const char* /* name */) {
+    return new Benchmark();
+}
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace libhwbinder
+}  // namespace tests
+}  // namespace hardware
+}  // namespace android
diff --git a/tests/libhwbinder/1.0/default/Benchmark.h b/tests/libhwbinder/1.0/default/Benchmark.h
new file mode 100644
index 0000000..454fdf2
--- /dev/null
+++ b/tests/libhwbinder/1.0/default/Benchmark.h
@@ -0,0 +1,31 @@
+#ifndef HIDL_GENERATED_android_hardware_benchmark_V1_0_Benchmark_H_
+#define HIDL_GENERATED_android_hardware_benchmark_V1_0_Benchmark_H_
+
+#include <android/hardware/tests/libhwbinder/1.0/IBenchmark.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace libhwbinder {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::tests::libhwbinder::V1_0::IBenchmark;
+using ::android::hardware::Return;
+using ::android::hardware::hidl_vec;
+
+struct Benchmark : public IBenchmark {
+  virtual Return<void> sendVec(const hidl_vec<uint8_t>& data, sendVec_cb _hidl_cb)  override;
+};
+
+extern "C" IBenchmark* HIDL_FETCH_IBenchmark(const char* name);
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace libhwbinder
+}  // namespace tests
+}  // namespace hardware
+}  // namespace android
+
+#endif  // HIDL_GENERATED_android_hardware_benchmark_V1_0_Benchmark_H_
diff --git a/tests/msgq/1.0/Android.bp b/tests/msgq/1.0/Android.bp
index 16454ec..58ee3d4 100644
--- a/tests/msgq/1.0/Android.bp
+++ b/tests/msgq/1.0/Android.bp
@@ -39,4 +39,9 @@
         "libutils",
         "libcutils",
     ],
+export_shared_lib_headers: [
+    "libhidl",
+    "libhwbinder",
+    "libutils",
+    ],
 }
diff --git a/tests/pointer/1.0/Android.bp b/tests/pointer/1.0/Android.bp
index 45659d7..2601a5b 100644
--- a/tests/pointer/1.0/Android.bp
+++ b/tests/pointer/1.0/Android.bp
@@ -47,4 +47,9 @@
         "libutils",
         "libcutils",
     ],
+export_shared_lib_headers: [
+    "libhidl",
+    "libhwbinder",
+    "libutils",
+    ],
 }
diff --git a/thermal/1.0/default/service.cpp b/thermal/1.0/default/service.cpp
index b09b5ec..ea86de4 100644
--- a/thermal/1.0/default/service.cpp
+++ b/thermal/1.0/default/service.cpp
@@ -14,40 +14,14 @@
  * limitations under the License.
  */
 
-#include <iostream>
-#include <unistd.h>
+#define LOG_TAG "android.hardware.thermal@1.0-service"
 
 #include <android/hardware/thermal/1.0/IThermal.h>
+#include <hidl/LegacySupport.h>
 
-#include <hidl/IServiceManager.h>
-#include <hwbinder/IPCThreadState.h>
-#include <hwbinder/ProcessState.h>
-#include <utils/Errors.h>
-
-#define LOG_TAG "android.hardware.thermal@1.0-service"
-#include <utils/Log.h>
-#include <utils/StrongPointer.h>
-
-using android::sp;
-
-// libhwbinder:
-using android::hardware::IPCThreadState;
-using android::hardware::ProcessState;
-
-// Generated HIDL files
 using android::hardware::thermal::V1_0::IThermal;
+using android::hardware::defaultPassthroughServiceImplementation;
 
 int main() {
-    const char instance[] = "thermal";
-    sp<IThermal> service = IThermal::getService(instance, true /* getStub */);
-    if (service.get() == nullptr) {
-        ALOGE("IThermal::getService returned NULL, exiting");
-        return EXIT_FAILURE;
-    }
-    LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
-    service->registerAsService(instance);
-
-    ProcessState::self()->setThreadPoolMaxThreadCount(0);
-    ProcessState::self()->startThreadPool();
-    IPCThreadState::self()->joinThreadPool();
+    return defaultPassthroughServiceImplementation<IThermal>("thermal");
 }
diff --git a/vibrator/1.0/default/service.cpp b/vibrator/1.0/default/service.cpp
index a4a7132..064e1e2 100644
--- a/vibrator/1.0/default/service.cpp
+++ b/vibrator/1.0/default/service.cpp
@@ -14,46 +14,13 @@
  * limitations under the License.
  */
 #define LOG_TAG "android.hardware.vibrator@1.0-service"
-#include <utils/Log.h>
-
-#include <iostream>
-#include <unistd.h>
 
 #include <android/hardware/vibrator/1.0/IVibrator.h>
+#include <hidl/LegacySupport.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;
-
-// Generated HIDL files
 using android::hardware::vibrator::V1_0::IVibrator;
+using android::hardware::defaultPassthroughServiceImplementation;
 
 int main() {
-    ALOGI("Service is starting.");
-    const char instance[] = "vibrator";
-    ALOGI("Retrieving default implementation of instance %s.",
-          instance);
-    android::sp<IVibrator> service = IVibrator::getService(instance, true);
-    if (service.get() == nullptr) {
-        ALOGE("IVibrator::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<IVibrator>("vibrator");
 }
diff --git a/vr/1.0/Android.bp b/vr/1.0/Android.bp
new file mode 100644
index 0000000..8fd00c5
--- /dev/null
+++ b/vr/1.0/Android.bp
@@ -0,0 +1,42 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+    name: "android.hardware.vr@1.0_genc++",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.vr@1.0",
+    srcs: [
+        "IVr.hal",
+    ],
+    out: [
+        "android/hardware/vr/1.0/VrAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.vr@1.0_genc++_headers",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.vr@1.0",
+    srcs: [
+        "IVr.hal",
+    ],
+    out: [
+        "android/hardware/vr/1.0/IVr.h",
+        "android/hardware/vr/1.0/IHwVr.h",
+        "android/hardware/vr/1.0/BnVr.h",
+        "android/hardware/vr/1.0/BpVr.h",
+        "android/hardware/vr/1.0/BsVr.h",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.vr@1.0",
+    generated_sources: ["android.hardware.vr@1.0_genc++"],
+    generated_headers: ["android.hardware.vr@1.0_genc++_headers"],
+    export_generated_headers: ["android.hardware.vr@1.0_genc++_headers"],
+    shared_libs: [
+        "libhidl",
+        "libhwbinder",
+        "libutils",
+        "libcutils",
+    ],
+}
diff --git a/vr/1.0/IVr.hal b/vr/1.0/IVr.hal
new file mode 100644
index 0000000..1f996e9
--- /dev/null
+++ b/vr/1.0/IVr.hal
@@ -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.
+ */
+
+package android.hardware.vr@1.0;
+
+interface IVr {
+  /**
+   * Convenience method to set up any state needed at runtime startup.  This is
+   * called once from the VrManagerService during its boot phase.
+   */
+  @callflow(next={"*"})
+  @entry
+  @exit
+  init();
+
+  /**
+   * Set the VR mode state.  Possible states of the enabled parameter are:
+   * false - VR mode is disabled, turn off all VR-specific settings.
+   * true - VR mode is enabled, turn on all VR-specific settings.
+   *
+   * This must be called whenever the the Android system enters or leaves VR
+   * mode. This will typically occur when the user switches to or from a VR
+   * application that is doing stereoscopic rendering.
+   */
+  @callflow(next={"*"})
+  @exit
+  setVrMode(bool enabled);
+};
diff --git a/vr/1.0/default/Android.bp b/vr/1.0/default/Android.bp
new file mode 100644
index 0000000..09b0002
--- /dev/null
+++ b/vr/1.0/default/Android.bp
@@ -0,0 +1,16 @@
+cc_library_shared {
+    name: "android.hardware.vr@1.0-impl",
+    relative_install_path: "hw",
+    srcs: ["Vr.cpp"],
+    shared_libs: [
+        "liblog",
+        "libcutils",
+        "libhardware",
+        "libhwbinder",
+        "libbase",
+        "libcutils",
+        "libutils",
+        "libhidl",
+        "android.hardware.vr@1.0",
+    ],
+}
diff --git a/vr/1.0/default/Vr.cpp b/vr/1.0/default/Vr.cpp
new file mode 100644
index 0000000..4b2c603
--- /dev/null
+++ b/vr/1.0/default/Vr.cpp
@@ -0,0 +1,60 @@
+/*
+ * 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 "VrService"
+
+#include <hardware/hardware.h>
+#include <hardware/vr.h>
+#include "Vr.h"
+
+namespace android {
+namespace hardware {
+namespace vr {
+namespace V1_0 {
+namespace implementation {
+
+Vr::Vr(vr_module_t *device) : mDevice(device) {}
+
+// Methods from ::android::hardware::vr::V1_0::IVr follow.
+Return<void> Vr::init() {
+    mDevice->init(mDevice);
+    return Void();
+}
+
+Return<void> Vr::setVrMode(bool enabled)  {
+    mDevice->set_vr_mode(mDevice, enabled);
+    return Void();
+}
+
+IVr* HIDL_FETCH_IVr(const char *name) {
+    vr_module_t *vr_module;
+    const hw_module_t *hw_module = NULL;
+
+    int ret = hw_get_module(name, &hw_module);
+    if (ret == 0) {
+        return new Vr(reinterpret_cast<vr_module_t*>(
+                const_cast<hw_module_t*>(hw_module)));
+    } else {
+        ALOGE("hw_get_module %s failed: %d", name, ret);
+        return nullptr;
+    }
+}
+
+} // namespace implementation
+}  // namespace V1_0
+}  // namespace vr
+}  // namespace hardware
+}  // namespace android
diff --git a/vr/1.0/default/Vr.h b/vr/1.0/default/Vr.h
new file mode 100644
index 0000000..90694d9
--- /dev/null
+++ b/vr/1.0/default/Vr.h
@@ -0,0 +1,51 @@
+/*
+ * 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 HIDL_GENERATED_android_hardware_vr_V1_0_Vr_H_
+#define HIDL_GENERATED_android_hardware_vr_V1_0_Vr_H_
+
+#include <android/hardware/vr/1.0/IVr.h>
+#include <hardware/vr.h>
+#include <hidl/MQDescriptor.h>
+
+namespace android {
+namespace hardware {
+namespace vr {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::vr::V1_0::IVr;
+using ::android::hardware::Return;
+
+struct Vr : public IVr {
+    Vr(vr_module_t *device);
+
+    // Methods from ::android::hardware::vr::V1_0::IVr follow.
+    Return<void> init()  override;
+    Return<void> setVrMode(bool enabled)  override;
+
+  private:
+    vr_module_t    *mDevice;
+};
+
+extern "C" IVr* HIDL_FETCH_IVr(const char* name);
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace vr
+}  // namespace hardware
+}  // namespace android
+
+#endif  // HIDL_GENERATED_android_hardware_vr_V1_0_Vr_H_
diff --git a/vr/1.0/default/android.hardware.vr@1.0-service.rc b/vr/1.0/default/android.hardware.vr@1.0-service.rc
new file mode 100644
index 0000000..6177089
--- /dev/null
+++ b/vr/1.0/default/android.hardware.vr@1.0-service.rc
@@ -0,0 +1,4 @@
+service vr-1-0 /system/bin/hw/android.hardware.vr@1.0-service
+    class hal
+    user system
+    group system readproc
diff --git a/vr/1.0/default/service.cpp b/vr/1.0/default/service.cpp
new file mode 100644
index 0000000..c27ceaf
--- /dev/null
+++ b/vr/1.0/default/service.cpp
@@ -0,0 +1,27 @@
+/*
+ * 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 "android.hardware.vr@1.0-service"
+
+#include <android/hardware/vr/1.0/IVr.h>
+#include <hidl/LegacySupport.h>
+
+// Generated HIDL files
+using android::hardware::vr::V1_0::IVr;
+using android::hardware::defaultPassthroughServiceImplementation;
+
+int main() {
+    return defaultPassthroughServiceImplementation<IVr>("vr");
+}
diff --git a/wifi/1.0/Android.bp b/wifi/1.0/Android.bp
index 59ad2c5..504da7b 100644
--- a/wifi/1.0/Android.bp
+++ b/wifi/1.0/Android.bp
@@ -115,4 +115,9 @@
         "libutils",
         "libcutils",
     ],
+export_shared_lib_headers: [
+    "libhidl",
+    "libhwbinder",
+    "libutils",
+    ],
 }
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>
diff --git a/wifi/supplicant/1.0/Android.bp b/wifi/supplicant/1.0/Android.bp
index 6b4ca84..a60179d 100644
--- a/wifi/supplicant/1.0/Android.bp
+++ b/wifi/supplicant/1.0/Android.bp
@@ -83,4 +83,9 @@
         "libutils",
         "libcutils",
     ],
+export_shared_lib_headers: [
+    "libhidl",
+    "libhwbinder",
+    "libutils",
+    ],
 }