Merge "sound trigger HAL: add specialized methods for extended sound models"
diff --git a/Android.bp b/Android.bp
index 3f9b925..25a147f 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,20 +1,27 @@
 // This is an autogenerated file, do not edit.
 subdirs = [
+    "audio/2.0",
     "audio/common/2.0",
     "audio/effect/2.0",
     "benchmarks/msgq/1.0",
+    "bluetooth/1.0",
+    "biometrics/fingerprint/2.1",
     "graphics/allocator/2.0",
     "graphics/allocator/2.0/default",
+    "graphics/composer/2.1",
+    "graphics/composer/2.1/default",
     "graphics/mapper/2.0",
     "graphics/mapper/2.0/default",
+    "light/2.0",
     "memtrack/1.0",
     "memtrack/1.0/default",
-    "light/2.0",
     "nfc/1.0",
     "nfc/1.0/default",
-    "radio/1.0",
     "power/1.0",
     "power/1.0/default",
+    "radio/1.0",
+    "sensors/1.0",
+    "sensors/1.0/default",
     "soundtrigger/2.0",
     "tests/bar/1.0",
     "tests/baz/1.0",
@@ -23,8 +30,10 @@
     "tests/libhwbinder/1.0",
     "tests/msgq/1.0",
     "tests/pointer/1.0",
-    "vibrator/1.0",
+    "thermal/1.0",
+    "thermal/1.0/default",
     "vehicle/2.0",
+    "vibrator/1.0",
     "wifi/1.0",
     "wifi/supplicant/1.0",
 ]
diff --git a/audio/2.0/Android.bp b/audio/2.0/Android.bp
new file mode 100644
index 0000000..5edb042
--- /dev/null
+++ b/audio/2.0/Android.bp
@@ -0,0 +1,96 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+    name: "android.hardware.audio@2.0_genc++",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.audio@2.0",
+    srcs: [
+        "types.hal",
+        "IDevice.hal",
+        "IDevicesFactory.hal",
+        "IPrimaryDevice.hal",
+        "IStream.hal",
+        "IStreamIn.hal",
+        "IStreamOut.hal",
+        "IStreamOutCallback.hal",
+    ],
+    out: [
+        "android/hardware/audio/2.0/types.cpp",
+        "android/hardware/audio/2.0/DeviceAll.cpp",
+        "android/hardware/audio/2.0/DevicesFactoryAll.cpp",
+        "android/hardware/audio/2.0/PrimaryDeviceAll.cpp",
+        "android/hardware/audio/2.0/StreamAll.cpp",
+        "android/hardware/audio/2.0/StreamInAll.cpp",
+        "android/hardware/audio/2.0/StreamOutAll.cpp",
+        "android/hardware/audio/2.0/StreamOutCallbackAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.audio@2.0_genc++_headers",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.audio@2.0",
+    srcs: [
+        "types.hal",
+        "IDevice.hal",
+        "IDevicesFactory.hal",
+        "IPrimaryDevice.hal",
+        "IStream.hal",
+        "IStreamIn.hal",
+        "IStreamOut.hal",
+        "IStreamOutCallback.hal",
+    ],
+    out: [
+        "android/hardware/audio/2.0/types.h",
+        "android/hardware/audio/2.0/IDevice.h",
+        "android/hardware/audio/2.0/IHwDevice.h",
+        "android/hardware/audio/2.0/BnDevice.h",
+        "android/hardware/audio/2.0/BpDevice.h",
+        "android/hardware/audio/2.0/BsDevice.h",
+        "android/hardware/audio/2.0/IDevicesFactory.h",
+        "android/hardware/audio/2.0/IHwDevicesFactory.h",
+        "android/hardware/audio/2.0/BnDevicesFactory.h",
+        "android/hardware/audio/2.0/BpDevicesFactory.h",
+        "android/hardware/audio/2.0/BsDevicesFactory.h",
+        "android/hardware/audio/2.0/IPrimaryDevice.h",
+        "android/hardware/audio/2.0/IHwPrimaryDevice.h",
+        "android/hardware/audio/2.0/BnPrimaryDevice.h",
+        "android/hardware/audio/2.0/BpPrimaryDevice.h",
+        "android/hardware/audio/2.0/BsPrimaryDevice.h",
+        "android/hardware/audio/2.0/IStream.h",
+        "android/hardware/audio/2.0/IHwStream.h",
+        "android/hardware/audio/2.0/BnStream.h",
+        "android/hardware/audio/2.0/BpStream.h",
+        "android/hardware/audio/2.0/BsStream.h",
+        "android/hardware/audio/2.0/IStreamIn.h",
+        "android/hardware/audio/2.0/IHwStreamIn.h",
+        "android/hardware/audio/2.0/BnStreamIn.h",
+        "android/hardware/audio/2.0/BpStreamIn.h",
+        "android/hardware/audio/2.0/BsStreamIn.h",
+        "android/hardware/audio/2.0/IStreamOut.h",
+        "android/hardware/audio/2.0/IHwStreamOut.h",
+        "android/hardware/audio/2.0/BnStreamOut.h",
+        "android/hardware/audio/2.0/BpStreamOut.h",
+        "android/hardware/audio/2.0/BsStreamOut.h",
+        "android/hardware/audio/2.0/IStreamOutCallback.h",
+        "android/hardware/audio/2.0/IHwStreamOutCallback.h",
+        "android/hardware/audio/2.0/BnStreamOutCallback.h",
+        "android/hardware/audio/2.0/BpStreamOutCallback.h",
+        "android/hardware/audio/2.0/BsStreamOutCallback.h",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.audio@2.0",
+    generated_sources: ["android.hardware.audio@2.0_genc++"],
+    generated_headers: ["android.hardware.audio@2.0_genc++_headers"],
+    export_generated_headers: ["android.hardware.audio@2.0_genc++_headers"],
+    shared_libs: [
+        "libhidl",
+        "libhwbinder",
+        "libutils",
+        "libcutils",
+        "android.hardware.audio.common@2.0",
+        "android.hardware.audio.effect@2.0",
+    ],
+}
diff --git a/audio/2.0/IDevice.hal b/audio/2.0/IDevice.hal
new file mode 100644
index 0000000..84e0d28
--- /dev/null
+++ b/audio/2.0/IDevice.hal
@@ -0,0 +1,226 @@
+/*
+ * 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.audio@2.0;
+
+import android.hardware.audio.common@2.0;
+import IStreamIn;
+import IStreamOut;
+
+interface IDevice {
+    typedef android.hardware.audio@2.0::Result Result;
+
+    /*
+     * Returns whether the audio hardware interface has been initialized.
+     *
+     * @return retval OK on success, NOT_INITIALIZED on failure.
+     */
+    initCheck() generates (Result retval);
+
+    /*
+     * Sets the audio volume for all audio activities other than voice call. If
+     * NOT_SUPPORTED is returned, the software mixer will emulate this
+     * capability.
+     *
+     * @param volume 1.0f means unity, 0.0f is zero.
+     * @return retval operation completion status.
+     */
+    setMasterVolume(float volume) generates (Result retval);
+
+    /*
+     * Get the current master volume value for the HAL, if the HAL supports
+     * master volume control. For example, AudioFlinger will query this value
+     * from the primary audio HAL when the service starts and use the value for
+     * setting the initial master volume across all HALs. HALs which do not
+     * support this method must return NOT_SUPPORTED in 'retval'.
+     *
+     * @return retval operation completion status.
+     * @return volume 1.0f means unity, 0.0f is zero.
+     */
+    getMasterVolume() generates (Result retval, float volume);
+
+    /*
+     * Sets microphone muting state.
+     *
+     * @param mute whether microphone is muted.
+     * @return retval operation completion status.
+     */
+    setMicMute(bool mute) generates (Result retval);
+
+    /*
+     * Gets whether microphone is muted.
+     *
+     * @return retval operation completion status.
+     * @return mute whether microphone is muted.
+     */
+    getMicMute() generates (Result retval, bool mute);
+
+    /*
+     * Set the audio mute status for all audio activities. If the return value
+     * is NOT_SUPPORTED, the software mixer will emulate this capability.
+     *
+     * @param mute whether audio is muted.
+     * @return retval operation completion status.
+     */
+    setMasterMute(bool mute) generates (Result retval);
+
+    /**
+     * Get the current master mute status for the HAL, if the HAL supports
+     * master mute control. AudioFlinger will query this value from the primary
+     * audio HAL when the service starts and use the value for setting the
+     * initial master mute across all HALs. HAL must indicate that the feature
+     * is not supported by returning NOT_SUPPORTED status.
+     *
+     * @return retval operation completion status.
+     * @return mute whether audio is muted.
+     */
+    getMasterMute() generates (Result retval, bool mute);
+
+    /*
+     * Returns audio input buffer size according to parameters passed or
+     * INVALID_ARGUMENTS if one of the parameters is not supported.
+     *
+     * @param config audio configuration.
+     * @return retval operation completion status.
+     * @return bufferSize input buffer size in bytes.
+     */
+    getInputBufferSize(AudioConfig config)
+            generates (Result retval, uint64_t bufferSize);
+
+    /*
+     * This method creates and opens the audio hardware output stream.
+     *
+     * @param ioHandle handle assigned by AudioFlinger.
+     * @param device device type and (if needed) address.
+     * @param config stream configuration.
+     * @param flags additional flags.
+     * @return retval operation completion status.
+     * @return outStream created output stream.
+     */
+    openOutputStream(
+            AudioIoHandle ioHandle,
+            DeviceAddress device,
+            AudioConfig config,
+            AudioOutputFlag flags) generates (Result retval, IStreamOut outStream);
+
+    /*
+     * This method creates and opens the audio hardware input stream.
+     *
+     * @param ioHandle handle assigned by AudioFlinger.
+     * @param device device type and (if needed) address.
+     * @param config stream configuration.
+     * @param flags additional flags.
+     * @param source source specification.
+     * @return retval operation completion status.
+     * @return inStream created input stream.
+     */
+    openInputStream(
+            AudioIoHandle ioHandle,
+            DeviceAddress device,
+            AudioConfig config,
+            AudioInputFlag flags,
+            AudioSource source) generates (Result retval, IStreamIn inStream);
+
+    /*
+     * Creates an audio patch between several source and sink ports.  The handle
+     * is allocated by the HAL and must be unique for this audio HAL module.
+     *
+     * @param sources patch sources.
+     * @param sinks patch sinks.
+     * @return retval operation completion status.
+     * @return patch created patch handle.
+     */
+    createAudioPatch(vec<AudioPortConfig> sources, vec<AudioPortConfig> sinks)
+            generates (Result retval, AudioPatchHandle patch);
+
+    /*
+     * Release an audio patch.
+     *
+     * @param patch patch handle.
+     * @return retval operation completion status.
+     */
+    releaseAudioPatch(AudioPatchHandle patch) generates (Result retval);
+
+    /*
+     * Returns the list of supported attributes for a given audio port.
+     *
+     * As input, 'port' contains the information (type, role, address etc...)
+     * needed by the HAL to identify the port.
+     *
+     * As output, 'port' contains possible attributes (sampling rates, formats,
+     * channel masks, gain controllers...) for this port.
+     *
+     * @param port port identifier.
+     * @return retval operation completion status.
+     * @return port port descriptor with all parameters filled up.
+     */
+    getAudioPort(AudioPort port)
+            generates (Result retval, AudioPort port);
+
+    /*
+     * Set audio port configuration.
+     *
+     * @param config audio port configuration.
+     * @return retval operation completion status.
+     */
+    setAudioPortConfig(AudioPortConfig config) generates (Result retval);
+
+    /*
+     * Gets the HW synchronization source of the device. Calling this method is
+     * equivalent to getting AUDIO_PARAMETER_STREAM_HW_AV_SYNC on the legacy
+     * HAL.
+     *
+     * @return retval operation completion status.
+     * @return hwAvSync HW synchronization source
+     */
+    getHwAvSync() generates (Result retval, AudioHwSync hwAvSync);
+
+    /*
+     * Sets whether the screen is on. Calling this method is equivalent to
+     * setting AUDIO_PARAMETER_KEY_SCREEN_STATE on the legacy HAL.
+     */
+    setScreenState(bool turnedOn);
+
+    /*
+     * Generic method for retrieving vendor-specific parameter values.
+     * The framework does not interpret the parameters, they are passed
+     * in an opaque manner between a vendor application and HAL.
+     *
+     * @param keys parameter keys.
+     * @return retval operation completion status.
+     * @return parameters parameter key value pairs.
+     */
+    getParameters(vec<string> keys)
+            generates (Result retval, vec<ParameterValue> parameters);
+
+    /*
+     * Generic method for setting vendor-specific parameter values.
+     * The framework does not interpret the parameters, they are passed
+     * in an opaque manner between a vendor application and HAL.
+     *
+     * @param parameters parameter key value pairs.
+     * @return retval operation completion status.
+     */
+    setParameters(vec<ParameterValue> parameters) generates (Result retval);
+
+    /*
+     * Dumps information about the stream into the provided file descriptor.
+     * This is used for the dumpsys facility.
+     *
+     * @param fd dump file descriptor.
+     */
+    debugDump(handle fd);
+};
diff --git a/audio/2.0/IDevicesFactory.hal b/audio/2.0/IDevicesFactory.hal
new file mode 100644
index 0000000..a4e6956
--- /dev/null
+++ b/audio/2.0/IDevicesFactory.hal
@@ -0,0 +1,44 @@
+/*
+ * 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.audio@2.0;
+
+import android.hardware.audio.common@2.0;
+import IDevice;
+
+interface IDevicesFactory {
+    typedef android.hardware.audio@2.0::Result Result;
+
+    enum Device {
+        PRIMARY,
+        A2DP,
+        USB,
+        R_SUBMIX
+    };
+
+    /*
+     * Opens an audio device. To close the device, it is necessary to release
+     * references to the returned device object.
+     *
+     * @param device device type.
+     * @return retval operation completion status. Returns INVALID_ARGUMENTS
+     *         if there is no corresponding hardware module found,
+     *         NOT_INITIALIZED if an error occured while opening the hardware
+     *         module.
+     * @return result the interface for the created device.
+     */
+    openDevice(Device device) generates (Result retval, IDevice result);
+};
diff --git a/audio/2.0/IPrimaryDevice.hal b/audio/2.0/IPrimaryDevice.hal
new file mode 100644
index 0000000..6beddfe
--- /dev/null
+++ b/audio/2.0/IPrimaryDevice.hal
@@ -0,0 +1,123 @@
+/*
+ * 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.audio@2.0;
+
+import android.hardware.audio.common@2.0;
+import IDevice;
+
+interface IPrimaryDevice extends IDevice {
+    typedef android.hardware.audio@2.0::Result Result;
+
+    /*
+     * Sets the audio volume of a voice call.
+     *
+     * @param volume 1.0f means unity, 0.0f is zero.
+     * @return retval operation completion status.
+     */
+    setVoiceVolume(float volume) generates (Result retval);
+
+    /*
+     * This method is used to notify the HAL about audio mode changes.
+     *
+     * @param mode new mode.
+     * @return retval operation completion status.
+     */
+    setMode(AudioMode mode) generates (Result retval);
+
+    /*
+     * Gets whether BT SCO Noise Reduction and Echo Cancellation are enabled.
+     * Calling this method is equivalent to getting AUDIO_PARAMETER_KEY_BT_NREC
+     * on the legacy HAL.
+     *
+     * @return retval operation completion status.
+     * @return enabled whether BT SCO NR + EC are enabled.
+     */
+    getBtScoNrecEnabled() generates (Result retval, bool enabled);
+
+    /*
+     * Sets whether BT SCO Noise Reduction and Echo Cancellation are enabled.
+     * Calling this method is equivalent to setting AUDIO_PARAMETER_KEY_BT_NREC
+     * on the legacy HAL.
+     *
+     * @param enabled whether BT SCO NR + EC are enabled.
+     * @return retval operation completion status.
+     */
+    setBtScoNrecEnabled(bool enabled) generates (Result retval);
+
+    /*
+     * Gets whether BT SCO Wideband mode is enabled. Calling this method is
+     * equivalent to getting AUDIO_PARAMETER_KEY_BT_SCO_WB on the legacy HAL.
+     *
+     * @return retval operation completion status.
+     * @return enabled whether BT Wideband is enabled.
+     */
+    getBtScoWidebandEnabled() generates (Result retval, bool enabled);
+
+    /*
+     * Sets whether BT SCO Wideband mode is enabled. Calling this method is
+     * equivalent to setting AUDIO_PARAMETER_KEY_BT_SCO_WB on the legacy HAL.
+     *
+     * @param enabled whether BT Wideband is enabled.
+     * @return retval operation completion status.
+     */
+    setBtScoWidebandEnabled(bool enabled) generates (Result retval);
+
+    enum TtyMode {
+        OFF,
+        VCO,
+        HCO,
+        FULL
+    };
+
+    /*
+     * Gets current TTY mode selection. Calling this method is equivalent to
+     * getting AUDIO_PARAMETER_KEY_TTY_MODE on the legacy HAL.
+     *
+     * @return retval operation completion status.
+     * @return mode TTY mode.
+     */
+    getTtyMode() generates (Result retval, TtyMode mode);
+
+    /*
+     * Sets current TTY mode. Calling this method is equivalent to setting
+     * AUDIO_PARAMETER_KEY_TTY_MODE on the legacy HAL.
+     *
+     * @param mode TTY mode.
+     * @return retval operation completion status.
+     */
+    setTtyMode(TtyMode mode) generates (Result retval);
+
+    /*
+     * Gets whether Hearing Aid Compatibility - Telecoil (HAC-T) mode is
+     * enabled. Calling this method is equivalent to getting
+     * AUDIO_PARAMETER_KEY_HAC on the legacy HAL.
+     *
+     * @return retval operation completion status.
+     * @return enabled whether HAC mode is enabled.
+     */
+    getHacEnabled() generates (Result retval, bool enabled);
+
+    /*
+     * Sets whether Hearing Aid Compatibility - Telecoil (HAC-T) mode is
+     * enabled. Calling this method is equivalent to setting
+     * AUDIO_PARAMETER_KEY_HAC on the legacy HAL.
+     *
+     * @param enabled whether HAC mode is enabled.
+     * @return retval operation completion status.
+     */
+    setHacEnabled(bool enabled) generates (Result retval);
+};
diff --git a/audio/2.0/IStream.hal b/audio/2.0/IStream.hal
new file mode 100644
index 0000000..09ba42a
--- /dev/null
+++ b/audio/2.0/IStream.hal
@@ -0,0 +1,229 @@
+/*
+ * 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.audio@2.0;
+
+import android.hardware.audio.common@2.0;
+import android.hardware.audio.effect@2.0::IEffect;
+
+interface IStream {
+    typedef android.hardware.audio@2.0::Result Result;
+
+    /*
+     * Return the frame size (number of bytes per sample).
+     *
+     * @return frameSize frame size in bytes.
+     */
+    getFrameSize() generates (uint64_t frameSize);
+
+    /*
+     * Return the frame count of the buffer. Calling this method is equivalent
+     * to getting AUDIO_PARAMETER_STREAM_FRAME_COUNT on the legacy HAL.
+     *
+     * @return count frame count.
+     */
+    getFrameCount() generates (uint64_t count);
+
+    /*
+     * Return the size of input/output buffer in bytes for this stream.
+     * It must be a multiple of the frame size.
+     *
+     * @return buffer buffer size in bytes.
+     */
+    getBufferSize() generates (uint64_t bufferSize);
+
+    /*
+     * Return the sampling rate in Hz.
+     *
+     * @return sampleRateHz sample rate in Hz.
+     */
+    getSampleRate() generates (uint32_t sampleRateHz);
+
+    /*
+     * Return supported sampling rates of the stream. Calling this method is
+     * equivalent to getting AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES on the
+     * legacy HAL.
+     *
+     * @return sampleRateHz supported sample rates.
+     */
+    getSupportedSampleRates() generates (vec<uint32_t> sampleRates);
+
+    /*
+     * Sets the sampling rate of the stream. Calling this method is equivalent
+     * to setting AUDIO_PARAMETER_STREAM_SAMPLING_RATE on the legacy HAL.
+     *
+     * @param sampleRateHz sample rate in Hz.
+     * @return retval operation completion status.
+     */
+    setSampleRate(uint32_t sampleRateHz) generates (Result retval);
+
+    /*
+     * Return the channel mask of the stream.
+     *
+     * @return mask channel mask.
+     */
+    getChannelMask() generates (AudioChannelMask mask);
+
+    /*
+     * Return supported channel masks of the stream. Calling this method is
+     * equivalent to getting AUDIO_PARAMETER_STREAM_SUP_CHANNELS on the legacy
+     * HAL.
+     *
+     * @return masks supported audio masks.
+     */
+    getSupportedChannelMasks() generates (vec<AudioChannelMask> masks);
+
+    /*
+     * Sets the channel mask of the stream. Calling this method is equivalent to
+     * setting AUDIO_PARAMETER_STREAM_CHANNELS on the legacy HAL.
+     *
+     * @param format audio format.
+     * @return retval operation completion status.
+     */
+    setChannelMask(AudioChannelMask mask) generates (Result retval);
+
+    /*
+     * Return the audio format of the stream.
+     *
+     * @return format audio format.
+     */
+    getFormat() generates (AudioFormat format);
+
+    /*
+     * Return supported audio formats of the stream. Calling this method is
+     * equivalent to getting AUDIO_PARAMETER_STREAM_SUP_FORMATS on the legacy
+     * HAL.
+     *
+     * @return formats supported audio formats.
+     */
+    getSupportedFormats() generates (vec<AudioFormat> formats);
+
+    /*
+     * Sets the audio format of the stream. Calling this method is equivalent to
+     * setting AUDIO_PARAMETER_STREAM_FORMAT on the legacy HAL.
+     *
+     * @param format audio format.
+     * @return retval operation completion status.
+     */
+    setFormat(AudioFormat format) generates (Result retval);
+
+    /*
+     * Convenience method for retrieving several stream parameters in
+     * one transaction.
+     *
+     * @return sampleRateHz sample rate in Hz.
+     * @return mask channel mask.
+     * @return format audio format.
+     */
+    getAudioProperties() generates (
+            uint32_t sampleRateHz, AudioChannelMask mask, AudioFormat format);
+
+    /*
+     * Applies audio effect to the stream.
+     *
+     * @param effect the effect to apply.
+     * @return retval operation completion status.
+     */
+    addEffect(IEffect effect) generates (Result retval);
+
+    /*
+     * Stops application of the effect to the stream.
+     *
+     * @param effect the effect to apply.
+     * @return retval operation completion status.
+     */
+    removeEffect(IEffect effect) generates (Result retval);
+
+    /*
+     * Put the audio hardware input/output into standby mode.
+     * Driver must exit from standby mode at the next I/O operation.
+     *
+     * @return retval operation completion status.
+     */
+    standby() generates (Result retval);
+
+    /*
+     * Return the set of device(s) which this stream is connected to.
+     *
+     * @return retval operation completion status.
+     * @return device set of device(s) which this stream is connected to.
+     */
+    getDevice() generates (Result retval, AudioDevice device);
+
+    /*
+     * Connects the stream to the device.
+     *
+     * This method must only be used for HALs that do not support
+     * 'IDevice.createAudioPatch' method. Calling this method is
+     * equivalent to setting AUDIO_PARAMETER_STREAM_ROUTING in the legacy HAL
+     * interface.
+     *
+     * @param address device to connect the stream to.
+     * @return retval operation completion status.
+     */
+    setDevice(DeviceAddress address) generates (Result retval);
+
+    /*
+     * Notifies the stream about device connection state. Calling this method is
+     * equivalent to setting AUDIO_PARAMETER_DEVICE_[DIS]CONNECT on the legacy
+     * HAL.
+     *
+     * @param address audio device specification.
+     * @param connected whether the device is connected.
+     * @return retval operation completion status.
+     */
+    setConnectedState(DeviceAddress address, bool connected)
+            generates (Result retval);
+
+    /*
+     * Sets the HW synchronization source. Calling this method is equivalent to
+     * setting AUDIO_PARAMETER_STREAM_HW_AV_SYNC on the legacy HAL.
+     *
+     * @param hwAvSync HW synchronization source
+     * @return retval operation completion status.
+     */
+    setHwAvSync(AudioHwSync hwAvSync) generates (Result retval);
+
+    /*
+     * Generic method for retrieving vendor-specific parameter values.
+     * The framework does not interpret the parameters, they are passed
+     * in an opaque manner between a vendor application and HAL.
+     *
+     * @param keys parameter keys.
+     * @return retval operation completion status.
+     * @return parameters parameter key value pairs.
+     */
+    getParameters(vec<string> keys)
+            generates (Result retval, vec<ParameterValue> parameters);
+
+    /*
+     * Generic method for setting vendor-specific parameter values.
+     * The framework does not interpret the parameters, they are passed
+     * in an opaque manner between a vendor application and HAL.
+     *
+     * @param parameters parameter key value pairs.
+     * @return retval operation completion status.
+     */
+    setParameters(vec<ParameterValue> parameters) generates (Result retval);
+
+    /*
+     * Dumps information about the stream into the provided file descriptor.
+     * This is used for the dumpsys facility.
+     *
+     * @param fd dump file descriptor.
+     */
+    debugDump(handle fd);
+};
diff --git a/audio/2.0/IStreamIn.hal b/audio/2.0/IStreamIn.hal
new file mode 100644
index 0000000..049df75
--- /dev/null
+++ b/audio/2.0/IStreamIn.hal
@@ -0,0 +1,85 @@
+/*
+ * 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.audio@2.0;
+
+import android.hardware.audio.common@2.0;
+import IStream;
+
+interface IStreamIn extends IStream {
+    typedef android.hardware.audio@2.0::Result Result;
+
+    /*
+     * Returns the source descriptor of the input stream. Calling this method is
+     * equivalent to getting AUDIO_PARAMETER_STREAM_INPUT_SOURCE on the legacy
+     * HAL.
+     *
+     * @return retval operation completion status.
+     * @return source audio source.
+     */
+    getAudioSource() generates (Result retval, AudioSource source);
+
+    /*
+     * Set the input gain for the audio driver.
+     *
+     * @param gain 1.0f is unity, 0.0f is zero.
+     * @result retval operation completion status.
+     */
+    setGain(float gain) generates (Result retval);
+
+    /*
+     * Read audio buffer in from driver. If at least one frame was read prior to
+     * the error, 'read' must return that byte count and then return an error
+     * in the subsequent call.
+     *
+     * @param size maximum amount of bytes to read.
+     * @return retval operation completion status.
+     * @return data audio data.
+     */
+    // TODO(mnaganov): Replace with FMQ version.
+    read(uint64_t size) generates (Result retval, vec<uint8_t> data);
+
+    /*
+     * Return the amount of input frames lost in the audio driver since the last
+     * call of this function.
+     *
+     * Audio driver is expected to reset the value to 0 and restart counting
+     * upon returning the current value by this function call. Such loss
+     * typically occurs when the user space process is blocked longer than the
+     * capacity of audio driver buffers.
+     *
+     * @return retval operation completion status.
+     * @return framesLost the number of input audio frames lost.
+     */
+    getInputFramesLost() generates (Result retval, uint32_t framesLost);
+
+    /**
+     * Return a recent count of the number of audio frames received and the
+     * clock time associated with that frame count.
+     *
+     * @return retval INVALID_STATE if the device is not ready/available,
+     *                NOT_SUPPORTED if the command is not supported,
+     *                OK otherwise.
+     * @return frames the total frame count received. This must be as early in
+     *                the capture pipeline as possible. In general, frames
+     *                must be non-negative and must not go "backwards".
+     * @return time is the clock monotonic time when frames was measured. In
+     *              general, time must be a positive quantity and must not
+     *              go "backwards".
+     */
+    getCapturePosition()
+            generates (Result retval, uint64_t frames, uint64_t time);
+};
diff --git a/audio/2.0/IStreamOut.hal b/audio/2.0/IStreamOut.hal
new file mode 100644
index 0000000..adce538
--- /dev/null
+++ b/audio/2.0/IStreamOut.hal
@@ -0,0 +1,191 @@
+/*
+ * 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.audio@2.0;
+
+import android.hardware.audio.common@2.0;
+import IStream;
+import IStreamOutCallback;
+
+interface IStreamOut extends IStream {
+    typedef android.hardware.audio@2.0::Result Result;
+
+    /*
+     * Return the audio hardware driver estimated latency in milliseconds.
+     *
+     * @return latencyMs latency in milliseconds.
+     */
+    getLatency() generates (uint32_t latencyMs);
+
+    /*
+     * This method is used in situations where audio mixing is done in the
+     * hardware. This method serves as a direct interface with hardware,
+     * allowing to directly set the volume as apposed to via the framework.
+     * This method might produce multiple PCM outputs or hardware accelerated
+     * codecs, such as MP3 or AAC.
+     *
+     * @param left left channel attenuation, 1.0f is unity, 0.0f is zero.
+     * @param right right channel attenuation, 1.0f is unity, 0.0f is zero.
+     * @return retval operation completion status.
+     */
+    setVolume(float left, float right) generates (Result retval);
+
+    /*
+     * Write audio buffer to driver. On success, sets 'retval' to 'OK', and
+     * returns number of bytes written. If at least one frame was written
+     * successfully prior to the error, it is suggested that the driver return
+     * that successful (short) byte count and then return an error in the
+     * subsequent call.
+     *
+     * If 'setCallback' has previously been called to enable non-blocking mode
+     * then 'write' is not allowed to block. It must write only the number of
+     * bytes that currently fit in the driver/hardware buffer and then return
+     * this byte count. If this is less than the requested write size the
+     * callback function must be called when more space is available in the
+     * driver/hardware buffer.
+     *
+     * @param data audio data.
+     * @return retval operation completion status.
+     * @return written number of bytes written.
+     */
+    // TODO(mnaganov): Replace with FMQ version.
+    write(vec<uint8_t> data) generates (Result retval, uint64_t written);
+
+    /*
+     * Return the number of audio frames written by the audio DSP to DAC since
+     * the output has exited standby.
+     *
+     * @return retval operation completion status.
+     * @return dspFrames number of audio frames written.
+     */
+    getRenderPosition() generates (Result retval, uint32_t dspFrames);
+
+    /*
+     * Get the local time at which the next write to the audio driver will be
+     * presented. The units are microseconds, where the epoch is decided by the
+     * local audio HAL.
+     *
+     * @return retval operation completion status.
+     * @return timestampUs time of the next write.
+     */
+    getNextWriteTimestamp() generates (Result retval, int64_t timestampUs);
+
+    /*
+     * Set the callback interface for notifying completion of non-blocking
+     * write and drain.
+     *
+     * Calling this function implies that all future 'write' and 'drain'
+     * must be non-blocking and use the callback to signal completion.
+     *
+     * @return retval operation completion status.
+     */
+    setCallback(IStreamOutCallback callback) generates (Result retval);
+
+    /*
+     * Returns whether HAL supports pausing and resuming of streams.
+     *
+     * @return supportsPause true if pausing is supported.
+     * @return supportsResume true if resume is supported.
+     */
+    supportsPauseAndResume()
+            generates (bool supportsPause, bool supportsResume);
+
+    /**
+     * Notifies to the audio driver to stop playback however the queued buffers
+     * are retained by the hardware. Useful for implementing pause/resume. Empty
+     * implementation if not supported however must be implemented for hardware
+     * with non-trivial latency. In the pause state, some audio hardware may
+     * still be using power. Client code may consider calling 'suspend' after a
+     * timeout to prevent that excess power usage.
+     *
+     * Implementation of this function is mandatory for offloaded playback.
+     *
+     * @return retval operation completion status.
+     */
+    pause() generates (Result retval);
+
+    /*
+     * Notifies to the audio driver to resume playback following a pause.
+     * Returns error INVALID_STATE if called without matching pause.
+     *
+     * Implementation of this function is mandatory for offloaded playback.
+     *
+     * @return retval operation completion status.
+     */
+    resume() generates (Result retval);
+
+    /*
+     * Returns whether HAL supports draining of streams.
+     *
+     * @return supports true if draining is supported.
+     */
+    supportsDrain() generates (bool supports);
+
+    /**
+     * Requests notification when data buffered by the driver/hardware has been
+     * played. If 'setCallback' has previously been called to enable
+     * non-blocking mode, then 'drain' must not block, instead it must return
+     * quickly and completion of the drain is notified through the callback. If
+     * 'setCallback' has not been called, then 'drain' must block until
+     * completion.
+     *
+     * If 'type' is 'AUDIO_DRAIN_ALL', the drain completes when all previously
+     * written data has been played.
+     *
+     * If 'type' is 'AUDIO_DRAIN_EARLY_NOTIFY', the drain completes shortly
+     * before all data for the current track has played to allow time for the
+     * framework to perform a gapless track switch.
+     *
+     * Drain must return immediately on 'stop' and 'flush' calls.
+     *
+     * Implementation of this function is mandatory for offloaded playback.
+     *
+     * @param type type of drain.
+     * @return retval operation completion status.
+     */
+    drain(AudioDrain type) generates (Result retval);
+
+    /*
+     * Notifies to the audio driver to flush the queued data. Stream must
+     * already be paused before calling 'flush'.
+     *
+     * Implementation of this function is mandatory for offloaded playback.
+     *
+     * @return retval operation completion status.
+     */
+    flush() generates (Result retval);
+
+    /*
+     * Return a recent count of the number of audio frames presented to an
+     * external observer. This excludes frames which have been written but are
+     * still in the pipeline. The count is not reset to zero when output enters
+     * standby. Also returns the value of CLOCK_MONOTONIC as of this
+     * presentation count. The returned count is expected to be 'recent', but
+     * does not need to be the most recent possible value. However, the
+     * associated time must correspond to whatever count is returned.
+     *
+     * Example: assume that N+M frames have been presented, where M is a 'small'
+     * number. Then it is permissible to return N instead of N+M, and the
+     * timestamp must correspond to N rather than N+M. The terms 'recent' and
+     * 'small' are not defined. They reflect the quality of the implementation.
+     *
+     * @return retval operation completion status.
+     * @return frames count of presented audio frames.
+     * @return timeStamp associated clock time.
+     */
+    getPresentationPosition()
+            generates (Result retval, uint64_t frames, TimeSpec timeStamp);
+};
diff --git a/audio/2.0/IStreamOutCallback.hal b/audio/2.0/IStreamOutCallback.hal
new file mode 100644
index 0000000..267c46d
--- /dev/null
+++ b/audio/2.0/IStreamOutCallback.hal
@@ -0,0 +1,37 @@
+/*
+ * 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.audio@2.0;
+
+/*
+ * Asynchronous write callback interface.
+ */
+interface IStreamOutCallback {
+    /*
+     * Non blocking write completed.
+     */
+    onWriteReady();
+
+    /*
+     * Drain completed.
+     */
+    onDrainReady();
+
+    /*
+     * Stream hit an error.
+     */
+    onError();
+};
diff --git a/audio/2.0/types.hal b/audio/2.0/types.hal
new file mode 100644
index 0000000..6369885
--- /dev/null
+++ b/audio/2.0/types.hal
@@ -0,0 +1,72 @@
+/*
+ * 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.audio@2.0;
+
+import android.hardware.audio.common@2.0;
+
+enum Result {
+    OK,
+    NOT_INITIALIZED,
+    INVALID_ARGUMENTS,
+    INVALID_STATE,
+    NOT_SUPPORTED
+};
+
+@export(name="audio_drain_type_t", value_prefix="AUDIO_DRAIN_")
+enum AudioDrain {
+    /* drain() returns when all data has been played. */
+    ALL,
+    /* drain() returns a short time before all data from the current track has
+       been played to give time for gapless track switch. */
+    EARLY_NOTIFY
+};
+
+/*
+ * A substitute for POSIX timespec.
+ */
+struct TimeSpec {
+    uint64_t tvSec;   // seconds
+    uint64_t tvNSec;  // nanoseconds
+};
+
+/*
+ * IEEE 802 MAC address.
+ */
+typedef uint8_t[6] MacAddress;
+
+struct ParameterValue {
+    string key;
+    string value;
+};
+
+/*
+ * Specifies a device in case when several devices of the same type
+ * can be connected (e.g. BT A2DP, USB).
+ */
+struct DeviceAddress {
+    AudioDevice device;  // discriminator
+    union Address {
+        MacAddress mac;     // used for BLUETOOTH_A2DP_*
+        uint8_t[4] ipv4;    // used for IP
+        struct Alsa {
+            int32_t card;
+            int32_t device;
+        } alsa;             // used for USB_*
+        int32_t busId;      // used for BUS
+    } address;
+    string rSubmixAddress;  // used for REMOTE_SUBMIX
+};
diff --git a/benchmarks/msgq/1.0/IBenchmarkMsgQ.hal b/benchmarks/msgq/1.0/IBenchmarkMsgQ.hal
index 2e50335..3af0b71 100644
--- a/benchmarks/msgq/1.0/IBenchmarkMsgQ.hal
+++ b/benchmarks/msgq/1.0/IBenchmarkMsgQ.hal
@@ -20,36 +20,37 @@
     /*
      * This method requests the service to set up Synchronous read/write
      * wait-free FMQ with the client as reader.
-     * @return ret Will be 0 if the setup is successful.
+     * @return ret Will be true if the setup was successful, false otherwise.
      * @return mqDescIn This structure describes the FMQ that was set up
      * by the service. Client can use it to set up the FMQ at its end.
      */
     configureClientInboxSyncReadWrite()
-        generates(int32_t ret, MQDescriptorSync mqDescIn);
+        generates(bool ret, MQDescriptorSync mqDescIn);
 
     /*
      * This method requests the service to set up Synchronous read/write
      * wait-free FMQ with the client as writer.
-     * @return Will be 0 if the setup is successful.
+     * @return ret Will be true if the setup was successful, false otherwise.
      * @return mqDescOut This structure describes the FMQ that was set up
      * by the service. Client can use it to set up the FMQ at its end.
      */
     configureClientOutboxSyncReadWrite()
-        generates(int32_t ret, MQDescriptorSync mqDescOut);
+        generates(bool ret, MQDescriptorSync mqDescOut);
 
     /*
      * This method request the service to write into the FMQ.
      * @param count Number to messages to write.
-     * @ret Number of messages succesfully written.
+     * @return ret Will be true if the write operation was successful,
+     * false otherwise.
      */
-    requestWrite(int32_t count) generates (int32_t ret);
+    requestWrite(int32_t count) generates (bool ret);
 
     /*
      * This method request the service to read from the FMQ.
      * @param count Number to messages to read.
-     * @ret Number of messages succesfully read.
+     * @ret Will be true if the read operation was successful, false otherwise.
      */
-    requestRead(int32_t count) generates (int32_t ret);
+    requestRead(int32_t count) generates (bool ret);
 
     /*
      * This method kicks off a benchmarking experiment where
diff --git a/biometrics/fingerprint/2.1/Android.bp b/biometrics/fingerprint/2.1/Android.bp
new file mode 100644
index 0000000..77b41b8
--- /dev/null
+++ b/biometrics/fingerprint/2.1/Android.bp
@@ -0,0 +1,54 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+    name: "android.hardware.biometrics.fingerprint@2.1_genc++",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.biometrics.fingerprint@2.1",
+    srcs: [
+        "types.hal",
+        "IBiometricsFingerprint.hal",
+        "IBiometricsFingerprintClientCallback.hal",
+    ],
+    out: [
+        "android/hardware/biometrics/fingerprint/2.1/types.cpp",
+        "android/hardware/biometrics/fingerprint/2.1/BiometricsFingerprintAll.cpp",
+        "android/hardware/biometrics/fingerprint/2.1/BiometricsFingerprintClientCallbackAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.biometrics.fingerprint@2.1_genc++_headers",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.biometrics.fingerprint@2.1",
+    srcs: [
+        "types.hal",
+        "IBiometricsFingerprint.hal",
+        "IBiometricsFingerprintClientCallback.hal",
+    ],
+    out: [
+        "android/hardware/biometrics/fingerprint/2.1/types.h",
+        "android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h",
+        "android/hardware/biometrics/fingerprint/2.1/IHwBiometricsFingerprint.h",
+        "android/hardware/biometrics/fingerprint/2.1/BnBiometricsFingerprint.h",
+        "android/hardware/biometrics/fingerprint/2.1/BpBiometricsFingerprint.h",
+        "android/hardware/biometrics/fingerprint/2.1/BsBiometricsFingerprint.h",
+        "android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprintClientCallback.h",
+        "android/hardware/biometrics/fingerprint/2.1/IHwBiometricsFingerprintClientCallback.h",
+        "android/hardware/biometrics/fingerprint/2.1/BnBiometricsFingerprintClientCallback.h",
+        "android/hardware/biometrics/fingerprint/2.1/BpBiometricsFingerprintClientCallback.h",
+        "android/hardware/biometrics/fingerprint/2.1/BsBiometricsFingerprintClientCallback.h",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.biometrics.fingerprint@2.1",
+    generated_sources: ["android.hardware.biometrics.fingerprint@2.1_genc++"],
+    generated_headers: ["android.hardware.biometrics.fingerprint@2.1_genc++_headers"],
+    export_generated_headers: ["android.hardware.biometrics.fingerprint@2.1_genc++_headers"],
+    shared_libs: [
+        "libhidl",
+        "libhwbinder",
+        "libutils",
+        "libcutils",
+    ],
+}
diff --git a/biometrics/fingerprint/2.1/IBiometricsFingerprint.hal b/biometrics/fingerprint/2.1/IBiometricsFingerprint.hal
new file mode 100644
index 0000000..a9c3190
--- /dev/null
+++ b/biometrics/fingerprint/2.1/IBiometricsFingerprint.hal
@@ -0,0 +1,157 @@
+/*
+ * 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.biometrics.fingerprint@2.1;
+
+interface IBiometricsFingerprint {
+  /*
+   * Fingerprint pre-enroll enroll request:
+   * Generates a unique token to upper layers to indicate the start of
+   * an enrollment transaction. pre-enroll and post-enroll specify
+   * a pin/password cleared time window where enrollment is allowed.
+   * Pre-enroll only generates a challenge, a full hardwareAuthToken is
+   * generated by trustzone after verifying a pin/password/swipe. This is to
+   * ensure adding a new fingerprint template was preceded by some kind of
+   * credential confirmation (e.g. device password).
+   *
+   * @return 0 if function failed, a uint64_t of challenge otherwise.
+   */
+  @callflow(next={"enroll", "postEnroll"})
+  preEnroll() generates (uint64_t authChallenge);
+
+  /*
+   * Fingerprint enroll request:
+   * Switches the HAL state machine to collect and store a new fingerprint
+   * template. Switches back as soon as enroll is complete, signalled by
+   * (fingerprintMsg.type == FINGERPRINT_TEMPLATE_ENROLLING &&
+   *  fingerprintMsg.data.enroll.samplesRemaining == 0)
+   * or after timeoutSec seconds.
+   * The fingerprint template must be assigned to the group gid.
+   *
+   * @param hat a valid Hardware Authentication Token (HAT), generated
+   * as a result of a preEnroll() call.
+   * @param gid a framework defined fingerprint set (group) id.
+   * @param timeoutSec a timeout in seconds.
+   *
+   * @return isOk indicates if the request is accepted.
+   * @return debugErrno is a value the framework logs in case isOk == false.
+   *
+   * A notify() function may be called with a more detailed error structure.
+   */
+  @callflow(next={"cancel", "enroll", "postEnroll", "remove"})
+  enroll(HwAuthToken hat, uint32_t gid, uint32_t timeoutSec)
+      generates (bool isOk, int32_t debugErrno);
+
+  /*
+   * Finishes the enroll operation and invalidates the preEnroll() generated
+   * challenge. This must be called at the end of a multi-finger enrollment
+   * session to indicate that no more fingers may be added.
+   *
+   * @return isOk indicates if the request is accepted.
+   * @return debugErrno is a value the framework logs in case isOk == false.
+   */
+  @callflow(next={"authenticate", "setActiveGroup", "enumerate", "remove"})
+  postEnroll() generates (bool isOk, int32_t debugErrno);
+
+  /*
+   * getAuthenticatorId:
+   * Returns a token associated with the current fingerprint set. This value
+   * must change whenever a new fingerprint is enrolled, thus creating a new
+   * fingerprint set.
+   *
+   * @return getAuthenticatorIdRet current authenticator id, 0 if function
+   * failed.
+   */
+  @callflow(next={"authenticate"})
+  getAuthenticatorId() generates (uint64_t AuthenticatorId);
+
+  /*
+   * Cancel pending enroll or authenticate, sending FINGERPRINT_ERROR_CANCELED
+   * to all running clients. Switches the HAL state machine back to the idle
+   * state. Unlike enrollDone() doesn't invalidate the preEnroll() challenge.
+   *
+   * @return isOk indicates if the request is accepted.
+   * @return debugErrno is a value the framework logs in case isOk == false.
+   */
+  @callflow(next={"authenticate", "enroll", "enumerate", "remove",
+    "setActiveGroup"})
+  cancel() generates (bool isOk, int32_t debugErrno);
+
+  /*
+   * Enumerate all the fingerprint templates found in the directory set by
+   * setActiveGroup():
+   * For each template found a notify() must be called with:
+   * fingerprintMsg.type == FINGERPRINT_TEMPLATE_ENUMERATED
+   * fingerprintMsg.data.enumerated.finger indicating a template id
+   * fingerprintMsg.data.enumerated.remainingTemplates indicating how many more
+   * enumeration messages to expect.
+   *
+   * @return isOk indicates if the request is accepted.
+   * @return debugErrno is a value the framework logs in case isOk == false.
+   */
+  @callflow(next={"remove", "enroll", "authenticate", "setActiveGroup"})
+  enumerate() generates (bool isOk, int32_t debugErrno);
+
+  /*
+   * Fingerprint remove request:
+   * Deletes fingerprint template(s).
+   * Works only within the path set by setActiveGroup().
+   * For each template found a notify() must be called with:
+   * fingerprintMsg.type == FINGERPRINT_TEMPLATE_REMOVED
+   * fingerprintMsg.data.removed.finger indicating the template id deleted
+   * fingerprintMsg.data.removed.remainingTemplates indicating how many more
+   * templates must be deleted by this operation.
+   *
+   * @param gid group id must match the last group set by setActiveGroup().
+   * @param fid template id to delete or 0 to delete all templates within the
+   * current group.
+   *
+   * @return isOk indicates if the request is accepted.
+   * @return debugErrno is a value the framework logs in case isOk == false.
+   */
+  @callflow(next={"enumerate", "authenticate", "cancel", "getAuthenticatorId",
+    "setActiveGroup"})
+  remove(uint32_t gid, uint32_t fid) generates (bool isOk, int32_t debugErrno);
+
+  /*
+   * Restricts the HAL operation to a set of fingerprints belonging to a group
+   * provided. The caller must provide a path to a storage location within the
+   * user's data directory.
+   *
+   * @param gid the fingerprint group (set) id.
+   * @param storePath filesystem path to the template storage directory.
+   *
+   * @return isOk indicates if the request is accepted.
+   * @return debugErrno is a value the framework logs in case isOk == false.
+   */
+  @callflow(next={"authenticate", "preEnroll", "enumerate", "remove"})
+  @entry
+  setActiveGroup(uint32_t gid, string storePath)
+      generates (bool isOk, int32_t debugErrno);
+
+  /*
+   * Authenticates an operation identifed by operationId
+   *
+   * @param operationId operation id.
+   * @param gid fingerprint group id.
+   *
+   * @return isOk indicates if the request is accepted.
+   * @return debugErrno is a value the framework logs in case isOk == false.
+   */
+  @callflow(next={"cancel", "preEnroll", "remove"})
+  authenticate(uint64_t operationId, uint32_t gid)
+      generates (bool isOk, int32_t debugErrno);
+};
diff --git a/biometrics/fingerprint/2.1/IBiometricsFingerprintClientCallback.hal b/biometrics/fingerprint/2.1/IBiometricsFingerprintClientCallback.hal
new file mode 100644
index 0000000..365e905
--- /dev/null
+++ b/biometrics/fingerprint/2.1/IBiometricsFingerprintClientCallback.hal
@@ -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.
+ */
+
+package android.hardware.biometrics.fingerprint@2.1;
+
+interface IBiometricsFingerprintClientCallback {
+    /* This function is the response chanel for all messages
+     * coming from the fingerprint HAL to the framework
+     *
+     * @param msg a union of message structures identified by
+     * FingerprintMsg.type
+     */
+    oneway notify(FingerprintMsg msg);
+};
diff --git a/biometrics/fingerprint/2.1/types.hal b/biometrics/fingerprint/2.1/types.hal
new file mode 100644
index 0000000..cf68c04
--- /dev/null
+++ b/biometrics/fingerprint/2.1/types.hal
@@ -0,0 +1,148 @@
+/*
+ * 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.biometrics.fingerprint@2.1;
+
+/*
+ * Fingerprint errors are meant to tell the framework to terminate the current
+ * operation and ask for the user to correct the situation. These will almost
+ * always result in messaging and user interaction to correct the problem.
+ *
+ * For example, ERROR_CANCELED should follow any acquisition message that
+ * results in a situation where the current operation can't continue without
+ * user interaction. For example, if the sensor is dirty during enrollment and
+ * no further enrollment progress can be made, send ACQUIRED_IMAGER_DIRTY
+ * followed by ERROR_CANCELED.
+ */
+enum FingerprintError : int32_t {
+  /* The hardware has an error that can't be resolved. */
+  ERROR_HW_UNAVAILABLE = 1,
+  /* Bad data; operation can't continue */
+  ERROR_UNABLE_TO_PROCESS = 2,
+  /* The operation has timed out waiting for user input. */
+  ERROR_TIMEOUT = 3,
+  /* No space available to store a template */
+  ERROR_NO_SPACE = 4,
+  /* The current operation has been canceled */
+  ERROR_CANCELED = 5,
+  /* Unable to remove a template */
+  ERROR_UNABLE_TO_REMOVE = 6,
+};
+
+/*
+ * Fingerprint acquisition info is meant as feedback for the current operation.
+ * Anything but ACQUIRED_GOOD must be shown to the user as feedback on how to
+ * take action on the current operation. For example, ACQUIRED_IMAGER_DIRTY may
+ * be used to tell the user to clean the sensor if it is detected to be dirty.
+ * If this causes the current operation to fail, an additional ERROR_CANCELED
+ * must be sent to stop the operation in progress (e.g. enrollment).
+ * In general, these messages will result in a "Try again" message.
+ */
+enum FingerprintAcquiredInfo : int32_t {
+  ACQUIRED_GOOD = 0,
+  /* sensor needs more data, i.e. longer swipe. */
+  ACQUIRED_PARTIAL = 1,
+  /* image doesn't contain enough detail for recognition*/
+  ACQUIRED_INSUFFICIENT = 2,
+  /* sensor needs to be cleaned */
+  ACQUIRED_IMAGER_DIRTY = 3,
+  /* mostly swipe-type sensors; not enough data collected */
+  ACQUIRED_TOO_SLOW = 4,
+  /* vendor-specific acquisition messages start here */
+  ACQUIRED_TOO_FAST = 5,
+  ACQUIRED_VENDOR_BASE = 1000,
+};
+
+/* TODO import from keymaster HIDL when available */
+enum HwAuthenticatorType : uint32_t {
+  HW_AUTH_NONE = 0,
+  HW_AUTH_PASSWORD = 1,
+  HW_AUTH_FINGERPRINT = 2,
+  HW_AUTH_ANY = 0xffffffff,
+};
+
+/* TODO import from keymaster HIDL when available */
+struct HwAuthToken {
+  uint8_t version;
+  uint64_t challenge;
+  uint64_t userId;
+  uint64_t authenticatorId;
+  uint32_t authenticatorType;
+  uint64_t timestamp;
+  uint8_t[32] hmac;
+};
+
+struct FingerprintFingerId {
+  /* Group ID */
+  uint32_t gid;
+  /* Fingerprint template ID */
+  uint32_t fid;
+};
+
+struct FingerprintEnroll {
+  /* Template ID */
+  FingerprintFingerId finger;
+  /* samplesRemaining goes from N (no data collected, but N scans needed)
+   * to 0 (no more data is needed to build a template). */
+  uint32_t samplesRemaining;
+  /* Vendor specific message. Used for user guidance */
+  uint64_t msg;
+};
+
+struct FingerprintIterator {
+  /* Template ID */
+  FingerprintFingerId finger;
+  /* How many templates remain to iterate through */
+  uint32_t remainingTemplates;
+};
+
+typedef FingerprintIterator FingerprintEnumerated;
+typedef FingerprintIterator FingerprintRemoved;
+
+struct FingerprintAcquired {
+  /* information about the image */
+  FingerprintAcquiredInfo acquiredInfo;
+};
+
+struct FingerprintAuthenticated {
+  /* Matched template ID */
+  FingerprintFingerId finger;
+  /* Authentication result from the keymaster */
+  HwAuthToken hat;
+};
+
+/* Run time type identification for the notify() call payload. */
+enum FingerprintMsgType : int32_t {
+  ERROR = -1,
+  ACQUIRED = 1,
+  TEMPLATE_ENROLLING = 3,
+  TEMPLATE_REMOVED = 4,
+  AUTHENTICATED = 5,
+  TEMPLATE_ENUMERATING = 6,
+};
+
+struct FingerprintMsg {
+  /* Selects the payload below */
+  FingerprintMsgType type;
+  union data {
+    FingerprintError error;
+    FingerprintEnroll enroll;
+    FingerprintEnumerated enumerated;
+    FingerprintRemoved removed;
+    FingerprintAcquired acquired;
+    FingerprintAuthenticated authenticated;
+  };
+};
diff --git a/bluetooth/1.0/Android.bp b/bluetooth/1.0/Android.bp
new file mode 100644
index 0000000..c5f898d
--- /dev/null
+++ b/bluetooth/1.0/Android.bp
@@ -0,0 +1,54 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+    name: "android.hardware.bluetooth@1.0_genc++",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.bluetooth@1.0",
+    srcs: [
+        "types.hal",
+        "IBluetoothHci.hal",
+        "IBluetoothHciCallbacks.hal",
+    ],
+    out: [
+        "android/hardware/bluetooth/1.0/types.cpp",
+        "android/hardware/bluetooth/1.0/BluetoothHciAll.cpp",
+        "android/hardware/bluetooth/1.0/BluetoothHciCallbacksAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.bluetooth@1.0_genc++_headers",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.bluetooth@1.0",
+    srcs: [
+        "types.hal",
+        "IBluetoothHci.hal",
+        "IBluetoothHciCallbacks.hal",
+    ],
+    out: [
+        "android/hardware/bluetooth/1.0/types.h",
+        "android/hardware/bluetooth/1.0/IBluetoothHci.h",
+        "android/hardware/bluetooth/1.0/IHwBluetoothHci.h",
+        "android/hardware/bluetooth/1.0/BnBluetoothHci.h",
+        "android/hardware/bluetooth/1.0/BpBluetoothHci.h",
+        "android/hardware/bluetooth/1.0/BsBluetoothHci.h",
+        "android/hardware/bluetooth/1.0/IBluetoothHciCallbacks.h",
+        "android/hardware/bluetooth/1.0/IHwBluetoothHciCallbacks.h",
+        "android/hardware/bluetooth/1.0/BnBluetoothHciCallbacks.h",
+        "android/hardware/bluetooth/1.0/BpBluetoothHciCallbacks.h",
+        "android/hardware/bluetooth/1.0/BsBluetoothHciCallbacks.h",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.bluetooth@1.0",
+    generated_sources: ["android.hardware.bluetooth@1.0_genc++"],
+    generated_headers: ["android.hardware.bluetooth@1.0_genc++_headers"],
+    export_generated_headers: ["android.hardware.bluetooth@1.0_genc++_headers"],
+    shared_libs: [
+        "libhidl",
+        "libhwbinder",
+        "libutils",
+        "libcutils",
+    ],
+}
diff --git a/bluetooth/1.0/Android.mk b/bluetooth/1.0/Android.mk
new file mode 100644
index 0000000..7100765
--- /dev/null
+++ b/bluetooth/1.0/Android.mk
@@ -0,0 +1,144 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.bluetooth@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 (Status)
+#
+GEN := $(intermediates)/android/hardware/bluetooth/1.0/Status.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.bluetooth@1.0::types.Status
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IBluetoothHci.hal
+#
+GEN := $(intermediates)/android/hardware/bluetooth/1.0/IBluetoothHci.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IBluetoothHci.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IBluetoothHciCallbacks.hal
+$(GEN): $(LOCAL_PATH)/IBluetoothHciCallbacks.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.bluetooth@1.0::IBluetoothHci
+
+$(GEN): $(LOCAL_PATH)/IBluetoothHci.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IBluetoothHciCallbacks.hal
+#
+GEN := $(intermediates)/android/hardware/bluetooth/1.0/IBluetoothHciCallbacks.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IBluetoothHciCallbacks.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.bluetooth@1.0::IBluetoothHciCallbacks
+
+$(GEN): $(LOCAL_PATH)/IBluetoothHciCallbacks.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.bluetooth@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 (Status)
+#
+GEN := $(intermediates)/android/hardware/bluetooth/1.0/Status.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.bluetooth@1.0::types.Status
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IBluetoothHci.hal
+#
+GEN := $(intermediates)/android/hardware/bluetooth/1.0/IBluetoothHci.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IBluetoothHci.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IBluetoothHciCallbacks.hal
+$(GEN): $(LOCAL_PATH)/IBluetoothHciCallbacks.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.bluetooth@1.0::IBluetoothHci
+
+$(GEN): $(LOCAL_PATH)/IBluetoothHci.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IBluetoothHciCallbacks.hal
+#
+GEN := $(intermediates)/android/hardware/bluetooth/1.0/IBluetoothHciCallbacks.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IBluetoothHciCallbacks.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.bluetooth@1.0::IBluetoothHciCallbacks
+
+$(GEN): $(LOCAL_PATH)/IBluetoothHciCallbacks.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/bluetooth/1.0/IBluetoothHci.hal b/bluetooth/1.0/IBluetoothHci.hal
new file mode 100644
index 0000000..10cf914
--- /dev/null
+++ b/bluetooth/1.0/IBluetoothHci.hal
@@ -0,0 +1,74 @@
+/*
+ * 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.bluetooth@1.0;
+
+import IBluetoothHciCallbacks;
+
+/*
+ * The Host Controller Interface (HCI) is the layer defined by the Bluetooth
+ * specification between the software that runs on the host and the Bluetooth
+ * controller chip. This boundary is the natural choice for a Hardware
+ * Abstraction Layer (HAL). Dealing only in HCI packets and events simplifies
+ * the stack and abstracts away power management, initialization, and other
+ * implementation-specific details related to the hardware.
+ */
+
+interface IBluetoothHci {
+    /**
+     * Initialize the underlying HCI interface.
+     *
+     * This method should be used to initialize any hardware interfaces
+     * required to communicate with the Bluetooth hardware in the
+     * device.
+     *
+     * @param callback implements IBluetoothHciCallbacks which will
+     *    receive callbacks when incoming HCI packets are received
+     *    from the controller to be sent to the host.
+     * @return status result of the initialization
+     */
+    initialize(IBluetoothHciCallbacks callback) generates (Status status);
+
+    /**
+     * Send an HCI command (as specified in the Bluetooth Specification
+     * V4.2, Vol 2, Part 5, Section 5.4.1) to the Bluetooth controller.
+     * Commands must be executed in order.
+     *
+     * @param command is the HCI command to be sent
+     */
+    sendHciCommand(HciPacket command);
+
+    /**
+     * Send an HCI ACL data packet (as specified in the Bluetooth Specification
+     * V4.2, Vol 2, Part 5, Section 5.4.2) to the Bluetooth controller.
+     * Packets must be processed in order.
+     * @param data HCI data packet to be sent
+     */
+    sendAclData(HciPacket data);
+
+    /**
+     * Send an SCO data packet (as specified in the Bluetooth Specification
+     * V4.2, Vol 2, Part 5, Section 5.4.3) to the Bluetooth controller.
+     * Packets must be processed in order.
+     * @param data HCI data packet to be sent
+     */
+    sendScoData(HciPacket data);
+
+    /**
+     * Close the HCI interface
+     */
+    close();
+};
diff --git a/bluetooth/1.0/IBluetoothHciCallbacks.hal b/bluetooth/1.0/IBluetoothHciCallbacks.hal
new file mode 100644
index 0000000..afaab6c
--- /dev/null
+++ b/bluetooth/1.0/IBluetoothHciCallbacks.hal
@@ -0,0 +1,39 @@
+/*
+ * 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.bluetooth@1.0;
+
+/* The interface from the Bluetooth Controller to the stack. */
+interface IBluetoothHciCallbacks {
+    /**
+     * This function is invoked when an HCI event is received from the
+     * Bluetooth controller to be forwarded to the Bluetooth stack.
+     * @param event is the HCI event to be sent to the Bluetooth stack.
+     */
+    oneway hciEventReceived(HciPacket event);
+
+    /**
+     * Send an ACL data packet form the controller to the host.
+     * @param data the ACL HCI packet to be passed to the host stack
+     */
+    oneway aclDataReceived(HciPacket data);
+
+    /**
+     * Send a SCO data packet form the controller to the host.
+     * @param data the SCO HCI packet to be passed to the host stack
+     */
+    oneway scoDataReceived(HciPacket data);
+};
diff --git a/bluetooth/1.0/types.hal b/bluetooth/1.0/types.hal
new file mode 100644
index 0000000..5f5570a
--- /dev/null
+++ b/bluetooth/1.0/types.hal
@@ -0,0 +1,29 @@
+/*
+ * 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.bluetooth@1.0;
+
+enum Status : int32_t {
+  SUCCESS,
+  TRANSPORT_ERROR,
+  INITIALIZATION_ERROR,
+  UNKNOWN
+};
+
+/**
+ * HCI packets are transmitted as a vector of type uint8_t.
+ */
+typedef vec<uint8_t> HciPacket;
diff --git a/graphics/composer/2.1/Android.bp b/graphics/composer/2.1/Android.bp
new file mode 100644
index 0000000..3c63a68
--- /dev/null
+++ b/graphics/composer/2.1/Android.bp
@@ -0,0 +1,55 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+    name: "android.hardware.graphics.composer@2.1_genc++",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.graphics.composer@2.1",
+    srcs: [
+        "types.hal",
+        "IComposer.hal",
+        "IComposerCallback.hal",
+    ],
+    out: [
+        "android/hardware/graphics/composer/2.1/types.cpp",
+        "android/hardware/graphics/composer/2.1/ComposerAll.cpp",
+        "android/hardware/graphics/composer/2.1/ComposerCallbackAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.graphics.composer@2.1_genc++_headers",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.graphics.composer@2.1",
+    srcs: [
+        "types.hal",
+        "IComposer.hal",
+        "IComposerCallback.hal",
+    ],
+    out: [
+        "android/hardware/graphics/composer/2.1/types.h",
+        "android/hardware/graphics/composer/2.1/IComposer.h",
+        "android/hardware/graphics/composer/2.1/IHwComposer.h",
+        "android/hardware/graphics/composer/2.1/BnComposer.h",
+        "android/hardware/graphics/composer/2.1/BpComposer.h",
+        "android/hardware/graphics/composer/2.1/BsComposer.h",
+        "android/hardware/graphics/composer/2.1/IComposerCallback.h",
+        "android/hardware/graphics/composer/2.1/IHwComposerCallback.h",
+        "android/hardware/graphics/composer/2.1/BnComposerCallback.h",
+        "android/hardware/graphics/composer/2.1/BpComposerCallback.h",
+        "android/hardware/graphics/composer/2.1/BsComposerCallback.h",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.graphics.composer@2.1",
+    generated_sources: ["android.hardware.graphics.composer@2.1_genc++"],
+    generated_headers: ["android.hardware.graphics.composer@2.1_genc++_headers"],
+    export_generated_headers: ["android.hardware.graphics.composer@2.1_genc++_headers"],
+    shared_libs: [
+        "libhidl",
+        "libhwbinder",
+        "libutils",
+        "libcutils",
+        "android.hardware.graphics.allocator@2.0",
+    ],
+}
diff --git a/graphics/composer/2.1/IComposer.hal b/graphics/composer/2.1/IComposer.hal
new file mode 100644
index 0000000..7bfa22b
--- /dev/null
+++ b/graphics/composer/2.1/IComposer.hal
@@ -0,0 +1,1166 @@
+/*
+ * 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.graphics.composer@2.1;
+
+import android.hardware.graphics.allocator@2.0::PixelFormat;
+import IComposerCallback;
+
+interface IComposer {
+    /*
+     * Optional capabilities which may be supported by some devices. The
+     * particular set of supported capabilities for a given device may be
+     * retrieved using getCapabilities.
+     */
+    enum Capability : int32_t {
+        INVALID = 0,
+
+        /*
+         * Specifies that the device supports sideband stream layers, for
+         * which buffer content updates and other synchronization will not be
+         * provided through the usual validate/present cycle and must be
+         * handled by an external implementation-defined mechanism. Only
+         * changes to layer state (such as position, size, etc.) need to be
+         * performed through the validate/present cycle.
+         */
+        SIDEBAND_STREAM = 1,
+
+        /*
+         * Specifies that the device will apply a color transform even when
+         * either the client or the device has chosen that all layers should
+         * be composed by the client. This will prevent the client from
+         * applying the color transform during its composition step.
+         */
+        SKIP_CLIENT_COLOR_TRANSFORM = 2,
+    };
+
+    /* Display attributes queryable through getDisplayAttribute. */
+    enum Attribute : int32_t {
+        INVALID = 0,
+
+        /* Dimensions in pixels */
+        WIDTH = 1,
+        HEIGHT = 2,
+
+        /* Vsync period in nanoseconds */
+        VSYNC_PERIOD = 3,
+
+        /*
+         * Dots per thousand inches (DPI * 1000). Scaling by 1000 allows these
+         * numbers to be stored in an int32_t without losing too much
+         * precision. If the DPI for a configuration is unavailable or is
+         * considered unreliable, the device may return UNSUPPORTED instead.
+         */
+        DPI_X = 4,
+        DPI_Y = 5,
+    };
+
+    /* Display requests returned by getDisplayRequests. */
+    enum DisplayRequest : uint32_t {
+        /*
+         * Instructs the client to provide a new client target buffer, even if
+         * no layers are marked for client composition.
+         */
+        FLIP_CLIENT_TARGET = 1 << 0,
+
+        /*
+         * Instructs the client to write the result of client composition
+         * directly into the virtual display output buffer. If any of the
+         * layers are not marked as Composition::CLIENT or the given display
+         * is not a virtual display, this request has no effect.
+         */
+        WRITE_CLIENT_TARGET_TO_OUTPUT = 1 << 1,
+    };
+
+    /* Layer requests returned from getDisplayRequests. */
+    enum LayerRequest : uint32_t {
+        /*
+         * The client should clear its target with transparent pixels where
+         * this layer would be. The client may ignore this request if the
+         * layer must be blended.
+         */
+        CLEAR_CLIENT_TARGET = 1 << 0,
+    };
+
+    /* Power modes for use with setPowerMode. */
+    enum PowerMode : int32_t {
+        /* The display is fully off (blanked). */
+        OFF = 0,
+
+        /*
+         * These are optional low power modes. getDozeSupport may be called to
+         * determine whether a given display supports these modes.
+         */
+
+        /*
+         * The display is turned on and configured in a low power state that
+         * is suitable for presenting ambient information to the user,
+         * possibly with lower fidelity than ON, but with greater efficiency.
+         */
+        DOZE = 1,
+
+        /*
+         * The display is configured as in DOZE but may stop applying display
+         * updates from the client. This is effectively a hint to the device
+         * that drawing to the display has been suspended and that the the
+         * device should remain on in a low power state and continue
+         * displaying its current contents indefinitely until the power mode
+         * changes.
+         *
+         * This mode may also be used as a signal to enable hardware-based
+         * doze functionality. In this case, the device is free to take over
+         * the display and manage it autonomously to implement a low power
+         * always-on display.
+         */
+        DOZE_SUSPEND = 3,
+
+        /* The display is fully on. */
+        ON = 2,
+    };
+
+    /* Vsync values passed to setVsyncEnabled. */
+    enum Vsync : int32_t {
+        INVALID = 0,
+
+        /* Enable vsync. */
+        ENABLE = 1,
+
+        /* Disable vsync. */
+        DISABLE = 2,
+    };
+
+    /* Blend modes, settable per layer. */
+    enum BlendMode : int32_t {
+        INVALID = 0,
+
+        /* colorOut = colorSrc */
+        NONE = 1,
+
+        /* colorOut = colorSrc + colorDst * (1 - alphaSrc) */
+        PREMULTIPLIED = 2,
+
+        /* colorOut = colorSrc * alphaSrc + colorDst * (1 - alphaSrc) */
+        COVERAGE = 3,
+    };
+
+    /* Possible composition types for a given layer. */
+    enum Composition : int32_t {
+        INVALID = 0,
+
+        /*
+         * The client will composite this layer into the client target buffer
+         * (provided to the device through setClientTarget).
+         *
+         * The device must not request any composition type changes for layers
+         * of this type.
+         */
+        CLIENT = 1,
+
+        /*
+         * The device will handle the composition of this layer through a
+         * hardware overlay or other similar means.
+         *
+         * Upon validateDisplay, the device may request a change from this
+         * type to CLIENT.
+         */
+        DEVICE = 2,
+
+        /*
+         * The device will render this layer using the color set through
+         * setLayerColor. If this functionality is not supported on a layer
+         * that the client sets to SOLID_COLOR, the device must request that
+         * the composition type of that layer is changed to CLIENT upon the
+         * next call to validateDisplay.
+         *
+         * Upon validateDisplay, the device may request a change from this
+         * type to CLIENT.
+         */
+        SOLID_COLOR = 3,
+
+        /*
+         * Similar to DEVICE, but the position of this layer may also be set
+         * asynchronously through setCursorPosition. If this functionality is
+         * not supported on a layer that the client sets to CURSOR, the device
+         * must request that the composition type of that layer is changed to
+         * CLIENT upon the next call to validateDisplay.
+         *
+         * Upon validateDisplay, the device may request a change from this
+         * type to either DEVICE or CLIENT.  Changing to DEVICE will prevent
+         * the use of setCursorPosition but still permit the device to
+         * composite the layer.
+         */
+        CURSOR = 4,
+
+        /*
+         * The device will handle the composition of this layer, as well as
+         * its buffer updates and content synchronization. Only supported on
+         * devices which provide Capability::SIDEBAND_STREAM.
+         *
+         * Upon validateDisplay, the device may request a change from this
+         * type to either DEVICE or CLIENT, but it is unlikely that content
+         * will display correctly in these cases.
+         */
+        SIDEBAND = 5,
+    };
+
+    /* Display types returned by getDisplayType. */
+    enum DisplayType : int32_t {
+        INVALID = 0,
+
+        /*
+         * All physical displays, including both internal displays and
+         * hotpluggable external displays.
+         */
+        PHYSICAL = 1,
+
+        /* Virtual displays created by createVirtualDisplay. */
+        VIRTUAL = 2,
+    };
+
+    struct Rect {
+        int32_t left;
+        int32_t top;
+        int32_t right;
+        int32_t bottom;
+    };
+
+    struct FRect {
+        float left;
+        float top;
+        float right;
+        float bottom;
+    };
+
+    struct Color {
+        uint8_t r;
+        uint8_t g;
+        uint8_t b;
+        uint8_t a;
+    };
+
+    /*
+     * Provides a list of supported capabilities (as described in the
+     * definition of Capability above). This list must not change after
+     * initialization.
+     *
+     * @return capabilities is a list of supported capabilities.
+     */
+    getCapabilities() generates (vec<Capability> capabilities);
+
+    /*
+     * Retrieves implementation-defined debug information, which will be
+     * displayed during, for example, `dumpsys SurfaceFlinger`.
+     *
+     * @return debugInfo is a string of debug information.
+     */
+    dumpDebugInfo() generates (string debugInfo);
+
+    /*
+     * Provides a IComposerCallback object for the device to call.
+     *
+     * @param callback is the IComposerCallback object.
+     */
+    registerCallback(IComposerCallback callback);
+
+    /*
+     * Returns the maximum number of virtual displays supported by this device
+     * (which may be 0). The client will not attempt to create more than this
+     * many virtual displays on this device. This number must not change for
+     * the lifetime of the device.
+     */
+    getMaxVirtualDisplayCount() generates (uint32_t count);
+
+    /*
+     * Creates a new virtual display with the given width and height. The
+     * format passed into this function is the default format requested by the
+     * consumer of the virtual display output buffers.
+     *
+     * The display will be assumed to be on from the time the first frame is
+     * presented until the display is destroyed.
+     *
+     * @param width is the width in pixels.
+     * @param height is the height in pixels.
+     * @param formatHint is the default output buffer format selected by
+     *        the consumer.
+     * @return error is NONE upon success. Otherwise,
+     *         UNSUPPORTED when the width or height is too large for the
+     *                     device to be able to create a virtual display.
+     *         NO_RESOURCES when the device is unable to create a new virtual
+     *                      display at this time.
+     * @return display is the newly-created virtual display.
+     * @return format is the format of the buffer the device will produce.
+     */
+    createVirtualDisplay(uint32_t width,
+                         uint32_t height,
+                         PixelFormat formatHint)
+              generates (Error error,
+                         Display display,
+                         PixelFormat format);
+
+    /*
+     * Destroys a virtual display. After this call all resources consumed by
+     * this display may be freed by the device and any operations performed on
+     * this display should fail.
+     *
+     * @param display is the virtual display to destroy.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_PARAMETER when the display handle which was passed in does
+     *                       not refer to a virtual display.
+     */
+    destroyVirtualDisplay(Display display) generates (Error error);
+
+    /*
+     * Accepts the changes required by the device from the previous
+     * validateDisplay call (which may be queried using
+     * getChangedCompositionTypes) and revalidates the display. This function
+     * is equivalent to requesting the changed types from
+     * getChangedCompositionTypes, setting those types on the corresponding
+     * layers, and then calling validateDisplay again.
+     *
+     * After this call it must be valid to present this display. Calling this
+     * after validateDisplay returns 0 changes must succeed with NONE, but
+     * should have no other effect.
+     *
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         NOT_VALIDATED when validateDisplay has not been called.
+     */
+    acceptDisplayChanges(Display display) generates (Error error);
+
+    /*
+     * Creates a new layer on the given display.
+     *
+     * @param display is the display on which to create the layer.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         NO_RESOURCES when the device was unable to create a layer this
+     *                      time.
+     * @return layer is the handle of the new layer.
+     */
+    createLayer(Display display) generates (Error error, Layer layer);
+
+    /*
+     * Destroys the given layer.
+     *
+     * @param display is the display on which the layer was created.
+     * @param layer is the layer to destroy.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_LAYER when an invalid layer handle was passed in.
+     */
+    destroyLayer(Display display, Layer layer) generates (Error error);
+
+    /*
+     * Retrieves which display configuration is currently active.
+     *
+     * If no display configuration is currently active, this function must
+     * return BAD_CONFIG. It is the responsibility of the client to call
+     * setActiveConfig with a valid configuration before attempting to present
+     * anything on the display.
+     *
+     * @param display is the display to which the active config is queried.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_CONFIG when no configuration is currently active.
+     * @return config is the currently active display configuration.
+     */
+    getActiveConfig(Display display) generates (Error error, Config config);
+
+    /*
+     * Retrieves the layers for which the device requires a different
+     * composition type than had been set prior to the last call to
+     * validateDisplay. The client will either update its state with these
+     * types and call acceptDisplayChanges, or will set new types and attempt
+     * to validate the display again.
+     *
+     * The number of changed layers must be the same as the value returned in
+     * numTypes from the last call to validateDisplay.
+     *
+     * @param display is the display to query.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         NOT_VALIDATED when validateDisplay has not been called.
+     * @return layers is an array of layer handles.
+     * @return types is an array of composition types, each corresponding to
+     *         an element of layers.
+     */
+    getChangedCompositionTypes(Display display)
+                    generates (Error error,
+                               vec<Layer> layers,
+                               vec<Composition> types);
+
+    /*
+     * Returns whether a client target with the given properties can be
+     * handled by the device.
+     *
+     * This function must return true for a client target with width and
+     * height equal to the active display configuration dimensions,
+     * PixelFormat::RGBA_8888, and Dataspace::UNKNOWN. It is not required to
+     * return true for any other configuration.
+     *
+     * @param display is the display to query.
+     * @param width is the client target width in pixels.
+     * @param height is the client target height in pixels.
+     * @param format is the client target format.
+     * @param dataspace is the client target dataspace, as described in
+     *        setLayerDataspace.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         UNSUPPORTED when the given configuration is not supported.
+     */
+    getClientTargetSupport(Display display,
+                           uint32_t width,
+                           uint32_t height,
+                           PixelFormat format,
+                           Dataspace dataspace)
+                generates (Error error);
+
+    /*
+     * Returns the color modes supported on this display.
+     *
+     * All devices must support at least ColorMode::NATIVE.
+     *
+     * @param display is the display to query.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     * @return modes is an array of color modes.
+     */
+    getColorModes(Display display)
+       generates (Error error,
+                  vec<ColorMode> modes);
+
+    /*
+     * Returns a display attribute value for a particular display
+     * configuration.
+     *
+     * @param display is the display to query.
+     * @param config is the display configuration for which to return
+     *        attribute values.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_CONFIG when config does not name a valid configuration for
+     *                    this display.
+     *         BAD_PARAMETER when attribute is unrecognized.
+     *         UNSUPPORTED when attribute cannot be queried for the config.
+     * @return value is the value of the attribute.
+     */
+    getDisplayAttribute(Display display,
+                        Config config,
+                        Attribute attribute)
+             generates (Error error,
+                        int32_t value);
+
+    /*
+     * Returns handles for all of the valid display configurations on this
+     * display.
+     *
+     * @param display is the display to query.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     * @return configs is an array of configuration handles.
+     */
+    getDisplayConfigs(Display display)
+           generates (Error error,
+                      vec<Config> configs);
+
+    /*
+     * Returns a human-readable version of the display's name.
+     *
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     * @return name is the name of the display.
+     */
+    getDisplayName(Display display) generates (Error error, string name);
+
+    /*
+     * Returns the display requests and the layer requests required for the
+     * last validated configuration.
+     *
+     * Display requests provide information about how the client should handle
+     * the client target. Layer requests provide information about how the
+     * client should handle an individual layer.
+     *
+     * The number of layer requests must be equal to the value returned in
+     * numRequests from the last call to validateDisplay.
+     *
+     * @param display is the display to query.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         NOT_VALIDATED when validateDisplay has not been called.
+     * @return displayRequestMask is the display requests for the current
+     *         validated state.
+     * @return layers is an array of layers which all have at least one
+     *         request.
+     * @return layerRequestMasks is the requests corresponding to each element
+     *         of layers.
+     */
+    getDisplayRequests(Display display)
+            generates (Error error,
+                       uint32_t displayRequestMask,
+                       vec<Layer> layers,
+                       vec<uint32_t> layerRequestMasks);
+
+    /*
+     * Returns whether the given display is a physical or virtual display.
+     *
+     * @param display is the display to query.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     * @return type is the type of the display.
+     */
+    getDisplayType(Display display) generates (Error error, DisplayType type);
+
+    /*
+     * Returns whether the given display supports PowerMode::DOZE and
+     * PowerMode::DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit over
+     * DOZE (see the definition of PowerMode for more information), but if
+     * both DOZE and DOZE_SUSPEND are no different from PowerMode::ON, the
+     * device should not claim support.
+     *
+     * @param display is the display to query.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     * @return support is true only when the display supports doze modes.
+     */
+    getDozeSupport(Display display) generates (Error error, bool support);
+
+    /*
+     * Returns the high dynamic range (HDR) capabilities of the given display,
+     * which are invariant with regard to the active configuration.
+     *
+     * Displays which are not HDR-capable must return no types.
+     *
+     * @param display is the display to query.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     * @return types is an array of HDR types, may have 0 elements if the
+     *         display is not HDR-capable.
+     * @return maxLuminance is the desired content maximum luminance for this
+     *         display in cd/m^2.
+     * @return maxAverageLuminance - the desired content maximum frame-average
+     *         luminance for this display in cd/m^2.
+     * @return minLuminance is the desired content minimum luminance for this
+     *         display in cd/m^2.
+     */
+    getHdrCapabilities(Display display)
+            generates (Error error,
+                       vec<Hdr> types,
+                       float maxLuminance,
+                       float maxAverageLuminance,
+                       float minLuminance);
+
+    /*
+     * Retrieves the release fences for device layers on this display which
+     * will receive new buffer contents this frame.
+     *
+     * A release fence is a file descriptor referring to a sync fence object
+     * which will be signaled after the device has finished reading from the
+     * buffer presented in the prior frame. This indicates that it is safe to
+     * start writing to the buffer again. If a given layer's fence is not
+     * returned from this function, it will be assumed that the buffer
+     * presented on the previous frame is ready to be written.
+     *
+     * The fences returned by this function should be unique for each layer
+     * (even if they point to the same underlying sync object).
+     *
+     * @param display is the display to query.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     * @return layers is an array of layer handles.
+     * @return fences is handle that contains an array of sync fence file
+     *         descriptors as described above, each corresponding to an
+     *         element of layers.
+     */
+    getReleaseFences(Display display)
+          generates (Error error,
+                     vec<Layer> layers,
+                     handle releaseFences);
+
+    /*
+     * Presents the current display contents on the screen (or in the case of
+     * virtual displays, into the output buffer).
+     *
+     * Prior to calling this function, the display must be successfully
+     * validated with validateDisplay. Note that setLayerBuffer and
+     * setLayerSurfaceDamage specifically do not count as layer state, so if
+     * there are no other changes to the layer state (or to the buffer's
+     * properties as described in setLayerBuffer), then it is safe to call
+     * this function without first validating the display.
+     *
+     * If this call succeeds, presentFence will be populated with a file
+     * descriptor referring to a present sync fence object. For physical
+     * displays, this fence will be signaled at the vsync when the result of
+     * composition of this frame starts to appear (for video-mode panels) or
+     * starts to transfer to panel memory (for command-mode panels). For
+     * virtual displays, this fence will be signaled when writes to the output
+     * buffer have completed and it is safe to read from it.
+     *
+     * @param display is the display to present.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         NO_RESOURCES when no valid output buffer has been set for a
+     *                      virtual display.
+     *         NOT_VALIDATED when validateDisplay has not successfully been
+     *                       called for this display.
+     * @return presentFence is a sync fence file descriptor as described
+     *         above.
+     */
+    presentDisplay(Display display)
+        generates (Error error,
+                   handle presentFence);
+
+    /*
+     * Sets the active configuration for this display. Upon returning, the
+     * given display configuration should be active and remain so until either
+     * this function is called again or the display is disconnected.
+     *
+     * @param display is the display to which the active config is set.
+     * @param config is the new display configuration.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_CONFIG when the configuration handle passed in is not valid
+     *                    for this display.
+     */
+    setActiveConfig(Display display, Config config) generates (Error error);
+
+    /*
+     * Sets the buffer handle which will receive the output of client
+     * composition.  Layers marked as Composition::CLIENT will be composited
+     * into this buffer prior to the call to presentDisplay, and layers not
+     * marked as Composition::CLIENT should be composited with this buffer by
+     * the device.
+     *
+     * The buffer handle provided may be empty if no layers are being
+     * composited by the client. This must not result in an error (unless an
+     * invalid display handle is also provided).
+     *
+     * Also provides a file descriptor referring to an acquire sync fence
+     * object, which will be signaled when it is safe to read from the client
+     * target buffer.  If it is already safe to read from this buffer, an
+     * empty handle may be passed instead.
+     *
+     * For more about dataspaces, see setLayerDataspace.
+     *
+     * The damage parameter describes a surface damage region as defined in
+     * the description of setLayerSurfaceDamage.
+     *
+     * Will be called before presentDisplay if any of the layers are marked as
+     * Composition::CLIENT. If no layers are so marked, then it is not
+     * necessary to call this function. It is not necessary to call
+     * validateDisplay after changing the target through this function.
+     *
+     * @param display is the display to which the client target is set.
+     * @param target is the new target buffer.
+     * @param acquireFence is a sync fence file descriptor as described above.
+     * @param dataspace is the dataspace of the buffer, as described in
+     *        setLayerDataspace.
+     * @param damage is the surface damage region.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_PARAMETER when the new target handle was invalid.
+     */
+    setClientTarget(Display display,
+                    handle target,
+                    handle acquireFence,
+                    Dataspace dataspace,
+                    vec<Rect> damage)
+         generates (Error error);
+
+    /*
+     * Sets the color mode of the given display.
+     *
+     * Upon returning from this function, the color mode change must have
+     * fully taken effect.
+     *
+     * All devices must support at least ColorMode::NATIVE, and displays are
+     * assumed to be in this mode upon hotplug.
+     *
+     * @param display is the display to which the color mode is set.
+     * @param mode is the mode to set to.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_PARAMETER when mode is not a valid color mode.
+     *         UNSUPPORTED when mode is not supported on this display.
+     */
+    setColorMode(Display display, ColorMode mode) generates (Error error);
+
+    /*
+     * Sets a color transform which will be applied after composition.
+     *
+     * If hint is not ColorTransform::ARBITRARY, then the device may use the
+     * hint to apply the desired color transform instead of using the color
+     * matrix directly.
+     *
+     * If the device is not capable of either using the hint or the matrix to
+     * apply the desired color transform, it should force all layers to client
+     * composition during validateDisplay.
+     *
+     * If Capability::SKIP_CLIENT_COLOR_TRANSFORM is present, then the client
+     * will never apply the color transform during client composition, even if
+     * all layers are being composed by the client.
+     *
+     * The matrix provided is an affine color transformation of the following
+     * form:
+     *
+     * |r.r r.g r.b 0|
+     * |g.r g.g g.b 0|
+     * |b.r b.g b.b 0|
+     * |Tr  Tg  Tb  1|
+     *
+     * This matrix will be provided in row-major form:
+     *
+     * {r.r, r.g, r.b, 0, g.r, ...}.
+     *
+     * Given a matrix of this form and an input color [R_in, G_in, B_in], the
+     * output color [R_out, G_out, B_out] will be:
+     *
+     * R_out = R_in * r.r + G_in * g.r + B_in * b.r + Tr
+     * G_out = R_in * r.g + G_in * g.g + B_in * b.g + Tg
+     * B_out = R_in * r.b + G_in * g.b + B_in * b.b + Tb
+     *
+     * @param display is the display to which the color transform is set.
+     * @param matrix is a 4x4 transform matrix (16 floats) as described above.
+     * @param hint is a hint value which may be used instead of the given
+     *        matrix unless it is ColorTransform::ARBITRARY.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_PARAMETER when hint is not a valid color transform hint.
+     */
+    setColorTransform(Display display,
+                      vec<float> matrix,
+                      ColorTransform hint)
+           generates (Error error);
+
+    /*
+     * Sets the output buffer for a virtual display. That is, the buffer to
+     * which the composition result will be written.
+     *
+     * Also provides a file descriptor referring to a release sync fence
+     * object, which will be signaled when it is safe to write to the output
+     * buffer. If it is already safe to write to the output buffer, an empty
+     * handle may be passed instead.
+     *
+     * Must be called at least once before presentDisplay, but does not have
+     * any interaction with layer state or display validation.
+     *
+     * @param display is the virtual display to which the output buffer is
+     *        set.
+     * @param buffer is the new output buffer.
+     * @param releaseFence is a sync fence file descriptor as described above.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_PARAMETER when the new output buffer handle was invalid.
+     *         UNSUPPORTED when display does not refer to a virtual display.
+     */
+    setOutputBuffer(Display display,
+                    handle buffer,
+                    handle releaseFence)
+         generates (Error error);
+
+    /*
+     * Sets the power mode of the given display. The transition must be
+     * complete when this function returns. It is valid to call this function
+     * multiple times with the same power mode.
+     *
+     * All displays must support PowerMode::ON and PowerMode::OFF.  Whether a
+     * display supports PowerMode::DOZE or PowerMode::DOZE_SUSPEND may be
+     * queried using getDozeSupport.
+     *
+     * @param display is the display to which the power mode is set.
+     * @param mode is the new power mode.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_PARAMETER when mode was not a valid power mode.
+     *         UNSUPPORTED when mode is not supported on this display.
+     */
+    setPowerMode(Display display, PowerMode mode) generates (Error error);
+
+    /*
+     * Enables or disables the vsync signal for the given display. Virtual
+     * displays never generate vsync callbacks, and any attempt to enable
+     * vsync for a virtual display though this function must succeed and have
+     * no other effect.
+     *
+     * @param display is the display to which the vsync mode is set.
+     * @param enabled indicates whether to enable or disable vsync
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_PARAMETER when enabled was an invalid value.
+     */
+    setVsyncEnabled(Display display, Vsync enabled) generates (Error error);
+
+    /*
+     * Instructs the device to inspect all of the layer state and determine if
+     * there are any composition type changes necessary before presenting the
+     * display. Permitted changes are described in the definition of
+     * Composition above.
+     *
+     * Also returns the number of layer requests required by the given layer
+     * configuration.
+     *
+     * @param display is the display to validate.
+     * @return error is NONE or HAS_CHANGES upon success.
+     *         NONE when no changes are necessary and it is safe to present
+     *              the display using the current layer state.
+     *         HAS_CHANGES when composition type changes are needed.
+     *         Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     * @return numTypes is the number of composition type changes required by
+     *         the device; if greater than 0, the client must either set and
+     *         validate new types, or call acceptDisplayChanges to accept the
+     *         changes returned by getChangedCompositionTypes. It must be the
+     *         same as the number of changes returned by
+     *         getChangedCompositionTypes (see the declaration of that
+     *         function for more information).
+     * @return numRequests is the number of layer requests required by this
+     *         layer configuration. It must be equal to the number of layer
+     *         requests returned by getDisplayRequests (see the declaration of
+     *         that function for more information).
+     */
+    validateDisplay(Display display)
+         generates (Error error,
+                    uint32_t numTypes,
+                    uint32_t numRequests);
+
+    /*
+     * Layer Functions
+     *
+     * These are functions which operate on layers, but which do not modify
+     * state that must be validated before use. See also 'Layer State
+     * Functions' below.
+     */
+
+    /*
+     * Asynchonously sets the position of a cursor layer.
+     *
+     * Prior to validateDisplay, a layer may be marked as Composition::CURSOR.
+     * If validation succeeds (i.e., the device does not request a composition
+     * change for that layer), then once a buffer has been set for the layer
+     * and it has been presented, its position may be set by this function at
+     * any time between presentDisplay and any subsequent validateDisplay
+     * calls for this display.
+     *
+     * Once validateDisplay is called, this function will not be called again
+     * until the validate/present sequence is completed.
+     *
+     * May be called from any thread so long as it is not interleaved with the
+     * validate/present sequence as described above.
+     *
+     * @param display is the display on which the layer was created.
+     * @param layer is the layer to which the position is set.
+     * @param x is the new x coordinate (in pixels from the left of the
+     *        screen).
+     * @param y is the new y coordinate (in pixels from the top of the
+     *        screen).
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_LAYER when the layer is invalid or is not currently marked
+     *                   as Composition::CURSOR.
+     *         NOT_VALIDATED when the device is currently in the middle of the
+     *                       validate/present sequence.
+     */
+    setCursorPosition(Display display,
+                      Layer layer,
+                      int32_t x,
+                      int32_t y)
+           generates (Error error);
+
+    /*
+     * Sets the buffer handle to be displayed for this layer. If the buffer
+     * properties set at allocation time (width, height, format, and usage)
+     * have not changed since the previous frame, it is not necessary to call
+     * validateDisplay before calling presentDisplay unless new state needs to
+     * be validated in the interim.
+     *
+     * Also provides a file descriptor referring to an acquire sync fence
+     * object, which will be signaled when it is safe to read from the given
+     * buffer. If it is already safe to read from the buffer, an empty handle
+     * may be passed instead.
+     *
+     * This function must return NONE and have no other effect if called for a
+     * layer with a composition type of Composition::SOLID_COLOR (because it
+     * has no buffer) or Composition::SIDEBAND or Composition::CLIENT (because
+     * synchronization and buffer updates for these layers are handled
+     * elsewhere).
+     *
+     * @param display is the display on which the layer was created.
+     * @param layer is the layer to which the buffer is set.
+     * @param buffer is the buffer handle to set.
+     * @param acquireFence is a sync fence file descriptor as described above.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_LAYER when an invalid layer handle was passed in.
+     *         BAD_PARAMETER when the buffer handle passed in was invalid.
+     */
+    setLayerBuffer(Display display,
+                   Layer layer,
+                   handle buffer,
+                   handle acquireFence)
+        generates (Error error);
+
+    /*
+     * Provides the region of the source buffer which has been modified since
+     * the last frame. This region does not need to be validated before
+     * calling presentDisplay.
+     *
+     * Once set through this function, the damage region remains the same
+     * until a subsequent call to this function.
+     *
+     * If damage is non-empty, then it may be assumed that any portion of the
+     * source buffer not covered by one of the rects has not been modified
+     * this frame. If damage is empty, then the whole source buffer must be
+     * treated as if it has been modified.
+     *
+     * If the layer's contents are not modified relative to the prior frame,
+     * damage will contain exactly one empty rect([0, 0, 0, 0]).
+     *
+     * The damage rects are relative to the pre-transformed buffer, and their
+     * origin is the top-left corner. They will not exceed the dimensions of
+     * the latched buffer.
+     *
+     * @param display is the display on which the layer was created.
+     * @param layer is the layer to which the damage region is set.
+     * @param damage is the new surface damage region.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_LAYER when an invalid layer handle was passed in.
+     */
+    setLayerSurfaceDamage(Display display,
+                          Layer layer,
+                          vec<Rect> damage)
+               generates (Error error);
+
+    /*
+     * Layer State Functions
+     *
+     * These functions modify the state of a given layer. They do not take
+     * effect until the display configuration is successfully validated with
+     * validateDisplay and the display contents are presented with
+     * presentDisplay.
+     */
+
+    /*
+     * Sets the blend mode of the given layer.
+     *
+     * @param display is the display on which the layer was created.
+     * @param layer is the layer to which the blend mode is set.
+     * @param mode is the new blend mode.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_LAYER when an invalid layer handle was passed in.
+     *         BAD_PARAMETER when an invalid blend mode was passed in.
+     */
+    setLayerBlendMode(Display display,
+                      Layer layer,
+                      BlendMode mode)
+           generates (Error error);
+
+    /*
+     * Sets the color of the given layer. If the composition type of the layer
+     * is not Composition::SOLID_COLOR, this call must succeed and have no
+     * other effect.
+     *
+     * @param display is the display on which the layer was created.
+     * @param layer is the layer to which the blend mode is set.
+     * @param color is the new color.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_LAYER when an invalid layer handle was passed in.
+     */
+    setLayerColor(Display display,
+                  Layer layer,
+                  Color color)
+       generates (Error error);
+
+    /*
+     * Sets the desired composition type of the given layer. During
+     * validateDisplay, the device may request changes to the composition
+     * types of any of the layers as described in the definition of
+     * Composition above.
+     *
+     * @param display is the display on which the layer was created.
+     * @param layer is the layer to which the blend mode is set.
+     * @param type is the new composition type.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_LAYER when an invalid layer handle was passed in.
+     *         BAD_PARAMETER when an invalid composition type was passed in.
+     *         UNSUPPORTED when a valid composition type was passed in, but it
+     *                     is not supported by this device.
+     */
+    setLayerCompositionType(Display display,
+                            Layer layer,
+                            Composition type)
+                 generates (Error error);
+
+    /*
+     * Sets the dataspace that the current buffer on this layer is in.
+     *
+     * The dataspace provides more information about how to interpret the
+     * buffer contents, such as the encoding standard and color transform.
+     *
+     * See the values of Dataspace for more information.
+     *
+     * @param display is the display on which the layer was created.
+     * @param layer is the layer to which the dataspace is set.
+     * @param dataspace is the new dataspace.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_LAYER when an invalid layer handle was passed in.
+     */
+    setLayerDataspace(Display display,
+                      Layer layer,
+                      Dataspace dataspace)
+           generates (Error error);
+
+    /*
+     * Sets the display frame (the portion of the display covered by a layer)
+     * of the given layer. This frame will not exceed the display dimensions.
+     *
+     * @param display is the display on which the layer was created.
+     * @param layer is the layer to which the frame is set.
+     * @param frame is the new display frame.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_LAYER when an invalid layer handle was passed in.
+     */
+    setLayerDisplayFrame(Display display,
+                         Layer layer,
+                         Rect frame)
+              generates (Error error);
+
+    /*
+     * Sets an alpha value (a floating point value in the range [0.0, 1.0])
+     * which will be applied to the whole layer. It can be conceptualized as a
+     * preprocessing step which applies the following function:
+     *   if (blendMode == BlendMode::PREMULTIPLIED)
+     *       out.rgb = in.rgb * planeAlpha
+     *   out.a = in.a * planeAlpha
+     *
+     * If the device does not support this operation on a layer which is
+     * marked Composition::DEVICE, it must request a composition type change
+     * to Composition::CLIENT upon the next validateDisplay call.
+     *
+     * @param display is the display on which the layer was created.
+     * @param layer is the layer to which the plane alpha is set.
+     * @param alpha is the plane alpha value to apply.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_LAYER when an invalid layer handle was passed in.
+     */
+    setLayerPlaneAlpha(Display display,
+                       Layer layer,
+                       float alpha)
+            generates (Error error);
+
+    /*
+     * Sets the sideband stream for this layer. If the composition type of the
+     * given layer is not Composition::SIDEBAND, this call must succeed and
+     * have no other effect.
+     *
+     * @param display is the display on which the layer was created.
+     * @param layer is the layer to which the sideband stream is set.
+     * @param stream is the new sideband stream.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_LAYER when an invalid layer handle was passed in.
+     *         BAD_PARAMETER when an invalid sideband stream was passed in.
+     */
+    setLayerSidebandStream(Display display,
+                           Layer layer,
+                           handle stream)
+                generates (Error error);
+
+    /*
+     * Sets the source crop (the portion of the source buffer which will fill
+     * the display frame) of the given layer. This crop rectangle will not
+     * exceed the dimensions of the latched buffer.
+     *
+     * If the device is not capable of supporting a true float source crop
+     * (i.e., it will truncate or round the floats to integers), it should set
+     * this layer to Composition::CLIENT when crop is non-integral for the
+     * most accurate rendering.
+     *
+     * If the device cannot support float source crops, but still wants to
+     * handle the layer, it should use the following code (or similar) to
+     * convert to an integer crop:
+     *   intCrop.left = (int) ceilf(crop.left);
+     *   intCrop.top = (int) ceilf(crop.top);
+     *   intCrop.right = (int) floorf(crop.right);
+     *   intCrop.bottom = (int) floorf(crop.bottom);
+     *
+     * @param display is the display on which the layer was created.
+     * @param layer is the layer to which the source crop is set.
+     * @param crop is the new source crop.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_LAYER when an invalid layer handle was passed in.
+     */
+    setLayerSourceCrop(Display display,
+                       Layer layer,
+                       FRect crop)
+            generates (Error error);
+
+    /*
+     * Sets the transform (rotation/flip) of the given layer.
+     *
+     * @param display is the display on which the layer was created.
+     * @param layer is the layer to which the transform is set.
+     * @param transform is the new transform.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_LAYER when an invalid layer handle was passed in.
+     *         BAD_PARAMETER when an invalid transform was passed in.
+     */
+    setLayerTransform(Display display,
+                      Layer layer,
+                      Transform transform)
+           generates (Error error);
+
+    /*
+     * Specifies the portion of the layer that is visible, including portions
+     * under translucent areas of other layers. The region is in screen space,
+     * and will not exceed the dimensions of the screen.
+     *
+     * @param display is the display on which the layer was created.
+     * @param layer is the layer to which the visible region is set.
+     * @param visible is the new visible region, in screen space.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_LAYER when an invalid layer handle was passed in.
+     */
+    setLayerVisibleRegion(Display display,
+                          Layer layer,
+                          vec<Rect> visible)
+               generates (Error error);
+
+    /*
+     * Sets the desired Z order (height) of the given layer. A layer with a
+     * greater Z value occludes a layer with a lesser Z value.
+     *
+     * @param display is the display on which the layer was created.
+     * @param layer is the layer to which the Z order is set.
+     * @param z is the new Z order.
+     * @return error is NONE upon success. Otherwise,
+     *         BAD_DISPLAY when an invalid display handle was passed in.
+     *         BAD_LAYER when an invalid layer handle was passed in.
+     */
+    setLayerZOrder(Display display,
+                   Layer layer,
+                   uint32_t z)
+        generates (Error error);
+};
diff --git a/graphics/composer/2.1/IComposerCallback.hal b/graphics/composer/2.1/IComposerCallback.hal
new file mode 100644
index 0000000..a8ca168
--- /dev/null
+++ b/graphics/composer/2.1/IComposerCallback.hal
@@ -0,0 +1,72 @@
+/*
+ * 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.graphics.composer@2.1;
+
+interface IComposerCallback {
+    enum Connection : int32_t {
+        INVALID = 0,
+
+        /* The display has been connected */
+        CONNECTED = 1,
+        /* The display has been disconnected */
+        DISCONNECTED = 2,
+    };
+
+    /*
+     * Notifies the client that the given display has either been connected or
+     * disconnected. Every active display (even a built-in physical display)
+     * must trigger at least one hotplug notification, even if it only occurs
+     * immediately after callback registration.
+     *
+     * Displays which have been connected are assumed to be in PowerMode::OFF,
+     * and the onVsync callback should not be called for a display until vsync
+     * has been enabled with setVsyncEnabled.
+     *
+     * The client may call back into the device while the callback is in
+     * progress. The device must serialize calls to this callback such that
+     * only one thread is calling it at a time.
+     *
+     * @param display is the display that triggers the hotplug event.
+     * @param connected indicates whether the display is connected or
+     *        disconnected.
+     */
+    onHotplug(Display display, Connection connected);
+
+    /*
+     * Notifies the client to trigger a screen refresh. This forces all layer
+     * state for this display to be resent, and the display to be validated
+     * and presented, even if there have been no changes.
+
+     * This refresh will occur some time after the callback is initiated, but
+     * not necessarily before it returns.  It is safe to trigger this callback
+     * from other functions which call into the device.
+     *
+     * @param display is the display to refresh.
+     */
+    oneway onRefresh(Display display);
+
+    /*
+     * Notifies the client that a vsync event has occurred. This callback must
+     * only be triggered when vsync is enabled for this display (through
+     * setVsyncEnabled).
+     *
+     * @param display is the display which has received a vsync event
+     * @param timestamp is the CLOCK_MONOTONIC time at which the vsync event
+     *        occurred, in nanoseconds.
+     */
+    oneway onVsync(Display display, int64_t timestamp);
+};
diff --git a/graphics/composer/2.1/default/Android.bp b/graphics/composer/2.1/default/Android.bp
new file mode 100644
index 0000000..f91c9a2
--- /dev/null
+++ b/graphics/composer/2.1/default/Android.bp
@@ -0,0 +1,16 @@
+cc_library_shared {
+    name: "android.hardware.graphics.composer@2.1-impl",
+    relative_install_path: "hw",
+    srcs: ["Hwc.cpp"],
+    shared_libs: [
+        "android.hardware.graphics.allocator@2.0",
+        "android.hardware.graphics.composer@2.1",
+        "libbase",
+        "libcutils",
+        "libhardware",
+        "libhidl",
+        "libhwbinder",
+        "liblog",
+        "libutils",
+    ],
+}
diff --git a/graphics/composer/2.1/default/Hwc.cpp b/graphics/composer/2.1/default/Hwc.cpp
new file mode 100644
index 0000000..09c62f0
--- /dev/null
+++ b/graphics/composer/2.1/default/Hwc.cpp
@@ -0,0 +1,1292 @@
+/*
+ * 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 "HwcPassthrough"
+
+#include <mutex>
+#include <type_traits>
+#include <unordered_map>
+#include <unordered_set>
+#include <utility>
+#include <vector>
+
+#include <hardware/gralloc.h>
+#include <hardware/gralloc1.h>
+#include <hardware/hwcomposer2.h>
+#include <log/log.h>
+
+#include "Hwc.h"
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace composer {
+namespace V2_1 {
+namespace implementation {
+
+using android::hardware::graphics::allocator::V2_0::PixelFormat;
+
+namespace {
+
+class HandleImporter {
+public:
+    HandleImporter() : mInitialized(false) {}
+
+    bool initialize()
+    {
+        // allow only one client
+        if (mInitialized) {
+            return false;
+        }
+
+        if (!openGralloc()) {
+            return false;
+        }
+
+        mInitialized = true;
+        return true;
+    }
+
+    void cleanup()
+    {
+        if (!mInitialized) {
+            return;
+        }
+
+        closeGralloc();
+        mInitialized = false;
+    }
+
+    // In IComposer, any buffer_handle_t is owned by the caller and we need to
+    // make a clone for hwcomposer2.  We also need to translate empty handle
+    // to nullptr.  This function does that, in-place.
+    bool importBuffer(buffer_handle_t& handle)
+    {
+        if (!handle->numFds && !handle->numInts) {
+            handle = nullptr;
+            return true;
+        }
+
+        buffer_handle_t clone = cloneBuffer(handle);
+        if (!clone) {
+            return false;
+        }
+
+        handle = clone;
+        return true;
+    }
+
+    void freeBuffer(buffer_handle_t handle)
+    {
+        if (!handle) {
+            return;
+        }
+
+        releaseBuffer(handle);
+    }
+
+    bool importFence(const native_handle_t* handle, int& fd)
+    {
+        if (handle->numFds == 0) {
+            fd = -1;
+        } else if (handle->numFds == 1) {
+            fd = dup(handle->data[0]);
+            if (fd < 0) {
+                ALOGE("failed to dup fence fd %d", handle->data[0]);
+                return false;
+            }
+        } else {
+            ALOGE("invalid fence handle with %d file descriptors",
+                    handle->numFds);
+            return false;
+        }
+
+        return true;
+    }
+
+    void closeFence(int fd)
+    {
+        if (fd >= 0) {
+            close(fd);
+        }
+    }
+
+private:
+    bool mInitialized;
+
+    // Some existing gralloc drivers do not support retaining more than once,
+    // when we are in passthrough mode.
+#ifdef BINDERIZED
+    bool openGralloc()
+    {
+        const hw_module_t* module;
+        int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
+        if (err) {
+            ALOGE("failed to get gralloc module");
+            return false;
+        }
+
+        uint8_t major = (module->module_api_version >> 8) & 0xff;
+        if (major > 1) {
+            ALOGE("unknown gralloc module major version %d", major);
+            return false;
+        }
+
+        if (major == 1) {
+            err = gralloc1_open(module, &mDevice);
+            if (err) {
+                ALOGE("failed to open gralloc1 device");
+                return false;
+            }
+
+            mRetain = reinterpret_cast<GRALLOC1_PFN_RETAIN>(
+                    mDevice->getFunction(mDevice, GRALLOC1_FUNCTION_RETAIN));
+            mRelease = reinterpret_cast<GRALLOC1_PFN_RELEASE>(
+                    mDevice->getFunction(mDevice, GRALLOC1_FUNCTION_RELEASE));
+            if (!mRetain || !mRelease) {
+                ALOGE("invalid gralloc1 device");
+                gralloc1_close(mDevice);
+                return false;
+            }
+        } else {
+            mModule = reinterpret_cast<const gralloc_module_t*>(module);
+        }
+
+        return true;
+    }
+
+    void closeGralloc()
+    {
+        if (mDevice) {
+            gralloc1_close(mDevice);
+        }
+    }
+
+    buffer_handle_t cloneBuffer(buffer_handle_t handle)
+    {
+        native_handle_t* clone = native_handle_clone(handle);
+        if (!clone) {
+            ALOGE("failed to clone buffer %p", handle);
+            return nullptr;
+        }
+
+        bool err;
+        if (mDevice) {
+            err = (mRetain(mDevice, clone) != GRALLOC1_ERROR_NONE);
+        } else {
+            err = (mModule->registerBuffer(mModule, clone) != 0);
+        }
+
+        if (err) {
+            ALOGE("failed to retain/register buffer %p", clone);
+            native_handle_close(clone);
+            native_handle_delete(clone);
+            return nullptr;
+        }
+
+        return clone;
+    }
+
+    void releaseBuffer(buffer_handle_t handle)
+    {
+        if (mDevice) {
+            mRelease(mDevice, handle);
+        } else {
+            mModule->unregisterBuffer(mModule, handle);
+            native_handle_close(handle);
+            native_handle_delete(const_cast<native_handle_t*>(handle));
+        }
+    }
+
+    // gralloc1
+    gralloc1_device_t* mDevice;
+    GRALLOC1_PFN_RETAIN mRetain;
+    GRALLOC1_PFN_RELEASE mRelease;
+
+    // gralloc0
+    const gralloc_module_t* mModule;
+#else
+    bool openGralloc() { return true; }
+    void closeGralloc() {}
+    buffer_handle_t cloneBuffer(buffer_handle_t handle) { return handle; }
+    void releaseBuffer(buffer_handle_t) {}
+#endif
+};
+
+HandleImporter sHandleImporter;
+
+class BufferClone {
+public:
+    BufferClone() : mHandle(nullptr) {}
+
+    BufferClone(BufferClone&& other)
+    {
+        mHandle = other.mHandle;
+        other.mHandle = nullptr;
+    }
+
+    BufferClone(const BufferClone& other) = delete;
+    BufferClone& operator=(const BufferClone& other) = delete;
+
+    BufferClone& operator=(buffer_handle_t handle)
+    {
+        clear();
+        mHandle = handle;
+        return *this;
+    }
+
+    ~BufferClone()
+    {
+        clear();
+    }
+
+private:
+    void clear()
+    {
+        if (mHandle) {
+            sHandleImporter.freeBuffer(mHandle);
+        }
+    }
+
+    buffer_handle_t mHandle;
+};
+
+} // anonymous namespace
+
+class HwcHal : public IComposer {
+public:
+    HwcHal(const hw_module_t* module);
+    virtual ~HwcHal();
+
+    // IComposer interface
+    Return<void> getCapabilities(getCapabilities_cb hidl_cb) override;
+    Return<void> dumpDebugInfo(dumpDebugInfo_cb hidl_cb) override;
+    Return<void> registerCallback(const sp<IComposerCallback>& callback) override;
+    Return<uint32_t> getMaxVirtualDisplayCount() override;
+    Return<void> createVirtualDisplay(uint32_t width, uint32_t height,
+            PixelFormat formatHint, createVirtualDisplay_cb hidl_cb) override;
+    Return<Error> destroyVirtualDisplay(Display display) override;
+    Return<Error> acceptDisplayChanges(Display display) override;
+    Return<void> createLayer(Display display,
+            createLayer_cb hidl_cb) override;
+    Return<Error> destroyLayer(Display display, Layer layer) override;
+    Return<void> getActiveConfig(Display display,
+            getActiveConfig_cb hidl_cb) override;
+    Return<void> getChangedCompositionTypes(Display display,
+            getChangedCompositionTypes_cb hidl_cb) override;
+    Return<Error> getClientTargetSupport(Display display,
+            uint32_t width, uint32_t height,
+            PixelFormat format, Dataspace dataspace) override;
+    Return<void> getColorModes(Display display,
+            getColorModes_cb hidl_cb) override;
+    Return<void> getDisplayAttribute(Display display,
+            Config config, Attribute attribute,
+            getDisplayAttribute_cb hidl_cb) override;
+    Return<void> getDisplayConfigs(Display display,
+            getDisplayConfigs_cb hidl_cb) override;
+    Return<void> getDisplayName(Display display,
+            getDisplayName_cb hidl_cb) override;
+    Return<void> getDisplayRequests(Display display,
+            getDisplayRequests_cb hidl_cb) override;
+    Return<void> getDisplayType(Display display,
+            getDisplayType_cb hidl_cb) override;
+    Return<void> getDozeSupport(Display display,
+            getDozeSupport_cb hidl_cb) override;
+    Return<void> getHdrCapabilities(Display display,
+            getHdrCapabilities_cb hidl_cb) override;
+    Return<void> getReleaseFences(Display display,
+            getReleaseFences_cb hidl_cb) override;
+    Return<void> presentDisplay(Display display,
+            presentDisplay_cb hidl_cb) override;
+    Return<Error> setActiveConfig(Display display, Config config) override;
+    Return<Error> setClientTarget(Display display,
+            const native_handle_t* target,
+            const native_handle_t* acquireFence,
+            Dataspace dataspace, const hidl_vec<Rect>& damage) override;
+    Return<Error> setColorMode(Display display, ColorMode mode) override;
+    Return<Error> setColorTransform(Display display,
+            const hidl_vec<float>& matrix, ColorTransform hint) override;
+    Return<Error> setOutputBuffer(Display display,
+            const native_handle_t* buffer,
+            const native_handle_t* releaseFence) override;
+    Return<Error> setPowerMode(Display display, PowerMode mode) override;
+    Return<Error> setVsyncEnabled(Display display, Vsync enabled) override;
+    Return<void> validateDisplay(Display display,
+            validateDisplay_cb hidl_cb) override;
+    Return<Error> setCursorPosition(Display display,
+            Layer layer, int32_t x, int32_t y) override;
+    Return<Error> setLayerBuffer(Display display,
+            Layer layer, const native_handle_t* buffer,
+            const native_handle_t* acquireFence) override;
+    Return<Error> setLayerSurfaceDamage(Display display,
+            Layer layer, const hidl_vec<Rect>& damage) override;
+    Return<Error> setLayerBlendMode(Display display,
+            Layer layer, BlendMode mode) override;
+    Return<Error> setLayerColor(Display display,
+            Layer layer, const Color& color) override;
+    Return<Error> setLayerCompositionType(Display display,
+            Layer layer, Composition type) override;
+    Return<Error> setLayerDataspace(Display display,
+            Layer layer, Dataspace dataspace) override;
+    Return<Error> setLayerDisplayFrame(Display display,
+            Layer layer, const Rect& frame) override;
+    Return<Error> setLayerPlaneAlpha(Display display,
+            Layer layer, float alpha) override;
+    Return<Error> setLayerSidebandStream(Display display,
+            Layer layer, const native_handle_t* stream) override;
+    Return<Error> setLayerSourceCrop(Display display,
+            Layer layer, const FRect& crop) override;
+    Return<Error> setLayerTransform(Display display,
+            Layer layer, Transform transform) override;
+    Return<Error> setLayerVisibleRegion(Display display,
+            Layer layer, const hidl_vec<Rect>& visible) override;
+    Return<Error> setLayerZOrder(Display display,
+            Layer layer, uint32_t z) override;
+
+private:
+    void initCapabilities();
+
+    template<typename T>
+    void initDispatch(T& func, hwc2_function_descriptor_t desc);
+    void initDispatch();
+
+    bool hasCapability(Capability capability) const;
+
+    static void hotplugHook(hwc2_callback_data_t callbackData,
+        hwc2_display_t display, int32_t connected);
+    static void refreshHook(hwc2_callback_data_t callbackData,
+        hwc2_display_t display);
+    static void vsyncHook(hwc2_callback_data_t callbackData,
+        hwc2_display_t display, int64_t timestamp);
+
+    hwc2_device_t* mDevice;
+
+    std::unordered_set<Capability> mCapabilities;
+
+    struct {
+        HWC2_PFN_ACCEPT_DISPLAY_CHANGES acceptDisplayChanges;
+        HWC2_PFN_CREATE_LAYER createLayer;
+        HWC2_PFN_CREATE_VIRTUAL_DISPLAY createVirtualDisplay;
+        HWC2_PFN_DESTROY_LAYER destroyLayer;
+        HWC2_PFN_DESTROY_VIRTUAL_DISPLAY destroyVirtualDisplay;
+        HWC2_PFN_DUMP dump;
+        HWC2_PFN_GET_ACTIVE_CONFIG getActiveConfig;
+        HWC2_PFN_GET_CHANGED_COMPOSITION_TYPES getChangedCompositionTypes;
+        HWC2_PFN_GET_CLIENT_TARGET_SUPPORT getClientTargetSupport;
+        HWC2_PFN_GET_COLOR_MODES getColorModes;
+        HWC2_PFN_GET_DISPLAY_ATTRIBUTE getDisplayAttribute;
+        HWC2_PFN_GET_DISPLAY_CONFIGS getDisplayConfigs;
+        HWC2_PFN_GET_DISPLAY_NAME getDisplayName;
+        HWC2_PFN_GET_DISPLAY_REQUESTS getDisplayRequests;
+        HWC2_PFN_GET_DISPLAY_TYPE getDisplayType;
+        HWC2_PFN_GET_DOZE_SUPPORT getDozeSupport;
+        HWC2_PFN_GET_HDR_CAPABILITIES getHdrCapabilities;
+        HWC2_PFN_GET_MAX_VIRTUAL_DISPLAY_COUNT getMaxVirtualDisplayCount;
+        HWC2_PFN_GET_RELEASE_FENCES getReleaseFences;
+        HWC2_PFN_PRESENT_DISPLAY presentDisplay;
+        HWC2_PFN_REGISTER_CALLBACK registerCallback;
+        HWC2_PFN_SET_ACTIVE_CONFIG setActiveConfig;
+        HWC2_PFN_SET_CLIENT_TARGET setClientTarget;
+        HWC2_PFN_SET_COLOR_MODE setColorMode;
+        HWC2_PFN_SET_COLOR_TRANSFORM setColorTransform;
+        HWC2_PFN_SET_CURSOR_POSITION setCursorPosition;
+        HWC2_PFN_SET_LAYER_BLEND_MODE setLayerBlendMode;
+        HWC2_PFN_SET_LAYER_BUFFER setLayerBuffer;
+        HWC2_PFN_SET_LAYER_COLOR setLayerColor;
+        HWC2_PFN_SET_LAYER_COMPOSITION_TYPE setLayerCompositionType;
+        HWC2_PFN_SET_LAYER_DATASPACE setLayerDataspace;
+        HWC2_PFN_SET_LAYER_DISPLAY_FRAME setLayerDisplayFrame;
+        HWC2_PFN_SET_LAYER_PLANE_ALPHA setLayerPlaneAlpha;
+        HWC2_PFN_SET_LAYER_SIDEBAND_STREAM setLayerSidebandStream;
+        HWC2_PFN_SET_LAYER_SOURCE_CROP setLayerSourceCrop;
+        HWC2_PFN_SET_LAYER_SURFACE_DAMAGE setLayerSurfaceDamage;
+        HWC2_PFN_SET_LAYER_TRANSFORM setLayerTransform;
+        HWC2_PFN_SET_LAYER_VISIBLE_REGION setLayerVisibleRegion;
+        HWC2_PFN_SET_LAYER_Z_ORDER setLayerZOrder;
+        HWC2_PFN_SET_OUTPUT_BUFFER setOutputBuffer;
+        HWC2_PFN_SET_POWER_MODE setPowerMode;
+        HWC2_PFN_SET_VSYNC_ENABLED setVsyncEnabled;
+        HWC2_PFN_VALIDATE_DISPLAY validateDisplay;
+    } mDispatch;
+
+    // cloned buffers for a display
+    struct DisplayBuffers {
+        BufferClone ClientTarget;
+        BufferClone OutputBuffer;
+
+        std::unordered_map<Layer, BufferClone> LayerBuffers;
+        std::unordered_map<Layer, BufferClone> LayerSidebandStreams;
+    };
+
+    std::mutex mCallbackMutex;
+    sp<IComposerCallback> mCallback;
+
+    std::mutex mDisplayMutex;
+    std::unordered_map<Display, DisplayBuffers> mDisplays;
+};
+
+HwcHal::HwcHal(const hw_module_t* module)
+    : mDevice(nullptr), mDispatch()
+{
+    if (!sHandleImporter.initialize()) {
+        LOG_ALWAYS_FATAL("failed to initialize handle importer");
+    }
+
+    int status = hwc2_open(module, &mDevice);
+    if (status) {
+        LOG_ALWAYS_FATAL("failed to open hwcomposer2 device: %s",
+                strerror(-status));
+    }
+
+    initCapabilities();
+    initDispatch();
+}
+
+HwcHal::~HwcHal()
+{
+    hwc2_close(mDevice);
+    mDisplays.clear();
+    sHandleImporter.cleanup();
+}
+
+void HwcHal::initCapabilities()
+{
+    uint32_t count = 0;
+    mDevice->getCapabilities(mDevice, &count, nullptr);
+
+    std::vector<Capability> caps(count);
+    mDevice->getCapabilities(mDevice, &count, reinterpret_cast<
+              std::underlying_type<Capability>::type*>(caps.data()));
+    caps.resize(count);
+
+    mCapabilities.insert(caps.cbegin(), caps.cend());
+}
+
+template<typename T>
+void HwcHal::initDispatch(T& func, hwc2_function_descriptor_t desc)
+{
+    auto pfn = mDevice->getFunction(mDevice, desc);
+    if (!pfn) {
+        LOG_ALWAYS_FATAL("failed to get hwcomposer2 function %d", desc);
+    }
+
+    func = reinterpret_cast<T>(pfn);
+}
+
+void HwcHal::initDispatch()
+{
+    initDispatch(mDispatch.acceptDisplayChanges,
+            HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES);
+    initDispatch(mDispatch.createLayer, HWC2_FUNCTION_CREATE_LAYER);
+    initDispatch(mDispatch.createVirtualDisplay,
+            HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY);
+    initDispatch(mDispatch.destroyLayer, HWC2_FUNCTION_DESTROY_LAYER);
+    initDispatch(mDispatch.destroyVirtualDisplay,
+            HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY);
+    initDispatch(mDispatch.dump, HWC2_FUNCTION_DUMP);
+    initDispatch(mDispatch.getActiveConfig, HWC2_FUNCTION_GET_ACTIVE_CONFIG);
+    initDispatch(mDispatch.getChangedCompositionTypes,
+            HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES);
+    initDispatch(mDispatch.getClientTargetSupport,
+            HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT);
+    initDispatch(mDispatch.getColorModes, HWC2_FUNCTION_GET_COLOR_MODES);
+    initDispatch(mDispatch.getDisplayAttribute,
+            HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE);
+    initDispatch(mDispatch.getDisplayConfigs,
+            HWC2_FUNCTION_GET_DISPLAY_CONFIGS);
+    initDispatch(mDispatch.getDisplayName, HWC2_FUNCTION_GET_DISPLAY_NAME);
+    initDispatch(mDispatch.getDisplayRequests,
+            HWC2_FUNCTION_GET_DISPLAY_REQUESTS);
+    initDispatch(mDispatch.getDisplayType, HWC2_FUNCTION_GET_DISPLAY_TYPE);
+    initDispatch(mDispatch.getDozeSupport, HWC2_FUNCTION_GET_DOZE_SUPPORT);
+    initDispatch(mDispatch.getHdrCapabilities,
+            HWC2_FUNCTION_GET_HDR_CAPABILITIES);
+    initDispatch(mDispatch.getMaxVirtualDisplayCount,
+            HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT);
+    initDispatch(mDispatch.getReleaseFences,
+            HWC2_FUNCTION_GET_RELEASE_FENCES);
+    initDispatch(mDispatch.presentDisplay, HWC2_FUNCTION_PRESENT_DISPLAY);
+    initDispatch(mDispatch.registerCallback, HWC2_FUNCTION_REGISTER_CALLBACK);
+    initDispatch(mDispatch.setActiveConfig, HWC2_FUNCTION_SET_ACTIVE_CONFIG);
+    initDispatch(mDispatch.setClientTarget, HWC2_FUNCTION_SET_CLIENT_TARGET);
+    initDispatch(mDispatch.setColorMode, HWC2_FUNCTION_SET_COLOR_MODE);
+    initDispatch(mDispatch.setColorTransform,
+            HWC2_FUNCTION_SET_COLOR_TRANSFORM);
+    initDispatch(mDispatch.setCursorPosition,
+            HWC2_FUNCTION_SET_CURSOR_POSITION);
+    initDispatch(mDispatch.setLayerBlendMode,
+            HWC2_FUNCTION_SET_LAYER_BLEND_MODE);
+    initDispatch(mDispatch.setLayerBuffer, HWC2_FUNCTION_SET_LAYER_BUFFER);
+    initDispatch(mDispatch.setLayerColor, HWC2_FUNCTION_SET_LAYER_COLOR);
+    initDispatch(mDispatch.setLayerCompositionType,
+            HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE);
+    initDispatch(mDispatch.setLayerDataspace,
+            HWC2_FUNCTION_SET_LAYER_DATASPACE);
+    initDispatch(mDispatch.setLayerDisplayFrame,
+            HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME);
+    initDispatch(mDispatch.setLayerPlaneAlpha,
+            HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA);
+
+    if (hasCapability(Capability::SIDEBAND_STREAM)) {
+        initDispatch(mDispatch.setLayerSidebandStream,
+                HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM);
+    }
+
+    initDispatch(mDispatch.setLayerSourceCrop,
+            HWC2_FUNCTION_SET_LAYER_SOURCE_CROP);
+    initDispatch(mDispatch.setLayerSurfaceDamage,
+            HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE);
+    initDispatch(mDispatch.setLayerTransform,
+            HWC2_FUNCTION_SET_LAYER_TRANSFORM);
+    initDispatch(mDispatch.setLayerVisibleRegion,
+            HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION);
+    initDispatch(mDispatch.setLayerZOrder, HWC2_FUNCTION_SET_LAYER_Z_ORDER);
+    initDispatch(mDispatch.setOutputBuffer, HWC2_FUNCTION_SET_OUTPUT_BUFFER);
+    initDispatch(mDispatch.setPowerMode, HWC2_FUNCTION_SET_POWER_MODE);
+    initDispatch(mDispatch.setVsyncEnabled, HWC2_FUNCTION_SET_VSYNC_ENABLED);
+    initDispatch(mDispatch.validateDisplay, HWC2_FUNCTION_VALIDATE_DISPLAY);
+}
+
+bool HwcHal::hasCapability(Capability capability) const
+{
+    return (mCapabilities.count(capability) > 0);
+}
+
+Return<void> HwcHal::getCapabilities(getCapabilities_cb hidl_cb)
+{
+    std::vector<Capability> caps(
+            mCapabilities.cbegin(), mCapabilities.cend());
+
+    hidl_vec<Capability> caps_reply;
+    caps_reply.setToExternal(caps.data(), caps.size());
+    hidl_cb(caps_reply);
+
+    return Void();
+}
+
+Return<void> HwcHal::dumpDebugInfo(dumpDebugInfo_cb hidl_cb)
+{
+    uint32_t len;
+    mDispatch.dump(mDevice, &len, nullptr);
+
+    std::vector<char> buf(len + 1);
+    mDispatch.dump(mDevice, &len, buf.data());
+    buf.resize(len + 1);
+    buf[len] = '\0';
+
+    hidl_string buf_reply;
+    buf_reply.setToExternal(buf.data(), len);
+    hidl_cb(buf_reply);
+
+    return Void();
+}
+
+void HwcHal::hotplugHook(hwc2_callback_data_t callbackData,
+        hwc2_display_t display, int32_t connected)
+{
+    auto hal = reinterpret_cast<HwcHal*>(callbackData);
+
+    {
+        std::lock_guard<std::mutex> lock(hal->mDisplayMutex);
+
+        if (connected == HWC2_CONNECTION_CONNECTED) {
+            hal->mDisplays.emplace(display, DisplayBuffers());
+        } else if (connected == HWC2_CONNECTION_DISCONNECTED) {
+            hal->mDisplays.erase(display);
+        }
+    }
+
+    hal->mCallback->onHotplug(display,
+            static_cast<IComposerCallback::Connection>(connected));
+}
+
+void HwcHal::refreshHook(hwc2_callback_data_t callbackData,
+        hwc2_display_t display)
+{
+    auto hal = reinterpret_cast<HwcHal*>(callbackData);
+    hal->mCallback->onRefresh(display);
+}
+
+void HwcHal::vsyncHook(hwc2_callback_data_t callbackData,
+        hwc2_display_t display, int64_t timestamp)
+{
+    auto hal = reinterpret_cast<HwcHal*>(callbackData);
+    hal->mCallback->onVsync(display, timestamp);
+}
+
+Return<void> HwcHal::registerCallback(const sp<IComposerCallback>& callback)
+{
+    std::lock_guard<std::mutex> lock(mCallbackMutex);
+
+    mCallback = callback;
+
+    mDispatch.registerCallback(mDevice, HWC2_CALLBACK_HOTPLUG, this,
+            reinterpret_cast<hwc2_function_pointer_t>(hotplugHook));
+    mDispatch.registerCallback(mDevice, HWC2_CALLBACK_REFRESH, this,
+            reinterpret_cast<hwc2_function_pointer_t>(refreshHook));
+    mDispatch.registerCallback(mDevice, HWC2_CALLBACK_VSYNC, this,
+            reinterpret_cast<hwc2_function_pointer_t>(vsyncHook));
+
+    return Void();
+}
+
+Return<uint32_t> HwcHal::getMaxVirtualDisplayCount()
+{
+    return mDispatch.getMaxVirtualDisplayCount(mDevice);
+}
+
+Return<void> HwcHal::createVirtualDisplay(uint32_t width, uint32_t height,
+        PixelFormat formatHint, createVirtualDisplay_cb hidl_cb)
+{
+    int32_t format = static_cast<int32_t>(formatHint);
+    hwc2_display_t display;
+    auto error = mDispatch.createVirtualDisplay(mDevice, width, height,
+            &format, &display);
+    if (error == HWC2_ERROR_NONE) {
+        std::lock_guard<std::mutex> lock(mDisplayMutex);
+
+        mDisplays.emplace(display, DisplayBuffers());
+    }
+
+    hidl_cb(static_cast<Error>(error), display,
+            static_cast<PixelFormat>(format));
+
+    return Void();
+}
+
+Return<Error> HwcHal::destroyVirtualDisplay(Display display)
+{
+    auto error = mDispatch.destroyVirtualDisplay(mDevice, display);
+    if (error == HWC2_ERROR_NONE) {
+        std::lock_guard<std::mutex> lock(mDisplayMutex);
+
+        mDisplays.erase(display);
+    }
+
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::acceptDisplayChanges(Display display)
+{
+    auto error = mDispatch.acceptDisplayChanges(mDevice, display);
+    return static_cast<Error>(error);
+}
+
+Return<void> HwcHal::createLayer(Display display, createLayer_cb hidl_cb)
+{
+    hwc2_layer_t layer;
+    auto error = mDispatch.createLayer(mDevice, display, &layer);
+
+    hidl_cb(static_cast<Error>(error), layer);
+
+    return Void();
+}
+
+Return<Error> HwcHal::destroyLayer(Display display, Layer layer)
+{
+    auto error = mDispatch.destroyLayer(mDevice, display, layer);
+    return static_cast<Error>(error);
+}
+
+Return<void> HwcHal::getActiveConfig(Display display,
+        getActiveConfig_cb hidl_cb)
+{
+    hwc2_config_t config;
+    auto error = mDispatch.getActiveConfig(mDevice, display, &config);
+
+    hidl_cb(static_cast<Error>(error), config);
+
+    return Void();
+}
+
+Return<void> HwcHal::getChangedCompositionTypes(Display display,
+        getChangedCompositionTypes_cb hidl_cb)
+{
+    uint32_t count = 0;
+    auto error = mDispatch.getChangedCompositionTypes(mDevice, display,
+            &count, nullptr, nullptr);
+    if (error != HWC2_ERROR_NONE) {
+        count = 0;
+    }
+
+    std::vector<hwc2_layer_t> layers(count);
+    std::vector<Composition> types(count);
+    error = mDispatch.getChangedCompositionTypes(mDevice, display,
+            &count, layers.data(),
+            reinterpret_cast<std::underlying_type<Composition>::type*>(
+                types.data()));
+    if (error != HWC2_ERROR_NONE) {
+        count = 0;
+    }
+    layers.resize(count);
+    types.resize(count);
+
+    hidl_vec<Layer> layers_reply;
+    layers_reply.setToExternal(layers.data(), layers.size());
+
+    hidl_vec<Composition> types_reply;
+    types_reply.setToExternal(types.data(), types.size());
+
+    hidl_cb(static_cast<Error>(error), layers_reply, types_reply);
+
+    return Void();
+}
+
+Return<Error> HwcHal::getClientTargetSupport(Display display,
+        uint32_t width, uint32_t height,
+        PixelFormat format, Dataspace dataspace)
+{
+    auto error = mDispatch.getClientTargetSupport(mDevice, display,
+            width, height, static_cast<int32_t>(format),
+            static_cast<int32_t>(dataspace));
+    return static_cast<Error>(error);
+}
+
+Return<void> HwcHal::getColorModes(Display display, getColorModes_cb hidl_cb)
+{
+    uint32_t count = 0;
+    auto error = mDispatch.getColorModes(mDevice, display, &count, nullptr);
+    if (error != HWC2_ERROR_NONE) {
+        count = 0;
+    }
+
+    std::vector<ColorMode> modes(count);
+    error = mDispatch.getColorModes(mDevice, display, &count,
+            reinterpret_cast<std::underlying_type<ColorMode>::type*>(
+                modes.data()));
+    if (error != HWC2_ERROR_NONE) {
+        count = 0;
+    }
+    modes.resize(count);
+
+    hidl_vec<ColorMode> modes_reply;
+    modes_reply.setToExternal(modes.data(), modes.size());
+    hidl_cb(static_cast<Error>(error), modes_reply);
+
+    return Void();
+}
+
+Return<void> HwcHal::getDisplayAttribute(Display display,
+        Config config, Attribute attribute,
+        getDisplayAttribute_cb hidl_cb)
+{
+    int32_t value;
+    auto error = mDispatch.getDisplayAttribute(mDevice, display, config,
+            static_cast<int32_t>(attribute), &value);
+
+    hidl_cb(static_cast<Error>(error), value);
+
+    return Void();
+}
+
+Return<void> HwcHal::getDisplayConfigs(Display display,
+        getDisplayConfigs_cb hidl_cb)
+{
+    uint32_t count = 0;
+    auto error = mDispatch.getDisplayConfigs(mDevice, display,
+            &count, nullptr);
+    if (error != HWC2_ERROR_NONE) {
+        count = 0;
+    }
+
+    std::vector<hwc2_config_t> configs(count);
+    error = mDispatch.getDisplayConfigs(mDevice, display,
+            &count, configs.data());
+    if (error != HWC2_ERROR_NONE) {
+        count = 0;
+    }
+    configs.resize(count);
+
+    hidl_vec<Config> configs_reply;
+    configs_reply.setToExternal(configs.data(), configs.size());
+    hidl_cb(static_cast<Error>(error), configs_reply);
+
+    return Void();
+}
+
+Return<void> HwcHal::getDisplayName(Display display,
+        getDisplayName_cb hidl_cb)
+{
+    uint32_t count = 0;
+    auto error = mDispatch.getDisplayName(mDevice, display, &count, nullptr);
+    if (error != HWC2_ERROR_NONE) {
+        count = 0;
+    }
+
+    std::vector<char> name(count + 1);
+    error = mDispatch.getDisplayName(mDevice, display, &count, name.data());
+    if (error != HWC2_ERROR_NONE) {
+        count = 0;
+    }
+    name.resize(count + 1);
+    name[count] = '\0';
+
+    hidl_string name_reply;
+    name_reply.setToExternal(name.data(), count);
+    hidl_cb(static_cast<Error>(error), name_reply);
+
+    return Void();
+}
+
+Return<void> HwcHal::getDisplayRequests(Display display,
+        getDisplayRequests_cb hidl_cb)
+{
+    int32_t display_reqs;
+    uint32_t count = 0;
+    auto error = mDispatch.getDisplayRequests(mDevice, display,
+            &display_reqs, &count, nullptr, nullptr);
+    if (error != HWC2_ERROR_NONE) {
+        count = 0;
+    }
+
+    std::vector<hwc2_layer_t> layers(count);
+    std::vector<int32_t> layer_reqs(count);
+    error = mDispatch.getDisplayRequests(mDevice, display,
+            &display_reqs, &count, layers.data(), layer_reqs.data());
+    if (error != HWC2_ERROR_NONE) {
+        count = 0;
+    }
+    layers.resize(count);
+    layer_reqs.resize(count);
+
+    hidl_vec<Layer> layers_reply;
+    layers_reply.setToExternal(layers.data(), layers.size());
+
+    hidl_vec<uint32_t> layer_reqs_reply;
+    layer_reqs_reply.setToExternal(
+            reinterpret_cast<uint32_t*>(layer_reqs.data()),
+            layer_reqs.size());
+
+    hidl_cb(static_cast<Error>(error), display_reqs,
+            layers_reply, layer_reqs_reply);
+
+    return Void();
+}
+
+Return<void> HwcHal::getDisplayType(Display display,
+        getDisplayType_cb hidl_cb)
+{
+    int32_t type;
+    auto error = mDispatch.getDisplayType(mDevice, display, &type);
+
+    hidl_cb(static_cast<Error>(error), static_cast<DisplayType>(type));
+
+    return Void();
+}
+
+Return<void> HwcHal::getDozeSupport(Display display,
+        getDozeSupport_cb hidl_cb)
+{
+    int32_t support;
+    auto error = mDispatch.getDozeSupport(mDevice, display, &support);
+
+    hidl_cb(static_cast<Error>(error), support);
+
+    return Void();
+}
+
+Return<void> HwcHal::getHdrCapabilities(Display display,
+        getHdrCapabilities_cb hidl_cb)
+{
+    float max_lumi, max_avg_lumi, min_lumi;
+    uint32_t count = 0;
+    auto error = mDispatch.getHdrCapabilities(mDevice, display,
+            &count, nullptr, &max_lumi, &max_avg_lumi, &min_lumi);
+    if (error != HWC2_ERROR_NONE) {
+        count = 0;
+    }
+
+    std::vector<Hdr> types(count);
+    error = mDispatch.getHdrCapabilities(mDevice, display, &count,
+            reinterpret_cast<std::underlying_type<Hdr>::type*>(types.data()),
+            &max_lumi, &max_avg_lumi, &min_lumi);
+    if (error != HWC2_ERROR_NONE) {
+        count = 0;
+    }
+    types.resize(count);
+
+    hidl_vec<Hdr> types_reply;
+    types_reply.setToExternal(types.data(), types.size());
+    hidl_cb(static_cast<Error>(error), types_reply,
+            max_lumi, max_avg_lumi, min_lumi);
+
+    return Void();
+}
+
+Return<void> HwcHal::getReleaseFences(Display display,
+        getReleaseFences_cb hidl_cb)
+{
+    uint32_t count = 0;
+    auto error = mDispatch.getReleaseFences(mDevice, display,
+            &count, nullptr, nullptr);
+    if (error != HWC2_ERROR_NONE) {
+        count = 0;
+    }
+
+    std::vector<hwc2_layer_t> layers(count);
+    std::vector<int32_t> fences(count);
+    error = mDispatch.getReleaseFences(mDevice, display,
+            &count, layers.data(), fences.data());
+    if (error != HWC2_ERROR_NONE) {
+        count = 0;
+    }
+    layers.resize(count);
+    fences.resize(count);
+
+    // filter out layers with release fence -1
+    std::vector<hwc2_layer_t> filtered_layers;
+    std::vector<int> filtered_fences;
+    for (size_t i = 0; i < layers.size(); i++) {
+        if (fences[i] >= 0) {
+            filtered_layers.push_back(layers[i]);
+            filtered_fences.push_back(fences[i]);
+        }
+    }
+
+    hidl_vec<Layer> layers_reply;
+    native_handle_t* fences_reply =
+        native_handle_create(filtered_fences.size(), 0);
+    if (fences_reply) {
+        layers_reply.setToExternal(filtered_layers.data(),
+                filtered_layers.size());
+        memcpy(fences_reply->data, filtered_fences.data(),
+                sizeof(int) * filtered_fences.size());
+
+        hidl_cb(static_cast<Error>(error), layers_reply, fences_reply);
+
+        native_handle_close(fences_reply);
+        native_handle_delete(fences_reply);
+    } else {
+        NATIVE_HANDLE_DECLARE_STORAGE(fences_storage, 0, 0);
+        fences_reply = native_handle_init(fences_storage, 0, 0);
+
+        hidl_cb(Error::NO_RESOURCES, layers_reply, fences_reply);
+
+        for (auto fence : filtered_fences) {
+            close(fence);
+        }
+    }
+
+    return Void();
+}
+
+Return<void> HwcHal::presentDisplay(Display display,
+        presentDisplay_cb hidl_cb)
+{
+    int32_t fence = -1;
+    auto error = mDispatch.presentDisplay(mDevice, display, &fence);
+
+    NATIVE_HANDLE_DECLARE_STORAGE(fence_storage, 1, 0);
+    native_handle_t* fence_reply;
+    if (fence >= 0) {
+        fence_reply = native_handle_init(fence_storage, 1, 0);
+        fence_reply->data[0] = fence;
+    } else {
+        fence_reply = native_handle_init(fence_storage, 0, 0);
+    }
+
+    hidl_cb(static_cast<Error>(error), fence_reply);
+
+    if (fence >= 0) {
+        close(fence);
+    }
+
+    return Void();
+}
+
+Return<Error> HwcHal::setActiveConfig(Display display, Config config)
+{
+    auto error = mDispatch.setActiveConfig(mDevice, display, config);
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setClientTarget(Display display,
+        const native_handle_t* target,
+        const native_handle_t* acquireFence,
+        Dataspace dataspace, const hidl_vec<Rect>& damage)
+{
+    if (!sHandleImporter.importBuffer(target)) {
+        return Error::NO_RESOURCES;
+    }
+
+    int32_t fence;
+    if (!sHandleImporter.importFence(acquireFence, fence)) {
+        sHandleImporter.freeBuffer(target);
+        return Error::NO_RESOURCES;
+    }
+
+    hwc_region_t damage_region = { damage.size(),
+        reinterpret_cast<const hwc_rect_t*>(&damage[0]) };
+
+    int32_t error = mDispatch.setClientTarget(mDevice, display,
+            target, fence, static_cast<int32_t>(dataspace),
+            damage_region);
+    if (error == HWC2_ERROR_NONE) {
+        std::lock_guard<std::mutex> lock(mDisplayMutex);
+
+        auto dpy = mDisplays.find(display);
+        dpy->second.ClientTarget = target;
+    } else {
+        sHandleImporter.freeBuffer(target);
+        sHandleImporter.closeFence(fence);
+    }
+
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setColorMode(Display display, ColorMode mode)
+{
+    auto error = mDispatch.setColorMode(mDevice, display,
+            static_cast<int32_t>(mode));
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setColorTransform(Display display,
+        const hidl_vec<float>& matrix, ColorTransform hint)
+{
+    auto error = mDispatch.setColorTransform(mDevice, display,
+            &matrix[0], static_cast<int32_t>(hint));
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setOutputBuffer(Display display,
+        const native_handle_t* buffer,
+        const native_handle_t* releaseFence)
+{
+    if (!sHandleImporter.importBuffer(buffer)) {
+        return Error::NO_RESOURCES;
+    }
+
+    int32_t fence;
+    if (!sHandleImporter.importFence(releaseFence, fence)) {
+        sHandleImporter.freeBuffer(buffer);
+        return Error::NO_RESOURCES;
+    }
+
+    int32_t error = mDispatch.setOutputBuffer(mDevice,
+            display, buffer, fence);
+    if (error == HWC2_ERROR_NONE) {
+        std::lock_guard<std::mutex> lock(mDisplayMutex);
+
+        auto dpy = mDisplays.find(display);
+        dpy->second.OutputBuffer = buffer;
+    } else {
+        sHandleImporter.freeBuffer(buffer);
+    }
+
+    // unlike in setClientTarget, fence is owned by us and is always closed
+    sHandleImporter.closeFence(fence);
+
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setPowerMode(Display display, PowerMode mode)
+{
+    auto error = mDispatch.setPowerMode(mDevice, display,
+            static_cast<int32_t>(mode));
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setVsyncEnabled(Display display,
+        Vsync enabled)
+{
+    auto error = mDispatch.setVsyncEnabled(mDevice, display,
+            static_cast<int32_t>(enabled));
+    return static_cast<Error>(error);
+}
+
+Return<void> HwcHal::validateDisplay(Display display,
+        validateDisplay_cb hidl_cb)
+{
+    uint32_t types_count = 0;
+    uint32_t reqs_count = 0;
+    auto error = mDispatch.validateDisplay(mDevice, display,
+            &types_count, &reqs_count);
+
+    hidl_cb(static_cast<Error>(error), types_count, reqs_count);
+
+    return Void();
+}
+
+Return<Error> HwcHal::setCursorPosition(Display display,
+        Layer layer, int32_t x, int32_t y)
+{
+    auto error = mDispatch.setCursorPosition(mDevice, display, layer, x, y);
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setLayerBuffer(Display display,
+        Layer layer, const native_handle_t* buffer,
+        const native_handle_t* acquireFence)
+{
+    if (!sHandleImporter.importBuffer(buffer)) {
+        return Error::NO_RESOURCES;
+    }
+
+    int32_t fence;
+    if (!sHandleImporter.importFence(acquireFence, fence)) {
+        sHandleImporter.freeBuffer(buffer);
+        return Error::NO_RESOURCES;
+    }
+
+    int32_t error = mDispatch.setLayerBuffer(mDevice,
+            display, layer, buffer, fence);
+    if (error == HWC2_ERROR_NONE) {
+        std::lock_guard<std::mutex> lock(mDisplayMutex);
+
+        auto dpy = mDisplays.find(display);
+        dpy->second.LayerBuffers[layer] = buffer;
+    } else {
+        sHandleImporter.freeBuffer(buffer);
+        sHandleImporter.closeFence(fence);
+    }
+
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setLayerSurfaceDamage(Display display,
+        Layer layer, const hidl_vec<Rect>& damage)
+{
+    hwc_region_t damage_region = { damage.size(),
+        reinterpret_cast<const hwc_rect_t*>(&damage[0]) };
+
+    auto error = mDispatch.setLayerSurfaceDamage(mDevice, display, layer,
+            damage_region);
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setLayerBlendMode(Display display,
+        Layer layer, BlendMode mode)
+{
+    auto error = mDispatch.setLayerBlendMode(mDevice, display, layer,
+            static_cast<int32_t>(mode));
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setLayerColor(Display display,
+        Layer layer, const Color& color)
+{
+    hwc_color_t hwc_color{color.r, color.g, color.b, color.a};
+    auto error = mDispatch.setLayerColor(mDevice, display, layer, hwc_color);
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setLayerCompositionType(Display display,
+        Layer layer, Composition type)
+{
+    auto error = mDispatch.setLayerCompositionType(mDevice, display, layer,
+            static_cast<int32_t>(type));
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setLayerDataspace(Display display,
+        Layer layer, Dataspace dataspace)
+{
+    auto error = mDispatch.setLayerDataspace(mDevice, display, layer,
+            static_cast<int32_t>(dataspace));
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setLayerDisplayFrame(Display display,
+        Layer layer, const Rect& frame)
+{
+    hwc_rect_t hwc_frame{frame.left, frame.top, frame.right, frame.bottom};
+    auto error = mDispatch.setLayerDisplayFrame(mDevice, display, layer,
+            hwc_frame);
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setLayerPlaneAlpha(Display display,
+        Layer layer, float alpha)
+{
+    auto error = mDispatch.setLayerPlaneAlpha(mDevice, display, layer, alpha);
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setLayerSidebandStream(Display display,
+        Layer layer, const native_handle_t* stream)
+{
+    if (!sHandleImporter.importBuffer(stream)) {
+        return Error::NO_RESOURCES;
+    }
+
+    int32_t error = mDispatch.setLayerSidebandStream(mDevice,
+            display, layer, stream);
+    if (error == HWC2_ERROR_NONE) {
+        std::lock_guard<std::mutex> lock(mDisplayMutex);
+
+        auto dpy = mDisplays.find(display);
+        dpy->second.LayerSidebandStreams[layer] = stream;
+    } else {
+        sHandleImporter.freeBuffer(stream);
+    }
+
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setLayerSourceCrop(Display display,
+        Layer layer, const FRect& crop)
+{
+    hwc_frect_t hwc_crop{crop.left, crop.top, crop.right, crop.bottom};
+    auto error = mDispatch.setLayerSourceCrop(mDevice, display, layer,
+            hwc_crop);
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setLayerTransform(Display display,
+        Layer layer, Transform transform)
+{
+    auto error = mDispatch.setLayerTransform(mDevice, display, layer,
+            static_cast<int32_t>(transform));
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setLayerVisibleRegion(Display display,
+        Layer layer, const hidl_vec<Rect>& visible)
+{
+    hwc_region_t visible_region = { visible.size(),
+        reinterpret_cast<const hwc_rect_t*>(&visible[0]) };
+
+    auto error = mDispatch.setLayerVisibleRegion(mDevice, display, layer,
+            visible_region);
+    return static_cast<Error>(error);
+}
+
+Return<Error> HwcHal::setLayerZOrder(Display display,
+        Layer layer, uint32_t z)
+{
+    auto error = mDispatch.setLayerZOrder(mDevice, display, layer, z);
+    return static_cast<Error>(error);
+}
+
+IComposer* HIDL_FETCH_IComposer(const char*)
+{
+    const hw_module_t* module;
+    int err = hw_get_module(HWC_HARDWARE_MODULE_ID, &module);
+    if (err) {
+        ALOGE("failed to get hwcomposer module");
+        return nullptr;
+    }
+
+    return new HwcHal(module);
+}
+
+} // namespace implementation
+} // namespace V2_1
+} // namespace composer
+} // namespace graphics
+} // namespace hardware
+} // namespace android
diff --git a/graphics/composer/2.1/default/Hwc.h b/graphics/composer/2.1/default/Hwc.h
new file mode 100644
index 0000000..de69417
--- /dev/null
+++ b/graphics/composer/2.1/default/Hwc.h
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+#ifndef ANDROID_HARDWARE_GRAPHICS_COMPOSER_V2_1_HWC_H
+#define ANDROID_HARDWARE_GRAPHICS_COMPOSER_V2_1_HWC_H
+
+#include <android/hardware/graphics/composer/2.1/IComposer.h>
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace composer {
+namespace V2_1 {
+namespace implementation {
+
+extern "C" IComposer* HIDL_FETCH_IComposer(const char* name);
+
+} // namespace implementation
+} // namespace V2_1
+} // namespace composer
+} // namespace graphics
+} // namespace hardware
+} // namespace android
+
+#endif  // ANDROID_HARDWARE_GRAPHICS_COMPOSER_V2_1_HWC_H
diff --git a/graphics/composer/2.1/types.hal b/graphics/composer/2.1/types.hal
new file mode 100644
index 0000000..3c591b3
--- /dev/null
+++ b/graphics/composer/2.1/types.hal
@@ -0,0 +1,163 @@
+/*
+ * 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.graphics.composer@2.1;
+
+/* Return codes from all functions. */
+enum Error : int32_t {
+    NONE            = 0, /* no error */
+    BAD_CONFIG      = 1, /* invalid Config */
+    BAD_DISPLAY     = 2, /* invalid Display */
+    BAD_LAYER       = 3, /* invalid Layer */
+    BAD_PARAMETER   = 4, /* invalid width, height, etc. */
+    HAS_CHANGES     = 5,
+    NO_RESOURCES    = 6, /* temporary failure due to resource contention */
+    NOT_VALIDATED   = 7, /* validateDisplay has not been called */
+    UNSUPPORTED     = 8, /* permanent failure */
+};
+
+typedef uint32_t Config;
+typedef uint64_t Display;
+typedef uint64_t Layer;
+
+/*
+ * Copied from android_transform_t
+ *
+ * TODO(olv) copy comments over and generate android_transform_t
+ */
+enum Transform : int32_t {
+    FLIP_H    = 0x1,
+    FLIP_V    = 0x2,
+    ROT_90    = 0x4,
+    ROT_180   = 0x3,
+    ROT_270   = 0x7,
+    RESERVED  = 0x8,
+};
+
+/*
+ * Copied from android_color_mode_t
+ *
+ * TODO(olv) copy comments over and generate android_color_mode_t
+ */
+enum ColorMode : int32_t {
+  NATIVE                        = 0,
+  STANDARD_BT601_625            = 1,
+  STANDARD_BT601_625_UNADJUSTED = 2,
+  STANDARD_BT601_525            = 3,
+  STANDARD_BT601_525_UNADJUSTED = 4,
+  STANDARD_BT709                = 5,
+  DCI_P3                        = 6,
+  SRGB                          = 7,
+  ADOBE_RGB                     = 8,
+};
+
+/*
+ * Copied from android_color_transform_t
+ *
+ * TODO(olv) copy comments over and generate android_color_transform_t
+ */
+enum ColorTransform : int32_t {
+    IDENTITY             = 0,
+    ARBITRARY_MATRIX     = 1,
+    VALUE_INVERSE        = 2,
+    GRAYSCALE            = 3,
+    CORRECT_PROTANOPIA   = 4,
+    CORRECT_DEUTERANOPIA = 5,
+    CORRECT_TRITANOPIA   = 6
+};
+
+/*
+ * Copied from android_dataspace_t
+ *
+ * TODO(olv) copy comments over and generate android_dataspace_t
+ */
+enum Dataspace : int32_t {
+    UNKNOWN                            = 0x0,
+    ARBITRARY                          = 0x1,
+
+    STANDARD_SHIFT                     = 16,
+    STANDARD_MASK                      = 63 << STANDARD_SHIFT,
+    STANDARD_UNSPECIFIED               = 0 << STANDARD_SHIFT,
+    STANDARD_BT709                     = 1 << STANDARD_SHIFT,
+    STANDARD_BT601_625                 = 2 << STANDARD_SHIFT,
+    STANDARD_BT601_625_UNADJUSTED      = 3 << STANDARD_SHIFT,
+    STANDARD_BT601_525                 = 4 << STANDARD_SHIFT,
+    STANDARD_BT601_525_UNADJUSTED      = 5 << STANDARD_SHIFT,
+    STANDARD_BT2020                    = 6 << STANDARD_SHIFT,
+    STANDARD_BT2020_CONSTANT_LUMINANCE = 7 << STANDARD_SHIFT,
+    STANDARD_BT470M                    = 8 << STANDARD_SHIFT,
+    STANDARD_FILM                      = 9 << STANDARD_SHIFT,
+
+    TRANSFER_SHIFT                     = 22,
+    TRANSFER_MASK                      = 31 << TRANSFER_SHIFT,
+    TRANSFER_UNSPECIFIED               = 0 << TRANSFER_SHIFT,
+    TRANSFER_LINEAR                    = 1 << TRANSFER_SHIFT,
+    TRANSFER_SRGB                      = 2 << TRANSFER_SHIFT,
+    TRANSFER_SMPTE_170M                = 3 << TRANSFER_SHIFT,
+    TRANSFER_GAMMA2_2                  = 4 << TRANSFER_SHIFT,
+    TRANSFER_GAMMA2_8                  = 5 << TRANSFER_SHIFT,
+    TRANSFER_ST2084                    = 6 << TRANSFER_SHIFT,
+    TRANSFER_HLG                       = 7 << TRANSFER_SHIFT,
+
+    RANGE_SHIFT                        = 27,
+    RANGE_MASK                         = 7 << RANGE_SHIFT,
+    RANGE_UNSPECIFIED                  = 0 << RANGE_SHIFT,
+    RANGE_FULL                         = 1 << RANGE_SHIFT,
+    RANGE_LIMITED                      = 2 << RANGE_SHIFT,
+
+    SRGB_LINEAR                        = 0x200,
+    V0_SRGB_LINEAR                     = STANDARD_BT709 |
+                                         TRANSFER_LINEAR |
+                                         RANGE_FULL,
+
+    SRGB                               = 0x201,
+    V0_SRGB                            = STANDARD_BT709 |
+                                         TRANSFER_SRGB |
+                                         RANGE_FULL,
+
+    JFIF                               = 0x101,
+    V0_JFIF                            = STANDARD_BT601_625 |
+                                         TRANSFER_SMPTE_170M |
+                                         RANGE_FULL,
+
+    BT601_625                          = 0x102,
+    V0_BT601_625                       = STANDARD_BT601_625 |
+                                         TRANSFER_SMPTE_170M |
+                                         RANGE_LIMITED,
+
+    BT601_525                          = 0x103,
+    V0_BT601_525                       = STANDARD_BT601_525 |
+                                         TRANSFER_SMPTE_170M |
+                                         RANGE_LIMITED,
+
+    BT709                              = 0x104,
+    V0_BT709                           = STANDARD_BT709 |
+                                         TRANSFER_SMPTE_170M |
+                                         RANGE_LIMITED,
+
+    DEPTH                              = 0x1000,
+};
+
+/*
+ * Copied from android_hdr_t
+ *
+ * TODO(olv) copy comments over and generate android_hdr_t
+ */
+enum Hdr : int32_t {
+    DOLBY_VISION = 1,
+    HDR10        = 2,
+    HLG          = 3,
+};
diff --git a/light/2.0/default/service.cpp b/light/2.0/default/service.cpp
index 582d224..e446878 100644
--- a/light/2.0/default/service.cpp
+++ b/light/2.0/default/service.cpp
@@ -27,11 +27,11 @@
     ALOGI("Retrieving default implementation of instance %s.",
           instance);
 
-    android::sp<ILight> service = ILight::getService(instance, true);
+    android::sp<ILight> service = ILight::getService(instance, true /* getStub */);
 
     if (service.get() == nullptr) {
         ALOGE("ILight::getService returned NULL, exiting");
-        return -1;
+        return EXIT_FAILURE;
     }
 
     LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
diff --git a/nfc/1.0/Android.mk b/nfc/1.0/Android.mk
index b6840bc..07775e9 100644
--- a/nfc/1.0/Android.mk
+++ b/nfc/1.0/Android.mk
@@ -13,9 +13,9 @@
 HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
 
 #
-# Build types.hal (nfc_data_t)
+# Build types.hal (NfcEvent)
 #
-GEN := $(intermediates)/android/hardware/nfc/1.0/nfc_data_t.java
+GEN := $(intermediates)/android/hardware/nfc/1.0/NfcEvent.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -23,16 +23,16 @@
 $(GEN): PRIVATE_CUSTOM_TOOL = \
         $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
         -Ljava -randroid.hardware:hardware/interfaces \
-        android.hardware.nfc@1.0::types.nfc_data_t
+        android.hardware.nfc@1.0::types.NfcEvent
 
 $(GEN): $(LOCAL_PATH)/types.hal
 	$(transform-generated-source)
 LOCAL_GENERATED_SOURCES += $(GEN)
 
 #
-# Build types.hal (nfc_event_t)
+# Build types.hal (NfcStatus)
 #
-GEN := $(intermediates)/android/hardware/nfc/1.0/nfc_event_t.java
+GEN := $(intermediates)/android/hardware/nfc/1.0/NfcStatus.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -40,24 +40,7 @@
 $(GEN): PRIVATE_CUSTOM_TOOL = \
         $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
         -Ljava -randroid.hardware:hardware/interfaces \
-        android.hardware.nfc@1.0::types.nfc_event_t
-
-$(GEN): $(LOCAL_PATH)/types.hal
-	$(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-
-#
-# Build types.hal (nfc_status_t)
-#
-GEN := $(intermediates)/android/hardware/nfc/1.0/nfc_status_t.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.nfc@1.0::types.nfc_status_t
+        android.hardware.nfc@1.0::types.NfcStatus
 
 $(GEN): $(LOCAL_PATH)/types.hal
 	$(transform-generated-source)
@@ -116,9 +99,9 @@
 HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
 
 #
-# Build types.hal (nfc_data_t)
+# Build types.hal (NfcEvent)
 #
-GEN := $(intermediates)/android/hardware/nfc/1.0/nfc_data_t.java
+GEN := $(intermediates)/android/hardware/nfc/1.0/NfcEvent.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -126,16 +109,16 @@
 $(GEN): PRIVATE_CUSTOM_TOOL = \
         $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
         -Ljava -randroid.hardware:hardware/interfaces \
-        android.hardware.nfc@1.0::types.nfc_data_t
+        android.hardware.nfc@1.0::types.NfcEvent
 
 $(GEN): $(LOCAL_PATH)/types.hal
 	$(transform-generated-source)
 LOCAL_GENERATED_SOURCES += $(GEN)
 
 #
-# Build types.hal (nfc_event_t)
+# Build types.hal (NfcStatus)
 #
-GEN := $(intermediates)/android/hardware/nfc/1.0/nfc_event_t.java
+GEN := $(intermediates)/android/hardware/nfc/1.0/NfcStatus.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -143,24 +126,7 @@
 $(GEN): PRIVATE_CUSTOM_TOOL = \
         $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
         -Ljava -randroid.hardware:hardware/interfaces \
-        android.hardware.nfc@1.0::types.nfc_event_t
-
-$(GEN): $(LOCAL_PATH)/types.hal
-	$(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-
-#
-# Build types.hal (nfc_status_t)
-#
-GEN := $(intermediates)/android/hardware/nfc/1.0/nfc_status_t.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.nfc@1.0::types.nfc_status_t
+        android.hardware.nfc@1.0::types.NfcStatus
 
 $(GEN): $(LOCAL_PATH)/types.hal
 	$(transform-generated-source)
diff --git a/nfc/1.0/INfc.hal b/nfc/1.0/INfc.hal
index 88fd39a..f003b2c 100644
--- a/nfc/1.0/INfc.hal
+++ b/nfc/1.0/INfc.hal
@@ -27,7 +27,7 @@
      * NCI initialization - ie accept CORE_RESET and subsequent commands through
      * the write() call.
      *
-     * If open() returns 0, the NCI stack will wait for a HAL_NFC_OPEN_CPLT_EVT
+     * If open() returns 0, the NCI stack will wait for a NfcEvent.OPEN_CPLT
      * before continuing.
      *
      * If open() returns any other value, the NCI stack will stop.
@@ -41,32 +41,32 @@
      * This method may queue writes and return immediately. The only
      * requirement is that the writes are executed in order.
      */
-    write(nfc_data_t data) generates (int32_t retval);
+    write(NfcData data) generates (int32_t retval);
 
     /*
-     * core_initialized() is called after the CORE_INIT_RSP is received from the NFCC.
+     * coreInitialized() is called after the CORE_INIT_RSP is received from the NFCC.
      * At this time, the HAL can do any chip-specific configuration.
      *
-     * If core_initialized() returns 0, the NCI stack will wait for a HAL_NFC_POST_INIT_CPLT_EVT
+     * If coreInitialized() returns 0, the NCI stack will wait for a NfcEvent.POST_INIT_CPLT
      * before continuing.
      *
-     * If core_initialized() returns any other value, the NCI stack will continue
+     * If coreInitialized() returns any other value, the NCI stack will continue
      * immediately.
      */
-    core_initialized(vec<uint8_t> data) generates (int32_t retval);
+    coreInitialized(NfcData data) generates (int32_t retval);
 
     /*
-     * pre_discover is called every time before starting RF discovery.
+     * prediscover is called every time before starting RF discovery.
      * It is a good place to do vendor-specific configuration that must be
      * performed every time RF discovery is about to be started.
      *
-     * If pre_discover() returns 0, the NCI stack will wait for a HAL_NFC_PRE_DISCOVER_CPLT_EVT
+     * If prediscover() returns 0, the NCI stack will wait for a NfcEvent.PREDISCOVER_CPLT
      * before continuing.
      *
-     * If pre_discover() returns any other value, the NCI stack will start
+     * If prediscover() returns any other value, the NCI stack will start
      * RF discovery immediately.
      */
-    pre_discover() generates (int32_t retval);
+    prediscover() generates (int32_t retval);
 
     /*
      * Close the NFC controller. Should free all resources.
@@ -75,15 +75,15 @@
 
     /*
      * Grant HAL the exclusive control to send NCI commands.
-     * Called in response to HAL_REQUEST_CONTROL_EVT.
+     * Called in response to NfcEvent.REQUEST_CONTROL.
      * Must only be called when there are no NCI commands pending.
-     * HAL_RELEASE_CONTROL_EVT will notify when HAL no longer needs exclusive control.
+     * NfcEvent.RELEASE_CONTROL will notify when HAL no longer needs exclusive control.
      */
-    control_granted() generates (int32_t retval);
+    controlGranted() generates (int32_t retval);
 
      /*
      * Restart controller by power cyle;
-     * HAL_OPEN_CPLT_EVT will notify when operation is complete.
+     * NfcEvent.OPEN_CPLT will notify when operation is complete.
      */
-    power_cycle() generates (int32_t retval);
+    powerCycle() generates (int32_t retval);
 };
diff --git a/nfc/1.0/INfcClientCallback.hal b/nfc/1.0/INfcClientCallback.hal
index f10062e..a56cc09 100644
--- a/nfc/1.0/INfcClientCallback.hal
+++ b/nfc/1.0/INfcClientCallback.hal
@@ -21,11 +21,11 @@
      * The callback passed in from the NFC stack that the HAL
      * can use to pass events back to the stack.
      */
-    sendEvent(nfc_event_t event, nfc_status_t event_status);
+    sendEvent(NfcEvent event, NfcStatus status);
 
     /*
      * The callback passed in from the NFC stack that the HAL
      * can use to pass incomming data to the stack.
      */
-    sendData(nfc_data_t data);
+    sendData(NfcData data);
 };
diff --git a/nfc/1.0/default/Nfc.cpp b/nfc/1.0/default/Nfc.cpp
index b836ada..d3868c1 100644
--- a/nfc/1.0/default/Nfc.cpp
+++ b/nfc/1.0/default/Nfc.cpp
@@ -19,19 +19,19 @@
 // Methods from ::android::hardware::nfc::V1_0::INfc follow.
 ::android::hardware::Return<int32_t> Nfc::open(const sp<INfcClientCallback>& clientCallback)  {
     mCallback = clientCallback;
-    return mDevice->open(mDevice, event_callback, data_callback);
+    return mDevice->open(mDevice, eventCallback, dataCallback);
 }
 
-::android::hardware::Return<int32_t> Nfc::write(const nfc_data_t& data)  {
-    return mDevice->write(mDevice, data.data.size(), &data.data[0]);
+::android::hardware::Return<int32_t> Nfc::write(const hidl_vec<uint8_t>& data)  {
+    return mDevice->write(mDevice, data.size(), &data[0]);
 }
 
-::android::hardware::Return<int32_t> Nfc::core_initialized(const hidl_vec<uint8_t>& data)  {
+::android::hardware::Return<int32_t> Nfc::coreInitialized(const hidl_vec<uint8_t>& data)  {
     hidl_vec<uint8_t> copy = data;
     return mDevice->core_initialized(mDevice, &copy[0]);
 }
 
-::android::hardware::Return<int32_t> Nfc::pre_discover()  {
+::android::hardware::Return<int32_t> Nfc::prediscover()  {
     return mDevice->pre_discover(mDevice);
 }
 
@@ -39,11 +39,11 @@
     return mDevice->close(mDevice);
 }
 
-::android::hardware::Return<int32_t> Nfc::control_granted()  {
+::android::hardware::Return<int32_t> Nfc::controlGranted()  {
     return mDevice->control_granted(mDevice);
 }
 
-::android::hardware::Return<int32_t> Nfc::power_cycle()  {
+::android::hardware::Return<int32_t> Nfc::powerCycle()  {
     return mDevice->power_cycle(mDevice);
 }
 
diff --git a/nfc/1.0/default/Nfc.h b/nfc/1.0/default/Nfc.h
index 98cd57e..e596495 100644
--- a/nfc/1.0/default/Nfc.h
+++ b/nfc/1.0/default/Nfc.h
@@ -13,7 +13,6 @@
 
 using ::android::hardware::nfc::V1_0::INfc;
 using ::android::hardware::nfc::V1_0::INfcClientCallback;
-using ::android::hardware::nfc::V1_0::nfc_data_t;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
 using ::android::hardware::hidl_vec;
@@ -23,23 +22,23 @@
 struct Nfc : public INfc {
   Nfc(nfc_nci_device_t* device);
   ::android::hardware::Return<int32_t> open(const sp<INfcClientCallback>& clientCallback)  override;
-  ::android::hardware::Return<int32_t> write(const nfc_data_t& data)  override;
-  ::android::hardware::Return<int32_t> core_initialized(const hidl_vec<uint8_t>& data)  override;
-  ::android::hardware::Return<int32_t> pre_discover()  override;
+  ::android::hardware::Return<int32_t> write(const hidl_vec<uint8_t>& data)  override;
+  ::android::hardware::Return<int32_t> coreInitialized(const hidl_vec<uint8_t>& data)  override;
+  ::android::hardware::Return<int32_t> prediscover()  override;
   ::android::hardware::Return<int32_t> close()  override;
-  ::android::hardware::Return<int32_t> control_granted()  override;
-  ::android::hardware::Return<int32_t> power_cycle()  override;
+  ::android::hardware::Return<int32_t> controlGranted()  override;
+  ::android::hardware::Return<int32_t> powerCycle()  override;
 
-  static void event_callback(uint8_t event, uint8_t status) {
+  static void eventCallback(uint8_t event, uint8_t status) {
       if (mCallback != nullptr) {
           mCallback->sendEvent(
-                  (::android::hardware::nfc::V1_0::nfc_event_t) event,
-                  (::android::hardware::nfc::V1_0::nfc_status_t) status);
+                  (::android::hardware::nfc::V1_0::NfcEvent) event,
+                  (::android::hardware::nfc::V1_0::NfcStatus) status);
       }
   }
-  static void data_callback(uint16_t data_len, uint8_t* p_data) {
-      nfc_data_t data;
-      data.data.setToExternal(p_data, data_len);
+  static void dataCallback(uint16_t data_len, uint8_t* p_data) {
+      hidl_vec<uint8_t> data;
+      data.setToExternal(p_data, data_len);
       if (mCallback != nullptr) {
           mCallback->sendData(data);
       }
diff --git a/nfc/1.0/default/service.cpp b/nfc/1.0/default/service.cpp
index 8952052..e70388d 100644
--- a/nfc/1.0/default/service.cpp
+++ b/nfc/1.0/default/service.cpp
@@ -26,7 +26,7 @@
     const char instance[] = "nfc_nci";
     ALOGI("Retrieving default implementation of instance %s.",
           instance);
-    android::sp<INfc> service = INfc::getService(instance, true);
+    android::sp<INfc> service = INfc::getService(instance, true /* getStub */);
     if (service.get() == nullptr) {
         ALOGE("INfc::getService returned NULL, exiting");
         return -1;
@@ -35,7 +35,7 @@
           instance, (service->isRemote() ? "REMOTE" : "LOCAL"));
     LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
     ALOGI("Registering instance %s.", instance);
-    service->registerAsService("nfc_nci");
+    service->registerAsService(instance);
     ALOGI("Ready.");
 
     ProcessState::self()->setThreadPoolMaxThreadCount(0);
diff --git a/nfc/1.0/types.hal b/nfc/1.0/types.hal
index 738dfd9..a266178 100644
--- a/nfc/1.0/types.hal
+++ b/nfc/1.0/types.hal
@@ -16,24 +16,22 @@
 
 package android.hardware.nfc@1.0;
 
-enum nfc_event_t : uint32_t {
-    HAL_NFC_OPEN_CPLT_EVT           = 0,
-    HAL_NFC_CLOSE_CPLT_EVT          = 1,
-    HAL_NFC_POST_INIT_CPLT_EVT      = 2,
-    HAL_NFC_PRE_DISCOVER_CPLT_EVT   = 3,
-    HAL_NFC_REQUEST_CONTROL_EVT     = 4,
-    HAL_NFC_RELEASE_CONTROL_EVT     = 5,
-    HAL_NFC_ERROR_EVT               = 6
+enum NfcEvent : uint32_t {
+    OPEN_CPLT           = 0,
+    CLOSE_CPLT          = 1,
+    POST_INIT_CPLT      = 2,
+    PRE_DISCOVER_CPLT   = 3,
+    REQUEST_CONTROL     = 4,
+    RELEASE_CONTROL     = 5,
+    ERROR               = 6
 };
 
-enum nfc_status_t : uint32_t {
-    HAL_NFC_STATUS_OK               = 0,
-    HAL_NFC_STATUS_FAILED           = 1,
-    HAL_NFC_STATUS_ERR_TRANSPORT    = 2,
-    HAL_NFC_STATUS_ERR_CMD_TIMEOUT  = 3,
-    HAL_NFC_STATUS_REFUSED          = 4
+enum NfcStatus : uint32_t {
+    OK               = 0,
+    FAILED           = 1,
+    ERR_TRANSPORT    = 2,
+    ERR_CMD_TIMEOUT  = 3,
+    REFUSED          = 4
 };
 
-struct nfc_data_t {
-    vec<uint8_t> data;
-};
+typedef vec<uint8_t> NfcData;
diff --git a/nfc/1.0/vts/Nfc.vts b/nfc/1.0/vts/Nfc.vts
index 8b3330f..8c18653 100644
--- a/nfc/1.0/vts/Nfc.vts
+++ b/nfc/1.0/vts/Nfc.vts
@@ -1,7 +1,7 @@
 component_class: HAL_HIDL
-component_type: NFC
 component_type_version: 1.0
 component_name: "INfc"
+component_type: NFC
 
 package: "android.hardware.nfc"
 
@@ -9,75 +9,79 @@
 import: "android.hardware.nfc@1.0::types"
 
 interface: {
-  api: {
-    name: "open"
-    return_type_hidl: {
-      type: TYPE_SCALAR
-      scalar_type: "int32_t"
+    api: {
+        name: "open"
+        return_type_hidl: {
+            type: TYPE_SCALAR
+            scalar_type: "int32_t"
+        }
+        arg: {
+            type: TYPE_HIDL_CALLBACK
+            predefined_type: "INfcClientCallback"
+            is_callback: true
+        }
     }
-    arg: {
-      type: TYPE_HIDL_CALLBACK
-      predefined_type: "INfcClientCallback"
-      is_callback: true
-    }
-  }
 
-  api: {
-    name: "write"
-    return_type_hidl: {
-      type: TYPE_SCALAR
-      scalar_type: "int32_t"
+    api: {
+        name: "write"
+        return_type_hidl: {
+            type: TYPE_SCALAR
+            scalar_type: "int32_t"
+        }
+        arg: {
+            type: TYPE_VECTOR
+            vector_value: {
+                type: TYPE_SCALAR
+                scalar_type: "uint8_t"
+            }
+        }
     }
-    arg: {
-      type: TYPE_STRUCT
-      predefined_type: "nfc_data_t"
-    }
-  }
 
-  api: {
-    name: "core_initialized"
-    return_type_hidl: {
-      type: TYPE_SCALAR
-      scalar_type: "int32_t"
+    api: {
+        name: "coreInitialized"
+        return_type_hidl: {
+            type: TYPE_SCALAR
+            scalar_type: "int32_t"
+        }
+        arg: {
+            type: TYPE_VECTOR
+            vector_value: {
+                type: TYPE_SCALAR
+                scalar_type: "uint8_t"
+            }
+        }
     }
-    arg: {
-      type: TYPE_VECTOR
-      vector_value: {
-        type: TYPE_SCALAR
-        scalar_type: "uint8_t"
-      }
-    }
-  }
 
-  api: {
-    name: "pre_discover"
-    return_type_hidl: {
-      type: TYPE_SCALAR
-      scalar_type: "int32_t"
+    api: {
+        name: "prediscover"
+        return_type_hidl: {
+            type: TYPE_SCALAR
+            scalar_type: "int32_t"
+        }
     }
-  }
 
-  api: {
-    name: "close"
-    return_type_hidl: {
-      type: TYPE_SCALAR
-      scalar_type: "int32_t"
+    api: {
+        name: "close"
+        return_type_hidl: {
+            type: TYPE_SCALAR
+            scalar_type: "int32_t"
+        }
     }
-  }
 
-  api: {
-    name: "control_granted"
-    return_type_hidl: {
-      type: TYPE_SCALAR
-      scalar_type: "int32_t"
+    api: {
+        name: "controlGranted"
+        return_type_hidl: {
+            type: TYPE_SCALAR
+            scalar_type: "int32_t"
+        }
     }
-  }
 
-  api: {
-    name: "power_cycle"
-    return_type_hidl: {
-      type: TYPE_SCALAR
-      scalar_type: "int32_t"
+    api: {
+        name: "powerCycle"
+        return_type_hidl: {
+            type: TYPE_SCALAR
+            scalar_type: "int32_t"
+        }
     }
-  }
+
 }
diff --git a/nfc/1.0/vts/NfcClientCallback.vts b/nfc/1.0/vts/NfcClientCallback.vts
index aab8c27..e468935 100644
--- a/nfc/1.0/vts/NfcClientCallback.vts
+++ b/nfc/1.0/vts/NfcClientCallback.vts
@@ -1,31 +1,34 @@
 component_class: HAL_HIDL
-component_type: NFC
 component_type_version: 1.0
 component_name: "INfcClientCallback"
+component_type: NFC
 
 package: "android.hardware.nfc"
 
 import: "android.hardware.nfc@1.0::types"
 
 interface: {
-  api: {
-    name: "sendEvent"
-    arg: {
-      type: TYPE_ENUM
-      predefined_type: "nfc_event_t"
+    api: {
+        name: "sendEvent"
+        arg: {
+            type: TYPE_ENUM
+            predefined_type: "NfcEvent"
+        }
+        arg: {
+            type: TYPE_ENUM
+            predefined_type: "NfcStatus"
+        }
     }
-    arg: {
-      type: TYPE_ENUM
-      predefined_type: "nfc_status_t"
-    }
-  }
 
-  api: {
-    name: "sendData"
-    arg: {
-      type: TYPE_STRUCT
-      predefined_type: "nfc_data_t"
-      is_const: true
+    api: {
+        name: "sendData"
+        arg: {
+            type: TYPE_VECTOR
+            vector_value: {
+                type: TYPE_SCALAR
+                scalar_type: "uint8_t"
+            }
+        }
     }
-  }
+
 }
diff --git a/nfc/1.0/vts/types.vts b/nfc/1.0/vts/types.vts
index bd5d1f4..f56ddf1 100644
--- a/nfc/1.0/vts/types.vts
+++ b/nfc/1.0/vts/types.vts
@@ -1,86 +1,73 @@
 component_class: HAL_HIDL
-component_type: NFC
 component_type_version: 1.0
 component_name: "types"
+component_type: NFC
 
 package: "android.hardware.nfc"
 
 attribute: {
-  name: "nfc_event_t"
-  type: TYPE_ENUM
-  enum_value: {
-    scalar_type: "uint32_t"
+    name: "NfcEvent"
+    type: TYPE_ENUM
+    enum_value: {
+        scalar_type: "uint32_t"
 
-    enumerator: "HAL_NFC_OPEN_CPLT_EVT"
-    scalar_value: {
-      uint32_t: 0
+        enumerator: "OPEN_CPLT"
+        scalar_value: {
+            uint32_t: 0
+        }
+        enumerator: "CLOSE_CPLT"
+        scalar_value: {
+            uint32_t: 1
+        }
+        enumerator: "POST_INIT_CPLT"
+        scalar_value: {
+            uint32_t: 2
+        }
+        enumerator: "PRE_DISCOVER_CPLT"
+        scalar_value: {
+            uint32_t: 3
+        }
+        enumerator: "REQUEST_CONTROL"
+        scalar_value: {
+            uint32_t: 4
+        }
+        enumerator: "RELEASE_CONTROL"
+        scalar_value: {
+            uint32_t: 5
+        }
+        enumerator: "ERROR"
+        scalar_value: {
+            uint32_t: 6
+        }
     }
-    enumerator: "HAL_NFC_CLOSE_CPLT_EVT"
-    scalar_value: {
-      uint32_t: 1
-    }
-    enumerator: "HAL_NFC_POST_INIT_CPLT_EVT"
-    scalar_value: {
-      uint32_t: 2
-    }
-    enumerator: "HAL_NFC_PRE_DISCOVER_CPLT_EVT"
-    scalar_value: {
-      uint32_t: 3
-    }
-    enumerator: "HAL_NFC_REQUEST_CONTROL_EVT"
-    scalar_value: {
-      uint32_t: 4
-    }
-    enumerator: "HAL_NFC_RELEASE_CONTROL_EVT"
-    scalar_value: {
-      uint32_t: 5
-    }
-    enumerator: "HAL_NFC_ERROR_EVT"
-    scalar_value: {
-      uint32_t: 6
-    }
-  }
 }
 
 attribute: {
-  name: "nfc_status_t"
-  type: TYPE_ENUM
-  enum_value: {
-    scalar_type: "uint32_t"
+    name: "NfcStatus"
+    type: TYPE_ENUM
+    enum_value: {
+        scalar_type: "uint32_t"
 
-    enumerator: "HAL_NFC_STATUS_OK"
-    scalar_value: {
-      uint32_t: 0
+        enumerator: "OK"
+        scalar_value: {
+            uint32_t: 0
+        }
+        enumerator: "FAILED"
+        scalar_value: {
+            uint32_t: 1
+        }
+        enumerator: "ERR_TRANSPORT"
+        scalar_value: {
+            uint32_t: 2
+        }
+        enumerator: "ERR_CMD_TIMEOUT"
+        scalar_value: {
+            uint32_t: 3
+        }
+        enumerator: "REFUSED"
+        scalar_value: {
+            uint32_t: 4
+        }
     }
-    enumerator: "HAL_NFC_STATUS_FAILED"
-    scalar_value: {
-      uint32_t: 1
-    }
-    enumerator: "HAL_NFC_STATUS_ERR_TRANSPORT"
-    scalar_value: {
-      uint32_t: 2
-    }
-    enumerator: "HAL_NFC_STATUS_ERR_CMD_TIMEOUT"
-    scalar_value: {
-      uint32_t: 3
-    }
-    enumerator: "HAL_NFC_STATUS_REFUSED"
-    scalar_value: {
-      uint32_t: 4
-    }
-  }
-}
-
-attribute: {
-  name: "nfc_data_t"
-  type: TYPE_STRUCT
-  struct_value: {
-    name: "data"
-    type: TYPE_VECTOR
-    vector_value: {
-      type: TYPE_SCALAR
-      scalar_type: "uint8_t"
-    }
-  }
 }
 
diff --git a/sensors/1.0/Android.bp b/sensors/1.0/Android.bp
new file mode 100644
index 0000000..32ee049
--- /dev/null
+++ b/sensors/1.0/Android.bp
@@ -0,0 +1,46 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+    name: "android.hardware.sensors@1.0_genc++",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.sensors@1.0",
+    srcs: [
+        "types.hal",
+        "ISensors.hal",
+    ],
+    out: [
+        "android/hardware/sensors/1.0/types.cpp",
+        "android/hardware/sensors/1.0/SensorsAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.sensors@1.0_genc++_headers",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.sensors@1.0",
+    srcs: [
+        "types.hal",
+        "ISensors.hal",
+    ],
+    out: [
+        "android/hardware/sensors/1.0/types.h",
+        "android/hardware/sensors/1.0/ISensors.h",
+        "android/hardware/sensors/1.0/IHwSensors.h",
+        "android/hardware/sensors/1.0/BnSensors.h",
+        "android/hardware/sensors/1.0/BpSensors.h",
+        "android/hardware/sensors/1.0/BsSensors.h",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.sensors@1.0",
+    generated_sources: ["android.hardware.sensors@1.0_genc++"],
+    generated_headers: ["android.hardware.sensors@1.0_genc++_headers"],
+    export_generated_headers: ["android.hardware.sensors@1.0_genc++_headers"],
+    shared_libs: [
+        "libhidl",
+        "libhwbinder",
+        "libutils",
+        "libcutils",
+    ],
+}
diff --git a/sensors/1.0/ISensors.hal b/sensors/1.0/ISensors.hal
new file mode 100644
index 0000000..adacfe0
--- /dev/null
+++ b/sensors/1.0/ISensors.hal
@@ -0,0 +1,124 @@
+/*
+ * 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.sensors@1.0;
+
+interface ISensors {
+    /**
+     * Enumerate all available (static) sensors.
+     */
+    getSensorsList() generates (vec<SensorInfo> list);
+
+    /**
+     *  Place the module in a specific mode. The following modes are defined
+     *
+     *  SENSOR_HAL_NORMAL_MODE - Normal operation. Default state of the module.
+     *
+     *  SENSOR_HAL_DATA_INJECTION_MODE - Loopback mode.
+     *    Data is injected for the supported sensors by the sensor service in
+     *    this mode.
+     *
+     * @return OK on success
+     *         BAD_VALUE if requested mode is not supported
+     *         PERMISSION_DENIED if operation is not allowed
+     */
+    setOperationMode(OperationMode mode) generates (Result result);
+
+    /* Activate/de-activate one sensor.
+     *
+     * sensorHandle is the handle of the sensor to change.
+     * enabled set to true to enable, or false to disable the sensor.
+     *
+     * After sensor de-activation, existing sensor events that have not
+     * been picked up by poll() should be abandoned immediately so that
+     * subsequent activation will not get stale sensor events (events
+     * that are generated prior to the latter activation).
+     *
+     * Returns OK on success, BAD_VALUE if sensorHandle is invalid.
+     */
+    activate(int32_t sensorHandle, bool enabled) generates (Result result);
+
+    /**
+     * Set the sampling period in nanoseconds for a given sensor.
+     * If samplingPeriodNs > maxDelay it will be truncated to
+     * maxDelay and if samplingPeriodNs < minDelay it will be
+     * replaced by minDelay.
+     *
+     * Returns OK on success, BAD_VALUE if sensorHandle is invalid.
+     */
+    setDelay(int32_t sensorHandle, int64_t samplingPeriodNs)
+        generates (Result result);
+
+    /**
+     * Generate a vector of sensor events containing at most "maxCount"
+     * entries.
+     *
+     * Additionally a vector of SensorInfos is returned for any dynamic sensors
+     * connected as notified by returned events of type DYNAMIC_SENSOR_META.
+     *
+     * This function should block if there is no sensor event
+     * available when being called.
+     *
+     * Returns OK on success or BAD_VALUE if maxCount <= 0.
+     */
+    poll(int32_t maxCount)
+        generates (
+                Result result,
+                vec<Event> data,
+                vec<SensorInfo> dynamicSensorsAdded);
+
+    /*
+     * Sets a sensor’s parameters, including sampling frequency and maximum
+     * report latency. This function can be called while the sensor is
+     * activated, in which case it must not cause any sensor measurements to
+     * be lost: transitioning from one sampling rate to the other cannot cause
+     * lost events, nor can transitioning from a high maximum report latency to
+     * a low maximum report latency.
+     * See the Batching sensor results page for details:
+     * http://source.android.com/devices/sensors/batching.html
+     *
+     * Returns OK on success, BAD_VALUE if any parameters are invalid.
+     */
+    batch(int32_t sensorHandle,
+          int32_t flags,
+          int64_t samplingPeriodNs,
+          int64_t maxReportLatencyNs) generates (Result result);
+
+    /*
+     * Flush adds a FLUSH_COMPLETE metadata event to the end of the "batch mode"
+     * FIFO for the specified sensor and flushes the FIFO.
+     * If the FIFO is empty or if the sensor doesn't support batching
+     * (FIFO size zero), it should return SUCCESS along with a trivial
+     * FLUSH_COMPLETE event added to the event stream.
+     * This applies to all sensors other than one-shot sensors.
+     * If the sensor is a one-shot sensor, flush must return BAD_VALUE and not
+     * generate any flush complete metadata.
+     * If the sensor is not active at the time flush() is called, flush() should
+     * return BAD_VALUE.
+     * Returns OK on success and BAD_VALUE if sensorHandle is invalid.
+     */
+    flush(int32_t sensorHandle) generates (Result result);
+
+    /*
+     * Inject a single sensor sample to this device.
+     * data points to the sensor event to be injected
+     * Returns OK on success
+     *         PERMISSION_DENIED if operation is not allowed
+     *         INVALID_OPERATION, if this functionality is unsupported
+     *         BAD_VALUE if sensor event cannot be injected
+     */
+    injectSensorData(Event event) generates (Result result);
+};
diff --git a/sensors/1.0/default/Android.bp b/sensors/1.0/default/Android.bp
new file mode 100644
index 0000000..d454cdb
--- /dev/null
+++ b/sensors/1.0/default/Android.bp
@@ -0,0 +1,38 @@
+cc_library_shared {
+    name: "android.hardware.sensors@1.0-impl",
+    relative_install_path: "hw",
+    srcs: ["Sensors.cpp"],
+    shared_libs: [
+        "liblog",
+        "libcutils",
+        "libhardware",
+        "libhwbinder",
+        "libbase",
+        "libcutils",
+        "libutils",
+        "libhidl",
+        "android.hardware.sensors@1.0",
+    ],
+    static_libs: [
+        "android.hardware.sensors@1.0-convert",
+    ],
+}
+
+cc_library_static {
+    name: "android.hardware.sensors@1.0-convert",
+    srcs: ["convert.cpp"],
+    export_include_dirs: ["include"],
+    shared_libs: [
+        "liblog",
+        "libcutils",
+        "libhardware",
+        "libhwbinder",
+        "libbase",
+        "libcutils",
+        "libutils",
+        "libhidl",
+        "android.hardware.sensors@1.0",
+    ],
+}
+
+
diff --git a/sensors/1.0/default/Android.mk b/sensors/1.0/default/Android.mk
new file mode 100644
index 0000000..4f418cb
--- /dev/null
+++ b/sensors/1.0/default/Android.mk
@@ -0,0 +1,24 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_MODULE := android.hardware.sensors@1.0-service
+LOCAL_INIT_RC := android.hardware.sensors@1.0-service.rc
+LOCAL_SRC_FILES := \
+	service.cpp \
+
+LOCAL_SHARED_LIBRARIES := \
+	liblog \
+	libcutils \
+	libdl \
+	libbase \
+	libutils \
+	libhardware_legacy \
+	libhardware \
+
+LOCAL_SHARED_LIBRARIES += \
+	libhwbinder \
+	libhidl \
+	android.hardware.sensors@1.0 \
+
+include $(BUILD_EXECUTABLE)
diff --git a/sensors/1.0/default/Sensors.cpp b/sensors/1.0/default/Sensors.cpp
new file mode 100644
index 0000000..ef052c3
--- /dev/null
+++ b/sensors/1.0/default/Sensors.cpp
@@ -0,0 +1,250 @@
+/*
+ * 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.
+ */
+
+#include "Sensors.h"
+
+#include "convert.h"
+
+#include <android-base/logging.h>
+
+namespace android {
+namespace hardware {
+namespace sensors {
+namespace V1_0 {
+namespace implementation {
+
+static Result ResultFromStatus(status_t err) {
+    switch (err) {
+        case OK:
+            return Result::OK;
+        case BAD_VALUE:
+            return Result::BAD_VALUE;
+        case PERMISSION_DENIED:
+            return Result::PERMISSION_DENIED;
+        default:
+            return Result::INVALID_OPERATION;
+    }
+}
+
+Sensors::Sensors()
+    : mInitCheck(NO_INIT),
+      mSensorModule(nullptr),
+      mSensorDevice(nullptr) {
+    status_t err = hw_get_module(
+            SENSORS_HARDWARE_MODULE_ID,
+            (hw_module_t const **)&mSensorModule);
+
+    if (mSensorModule == NULL) {
+        err = UNKNOWN_ERROR;
+    }
+
+    if (err != OK) {
+        LOG(ERROR) << "Couldn't load "
+                   << SENSORS_HARDWARE_MODULE_ID
+                   << " module ("
+                   << strerror(-err)
+                   << ")";
+
+        mInitCheck = err;
+        return;
+    }
+
+    err = sensors_open_1(&mSensorModule->common, &mSensorDevice);
+
+    if (err != OK) {
+        LOG(ERROR) << "Couldn't open device for module "
+                   << SENSORS_HARDWARE_MODULE_ID
+                   << " ("
+                   << strerror(-err)
+                   << ")";
+
+        mInitCheck = err;
+        return;
+    }
+
+    // Require all the old HAL APIs to be present except for injection, which
+    // is considered optional.
+    CHECK_GE(getHalDeviceVersion(), SENSORS_DEVICE_API_VERSION_1_3);
+
+    mInitCheck = OK;
+}
+
+status_t Sensors::initCheck() const {
+    return mInitCheck;
+}
+
+Return<void> Sensors::getSensorsList(getSensorsList_cb _aidl_cb) {
+    sensor_t const *list;
+    size_t count = mSensorModule->get_sensors_list(mSensorModule, &list);
+
+    hidl_vec<SensorInfo> out;
+    out.resize(count);
+
+    for (size_t i = 0; i < count; ++i) {
+        const sensor_t *src = &list[i];
+        SensorInfo *dst = &out[i];
+
+        convertFromSensor(*src, dst);
+    }
+
+    _aidl_cb(out);
+
+    return Void();
+}
+
+int Sensors::getHalDeviceVersion() const {
+    if (!mSensorDevice) {
+        return -1;
+    }
+
+    return mSensorDevice->common.version;
+}
+
+Return<Result> Sensors::setOperationMode(OperationMode mode) {
+    return ResultFromStatus(mSensorModule->set_operation_mode((uint32_t)mode));
+}
+
+Return<Result> Sensors::activate(
+        int32_t sensor_handle, bool enabled) {
+    return ResultFromStatus(
+            mSensorDevice->activate(
+                reinterpret_cast<sensors_poll_device_t *>(mSensorDevice),
+                sensor_handle,
+                enabled));
+}
+
+Return<Result> Sensors::setDelay(
+        int32_t sensor_handle, int64_t sampling_period_ns) {
+    return ResultFromStatus(
+            mSensorDevice->setDelay(
+                reinterpret_cast<sensors_poll_device_t *>(mSensorDevice),
+                sensor_handle,
+                sampling_period_ns));
+}
+
+Return<void> Sensors::poll(int32_t maxCount, poll_cb _aidl_cb) {
+    hidl_vec<Event> out;
+    hidl_vec<SensorInfo> dynamicSensorsAdded;
+
+    if (maxCount <= 0) {
+        _aidl_cb(Result::BAD_VALUE, out, dynamicSensorsAdded);
+        return Void();
+    }
+
+    std::unique_ptr<sensors_event_t[]> data(new sensors_event_t[maxCount]);
+
+    int err = mSensorDevice->poll(
+            reinterpret_cast<sensors_poll_device_t *>(mSensorDevice),
+            data.get(),
+            maxCount);
+
+    if (err < 0) {
+        _aidl_cb(ResultFromStatus(err), out, dynamicSensorsAdded);
+        return Void();
+    }
+
+    const size_t count = (size_t)err;
+
+    for (size_t i = 0; i < count; ++i) {
+        if (data[i].type != SENSOR_TYPE_DYNAMIC_SENSOR_META) {
+            continue;
+        }
+
+        const dynamic_sensor_meta_event_t *dyn = &data[i].dynamic_sensor_meta;
+
+        if (!dyn->connected) {
+            continue;
+        }
+
+        CHECK(dyn->sensor != nullptr);
+        CHECK_EQ(dyn->sensor->handle, dyn->handle);
+
+        SensorInfo info;
+        convertFromSensor(*dyn->sensor, &info);
+
+        size_t numDynamicSensors = dynamicSensorsAdded.size();
+        dynamicSensorsAdded.resize(numDynamicSensors + 1);
+        dynamicSensorsAdded[numDynamicSensors] = info;
+    }
+
+    out.resize(count);
+    convertFromSensorEvents(err, data.get(), &out);
+
+    _aidl_cb(Result::OK, out, dynamicSensorsAdded);
+
+    return Void();
+}
+
+Return<Result> Sensors::batch(
+        int32_t sensor_handle,
+        int32_t flags,
+        int64_t sampling_period_ns,
+        int64_t max_report_latency_ns) {
+    return ResultFromStatus(
+            mSensorDevice->batch(
+                mSensorDevice,
+                sensor_handle,
+                flags,
+                sampling_period_ns,
+                max_report_latency_ns));
+}
+
+Return<Result> Sensors::flush(int32_t sensor_handle) {
+    return ResultFromStatus(mSensorDevice->flush(mSensorDevice, sensor_handle));
+}
+
+Return<Result> Sensors::injectSensorData(const Event& event) {
+    if (getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_4) {
+        return Result::INVALID_OPERATION;
+    }
+
+    sensors_event_t out;
+    convertToSensorEvent(event, &out);
+
+    return ResultFromStatus(
+            mSensorDevice->inject_sensor_data(mSensorDevice, &out));
+}
+
+// static
+void Sensors::convertFromSensorEvents(
+        size_t count,
+        const sensors_event_t *srcArray,
+        hidl_vec<Event> *dstVec) {
+    for (size_t i = 0; i < count; ++i) {
+        const sensors_event_t &src = srcArray[i];
+        Event *dst = &(*dstVec)[i];
+
+        convertFromSensorEvent(src, dst);
+    }
+}
+
+ISensors *HIDL_FETCH_ISensors(const char * /* hal */) {
+    Sensors *sensors = new Sensors;
+    if (sensors->initCheck() != OK) {
+        delete sensors;
+        sensors = nullptr;
+
+        return nullptr;
+    }
+
+    return sensors;
+}
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace sensors
+}  // namespace hardware
+}  // namespace android
diff --git a/sensors/1.0/default/Sensors.h b/sensors/1.0/default/Sensors.h
new file mode 100644
index 0000000..f9b837d
--- /dev/null
+++ b/sensors/1.0/default/Sensors.h
@@ -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.
+ */
+
+#ifndef HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_SENSORS_H_
+
+#define HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_SENSORS_H_
+
+#include <android/hardware/sensors/1.0/ISensors.h>
+#include <hardware/sensors.h>
+
+namespace android {
+namespace hardware {
+namespace sensors {
+namespace V1_0 {
+namespace implementation {
+
+struct Sensors : public ::android::hardware::sensors::V1_0::ISensors {
+    Sensors();
+
+    status_t initCheck() const;
+
+    Return<void> getSensorsList(getSensorsList_cb _aidl_cb) override;
+
+    Return<Result> setOperationMode(OperationMode mode) override;
+
+    Return<Result> activate(
+            int32_t sensor_handle, bool enabled) override;
+
+    Return<Result> setDelay(
+            int32_t sensor_handle, int64_t sampling_period_ns) override;
+
+    Return<void> poll(int32_t maxCount, poll_cb _hidl_cb) override;
+
+    Return<Result> batch(
+            int32_t sensor_handle,
+            int32_t flags,
+            int64_t sampling_period_ns,
+            int64_t max_report_latency_ns) override;
+
+    Return<Result> flush(int32_t sensor_handle) override;
+
+    Return<Result> injectSensorData(const Event& event) override;
+
+private:
+    status_t mInitCheck;
+    sensors_module_t *mSensorModule;
+    sensors_poll_device_1_t *mSensorDevice;
+
+    int getHalDeviceVersion() const;
+
+    static void convertFromSensorEvents(
+            size_t count, const sensors_event_t *src, hidl_vec<Event> *dst);
+
+    DISALLOW_COPY_AND_ASSIGN(Sensors);
+};
+
+extern "C" ISensors *HIDL_FETCH_ISensors(const char *name);
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace sensors
+}  // namespace hardware
+}  // namespace android
+
+#endif  // HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_SENSORS_H_
diff --git a/sensors/1.0/default/android.hardware.sensors@1.0-service.rc b/sensors/1.0/default/android.hardware.sensors@1.0-service.rc
new file mode 100644
index 0000000..2cba0fc
--- /dev/null
+++ b/sensors/1.0/default/android.hardware.sensors@1.0-service.rc
@@ -0,0 +1,4 @@
+service sensors-hal-1-0 /system/bin/hw/android.hardware.sensors@1.0-service
+    class main
+    user system
+    group system readproc
diff --git a/sensors/1.0/default/convert.cpp b/sensors/1.0/default/convert.cpp
new file mode 100644
index 0000000..f4e1841
--- /dev/null
+++ b/sensors/1.0/default/convert.cpp
@@ -0,0 +1,346 @@
+/*
+ * 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.
+ */
+
+#include "include/convert.h"
+
+#include <android-base/logging.h>
+
+namespace android {
+namespace hardware {
+namespace sensors {
+namespace V1_0 {
+namespace implementation {
+
+void convertFromSensor(const sensor_t &src, SensorInfo *dst) {
+    dst->name = src.name;
+    dst->vendor = src.vendor;
+    dst->version = src.version;
+    dst->sensorHandle = src.handle;
+    dst->type = (SensorType)src.type;
+    dst->maxRange = src.maxRange;
+    dst->resolution = src.resolution;
+    dst->power = src.power;
+    dst->minDelay = src.minDelay;
+    dst->fifoReservedEventCount = src.fifoReservedEventCount;
+    dst->fifoMaxEventCount = src.fifoMaxEventCount;
+    dst->typeAsString = src.stringType;
+    dst->requiredPermission = src.requiredPermission;
+    dst->maxDelay = src.maxDelay;
+    dst->flags = src.flags;
+}
+
+void convertToSensor(
+        const ::android::hardware::sensors::V1_0::SensorInfo &src,
+        sensor_t *dst) {
+    dst->name = strdup(src.name.c_str());
+    dst->vendor = strdup(src.vendor.c_str());
+    dst->version = src.version;
+    dst->handle = src.sensorHandle;
+    dst->type = (int)src.type;
+    dst->maxRange = src.maxRange;
+    dst->resolution = src.resolution;
+    dst->power = src.power;
+    dst->minDelay = src.minDelay;
+    dst->fifoReservedEventCount = src.fifoReservedEventCount;
+    dst->fifoMaxEventCount = src.fifoMaxEventCount;
+    dst->stringType = strdup(src.typeAsString.c_str());
+    dst->requiredPermission = strdup(src.requiredPermission.c_str());
+    dst->maxDelay = src.maxDelay;
+    dst->flags = src.flags;
+    dst->reserved[0] = dst->reserved[1] = 0;
+}
+
+void convertFromSensorEvent(const sensors_event_t &src, Event *dst) {
+    typedef ::android::hardware::sensors::V1_0::SensorType SensorType;
+    typedef ::android::hardware::sensors::V1_0::MetaDataEventType MetaDataEventType;
+
+    dst->sensorHandle = src.sensor;
+    dst->sensorType = (SensorType)src.type;
+    dst->timestamp = src.timestamp;
+
+    switch (dst->sensorType) {
+        case SensorType::SENSOR_TYPE_META_DATA:
+        {
+            dst->u.meta.what = (MetaDataEventType)src.meta_data.what;
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_ACCELEROMETER:
+        case SensorType::SENSOR_TYPE_GEOMAGNETIC_FIELD:
+        case SensorType::SENSOR_TYPE_ORIENTATION:
+        case SensorType::SENSOR_TYPE_GYROSCOPE:
+        case SensorType::SENSOR_TYPE_GRAVITY:
+        case SensorType::SENSOR_TYPE_LINEAR_ACCELERATION:
+        {
+            dst->u.vec3.x = src.acceleration.x;
+            dst->u.vec3.y = src.acceleration.y;
+            dst->u.vec3.z = src.acceleration.z;
+            dst->u.vec3.status = (SensorStatus)src.acceleration.status;
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_ROTATION_VECTOR:
+        case SensorType::SENSOR_TYPE_GAME_ROTATION_VECTOR:
+        case SensorType::SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR:
+        {
+            dst->u.vec4.x = src.data[0];
+            dst->u.vec4.y = src.data[1];
+            dst->u.vec4.z = src.data[2];
+            dst->u.vec4.w = src.data[3];
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED:
+        case SensorType::SENSOR_TYPE_GYROSCOPE_UNCALIBRATED:
+        {
+            dst->u.uncal.x = src.uncalibrated_gyro.x_uncalib;
+            dst->u.uncal.y = src.uncalibrated_gyro.y_uncalib;
+            dst->u.uncal.z = src.uncalibrated_gyro.z_uncalib;
+            dst->u.uncal.x_bias = src.uncalibrated_gyro.x_bias;
+            dst->u.uncal.y_bias = src.uncalibrated_gyro.y_bias;
+            dst->u.uncal.z_bias = src.uncalibrated_gyro.z_bias;
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_DEVICE_ORIENTATION:
+        case SensorType::SENSOR_TYPE_LIGHT:
+        case SensorType::SENSOR_TYPE_PRESSURE:
+        case SensorType::SENSOR_TYPE_TEMPERATURE:
+        case SensorType::SENSOR_TYPE_PROXIMITY:
+        case SensorType::SENSOR_TYPE_RELATIVE_HUMIDITY:
+        case SensorType::SENSOR_TYPE_AMBIENT_TEMPERATURE:
+        case SensorType::SENSOR_TYPE_SIGNIFICANT_MOTION:
+        case SensorType::SENSOR_TYPE_STEP_DETECTOR:
+        case SensorType::SENSOR_TYPE_TILT_DETECTOR:
+        case SensorType::SENSOR_TYPE_WAKE_GESTURE:
+        case SensorType::SENSOR_TYPE_GLANCE_GESTURE:
+        case SensorType::SENSOR_TYPE_PICK_UP_GESTURE:
+        case SensorType::SENSOR_TYPE_WRIST_TILT_GESTURE:
+        case SensorType::SENSOR_TYPE_STATIONARY_DETECT:
+        case SensorType::SENSOR_TYPE_MOTION_DETECT:
+        case SensorType::SENSOR_TYPE_HEART_BEAT:
+        {
+            dst->u.scalar = src.data[0];
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_STEP_COUNTER:
+        {
+            dst->u.stepCount = src.u64.step_counter;
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_HEART_RATE:
+        {
+            dst->u.heartRate.bpm = src.heart_rate.bpm;
+            dst->u.heartRate.status = (SensorStatus)src.heart_rate.status;
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_POSE_6DOF:  // 15 floats
+        {
+            for (size_t i = 0; i < 15; ++i) {
+                dst->u.pose6DOF[i] = src.data[i];
+            }
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_DYNAMIC_SENSOR_META:
+        {
+            dst->u.dynamic.connected = src.dynamic_sensor_meta.connected;
+            dst->u.dynamic.sensorHandle = src.dynamic_sensor_meta.handle;
+
+            memcpy(dst->u.dynamic.uuid.data(),
+                   src.dynamic_sensor_meta.uuid,
+                   16);
+
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_ADDITIONAL_INFO:
+        {
+            ::android::hardware::sensors::V1_0::AdditionalInfo *dstInfo =
+                &dst->u.additional;
+
+            const additional_info_event_t &srcInfo = src.additional_info;
+
+            dstInfo->type =
+                (::android::hardware::sensors::V1_0::AdditionalInfoType)
+                    srcInfo.type;
+
+            dstInfo->serial = srcInfo.serial;
+
+            CHECK_EQ(sizeof(dstInfo->u), sizeof(srcInfo.data_int32));
+            memcpy(&dstInfo->u, srcInfo.data_int32, sizeof(srcInfo.data_int32));
+            break;
+        }
+
+        default:
+        {
+            CHECK_GE((int32_t)dst->sensorType,
+                     (int32_t)SensorType::SENSOR_TYPE_DEVICE_PRIVATE_BASE);
+
+            memcpy(dst->u.data.data(), src.data, 16 * sizeof(float));
+            break;
+        }
+    }
+}
+
+void convertToSensorEvent(const Event &src, sensors_event_t *dst) {
+    dst->version = sizeof(sensors_event_t);
+    dst->sensor = src.sensorHandle;
+    dst->type = (int32_t)src.sensorType;
+    dst->reserved0 = 0;
+    dst->timestamp = src.timestamp;
+    dst->flags = 0;
+    dst->reserved1[0] = dst->reserved1[1] = dst->reserved1[2] = 0;
+
+    switch (src.sensorType) {
+        case SensorType::SENSOR_TYPE_META_DATA:
+        {
+            dst->meta_data.what = (int32_t)src.u.meta.what;
+            dst->meta_data.sensor = dst->sensor;
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_ACCELEROMETER:
+        case SensorType::SENSOR_TYPE_GEOMAGNETIC_FIELD:
+        case SensorType::SENSOR_TYPE_ORIENTATION:
+        case SensorType::SENSOR_TYPE_GYROSCOPE:
+        case SensorType::SENSOR_TYPE_GRAVITY:
+        case SensorType::SENSOR_TYPE_LINEAR_ACCELERATION:
+        {
+            dst->acceleration.x = src.u.vec3.x;
+            dst->acceleration.y = src.u.vec3.y;
+            dst->acceleration.z = src.u.vec3.z;
+            dst->acceleration.status = (int8_t)src.u.vec3.status;
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_ROTATION_VECTOR:
+        case SensorType::SENSOR_TYPE_GAME_ROTATION_VECTOR:
+        case SensorType::SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR:
+        {
+            dst->data[0] = src.u.vec4.x;
+            dst->data[1] = src.u.vec4.y;
+            dst->data[2] = src.u.vec4.z;
+            dst->data[3] = src.u.vec4.w;
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED:
+        case SensorType::SENSOR_TYPE_GYROSCOPE_UNCALIBRATED:
+        {
+            dst->uncalibrated_gyro.x_uncalib = src.u.uncal.x;
+            dst->uncalibrated_gyro.y_uncalib = src.u.uncal.y;
+            dst->uncalibrated_gyro.z_uncalib = src.u.uncal.z;
+            dst->uncalibrated_gyro.x_bias = src.u.uncal.x_bias;
+            dst->uncalibrated_gyro.y_bias = src.u.uncal.y_bias;
+            dst->uncalibrated_gyro.z_bias = src.u.uncal.z_bias;
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_DEVICE_ORIENTATION:
+        case SensorType::SENSOR_TYPE_LIGHT:
+        case SensorType::SENSOR_TYPE_PRESSURE:
+        case SensorType::SENSOR_TYPE_TEMPERATURE:
+        case SensorType::SENSOR_TYPE_PROXIMITY:
+        case SensorType::SENSOR_TYPE_RELATIVE_HUMIDITY:
+        case SensorType::SENSOR_TYPE_AMBIENT_TEMPERATURE:
+        case SensorType::SENSOR_TYPE_SIGNIFICANT_MOTION:
+        case SensorType::SENSOR_TYPE_STEP_DETECTOR:
+        case SensorType::SENSOR_TYPE_TILT_DETECTOR:
+        case SensorType::SENSOR_TYPE_WAKE_GESTURE:
+        case SensorType::SENSOR_TYPE_GLANCE_GESTURE:
+        case SensorType::SENSOR_TYPE_PICK_UP_GESTURE:
+        case SensorType::SENSOR_TYPE_WRIST_TILT_GESTURE:
+        case SensorType::SENSOR_TYPE_STATIONARY_DETECT:
+        case SensorType::SENSOR_TYPE_MOTION_DETECT:
+        case SensorType::SENSOR_TYPE_HEART_BEAT:
+        {
+            dst->data[0] = src.u.scalar;
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_STEP_COUNTER:
+        {
+            dst->u64.step_counter = src.u.stepCount;
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_HEART_RATE:
+        {
+            dst->heart_rate.bpm = src.u.heartRate.bpm;
+            dst->heart_rate.status = (int8_t)src.u.heartRate.status;
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_POSE_6DOF:  // 15 floats
+        {
+            for (size_t i = 0; i < 15; ++i) {
+                dst->data[i] = src.u.pose6DOF[i];
+            }
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_DYNAMIC_SENSOR_META:
+        {
+            dst->dynamic_sensor_meta.connected = src.u.dynamic.connected;
+            dst->dynamic_sensor_meta.handle = src.u.dynamic.sensorHandle;
+            dst->dynamic_sensor_meta.sensor = NULL;  // to be filled in later
+
+            memcpy(dst->dynamic_sensor_meta.uuid,
+                   src.u.dynamic.uuid.data(),
+                   16);
+
+            break;
+        }
+
+        case SensorType::SENSOR_TYPE_ADDITIONAL_INFO:
+        {
+            const ::android::hardware::sensors::V1_0::AdditionalInfo &srcInfo =
+                src.u.additional;
+
+            additional_info_event_t *dstInfo = &dst->additional_info;
+            dstInfo->type = (int32_t)srcInfo.type;
+            dstInfo->serial = srcInfo.serial;
+
+            CHECK_EQ(sizeof(srcInfo.u), sizeof(dstInfo->data_int32));
+
+            memcpy(dstInfo->data_int32,
+                   &srcInfo.u,
+                   sizeof(dstInfo->data_int32));
+
+            break;
+        }
+
+        default:
+        {
+            CHECK_GE((int32_t)src.sensorType,
+                     (int32_t)SensorType::SENSOR_TYPE_DEVICE_PRIVATE_BASE);
+
+            memcpy(dst->data, src.u.data.data(), 16 * sizeof(float));
+            break;
+        }
+    }
+}
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace sensors
+}  // namespace hardware
+}  // namespace android
+
diff --git a/sensors/1.0/default/include/convert.h b/sensors/1.0/default/include/convert.h
new file mode 100644
index 0000000..d289a81
--- /dev/null
+++ b/sensors/1.0/default/include/convert.h
@@ -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.
+ */
+
+#ifndef HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_INCLUDE_CONVERT_H_
+
+#define HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_INCLUDE_CONVERT_H_
+
+#include <android/hardware/sensors/1.0/ISensors.h>
+#include <hardware/sensors.h>
+
+namespace android {
+namespace hardware {
+namespace sensors {
+namespace V1_0 {
+namespace implementation {
+
+void convertFromSensor(const sensor_t &src, SensorInfo *dst);
+void convertToSensor(const SensorInfo &src, sensor_t *dst);
+
+void convertFromSensorEvent(const sensors_event_t &src, Event *dst);
+void convertToSensorEvent(const Event &src, sensors_event_t *dst);
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace sensors
+}  // namespace hardware
+}  // namespace android
+
+#endif  // HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_INCLUDE_CONVERT_H_
diff --git a/sensors/1.0/default/service.cpp b/sensors/1.0/default/service.cpp
new file mode 100644
index 0000000..da543ef
--- /dev/null
+++ b/sensors/1.0/default/service.cpp
@@ -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.
+ */
+
+#include <android-base/logging.h>
+#include <android/hardware/sensors/1.0/ISensors.h>
+#include <hwbinder/IPCThreadState.h>
+#include <hwbinder/ProcessState.h>
+
+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;
+}
+
diff --git a/sensors/1.0/types.hal b/sensors/1.0/types.hal
new file mode 100644
index 0000000..ba4921c
--- /dev/null
+++ b/sensors/1.0/types.hal
@@ -0,0 +1,1064 @@
+/*
+ * 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.sensors@1.0;
+
+/**
+ * Please see the Sensors section of source.android.com for an
+ * introduction to and detailed descriptions of Android sensor types:
+ * http://source.android.com/devices/sensors/index.html
+ */
+
+/* Type enumerating various result codes returned from ISensors methods */
+enum Result : int32_t {
+    OK,
+    BAD_VALUE,
+    PERMISSION_DENIED,
+    INVALID_OPERATION,
+};
+
+/*
+ * Sensor HAL modes used in setOperationMode method
+ */
+@export(name="")
+enum OperationMode : int32_t {
+    SENSOR_HAL_NORMAL_MODE              = 0,
+    SENSOR_HAL_DATA_INJECTION_MODE      = 1,
+};
+
+/*
+ * Sensor type
+ *
+ * Each sensor has a type which defines what this sensor measures and how
+ * measures are reported. See the Base sensors and Composite sensors lists
+ * for complete descriptions:
+ * http://source.android.com/devices/sensors/base_triggers.html
+ * http://source.android.com/devices/sensors/composite_sensors.html
+ *
+ * Device manufacturers (OEMs) can define their own sensor types, for
+ * their private use by applications or services provided by them. Such
+ * sensor types are specific to an OEM and can't be exposed in the SDK.
+ * These types must start at SENSOR_TYPE_DEVICE_PRIVATE_BASE.
+ *
+ * All sensors defined outside of the device private range must correspond to
+ * a type defined in this file, and must satisfy the characteristics listed in
+ * the description of the sensor type.
+ *
+ * Each sensor also has a "typeAsString".
+ *  - StringType of sensors inside of the device private range MUST be prefixed
+ *    by the sensor provider's or OEM reverse domain name. In particular, they
+ *    cannot use the "android.sensor" prefix.
+ *  - StringType of sensors outside of the device private range MUST correspond
+ *    to the one defined in this file (starting with "android.sensor").
+ *    For example, accelerometers must have
+ *      type=SENSOR_TYPE_ACCELEROMETER and
+ *      stringType=SENSOR_STRING_TYPE_ACCELEROMETER
+ *
+ * When android introduces a new sensor type that can replace an OEM-defined
+ * sensor type, the OEM must use the official sensor type and stringType on
+ * versions of the HAL that support this new official sensor type.
+ *
+ * Example (made up): Suppose Google's Glass team wants to surface a sensor
+ * detecting that Glass is on a head.
+ *  - Such a sensor is not officially supported in android KitKat
+ *  - Glass devices launching on KitKat can implement a sensor with
+ *    type = 0x10001 and stringType = "com.google.glass.onheaddetector"
+ *  - In L android release, if android decides to define
+ *    SENSOR_TYPE_ON_HEAD_DETECTOR and STRING_SENSOR_TYPE_ON_HEAD_DETECTOR,
+ *    those types should replace the Glass-team-specific types in all future
+ *    launches.
+ *  - When launching Glass on the L release, Google should now use the official
+ *    type (SENSOR_TYPE_ON_HEAD_DETECTOR) and stringType.
+ *  - This way, all applications can now use this sensor.
+ */
+
+/*
+ * Wake up sensors.
+ * Each sensor may have either or both a wake-up and a non-wake variant.
+ * When registered in batch mode, wake-up sensors will wake up the AP when
+ * their FIFOs are full or when the batch timeout expires. A separate FIFO has
+ * to be maintained for wake up sensors and non wake up sensors. The non
+ * wake-up sensors need to overwrite their FIFOs when they are full till the AP
+ * wakes up and the wake-up sensors will wake-up the AP when their FIFOs are
+ * full or when the batch timeout expires without losing events.
+ * Wake-up and non wake-up variants of each sensor can be activated at
+ * different rates independently of each other.
+ *
+ * Note: Proximity sensor and significant motion sensor which were defined in
+ * previous releases are also wake-up sensors and should be treated as such.
+ * Wake-up one-shot sensors like SIGNIFICANT_MOTION cannot be batched, hence
+ * the text about batch above doesn't apply to them. See the definitions of
+ * SENSOR_TYPE_PROXIMITY and SENSOR_TYPE_SIGNIFICANT_MOTION for more info.
+ *
+ * Set SENSOR_FLAG_WAKE_UP flag for all wake-up sensors.
+ *
+ * For example, A device can have two sensors both of SENSOR_TYPE_ACCELEROMETER
+ * and one of them can be a wake_up sensor (with SENSOR_FLAG_WAKE_UP flag set)
+ * and the other can be a regular non wake_up sensor. Both of these sensors
+ * must be activated/deactivated independently of the other.
+ */
+
+@export(name="")
+enum SensorType : int32_t {
+    /* META_DATA is a special event type used to populate the MetaData
+     * structure. It doesn't correspond to a physical sensor. Events of this
+     * type exist only inside the HAL, their primary purpose is to signal the
+     * completion of a flush request.
+     */
+    SENSOR_TYPE_META_DATA                       = 0,
+
+    /*
+     * SENSOR_TYPE_ACCELEROMETER
+     * reporting-mode: continuous
+     *
+     * All values are in SI units (m/s^2) and measure the acceleration of the
+     * device minus the force of gravity.
+     *
+     * Implement the non-wake-up version of this sensor and implement the
+     * wake-up version if the system possesses a wake up fifo.
+     */
+    SENSOR_TYPE_ACCELEROMETER                   = 1,
+
+    /*
+     * SENSOR_TYPE_GEOMAGNETIC_FIELD
+     * reporting-mode: continuous
+     *
+     * All values are in micro-Tesla (uT) and measure the geomagnetic
+     * field in the X, Y and Z axis.
+     *
+     * Implement the non-wake-up version of this sensor and implement the
+     * wake-up version if the system possesses a wake up fifo.
+     */
+    SENSOR_TYPE_GEOMAGNETIC_FIELD               = 2,
+
+    /*
+     * SENSOR_TYPE_ORIENTATION
+     * reporting-mode: continuous
+     *
+     * All values are angles in degrees.
+     *
+     * Orientation sensors return sensor events for all 3 axes at a constant
+     * rate defined by setDelay().
+     *
+     * Implement the non-wake-up version of this sensor and implement the
+     * wake-up version if the system possesses a wake up fifo.
+     */
+    SENSOR_TYPE_ORIENTATION                     = 3,
+
+    /*
+     * SENSOR_TYPE_GYROSCOPE
+     * reporting-mode: continuous
+     *
+     * All values are in radians/second and measure the rate of rotation
+     * around the X, Y and Z axis.
+     *
+     * Implement the non-wake-up version of this sensor and implement the
+     * wake-up version if the system possesses a wake up fifo.
+     */
+    SENSOR_TYPE_GYROSCOPE                       = 4,
+
+    /*
+     * SENSOR_TYPE_LIGHT
+     * reporting-mode: on-change
+     *
+     * The light sensor value is returned in SI lux units.
+     *
+     * Both wake-up and non wake-up versions are useful.
+     */
+    SENSOR_TYPE_LIGHT                           = 5,
+
+    /*
+     * SENSOR_TYPE_PRESSURE
+     * reporting-mode: continuous
+     *
+     * The pressure sensor return the athmospheric pressure in hectopascal (hPa)
+     *
+     * Implement the non-wake-up version of this sensor and implement the
+     * wake-up version if the system possesses a wake up fifo.
+     */
+    SENSOR_TYPE_PRESSURE                        = 6,
+
+    /* SENSOR_TYPE_TEMPERATURE is deprecated in the HAL */
+    SENSOR_TYPE_TEMPERATURE                     = 7,
+
+    /*
+     * SENSOR_TYPE_PROXIMITY
+     * reporting-mode: on-change
+     *
+     * The proximity sensor which turns the screen off and back on during calls
+     * is the wake-up proximity sensor. Implement wake-up proximity sensor
+     * before implementing a non wake-up proximity sensor. For the wake-up
+     * proximity sensor set the flag SENSOR_FLAG_WAKE_UP.
+     * The value corresponds to the distance to the nearest object in
+     * centimeters.
+     */
+    SENSOR_TYPE_PROXIMITY                       = 8,
+
+    /*
+     * SENSOR_TYPE_GRAVITY
+     * reporting-mode: continuous
+     *
+     * A gravity output indicates the direction of and magnitude of gravity in
+     * the devices's coordinates.
+     *
+     * Implement the non-wake-up version of this sensor and implement the
+     * wake-up version if the system possesses a wake up fifo.
+     */
+    SENSOR_TYPE_GRAVITY                         = 9,
+
+    /*
+     * SENSOR_TYPE_LINEAR_ACCELERATION
+     * reporting-mode: continuous
+     *
+     * Indicates the linear acceleration of the device in device coordinates,
+     * not including gravity.
+     *
+     * Implement the non-wake-up version of this sensor and implement the
+     * wake-up version if the system possesses a wake up fifo.
+     */
+    SENSOR_TYPE_LINEAR_ACCELERATION             = 10,
+
+    /*
+     * SENSOR_TYPE_ROTATION_VECTOR
+     * reporting-mode: continuous
+     *
+     * The rotation vector symbolizes the orientation of the device relative to
+     * the East-North-Up coordinates frame.
+     *
+     * Implement the non-wake-up version of this sensor and implement the
+     * wake-up version if the system possesses a wake up fifo.
+     */
+    SENSOR_TYPE_ROTATION_VECTOR                 = 11,
+
+    /*
+     * SENSOR_TYPE_RELATIVE_HUMIDITY
+     * reporting-mode: on-change
+     *
+     * A relative humidity sensor measures relative ambient air humidity and
+     * returns a value in percent.
+     *
+     * Both wake-up and non wake-up versions are useful.
+     */
+    SENSOR_TYPE_RELATIVE_HUMIDITY               = 12,
+
+    /*
+     * SENSOR_TYPE_AMBIENT_TEMPERATURE
+     * reporting-mode: on-change
+     *
+     * The ambient (room) temperature in degree Celsius.
+     *
+     * Both wake-up and non wake-up versions are useful.
+     */
+    SENSOR_TYPE_AMBIENT_TEMPERATURE             = 13,
+
+    /*
+     * SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED
+     * reporting-mode: continuous
+     *
+     * Similar to SENSOR_TYPE_MAGNETIC_FIELD, but the hard iron calibration is
+     * reported separately instead of being included in the measurement.
+     *
+     * Implement the non-wake-up version of this sensor and implement the
+     * wake-up version if the system possesses a wake up fifo.
+     */
+    SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED     = 14,
+
+    /*
+     * SENSOR_TYPE_GAME_ROTATION_VECTOR
+     * reporting-mode: continuous
+     *
+     * Similar to SENSOR_TYPE_ROTATION_VECTOR, but not using the geomagnetic
+     * field.
+     *
+     * Implement the non-wake-up version of this sensor and implement the
+     * wake-up version if the system possesses a wake up fifo.
+     */
+    SENSOR_TYPE_GAME_ROTATION_VECTOR            = 15,
+
+    /*
+     * SENSOR_TYPE_GYROSCOPE_UNCALIBRATED
+     * reporting-mode: continuous
+     *
+     * All values are in radians/second and measure the rate of rotation
+     * around the X, Y and Z axis.
+     *
+     * Implement the non-wake-up version of this sensor and implement the
+     * wake-up version if the system possesses a wake up fifo.
+     */
+    SENSOR_TYPE_GYROSCOPE_UNCALIBRATED          = 16,
+
+    /*
+     * SENSOR_TYPE_SIGNIFICANT_MOTION
+     * reporting-mode: one-shot
+     *
+     * A sensor of this type triggers an event each time significant motion
+     * is detected and automatically disables itself.
+     * For Significant Motion sensor to be useful, it must be defined as a
+     * wake-up sensor. (set SENSOR_FLAG_WAKE_UP). Implement the wake-up
+     * significant motion sensor. A non wake-up version is not useful.
+     * The only allowed value to return is 1.0.
+     */
+    SENSOR_TYPE_SIGNIFICANT_MOTION              = 17,
+
+    /*
+     * SENSOR_TYPE_STEP_DETECTOR
+     * reporting-mode: special
+     *
+     * A sensor of this type triggers an event each time a step is taken
+     * by the user. The only allowed value to return is 1.0 and an event
+     * is generated for each step.
+     *
+     * Both wake-up and non wake-up versions are useful.
+     */
+    SENSOR_TYPE_STEP_DETECTOR                   = 18,
+
+    /*
+     * SENSOR_TYPE_STEP_COUNTER
+     * reporting-mode: on-change
+     *
+     * A sensor of this type returns the number of steps taken by the user since
+     * the last reboot while activated. The value is returned as a uint64_t and
+     * is reset to zero only on a system / android reboot.
+     *
+     * Implement the non-wake-up version of this sensor and implement the
+     * wake-up version if the system possesses a wake up fifo.
+     */
+    SENSOR_TYPE_STEP_COUNTER                    = 19,
+
+    /*
+     * SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR
+     * reporting-mode: continuous
+     *
+     *  Similar to SENSOR_TYPE_ROTATION_VECTOR, but using a magnetometer instead
+     *  of using a gyroscope.
+     *
+     * Implement the non-wake-up version of this sensor and implement the
+     * wake-up version if the system possesses a wake up fifo.
+     */
+    SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR     = 20,
+
+    /*
+     * SENSOR_TYPE_HEART_RATE
+     * reporting-mode: on-change
+     *
+     *  A sensor of this type returns the current heart rate.
+     *  The events contain the current heart rate in beats per minute (BPM) and
+     *  the status of the sensor during the measurement. See "HeartRate" below
+     *  for more details.
+     *
+     *  Because this sensor is on-change, events must be generated when and only
+     *  when heart_rate.bpm or heart_rate.status have changed since the last
+     *  event. In particular, upon the first activation, unless the device is
+     *  known to not be on the body, the status field of the first event must be
+     *  set to SENSOR_STATUS_UNRELIABLE. The event should be generated no faster
+     *  than every period_ns passed to setDelay() or to batch().
+     *  See the definition of the on-change reporting mode for more information.
+     *
+     *  SensorInfo.requiredPermission must be set to
+     *  SENSOR_PERMISSION_BODY_SENSORS.
+     *
+     *  Both wake-up and non wake-up versions are useful.
+     */
+    SENSOR_TYPE_HEART_RATE                      = 21,
+
+    /*
+     * SENSOR_TYPE_WAKE_UP_TILT_DETECTOR
+     * reporting-mode: special (setDelay has no impact)
+     *
+     * A sensor of this type generates an event each time a tilt event is
+     * detected. A tilt event should be generated if the direction of the
+     * 2-seconds window average gravity changed by at least 35 degrees since the
+     * activation or the last trigger of the sensor.
+     *
+     *  reference_estimated_gravity = average of accelerometer measurements over
+     *  the first 1 second after activation or the estimated gravity at the last
+     *  trigger.
+     *
+     *  current_estimated_gravity = average of accelerometer measurements over
+     *  the last 2 seconds.
+     *
+     *  trigger when
+     *     angle(reference_estimated_gravity, current_estimated_gravity)
+     *       > 35 degrees
+     *
+     * Large accelerations without a change in phone orientation should not
+     * trigger a tilt event.
+     * For example, a sharp turn or strong acceleration while driving a car
+     * should not trigger a tilt event, even though the angle of the average
+     * acceleration might vary by more than 35 degrees.
+     *
+     * Typically, this sensor is implemented with the help of only an
+     * accelerometer. Other sensors can be used as well if they do not increase
+     * the power consumption significantly. This is a low power sensor that
+     * should allow the AP to go into suspend mode. Do not emulate this sensor
+     * in the HAL.
+     * Like other wake up sensors, the driver is expected to a hold a wake_lock
+     * with a timeout of 200 ms while reporting this event. The only allowed
+     * return value is 1.0.
+     *
+     * Implement only the wake-up version of this sensor.
+     */
+    SENSOR_TYPE_TILT_DETECTOR                   = 22,
+
+    /*
+     * SENSOR_TYPE_WAKE_GESTURE
+     * reporting-mode: one-shot
+     *
+     * A sensor enabling waking up the device based on a device specific motion.
+     *
+     * When this sensor triggers, the device behaves as if the power button was
+     * pressed, turning the screen on. This behavior (turning on the screen when
+     * this sensor triggers) might be deactivated by the user in the device
+     * settings. Changes in settings do not impact the behavior of the sensor:
+     * only whether the framework turns the screen on when it triggers.
+     *
+     * The actual gesture to be detected is not specified, and can be chosen by
+     * the manufacturer of the device.
+     * This sensor must be low power, as it is likely to be activated 24/7.
+     * The only allowed value to return is 1.0.
+     *
+     * Implement only the wake-up version of this sensor.
+     */
+    SENSOR_TYPE_WAKE_GESTURE                    = 23,
+
+    /*
+     * SENSOR_TYPE_GLANCE_GESTURE
+     * reporting-mode: one-shot
+     *
+     * A sensor enabling briefly turning the screen on to enable the user to
+     * glance content on screen based on a specific motion.  The device should
+     * turn the screen off after a few moments.
+     *
+     * When this sensor triggers, the device turns the screen on momentarily
+     * to allow the user to glance notifications or other content while the
+     * device remains locked in a non-interactive state (dozing). This behavior
+     * (briefly turning on the screen when this sensor triggers) might be
+     * deactivated by the user in the device settings.
+     * Changes in settings do not impact the behavior of the sensor: only
+     * whether the framework briefly turns the screen on when it triggers.
+     *
+     * The actual gesture to be detected is not specified, and can be chosen by
+     * the manufacturer of the device.
+     * This sensor must be low power, as it is likely to be activated 24/7.
+     * The only allowed value to return is 1.0.
+     *
+     * Implement only the wake-up version of this sensor.
+     */
+    SENSOR_TYPE_GLANCE_GESTURE                  = 24,
+
+    /**
+     * SENSOR_TYPE_PICK_UP_GESTURE
+     * reporting-mode: one-shot
+     *
+     * A sensor of this type triggers when the device is picked up regardless of
+     * wherever is was before (desk, pocket, bag). The only allowed return value
+     * is 1.0. This sensor de-activates itself immediately after it triggers.
+     *
+     * Implement only the wake-up version of this sensor.
+     */
+    SENSOR_TYPE_PICK_UP_GESTURE                 = 25,
+
+    /*
+     * SENSOR_TYPE_WRIST_TILT_GESTURE
+     * trigger-mode: special
+     * wake-up sensor: yes
+     *
+     * A sensor of this type triggers an event each time a tilt of the
+     * wrist-worn device is detected.
+     *
+     * This sensor must be low power, as it is likely to be activated 24/7.
+     * The only allowed value to return is 1.0.
+     *
+     * Implement only the wake-up version of this sensor.
+     */
+    SENSOR_TYPE_WRIST_TILT_GESTURE              = 26,
+
+    /*
+     * SENSOR_TYPE_DEVICE_ORIENTATION
+     * reporting-mode: on-change
+     *
+     * The current orientation of the device. The value should be reported in
+     * the "scalar" element of the EventPayload in Event. The
+     * only values that can be reported are (please refer to Android Sensor
+     * Coordinate System to understand the X and Y axis direction with respect
+     * to default orientation):
+     *  - 0: device is in default orientation (Y axis is vertical and points up)
+     *  - 1: device is rotated 90 degrees counter-clockwise from default
+     *       orientation (X axis is vertical and points up)
+     *  - 2: device is rotated 180 degrees from default orientation (Y axis is
+     *       vertical and points down)
+     *  - 3: device is rotated 90 degrees clockwise from default orientation
+     *       (X axis is vertical and points down)
+     *
+     * Moving the device to an orientation where the Z axis is vertical (either
+     * up or down) should not cause a new event to be reported.
+     *
+     * To improve the user experience of this sensor, it is recommended to
+     * implement some physical (i.e., rotation angle) and temporal (i.e., delay)
+     * hysteresis.
+     * In other words, minor or transient rotations should not cause a new event
+     * to be reported.
+     *
+     * This sensor should only be implemented with the help of an accelerometer.
+     * This is a low power sensor that should reduce the number of interrupts of
+     * the AP. Do not emulate this sensor in the HAL.
+     *
+     * Both wake-up and non wake-up versions are useful.
+     */
+    SENSOR_TYPE_DEVICE_ORIENTATION              = 27,
+
+    /*
+     * SENSOR_TYPE_POSE_6DOF
+     * trigger-mode: continuous
+     *
+     * A sensor of this type returns the pose of the device.
+     * Pose of the device is defined as the orientation of the device from a
+     * Earth Centered Earth Fixed frame and the translation from an arbitrary
+     * point at subscription.
+     *
+     * This sensor can be high power. It can use any and all of the following
+     *           . Accelerometer
+     *           . Gyroscope
+     *           . Camera
+     *           . Depth Camera
+     *
+     */
+    SENSOR_TYPE_POSE_6DOF                       = 28,
+
+    /*
+     * SENSOR_TYPE_STATIONARY_DETECT
+     * trigger mode: one shot
+     *
+     * A sensor of this type returns an event if the device is still/stationary
+     * for a while. The period of time to monitor for statinarity should be
+     * greater than 5 seconds, and less than 10 seconds.
+     *
+     * Stationarity here refers to absolute stationarity. eg: device on desk.
+     *
+     * The only allowed value to return is 1.0.
+     */
+    SENSOR_TYPE_STATIONARY_DETECT               = 29,
+
+    /*
+     * SENSOR_TYPE_MOTION_DETECT
+     * trigger mode: one shot
+     *
+     * A sensor of this type returns an event if the device is not still for
+     * a while. The period of time to monitor for statinarity should be greater
+     * than 5 seconds, and less than 10 seconds.
+     *
+     * Motion here refers to any mechanism in which the device is causes to be
+     * moved in its inertial frame. eg: Pickin up the device and walking with it
+     * to a nearby room may trigger motion wherewas keeping the device on a
+     * table on a smooth train moving at constant velocity may not trigger
+     * motion.
+     *
+     * The only allowed value to return is 1.0.
+     */
+    SENSOR_TYPE_MOTION_DETECT                   = 30,
+
+    /*
+     * SENSOR_TYPE_HEART_BEAT
+     * trigger mode: continuous
+     *
+     * A sensor of this type returns an event everytime a hear beat peak is
+     * detected.
+     *
+     * Peak here ideally corresponds to the positive peak in the QRS complex of
+     * and ECG signal.
+     *
+     * The sensor is not expected to be optimized for latency. As a guide, a
+     * latency of up to 10 seconds is acceptable. However the timestamp attached
+     * to the event should be accurate and should correspond to the time the
+     * peak occured.
+     *
+     * The sensor event contains a parameter for the confidence in the detection
+     * of the peak where 0.0 represent no information at all, and 1.0 represents
+     * certainty.
+     */
+    SENSOR_TYPE_HEART_BEAT                      = 31,
+
+    /**
+     * SENSOR_TYPE_DYNAMIC_SENSOR_META
+     * trigger-mode: special
+     *
+     * A sensor event of this type is received when a dynamic sensor is added to
+     * or removed from the system. At most one sensor of this type can be
+     * present in one sensor HAL implementation and presence of a sensor of this
+     * type in sensor HAL implementation indicates that this sensor HAL supports
+     * dynamic sensor feature. Operations, such as batch, activate and setDelay,
+     * to this special purpose sensor should be treated as no-op and return
+     * successful; flush() also has to generate flush complete event as if this
+     * is a sensor that does not support batching.
+     *
+     * A dynamic sensor connection indicates connection of a physical device or
+     * instantiation of a virtual sensor backed by algorithm; and a dynamic
+     * sensor disconnection indicates the the opposite. A sensor event of
+     * SENSOR_TYPE_DYNAMIC_SENSOR_META type should be delivered regardless of
+     * the activation status of the sensor in the event of dynamic sensor
+     * connection and disconnection. In the sensor event, besides the common
+     * data entries, "dynamic_sensor_meta", which includes fields for connection
+     * status, handle of the sensor involved, pointer to sensor_t structure and
+     * a uuid field, should be populated.
+     *
+     * At a dynamic sensor connection event, fields of sensor_t structure
+     * referenced by a pointer in dynamic_sensor_meta should be filled as if it
+     * was regular sensors. Sensor HAL is responsible for recovery of memory if
+     * the corresponding data is dynamicially allocated. However, the the
+     * pointer must be valid until the first activate call to the sensor
+     * reported in this connection event. At a dynamic sensor disconnection,
+     * the sensor_t pointer should be NULL.
+     *
+     * The sensor handle assigned to dynamic sensors should never be the same as
+     * that of any regular static sensors, and should be unique until next boot.
+     * In another word, if a handle h is used for a dynamic sensor A, that same
+     * number cannot be used for the same dynamic sensor A or another dynamic
+     * sensor B even after disconnection of A until reboot.
+     *
+     * The UUID field will be used for identifying the sensor in addition to
+     * name, vendor and version and type. For physical sensors of the same
+     * model, all sensors will have the same values in sensor_t, but the UUID
+     * should be unique and persistent for each individual unit. An all zero
+     * UUID indicates it is not possible to differentiate individual sensor
+     * unit.
+     *
+     */
+    SENSOR_TYPE_DYNAMIC_SENSOR_META             = 32,
+
+    /**
+     * SENSOR_TYPE_ADDITIONAL_INFO
+     * reporting-mode: N/A
+     *
+     * This sensor type is for delivering additional sensor information aside
+     * from sensor event data.
+     * Additional information may include sensor front-end group delay, internal
+     * calibration parameters, noise level metrics, device internal temperature,
+     * etc.
+     *
+     * This type will never bind to a sensor. In other words, no sensor in the
+     * sensor list should be of the type SENSOR_TYPE_ADDITIONAL_INFO. If a
+     * sensor HAL supports sensor additional information feature, it reports
+     * sensor_event_t with "sensor" field set to handle of the reporting sensor
+     * and "type" field set to SENSOR_TYPE_ADDITIONAL_INFO. Delivery of
+     * additional information events is triggered under two conditions: an
+     * enable activate() call or a flush() call to the corresponding sensor.
+     *
+     * A single additional information report consists of multiple frames.
+     * Sequences of these frames are ordered using timestamps, which means the
+     * timestamps of sequential frames have to be at least 1 nanosecond apart
+     * from each other. Each frame is a sensor_event_t delivered through the HAL
+     * interface, with related data stored in the "additional_info" field, which
+     * is of type additional_info_event_t.
+     * The "type" field of additional_info_event_t denotes the nature of the
+     * payload data (see additional_info_type_t).
+     * The "serial" field is used to keep the sequence of payload data that
+     * spans multiple frames. The first frame of the entire report is always of
+     * type AINFO_BEGIN, and the last frame is always AINFO_END.
+     *
+     * All additional information frames have to be delivered after flush
+     * complete event if flush() was triggering the report.
+     */
+    SENSOR_TYPE_ADDITIONAL_INFO                 = 33,
+
+    /*
+     * Base for device manufacturers private sensor types.
+     * These sensor types can't be exposed in the SDK.
+     */
+    SENSOR_TYPE_DEVICE_PRIVATE_BASE             = 0x10000
+};
+
+@export(name="")
+enum SensorFlagBits : uint64_t {
+    /*
+     * Whether this sensor wakes up the AP from suspend mode when data is
+     * available.  Whenever sensor events are delivered from a wake_up sensor,
+     * the driver needs to hold a wake_lock till the events are read by the
+     * SensorService i.e till ISensors::poll() is called the next time.
+     * Once poll is called again it means events have been read by the
+     * SensorService, the driver can safely release the wake_lock. SensorService
+     * will continue to hold a wake_lock till the app actually reads the events.
+     */
+    SENSOR_FLAG_WAKE_UP                     = 1,
+
+    /*
+     * Reporting modes for various sensors. Each sensor will have exactly one of
+     * these modes set.
+     * The least significant 2nd, 3rd and 4th bits are used to represent four
+     * possible reporting modes.
+     */
+    SENSOR_FLAG_CONTINUOUS_MODE             = 0,
+    SENSOR_FLAG_ON_CHANGE_MODE              = 2,
+    SENSOR_FLAG_ONE_SHOT_MODE               = 4,
+    SENSOR_FLAG_SPECIAL_REPORTING_MODE      = 6,
+
+    /*
+     * Set this flag if the sensor supports data_injection mode and allows data
+     * to be injected from the SensorService. When in data_injection ONLY
+     * sensors with this flag set are injected sensor data and only sensors with
+     * this flag set are activated. Eg: Accelerometer and Step Counter sensors
+     * can be set with this flag and SensorService will inject accelerometer
+     * data and read the corresponding step counts.
+     */
+    SENSOR_FLAG_SUPPORTS_DATA_INJECTION     = 0x10,
+
+    /*
+     * Set this flag if the sensor is a dynamically connected sensor. See
+     * DynamicSensorInfo and DYNAMIC_SENSOR_META for details.
+     */
+    SENSOR_FLAG_DYNAMIC_SENSOR              = 0x20,
+
+    /*
+     * Set this flag if sensor additional information is supported.
+     * See ADDITIONAL_INFO and AdditionalInfo for details.
+     */
+    SENSOR_FLAG_ADDITIONAL_INFO             = 0x40,
+};
+
+struct SensorInfo {
+    /* handle that identifies this sensors. This handle is used to reference
+     * this sensor throughout the HAL API.
+     */
+    int32_t sensorHandle;
+
+    /* Name of this sensor.
+     * All sensors of the same "type" must have a different "name".
+     */
+    string name;
+
+    /* vendor of the hardware part */
+    string vendor;
+
+    /* version of the hardware part + driver. The value of this field
+     * must increase when the driver is updated in a way that changes the
+     * output of this sensor. This is important for fused sensors when the
+     * fusion algorithm is updated.
+     */
+    int32_t version;
+
+    /* this sensor's type. */
+    SensorType type;
+
+    /* type of this sensor as a string. Set to corresponding
+     * SENSOR_STRING_TYPE_*.
+     * When defining an OEM specific sensor or sensor manufacturer specific
+     * sensor, use your reserve domain name as a prefix.
+     * ex: com.google.glass.onheaddetector
+     * For sensors of known type, the android framework might overwrite this
+     * string automatically.
+     */
+    string typeAsString;
+
+    /* maximum range of this sensor's value in SI units */
+    float maxRange;
+
+    /* smallest difference between two values reported by this sensor */
+    float resolution;
+
+    /* rough estimate of this sensor's power consumption in mA */
+    float power;
+
+    /* this value depends on the reporting mode:
+     *
+     *   continuous: minimum sample period allowed in microseconds
+     *   on-change : 0
+     *   one-shot  :-1
+     *   special   : 0, unless otherwise noted
+     */
+    int32_t minDelay;
+
+    /* number of events reserved for this sensor in the batch mode FIFO.
+     * If there is a dedicated FIFO for this sensor, then this is the
+     * size of this FIFO. If the FIFO is shared with other sensors,
+     * this is the size reserved for that sensor and it can be zero.
+     */
+    uint32_t fifoReservedEventCount;
+
+    /* maximum number of events of this sensor that could be batched.
+     * This is especially relevant when the FIFO is shared between
+     * several sensors; this value is then set to the size of that FIFO.
+     */
+    uint32_t fifoMaxEventCount;
+
+    /* permission required to see this sensor, register to it and receive data.
+     * Set to "" if no permission is required. Some sensor types like the
+     * heart rate monitor have a mandatory require_permission.
+     * For sensors that always require a specific permission, like the heart
+     * rate monitor, the android framework might overwrite this string
+     * automatically.
+     */
+    string requiredPermission;
+
+    /* This value is defined only for continuous mode and on-change sensors.
+     * It is the delay between two sensor events corresponding to the lowest
+     * frequency that this sensor supports. When lower frequencies are requested
+     * through batch()/setDelay() the events will be generated at this frequency
+     * instead.
+     * It can be used by the framework or applications to estimate when the
+     * batch FIFO may be full.
+     *
+     * NOTE: periodNs is in nanoseconds where as maxDelay/minDelay are in
+     *       microseconds.
+     *
+     *       continuous, on-change: maximum sampling period allowed in
+     *                              microseconds.
+     *
+     *          one-shot, special : 0
+     */
+    int32_t maxDelay;
+
+    /* Bitmask of SensorFlagBits */
+    uint64_t flags;
+};
+
+@export(name="")
+enum SensorStatus : int8_t {
+    SENSOR_STATUS_NO_CONTACT      = -1,
+    SENSOR_STATUS_UNRELIABLE      = 0,
+    SENSOR_STATUS_ACCURACY_LOW    = 1,
+    SENSOR_STATUS_ACCURACY_MEDIUM = 2,
+    SENSOR_STATUS_ACCURACY_HIGH   = 3,
+};
+
+struct Vec3 {
+    float x;
+    float y;
+    float z;
+    SensorStatus status;
+};
+
+struct Vec4 {
+    float x;
+    float y;
+    float z;
+    float w;
+};
+
+struct Uncal {
+    float x;
+    float y;
+    float z;
+    float x_bias;
+    float y_bias;
+    float z_bias;
+};
+
+struct HeartRate {
+    /* Heart rate in beats per minute.
+     * Set to 0 when status is SENSOR_STATUS_UNRELIABLE or ..._NO_CONTACT
+     */
+    float bpm;
+
+    /* Status of the sensor for this reading. Set to one SENSOR_STATUS_...
+     * Note that this value should only be set for sensors that explicitly
+     * define the meaning of this field. This field is not piped through the
+     * framework for other sensors.
+     */
+    SensorStatus status;
+};
+
+@export(name="")
+enum MetaDataEventType : uint32_t {
+    META_DATA_FLUSH_COMPLETE = 1,
+};
+
+struct MetaData {
+    MetaDataEventType what;
+};
+
+struct DynamicSensorInfo {
+    bool connected;
+    int32_t sensorHandle;
+
+    /* UUID of a dynamic sensor (using RFC 4122 byte order)
+     * For UUID 12345678-90AB-CDEF-1122-334455667788 the uuid field should be
+     * initialized as:
+     *   {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF, 0x11, ...}
+     */
+    uint8_t[16] uuid;
+};
+
+@export(name="additional_info_type_t")
+enum AdditionalInfoType : uint32_t {
+    /* Marks the beginning of additional information frames */
+    AINFO_BEGIN                       = 0,
+
+    /* Marks the end of additional information frames */
+    AINFO_END                         = 1,
+
+    /* Estimation of the delay that is not tracked by sensor timestamps. This
+     * includes delay introduced by sensor front-end filtering, data transport,
+     * etc.
+     * float[2]: delay in seconds, standard deviation of estimated value
+     */
+    AINFO_UNTRACKED_DELAY             = 0x10000,
+
+    /* float: Celsius temperature */
+    AINFO_INTERNAL_TEMPERATURE,
+
+    /* First three rows of a homogeneous matrix, which represents calibration to
+     * a three-element vector raw sensor reading.
+     * float[12]: 3x4 matrix in row major order
+     */
+    AINFO_VEC3_CALIBRATION,
+
+    /* Location and orientation of sensor element in the device frame: origin is
+     * the geometric center of the mobile device screen surface; the axis
+     * definition corresponds to Android sensor definitions.
+     * float[12]: 3x4 matrix in row major order
+     */
+    AINFO_SENSOR_PLACEMENT,
+
+    /* float[2]: raw sample period in seconds,
+     *           standard deviation of sampling period
+     */
+    AINFO_SAMPLING,
+
+    /* Sampling channel modeling information
+     * int32_t: noise type
+     * float[n]: parameters
+     */
+    AINFO_CHANNEL_NOISE               = 0x20000,
+
+    /* float[3]: sample period, standard deviation of sample period,
+     * quantization unit
+     */
+    AINFO_CHANNEL_SAMPLER,
+
+    /* Represents a filter:
+     *   \sum_j a_j y[n-j] == \sum_i b_i x[n-i]
+     *
+     * int32_t[3]: number of feedforward coeffients M,
+     *             number of feedback coefficients N (for FIR filter, N = 1).
+     *             bit mask that represents which element the filter is applied
+     *             to. (bit 0==1 means this filter applies to vector element 0).
+     * float[M+N]: filter coefficients (b0, b1, ..., b_{M-1}), then
+     *             (a0, a1, ..., a_{N-1}), a0 is always 1.
+     *
+     * Multiple frames may be needed for higher number of taps.
+     */
+    AINFO_CHANNEL_FILTER,
+
+    /* int32_t[2]: size in (row, column) ... 1st frame
+     * float[n]: matrix element values in row major order.
+     */
+    AINFO_CHANNEL_LINEAR_TRANSFORM,
+
+    /* int32_t[2]: extrapolate method, interpolate method
+     * float[n]: mapping key points in paris, (in, out)...
+     *           (may be used to model saturation).
+     */
+    AINFO_CHANNEL_NONLINEAR_MAP,
+
+    /* int32_t: resample method (0-th order, 1st order...)
+     * float[1]: resample ratio (upsampling if < 1.0, downsampling if > 1.0).
+     */
+    AINFO_CHANNEL_RESAMPLER,
+
+    /* Custom information */
+    AINFO_CUSTOM_START                = 0x10000000,
+
+    /* Debugging */
+    AINFO_DEBUGGING_START             = 0x40000000,
+};
+
+struct AdditionalInfo {
+    /* type of payload data, see AdditionalInfoType */
+    AdditionalInfoType type;
+
+    /* sequence number of this frame for this type */
+    int32_t serial;
+
+    union Payload {
+        /* for each frame, a single data type, either int32_t or float,
+         * should be used.
+         */
+        int32_t[14] data_int32;
+        float[14] data_float;
+    } u;
+};
+
+/* acceleration values are in meter per second per second (m/s^2)
+ * magnetic vector values are in micro-Tesla (uT)
+ * orientation values are in degrees
+ * gyroscope values are in rad/s
+ * temperature is in degrees centigrade (Celsius)
+ * distance in centimeters
+ * light in SI lux units
+ * pressure in hectopascal (hPa)
+ * relative humidity in percent
+ */
+union EventPayload {
+    /* SENSOR_TYPE_ACCELEROMETER, SENSOR_TYPE_GEOMAGNETIC_FIELD,
+     * SENSOR_TYPE_ORIENTATION, SENSOR_TYPE_GYROSCOPE, SENSOR_TYPE_GRAVITY,
+     * SENSOR_TYPE_LINEAR_ACCELERATION
+     */
+    Vec3 vec3;
+
+    /* SENSOR_TYPE_ROTATION_VECTOR, SENSOR_TYPE_GAME_ROTATION_VECTOR,
+     * SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR
+     */
+    Vec4 vec4;
+
+    /* SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED,
+     * SENSOR_TYPE_GYROSCOPE_UNCALIBRATED
+     */
+    Uncal uncal;
+
+    /* SENSOR_TYPE_META_DATA */
+    MetaData meta;
+
+    /* SENSOR_TYPE_DEVICE_ORIENTATION, SENSOR_TYPE_LIGHT, SENSOR_TYPE_PRESSURE,
+     * SENSOR_TYPE_TEMPERATURE, SENSOR_TYPE_PROXIMITY,
+     * SENSOR_TYPE_RELATIVE_HUMIDITY, SENSOR_TYPE_AMBIENT_TEMPERATURE,
+     * SENSOR_TYPE_SIGNIFICANT_MOTION, SENSOR_TYPE_STEP_DETECTOR,
+     * SENSOR_TYPE_TILT_DETECTOR, SENSOR_TYPE_WAKE_GESTURE,
+     * SENSOR_TYPE_GLANCE_GESTURE, SENSOR_TYPE_PICK_UP_GESTURE,
+     * SENSOR_TYPE_WRIST_TILT_GESTURE, SENSOR_TYPE_STATIONARY_DETECT,
+     * SENSOR_TYPE_MOTION_DETECT, SENSOR_TYPE_HEART_BEAT
+     */
+    float scalar;
+
+    /* SENSOR_TYPE_STEP_COUNTER */
+    uint64_t stepCount;
+
+    /* SENSOR_TYPE_HEART_RATE */
+    HeartRate heartRate;
+
+    /* SENSOR_TYPE_POSE_6DOF */
+    float[15] pose6DOF;
+
+    /* SENSOR_TYPE_DYNAMIC_SENSOR_META */
+    DynamicSensorInfo dynamic;
+
+    /* SENSOR_TYPE_ADDITIONAL_INFO */
+    AdditionalInfo additional;
+
+    /* undefined/custom sensor type, >= SENSOR_TYPE_DEVICE_PRIVATE_BASE */
+    float[16] data;
+};
+
+struct Event {
+    /* Time measured in nanoseconds, in "elapsedRealtimeNano()'s" timebase. */
+    int64_t timestamp;
+
+    /* sensor identifier */
+    int32_t sensorHandle;
+
+    SensorType sensorType;
+
+    /* Union discriminated on sensorType */
+    EventPayload u;
+};
diff --git a/tests/msgq/1.0/ITestMsgQ.hal b/tests/msgq/1.0/ITestMsgQ.hal
index 93a6e8a..fc96181 100644
--- a/tests/msgq/1.0/ITestMsgQ.hal
+++ b/tests/msgq/1.0/ITestMsgQ.hal
@@ -20,24 +20,26 @@
     /*
      * This method requests the service to set up Synchronous read/write
      * wait-free FMQ with the client as reader.
-     * @return ret Will be 0 if the setup is successful.
+     * @return ret Will be true if the setup is successful, false otherwise.
      * @return mqDesc This structure describes the FMQ that was
      * set up by the service. Client can use it to set up the FMQ at its end.
      */
     configureFmqSyncReadWrite()
-        generates(int32_t ret, MQDescriptorSync mqDesc);
+        generates(bool ret, MQDescriptorSync mqDesc);
 
     /*
      * This method request the service to write into the FMQ.
      * @param count Number to messages to write.
-     * @ret Number of messages succesfully written.
+     * @return ret Will be true if the write operation was successful,
+     * false otherwise.
      */
-    requestWrite(int32_t count) generates(int32_t ret);
+    requestWrite(int32_t count) generates(bool ret);
 
     /*
      * This method request the service to read from the FMQ.
      * @param count Number to messages to read.
-     * @ret Number of messages succesfully read.
+     * @return ret Will be true if the read operation was successful, false
+     * otherwise.
      */
-    requestRead(int32_t count) generates(int32_t ret);
+    requestRead(int32_t count) generates(bool ret);
 };
diff --git a/thermal/1.0/Android.bp b/thermal/1.0/Android.bp
new file mode 100644
index 0000000..0c5dd19
--- /dev/null
+++ b/thermal/1.0/Android.bp
@@ -0,0 +1,46 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+    name: "android.hardware.thermal@1.0_genc++",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.thermal@1.0",
+    srcs: [
+        "types.hal",
+        "IThermal.hal",
+    ],
+    out: [
+        "android/hardware/thermal/1.0/types.cpp",
+        "android/hardware/thermal/1.0/ThermalAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.thermal@1.0_genc++_headers",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.thermal@1.0",
+    srcs: [
+        "types.hal",
+        "IThermal.hal",
+    ],
+    out: [
+        "android/hardware/thermal/1.0/types.h",
+        "android/hardware/thermal/1.0/IThermal.h",
+        "android/hardware/thermal/1.0/IHwThermal.h",
+        "android/hardware/thermal/1.0/BnThermal.h",
+        "android/hardware/thermal/1.0/BpThermal.h",
+        "android/hardware/thermal/1.0/BsThermal.h",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.thermal@1.0",
+    generated_sources: ["android.hardware.thermal@1.0_genc++"],
+    generated_headers: ["android.hardware.thermal@1.0_genc++_headers"],
+    export_generated_headers: ["android.hardware.thermal@1.0_genc++_headers"],
+    shared_libs: [
+        "libhidl",
+        "libhwbinder",
+        "libutils",
+        "libcutils",
+    ],
+}
diff --git a/thermal/1.0/Android.mk b/thermal/1.0/Android.mk
new file mode 100644
index 0000000..47a4d61
--- /dev/null
+++ b/thermal/1.0/Android.mk
@@ -0,0 +1,306 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.thermal@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 (CoolingDevice)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/CoolingDevice.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.thermal@1.0::types.CoolingDevice
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (CoolingType)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/CoolingType.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.thermal@1.0::types.CoolingType
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (CpuUsage)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/CpuUsage.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.thermal@1.0::types.CpuUsage
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (Temperature)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/Temperature.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.thermal@1.0::types.Temperature
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (TemperatureType)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/TemperatureType.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.thermal@1.0::types.TemperatureType
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (ThermalStatus)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/ThermalStatus.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.thermal@1.0::types.ThermalStatus
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (ThermalStatusCode)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/ThermalStatusCode.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.thermal@1.0::types.ThermalStatusCode
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IThermal.hal
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/IThermal.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IThermal.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.thermal@1.0::IThermal
+
+$(GEN): $(LOCAL_PATH)/IThermal.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.thermal@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 (CoolingDevice)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/CoolingDevice.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.thermal@1.0::types.CoolingDevice
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (CoolingType)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/CoolingType.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.thermal@1.0::types.CoolingType
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (CpuUsage)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/CpuUsage.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.thermal@1.0::types.CpuUsage
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (Temperature)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/Temperature.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.thermal@1.0::types.Temperature
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (TemperatureType)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/TemperatureType.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.thermal@1.0::types.TemperatureType
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (ThermalStatus)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/ThermalStatus.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.thermal@1.0::types.ThermalStatus
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (ThermalStatusCode)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/ThermalStatusCode.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.thermal@1.0::types.ThermalStatusCode
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IThermal.hal
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/IThermal.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IThermal.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.thermal@1.0::IThermal
+
+$(GEN): $(LOCAL_PATH)/IThermal.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/thermal/1.0/IThermal.hal b/thermal/1.0/IThermal.hal
new file mode 100644
index 0000000..4697f32
--- /dev/null
+++ b/thermal/1.0/IThermal.hal
@@ -0,0 +1,69 @@
+/*
+ * 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.thermal@1.0;
+
+interface IThermal {
+
+    /*
+     * Retrieves temperatures in Celsius.
+     *
+     * @return status Status of the operation. If status code is FAILURE,
+     *         the status.debugMessage must be populated with the human-readable
+     *         error message.
+     * @return temperatures If status code is SUCCESS, it's filled with the
+     *         current temperatures. The order of temperatures of built-in
+     *         devices (such as CPUs, GPUs and etc.) 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 such temperatures.
+     *
+     */
+    getTemperatures()
+        generates (ThermalStatus status, vec<Temperature> temperatures);
+
+    /*
+     * Retrieves CPU usage information of each core: active and total times
+     * in ms since first boot.
+     *
+     * @return status Status of the operation. If status code is FAILURE,
+     *         the status.debugMessage must be populated with the human-readable
+     *         error message.
+     * @return cpuUsages If status code is SUCCESS, it's filled with the current
+     *         CPU usages. The order and number of CPUs in the list must be kept
+     *         the same regardless the number of calls to this method.
+     *
+     */
+    getCpuUsages() generates (ThermalStatus status, vec<CpuUsage> cpuUsages);
+
+    /*
+     * Retrieves the cooling devices information.
+     *
+     * @return status Status of the operation. If status code is FAILURE,
+     *         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
+     *         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.
+     *
+     */
+    getCoolingDevices()
+        generates (ThermalStatus status, vec<CoolingDevice> devices);
+
+};
diff --git a/thermal/1.0/default/Android.bp b/thermal/1.0/default/Android.bp
new file mode 100644
index 0000000..626dcaf
--- /dev/null
+++ b/thermal/1.0/default/Android.bp
@@ -0,0 +1,16 @@
+cc_library_shared {
+    name: "android.hardware.thermal@1.0-impl",
+    relative_install_path: "hw",
+    srcs: ["Thermal.cpp"],
+    shared_libs: [
+        "liblog",
+        "libcutils",
+        "libhardware",
+        "libhwbinder",
+        "libbase",
+        "libcutils",
+        "libutils",
+        "libhidl",
+        "android.hardware.thermal@1.0",
+    ],
+}
diff --git a/thermal/1.0/default/Android.mk b/thermal/1.0/default/Android.mk
new file mode 100644
index 0000000..fa7414e
--- /dev/null
+++ b/thermal/1.0/default/Android.mk
@@ -0,0 +1,39 @@
+#
+# 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_RELATIVE_PATH := hw
+LOCAL_MODULE := android.hardware.thermal@1.0-service
+LOCAL_INIT_RC := android.hardware.thermal@1.0-service.rc
+LOCAL_SRC_FILES := \
+        service.cpp \
+
+LOCAL_SHARED_LIBRARIES := \
+        liblog \
+        libcutils \
+        libdl \
+        libbase \
+        libutils \
+        libhardware_legacy \
+        libhardware \
+
+LOCAL_SHARED_LIBRARIES += \
+        libhwbinder \
+        libhidl \
+        android.hardware.thermal@1.0 \
+
+include $(BUILD_EXECUTABLE)
diff --git a/thermal/1.0/default/Thermal.cpp b/thermal/1.0/default/Thermal.cpp
new file mode 100644
index 0000000..1b91687
--- /dev/null
+++ b/thermal/1.0/default/Thermal.cpp
@@ -0,0 +1,202 @@
+/*
+ * 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.thermal@1.0-impl"
+#include <utils/Log.h>
+
+#include <errno.h>
+#include <hardware/hardware.h>
+#include <hardware/thermal.h>
+
+#include "Thermal.h"
+
+namespace android {
+namespace hardware {
+namespace thermal {
+namespace V1_0 {
+namespace implementation {
+
+Thermal::Thermal(thermal_module_t* module) : mModule(module) {
+}
+
+// Methods from ::android::hardware::thermal::V1_0::IThermal follow.
+Return<void> Thermal::getTemperatures(getTemperatures_cb _hidl_cb)  {
+    ThermalStatus status;
+    status.code = ThermalStatusCode::SUCCESS;
+    hidl_vec<Temperature> temperatures;
+
+    if (!mModule || !mModule->getTemperatures) {
+        ALOGI("getTemperatures is not implemented in Thermal HAL.");
+        _hidl_cb(status, temperatures);
+        return Void();
+    }
+
+    ssize_t list_size = mModule->getTemperatures(mModule, nullptr, 0);
+    if (list_size >= 0) {
+       temperature_t *list = new temperature_t[list_size];
+       ssize_t size = mModule->getTemperatures(mModule, list, list_size);
+       if (size >= 0) {
+           if (list_size > size) {
+               list_size = size;
+           }
+
+           temperatures.resize(list_size);
+           for (ssize_t i = 0; i < list_size; ++i) {
+               switch (list[i].type) {
+                   case DEVICE_TEMPERATURE_UNKNOWN:
+                       temperatures[i].type = TemperatureType::UNKNOWN;
+                       break;
+                   case DEVICE_TEMPERATURE_CPU:
+                       temperatures[i].type = TemperatureType::CPU;
+                       break;
+                   case DEVICE_TEMPERATURE_GPU:
+                       temperatures[i].type = TemperatureType::GPU;
+                       break;
+                   case DEVICE_TEMPERATURE_BATTERY:
+                       temperatures[i].type = TemperatureType::BATTERY;
+                       break;
+                   case DEVICE_TEMPERATURE_SKIN:
+                       temperatures[i].type = TemperatureType::SKIN;
+                       break;
+                   default:
+                       ALOGE("Unknown temperature %s type", list[i].name);;
+               }
+               temperatures[i].name = list[i].name;
+               temperatures[i].currentValue = list[i].current_value;
+               temperatures[i].throttlingThreshold = list[i].throttling_threshold;
+               temperatures[i].shutdownThreshold = list[i].shutdown_threshold;
+               temperatures[i].vrThrottlingThreshold = list[i].vr_throttling_threshold;
+           }
+       } else {
+           status.code = ThermalStatusCode::FAILURE;
+           status.debugMessage = strerror(-size);
+       }
+       delete[] list;
+    } else {
+        status.code = ThermalStatusCode::FAILURE;
+        status.debugMessage = strerror(-list_size);
+    }
+    _hidl_cb(status, temperatures);
+    return Void();
+}
+
+Return<void> Thermal::getCpuUsages(getCpuUsages_cb _hidl_cb)  {
+    ThermalStatus status;
+    hidl_vec<CpuUsage> cpuUsages;
+    status.code = ThermalStatusCode::SUCCESS;
+
+    if (!mModule || !mModule->getCpuUsages) {
+        ALOGI("getCpuUsages is not implemented in Thermal HAL");
+        _hidl_cb(status, cpuUsages);
+        return Void();
+    }
+
+    ssize_t size = mModule->getCpuUsages(mModule, nullptr);
+    if (size >= 0) {
+        cpu_usage_t *list = new cpu_usage_t[size];
+        size = mModule->getCpuUsages(mModule, list);
+        if (size >= 0) {
+            cpuUsages.resize(size);
+            for (ssize_t i = 0; i < size; ++i) {
+                cpuUsages[i].name = list[i].name;
+                cpuUsages[i].active = list[i].active;
+                cpuUsages[i].total = list[i].total;
+                cpuUsages[i].isOnline = list[i].is_online;
+            }
+        } else {
+            status.code = ThermalStatusCode::FAILURE;
+            status.debugMessage = strerror(-size);
+        }
+        delete[] list;
+    } else {
+        status.code = ThermalStatusCode::FAILURE;
+        status.debugMessage = strerror(-size);
+    }
+    _hidl_cb(status, cpuUsages);
+    return Void();
+}
+
+Return<void> Thermal::getCoolingDevices(getCoolingDevices_cb _hidl_cb)  {
+    ThermalStatus status;
+    status.code = ThermalStatusCode::SUCCESS;
+    hidl_vec<CoolingDevice> coolingDevices;
+
+    if (!mModule || !mModule->getCoolingDevices) {
+        ALOGI("getCoolingDevices is not implemented in Thermal HAL.");
+        _hidl_cb(status, coolingDevices);
+        return Void();
+    }
+
+    ssize_t list_size = mModule->getCoolingDevices(mModule, nullptr, 0);
+    if (list_size >= 0) {
+        cooling_device_t *list = new cooling_device_t[list_size];
+        ssize_t size = mModule->getCoolingDevices(mModule, list, list_size);
+        if (size >= 0) {
+            if (list_size > size) {
+                list_size = size;
+            }
+            coolingDevices.resize(list_size);
+            for (ssize_t i = 0; i < list_size; ++i) {
+                switch (list[i].type) {
+                    case FAN_RPM:
+                        coolingDevices[i].type = CoolingType::FAN_RPM;
+                        break;
+                    default:
+                        ALOGE("Unknown cooling device %s type", list[i].name);
+                }
+                coolingDevices[i].name = list[i].name;
+                coolingDevices[i].currentValue = list[i].current_value;
+            }
+
+        } else {
+            status.code = ThermalStatusCode::FAILURE;
+            status.debugMessage = strerror(-size);
+        }
+        delete[] list;
+    } else {
+        status.code = ThermalStatusCode::FAILURE;
+        status.debugMessage = strerror(-list_size);
+    }
+    _hidl_cb(status, coolingDevices);
+    return Void();
+}
+
+IThermal* HIDL_FETCH_IThermal(const char* /* name */) {
+    thermal_module_t* module;
+    status_t err = hw_get_module(THERMAL_HARDWARE_MODULE_ID,
+            const_cast<hw_module_t const**>(reinterpret_cast<hw_module_t**>(&module)));
+    if (err || !module) {
+        ALOGE("Couldn't load %s module (%s)", THERMAL_HARDWARE_MODULE_ID,
+              strerror(-err));
+    }
+
+    if (err == 0 && module->common.methods->open) {
+        struct hw_device_t* device;
+        err = module->common.methods->open(&module->common, THERMAL_HARDWARE_MODULE_ID, &device);
+        if (err) {
+            ALOGE("Couldn't open %s module (%s)", THERMAL_HARDWARE_MODULE_ID, strerror(-err));
+        } else {
+            return new Thermal(reinterpret_cast<thermal_module_t*>(device));
+        }
+    }
+    return new Thermal(module);
+}
+
+} // namespace implementation
+}  // namespace V1_0
+}  // namespace thermal
+}  // namespace hardware
+}  // namespace android
diff --git a/thermal/1.0/default/Thermal.h b/thermal/1.0/default/Thermal.h
new file mode 100644
index 0000000..8212ab9
--- /dev/null
+++ b/thermal/1.0/default/Thermal.h
@@ -0,0 +1,45 @@
+#ifndef HIDL_GENERATED_android_hardware_thermal_V1_0_Thermal_H_
+#define HIDL_GENERATED_android_hardware_thermal_V1_0_Thermal_H_
+
+#include <android/hardware/thermal/1.0/IThermal.h>
+#include <hidl/Status.h>
+#include <hardware/thermal.h>
+
+#include <hidl/MQDescriptor.h>
+
+namespace android {
+namespace hardware {
+namespace thermal {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::thermal::V1_0::CoolingDevice;
+using ::android::hardware::thermal::V1_0::CpuUsage;
+using ::android::hardware::thermal::V1_0::IThermal;
+using ::android::hardware::thermal::V1_0::Temperature;
+using ::android::hardware::thermal::V1_0::ThermalStatus;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+struct Thermal : public IThermal {
+    Thermal(thermal_module_t* module);
+    // Methods from ::android::hardware::thermal::V1_0::IThermal follow.
+    Return<void> getTemperatures(getTemperatures_cb _hidl_cb)  override;
+    Return<void> getCpuUsages(getCpuUsages_cb _hidl_cb)  override;
+    Return<void> getCoolingDevices(getCoolingDevices_cb _hidl_cb)  override;
+    private:
+        thermal_module_t* mModule;
+};
+
+extern "C" IThermal* HIDL_FETCH_IThermal(const char* name);
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace thermal
+}  // namespace hardware
+}  // namespace android
+
+#endif  // HIDL_GENERATED_android_hardware_thermal_V1_0_Thermal_H_
diff --git a/thermal/1.0/default/android.hardware.thermal@1.0-service.rc b/thermal/1.0/default/android.hardware.thermal@1.0-service.rc
new file mode 100644
index 0000000..cc7ba6a
--- /dev/null
+++ b/thermal/1.0/default/android.hardware.thermal@1.0-service.rc
@@ -0,0 +1,4 @@
+service thermal-hal-1-0 /system/bin/hw/android.hardware.thermal@1.0-service
+    class hal
+    user system
+    group system readproc
diff --git a/thermal/1.0/default/service.cpp b/thermal/1.0/default/service.cpp
new file mode 100644
index 0000000..b09b5ec
--- /dev/null
+++ b/thermal/1.0/default/service.cpp
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+#include <iostream>
+#include <unistd.h>
+
+#include <android/hardware/thermal/1.0/IThermal.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;
+
+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();
+}
diff --git a/thermal/1.0/types.hal b/thermal/1.0/types.hal
new file mode 100644
index 0000000..b3dcc7d
--- /dev/null
+++ b/thermal/1.0/types.hal
@@ -0,0 +1,140 @@
+/*
+ * 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.thermal@1.0;
+
+/** Device temperature types */
+enum TemperatureType : int32_t {
+    UNKNOWN = -1,
+    CPU = 0,
+    GPU = 1,
+    BATTERY = 2,
+    SKIN = 3,
+};
+
+enum CoolingType : int32_t {
+    /** Fan cooling device speed in RPM. */
+    FAN_RPM = 0,
+};
+
+struct Temperature {
+    /**
+     * This temperature's type.
+     */
+    TemperatureType type;
+
+    /**
+     * Name of this temperature.
+     * All temperatures of the same "type" must have a different "name",
+     * e.g., cpu0, battery.
+     */
+    string name;
+
+    /**
+     * Current temperature in Celsius. If not available set by HAL to
+     * UNKNOWN_TEMPERATURE.
+     * Current temperature can be in any units if type=UNKNOWN.
+     */
+    float currentValue;
+
+    /**
+     * Throttling temperature constant for this temperature.
+     * If not available, set by HAL to UNKNOWN_TEMPERATURE.
+     */
+    float throttlingThreshold;
+
+    /**
+     * Shutdown temperature constant for this temperature.
+     * If not available, set by HAL to UNKNOWN_TEMPERATURE.
+     */
+    float shutdownThreshold;
+
+    /**
+     * Threshold temperature above which the VR mode clockrate minimums cannot
+     * be maintained for this device.
+     * If not available, set by HAL to UNKNOWN_TEMPERATURE.
+     */
+    float vrThrottlingThreshold;
+
+};
+
+struct CoolingDevice {
+    /**
+     * This cooling device type.
+     */
+    CoolingType type;
+
+    /**
+     * Name of this cooling device.
+     * All cooling devices of the same "type" must have a different "name".
+     */
+    string name;
+
+    /**
+     * Current cooling device value. Units depend on cooling device "type".
+     */
+    float currentValue;
+
+};
+
+struct CpuUsage {
+    /**
+     * Name of this CPU.
+     * All CPUs must have a different "name".
+     */
+    string name;
+
+    /**
+     * Active time since the last boot in ms.
+     */
+    uint64_t active;
+
+    /**
+     * Total time since the last boot in ms.
+     */
+    uint64_t total;
+
+    /**
+     * Is set to true when a core is online.
+     * If the core is offline, all other members except |name| should be ignored.
+     */
+    bool isOnline;
+
+};
+
+enum ThermalStatusCode : uint32_t {
+    /** No errors. */
+    SUCCESS,
+    /** Unknown failure occured. */
+    FAILURE
+};
+
+/**
+ * Generic structure to return the status of any thermal operation.
+ */
+struct ThermalStatus {
+    ThermalStatusCode code;
+
+    /**
+     * A specific error message to provide more information.
+     * This can be used for debugging purposes only.
+     */
+    string debugMessage;
+};
+
+/**
+ * TODO(pbond): add float constant UNDEFINED_TEMPERATURE.
+ */