Merge "Add analog force mode for analog/digital hybrid modes."
diff --git a/audio/2.0/IDevice.hal b/audio/2.0/IDevice.hal
index 2b5329b..62c2081 100644
--- a/audio/2.0/IDevice.hal
+++ b/audio/2.0/IDevice.hal
@@ -23,14 +23,14 @@
 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.
@@ -40,7 +40,7 @@
      */
     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
@@ -52,7 +52,7 @@
      */
     getMasterVolume() generates (Result retval, float volume);
 
-    /*
+    /**
      * Sets microphone muting state.
      *
      * @param mute whether microphone is muted.
@@ -60,7 +60,7 @@
      */
     setMicMute(bool mute) generates (Result retval);
 
-    /*
+    /**
      * Gets whether microphone is muted.
      *
      * @return retval operation completion status.
@@ -68,7 +68,7 @@
      */
     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.
      *
@@ -89,7 +89,7 @@
      */
     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.
      *
@@ -100,7 +100,7 @@
     getInputBufferSize(AudioConfig config)
             generates (Result retval, uint64_t bufferSize);
 
-    /*
+    /**
      * This method creates and opens the audio hardware output stream.
      * If the stream can not be opened with the proposed audio config,
      * HAL must provide suggested values for the audio config.
@@ -122,7 +122,7 @@
                     IStreamOut outStream,
                     AudioConfig suggestedConfig);
 
-    /*
+    /**
      * This method creates and opens the audio hardware input stream.
      * If the stream can not be opened with the proposed audio config,
      * HAL must provide suggested values for the audio config.
@@ -146,14 +146,14 @@
                     IStreamIn inStream,
                     AudioConfig suggestedConfig);
 
-    /*
+    /**
      * Returns whether HAL supports audio patches.
      *
      * @return supports true if audio patches are supported.
      */
     supportsAudioPatches() generates (bool supports);
 
-    /*
+    /**
      * 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.
      *
@@ -165,7 +165,7 @@
     createAudioPatch(vec<AudioPortConfig> sources, vec<AudioPortConfig> sinks)
             generates (Result retval, AudioPatchHandle patch);
 
-    /*
+    /**
      * Release an audio patch.
      *
      * @param patch patch handle.
@@ -173,7 +173,7 @@
      */
     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...)
@@ -189,7 +189,7 @@
     getAudioPort(AudioPort port)
             generates (Result retval, AudioPort resultPort);
 
-    /*
+    /**
      * Set audio port configuration.
      *
      * @param config audio port configuration.
@@ -197,7 +197,7 @@
      */
     setAudioPortConfig(AudioPortConfig config) generates (Result retval);
 
-    /*
+    /**
      * Gets the HW synchronization source of the device. Calling this method is
      * equivalent to getting AUDIO_PARAMETER_HW_AV_SYNC on the legacy HAL.
      *
@@ -205,7 +205,7 @@
      */
     getHwAvSync() generates (AudioHwSync hwAvSync);
 
-    /*
+    /**
      * Sets whether the screen is on. Calling this method is equivalent to
      * setting AUDIO_PARAMETER_KEY_SCREEN_STATE on the legacy HAL.
      *
@@ -214,7 +214,7 @@
      */
     setScreenState(bool turnedOn) 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.
@@ -226,7 +226,7 @@
     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.
@@ -236,7 +236,7 @@
      */
     setParameters(vec<ParameterValue> parameters) generates (Result retval);
 
-    /*
+    /**
      * Dumps information about the stream into the provided file descriptor.
      * This is used for the dumpsys facility.
      *
diff --git a/audio/2.0/IDevicesFactory.hal b/audio/2.0/IDevicesFactory.hal
index 0ef6bc5..6bbe7a1 100644
--- a/audio/2.0/IDevicesFactory.hal
+++ b/audio/2.0/IDevicesFactory.hal
@@ -30,7 +30,7 @@
         STUB
     };
 
-    /*
+    /**
      * Opens an audio device. To close the device, it is necessary to release
      * references to the returned device object.
      *
diff --git a/audio/2.0/IPrimaryDevice.hal b/audio/2.0/IPrimaryDevice.hal
index f1dd56e..adeb366 100644
--- a/audio/2.0/IPrimaryDevice.hal
+++ b/audio/2.0/IPrimaryDevice.hal
@@ -22,7 +22,7 @@
 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.
@@ -30,7 +30,7 @@
      */
     setVoiceVolume(float volume) generates (Result retval);
 
-    /*
+    /**
      * This method is used to notify the HAL about audio mode changes.
      *
      * @param mode new mode.
@@ -38,7 +38,7 @@
      */
     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.
@@ -48,7 +48,7 @@
      */
     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.
@@ -58,7 +58,7 @@
      */
     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.
      *
@@ -67,7 +67,7 @@
      */
     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.
      *
@@ -83,7 +83,7 @@
         FULL
     };
 
-    /*
+    /**
      * Gets current TTY mode selection. Calling this method is equivalent to
      * getting AUDIO_PARAMETER_KEY_TTY_MODE on the legacy HAL.
      *
@@ -92,7 +92,7 @@
      */
     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.
      *
@@ -101,7 +101,7 @@
      */
     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.
@@ -111,7 +111,7 @@
      */
     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.
diff --git a/audio/2.0/IStream.hal b/audio/2.0/IStream.hal
index 8de7851..2b9cc06 100644
--- a/audio/2.0/IStream.hal
+++ b/audio/2.0/IStream.hal
@@ -22,14 +22,14 @@
 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.
      *
@@ -37,7 +37,7 @@
      */
     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.
      *
@@ -45,14 +45,14 @@
      */
     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.
@@ -61,7 +61,7 @@
      */
     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.
      *
@@ -70,14 +70,14 @@
      */
     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.
@@ -86,7 +86,7 @@
      */
     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.
      *
@@ -95,14 +95,14 @@
      */
     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.
@@ -111,7 +111,7 @@
      */
     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.
      *
@@ -120,7 +120,7 @@
      */
     setFormat(AudioFormat format) generates (Result retval);
 
-    /*
+    /**
      * Convenience method for retrieving several stream parameters in
      * one transaction.
      *
@@ -131,7 +131,7 @@
     getAudioProperties() generates (
             uint32_t sampleRateHz, AudioChannelMask mask, AudioFormat format);
 
-    /*
+    /**
      * Applies audio effect to the stream.
      *
      * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
@@ -140,7 +140,7 @@
      */
     addEffect(uint64_t effectId) generates (Result retval);
 
-    /*
+    /**
      * Stops application of the effect to the stream.
      *
      * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
@@ -149,7 +149,7 @@
      */
     removeEffect(uint64_t effectId) generates (Result retval);
 
-    /*
+    /**
      * Put the audio hardware input/output into standby mode.
      * Driver must exit from standby mode at the next I/O operation.
      *
@@ -157,14 +157,14 @@
      */
     standby() generates (Result retval);
 
-    /*
+    /**
      * Return the set of device(s) which this stream is connected to.
      *
      * @return device set of device(s) which this stream is connected to.
      */
     getDevice() generates (AudioDevice device);
 
-    /*
+    /**
      * Connects the stream to the device.
      *
      * This method must only be used for HALs that do not support
@@ -177,7 +177,7 @@
      */
     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.
@@ -189,7 +189,7 @@
     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.
      *
@@ -198,7 +198,7 @@
      */
     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.
@@ -210,7 +210,7 @@
     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.
@@ -220,7 +220,7 @@
      */
     setParameters(vec<ParameterValue> parameters) generates (Result retval);
 
-    /*
+    /**
      * Dumps information about the stream into the provided file descriptor.
      * This is used for the dumpsys facility.
      *
@@ -228,7 +228,7 @@
      */
     debugDump(handle fd);
 
-    /*
+    /**
      * Called by the framework to start a stream operating in mmap mode.
      * createMmapBuffer() must be called before calling start().
      * Function only implemented by streams operating in mmap mode.
@@ -249,7 +249,7 @@
      */
     stop() generates (Result retval) ;
 
-    /*
+    /**
      * Called by the framework to retrieve information on the mmap buffer used for audio
      * samples transfer.
      * Function only implemented by streams operating in mmap mode.
@@ -266,7 +266,7 @@
     createMmapBuffer(int32_t minSizeFrames)
             generates (Result retval, MmapBufferInfo info);
 
-    /*
+    /**
      * Called by the framework to read current read/write position in the mmap buffer
      * with associated time stamp.
      * Function only implemented by streams operating in mmap mode.
@@ -280,7 +280,7 @@
     getMmapPosition()
             generates (Result retval, MmapPosition position);
 
-    /*
+    /**
      * Called by the framework to deinitialize the stream and free up
      * all the currently allocated resources. It is recommended to close
      * the stream on the client side as soon as it is becomes unused.
diff --git a/audio/2.0/IStreamIn.hal b/audio/2.0/IStreamIn.hal
index 6f1f9df..6b79f48 100644
--- a/audio/2.0/IStreamIn.hal
+++ b/audio/2.0/IStreamIn.hal
@@ -22,7 +22,7 @@
 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.
@@ -32,7 +32,7 @@
      */
     getAudioSource() generates (Result retval, AudioSource source);
 
-    /*
+    /**
      * Set the input gain for the audio driver.
      *
      * @param gain 1.0f is unity, 0.0f is zero.
@@ -40,7 +40,7 @@
      */
     setGain(float gain) generates (Result retval);
 
-    /*
+    /**
      * Commands that can be executed on the driver reader thread.
      */
     enum ReadCommand : int32_t {
@@ -48,7 +48,7 @@
         GET_CAPTURE_POSITION
     };
 
-    /*
+    /**
      * Data structure passed to the driver for executing commands
      * on the driver reader thread.
      */
@@ -60,7 +60,7 @@
         } params;
     };
 
-    /*
+    /**
      * Data structure passed back to the client via status message queue
      * of 'read' operation.
      *
@@ -81,7 +81,7 @@
         } reply;
     };
 
-    /*
+    /**
      * Set up required transports for receiving audio buffers from the driver.
      *
      * The transport consists of three message queues:
@@ -119,7 +119,7 @@
             fmq_sync<ReadStatus> statusMQ,
             ThreadInfo threadInfo);
 
-    /*
+    /**
      * Return the amount of input frames lost in the audio driver since the last
      * call of this function.
      *
diff --git a/audio/2.0/IStreamOut.hal b/audio/2.0/IStreamOut.hal
index 9ee32c5..84b7447 100644
--- a/audio/2.0/IStreamOut.hal
+++ b/audio/2.0/IStreamOut.hal
@@ -23,14 +23,14 @@
 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.
@@ -43,7 +43,7 @@
      */
     setVolume(float left, float right) generates (Result retval);
 
-    /*
+    /**
      * Commands that can be executed on the driver writer thread.
      */
     enum WriteCommand : int32_t {
@@ -52,7 +52,7 @@
         GET_LATENCY
     };
 
-    /*
+    /**
      * Data structure passed back to the client via status message queue
      * of 'write' operation.
      *
@@ -75,7 +75,7 @@
         } reply;
     };
 
-    /*
+    /**
      * Set up required transports for passing audio buffers to the driver.
      *
      * The transport consists of three message queues:
@@ -112,7 +112,7 @@
             fmq_sync<WriteStatus> statusMQ,
             ThreadInfo threadInfo);
 
-    /*
+    /**
      * Return the number of audio frames written by the audio DSP to DAC since
      * the output has exited standby.
      *
@@ -121,7 +121,7 @@
      */
     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.
@@ -131,7 +131,7 @@
      */
     getNextWriteTimestamp() generates (Result retval, int64_t timestampUs);
 
-    /*
+    /**
      * Set the callback interface for notifying completion of non-blocking
      * write and drain.
      *
@@ -146,7 +146,7 @@
      */
     setCallback(IStreamOutCallback callback) generates (Result retval);
 
-    /*
+    /**
      * Clears the callback previously set via 'setCallback' method.
      *
      * Warning: failure to call this method results in callback implementation
@@ -156,7 +156,7 @@
      */
     clearCallback() generates (Result retval);
 
-    /*
+    /**
      * Returns whether HAL supports pausing and resuming of streams.
      *
      * @return supportsPause true if pausing is supported.
@@ -179,7 +179,7 @@
      */
     pause() generates (Result retval);
 
-    /*
+    /**
      * Notifies to the audio driver to resume playback following a pause.
      * Returns error INVALID_STATE if called without matching pause.
      *
@@ -189,7 +189,7 @@
      */
     resume() generates (Result retval);
 
-    /*
+    /**
      * Returns whether HAL supports draining of streams.
      *
      * @return supports true if draining is supported.
@@ -220,7 +220,7 @@
      */
     drain(AudioDrain type) generates (Result retval);
 
-    /*
+    /**
      * Notifies to the audio driver to flush the queued data. Stream must
      * already be paused before calling 'flush'.
      *
@@ -230,7 +230,7 @@
      */
     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
diff --git a/audio/2.0/IStreamOutCallback.hal b/audio/2.0/IStreamOutCallback.hal
index cdb38de..01e123c 100644
--- a/audio/2.0/IStreamOutCallback.hal
+++ b/audio/2.0/IStreamOutCallback.hal
@@ -16,21 +16,21 @@
 
 package android.hardware.audio@2.0;
 
-/*
+/**
  * Asynchronous write callback interface.
  */
 interface IStreamOutCallback {
-    /*
+    /**
      * Non blocking write completed.
      */
     oneway onWriteReady();
 
-    /*
+    /**
      * Drain completed.
      */
     oneway onDrainReady();
 
-    /*
+    /**
      * Stream hit an error.
      */
     oneway onError();
diff --git a/audio/2.0/default/Device.cpp b/audio/2.0/default/Device.cpp
index 8a51cd7..5ced0bc 100644
--- a/audio/2.0/default/Device.cpp
+++ b/audio/2.0/default/Device.cpp
@@ -59,6 +59,14 @@
     }
 }
 
+void Device::closeInputStream(audio_stream_in_t* stream) {
+    mDevice->close_input_stream(mDevice, stream);
+}
+
+void Device::closeOutputStream(audio_stream_out_t* stream) {
+    mDevice->close_output_stream(mDevice, stream);
+}
+
 char* Device::halGetParameters(const char* keys) {
     return mDevice->get_parameters(mDevice, keys);
 }
@@ -160,7 +168,7 @@
     ALOGV("open_output_stream status %d stream %p", status, halStream);
     sp<IStreamOut> streamOut;
     if (status == OK) {
-        streamOut = new StreamOut(mDevice, halStream);
+        streamOut = new StreamOut(this, halStream);
     }
     AudioConfig suggestedConfig;
     HidlUtils::audioConfigFromHal(halConfig, &suggestedConfig);
@@ -196,7 +204,7 @@
     ALOGV("open_input_stream status %d stream %p", status, halStream);
     sp<IStreamIn> streamIn;
     if (status == OK) {
-        streamIn = new StreamIn(mDevice, halStream);
+        streamIn = new StreamIn(this, halStream);
     }
     AudioConfig suggestedConfig;
     HidlUtils::audioConfigFromHal(halConfig, &suggestedConfig);
diff --git a/audio/2.0/default/Device.h b/audio/2.0/default/Device.h
index 46177fc..7738361 100644
--- a/audio/2.0/default/Device.h
+++ b/audio/2.0/default/Device.h
@@ -98,6 +98,8 @@
 
     // Utility methods for extending interfaces.
     Result analyzeStatus(const char* funcName, int status);
+    void closeInputStream(audio_stream_in_t* stream);
+    void closeOutputStream(audio_stream_out_t* stream);
     audio_hw_device_t* device() const { return mDevice; }
 
   private:
diff --git a/audio/2.0/default/StreamIn.cpp b/audio/2.0/default/StreamIn.cpp
index b641e82..2745607 100644
--- a/audio/2.0/default/StreamIn.cpp
+++ b/audio/2.0/default/StreamIn.cpp
@@ -135,7 +135,7 @@
 
 }  // namespace
 
-StreamIn::StreamIn(audio_hw_device_t* device, audio_stream_in_t* stream)
+StreamIn::StreamIn(const sp<Device>& device, audio_stream_in_t* stream)
         : mIsClosed(false), mDevice(device), mStream(stream),
           mStreamCommon(new Stream(&stream->common)),
           mStreamMmap(new StreamMmap<audio_stream_in_t>(stream)),
@@ -154,9 +154,8 @@
         status_t status = EventFlag::deleteEventFlag(&mEfGroup);
         ALOGE_IF(status, "read MQ event flag deletion error: %s", strerror(-status));
     }
-    mDevice->close_input_stream(mDevice, mStream);
+    mDevice->closeInputStream(mStream);
     mStream = nullptr;
-    mDevice = nullptr;
 }
 
 // Methods from ::android::hardware::audio::V2_0::IStream follow.
diff --git a/audio/2.0/default/StreamIn.h b/audio/2.0/default/StreamIn.h
index b867387..950d68f 100644
--- a/audio/2.0/default/StreamIn.h
+++ b/audio/2.0/default/StreamIn.h
@@ -27,6 +27,7 @@
 #include <hidl/Status.h>
 #include <utils/Thread.h>
 
+#include "Device.h"
 #include "Stream.h"
 
 namespace android {
@@ -55,7 +56,7 @@
     typedef MessageQueue<uint8_t, kSynchronizedReadWrite> DataMQ;
     typedef MessageQueue<ReadStatus, kSynchronizedReadWrite> StatusMQ;
 
-    StreamIn(audio_hw_device_t* device, audio_stream_in_t* stream);
+    StreamIn(const sp<Device>& device, audio_stream_in_t* stream);
 
     // Methods from ::android::hardware::audio::V2_0::IStream follow.
     Return<uint64_t> getFrameSize()  override;
@@ -101,10 +102,10 @@
 
   private:
     bool mIsClosed;
-    audio_hw_device_t *mDevice;
+    const sp<Device> mDevice;
     audio_stream_in_t *mStream;
-    sp<Stream> mStreamCommon;
-    sp<StreamMmap<audio_stream_in_t>> mStreamMmap;
+    const sp<Stream> mStreamCommon;
+    const sp<StreamMmap<audio_stream_in_t>> mStreamMmap;
     std::unique_ptr<CommandMQ> mCommandMQ;
     std::unique_ptr<DataMQ> mDataMQ;
     std::unique_ptr<StatusMQ> mStatusMQ;
diff --git a/audio/2.0/default/StreamOut.cpp b/audio/2.0/default/StreamOut.cpp
index d820f3c..88045a0 100644
--- a/audio/2.0/default/StreamOut.cpp
+++ b/audio/2.0/default/StreamOut.cpp
@@ -135,7 +135,7 @@
 
 }  // namespace
 
-StreamOut::StreamOut(audio_hw_device_t* device, audio_stream_out_t* stream)
+StreamOut::StreamOut(const sp<Device>& device, audio_stream_out_t* stream)
         : mIsClosed(false), mDevice(device), mStream(stream),
           mStreamCommon(new Stream(&stream->common)),
           mStreamMmap(new StreamMmap<audio_stream_out_t>(stream)),
@@ -155,9 +155,8 @@
         ALOGE_IF(status, "write MQ event flag deletion error: %s", strerror(-status));
     }
     mCallback.clear();
-    mDevice->close_output_stream(mDevice, mStream);
+    mDevice->closeOutputStream(mStream);
     mStream = nullptr;
-    mDevice = nullptr;
 }
 
 // Methods from ::android::hardware::audio::V2_0::IStream follow.
diff --git a/audio/2.0/default/StreamOut.h b/audio/2.0/default/StreamOut.h
index bbe64a1..99352bc 100644
--- a/audio/2.0/default/StreamOut.h
+++ b/audio/2.0/default/StreamOut.h
@@ -27,6 +27,7 @@
 #include <fmq/MessageQueue.h>
 #include <utils/Thread.h>
 
+#include "Device.h"
 #include "Stream.h"
 
 namespace android {
@@ -57,7 +58,7 @@
     typedef MessageQueue<uint8_t, kSynchronizedReadWrite> DataMQ;
     typedef MessageQueue<WriteStatus, kSynchronizedReadWrite> StatusMQ;
 
-    StreamOut(audio_hw_device_t* device, audio_stream_out_t* stream);
+    StreamOut(const sp<Device>& device, audio_stream_out_t* stream);
 
     // Methods from ::android::hardware::audio::V2_0::IStream follow.
     Return<uint64_t> getFrameSize()  override;
@@ -112,10 +113,10 @@
 
   private:
     bool mIsClosed;
-    audio_hw_device_t *mDevice;
+    const sp<Device> mDevice;
     audio_stream_out_t *mStream;
-    sp<Stream> mStreamCommon;
-    sp<StreamMmap<audio_stream_out_t>> mStreamMmap;
+    const sp<Stream> mStreamCommon;
+    const sp<StreamMmap<audio_stream_out_t>> mStreamMmap;
     sp<IStreamOutCallback> mCallback;
     std::unique_ptr<CommandMQ> mCommandMQ;
     std::unique_ptr<DataMQ> mDataMQ;
diff --git a/audio/2.0/types.hal b/audio/2.0/types.hal
index 8e9ff14..93118c2 100644
--- a/audio/2.0/types.hal
+++ b/audio/2.0/types.hal
@@ -28,14 +28,16 @@
 
 @export(name="audio_drain_type_t", value_prefix="AUDIO_DRAIN_")
 enum AudioDrain : int32_t {
-    /* drain() returns when all data has been played. */
+    /** 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. */
+    /**
+     * 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 {
@@ -43,7 +45,7 @@
     uint64_t tvNSec;  // nanoseconds
 };
 
-/*
+/**
  * IEEE 802 MAC address.
  */
 typedef uint8_t[6] MacAddress;
@@ -53,7 +55,7 @@
     string value;
 };
 
-/*
+/**
  * Specifies a device in case when several devices of the same type
  * can be connected (e.g. BT A2DP, USB).
  */
@@ -71,7 +73,7 @@
     string rSubmixAddress;  // used for REMOTE_SUBMIX
 };
 
-/*
+/**
  * Mmap buffer descriptor returned by IStream.createMmapBuffer().
  * Used by streams opened in mmap mode.
  */
@@ -81,7 +83,7 @@
     int32_t burstSizeFrames;      // transfer size granularity in frames
 };
 
-/*
+/**
  * Mmap buffer read/write position returned by IStream.getMmapPosition().
  * Used by streams opened in mmap mode.
  */
@@ -90,7 +92,7 @@
     int32_t  positionFrames;  // increasing 32 bit frame count reset when IStream.stop() is called
 };
 
-/*
+/**
  * The message queue flags used to synchronize reads and writes from
  * message queues used by StreamIn and StreamOut.
  */
diff --git a/audio/common/2.0/types.hal b/audio/common/2.0/types.hal
index dd7281d..7c49795 100644
--- a/audio/common/2.0/types.hal
+++ b/audio/common/2.0/types.hal
@@ -16,28 +16,28 @@
 
 package android.hardware.audio.common@2.0;
 
-/*
+/**
  *
  *  IDs and Handles
  *
  */
 
-/*
+/**
  * Handle type for identifying audio sources and sinks.
  */
 typedef int32_t AudioIoHandle;
 
-/*
+/**
  * Audio hw module handle functions or structures referencing a module.
  */
 typedef int32_t AudioModuleHandle;
 
-/*
+/**
  * Each port has a unique ID or handle allocated by policy manager.
  */
 typedef int32_t AudioPortHandle;
 
-/*
+/**
  * Each patch is identified by a handle at the interface used to create that
  * patch. For instance, when a patch is created by the audio HAL, the HAL
  * allocates and returns a handle.  This handle is unique to a given audio HAL
@@ -47,12 +47,12 @@
  */
 typedef int32_t AudioPatchHandle;
 
-/*
+/**
  * A HW synchronization source returned by the audio HAL.
  */
 typedef uint32_t AudioHwSync;
 
-/*
+/**
  * Each port has a unique ID or handle allocated by policy manager.
  */
 @export(name="")
@@ -63,7 +63,7 @@
     AUDIO_PATCH_HANDLE_NONE = 0,
 };
 
-/*
+/**
  * Commonly used structure for passing unique identifieds (UUID).
  * For the definition of UUID, refer to ITU-T X.667 spec.
  */
@@ -76,13 +76,13 @@
 };
 
 
-/*
+/**
  *
  *  Audio streams
  *
  */
 
-/*
+/**
  * Audio stream type describing the intented use case of a stream.
  */
 @export(name="audio_stream_type_t", value_prefix="AUDIO_STREAM_")
@@ -126,13 +126,13 @@
     CAMCORDER           = 5,
     VOICE_RECOGNITION   = 6,
     VOICE_COMMUNICATION = 7,
-    /*
+    /**
      * Source for the mix to be presented remotely. An example of remote
      * presentation is Wifi Display where a dongle attached to a TV can be used
      * to play the mix captured by this audio source.
      */
     REMOTE_SUBMIX       = 8,
-    /*
+    /**
      * Source for unprocessed sound. Usage examples include level measurement
      * and raw signal analysis.
      */
@@ -141,7 +141,7 @@
     CNT,
     MAX                 = CNT - 1,
     FM_TUNER            = 1998,
-    /*
+    /**
      * A low-priority, preemptible audio source for for background software
      * hotword detection. Same tuning as VOICE_RECOGNITION.  Used only
      * internally by the framework.
@@ -150,30 +150,30 @@
 };
 
 typedef int32_t AudioSession;
-/*
+/**
  * Special audio session values.
  */
 @export(name="audio_session_t", value_prefix="AUDIO_SESSION_")
 enum AudioSessionConsts : int32_t {
-    /*
+    /**
      * Session for effects attached to a particular output stream
      * (value must be less than 0)
      */
     OUTPUT_STAGE = -1,
-    /*
+    /**
      * Session for effects applied to output mix. These effects can
      * be moved by audio policy manager to another output stream
      * (value must be 0)
      */
     OUTPUT_MIX = 0,
-    /*
+    /**
      * Application does not specify an explicit session ID to be used, and
      * requests a new session ID to be allocated. Corresponds to
      * AudioManager.AUDIO_SESSION_ID_GENERATE and
      * AudioSystem.AUDIO_SESSION_ALLOCATE.
      */
     ALLOCATE = 0,
-    /*
+    /**
      * For use with AudioRecord::start(), this indicates no trigger session.
      * It is also used with output tracks and patch tracks, which never have a
      * session.
@@ -181,7 +181,7 @@
     NONE = 0
 };
 
-/*
+/**
  * Audio format  is a 32-bit word that consists of:
  *   main format field (upper 8 bits)
  *   sub format field (lower 24 bits).
@@ -196,13 +196,13 @@
 enum AudioFormat : uint32_t {
     INVALID             = 0xFFFFFFFFUL,
     DEFAULT             = 0,
-    PCM                 = 0x00000000UL, /* DO NOT CHANGE */
+    PCM                 = 0x00000000UL, /** DO NOT CHANGE */
     MP3                 = 0x01000000UL,
     AMR_NB              = 0x02000000UL,
     AMR_WB              = 0x03000000UL,
     AAC                 = 0x04000000UL,
-    HE_AAC_V1           = 0x05000000UL, /* Deprecated, Use AAC_HE_V1*/
-    HE_AAC_V2           = 0x06000000UL, /* Deprecated, Use AAC_HE_V2*/
+    HE_AAC_V1           = 0x05000000UL, /** Deprecated, Use AAC_HE_V1 */
+    HE_AAC_V2           = 0x06000000UL, /** Deprecated, Use AAC_HE_V2 */
     VORBIS              = 0x07000000UL,
     OPUS                = 0x08000000UL,
     AC3                 = 0x09000000UL,
@@ -232,10 +232,10 @@
     APTX_HD             = 0x21000000UL,
     AC4                 = 0x22000000UL,
     LDAC                = 0x23000000UL,
-    MAIN_MASK           = 0xFF000000UL, /* Deprecated */
+    MAIN_MASK           = 0xFF000000UL, /** Deprecated */
     SUB_MASK            = 0x00FFFFFFUL,
 
-    /* Subformats */
+    /** Subformats */
     PCM_SUB_16_BIT        = 0x1, // PCM signed 16 bits
     PCM_SUB_8_BIT         = 0x2, // PCM unsigned 8 bits
     PCM_SUB_32_BIT        = 0x3, // PCM signed .31 fixed point
@@ -260,10 +260,10 @@
 
     VORBIS_SUB_NONE       = 0x0,
 
-    /* Aliases */
-    /* note != AudioFormat.ENCODING_PCM_16BIT */
+    /** Aliases */
+    /** note != AudioFormat.ENCODING_PCM_16BIT */
     PCM_16_BIT          = (PCM | PCM_SUB_16_BIT),
-    /* note != AudioFormat.ENCODING_PCM_8BIT */
+    /** note != AudioFormat.ENCODING_PCM_8BIT */
     PCM_8_BIT           = (PCM | PCM_SUB_8_BIT),
     PCM_32_BIT          = (PCM | PCM_SUB_32_BIT),
     PCM_8_24_BIT        = (PCM | PCM_SUB_8_24_BIT),
@@ -291,7 +291,7 @@
     AAC_ADTS_ELD        = (AAC_ADTS | AAC_SUB_ELD)
 };
 
-/*
+/**
  * Usage of these values highlights places in the code that use 2- or 8- channel
  * assumptions.
  */
@@ -301,7 +301,7 @@
     FCC_8 = 8  // This is typically due to audio mixer and resampler limitations
 };
 
-/*
+/**
  * A channel mask per se only defines the presence or absence of a channel, not
  * the order.  See AUDIO_INTERLEAVE_* for the platform convention of order.
  *
@@ -335,21 +335,21 @@
  */
 @export(name="", value_prefix="AUDIO_CHANNEL_")
 enum AudioChannelMask : uint32_t {
-    REPRESENTATION_POSITION = 0, /* must be 0 for compatibility */
-    /* 1 is reserved for future use */
+    REPRESENTATION_POSITION = 0, /** must be 0 for compatibility */
+    /** 1 is reserved for future use */
     REPRESENTATION_INDEX    = 2,
-    /* 3 is reserved for future use */
+    /** 3 is reserved for future use */
 
-    /* These can be a complete value of AudioChannelMask */
+    /** These can be a complete value of AudioChannelMask */
     NONE                      = 0x0,
     INVALID                   = 0xC0000000,
 
-   /*
+   /**
     * These can be the bits portion of an AudioChannelMask
     * with representation REPRESENTATION_POSITION.
     */
 
-    /* output channels */
+    /** output channels */
     OUT_FRONT_LEFT            = 0x1,
     OUT_FRONT_RIGHT           = 0x2,
     OUT_FRONT_CENTER          = 0x4,
@@ -375,7 +375,7 @@
     OUT_QUAD     = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
             OUT_BACK_LEFT | OUT_BACK_RIGHT),
     OUT_QUAD_BACK = OUT_QUAD,
-    /* like OUT_QUAD_BACK with *_SIDE_* instead of *_BACK_* */
+    /** like OUT_QUAD_BACK with *_SIDE_* instead of *_BACK_* */
     OUT_QUAD_SIDE = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
             OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
     OUT_SURROUND = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
@@ -385,7 +385,7 @@
             OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
             OUT_BACK_LEFT | OUT_BACK_RIGHT),
     OUT_5POINT1_BACK = OUT_5POINT1,
-    /* like OUT_5POINT1_BACK with *_SIDE_* instead of *_BACK_* */
+    /** like OUT_5POINT1_BACK with *_SIDE_* instead of *_BACK_* */
     OUT_5POINT1_SIDE = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
             OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
             OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
@@ -393,7 +393,7 @@
             OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
             OUT_BACK_LEFT | OUT_BACK_RIGHT |
             OUT_BACK_CENTER),
-    /* matches the correct AudioFormat.CHANNEL_OUT_7POINT1_SURROUND */
+    /** matches the correct AudioFormat.CHANNEL_OUT_7POINT1_SURROUND */
     OUT_7POINT1  = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
             OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
             OUT_BACK_LEFT | OUT_BACK_RIGHT |
@@ -408,9 +408,9 @@
             OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_CENTER | OUT_TOP_FRONT_RIGHT |
             OUT_TOP_BACK_LEFT | OUT_TOP_BACK_CENTER | OUT_TOP_BACK_RIGHT),
 
-    /* These are bits only, not complete values */
+    /** These are bits only, not complete values */
 
-    /* input channels */
+    /** input channels */
     IN_LEFT            = 0x4,
     IN_RIGHT           = 0x8,
     IN_FRONT           = 0x10,
@@ -456,7 +456,7 @@
 };
 
 
-/*
+/**
  * Expresses the convention when stereo audio samples are stored interleaved
  * in an array.  This should improve readability by allowing code to use
  * symbolic indices instead of hard-coded [0] and [1].
@@ -472,7 +472,7 @@
     RIGHT  = 1,
 };
 
-/*
+/**
  * Major modes for a mobile device. The current mode setting affects audio
  * routing.
  */
@@ -492,10 +492,10 @@
 @export(name="", value_prefix="AUDIO_DEVICE_")
 enum AudioDevice : uint32_t {
     NONE                          = 0x0,
-    /* reserved bits */
+    /** reserved bits */
     BIT_IN                        = 0x80000000,
     BIT_DEFAULT                   = 0x40000000,
-    /* output devices */
+    /** output devices */
     OUT_EARPIECE                  = 0x1,
     OUT_SPEAKER                   = 0x2,
     OUT_WIRED_HEADSET             = 0x4,
@@ -508,30 +508,30 @@
     OUT_BLUETOOTH_A2DP_SPEAKER    = 0x200,
     OUT_AUX_DIGITAL               = 0x400,
     OUT_HDMI                      = OUT_AUX_DIGITAL,
-    /* uses an analog connection (multiplexed over the USB pins for instance) */
+    /** uses an analog connection (multiplexed over the USB pins for instance) */
     OUT_ANLG_DOCK_HEADSET         = 0x800,
     OUT_DGTL_DOCK_HEADSET         = 0x1000,
-    /* USB accessory mode: Android device is USB device and dock is USB host */
+    /** USB accessory mode: Android device is USB device and dock is USB host */
     OUT_USB_ACCESSORY             = 0x2000,
-    /* USB host mode: Android device is USB host and dock is USB device */
+    /** USB host mode: Android device is USB host and dock is USB device */
     OUT_USB_DEVICE                = 0x4000,
     OUT_REMOTE_SUBMIX             = 0x8000,
-    /* Telephony voice TX path */
+    /** Telephony voice TX path */
     OUT_TELEPHONY_TX              = 0x10000,
-    /* Analog jack with line impedance detected */
+    /** Analog jack with line impedance detected */
     OUT_LINE                      = 0x20000,
-    /* HDMI Audio Return Channel */
+    /** HDMI Audio Return Channel */
     OUT_HDMI_ARC                  = 0x40000,
-    /* S/PDIF out */
+    /** S/PDIF out */
     OUT_SPDIF                     = 0x80000,
-    /* FM transmitter out */
+    /** FM transmitter out */
     OUT_FM                        = 0x100000,
-    /* Line out for av devices */
+    /** Line out for av devices */
     OUT_AUX_LINE                  = 0x200000,
-    /* limited-output speaker device for acoustic safety */
+    /** limited-output speaker device for acoustic safety */
     OUT_SPEAKER_SAFE              = 0x400000,
     OUT_IP                        = 0x800000,
-    /* audio bus implemented by the audio system (e.g an MOST stereo channel) */
+    /** audio bus implemented by the audio system (e.g an MOST stereo channel) */
     OUT_BUS                       = 0x1000000,
     OUT_PROXY                     = 0x2000000,
     OUT_USB_HEADSET               = 0x4000000,
@@ -571,7 +571,7 @@
             OUT_BLUETOOTH_SCO_HEADSET |
             OUT_BLUETOOTH_SCO_CARKIT),
     OUT_ALL_USB  = (OUT_USB_ACCESSORY | OUT_USB_DEVICE | OUT_USB_HEADSET),
-    /* input devices */
+    /** input devices */
     IN_COMMUNICATION         = BIT_IN | 0x1,
     IN_AMBIENT               = BIT_IN | 0x2,
     IN_BUILTIN_MIC           = BIT_IN | 0x4,
@@ -579,7 +579,7 @@
     IN_WIRED_HEADSET         = BIT_IN | 0x10,
     IN_AUX_DIGITAL           = BIT_IN | 0x20,
     IN_HDMI                  = IN_AUX_DIGITAL,
-    /* Telephony voice RX path */
+    /** Telephony voice RX path */
     IN_VOICE_CALL            = BIT_IN | 0x40,
     IN_TELEPHONY_RX          = IN_VOICE_CALL,
     IN_BACK_MIC              = BIT_IN | 0x80,
@@ -588,18 +588,18 @@
     IN_DGTL_DOCK_HEADSET     = BIT_IN | 0x400,
     IN_USB_ACCESSORY         = BIT_IN | 0x800,
     IN_USB_DEVICE            = BIT_IN | 0x1000,
-    /* FM tuner input */
+    /** FM tuner input */
     IN_FM_TUNER              = BIT_IN | 0x2000,
-    /* TV tuner input */
+    /** TV tuner input */
     IN_TV_TUNER              = BIT_IN | 0x4000,
-    /* Analog jack with line impedance detected */
+    /** Analog jack with line impedance detected */
     IN_LINE                  = BIT_IN | 0x8000,
-    /* S/PDIF in */
+    /** S/PDIF in */
     IN_SPDIF                 = BIT_IN | 0x10000,
     IN_BLUETOOTH_A2DP        = BIT_IN | 0x20000,
     IN_LOOPBACK              = BIT_IN | 0x40000,
     IN_IP                    = BIT_IN | 0x80000,
-    /* audio bus implemented by the audio system (e.g an MOST stereo channel) */
+    /** audio bus implemented by the audio system (e.g an MOST stereo channel) */
     IN_BUS                   = BIT_IN | 0x100000,
     IN_PROXY                 = BIT_IN | 0x1000000,
     IN_USB_HEADSET           = BIT_IN | 0x2000000,
@@ -633,7 +633,7 @@
     IN_ALL_USB  = (IN_USB_ACCESSORY | IN_USB_DEVICE | IN_USB_HEADSET),
 };
 
-/*
+/**
  * The audio output flags serve two purposes:
  *
  *  - when an AudioTrack is created they indicate a "wish" to be connected to an
@@ -674,7 +674,7 @@
     VOIP_RX = 0x8000,    // preferred output for VoIP calls.
 };
 
-/*
+/**
  * The audio input flags are analogous to audio output flags.
  * Currently they are used only when an AudioRecord is created,
  * to indicate a preference to be connected to an input stream with
@@ -717,7 +717,7 @@
     MAX                                = CNT - 1,
 };
 
-/*
+/**
  * Additional information about the stream passed to hardware decoders.
  */
 struct AudioOffloadInfo {
@@ -734,7 +734,7 @@
     AudioUsage usage;
 };
 
-/*
+/**
  * Commonly used audio stream configuration parameters.
  */
 struct AudioConfig {
@@ -746,13 +746,13 @@
 };
 
 
-/*
+/**
  *
  *  Volume control
  *
  */
 
-/*
+/**
  * Type of gain control exposed by an audio port.
  */
 @export(name="", value_prefix="AUDIO_GAIN_MODE_")
@@ -762,7 +762,7 @@
     RAMP = 0x4      // supports gain ramps
 };
 
-/*
+/**
  * An audio_gain struct is a representation of a gain stage.
  * A gain stage is always attached to an audio port.
  */
@@ -777,7 +777,7 @@
     uint32_t maxRampMs;   // maximum ramp duration in ms
 };
 
-/*
+/**
  * The gain configuration structure is used to get or set the gain values of a
  * given port.
  */
@@ -785,7 +785,7 @@
     int32_t index;  // index of the corresponding AudioGain in AudioPort.gains
     AudioGainMode mode;
     AudioChannelMask channelMask;  // channels which gain value follows
-    /*
+    /**
      * 4 = sizeof(AudioChannelMask),
      * 8 is not "FCC_8", so it won't need to be changed for > 8 channels.
      * Gain values in millibels for each channel ordered from LSb to MSb in
@@ -797,13 +797,13 @@
 };
 
 
-/*
+/**
  *
  *  Routing control
  *
  */
 
-/*
+/**
  * Types defined here are used to describe an audio source or sink at internal
  * framework interfaces (audio policy, patch panel) or at the audio HAL.
  * Sink and sources are grouped in a concept of “audio port” representing an
@@ -811,7 +811,7 @@
  * the interface.
  */
 
-/* Audio port role: either source or sink */
+/** Audio port role: either source or sink */
 @export(name="audio_port_role_t", value_prefix="AUDIO_PORT_ROLE_")
 enum AudioPortRole : int32_t {
     NONE,
@@ -819,7 +819,7 @@
     SINK,
 };
 
-/*
+/**
  * Audio port type indicates if it is a session (e.g AudioTrack), a mix (e.g
  * PlaybackThread output) or a physical device (e.g OUT_SPEAKER)
  */
@@ -831,7 +831,7 @@
     SESSION,
 };
 
-/*
+/**
  * Extension for audio port configuration structure when the audio port is a
  * hardware device.
  */
@@ -841,7 +841,7 @@
     uint8_t[32] address;         // device address. "" if N/A
 };
 
-/*
+/**
  * Extension for audio port configuration structure when the audio port is an
  * audio session.
  */
@@ -849,7 +849,7 @@
     AudioSession session;
 };
 
-/*
+/**
  * Flags indicating which fields are to be considered in AudioPortConfig.
  */
 @export(name="", value_prefix="AUDIO_PORT_CONFIG_")
@@ -861,7 +861,7 @@
     ALL = SAMPLE_RATE | CHANNEL_MASK | FORMAT | GAIN
 };
 
-/*
+/**
  * Audio port configuration structure used to specify a particular configuration
  * of an audio port.
  */
@@ -888,7 +888,7 @@
     } ext;
 };
 
-/*
+/**
  * Extension for audio port structure when the audio port is a hardware device.
  */
 struct AudioPortDeviceExt {
@@ -897,7 +897,7 @@
     uint8_t[32] address;
 };
 
-/*
+/**
  * Latency class of the audio mix.
  */
 @export(name="audio_mix_latency_class_t", value_prefix="AUDIO_LATENCY_")
@@ -912,7 +912,7 @@
     AudioMixLatencyClass latencyClass;
 };
 
-/*
+/**
  * Extension for audio port structure when the audio port is an audio session.
  */
 struct AudioPortSessionExt {
diff --git a/audio/effect/2.0/IAcousticEchoCancelerEffect.hal b/audio/effect/2.0/IAcousticEchoCancelerEffect.hal
index 9e2e0c3..b5f94a5 100644
--- a/audio/effect/2.0/IAcousticEchoCancelerEffect.hal
+++ b/audio/effect/2.0/IAcousticEchoCancelerEffect.hal
@@ -20,12 +20,12 @@
 import IEffect;
 
 interface IAcousticEchoCancelerEffect extends IEffect {
-    /*
+    /**
      * Sets echo delay value in milliseconds.
      */
     setEchoDelay(uint32_t echoDelayMs) generates (Result retval);
 
-    /*
+    /**
      * Gets echo delay value in milliseconds.
      */
     getEchoDelay() generates (Result retval, uint32_t echoDelayMs);
diff --git a/audio/effect/2.0/IAutomaticGainControlEffect.hal b/audio/effect/2.0/IAutomaticGainControlEffect.hal
index a02002d..b8ca7e3 100644
--- a/audio/effect/2.0/IAutomaticGainControlEffect.hal
+++ b/audio/effect/2.0/IAutomaticGainControlEffect.hal
@@ -20,32 +20,32 @@
 import IEffect;
 
 interface IAutomaticGainControlEffect extends IEffect {
-    /*
+    /**
      * Sets target level in millibels.
      */
     setTargetLevel(int16_t targetLevelMb) generates (Result retval);
 
-    /*
+    /**
      * Gets target level.
      */
     getTargetLevel() generates (Result retval, int16_t targetLevelMb);
 
-    /*
+    /**
      * Sets gain in the compression range in millibels.
      */
     setCompGain(int16_t compGainMb) generates (Result retval);
 
-    /*
+    /**
      * Gets gain in the compression range.
      */
     getCompGain() generates (Result retval, int16_t compGainMb);
 
-    /*
+    /**
      * Enables or disables limiter.
      */
     setLimiterEnabled(bool enabled) generates (Result retval);
 
-    /*
+    /**
      * Returns whether limiter is enabled.
      */
     isLimiterEnabled() generates (Result retval, bool enabled);
@@ -56,12 +56,12 @@
         bool limiterEnabled;
     };
 
-    /*
+    /**
      * Sets all properties at once.
      */
     setAllProperties(AllProperties properties) generates (Result retval);
 
-    /*
+    /**
      * Gets all properties at once.
      */
     getAllProperties() generates (Result retval, AllProperties properties);
diff --git a/audio/effect/2.0/IBassBoostEffect.hal b/audio/effect/2.0/IBassBoostEffect.hal
index bcf7b7d..db6a297 100644
--- a/audio/effect/2.0/IBassBoostEffect.hal
+++ b/audio/effect/2.0/IBassBoostEffect.hal
@@ -20,7 +20,7 @@
 import IEffect;
 
 interface IBassBoostEffect extends IEffect {
-    /*
+    /**
      * Returns whether setting bass boost strength is supported.
      */
     isStrengthSupported() generates (Result retval, bool strengthSupported);
@@ -30,7 +30,7 @@
         MAX = 1000
     };
 
-    /*
+    /**
      * Sets bass boost strength.
      *
      * @param strength strength of the effect. The valid range for strength
@@ -41,7 +41,7 @@
      */
     setStrength(uint16_t strength) generates (Result retval);
 
-    /*
+    /**
      * Gets virtualization strength.
      */
     getStrength() generates (Result retval, uint16_t strength);
diff --git a/audio/effect/2.0/IEffect.hal b/audio/effect/2.0/IEffect.hal
index d254e8c..332e2df 100644
--- a/audio/effect/2.0/IEffect.hal
+++ b/audio/effect/2.0/IEffect.hal
@@ -20,7 +20,7 @@
 import IEffectBufferProviderCallback;
 
 interface IEffect {
-    /*
+    /**
      * Initialize effect engine--all configurations return to default.
      *
      * @return retval operation completion status.
@@ -29,7 +29,7 @@
     @callflow(next={"*"})
     init() generates (Result retval);
 
-    /*
+    /**
      * Apply new audio parameters configurations for input and output buffers.
      * The provider callbacks may be empty, but in this case the buffer
      * must be provided in the EffectConfig structure.
@@ -45,7 +45,7 @@
             IEffectBufferProviderCallback outputBufferProvider)
             generates (Result retval);
 
-    /*
+    /**
      * Reset the effect engine. Keep configuration but resets state and buffer
      * content.
      *
@@ -54,7 +54,7 @@
     @callflow(next={"*"})
     reset() generates (Result retval);
 
-    /*
+    /**
      * Enable processing.
      *
      * @return retval operation completion status.
@@ -62,7 +62,7 @@
     @callflow(next={"prepareForProcessing"})
     enable() generates (Result retval);
 
-    /*
+    /**
      * Disable processing.
      *
      * @return retval operation completion status.
@@ -70,7 +70,7 @@
     @callflow(next={"close"})
     disable() generates (Result retval);
 
-    /*
+    /**
      * Set the rendering device the audio output path is connected to.  The
      * effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its
      * descriptor to receive this command when the device changes.
@@ -84,7 +84,7 @@
     @callflow(next={"*"})
     setDevice(AudioDevice device) generates (Result retval);
 
-    /*
+    /**
      * Set and get volume. Used by audio framework to delegate volume control to
      * effect engine. The effect implementation must set EFFECT_FLAG_VOLUME_CTRL
      * flag in its descriptor to receive this command. The effect engine must
@@ -103,7 +103,7 @@
     setAndGetVolume(vec<uint32_t> volumes)
             generates (Result retval, vec<uint32_t> result);
 
-    /*
+    /**
      * Notify the effect of the volume change. The effect implementation must
      * set EFFECT_FLAG_VOLUME_IND flag in its descriptor to receive this
      * command.
@@ -116,7 +116,7 @@
     volumeChangeNotification(vec<uint32_t> volumes)
             generates (Result retval);
 
-    /*
+    /**
      * Set the audio mode. The effect implementation must set
      * EFFECT_FLAG_AUDIO_MODE_IND flag in its descriptor to receive this command
      * when the audio mode changes.
@@ -127,7 +127,7 @@
     @callflow(next={"*"})
     setAudioMode(AudioMode mode) generates (Result retval);
 
-    /*
+    /**
      * Apply new audio parameters configurations for input and output buffers of
      * reverse stream.  An example of reverse stream is the echo reference
      * supplied to an Acoustic Echo Canceler.
@@ -143,7 +143,7 @@
             IEffectBufferProviderCallback outputBufferProvider)
             generates (Result retval);
 
-    /*
+    /**
      * Set the capture device the audio input path is connected to. The effect
      * implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to
      * receive this command when the device changes.
@@ -157,7 +157,7 @@
     @callflow(next={"*"})
     setInputDevice(AudioDevice device) generates (Result retval);
 
-    /*
+    /**
      * Read audio parameters configurations for input and output buffers.
      *
      * @return retval operation completion status.
@@ -166,7 +166,7 @@
     @callflow(next={"*"})
     getConfig() generates (Result retval, EffectConfig config);
 
-    /*
+    /**
      * Read audio parameters configurations for input and output buffers of
      * reverse stream.
      *
@@ -176,7 +176,7 @@
     @callflow(next={"*"})
     getConfigReverse() generates (Result retval, EffectConfig config);
 
-    /*
+    /**
      * Queries for supported combinations of main and auxiliary channels
      * (e.g. for a multi-microphone noise suppressor).
      *
@@ -190,7 +190,7 @@
     getSupportedAuxChannelsConfigs(uint32_t maxConfigs)
             generates (Result retval, vec<EffectAuxChannelsConfig> result);
 
-    /*
+    /**
      * Retrieves the current configuration of main and auxiliary channels.
      *
      * @return retval absence of the feature support is indicated using
@@ -201,7 +201,7 @@
     getAuxChannelsConfig()
             generates (Result retval, EffectAuxChannelsConfig result);
 
-    /*
+    /**
      * Sets the current configuration of main and auxiliary channels.
      *
      * @return retval operation completion status; absence of the feature
@@ -211,7 +211,7 @@
     setAuxChannelsConfig(EffectAuxChannelsConfig config)
             generates (Result retval);
 
-    /*
+    /**
      * Set the audio source the capture path is configured for (Camcorder, voice
      * recognition...).
      *
@@ -224,7 +224,7 @@
     @callflow(next={"*"})
     setAudioSource(AudioSource source) generates (Result retval);
 
-    /*
+    /**
      * This command indicates if the playback thread the effect is attached to
      * is offloaded or not, and updates the I/O handle of the playback thread
      * the effect is attached to.
@@ -235,7 +235,7 @@
     @callflow(next={"*"})
     offload(EffectOffloadParameter param) generates (Result retval);
 
-    /*
+    /**
      * Returns the effect descriptor.
      *
      * @return retval operation completion status.
@@ -244,7 +244,7 @@
     @callflow(next={"*"})
     getDescriptor() generates (Result retval, EffectDescriptor descriptor);
 
-    /*
+    /**
      * Set up required transports for passing audio buffers to the effect.
      *
      * The transport consists of shared memory and a message queue for reporting
@@ -270,7 +270,7 @@
     @callflow(next={"setProcessBuffers"})
     prepareForProcessing() generates (Result retval, fmq_sync<Result> statusMQ);
 
-    /*
+    /**
      * Set up input and output buffers for processing audio data. The effect
      * may modify both the input and the output buffer during the operation.
      * Buffers may be set multiple times during effect lifetime.
@@ -289,7 +289,7 @@
     setProcessBuffers(AudioBuffer inBuffer, AudioBuffer outBuffer) generates (
             Result retval);
 
-    /*
+    /**
      * Execute a vendor specific command on the effect. The command code
      * and data, as well as result data are not interpreted by Android
      * Framework and are passed as-is between the application and the effect.
@@ -310,7 +310,7 @@
     command(uint32_t commandId, vec<uint8_t> data, uint32_t resultMaxSize)
             generates (int32_t status, vec<uint8_t> result);
 
-    /*
+    /**
      * Set a vendor-specific parameter and apply it immediately. The parameter
      * code and data are not interpreted by Android Framework and are passed
      * as-is between the application and the effect.
@@ -331,7 +331,7 @@
     setParameter(vec<uint8_t> parameter, vec<uint8_t> value)
             generates (Result retval);
 
-    /*
+    /**
      * Get a vendor-specific parameter value. The parameter code and returned
      * data are not interpreted by Android Framework and are passed as-is
      * between the application and the effect.
@@ -353,7 +353,7 @@
     getParameter(vec<uint8_t> parameter, uint32_t valueMaxSize)
             generates (Result retval, vec<uint8_t> value);
 
-    /*
+    /**
      * Get supported configs for a vendor-specific feature. The configs returned
      * are not interpreted by Android Framework and are passed as-is between the
      * application and the effect.
@@ -384,7 +384,7 @@
                     uint32_t configsCount,
                     vec<uint8_t> configsData);
 
-    /*
+    /**
      * Get the current config for a vendor-specific feature. The config returned
      * is not interpreted by Android Framework and is passed as-is between the
      * application and the effect.
@@ -406,7 +406,7 @@
     getCurrentConfigForFeature(uint32_t featureId, uint32_t configSize)
             generates (Result retval, vec<uint8_t> configData);
 
-    /*
+    /**
      * Set the current config for a vendor-specific feature. The config data
      * is not interpreted by Android Framework and is passed as-is between the
      * application and the effect.
@@ -426,7 +426,7 @@
     setCurrentConfigForFeature(uint32_t featureId, vec<uint8_t> configData)
             generates (Result retval);
 
-    /*
+    /**
      * Called by the framework to deinitialize the effect and free up
      * all the currently allocated resources. It is recommended to close
      * the effect on the client side as soon as it is becomes unused.
diff --git a/audio/effect/2.0/IEffectBufferProviderCallback.hal b/audio/effect/2.0/IEffectBufferProviderCallback.hal
index 53f4d6e..6ab33c3 100644
--- a/audio/effect/2.0/IEffectBufferProviderCallback.hal
+++ b/audio/effect/2.0/IEffectBufferProviderCallback.hal
@@ -16,12 +16,12 @@
 
 package android.hardware.audio.effect@2.0;
 
-/*
+/**
  * This callback interface contains functions that can be used by the effect
  * engine 'process' function to exchange input and output audio buffers.
  */
 interface IEffectBufferProviderCallback {
-    /*
+    /**
      * Called to retrieve a buffer where data should read from by 'process'
      * function.
      *
@@ -29,7 +29,7 @@
      */
     getBuffer() generates (AudioBuffer buffer);
 
-    /*
+    /**
      * Called to provide a buffer with the data written by 'process' function.
      *
      * @param buffer audio buffer for processing
diff --git a/audio/effect/2.0/IEffectsFactory.hal b/audio/effect/2.0/IEffectsFactory.hal
index c82b4a2..3d300ec 100644
--- a/audio/effect/2.0/IEffectsFactory.hal
+++ b/audio/effect/2.0/IEffectsFactory.hal
@@ -20,7 +20,7 @@
 import IEffect;
 
 interface IEffectsFactory {
-    /*
+    /**
      * Returns descriptors of different effects in all loaded libraries.
      *
      * @return retval operation completion status.
@@ -28,7 +28,7 @@
      */
     getAllDescriptors() generates(Result retval, vec<EffectDescriptor> result);
 
-    /*
+    /**
      * Returns a descriptor of a particular effect.
      *
      * @return retval operation completion status.
@@ -36,7 +36,7 @@
      */
     getDescriptor(Uuid uid) generates(Result retval, EffectDescriptor result);
 
-    /*
+    /**
      * Creates an effect engine of the specified type.  To release the effect
      * engine, it is necessary to release references to the returned effect
      * object.
@@ -56,7 +56,7 @@
     createEffect(Uuid uid, AudioSession session, AudioIoHandle ioHandle)
         generates (Result retval, IEffect result, uint64_t effectId);
 
-    /*
+    /**
      * Dumps information about effects into the provided file descriptor.
      * This is used for the dumpsys facility.
      *
diff --git a/audio/effect/2.0/IEnvironmentalReverbEffect.hal b/audio/effect/2.0/IEnvironmentalReverbEffect.hal
index d9b1ee6..dca89f9 100644
--- a/audio/effect/2.0/IEnvironmentalReverbEffect.hal
+++ b/audio/effect/2.0/IEnvironmentalReverbEffect.hal
@@ -20,12 +20,12 @@
 import IEffect;
 
 interface IEnvironmentalReverbEffect extends IEffect {
-    /*
+    /**
      * Sets whether the effect should be bypassed.
      */
     setBypass(bool bypass) generates (Result retval);
 
-    /*
+    /**
      * Gets whether the effect should be bypassed.
      */
     getBypass() generates (Result retval, bool bypass);
@@ -53,102 +53,102 @@
         DENSITY_MAX = 1000
     };
 
-    /*
+    /**
      * Sets the room level.
      */
     setRoomLevel(int16_t roomLevel) generates (Result retval);
 
-    /*
+    /**
      * Gets the room level.
      */
     getRoomLevel() generates (Result retval, int16_t roomLevel);
 
-    /*
+    /**
      * Sets the room high frequences level.
      */
     setRoomHfLevel(int16_t roomHfLevel) generates (Result retval);
 
-    /*
+    /**
      * Gets the room high frequences level.
      */
     getRoomHfLevel() generates (Result retval, int16_t roomHfLevel);
 
-    /*
+    /**
      * Sets the room decay time.
      */
     setDecayTime(uint32_t decayTime) generates (Result retval);
 
-    /*
+    /**
      * Gets the room decay time.
      */
     getDecayTime() generates (Result retval, uint32_t decayTime);
 
-    /*
+    /**
      * Sets the ratio of high frequences decay.
      */
     setDecayHfRatio(int16_t decayHfRatio) generates (Result retval);
 
-    /*
+    /**
      * Gets the ratio of high frequences decay.
      */
     getDecayHfRatio() generates (Result retval, int16_t decayHfRatio);
 
-    /*
+    /**
      * Sets the level of reflections in the room.
      */
     setReflectionsLevel(int16_t reflectionsLevel) generates (Result retval);
 
-    /*
+    /**
      * Gets the level of reflections in the room.
      */
     getReflectionsLevel() generates (Result retval, int16_t reflectionsLevel);
 
-    /*
+    /**
      * Sets the reflections delay in the room.
      */
     setReflectionsDelay(uint32_t reflectionsDelay) generates (Result retval);
 
-    /*
+    /**
      * Gets the reflections delay in the room.
      */
     getReflectionsDelay() generates (Result retval, uint32_t reflectionsDelay);
 
-    /*
+    /**
      * Sets the reverb level of the room.
      */
     setReverbLevel(int16_t reverbLevel) generates (Result retval);
 
-    /*
+    /**
      * Gets the reverb level of the room.
      */
     getReverbLevel() generates (Result retval, int16_t reverbLevel);
 
-    /*
+    /**
      * Sets the reverb delay of the room.
      */
     setReverbDelay(uint32_t reverDelay) generates (Result retval);
 
-    /*
+    /**
      * Gets the reverb delay of the room.
      */
     getReverbDelay() generates (Result retval, uint32_t reverbDelay);
 
-    /*
+    /**
      * Sets room diffusion.
      */
     setDiffusion(int16_t diffusion) generates (Result retval);
 
-    /*
+    /**
      * Gets room diffusion.
      */
     getDiffusion() generates (Result retval, int16_t diffusion);
 
-    /*
+    /**
      * Sets room wall density.
      */
     setDensity(int16_t density) generates (Result retval);
 
-    /*
+    /**
      * Gets room wall density.
      */
     getDensity() generates (Result retval, int16_t density);
@@ -166,12 +166,12 @@
         int16_t  density;           // in permilles,    range 0 to 1000
     };
 
-    /*
+    /**
      * Sets all properties at once.
      */
     setAllProperties(AllProperties properties) generates (Result retval);
 
-    /*
+    /**
      * Gets all properties at once.
      */
     getAllProperties() generates (Result retval, AllProperties properties);
diff --git a/audio/effect/2.0/IEqualizerEffect.hal b/audio/effect/2.0/IEqualizerEffect.hal
index b8fa177..1528e0d 100644
--- a/audio/effect/2.0/IEqualizerEffect.hal
+++ b/audio/effect/2.0/IEqualizerEffect.hal
@@ -20,58 +20,58 @@
 import IEffect;
 
 interface IEqualizerEffect extends IEffect {
-    /*
+    /**
      * Gets the number of frequency bands that the equalizer supports.
      */
     getNumBands() generates (Result retval, uint16_t numBands);
 
-    /*
+    /**
      * Returns the minimum and maximum band levels supported.
      */
     getLevelRange()
             generates (Result retval, int16_t minLevel, int16_t maxLevel);
 
-    /*
+    /**
      * Sets the gain for the given equalizer band.
      */
     setBandLevel(uint16_t band, int16_t level) generates (Result retval);
 
-    /*
+    /**
      * Gets the gain for the given equalizer band.
      */
     getBandLevel(uint16_t band) generates (Result retval, int16_t level);
 
-    /*
+    /**
      * Gets the center frequency of the given band, in milliHertz.
      */
     getBandCenterFrequency(uint16_t band)
             generates (Result retval, uint32_t centerFreqmHz);
 
-    /*
+    /**
      * Gets the frequency range of the given frequency band, in milliHertz.
      */
     getBandFrequencyRange(uint16_t band)
             generates (Result retval, uint32_t minFreqmHz, uint32_t maxFreqmHz);
 
-    /*
+    /**
      * Gets the band that has the most effect on the given frequency
      * in milliHertz.
      */
     getBandForFrequency(uint32_t freqmHz)
             generates (Result retval, uint16_t band);
 
-    /*
+    /**
      * Gets the names of all presets the equalizer supports.
      */
     getPresetNames() generates (Result retval, vec<string> names);
 
-    /*
+    /**
      * Sets the current preset using the index of the preset in the names
      * vector returned via 'getPresetNames'.
      */
     setCurrentPreset(uint16_t preset) generates (Result retval);
 
-    /*
+    /**
      * Gets the current preset.
      */
     getCurrentPreset() generates (Result retval, uint16_t preset);
@@ -81,12 +81,12 @@
         vec<int16_t> bandLevels;
     };
 
-    /*
+    /**
      * Sets all properties at once.
      */
     setAllProperties(AllProperties properties) generates (Result retval);
 
-    /*
+    /**
      * Gets all properties at once.
      */
     getAllProperties() generates (Result retval, AllProperties properties);
diff --git a/audio/effect/2.0/ILoudnessEnhancerEffect.hal b/audio/effect/2.0/ILoudnessEnhancerEffect.hal
index 3e1ee4e..adeb1c8 100644
--- a/audio/effect/2.0/ILoudnessEnhancerEffect.hal
+++ b/audio/effect/2.0/ILoudnessEnhancerEffect.hal
@@ -20,12 +20,12 @@
 import IEffect;
 
 interface ILoudnessEnhancerEffect extends IEffect {
-    /*
+    /**
      * Sets target gain expressed in millibels.
      */
     setTargetGain(int32_t targetGainMb) generates (Result retval);
 
-    /*
+    /**
      * Gets target gain expressed in millibels.
      */
     getTargetGain() generates (Result retval, int32_t targetGainMb);
diff --git a/audio/effect/2.0/INoiseSuppressionEffect.hal b/audio/effect/2.0/INoiseSuppressionEffect.hal
index ae2bfb5..6617a1e 100644
--- a/audio/effect/2.0/INoiseSuppressionEffect.hal
+++ b/audio/effect/2.0/INoiseSuppressionEffect.hal
@@ -26,12 +26,12 @@
         HIGH
     };
 
-    /*
+    /**
      * Sets suppression level.
      */
     setSuppressionLevel(Level level) generates (Result retval);
 
-    /*
+    /**
      * Gets suppression level.
      */
     getSuppressionLevel() generates (Result retval, Level level);
@@ -41,12 +41,12 @@
         MULTI_CHANNEL
     };
 
-    /*
+    /**
      * Set suppression type.
      */
     setSuppressionType(Type type) generates (Result retval);
 
-    /*
+    /**
      * Get suppression type.
      */
     getSuppressionType() generates (Result retval, Type type);
@@ -56,12 +56,12 @@
         Type type;
     };
 
-    /*
+    /**
      * Sets all properties at once.
      */
     setAllProperties(AllProperties properties) generates (Result retval);
 
-    /*
+    /**
      * Gets all properties at once.
      */
     getAllProperties() generates (Result retval, AllProperties properties);
diff --git a/audio/effect/2.0/IVirtualizerEffect.hal b/audio/effect/2.0/IVirtualizerEffect.hal
index 2b7116c..49b49a0 100644
--- a/audio/effect/2.0/IVirtualizerEffect.hal
+++ b/audio/effect/2.0/IVirtualizerEffect.hal
@@ -20,7 +20,7 @@
 import IEffect;
 
 interface IVirtualizerEffect extends IEffect {
-    /*
+    /**
      * Returns whether setting virtualization strength is supported.
      */
     isStrengthSupported() generates (bool strengthSupported);
@@ -30,7 +30,7 @@
         MAX = 1000
     };
 
-    /*
+    /**
      * Sets virtualization strength.
      *
      * @param strength strength of the effect. The valid range for strength
@@ -41,7 +41,7 @@
      */
     setStrength(uint16_t strength) generates (Result retval);
 
-    /*
+    /**
      * Gets virtualization strength.
      */
     getStrength() generates (Result retval, uint16_t strength);
@@ -56,19 +56,19 @@
         int16_t elevation; // 0 is the horizontal plane
                            // +90 is above the listener, -90 is below
     };
-    /*
+    /**
      * Retrieves virtual speaker angles for the given channel mask on the
      * specified device.
      */
     getVirtualSpeakerAngles(AudioChannelMask mask, AudioDevice device)
             generates (Result retval, vec<SpeakerAngle> speakerAngles);
 
-    /*
+    /**
      * Forces the virtualizer effect for the given output device.
      */
     forceVirtualizationMode(AudioDevice device) generates (Result retval);
 
-    /*
+    /**
      * Returns audio device reflecting the current virtualization mode,
      * AUDIO_DEVICE_NONE when not virtualizing.
      */
diff --git a/audio/effect/2.0/IVisualizerEffect.hal b/audio/effect/2.0/IVisualizerEffect.hal
index 79dc9ee..fd3edbd 100644
--- a/audio/effect/2.0/IVisualizerEffect.hal
+++ b/audio/effect/2.0/IVisualizerEffect.hal
@@ -25,12 +25,12 @@
         MIN = 128    // minimum capture size in samples
     };
 
-    /*
+    /**
      * Sets the number PCM samples in the capture.
      */
     setCaptureSize(uint16_t captureSize) generates (Result retval);
 
-    /*
+    /**
      * Gets the number PCM samples in the capture.
      */
     getCaptureSize() generates (Result retval, uint16_t captureSize);
@@ -42,22 +42,22 @@
         AS_PLAYED = 1
     };
 
-    /*
+    /**
      * Specifies the way the captured data is scaled.
      */
     setScalingMode(ScalingMode scalingMode) generates (Result retval);
 
-    /*
+    /**
      * Retrieves the way the captured data is scaled.
      */
     getScalingMode() generates (Result retval, ScalingMode scalingMode);
 
-    /*
+    /**
      * Informs the visualizer about the downstream latency.
      */
     setLatency(uint32_t latencyMs) generates (Result retval);
 
-    /*
+    /**
      * Gets the downstream latency.
      */
     getLatency() generates (Result retval, uint32_t latencyMs);
@@ -69,19 +69,19 @@
         PEAK_RMS = 0x1
     };
 
-    /*
+    /**
      * Specifies which measurements are to be made.
      */
     setMeasurementMode(MeasurementMode measurementMode)
             generates (Result retval);
 
-    /*
+    /**
      * Retrieves which measurements are to be made.
      */
     getMeasurementMode() generates (
             Result retval, MeasurementMode measurementMode);
 
-    /*
+    /**
      * Retrieves the latest PCM snapshot captured by the visualizer engine.  The
      * number of samples to capture is specified by 'setCaptureSize' parameter.
      *
@@ -99,7 +99,7 @@
             } peakAndRms;
         } value;
     };
-    /*
+    /**
      * Retrieves the lastest measurements. The measurements to be made
      * are specified by 'setMeasurementMode' parameter.
      *
diff --git a/audio/effect/2.0/types.hal b/audio/effect/2.0/types.hal
index 0626ec5..2c5e4ef 100644
--- a/audio/effect/2.0/types.hal
+++ b/audio/effect/2.0/types.hal
@@ -27,7 +27,7 @@
     RESULT_TOO_BIG
 };
 
-/*
+/**
  * Effect engine capabilities/requirements flags.
  *
  * Definitions for flags field of effect descriptor.
@@ -195,7 +195,7 @@
     NO_PROCESS = 1 << NO_PROCESS_SHIFT
 };
 
-/*
+/**
  * The effect descriptor contains necessary information to facilitate the
  * enumeration of the effect engines present in a library.
  */
@@ -212,7 +212,7 @@
     uint8_t[64] implementor;  // human readable effect implementor name
 };
 
-/*
+/**
  * A buffer is a chunk of audio data for processing.  Multi-channel audio is
  * always interleaved. The channel order is from LSB to MSB with regard to the
  * channel mask definition in audio.h, audio_channel_mask_t, e.g.:
@@ -235,7 +235,7 @@
     ACCESS_ACCUMULATE
 };
 
-/*
+/**
  * Determines what fields of EffectBufferConfig need to be considered.
  */
 @export(name="", value_prefix="EFFECT_CONFIG_")
@@ -248,7 +248,7 @@
     ALL = BUFFER | SMP_RATE | CHANNELS | FORMAT | ACC_MODE
 };
 
-/*
+/**
  * The buffer config structure specifies the input or output audio format
  * to be used by the effect engine.
  */
@@ -285,7 +285,7 @@
                              // the effect is attached to
 };
 
-/*
+/**
  * The message queue flags used to synchronize reads and writes from
  * the status message queue used by effects.
  */
diff --git a/automotive/evs/1.0/types.hal b/automotive/evs/1.0/types.hal
index 661c2a9..0ce39d1 100644
--- a/automotive/evs/1.0/types.hal
+++ b/automotive/evs/1.0/types.hal
@@ -17,7 +17,7 @@
 package android.hardware.automotive.evs@1.0;
 
 
-/*
+/**
  * Bit flags indicating suggested uses for a given EVS camera
  *
  * The values in the UsageHint bit field provide a generic expression of how a
@@ -35,7 +35,7 @@
 };
 
 
-/*
+/**
  * Structure describing the basic properties of an EVS camera
  *
  * The HAL is responsible for filling out this structure for each
@@ -55,7 +55,7 @@
 };
 
 
-/*
+/**
  * Structure describing the basic properties of an EVS display
  *
  * The HAL is responsible for filling out this structure to describe
@@ -71,7 +71,7 @@
 };
 
 
-/*
+/**
  * Structure representing an image buffer through our APIs
  *
  * In addition to the handle to the graphics memory, we need to retain
@@ -94,7 +94,7 @@
 };
 
 
-/*
+/**
  * States for control of the EVS display
  *
  * The DisplayInfo structure describes the basic properties of an EVS display. Any EVS
@@ -112,11 +112,11 @@
 };
 
 
-/* Error codes used in EVS HAL interface. */
+/** Error codes used in EVS HAL interface. */
 enum EvsResult : uint32_t {
     OK = 0,
     INVALID_ARG,
     STREAM_ALREADY_RUNNING,
     BUFFER_NOT_AVAILABLE,
     UNDERLYING_SERVICE_ERROR,
-};
\ No newline at end of file
+};
diff --git a/automotive/vehicle/2.0/IVehicle.hal b/automotive/vehicle/2.0/IVehicle.hal
index 5de416f..d962de0 100644
--- a/automotive/vehicle/2.0/IVehicle.hal
+++ b/automotive/vehicle/2.0/IVehicle.hal
@@ -25,7 +25,7 @@
    */
   getAllPropConfigs() generates (vec<VehiclePropConfig> propConfigs);
 
-  /*
+  /**
    * Returns a list of property configurations for given properties.
    *
    * If requested VehicleProperty wasn't found it must return
diff --git a/automotive/vehicle/2.0/IVehicleCallback.hal b/automotive/vehicle/2.0/IVehicleCallback.hal
index 167e5e1..7060418 100644
--- a/automotive/vehicle/2.0/IVehicleCallback.hal
+++ b/automotive/vehicle/2.0/IVehicleCallback.hal
@@ -18,7 +18,7 @@
 
 interface IVehicleCallback {
 
-    /*
+    /**
      * Event callback happens whenever a variable that the API user has
      * subscribed to needs to be reported. This may be based purely on
      * threshold and frequency (a regular subscription, see subscribe call's
@@ -31,7 +31,7 @@
      */
     oneway onPropertyEvent(vec<VehiclePropValue> propValues);
 
-    /*
+    /**
      * This method gets called if the client was subscribed to a property using
      * SubscribeFlags::SET_CALL flag and IVehicle#set(...) method was called.
      *
@@ -42,7 +42,7 @@
      */
     oneway onPropertySet(VehiclePropValue propValue);
 
-    /*
+    /**
      * Set property value is usually asynchronous operation. Thus even if
      * client received StatusCode::OK from the IVehicle::set(...) this
      * doesn't guarantee that the value was successfully propagated to the
diff --git a/automotive/vehicle/2.0/types.hal b/automotive/vehicle/2.0/types.hal
index a998d33..f1fb6bf 100644
--- a/automotive/vehicle/2.0/types.hal
+++ b/automotive/vehicle/2.0/types.hal
@@ -16,7 +16,7 @@
 
 package android.hardware.automotive.vehicle@2.0;
 
-/*
+/**
  * Enumerates supported data types for VehicleProperty.
  *
  * This is a bitwise flag that supposed to be used in VehicleProperty enum.
@@ -31,7 +31,7 @@
     FLOAT_VEC      = 0x00610000,
     BYTES          = 0x00700000,
 
-    /*
+    /**
      * Any combination of scalar or vector types. The exact format must be
      * provided in the description of the property.
      */
@@ -40,7 +40,7 @@
     MASK           = 0x00ff0000
 };
 
-/*
+/**
  * Some properties may be associated with particular vehicle areas. For
  * example, VehicleProperty:DOOR_LOCK property must be associated with
  * particular door, thus this property must be marked with
@@ -62,18 +62,18 @@
       MASK         = 0x0f000000,
 };
 
-/*
+/**
  * Enumerates property groups.
  *
  * This is a bitwise flag that supposed to be used in VehicleProperty enum.
  */
 enum VehiclePropertyGroup : int32_t {
-    /*
+    /**
      * Properties declared in AOSP must have this flag.
      */
     SYSTEM         = 0x10000000,
 
-    /*
+    /**
      * Properties declared by vendors must have this flag.
      */
     VENDOR         = 0x20000000,
@@ -81,7 +81,7 @@
     MASK           = 0xf0000000,
 };
 
-/*
+/**
  * Declares all vehicle properties. VehicleProperty has a bitwise structure.
  * Each property must have:
  *   - an unique id from range 0x0100 - 0xffff
@@ -95,10 +95,10 @@
  */
 enum VehicleProperty: int32_t {
 
-    /* Undefined property. */
+    /** Undefined property. */
     INVALID = 0x00000000,
 
-    /*
+    /**
      * VIN of vehicle
      *
      * @change_mode VehiclePropertyChangeMode:STATIC
@@ -110,7 +110,7 @@
         | VehiclePropertyType:STRING
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Maker name of vehicle
      *
      * @change_mode VehiclePropertyChangeMode:STATIC
@@ -122,7 +122,7 @@
         | VehiclePropertyType:STRING
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Model of vehicle
      *
      * @change_mode VehiclePropertyChangeMode:STATIC
@@ -134,7 +134,7 @@
         | VehiclePropertyType:STRING
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Model year of vehicle.
      *
      * @change_mode VehiclePropertyChangeMode:STATIC
@@ -147,7 +147,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Fuel capacity of the vehicle
      *
      * @change_mode VehiclePropertyChangeMode:STATIC
@@ -160,7 +160,7 @@
         | VehiclePropertyType:FLOAT
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Current odometer value of the vehicle
      *
      * @change_mode VehiclePropertyChangeMode:ON_CHANGE | VehiclePropertyChangeMode:CONTINUOUS
@@ -173,7 +173,7 @@
         | VehiclePropertyType:FLOAT
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Speed of the vehicle
      *
      * @change_mode VehiclePropertyChangeMode:ON_CHANGE|VehiclePropertyChangeMode:CONTINUOUS
@@ -186,7 +186,7 @@
         | VehiclePropertyType:FLOAT
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Temperature of engine coolant
      *
      * @change_mode VehiclePropertyChangeMode:ON_CHANGE|VehiclePropertyChangeMode:CONTINUOUS
@@ -199,7 +199,7 @@
         | VehiclePropertyType:FLOAT
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Temperature of engine oil
      *
      * @change_mode VehiclePropertyChangeMode:ON_CHANGE|VehiclePropertyChangeMode:CONTINUOUS
@@ -212,7 +212,7 @@
         | VehiclePropertyType:FLOAT
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Engine rpm
      *
      * @change_mode VehiclePropertyChangeMode:ON_CHANGE|VehiclePropertyChangeMode:CONTINUOUS
@@ -225,7 +225,7 @@
         | VehiclePropertyType:FLOAT
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Currently selected gear
      *
      * @change_mode VehiclePropertyChangeMode:ON_CHANGE
@@ -238,7 +238,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Current gear. In non-manual case, selected gear does not necessarily
      * match the current gear.
      *
@@ -252,7 +252,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Parking brake state.
      *
      * @change_mode VehiclePropertyChangeMode:ON_CHANGE
@@ -264,7 +264,7 @@
         | VehiclePropertyType:BOOLEAN
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Driving status policy.
      *
      * @change_mode VehiclePropertyChangeMode:ON_CHANGE
@@ -277,7 +277,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Warning for fuel low level.
      *
      * @change_mode VehiclePropertyChangeMode:ON_CHANGE
@@ -289,7 +289,7 @@
         | VehiclePropertyType:BOOLEAN
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Night mode or not.
      *
      * @change_mode VehiclePropertyChangeMode:ON_CHANGE
@@ -301,7 +301,7 @@
         | VehiclePropertyType:BOOLEAN
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * State of the vehicles turn signals
      *
      * Values from VehicleTurnSignal
@@ -315,7 +315,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Represents ignition state
      *
      * @change_mode VehiclePropertyChangeMode:ON_CHANGE
@@ -327,7 +327,7 @@
             | VehiclePropertyType:INT32
             | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Fan speed setting
      *
      * IVehicle#set may return StatusCode::NOT_AVAILABLE and IVehicle#get is not
@@ -343,7 +343,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:ZONE),
 
-    /*
+    /**
      * Fan direction setting
      *
      * IVehicle#set may return StatusCode::NOT_AVAILABLE and IVehicle#get is not
@@ -360,7 +360,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:ZONE),
 
-    /*
+    /**
      * HVAC current temperature.
      *
      * IVehicle#set may return StatusCode::NOT_AVAILABLE and IVehicle#get is not
@@ -376,7 +376,7 @@
         | VehiclePropertyType:FLOAT
         | VehicleArea:ZONE),
 
-    /*
+    /**
      * HVAC, target temperature set.
      *
      * IVehicle#set may return StatusCode::NOT_AVAILABLE and IVehicle#get is not
@@ -392,7 +392,7 @@
         | VehiclePropertyType:FLOAT
         | VehicleArea:ZONE),
 
-    /*
+    /**
      * On/off defrost
      *
      * IVehicle#set may return StatusCode::NOT_AVAILABLE and IVehicle#get is not
@@ -408,7 +408,7 @@
         | VehiclePropertyType:BOOLEAN
         | VehicleArea:WINDOW),
 
-    /*
+    /**
      * On/off AC
      *
      * IVehicle#set may return StatusCode::NOT_AVAILABLE and IVehicle#get is not
@@ -425,7 +425,7 @@
         | VehiclePropertyType:BOOLEAN
         | VehicleArea:ZONE),
 
-    /*
+    /**
      * On/off max AC
      *
      * IVehicle#set may return StatusCode::NOT_AVAILABLE and IVehicle#get is not
@@ -441,7 +441,7 @@
         | VehiclePropertyType:BOOLEAN
         | VehicleArea:ZONE),
 
-    /*
+    /**
      * On/off max defrost
      *
      * IVehicle#set may return StatusCode::NOT_AVAILABLE and IVehicle#get is not
@@ -457,7 +457,7 @@
         | VehiclePropertyType:BOOLEAN
         | VehicleArea:ZONE),
 
-    /*
+    /**
      * On/off re-circulation
      *
      * IVehicle#set may return StatusCode::NOT_AVAILABLE and IVehicle#get is not
@@ -473,7 +473,7 @@
         | VehiclePropertyType:BOOLEAN
         | VehicleArea:ZONE),
 
-    /*
+    /**
      * On/off dual. This must be defined per each row.
      *
      * IVehicle#set may return StatusCode::NOT_AVAILABLE and IVehicle#get is not
@@ -489,7 +489,7 @@
         | VehiclePropertyType:BOOLEAN
         | VehicleArea:ZONE),
 
-    /*
+    /**
      * On/off automatic mode
      *
      * IVehicle#set may return StatusCode::NOT_AVAILABLE and IVehicle#get is not
@@ -505,7 +505,7 @@
         | VehiclePropertyType:BOOLEAN
         | VehicleArea:ZONE),
 
-    /*
+    /**
      * Seat temperature
      *
      * Negative values indicate cooling.
@@ -622,7 +622,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:ZONE),
 
-    /*
+    /**
      * Represents power state for HVAC. Some HVAC properties must require
      * matching power to be turned on to get out of OFF state. For non-zoned
      * HVAC properties, VEHICLE_ALL_ZONE corresponds to global power state.
@@ -640,7 +640,7 @@
         | VehiclePropertyType:BOOLEAN
         | VehicleArea:ZONE),
 
-    /*
+    /**
      * Outside temperature
      *
      * @change_mode VehiclePropertyChangeMode:ON_CHANGE|VehiclePropertyChangeMode:CONTINUOUS
@@ -653,7 +653,7 @@
         | VehiclePropertyType:FLOAT
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Cabin temperature
      *
      * @change_mode VehiclePropertyChangeMode:ON_CHANGE|VehiclePropertyChangeMode:CONTINUOUS
@@ -666,7 +666,7 @@
         | VehiclePropertyType:FLOAT
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Radio presets stored on the Car radio module. The data type used is int32
      * array with the following fields:
      * <ul>
@@ -690,7 +690,7 @@
         | VehiclePropertyType:INT32_VEC
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Represents audio focus state of Android side. Note that car's audio
      * module must own audio focus and grant audio focus to Android side when
      * requested by Android side. The focus has both per stream characteristics
@@ -776,7 +776,7 @@
         | VehiclePropertyType:INT32_VEC
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * A property to allow external component to control audio focus. Depending on
      * H/W architecture, audio HAL may need to control audio focus while vehicle
      * HAL is still interacting with upper layer. In such case, audio HAL may set
@@ -793,7 +793,7 @@
         | VehiclePropertyType:INT32_VEC
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Property to control audio volume of each audio context.
      *
      * VehiclePropConfig
@@ -830,7 +830,7 @@
         | VehiclePropertyType:INT32_VEC
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Property to allow audio volume sync from external components like audio HAL.
      * Some vehicle HAL implementation may get volume control from audio HAL and in such
      * case, setting AUDIO_VOLUME_EXT_SYNC property may trigger event in AUDIO_VOLUME property.
@@ -846,7 +846,7 @@
         | VehiclePropertyType:INT32_VEC
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Property for handling volume limit set by user. This limits maximum
      * volume that can be set per each context or physical stream.
      *
@@ -880,7 +880,7 @@
         | VehiclePropertyType:INT32_VEC
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Property to share audio routing policy of android side. This property is
      * set at the beginning to pass audio policy in android side down to
      * vehicle HAL and car audio module.
@@ -908,7 +908,7 @@
         | VehiclePropertyType:INT32_VEC
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Property to return audio H/W variant type used in this car. This allows
      * android side to support different audio policy based on H/W variant used.
      * Note that other components like CarService may need overlay update to
@@ -926,7 +926,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Property to pass hint on external audio routing. When android side
      * request focus with VehicleAudioExtFocusflag, this
      * property must be set before setting AUDIO_FOCUS property as a hint for
@@ -1028,7 +1028,7 @@
         | VehiclePropertyType:STRING
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Property to control power state of application processor
      *
      * It is assumed that AP's power state is controller by separate power
@@ -1054,7 +1054,7 @@
         | VehiclePropertyType:INT32_VEC
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Property to represent brightness of the display. Some cars have single
      * control for the brightness of all displays and this property is to share
      * change in that control.
@@ -1073,7 +1073,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Property to report bootup reason for the current power on. This is a
      * static property that will not change for the whole duration until power
      * off. For example, even if user presses power on button after automatic
@@ -1091,7 +1091,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Property to feed H/W input events to android
      *
      * int32Values[0] : action defined by VehicleHwKeyInputAction
@@ -1109,7 +1109,7 @@
         | VehiclePropertyType:INT32_VEC
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Property to define instrument cluster information.
      * For VehicleInstrumentClusterType:EXTERNAL_DISPLAY:
      *  READ:
@@ -1143,7 +1143,7 @@
         | VehiclePropertyType:INT32_VEC
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Current date and time, encoded as Unix time.
      * This value denotes the number of seconds that have elapsed since
      * 1/1/1970.
@@ -1158,7 +1158,7 @@
         | VehiclePropertyType:INT64
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Current time only.
      * Some vehicles may not keep track of date.  This property only affects
      * the current time, in seconds during the day.  Thus, the max value for
@@ -1174,7 +1174,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Door position
      *
      * This is an integer in case a door may be set to a particular position.
@@ -1192,7 +1192,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:DOOR),
 
-    /*
+    /**
      * Door move
      *
      * @change_mode VehiclePropertyChangeMode:ON_CHANGE
@@ -1204,7 +1204,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:DOOR),
 
-    /*
+    /**
      * Door lock
      *
      * 'true' indicates door is locked
@@ -1218,7 +1218,7 @@
         | VehiclePropertyType:BOOLEAN
         | VehicleArea:DOOR),
 
-    /*
+    /**
      * Mirror Z Position
      *
      * Positive value indicates tilt upwards, negative value is downwards
@@ -1232,7 +1232,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:MIRROR),
 
-    /*
+    /**
      * Mirror Z Move
      *
      * Positive value indicates tilt upwards, negative value is downwards
@@ -1246,7 +1246,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:MIRROR),
 
-    /*
+    /**
      * Mirror Y Position
      *
      * Positive value indicate tilt right, negative value is left
@@ -1260,7 +1260,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:MIRROR),
 
-    /*
+    /**
      * Mirror Y Move
      *
      * Positive value indicate tilt right, negative value is left
@@ -1274,7 +1274,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:MIRROR),
 
-    /*
+    /**
      * Mirror Lock
      *
      * True indicates mirror positions are locked and not changeable
@@ -1288,7 +1288,7 @@
         | VehiclePropertyType:BOOLEAN
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Mirror Fold
      *
      * True indicates mirrors are folded
@@ -1302,7 +1302,7 @@
         | VehiclePropertyType:BOOLEAN
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Seat memory select
      *
      * This parameter selects the memory preset to use to select the seat
@@ -1322,7 +1322,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Seat memory set
      *
      * This setting allows the user to save the current seat position settings
@@ -1338,7 +1338,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Seatbelt buckled
      *
      * True indicates belt is buckled.
@@ -1355,7 +1355,7 @@
         | VehiclePropertyType:BOOLEAN
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Seatbelt height position
      *
      * Adjusts the shoulder belt anchor point.
@@ -1371,7 +1371,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Seatbelt height move
      *
      * @change_mode VehiclePropertyChangeMode:ON_CHANGE
@@ -1383,7 +1383,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Seat fore/aft position
      *
      * Sets the seat position forward (closer to steering wheel) and backwards.
@@ -1399,7 +1399,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Seat fore/aft move
      *
      * Moves the seat position forward and aft.
@@ -1413,7 +1413,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Seat backrest angle 1 position
      *
      * Backrest angle 1 is the actuator closest to the bottom of the seat.
@@ -1429,7 +1429,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Seat backrest angle 1 move
      *
      * Moves the backrest forward or recline.
@@ -1443,7 +1443,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Seat backrest angle 2 position
      *
      * Backrest angle 2 is the next actuator up from the bottom of the seat.
@@ -1459,7 +1459,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Seat backrest angle 2 move
      *
      * Moves the backrest forward or recline.
@@ -1473,7 +1473,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Seat height position
      *
      * Sets the seat height.
@@ -1489,7 +1489,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Seat height move
      *
      * Moves the seat height.
@@ -1503,7 +1503,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Seat depth position
      *
      * Sets the seat depth, distance from back rest to front edge of seat.
@@ -1519,7 +1519,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Seat depth move
      *
      * Adjusts the seat depth.
@@ -1533,7 +1533,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Seat tilt position
      *
      * Sets the seat tilt.
@@ -1549,7 +1549,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Seat tilt move
      *
      * Tilts the seat.
@@ -1563,7 +1563,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Lumber fore/aft position
      *
      * Pushes the lumbar support forward and backwards
@@ -1579,7 +1579,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Lumbar fore/aft move
      *
      * Adjusts the lumbar support.
@@ -1593,7 +1593,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Lumbar side support position
      *
      * Sets the amount of lateral lumbar support.
@@ -1609,7 +1609,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Lumbar side support move
      *
      * Adjusts the amount of lateral lumbar support.
@@ -1623,7 +1623,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Headrest height position
      *
      * Sets the headrest height.
@@ -1639,7 +1639,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Headrest height move
      *
      * Moves the headrest up and down.
@@ -1653,7 +1653,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Headrest angle position
      *
      * Sets the angle of the headrest.
@@ -1669,7 +1669,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Headrest angle move
      *
      * Adjusts the angle of the headrest
@@ -1683,7 +1683,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Headrest fore/aft position
      *
      * Adjusts the headrest forwards and backwards.
@@ -1699,7 +1699,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Headrest fore/aft move
      *
      * @change_mode VehiclePropertyChangeMode:ON_CHANGE
@@ -1711,7 +1711,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:SEAT),
 
-    /*
+    /**
      * Window Position
      *
      * Max = window up / closed
@@ -1726,7 +1726,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Window Move
      *
      * Max = window up / closed
@@ -1743,7 +1743,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Window Vent Position
      *
      * This feature is used to control the vent feature on a sunroof.
@@ -1760,7 +1760,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Window Vent Move
      *
      * This feature is used to control the vent feature on a sunroof.
@@ -1777,7 +1777,7 @@
         | VehiclePropertyType:INT32
         | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Window Lock
      *
      * True indicates windows are locked and can't be moved.
@@ -1792,7 +1792,7 @@
         | VehicleArea:GLOBAL),
 };
 
-/*
+/**
  * Bit flags for fan direction
  */
 enum VehicleHvacFanDirection : int32_t {
@@ -1803,11 +1803,11 @@
   DEFROST_AND_FLOOR = 0x5,
 };
 
-/*
+/**
  * Constants relevant to radio.
  */
 enum VehicleRadioConstants : int32_t {
-  /* Minimum value for the radio preset */
+  /** Minimum value for the radio preset */
   VEHICLE_RADIO_PRESET_MIN_VALUE = 1,
 };
 
@@ -1815,7 +1815,7 @@
   REQUEST_GAIN = 0x1,
   REQUEST_GAIN_TRANSIENT = 0x2,
   REQUEST_GAIN_TRANSIENT_MAY_DUCK = 0x3,
-  /*
+  /**
    * This is for the case where android side plays sound like UI feedback
    * and car side does not need to duck existing playback as long as
    * requested stream is available.
@@ -1826,34 +1826,34 @@
 };
 
 enum VehicleAudioFocusState : int32_t {
-  /*
+  /**
    * Android side has permanent focus and can play allowed streams.
    */
   STATE_GAIN = 0x1,
 
-  /*
+  /**
    * Android side has transient focus and can play allowed streams.
    */
   STATE_GAIN_TRANSIENT = 0x2,
 
-  /*
+  /**
    * Car audio module is playing guidance kind of sound outside Android.
    * Android side can still play through allowed streams with ducking.
    */
   STATE_LOSS_TRANSIENT_CAN_DUCK = 0x3,
 
-  /*
+  /**
    * Car audio module is playing transient sound outside Android. Android side
    * must stop playing any sounds.
    */
   STATE_LOSS_TRANSIENT = 0x4,
 
-  /*
+  /**
    * Android side has lost focus and cannot play any sound.
    */
   STATE_LOSS = 0x5,
 
-  /*
+  /**
    * car audio module is playing safety critical sound, and Android side cannot
    * request focus until the current state is finished. car audio module
    * restore it to the previous state when it can allow Android to play.
@@ -1862,7 +1862,7 @@
 
 };
 
-/*
+/**
  * Flags to represent multiple streams by combining these.
  */
 enum VehicleAudioStreamFlag : int32_t {
@@ -1871,7 +1871,7 @@
   STREAM2_FLAG = (0x1 << 2),
 };
 
-/*
+/**
  * Represents stream number (always 0 to N -1 where N is max number of streams).
  * Can be used for audio related property expecting one stream.
  */
@@ -1880,27 +1880,27 @@
   STREAM1 = 1,
 };
 
-/*
+/**
  * Flag to represent external focus state (outside Android).
  */
 enum VehicleAudioExtFocusFlag : int32_t {
-  /*
+  /**
    * No external focus holder.
    */
   NONE_FLAG = 0x0,
 
-  /*
+  /**
    * Car side (outside Android) has component holding GAIN kind of focus state.
    */
   PERMANENT_FLAG = 0x1,
 
-  /*
+  /**
    * Car side (outside Android) has component holding GAIN_TRANSIENT kind of
    * focus state.
    */
   TRANSIENT_FLAG = 0x2,
 
-  /*
+  /**
    * Car side is expected to play something while focus is held by Android side.
    * One example can be radio attached in car side. But Android's radio app
    * still must have focus, and Android side must be in GAIN state, but
@@ -1909,14 +1909,14 @@
    */
   PLAY_ONLY_FLAG = 0x4,
 
-  /*
+  /**
    * Car side must mute any media including radio. This can be used with any
    * focus request including GAIN* and RELEASE.
    */
   MUTE_MEDIA_FLAG = 0x8,
 };
 
-/*
+/**
  * Index in int32Values for VehicleProperty#AUDIO_FOCUS property.
  */
 enum VehicleAudioFocusIndex : int32_t {
@@ -1926,65 +1926,65 @@
   AUDIO_CONTEXTS = 3,
 };
 
-/*
+/**
  * Flags to tell the current audio context.
  */
 enum VehicleAudioContextFlag : int32_t {
-  /* Music playback is currently active. */
+  /** Music playback is currently active. */
   MUSIC_FLAG = 0x1,
 
-  /* Navigation is currently running. */
+  /** Navigation is currently running. */
   NAVIGATION_FLAG = 0x2,
 
-  /* Voice command session is currently running. */
+  /** Voice command session is currently running. */
   VOICE_COMMAND_FLAG = 0x4,
 
-  /* Voice call is currently active. */
+  /** Voice call is currently active. */
   CALL_FLAG = 0x8,
 
-  /*
+  /**
    * Alarm is active.
    * This must be only used in VehicleProperty#AUDIO_ROUTING_POLICY.
    */
   ALARM_FLAG = 0x10,
 
-  /*
+  /**
    * Notification sound is active.
    * This must be only used in VehicleProperty#AUDIO_ROUTING_POLICY.
    */
   NOTIFICATION_FLAG = 0x20,
 
-  /*
+  /**
    * Context unknown. Only used for VehicleProperty#AUDIO_ROUTING_POLICY to
    * represent default stream for unknown contents.
    */
   UNKNOWN_FLAG = 0x40,
 
-  /* Safety alert / warning is played. */
+  /** Safety alert / warning is played. */
   SAFETY_ALERT_FLAG = 0x80,
 
-  /* CD / DVD kind of audio is played */
+  /** CD / DVD kind of audio is played */
   CD_ROM_FLAG = 0x100,
 
-  /* Aux audio input is played */
+  /** Aux audio input is played */
   AUX_AUDIO_FLAG = 0x200,
 
-  /* system sound like UI feedback */
+  /** system sound like UI feedback */
   SYSTEM_SOUND_FLAG = 0x400,
 
-  /* Radio is played */
+  /** Radio is played */
   RADIO_FLAG = 0x800,
 
-  /* Ext source is played. This is for tagging generic ext sources. */
+  /** Ext source is played. This is for tagging generic ext sources. */
   EXT_SOURCE_FLAG = 0x1000,
 };
 
-/*
+/**
  * flags to represent capability of audio volume property.
  * used in configArray[1] of VehiclePropConfig.
  */
 enum VehicleAudioVolumeCapabilityFlag : int32_t {
-  /*
+  /**
    * External audio module or vehicle hal has persistent storage
    * to keep the volume level. This must be set only when per context
    * volume level is supported. When this is set, audio volume level per
@@ -1998,7 +1998,7 @@
    */
   PERSISTENT_STORAGE = 0x1,
 
-  /*
+  /**
    * When this flag is set, the H/W can support only single master volume for
    * all streams.
    * There is no way to set volume level differently per each stream or context.
@@ -2006,13 +2006,13 @@
   MASTER_VOLUME_ONLY = 0x2,
 };
 
-/*
+/**
  * enum to represent audio volume state.
  */
 enum VehicleAudioVolumeState : int32_t {
   STATE_OK = 0,
 
-  /*
+  /**
    * Audio volume has reached volume limit set in
    * VehicleProperty#AUDIO_VOLUME_LIMIT and user's request to increase volume
    * further is not allowed.
@@ -2020,7 +2020,7 @@
   LIMIT_REACHED = 1,
 };
 
-/*
+/**
  * Index in int32Values for VehicleProperty#AUDIO_VOLUME property.
  */
 enum VehicleAudioVolumeIndex : int32_t {
@@ -2029,7 +2029,7 @@
   INDEX_STATE = 2,
 };
 
-/*
+/**
  * Index in int32Values for VehicleProperty#AUDIO_VOLUME_LIMIT property.
  */
 enum VehicleAudioVolumeLimitIndex : int32_t {
@@ -2037,7 +2037,7 @@
   MAX_VOLUME = 1,
 };
 
-/*
+/**
  * Index in int32Values for VehicleProperty#AUDIO_ROUTING_POLICY property.
  */
 enum VehicleAudioRoutingPolicyIndex : int32_t {
@@ -2045,12 +2045,12 @@
   CONTEXTS = 1,
 };
 
-/*
+/**
  * Flag to be used in VehiclePropConfig#configFlags for
  * VehicleProperty#AUDIO_HW_VARIANT.
  */
 enum VehicleAudioHwVariantConfigFlag : int32_t {
-  /*
+  /**
    * Flag to tell that radio is internal to android and radio must
    * be treated like other android stream like media.
    * When this flag is not set or AUDIO_HW_VARIANT does not exist,
@@ -2061,13 +2061,13 @@
 };
 
 enum VehicleApPowerStateConfigFlag : int32_t /* NOTE: type is guessed */ {
-  /*
+  /**
    * AP can enter deep sleep state. If not set, AP will always shutdown from
    * VehicleApPowerState#SHUTDOWN_PREPARE power state.
    */
   ENABLE_DEEP_SLEEP_FLAG = 0x1,
 
-  /*
+  /**
    * The power controller can power on AP from off state after timeout
    * specified in VehicleApPowerSet VEHICLE_AP_POWER_SET_SHUTDOWN_READY message.
    */
@@ -2075,19 +2075,19 @@
 };
 
 enum VehicleApPowerState : int32_t /* NOTE: type is guessed */ {
-  /* vehicle HAL will never publish this state to AP */
+  /** vehicle HAL will never publish this state to AP */
   OFF = 0,
 
-  /* vehicle HAL will never publish this state to AP */
+  /** vehicle HAL will never publish this state to AP */
   DEEP_SLEEP = 1,
 
-  /* AP is on but display must be off. */
+  /** AP is on but display must be off. */
   ON_DISP_OFF = 2,
 
-  /* AP is on with display on. This state allows full user interaction. */
+  /** AP is on with display on. This state allows full user interaction. */
   ON_FULL = 3,
 
-  /*
+  /**
    * The power controller has requested AP to shutdown. AP can either enter
    * sleep state or start full shutdown. AP can also request postponing
    * shutdown by sending VehicleApPowerSetState#SHUTDOWN_POSTPONE message. The
@@ -2100,30 +2100,30 @@
 };
 
 enum VehicleApPowerStateShutdownParam : int32_t {
-  /* AP must shutdown immediately. Postponing is not allowed. */
+  /** AP must shutdown immediately. Postponing is not allowed. */
   SHUTDOWN_IMMEDIATELY = 1,
 
-  /* AP can enter deep sleep instead of shutting down completely. */
+  /** AP can enter deep sleep instead of shutting down completely. */
   CAN_SLEEP = 2,
 
-  /* AP can only shutdown with postponing allowed. */
+  /** AP can only shutdown with postponing allowed. */
   SHUTDOWN_ONLY = 3,
 };
 
 enum VehicleApPowerSetState : int32_t /* NOTE: type is guessed */ {
-  /*
+  /**
    * AP has finished boot up, and can start shutdown if requested by power
    * controller.
    */
   BOOT_COMPLETE = 0x1,
 
-  /*
+  /**
    * AP is entering deep sleep state. How this state is implemented may vary
    * depending on each H/W, but AP's power must be kept in this state.
    */
   DEEP_SLEEP_ENTRY = 0x2,
 
-  /*
+  /**
    * AP is exiting from deep sleep state, and is in
    * VehicleApPowerState#SHUTDOWN_PREPARE state.
    * The power controller may change state to other ON states based on the
@@ -2131,7 +2131,7 @@
    */
   DEEP_SLEEP_EXIT = 0x3,
 
-  /*
+  /**
    * int32Values[1]: Time to postpone shutdown in ms. Maximum value can be
    *                 5000 ms.
    *                 If AP needs more time, it will send another POSTPONE
@@ -2139,7 +2139,7 @@
    */
   SHUTDOWN_POSTPONE = 0x4,
 
-  /*
+  /**
    * AP is starting shutting down. When system completes shutdown, everything
    * will stop in AP as kernel will stop all other contexts. It is
    * responsibility of vehicle HAL or lower level to synchronize that state
@@ -2158,7 +2158,7 @@
    */
   SHUTDOWN_START = 0x5,
 
-  /*
+  /**
    * User has requested to turn off headunit's display, which is detected in
    * android side.
    * The power controller may change the power state to
@@ -2166,7 +2166,7 @@
    */
   DISPLAY_OFF = 0x6,
 
-  /*
+  /**
    * User has requested to turn on headunit's display, most probably from power
    * key input which is attached to headunit. The power controller may change
    * the power state to VehicleApPowerState#ON_FULL.
@@ -2174,7 +2174,7 @@
   DISPLAY_ON = 0x7,
 };
 
-/*
+/**
  * Index in int32Values for VehicleProperty#AP_POWER_STATE property.
  */
 enum VehicleApPowerStateIndex : int32_t {
@@ -2182,23 +2182,23 @@
   ADDITIONAL = 1,
 };
 
-/*
+/**
  * Enum to represent bootup reason.
  */
 enum VehicleApPowerBootupReason : int32_t {
-  /*
+  /**
    * Power on due to user's pressing of power key or rotating of ignition
    * switch.
    */
   USER_POWER_ON = 0,
 
-  /*
+  /**
    * Automatic power on triggered by door unlock or any other kind of automatic
    * user detection.
    */
   USER_UNLOCK = 1,
 
-  /*
+  /**
    * Automatic power on triggered by timer. This only happens when AP has asked
    * wake-up after
    * certain time through time specified in
@@ -2208,40 +2208,40 @@
 };
 
 enum VehicleHwKeyInputAction : int32_t {
-  /* Key down */
+  /** Key down */
   ACTION_DOWN = 0,
 
-  /* Key up */
+  /** Key up */
   ACTION_UP = 1,
 };
 
 enum VehicleDisplay : int32_t {
-  /* center console */
+  /** center console */
   MAIN = 0,
 
   INSTRUMENT_CLUSTER = 1,
 };
 
-/*
+/**
  * Represents instrument cluster type available in system
  */
 enum VehicleInstrumentClusterType : int32_t {
-  /* Android has no access to instument cluster */
+  /** Android has no access to instument cluster */
   NONE = 0,
 
-  /*
+  /**
    * Instrument cluster can communicate through vehicle hal with additional
    * properties to exchange meta-data
    */
   HAL_INTERFACE = 1,
 
-  /*
+  /**
    * Instrument cluster is external display where android can render contents
    */
   EXTERNAL_DISPLAY = 2,
 };
 
-/*
+/**
  * Units used for int or float type with no attached enum types.
  */
 enum VehicleUnit : int32_t {
@@ -2263,17 +2263,17 @@
     YEAR           = 0x59,
 };
 
-  /*
+  /**
    * This describes how value of property can change.
    */
 enum VehiclePropertyChangeMode : int32_t {
-  /*
+  /**
    * Property of this type must never be changed. Subscription is not supported
    * for these properties.
    */
   STATIC = 0x00,
 
-  /*
+  /**
    * Property of this type must be reported when there is a change.
    * IVehicle#get call must return the current value.
    * Set operation for this property is assumed to be asynchronous. When the
@@ -2284,18 +2284,18 @@
    */
   ON_CHANGE = 0x01,
 
-  /*
+  /**
    * Property of this type change continuously and requires fixed rate of
    * sampling to retrieve the data.
    */
   CONTINUOUS = 0x02,
 
-  /*
+  /**
    * Property of this type may be polled to get the current value.
    */
   POLL = 0x03,
 
-  /*
+  /**
    * This is for property where change event must be sent only when the
    * value is set from external component. Normal value change must not trigger
    * event. For example, clock property can send change event only when it is
@@ -2305,7 +2305,7 @@
   ON_SET = 0x04,
 };
 
-/*
+/**
  * Property config defines the capabilities of it. User of the API
  * must first get the property config to understand the output from get()
  * commands and also to ensure that set() or events commands are in sync with
@@ -2319,7 +2319,7 @@
   READ_WRITE = 0x03,
 };
 
-/*
+/**
  * Car states.
  *
  * The driving states determine what features of the UI will be accessible.
@@ -2333,7 +2333,7 @@
   LIMIT_MESSAGE_LEN = 0x10,
 };
 
-/*
+/**
  * Various gears which can be selected by user and chosen in system.
  */
 enum VehicleGear: int32_t {
@@ -2353,7 +2353,7 @@
   GEAR_9 = 0x1000,
 };
 
-/*
+/**
  * Various zones in the car.
  *
  * Zones are used for Air Conditioning purposes and divide the car into physical
@@ -2379,7 +2379,7 @@
   WHOLE_CABIN = 0x80000000,
 };
 
-/*
+/**
  * Various Seats in the car.
  */
 enum VehicleAreaSeat : int32_t {
@@ -2394,7 +2394,7 @@
     ROW_3_RIGHT  = 0x0400
 };
 
-/*
+/**
  * Various windshields/windows in the car.
  */
 enum VehicleAreaWindow : int32_t {
@@ -2434,7 +2434,7 @@
 };
 
 struct VehicleAreaConfig {
-    /*
+    /**
      * Area id is ignored for VehiclePropertyGroup:GLOBAL properties.
      */
     int32_t areaId;
@@ -2450,32 +2450,32 @@
 };
 
 struct VehiclePropConfig {
-    /* Property identifier */
+    /** Property identifier */
     int32_t prop;
 
-    /*
+    /**
      * Defines if the property is read or write or both.
      */
     VehiclePropertyAccess access;
 
-    /*
+    /**
      * Defines the change mode of the property.
      */
     VehiclePropertyChangeMode changeMode;
 
-    /*
+    /**
      * Some of the properties may have associated areas (for example, some hvac
      * properties are associated with VehicleAreaZone), in these
      * cases the config may contain an ORed value for the associated areas.
      */
     int32_t supportedAreas;
 
-    /*
+    /**
      * Contains per-area configuration.
      */
     vec<VehicleAreaConfig> areaConfigs;
 
-    /*
+    /**
      * Configuration flags for this property.
      *
      * For example, it may store the number of presets that are stored by the
@@ -2483,70 +2483,70 @@
      */
     int32_t configFlags;
 
-    /* Contains additional configuration parameters */
+    /** Contains additional configuration parameters */
     vec<int32_t> configArray;
 
-    /*
+    /**
      * Some properties may require additional information passed over this
      * string. Most properties do not need to set this.
      */
     string configString;
 
-    /*
+    /**
      * Min sample rate in Hz.
      * Must be defined for VehiclePropertyChangeMode::CONTINUOUS
      */
     float minSampleRate;
 
-    /*
+    /**
      * Must be defined for VehiclePropertyChangeMode::CONTINUOUS
      * Max sample rate in Hz.
      */
     float maxSampleRate;
 };
 
-/*
+/**
  * Encapsulates the property name and the associated value. It
  * is used across various API calls to set values, get values or to register for
  * events.
  */
 struct VehiclePropValue {
-    /* Property identifier */
+    /** Property identifier */
     int32_t prop;
 
-    /* Time is elapsed nanoseconds since boot */
+    /** Time is elapsed nanoseconds since boot */
     int64_t timestamp;
 
-    /*
+    /**
      * Area type(s) for non-global property it must be one of the value from
      * VehicleArea* enums or 0 for global properties.
      */
     int32_t areaId;
 
-    /*
+    /**
      * Contains value for a single property. Depending on property data type of
      * this property (VehiclePropetyType) one field of this structure must be filled in.
      */
     struct RawValue {
-        /*
+        /**
          * This is used for properties of types VehiclePropertyType#INT
          * and VehiclePropertyType#INT_VEC
          */
         vec<int32_t> int32Values;
 
-        /*
+        /**
          * This is used for properties of types VehiclePropertyType#FLOAT
          * and VehiclePropertyType#FLOAT_VEC
          */
         vec<float> floatValues;
 
-        /* This is used for properties of type VehiclePropertyType#INT64 */
+        /** This is used for properties of type VehiclePropertyType#INT64 */
         vec<int64_t> int64Values;
 
-        /* This is used for properties of type VehiclePropertyType#BYTES */
+        /** This is used for properties of type VehiclePropertyType#BYTES */
         vec<uint8_t> bytes;
 
-        /* This is used for properties of type VehiclePropertyType#STRING */
+        /** This is used for properties of type VehiclePropertyType#STRING */
         string stringValue;
     };
 
@@ -2556,53 +2556,53 @@
 enum VehicleIgnitionState : int32_t {
     UNDEFINED = 0,
 
-    /* Steering wheel is locked */
+    /** Steering wheel is locked */
     LOCK = 1,
 
-     /*
+     /**
       * Steering wheel is not locked, engine and all accessories are OFF. If
       * car can be in LOCK and OFF state at the same time than HAL must report
       * LOCK state.
       */
     OFF,
 
-    /*
+    /**
      * Typically in this state accessories become available (e.g. radio).
      * Instrument cluster and engine are turned off
      */
     ACC,
 
-    /*
+    /**
      * Ignition is in state ON. Accessories and instrument cluster available,
      * engine might be running or ready to be started.
      */
     ON,
 
-    /* Typically in this state engine is starting (cranking). */
+    /** Typically in this state engine is starting (cranking). */
     START
 };
 
 
-/*
+/**
  * Represent the operation where the current error has happened.
  */
 enum VehiclePropertyOperation : int32_t {
-    /*
+    /**
      * Generic error to this property which is not tied to any operation.
      */
     GENERIC = 0,
 
-    /*
+    /**
      * Error happened while handling property set.
      */
     SET = 1,
 
-    /*
+    /**
      * Error happened while handling property get.
      */
     GET = 2,
 
-    /*
+    /**
      * Error happened while handling property subscription.
      */
     SUBSCRIBE = 3,
@@ -2612,13 +2612,13 @@
 enum SubscribeFlags : int32_t {
   UNDEFINED = 0x0,
 
-  /*
+  /**
    * Subscribe to event that was originated in vehicle HAL
    * (most likely this event came from the vehicle itself).
    */
   HAL_EVENT = 0x1,
 
-  /*
+  /**
    * Use this flag to subscribe on events when IVehicle#set(...) was called by
    * vehicle HAL's client (e.g. Car Service).
    */
@@ -2627,20 +2627,20 @@
   DEFAULT = HAL_EVENT,
 };
 
-/*
+/**
  * Encapsulates information about subscription to vehicle property events.
  */
 struct SubscribeOptions {
-  /* Property to subscribe */
+  /** Property to subscribe */
   int32_t propId;
 
-  /*
+  /**
    * Area ids - this must be a bit mask of areas to subscribe or 0 to subscribe
    * to all areas.
    */
   int32_t vehicleAreas;
 
-  /*
+  /**
    * Sample rate in Hz.
    *
    * Must be provided for properties with
@@ -2651,31 +2651,31 @@
    */
   float sampleRate;
 
-  /* Flags that indicate what kind of events listen to. */
+  /** Flags that indicate what kind of events listen to. */
   SubscribeFlags flags;
 };
 
-/* Error codes used in vehicle HAL interface. */
+/** Error codes used in vehicle HAL interface. */
 enum StatusCode : int32_t {
   OK = 0,
 
-  /* Try again. */
+  /** Try again. */
   TRY_AGAIN = 1,
 
-  /* Invalid argument provided. */
+  /** Invalid argument provided. */
   INVALID_ARG = 2,
 
-  /*
+  /**
    * This code must be returned when device that associated with the vehicle
    * property is not available. For example, when client tries to set HVAC
    * temperature when the whole HVAC unit is turned OFF.
    */
   NOT_AVAILABLE = 3,
 
-  /* Access denied */
+  /** Access denied */
   ACCESS_DENIED = 4,
 
-  /* Something unexpected has happened in Vehicle HAL */
+  /** Something unexpected has happened in Vehicle HAL */
   INTERNAL_ERROR = 5,
 };
 
diff --git a/automotive/vehicle/2.1/IVehicle.hal b/automotive/vehicle/2.1/IVehicle.hal
index 5b6a23f..a22d1e6 100644
--- a/automotive/vehicle/2.1/IVehicle.hal
+++ b/automotive/vehicle/2.1/IVehicle.hal
@@ -18,7 +18,7 @@
 
 import android.hardware.automotive.vehicle@2.0;
 
-/*
+/**
  * New revision of IVehicle interface that supports properties defined in
  * VehicleProperty enum version 2.1.
  *
diff --git a/automotive/vehicle/2.1/types.hal b/automotive/vehicle/2.1/types.hal
index 9b219b2..08dc144 100644
--- a/automotive/vehicle/2.1/types.hal
+++ b/automotive/vehicle/2.1/types.hal
@@ -18,11 +18,11 @@
 
 import android.hardware.automotive.vehicle@2.0;
 
-/*
+/**
  * Extension of VehicleProperty enum declared in Vehicle HAL 2.0
  */
 enum VehicleProperty: @2.0::VehicleProperty {
-    /*
+    /**
      * Reports wheel rotational distance in meters since last wheel tick
      * event
      *
@@ -44,7 +44,7 @@
       | VehiclePropertyType:FLOAT_VEC
       | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * OBD2 Live Sensor Data
      *
      * This property uses COMPLEX data to send a snapshot of the current (live)
@@ -84,7 +84,7 @@
       | VehiclePropertyType:COMPLEX
       | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * OBD2 Freeze Frame Sensor Data
      *
      * This property uses COMPLEX data to send a snapshot of the values of the
@@ -132,7 +132,7 @@
       | VehiclePropertyType:COMPLEX
       | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * OBD2 Freeze Frame Information
      *
      * This property describes the current freeze frames stored in vehicle
@@ -153,7 +153,7 @@
       | VehiclePropertyType:COMPLEX
       | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * OBD2 Freeze Frame Clear
      *
      * This property allows deletion of any of the freeze frames stored in
@@ -175,7 +175,7 @@
       | VehiclePropertyType:COMPLEX
       | VehicleArea:GLOBAL),
 
-    /*
+    /**
      * Vehicle Maps Service (VMS) message
      *
      * This property uses COMPLEX data to communicate vms messages.
@@ -196,7 +196,7 @@
         | VehicleArea:GLOBAL),
 };
 
-/* The status of a fuel system as described by the OBD2 specification. */
+/** The status of a fuel system as described by the OBD2 specification. */
 enum FuelSystemStatus : int32_t {
   OPEN_INSUFFICIENT_ENGINE_TEMPERATURE = 1,
 
@@ -209,14 +209,14 @@
   CLOSED_LOOP_BUT_FEEDBACK_FAULT = 16,
 };
 
-/* Defines which ignition monitors are available to be read. */
+/** Defines which ignition monitors are available to be read. */
 enum IgnitionMonitorKind : int32_t {
   SPARK = 0,
 
   COMPRESSION = 1,
 };
 
-/* These ignition monitors are common to both SPARK and COMPRESSION. */
+/** These ignition monitors are common to both SPARK and COMPRESSION. */
 enum CommonIgnitionMonitors : int32_t {
   COMPONENTS_AVAILABLE = 0x1 << 0,
   COMPONENTS_INCOMPLETE = 0x1 << 1,
@@ -228,7 +228,7 @@
   MISFIRE_INCOMPLETE = 0x1 << 5,
 };
 
-/* Ignition monitors available for SPARK vehicles. */
+/** Ignition monitors available for SPARK vehicles. */
 enum SparkIgnitionMonitors : CommonIgnitionMonitors {
   EGR_AVAILABLE = 0x1 << 6,
   EGR_INCOMPLETE = 0x1 << 7,
@@ -255,7 +255,7 @@
   CATALYST_INCOMPLETE = 0x1 << 21,
 };
 
-/* Ignition monitors only available for COMPRESSION vehicles. */
+/** Ignition monitors only available for COMPRESSION vehicles. */
 enum CompressionIgnitionMonitors : CommonIgnitionMonitors {
   EGR_OR_VVT_AVAILABLE = 0x1 << 6,
   EGR_OR_VVT_INCOMPLETE = 0x1 << 7,
@@ -336,7 +336,7 @@
   BIFUEL_RUNNING_DIESEL = 23,
 };
 
-/*
+/**
  * This enum provides the canonical mapping for sensor properties that have an integer value.
  * The ordering of the values is taken from the OBD2 specification.
  * Some of the properties are represented as an integer mapping to another enum. In those cases
@@ -344,15 +344,15 @@
  * Any value greater than the last reserved index is available to vendors to map their extensions.
  */
 enum Obd2IntegerSensorIndex : int32_t {
-  /* refer to FuelSystemStatus for a description of this value. */
+  /** refer to FuelSystemStatus for a description of this value. */
   FUEL_SYSTEM_STATUS = 0,
 
   MALFUNCTION_INDICATOR_LIGHT_ON = 1,
 
-  /* refer to IgnitionMonitorKind for a description of this value. */
+  /** refer to IgnitionMonitorKind for a description of this value. */
   IGNITION_MONITORS_SUPPORTED = 2,
 
-  /*
+  /**
    * The value of this sensor is a bitmask that specifies whether ignition-specific
    * tests are available and whether they are complete. The semantics of the individual
    * bits in this value are given by, respectively, SparkIgnitionMonitors and
@@ -362,7 +362,7 @@
 
   INTAKE_AIR_TEMPERATURE = 4,
 
-  /* refer to SecondaryAirStatus for a description of this value. */
+  /** refer to SecondaryAirStatus for a description of this value. */
   COMMANDED_SECONDARY_AIR_STATUS = 5,
 
   NUM_OXYGEN_SENSORS_PRESENT = 6,
@@ -395,7 +395,7 @@
 
   MAX_AIR_FLOW_RATE_FROM_MASS_AIR_FLOW_SENSOR = 20,
 
-  /* refer to FuelType for a description of this value. */
+  /** refer to FuelType for a description of this value. */
   FUEL_TYPE = 21,
 
   FUEL_RAIL_ABSOLUTE_PRESSURE = 22,
@@ -421,7 +421,7 @@
   LAST_SYSTEM_INDEX = ENGINE_PERCENT_TORQUE_DATA_POINT4,
 };
 
-/*
+/**
  * This enum provides the canonical mapping for sensor properties that have a floating-point value.
  * The ordering of the values is taken from the OBD2 specification.
  * Any value greater than the last reserved index is available to vendors to map their extensions.
@@ -572,34 +572,34 @@
   LAST_SYSTEM_INDEX = ENGINE_FUEL_RATE,
 };
 
-/*
+/**
  * This enum lists the types of supported VMS messages.
  */
 enum VmsMessageType : int32_t {
-  /* A client subscribes to a layer. */
+  /** A client subscribes to a layer. */
   SUBSCRIBE = 1,
 
-  /* A client unsubscribes from a layer. */
+  /** A client unsubscribes from a layer. */
   UNSUBSCRIBE = 2,
 
-  /* A client publishes a data packet. */
+  /** A client publishes a data packet. */
   DATA = 3,
 };
 
-/*
+/**
  * This enum provides the canonical mapping for VMS properties that have an
  * integer value.
  */
 enum VmsMessageIntegerValuesIndex : int32_t {
-  /* The message type as enumerated by VmsMessageType enum. */
+  /** The message type as enumerated by VmsMessageType enum. */
   VMS_MESSAGE_TYPE = 0,
 
-  /* The layer ID as defined in the vms protocol. */
+  /** The layer ID as defined in the vms protocol. */
   VMS_LAYER_ID = 1,
 
-  /* The version of the VMS layer. */
+  /** The version of the VMS layer. */
   VMS_LAYER_VERSION = 2,
 
-  /* The number of bytes in the payload */
+  /** The number of bytes in the payload */
   VMS_PAYLOAD_SIZE_BYTES = 3,
 };
diff --git a/biometrics/fingerprint/2.1/IBiometricsFingerprint.hal b/biometrics/fingerprint/2.1/IBiometricsFingerprint.hal
index 0b92848..14f3005 100644
--- a/biometrics/fingerprint/2.1/IBiometricsFingerprint.hal
+++ b/biometrics/fingerprint/2.1/IBiometricsFingerprint.hal
@@ -19,7 +19,7 @@
 import IBiometricsFingerprintClientCallback;
 
 interface IBiometricsFingerprint {
-  /*
+  /**
    * Set notification callback:
    * Registers a user function that must receive notifications from the HAL
    * This call must block if the HAL state machine is in busy state until HAL
@@ -32,7 +32,7 @@
   setNotify(IBiometricsFingerprintClientCallback clientCallback)
       generates (uint64_t deviceId);
 
-  /*
+  /**
    * 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
@@ -47,7 +47,7 @@
   @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
@@ -69,7 +69,7 @@
   enroll(uint8_t[69] hat, uint32_t gid, uint32_t timeoutSec)
       generates (RequestStatus 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.
@@ -79,7 +79,7 @@
   @callflow(next={"authenticate", "setActiveGroup", "enumerate", "remove"})
   postEnroll() generates (RequestStatus 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
@@ -91,7 +91,7 @@
   @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.
@@ -102,7 +102,7 @@
     "setActiveGroup"})
   cancel() generates (RequestStatus debugErrno);
 
-  /*
+  /**
    * Enumerate all the fingerprint templates found in the directory set by
    * setActiveGroup():
    * For each template found a notify() must be called with:
@@ -116,7 +116,7 @@
   @callflow(next={"remove", "enroll", "authenticate", "setActiveGroup"})
   enumerate() generates (RequestStatus debugErrno);
 
-  /*
+  /**
    * Fingerprint remove request:
    * Deletes fingerprint template(s).
    * Works only within the path set by setActiveGroup().
@@ -136,7 +136,7 @@
     "setActiveGroup"})
   remove(uint32_t gid, uint32_t fid) generates (RequestStatus 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.
@@ -150,7 +150,7 @@
   setActiveGroup(uint32_t gid, string storePath)
       generates (RequestStatus debugErrno);
 
-  /*
+  /**
    * Authenticates an operation identified by operationId
    *
    * @param operationId operation id.
diff --git a/biometrics/fingerprint/2.1/types.hal b/biometrics/fingerprint/2.1/types.hal
index e389773..7402085 100644
--- a/biometrics/fingerprint/2.1/types.hal
+++ b/biometrics/fingerprint/2.1/types.hal
@@ -16,7 +16,7 @@
 
 package android.hardware.biometrics.fingerprint@2.1;
 
-/*
+/**
  * Request status indicates whether the request is accepted by the vendor
  * implementation or not. These values are taken from the errno set,
  * except for the SYS_UNKNOWN
@@ -37,7 +37,7 @@
   SYS_ETIMEDOUT = -110,
 };
 
-/*
+/**
  * 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.
@@ -49,27 +49,27 @@
  * followed by ERROR_CANCELED.
  */
 enum FingerprintError : int32_t {
-  /* Used for testing, no error returned */
+  /** Used for testing, no error returned */
   ERROR_NO_ERROR = 0,
-  /* The hardware has an error that can't be resolved. */
+  /** The hardware has an error that can't be resolved. */
   ERROR_HW_UNAVAILABLE = 1,
-  /* Bad data; operation can't continue */
+  /** Bad data; operation can't continue */
   ERROR_UNABLE_TO_PROCESS = 2,
-  /* The operation has timed out waiting for user input. */
+  /** The operation has timed out waiting for user input. */
   ERROR_TIMEOUT = 3,
-  /* No space available to store a template */
+  /** No space available to store a template */
   ERROR_NO_SPACE = 4,
-  /* The current operation has been canceled */
+  /** The current operation has been canceled */
   ERROR_CANCELED = 5,
-  /* Unable to remove a template */
+  /** Unable to remove a template */
   ERROR_UNABLE_TO_REMOVE = 6,
-  /* The hardware is in lockout due to too many attempts */
+  /** The hardware is in lockout due to too many attempts */
   ERROR_LOCKOUT = 7,
-  /* Vendor-specific error message */
+  /** Vendor-specific error message */
   ERROR_VENDOR = 8
 };
 
-/*
+/**
  * 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
@@ -80,41 +80,43 @@
  */
 enum FingerprintAcquiredInfo : int32_t {
   ACQUIRED_GOOD = 0,
-  /* sensor needs more data, i.e. longer swipe. */
+  /** sensor needs more data, i.e. longer swipe. */
   ACQUIRED_PARTIAL = 1,
-  /* image doesn't contain enough detail for recognition*/
+  /**
+   * image doesn't contain enough detail for recognition*/
   ACQUIRED_INSUFFICIENT = 2,
-  /* sensor needs to be cleaned */
+  /** sensor needs to be cleaned */
   ACQUIRED_IMAGER_DIRTY = 3,
-  /* mostly swipe-type sensors; not enough data collected */
+  /** mostly swipe-type sensors; not enough data collected */
   ACQUIRED_TOO_SLOW = 4,
-  /* vendor-specific acquisition messages start here */
+  /** vendor-specific acquisition messages start here */
   ACQUIRED_TOO_FAST = 5,
-  /* vendor-specific acquisition messages */
+  /** vendor-specific acquisition messages */
   ACQUIRED_VENDOR = 6
 };
 
 struct FingerprintFingerId {
-  /* Group ID */
+  /** Group ID */
   uint32_t gid;
-  /* Fingerprint template ID */
+  /** Fingerprint template ID */
   uint32_t fid;
 };
 
 struct FingerprintEnroll {
-  /* Template ID */
+  /** Template ID */
   FingerprintFingerId finger;
-  /* samplesRemaining goes from N (no data collected, but N scans needed)
+  /**
+   * 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 */
+  /** Vendor specific message. Used for user guidance */
   uint64_t msg;
 };
 
 struct FingerprintIterator {
-  /* Template ID */
+  /** Template ID */
   FingerprintFingerId finger;
-  /* How many templates remain to iterate through */
+  /** How many templates remain to iterate through */
   uint32_t remainingTemplates;
 };
 
@@ -122,18 +124,18 @@
 typedef FingerprintIterator FingerprintRemoved;
 
 struct FingerprintAcquired {
-  /* information about the image */
+  /** information about the image */
   FingerprintAcquiredInfo acquiredInfo;
 };
 
 struct FingerprintAuthenticated {
-  /* Matched template ID */
+  /** Matched template ID */
   FingerprintFingerId finger;
-  /* Authentication result from the keymaster */
+  /** Authentication result from the keymaster */
   uint8_t[69] hat;
 };
 
-/* Run time type identification for the notify() call payload. */
+/** Run time type identification for the notify() call payload. */
 enum FingerprintMsgType : int32_t {
   ERROR = -1,
   ACQUIRED = 1,
diff --git a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
index 9a4efae..6156553 100644
--- a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
+++ b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
@@ -23,9 +23,8 @@
 #include <hardware/bluetooth.h>
 #include <utils/Log.h>
 
+#include <VtsHalHidlTargetCallbackBase.h>
 #include <VtsHalHidlTargetTestBase.h>
-#include <condition_variable>
-#include <mutex>
 #include <queue>
 
 using ::android::hardware::bluetooth::V1_0::IBluetoothHci;
@@ -92,6 +91,11 @@
 #define ACL_BROADCAST_ACTIVE_SLAVE (0x1 << 4)
 #define ACL_PACKET_BOUNDARY_COMPLETE (0x3 << 6)
 
+constexpr char kCallbackNameAclEventReceived[] = "aclDataReceived";
+constexpr char kCallbackNameHciEventReceived[] = "hciEventReceived";
+constexpr char kCallbackNameInitializationComplete[] = "initializationComplete";
+constexpr char kCallbackNameScoEventReceived[] = "scoDataReceived";
+
 class ThroughputLogger {
  public:
   ThroughputLogger(std::string task)
@@ -121,7 +125,8 @@
  public:
   virtual void SetUp() override {
     // currently test passthrough mode only
-    bluetooth = ::testing::VtsHalHidlTargetTestBase::getService<IBluetoothHci>();
+    bluetooth =
+        ::testing::VtsHalHidlTargetTestBase::getService<IBluetoothHci>();
     ASSERT_NE(bluetooth, nullptr);
     ALOGI("%s: getService() for bluetooth is %s", __func__,
           bluetooth->isRemote() ? "remote" : "local");
@@ -135,10 +140,6 @@
     max_sco_data_packets = 0;
 
     initialized = false;
-    initialized_count = 0;
-    event_count = 0;
-    acl_count = 0;
-    sco_count = 0;
     event_cb_count = 0;
     acl_cb_count = 0;
     sco_cb_count = 0;
@@ -146,7 +147,18 @@
     ASSERT_EQ(initialized, false);
     bluetooth->initialize(bluetooth_cb);
 
-    wait_for_init_callback();
+    bluetooth_cb->SetWaitTimeout(kCallbackNameInitializationComplete,
+                                 WAIT_FOR_INIT_TIMEOUT);
+    bluetooth_cb->SetWaitTimeout(kCallbackNameHciEventReceived,
+                                 WAIT_FOR_HCI_EVENT_TIMEOUT);
+    bluetooth_cb->SetWaitTimeout(kCallbackNameAclEventReceived,
+                                 WAIT_FOR_ACL_DATA_TIMEOUT);
+    bluetooth_cb->SetWaitTimeout(kCallbackNameScoEventReceived,
+                                 WAIT_FOR_SCO_DATA_TIMEOUT);
+
+    EXPECT_TRUE(
+        bluetooth_cb->WaitForCallback(kCallbackNameInitializationComplete)
+            .first);
 
     ASSERT_EQ(initialized, true);
   }
@@ -171,82 +183,10 @@
   void wait_for_command_complete_event(hidl_vec<uint8_t> cmd);
   int wait_for_completed_packets_event(uint16_t handle);
 
-  // Inform the test about the initialization callback
-  inline void notify_initialized() {
-    std::unique_lock<std::mutex> lock(initialized_mutex);
-    initialized_count++;
-    initialized_condition.notify_one();
-  }
-
-  // Test code calls this function to wait for the init callback
-  inline void wait_for_init_callback() {
-    std::unique_lock<std::mutex> lock(initialized_mutex);
-
-    auto start_time = std::chrono::steady_clock::now();
-    while (initialized_count == 0)
-      if (initialized_condition.wait_until(lock,
-                                     start_time + WAIT_FOR_INIT_TIMEOUT) ==
-          std::cv_status::timeout)
-        return;
-    initialized_count--;
-  }
-
-  // Inform the test about an event callback
-  inline void notify_event_received() {
-    std::unique_lock<std::mutex> lock(event_mutex);
-    event_count++;
-    event_condition.notify_one();
-  }
-
-  // Test code calls this function to wait for an event callback
-  inline void wait_for_event() {
-    std::unique_lock<std::mutex> lock(event_mutex);
-
-    auto start_time = std::chrono::steady_clock::now();
-    while (event_count == 0)
-      if (event_condition.wait_until(lock,
-                                     start_time + WAIT_FOR_HCI_EVENT_TIMEOUT) ==
-          std::cv_status::timeout)
-        return;
-    event_count--;
-  }
-
-  // Inform the test about an acl data callback
-  inline void notify_acl_data_received() {
-    std::unique_lock<std::mutex> lock(acl_mutex);
-    acl_count++;
-    acl_condition.notify_one();
-  }
-
-  // Test code calls this function to wait for an acl data callback
-  inline void wait_for_acl() {
-    std::unique_lock<std::mutex> lock(acl_mutex);
-
-    while (acl_count == 0)
-      acl_condition.wait_until(
-          lock, std::chrono::steady_clock::now() + WAIT_FOR_ACL_DATA_TIMEOUT);
-    acl_count--;
-  }
-
-  // Inform the test about a sco data callback
-  inline void notify_sco_data_received() {
-    std::unique_lock<std::mutex> lock(sco_mutex);
-    sco_count++;
-    sco_condition.notify_one();
-  }
-
-  // Test code calls this function to wait for a sco data callback
-  inline void wait_for_sco() {
-    std::unique_lock<std::mutex> lock(sco_mutex);
-
-    while (sco_count == 0)
-      sco_condition.wait_until(
-          lock, std::chrono::steady_clock::now() + WAIT_FOR_SCO_DATA_TIMEOUT);
-    sco_count--;
-  }
-
   // A simple test implementation of BluetoothHciCallbacks.
-  class BluetoothHciCallbacks : public IBluetoothHciCallbacks {
+  class BluetoothHciCallbacks
+      : public ::testing::VtsHalHidlTargetCallbackBase<BluetoothHidlTest>,
+        public IBluetoothHciCallbacks {
     BluetoothHidlTest& parent_;
 
    public:
@@ -256,7 +196,7 @@
 
     Return<void> initializationComplete(Status status) override {
       parent_.initialized = (status == Status::SUCCESS);
-      parent_.notify_initialized();
+      NotifyFromCallback(kCallbackNameInitializationComplete);
       ALOGV("%s (status = %d)", __func__, static_cast<int>(status));
       return Void();
     };
@@ -265,7 +205,7 @@
         const ::android::hardware::hidl_vec<uint8_t>& event) override {
       parent_.event_cb_count++;
       parent_.event_queue.push(event);
-      parent_.notify_event_received();
+      NotifyFromCallback(kCallbackNameHciEventReceived);
       ALOGV("Event received (length = %d)", static_cast<int>(event.size()));
       return Void();
     };
@@ -274,7 +214,7 @@
         const ::android::hardware::hidl_vec<uint8_t>& data) override {
       parent_.acl_cb_count++;
       parent_.acl_queue.push(data);
-      parent_.notify_acl_data_received();
+      NotifyFromCallback(kCallbackNameAclEventReceived);
       return Void();
     };
 
@@ -282,13 +222,13 @@
         const ::android::hardware::hidl_vec<uint8_t>& data) override {
       parent_.sco_cb_count++;
       parent_.sco_queue.push(data);
-      parent_.notify_sco_data_received();
+      NotifyFromCallback(kCallbackNameScoEventReceived);
       return Void();
     };
   };
 
   sp<IBluetoothHci> bluetooth;
-  sp<IBluetoothHciCallbacks> bluetooth_cb;
+  sp<BluetoothHciCallbacks> bluetooth_cb;
   std::queue<hidl_vec<uint8_t>> event_queue;
   std::queue<hidl_vec<uint8_t>> acl_queue;
   std::queue<hidl_vec<uint8_t>> sco_queue;
@@ -303,20 +243,6 @@
   int max_sco_data_packet_length;
   int max_acl_data_packets;
   int max_sco_data_packets;
-
- private:
-  std::mutex initialized_mutex;
-  std::mutex event_mutex;
-  std::mutex sco_mutex;
-  std::mutex acl_mutex;
-  std::condition_variable initialized_condition;
-  std::condition_variable event_condition;
-  std::condition_variable sco_condition;
-  std::condition_variable acl_condition;
-  int initialized_count;
-  int event_count;
-  int sco_count;
-  int acl_count;
 };
 
 // A class for test environment setup (kept since this file is a template).
@@ -334,7 +260,8 @@
   int status_event_count = 0;
   hidl_vec<uint8_t> event;
   do {
-    wait_for_event();
+    EXPECT_TRUE(
+        bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
     EXPECT_LT(static_cast<size_t>(0), event_queue.size());
     if (event_queue.size() == 0) {
       event.resize(0);
@@ -366,7 +293,8 @@
   hidl_vec<uint8_t> cmd = COMMAND_HCI_READ_BUFFER_SIZE;
   bluetooth->sendHciCommand(cmd);
 
-  wait_for_event();
+  EXPECT_TRUE(
+      bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
 
   EXPECT_LT(static_cast<size_t>(0), event_queue.size());
   if (event_queue.size() == 0) return;
@@ -420,7 +348,8 @@
     bluetooth->sendHciCommand(cmd);
 
     // Check the loopback of the HCI packet
-    wait_for_event();
+    EXPECT_TRUE(
+        bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
     hidl_vec<uint8_t> event = event_queue.front();
     event_queue.pop();
     size_t compare_length =
@@ -456,7 +385,8 @@
     bluetooth->sendScoData(sco_vector);
 
     // Check the loopback of the SCO packet
-    wait_for_sco();
+    EXPECT_TRUE(
+        bluetooth_cb->WaitForCallback(kCallbackNameScoEventReceived).first);
     hidl_vec<uint8_t> sco_loopback = sco_queue.front();
     sco_queue.pop();
 
@@ -501,7 +431,8 @@
     bluetooth->sendAclData(acl_vector);
 
     // Check the loopback of the ACL packet
-    wait_for_acl();
+    EXPECT_TRUE(
+        bluetooth_cb->WaitForCallback(kCallbackNameAclEventReceived).first);
     hidl_vec<uint8_t> acl_loopback = acl_queue.front();
     acl_queue.pop();
 
@@ -527,7 +458,8 @@
 
 // Return the number of completed packets reported by the controller.
 int BluetoothHidlTest::wait_for_completed_packets_event(uint16_t handle) {
-  wait_for_event();
+  EXPECT_TRUE(
+      bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
   int packets_processed = 0;
   while (event_queue.size() > 0) {
     hidl_vec<uint8_t> event = event_queue.front();
@@ -554,7 +486,8 @@
   int connection_event_count = 0;
   hidl_vec<uint8_t> event;
   do {
-    wait_for_event();
+    EXPECT_TRUE(
+        bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
     event = event_queue.front();
     event_queue.pop();
     EXPECT_GT(event.size(),
@@ -592,7 +525,7 @@
 }
 
 // Empty test: Initialize()/Close() are called in SetUp()/TearDown().
-TEST_F(BluetoothHidlTest, InitializeAndClose) { }
+TEST_F(BluetoothHidlTest, InitializeAndClose) {}
 
 // Send an HCI Reset with sendHciCommand and wait for a command complete event.
 TEST_F(BluetoothHidlTest, HciReset) {
@@ -607,7 +540,8 @@
   hidl_vec<uint8_t> cmd = COMMAND_HCI_READ_LOCAL_VERSION_INFORMATION;
   bluetooth->sendHciCommand(cmd);
 
-  wait_for_event();
+  EXPECT_TRUE(
+      bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
 
   hidl_vec<uint8_t> event = event_queue.front();
   event_queue.pop();
@@ -627,7 +561,8 @@
   hidl_vec<uint8_t> cmd = COMMAND_HCI_SHOULD_BE_UNKNOWN;
   bluetooth->sendHciCommand(cmd);
 
-  wait_for_event();
+  EXPECT_TRUE(
+      bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
 
   hidl_vec<uint8_t> event = event_queue.front();
   event_queue.pop();
diff --git a/broadcastradio/1.0/IBroadcastRadio.hal b/broadcastradio/1.0/IBroadcastRadio.hal
index c7fe62d..f599b10 100644
--- a/broadcastradio/1.0/IBroadcastRadio.hal
+++ b/broadcastradio/1.0/IBroadcastRadio.hal
@@ -21,7 +21,7 @@
 
 interface IBroadcastRadio {
 
-    /*
+    /**
      * Retrieve implementation properties.
      * @return result Operation completion status: OK in case of success,
      *                NOT_INITIALIZED in case of initialization error.
@@ -30,7 +30,7 @@
      */
     getProperties() generates (Result result, Properties properties);
 
-    /*
+    /**
      * Open a tuner interface for the requested configuration.
      * If no other tuner is opened, this will power on the radio hardware.
      * The hardware must be powered down when all tuner interface are released.
diff --git a/broadcastradio/1.0/IBroadcastRadioFactory.hal b/broadcastradio/1.0/IBroadcastRadioFactory.hal
index 82a97c4..ae82b07 100644
--- a/broadcastradio/1.0/IBroadcastRadioFactory.hal
+++ b/broadcastradio/1.0/IBroadcastRadioFactory.hal
@@ -20,7 +20,7 @@
 
 interface IBroadcastRadioFactory {
 
-    /*
+    /**
      * Connects to a broadcast radio HAL module for a given class
      * (AM/FM, Satellite, DAB).
      *
diff --git a/broadcastradio/1.0/ITuner.hal b/broadcastradio/1.0/ITuner.hal
index ae4b284..abbbd7a 100644
--- a/broadcastradio/1.0/ITuner.hal
+++ b/broadcastradio/1.0/ITuner.hal
@@ -20,7 +20,7 @@
 
 interface ITuner {
 
-    /*
+    /**
      * Apply current radio band configuration (band, range, channel spacing...).
      * Automatically cancels pending scan, step or tune.
      * ITunerCallback.configChange() method MUST be called once the
@@ -33,7 +33,7 @@
      */
     setConfiguration(BandConfig config) generates(Result result);
 
-    /*
+    /**
      * Retrieve current radio band configuration.
      * @return result OK if valid configuration is returned,
      *                NOT_INITIALIZED in case of initialization error.
@@ -41,7 +41,7 @@
      */
     getConfiguration() generates(Result result, BandConfig config);
 
-    /*
+    /**
      * Start scanning up to next valid station.
      * Shall be called only when a valid configuration has been applied.
      * Automatically cancels pending scan, step or tune.
@@ -57,7 +57,7 @@
      */
     scan(Direction direction, bool skipSubChannel) generates(Result result);
 
-    /*
+    /**
      * Move one channel spacing up or down.
      * Must be called when a valid configuration has been applied.
      * Automatically cancels pending scan, step or tune.
@@ -73,7 +73,7 @@
      */
     step(Direction direction, bool skipSubChannel) generates(Result result);
 
-    /*
+    /**
      * Tune to specified channel.
      * Must be called when a valid configuration has been applied.
      * Automatically cancels pending scan, step or tune.
@@ -91,7 +91,7 @@
      */
     tune(uint32_t channel, uint32_t subChannel) generates(Result result);
 
-    /*
+    /**
      * Cancel a scan, step or tune operation.
      * Shall be called only while a scan, step or tune operation is pending.
      * ITunerCallback.tuneComplete() MUST NOT be sent by the HAL.
@@ -101,7 +101,7 @@
      */
     cancel() generates(Result result);
 
-    /*
+    /**
      * Retrieve current station information.
      * @return result OK if scan successfully started
      *                NOT_INITIALIZED if another error occurs
diff --git a/broadcastradio/1.0/ITunerCallback.hal b/broadcastradio/1.0/ITunerCallback.hal
index a7e1260..0966ff4 100644
--- a/broadcastradio/1.0/ITunerCallback.hal
+++ b/broadcastradio/1.0/ITunerCallback.hal
@@ -19,13 +19,13 @@
 
 interface ITunerCallback {
 
-    /*
+    /**
      * Method called by the HAL when a HW failure occurs.
      * The framework MUST close the ITuner interface and open a new one.
      */
     oneway hardwareFailure();
 
-    /*
+    /**
      * Method called by the HAL when a new configuration is applied
      * in response to IDevice.openTuner() or ITuner.setConfiguration().
      * @param result OK if the configuration has been applied,
@@ -35,7 +35,7 @@
      */
     oneway configChange(Result result, BandConfig config);
 
-    /*
+    /**
      * Method called by the HAL when a tuning operation completes
      * following a step(), scan() or tune() command.
      * @param result OK if tune succeeded or TIMEOUT in case of time out.
@@ -43,33 +43,33 @@
      */
     oneway tuneComplete(Result result, ProgramInfo info);
 
-    /*
+    /**
      * Method called by the HAL when a frequency switch occurs.
      * @param info A ProgramInfo structure describing the new tuned station.
      */
     oneway afSwitch(ProgramInfo info);
 
-    /*
+    /**
      * Method called by the HAL when the antenna connection state changes.
      * @param connected True if the antenna is connected, false otherwise.
      */
     oneway antennaStateChange(bool connected);
 
-    /*
+    /**
      * Method called by the HAL when a traffic announcement starts or
      * stops.
      * @param active True if the announcement starts, false if it stops.
      */
     oneway trafficAnnouncement(bool active);
 
-    /*
+    /**
      * Method called by the HAL when an emergency announcement starts
      * or stops.
      * @param active True if the announcement starts, false if it stops.
      */
     oneway emergencyAnnouncement(bool active);
 
-    /*
+    /**
      * Method called by the HAL when metadata for current station
      * are updated.
      * @param channel The channel the metadata is associated with.
@@ -77,4 +77,4 @@
      * @param metadata A list of all updated metada.
      */
     oneway newMetadata(uint32_t channel, uint32_t subChannel, vec<MetaData>  metadata);
-};
\ No newline at end of file
+};
diff --git a/broadcastradio/1.0/types.hal b/broadcastradio/1.0/types.hal
index d8b2da3..045231d 100644
--- a/broadcastradio/1.0/types.hal
+++ b/broadcastradio/1.0/types.hal
@@ -24,33 +24,33 @@
     TIMEOUT,
 };
 
-/*
+/**
  * Radio hardware module class. A given radio hardware module HAL is of one
  * class only. The platform can not have more than one hardware module of
  * each class. Current version of the framework only supports RADIO_CLASS_AM_FM.
  */
 enum Class : uint32_t {
-    /* FM (including HD radio) and AM */
+    /** FM (including HD radio) and AM */
     AM_FM = 0,
-    /* Satellite Radio */
+    /** Satellite Radio */
     SAT   = 1,
-    /* Digital Radio (DAB) */
+    /** Digital Radio (DAB) */
     DT    = 2,
 };
 
-/* value for field "type" of radio band described in struct radio_hal_band_config */
+/** value for field "type" of radio band described in struct radio_hal_band_config */
 enum Band : uint32_t {
-    /* Amplitude Modulation band: LW, MW, SW */
+    /** Amplitude Modulation band: LW, MW, SW */
     AM     = 0,
-    /* Frequency Modulation band: FM */
+    /** Frequency Modulation band: FM */
     FM     = 1,
-    /* FM HD Radio / DRM (IBOC) */
+    /** FM HD Radio / DRM (IBOC) */
     FM_HD  = 2,
-    /* AM HD Radio / DRM (IBOC) */
+    /** AM HD Radio / DRM (IBOC) */
     AM_HD  = 3,
 };
 
-/* RDS variant implemented. A struct FmBandConfig can list none or several. */
+/** RDS variant implemented. A struct FmBandConfig can list none or several. */
 enum Rds : uint32_t {
     NONE   = 0,
     WORLD  = (1<<0),
@@ -65,35 +65,35 @@
     D75   = (1<<1),
 };
 
-/* Scanning direction for scan() and step() tuner APIs */
+/** Scanning direction for scan() and step() tuner APIs */
 enum Direction : uint32_t {
     UP,
     DOWN
 };
 
-/* Unique handle allocated to a radio module */
+/** Unique handle allocated to a radio module */
 typedef uint32_t Handle;
 
 
-/* Additional attributes for an FM band configuration */
+/** Additional attributes for an FM band configuration */
 struct FmBandConfig {
-    /* deemphasis variant */
+    /** deemphasis variant */
     Deemphasis deemphasis;
-    /* stereo supported */
+    /** stereo supported */
     bool       stereo;
-    /* RDS variants supported */
+    /** RDS variants supported */
     Rds        rds;
-    /* Traffic Announcement supported */
+    /** Traffic Announcement supported */
     bool       ta;
-    /* Alternate Frequency supported */
+    /** Alternate Frequency supported */
     bool       af;
-    /* Emergency announcements supported */
+    /** Emergency announcements supported */
     bool       ea;
 };
 
-/* Additional attributes for an AM band configuration */
+/** Additional attributes for an AM band configuration */
 struct AmBandConfig {
-    /* Stereo supported */
+    /** Stereo supported */
     bool       stereo;
 };
 
@@ -120,83 +120,84 @@
  * If more than one tuner is supported (num_tuners > 1), only one can be
  * connected to the audio source. */
 struct Properties {
-    /* Class of this module. E.g AM_FM */
+    /** Class of this module. E.g AM_FM */
     Class           classId;
-    /* implementor name */
+    /** implementor name */
     string          implementor;
-    /* product name */
+    /** product name */
     string          product;
-    /* product version */
+    /** product version */
     string          version;
-    /* serial number (for subscription services) */
+    /** serial number (for subscription services) */
     string          serial;
-    /* number of tuners controllable independently */
+    /** number of tuners controllable independently */
     uint32_t        numTuners;
-    /* number of audio sources driven simultaneously */
+    /** number of audio sources driven simultaneously */
     uint32_t        numAudioSources;
-    /* the hardware supports capture of audio source from audio HAL */
+    /** the hardware supports capture of audio source from audio HAL */
     bool            supportsCapture;
-    vec<BandConfig> bands; /* band descriptors */
+    vec<BandConfig> bands; /** band descriptors */
 };
 
 enum MetadataType : int32_t {
     INVALID    = -1,
-    /* Signed 32 bit integer  */
+    /** Signed 32 bit integer  */
     INT        = 0,
-    /* String */
+    /** String */
     TEXT       = 1,
-    /* Raw binary data (icon or art)
+    /**
+     * Raw binary data (icon or art)
        This data must be transparent to the android framework */
     RAW        = 2,
-    /* clock data, see MetaDataClock */
+    /** clock data, see MetaDataClock */
     CLOCK      = 3,
 };
 
 enum MetadataKey : int32_t {
     INVALID      = -1,
-    /* RDS PI                 - string  */
+    /** RDS PI                 - string  */
     RDS_PI       = 0,
-    /* RDS PS                 - string */
+    /** RDS PS                 - string */
     RDS_PS       = 1,
-    /* RDS PTY                - int32_t  */
+    /** RDS PTY                - int32_t  */
     RDS_PTY      = 2,
-    /* RBDS PTY               - int32_t  */
+    /** RBDS PTY               - int32_t  */
     RBDS_PTY     = 3,
-    /* RDS RT                 - string  */
+    /** RDS RT                 - string  */
     RDS_RT       = 4,
-    /* Song title             - string  */
+    /** Song title             - string  */
     TITLE        = 5,
-    /* Artist name            - string  */
+    /** Artist name            - string  */
     ARTIST       = 6,
-    /* Album name             - string  */
+    /** Album name             - string  */
     ALBUM        = 7,
-    /* Musical genre          - string  */
+    /** Musical genre          - string  */
     GENRE        = 8,
-    /* Station icon           - raw  */
+    /** Station icon           - raw  */
     ICON         = 9,
-    /* Album art              - raw  */
+    /** Album art              - raw  */
     ART          = 10,
-    /* Clock                  - MetaDataClock */
+    /** Clock                  - MetaDataClock */
     CLOCK        = 11,
 };
 
 struct MetaDataClock {
-     /* Seconds since epoch at GMT + 0. */
+     /** Seconds since epoch at GMT + 0. */
     uint64_t utcSecondsSinceEpoch;
-    /* Minutes offset from the GMT. */
+    /** Minutes offset from the GMT. */
     int32_t timezoneOffsetInMinutes;
 };
 
 struct MetaData {
     MetadataType type;
     MetadataKey key;
-    /* Value used for type MetadataType.INT */
+    /** Value used for type MetadataType.INT */
     int32_t intValue;
-    /* Value used for type MetadataType.CLOCK */
+    /** Value used for type MetadataType.CLOCK */
     MetaDataClock  clockValue;
-    /* Value used for type MetadataType.TEXT */
+    /** Value used for type MetadataType.TEXT */
     string  stringValue;
-    /* Value used for type MetadataType.RAW */
+    /** Value used for type MetadataType.RAW */
     vec<uint8_t> rawValue;
 };
 
@@ -205,12 +206,12 @@
  * Contains information on currently tuned channel.
  */
 struct ProgramInfo {
-    uint32_t     channel;   /* current channel. (e.g kHz for band type AM_FM) */
-    uint32_t     subChannel; /* current sub channel. (FM_HD) */
-    bool         tuned;     /* tuned to a program or not */
-    bool         stereo;    /* program is stereo or not */
-    bool         digital;   /* digital program or not (e.g HD Radio program) */
-    uint32_t     signalStrength; /* signal strength from 0 to 100 */
-    vec<MetaData> metadata; /* non empty if meta data are present (e.g PTY, song title ...) */
+    uint32_t     channel;   /** current channel. (e.g kHz for band type AM_FM) */
+    uint32_t     subChannel; /** current sub channel. (FM_HD) */
+    bool         tuned;     /** tuned to a program or not */
+    bool         stereo;    /** program is stereo or not */
+    bool         digital;   /** digital program or not (e.g HD Radio program) */
+    uint32_t     signalStrength; /** signal strength from 0 to 100 */
+    vec<MetaData> metadata; /** non empty if meta data are present (e.g PTY, song title ...) */
 };
 
diff --git a/broadcastradio/1.1/IBroadcastRadio.hal b/broadcastradio/1.1/IBroadcastRadio.hal
index a6347c7..dd37d49 100644
--- a/broadcastradio/1.1/IBroadcastRadio.hal
+++ b/broadcastradio/1.1/IBroadcastRadio.hal
@@ -20,7 +20,7 @@
 
 interface IBroadcastRadio extends @1.0::IBroadcastRadio {
 
-    /*
+    /**
      * Retrieve implementation properties.
      * @return properties A Properties structure containing implementation
      *                    description and capabilities.
diff --git a/broadcastradio/1.1/ITunerCallback.hal b/broadcastradio/1.1/ITunerCallback.hal
index 178568a..158e217 100644
--- a/broadcastradio/1.1/ITunerCallback.hal
+++ b/broadcastradio/1.1/ITunerCallback.hal
@@ -25,7 +25,7 @@
  * ones, to avoid receiving a callback twice.
  */
 interface ITunerCallback extends @1.0::ITunerCallback {
-    /*
+    /**
      * Method called by the HAL when a tuning operation completes
      * following a step(), scan() or tune() command.
      * @param result OK if tune succeeded or TIMEOUT in case of time out.
@@ -33,7 +33,7 @@
      */
     oneway tuneComplete_1_1(Result result, ProgramInfo info);
 
-    /*
+    /**
      * Method called by the HAL when a frequency switch occurs.
      * @param info A ProgramInfo structure describing the new tuned station.
      */
diff --git a/camera/device/1.0/types.hal b/camera/device/1.0/types.hal
index b32c938..bf632d1 100644
--- a/camera/device/1.0/types.hal
+++ b/camera/device/1.0/types.hal
@@ -249,7 +249,7 @@
     vec<CameraFace> faces;
 };
 
-/*
+/**
  * A simple integer handle to use to reference a particular memory buffer
  * between the HAL and the framework.
  */
diff --git a/camera/device/3.2/types.hal b/camera/device/3.2/types.hal
index ba5bbe0..fd75528 100644
--- a/camera/device/3.2/types.hal
+++ b/camera/device/3.2/types.hal
@@ -68,16 +68,16 @@
  * The required counterclockwise rotation of camera stream.
  */
 enum StreamRotation : uint32_t  {
-    /* No rotation */
+    /** No rotation */
     ROTATION_0 = 0,
 
-    /* Rotate by 90 degree counterclockwise */
+    /** Rotate by 90 degree counterclockwise */
     ROTATION_90 = 1,
 
-    /* Rotate by 180 degree counterclockwise */
+    /** Rotate by 180 degree counterclockwise */
     ROTATION_180 = 2,
 
-    /* Rotate by 270 degree counterclockwise */
+    /** Rotate by 270 degree counterclockwise */
     ROTATION_270 = 3
 
 };
diff --git a/configstore/1.0/ISurfaceFlingerConfigs.hal b/configstore/1.0/ISurfaceFlingerConfigs.hal
index 3b5c1b0..dcc9bbb 100644
--- a/configstore/1.0/ISurfaceFlingerConfigs.hal
+++ b/configstore/1.0/ISurfaceFlingerConfigs.hal
@@ -16,7 +16,7 @@
 package android.hardware.configstore@1.0;
 
 interface ISurfaceFlingerConfigs {
-    /*
+    /**
      * The following two methods define (respectively):
      *
      * - The phase offset between hardware vsync and when apps are woken up by the
@@ -40,13 +40,13 @@
     vsyncEventPhaseOffsetNs() generates (OptionalInt64 value);
     vsyncSfEventPhaseOffsetNs() generates (OptionalInt64 value);
 
-    /*
+    /**
      * Instruct the Render Engine to use EGL_IMG_context_priority hint if
      * availabe.
      */
     useContextPriority() generates(OptionalBool value);
 
-    /*
+    /**
      * hasWideColorDisplay indicates that the device has
      * or can support a wide-color display, e.g. color space
      * greater than sRGB. Typical display may have same
@@ -60,7 +60,7 @@
      */
     hasWideColorDisplay() generates (OptionalBool value);
 
-    /*
+    /**
      * hwHdrDisplay indicates that the device has
      * or can support an HDR (High Dynamic Range) display.
      * Typically an HDR display is also wide-color.
@@ -69,13 +69,13 @@
      */
     hasHDRDisplay() generates (OptionalBool value);
 
-    /*
+    /**
      * Specify the offset in nanoseconds to add to vsync time when timestamping
      * present fences.
      */
     presentTimeOffsetFromVSyncNs() generates(OptionalInt64 value);
 
-    /*
+    /**
      * Some hardware can do RGB->YUV conversion more efficiently in hardware
      * controlled by HWC than in hardware controlled by the video encoder.
      * This instruct VirtualDisplaySurface to use HWC for such conversion on
@@ -83,19 +83,19 @@
      */
     useHwcForRGBtoYUV() generates(OptionalBool value);
 
-    /*
+    /**
      *  Maximum dimension supported by HWC for virtual display.
      *  Must be equals to min(max_width, max_height).
      */
     maxVirtualDisplaySize() generates (OptionalUInt64 value);
 
-    /*
+    /**
      * Indicates if Sync framework is available. Sync framework provides fence
      * mechanism which significantly reduces buffer processing latency.
      */
     hasSyncFramework() generates(OptionalBool value);
 
-    /*
+    /**
      * Return true if surface flinger should use vr flinger for compatible vr
      * apps, false otherwise. Devices that will never be running vr apps should
      * return false to avoid extra resource usage. Daydream ready devices must
@@ -103,7 +103,7 @@
      */
     useVrFlinger() generates (OptionalBool value);
 
-    /*
+    /**
      * Controls the number of buffers SurfaceFlinger will allocate for use in
      * FramebufferSurface.
      */
diff --git a/contexthub/1.0/IContexthub.hal b/contexthub/1.0/IContexthub.hal
index c0928d5..8dccd67 100644
--- a/contexthub/1.0/IContexthub.hal
+++ b/contexthub/1.0/IContexthub.hal
@@ -18,7 +18,7 @@
 
 import IContexthubCallback;
 
-/*
+/**
  * The Context Hub HAL provides an interface to a separate low-power processing
  * domain that has direct access to contextual information, such as sensors.
  * Native applications that run within a context hub are known as nanoapps, and
@@ -26,14 +26,14 @@
  * standardized via the CHRE API, defined elsewhere.
  */
 interface IContexthub {
-    /*
+    /**
      * Enumerate all available context hubs on the system.
      *
      * @return hubs list of hubs on this system.
      */
     getHubs() generates (vec<ContextHub> hubs);
 
-    /*
+    /**
      * Register a callback for the HAL implementation to send asynchronous
      * messages to the service from a context hub. There can be a maximum of
      * one callback registered with the HAL. A call to this function when a
diff --git a/contexthub/1.0/IContexthubCallback.hal b/contexthub/1.0/IContexthubCallback.hal
index 9a6db4c..264f84c 100644
--- a/contexthub/1.0/IContexthubCallback.hal
+++ b/contexthub/1.0/IContexthubCallback.hal
@@ -17,7 +17,7 @@
 package android.hardware.contexthub@1.0;
 
 interface IContexthubCallback {
-    /*
+    /**
      * This callback is passed by the Contexthub service to the HAL
      * implementation to allow the HAL to send asynchronous messages back
      * to the service and registered clients of the ContextHub service.
@@ -27,7 +27,7 @@
      */
      handleClientMsg(ContextHubMsg msg);
 
-    /*
+    /**
      * This callback is passed by the Contexthub service to the HAL
      * implementation to allow the HAL to send the response for a
      * transaction.
@@ -39,7 +39,7 @@
      */
      handleTxnResult(uint32_t txnId, TransactionResult result);
 
-    /*
+    /**
      * This callback is passed by the Contexthub service to the HAL
      * implementation to allow the HAL to send an asynchronous event
      * to the ContextHub service.
@@ -49,7 +49,7 @@
      */
      handleHubEvent(AsyncEventType evt);
 
-    /*
+    /**
      * This callback is passed by the Contexthub service to the HAL
      * implementation to allow the HAL to send a notification to the service
      * that a nanp-app has aborted.
@@ -63,7 +63,7 @@
      */
      handleAppAbort(uint64_t appId, uint32_t abortCode);
 
-     /*
+     /**
       * This callback is passed by the Contexthub service to the HAL
       * implementation to allow the HAL to send information about the
       * currently loaded and active nanoapps on the hub.
diff --git a/dumpstate/1.0/IDumpstateDevice.hal b/dumpstate/1.0/IDumpstateDevice.hal
index fec3eb4..206c139 100644
--- a/dumpstate/1.0/IDumpstateDevice.hal
+++ b/dumpstate/1.0/IDumpstateDevice.hal
@@ -17,7 +17,7 @@
 package android.hardware.dumpstate@1.0;
 
 interface IDumpstateDevice {
-    /*
+    /**
      * Dumps device-specific state into the given file descriptor.
      */
     dumpstateBoard(handle h);
diff --git a/gatekeeper/1.0/IGatekeeper.hal b/gatekeeper/1.0/IGatekeeper.hal
index c193477..59dd7d1 100644
--- a/gatekeeper/1.0/IGatekeeper.hal
+++ b/gatekeeper/1.0/IGatekeeper.hal
@@ -91,7 +91,7 @@
        vec<uint8_t> providedPassword)
     generates (GatekeeperResponse response);
 
-/*
+/**
  * Deletes the enrolledPasswordHandle associated with the uid. Once deleted
  * the user cannot be verified anymore.
  * This is an optional method.
@@ -107,7 +107,7 @@
  */
 deleteUser(uint32_t uid) generates (GatekeeperResponse response);
 
-/*
+/**
  * Deletes all the enrolled_password_handles for all uid's. Once called,
  * no users must be enrolled on the device.
  * This is an optional method.
diff --git a/gatekeeper/1.0/types.hal b/gatekeeper/1.0/types.hal
index 59076e0..f243675 100644
--- a/gatekeeper/1.0/types.hal
+++ b/gatekeeper/1.0/types.hal
@@ -31,12 +31,13 @@
  * Gatekeeper response to any/all requests has this structure as mandatory part
  */
 struct GatekeeperResponse {
-    /* request completion status */
+    /** request completion status */
     GatekeeperStatusCode code;
-    /* retry timeout in ms, if code == ERROR_RETRY_TIMEOUT
+    /**
+     * retry timeout in ms, if code == ERROR_RETRY_TIMEOUT
      * otherwise unused (0)
      */
     uint32_t timeout;
-    /* optional crypto blob. Opaque to Android system. */
+    /** optional crypto blob. Opaque to Android system. */
     vec<uint8_t> data;
 };
diff --git a/gnss/1.0/IAGnss.hal b/gnss/1.0/IAGnss.hal
index b8f5746..fb0f606 100644
--- a/gnss/1.0/IAGnss.hal
+++ b/gnss/1.0/IAGnss.hal
@@ -18,7 +18,7 @@
 
 import IAGnssCallback;
 
-/*
+/**
  * Extended interface for AGNSS support.
  */
 interface IAGnss {
@@ -30,7 +30,7 @@
         IPV4V6   = 3
     };
 
-    /*
+    /**
      * Opens the AGNSS interface and provides the callback routines to the
      * implementation of this interface.
      *
@@ -38,21 +38,21 @@
      */
     setCallback(IAGnssCallback callback);
 
-    /*
+    /**
      * Notifies that the AGNSS data connection has been closed.
      *
      * @return success True if the operation is successful.
      */
     dataConnClosed() generates (bool success);
 
-    /*
+    /**
      * Notifies that a data connection is not available for AGNSS.
      *
      * @return success True if the operation is successful.
      */
     dataConnFailed() generates (bool success);
 
-    /*
+    /**
      * Sets the hostname and port for the AGNSS server.
      *
      * @param type Specifies if SUPL or C2K.
@@ -64,7 +64,7 @@
     setServer(AGnssType type, string hostname, int32_t port)
         generates (bool success);
 
-    /*
+    /**
      * Notifies that a data connection is available and sets the name of the
      * APN, and its IP type, to be used for SUPL connections.
      *
diff --git a/gnss/1.0/IAGnssCallback.hal b/gnss/1.0/IAGnssCallback.hal
index fe2e101..81f1689 100644
--- a/gnss/1.0/IAGnssCallback.hal
+++ b/gnss/1.0/IAGnssCallback.hal
@@ -39,39 +39,39 @@
         AGNSS_DATA_CONN_FAILED   = 5
     };
 
-    /*
+    /**
      * Represents the status of AGNSS augmented to support IPv4.
      */
     @export(name="", value_prefix="GPS_")
     struct AGnssStatusIpV4 {
         AGnssType type;
         AGnssStatusValue status;
-        /*
+        /**
          * 32-bit IPv4 address.
          */
         uint32_t ipV4Addr;
     };
 
-    /*
+    /**
      * Represents the status of AGNSS augmented to support IPv6.
      */
     struct AGnssStatusIpV6 {
         AGnssType type;
         AGnssStatusValue status;
-        /*
+        /**
          * 128-bit IPv6 address.
          */
         uint8_t[16] ipV6Addr;
     };
 
-    /*
+    /**
      * Callback with AGNSS(IpV4) status information.
      *
      * @param status Will be of type AGnssStatusIpV4.
      */
     agnssStatusIpV4Cb(AGnssStatusIpV4 status);
 
-    /*
+    /**
      * Callback with AGNSS(IpV6) status information.
      *
      * @param status Will be of type AGnssStatusIpV6.
diff --git a/gnss/1.0/IAGnssRil.hal b/gnss/1.0/IAGnssRil.hal
index 6292273..6f91f7f 100644
--- a/gnss/1.0/IAGnssRil.hal
+++ b/gnss/1.0/IAGnssRil.hal
@@ -18,7 +18,7 @@
 
 import IAGnssRilCallback;
 
-/*
+/**
  * Extended interface for AGNSS RIL support. An Assisted GNSS Radio Interface
  * Layer interface allows the GNSS chipset to request radio interface layer
  * information from Android platform. Examples of such information are reference
@@ -50,41 +50,42 @@
         LTE_CELLID   = 4,
     };
 
-    /* CellID for 2G, 3G and LTE, used in AGNSS. */
+    /** CellID for 2G, 3G and LTE, used in AGNSS. */
     struct AGnssRefLocationCellID {
         AGnssRefLocationType type;
 
-        /* Mobile Country Code. */
+        /** Mobile Country Code. */
         uint16_t mcc;
 
-        /* Mobile Network Code .*/
+        /**
+         * Mobile Network Code .*/
         uint16_t mnc;
 
-        /*
+        /**
          * Location Area Code in 2G, 3G and LTE. In 3G lac is discarded. In LTE,
          * lac is populated with tac, to ensure that we don't break old clients that
          * might rely in the old (wrong) behavior.
          */
         uint16_t lac;
 
-        /* Cell id in 2G. Utran Cell id in 3G. Cell Global Id EUTRA in LTE. */
+        /** Cell id in 2G. Utran Cell id in 3G. Cell Global Id EUTRA in LTE. */
         uint32_t cid;
 
-        /* Tracking Area Code in LTE. */
+        /** Tracking Area Code in LTE. */
         uint16_t tac;
 
-        /* Physical Cell id in LTE (not used in 2G and 3G) */
+        /** Physical Cell id in LTE (not used in 2G and 3G) */
         uint16_t pcid;
     };
 
-    /* Represents ref locations */
+    /** Represents ref locations */
     struct AGnssRefLocation {
         AGnssRefLocationType type;
 
         AGnssRefLocationCellID cellID;
     };
 
-    /*
+    /**
      * Opens the AGNSS interface and provides the callback routines
      * to the implementation of this interface.
      *
@@ -92,14 +93,14 @@
      */
     setCallback(IAGnssRilCallback callback);
 
-    /*
+    /**
      * Sets the reference location.
      *
      * @param agnssReflocation AGNSS reference location CellID.
      */
     setRefLocation(AGnssRefLocation agnssReflocation);
 
-    /*
+    /**
      * Sets the SET ID.
      *
      * @param type Must be populated with either IMSI or MSISDN or NONE.
@@ -114,7 +115,7 @@
      */
     setSetId(SetIDType type, string setid) generates (bool success);
 
-    /*
+    /**
      * Notify GNSS of network status changes.
      *
      * @param connected Indicates whether network connectivity exists and
@@ -129,7 +130,7 @@
     updateNetworkState(bool connected, NetworkType type, bool roaming)
         generates (bool success);
 
-    /*
+    /**
      * Notify GNSS of network status changes.
      *
      * @param available Indicates whether network connectivity is available.
diff --git a/gnss/1.0/IAGnssRilCallback.hal b/gnss/1.0/IAGnssRilCallback.hal
index 2d64e54..d2a1a3f 100644
--- a/gnss/1.0/IAGnssRilCallback.hal
+++ b/gnss/1.0/IAGnssRilCallback.hal
@@ -16,26 +16,26 @@
 
 package android.hardware.gnss@1.0;
 
-/*
+/**
  * Callback for IAGnssRil interface. Used to request SET ID and
  * Reference Location.
  */
 interface IAGnssRilCallback {
-    /* Kinds of SET ID that can be requested */
+    /** Kinds of SET ID that can be requested */
     @export(name="", value_prefix="AGPS_RIL_REQUEST_SETID_")
     enum ID : uint32_t {
         IMSI    = 1 << 0L,
         MSISDN  = 1 << 1L,
     };
 
-    /*
+    /**
      * The Hal uses this API to request a SET ID.
      *
      * @param setIdflag Specifies the kind of SET ID that is required by the HAL.
      */
     requestSetIdCb(bitfield<ID> setIdflag);
 
-    /*
+    /**
      * The Hal uses this API to request a reference location.
      *
      */
diff --git a/gnss/1.0/IGnss.hal b/gnss/1.0/IGnss.hal
index 5cde79e..602c615 100644
--- a/gnss/1.0/IGnss.hal
+++ b/gnss/1.0/IGnss.hal
@@ -28,23 +28,23 @@
 import IGnssNi;
 import IGnssXtra;
 
-/* Represents the standard GNSS (Global Navigation Satellite System) interface. */
+/** Represents the standard GNSS (Global Navigation Satellite System) interface. */
 interface IGnss {
-    /* Requested operational mode for GNSS operation. */
+    /** Requested operational mode for GNSS operation. */
     @export(name="", value_prefix="GPS_POSITION_MODE_")
     enum GnssPositionMode : uint8_t {
         /** Mode for running GNSS standalone (no assistance). */
         STANDALONE  = 0,
         /** AGNSS MS-Based mode. */
         MS_BASED    = 1,
-        /*
+        /**
          * AGNSS MS-Assisted mode. This mode is not maintained by the platform anymore.
          * It is strongly recommended to use MS_BASED instead.
          */
         MS_ASSISTED = 2,
     };
 
-    /* Requested recurrence mode for GNSS operation. */
+    /** Requested recurrence mode for GNSS operation. */
     @export(name="", value_prefix="GPS_POSITION_")
     enum GnssPositionRecurrence : uint32_t {
         /** Receive GNSS fixes on a recurring basis at a specified period. */
@@ -53,7 +53,7 @@
         RECURRENCE_SINGLE    = 1
     };
 
-    /*
+    /**
      * Flags used to specify which aiding data to delete when calling
      * deleteAidingData().
      */
@@ -74,7 +74,7 @@
         DELETE_ALL          = 0xFFFF
     };
 
-    /*
+    /**
      * Opens the interface and provides the callback routines
      * to the implementation of this interface.
      *
@@ -84,7 +84,7 @@
      */
     setCallback(IGnssCallback callback) generates (bool success);
 
-    /*
+    /**
      * Starts a location output stream using the IGnssCallback
      * gnssLocationCb(), following the settings from the most recent call to
      * setPositionMode().
@@ -96,19 +96,19 @@
      */
     start() generates (bool success);
 
-    /*
+    /**
      * Stops the location output stream.
      *
      * @return success Returns true on success.
      */
     stop() generates (bool success);
 
-    /*
+    /**
      * Closes the interface.
      */
     cleanup();
 
-    /*
+    /**
      * Injects the current time.
      *
      * @param timeMs This is the UTC time received from the NTP server, its value
@@ -124,7 +124,7 @@
     injectTime(GnssUtcTime timeMs, int64_t timeReferenceMs, int32_t uncertaintyMs)
         generates (bool success);
 
-    /*
+    /**
      * Injects current location from another location provider (typically cell
      * ID).
      *
@@ -137,7 +137,7 @@
     injectLocation(double latitudeDegrees, double longitudeDegrees, float accuracyMeters)
         generates (bool success);
 
-    /*
+    /**
      * Specifies that the next call to start will not use the
      * information defined in the flags. GnssAidingData value of DELETE_ALL is
      * passed for a cold start.
@@ -146,7 +146,7 @@
      */
     deleteAidingData(GnssAidingData aidingDataFlags);
 
-    /*
+    /**
      * Sets the GnssPositionMode parameter,its associated recurrence value,
      * the time between fixes,requested fix accuracy and time to first fix.
      *
@@ -165,70 +165,70 @@
                     uint32_t preferredTimeMs)
         generates (bool success);
 
-    /*
+    /**
      * This method returns the IAGnssRil Interface.
      *
      * @return aGnssRilIface Handle to the IAGnssRil interface.
      */
     getExtensionAGnssRil() generates (IAGnssRil aGnssRilIface);
 
-    /*
+    /**
      * This method returns the IGnssGeofencing Interface.
      *
      * @return gnssGeofencingIface Handle to the IGnssGeofencing interface.
      */
     getExtensionGnssGeofencing() generates(IGnssGeofencing gnssGeofencingIface);
 
-    /*
+    /**
      * This method returns the IAGnss Interface.
      *
      * @return aGnssIface Handle to the IAGnss interface.
      */
     getExtensionAGnss() generates (IAGnss aGnssIface);
 
-    /*
+    /**
      * This method returns the IGnssNi interface.
      *
      * @return gnssNiIface Handle to the IGnssNi interface.
      */
     getExtensionGnssNi() generates (IGnssNi gnssNiIface);
 
-    /*
+    /**
      * This method returns the IGnssMeasurement interface.
      *
      * @return gnssMeasurementIface Handle to the IGnssMeasurement interface.
      */
     getExtensionGnssMeasurement() generates (IGnssMeasurement gnssMeasurementIface);
 
-    /*
+    /**
      * This method returns the IGnssNavigationMessage interface.
      *
      * @return gnssNavigationIface gnssNavigationIface to the IGnssNavigationMessage interface.
      */
     getExtensionGnssNavigationMessage() generates (IGnssNavigationMessage gnssNavigationIface);
 
-    /*
+    /**
      * This method returns the IGnssXtra interface.
      *
      * @return xtraIface Handle to the IGnssXtra interface.
      */
     getExtensionXtra() generates (IGnssXtra xtraIface);
 
-    /*
+    /**
      * This method returns the IGnssConfiguration interface.
      *
      * @return gnssConfigIface Handle to the IGnssConfiguration interface.
      */
     getExtensionGnssConfiguration() generates (IGnssConfiguration gnssConfigIface);
 
-    /*
+    /**
      * This method returns the IGnssDebug interface.
      *
      * @return debugIface Handle to the IGnssDebug interface.
      */
     getExtensionGnssDebug() generates (IGnssDebug debugIface);
 
-    /*
+    /**
      * This method returns the IGnssBatching interface.
      *
      * @return batchingIface Handle to the IGnssBatching interface.
diff --git a/gnss/1.0/IGnssBatching.hal b/gnss/1.0/IGnssBatching.hal
index 6f2dde6..a5e01e3 100644
--- a/gnss/1.0/IGnssBatching.hal
+++ b/gnss/1.0/IGnssBatching.hal
@@ -18,7 +18,7 @@
 
 import IGnssBatchingCallback;
 
-/*
+/**
  * Extended interface for GNSS Batching support.
  *
  * If this interface is supported, this batching request must be able to run in
@@ -39,12 +39,12 @@
  */
 
 interface IGnssBatching {
-    /*
+    /**
      * Enum which holds the bit masks for batching control.
      */
     @export(name="", value_prefix="FLP_BATCH_")
     enum Flag : uint8_t {
-        /*
+        /**
          * If this flag is set, the hardware implementation
          * must wake up the application processor when the FIFO is full, and
          * call IGnssBatchingCallback to return the locations.
@@ -56,19 +56,19 @@
     };
 
     struct Options {
-        /*
+        /**
          * Time interval between samples in the location batch, in nano
          * seconds.
          */
         int64_t periodNanos;
 
-        /*
+        /**
          * Flags controlling how batching should behave.
          */
         bitfield<Flag> flags;
     };
 
-    /*
+    /**
      * Opens the interface and provides the callback routines
      * to the implementation of this interface.
      *
@@ -78,7 +78,7 @@
      */
     init(IGnssBatchingCallback callback) generates (bool success);
 
-    /*
+    /**
      * Return the batch size (in number of GnssLocation objects)
      * available in this hardware implementation.
      *
@@ -93,7 +93,7 @@
      */
     getBatchSize() generates (uint16_t batchSize);
 
-    /*
+    /**
      * Start batching locations. This API is primarily used when the AP is
      * asleep and the device can batch locations in the hardware.
      *
diff --git a/gnss/1.0/IGnssBatchingCallback.hal b/gnss/1.0/IGnssBatchingCallback.hal
index a8f4b88..5697cc4 100644
--- a/gnss/1.0/IGnssBatchingCallback.hal
+++ b/gnss/1.0/IGnssBatchingCallback.hal
@@ -16,9 +16,9 @@
 
 package android.hardware.gnss@1.0;
 
-/* The callback interface to report measurements from the HAL. */
+/** The callback interface to report measurements from the HAL. */
 interface IGnssBatchingCallback {
-    /*
+    /**
      * Called when a batch of locations is output, by various means, including
      * a flush request, as well as the buffer becoming full (if appropriate option
      * is set.)
diff --git a/gnss/1.0/IGnssCallback.hal b/gnss/1.0/IGnssCallback.hal
index 0c3b9f0..89e5e0e 100644
--- a/gnss/1.0/IGnssCallback.hal
+++ b/gnss/1.0/IGnssCallback.hal
@@ -16,16 +16,16 @@
 
 package android.hardware.gnss@1.0;
 
-/*
+/**
  * The interface is required for the HAL to communicate certain information
  * like status and location info back to the platform, the platform implements
  * the interfaces and passes a handle to the HAL.
  */
 interface IGnssCallback {
-    /* Flags for the gnssSetCapabilities callback. */
+    /** Flags for the gnssSetCapabilities callback. */
     @export(name="", value_prefix="GPS_CAPABILITY_")
     enum Capabilities : uint32_t {
-        /*
+        /**
          * GNSS HAL schedules fixes for RECURRENCE_PERIODIC mode.
          * If this is not set, then the framework will use 1000ms for
          * minInterval and will call start() and stop() to schedule the GNSS.
@@ -47,7 +47,7 @@
         NAV_MESSAGES                    = 1 << 7
     };
 
-    /* GNSS status event values. */
+    /** GNSS status event values. */
     @export(name="", value_prefix="GPS_STATUS_")
     enum GnssStatusValue : uint8_t {
         /** GNSS status unknown. */
@@ -62,7 +62,7 @@
         ENGINE_OFF     = 4
     };
 
-    /*
+    /**
      * Flags that indicate information about the satellite
      */
     @export(name="", value_prefix="GNSS_SV_FLAGS_")
@@ -75,7 +75,7 @@
     };
 
     struct GnssSvInfo {
-        /*
+        /**
          * Pseudo-random number for the SV, or FCN/OSN number for Glonass. The
          * distinction is made by looking at constellation field. Values must be
          * in the range of:
@@ -93,12 +93,12 @@
          */
         int16_t svid;
 
-        /*
+        /**
          * Defines the constellation of the given SV.
          */
         GnssConstellationType constellation;
 
-        /*
+        /**
          * Carrier-to-noise density in dB-Hz, typically in the range [0, 63].
          * It contains the measured C/N0 value for the signal at the antenna port.
          *
@@ -112,7 +112,7 @@
         /** Azimuth of SV in degrees. */
         float azimuthDegrees;
 
-        /*
+        /**
          * Carrier frequency of the signal tracked, for example it can be the
          * GPS central frequency for L1 = 1575.45 MHz, or L2 = 1227.60 MHz, L5 =
          * 1176.45 MHz, varying GLO channels, etc. If the field is not set, it
@@ -130,22 +130,22 @@
          */
         float carrierFrequencyHz;
 
-        /*
+        /**
          * Contains additional data about the given SV.
          */
         bitfield<GnssSvFlags> svFlag;
     };
 
-    /*
+    /**
      * Represents SV status.
      */
     struct GnssSvStatus {
-        /*
+        /**
          * Number of GNSS SVs currently visible, refers to the SVs stored in sv_list
          */
         uint32_t numSvs;
 
-        /*
+        /**
          * Pointer to an array of SVs information for all GNSS constellations,
          * except GNSS, which is reported using svList
          */
@@ -153,26 +153,26 @@
 
     };
 
-    /*
+    /**
      * Called when a GNSS location is available.
      *
      * @param location Location information from HAL.
      */
     gnssLocationCb(GnssLocation location);
 
-    /*
+    /**
      * Called to communicate the status of the GNSS engine.
      *
      * @param status Status information from HAL.
      */
     gnssStatusCb(GnssStatusValue status);
 
-    /*
+    /**
      * @param svInfo SV status information from HAL.
      */
     gnssSvStatusCb(GnssSvStatus svInfo);
 
-    /*
+    /**
      * Called when NMEA data is available.
      * Callback for reporting NMEA sentences.
      *
@@ -195,7 +195,7 @@
      */
     gnssNmeaCb(GnssUtcTime timestamp, string nmea);
 
-    /*
+    /**
      * Callback to inform framework of the GNSS engine's capabilities.
      *
      * @param capabilities Capability parameter is a bit field of
@@ -203,7 +203,7 @@
      */
     gnssSetCapabilitesCb(bitfield<Capabilities> capabilities);
 
-    /*
+    /**
      * Callback utility for acquiring the GNSS wakelock. This can be used to prevent
      * the CPU from suspending while handling GNSS events.
      */
@@ -215,7 +215,7 @@
     /** Callback for requesting NTP time */
     gnssRequestTimeCb();
 
-    /*
+    /**
      * Provides information about how new the underlying GPS/GNSS hardware and
      * software is.
      *
@@ -228,14 +228,14 @@
      * GnssMeasurement support will be verified.
      */
     struct GnssSystemInfo{
-        /*
+        /**
          * year in which the last update was made to the underlying hardware/firmware
          * used to capture GNSS signals, e.g. 2016
          */
         uint16_t yearOfHw;
     };
 
-    /*
+    /**
      * Callback to inform framework of the engine's hardware version information.
      *
      * @param info GnssSystemInfo about the GPS/GNSS hardware.
diff --git a/gnss/1.0/IGnssConfiguration.hal b/gnss/1.0/IGnssConfiguration.hal
index 2fb6e4e..e315286 100644
--- a/gnss/1.0/IGnssConfiguration.hal
+++ b/gnss/1.0/IGnssConfiguration.hal
@@ -16,68 +16,68 @@
 
 package android.hardware.gnss@1.0;
 
-/*
+/**
  * Interface for passing GNSS configuration info from platform to HAL.
  */
 interface IGnssConfiguration {
-    /*
+    /**
      * Enum which holds the bit masks for SUPL_MODE configuration parameter.
      */
     enum SuplMode : uint8_t {
-        /* Mobile Station Based */
+        /** Mobile Station Based */
         MSB = 0x01,
 
-        /* Mobile Station Assisted */
+        /** Mobile Station Assisted */
         MSA = 0x02
     };
 
-    /*
+    /**
      * Enum which holds the bit masks for GPS_LOCK configuration parameter.
      */
     enum GpsLock : uint8_t {
-        /* Lock Mobile Originated GPS functionalitues. */
+        /** Lock Mobile Originated GPS functionalitues. */
         MO    =  0x01,
 
-        /* Lock Network initiated GPS functionalities. */
+        /** Lock Network initiated GPS functionalities. */
         NI    =  0x02
     };
 
-    /*
+    /**
      * Enum that hold the bit masks for various LTE Positioning Profile settings (LPP_PROFILE
      * configuration parameter). If none of the bits in the enum are set, the default setting is
      * Radio Resource Location Protocol(RRLP).
      */
     enum LppProfile : uint8_t {
-        /* Enable LTE Positioning Protocol user plane */
+        /** Enable LTE Positioning Protocol user plane */
         USER_PLANE          = 0x01,
 
-        /* Enable LTE Positioning Protocol Control plane */
+        /** Enable LTE Positioning Protocol Control plane */
         CONTROL_PLANE       = 0x02
     };
 
-    /*
+    /**
      * Enum which holds the bit masks for A_GLONASS_POS_PROTOCOL_SELECT
      * configuration parameter.
      */
     enum GlonassPosProtocol : uint8_t {
-        /* Radio Resource Control(RRC) control-plane. */
+        /** Radio Resource Control(RRC) control-plane. */
         RRC_CPLANE                  = 0x01,
 
-        /* Radio Resource Location user-plane. */
+        /** Radio Resource Location user-plane. */
         RRLP_CPLANE                 = 0x02,
 
-        /* LTE Positioning Protocol User plane */
+        /** LTE Positioning Protocol User plane */
         LPP_UPLANE                  = 0x04
     };
 
-    /*
+    /**
      * IMPORTANT: GNSS HAL must expect the below methods to be called multiple
      * times. They can be called even when GnssLocationProvider is already
      * constructed and enabled. GNSS HAL must maintain the existing requests
      * for various callbacks regardless the change in configuration data.
      */
 
-     /*
+     /**
       * This method enables or disables emergency SUPL.
       *
       * @param enabled True if emergency SUPL is to be enabled.
@@ -86,7 +86,7 @@
       */
      setSuplEs(bool enabled) generates (bool success);
 
-     /*
+     /**
       * This method sets the SUPL version requested by Carrier. The GNSS HAL
       * must use this version of the SUPL protocol if supported.
       *
@@ -99,7 +99,7 @@
       */
      setSuplVersion(uint32_t version) generates (bool success);
 
-     /*
+     /**
       * This method sets the SUPL mode.
       *
       * @param mode Bit mask that specifies the SUPL mode which is set with the SuplMode enum.
@@ -108,7 +108,7 @@
       */
      setSuplMode(bitfield<SuplMode> mode) generates (bool success);
 
-     /*
+     /**
       * This setting configures how GPS functionalities should be locked when
       * user turns off GPS On setting.
       *
@@ -119,7 +119,7 @@
       */
      setGpsLock(bitfield<GpsLock> lock) generates (bool success);
 
-     /*
+     /**
       * This method sets the LTE Positioning Profile configuration.
       *
       * @param lppProfile Bitmask that specifies the LTE Positioning Profile
@@ -129,7 +129,7 @@
       */
      setLppProfile(bitfield<LppProfile> lppProfile) generates (bool success);
 
-     /*
+     /**
       * This method selects positioning protocol on A-Glonass system.
       *
       * @param protocol Bitmask that specifies the positioning protocol to be
@@ -139,7 +139,7 @@
       */
      setGlonassPositioningProtocol(bitfield<GlonassPosProtocol> protocol) generates (bool success);
 
-     /*
+     /**
       * This method configures which PDN to use.
       *
       * @param enable Use emergency PDN if true and regular PDN if false.
diff --git a/gnss/1.0/IGnssDebug.hal b/gnss/1.0/IGnssDebug.hal
index 8784d1a..9c1038f 100644
--- a/gnss/1.0/IGnssDebug.hal
+++ b/gnss/1.0/IGnssDebug.hal
@@ -1,107 +1,107 @@
 package android.hardware.gnss@1.0;
 
-/* Extended interface for DEBUG support. */
+/** Extended interface for DEBUG support. */
 interface IGnssDebug {
     enum SatelliteEphemerisType : uint8_t {
-        /* no information is known to the gnss hardware, about this satellite */
+        /** no information is known to the gnss hardware, about this satellite */
         UNKNOWN,
-        /*  this satellite is known to exist */
+        /**  this satellite is known to exist */
         KNOWN,
-        /*  this satellite is not known to exist */
+        /**  this satellite is not known to exist */
         NONEXISTENT,
-        /* Only Almanac (approximate) location known for this satellite */
+        /** Only Almanac (approximate) location known for this satellite */
         ALMANAC_ONLY,
-        /* Ephemeris is known from demodulating the signal on device */
+        /** Ephemeris is known from demodulating the signal on device */
         DEMODULATED,
-        /* Ephemeris has been provided by SUPL */
+        /** Ephemeris has been provided by SUPL */
         SUPL_PROVIDED,
-        /* Ephemeris has been provided by another server */
+        /** Ephemeris has been provided by another server */
         OTHER_SERVER_PROVIDED,
-        /*
+        /**
          * Predicted ephemeris has been provided by a server
          * (e.g. Xtra, Extended Ephemeris, etc...)
          */
         SERVER_PREDICTED,
-        /*
+        /**
          * Predicted ephemeris in use, generated locally on the device (e.g. from prior
          * ephemeris)
          */
         LOCALLY_PREDICTED
     };
 
-    /*
+    /**
      * Provides the current best known position from any
      * source (GNSS or injected assistance).
      */
     struct PositionDebug {
-        /*
+        /**
          * Validity of the data in this struct. False only if no
          * latitude/longitude information is known.
          */
         bool valid;
-        /* Latitude expressed in degrees */
+        /** Latitude expressed in degrees */
         double latitudeDegrees;
-        /* Longitude expressed in degrees */
+        /** Longitude expressed in degrees */
         double longitudeDegrees;
-        /* Altitude above ellipsoid expressed in meters */
+        /** Altitude above ellipsoid expressed in meters */
         float altitudeMeters;
-        /* Represents speed in meters per second. */
+        /** Represents speed in meters per second. */
         float speedMetersPerSec;
-        /* Represents heading in degrees. */
+        /** Represents heading in degrees. */
         float bearingDegrees;
-        /*
+        /**
          * estimated horizontal accuracy of position expressed in meters, radial,
          * 68% confidence.
          */
         double horizontalAccuracyMeters;
-        /*
+        /**
          * estimated vertical accuracy of position expressed in meters, with
          * 68% confidence.
          */
         double verticalAccuracyMeters;
-        /*
+        /**
          * estimated speed accuracy in meters per second with 68% confidence.
          */
         double speedAccuracyMetersPerSecond;
-        /*
+        /**
          * estimated bearing accuracy degrees with 68% confidence.
          */
         double bearingAccuracyDegrees;
-        /*
+        /**
          * Time duration before this report that this position information was
          * valid.
          */
         float ageSeconds;
     };
 
-    /*
+    /**
      * Provides the current best known UTC time estimate.
      */
     struct TimeDebug {
-        /*
+        /**
          * Validity of the data in the struct.
          * False if current time is unknown.
          */
         bool valid;
-        /*
+        /**
          * UTC time estimate.
          */
         GnssUtcTime timeEstimate;
-        /* 68% error estimate in time. */
+        /** 68% error estimate in time. */
         float timeUncertaintyNs;
     };
 
-    /*
+    /**
      * Provides a single satellite info that has decoded navigation data.
      */
     struct SatelliteData {
-        /* Satellite vehicle ID number */
+        /** Satellite vehicle ID number */
         int16_t svid;
-        /* Defines the constellation type of the given SV. */
+        /** Defines the constellation type of the given SV. */
         GnssConstellationType constellation;
-        /* Defines the ephemeris type of the satellite. */
+        /** Defines the ephemeris type of the satellite. */
         SatelliteEphemerisType ephemerisType;
-        /*
+        /**
          * Time duration before this report, that the ephemeris source was last
          * updated, e.g. latest demodulation, or latest server download.
          * Set to 0 when ephemerisType is UNKNOWN.
@@ -109,16 +109,16 @@
         float ephemerisAgeSeconds;
     };
 
-    /*
+    /**
      * Provides a set of debug information that is filled by the GNSS chipset
      * when the method getDebugData() is invoked.
      */
     struct DebugData {
-        /* Current best known position. */
+        /** Current best known position. */
         PositionDebug position;
-        /* Current best know time estimate */
+        /** Current best know time estimate */
         TimeDebug time;
-        /*
+        /**
          * Provides a list of the decoded satellite ephemeris.
          * Must provide a complete list for all constellations device can track,
          * including GnssConstellationType UNKNOWN.
@@ -127,7 +127,7 @@
 
     };
 
-    /*
+    /**
      * This methods requests position, time and satellite ephemeris debug information
      * from the HAL.
      *
diff --git a/gnss/1.0/IGnssGeofenceCallback.hal b/gnss/1.0/IGnssGeofenceCallback.hal
index 722317e..a73790a 100644
--- a/gnss/1.0/IGnssGeofenceCallback.hal
+++ b/gnss/1.0/IGnssGeofenceCallback.hal
@@ -16,7 +16,7 @@
 
 package android.hardware.gnss@1.0;
 
-/*
+/**
  * GNSS Geofence.
  * There are 3 states associated with a Geofence: Inside, Outside, Unknown.
  * There are 3 transitions: ENTERED, EXITED, UNCERTAIN.
@@ -114,7 +114,7 @@
         ERROR_GENERIC            = -149
     };
 
-    /*
+    /**
      * The callback associated with the geofence transition.
      * The callback must only be called when the caller is interested in that
      * particular transition. For instance, if the caller is interested only in
@@ -134,7 +134,7 @@
     gnssGeofenceTransitionCb(int32_t geofenceId, GnssLocation location,
         GeofenceTransition transition, GnssUtcTime timestamp);
 
-    /*
+    /**
      * The callback associated with the availability of the GNSS system for
      * geofencing monitoring. If the GNSS system determines that it cannot monitor
      * geofences because of lack of reliability or unavailability of the GNSS
@@ -145,7 +145,7 @@
      */
     gnssGeofenceStatusCb(GeofenceAvailability status, GnssLocation lastLocation);
 
-    /*
+    /**
      * The callback associated with the addGeofence call.
      *
      * @param geofenceId Id of the geofence.
@@ -159,7 +159,7 @@
      */
     gnssGeofenceAddCb(int32_t geofenceId, GeofenceStatus status);
 
-    /*
+    /**
      * The callback associated with the removeGeofence call.
      *
      * @param geofenceId Id of the geofence.
@@ -169,7 +169,7 @@
      */
     gnssGeofenceRemoveCb(int32_t geofenceId, GeofenceStatus status);
 
-    /*
+    /**
      * The callback associated with the pauseGeofence call.
      *
      * @param geofenceId Id of the geofence.
@@ -180,7 +180,7 @@
      */
     gnssGeofencePauseCb(int32_t geofenceId, GeofenceStatus status);
 
-    /*
+    /**
      * The callback associated with the resumeGeofence call.
      *
      * @param geofenceId - Id of the geofence.
diff --git a/gnss/1.0/IGnssGeofencing.hal b/gnss/1.0/IGnssGeofencing.hal
index b8348b3..562355a 100644
--- a/gnss/1.0/IGnssGeofencing.hal
+++ b/gnss/1.0/IGnssGeofencing.hal
@@ -18,9 +18,9 @@
 
 import IGnssGeofenceCallback;
 
-/* Extended interface for GNSS Geofencing support */
+/** Extended interface for GNSS Geofencing support */
 interface IGnssGeofencing {
-    /*
+    /**
      * Opens the geofence interface and provides the callback routines
      * to the HAL.
      *
@@ -28,7 +28,7 @@
      */
     setCallback(IGnssGeofenceCallback callback);
 
-    /*
+    /**
      * Add a geofence area. This api currently supports circular geofences.
      *
      * @param geofenceId The id for the geofence. If a geofence with this id
@@ -59,14 +59,14 @@
             uint32_t notificationResponsivenessMs,
             uint32_t unknownTimerMs);
 
-    /*
+    /**
      * Pause monitoring a particular geofence.
      *
      * @param geofenceId The id for the geofence.
      */
     pauseGeofence(int32_t geofenceId);
 
-    /*
+    /**
      * Resume monitoring a particular geofence.
      *
      * @param geofenceId - The id for the geofence.
@@ -78,7 +78,7 @@
     resumeGeofence(int32_t geofenceId,
             bitfield<IGnssGeofenceCallback.GeofenceTransition> monitorTransitions);
 
-    /*
+    /**
      * Remove a geofence area. After the function returns, no notifications
      * must be sent.
      *
diff --git a/gnss/1.0/IGnssMeasurement.hal b/gnss/1.0/IGnssMeasurement.hal
index 8329442..fad83d2 100644
--- a/gnss/1.0/IGnssMeasurement.hal
+++ b/gnss/1.0/IGnssMeasurement.hal
@@ -18,7 +18,7 @@
 
 import IGnssMeasurementCallback;
 
-/*
+/**
  * Extended interface for GNSS Measurements support.
  */
 interface IGnssMeasurement {
@@ -29,7 +29,7 @@
         ERROR_GENERIC = -101
     };
 
-    /*
+    /**
      * Initializes the interface and registers the callback routines with the HAL.
      * After a successful call to 'setCallback' the HAL must begin to provide updates at
      * an average output rate of 1Hz (occasional
@@ -46,7 +46,7 @@
      */
     setCallback(IGnssMeasurementCallback callback) generates (GnssMeasurementStatus initRet);
 
-    /*
+    /**
      * Stops updates from the HAL, and unregisters the callback routines.
      * After a call to close(), the previously registered callbacks must be
      * considered invalid by the HAL.
diff --git a/gnss/1.0/IGnssMeasurementCallback.hal b/gnss/1.0/IGnssMeasurementCallback.hal
index 5789621..467bf19 100644
--- a/gnss/1.0/IGnssMeasurementCallback.hal
+++ b/gnss/1.0/IGnssMeasurementCallback.hal
@@ -16,9 +16,9 @@
 
 package android.hardware.gnss@1.0;
 
-/* The callback interface to report measurements from the HAL. */
+/** The callback interface to report measurements from the HAL. */
 interface IGnssMeasurementCallback {
-    /*
+    /**
      * Flags to indicate what fields in GnssClock are valid.
      */
     @export(name="", value_prefix="GNSS_CLOCK_")
@@ -39,7 +39,7 @@
         HAS_DRIFT_UNCERTAINTY  = 1 << 6
     };
 
-    /*
+    /**
      * Flags to indicate what fields in GnssMeasurement are valid.
      */
     @export(name="", value_prefix="GNSS_MEASUREMENT_")
@@ -58,7 +58,7 @@
         HAS_AUTOMATIC_GAIN_CONTROL     = 1 << 13
     };
 
-    /*
+    /**
      * Enumeration of available values for the GNSS Measurement's multipath
      * indicator.
      */
@@ -72,7 +72,7 @@
         INDICATIOR_NOT_PRESENT = 2
     };
 
-    /*
+    /**
      * Flags indicating the GNSS measurement state.
      *
      * The expected behavior here is for GNSS HAL to set all the flags that applies.
@@ -106,7 +106,7 @@
         STATE_GLO_TOD_KNOWN          = 1 << 15,
     };
 
-    /*
+    /**
      * Flags indicating the Accumulated Delta Range's states.
      */
     @export(name="", value_prefix="GNSS_")
@@ -117,17 +117,17 @@
         ADR_STATE_CYCLE_SLIP = 1 << 2,
     };
 
-    /*
+    /**
      * Represents an estimate of the GNSS clock time.
      */
     struct GnssClock {
-        /*
+        /**
          * A set of flags indicating the validity of the fields in this data
          * structure.
          */
         bitfield<GnssClockFlags> gnssClockFlags;
 
-        /*
+        /**
          * Leap second data.
          * The sign of the value is defined by the following equation:
          *      utcTimeNs = timeNs - (fullBiasNs + biasNs) - leapSecond *
@@ -138,7 +138,7 @@
          */
         int16_t leapSecond;
 
-        /*
+        /**
          * The GNSS receiver internal clock value. This is the local hardware clock
          * value.
          *
@@ -159,7 +159,7 @@
          */
         int64_t timeNs;
 
-        /*
+        /**
          * 1-Sigma uncertainty associated with the clock's time in nanoseconds.
          * The uncertainty is represented as an absolute (single sided) value.
          *
@@ -170,7 +170,7 @@
          */
         double timeUncertaintyNs;
 
-        /*
+        /**
          * The difference between hardware clock ('time' field) inside GNSS receiver
          * and the true GNSS time since 0000Z, January 6, 1980, in nanoseconds.
          *
@@ -187,7 +187,7 @@
          */
         int64_t fullBiasNs;
 
-        /*
+        /**
          * Sub-nanosecond bias.
          * The error estimate for the sum of this and the fullBiasNs is the
          * biasUncertaintyNs.
@@ -198,7 +198,7 @@
          */
         double biasNs;
 
-        /*
+        /**
          * 1-Sigma uncertainty associated with the local estimate of GNSS time (clock
          * bias) in nanoseconds. The uncertainty is represented as an absolute
          * (single sided) value.
@@ -209,7 +209,7 @@
          */
         double biasUncertaintyNs;
 
-        /*
+        /**
          * The clock's drift in nanoseconds (per second).
          *
          * A positive value means that the frequency is higher than the nominal
@@ -223,7 +223,7 @@
          */
         double driftNsps;
 
-        /*
+        /**
          * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per
          * second).
          * The uncertainty is represented as an absolute (single sided) value.
@@ -234,7 +234,7 @@
          */
         double driftUncertaintyNsps;
 
-        /*
+        /**
          * When there are any discontinuities in the HW clock, this field is
          * mandatory.
          *
@@ -267,7 +267,7 @@
 
     };
 
-    /*
+    /**
      * Represents a GNSS Measurement, it contains raw and computed information.
      *
      * All signal measurement information (e.g. svTime,
@@ -277,24 +277,24 @@
      * position, velocity, or time.
      */
     struct GnssMeasurement{
-        /*
+        /**
          * A set of flags indicating the validity of the fields in this data
          * structure.
          */
         bitfield<GnssMeasurementFlags> flags;
 
-        /*
+        /**
          * Satellite vehicle ID number, as defined in GnssSvInfo::svid
          * This is a mandatory value.
          */
         int16_t svid;
 
-        /*
+        /**
          * Defines the constellation of the given SV.
          */
         GnssConstellationType constellation;
 
-        /*
+        /**
          * Time offset at which the measurement was taken in nanoseconds.
          * The reference receiver's time is specified by GnssData::clock::timeNs.
          *
@@ -307,7 +307,7 @@
          */
         double timeOffsetNs;
 
-        /*
+        /**
          * Per satellite sync state. It represents the current sync state for the
          * associated satellite.
          * Based on the sync state, the 'received GNSS tow' field must be interpreted
@@ -317,7 +317,7 @@
          */
         bitfield<GnssMeasurementState> state;
 
-        /*
+        /**
          * The received GNSS Time-of-Week at the measurement time, in nanoseconds.
          * For GNSS & QZSS, this is the received GNSS Time-of-Week at the
          * measurement time, in nanoseconds. The value is relative to the
@@ -402,14 +402,14 @@
          */
         int64_t receivedSvTimeInNs;
 
-        /*
+        /**
          * 1-Sigma uncertainty of the Received GNSS Time-of-Week in nanoseconds.
          *
          * This value must be populated if 'state' != STATE_UNKNOWN.
          */
         int64_t receivedSvTimeUncertaintyInNs;
 
-        /*
+        /**
          * Carrier-to-noise density in dB-Hz, typically in the range [0, 63].
          * It contains the measured C/N0 value for the signal at the antenna port.
          *
@@ -417,7 +417,7 @@
          */
         double cN0DbHz;
 
-        /*
+        /**
          * Pseudorange rate at the timestamp in m/s. The correction of a given
          * Pseudorange Rate value includes corrections for receiver and satellite
          * clock frequency errors. Ensure that this field is independent (see
@@ -445,7 +445,7 @@
          */
         double pseudorangeRateMps;
 
-        /*
+        /**
          * 1-Sigma uncertainty of the pseudorangeRateMps.
          * The uncertainty is represented as an absolute (single sided) value.
          *
@@ -453,7 +453,7 @@
          */
         double pseudorangeRateUncertaintyMps;
 
-        /*
+        /**
          * Accumulated delta range's state. It indicates whether ADR is reset or
          * there is a cycle slip(indicating loss of lock).
          *
@@ -461,7 +461,7 @@
          */
         bitfield<GnssAccumulatedDeltaRangeState> accumulatedDeltaRangeState;
 
-        /*
+        /**
          * Accumulated delta range since the last channel reset in meters.
          * A positive value indicates that the SV is moving away from the receiver.
          *
@@ -476,14 +476,14 @@
          */
         double accumulatedDeltaRangeM;
 
-        /*
+        /**
          * 1-Sigma uncertainty of the accumulated delta range in meters.
          * This value must be populated if 'accumulated delta range state' !=
          * ADR_STATE_UNKNOWN.
          */
         double accumulatedDeltaRangeUncertaintyM;
 
-        /*
+        /**
          * Carrier frequency of the signal tracked, for example it can be the
          * GPS central frequency for L1 = 1575.45 MHz, or L2 = 1227.60 MHz, L5 =
          * 1176.45 MHz, varying GLO channels, etc. If the field is not set, it
@@ -501,7 +501,7 @@
          */
         float carrierFrequencyHz;
 
-        /*
+        /**
          * The number of full carrier cycles between the satellite and the
          * receiver. The reference frequency is given by the field
          * 'carrierFrequencyHz'. Indications of possible cycle slips and
@@ -513,7 +513,7 @@
          */
         int64_t carrierCycles;
 
-        /*
+        /**
          * The RF phase detected by the receiver, in the range [0.0, 1.0].
          * This is usually the fractional part of the complete carrier phase
          * measurement.
@@ -526,14 +526,14 @@
          */
         double carrierPhase;
 
-        /*
+        /**
          * 1-Sigma uncertainty of the carrier-phase.
          * If the data is available, gnssClockFlags must contain
          * HAS_CARRIER_PHASE_UNCERTAINTY.
          */
         double carrierPhaseUncertainty;
 
-        /*
+        /**
          * An enumeration that indicates the 'multipath' state of the event.
          *
          * The multipath Indicator is intended to report the presence of overlapping
@@ -554,7 +554,7 @@
          */
         GnssMultipathIndicator multipathIndicator;
 
-        /*
+        /**
          * Signal-to-noise ratio at correlator output in dB.
          * If the data is available, gnssClockFlags must contain MEASUREMENT_HAS_SNR.
          * This is the power ratio of the "correlation peak height above the
@@ -562,7 +562,7 @@
          */
         double snrDb;
 
-        /*
+        /**
          * Automatic gain control (AGC) level. AGC acts as a variable gain
          * amplifier adjusting the power of the incoming signal. The AGC level
          * may be used to indicate potential interference. When AGC is at a
@@ -581,7 +581,7 @@
         double agcLevelDb;
     };
 
-    /*
+    /**
      * Represents a reading of GNSS measurements. For devices where GnssSystemInfo's
      * yearOfHw is set to 2016+, it is mandatory that these be provided, on
      * request, when the GNSS receiver is searching/tracking signals.
@@ -590,17 +590,17 @@
      * - Reporting of all tracked constellations are encouraged.
      */
     struct GnssData {
-        /* Number of GnssMeasurement elements. */
+        /** Number of GnssMeasurement elements. */
         uint32_t measurementCount;
 
-        /* The array of measurements. */
+        /** The array of measurements. */
         GnssMeasurement[GnssMax:SVS_COUNT] measurements;
 
         /** The GNSS clock time reading. */
         GnssClock clock;
     };
 
-    /*
+    /**
      * Callback for the hal to pass a GnssData structure back to the client.
      *
      * @param data Contains a reading of GNSS measurements.
diff --git a/gnss/1.0/IGnssNavigationMessage.hal b/gnss/1.0/IGnssNavigationMessage.hal
index ddd9169..db46d11 100644
--- a/gnss/1.0/IGnssNavigationMessage.hal
+++ b/gnss/1.0/IGnssNavigationMessage.hal
@@ -18,7 +18,7 @@
 
 import IGnssNavigationMessageCallback;
 
-/*
+/**
  * Extended interface for GNSS navigation message reporting support.
  */
 interface IGnssNavigationMessage {
@@ -29,7 +29,7 @@
         ERROR_GENERIC = -101
     };
 
-    /*
+    /**
      * Initializes the interface and registers the callback routines with the HAL.
      * After a successful call to 'setCallback' the HAL must begin to provide updates as
      * they become available.
@@ -45,7 +45,7 @@
      */
      setCallback(IGnssNavigationMessageCallback callback) generates (GnssNavigationMessageStatus initRet);
 
-    /*
+    /**
      * Stops updates from the HAL, and unregisters the callback routines.
      * After a call to close(), the previously registered callbacks must be
      * considered invalid by the HAL.
diff --git a/gnss/1.0/IGnssNavigationMessageCallback.hal b/gnss/1.0/IGnssNavigationMessageCallback.hal
index 2e6b853..714351b 100644
--- a/gnss/1.0/IGnssNavigationMessageCallback.hal
+++ b/gnss/1.0/IGnssNavigationMessageCallback.hal
@@ -18,7 +18,7 @@
 
 /** Represents a GNSS navigation message (or a fragment of it). */
 interface IGnssNavigationMessageCallback {
-    /*
+    /**
      * Enumeration of available values to indicate the GNSS Navigation message
      * types.
      *
@@ -48,7 +48,7 @@
         GAL_F           = 0x0602
     };
 
-    /*
+    /**
      * Status of Navigation Message
      * When a message is received properly without any parity error in its
      * navigation words, the status must be set to PARITY_PASSED. But if a message is
@@ -65,26 +65,26 @@
     };
 
     struct GnssNavigationMessage {
-        /*
+        /**
          * Satellite vehicle ID number, as defined in GnssSvInfo::svid
          * This is a mandatory value.
          */
         int16_t svid;
 
-        /*
+        /**
          * The type of message contained in the structure.
          * This is a mandatory value.
          */
         GnssNavigationMessageType type;
 
-        /*
+        /**
          * The status of the received navigation message.
          * No need to send any navigation message that contains words with parity
          * error and cannot be corrected.
          */
         bitfield<NavigationMessageStatus> status;
 
-        /*
+        /**
          * Message identifier. It provides an index so the complete Navigation
          * Message can be assembled.
          *
@@ -106,7 +106,7 @@
          */
         int16_t messageId;
 
-        /*
+        /**
          * Sub-message identifier. If required by the message 'type', this value
          * contains a sub-index within the current message (or frame) that is being
          * transmitted.
@@ -123,7 +123,7 @@
          */
         int16_t submessageId;
 
-        /*
+        /**
          * The data of the reported GNSS message. The bytes (or words) are specified
          * using big endian format (MSB first). The data is stored and decoded
          * in a server for research purposes.
@@ -158,7 +158,7 @@
         vec<uint8_t> data;
     };
 
-    /*
+    /**
      * The callback to report an available fragment of a GNSS navigation messages
      * from the HAL.
      *
diff --git a/gnss/1.0/IGnssNi.hal b/gnss/1.0/IGnssNi.hal
index c823bf0..fa98ab0 100644
--- a/gnss/1.0/IGnssNi.hal
+++ b/gnss/1.0/IGnssNi.hal
@@ -17,19 +17,19 @@
 package android.hardware.gnss@1.0;
 import IGnssNiCallback;
 
-/*
+/**
  * Extended interface for Network-initiated (NI) support. This interface is used
  * to respond to NI notifications originating from the HAL.
  */
 interface IGnssNi {
-    /*
+    /**
      * Registers the callbacks for HAL to use.
      *
      * @param callback handle to IGnssNiCallback interface.
      */
     setCallback(IGnssNiCallback callback);
 
-    /*
+    /**
      * Sends a response to HAL.
      *
      * @param notifId An ID generated by HAL to associate NI notifications and
diff --git a/gnss/1.0/IGnssNiCallback.hal b/gnss/1.0/IGnssNiCallback.hal
index c5fb223..163ba25 100644
--- a/gnss/1.0/IGnssNiCallback.hal
+++ b/gnss/1.0/IGnssNiCallback.hal
@@ -16,9 +16,9 @@
 
 package android.hardware.gnss@1.0;
 
-/* GNSS Network Initiated callback interface. */
+/** GNSS Network Initiated callback interface. */
 interface IGnssNiCallback {
-    /*
+    /**
      * GnssNiType constants
      */
     @export(name="", value_prefix="GPS_NI_TYPE_")
@@ -28,7 +28,7 @@
         UMTS_CTRL_PLANE = 3
     };
 
-    /*
+    /**
      * GnssNiNotifyFlags constants
      */
     @export(name="", value_prefix="GPS_NI_")
@@ -41,7 +41,7 @@
         PRIVACY_OVERRIDE = 0x0004,
     };
 
-    /*
+    /**
      * GNSS NI responses, used to define the response in
      * NI structures
      */
@@ -52,7 +52,7 @@
         RESPONSE_NORESP  = 3,
     };
 
-    /*
+    /**
      * NI data encoding scheme
      */
     @export(name="", value_prefix="GPS_")
@@ -66,59 +66,59 @@
 
     /** Represents an NI request */
     struct GnssNiNotification{
-        /*
+        /**
          * An ID generated by HAL to associate NI notifications and UI
          * responses.
          */
         int32_t notificationId;
 
-        /*
+        /**
          * A type used to distinguish different categories of NI
          * events, such as VOICE, UMTS_SUPL etc.
          */
         GnssNiType niType;
 
-        /*
+        /**
          * Notification/verification options, combinations of GnssNiNotifyFlags
          * constants.
          */
         bitfield<GnssNiNotifyFlags> notifyFlags;
 
-        /*
+        /**
          * Timeout period to wait for user response.
          * Set to 0 for no timeout limit. Specified in seconds.
          */
         uint32_t timeoutSec;
 
-        /*
+        /**
          * Default response when timeout.
          */
         GnssUserResponseType defaultResponse;
 
-        /*
+        /**
          * String representing the requester of the network inititated location
          * request.
          */
         string requestorId;
 
-        /*
+        /**
          * Notification message. String representing the service(for eg. SUPL-service)
          * who sent the network initiated location request.
          */
         string notificationMessage;
 
-        /*
+        /**
          * requestorId decoding scheme.
          */
         GnssNiEncodingType requestorIdEncoding;
 
-        /*
+        /**
          * notificationId decoding scheme
          */
         GnssNiEncodingType notificationIdEncoding;
     };
 
-    /*
+    /**
      * Callback with a network initiated request.
      *
      * @param notification network initiated request.
diff --git a/gnss/1.0/IGnssXtra.hal b/gnss/1.0/IGnssXtra.hal
index 5222fde..a2c8f39 100644
--- a/gnss/1.0/IGnssXtra.hal
+++ b/gnss/1.0/IGnssXtra.hal
@@ -1,12 +1,12 @@
 package android.hardware.gnss@1.0;
 import IGnssXtraCallback;
 
-/*
+/**
  * This interface is used by the GNSS HAL to request the framework
  * to download XTRA data.
  */
 interface IGnssXtra {
-    /*
+    /**
      * Opens the XTRA interface and provides the callback routines
      * to the implementation of this interface.
      *
@@ -16,7 +16,7 @@
      */
     setCallback(IGnssXtraCallback callback) generates (bool success);
 
-    /*
+    /**
      * Inject the downloaded XTRA data into the GNSS receiver.
      *
      * @param xtraData GNSS XTRA data.
diff --git a/gnss/1.0/IGnssXtraCallback.hal b/gnss/1.0/IGnssXtraCallback.hal
index 42df082..838f1ad 100644
--- a/gnss/1.0/IGnssXtraCallback.hal
+++ b/gnss/1.0/IGnssXtraCallback.hal
@@ -1,10 +1,10 @@
 package android.hardware.gnss@1.0;
 
-/*
+/**
  * This interface is used by the GNSS HAL to request download of XTRA data.
  */
 interface IGnssXtraCallback {
-   /*
+   /**
     * Callback to request the client to download XTRA data. The client should
     * download XTRA data and inject it by calling injectXtraData().
     */
diff --git a/gnss/1.0/types.hal b/gnss/1.0/types.hal
index d5e0e9b..ea2c756 100644
--- a/gnss/1.0/types.hal
+++ b/gnss/1.0/types.hal
@@ -22,10 +22,10 @@
     SVS_COUNT = 64,
 };
 
-/* Milliseconds since January 1, 1970 */
+/** Milliseconds since January 1, 1970 */
 typedef int64_t GnssUtcTime;
 
-/*
+/**
  * Constellation type of GnssSvInfo
  */
 
@@ -61,52 +61,52 @@
     HAS_BEARING_ACCURACY      = 0x0080
 };
 
-/* Represents a location. */
+/** Represents a location. */
 struct GnssLocation {
-    /* Contains GnssLocationFlags bits. */
+    /** Contains GnssLocationFlags bits. */
     bitfield<GnssLocationFlags> gnssLocationFlags;
 
-    /* Represents latitude in degrees. */
+    /** Represents latitude in degrees. */
     double latitudeDegrees;
 
-    /* Represents longitude in degrees. */
+    /** Represents longitude in degrees. */
     double longitudeDegrees;
 
-    /*
+    /**
      * Represents altitude in meters above the WGS 84 reference ellipsoid.
      */
     double altitudeMeters;
 
-    /* Represents speed in meters per second. */
+    /** Represents speed in meters per second. */
     float speedMetersPerSec;
 
-    /* Represents heading in degrees. */
+    /** Represents heading in degrees. */
     float bearingDegrees;
 
-    /*
+    /**
     * Represents expected horizontal position accuracy, radial, in meters
     * (68% confidence).
     */
     float horizontalAccuracyMeters;
 
-    /*
+    /**
     * Represents expected vertical position accuracy in meters
     * (68% confidence).
     */
     float verticalAccuracyMeters;
 
-    /*
+    /**
     * Represents expected speed accuracy in meter per seconds
     * (68% confidence).
     */
     float speedAccuracyMetersPerSecond;
 
-    /*
+    /**
     * Represents expected bearing accuracy in degrees
     * (68% confidence).
     */
     float bearingAccuracyDegrees;
 
-    /* Timestamp for the location fix. */
+    /** Timestamp for the location fix. */
     GnssUtcTime timestamp;
 };
diff --git a/graphics/allocator/2.0/IAllocator.hal b/graphics/allocator/2.0/IAllocator.hal
index 00d07d5..bf0e141 100644
--- a/graphics/allocator/2.0/IAllocator.hal
+++ b/graphics/allocator/2.0/IAllocator.hal
@@ -20,23 +20,23 @@
 
 interface IAllocator {
     enum Capability : int32_t {
-        /* reserved */
+        /** reserved */
         INVALID = 0,
 
-        /*
+        /**
          * IAllocatorClient::testAllocate must always return UNDEFINED unless
          * this capability is supported.
          */
         TEST_ALLOCATE = 1,
 
-        /*
+        /**
          * IAllocatorClient::BufferDescriptorInfo::layerCount must be 1 unless
          * this capability is supported.
          */
         LAYERED_BUFFERS = 2,
     };
 
-    /*
+    /**
      * Provides a list of supported capabilities (as described in the
      * definition of Capability above). This list must not change after
      * initialization.
@@ -48,7 +48,7 @@
     @callflow(next="*")
     getCapabilities() generates (vec<Capability> capabilities);
 
-    /*
+    /**
      * Retrieves implementation-defined debug information, which will be
      * displayed during, for example, `dumpsys SurfaceFlinger`.
      *
@@ -59,7 +59,7 @@
     @callflow(next="*")
     dumpDebugInfo() generates (string debugInfo);
 
-    /*
+    /**
      * Creates a client of the allocator. All resources created by the client
      * are owned by the client and are only visible to the client, unless they
      * are exported by exportHandle.
diff --git a/graphics/allocator/2.0/IAllocatorClient.hal b/graphics/allocator/2.0/IAllocatorClient.hal
index 080e3ea..8ca568f 100644
--- a/graphics/allocator/2.0/IAllocatorClient.hal
+++ b/graphics/allocator/2.0/IAllocatorClient.hal
@@ -20,7 +20,7 @@
 
 interface IAllocatorClient {
     struct BufferDescriptorInfo {
-        /*
+        /**
          * The width specifies how many columns of pixels must be in the
          * allocated buffer, but does not necessarily represent the offset in
          * columns between the same column in adjacent rows. The rows may be
@@ -28,34 +28,34 @@
          */
         uint32_t width;
 
-       /*
+       /**
         * The height specifies how many rows of pixels must be in the
         * allocated buffer.
         */
         uint32_t height;
 
-       /*
+       /**
         * The number of image layers that must be in the allocated buffer.
         */
         uint32_t layerCount;
 
-        /* Buffer pixel format. */
+        /** Buffer pixel format. */
         PixelFormat format;
 
-        /*
+        /**
          * Buffer producer usage mask; valid flags can be found in the
          * definition of ProducerUsage.
          */
         uint64_t producerUsageMask;
 
-        /*
+        /**
          * Buffer consumer usage mask; valid flags can be found in the
          * definition of ConsumerUsage.
          */
         uint64_t consumerUsageMask;
     };
 
-    /*
+    /**
      * Creates a new, opaque buffer descriptor.
      *
      * @param descriptorInfo specifies the attributes of the buffer
@@ -71,7 +71,7 @@
           generates (Error error,
                      BufferDescriptor descriptor);
 
-    /*
+    /**
      * Destroys an existing buffer descriptor.
      *
      * @param descriptor is the descriptor to destroy.
@@ -81,7 +81,7 @@
     @callflow(next="*")
     destroyDescriptor(BufferDescriptor descriptor) generates (Error error);
 
-    /*
+    /**
      * Tests whether a buffer allocation can succeed, ignoring potential
      * resource contention which might lead to a NO_RESOURCES error.
      *
@@ -98,7 +98,7 @@
     @callflow(next="allocate")
     testAllocate(vec<BufferDescriptor> descriptors) generates (Error error);
 
-    /*
+    /**
      * Attempts to allocate a list of buffers sharing a backing store.
      *
      * Each buffer must correspond to one of the descriptors passed into the
@@ -124,7 +124,7 @@
         generates (Error error,
                    vec<Buffer> buffers);
 
-    /*
+    /**
      * Frees a buffer.
      *
      * @param buffer is the buffer to be freed.
@@ -135,7 +135,7 @@
     @callflow(next="*")
     free(Buffer buffer) generates (Error error);
 
-    /*
+    /**
      * Exports a buffer for use in other client libraries or for cross-process
      * sharing.
      *
diff --git a/graphics/allocator/2.0/types.hal b/graphics/allocator/2.0/types.hal
index f9d1e1b..d9b184b 100644
--- a/graphics/allocator/2.0/types.hal
+++ b/graphics/allocator/2.0/types.hal
@@ -17,130 +17,131 @@
 package android.hardware.graphics.allocator@2.0;
 
 enum Error : int32_t {
-    NONE            = 0, /* no error */
-    BAD_DESCRIPTOR  = 1, /* invalid BufferDescriptor */
-    BAD_BUFFER      = 2, /* invalid Buffer */
-    BAD_VALUE       = 3, /* invalid width, height, etc. */
-    NOT_SHARED      = 4, /* buffers not sharing backing store */
-    NO_RESOURCES    = 5, /* temporary failure due to resource contention */
-    UNDEFINED       = 6, /* an operation has no defined meaning */
-    UNSUPPORTED     = 7, /* permanent failure */
+    NONE            = 0, /** no error */
+    BAD_DESCRIPTOR  = 1, /** invalid BufferDescriptor */
+    BAD_BUFFER      = 2, /** invalid Buffer */
+    BAD_VALUE       = 3, /** invalid width, height, etc. */
+    NOT_SHARED      = 4, /** buffers not sharing backing store */
+    NO_RESOURCES    = 5, /** temporary failure due to resource contention */
+    UNDEFINED       = 6, /** an operation has no defined meaning */
+    UNSUPPORTED     = 7, /** permanent failure */
 };
 
 enum ProducerUsage : uint64_t {
-    /* bit 0 is reserved */
+    /** bit 0 is reserved */
 
-    /* buffer is read by CPU occasionally */
+    /** buffer is read by CPU occasionally */
     CPU_READ        = 1ULL << 1,
-    /* buffer is read by CPU frequently */
+    /** buffer is read by CPU frequently */
     CPU_READ_OFTEN  = 1ULL << 2,
 
-    /* bit 3 is reserved */
-    /* bit 4 is reserved */
+    /** bit 3 is reserved */
+    /** bit 4 is reserved */
 
-    /* buffer is written by CPU occasionally */
+    /** buffer is written by CPU occasionally */
     CPU_WRITE       = 1ULL << 5,
-    /* buffer is written by CPU frequently */
+    /** buffer is written by CPU frequently */
     CPU_WRITE_OFTEN = 1ULL << 6,
 
-    /* bit 7 is reserved */
-    /* bit 8 is reserved */
+    /** bit 7 is reserved */
+    /** bit 8 is reserved */
 
-    /* buffer is used as a GPU render target */
+    /** buffer is used as a GPU render target */
     GPU_RENDER_TARGET = 1ULL << 9,
 
-    /* bit 10 is reserved */
-    /* bit 11 is reserved */
-    /* bit 12 is reserved */
-    /* bit 13 is reserved */
+    /** bit 10 is reserved */
+    /** bit 11 is reserved */
+    /** bit 12 is reserved */
+    /** bit 13 is reserved */
 
-    /*
+    /**
      * Buffer is allocated with hardware-level protection against copying the
      * contents (or information derived from the contents) into unprotected
      * memory.
      */
     PROTECTED         = 1ULL << 14,
 
-    /* bit 15 is reserved */
-    /* bit 16 is reserved */
+    /** bit 15 is reserved */
+    /** bit 16 is reserved */
 
-    /* buffer is used as a camera HAL output */
+    /** buffer is used as a camera HAL output */
     CAMERA            = 1ULL << 17,
 
-    /* bit 18 is reserved */
-    /* bit 19 is reserved */
-    /* bit 20 is reserved */
-    /* bit 21 is reserved */
+    /** bit 18 is reserved */
+    /** bit 19 is reserved */
+    /** bit 20 is reserved */
+    /** bit 21 is reserved */
 
-    /* buffer is used as a video decoder output */
+    /** buffer is used as a video decoder output */
     VIDEO_DECODER     = 1ULL << 22,
 
-    /* buffer is used as a sensor direct report output */
+    /** buffer is used as a sensor direct report output */
     SENSOR_DIRECT_DATA = 1ULL << 23,
 
-    /* bits 24-27 are reserved for future versions */
-    /* bits 28-31 are reserved for vendor extensions */
+    /** bits 24-27 are reserved for future versions */
+    /** bits 28-31 are reserved for vendor extensions */
 
-    /* bits 32-47 are reserved for future versions */
-    /* bits 48-63 are reserved for vendor extensions */
+    /** bits 32-47 are reserved for future versions */
+    /** bits 48-63 are reserved for vendor extensions */
 };
 
 enum ConsumerUsage : uint64_t {
-    /* bit 0 is reserved */
+    /** bit 0 is reserved */
 
-    /* buffer is read by CPU occasionally */
+    /** buffer is read by CPU occasionally */
     CPU_READ          = 1ULL << 1,
-    /* buffer is read by CPU frequently */
+    /** buffer is read by CPU frequently */
     CPU_READ_OFTEN    = 1ULL << 2,
 
-    /* bit 3 is reserved */
-    /* bit 4 is reserved */
-    /* bit 5 is reserved */
-    /* bit 6 is reserved */
-    /* bit 7 is reserved */
+    /** bit 3 is reserved */
+    /** bit 4 is reserved */
+    /** bit 5 is reserved */
+    /** bit 6 is reserved */
+    /** bit 7 is reserved */
 
-    /* buffer is used as a GPU texture */
+    /** buffer is used as a GPU texture */
     GPU_TEXTURE       = 1ULL << 8,
 
-    /* bit 9 is reserved */
-    /* bit 10 is reserved */
+    /** bit 9 is reserved */
+    /** bit 10 is reserved */
 
-    /* buffer is used by hwcomposer HAL */
+    /** buffer is used by hwcomposer HAL */
     HWCOMPOSER        = 1ULL << 11,
-    /* buffer is a hwcomposer HAL client target */
+    /** buffer is a hwcomposer HAL client target */
     CLIENT_TARGET     = 1ULL << 12,
 
-    /* bit 13 is reserved */
-    /* bit 14 is reserved */
+    /** bit 13 is reserved */
+    /** bit 14 is reserved */
 
-    /* buffer is used as a hwcomposer HAL cursor */
+    /** buffer is used as a hwcomposer HAL cursor */
     CURSOR            = 1ULL << 15,
 
-    /* buffer is used as a video encoder input */
+    /** buffer is used as a video encoder input */
     VIDEO_ENCODER     = 1ULL << 16,
 
-    /* bit 17 is reserved */
+    /** bit 17 is reserved */
 
-    /* buffer is used as a camera HAL input */
+    /** buffer is used as a camera HAL input */
     CAMERA            = 1ULL << 18,
 
-    /* bit 19 is reserved */
+    /** bit 19 is reserved */
 
-    /* buffer is used as a renderscript allocation */
+    /** buffer is used as a renderscript allocation */
     RENDERSCRIPT      = 1ULL << 20,
 
-    /* bit 21 is reserved */
-    /* bit 22 is reserved */
+    /** bit 21 is reserved */
+    /** bit 22 is reserved */
 
-    /* buffer is used as as an OpenGL shader storage or uniform
+    /**
+     * buffer is used as as an OpenGL shader storage or uniform
        buffer object */
     GPU_DATA_BUFFER    = 1ULL << 23,
 
-    /* bits 24-27 are reserved for future versions */
-    /* bits 28-31 are reserved for vendor extensions */
+    /** bits 24-27 are reserved for future versions */
+    /** bits 28-31 are reserved for vendor extensions */
 
-    /* bits 32-47 are reserved for future versions */
-    /* bits 48-63 are reserved for vendor extensions */
+    /** bits 32-47 are reserved for future versions */
+    /** bits 48-63 are reserved for vendor extensions */
 };
 
 typedef uint64_t BufferDescriptor;
diff --git a/graphics/bufferqueue/1.0/IGraphicBufferProducer.hal b/graphics/bufferqueue/1.0/IGraphicBufferProducer.hal
index c59a16c..87bb814 100644
--- a/graphics/bufferqueue/1.0/IGraphicBufferProducer.hal
+++ b/graphics/bufferqueue/1.0/IGraphicBufferProducer.hal
@@ -546,7 +546,7 @@
      */
     disconnect(
             int32_t api,
-            DisconnectMode mode /* = DisconnectMode::API */
+            DisconnectMode mode /** = DisconnectMode::API */
         ) generates (
             Status status
         );
diff --git a/graphics/common/1.0/types.hal b/graphics/common/1.0/types.hal
index 70cb8ec..8aa0779 100644
--- a/graphics/common/1.0/types.hal
+++ b/graphics/common/1.0/types.hal
@@ -21,7 +21,7 @@
  */
 @export(name="android_pixel_format_t", value_prefix="HAL_PIXEL_FORMAT_")
 enum PixelFormat : int32_t {
-    /*
+    /**
      * "linear" color pixel formats:
      *
      * When used with ANativeWindow, the dataSpace field describes the color
@@ -37,7 +37,7 @@
     RGB_565            = 4,
     BGRA_8888          = 5,
 
-    /*
+    /**
      * The following formats use 10bit integers for R, G, and B and
      * 2 bits for alpha. This is used to improve color precision on
      * wide-color devices, e.g. Display-P3 or scRGB.
@@ -47,7 +47,7 @@
      */
     RGBA_1010102       = 0x2B,
 
-    /*
+    /**
      * The following formats use a 16bit float per color component.
      *
      * When used with ANativeWindow, the dataSpace field describes the color
@@ -55,7 +55,7 @@
      */
     RGBA_FP16          = 0x16,
 
-    /*
+    /**
      * 0x101 - 0x1FF
      *
      * This range is reserved for pixel formats that are specific to the HAL
@@ -66,7 +66,7 @@
      * GL_OES_EGL_image_external OpenGL ES extension.
      */
 
-    /*
+    /**
      * Android YUV format:
      *
      * This format is exposed outside of the HAL to software decoders and
@@ -95,7 +95,7 @@
     YV12   = 0x32315659, // YCrCb 4:2:0 Planar
 
 
-    /*
+    /**
      * Android Y8 format:
      *
      * This format is exposed outside of the HAL to the framework.
@@ -120,7 +120,7 @@
      */
     Y8     = 0x20203859,
 
-    /*
+    /**
      * Android Y16 format:
      *
      * This format is exposed outside of the HAL to the framework.
@@ -149,7 +149,7 @@
      */
     Y16    = 0x20363159,
 
-    /*
+    /**
      * Android RAW sensor format:
      *
      * This format is exposed outside of the camera HAL to applications.
@@ -195,7 +195,7 @@
      */
     RAW16 = 0x20,
 
-    /*
+    /**
      * Android RAW10 format:
      *
      * This format is exposed outside of the camera HAL to applications.
@@ -249,7 +249,7 @@
      */
     RAW10 = 0x25,
 
-    /*
+    /**
      * Android RAW12 format:
      *
      * This format is exposed outside of camera HAL to applications.
@@ -299,7 +299,7 @@
      */
     RAW12 = 0x26,
 
-    /*
+    /**
      * Android opaque RAW format:
      *
      * This format is exposed outside of the camera HAL to applications.
@@ -320,7 +320,7 @@
      */
     RAW_OPAQUE = 0x24,
 
-    /*
+    /**
      * Android binary blob graphics buffer format:
      *
      * This format is used to carry task-specific data which does not have a
@@ -346,7 +346,7 @@
      */
     BLOB = 0x21,
 
-    /*
+    /**
      * Android format indicating that the choice of format is entirely up to the
      * device-specific Gralloc implementation.
      *
@@ -364,7 +364,7 @@
      */
     IMPLEMENTATION_DEFINED = 0x22,
 
-    /*
+    /**
      * Android flexible YCbCr 4:2:0 formats
      *
      * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:0
@@ -386,7 +386,7 @@
      */
     YCBCR_420_888 = 0x23,
 
-    /*
+    /**
      * Android flexible YCbCr 4:2:2 formats
      *
      * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:2
@@ -400,7 +400,7 @@
      */
     YCBCR_422_888 = 0x27,
 
-    /*
+    /**
      * Android flexible YCbCr 4:4:4 formats
      *
      * This format allows platforms to use an efficient YCbCr/YCrCb 4:4:4
@@ -414,7 +414,7 @@
      */
     YCBCR_444_888 = 0x28,
 
-    /*
+    /**
      * Android flexible RGB 888 formats
      *
      * This format allows platforms to use an efficient RGB/BGR/RGBX/BGRX
@@ -428,7 +428,7 @@
      */
     FLEX_RGB_888 = 0x29,
 
-    /*
+    /**
      * Android flexible RGBA 8888 formats
      *
      * This format allows platforms to use an efficient RGBA/BGRA/ARGB/ABGR
@@ -442,7 +442,7 @@
      */
     FLEX_RGBA_8888 = 0x2A,
 
-    /* Legacy formats (deprecated), used by ImageFormat.java */
+    /** Legacy formats (deprecated), used by ImageFormat.java */
     YCBCR_422_SP       = 0x10,  // NV16
     YCRCB_420_SP       = 0x11,  // NV21
     YCBCR_422_I        = 0x14,  // YUY2
@@ -458,18 +458,19 @@
  */
 @export(name="android_transform_t", value_prefix="HAL_TRANSFORM_")
 enum Transform : int32_t {
-    /* flip source image horizontally (around the vertical axis) */
+    /** flip source image horizontally (around the vertical axis) */
     FLIP_H    = 0x01,
-    /* flip source image vertically (around the horizontal axis)*/
+    /**
+     * flip source image vertically (around the horizontal axis)*/
     FLIP_V    = 0x02,
-    /* rotate source image 90 degrees clockwise */
+    /** rotate source image 90 degrees clockwise */
     ROT_90    = 0x04,
-    /* rotate source image 180 degrees */
+    /** rotate source image 180 degrees */
     ROT_180   = 0x03,
-    /* rotate source image 270 degrees clockwise */
+    /** rotate source image 270 degrees clockwise */
     ROT_270   = 0x07,
 
-    /* 0x08 is reserved */
+    /** 0x08 is reserved */
 };
 
 /**
@@ -517,7 +518,7 @@
  */
 @export(name="android_dataspace_t", value_prefix="HAL_DATASPACE_")
 enum Dataspace : int32_t {
-    /*
+    /**
      * Default-assumption data space, when not explicitly specified.
      *
      * It is safest to assume the buffer is an image with sRGB primaries and
@@ -528,7 +529,7 @@
      */
     UNKNOWN = 0x0,
 
-    /*
+    /**
      * Arbitrary dataspace with manually defined characteristics.  Definition
      * for colorspaces or other meaning must be communicated separately.
      *
@@ -541,7 +542,7 @@
      */
     ARBITRARY = 0x1,
 
-    /*
+    /**
      * Color-description aspects
      *
      * The following aspects define various characteristics of the color
@@ -551,7 +552,7 @@
 
     STANDARD_SHIFT = 16,
 
-    /*
+    /**
      * Standard aspect
      *
      * Defines the chromaticity coordinates of the source primaries in terms of
@@ -559,7 +560,7 @@
      */
     STANDARD_MASK = 63 << STANDARD_SHIFT,  // 0x3F
 
-    /*
+    /**
      * Chromacity coordinates are unknown or are determined by the application.
      * Implementations shall use the following suggested standards:
      *
@@ -574,7 +575,7 @@
      */
     STANDARD_UNSPECIFIED = 0 << STANDARD_SHIFT,
 
-    /*
+    /**
      * Primaries:       x       y
      *  green           0.300   0.600
      *  blue            0.150   0.060
@@ -586,7 +587,7 @@
      */
     STANDARD_BT709 = 1 << STANDARD_SHIFT,
 
-    /*
+    /**
      * Primaries:       x       y
      *  green           0.290   0.600
      *  blue            0.150   0.060
@@ -600,7 +601,7 @@
      */
     STANDARD_BT601_625 = 2 << STANDARD_SHIFT,
 
-    /*
+    /**
      * Primaries:       x       y
      *  green           0.290   0.600
      *  blue            0.150   0.060
@@ -612,7 +613,7 @@
      */
     STANDARD_BT601_625_UNADJUSTED = 3 << STANDARD_SHIFT,
 
-    /*
+    /**
      * Primaries:       x       y
      *  green           0.310   0.595
      *  blue            0.155   0.070
@@ -626,7 +627,7 @@
      */
     STANDARD_BT601_525 = 4 << STANDARD_SHIFT,
 
-    /*
+    /**
      * Primaries:       x       y
      *  green           0.310   0.595
      *  blue            0.155   0.070
@@ -638,7 +639,7 @@
      */
     STANDARD_BT601_525_UNADJUSTED = 5 << STANDARD_SHIFT,
 
-    /*
+    /**
      * Primaries:       x       y
      *  green           0.170   0.797
      *  blue            0.131   0.046
@@ -650,7 +651,7 @@
      */
     STANDARD_BT2020 = 6 << STANDARD_SHIFT,
 
-    /*
+    /**
      * Primaries:       x       y
      *  green           0.170   0.797
      *  blue            0.131   0.046
@@ -662,7 +663,7 @@
      */
     STANDARD_BT2020_CONSTANT_LUMINANCE = 7 << STANDARD_SHIFT,
 
-    /*
+    /**
      * Primaries:       x      y
      *  green           0.21   0.71
      *  blue            0.14   0.08
@@ -674,7 +675,7 @@
      */
     STANDARD_BT470M = 8 << STANDARD_SHIFT,
 
-    /*
+    /**
      * Primaries:       x       y
      *  green           0.243   0.692
      *  blue            0.145   0.049
@@ -686,7 +687,7 @@
      */
     STANDARD_FILM = 9 << STANDARD_SHIFT,
 
-    /*
+    /**
      * SMPTE EG 432-1 and SMPTE RP 431-2. (DCI-P3)
      * Primaries:       x       y
      *  green           0.265   0.690
@@ -696,7 +697,7 @@
      */
     STANDARD_DCI_P3 = 10 << STANDARD_SHIFT,
 
-    /*
+    /**
      * Adobe RGB
      * Primaries:       x       y
      *  green           0.210   0.710
@@ -710,7 +711,7 @@
 
     TRANSFER_SHIFT = 22,
 
-    /*
+    /**
      * Transfer aspect
      *
      * Transfer characteristics are the opto-electronic transfer characteristic
@@ -726,7 +727,7 @@
 
     TRANSFER_MASK = 31 << TRANSFER_SHIFT,  // 0x1F
 
-    /*
+    /**
      * Transfer characteristics are unknown or are determined by the
      * application.
      *
@@ -740,7 +741,7 @@
      */
     TRANSFER_UNSPECIFIED = 0 << TRANSFER_SHIFT,
 
-    /*
+    /**
      * Transfer characteristic curve:
      *  E = L
      *      L - luminance of image 0 <= L <= 1 for conventional colorimetry
@@ -748,7 +749,7 @@
      */
     TRANSFER_LINEAR = 1 << TRANSFER_SHIFT,
 
-    /*
+    /**
      * Transfer characteristic curve:
      *
      * E = 1.055 * L^(1/2.4) - 0.055  for 0.0031308 <= L <= 1
@@ -758,7 +759,7 @@
      */
     TRANSFER_SRGB = 2 << TRANSFER_SHIFT,
 
-    /*
+    /**
      * BT.601 525, BT.601 625, BT.709, BT.2020
      *
      * Transfer characteristic curve:
@@ -769,7 +770,7 @@
      */
     TRANSFER_SMPTE_170M = 3 << TRANSFER_SHIFT,
 
-    /*
+    /**
      * Assumed display gamma 2.2.
      *
      * Transfer characteristic curve:
@@ -779,7 +780,7 @@
      */
     TRANSFER_GAMMA2_2 = 4 << TRANSFER_SHIFT,
 
-    /*
+    /**
      *  display gamma 2.6.
      *
      * Transfer characteristic curve:
@@ -789,7 +790,7 @@
      */
     TRANSFER_GAMMA2_6 = 5 << TRANSFER_SHIFT,
 
-    /*
+    /**
      *  display gamma 2.8.
      *
      * Transfer characteristic curve:
@@ -799,7 +800,7 @@
      */
     TRANSFER_GAMMA2_8 = 6 << TRANSFER_SHIFT,
 
-    /*
+    /**
      * SMPTE ST 2084 (Dolby Perceptual Quantizer)
      *
      * Transfer characteristic curve:
@@ -815,7 +816,7 @@
      */
     TRANSFER_ST2084 = 7 << TRANSFER_SHIFT,
 
-    /*
+    /**
      * ARIB STD-B67 Hybrid Log Gamma
      *
      * Transfer characteristic curve:
@@ -833,7 +834,7 @@
 
     RANGE_SHIFT = 27,
 
-    /*
+    /**
      * Range aspect
      *
      * Defines the range of values corresponding to the unit range of 0-1.
@@ -841,7 +842,7 @@
      */
     RANGE_MASK = 7 << RANGE_SHIFT,  // 0x7
 
-    /*
+    /**
      * Range is unknown or are determined by the application.  Implementations
      * shall use the following suggested ranges:
      *
@@ -854,13 +855,13 @@
      */
     RANGE_UNSPECIFIED = 0 << RANGE_SHIFT,
 
-    /*
+    /**
      * Full range uses all values for Y, Cb and Cr from
      * 0 to 2^b-1, where b is the bit depth of the color format.
      */
     RANGE_FULL = 1 << RANGE_SHIFT,
 
-    /*
+    /**
      * Limited range uses values 16/256*2^b to 235/256*2^b for Y, and
      * 1/16*2^b to 15/16*2^b for Cb, Cr, R, G and B, where b is the bit depth of
      * the color format.
@@ -875,7 +876,7 @@
      */
     RANGE_LIMITED = 2 << RANGE_SHIFT,
 
-    /*
+    /**
      * Extended range is used for scRGB. Intended for use with
      * floating point pixel formats. [0.0 - 1.0] is the standard
      * sRGB space. Values outside the range 0.0 - 1.0 can encode
@@ -884,11 +885,11 @@
      */
     RANGE_EXTENDED = 3 << RANGE_SHIFT,
 
-    /*
+    /**
      * Legacy dataspaces
      */
 
-    /*
+    /**
      * sRGB linear encoding:
      *
      * The red, green, and blue components are stored in sRGB space, but
@@ -903,7 +904,7 @@
     V0_SRGB_LINEAR = STANDARD_BT709 | TRANSFER_LINEAR | RANGE_FULL,
 
 
-    /*
+    /**
      * scRGB linear encoding:
      *
      * The red, green, and blue components are stored in extended sRGB space,
@@ -918,7 +919,7 @@
     V0_SCRGB_LINEAR = STANDARD_BT709 | TRANSFER_LINEAR | RANGE_EXTENDED,
 
 
-    /*
+    /**
      * sRGB gamma encoding:
      *
      * The red, green and blue components are stored in sRGB space, and
@@ -936,7 +937,7 @@
     V0_SRGB = STANDARD_BT709 | TRANSFER_SRGB | RANGE_FULL,
 
 
-    /*
+    /**
      * scRGB:
      *
      * The red, green, and blue components are stored in extended sRGB space,
@@ -950,7 +951,7 @@
      */
     V0_SCRGB = STANDARD_BT709 | TRANSFER_SRGB | RANGE_EXTENDED,
 
-    /*
+    /**
      * YCbCr Colorspaces
      * -----------------
      *
@@ -961,7 +962,7 @@
      * at the source as a function of linear optical intensity (luminance).
      */
 
-    /*
+    /**
      * JPEG File Interchange Format (JFIF)
      *
      * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255
@@ -972,7 +973,7 @@
 
     V0_JFIF = STANDARD_BT601_625 | TRANSFER_SMPTE_170M | RANGE_FULL,
 
-    /*
+    /**
      * ITU-R Recommendation 601 (BT.601) - 625-line
      *
      * Standard-definition television, 625 Lines (PAL)
@@ -984,7 +985,7 @@
     V0_BT601_625 = STANDARD_BT601_625 | TRANSFER_SMPTE_170M | RANGE_LIMITED,
 
 
-    /*
+    /**
      * ITU-R Recommendation 601 (BT.601) - 525-line
      *
      * Standard-definition television, 525 Lines (NTSC)
@@ -995,7 +996,7 @@
 
     V0_BT601_525 = STANDARD_BT601_525 | TRANSFER_SMPTE_170M | RANGE_LIMITED,
 
-    /*
+    /**
      * ITU-R Recommendation 709 (BT.709)
      *
      * High-definition television
@@ -1007,7 +1008,7 @@
     V0_BT709 = STANDARD_BT709 | TRANSFER_SMPTE_170M | RANGE_LIMITED,
 
 
-    /*
+    /**
      * SMPTE EG 432-1 and SMPTE RP 431-2.
      *
      * Digital Cinema DCI-P3
@@ -1017,7 +1018,7 @@
     DCI_P3_LINEAR = STANDARD_DCI_P3 | TRANSFER_LINEAR | RANGE_FULL,
 
 
-    /*
+    /**
      * SMPTE EG 432-1 and SMPTE RP 431-2.
      *
      * Digital Cinema DCI-P3
@@ -1029,7 +1030,7 @@
     DCI_P3 = STANDARD_DCI_P3 | TRANSFER_GAMMA2_6 | RANGE_FULL,
 
 
-    /*
+    /**
      * Display P3
      *
      * Display P3 uses same primaries and white-point as DCI-P3
@@ -1038,7 +1039,7 @@
     DISPLAY_P3_LINEAR = STANDARD_DCI_P3 | TRANSFER_LINEAR | RANGE_FULL,
 
 
-    /*
+    /**
      * Display P3
      *
      * Use same primaries and white-point as DCI-P3
@@ -1047,7 +1048,7 @@
     DISPLAY_P3 = STANDARD_DCI_P3 | TRANSFER_SRGB | RANGE_FULL,
 
 
-    /*
+    /**
      * Adobe RGB
      *
      * Use full range, gamma 2.2 transfer and Adobe RGB primaries
@@ -1057,7 +1058,7 @@
     ADOBE_RGB = STANDARD_ADOBE_RGB | TRANSFER_GAMMA2_2 | RANGE_FULL,
 
 
-    /*
+    /**
      * ITU-R Recommendation 2020 (BT.2020)
      *
      * Ultra High-definition television
@@ -1067,7 +1068,7 @@
     BT2020_LINEAR = STANDARD_BT2020 | TRANSFER_LINEAR | RANGE_FULL,
 
 
-    /*
+    /**
      * ITU-R Recommendation 2020 (BT.2020)
      *
      * Ultra High-definition television
@@ -1076,7 +1077,7 @@
      */
     BT2020 = STANDARD_BT2020 | TRANSFER_SMPTE_170M | RANGE_FULL,
 
-    /*
+    /**
      * ITU-R Recommendation 2020 (BT.2020)
      *
      * Ultra High-definition television
@@ -1086,11 +1087,11 @@
     BT2020_PQ = STANDARD_BT2020 | TRANSFER_ST2084 | RANGE_FULL,
 
 
-    /*
+    /**
      * Data spaces for non-color formats
      */
 
-    /*
+    /**
      * The buffer contains depth ranging measurements from a depth camera.
      * This value is valid with formats:
      *    HAL_PIXEL_FORMAT_Y16: 16-bit samples, consisting of a depth measurement
@@ -1111,7 +1112,7 @@
     DEPTH = 0x1000,
 
 
-    /*
+    /**
      * The buffer contains sensor events from sensor direct report.
      * This value is valid with formats:
      *    HAL_PIXEL_FORMAT_BLOB: an array of sensor event structure that forms
@@ -1121,7 +1122,7 @@
     SENSOR = 0x1001
 };
 
-/*
+/**
  * Color modes that may be supported by a display.
  *
  * Definitions:
@@ -1167,7 +1168,7 @@
  */
 @export(name="android_color_mode_t", value_prefix="HAL_COLOR_MODE_")
 enum ColorMode : int32_t {
-  /*
+  /**
    * DEFAULT is the "native" gamut of the display.
    * White Point: Vendor/OEM defined
    * Panel Gamma: Vendor/OEM defined (typically 2.2)
@@ -1175,7 +1176,7 @@
    */
   NATIVE = 0,
 
-  /*
+  /**
    * STANDARD_BT601_625 corresponds with display
    * settings that implement the ITU-R Recommendation BT.601
    * or Rec 601. Using 625 line version
@@ -1201,7 +1202,7 @@
    */
   STANDARD_BT601_625 = 1,
 
-  /*
+  /**
    * Primaries:
    *                  x       y
    *  green           0.290   0.600
@@ -1221,7 +1222,7 @@
    */
   STANDARD_BT601_625_UNADJUSTED = 2,
 
-  /*
+  /**
    * Primaries:
    *                  x       y
    *  green           0.310   0.595
@@ -1243,7 +1244,7 @@
    */
   STANDARD_BT601_525 = 3,
 
-  /*
+  /**
    * Primaries:
    *                  x       y
    *  green           0.310   0.595
@@ -1263,7 +1264,7 @@
    */
   STANDARD_BT601_525_UNADJUSTED = 4,
 
-  /*
+  /**
    * REC709 corresponds with display settings that implement
    * the ITU-R Recommendation BT.709 / Rec. 709 for high-definition television.
    * Rendering Intent: Colorimetric
@@ -1291,7 +1292,7 @@
    */
   STANDARD_BT709 = 5,
 
-  /*
+  /**
    * DCI_P3 corresponds with display settings that implement
    * SMPTE EG 432-1 and SMPTE RP 431-2
    * Rendering Intent: Colorimetric
@@ -1306,7 +1307,7 @@
    */
   DCI_P3 = 6,
 
-  /*
+  /**
    * SRGB corresponds with display settings that implement
    * the sRGB color space. Uses the same primaries as ITU-R Recommendation
    * BT.709
@@ -1334,7 +1335,7 @@
    */
   SRGB = 7,
 
-  /*
+  /**
    * ADOBE_RGB corresponds with the RGB color space developed
    * by Adobe Systems, Inc. in 1998.
    * Rendering Intent: Colorimetric
@@ -1349,7 +1350,7 @@
    */
   ADOBE_RGB = 8,
 
-  /*
+  /**
    * DISPLAY_P3 is a color space that uses the DCI_P3 primaries,
    * the D65 white point and the SRGB transfer functions.
    * Rendering Intent: Colorimetric
@@ -1372,46 +1373,47 @@
   DISPLAY_P3 = 9
 };
 
-/*
+/**
  * Color transforms that may be applied by hardware composer to the whole
  * display.
  */
 @export(name="android_color_transform_t", value_prefix="HAL_COLOR_TRANSFORM_")
 enum ColorTransform : int32_t {
-    /* Applies no transform to the output color */
+    /** Applies no transform to the output color */
     IDENTITY = 0,
 
-    /* Applies an arbitrary transform defined by a 4x4 affine matrix */
+    /** Applies an arbitrary transform defined by a 4x4 affine matrix */
     ARBITRARY_MATRIX = 1,
 
-    /* Applies a transform that inverts the value or luminance of the color, but
+    /**
+     * Applies a transform that inverts the value or luminance of the color, but
      * does not modify hue or saturation */
     VALUE_INVERSE = 2,
 
-    /* Applies a transform that maps all colors to shades of gray */
+    /** Applies a transform that maps all colors to shades of gray */
     GRAYSCALE = 3,
 
-    /* Applies a transform which corrects for protanopic color blindness */
+    /** Applies a transform which corrects for protanopic color blindness */
     CORRECT_PROTANOPIA = 4,
 
-    /* Applies a transform which corrects for deuteranopic color blindness */
+    /** Applies a transform which corrects for deuteranopic color blindness */
     CORRECT_DEUTERANOPIA = 5,
 
-    /* Applies a transform which corrects for tritanopic color blindness */
+    /** Applies a transform which corrects for tritanopic color blindness */
     CORRECT_TRITANOPIA = 6
 };
 
-/*
+/**
  * Supported HDR formats. Must be kept in sync with equivalents in Display.java.
  */
 @export(name="android_hdr_t", value_prefix="HAL_HDR_")
 enum Hdr : int32_t {
-    /* Device supports Dolby Vision HDR */
+    /** Device supports Dolby Vision HDR */
     DOLBY_VISION = 1,
 
-    /* Device supports HDR10 */
+    /** Device supports HDR10 */
     HDR10 = 2,
 
-    /* Device supports hybrid log-gamma HDR */
+    /** Device supports hybrid log-gamma HDR */
     HLG = 3
 };
diff --git a/graphics/composer/2.1/IComposer.hal b/graphics/composer/2.1/IComposer.hal
index 553a537..b3ac761 100644
--- a/graphics/composer/2.1/IComposer.hal
+++ b/graphics/composer/2.1/IComposer.hal
@@ -19,7 +19,7 @@
 import IComposerClient;
 
 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.
@@ -27,7 +27,7 @@
     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
@@ -37,7 +37,7 @@
          */
         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
@@ -46,7 +46,7 @@
         SKIP_CLIENT_COLOR_TRANSFORM = 2,
     };
 
-    /*
+    /**
      * Provides a list of supported capabilities (as described in the
      * definition of Capability above). This list must not change after
      * initialization.
@@ -58,7 +58,7 @@
     @callflow(next="*")
     getCapabilities() generates (vec<Capability> capabilities);
 
-    /*
+    /**
      * Retrieves implementation-defined debug information, which will be
      * displayed during, for example, `dumpsys SurfaceFlinger`.
      *
@@ -69,7 +69,7 @@
     @callflow(next="*")
     dumpDebugInfo() generates (string debugInfo);
 
-    /*
+    /**
      * Creates a client of the composer. All resources created by the client
      * are owned by the client and are only visible to the client.
      *
diff --git a/graphics/composer/2.1/IComposerCallback.hal b/graphics/composer/2.1/IComposerCallback.hal
index 541d7eb..ab74c30 100644
--- a/graphics/composer/2.1/IComposerCallback.hal
+++ b/graphics/composer/2.1/IComposerCallback.hal
@@ -20,13 +20,13 @@
     enum Connection : int32_t {
         INVALID = 0,
 
-        /* The display has been connected */
+        /** The display has been connected */
         CONNECTED = 1,
-        /* The display has been disconnected */
+        /** 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
@@ -47,7 +47,7 @@
     @callflow(next="*")
     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.
@@ -61,7 +61,7 @@
     @callflow(next="*")
     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).
diff --git a/graphics/composer/2.1/IComposerClient.hal b/graphics/composer/2.1/IComposerClient.hal
index 107ac5e..85572d4 100644
--- a/graphics/composer/2.1/IComposerClient.hal
+++ b/graphics/composer/2.1/IComposerClient.hal
@@ -20,18 +20,18 @@
 import IComposerCallback;
 
 interface IComposerClient {
-    /* Display attributes queryable through getDisplayAttribute. */
+    /** Display attributes queryable through getDisplayAttribute. */
     enum Attribute : int32_t {
         INVALID = 0,
 
-        /* Dimensions in pixels */
+        /** Dimensions in pixels */
         WIDTH = 1,
         HEIGHT = 2,
 
-        /* Vsync period in nanoseconds */
+        /** 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
@@ -41,15 +41,15 @@
         DPI_Y = 5,
     };
 
-    /* Display requests returned by getDisplayRequests. */
+    /** 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
@@ -58,9 +58,9 @@
         WRITE_CLIENT_TARGET_TO_OUTPUT = 1 << 1,
     };
 
-    /* Layer requests returned from getDisplayRequests. */
+    /** Layer requests returned from getDisplayRequests. */
     enum LayerRequest : uint32_t {
-        /*
+        /**
          * The client must clear its target with transparent pixels where
          * this layer would be. The client may ignore this request if the
          * layer must be blended.
@@ -68,24 +68,24 @@
         CLEAR_CLIENT_TARGET = 1 << 0,
     };
 
-    /* Power modes for use with setPowerMode. */
+    /** Power modes for use with setPowerMode. */
     enum PowerMode : int32_t {
-        /* The display is fully off (blanked). */
+        /** 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
@@ -100,40 +100,40 @@
          */
         DOZE_SUSPEND = 3,
 
-        /* The display is fully on. */
+        /** The display is fully on. */
         ON = 2,
     };
 
-    /* Vsync values passed to setVsyncEnabled. */
+    /** Vsync values passed to setVsyncEnabled. */
     enum Vsync : int32_t {
         INVALID = 0,
 
-        /* Enable vsync. */
+        /** Enable vsync. */
         ENABLE = 1,
 
-        /* Disable vsync. */
+        /** Disable vsync. */
         DISABLE = 2,
     };
 
-    /* Blend modes, settable per layer. */
+    /** Blend modes, settable per layer. */
     enum BlendMode : int32_t {
         INVALID = 0,
 
-        /* colorOut = colorSrc */
+        /** colorOut = colorSrc */
         NONE = 1,
 
-        /* colorOut = colorSrc + colorDst * (1 - alphaSrc) */
+        /** colorOut = colorSrc + colorDst * (1 - alphaSrc) */
         PREMULTIPLIED = 2,
 
-        /* colorOut = colorSrc * alphaSrc + colorDst * (1 - alphaSrc) */
+        /** colorOut = colorSrc * alphaSrc + colorDst * (1 - alphaSrc) */
         COVERAGE = 3,
     };
 
-    /* Possible composition types for a given layer. */
+    /** Possible composition types for a given layer. */
     enum Composition : int32_t {
         INVALID = 0,
 
-        /*
+        /**
          * The client must composite this layer into the client target buffer
          * (provided to the device through setClientTarget).
          *
@@ -142,7 +142,7 @@
          */
         CLIENT = 1,
 
-        /*
+        /**
          * The device must handle the composition of this layer through a
          * hardware overlay or other similar means.
          *
@@ -151,7 +151,7 @@
          */
         DEVICE = 2,
 
-        /*
+        /**
          * The device must 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
@@ -163,7 +163,7 @@
          */
         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
@@ -177,7 +177,7 @@
          */
         CURSOR = 4,
 
-        /*
+        /**
          * The device must handle the composition of this layer, as well as
          * its buffer updates and content synchronization. Only supported on
          * devices which provide Capability::SIDEBAND_STREAM.
@@ -189,26 +189,26 @@
         SIDEBAND = 5,
     };
 
-    /* Display types returned by getDisplayType. */
+    /** 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 displays created by createVirtualDisplay. */
         VIRTUAL = 2,
     };
 
-    /* Special index values (always negative) for command queue commands. */
+    /** Special index values (always negative) for command queue commands. */
     enum HandleIndex : int32_t {
-        /* No handle */
+        /** No handle */
         EMPTY = -1,
 
-        /* Use cached handle */
+        /** Use cached handle */
         CACHED = -2,
     };
 
@@ -233,7 +233,7 @@
         uint8_t a;
     };
 
-    /*
+    /**
      * Provides a IComposerCallback object for the device to call.
      *
      * This function must be called only once.
@@ -244,7 +244,7 @@
     @callflow(next="*")
     registerCallback(IComposerCallback callback);
 
-    /*
+    /**
      * Returns the maximum number of virtual displays supported by this device
      * (which may be 0). The client must not attempt to create more than this
      * many virtual displays on this device. This number must not change for
@@ -255,7 +255,7 @@
     @callflow(next="*")
     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.
@@ -286,7 +286,7 @@
                          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 must fail.
@@ -300,7 +300,7 @@
     @callflow(next="*")
     destroyVirtualDisplay(Display display) generates (Error error);
 
-    /*
+    /**
      * Creates a new layer on the given display.
      *
      * @param display is the display on which to create the layer.
@@ -317,7 +317,7 @@
      generates (Error error,
                 Layer layer);
 
-    /*
+    /**
      * Destroys the given layer.
      *
      * @param display is the display on which the layer was created.
@@ -329,7 +329,7 @@
     @callflow(next="*")
     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
@@ -346,7 +346,7 @@
     @callflow(next="*")
     getActiveConfig(Display display) generates (Error error, Config config);
 
-    /*
+    /**
      * Returns whether a client target with the given properties can be
      * handled by the device.
      *
@@ -373,7 +373,7 @@
                            Dataspace dataspace)
                 generates (Error error);
 
-    /*
+    /**
      * Returns the color modes supported on this display.
      *
      * All devices must support at least ColorMode::NATIVE.
@@ -388,7 +388,7 @@
        generates (Error error,
                   vec<ColorMode> modes);
 
-    /*
+    /**
      * Returns a display attribute value for a particular display
      * configuration.
      *
@@ -410,7 +410,7 @@
              generates (Error error,
                         int32_t value);
 
-    /*
+    /**
      * Returns handles for all of the valid display configurations on this
      * display.
      *
@@ -424,7 +424,7 @@
            generates (Error error,
                       vec<Config> configs);
 
-    /*
+    /**
      * Returns a human-readable version of the display's name.
      *
      * @return error is NONE upon success. Otherwise,
@@ -434,7 +434,7 @@
     @callflow(next="*")
     getDisplayName(Display display) generates (Error error, string name);
 
-    /*
+    /**
      * Returns whether the given display is a physical or virtual display.
      *
      * @param display is the display to query.
@@ -445,7 +445,7 @@
     @callflow(next="*")
     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
@@ -460,7 +460,7 @@
     @callflow(next="*")
     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.
      *
@@ -486,7 +486,7 @@
                        float maxAverageLuminance,
                        float minLuminance);
 
-    /*
+    /**
      * Set the number of client target slots to be reserved.
      *
      * @param display is the display to which the slots are reserved.
@@ -500,7 +500,7 @@
                              uint32_t clientTargetSlotCount)
                   generates (Error error);
 
-    /*
+    /**
      * Sets the active configuration for this display. Upon returning, the
      * given display configuration must be active and remain so until either
      * this function is called again or the display is disconnected.
@@ -515,7 +515,7 @@
     @callflow(next="*")
     setActiveConfig(Display display, Config config) generates (Error error);
 
-    /*
+    /**
      * Sets the color mode of the given display.
      *
      * Upon returning from this function, the color mode change must have
@@ -534,7 +534,7 @@
     @callflow(next="*")
     setColorMode(Display display, ColorMode mode) 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.
@@ -553,7 +553,7 @@
     @callflow(next="*")
     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
@@ -568,7 +568,7 @@
     @callflow(next="*")
     setVsyncEnabled(Display display, Vsync enabled) generates (Error error);
 
-    /*
+    /**
      * Sets the input command message queue.
      *
      * @param descriptor is the descriptor of the input command message queue.
@@ -579,7 +579,7 @@
     setInputCommandQueue(fmq_sync<uint32_t> descriptor)
               generates (Error error);
 
-    /*
+    /**
      * Gets the output command message queue.
      *
      * This function must only be called inside executeCommands closure.
@@ -593,7 +593,7 @@
               generates (Error error,
                          fmq_sync<uint32_t> descriptor);
 
-    /*
+    /**
      * Executes commands from the input command message queue. Return values
      * generated by the input commands are written to the output command
      * message queue in the form of value commands.
@@ -620,7 +620,7 @@
                     uint32_t outLength,
                     vec<handle> outHandles);
 
-    /*
+    /**
      * SELECT_DISPLAY has this pseudo prototype
      *
      *   selectDisplay(Display display);
@@ -1099,18 +1099,18 @@
         OPCODE_SHIFT                       = 16,
         OPCODE_MASK                        = 0xffff << OPCODE_SHIFT,
 
-        /* special commands */
+        /** special commands */
         SELECT_DISPLAY                     = 0x000 << OPCODE_SHIFT,
         SELECT_LAYER                       = 0x001 << OPCODE_SHIFT,
 
-        /* value commands (for return values) */
+        /** value commands (for return values) */
         SET_ERROR                          = 0x100 << OPCODE_SHIFT,
         SET_CHANGED_COMPOSITION_TYPES      = 0x101 << OPCODE_SHIFT,
         SET_DISPLAY_REQUESTS               = 0x102 << OPCODE_SHIFT,
         SET_PRESENT_FENCE                  = 0x103 << OPCODE_SHIFT,
         SET_RELEASE_FENCES                 = 0x104 << OPCODE_SHIFT,
 
-        /* display commands */
+        /** display commands */
         SET_COLOR_TRANSFORM                = 0x200 << OPCODE_SHIFT,
         SET_CLIENT_TARGET                  = 0x201 << OPCODE_SHIFT,
         SET_OUTPUT_BUFFER                  = 0x202 << OPCODE_SHIFT,
@@ -1118,12 +1118,12 @@
         ACCEPT_DISPLAY_CHANGES             = 0x204 << OPCODE_SHIFT,
         PRESENT_DISPLAY                    = 0x205 << OPCODE_SHIFT,
 
-        /* layer commands (VALIDATE_DISPLAY not required) */
+        /** layer commands (VALIDATE_DISPLAY not required) */
         SET_LAYER_CURSOR_POSITION          = 0x300 << OPCODE_SHIFT,
         SET_LAYER_BUFFER                   = 0x301 << OPCODE_SHIFT,
         SET_LAYER_SURFACE_DAMAGE           = 0x302 << OPCODE_SHIFT,
 
-        /* layer state commands (VALIDATE_DISPLAY required) */
+        /** layer state commands (VALIDATE_DISPLAY required) */
         SET_LAYER_BLEND_MODE               = 0x400 << OPCODE_SHIFT,
         SET_LAYER_COLOR                    = 0x401 << OPCODE_SHIFT,
         SET_LAYER_COMPOSITION_TYPE         = 0x402 << OPCODE_SHIFT,
@@ -1136,7 +1136,7 @@
         SET_LAYER_VISIBLE_REGION           = 0x409 << OPCODE_SHIFT,
         SET_LAYER_Z_ORDER                  = 0x40a << OPCODE_SHIFT,
 
-        /* 0x800 - 0xfff are reserved for vendor extensions */
-        /* 0x1000 - 0xffff are reserved */
+        /** 0x800 - 0xfff are reserved for vendor extensions */
+        /** 0x1000 - 0xffff are reserved */
     };
 };
diff --git a/graphics/composer/2.1/types.hal b/graphics/composer/2.1/types.hal
index e54031e..9f0dd8b 100644
--- a/graphics/composer/2.1/types.hal
+++ b/graphics/composer/2.1/types.hal
@@ -16,17 +16,17 @@
 
 package android.hardware.graphics.composer@2.1;
 
-/* Return codes from all functions. */
+/** 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. */
-    /* 5 is reserved */
-    NO_RESOURCES    = 6, /* temporary failure due to resource contention */
-    NOT_VALIDATED   = 7, /* validateDisplay has not been called */
-    UNSUPPORTED     = 8, /* permanent failure */
+    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. */
+    /** 5 is reserved */
+    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;
diff --git a/graphics/mapper/2.0/IMapper.hal b/graphics/mapper/2.0/IMapper.hal
index 21a6dfa..573dcd0 100644
--- a/graphics/mapper/2.0/IMapper.hal
+++ b/graphics/mapper/2.0/IMapper.hal
@@ -27,7 +27,7 @@
         int32_t height;
     };
 
-    /*
+    /**
      * Adds a reference to the given buffer handle.
      *
      * A buffer handle received from a remote process or exported by
@@ -49,7 +49,7 @@
     @callflow(next="*")
     retain(handle bufferHandle) generates (Error error);
 
-    /*
+    /**
      * Removes a reference from the given buffer buffer.
      *
      * If no references remain, the buffer handle must be freed with
@@ -65,7 +65,7 @@
     @exit
     release(handle bufferHandle) generates (Error error);
 
-    /*
+    /**
      * Gets the width and height of the buffer in pixels.
      *
      * See IAllocator::BufferDescriptorInfo for more information.
@@ -82,7 +82,7 @@
                   uint32_t width,
                   uint32_t height);
 
-    /*
+    /**
      * Gets the format of the buffer.
      *
      * See IAllocator::BufferDescriptorInfo for more information.
@@ -97,7 +97,7 @@
         generates (Error error,
                    PixelFormat format);
 
-    /*
+    /**
      * Gets the number of layers of the buffer.
      *
      * See IAllocator::BufferDescriptorInfo for more information.
@@ -112,7 +112,7 @@
        generates (Error error,
                   uint32_t layerCount);
 
-    /*
+    /**
      * Gets the producer usage flags which were used to allocate this buffer.
      *
      * See IAllocator::BufferDescriptorInfo for more information.
@@ -128,7 +128,7 @@
               generates (Error error,
                          uint64_t usageMask);
 
-    /*
+    /**
      * Gets the consumer usage flags which were used to allocate this buffer.
      *
      * See IAllocator::BufferDescriptorInfo for more information.
@@ -144,7 +144,7 @@
               generates (Error error,
                          uint64_t usageMask);
 
-    /*
+    /**
      * Gets a value that uniquely identifies the backing store of the given
      * buffer.
      *
@@ -165,7 +165,7 @@
          generates (Error error,
                     BackingStore store);
 
-    /*
+    /**
      * Gets the stride of the buffer in pixels.
      *
      * The stride is the offset in pixel-sized elements between the same
@@ -185,7 +185,7 @@
         generates (Error error,
                    uint32_t stride);
 
-    /*
+    /**
      * Locks the given buffer for the specified CPU usage.
      *
      * Exactly one of producerUsageMask and consumerUsageMask must be 0. The
@@ -247,7 +247,7 @@
         generates (Error error,
                    pointer data);
 
-    /*
+    /**
      * This is largely the same as lock(), except that instead of returning a
      * pointer directly to the buffer data, it returns an FlexLayout struct
      * describing how to access the data planes.
@@ -296,7 +296,7 @@
         generates (Error error,
                    FlexLayout layout);
 
-    /*
+    /**
      * This function indicates to the device that the client will be done with
      * the buffer when releaseFence signals.
      *
diff --git a/graphics/mapper/2.0/types.hal b/graphics/mapper/2.0/types.hal
index aa33141..2946e85 100644
--- a/graphics/mapper/2.0/types.hal
+++ b/graphics/mapper/2.0/types.hal
@@ -16,7 +16,7 @@
 
 package android.hardware.graphics.mapper@2.0;
 
-/*
+/**
  * Structures for describing flexible YUVA/RGBA formats for consumption by
  * applications. Such flexible formats contain a plane for each component (e.g.
  * red, green, blue), where each plane is laid out in a grid-like pattern
@@ -49,19 +49,19 @@
  */
 
 enum FlexComponent : int32_t {
-    Y  = 1 << 0, /* luma */
-    CB = 1 << 1, /* chroma blue */
-    CR = 1 << 2, /* chroma red */
+    Y  = 1 << 0, /** luma */
+    CB = 1 << 1, /** chroma blue */
+    CR = 1 << 2, /** chroma red */
 
-    R  = 1 << 10, /* red */
-    G  = 1 << 11, /* green */
-    B  = 1 << 12, /* blue */
+    R  = 1 << 10, /** red */
+    G  = 1 << 11, /** green */
+    B  = 1 << 12, /** blue */
 
-    A  = 1 << 30, /* alpha */
+    A  = 1 << 30, /** alpha */
 };
 
 enum FlexFormat : int32_t {
-    /* not a flexible format */
+    /** not a flexible format */
     INVALID = 0x0,
 
     Y       = FlexComponent:Y,
@@ -73,38 +73,38 @@
 };
 
 struct FlexPlane {
-    /* Pointer to the first byte of the top-left pixel of the plane. */
+    /** Pointer to the first byte of the top-left pixel of the plane. */
     pointer topLeft;
 
     FlexComponent component;
 
-    /*
+    /**
      * Bits allocated for the component in each pixel. Must be a positive
      * multiple of 8.
      */
     int32_t bitsPerComponent;
 
-    /*
+    /**
      * Number of the most significant bits used in the format for this
      * component. Must be between 1 and bitsPerComponent, inclusive.
      */
     int32_t bitsUsed;
 
-    /* Horizontal increment. */
+    /** Horizontal increment. */
     int32_t hIncrement;
-    /* Vertical increment. */
+    /** Vertical increment. */
     int32_t vIncrement;
-    /* Horizontal subsampling. Must be a positive power of 2. */
+    /** Horizontal subsampling. Must be a positive power of 2. */
     int32_t hSubsampling;
-    /* Vertical subsampling. Must be a positive power of 2. */
+    /** Vertical subsampling. Must be a positive power of 2. */
     int32_t vSubsampling;
 };
 
 struct FlexLayout {
-    /* The kind of flexible format. */
+    /** The kind of flexible format. */
     FlexFormat format;
 
-    /*
+    /**
      * A plane for each component; ordered in increasing component value
      * order. E.g. FlexFormat::RGBA maps 0 -> R, 1 -> G, etc.  Can have size 0
      * for FlexFormat::INVALID.
@@ -112,5 +112,5 @@
     vec<FlexPlane> planes;
 };
 
-/* Backing store ID of a buffer. See IMapper::getBackingStore. */
+/** Backing store ID of a buffer. See IMapper::getBackingStore. */
 typedef uint64_t BackingStore;
diff --git a/health/1.0/types.hal b/health/1.0/types.hal
index c5b5cc1..377d1bd 100644
--- a/health/1.0/types.hal
+++ b/health/1.0/types.hal
@@ -16,7 +16,7 @@
 
 package android.hardware.health@1.0;
 
-/*
+/**
  * Possible return values for optional HAL method(s) like
  * IHealth::energyCounter()
  */
@@ -26,7 +26,7 @@
     UNKNOWN,
 };
 
-/*
+/**
  * Possible values for Battery Status.
  * Note: These are currently in sync with BatteryManager and must not
  * be extended / altered.
@@ -36,7 +36,7 @@
     UNKNOWN = 1,
     CHARGING = 2,
     DISCHARGING = 3,
-    /*
+    /**
      * Battery is *not* charging - special case when charger is present
      * but battery isn't charging
      */
@@ -44,7 +44,7 @@
     FULL = 5,
 };
 
-/*
+/**
  * Possible values for Battery Health.
  * Note: These are currently in sync with BatteryManager and must not
  * be extended / altered.
@@ -56,7 +56,7 @@
     OVERHEAT = 3,
     DEAD = 4,
     OVER_VOLTAGE = 5,
-    /*
+    /**
      * Battery experienced an unknown/unspecifid failure.
      */
     UNSPECIFIED_FAILURE = 6,
@@ -65,149 +65,149 @@
 
 struct HealthConfig {
 
-    /*
+    /**
      * periodicChoresIntervalFast is used while the device is not in
      * suspend, or in suspend and connected to a charger (to watch for battery
      * overheat due to charging)
      */
     int32_t periodicChoresIntervalFast;
 
-    /*
+    /**
      * periodicChoresIntervalSlow is used when the device is in suspend and
      * not connected to a charger (to watch for a battery drained to zero
      * remaining capacity).
      */
     int32_t periodicChoresIntervalSlow;
 
-    /*
+    /**
      * power_supply sysfs attribute file paths. Set these to specific paths
      * to use for the associated battery parameters. Clients must search
      * for appropriate power_supply attribute files to use, for any paths
      * left empty after the HAL is initialized.
      */
 
-    /*
+    /**
      * batteryStatusPath - file path to read battery charging status.
      * (POWER_SUPPLY_PROP_STATUS)
      */
     string batteryStatusPath;
 
 
-    /*
+    /**
      * batteryHealthPath - file path to read battery health.
      * (POWER_SUPPLY_PROP_HEALTH)
      */
     string batteryHealthPath;
 
-    /*
+    /**
      * batteryPresentPath - file path to read battery present status.
      * (POWER_SUPPLY_PROP_PRESENT)
      */
     string batteryPresentPath;
 
 
-    /*
+    /**
      * batteryCapacityPath - file path to read remaining battery capacity.
      * (POWER_SUPPLY_PROP_CAPACITY)
      */
     string batteryCapacityPath;
 
-    /*
+    /**
      * batteryVoltagePath - file path to read battery voltage.
      * (POWER_SUPPLY_PROP_VOLTAGE_NOW)
      */
     string batteryVoltagePath;
 
-    /*
+    /**
      * batteryTemperaturePath - file path to read battery temperature in tenths
      * of degree celcius. (POWER_SUPPLY_PROP_TEMP)
      */
     string batteryTemperaturePath;
 
-    /*
+    /**
      * batteryTechnologyPath - file path to read battery technology.
      * (POWER_SUPPLY_PROP_TECHNOLOGY)
      */
     string batteryTechnologyPath;
 
-    /*
+    /**
      * batteryCurrentNowPath - file path to read battery instantaneous current.
      * (POWER_SUPPLY_PROP_CURRENT_NOW)
      */
     string batteryCurrentNowPath;
 
-    /*
+    /**
      * batteryCurrentAvgPath - file path to read battery average current.
      * (POWER_SUPPLY_PROP_CURRENT_AVG)
      */
     string batteryCurrentAvgPath;
 
-    /*
+    /**
      * batteryChargeCounterPath - file path to read battery accumulated charge.
      * (POWER_SUPPLY_PROP_CHARGE_COUNTER)
      */
     string batteryChargeCounterPath;
 
-    /*
+    /**
      * batteryFullChargerPath - file path to read battery charge value when it
      * is considered to be full. (POWER_SUPPLY_PROP_CHARGE_FULL)
      */
     string batteryFullChargePath;
 
-    /*
+    /**
      * batteryCycleCountPath - file path to read battery charge cycle count.
      * (POWER_SUPPLY_PROP_CYCLE_COUNT)
      */
     string batteryCycleCountPath;
 };
 
-/*
+/**
  * The parameter to healthd mainloop update calls
  */
 struct HealthInfo {
-    /* AC charger state - 'true' if online */
+    /** AC charger state - 'true' if online */
     bool chargerAcOnline;
 
-    /* USB charger state - 'true' if online */
+    /** USB charger state - 'true' if online */
     bool chargerUsbOnline;
 
-    /* Wireless charger state - 'true' if online */
+    /** Wireless charger state - 'true' if online */
     bool chargerWirelessOnline;
 
-    /* Maximum charging current supported by charger in uA */
+    /** Maximum charging current supported by charger in uA */
     int32_t maxChargingCurrent;
 
-    /* Maximum charging voltage supported by charger in uV */
+    /** Maximum charging voltage supported by charger in uV */
     int32_t maxChargingVoltage;
 
     BatteryStatus batteryStatus;
 
     BatteryHealth batteryHealth;
 
-    /* 'true' if battery is present */
+    /** 'true' if battery is present */
     bool batteryPresent;
 
-    /* Remaining battery capacity in percent */
+    /** Remaining battery capacity in percent */
     int32_t batteryLevel;
 
-    /* Instantaneous battery voltage in uV */
+    /** Instantaneous battery voltage in uV */
     int32_t batteryVoltage;
 
-    /* Instantaneous battery temperature in tenths of degree celcius */
+    /** Instantaneous battery temperature in tenths of degree celcius */
     int32_t batteryTemperature;
 
-    /* Instantaneous battery current in uA */
+    /** Instantaneous battery current in uA */
     int32_t batteryCurrent;
 
-    /* Battery charge cycle count */
+    /** Battery charge cycle count */
     int32_t batteryCycleCount;
 
-    /* Battery charge value when it is considered to be "full" in uA-h */
+    /** Battery charge value when it is considered to be "full" in uA-h */
     int32_t batteryFullCharge;
 
-    /* Instantaneous battery capacity in uA-h */
+    /** Instantaneous battery capacity in uA-h */
     int32_t batteryChargeCounter;
 
-    /* Battery technology, e.g. "Li-ion, Li-Poly" etc. */
+    /** Battery technology, e.g. "Li-ion, Li-Poly" etc. */
     string batteryTechnology;
 };
diff --git a/keymaster/3.0/default/KeymasterDevice.cpp b/keymaster/3.0/default/KeymasterDevice.cpp
index 720b946..6b4524b 100644
--- a/keymaster/3.0/default/KeymasterDevice.cpp
+++ b/keymaster/3.0/default/KeymasterDevice.cpp
@@ -698,14 +698,21 @@
     return legacy_enum_conversion(keymaster_device_->abort(keymaster_device_, operationHandle));
 }
 
-IKeymasterDevice* HIDL_FETCH_IKeymasterDevice(const char* /* name */) {
+IKeymasterDevice* HIDL_FETCH_IKeymasterDevice(const char* name) {
     keymaster2_device_t* dev = nullptr;
 
-    uint32_t version;
-    bool supports_ec;
-    bool supports_all_digests;
-    auto rc = keymaster_device_initialize(&dev, &version, &supports_ec, &supports_all_digests);
-    if (rc) return nullptr;
+    ALOGI("Fetching keymaster device name %s", name);
+
+    uint32_t version = -1;
+    bool supports_ec = false;
+    bool supports_all_digests = false;
+
+    if (name && strcmp(name, "softwareonly") == 0) {
+        dev = (new SoftKeymasterDevice(new SoftwareOnlyHidlKeymasterContext))->keymaster2_device();
+    } else if (name && strcmp(name, "default") == 0) {
+        auto rc = keymaster_device_initialize(&dev, &version, &supports_ec, &supports_all_digests);
+        if (rc) return nullptr;
+    }
 
     auto kmrc = ::keymaster::ConfigureDevice(dev);
     if (kmrc != KM_ERROR_OK) {
diff --git a/keymaster/3.0/types.hal b/keymaster/3.0/types.hal
index 1f4a0cc..6dad23e 100644
--- a/keymaster/3.0/types.hal
+++ b/keymaster/3.0/types.hal
@@ -17,40 +17,40 @@
 package android.hardware.keymaster@3.0;
 
 enum TagType : uint32_t {
-    INVALID = 0 << 28, /* Invalid type, used to designate a tag as uninitialized */
+    INVALID = 0 << 28, /** Invalid type, used to designate a tag as uninitialized */
     ENUM = 1 << 28,
-    ENUM_REP = 2 << 28, /* Repeatable enumeration value. */
+    ENUM_REP = 2 << 28, /** Repeatable enumeration value. */
     UINT = 3 << 28,
-    UINT_REP = 4 << 28, /* Repeatable integer value */
+    UINT_REP = 4 << 28, /** Repeatable integer value */
     ULONG = 5 << 28,
     DATE = 6 << 28,
     BOOL = 7 << 28,
     BIGNUM = 8 << 28,
     BYTES = 9 << 28,
-    ULONG_REP = 10 << 28, /* Repeatable long value */
+    ULONG_REP = 10 << 28, /** Repeatable long value */
 };
 
 enum Tag : uint32_t {
     INVALID = TagType:INVALID | 0,
 
-    /*
+    /**
      * Tags that must be semantically enforced by hardware and software implementations.
      */
 
-    /* Crypto parameters */
-    PURPOSE = TagType:ENUM_REP | 1,    /* KeyPurpose. */
-    ALGORITHM = TagType:ENUM | 2,      /* Algorithm. */
-    KEY_SIZE = TagType:UINT | 3,       /* Key size in bits. */
-    BLOCK_MODE = TagType:ENUM_REP | 4, /* BlockMode. */
-    DIGEST = TagType:ENUM_REP | 5,     /* Digest. */
-    PADDING = TagType:ENUM_REP | 6,    /* PaddingMode. */
-    CALLER_NONCE = TagType:BOOL | 7,   /* Allow caller to specify nonce or IV. */
+    /** Crypto parameters */
+    PURPOSE = TagType:ENUM_REP | 1,    /** KeyPurpose. */
+    ALGORITHM = TagType:ENUM | 2,      /** Algorithm. */
+    KEY_SIZE = TagType:UINT | 3,       /** Key size in bits. */
+    BLOCK_MODE = TagType:ENUM_REP | 4, /** BlockMode. */
+    DIGEST = TagType:ENUM_REP | 5,     /** Digest. */
+    PADDING = TagType:ENUM_REP | 6,    /** PaddingMode. */
+    CALLER_NONCE = TagType:BOOL | 7,   /** Allow caller to specify nonce or IV. */
     MIN_MAC_LENGTH = TagType:UINT | 8, /* Minimum length of MAC or AEAD authentication tag in
                                         * bits. */
-    KDF = TagType:ENUM_REP | 9,        /* KeyDerivationFunction. */
-    EC_CURVE = TagType:ENUM | 10,      /* EcCurve. */
+    KDF = TagType:ENUM_REP | 9,        /** KeyDerivationFunction. */
+    EC_CURVE = TagType:ENUM | 10,      /** EcCurve. */
 
-    /* Algorithm-specific. */
+    /** Algorithm-specific. */
     RSA_PUBLIC_EXPONENT = TagType:ULONG | 200,
     ECIES_SINGLE_HASH_MODE = TagType:BOOL | 201, /* Whether the ephemeral public key is fed into the
                                                   * KDF. */
@@ -58,17 +58,17 @@
                                                   * will contain an application-scoped and
                                                   * time-bounded device-unique ID.*/
 
-    /* Other hardware-enforced. */
-    BLOB_USAGE_REQUIREMENTS = TagType:ENUM | 301, /* KeyBlobUsageRequirements. */
-    BOOTLOADER_ONLY = TagType:BOOL | 302,         /* Usable only by bootloader. */
+    /** Other hardware-enforced. */
+    BLOB_USAGE_REQUIREMENTS = TagType:ENUM | 301, /** KeyBlobUsageRequirements. */
+    BOOTLOADER_ONLY = TagType:BOOL | 302,         /** Usable only by bootloader. */
 
-    /*
+    /**
      * Tags that should be semantically enforced by hardware if possible and will otherwise be
      * enforced by software (keystore).
      */
 
-    /* Key validity period */
-    ACTIVE_DATETIME = TagType:DATE | 400,             /* Start of validity. */
+    /** Key validity period */
+    ACTIVE_DATETIME = TagType:DATE | 400,             /** Start of validity. */
     ORIGINATION_EXPIRE_DATETIME = TagType:DATE | 401, /* Date when new "messages" should no longer
                                                        * be created. */
     USAGE_EXPIRE_DATETIME = TagType:DATE | 402,       /* Date when existing "messages" should no
@@ -78,13 +78,13 @@
     MAX_USES_PER_BOOT = TagType:UINT | 404,           /* Number of times the key can be used per
                                                        * boot. */
 
-    /* User authentication */
-    ALL_USERS = TagType:BOOL | 500,           /* Reserved for future use -- ignore. */
-    USER_ID = TagType:UINT | 501,             /* Reserved for future use -- ignore. */
+    /** User authentication */
+    ALL_USERS = TagType:BOOL | 500,           /** Reserved for future use -- ignore. */
+    USER_ID = TagType:UINT | 501,             /** Reserved for future use -- ignore. */
     USER_SECURE_ID = TagType:ULONG_REP | 502, /* Secure ID of authorized user or authenticator(s).
                                                * Disallowed if ALL_USERS or NO_AUTH_REQUIRED is
                                                * present. */
-    NO_AUTH_REQUIRED = TagType:BOOL | 503,    /* If key is usable without authentication. */
+    NO_AUTH_REQUIRED = TagType:BOOL | 503,    /** If key is usable without authentication. */
     USER_AUTH_TYPE = TagType:ENUM | 504,      /* Bitmask of authenticator types allowed when
                                                * USER_SECURE_ID contains a secure user ID, rather
                                                * than a secure authenticator ID.  Defined in
@@ -99,27 +99,27 @@
                                                * if device is still on-body (requires secure on-body
                                                * sensor. */
 
-    /* Application access control */
+    /** Application access control */
     ALL_APPLICATIONS = TagType:BOOL | 600, /* Specified to indicate key is usable by all
                                             * applications. */
-    APPLICATION_ID = TagType:BYTES | 601,  /* Byte string identifying the authorized application. */
+    APPLICATION_ID = TagType:BYTES | 601,  /** Byte string identifying the authorized application. */
     EXPORTABLE = TagType:BOOL | 602,       /* If true, private/secret key can be exported, but only
                                             * if all access control requirements for use are
                                             * met. (keymaster2) */
 
-    /*
+    /**
      * Semantically unenforceable tags, either because they have no specific meaning or because
      * they're informational only.
      */
-    APPLICATION_DATA = TagType:BYTES | 700,      /* Data provided by authorized application. */
-    CREATION_DATETIME = TagType:DATE | 701,      /* Key creation time */
-    ORIGIN = TagType:ENUM | 702,                 /* keymaster_key_origin_t. */
-    ROLLBACK_RESISTANT = TagType:BOOL | 703,     /* Whether key is rollback-resistant. */
-    ROOT_OF_TRUST = TagType:BYTES | 704,         /* Root of trust ID. */
-    OS_VERSION = TagType:UINT | 705,             /* Version of system (keymaster2) */
-    OS_PATCHLEVEL = TagType:UINT | 706,          /* Patch level of system (keymaster2) */
-    UNIQUE_ID = TagType:BYTES | 707,             /* Used to provide unique ID in attestation */
-    ATTESTATION_CHALLENGE = TagType:BYTES | 708, /* Used to provide challenge in attestation */
+    APPLICATION_DATA = TagType:BYTES | 700,      /** Data provided by authorized application. */
+    CREATION_DATETIME = TagType:DATE | 701,      /** Key creation time */
+    ORIGIN = TagType:ENUM | 702,                 /** keymaster_key_origin_t. */
+    ROLLBACK_RESISTANT = TagType:BOOL | 703,     /** Whether key is rollback-resistant. */
+    ROOT_OF_TRUST = TagType:BYTES | 704,         /** Root of trust ID. */
+    OS_VERSION = TagType:UINT | 705,             /** Version of system (keymaster2) */
+    OS_PATCHLEVEL = TagType:UINT | 706,          /** Patch level of system (keymaster2) */
+    UNIQUE_ID = TagType:BYTES | 707,             /** Used to provide unique ID in attestation */
+    ATTESTATION_CHALLENGE = TagType:BYTES | 708, /** Used to provide challenge in attestation */
     ATTESTATION_APPLICATION_ID = TagType:BYTES | 709, /* Used to identify the set of possible
                                                        * applications of which one has initiated a
                                                        * key attestation */
@@ -140,13 +140,13 @@
     ATTESTATION_ID_MODEL = TagType:BYTES | 717,  /* Used to provide the device's model name to be
                                                     included in attestation */
 
-    /* Tags used only to provide data to or receive data from operations */
-    ASSOCIATED_DATA = TagType:BYTES | 1000, /* Used to provide associated data for AEAD modes. */
-    NONCE = TagType:BYTES | 1001,           /* Nonce or Initialization Vector */
+    /** Tags used only to provide data to or receive data from operations */
+    ASSOCIATED_DATA = TagType:BYTES | 1000, /** Used to provide associated data for AEAD modes. */
+    NONCE = TagType:BYTES | 1001,           /** Nonce or Initialization Vector */
     AUTH_TOKEN = TagType:BYTES | 1002,      /* Authentication token that proves secure user
                                              * authentication has been performed.  Structure defined
                                              * in hw_auth_token_t in hw_auth_token.h. */
-    MAC_LENGTH = TagType:UINT | 1003,       /* MAC or AEAD authentication tag length in bits. */
+    MAC_LENGTH = TagType:UINT | 1003,       /** MAC or AEAD authentication tag length in bits. */
 
     RESET_SINCE_ID_ROTATION = TagType:BOOL | 1004, /* Whether the device has beeen factory reset
                                                     * since the last unique ID rotation.  Used for
@@ -154,15 +154,15 @@
 };
 
 enum Algorithm : uint32_t {
-    /* Asymmetric algorithms. */
+    /** Asymmetric algorithms. */
     RSA = 1,
     // DSA = 2, -- Removed, do not re-use value 2.
     EC = 3,
 
-    /* Block ciphers algorithms */
+    /** Block ciphers algorithms */
     AES = 32,
 
-    /* MAC algorithms */
+    /** MAC algorithms */
     HMAC = 128,
 };
 
@@ -170,13 +170,15 @@
  * Symmetric block cipher modes provided by keymaster implementations.
  */
 enum BlockMode : uint32_t {
-    /* Unauthenticated modes, usable only for encryption/decryption and not generally recommended
+    /**
+     * Unauthenticated modes, usable only for encryption/decryption and not generally recommended
      * except for compatibility with existing other protocols. */
     ECB = 1,
     CBC = 2,
     CTR = 3,
 
-    /* Authenticated modes, usable for encryption/decryption and signing/verification.  Recommended
+    /**
+     * Authenticated modes, usable for encryption/decryption and signing/verification.  Recommended
      * over unauthenticated modes for all purposes. */
     GCM = 32,
 };
@@ -188,7 +190,7 @@
  * cryptographically-appropriate pairs.
  */
 enum PaddingMode : uint32_t {
-    NONE = 1, /* deprecated */
+    NONE = 1, /** deprecated */
     RSA_OAEP = 2,
     RSA_PSS = 3,
     RSA_PKCS1_1_5_ENCRYPT = 4,
@@ -227,9 +229,9 @@
  * guaranteed never to have existed outide the secure hardware.
  */
 enum KeyOrigin : uint32_t {
-    GENERATED = 0, /* Generated in keymaster.  Should not exist outside the TEE. */
-    DERIVED = 1,   /* Derived inside keymaster.  Likely exists off-device. */
-    IMPORTED = 2,  /* Imported into keymaster.  Existed as cleartext in Android. */
+    GENERATED = 0, /** Generated in keymaster.  Should not exist outside the TEE. */
+    DERIVED = 1,   /** Derived inside keymaster.  Likely exists off-device. */
+    IMPORTED = 2,  /** Imported into keymaster.  Existed as cleartext in Android. */
     UNKNOWN = 3,   /* Keymaster did not record origin.  This value can only be seen on keys in a
                     * keymaster0 implementation.  The keymaster0 adapter uses this value to document
                     * the fact that it is unkown whether the key was generated inside or imported
@@ -252,12 +254,12 @@
  * Possible purposes of a key (or pair).
  */
 enum KeyPurpose : uint32_t {
-    ENCRYPT = 0,    /* Usable with RSA, EC and AES keys. */
-    DECRYPT = 1,    /* Usable with RSA, EC and AES keys. */
-    SIGN = 2,       /* Usable with RSA, EC and HMAC keys. */
-    VERIFY = 3,     /* Usable with RSA, EC and HMAC keys. */
-    DERIVE_KEY = 4, /* Usable with EC keys. */
-    WRAP_KEY = 5,   /* Usable with wrapping keys. */
+    ENCRYPT = 0,    /** Usable with RSA, EC and AES keys. */
+    DECRYPT = 1,    /** Usable with RSA, EC and AES keys. */
+    SIGN = 2,       /** Usable with RSA, EC and HMAC keys. */
+    VERIFY = 3,     /** Usable with RSA, EC and HMAC keys. */
+    DERIVE_KEY = 4, /** Usable with EC keys. */
+    WRAP_KEY = 5,   /** Usable with wrapping keys. */
 };
 
 /**
@@ -283,8 +285,8 @@
     INVALID_AUTHORIZATION_TIMEOUT = -16,
     UNSUPPORTED_KEY_FORMAT = -17,
     INCOMPATIBLE_KEY_FORMAT = -18,
-    UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM = -19,   /* For PKCS8 & PKCS12 */
-    UNSUPPORTED_KEY_VERIFICATION_ALGORITHM = -20, /* For PKCS8 & PKCS12 */
+    UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM = -19,   /** For PKCS8 & PKCS12 */
+    UNSUPPORTED_KEY_VERIFICATION_ALGORITHM = -20, /** For PKCS8 & PKCS12 */
     INVALID_INPUT_LENGTH = -21,
     KEY_EXPORT_OPTIONS_INVALID = -22,
     DELEGATION_NOT_ALLOWED = -23,
@@ -340,17 +342,17 @@
  * Key derivation functions, mostly used in ECIES.
  */
 enum KeyDerivationFunction : uint32_t {
-    /* Do not apply a key derivation function; use the raw agreed key */
+    /** Do not apply a key derivation function; use the raw agreed key */
     NONE = 0,
-    /* HKDF defined in RFC 5869 with SHA256 */
+    /** HKDF defined in RFC 5869 with SHA256 */
     RFC5869_SHA256 = 1,
-    /* KDF1 defined in ISO 18033-2 with SHA1 */
+    /** KDF1 defined in ISO 18033-2 with SHA1 */
     ISO18033_2_KDF1_SHA1 = 2,
-    /* KDF1 defined in ISO 18033-2 with SHA256 */
+    /** KDF1 defined in ISO 18033-2 with SHA256 */
     ISO18033_2_KDF1_SHA256 = 3,
-    /* KDF2 defined in ISO 18033-2 with SHA1 */
+    /** KDF2 defined in ISO 18033-2 with SHA1 */
     ISO18033_2_KDF2_SHA1 = 4,
-    /* KDF2 defined in ISO 18033-2 with SHA256 */
+    /** KDF2 defined in ISO 18033-2 with SHA256 */
     ISO18033_2_KDF2_SHA256 = 5,
 };
 
@@ -368,11 +370,12 @@
 };
 
 struct KeyParameter {
-    /* Discriminates the uinon/blob field used.  The blob cannot be coincided with the union, but
+    /**
+     * Discriminates the uinon/blob field used.  The blob cannot be coincided with the union, but
      * only one of "f" and "blob" is ever used at a time. */
     Tag tag;
     union IntegerParams {
-        /* Enum types */
+        /** Enum types */
         Algorithm algorithm;
         BlockMode blockMode;
         PaddingMode paddingMode;
@@ -384,7 +387,7 @@
         KeyDerivationFunction keyDerivationFunction;
         HardwareAuthenticatorType hardwareAuthenticatorType;
 
-        /* Other types */
+        /** Other types */
         bool boolValue;  // Always true, if a boolean tag is present.
         uint32_t integer;
         uint64_t longInteger;
@@ -424,8 +427,8 @@
  * Formats for key import and export.
  */
 enum KeyFormat : uint32_t {
-    X509 = 0,  /* for public key export */
-    PKCS8 = 1, /* for asymmetric key pair import */
+    X509 = 0,  /** for public key export */
+    PKCS8 = 1, /** for asymmetric key pair import */
     RAW = 3,   /* for symmetric key import and export*/
 };
 
diff --git a/keymaster/3.0/vts/functional/Android.mk b/keymaster/3.0/vts/functional/Android.mk
new file mode 100644
index 0000000..4265b9f
--- /dev/null
+++ b/keymaster/3.0/vts/functional/Android.mk
@@ -0,0 +1,39 @@
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := keymaster_hidl_hal_test
+LOCAL_SRC_FILES := \
+        authorization_set.cpp \
+        attestation_record.cpp \
+        key_param_output.cpp \
+        keymaster_hidl_hal_test.cpp \
+        keystore_tags_utils.cpp \
+
+LOCAL_SHARED_LIBRARIES := \
+        android.hardware.keymaster@3.0 \
+        libcrypto \
+        libhidlbase \
+        liblog \
+        libsoftkeymasterdevice \
+        libutils \
+
+LOCAL_STATIC_LIBRARIES := \
+        VtsHalHidlTargetTestBase \
+
+LOCAL_CFLAGS := -Wall -Werror
+
+include $(BUILD_NATIVE_TEST)
diff --git a/keymaster/3.0/vts/functional/attestation_record.cpp b/keymaster/3.0/vts/functional/attestation_record.cpp
new file mode 100644
index 0000000..6cdd44c
--- /dev/null
+++ b/keymaster/3.0/vts/functional/attestation_record.cpp
@@ -0,0 +1,289 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "attestation_record.h"
+
+#include <assert.h>
+
+#include <openssl/asn1t.h>
+#include <openssl/bn.h>
+#include <openssl/evp.h>
+#include <openssl/x509.h>
+
+#include "openssl_utils.h"
+
+namespace android {
+namespace hardware {
+namespace keymaster {
+namespace V3_0 {
+
+struct stack_st_ASN1_TYPE_Delete {
+    void operator()(stack_st_ASN1_TYPE* p) { sk_ASN1_TYPE_free(p); }
+};
+
+struct ASN1_STRING_Delete {
+    void operator()(ASN1_STRING* p) { ASN1_STRING_free(p); }
+};
+
+struct ASN1_TYPE_Delete {
+    void operator()(ASN1_TYPE* p) { ASN1_TYPE_free(p); }
+};
+
+#define ASN1_INTEGER_SET STACK_OF(ASN1_INTEGER)
+
+typedef struct km_root_of_trust {
+    ASN1_OCTET_STRING* verified_boot_key;
+    ASN1_BOOLEAN* device_locked;
+    ASN1_ENUMERATED* verified_boot_state;
+} KM_ROOT_OF_TRUST;
+
+ASN1_SEQUENCE(KM_ROOT_OF_TRUST) = {
+    ASN1_SIMPLE(KM_ROOT_OF_TRUST, verified_boot_key, ASN1_OCTET_STRING),
+    ASN1_SIMPLE(KM_ROOT_OF_TRUST, device_locked, ASN1_BOOLEAN),
+    ASN1_SIMPLE(KM_ROOT_OF_TRUST, verified_boot_state, ASN1_ENUMERATED),
+} ASN1_SEQUENCE_END(KM_ROOT_OF_TRUST);
+IMPLEMENT_ASN1_FUNCTIONS(KM_ROOT_OF_TRUST);
+
+typedef struct km_auth_list {
+    ASN1_INTEGER_SET* purpose;
+    ASN1_INTEGER* algorithm;
+    ASN1_INTEGER* key_size;
+    ASN1_INTEGER_SET* digest;
+    ASN1_INTEGER_SET* padding;
+    ASN1_INTEGER_SET* kdf;
+    ASN1_INTEGER* ec_curve;
+    ASN1_INTEGER* rsa_public_exponent;
+    ASN1_INTEGER* active_date_time;
+    ASN1_INTEGER* origination_expire_date_time;
+    ASN1_INTEGER* usage_expire_date_time;
+    ASN1_NULL* no_auth_required;
+    ASN1_INTEGER* user_auth_type;
+    ASN1_INTEGER* auth_timeout;
+    ASN1_NULL* allow_while_on_body;
+    ASN1_NULL* all_applications;
+    ASN1_OCTET_STRING* application_id;
+    ASN1_INTEGER* creation_date_time;
+    ASN1_INTEGER* origin;
+    ASN1_NULL* rollback_resistant;
+    KM_ROOT_OF_TRUST* root_of_trust;
+    ASN1_INTEGER* os_version;
+    ASN1_INTEGER* os_patchlevel;
+    ASN1_OCTET_STRING* attestation_application_id;
+} KM_AUTH_LIST;
+
+ASN1_SEQUENCE(KM_AUTH_LIST) = {
+    ASN1_EXP_SET_OF_OPT(KM_AUTH_LIST, purpose, ASN1_INTEGER, TAG_PURPOSE.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, algorithm, ASN1_INTEGER, TAG_ALGORITHM.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, key_size, ASN1_INTEGER, TAG_KEY_SIZE.maskedTag()),
+    ASN1_EXP_SET_OF_OPT(KM_AUTH_LIST, digest, ASN1_INTEGER, TAG_DIGEST.maskedTag()),
+    ASN1_EXP_SET_OF_OPT(KM_AUTH_LIST, padding, ASN1_INTEGER, TAG_PADDING.maskedTag()),
+    ASN1_EXP_SET_OF_OPT(KM_AUTH_LIST, kdf, ASN1_INTEGER, TAG_KDF.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, ec_curve, ASN1_INTEGER, TAG_EC_CURVE.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, rsa_public_exponent, ASN1_INTEGER,
+                 TAG_RSA_PUBLIC_EXPONENT.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, active_date_time, ASN1_INTEGER, TAG_ACTIVE_DATETIME.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, origination_expire_date_time, ASN1_INTEGER,
+                 TAG_ORIGINATION_EXPIRE_DATETIME.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, usage_expire_date_time, ASN1_INTEGER,
+                 TAG_USAGE_EXPIRE_DATETIME.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, no_auth_required, ASN1_NULL, TAG_NO_AUTH_REQUIRED.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, user_auth_type, ASN1_INTEGER, TAG_USER_AUTH_TYPE.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, auth_timeout, ASN1_INTEGER, TAG_AUTH_TIMEOUT.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, allow_while_on_body, ASN1_NULL, TAG_ALLOW_WHILE_ON_BODY.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, all_applications, ASN1_NULL, TAG_ALL_APPLICATIONS.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, application_id, ASN1_OCTET_STRING, TAG_APPLICATION_ID.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, creation_date_time, ASN1_INTEGER, TAG_CREATION_DATETIME.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, origin, ASN1_INTEGER, TAG_ORIGIN.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, rollback_resistant, ASN1_NULL, TAG_ROLLBACK_RESISTANT.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, root_of_trust, KM_ROOT_OF_TRUST, TAG_ROOT_OF_TRUST.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, os_version, ASN1_INTEGER, TAG_OS_VERSION.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, os_patchlevel, ASN1_INTEGER, TAG_OS_PATCHLEVEL.maskedTag()),
+    ASN1_EXP_OPT(KM_AUTH_LIST, attestation_application_id, ASN1_OCTET_STRING,
+                 TAG_ATTESTATION_APPLICATION_ID.maskedTag()),
+} ASN1_SEQUENCE_END(KM_AUTH_LIST);
+IMPLEMENT_ASN1_FUNCTIONS(KM_AUTH_LIST);
+
+typedef struct km_key_description {
+    ASN1_INTEGER* attestation_version;
+    ASN1_ENUMERATED* attestation_security_level;
+    ASN1_INTEGER* keymaster_version;
+    ASN1_ENUMERATED* keymaster_security_level;
+    ASN1_OCTET_STRING* attestation_challenge;
+    KM_AUTH_LIST* software_enforced;
+    KM_AUTH_LIST* tee_enforced;
+    ASN1_INTEGER* unique_id;
+} KM_KEY_DESCRIPTION;
+
+ASN1_SEQUENCE(KM_KEY_DESCRIPTION) = {
+    ASN1_SIMPLE(KM_KEY_DESCRIPTION, attestation_version, ASN1_INTEGER),
+    ASN1_SIMPLE(KM_KEY_DESCRIPTION, attestation_security_level, ASN1_ENUMERATED),
+    ASN1_SIMPLE(KM_KEY_DESCRIPTION, keymaster_version, ASN1_INTEGER),
+    ASN1_SIMPLE(KM_KEY_DESCRIPTION, keymaster_security_level, ASN1_ENUMERATED),
+    ASN1_SIMPLE(KM_KEY_DESCRIPTION, attestation_challenge, ASN1_OCTET_STRING),
+    ASN1_SIMPLE(KM_KEY_DESCRIPTION, unique_id, ASN1_OCTET_STRING),
+    ASN1_SIMPLE(KM_KEY_DESCRIPTION, software_enforced, KM_AUTH_LIST),
+    ASN1_SIMPLE(KM_KEY_DESCRIPTION, tee_enforced, KM_AUTH_LIST),
+} ASN1_SEQUENCE_END(KM_KEY_DESCRIPTION);
+IMPLEMENT_ASN1_FUNCTIONS(KM_KEY_DESCRIPTION);
+
+template <Tag tag>
+void copyAuthTag(const stack_st_ASN1_INTEGER* stack, TypedTag<TagType::ENUM_REP, tag> ttag,
+                 AuthorizationSet* auth_list) {
+    typedef typename TypedTag2ValueType<decltype(ttag)>::type ValueT;
+    for (size_t i = 0; i < sk_ASN1_INTEGER_num(stack); ++i) {
+        auth_list->push_back(
+            ttag, static_cast<ValueT>(ASN1_INTEGER_get(sk_ASN1_INTEGER_value(stack, i))));
+    }
+}
+
+template <Tag tag>
+void copyAuthTag(const ASN1_INTEGER* asn1_int, TypedTag<TagType::ENUM, tag> ttag,
+                 AuthorizationSet* auth_list) {
+    typedef typename TypedTag2ValueType<decltype(ttag)>::type ValueT;
+    if (!asn1_int) return;
+    auth_list->push_back(ttag, static_cast<ValueT>(ASN1_INTEGER_get(asn1_int)));
+}
+
+template <Tag tag>
+void copyAuthTag(const ASN1_INTEGER* asn1_int, TypedTag<TagType::UINT, tag> ttag,
+                 AuthorizationSet* auth_list) {
+    if (!asn1_int) return;
+    auth_list->push_back(ttag, ASN1_INTEGER_get(asn1_int));
+}
+
+BIGNUM* construct_uint_max() {
+    BIGNUM* value = BN_new();
+    BIGNUM_Ptr one(BN_new());
+    BN_one(one.get());
+    BN_lshift(value, one.get(), 32);
+    return value;
+}
+
+uint64_t BignumToUint64(BIGNUM* num) {
+    static_assert((sizeof(BN_ULONG) == sizeof(uint32_t)) || (sizeof(BN_ULONG) == sizeof(uint64_t)),
+                  "This implementation only supports 32 and 64-bit BN_ULONG");
+    if (sizeof(BN_ULONG) == sizeof(uint32_t)) {
+        BIGNUM_Ptr uint_max(construct_uint_max());
+        BIGNUM_Ptr hi(BN_new()), lo(BN_new());
+        BN_CTX_Ptr ctx(BN_CTX_new());
+        BN_div(hi.get(), lo.get(), num, uint_max.get(), ctx.get());
+        return static_cast<uint64_t>(BN_get_word(hi.get())) << 32 | BN_get_word(lo.get());
+    } else if (sizeof(BN_ULONG) == sizeof(uint64_t)) {
+        return BN_get_word(num);
+    } else {
+        return 0;
+    }
+}
+
+template <Tag tag>
+void copyAuthTag(const ASN1_INTEGER* asn1_int, TypedTag<TagType::ULONG, tag> ttag,
+                 AuthorizationSet* auth_list) {
+    if (!asn1_int) return;
+    BIGNUM_Ptr num(ASN1_INTEGER_to_BN(asn1_int, nullptr));
+    auth_list->push_back(ttag, BignumToUint64(num.get()));
+}
+
+template <Tag tag>
+void copyAuthTag(const ASN1_INTEGER* asn1_int, TypedTag<TagType::DATE, tag> ttag,
+                 AuthorizationSet* auth_list) {
+    if (!asn1_int) return;
+    BIGNUM_Ptr num(ASN1_INTEGER_to_BN(asn1_int, nullptr));
+    auth_list->push_back(ttag, BignumToUint64(num.get()));
+}
+
+template <Tag tag>
+void copyAuthTag(const ASN1_NULL* asn1_null, TypedTag<TagType::BOOL, tag> ttag,
+                 AuthorizationSet* auth_list) {
+    if (!asn1_null) return;
+    auth_list->push_back(ttag);
+}
+
+template <Tag tag>
+void copyAuthTag(const ASN1_OCTET_STRING* asn1_string, TypedTag<TagType::BYTES, tag> ttag,
+                 AuthorizationSet* auth_list) {
+    if (!asn1_string) return;
+    hidl_vec<uint8_t> buf;
+    buf.setToExternal(asn1_string->data, asn1_string->length);
+    auth_list->push_back(ttag, buf);
+}
+
+// Extract the values from the specified ASN.1 record and place them in auth_list.
+static ErrorCode extract_auth_list(const KM_AUTH_LIST* record, AuthorizationSet* auth_list) {
+    if (!record) return ErrorCode::OK;
+
+    copyAuthTag(record->active_date_time, TAG_ACTIVE_DATETIME, auth_list);
+    copyAuthTag(record->algorithm, TAG_ALGORITHM, auth_list);
+    copyAuthTag(record->all_applications, TAG_ALL_APPLICATIONS, auth_list);
+    copyAuthTag(record->application_id, TAG_APPLICATION_ID, auth_list);
+    copyAuthTag(record->auth_timeout, TAG_AUTH_TIMEOUT, auth_list);
+    copyAuthTag(record->creation_date_time, TAG_CREATION_DATETIME, auth_list);
+    copyAuthTag(record->digest, TAG_DIGEST, auth_list);
+    copyAuthTag(record->ec_curve, TAG_EC_CURVE, auth_list);
+    copyAuthTag(record->key_size, TAG_KEY_SIZE, auth_list);
+    copyAuthTag(record->no_auth_required, TAG_NO_AUTH_REQUIRED, auth_list);
+    copyAuthTag(record->origin, TAG_ORIGIN, auth_list);
+    copyAuthTag(record->origination_expire_date_time, TAG_ORIGINATION_EXPIRE_DATETIME, auth_list);
+    copyAuthTag(record->os_patchlevel, TAG_OS_PATCHLEVEL, auth_list);
+    copyAuthTag(record->os_version, TAG_OS_VERSION, auth_list);
+    copyAuthTag(record->padding, TAG_PADDING, auth_list);
+    copyAuthTag(record->purpose, TAG_PURPOSE, auth_list);
+    copyAuthTag(record->rollback_resistant, TAG_ROLLBACK_RESISTANT, auth_list);
+    copyAuthTag(record->rsa_public_exponent, TAG_RSA_PUBLIC_EXPONENT, auth_list);
+    copyAuthTag(record->usage_expire_date_time, TAG_USAGE_EXPIRE_DATETIME, auth_list);
+    copyAuthTag(record->user_auth_type, TAG_USER_AUTH_TYPE, auth_list);
+
+    return ErrorCode::OK;
+}
+
+MAKE_OPENSSL_PTR_TYPE(KM_KEY_DESCRIPTION)
+
+// Parse the DER-encoded attestation record, placing the results in keymaster_version,
+// attestation_challenge, software_enforced, tee_enforced and unique_id.
+ErrorCode parse_attestation_record(const uint8_t* asn1_key_desc, size_t asn1_key_desc_len,
+                                   uint32_t* attestation_version,  //
+                                   SecurityLevel* attestation_security_level,
+                                   uint32_t* keymaster_version,
+                                   SecurityLevel* keymaster_security_level,
+                                   hidl_vec<uint8_t>* attestation_challenge,
+                                   AuthorizationSet* software_enforced,
+                                   AuthorizationSet* tee_enforced,  //
+                                   hidl_vec<uint8_t>* unique_id) {
+    const uint8_t* p = asn1_key_desc;
+    KM_KEY_DESCRIPTION_Ptr record(d2i_KM_KEY_DESCRIPTION(nullptr, &p, asn1_key_desc_len));
+    if (!record.get()) return ErrorCode::UNKNOWN_ERROR;
+
+    *attestation_version = ASN1_INTEGER_get(record->attestation_version);
+    *attestation_security_level =
+        static_cast<SecurityLevel>(ASN1_ENUMERATED_get(record->attestation_security_level));
+    *keymaster_version = ASN1_INTEGER_get(record->keymaster_version);
+    *keymaster_security_level =
+        static_cast<SecurityLevel>(ASN1_ENUMERATED_get(record->keymaster_security_level));
+
+    attestation_challenge->setToExternal(record->attestation_challenge->data,
+                                         record->attestation_challenge->length);
+
+    unique_id->setToExternal(record->unique_id->data, record->unique_id->length);
+
+    ErrorCode error = extract_auth_list(record->software_enforced, software_enforced);
+    if (error != ErrorCode::OK) return error;
+
+    return extract_auth_list(record->tee_enforced, tee_enforced);
+}
+
+}  // namespace V3_0
+}  // namespace keymaster
+}  // namespace hardware
+}  // namespace android
diff --git a/keymaster/3.0/vts/functional/attestation_record.h b/keymaster/3.0/vts/functional/attestation_record.h
new file mode 100644
index 0000000..a042055
--- /dev/null
+++ b/keymaster/3.0/vts/functional/attestation_record.h
@@ -0,0 +1,57 @@
+/*
+ * 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 HARDWARE_INTERFACES_KEYMASTER_30_VTS_FUNCTIONAL_ATTESTATION_RECORD_H_
+#define HARDWARE_INTERFACES_KEYMASTER_30_VTS_FUNCTIONAL_ATTESTATION_RECORD_H_
+
+#include "authorization_set.h"
+
+namespace android {
+namespace hardware {
+namespace keymaster {
+namespace V3_0 {
+
+/**
+ * The OID for Android attestation records.  For the curious, it breaks down as follows:
+ *
+ * 1 = ISO
+ * 3 = org
+ * 6 = DoD (Huh? OIDs are weird.)
+ * 1 = IANA
+ * 4 = Private
+ * 1 = Enterprises
+ * 11129 = Google
+ * 2 = Google security
+ * 1 = certificate extension
+ * 17 = Android attestation extension.
+ */
+static const char kAttestionRecordOid[] = "1.3.6.1.4.1.11129.2.1.17";
+
+ErrorCode parse_attestation_record(const uint8_t* asn1_key_desc, size_t asn1_key_desc_len,
+                                   uint32_t* attestation_version,  //
+                                   SecurityLevel* attestation_security_level,
+                                   uint32_t* keymaster_version,
+                                   SecurityLevel* keymaster_security_level,
+                                   hidl_vec<uint8_t>* attestation_challenge,
+                                   AuthorizationSet* software_enforced,
+                                   AuthorizationSet* tee_enforced,  //
+                                   hidl_vec<uint8_t>* unique_id);
+}  // namespace V3_0
+}  // namespace keymaster
+}  // namespace hardware
+}  // namespace android
+
+#endif  // HARDWARE_INTERFACES_KEYMASTER_30_VTS_FUNCTIONAL_ATTESTATION_RECORD_H_
diff --git a/keymaster/3.0/vts/functional/authorization_set.cpp b/keymaster/3.0/vts/functional/authorization_set.cpp
new file mode 100644
index 0000000..303f7e7
--- /dev/null
+++ b/keymaster/3.0/vts/functional/authorization_set.cpp
@@ -0,0 +1,422 @@
+/*
+ * Copyright (C) 2014 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 "authorization_set.h"
+
+#include <assert.h>
+#include <istream>
+#include <limits>
+#include <ostream>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <new>
+
+namespace android {
+namespace hardware {
+namespace keymaster {
+namespace V3_0 {
+
+inline bool keyParamLess(const KeyParameter& a, const KeyParameter& b) {
+    if (a.tag != b.tag) return a.tag < b.tag;
+    int retval;
+    switch (typeFromTag(a.tag)) {
+    case TagType::INVALID:
+    case TagType::BOOL:
+        return false;
+    case TagType::ENUM:
+    case TagType::ENUM_REP:
+    case TagType::UINT:
+    case TagType::UINT_REP:
+        return a.f.integer < b.f.integer;
+    case TagType::ULONG:
+    case TagType::ULONG_REP:
+        return a.f.longInteger < b.f.longInteger;
+    case TagType::DATE:
+        return a.f.dateTime < b.f.dateTime;
+    case TagType::BIGNUM:
+    case TagType::BYTES:
+        // Handle the empty cases.
+        if (a.blob.size() == 0) return b.blob.size() != 0;
+        if (b.blob.size() == 0) return false;
+
+        retval = memcmp(&a.blob[0], &b.blob[0], std::min(a.blob.size(), b.blob.size()));
+        if (retval == 0) {
+            // One is the prefix of the other, so the longer wins
+            return a.blob.size() < b.blob.size();
+        } else {
+            return retval < 0;
+        }
+    }
+    return false;
+}
+
+inline bool keyParamEqual(const KeyParameter& a, const KeyParameter& b) {
+    if (a.tag != b.tag) return false;
+
+    switch (typeFromTag(a.tag)) {
+    case TagType::INVALID:
+    case TagType::BOOL:
+        return true;
+    case TagType::ENUM:
+    case TagType::ENUM_REP:
+    case TagType::UINT:
+    case TagType::UINT_REP:
+        return a.f.integer == b.f.integer;
+    case TagType::ULONG:
+    case TagType::ULONG_REP:
+        return a.f.longInteger == b.f.longInteger;
+    case TagType::DATE:
+        return a.f.dateTime == b.f.dateTime;
+    case TagType::BIGNUM:
+    case TagType::BYTES:
+        if (a.blob.size() != b.blob.size()) return false;
+        return a.blob.size() == 0 || memcmp(&a.blob[0], &b.blob[0], a.blob.size()) == 0;
+    }
+    return false;
+}
+
+void AuthorizationSet::Sort() {
+    std::sort(data_.begin(), data_.end(), keyParamLess);
+}
+
+void AuthorizationSet::Deduplicate() {
+    if (data_.empty()) return;
+
+    Sort();
+    std::vector<KeyParameter> result;
+
+    auto curr = data_.begin();
+    auto prev = curr++;
+    for (; curr != data_.end(); ++prev, ++curr) {
+        if (prev->tag == Tag::INVALID) continue;
+
+        if (!keyParamEqual(*prev, *curr)) {
+            result.emplace_back(std::move(*prev));
+        }
+    }
+    result.emplace_back(std::move(*prev));
+
+    std::swap(data_, result);
+}
+
+void AuthorizationSet::Union(const AuthorizationSet& other) {
+    data_.insert(data_.end(), other.data_.begin(), other.data_.end());
+    Deduplicate();
+}
+
+void AuthorizationSet::Subtract(const AuthorizationSet& other) {
+    Deduplicate();
+
+    auto i = other.begin();
+    while (i != other.end()) {
+        int pos = -1;
+        do {
+            pos = find(i->tag, pos);
+            if (pos != -1 && keyParamEqual(*i, data_[pos])) {
+                data_.erase(data_.begin() + pos);
+                break;
+            }
+        } while (pos != -1);
+        ++i;
+    }
+}
+
+int AuthorizationSet::find(Tag tag, int begin) const {
+    auto iter = data_.begin() + (1 + begin);
+
+    while (iter != data_.end() && iter->tag != tag)
+        ++iter;
+
+    if (iter != data_.end()) return iter - data_.begin();
+    return -1;
+}
+
+bool AuthorizationSet::erase(int index) {
+    auto pos = data_.begin() + index;
+    if (pos != data_.end()) {
+        data_.erase(pos);
+        return true;
+    }
+    return false;
+}
+
+KeyParameter& AuthorizationSet::operator[](int at) {
+    return data_[at];
+}
+
+const KeyParameter& AuthorizationSet::operator[](int at) const {
+    return data_[at];
+}
+
+void AuthorizationSet::Clear() {
+    data_.clear();
+}
+
+size_t AuthorizationSet::GetTagCount(Tag tag) const {
+    size_t count = 0;
+    for (int pos = -1; (pos = find(tag, pos)) != -1;)
+        ++count;
+    return count;
+}
+
+NullOr<const KeyParameter&> AuthorizationSet::GetEntry(Tag tag) const {
+    int pos = find(tag);
+    if (pos == -1) return {};
+    return data_[pos];
+}
+
+/**
+ * Persistent format is:
+ * | 32 bit indirect_size         |
+ * --------------------------------
+ * | indirect_size bytes of data  | this is where the blob data is stored
+ * --------------------------------
+ * | 32 bit element_count         | number of entries
+ * | 32 bit elements_size         | total bytes used by entries (entries have variable length)
+ * --------------------------------
+ * | elementes_size bytes of data | where the elements are stored
+ */
+
+/**
+ * Persistent format of blobs and bignums:
+ * | 32 bit tag             |
+ * | 32 bit blob_length     |
+ * | 32 bit indirect_offset |
+ */
+
+struct OutStreams {
+    std::ostream& indirect;
+    std::ostream& elements;
+};
+
+OutStreams& serializeParamValue(OutStreams& out, const hidl_vec<uint8_t>& blob) {
+    uint32_t buffer;
+
+    // write blob_length
+    auto blob_length = blob.size();
+    if (blob_length > std::numeric_limits<uint32_t>::max()) {
+        out.elements.setstate(std::ios_base::badbit);
+        return out;
+    }
+    buffer = blob_length;
+    out.elements.write(reinterpret_cast<const char*>(&buffer), sizeof(uint32_t));
+
+    // write indirect_offset
+    auto offset = out.indirect.tellp();
+    if (offset < 0 || offset > std::numeric_limits<uint32_t>::max() ||
+        static_cast<uint32_t>((std::numeric_limits<uint32_t>::max() - offset)) <
+            blob_length) {  // overflow check
+        out.elements.setstate(std::ios_base::badbit);
+        return out;
+    }
+    buffer = offset;
+    out.elements.write(reinterpret_cast<const char*>(&buffer), sizeof(uint32_t));
+
+    // write blob to indirect stream
+    if (blob_length) out.indirect.write(reinterpret_cast<const char*>(&blob[0]), blob_length);
+
+    return out;
+}
+
+template <typename T> OutStreams& serializeParamValue(OutStreams& out, const T& value) {
+    out.elements.write(reinterpret_cast<const char*>(&value), sizeof(T));
+    return out;
+}
+
+OutStreams& serialize(TAG_INVALID_t&&, OutStreams& out, const KeyParameter&) {
+    // skip invalid entries.
+    return out;
+}
+template <typename T> OutStreams& serialize(T ttag, OutStreams& out, const KeyParameter& param) {
+    out.elements.write(reinterpret_cast<const char*>(&param.tag), sizeof(int32_t));
+    return serializeParamValue(out, accessTagValue(ttag, param));
+}
+
+template <typename... T> struct choose_serializer;
+template <typename... Tags> struct choose_serializer<MetaList<Tags...>> {
+    static OutStreams& serialize(OutStreams& out, const KeyParameter& param) {
+        return choose_serializer<Tags...>::serialize(out, param);
+    }
+};
+template <> struct choose_serializer<> {
+    static OutStreams& serialize(OutStreams& out, const KeyParameter&) { return out; }
+};
+template <TagType tag_type, Tag tag, typename... Tail>
+struct choose_serializer<TypedTag<tag_type, tag>, Tail...> {
+    static OutStreams& serialize(OutStreams& out, const KeyParameter& param) {
+        if (param.tag == tag) {
+            return V3_0::serialize(TypedTag<tag_type, tag>(), out, param);
+        } else {
+            return choose_serializer<Tail...>::serialize(out, param);
+        }
+    }
+};
+
+OutStreams& serialize(OutStreams& out, const KeyParameter& param) {
+    return choose_serializer<all_tags_t>::serialize(out, param);
+}
+
+std::ostream& serialize(std::ostream& out, const std::vector<KeyParameter>& params) {
+    std::stringstream indirect;
+    std::stringstream elements;
+    OutStreams streams = {indirect, elements};
+    for (const auto& param : params) {
+        serialize(streams, param);
+    }
+    if (indirect.bad() || elements.bad()) {
+        out.setstate(std::ios_base::badbit);
+        return out;
+    }
+    auto pos = indirect.tellp();
+    if (pos < 0 || pos > std::numeric_limits<uint32_t>::max()) {
+        out.setstate(std::ios_base::badbit);
+        return out;
+    }
+    uint32_t indirect_size = pos;
+    pos = elements.tellp();
+    if (pos < 0 || pos > std::numeric_limits<uint32_t>::max()) {
+        out.setstate(std::ios_base::badbit);
+        return out;
+    }
+    uint32_t elements_size = pos;
+    uint32_t element_count = params.size();
+
+    out.write(reinterpret_cast<const char*>(&indirect_size), sizeof(uint32_t));
+
+    pos = out.tellp();
+    if (indirect_size) out << indirect.rdbuf();
+    assert(out.tellp() - pos == indirect_size);
+
+    out.write(reinterpret_cast<const char*>(&element_count), sizeof(uint32_t));
+    out.write(reinterpret_cast<const char*>(&elements_size), sizeof(uint32_t));
+
+    pos = out.tellp();
+    if (elements_size) out << elements.rdbuf();
+    assert(out.tellp() - pos == elements_size);
+
+    return out;
+}
+
+struct InStreams {
+    std::istream& indirect;
+    std::istream& elements;
+};
+
+InStreams& deserializeParamValue(InStreams& in, hidl_vec<uint8_t>* blob) {
+    uint32_t blob_length = 0;
+    uint32_t offset = 0;
+    in.elements.read(reinterpret_cast<char*>(&blob_length), sizeof(uint32_t));
+    blob->resize(blob_length);
+    in.elements.read(reinterpret_cast<char*>(&offset), sizeof(uint32_t));
+    in.indirect.seekg(offset);
+    in.indirect.read(reinterpret_cast<char*>(&(*blob)[0]), blob->size());
+    return in;
+}
+
+template <typename T> InStreams& deserializeParamValue(InStreams& in, T* value) {
+    in.elements.read(reinterpret_cast<char*>(value), sizeof(T));
+    return in;
+}
+
+InStreams& deserialize(TAG_INVALID_t&&, InStreams& in, KeyParameter*) {
+    // there should be no invalid KeyParamaters but if handle them as zero sized.
+    return in;
+}
+
+template <typename T> InStreams& deserialize(T&& ttag, InStreams& in, KeyParameter* param) {
+    return deserializeParamValue(in, &accessTagValue(ttag, *param));
+}
+
+template <typename... T> struct choose_deserializer;
+template <typename... Tags> struct choose_deserializer<MetaList<Tags...>> {
+    static InStreams& deserialize(InStreams& in, KeyParameter* param) {
+        return choose_deserializer<Tags...>::deserialize(in, param);
+    }
+};
+template <> struct choose_deserializer<> {
+    static InStreams& deserialize(InStreams& in, KeyParameter*) {
+        // encountered an unknown tag -> fail parsing
+        in.elements.setstate(std::ios_base::badbit);
+        return in;
+    }
+};
+template <TagType tag_type, Tag tag, typename... Tail>
+struct choose_deserializer<TypedTag<tag_type, tag>, Tail...> {
+    static InStreams& deserialize(InStreams& in, KeyParameter* param) {
+        if (param->tag == tag) {
+            return V3_0::deserialize(TypedTag<tag_type, tag>(), in, param);
+        } else {
+            return choose_deserializer<Tail...>::deserialize(in, param);
+        }
+    }
+};
+
+InStreams& deserialize(InStreams& in, KeyParameter* param) {
+    in.elements.read(reinterpret_cast<char*>(&param->tag), sizeof(Tag));
+    return choose_deserializer<all_tags_t>::deserialize(in, param);
+}
+
+std::istream& deserialize(std::istream& in, std::vector<KeyParameter>* params) {
+    uint32_t indirect_size = 0;
+    in.read(reinterpret_cast<char*>(&indirect_size), sizeof(uint32_t));
+    std::string indirect_buffer(indirect_size, '\0');
+    if (indirect_buffer.size() != indirect_size) {
+        in.setstate(std::ios_base::badbit);
+        return in;
+    }
+    in.read(&indirect_buffer[0], indirect_buffer.size());
+
+    uint32_t element_count = 0;
+    in.read(reinterpret_cast<char*>(&element_count), sizeof(uint32_t));
+    uint32_t elements_size = 0;
+    in.read(reinterpret_cast<char*>(&elements_size), sizeof(uint32_t));
+
+    std::string elements_buffer(elements_size, '\0');
+    if (elements_buffer.size() != elements_size) {
+        in.setstate(std::ios_base::badbit);
+        return in;
+    }
+    in.read(&elements_buffer[0], elements_buffer.size());
+
+    if (in.bad()) return in;
+
+    // TODO write one-shot stream buffer to avoid copying here
+    std::stringstream indirect(indirect_buffer);
+    std::stringstream elements(elements_buffer);
+    InStreams streams = {indirect, elements};
+
+    params->resize(element_count);
+
+    for (uint32_t i = 0; i < element_count; ++i) {
+        deserialize(streams, &(*params)[i]);
+    }
+    return in;
+}
+
+void AuthorizationSet::Serialize(std::ostream* out) const {
+    serialize(*out, data_);
+}
+
+void AuthorizationSet::Deserialize(std::istream* in) {
+    deserialize(*in, &data_);
+}
+
+}  // namespace V3_0
+}  // namespace keymaster
+}  // namespace hardware
+}  // namespace android
diff --git a/keymaster/3.0/vts/functional/authorization_set.h b/keymaster/3.0/vts/functional/authorization_set.h
new file mode 100644
index 0000000..5f92d81
--- /dev/null
+++ b/keymaster/3.0/vts/functional/authorization_set.h
@@ -0,0 +1,420 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef HARDWARE_INTERFACES_KEYMASTER_30_VTS_FUNCTIONAL_AUTHORIZATION_SET_H_
+#define HARDWARE_INTERFACES_KEYMASTER_30_VTS_FUNCTIONAL_AUTHORIZATION_SET_H_
+
+#include "keymaster_tags.h"
+
+#include <utility>
+#include <vector>
+
+namespace android {
+namespace hardware {
+namespace keymaster {
+namespace V3_0 {
+
+class AuthorizationSetBuilder;
+
+/**
+ * An ordered collection of KeyParameters. It provides memory ownership and some convenient
+ * functionality for sorting, deduplicating, joining, and subtracting sets of KeyParameters.
+ * For serialization, wrap the backing store of this structure in a hidl_vec<KeyParameter>.
+ */
+class AuthorizationSet {
+  public:
+    typedef KeyParameter value_type;
+
+    /**
+     * Construct an empty, dynamically-allocated, growable AuthorizationSet.
+     */
+    AuthorizationSet(){};
+
+    // Copy constructor.
+    AuthorizationSet(const AuthorizationSet& other) : data_(other.data_) {}
+
+    // Move constructor.
+    AuthorizationSet(AuthorizationSet&& other) : data_(std::move(other.data_)) {}
+
+    // Constructor from hidl_vec<KeyParameter>
+    AuthorizationSet(const hidl_vec<KeyParameter>& other) { *this = other; }
+
+    // Copy assignment.
+    AuthorizationSet& operator=(const AuthorizationSet& other) {
+        data_ = other.data_;
+        return *this;
+    }
+
+    // Move assignment.
+    AuthorizationSet& operator=(AuthorizationSet&& other) {
+        data_ = std::move(other.data_);
+        return *this;
+    }
+
+    AuthorizationSet& operator=(const hidl_vec<KeyParameter>& other) {
+        if (other.size() > 0) {
+            data_.resize(other.size());
+            for (size_t i = 0; i < data_.size(); ++i) {
+                /* This makes a deep copy even of embedded blobs.
+                 * See assignment operator/copy constructor of hidl_vec.*/
+                data_[i] = other[i];
+            }
+        }
+        return *this;
+    }
+
+    /**
+     * Clear existing authorization set data
+     */
+    void Clear();
+
+    ~AuthorizationSet() = default;
+
+    /**
+     * Returns the size of the set.
+     */
+    size_t size() const { return data_.size(); }
+
+    /**
+     * Returns true if the set is empty.
+     */
+    bool empty() const { return size() == 0; }
+
+    /**
+     * Returns the data in the set, directly. Be careful with this.
+     */
+    const KeyParameter* data() const { return data_.data(); }
+
+    /**
+     * Sorts the set
+     */
+    void Sort();
+
+    /**
+     * Sorts the set and removes duplicates (inadvertently duplicating tags is easy to do with the
+     * AuthorizationSetBuilder).
+     */
+    void Deduplicate();
+
+    /**
+     * Adds all elements from \p set that are not already present in this AuthorizationSet.  As a
+     * side-effect, if \p set is not null this AuthorizationSet will end up sorted.
+     */
+    void Union(const AuthorizationSet& set);
+
+    /**
+     * Removes all elements in \p set from this AuthorizationSet.
+     */
+    void Subtract(const AuthorizationSet& set);
+
+    /**
+     * Returns the offset of the next entry that matches \p tag, starting from the element after \p
+     * begin.  If not found, returns -1.
+     */
+    int find(Tag tag, int begin = -1) const;
+
+    /**
+     * Removes the entry at the specified index. Returns true if successful, false if the index was
+     * out of bounds.
+     */
+    bool erase(int index);
+
+    /**
+     * Returns iterator (pointer) to beginning of elems array, to enable STL-style iteration
+     */
+    std::vector<KeyParameter>::const_iterator begin() const { return data_.begin(); }
+
+    /**
+     * Returns iterator (pointer) one past end of elems array, to enable STL-style iteration
+     */
+    std::vector<KeyParameter>::const_iterator end() const { return data_.end(); }
+
+    /**
+     * Returns the nth element of the set.
+     * Like for std::vector::operator[] there is no range check performed. Use of out of range
+     * indices is undefined.
+     */
+    KeyParameter& operator[](int n);
+
+    /**
+     * Returns the nth element of the set.
+     * Like for std::vector::operator[] there is no range check performed. Use of out of range
+     * indices is undefined.
+     */
+    const KeyParameter& operator[](int n) const;
+
+    /**
+     * Returns true if the set contains at least one instance of \p tag
+     */
+    bool Contains(Tag tag) const { return find(tag) != -1; }
+
+    template <typename T> bool Contains(T tag) const { return find(tag) != -1; }
+
+    template <TagType tag_type, Tag tag, typename ValueT>
+    bool Contains(TypedTag<tag_type, tag> ttag, const ValueT& value) const {
+        for (const auto& param : data_) {
+            auto entry = authorizationValue(ttag, param);
+            if (entry.isOk() && static_cast<ValueT>(entry.value()) == value) return true;
+        }
+        return false;
+    }
+    /**
+     * Returns the number of \p tag entries.
+     */
+    size_t GetTagCount(Tag tag) const;
+
+    template <typename T>
+    inline NullOr<const typename TypedTag2ValueType<T>::type&> GetTagValue(T tag) const {
+        auto entry = GetEntry(tag);
+        if (entry.isOk()) return authorizationValue(tag, entry.value());
+        return {};
+    }
+
+    void push_back(const KeyParameter& param) { data_.push_back(param); }
+    void push_back(KeyParameter&& param) { data_.push_back(std::move(param)); }
+
+    void push_back(const AuthorizationSet& set) {
+        for (auto& entry : set) {
+            push_back(entry);
+        }
+    }
+
+    void push_back(AuthorizationSet&& set) {
+        move(set.begin(), set.end());
+        set.Clear();
+    }
+
+    template <Tag tag>
+    void push_back(TypedTag<TagType::BYTES, tag> ttag, const uint8_t* data, size_t data_length) {
+        hidl_vec<uint8_t> new_blob;
+        new_blob.setToExternal(const_cast<uint8_t*>(data), data_length);
+        push_back(ttag, std::move(new_blob));
+    }
+
+    /**
+     * Append the tag and enumerated value to the set.
+     * "val" may be exactly one parameter unless a boolean parameter is added.
+     * In this case "val" is omitted. This condition is checked at compile time by Authorization()
+     */
+    template <typename TypedTagT, typename... Value> void push_back(TypedTagT tag, Value&&... val) {
+        push_back(Authorization(tag, std::forward<Value>(val)...));
+    }
+
+    template <typename Iterator> void push_back(Iterator begin, Iterator end) {
+        while (begin != end) {
+            push_back(*begin);
+            ++begin;
+        }
+    }
+
+    template <typename Iterator> void move(Iterator begin, Iterator end) {
+        std::move(begin, end, std::back_inserter(data_));
+    }
+
+    hidl_vec<KeyParameter> hidl_data() const {
+        hidl_vec<KeyParameter> result;
+        result.setToExternal(const_cast<KeyParameter*>(data()), size());
+        return result;
+    }
+
+    void Serialize(std::ostream* out) const;
+    void Deserialize(std::istream* in);
+
+  private:
+    NullOr<const KeyParameter&> GetEntry(Tag tag) const;
+
+    std::vector<KeyParameter> data_;
+};
+
+class AuthorizationSetBuilder : public AuthorizationSet {
+  public:
+    template <typename TagType, typename... ValueType>
+    AuthorizationSetBuilder& Authorization(TagType ttag, ValueType&&... value) {
+        push_back(ttag, std::forward<ValueType>(value)...);
+        return *this;
+    }
+
+    template <Tag tag>
+    AuthorizationSetBuilder& Authorization(TypedTag<TagType::BYTES, tag> ttag, const uint8_t* data,
+                                           size_t data_length) {
+        hidl_vec<uint8_t> new_blob;
+        new_blob.setToExternal(const_cast<uint8_t*>(data), data_length);
+        push_back(ttag, std::move(new_blob));
+        return *this;
+    }
+
+    template <Tag tag>
+    AuthorizationSetBuilder& Authorization(TypedTag<TagType::BYTES, tag> ttag, const char* data,
+                                           size_t data_length) {
+        return Authorization(ttag, reinterpret_cast<const uint8_t*>(data), data_length);
+    }
+
+    AuthorizationSetBuilder& Authorizations(AuthorizationSet&& set);
+    AuthorizationSetBuilder& Authorizations(const AuthorizationSet& set);
+
+    AuthorizationSetBuilder& RsaKey(uint32_t key_size, uint64_t public_exponent);
+    AuthorizationSetBuilder& EcdsaKey(uint32_t key_size);
+    AuthorizationSetBuilder& EcdsaKey(EcCurve curve);
+    AuthorizationSetBuilder& AesKey(uint32_t key_size);
+    AuthorizationSetBuilder& HmacKey(uint32_t key_size);
+
+    AuthorizationSetBuilder& RsaSigningKey(uint32_t key_size, uint64_t public_exponent);
+    AuthorizationSetBuilder& RsaEncryptionKey(uint32_t key_size, uint64_t public_exponent);
+    AuthorizationSetBuilder& EcdsaSigningKey(uint32_t key_size);
+    AuthorizationSetBuilder& EcdsaSigningKey(EcCurve curve);
+    AuthorizationSetBuilder& AesEncryptionKey(uint32_t key_size);
+
+    AuthorizationSetBuilder& SigningKey();
+    AuthorizationSetBuilder& EncryptionKey();
+    AuthorizationSetBuilder& NoDigestOrPadding();
+    AuthorizationSetBuilder& EcbMode();
+
+    AuthorizationSetBuilder& BlockMode(std::initializer_list<BlockMode> block_modes);
+    AuthorizationSetBuilder& Digest(std::initializer_list<Digest> digests);
+    AuthorizationSetBuilder& Padding(std::initializer_list<PaddingMode> padding_modes);
+
+    // The following forwarding templates enable BlockMode,Digest and Padding to be called with a
+    // variable number of arguments; no need to wrap them in braces to make them an initalizer_list.
+    template <typename... T> AuthorizationSetBuilder& BlockMode(T&&... a) {
+        return BlockMode({std::forward<T>(a)...});
+    }
+    template <typename... T> AuthorizationSetBuilder& Digest(T&&... a) {
+        return Digest({std::forward<T>(a)...});
+    }
+    template <typename... T> AuthorizationSetBuilder& Padding(T&&... a) {
+        return Padding({std::forward<T>(a)...});
+    }
+};
+
+inline AuthorizationSetBuilder& AuthorizationSetBuilder::Authorizations(AuthorizationSet&& set) {
+    move(set.begin(), set.end());
+    set.Clear();
+    return *this;
+}
+
+inline AuthorizationSetBuilder&
+AuthorizationSetBuilder::Authorizations(const AuthorizationSet& set) {
+    push_back(set.begin(), set.end());
+    return *this;
+}
+
+inline AuthorizationSetBuilder& AuthorizationSetBuilder::RsaKey(uint32_t key_size,
+                                                                uint64_t public_exponent) {
+    Authorization(TAG_ALGORITHM, Algorithm::RSA);
+    Authorization(TAG_KEY_SIZE, key_size);
+    Authorization(TAG_RSA_PUBLIC_EXPONENT, public_exponent);
+    return *this;
+}
+
+inline AuthorizationSetBuilder& AuthorizationSetBuilder::EcdsaKey(uint32_t key_size) {
+    Authorization(TAG_ALGORITHM, Algorithm::EC);
+    Authorization(TAG_KEY_SIZE, key_size);
+    return *this;
+}
+
+inline AuthorizationSetBuilder& AuthorizationSetBuilder::EcdsaKey(EcCurve curve) {
+    Authorization(TAG_ALGORITHM, Algorithm::EC);
+    Authorization(TAG_EC_CURVE, curve);
+    return *this;
+}
+
+inline AuthorizationSetBuilder& AuthorizationSetBuilder::AesKey(uint32_t key_size) {
+    Authorization(TAG_ALGORITHM, Algorithm::AES);
+    return Authorization(TAG_KEY_SIZE, key_size);
+}
+
+inline AuthorizationSetBuilder& AuthorizationSetBuilder::HmacKey(uint32_t key_size) {
+    Authorization(TAG_ALGORITHM, Algorithm::HMAC);
+    Authorization(TAG_KEY_SIZE, key_size);
+    return SigningKey();
+}
+
+inline AuthorizationSetBuilder& AuthorizationSetBuilder::RsaSigningKey(uint32_t key_size,
+                                                                       uint64_t public_exponent) {
+    RsaKey(key_size, public_exponent);
+    return SigningKey();
+}
+
+inline AuthorizationSetBuilder&
+AuthorizationSetBuilder::RsaEncryptionKey(uint32_t key_size, uint64_t public_exponent) {
+    RsaKey(key_size, public_exponent);
+    return EncryptionKey();
+}
+
+inline AuthorizationSetBuilder& AuthorizationSetBuilder::EcdsaSigningKey(uint32_t key_size) {
+    EcdsaKey(key_size);
+    return SigningKey();
+}
+
+inline AuthorizationSetBuilder& AuthorizationSetBuilder::EcdsaSigningKey(EcCurve curve) {
+    EcdsaKey(curve);
+    return SigningKey();
+}
+
+inline AuthorizationSetBuilder& AuthorizationSetBuilder::AesEncryptionKey(uint32_t key_size) {
+    AesKey(key_size);
+    return EncryptionKey();
+}
+
+inline AuthorizationSetBuilder& AuthorizationSetBuilder::SigningKey() {
+    Authorization(TAG_PURPOSE, KeyPurpose::SIGN);
+    return Authorization(TAG_PURPOSE, KeyPurpose::VERIFY);
+}
+
+inline AuthorizationSetBuilder& AuthorizationSetBuilder::EncryptionKey() {
+    Authorization(TAG_PURPOSE, KeyPurpose::ENCRYPT);
+    return Authorization(TAG_PURPOSE, KeyPurpose::DECRYPT);
+}
+
+inline AuthorizationSetBuilder& AuthorizationSetBuilder::NoDigestOrPadding() {
+    Authorization(TAG_DIGEST, Digest::NONE);
+    return Authorization(TAG_PADDING, PaddingMode::NONE);
+}
+
+inline AuthorizationSetBuilder& AuthorizationSetBuilder::EcbMode() {
+    return BlockMode(BlockMode::ECB);
+}
+
+inline AuthorizationSetBuilder&
+AuthorizationSetBuilder::BlockMode(std::initializer_list<V3_0::BlockMode> block_modes) {
+    for (auto block_mode : block_modes) {
+        Authorization(TAG_BLOCK_MODE, block_mode);
+    }
+    return *this;
+}
+
+inline AuthorizationSetBuilder&
+AuthorizationSetBuilder::Digest(std::initializer_list<V3_0::Digest> digests) {
+    for (auto digest : digests) {
+        Authorization(TAG_DIGEST, digest);
+    }
+    return *this;
+}
+
+inline AuthorizationSetBuilder&
+AuthorizationSetBuilder::Padding(std::initializer_list<V3_0::PaddingMode> padding_modes) {
+    for (auto padding : padding_modes) {
+        Authorization(TAG_PADDING, padding);
+    }
+    return *this;
+}
+
+}  // namespace V3_0
+}  // namespace keymaster
+}  // namespace hardware
+}  // namespace android
+
+#endif  // HARDWARE_INTERFACES_KEYMASTER_30_VTS_FUNCTIONAL_AUTHORIZATION_SET_H_
diff --git a/keymaster/3.0/vts/functional/key_param_output.cpp b/keymaster/3.0/vts/functional/key_param_output.cpp
new file mode 100644
index 0000000..fc9f685
--- /dev/null
+++ b/keymaster/3.0/vts/functional/key_param_output.cpp
@@ -0,0 +1,131 @@
+/*
+ * 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 "key_param_output.h"
+
+#include <iomanip>
+
+namespace android {
+namespace hardware {
+
+namespace keymaster {
+namespace V3_0 {
+
+::std::ostream& operator<<(::std::ostream& os, const hidl_vec<KeyParameter>& set) {
+    if (set.size() == 0) {
+        os << "(Empty)" << ::std::endl;
+    } else {
+        os << "\n";
+        for (size_t i = 0; i < set.size(); ++i)
+            os << set[i] << ::std::endl;
+    }
+    return os;
+}
+
+::std::ostream& operator<<(::std::ostream& os, ErrorCode value) {
+    return os << (int)value;
+}
+
+::std::ostream& operator<<(::std::ostream& os, Digest value) {
+    return os << stringify(value);
+}
+
+::std::ostream& operator<<(::std::ostream& os, Algorithm value) {
+    return os << stringify(value);
+}
+
+::std::ostream& operator<<(::std::ostream& os, BlockMode value) {
+    return os << stringify(value);
+}
+
+::std::ostream& operator<<(::std::ostream& os, PaddingMode value) {
+    return os << stringify(value);
+}
+
+::std::ostream& operator<<(::std::ostream& os, KeyOrigin value) {
+    return os << stringify(value);
+}
+
+::std::ostream& operator<<(::std::ostream& os, KeyPurpose value) {
+    return os << stringify(value);
+}
+
+::std::ostream& operator<<(::std::ostream& os, EcCurve value) {
+    return os << stringify(value);
+}
+
+::std::ostream& operator<<(::std::ostream& os, const KeyParameter& param) {
+    os << stringifyTag(param.tag) << ": ";
+    switch (typeFromTag(param.tag)) {
+    case TagType::INVALID:
+        return os << " Invalid";
+    case TagType::UINT_REP:
+    case TagType::UINT:
+        return os << param.f.integer;
+    case TagType::ENUM_REP:
+    case TagType::ENUM:
+        switch (param.tag) {
+        case Tag::ALGORITHM:
+            return os << param.f.algorithm;
+        case Tag::BLOCK_MODE:
+            return os << param.f.blockMode;
+        case Tag::PADDING:
+            return os << param.f.paddingMode;
+        case Tag::DIGEST:
+            return os << param.f.digest;
+        case Tag::EC_CURVE:
+            return os << (int)param.f.ecCurve;
+        case Tag::ORIGIN:
+            return os << param.f.origin;
+        case Tag::BLOB_USAGE_REQUIREMENTS:
+            return os << (int)param.f.keyBlobUsageRequirements;
+        case Tag::PURPOSE:
+            return os << param.f.purpose;
+        default:
+            return os << " UNKNOWN ENUM " << param.f.integer;
+        }
+    case TagType::ULONG_REP:
+    case TagType::ULONG:
+        return os << param.f.longInteger;
+    case TagType::DATE:
+        return os << param.f.dateTime;
+    case TagType::BOOL:
+        return os << "true";
+    case TagType::BIGNUM:
+        os << " Bignum: ";
+        for (size_t i = 0; i < param.blob.size(); ++i) {
+            os << ::std::hex << ::std::setw(2) << static_cast<int>(param.blob[i]) << ::std::dec;
+        }
+        return os;
+    case TagType::BYTES:
+        os << " Bytes: ";
+        for (size_t i = 0; i < param.blob.size(); ++i) {
+            os << ::std::hex << ::std::setw(2) << static_cast<int>(param.blob[i]) << ::std::dec;
+        }
+        return os;
+    }
+    return os << "UNKNOWN TAG TYPE!";
+}
+
+::std::ostream& operator<<(::std::ostream& os, const KeyCharacteristics& chars) {
+    return os << "SW: " << chars.softwareEnforced << ::std::endl
+              << "TEE: " << chars.teeEnforced << ::std::endl;
+}
+
+}  // namespace V3_0
+}  // namespace keymaster
+}  // namespace hardware
+}  // namespace android
diff --git a/keymaster/3.0/vts/functional/key_param_output.h b/keymaster/3.0/vts/functional/key_param_output.h
new file mode 100644
index 0000000..5edec2d
--- /dev/null
+++ b/keymaster/3.0/vts/functional/key_param_output.h
@@ -0,0 +1,50 @@
+/*
+ * 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 <android/hardware/keymaster/3.0/types.h>
+
+#include "keymaster_tags.h"
+
+namespace android {
+namespace hardware {
+namespace keymaster {
+namespace V3_0 {
+
+template <typename ValueT>
+::std::ostream& operator<<(::std::ostream& os, const NullOr<ValueT>& value) {
+    if (!value.isOk()) {
+        os << "(value not present)";
+    } else {
+        os << value.value();
+    }
+    return os;
+}
+
+::std::ostream& operator<<(::std::ostream& os, const hidl_vec<KeyParameter>& set);
+::std::ostream& operator<<(::std::ostream& os, BlockMode value);
+::std::ostream& operator<<(::std::ostream& os, Digest value);
+::std::ostream& operator<<(::std::ostream& os, EcCurve value);
+::std::ostream& operator<<(::std::ostream& os, ErrorCode value);
+::std::ostream& operator<<(::std::ostream& os, PaddingMode value);
+::std::ostream& operator<<(::std::ostream& os, const KeyCharacteristics& value);
+::std::ostream& operator<<(::std::ostream& os, const KeyParameter& value);
+
+}  // namespace V3_0
+}  // namespace keymaster
+}  // namespace hardware
+}  // namespace android
diff --git a/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp b/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp
new file mode 100644
index 0000000..2382f0b
--- /dev/null
+++ b/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp
@@ -0,0 +1,3911 @@
+/*
+ * 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 "keymaster_hidl_hal_test"
+#include <cutils/log.h>
+
+#include <iostream>
+
+#include <openssl/evp.h>
+#include <openssl/x509.h>
+
+#include <android/hardware/keymaster/3.0/IKeymasterDevice.h>
+#include <android/hardware/keymaster/3.0/types.h>
+
+#include <cutils/properties.h>
+
+#include <keymaster/keymaster_configuration.h>
+
+#include "authorization_set.h"
+#include "key_param_output.h"
+
+#include <VtsHalHidlTargetTestBase.h>
+
+#include "attestation_record.h"
+#include "openssl_utils.h"
+
+using ::android::sp;
+
+using ::std::string;
+
+// This service_name will be passed to getService when retrieving the keymaster service to test.  To
+// change it from "default" specify the selected service name on the command line.  The first
+// non-gtest argument will be used as the service name.
+string service_name = "default";
+
+namespace android {
+namespace hardware {
+
+template <typename T> bool operator==(const hidl_vec<T>& a, const hidl_vec<T>& b) {
+    if (a.size() != b.size()) {
+        return false;
+    }
+    for (size_t i = 0; i < a.size(); ++i) {
+        if (a[i] != b[i]) {
+            return false;
+        }
+    }
+    return true;
+}
+
+namespace keymaster {
+namespace V3_0 {
+
+bool operator==(const KeyParameter& a, const KeyParameter& b) {
+    if (a.tag != b.tag) {
+        return false;
+    }
+
+    switch (a.tag) {
+
+    /* Boolean tags */
+    case Tag::INVALID:
+    case Tag::CALLER_NONCE:
+    case Tag::INCLUDE_UNIQUE_ID:
+    case Tag::ECIES_SINGLE_HASH_MODE:
+    case Tag::BOOTLOADER_ONLY:
+    case Tag::NO_AUTH_REQUIRED:
+    case Tag::ALLOW_WHILE_ON_BODY:
+    case Tag::EXPORTABLE:
+    case Tag::ALL_APPLICATIONS:
+    case Tag::ROLLBACK_RESISTANT:
+    case Tag::RESET_SINCE_ID_ROTATION:
+        return true;
+
+    /* Integer tags */
+    case Tag::KEY_SIZE:
+    case Tag::MIN_MAC_LENGTH:
+    case Tag::MIN_SECONDS_BETWEEN_OPS:
+    case Tag::MAX_USES_PER_BOOT:
+    case Tag::ALL_USERS:
+    case Tag::USER_ID:
+    case Tag::OS_VERSION:
+    case Tag::OS_PATCHLEVEL:
+    case Tag::MAC_LENGTH:
+    case Tag::AUTH_TIMEOUT:
+        return a.f.integer == b.f.integer;
+
+    /* Long integer tags */
+    case Tag::RSA_PUBLIC_EXPONENT:
+    case Tag::USER_SECURE_ID:
+        return a.f.longInteger == b.f.longInteger;
+
+    /* Date-time tags */
+    case Tag::ACTIVE_DATETIME:
+    case Tag::ORIGINATION_EXPIRE_DATETIME:
+    case Tag::USAGE_EXPIRE_DATETIME:
+    case Tag::CREATION_DATETIME:
+        return a.f.dateTime == b.f.dateTime;
+
+    /* Bytes tags */
+    case Tag::APPLICATION_ID:
+    case Tag::APPLICATION_DATA:
+    case Tag::ROOT_OF_TRUST:
+    case Tag::UNIQUE_ID:
+    case Tag::ATTESTATION_CHALLENGE:
+    case Tag::ATTESTATION_APPLICATION_ID:
+    case Tag::ATTESTATION_ID_BRAND:
+    case Tag::ATTESTATION_ID_DEVICE:
+    case Tag::ATTESTATION_ID_PRODUCT:
+    case Tag::ATTESTATION_ID_SERIAL:
+    case Tag::ATTESTATION_ID_IMEI:
+    case Tag::ATTESTATION_ID_MEID:
+    case Tag::ATTESTATION_ID_MANUFACTURER:
+    case Tag::ATTESTATION_ID_MODEL:
+    case Tag::ASSOCIATED_DATA:
+    case Tag::NONCE:
+    case Tag::AUTH_TOKEN:
+        return a.blob == b.blob;
+
+    /* Enum tags */
+    case Tag::PURPOSE:
+        return a.f.purpose == b.f.purpose;
+    case Tag::ALGORITHM:
+        return a.f.algorithm == b.f.algorithm;
+    case Tag::BLOCK_MODE:
+        return a.f.blockMode == b.f.blockMode;
+    case Tag::DIGEST:
+        return a.f.digest == b.f.digest;
+    case Tag::PADDING:
+        return a.f.paddingMode == b.f.paddingMode;
+    case Tag::EC_CURVE:
+        return a.f.ecCurve == b.f.ecCurve;
+    case Tag::BLOB_USAGE_REQUIREMENTS:
+        return a.f.keyBlobUsageRequirements == b.f.keyBlobUsageRequirements;
+    case Tag::USER_AUTH_TYPE:
+        return a.f.integer == b.f.integer;
+    case Tag::ORIGIN:
+        return a.f.origin == b.f.origin;
+
+    /* Unsupported tags */
+    case Tag::KDF:
+        return false;
+    }
+}
+
+bool operator==(const AuthorizationSet& a, const AuthorizationSet& b) {
+    return a.size() == b.size() && std::equal(a.begin(), a.end(), b.begin());
+}
+
+bool operator==(const KeyCharacteristics& a, const KeyCharacteristics& b) {
+    // This isn't very efficient. Oh, well.
+    AuthorizationSet a_sw(a.softwareEnforced);
+    AuthorizationSet b_sw(b.softwareEnforced);
+    AuthorizationSet a_tee(b.teeEnforced);
+    AuthorizationSet b_tee(b.teeEnforced);
+
+    a_sw.Sort();
+    b_sw.Sort();
+    a_tee.Sort();
+    b_tee.Sort();
+
+    return a_sw == b_sw && a_tee == b_sw;
+}
+
+::std::ostream& operator<<(::std::ostream& os, const AuthorizationSet& set) {
+    if (set.size() == 0)
+        os << "(Empty)" << ::std::endl;
+    else {
+        os << "\n";
+        for (size_t i = 0; i < set.size(); ++i)
+            os << set[i] << ::std::endl;
+    }
+    return os;
+}
+
+namespace test {
+namespace {
+
+template <TagType tag_type, Tag tag, typename ValueT>
+bool contains(hidl_vec<KeyParameter>& set, TypedTag<tag_type, tag> ttag, ValueT expected_value) {
+    size_t count = std::count_if(set.begin(), set.end(), [&](const KeyParameter& param) {
+        return param.tag == tag && accessTagValue(ttag, param) == expected_value;
+    });
+    return count == 1;
+}
+
+template <TagType tag_type, Tag tag>
+bool contains(hidl_vec<KeyParameter>& set, TypedTag<tag_type, tag>) {
+    size_t count = std::count_if(set.begin(), set.end(),
+                                 [&](const KeyParameter& param) { return param.tag == tag; });
+    return count > 0;
+}
+
+constexpr char hex_value[256] = {0, 0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0,  //
+                                 0, 0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0,  //
+                                 0, 0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0,  //
+                                 0, 1,  2,  3,  4,  5,  6,  7, 8, 9, 0, 0, 0, 0, 0, 0,  // '0'..'9'
+                                 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0,  // 'A'..'F'
+                                 0, 0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0,  //
+                                 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0,  // 'a'..'f'
+                                 0, 0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0,  //
+                                 0, 0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0,  //
+                                 0, 0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0,  //
+                                 0, 0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0,  //
+                                 0, 0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0,  //
+                                 0, 0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0,  //
+                                 0, 0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0,  //
+                                 0, 0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0,  //
+                                 0, 0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0};
+
+string hex2str(string a) {
+    string b;
+    size_t num = a.size() / 2;
+    b.resize(num);
+    for (size_t i = 0; i < num; i++) {
+        b[i] = (hex_value[a[i * 2] & 0xFF] << 4) + (hex_value[a[i * 2 + 1] & 0xFF]);
+    }
+    return b;
+}
+
+string rsa_key = hex2str("30820275020100300d06092a864886f70d01010105000482025f3082025b"
+                         "02010002818100c6095409047d8634812d5a218176e45c41d60a75b13901"
+                         "f234226cffe776521c5a77b9e389417b71c0b6a44d13afe4e4a2805d46c9"
+                         "da2935adb1ff0c1f24ea06e62b20d776430a4d435157233c6f916783c30e"
+                         "310fcbd89b85c2d56771169785ac12bca244abda72bfb19fc44d27c81e1d"
+                         "92de284f4061edfd99280745ea6d2502030100010281801be0f04d9cae37"
+                         "18691f035338308e91564b55899ffb5084d2460e6630257e05b3ceab0297"
+                         "2dfabcd6ce5f6ee2589eb67911ed0fac16e43a444b8c861e544a05933657"
+                         "72f8baf6b22fc9e3c5f1024b063ac080a7b2234cf8aee8f6c47bbf4fd3ac"
+                         "e7240290bef16c0b3f7f3cdd64ce3ab5912cf6e32f39ab188358afcccd80"
+                         "81024100e4b49ef50f765d3b24dde01aceaaf130f2c76670a91a61ae08af"
+                         "497b4a82be6dee8fcdd5e3f7ba1cfb1f0c926b88f88c92bfab137fba2285"
+                         "227b83c342ff7c55024100ddabb5839c4c7f6bf3d4183231f005b31aa58a"
+                         "ffdda5c79e4cce217f6bc930dbe563d480706c24e9ebfcab28a6cdefd324"
+                         "b77e1bf7251b709092c24ff501fd91024023d4340eda3445d8cd26c14411"
+                         "da6fdca63c1ccd4b80a98ad52b78cc8ad8beb2842c1d280405bc2f6c1bea"
+                         "214a1d742ab996b35b63a82a5e470fa88dbf823cdd02401b7b57449ad30d"
+                         "1518249a5f56bb98294d4b6ac12ffc86940497a5a5837a6cf946262b4945"
+                         "26d328c11e1126380fde04c24f916dec250892db09a6d77cdba351024077"
+                         "62cd8f4d050da56bd591adb515d24d7ccd32cca0d05f866d583514bd7324"
+                         "d5f33645e8ed8b4a1cb3cc4a1d67987399f2a09f5b3fb68c88d5e5d90ac3"
+                         "3492d6");
+
+string ec_key = hex2str("308187020100301306072a8648ce3d020106082a8648ce3d030107046d30"
+                        "6b0201010420737c2ecd7b8d1940bf2930aa9b4ed3ff941eed09366bc032"
+                        "99986481f3a4d859a14403420004bf85d7720d07c25461683bc648b4778a"
+                        "9a14dd8a024e3bdd8c7ddd9ab2b528bbc7aa1b51f14ebbbb0bd0ce21bcc4"
+                        "1c6eb00083cf3376d11fd44949e0b2183bfe");
+
+struct RSA_Delete {
+    void operator()(RSA* p) { RSA_free(p); }
+};
+
+X509* parse_cert_blob(const hidl_vec<uint8_t>& blob) {
+    const uint8_t* p = blob.data();
+    return d2i_X509(nullptr, &p, blob.size());
+}
+
+bool verify_chain(const hidl_vec<hidl_vec<uint8_t>>& chain) {
+    for (size_t i = 0; i < chain.size() - 1; ++i) {
+        auto& key_cert_blob = chain[i];
+        auto& signing_cert_blob = chain[i + 1];
+
+        X509_Ptr key_cert(parse_cert_blob(key_cert_blob));
+        X509_Ptr signing_cert(parse_cert_blob(signing_cert_blob));
+        EXPECT_TRUE(!!key_cert.get() && !!signing_cert.get());
+        if (!key_cert.get() || !signing_cert.get()) return false;
+
+        EVP_PKEY_Ptr signing_pubkey(X509_get_pubkey(signing_cert.get()));
+        EXPECT_TRUE(!!signing_pubkey.get());
+        if (!signing_pubkey.get()) return false;
+
+        EXPECT_EQ(1, X509_verify(key_cert.get(), signing_pubkey.get()))
+            << "Verification of certificate " << i << " failed";
+    }
+
+    return true;
+}
+
+// Extract attestation record from cert. Returned object is still part of cert; don't free it
+// separately.
+ASN1_OCTET_STRING* get_attestation_record(X509* certificate) {
+    ASN1_OBJECT_Ptr oid(OBJ_txt2obj(kAttestionRecordOid, 1 /* dotted string format */));
+    EXPECT_TRUE(!!oid.get());
+    if (!oid.get()) return nullptr;
+
+    int location = X509_get_ext_by_OBJ(certificate, oid.get(), -1 /* search from beginning */);
+    EXPECT_NE(-1, location);
+    if (location == -1) return nullptr;
+
+    X509_EXTENSION* attest_rec_ext = X509_get_ext(certificate, location);
+    EXPECT_TRUE(!!attest_rec_ext);
+    if (!attest_rec_ext) return nullptr;
+
+    ASN1_OCTET_STRING* attest_rec = X509_EXTENSION_get_data(attest_rec_ext);
+    EXPECT_TRUE(!!attest_rec);
+    return attest_rec;
+}
+
+bool tag_in_list(const KeyParameter& entry) {
+    // Attestations don't contain everything in key authorization lists, so we need to filter
+    // the key lists to produce the lists that we expect to match the attestations.
+    auto tag_list = {
+        Tag::USER_ID, Tag::INCLUDE_UNIQUE_ID, Tag::BLOB_USAGE_REQUIREMENTS,
+        Tag::EC_CURVE /* Tag::EC_CURVE will be included by KM2 implementations */,
+    };
+    return std::find(tag_list.begin(), tag_list.end(), entry.tag) != tag_list.end();
+}
+
+AuthorizationSet filter_tags(const AuthorizationSet& set) {
+    AuthorizationSet filtered;
+    std::remove_copy_if(set.begin(), set.end(), std::back_inserter(filtered), tag_in_list);
+    return filtered;
+}
+
+std::string make_string(const uint8_t* data, size_t length) {
+    return std::string(reinterpret_cast<const char*>(data), length);
+}
+
+template <size_t N> std::string make_string(const uint8_t (&a)[N]) {
+    return make_string(a, N);
+}
+
+class HidlBuf : public hidl_vec<uint8_t> {
+    typedef hidl_vec<uint8_t> super;
+
+  public:
+    HidlBuf() {}
+    HidlBuf(const super& other) : super(other) {}
+    HidlBuf(super&& other) : super(std::move(other)) {}
+    explicit HidlBuf(const std::string& other) : HidlBuf() { *this = other; }
+
+    HidlBuf& operator=(const super& other) {
+        super::operator=(other);
+        return *this;
+    }
+
+    HidlBuf& operator=(super&& other) {
+        super::operator=(std::move(other));
+        return *this;
+    }
+
+    HidlBuf& operator=(const string& other) {
+        resize(other.size());
+        for (size_t i = 0; i < other.size(); ++i) {
+            (*this)[i] = static_cast<uint8_t>(other[i]);
+        }
+        return *this;
+    }
+
+    string to_string() const { return string(reinterpret_cast<const char*>(data()), size()); }
+};
+
+constexpr uint64_t kOpHandleSentinel = 0xFFFFFFFFFFFFFFFF;
+
+}  // namespace
+
+class KeymasterHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+  public:
+    void TearDown() override {
+        if (key_blob_.size()) {
+            EXPECT_EQ(ErrorCode::OK, DeleteKey());
+        }
+        AbortIfNeeded();
+    }
+
+    // SetUpTestCase runs only once per test case, not once per test.
+    static void SetUpTestCase() {
+        keymaster_ = IKeymasterDevice::getService(service_name);
+        ASSERT_NE(keymaster_, nullptr);
+
+        ASSERT_TRUE(
+            keymaster_
+                ->getHardwareFeatures([&](bool isSecure, bool supportsEc, bool supportsSymmetric,
+                                          bool supportsAttestation, bool supportsAllDigests,
+                                          const hidl_string& name, const hidl_string& author) {
+                    is_secure_ = isSecure;
+                    supports_ec_ = supportsEc;
+                    supports_symmetric_ = supportsSymmetric;
+                    supports_attestation_ = supportsAttestation;
+                    supports_all_digests_ = supportsAllDigests;
+                    name_ = name;
+                    author_ = author;
+                })
+                .isOk());
+
+        os_version_ = ::keymaster::GetOsVersion();
+        os_patch_level_ = ::keymaster::GetOsPatchlevel();
+    }
+
+    static void TearDownTestCase() { keymaster_.clear(); }
+
+    static IKeymasterDevice& keymaster() { return *keymaster_; }
+    static uint32_t os_version() { return os_version_; }
+    static uint32_t os_patch_level() { return os_patch_level_; }
+
+    AuthorizationSet UserAuths() { return AuthorizationSetBuilder().Authorization(TAG_USER_ID, 7); }
+
+    ErrorCode GenerateKey(const AuthorizationSet& key_desc, HidlBuf* key_blob,
+                          KeyCharacteristics* key_characteristics) {
+        EXPECT_NE(key_blob, nullptr);
+        EXPECT_NE(key_characteristics, nullptr);
+        EXPECT_EQ(0U, key_blob->size());
+
+        ErrorCode error;
+        EXPECT_TRUE(keymaster_
+                        ->generateKey(key_desc.hidl_data(),
+                                      [&](ErrorCode hidl_error, const HidlBuf& hidl_key_blob,
+                                          const KeyCharacteristics& hidl_key_characteristics) {
+                                          error = hidl_error;
+                                          *key_blob = hidl_key_blob;
+                                          *key_characteristics = hidl_key_characteristics;
+                                      })
+                        .isOk());
+        // On error, blob & characteristics should be empty.
+        if (error != ErrorCode::OK) {
+            EXPECT_EQ(0U, key_blob->size());
+            EXPECT_EQ(0U, (key_characteristics->softwareEnforced.size() +
+                           key_characteristics->teeEnforced.size()));
+        }
+        return error;
+    }
+
+    ErrorCode GenerateKey(const AuthorizationSet& key_desc) {
+        return GenerateKey(key_desc, &key_blob_, &key_characteristics_);
+    }
+
+    ErrorCode ImportKey(const AuthorizationSet& key_desc, KeyFormat format,
+                        const string& key_material, HidlBuf* key_blob,
+                        KeyCharacteristics* key_characteristics) {
+        ErrorCode error;
+        EXPECT_TRUE(keymaster_
+                        ->importKey(key_desc.hidl_data(), format, HidlBuf(key_material),
+                                    [&](ErrorCode hidl_error, const HidlBuf& hidl_key_blob,
+                                        const KeyCharacteristics& hidl_key_characteristics) {
+                                        error = hidl_error;
+                                        *key_blob = hidl_key_blob;
+                                        *key_characteristics = hidl_key_characteristics;
+                                    })
+                        .isOk());
+        // On error, blob & characteristics should be empty.
+        if (error != ErrorCode::OK) {
+            EXPECT_EQ(0U, key_blob->size());
+            EXPECT_EQ(0U, (key_characteristics->softwareEnforced.size() +
+                           key_characteristics->teeEnforced.size()));
+        }
+        return error;
+    }
+
+    ErrorCode ImportKey(const AuthorizationSet& key_desc, KeyFormat format,
+                        const string& key_material) {
+        return ImportKey(key_desc, format, key_material, &key_blob_, &key_characteristics_);
+    }
+
+    ErrorCode ExportKey(KeyFormat format, const HidlBuf& key_blob, const HidlBuf& client_id,
+                        const HidlBuf& app_data, HidlBuf* key_material) {
+        ErrorCode error;
+        EXPECT_TRUE(
+            keymaster_
+                ->exportKey(format, key_blob, client_id, app_data,
+                            [&](ErrorCode hidl_error_code, const HidlBuf& hidl_key_material) {
+                                error = hidl_error_code;
+                                *key_material = hidl_key_material;
+                            })
+                .isOk());
+        // On error, blob should be empty.
+        if (error != ErrorCode::OK) {
+            EXPECT_EQ(0U, key_material->size());
+        }
+        return error;
+    }
+
+    ErrorCode ExportKey(KeyFormat format, HidlBuf* key_material) {
+        HidlBuf client_id, app_data;
+        return ExportKey(format, key_blob_, client_id, app_data, key_material);
+    }
+
+    ErrorCode DeleteKey(HidlBuf* key_blob) {
+        ErrorCode error = keymaster_->deleteKey(*key_blob);
+        *key_blob = HidlBuf();
+        return error;
+    }
+
+    ErrorCode DeleteKey() { return DeleteKey(&key_blob_); }
+
+    ErrorCode GetCharacteristics(const HidlBuf& key_blob, const HidlBuf& client_id,
+                                 const HidlBuf& app_data, KeyCharacteristics* key_characteristics) {
+        ErrorCode error;
+        keymaster_->getKeyCharacteristics(
+            key_blob, client_id, app_data,
+            [&](ErrorCode hidl_error, const KeyCharacteristics& hidl_key_characteristics) {
+                error = hidl_error, *key_characteristics = hidl_key_characteristics;
+            });
+        return error;
+    }
+
+    ErrorCode GetCharacteristics(const HidlBuf& key_blob, KeyCharacteristics* key_characteristics) {
+        HidlBuf client_id, app_data;
+        return GetCharacteristics(key_blob, client_id, app_data, key_characteristics);
+    }
+
+    ErrorCode Begin(KeyPurpose purpose, const HidlBuf& key_blob, const AuthorizationSet& in_params,
+                    AuthorizationSet* out_params, OperationHandle* op_handle) {
+        SCOPED_TRACE("Begin");
+        ErrorCode error;
+        OperationHandle saved_handle = *op_handle;
+        EXPECT_TRUE(
+            keymaster_
+                ->begin(purpose, key_blob, in_params.hidl_data(),
+                        [&](ErrorCode hidl_error, const hidl_vec<KeyParameter>& hidl_out_params,
+                            uint64_t hidl_op_handle) {
+                            error = hidl_error;
+                            *out_params = hidl_out_params;
+                            *op_handle = hidl_op_handle;
+                        })
+                .isOk());
+        if (error != ErrorCode::OK) {
+            // Some implementations may modify *op_handle on error.
+            *op_handle = saved_handle;
+        }
+        return error;
+    }
+
+    ErrorCode Begin(KeyPurpose purpose, const AuthorizationSet& in_params,
+                    AuthorizationSet* out_params) {
+        SCOPED_TRACE("Begin");
+        EXPECT_EQ(kOpHandleSentinel, op_handle_);
+        return Begin(purpose, key_blob_, in_params, out_params, &op_handle_);
+    }
+
+    ErrorCode Begin(KeyPurpose purpose, const AuthorizationSet& in_params) {
+        SCOPED_TRACE("Begin");
+        AuthorizationSet out_params;
+        ErrorCode error = Begin(purpose, in_params, &out_params);
+        EXPECT_TRUE(out_params.empty());
+        return error;
+    }
+
+    ErrorCode Update(OperationHandle op_handle, const AuthorizationSet& in_params,
+                     const string& input, AuthorizationSet* out_params, string* output,
+                     size_t* input_consumed) {
+        SCOPED_TRACE("Update");
+        ErrorCode error;
+        EXPECT_TRUE(keymaster_
+                        ->update(op_handle, in_params.hidl_data(), HidlBuf(input),
+                                 [&](ErrorCode hidl_error, uint32_t hidl_input_consumed,
+                                     const hidl_vec<KeyParameter>& hidl_out_params,
+                                     const HidlBuf& hidl_output) {
+                                     error = hidl_error;
+                                     out_params->push_back(AuthorizationSet(hidl_out_params));
+                                     output->append(hidl_output.to_string());
+                                     *input_consumed = hidl_input_consumed;
+                                 })
+                        .isOk());
+        return error;
+    }
+
+    ErrorCode Update(const string& input, string* out, size_t* input_consumed) {
+        SCOPED_TRACE("Update");
+        AuthorizationSet out_params;
+        ErrorCode error = Update(op_handle_, AuthorizationSet() /* in_params */, input, &out_params,
+                                 out, input_consumed);
+        EXPECT_TRUE(out_params.empty());
+        return error;
+    }
+
+    ErrorCode Finish(OperationHandle op_handle, const AuthorizationSet& in_params,
+                     const string& input, const string& signature, AuthorizationSet* out_params,
+                     string* output) {
+        SCOPED_TRACE("Finish");
+        ErrorCode error;
+        EXPECT_TRUE(
+            keymaster_
+                ->finish(op_handle, in_params.hidl_data(), HidlBuf(input), HidlBuf(signature),
+                         [&](ErrorCode hidl_error, const hidl_vec<KeyParameter>& hidl_out_params,
+                             const HidlBuf& hidl_output) {
+                             error = hidl_error;
+                             *out_params = hidl_out_params;
+                             output->append(hidl_output.to_string());
+                         })
+                .isOk());
+        op_handle_ = kOpHandleSentinel;  // So dtor doesn't Abort().
+        return error;
+    }
+
+    ErrorCode Finish(const string& message, string* output) {
+        SCOPED_TRACE("Finish");
+        AuthorizationSet out_params;
+        string finish_output;
+        ErrorCode error = Finish(op_handle_, AuthorizationSet() /* in_params */, message,
+                                 "" /* signature */, &out_params, output);
+        if (error != ErrorCode::OK) {
+            return error;
+        }
+        EXPECT_EQ(0U, out_params.size());
+        return error;
+    }
+
+    ErrorCode Finish(const string& message, const string& signature, string* output) {
+        SCOPED_TRACE("Finish");
+        AuthorizationSet out_params;
+        ErrorCode error = Finish(op_handle_, AuthorizationSet() /* in_params */, message, signature,
+                                 &out_params, output);
+        op_handle_ = kOpHandleSentinel;  // So dtor doesn't Abort().
+        if (error != ErrorCode::OK) {
+            return error;
+        }
+        EXPECT_EQ(0U, out_params.size());
+        return error;
+    }
+
+    ErrorCode Abort(OperationHandle op_handle) {
+        SCOPED_TRACE("Abort");
+        auto retval = keymaster_->abort(op_handle);
+        EXPECT_TRUE(retval.isOk());
+        return retval;
+    }
+
+    void AbortIfNeeded() {
+        SCOPED_TRACE("AbortIfNeeded");
+        if (op_handle_ != kOpHandleSentinel) {
+            EXPECT_EQ(ErrorCode::OK, Abort(op_handle_));
+            op_handle_ = kOpHandleSentinel;
+        }
+    }
+
+    ErrorCode AttestKey(const HidlBuf& key_blob, const AuthorizationSet& attest_params,
+                        hidl_vec<hidl_vec<uint8_t>>* cert_chain) {
+        SCOPED_TRACE("AttestKey");
+        ErrorCode error;
+        keymaster_->attestKey(
+            key_blob, attest_params.hidl_data(),
+            [&](ErrorCode hidl_error, const hidl_vec<hidl_vec<uint8_t>>& hidl_cert_chain) {
+                error = hidl_error;
+                *cert_chain = hidl_cert_chain;
+            });
+        return error;
+    }
+
+    ErrorCode AttestKey(const AuthorizationSet& attest_params,
+                        hidl_vec<hidl_vec<uint8_t>>* cert_chain) {
+        SCOPED_TRACE("AttestKey");
+        return AttestKey(key_blob_, attest_params, cert_chain);
+    }
+
+    string ProcessMessage(const HidlBuf& key_blob, KeyPurpose operation, const string& message,
+                          const AuthorizationSet& in_params, AuthorizationSet* out_params) {
+        SCOPED_TRACE("ProcessMessage");
+        AuthorizationSet begin_out_params;
+        EXPECT_EQ(ErrorCode::OK,
+                  Begin(operation, key_blob, in_params, &begin_out_params, &op_handle_));
+
+        string unused;
+        AuthorizationSet finish_params;
+        AuthorizationSet finish_out_params;
+        string output;
+        EXPECT_EQ(ErrorCode::OK,
+                  Finish(op_handle_, finish_params, message, unused, &finish_out_params, &output));
+        op_handle_ = kOpHandleSentinel;
+
+        out_params->push_back(begin_out_params);
+        out_params->push_back(finish_out_params);
+        return output;
+    }
+
+    string SignMessage(const HidlBuf& key_blob, const string& message,
+                       const AuthorizationSet& params) {
+        SCOPED_TRACE("SignMessage");
+        AuthorizationSet out_params;
+        string signature = ProcessMessage(key_blob, KeyPurpose::SIGN, message, params, &out_params);
+        EXPECT_TRUE(out_params.empty());
+        return signature;
+    }
+
+    string SignMessage(const string& message, const AuthorizationSet& params) {
+        SCOPED_TRACE("SignMessage");
+        return SignMessage(key_blob_, message, params);
+    }
+
+    string MacMessage(const string& message, Digest digest, size_t mac_length) {
+        SCOPED_TRACE("MacMessage");
+        return SignMessage(
+            key_blob_, message,
+            AuthorizationSetBuilder().Digest(digest).Authorization(TAG_MAC_LENGTH, mac_length));
+    }
+
+    void CheckHmacTestVector(const string& key, const string& message, Digest digest,
+                             const string& expected_mac) {
+        SCOPED_TRACE("CheckHmacTestVector");
+        ASSERT_EQ(ErrorCode::OK,
+                  ImportKey(AuthorizationSetBuilder()
+                                .Authorization(TAG_NO_AUTH_REQUIRED)
+                                .HmacKey(key.size() * 8)
+                                .Authorization(TAG_MIN_MAC_LENGTH, expected_mac.size() * 8)
+                                .Digest(digest),
+                            KeyFormat::RAW, key));
+        string signature = MacMessage(message, digest, expected_mac.size() * 8);
+        EXPECT_EQ(expected_mac, signature) << "Test vector didn't match for digest " << (int)digest;
+        DeleteKey();
+    }
+
+    void CheckAesCtrTestVector(const string& key, const string& nonce, const string& message,
+                               const string& expected_ciphertext) {
+        SCOPED_TRACE("CheckAesCtrTestVector");
+        ASSERT_EQ(ErrorCode::OK, ImportKey(AuthorizationSetBuilder()
+                                               .Authorization(TAG_NO_AUTH_REQUIRED)
+                                               .AesEncryptionKey(key.size() * 8)
+                                               .BlockMode(BlockMode::CTR)
+                                               .Authorization(TAG_CALLER_NONCE)
+                                               .Padding(PaddingMode::NONE),
+                                           KeyFormat::RAW, key));
+
+        auto params = AuthorizationSetBuilder()
+                          .Authorization(TAG_NONCE, nonce.data(), nonce.size())
+                          .BlockMode(BlockMode::CTR)
+                          .Padding(PaddingMode::NONE);
+        AuthorizationSet out_params;
+        string ciphertext = EncryptMessage(key_blob_, message, params, &out_params);
+        EXPECT_EQ(expected_ciphertext, ciphertext);
+    }
+
+    void VerifyMessage(const HidlBuf& key_blob, const string& message, const string& signature,
+                       const AuthorizationSet& params) {
+        SCOPED_TRACE("VerifyMessage");
+        AuthorizationSet begin_out_params;
+        ASSERT_EQ(ErrorCode::OK,
+                  Begin(KeyPurpose::VERIFY, key_blob, params, &begin_out_params, &op_handle_));
+
+        string unused;
+        AuthorizationSet finish_params;
+        AuthorizationSet finish_out_params;
+        string output;
+        EXPECT_EQ(ErrorCode::OK, Finish(op_handle_, finish_params, message, signature,
+                                        &finish_out_params, &output));
+        op_handle_ = kOpHandleSentinel;
+        EXPECT_TRUE(output.empty());
+    }
+
+    void VerifyMessage(const string& message, const string& signature,
+                       const AuthorizationSet& params) {
+        SCOPED_TRACE("VerifyMessage");
+        VerifyMessage(key_blob_, message, signature, params);
+    }
+
+    string EncryptMessage(const HidlBuf& key_blob, const string& message,
+                          const AuthorizationSet& in_params, AuthorizationSet* out_params) {
+        SCOPED_TRACE("EncryptMessage");
+        return ProcessMessage(key_blob, KeyPurpose::ENCRYPT, message, in_params, out_params);
+    }
+
+    string EncryptMessage(const string& message, const AuthorizationSet& params,
+                          AuthorizationSet* out_params) {
+        SCOPED_TRACE("EncryptMessage");
+        return EncryptMessage(key_blob_, message, params, out_params);
+    }
+
+    string EncryptMessage(const string& message, const AuthorizationSet& params) {
+        SCOPED_TRACE("EncryptMessage");
+        AuthorizationSet out_params;
+        string ciphertext = EncryptMessage(message, params, &out_params);
+        EXPECT_TRUE(out_params.empty())
+            << "Output params should be empty. Contained: " << out_params;
+        return ciphertext;
+    }
+
+    string DecryptMessage(const HidlBuf& key_blob, const string& ciphertext,
+                          const AuthorizationSet& params) {
+        SCOPED_TRACE("DecryptMessage");
+        AuthorizationSet out_params;
+        string plaintext =
+            ProcessMessage(key_blob, KeyPurpose::DECRYPT, ciphertext, params, &out_params);
+        EXPECT_TRUE(out_params.empty());
+        return plaintext;
+    }
+
+    string DecryptMessage(const string& ciphertext, const AuthorizationSet& params) {
+        SCOPED_TRACE("DecryptMessage");
+        return DecryptMessage(key_blob_, ciphertext, params);
+    }
+
+    template <TagType tag_type, Tag tag, typename ValueT>
+    void CheckKm0CryptoParam(TypedTag<tag_type, tag> ttag, ValueT expected) {
+        SCOPED_TRACE("CheckKm0CryptoParam");
+        if (is_secure_) {
+            EXPECT_TRUE(contains(key_characteristics_.teeEnforced, ttag, expected));
+            EXPECT_FALSE(contains(key_characteristics_.softwareEnforced, ttag));
+        } else {
+            EXPECT_TRUE(contains(key_characteristics_.softwareEnforced, ttag, expected));
+            EXPECT_FALSE(contains(key_characteristics_.teeEnforced, ttag));
+        }
+    }
+
+    template <TagType tag_type, Tag tag, typename ValueT>
+    void CheckKm1CryptoParam(TypedTag<tag_type, tag> ttag, ValueT expected) {
+        SCOPED_TRACE("CheckKm1CryptoParam");
+        if (is_secure_ && supports_symmetric_) {
+            EXPECT_TRUE(contains(key_characteristics_.teeEnforced, ttag, expected));
+            EXPECT_FALSE(contains(key_characteristics_.softwareEnforced, ttag));
+        } else {
+            EXPECT_TRUE(contains(key_characteristics_.softwareEnforced, ttag, expected));
+            EXPECT_FALSE(contains(key_characteristics_.teeEnforced, ttag));
+        }
+    }
+
+    template <TagType tag_type, Tag tag, typename ValueT>
+    void CheckKm2CryptoParam(TypedTag<tag_type, tag> ttag, ValueT expected) {
+        SCOPED_TRACE("CheckKm2CryptoParam");
+        if (supports_attestation_) {
+            EXPECT_TRUE(contains(key_characteristics_.teeEnforced, ttag, expected));
+            EXPECT_FALSE(contains(key_characteristics_.softwareEnforced, ttag));
+        } else if (!supports_symmetric_ /* KM version < 1 or SW */) {
+            EXPECT_TRUE(contains(key_characteristics_.softwareEnforced, ttag, expected));
+            EXPECT_FALSE(contains(key_characteristics_.teeEnforced, ttag));
+        }
+    }
+
+    void CheckOrigin() {
+        SCOPED_TRACE("CheckOrigin");
+        if (is_secure_ && supports_symmetric_) {
+            EXPECT_TRUE(
+                contains(key_characteristics_.teeEnforced, TAG_ORIGIN, KeyOrigin::IMPORTED));
+        } else if (is_secure_) {
+            EXPECT_TRUE(contains(key_characteristics_.teeEnforced, TAG_ORIGIN, KeyOrigin::UNKNOWN));
+        } else {
+            EXPECT_TRUE(
+                contains(key_characteristics_.softwareEnforced, TAG_ORIGIN, KeyOrigin::IMPORTED));
+        }
+    }
+
+    static bool IsSecure() { return is_secure_; }
+    static bool SupportsEc() { return supports_ec_; }
+    static bool SupportsSymmetric() { return supports_symmetric_; }
+    static bool SupportsAllDigests() { return supports_all_digests_; }
+    static bool SupportsAttestation() { return supports_attestation_; }
+
+    static bool Km2Profile() {
+        return SupportsAttestation() && SupportsAllDigests() && SupportsSymmetric() &&
+               SupportsEc() && IsSecure();
+    }
+
+    static bool Km1Profile() {
+        return !SupportsAttestation() && SupportsSymmetric() && SupportsEc() && IsSecure();
+    }
+
+    static bool Km0Profile() {
+        return !SupportsAttestation() && !SupportsAllDigests() && !SupportsSymmetric() &&
+               IsSecure();
+    }
+
+    static bool SwOnlyProfile() {
+        return !SupportsAttestation() && !SupportsAllDigests() && !SupportsSymmetric() &&
+               !SupportsEc() && !IsSecure();
+    }
+
+    HidlBuf key_blob_;
+    KeyCharacteristics key_characteristics_;
+    OperationHandle op_handle_ = kOpHandleSentinel;
+
+  private:
+    static sp<IKeymasterDevice> keymaster_;
+    static uint32_t os_version_;
+    static uint32_t os_patch_level_;
+
+    static bool is_secure_;
+    static bool supports_ec_;
+    static bool supports_symmetric_;
+    static bool supports_attestation_;
+    static bool supports_all_digests_;
+    static hidl_string name_;
+    static hidl_string author_;
+};
+
+uint32_t expected_keymaster_version() {
+    if (!KeymasterHidlTest::IsSecure()) return 2;  // SW is KM2
+
+    uint32_t keymaster_version = 0;
+    if (KeymasterHidlTest::SupportsSymmetric()) keymaster_version = 1;
+    if (KeymasterHidlTest::SupportsAttestation()) keymaster_version = 2;
+    return keymaster_version;
+}
+
+bool verify_attestation_record(const string& challenge, AuthorizationSet expected_sw_enforced,
+                               AuthorizationSet expected_tee_enforced,
+                               const hidl_vec<uint8_t>& attestation_cert) {
+
+    X509_Ptr cert(parse_cert_blob(attestation_cert));
+    EXPECT_TRUE(!!cert.get());
+    if (!cert.get()) return false;
+
+    ASN1_OCTET_STRING* attest_rec = get_attestation_record(cert.get());
+    EXPECT_TRUE(!!attest_rec);
+    if (!attest_rec) return false;
+
+    AuthorizationSet att_sw_enforced;
+    AuthorizationSet att_tee_enforced;
+    uint32_t att_attestation_version;
+    uint32_t att_keymaster_version;
+    SecurityLevel att_attestation_security_level;
+    SecurityLevel att_keymaster_security_level;
+    HidlBuf att_challenge;
+    HidlBuf att_unique_id;
+    EXPECT_EQ(ErrorCode::OK,
+              parse_attestation_record(attest_rec->data,                 //
+                                       attest_rec->length,               //
+                                       &att_attestation_version,         //
+                                       &att_attestation_security_level,  //
+                                       &att_keymaster_version,           //
+                                       &att_keymaster_security_level,    //
+                                       &att_challenge,                   //
+                                       &att_sw_enforced,                 //
+                                       &att_tee_enforced,                //
+                                       &att_unique_id));
+
+    EXPECT_EQ(1U, att_attestation_version);
+    EXPECT_EQ(expected_keymaster_version(), att_keymaster_version);
+    EXPECT_EQ(KeymasterHidlTest::IsSecure() ? SecurityLevel::TRUSTED_ENVIRONMENT
+                                            : SecurityLevel::SOFTWARE,
+              att_keymaster_security_level);
+    EXPECT_EQ(KeymasterHidlTest::SupportsAttestation() ? SecurityLevel::TRUSTED_ENVIRONMENT
+                                                       : SecurityLevel::SOFTWARE,
+              att_attestation_security_level);
+
+    EXPECT_EQ(challenge.length(), att_challenge.size());
+    EXPECT_EQ(0, memcmp(challenge.data(), att_challenge.data(), challenge.length()));
+
+    att_sw_enforced.Sort();
+    expected_sw_enforced.Sort();
+    EXPECT_EQ(filter_tags(expected_sw_enforced), filter_tags(att_sw_enforced));
+
+    att_tee_enforced.Sort();
+    expected_tee_enforced.Sort();
+    EXPECT_EQ(filter_tags(expected_tee_enforced), filter_tags(att_tee_enforced));
+
+    return true;
+}
+
+sp<IKeymasterDevice> KeymasterHidlTest::keymaster_;
+uint32_t KeymasterHidlTest::os_version_;
+uint32_t KeymasterHidlTest::os_patch_level_;
+bool KeymasterHidlTest::is_secure_;
+bool KeymasterHidlTest::supports_ec_;
+bool KeymasterHidlTest::supports_symmetric_;
+bool KeymasterHidlTest::supports_all_digests_;
+bool KeymasterHidlTest::supports_attestation_;
+hidl_string KeymasterHidlTest::name_;
+hidl_string KeymasterHidlTest::author_;
+
+typedef KeymasterHidlTest KeymasterVersionTest;
+
+/*
+ * KeymasterVersionTest.SensibleFeatures:
+ *
+ * Queries keymaster to find the set of features it supports. Fails if the combination doesn't
+ * correspond to any well-defined keymaster version.
+ */
+TEST_F(KeymasterVersionTest, SensibleFeatures) {
+    EXPECT_TRUE(Km2Profile() || Km1Profile() || Km0Profile() || SwOnlyProfile())
+        << "Keymaster feature set doesn't fit any reasonable profile.  Reported features:"
+        << "SupportsAttestation [" << SupportsAttestation() << "], "
+        << "SupportsSymmetric [" << SupportsSymmetric() << "], "
+        << "SupportsAllDigests [" << SupportsAllDigests() << "], "
+        << "SupportsEc [" << SupportsEc() << "], "
+        << "IsSecure [" << IsSecure() << "]";
+}
+
+class NewKeyGenerationTest : public KeymasterHidlTest {
+  protected:
+    void CheckBaseParams(const KeyCharacteristics& keyCharacteristics) {
+        // TODO(swillden): Distinguish which params should be in which auth list.
+
+        AuthorizationSet auths(keyCharacteristics.teeEnforced);
+        auths.push_back(AuthorizationSet(keyCharacteristics.softwareEnforced));
+
+        EXPECT_TRUE(auths.Contains(TAG_ORIGIN, KeyOrigin::GENERATED));
+
+        EXPECT_TRUE(auths.Contains(TAG_PURPOSE, KeyPurpose::SIGN));
+        EXPECT_TRUE(auths.Contains(TAG_PURPOSE, KeyPurpose::VERIFY));
+        EXPECT_TRUE(auths.Contains(TAG_USER_ID, 7))
+            << "User ID should be 7, was " << auths.GetTagValue(TAG_USER_ID);
+
+        // Verify that App ID, App data and ROT are NOT included.
+        EXPECT_FALSE(auths.Contains(TAG_ROOT_OF_TRUST));
+        EXPECT_FALSE(auths.Contains(TAG_APPLICATION_ID));
+        EXPECT_FALSE(auths.Contains(TAG_APPLICATION_DATA));
+
+        // Check that some unexpected tags/values are NOT present.
+        EXPECT_FALSE(auths.Contains(TAG_PURPOSE, KeyPurpose::ENCRYPT));
+        EXPECT_FALSE(auths.Contains(TAG_PURPOSE, KeyPurpose::DECRYPT));
+        EXPECT_FALSE(auths.Contains(TAG_AUTH_TIMEOUT, 301));
+
+        // Now check that unspecified, defaulted tags are correct.
+        EXPECT_TRUE(auths.Contains(TAG_CREATION_DATETIME));
+
+        if (SupportsAttestation()) {
+            EXPECT_TRUE(auths.Contains(TAG_OS_VERSION, os_version()))
+                << "OS version is " << os_version() << " key reported "
+                << auths.GetTagValue(TAG_OS_VERSION);
+            EXPECT_TRUE(auths.Contains(TAG_OS_PATCHLEVEL, os_patch_level()))
+                << "OS patch level is " << os_patch_level() << " key reported "
+                << auths.GetTagValue(TAG_OS_PATCHLEVEL);
+        }
+    }
+};
+
+/*
+ * NewKeyGenerationTest.Rsa
+ *
+ * Verifies that keymaster can generate all required RSA key sizes, and that the resulting keys have
+ * correct characteristics.
+ */
+TEST_F(NewKeyGenerationTest, Rsa) {
+    for (auto key_size : {1024, 2048, 3072, 4096}) {
+        HidlBuf key_blob;
+        KeyCharacteristics key_characteristics;
+        ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                                 .RsaSigningKey(key_size, 3)
+                                                 .Digest(Digest::NONE)
+                                                 .Padding(PaddingMode::NONE)
+                                                 .Authorizations(UserAuths()),
+                                             &key_blob, &key_characteristics));
+
+        ASSERT_GT(key_blob.size(), 0U);
+        CheckBaseParams(key_characteristics);
+
+        AuthorizationSet crypto_params;
+        if (IsSecure()) {
+            crypto_params = key_characteristics.teeEnforced;
+        } else {
+            crypto_params = key_characteristics.softwareEnforced;
+        }
+
+        EXPECT_TRUE(crypto_params.Contains(TAG_ALGORITHM, KM_ALGORITHM_RSA));
+        EXPECT_TRUE(crypto_params.Contains(TAG_KEY_SIZE, key_size));
+        EXPECT_TRUE(crypto_params.Contains(TAG_RSA_PUBLIC_EXPONENT, 3));
+
+        EXPECT_EQ(ErrorCode::OK, DeleteKey(&key_blob));
+    }
+}
+
+/*
+ * NewKeyGenerationTest.RsaNoDefaultSize
+ *
+ * Verifies that failing to specify a key size for RSA key generation returns UNSUPPORTED_KEY_SIZE.
+ */
+TEST_F(NewKeyGenerationTest, RsaNoDefaultSize) {
+    ASSERT_EQ(ErrorCode::UNSUPPORTED_KEY_SIZE,
+              GenerateKey(AuthorizationSetBuilder()
+                              .Authorization(TAG_ALGORITHM, Algorithm::RSA)
+                              .Authorization(TAG_RSA_PUBLIC_EXPONENT, 3)
+                              .SigningKey()));
+}
+
+/*
+ * NewKeyGenerationTest.Ecdsa
+ *
+ * Verifies that keymaster can generate all required EC key sizes, and that the resulting keys have
+ * correct characteristics.
+ */
+TEST_F(NewKeyGenerationTest, Ecdsa) {
+    for (auto key_size : {224, 256, 384, 521}) {
+        HidlBuf key_blob;
+        KeyCharacteristics key_characteristics;
+        ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                                 .EcdsaSigningKey(key_size)
+                                                 .Digest(Digest::NONE)
+                                                 .Authorizations(UserAuths()),
+                                             &key_blob, &key_characteristics));
+        ASSERT_GT(key_blob.size(), 0U);
+        CheckBaseParams(key_characteristics);
+
+        AuthorizationSet crypto_params;
+        if (IsSecure()) {
+            crypto_params = key_characteristics.teeEnforced;
+        } else {
+            crypto_params = key_characteristics.softwareEnforced;
+        }
+
+        EXPECT_TRUE(crypto_params.Contains(TAG_ALGORITHM, Algorithm::EC));
+        EXPECT_TRUE(crypto_params.Contains(TAG_KEY_SIZE, key_size));
+
+        EXPECT_EQ(ErrorCode::OK, DeleteKey(&key_blob));
+    }
+}
+
+/*
+ * NewKeyGenerationTest.EcdsaDefaultSize
+ *
+ * Verifies that failing to specify a key size for EC key generation returns UNSUPPORTED_KEY_SIZE.
+ */
+TEST_F(NewKeyGenerationTest, EcdsaDefaultSize) {
+    ASSERT_EQ(ErrorCode::UNSUPPORTED_KEY_SIZE,
+              GenerateKey(AuthorizationSetBuilder()
+                              .Authorization(TAG_ALGORITHM, Algorithm::EC)
+                              .SigningKey()
+                              .Digest(Digest::NONE)));
+}
+
+/*
+ * NewKeyGenerationTest.EcdsaInvalidSize
+ *
+ * Verifies that failing to specify an invalid key size for EC key generation returns
+ * UNSUPPORTED_KEY_SIZE.
+ */
+TEST_F(NewKeyGenerationTest, EcdsaInvalidSize) {
+    ASSERT_EQ(ErrorCode::UNSUPPORTED_KEY_SIZE,
+              GenerateKey(AuthorizationSetBuilder().EcdsaSigningKey(190).Digest(Digest::NONE)));
+}
+
+/*
+ * NewKeyGenerationTest.EcdsaMismatchKeySize
+ *
+ * Verifies that specifying mismatched key size and curve for EC key generation returns
+ * INVALID_ARGUMENT.
+ */
+TEST_F(NewKeyGenerationTest, EcdsaMismatchKeySize) {
+    ASSERT_EQ(ErrorCode::INVALID_ARGUMENT,
+              GenerateKey(AuthorizationSetBuilder()
+                              .EcdsaSigningKey(224)
+                              .Authorization(TAG_EC_CURVE, EcCurve::P_256)
+                              .Digest(Digest::NONE)))
+        << "(Possibly b/36233343)";
+}
+
+TEST_F(NewKeyGenerationTest, EcdsaAllValidSizes) {
+    size_t valid_sizes[] = {224, 256, 384, 521};
+    for (size_t size : valid_sizes) {
+        EXPECT_EQ(ErrorCode::OK,
+                  GenerateKey(AuthorizationSetBuilder().EcdsaSigningKey(size).Digest(Digest::NONE)))
+            << "Failed to generate size: " << size;
+        DeleteKey();
+    }
+}
+
+/*
+ * NewKeyGenerationTest.EcdsaAllValidCurves
+ *
+ * Verifies that keymaster supports all required EC curves.
+ */
+TEST_F(NewKeyGenerationTest, EcdsaAllValidCurves) {
+    EcCurve curves[] = {EcCurve::P_224, EcCurve::P_256, EcCurve::P_384, EcCurve::P_521};
+    for (auto curve : curves) {
+        EXPECT_EQ(
+            ErrorCode::OK,
+            GenerateKey(AuthorizationSetBuilder().EcdsaSigningKey(curve).Digest(Digest::SHA_2_512)))
+            << "Failed to generate key on curve: " << curve;
+        DeleteKey();
+    }
+}
+
+/*
+ * NewKeyGenerationTest.Hmac
+ *
+ * Verifies that keymaster supports all required digests, and that the resulting keys have correct
+ * characteristics.
+ */
+TEST_F(NewKeyGenerationTest, Hmac) {
+    for (auto digest : {Digest::MD5, Digest::SHA1, Digest::SHA_2_224, Digest::SHA_2_256,
+                        Digest::SHA_2_384, Digest::SHA_2_512}) {
+        HidlBuf key_blob;
+        KeyCharacteristics key_characteristics;
+        constexpr size_t key_size = 128;
+        ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                                 .HmacKey(key_size)
+                                                 .Digest(digest)
+                                                 .Authorization(TAG_MIN_MAC_LENGTH, 128)
+                                                 .Authorizations(UserAuths()),
+                                             &key_blob, &key_characteristics));
+
+        ASSERT_GT(key_blob.size(), 0U);
+        CheckBaseParams(key_characteristics);
+
+        AuthorizationSet teeEnforced = key_characteristics.teeEnforced;
+        AuthorizationSet softwareEnforced = key_characteristics.softwareEnforced;
+        if (SupportsAttestation() || SupportsAllDigests()) {
+            // Either KM2, which must support all, or KM1 that claims full support
+            EXPECT_TRUE(teeEnforced.Contains(TAG_ALGORITHM, Algorithm::HMAC));
+            EXPECT_TRUE(teeEnforced.Contains(TAG_KEY_SIZE, key_size));
+        } else if (SupportsSymmetric()) {
+            if (digest == Digest::SHA1 || digest == Digest::SHA_2_256) {
+                // KM1 must support SHA1 and SHA256 in hardware
+                EXPECT_TRUE(teeEnforced.Contains(TAG_ALGORITHM, Algorithm::HMAC));
+                EXPECT_TRUE(teeEnforced.Contains(TAG_KEY_SIZE, key_size));
+            } else {
+                // Othere digests may or may not be supported
+                EXPECT_TRUE(teeEnforced.Contains(TAG_ALGORITHM, Algorithm::HMAC) ||
+                            softwareEnforced.Contains(TAG_ALGORITHM, Algorithm::HMAC));
+                EXPECT_TRUE(teeEnforced.Contains(TAG_KEY_SIZE, key_size) ||
+                            softwareEnforced.Contains(TAG_KEY_SIZE, key_size));
+            }
+        } else {
+            // KM0 and SW KM do all digests in SW.
+            EXPECT_TRUE(softwareEnforced.Contains(TAG_ALGORITHM, Algorithm::HMAC));
+            EXPECT_TRUE(softwareEnforced.Contains(TAG_KEY_SIZE, key_size));
+        }
+
+        EXPECT_EQ(ErrorCode::OK, DeleteKey(&key_blob));
+    }
+}
+
+/*
+ * NewKeyGenerationTest.HmacCheckKeySizes
+ *
+ * Verifies that keymaster supports all key sizes, and rejects all invalid key sizes.
+ */
+TEST_F(NewKeyGenerationTest, HmacCheckKeySizes) {
+    for (size_t key_size = 0; key_size <= 512; ++key_size) {
+        if (key_size < 64 || key_size % 8 != 0) {
+            // To keep this test from being very slow, we only test a random fraction of non-byte
+            // key sizes.  We test only ~10% of such cases. Since there are 392 of them, we expect
+            // to run ~40 of them in each run.
+            if (key_size % 8 == 0 || random() % 10 == 0) {
+                EXPECT_EQ(ErrorCode::UNSUPPORTED_KEY_SIZE,
+                          GenerateKey(AuthorizationSetBuilder()
+                                          .HmacKey(key_size)
+                                          .Digest(Digest::SHA_2_256)
+                                          .Authorization(TAG_MIN_MAC_LENGTH, 256)))
+                    << "HMAC key size " << key_size << " invalid (Possibly b/33462346)";
+            }
+        } else {
+            EXPECT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                                     .HmacKey(key_size)
+                                                     .Digest(Digest::SHA_2_256)
+                                                     .Authorization(TAG_MIN_MAC_LENGTH, 256)));
+            DeleteKey();
+        }
+    }
+}
+
+/*
+ * NewKeyGenerationTest.HmacCheckMinMacLengths
+ *
+ * Verifies that keymaster supports all required MAC lengths and rejects all invalid lengths.  This
+ * test is probabilistic in order to keep the runtime down, but any failure prints out the specific
+ * MAC length that failed, so reproducing a failed run will be easy.
+ */
+TEST_F(NewKeyGenerationTest, HmacCheckMinMacLengths) {
+    for (size_t min_mac_length = 0; min_mac_length <= 256; ++min_mac_length) {
+        if (min_mac_length < 64 || min_mac_length % 8 != 0) {
+            // To keep this test from being very long, we only test a random fraction of non-byte
+            // lengths.  We test only ~10% of such cases. Since there are 172 of them, we expect to
+            // run ~17 of them in each run.
+            if (min_mac_length % 8 == 0 || random() % 10 == 0) {
+                EXPECT_EQ(ErrorCode::UNSUPPORTED_MIN_MAC_LENGTH,
+                          GenerateKey(AuthorizationSetBuilder()
+                                          .HmacKey(128)
+                                          .Digest(Digest::SHA_2_256)
+                                          .Authorization(TAG_MIN_MAC_LENGTH, min_mac_length)))
+                    << "HMAC min mac length " << min_mac_length << " invalid.";
+            }
+        } else {
+            EXPECT_EQ(ErrorCode::OK,
+                      GenerateKey(AuthorizationSetBuilder()
+                                      .HmacKey(128)
+                                      .Digest(Digest::SHA_2_256)
+                                      .Authorization(TAG_MIN_MAC_LENGTH, min_mac_length)));
+            DeleteKey();
+        }
+    }
+}
+
+/*
+ * NewKeyGenerationTest.HmacMultipleDigests
+ *
+ * Verifies that keymaster rejects HMAC key generation with multiple specified digest algorithms.
+ */
+TEST_F(NewKeyGenerationTest, HmacMultipleDigests) {
+    ASSERT_EQ(ErrorCode::UNSUPPORTED_DIGEST,
+              GenerateKey(AuthorizationSetBuilder()
+                              .HmacKey(128)
+                              .Digest(Digest::SHA1)
+                              .Digest(Digest::SHA_2_256)
+                              .Authorization(TAG_MIN_MAC_LENGTH, 128)));
+}
+
+/*
+ * NewKeyGenerationTest.HmacDigestNone
+ *
+ * Verifies that keymaster rejects HMAC key generation with no digest or Digest::NONE
+ */
+TEST_F(NewKeyGenerationTest, HmacDigestNone) {
+    ASSERT_EQ(
+        ErrorCode::UNSUPPORTED_DIGEST,
+        GenerateKey(AuthorizationSetBuilder().HmacKey(128).Authorization(TAG_MIN_MAC_LENGTH, 128)));
+
+    ASSERT_EQ(ErrorCode::UNSUPPORTED_DIGEST,
+              GenerateKey(AuthorizationSetBuilder()
+                              .HmacKey(128)
+                              .Digest(Digest::NONE)
+                              .Authorization(TAG_MIN_MAC_LENGTH, 128)));
+}
+
+typedef KeymasterHidlTest GetKeyCharacteristicsTest;
+
+/*
+ * GetKeyCharacteristicsTest.HmacDigestNone
+ *
+ * Verifies that getKeyCharacteristics functions, and that generated and retrieved key
+ * characteristics match.
+ */
+TEST_F(GetKeyCharacteristicsTest, SimpleRsa) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .RsaSigningKey(256, 3)
+                                             .Digest(Digest::NONE)
+                                             .Padding(PaddingMode::NONE)));
+
+    KeyCharacteristics retrieved_chars;
+    ASSERT_EQ(ErrorCode::OK, GetCharacteristics(key_blob_, &retrieved_chars));
+
+    AuthorizationSet gen_sw = key_characteristics_.softwareEnforced;
+    AuthorizationSet gen_tee = key_characteristics_.teeEnforced;
+    AuthorizationSet retrieved_sw = retrieved_chars.softwareEnforced;
+    AuthorizationSet retrieved_tee = retrieved_chars.teeEnforced;
+
+    EXPECT_EQ(gen_sw, retrieved_sw);
+    EXPECT_EQ(gen_tee, retrieved_tee);
+}
+
+typedef KeymasterHidlTest SigningOperationsTest;
+
+/*
+ * SigningOperationsTest.RsaSuccess
+ *
+ * Verifies that raw RSA signature operations succeed.
+ */
+TEST_F(SigningOperationsTest, RsaSuccess) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .RsaSigningKey(1024, 3)
+                                             .Digest(Digest::NONE)
+                                             .Padding(PaddingMode::NONE)
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)));
+    string message = "12345678901234567890123456789012";
+    string signature = SignMessage(
+        message, AuthorizationSetBuilder().Digest(Digest::NONE).Padding(PaddingMode::NONE));
+}
+
+/*
+ * SigningOperationsTest.RsaPssSha256Success
+ *
+ * Verifies that RSA-PSS signature operations succeed.
+ */
+TEST_F(SigningOperationsTest, RsaPssSha256Success) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .RsaSigningKey(1024, 3)
+                                             .Digest(Digest::SHA_2_256)
+                                             .Padding(PaddingMode::RSA_PSS)
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)));
+    // Use large message, which won't work without digesting.
+    string message(1024, 'a');
+    string signature = SignMessage(
+        message, AuthorizationSetBuilder().Digest(Digest::SHA_2_256).Padding(PaddingMode::RSA_PSS));
+}
+
+/*
+ * SigningOperationsTest.RsaPaddingNoneDoesNotAllowOther
+ *
+ * Verifies that keymaster rejects signature operations that specify a padding mode when the key
+ * supports only unpadded operations.
+ */
+TEST_F(SigningOperationsTest, RsaPaddingNoneDoesNotAllowOther) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .RsaSigningKey(1024, 3)
+                                             .Digest(Digest::NONE)
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .Padding(PaddingMode::NONE)));
+    string message = "12345678901234567890123456789012";
+    string signature;
+
+    EXPECT_EQ(ErrorCode::INCOMPATIBLE_PADDING_MODE,
+              Begin(KeyPurpose::SIGN, AuthorizationSetBuilder()
+                                          .Digest(Digest::NONE)
+                                          .Padding(PaddingMode::RSA_PKCS1_1_5_SIGN)));
+}
+
+/*
+ * SigningOperationsTest.RsaPkcs1Sha256Success
+ *
+ * Verifies that digested RSA-PKCS1 signature operations succeed.
+ */
+TEST_F(SigningOperationsTest, RsaPkcs1Sha256Success) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .RsaSigningKey(1024, 3)
+                                             .Digest(Digest::SHA_2_256)
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .Padding(PaddingMode::RSA_PKCS1_1_5_SIGN)));
+    string message(1024, 'a');
+    string signature = SignMessage(message, AuthorizationSetBuilder()
+                                                .Digest(Digest::SHA_2_256)
+                                                .Padding(PaddingMode::RSA_PKCS1_1_5_SIGN));
+}
+
+/*
+ * SigningOperationsTest.RsaPkcs1NoDigestSuccess
+ *
+ * Verifies that undigested RSA-PKCS1 signature operations succeed.
+ */
+TEST_F(SigningOperationsTest, RsaPkcs1NoDigestSuccess) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .RsaSigningKey(1024, 3)
+                                             .Digest(Digest::NONE)
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .Padding(PaddingMode::RSA_PKCS1_1_5_SIGN)));
+    string message(53, 'a');
+    string signature = SignMessage(
+        message,
+        AuthorizationSetBuilder().Digest(Digest::NONE).Padding(PaddingMode::RSA_PKCS1_1_5_SIGN));
+}
+
+/*
+ * SigningOperationsTest.RsaPkcs1NoDigestTooLarge
+ *
+ * Verifies that undigested RSA-PKCS1 signature operations fail with the correct error code when
+ * given a too-long message.
+ */
+TEST_F(SigningOperationsTest, RsaPkcs1NoDigestTooLong) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .RsaSigningKey(1024, 3)
+                                             .Digest(Digest::NONE)
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .Padding(PaddingMode::RSA_PKCS1_1_5_SIGN)));
+    string message(129, 'a');
+
+    EXPECT_EQ(ErrorCode::OK,
+              Begin(KeyPurpose::SIGN, AuthorizationSetBuilder()
+                                          .Digest(Digest::NONE)
+                                          .Padding(PaddingMode::RSA_PKCS1_1_5_SIGN)));
+    string signature;
+    EXPECT_EQ(ErrorCode::INVALID_INPUT_LENGTH, Finish(message, &signature));
+}
+
+/*
+ * SigningOperationsTest.RsaPssSha512TooSmallKey
+ *
+ * Verifies that undigested RSA-PSS signature operations fail with the correct error code when
+ * used with a key that is too small for the message.
+ *
+ * A PSS-padded message is of length salt_size + digest_size + 16 (sizes in bits), and the keymaster
+ * specification requires that salt_size == digest_size, so the message will be digest_size * 2 +
+ * 16. Such a message can only be signed by a given key if the key is at least that size. This test
+ * uses SHA512, which has a digest_size == 512, so the message size is 1040 bits, too large for a
+ * 1024-bit key.
+ */
+TEST_F(SigningOperationsTest, RsaPssSha512TooSmallKey) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .RsaSigningKey(1024, 3)
+                                             .Digest(Digest::SHA_2_512)
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .Padding(PaddingMode::RSA_PSS)));
+    EXPECT_EQ(
+        ErrorCode::INCOMPATIBLE_DIGEST,
+        Begin(KeyPurpose::SIGN,
+              AuthorizationSetBuilder().Digest(Digest::SHA_2_512).Padding(PaddingMode::RSA_PSS)))
+        << "(Possibly b/33346750)";
+}
+
+/*
+ * SigningOperationsTest.RsaNoPaddingTooLong
+ *
+ * Verifies that raw RSA signature operations fail with the correct error code when
+ * given a too-long message.
+ */
+TEST_F(SigningOperationsTest, RsaNoPaddingTooLong) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .RsaSigningKey(1024, 3)
+                                             .Digest(Digest::NONE)
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .Padding(PaddingMode::RSA_PKCS1_1_5_SIGN)));
+    // One byte too long
+    string message(1024 / 8 + 1, 'a');
+    ASSERT_EQ(ErrorCode::OK,
+              Begin(KeyPurpose::SIGN, AuthorizationSetBuilder()
+                                          .Digest(Digest::NONE)
+                                          .Padding(PaddingMode::RSA_PKCS1_1_5_SIGN)));
+    string result;
+    EXPECT_EQ(ErrorCode::INVALID_INPUT_LENGTH, Finish(message, &result));
+
+    // Very large message that should exceed the transfer buffer size of any reasonable TEE.
+    message = string(128 * 1024, 'a');
+    ASSERT_EQ(ErrorCode::OK,
+              Begin(KeyPurpose::SIGN, AuthorizationSetBuilder()
+                                          .Digest(Digest::NONE)
+                                          .Padding(PaddingMode::RSA_PKCS1_1_5_SIGN)));
+    EXPECT_EQ(ErrorCode::INVALID_INPUT_LENGTH, Finish(message, &result));
+}
+
+/*
+ * SigningOperationsTest.RsaAbort
+ *
+ * Verifies that operations can be aborted correctly.  Uses an RSA signing operation for the test,
+ * but the behavior should be algorithm and purpose-independent.
+ */
+TEST_F(SigningOperationsTest, RsaAbort) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .RsaSigningKey(1024, 3)
+                                             .Digest(Digest::NONE)
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .Padding(PaddingMode::NONE)));
+
+    ASSERT_EQ(ErrorCode::OK,
+              Begin(KeyPurpose::SIGN,
+                    AuthorizationSetBuilder().Digest(Digest::NONE).Padding(PaddingMode::NONE)));
+    EXPECT_EQ(ErrorCode::OK, Abort(op_handle_));
+
+    // Another abort should fail
+    EXPECT_EQ(ErrorCode::INVALID_OPERATION_HANDLE, Abort(op_handle_));
+
+    // Set to sentinel, so TearDown() doesn't try to abort again.
+    op_handle_ = kOpHandleSentinel;
+}
+
+/*
+ * SigningOperationsTest.RsaUnsupportedPadding
+ *
+ * Verifies that RSA operations fail with the correct error (but key gen succeeds) when used with a
+ * padding mode inappropriate for RSA.
+ */
+TEST_F(SigningOperationsTest, RsaUnsupportedPadding) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .RsaSigningKey(1024, 3)
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .Digest(Digest::SHA_2_256 /* supported digest */)
+                                             .Padding(PaddingMode::PKCS7)));
+    ASSERT_EQ(
+        ErrorCode::UNSUPPORTED_PADDING_MODE,
+        Begin(KeyPurpose::SIGN,
+              AuthorizationSetBuilder().Digest(Digest::SHA_2_256).Padding(PaddingMode::PKCS7)));
+}
+
+/*
+ * SigningOperationsTest.RsaPssNoDigest
+ *
+ * Verifies that RSA PSS operations fail when no digest is used.  PSS requires a digest.
+ */
+TEST_F(SigningOperationsTest, RsaNoDigest) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .RsaSigningKey(1024, 3)
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .Digest(Digest::NONE)
+                                             .Padding(PaddingMode::RSA_PSS)));
+    ASSERT_EQ(ErrorCode::INCOMPATIBLE_DIGEST,
+              Begin(KeyPurpose::SIGN,
+                    AuthorizationSetBuilder().Digest(Digest::NONE).Padding(PaddingMode::RSA_PSS)));
+
+    ASSERT_EQ(ErrorCode::UNSUPPORTED_DIGEST,
+              Begin(KeyPurpose::SIGN, AuthorizationSetBuilder().Padding(PaddingMode::RSA_PSS)));
+}
+
+/*
+ * SigningOperationsTest.RsaPssNoDigest
+ *
+ * Verifies that RSA operations fail when no padding mode is specified.  PaddingMode::NONE is
+ * supported in some cases (as validated in other tests), but a mode must be specified.
+ */
+TEST_F(SigningOperationsTest, RsaNoPadding) {
+    // Padding must be specified
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .RsaKey(1024, 3)
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .SigningKey()
+                                             .Digest(Digest::NONE)));
+    ASSERT_EQ(ErrorCode::UNSUPPORTED_PADDING_MODE,
+              Begin(KeyPurpose::SIGN, AuthorizationSetBuilder().Digest(Digest::NONE)));
+}
+
+/*
+ * SigningOperationsTest.RsaShortMessage
+ *
+ * Verifies that raw RSA signatures succeed with a message shorter than the key size.
+ */
+TEST_F(SigningOperationsTest, RsaTooShortMessage) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .RsaSigningKey(1024, 3)
+                                             .Digest(Digest::NONE)
+                                             .Padding(PaddingMode::NONE)));
+
+    // Barely shorter
+    string message(1024 / 8 - 1, 'a');
+    SignMessage(message, AuthorizationSetBuilder().Digest(Digest::NONE).Padding(PaddingMode::NONE));
+
+    // Much shorter
+    message = "a";
+    SignMessage(message, AuthorizationSetBuilder().Digest(Digest::NONE).Padding(PaddingMode::NONE));
+}
+
+/*
+ * SigningOperationsTest.RsaSignWithEncryptionKey
+ *
+ * Verifies that RSA encryption keys cannot be used to sign.
+ */
+TEST_F(SigningOperationsTest, RsaSignWithEncryptionKey) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .RsaEncryptionKey(1024, 3)
+                                             .Digest(Digest::NONE)
+                                             .Padding(PaddingMode::NONE)));
+    ASSERT_EQ(ErrorCode::INCOMPATIBLE_PURPOSE,
+              Begin(KeyPurpose::SIGN,
+                    AuthorizationSetBuilder().Digest(Digest::NONE).Padding(PaddingMode::NONE)));
+}
+
+/*
+ * SigningOperationsTest.RsaSignTooLargeMessage
+ *
+ * Verifies that attempting a raw signature of a message which is the same length as the key, but
+ * numerically larger than the public modulus, fails with the correct error.
+ */
+TEST_F(SigningOperationsTest, RsaSignTooLargeMessage) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .RsaSigningKey(1024, 3)
+                                             .Digest(Digest::NONE)
+                                             .Padding(PaddingMode::NONE)));
+
+    // Largest possible message will always be larger than the public modulus.
+    string message(1024 / 8, static_cast<char>(0xff));
+    ASSERT_EQ(ErrorCode::OK, Begin(KeyPurpose::SIGN, AuthorizationSetBuilder()
+                                                         .Authorization(TAG_NO_AUTH_REQUIRED)
+                                                         .Digest(Digest::NONE)
+                                                         .Padding(PaddingMode::NONE)));
+    string signature;
+    ASSERT_EQ(ErrorCode::INVALID_ARGUMENT, Finish(message, &signature));
+}
+
+/*
+ * SigningOperationsTest.EcdsaAllSizesAndHashes
+ *
+ * Verifies that ECDSA operations succeed with all possible key sizes and hashes.
+ */
+TEST_F(SigningOperationsTest, EcdsaAllSizesAndHashes) {
+    for (auto key_size : {224, 256, 384, 521}) {
+        for (auto digest : {
+                 Digest::SHA1, Digest::SHA_2_224, Digest::SHA_2_256, Digest::SHA_2_384,
+                 Digest::SHA_2_512,
+             }) {
+            ErrorCode error = GenerateKey(AuthorizationSetBuilder()
+                                              .Authorization(TAG_NO_AUTH_REQUIRED)
+                                              .EcdsaSigningKey(key_size)
+                                              .Digest(digest));
+            EXPECT_EQ(ErrorCode::OK, error) << "Failed to generate ECDSA key with size " << key_size
+                                            << " and digest " << digest;
+            if (error != ErrorCode::OK) continue;
+
+            string message(1024, 'a');
+            if (digest == Digest::NONE) message.resize(key_size / 8);
+            SignMessage(message, AuthorizationSetBuilder().Digest(digest));
+            DeleteKey();
+        }
+    }
+}
+
+/*
+ * SigningOperationsTest.EcdsaAllCurves
+ *
+ * Verifies that ECDSA operations succeed with all possible curves.
+ */
+TEST_F(SigningOperationsTest, EcdsaAllCurves) {
+    for (auto curve : {EcCurve::P_224, EcCurve::P_256, EcCurve::P_384, EcCurve::P_521}) {
+        ErrorCode error = GenerateKey(AuthorizationSetBuilder()
+                                          .Authorization(TAG_NO_AUTH_REQUIRED)
+                                          .EcdsaSigningKey(curve)
+                                          .Digest(Digest::SHA_2_256));
+        EXPECT_EQ(ErrorCode::OK, error) << "Failed to generate ECDSA key with curve " << curve;
+        if (error != ErrorCode::OK) continue;
+
+        string message(1024, 'a');
+        SignMessage(message, AuthorizationSetBuilder().Digest(Digest::SHA_2_256));
+        DeleteKey();
+    }
+}
+
+/*
+ * SigningOperationsTest.EcdsaNoDigestHugeData
+ *
+ * Verifies that ECDSA operations support very large messages, even without digesting.  This should
+ * work because ECDSA actually only signs the leftmost L_n bits of the message, however large it may
+ * be.  Not using digesting is a bad idea, but in some cases digesting is done by the framework.
+ */
+TEST_F(SigningOperationsTest, EcdsaNoDigestHugeData) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .EcdsaSigningKey(224)
+                                             .Digest(Digest::NONE)));
+    string message(64 * 1024, 'a');
+    SignMessage(message, AuthorizationSetBuilder().Digest(Digest::NONE));
+}
+
+/*
+ * SigningOperationsTest.AesEcbSign
+ *
+ * Verifies that attempts to use AES keys to sign fail in the correct way.
+ */
+TEST_F(SigningOperationsTest, AesEcbSign) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .SigningKey()
+                                             .AesEncryptionKey(128)
+                                             .Authorization(TAG_BLOCK_MODE, BlockMode::ECB)))
+        << "(Possibly b/36252957)";
+
+    AuthorizationSet out_params;
+    EXPECT_EQ(ErrorCode::UNSUPPORTED_PURPOSE,
+              Begin(KeyPurpose::SIGN, AuthorizationSet() /* in_params */, &out_params))
+        << "(Possibly b/36233187)";
+
+    EXPECT_EQ(ErrorCode::UNSUPPORTED_PURPOSE,
+              Begin(KeyPurpose::VERIFY, AuthorizationSet() /* in_params */, &out_params))
+        << "(Possibly b/36233187)";
+}
+
+/*
+ * SigningOperationsTest.HmacAllDigests
+ *
+ * Verifies that HMAC works with all digests.
+ */
+TEST_F(SigningOperationsTest, HmacAllDigests) {
+    for (auto digest : {Digest::SHA1, Digest::SHA_2_224, Digest::SHA_2_256, Digest::SHA_2_384,
+                        Digest::SHA_2_512}) {
+        ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                                 .Authorization(TAG_NO_AUTH_REQUIRED)
+                                                 .HmacKey(128)
+                                                 .Digest(digest)
+                                                 .Authorization(TAG_MIN_MAC_LENGTH, 160)))
+            << "Failed to create HMAC key with digest " << digest;
+        string message = "12345678901234567890123456789012";
+        string signature = MacMessage(message, digest, 160);
+        EXPECT_EQ(160U / 8U, signature.size())
+            << "Failed to sign with HMAC key with digest " << digest;
+        DeleteKey();
+    }
+}
+
+/*
+ * SigningOperationsTest.HmacSha256TooLargeMacLength
+ *
+ * Verifies that HMAC fails in the correct way when asked to generate a MAC larger than the digest
+ * size.
+ */
+TEST_F(SigningOperationsTest, HmacSha256TooLargeMacLength) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .HmacKey(128)
+                                             .Digest(Digest::SHA_2_256)
+                                             .Authorization(TAG_MIN_MAC_LENGTH, 256)));
+    AuthorizationSet output_params;
+    EXPECT_EQ(
+        ErrorCode::UNSUPPORTED_MAC_LENGTH,
+        Begin(
+            KeyPurpose::SIGN, key_blob_,
+            AuthorizationSetBuilder().Digest(Digest::SHA_2_256).Authorization(TAG_MAC_LENGTH, 264),
+            &output_params, &op_handle_));
+}
+
+/*
+ * SigningOperationsTest.HmacSha256TooSmallMacLength
+ *
+ * Verifies that HMAC fails in the correct way when asked to generate a MAC smaller than the
+ * specified minimum MAC length.
+ */
+TEST_F(SigningOperationsTest, HmacSha256TooSmallMacLength) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .HmacKey(128)
+                                             .Digest(Digest::SHA_2_256)
+                                             .Authorization(TAG_MIN_MAC_LENGTH, 128)));
+    AuthorizationSet output_params;
+    EXPECT_EQ(
+        ErrorCode::INVALID_MAC_LENGTH,
+        Begin(
+            KeyPurpose::SIGN, key_blob_,
+            AuthorizationSetBuilder().Digest(Digest::SHA_2_256).Authorization(TAG_MAC_LENGTH, 120),
+            &output_params, &op_handle_));
+}
+
+/*
+ * SigningOperationsTest.HmacRfc4231TestCase3
+ *
+ * Validates against the test vectors from RFC 4231 test case 3.
+ */
+TEST_F(SigningOperationsTest, HmacRfc4231TestCase3) {
+    string key(20, 0xaa);
+    string message(50, 0xdd);
+    uint8_t sha_224_expected[] = {
+        0x7f, 0xb3, 0xcb, 0x35, 0x88, 0xc6, 0xc1, 0xf6, 0xff, 0xa9, 0x69, 0x4d, 0x7d, 0x6a,
+        0xd2, 0x64, 0x93, 0x65, 0xb0, 0xc1, 0xf6, 0x5d, 0x69, 0xd1, 0xec, 0x83, 0x33, 0xea,
+    };
+    uint8_t sha_256_expected[] = {
+        0x77, 0x3e, 0xa9, 0x1e, 0x36, 0x80, 0x0e, 0x46, 0x85, 0x4d, 0xb8,
+        0xeb, 0xd0, 0x91, 0x81, 0xa7, 0x29, 0x59, 0x09, 0x8b, 0x3e, 0xf8,
+        0xc1, 0x22, 0xd9, 0x63, 0x55, 0x14, 0xce, 0xd5, 0x65, 0xfe,
+    };
+    uint8_t sha_384_expected[] = {
+        0x88, 0x06, 0x26, 0x08, 0xd3, 0xe6, 0xad, 0x8a, 0x0a, 0xa2, 0xac, 0xe0,
+        0x14, 0xc8, 0xa8, 0x6f, 0x0a, 0xa6, 0x35, 0xd9, 0x47, 0xac, 0x9f, 0xeb,
+        0xe8, 0x3e, 0xf4, 0xe5, 0x59, 0x66, 0x14, 0x4b, 0x2a, 0x5a, 0xb3, 0x9d,
+        0xc1, 0x38, 0x14, 0xb9, 0x4e, 0x3a, 0xb6, 0xe1, 0x01, 0xa3, 0x4f, 0x27,
+    };
+    uint8_t sha_512_expected[] = {
+        0xfa, 0x73, 0xb0, 0x08, 0x9d, 0x56, 0xa2, 0x84, 0xef, 0xb0, 0xf0, 0x75, 0x6c,
+        0x89, 0x0b, 0xe9, 0xb1, 0xb5, 0xdb, 0xdd, 0x8e, 0xe8, 0x1a, 0x36, 0x55, 0xf8,
+        0x3e, 0x33, 0xb2, 0x27, 0x9d, 0x39, 0xbf, 0x3e, 0x84, 0x82, 0x79, 0xa7, 0x22,
+        0xc8, 0x06, 0xb4, 0x85, 0xa4, 0x7e, 0x67, 0xc8, 0x07, 0xb9, 0x46, 0xa3, 0x37,
+        0xbe, 0xe8, 0x94, 0x26, 0x74, 0x27, 0x88, 0x59, 0xe1, 0x32, 0x92, 0xfb,
+    };
+
+    CheckHmacTestVector(key, message, Digest::SHA_2_224, make_string(sha_224_expected));
+    CheckHmacTestVector(key, message, Digest::SHA_2_256, make_string(sha_256_expected));
+    CheckHmacTestVector(key, message, Digest::SHA_2_384, make_string(sha_384_expected));
+    CheckHmacTestVector(key, message, Digest::SHA_2_512, make_string(sha_512_expected));
+}
+
+/*
+ * SigningOperationsTest.HmacRfc4231TestCase5
+ *
+ * Validates against the test vectors from RFC 4231 test case 5.
+ */
+TEST_F(SigningOperationsTest, HmacRfc4231TestCase5) {
+    string key(20, 0x0c);
+    string message = "Test With Truncation";
+
+    uint8_t sha_224_expected[] = {
+        0x0e, 0x2a, 0xea, 0x68, 0xa9, 0x0c, 0x8d, 0x37,
+        0xc9, 0x88, 0xbc, 0xdb, 0x9f, 0xca, 0x6f, 0xa8,
+    };
+    uint8_t sha_256_expected[] = {
+        0xa3, 0xb6, 0x16, 0x74, 0x73, 0x10, 0x0e, 0xe0,
+        0x6e, 0x0c, 0x79, 0x6c, 0x29, 0x55, 0x55, 0x2b,
+    };
+    uint8_t sha_384_expected[] = {
+        0x3a, 0xbf, 0x34, 0xc3, 0x50, 0x3b, 0x2a, 0x23,
+        0xa4, 0x6e, 0xfc, 0x61, 0x9b, 0xae, 0xf8, 0x97,
+    };
+    uint8_t sha_512_expected[] = {
+        0x41, 0x5f, 0xad, 0x62, 0x71, 0x58, 0x0a, 0x53,
+        0x1d, 0x41, 0x79, 0xbc, 0x89, 0x1d, 0x87, 0xa6,
+    };
+
+    CheckHmacTestVector(key, message, Digest::SHA_2_224, make_string(sha_224_expected));
+    CheckHmacTestVector(key, message, Digest::SHA_2_256, make_string(sha_256_expected));
+    CheckHmacTestVector(key, message, Digest::SHA_2_384, make_string(sha_384_expected));
+    CheckHmacTestVector(key, message, Digest::SHA_2_512, make_string(sha_512_expected));
+}
+
+/*
+ * SigningOperationsTest.HmacRfc4231TestCase6
+ *
+ * Validates against the test vectors from RFC 4231 test case 6.
+ */
+TEST_F(SigningOperationsTest, HmacRfc4231TestCase6) {
+    string key(131, 0xaa);
+    string message = "Test Using Larger Than Block-Size Key - Hash Key First";
+
+    uint8_t sha_224_expected[] = {
+        0x95, 0xe9, 0xa0, 0xdb, 0x96, 0x20, 0x95, 0xad, 0xae, 0xbe, 0x9b, 0x2d, 0x6f, 0x0d,
+        0xbc, 0xe2, 0xd4, 0x99, 0xf1, 0x12, 0xf2, 0xd2, 0xb7, 0x27, 0x3f, 0xa6, 0x87, 0x0e,
+    };
+    uint8_t sha_256_expected[] = {
+        0x60, 0xe4, 0x31, 0x59, 0x1e, 0xe0, 0xb6, 0x7f, 0x0d, 0x8a, 0x26,
+        0xaa, 0xcb, 0xf5, 0xb7, 0x7f, 0x8e, 0x0b, 0xc6, 0x21, 0x37, 0x28,
+        0xc5, 0x14, 0x05, 0x46, 0x04, 0x0f, 0x0e, 0xe3, 0x7f, 0x54,
+    };
+    uint8_t sha_384_expected[] = {
+        0x4e, 0xce, 0x08, 0x44, 0x85, 0x81, 0x3e, 0x90, 0x88, 0xd2, 0xc6, 0x3a,
+        0x04, 0x1b, 0xc5, 0xb4, 0x4f, 0x9e, 0xf1, 0x01, 0x2a, 0x2b, 0x58, 0x8f,
+        0x3c, 0xd1, 0x1f, 0x05, 0x03, 0x3a, 0xc4, 0xc6, 0x0c, 0x2e, 0xf6, 0xab,
+        0x40, 0x30, 0xfe, 0x82, 0x96, 0x24, 0x8d, 0xf1, 0x63, 0xf4, 0x49, 0x52,
+    };
+    uint8_t sha_512_expected[] = {
+        0x80, 0xb2, 0x42, 0x63, 0xc7, 0xc1, 0xa3, 0xeb, 0xb7, 0x14, 0x93, 0xc1, 0xdd,
+        0x7b, 0xe8, 0xb4, 0x9b, 0x46, 0xd1, 0xf4, 0x1b, 0x4a, 0xee, 0xc1, 0x12, 0x1b,
+        0x01, 0x37, 0x83, 0xf8, 0xf3, 0x52, 0x6b, 0x56, 0xd0, 0x37, 0xe0, 0x5f, 0x25,
+        0x98, 0xbd, 0x0f, 0xd2, 0x21, 0x5d, 0x6a, 0x1e, 0x52, 0x95, 0xe6, 0x4f, 0x73,
+        0xf6, 0x3f, 0x0a, 0xec, 0x8b, 0x91, 0x5a, 0x98, 0x5d, 0x78, 0x65, 0x98,
+    };
+
+    CheckHmacTestVector(key, message, Digest::SHA_2_224, make_string(sha_224_expected));
+    CheckHmacTestVector(key, message, Digest::SHA_2_256, make_string(sha_256_expected));
+    CheckHmacTestVector(key, message, Digest::SHA_2_384, make_string(sha_384_expected));
+    CheckHmacTestVector(key, message, Digest::SHA_2_512, make_string(sha_512_expected));
+}
+
+/*
+ * SigningOperationsTest.HmacRfc4231TestCase7
+ *
+ * Validates against the test vectors from RFC 4231 test case 7.
+ */
+TEST_F(SigningOperationsTest, HmacRfc4231TestCase7) {
+    string key(131, 0xaa);
+    string message = "This is a test using a larger than block-size key and a larger than "
+                     "block-size data. The key needs to be hashed before being used by the HMAC "
+                     "algorithm.";
+
+    uint8_t sha_224_expected[] = {
+        0x3a, 0x85, 0x41, 0x66, 0xac, 0x5d, 0x9f, 0x02, 0x3f, 0x54, 0xd5, 0x17, 0xd0, 0xb3,
+        0x9d, 0xbd, 0x94, 0x67, 0x70, 0xdb, 0x9c, 0x2b, 0x95, 0xc9, 0xf6, 0xf5, 0x65, 0xd1,
+    };
+    uint8_t sha_256_expected[] = {
+        0x9b, 0x09, 0xff, 0xa7, 0x1b, 0x94, 0x2f, 0xcb, 0x27, 0x63, 0x5f,
+        0xbc, 0xd5, 0xb0, 0xe9, 0x44, 0xbf, 0xdc, 0x63, 0x64, 0x4f, 0x07,
+        0x13, 0x93, 0x8a, 0x7f, 0x51, 0x53, 0x5c, 0x3a, 0x35, 0xe2,
+    };
+    uint8_t sha_384_expected[] = {
+        0x66, 0x17, 0x17, 0x8e, 0x94, 0x1f, 0x02, 0x0d, 0x35, 0x1e, 0x2f, 0x25,
+        0x4e, 0x8f, 0xd3, 0x2c, 0x60, 0x24, 0x20, 0xfe, 0xb0, 0xb8, 0xfb, 0x9a,
+        0xdc, 0xce, 0xbb, 0x82, 0x46, 0x1e, 0x99, 0xc5, 0xa6, 0x78, 0xcc, 0x31,
+        0xe7, 0x99, 0x17, 0x6d, 0x38, 0x60, 0xe6, 0x11, 0x0c, 0x46, 0x52, 0x3e,
+    };
+    uint8_t sha_512_expected[] = {
+        0xe3, 0x7b, 0x6a, 0x77, 0x5d, 0xc8, 0x7d, 0xba, 0xa4, 0xdf, 0xa9, 0xf9, 0x6e,
+        0x5e, 0x3f, 0xfd, 0xde, 0xbd, 0x71, 0xf8, 0x86, 0x72, 0x89, 0x86, 0x5d, 0xf5,
+        0xa3, 0x2d, 0x20, 0xcd, 0xc9, 0x44, 0xb6, 0x02, 0x2c, 0xac, 0x3c, 0x49, 0x82,
+        0xb1, 0x0d, 0x5e, 0xeb, 0x55, 0xc3, 0xe4, 0xde, 0x15, 0x13, 0x46, 0x76, 0xfb,
+        0x6d, 0xe0, 0x44, 0x60, 0x65, 0xc9, 0x74, 0x40, 0xfa, 0x8c, 0x6a, 0x58,
+    };
+
+    CheckHmacTestVector(key, message, Digest::SHA_2_224, make_string(sha_224_expected));
+    CheckHmacTestVector(key, message, Digest::SHA_2_256, make_string(sha_256_expected));
+    CheckHmacTestVector(key, message, Digest::SHA_2_384, make_string(sha_384_expected));
+    CheckHmacTestVector(key, message, Digest::SHA_2_512, make_string(sha_512_expected));
+}
+
+typedef KeymasterHidlTest VerificationOperationsTest;
+
+/*
+ * VerificationOperationsTest.RsaSuccess
+ *
+ * Verifies that a simple RSA signature/verification sequence succeeds.
+ */
+TEST_F(VerificationOperationsTest, RsaSuccess) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .RsaSigningKey(1024, 3)
+                                             .Digest(Digest::NONE)
+                                             .Padding(PaddingMode::NONE)));
+    string message = "12345678901234567890123456789012";
+    string signature = SignMessage(
+        message, AuthorizationSetBuilder().Digest(Digest::NONE).Padding(PaddingMode::NONE));
+    VerifyMessage(message, signature,
+                  AuthorizationSetBuilder().Digest(Digest::NONE).Padding(PaddingMode::NONE));
+}
+
+/*
+ * VerificationOperationsTest.RsaSuccess
+ *
+ * Verifies RSA signature/verification for all padding modes and digests.
+ */
+TEST_F(VerificationOperationsTest, RsaAllPaddingsAndDigests) {
+    ASSERT_EQ(ErrorCode::OK,
+              GenerateKey(AuthorizationSetBuilder()
+                              .Authorization(TAG_NO_AUTH_REQUIRED)
+                              .RsaSigningKey(2048, 3)
+                              .Digest(Digest::NONE, Digest::MD5, Digest::SHA1, Digest::SHA_2_224,
+                                      Digest::SHA_2_256, Digest::SHA_2_384, Digest::SHA_2_512)
+                              .Padding(PaddingMode::NONE)
+                              .Padding(PaddingMode::RSA_PSS)
+                              .Padding(PaddingMode::RSA_PKCS1_1_5_SIGN)));
+
+    string message(128, 'a');
+    string corrupt_message(message);
+    ++corrupt_message[corrupt_message.size() / 2];
+
+    for (auto padding :
+         {PaddingMode::NONE, PaddingMode::RSA_PSS, PaddingMode::RSA_PKCS1_1_5_SIGN}) {
+
+        for (auto digest : {Digest::NONE, Digest::MD5, Digest::SHA1, Digest::SHA_2_224,
+                            Digest::SHA_2_256, Digest::SHA_2_384, Digest::SHA_2_512}) {
+            if (padding == PaddingMode::NONE && digest != Digest::NONE) {
+                // Digesting only makes sense with padding.
+                continue;
+            }
+
+            if (padding == PaddingMode::RSA_PSS && digest == Digest::NONE) {
+                // PSS requires digesting.
+                continue;
+            }
+
+            string signature =
+                SignMessage(message, AuthorizationSetBuilder().Digest(digest).Padding(padding));
+            VerifyMessage(message, signature,
+                          AuthorizationSetBuilder().Digest(digest).Padding(padding));
+
+            if (digest != Digest::NONE) {
+                // Verify with OpenSSL.
+                HidlBuf pubkey;
+                ASSERT_EQ(ErrorCode::OK, ExportKey(KeyFormat::X509, &pubkey));
+
+                const uint8_t* p = pubkey.data();
+                EVP_PKEY_Ptr pkey(d2i_PUBKEY(nullptr /* alloc new */, &p, pubkey.size()));
+                ASSERT_TRUE(pkey.get());
+
+                EVP_MD_CTX digest_ctx;
+                EVP_MD_CTX_init(&digest_ctx);
+                EVP_PKEY_CTX* pkey_ctx;
+                const EVP_MD* md = openssl_digest(digest);
+                ASSERT_NE(md, nullptr);
+                EXPECT_EQ(1, EVP_DigestVerifyInit(&digest_ctx, &pkey_ctx, md, nullptr /* engine */,
+                                                  pkey.get()));
+
+                switch (padding) {
+                case PaddingMode::RSA_PSS:
+                    EXPECT_GT(EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING), 0);
+                    EXPECT_GT(EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, EVP_MD_size(md)), 0);
+                    break;
+                case PaddingMode::RSA_PKCS1_1_5_SIGN:
+                    // PKCS1 is the default; don't need to set anything.
+                    break;
+                default:
+                    FAIL();
+                    break;
+                }
+
+                EXPECT_EQ(1, EVP_DigestVerifyUpdate(&digest_ctx, message.data(), message.size()));
+                EXPECT_EQ(1, EVP_DigestVerifyFinal(
+                                 &digest_ctx, reinterpret_cast<const uint8_t*>(signature.data()),
+                                 signature.size()));
+                EVP_MD_CTX_cleanup(&digest_ctx);
+            }
+
+            // Corrupt signature shouldn't verify.
+            string corrupt_signature(signature);
+            ++corrupt_signature[corrupt_signature.size() / 2];
+
+            EXPECT_EQ(ErrorCode::OK,
+                      Begin(KeyPurpose::VERIFY,
+                            AuthorizationSetBuilder().Digest(digest).Padding(padding)));
+            string result;
+            EXPECT_EQ(ErrorCode::VERIFICATION_FAILED, Finish(message, corrupt_signature, &result));
+
+            // Corrupt message shouldn't verify
+            EXPECT_EQ(ErrorCode::OK,
+                      Begin(KeyPurpose::VERIFY,
+                            AuthorizationSetBuilder().Digest(digest).Padding(padding)));
+            EXPECT_EQ(ErrorCode::VERIFICATION_FAILED, Finish(corrupt_message, signature, &result));
+        }
+    }
+}
+
+/*
+ * VerificationOperationsTest.RsaSuccess
+ *
+ * Verifies ECDSA signature/verification for all digests and curves.
+ */
+TEST_F(VerificationOperationsTest, EcdsaAllDigestsAndCurves) {
+    auto digests = {
+        Digest::NONE,      Digest::SHA1,      Digest::SHA_2_224,
+        Digest::SHA_2_256, Digest::SHA_2_384, Digest::SHA_2_512,
+    };
+
+    string message = "1234567890";
+    string corrupt_message = "2234567890";
+    for (auto curve : {EcCurve::P_224, EcCurve::P_256, EcCurve::P_384, EcCurve::P_521}) {
+        ErrorCode error = GenerateKey(AuthorizationSetBuilder()
+                                          .Authorization(TAG_NO_AUTH_REQUIRED)
+                                          .EcdsaSigningKey(curve)
+                                          .Digest(digests));
+        EXPECT_EQ(ErrorCode::OK, error) << "Failed to generate key for EC curve " << curve;
+        if (error != ErrorCode::OK) {
+            continue;
+        }
+
+        for (auto digest : digests) {
+            string signature = SignMessage(message, AuthorizationSetBuilder().Digest(digest));
+            VerifyMessage(message, signature, AuthorizationSetBuilder().Digest(digest));
+
+            // Verify with OpenSSL
+            if (digest != Digest::NONE) {
+                HidlBuf pubkey;
+                ASSERT_EQ(ErrorCode::OK, ExportKey(KeyFormat::X509, &pubkey))
+                    << curve << ' ' << digest;
+
+                const uint8_t* p = pubkey.data();
+                EVP_PKEY_Ptr pkey(d2i_PUBKEY(nullptr /* alloc new */, &p, pubkey.size()));
+                ASSERT_TRUE(pkey.get());
+
+                EVP_MD_CTX digest_ctx;
+                EVP_MD_CTX_init(&digest_ctx);
+                EVP_PKEY_CTX* pkey_ctx;
+                const EVP_MD* md = openssl_digest(digest);
+
+                EXPECT_EQ(1, EVP_DigestVerifyInit(&digest_ctx, &pkey_ctx, md, nullptr /* engine */,
+                                                  pkey.get()))
+                    << curve << ' ' << digest;
+
+                EXPECT_EQ(1, EVP_DigestVerifyUpdate(&digest_ctx, message.data(), message.size()))
+                    << curve << ' ' << digest;
+
+                EXPECT_EQ(1, EVP_DigestVerifyFinal(
+                                 &digest_ctx, reinterpret_cast<const uint8_t*>(signature.data()),
+                                 signature.size()))
+                    << curve << ' ' << digest;
+
+                EVP_MD_CTX_cleanup(&digest_ctx);
+            }
+
+            // Corrupt signature shouldn't verify.
+            string corrupt_signature(signature);
+            ++corrupt_signature[corrupt_signature.size() / 2];
+
+            EXPECT_EQ(ErrorCode::OK,
+                      Begin(KeyPurpose::VERIFY, AuthorizationSetBuilder().Digest(digest)))
+                << curve << ' ' << digest;
+
+            string result;
+            EXPECT_EQ(ErrorCode::VERIFICATION_FAILED, Finish(message, corrupt_signature, &result))
+                << curve << ' ' << digest;
+
+            // Corrupt message shouldn't verify
+            EXPECT_EQ(ErrorCode::OK,
+                      Begin(KeyPurpose::VERIFY, AuthorizationSetBuilder().Digest(digest)))
+                << curve << ' ' << digest;
+
+            EXPECT_EQ(ErrorCode::VERIFICATION_FAILED, Finish(corrupt_message, signature, &result))
+                << curve << ' ' << digest;
+        }
+
+        ASSERT_EQ(ErrorCode::OK, DeleteKey());
+    }
+}
+
+/*
+ * VerificationOperationsTest.HmacSigningKeyCannotVerify
+ *
+ * Verifies HMAC signing and verification, but that a signing key cannot be used to verify.
+ */
+TEST_F(VerificationOperationsTest, HmacSigningKeyCannotVerify) {
+    string key_material = "HelloThisIsAKey";
+
+    HidlBuf signing_key, verification_key;
+    KeyCharacteristics signing_key_chars, verification_key_chars;
+    EXPECT_EQ(ErrorCode::OK,
+              ImportKey(AuthorizationSetBuilder()
+                            .Authorization(TAG_NO_AUTH_REQUIRED)
+                            .Authorization(TAG_ALGORITHM, Algorithm::HMAC)
+                            .Authorization(TAG_PURPOSE, KeyPurpose::SIGN)
+                            .Digest(Digest::SHA1)
+                            .Authorization(TAG_MIN_MAC_LENGTH, 160),
+                        KeyFormat::RAW, key_material, &signing_key, &signing_key_chars));
+    EXPECT_EQ(ErrorCode::OK,
+              ImportKey(AuthorizationSetBuilder()
+                            .Authorization(TAG_NO_AUTH_REQUIRED)
+                            .Authorization(TAG_ALGORITHM, Algorithm::HMAC)
+                            .Authorization(TAG_PURPOSE, KeyPurpose::VERIFY)
+                            .Digest(Digest::SHA1)
+                            .Authorization(TAG_MIN_MAC_LENGTH, 160),
+                        KeyFormat::RAW, key_material, &verification_key, &verification_key_chars));
+
+    string message = "This is a message.";
+    string signature = SignMessage(
+        signing_key, message,
+        AuthorizationSetBuilder().Digest(Digest::SHA1).Authorization(TAG_MAC_LENGTH, 160));
+
+    // Signing key should not work.
+    AuthorizationSet out_params;
+    EXPECT_EQ(ErrorCode::INCOMPATIBLE_PURPOSE,
+              Begin(KeyPurpose::VERIFY, signing_key, AuthorizationSetBuilder().Digest(Digest::SHA1),
+                    &out_params, &op_handle_));
+
+    // Verification key should work.
+    VerifyMessage(verification_key, message, signature,
+                  AuthorizationSetBuilder().Digest(Digest::SHA1));
+
+    EXPECT_EQ(ErrorCode::OK, DeleteKey(&signing_key));
+    EXPECT_EQ(ErrorCode::OK, DeleteKey(&verification_key));
+}
+
+typedef KeymasterHidlTest ExportKeyTest;
+
+/*
+ * ExportKeyTest.RsaUnsupportedKeyFormat
+ *
+ * Verifies that attempting to export RSA keys in PKCS#8 format fails with the correct error.
+ */
+TEST_F(ExportKeyTest, RsaUnsupportedKeyFormat) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .RsaSigningKey(256, 3)
+                                             .Digest(Digest::NONE)
+                                             .Padding(PaddingMode::NONE)));
+    HidlBuf export_data;
+    ASSERT_EQ(ErrorCode::UNSUPPORTED_KEY_FORMAT, ExportKey(KeyFormat::PKCS8, &export_data));
+}
+
+/*
+ * ExportKeyTest.RsaCorruptedKeyBlob
+ *
+ * Verifies that attempting to export RSA keys from corrupted key blobs fails.  This is essentially
+ * a poor-man's key blob fuzzer.
+ */
+// Disabled due to b/33385206
+TEST_F(ExportKeyTest, DISABLED_RsaCorruptedKeyBlob) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .RsaSigningKey(256, 3)
+                                             .Digest(Digest::NONE)
+                                             .Padding(PaddingMode::NONE)));
+    for (size_t i = 0; i < key_blob_.size(); ++i) {
+        HidlBuf corrupted(key_blob_);
+        ++corrupted[i];
+
+        HidlBuf export_data;
+        EXPECT_EQ(ErrorCode::INVALID_KEY_BLOB,
+                  ExportKey(KeyFormat::X509, corrupted, HidlBuf(), HidlBuf(), &export_data))
+            << "Blob corrupted at offset " << i << " erroneously accepted as valid";
+    }
+}
+
+/*
+ * ExportKeyTest.RsaCorruptedKeyBlob
+ *
+ * Verifies that attempting to export ECDSA keys from corrupted key blobs fails.  This is
+ * essentially a poor-man's key blob fuzzer.
+ */
+// Disabled due to b/33385206
+TEST_F(ExportKeyTest, DISABLED_EcCorruptedKeyBlob) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .EcdsaSigningKey(EcCurve::P_256)
+                                             .Digest(Digest::NONE)));
+    for (size_t i = 0; i < key_blob_.size(); ++i) {
+        HidlBuf corrupted(key_blob_);
+        ++corrupted[i];
+
+        HidlBuf export_data;
+        EXPECT_EQ(ErrorCode::INVALID_KEY_BLOB,
+                  ExportKey(KeyFormat::X509, corrupted, HidlBuf(), HidlBuf(), &export_data))
+            << "Blob corrupted at offset " << i << " erroneously accepted as valid";
+    }
+}
+
+/*
+ * ExportKeyTest.AesKeyUnexportable
+ *
+ * Verifies that attempting to export AES keys fails in the expected way.
+ */
+TEST_F(ExportKeyTest, AesKeyUnexportable) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .EcbMode()
+                                             .Padding(PaddingMode::NONE)));
+
+    HidlBuf export_data;
+    EXPECT_EQ(ErrorCode::UNSUPPORTED_KEY_FORMAT, ExportKey(KeyFormat::X509, &export_data));
+    EXPECT_EQ(ErrorCode::UNSUPPORTED_KEY_FORMAT, ExportKey(KeyFormat::PKCS8, &export_data));
+    EXPECT_EQ(ErrorCode::UNSUPPORTED_KEY_FORMAT, ExportKey(KeyFormat::RAW, &export_data));
+}
+typedef KeymasterHidlTest ImportKeyTest;
+
+/*
+ * ImportKeyTest.RsaSuccess
+ *
+ * Verifies that importing and using an RSA key pair works correctly.
+ */
+TEST_F(ImportKeyTest, RsaSuccess) {
+    ASSERT_EQ(ErrorCode::OK, ImportKey(AuthorizationSetBuilder()
+                                           .Authorization(TAG_NO_AUTH_REQUIRED)
+                                           .RsaSigningKey(1024, 65537)
+                                           .Digest(Digest::SHA_2_256)
+                                           .Padding(PaddingMode::RSA_PSS),
+                                       KeyFormat::PKCS8, rsa_key));
+
+    CheckKm0CryptoParam(TAG_ALGORITHM, Algorithm::RSA);
+    CheckKm0CryptoParam(TAG_KEY_SIZE, 1024U);
+    CheckKm0CryptoParam(TAG_RSA_PUBLIC_EXPONENT, 65537U);
+    CheckKm1CryptoParam(TAG_DIGEST, Digest::SHA_2_256);
+    CheckKm1CryptoParam(TAG_PADDING, PaddingMode::RSA_PSS);
+    CheckOrigin();
+
+    string message(1024 / 8, 'a');
+    auto params = AuthorizationSetBuilder().Digest(Digest::SHA_2_256).Padding(PaddingMode::RSA_PSS);
+    string signature = SignMessage(message, params);
+    VerifyMessage(message, signature, params);
+}
+
+/*
+ * ImportKeyTest.RsaKeySizeMismatch
+ *
+ * Verifies that importing an RSA key pair with a size that doesn't match the key fails in the
+ * correct way.
+ */
+TEST_F(ImportKeyTest, RsaKeySizeMismatch) {
+    ASSERT_EQ(ErrorCode::IMPORT_PARAMETER_MISMATCH,
+              ImportKey(AuthorizationSetBuilder()
+                            .RsaSigningKey(2048 /* Doesn't match key */, 65537)
+                            .Digest(Digest::NONE)
+                            .Padding(PaddingMode::NONE),
+                        KeyFormat::PKCS8, rsa_key));
+}
+
+/*
+ * ImportKeyTest.RsaPublicExponentMismatch
+ *
+ * Verifies that importing an RSA key pair with a public exponent that doesn't match the key fails
+ * in the correct way.
+ */
+TEST_F(ImportKeyTest, RsaPublicExponentMismatch) {
+    ASSERT_EQ(ErrorCode::IMPORT_PARAMETER_MISMATCH,
+              ImportKey(AuthorizationSetBuilder()
+                            .RsaSigningKey(1024, 3 /* Doesn't match key */)
+                            .Digest(Digest::NONE)
+                            .Padding(PaddingMode::NONE),
+                        KeyFormat::PKCS8, rsa_key));
+}
+
+/*
+ * ImportKeyTest.EcdsaSuccess
+ *
+ * Verifies that importing and using an ECDSA key pair works correctly.
+ */
+TEST_F(ImportKeyTest, EcdsaSuccess) {
+    ASSERT_EQ(ErrorCode::OK, ImportKey(AuthorizationSetBuilder()
+                                           .Authorization(TAG_NO_AUTH_REQUIRED)
+                                           .EcdsaSigningKey(256)
+                                           .Digest(Digest::SHA_2_256),
+                                       KeyFormat::PKCS8, ec_key))
+        << "(Possibly b/33945114)";
+
+    CheckKm0CryptoParam(TAG_ALGORITHM, Algorithm::EC);
+    CheckKm0CryptoParam(TAG_KEY_SIZE, 256U);
+    CheckKm1CryptoParam(TAG_DIGEST, Digest::SHA_2_256);
+    CheckKm2CryptoParam(TAG_EC_CURVE, EcCurve::P_256);
+
+    CheckOrigin();
+
+    string message(32, 'a');
+    auto params = AuthorizationSetBuilder().Digest(Digest::SHA_2_256);
+    string signature = SignMessage(message, params);
+    VerifyMessage(message, signature, params);
+}
+
+/*
+ * ImportKeyTest.EcdsaSizeMismatch
+ *
+ * Verifies that importing an ECDSA key pair with a size that doesn't match the key fails in the
+ * correct way.
+ */
+TEST_F(ImportKeyTest, EcdsaSizeMismatch) {
+    ASSERT_EQ(ErrorCode::IMPORT_PARAMETER_MISMATCH,
+              ImportKey(AuthorizationSetBuilder()
+                            .EcdsaSigningKey(224 /* Doesn't match key */)
+                            .Digest(Digest::NONE),
+                        KeyFormat::PKCS8, ec_key));
+}
+
+/*
+ * ImportKeyTest.EcdsaCurveMismatch
+ *
+ * Verifies that importing an ECDSA key pair with a curve that doesn't match the key fails in the
+ * correct way.
+ */
+TEST_F(ImportKeyTest, EcdsaCurveMismatch) {
+    if (SupportsSymmetric() && !SupportsAttestation()) {
+        // KM1 hardware doesn't know about curves
+        return;
+    }
+
+    ASSERT_EQ(ErrorCode::IMPORT_PARAMETER_MISMATCH,
+              ImportKey(AuthorizationSetBuilder()
+                            .EcdsaSigningKey(EcCurve::P_224 /* Doesn't match key */)
+                            .Digest(Digest::NONE),
+                        KeyFormat::PKCS8, ec_key))
+        << "(Possibly b/36233241)";
+}
+
+/*
+ * ImportKeyTest.AesSuccess
+ *
+ * Verifies that importing and using an AES key works.
+ */
+TEST_F(ImportKeyTest, AesSuccess) {
+    string key = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+    ASSERT_EQ(ErrorCode::OK, ImportKey(AuthorizationSetBuilder()
+                                           .Authorization(TAG_NO_AUTH_REQUIRED)
+                                           .AesEncryptionKey(key.size() * 8)
+                                           .EcbMode()
+                                           .Padding(PaddingMode::PKCS7),
+                                       KeyFormat::RAW, key));
+
+    CheckKm1CryptoParam(TAG_ALGORITHM, Algorithm::AES);
+    CheckKm1CryptoParam(TAG_KEY_SIZE, 128U);
+    CheckKm1CryptoParam(TAG_PADDING, PaddingMode::PKCS7);
+    CheckKm1CryptoParam(TAG_BLOCK_MODE, BlockMode::ECB);
+    CheckOrigin();
+
+    string message = "Hello World!";
+    auto params = AuthorizationSetBuilder().BlockMode(BlockMode::ECB).Padding(PaddingMode::PKCS7);
+    string ciphertext = EncryptMessage(message, params);
+    string plaintext = DecryptMessage(ciphertext, params);
+    EXPECT_EQ(message, plaintext);
+}
+
+/*
+ * ImportKeyTest.AesSuccess
+ *
+ * Verifies that importing and using an HMAC key works.
+ */
+TEST_F(ImportKeyTest, HmacKeySuccess) {
+    string key = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+    ASSERT_EQ(ErrorCode::OK, ImportKey(AuthorizationSetBuilder()
+                                           .Authorization(TAG_NO_AUTH_REQUIRED)
+                                           .HmacKey(key.size() * 8)
+                                           .Digest(Digest::SHA_2_256)
+                                           .Authorization(TAG_MIN_MAC_LENGTH, 256),
+                                       KeyFormat::RAW, key));
+
+    CheckKm1CryptoParam(TAG_ALGORITHM, Algorithm::HMAC);
+    CheckKm1CryptoParam(TAG_KEY_SIZE, 128U);
+    CheckKm1CryptoParam(TAG_DIGEST, Digest::SHA_2_256);
+    CheckOrigin();
+
+    string message = "Hello World!";
+    string signature = MacMessage(message, Digest::SHA_2_256, 256);
+    VerifyMessage(message, signature, AuthorizationSetBuilder().Digest(Digest::SHA_2_256));
+}
+
+typedef KeymasterHidlTest EncryptionOperationsTest;
+
+/*
+ * EncryptionOperationsTest.RsaNoPaddingSuccess
+ *
+ * Verifies that raw RSA encryption works.
+ */
+TEST_F(EncryptionOperationsTest, RsaNoPaddingSuccess) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .RsaEncryptionKey(1024, 3)
+                                             .Padding(PaddingMode::NONE)));
+
+    string message = string(1024 / 8, 'a');
+    auto params = AuthorizationSetBuilder().Padding(PaddingMode::NONE);
+    string ciphertext1 = EncryptMessage(message, params);
+    EXPECT_EQ(1024U / 8, ciphertext1.size());
+
+    string ciphertext2 = EncryptMessage(message, params);
+    EXPECT_EQ(1024U / 8, ciphertext2.size());
+
+    // Unpadded RSA is deterministic
+    EXPECT_EQ(ciphertext1, ciphertext2);
+}
+
+/*
+ * EncryptionOperationsTest.RsaNoPaddingShortMessage
+ *
+ * Verifies that raw RSA encryption of short messages works.
+ */
+TEST_F(EncryptionOperationsTest, RsaNoPaddingShortMessage) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .RsaEncryptionKey(1024, 3)
+                                             .Padding(PaddingMode::NONE)));
+
+    string message = "1";
+    auto params = AuthorizationSetBuilder().Padding(PaddingMode::NONE);
+
+    string ciphertext = EncryptMessage(message, params);
+    EXPECT_EQ(1024U / 8, ciphertext.size());
+
+    string expected_plaintext = string(1024 / 8 - 1, 0) + message;
+    string plaintext = DecryptMessage(ciphertext, params);
+
+    EXPECT_EQ(expected_plaintext, plaintext);
+
+    // Degenerate case, encrypting a numeric 1 yields 0x00..01 as the ciphertext.
+    message = static_cast<char>(1);
+    ciphertext = EncryptMessage(message, params);
+    EXPECT_EQ(1024U / 8, ciphertext.size());
+    EXPECT_EQ(ciphertext, string(1024 / 8 - 1, 0) + message);
+}
+
+/*
+ * EncryptionOperationsTest.RsaNoPaddingTooLong
+ *
+ * Verifies that raw RSA encryption of too-long messages fails in the expected way.
+ */
+TEST_F(EncryptionOperationsTest, RsaNoPaddingTooLong) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .RsaEncryptionKey(1024, 3)
+                                             .Padding(PaddingMode::NONE)));
+
+    string message(1024 / 8 + 1, 'a');
+
+    auto params = AuthorizationSetBuilder().Padding(PaddingMode::NONE);
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::ENCRYPT, params));
+
+    string result;
+    EXPECT_EQ(ErrorCode::INVALID_INPUT_LENGTH, Finish(message, &result));
+}
+
+/*
+ * EncryptionOperationsTest.RsaNoPaddingTooLong
+ *
+ * Verifies that raw RSA encryption of too-large (numerically) messages fails in the expected way.
+ */
+TEST_F(EncryptionOperationsTest, RsaNoPaddingTooLarge) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .RsaEncryptionKey(1024, 3)
+                                             .Padding(PaddingMode::NONE)));
+
+    HidlBuf exported;
+    ASSERT_EQ(ErrorCode::OK, ExportKey(KeyFormat::X509, &exported));
+
+    const uint8_t* p = exported.data();
+    EVP_PKEY_Ptr pkey(d2i_PUBKEY(nullptr /* alloc new */, &p, exported.size()));
+    RSA_Ptr rsa(EVP_PKEY_get1_RSA(pkey.get()));
+
+    size_t modulus_len = BN_num_bytes(rsa->n);
+    ASSERT_EQ(1024U / 8, modulus_len);
+    std::unique_ptr<uint8_t[]> modulus_buf(new uint8_t[modulus_len]);
+    BN_bn2bin(rsa->n, modulus_buf.get());
+
+    // The modulus is too big to encrypt.
+    string message(reinterpret_cast<const char*>(modulus_buf.get()), modulus_len);
+
+    auto params = AuthorizationSetBuilder().Padding(PaddingMode::NONE);
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::ENCRYPT, params));
+
+    string result;
+    EXPECT_EQ(ErrorCode::INVALID_ARGUMENT, Finish(message, &result));
+
+    // One smaller than the modulus is okay.
+    BN_sub(rsa->n, rsa->n, BN_value_one());
+    modulus_len = BN_num_bytes(rsa->n);
+    ASSERT_EQ(1024U / 8, modulus_len);
+    BN_bn2bin(rsa->n, modulus_buf.get());
+    message = string(reinterpret_cast<const char*>(modulus_buf.get()), modulus_len);
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::ENCRYPT, params));
+    EXPECT_EQ(ErrorCode::OK, Finish(message, &result));
+}
+
+/*
+ * EncryptionOperationsTest.RsaOaepSuccess
+ *
+ * Verifies that RSA-OAEP encryption operations work, with all digests.
+ */
+TEST_F(EncryptionOperationsTest, RsaOaepSuccess) {
+    auto digests = {Digest::MD5,       Digest::SHA1,      Digest::SHA_2_224,
+                    Digest::SHA_2_256, Digest::SHA_2_384, Digest::SHA_2_512};
+
+    size_t key_size = 2048;  // Need largish key for SHA-512 test.
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .RsaEncryptionKey(key_size, 3)
+                                             .Padding(PaddingMode::RSA_OAEP)
+                                             .Digest(digests)));
+
+    string message = "Hello";
+
+    for (auto digest : digests) {
+        auto params = AuthorizationSetBuilder().Digest(digest).Padding(PaddingMode::RSA_OAEP);
+        string ciphertext1 = EncryptMessage(message, params);
+        if (HasNonfatalFailure()) std::cout << "-->" << digest << std::endl;
+        EXPECT_EQ(key_size / 8, ciphertext1.size());
+
+        string ciphertext2 = EncryptMessage(message, params);
+        EXPECT_EQ(key_size / 8, ciphertext2.size());
+
+        // OAEP randomizes padding so every result should be different (with astronomically high
+        // probability).
+        EXPECT_NE(ciphertext1, ciphertext2);
+
+        string plaintext1 = DecryptMessage(ciphertext1, params);
+        EXPECT_EQ(message, plaintext1) << "RSA-OAEP failed with digest " << digest;
+        string plaintext2 = DecryptMessage(ciphertext2, params);
+        EXPECT_EQ(message, plaintext2) << "RSA-OAEP failed with digest " << digest;
+
+        // Decrypting corrupted ciphertext should fail.
+        size_t offset_to_corrupt = random() % ciphertext1.size();
+        char corrupt_byte;
+        do {
+            corrupt_byte = static_cast<char>(random() % 256);
+        } while (corrupt_byte == ciphertext1[offset_to_corrupt]);
+        ciphertext1[offset_to_corrupt] = corrupt_byte;
+
+        EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params));
+        string result;
+        EXPECT_EQ(ErrorCode::UNKNOWN_ERROR, Finish(ciphertext1, &result));
+        EXPECT_EQ(0U, result.size());
+    }
+}
+
+/*
+ * EncryptionOperationsTest.RsaOaepInvalidDigest
+ *
+ * Verifies that RSA-OAEP encryption operations fail in the correct way when asked to operate
+ * without a digest.
+ */
+TEST_F(EncryptionOperationsTest, RsaOaepInvalidDigest) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .RsaEncryptionKey(1024, 3)
+                                             .Padding(PaddingMode::RSA_OAEP)
+                                             .Digest(Digest::NONE)));
+    string message = "Hello World!";
+
+    auto params = AuthorizationSetBuilder().Padding(PaddingMode::RSA_OAEP).Digest(Digest::NONE);
+    EXPECT_EQ(ErrorCode::INCOMPATIBLE_DIGEST, Begin(KeyPurpose::ENCRYPT, params));
+}
+
+/*
+ * EncryptionOperationsTest.RsaOaepInvalidDigest
+ *
+ * Verifies that RSA-OAEP encryption operations fail in the correct way when asked to decrypt with a
+ * different digest than was used to encrypt.
+ */
+TEST_F(EncryptionOperationsTest, RsaOaepDecryptWithWrongDigest) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .RsaEncryptionKey(1024, 3)
+                                             .Padding(PaddingMode::RSA_OAEP)
+                                             .Digest(Digest::SHA_2_256, Digest::SHA_2_224)));
+    string message = "Hello World!";
+    string ciphertext = EncryptMessage(
+        message,
+        AuthorizationSetBuilder().Digest(Digest::SHA_2_224).Padding(PaddingMode::RSA_OAEP));
+
+    EXPECT_EQ(
+        ErrorCode::OK,
+        Begin(KeyPurpose::DECRYPT,
+              AuthorizationSetBuilder().Digest(Digest::SHA_2_256).Padding(PaddingMode::RSA_OAEP)));
+    string result;
+    EXPECT_EQ(ErrorCode::UNKNOWN_ERROR, Finish(ciphertext, &result));
+    EXPECT_EQ(0U, result.size());
+}
+
+/*
+ * EncryptionOperationsTest.RsaOaepTooLarge
+ *
+ * Verifies that RSA-OAEP encryption operations fail in the correct way when asked to encrypt a
+ * too-large message.
+ */
+TEST_F(EncryptionOperationsTest, RsaOaepTooLarge) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .RsaEncryptionKey(1024, 3)
+                                             .Padding(PaddingMode::RSA_OAEP)
+                                             .Digest(Digest::SHA1)));
+    constexpr size_t digest_size = 160 /* SHA1 */ / 8;
+    constexpr size_t oaep_overhead = 2 * digest_size + 2;
+    string message(1024 / 8 - oaep_overhead + 1, 'a');
+    EXPECT_EQ(ErrorCode::OK,
+              Begin(KeyPurpose::ENCRYPT,
+                    AuthorizationSetBuilder().Padding(PaddingMode::RSA_OAEP).Digest(Digest::SHA1)));
+    string result;
+    EXPECT_EQ(ErrorCode::INVALID_INPUT_LENGTH, Finish(message, &result));
+    EXPECT_EQ(0U, result.size());
+}
+
+/*
+ * EncryptionOperationsTest.RsaPkcs1Success
+ *
+ * Verifies that RSA PKCS encryption/decrypts works.
+ */
+TEST_F(EncryptionOperationsTest, RsaPkcs1Success) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .RsaEncryptionKey(1024, 3)
+                                             .Padding(PaddingMode::RSA_PKCS1_1_5_ENCRYPT)));
+
+    string message = "Hello World!";
+    auto params = AuthorizationSetBuilder().Padding(PaddingMode::RSA_PKCS1_1_5_ENCRYPT);
+    string ciphertext1 = EncryptMessage(message, params);
+    EXPECT_EQ(1024U / 8, ciphertext1.size());
+
+    string ciphertext2 = EncryptMessage(message, params);
+    EXPECT_EQ(1024U / 8, ciphertext2.size());
+
+    // PKCS1 v1.5 randomizes padding so every result should be different.
+    EXPECT_NE(ciphertext1, ciphertext2);
+
+    string plaintext = DecryptMessage(ciphertext1, params);
+    EXPECT_EQ(message, plaintext);
+
+    // Decrypting corrupted ciphertext should fail.
+    size_t offset_to_corrupt = random() % ciphertext1.size();
+    char corrupt_byte;
+    do {
+        corrupt_byte = static_cast<char>(random() % 256);
+    } while (corrupt_byte == ciphertext1[offset_to_corrupt]);
+    ciphertext1[offset_to_corrupt] = corrupt_byte;
+
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params));
+    string result;
+    EXPECT_EQ(ErrorCode::UNKNOWN_ERROR, Finish(ciphertext1, &result));
+    EXPECT_EQ(0U, result.size());
+}
+
+/*
+ * EncryptionOperationsTest.RsaPkcs1TooLarge
+ *
+ * Verifies that RSA PKCS encryption fails in the correct way when the mssage is too large.
+ */
+TEST_F(EncryptionOperationsTest, RsaPkcs1TooLarge) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .RsaEncryptionKey(1024, 3)
+                                             .Padding(PaddingMode::RSA_PKCS1_1_5_ENCRYPT)));
+    string message(1024 / 8 - 10, 'a');
+
+    auto params = AuthorizationSetBuilder().Padding(PaddingMode::RSA_PKCS1_1_5_ENCRYPT);
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::ENCRYPT, params));
+    string result;
+    EXPECT_EQ(ErrorCode::INVALID_INPUT_LENGTH, Finish(message, &result));
+    EXPECT_EQ(0U, result.size());
+}
+
+/*
+ * EncryptionOperationsTest.EcdsaEncrypt
+ *
+ * Verifies that attempting to use ECDSA keys to encrypt fails in the correct way.
+ */
+TEST_F(EncryptionOperationsTest, EcdsaEncrypt) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .EcdsaSigningKey(224)
+                                             .Digest(Digest::NONE)));
+    auto params = AuthorizationSetBuilder().Digest(Digest::NONE);
+    ASSERT_EQ(ErrorCode::UNSUPPORTED_PURPOSE, Begin(KeyPurpose::ENCRYPT, params))
+        << "(Possibly b/33543625)";
+    ASSERT_EQ(ErrorCode::UNSUPPORTED_PURPOSE, Begin(KeyPurpose::DECRYPT, params))
+        << "(Possibly b/33543625)";
+}
+
+/*
+ * EncryptionOperationsTest.HmacEncrypt
+ *
+ * Verifies that attempting to use HMAC keys to encrypt fails in the correct way.
+ */
+TEST_F(EncryptionOperationsTest, HmacEncrypt) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .HmacKey(128)
+                                             .Digest(Digest::SHA_2_256)
+                                             .Padding(PaddingMode::NONE)
+                                             .Authorization(TAG_MIN_MAC_LENGTH, 128)));
+    auto params = AuthorizationSetBuilder()
+                      .Digest(Digest::SHA_2_256)
+                      .Padding(PaddingMode::NONE)
+                      .Authorization(TAG_MAC_LENGTH, 128);
+    ASSERT_EQ(ErrorCode::UNSUPPORTED_PURPOSE, Begin(KeyPurpose::ENCRYPT, params))
+        << "(Possibly b/33543625)";
+    ASSERT_EQ(ErrorCode::UNSUPPORTED_PURPOSE, Begin(KeyPurpose::DECRYPT, params))
+        << "(Possibly b/33543625)";
+}
+
+/*
+ * EncryptionOperationsTest.AesEcbRoundTripSuccess
+ *
+ * Verifies that AES ECB mode works.
+ */
+TEST_F(EncryptionOperationsTest, AesEcbRoundTripSuccess) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .Authorization(TAG_BLOCK_MODE, BlockMode::ECB)
+                                             .Padding(PaddingMode::NONE)));
+
+    auto params = AuthorizationSetBuilder().BlockMode(BlockMode::ECB).Padding(PaddingMode::NONE);
+
+    // Two-block message.
+    string message = "12345678901234567890123456789012";
+    string ciphertext1 = EncryptMessage(message, params);
+    EXPECT_EQ(message.size(), ciphertext1.size());
+
+    string ciphertext2 = EncryptMessage(string(message), params);
+    EXPECT_EQ(message.size(), ciphertext2.size());
+
+    // ECB is deterministic.
+    EXPECT_EQ(ciphertext1, ciphertext2);
+
+    string plaintext = DecryptMessage(ciphertext1, params);
+    EXPECT_EQ(message, plaintext);
+}
+
+/*
+ * EncryptionOperationsTest.AesEcbRoundTripSuccess
+ *
+ * Verifies that AES encryption fails in the correct way when an unauthorized mode is specified.
+ */
+TEST_F(EncryptionOperationsTest, AesWrongMode) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .Authorization(TAG_BLOCK_MODE, BlockMode::CBC)
+                                             .Padding(PaddingMode::NONE)));
+    // Two-block message.
+    string message = "12345678901234567890123456789012";
+    EXPECT_EQ(
+        ErrorCode::INCOMPATIBLE_BLOCK_MODE,
+        Begin(KeyPurpose::ENCRYPT,
+              AuthorizationSetBuilder().BlockMode(BlockMode::ECB).Padding(PaddingMode::NONE)));
+}
+
+/*
+ * EncryptionOperationsTest.AesEcbNoPaddingWrongInputSize
+ *
+ * Verifies that AES encryption fails in the correct way when provided an input that is not a
+ * multiple of the block size and no padding is specified.
+ */
+TEST_F(EncryptionOperationsTest, AesEcbNoPaddingWrongInputSize) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .Authorization(TAG_BLOCK_MODE, BlockMode::ECB)
+                                             .Padding(PaddingMode::NONE)));
+    // Message is slightly shorter than two blocks.
+    string message(16 * 2 - 1, 'a');
+
+    auto params = AuthorizationSetBuilder().BlockMode(BlockMode::ECB).Padding(PaddingMode::NONE);
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::ENCRYPT, params));
+    string ciphertext;
+    EXPECT_EQ(ErrorCode::INVALID_INPUT_LENGTH, Finish(message, &ciphertext));
+    EXPECT_EQ(0U, ciphertext.size());
+}
+
+/*
+ * EncryptionOperationsTest.AesEcbPkcs7Padding
+ *
+ * Verifies that AES PKCS7 padding works for any message length.
+ */
+TEST_F(EncryptionOperationsTest, AesEcbPkcs7Padding) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .Authorization(TAG_BLOCK_MODE, BlockMode::ECB)
+                                             .Padding(PaddingMode::PKCS7)));
+
+    auto params = AuthorizationSetBuilder().BlockMode(BlockMode::ECB).Padding(PaddingMode::PKCS7);
+
+    // Try various message lengths; all should work.
+    for (size_t i = 0; i < 32; ++i) {
+        string message(i, 'a');
+        string ciphertext = EncryptMessage(message, params);
+        EXPECT_EQ(i + 16 - (i % 16), ciphertext.size());
+        string plaintext = DecryptMessage(ciphertext, params);
+        EXPECT_EQ(message, plaintext);
+    }
+}
+
+/*
+ * EncryptionOperationsTest.AesEcbWrongPadding
+ *
+ * Verifies that AES enryption fails in the correct way when an unauthorized padding mode is
+ * specified.
+ */
+TEST_F(EncryptionOperationsTest, AesEcbWrongPadding) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .Authorization(TAG_BLOCK_MODE, BlockMode::ECB)
+                                             .Padding(PaddingMode::NONE)));
+
+    auto params = AuthorizationSetBuilder().BlockMode(BlockMode::ECB).Padding(PaddingMode::PKCS7);
+
+    // Try various message lengths; all should fail
+    for (size_t i = 0; i < 32; ++i) {
+        string message(i, 'a');
+        EXPECT_EQ(ErrorCode::INCOMPATIBLE_PADDING_MODE, Begin(KeyPurpose::ENCRYPT, params));
+    }
+}
+
+/*
+ * EncryptionOperationsTest.AesEcbPkcs7PaddingCorrupted
+ *
+ * Verifies that AES decryption fails in the correct way when the padding is corrupted.
+ */
+TEST_F(EncryptionOperationsTest, AesEcbPkcs7PaddingCorrupted) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .Authorization(TAG_BLOCK_MODE, BlockMode::ECB)
+                                             .Padding(PaddingMode::PKCS7)));
+
+    auto params = AuthorizationSetBuilder().BlockMode(BlockMode::ECB).Padding(PaddingMode::PKCS7);
+
+    string message = "a";
+    string ciphertext = EncryptMessage(message, params);
+    EXPECT_EQ(16U, ciphertext.size());
+    EXPECT_NE(ciphertext, message);
+    ++ciphertext[ciphertext.size() / 2];
+
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params));
+    string plaintext;
+    EXPECT_EQ(ErrorCode::INVALID_INPUT_LENGTH, Finish(message, &plaintext));
+}
+
+HidlBuf CopyIv(const AuthorizationSet& set) {
+    auto iv = set.GetTagValue(TAG_NONCE);
+    EXPECT_TRUE(iv.isOk());
+    return iv.value();
+}
+
+/*
+ * EncryptionOperationsTest.AesCtrRoundTripSuccess
+ *
+ * Verifies that AES CTR mode works.
+ */
+TEST_F(EncryptionOperationsTest, AesCtrRoundTripSuccess) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .Authorization(TAG_BLOCK_MODE, BlockMode::CTR)
+                                             .Padding(PaddingMode::NONE)));
+
+    auto params = AuthorizationSetBuilder().BlockMode(BlockMode::CTR).Padding(PaddingMode::NONE);
+
+    string message = "123";
+    AuthorizationSet out_params;
+    string ciphertext1 = EncryptMessage(message, params, &out_params);
+    HidlBuf iv1 = CopyIv(out_params);
+    EXPECT_EQ(16U, iv1.size());
+
+    EXPECT_EQ(message.size(), ciphertext1.size());
+
+    out_params.Clear();
+    string ciphertext2 = EncryptMessage(message, params, &out_params);
+    HidlBuf iv2 = CopyIv(out_params);
+    EXPECT_EQ(16U, iv2.size());
+
+    // IVs should be random, so ciphertexts should differ.
+    EXPECT_NE(ciphertext1, ciphertext2);
+
+    auto params_iv1 =
+        AuthorizationSetBuilder().Authorizations(params).Authorization(TAG_NONCE, iv1);
+    auto params_iv2 =
+        AuthorizationSetBuilder().Authorizations(params).Authorization(TAG_NONCE, iv2);
+
+    string plaintext = DecryptMessage(ciphertext1, params_iv1);
+    EXPECT_EQ(message, plaintext);
+    plaintext = DecryptMessage(ciphertext2, params_iv2);
+    EXPECT_EQ(message, plaintext);
+
+    // Using the wrong IV will result in a "valid" decryption, but the data will be garbage.
+    plaintext = DecryptMessage(ciphertext1, params_iv2);
+    EXPECT_NE(message, plaintext);
+    plaintext = DecryptMessage(ciphertext2, params_iv1);
+    EXPECT_NE(message, plaintext);
+}
+
+/*
+ * EncryptionOperationsTest.AesIncremental
+ *
+ * Verifies that AES works, all modes, when provided data in various size increments.
+ */
+TEST_F(EncryptionOperationsTest, AesIncremental) {
+    auto block_modes = {
+        BlockMode::ECB, BlockMode::CBC, BlockMode::CTR, BlockMode::GCM,
+    };
+
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .BlockMode(block_modes)
+                                             .Padding(PaddingMode::NONE)
+                                             .Authorization(TAG_MIN_MAC_LENGTH, 128)));
+
+    for (int increment = 1; increment <= 240; ++increment) {
+        for (auto block_mode : block_modes) {
+            string message(240, 'a');
+            auto params = AuthorizationSetBuilder()
+                              .BlockMode(block_mode)
+                              .Padding(PaddingMode::NONE)
+                              .Authorization(TAG_MAC_LENGTH, 128) /* for GCM */;
+
+            AuthorizationSet output_params;
+            EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::ENCRYPT, params, &output_params));
+
+            string ciphertext;
+            size_t input_consumed;
+            string to_send;
+            for (size_t i = 0; i < message.size(); i += increment) {
+                to_send.append(message.substr(i, increment));
+                EXPECT_EQ(ErrorCode::OK, Update(to_send, &ciphertext, &input_consumed));
+                to_send = to_send.substr(input_consumed);
+
+                switch (block_mode) {
+                case BlockMode::ECB:
+                case BlockMode::CBC:
+                    // Implementations must take as many blocks as possible, leaving less than
+                    // a block.
+                    EXPECT_LE(to_send.length(), 16U);
+                    break;
+                case BlockMode::GCM:
+                case BlockMode::CTR:
+                    // Implementations must always take all the data.
+                    EXPECT_EQ(0U, to_send.length());
+                    break;
+                }
+            }
+            EXPECT_EQ(ErrorCode::OK, Finish(to_send, &ciphertext)) << "Error sending " << to_send;
+
+            switch (block_mode) {
+            case BlockMode::GCM:
+                EXPECT_EQ(message.size() + 16, ciphertext.size());
+                break;
+            case BlockMode::CTR:
+                EXPECT_EQ(message.size(), ciphertext.size());
+                break;
+            case BlockMode::CBC:
+            case BlockMode::ECB:
+                EXPECT_EQ(message.size() + message.size() % 16, ciphertext.size());
+                break;
+            }
+
+            auto iv = output_params.GetTagValue(TAG_NONCE);
+            switch (block_mode) {
+            case BlockMode::CBC:
+            case BlockMode::GCM:
+            case BlockMode::CTR:
+                ASSERT_TRUE(iv.isOk()) << "No IV for block mode " << block_mode;
+                EXPECT_EQ(block_mode == BlockMode::GCM ? 12U : 16U, iv.value().size());
+                params.push_back(TAG_NONCE, iv.value());
+                break;
+
+            case BlockMode::ECB:
+                EXPECT_FALSE(iv.isOk()) << "ECB mode should not generate IV";
+                break;
+            }
+
+            EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params))
+                << "Decrypt begin() failed for block mode " << block_mode;
+
+            string plaintext;
+            for (size_t i = 0; i < ciphertext.size(); i += increment) {
+                to_send.append(ciphertext.substr(i, increment));
+                EXPECT_EQ(ErrorCode::OK, Update(to_send, &plaintext, &input_consumed));
+                to_send = to_send.substr(input_consumed);
+            }
+            ErrorCode error = Finish(to_send, &plaintext);
+            ASSERT_EQ(ErrorCode::OK, error)
+                << "Decryption failed for block mode " << block_mode << " and increment "
+                << increment << " (Possibly b/33584622)";
+            if (error == ErrorCode::OK) {
+                ASSERT_EQ(message, plaintext) << "Decryption didn't match for block mode "
+                                              << block_mode << " and increment " << increment;
+            }
+        }
+    }
+}
+
+struct AesCtrSp80038aTestVector {
+    const char* key;
+    const char* nonce;
+    const char* plaintext;
+    const char* ciphertext;
+};
+
+// These test vectors are taken from
+// http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf, section F.5.
+static const AesCtrSp80038aTestVector kAesCtrSp80038aTestVectors[] = {
+    // AES-128
+    {
+        "2b7e151628aed2a6abf7158809cf4f3c", "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff",
+        "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e51"
+        "30c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710",
+        "874d6191b620e3261bef6864990db6ce9806f66b7970fdff8617187bb9fffdff"
+        "5ae4df3edbd5d35e5b4f09020db03eab1e031dda2fbe03d1792170a0f3009cee",
+    },
+    // AES-192
+    {
+        "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff",
+        "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e51"
+        "30c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710",
+        "1abc932417521ca24f2b0459fe7e6e0b090339ec0aa6faefd5ccc2c6f4ce8e94"
+        "1e36b26bd1ebc670d1bd1d665620abf74f78a7f6d29809585a97daec58c6b050",
+    },
+    // AES-256
+    {
+        "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4",
+        "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff",
+        "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e51"
+        "30c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710",
+        "601ec313775789a5b7a7f504bbf3d228f443e3ca4d62b59aca84e990cacaf5c5"
+        "2b0930daa23de94ce87017ba2d84988ddfc9c58db67aada613c2dd08457941a6",
+    },
+};
+
+/*
+ * EncryptionOperationsTest.AesCtrSp80038aTestVector
+ *
+ * Verifies AES CTR implementation against SP800-38A test vectors.
+ */
+TEST_F(EncryptionOperationsTest, AesCtrSp80038aTestVector) {
+    for (size_t i = 0; i < 3; i++) {
+        const AesCtrSp80038aTestVector& test(kAesCtrSp80038aTestVectors[i]);
+        const string key = hex2str(test.key);
+        const string nonce = hex2str(test.nonce);
+        const string plaintext = hex2str(test.plaintext);
+        const string ciphertext = hex2str(test.ciphertext);
+        CheckAesCtrTestVector(key, nonce, plaintext, ciphertext);
+    }
+}
+
+/*
+ * EncryptionOperationsTest.AesCtrIncompatiblePaddingMode
+ *
+ * Verifies that keymaster rejects use of CTR mode with PKCS7 padding in the correct way.
+ */
+TEST_F(EncryptionOperationsTest, AesCtrIncompatiblePaddingMode) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .Authorization(TAG_BLOCK_MODE, BlockMode::CTR)
+                                             .Padding(PaddingMode::PKCS7)));
+    auto params = AuthorizationSetBuilder().BlockMode(BlockMode::CTR).Padding(PaddingMode::NONE);
+    EXPECT_EQ(ErrorCode::INCOMPATIBLE_PADDING_MODE, Begin(KeyPurpose::ENCRYPT, params));
+}
+
+/*
+ * EncryptionOperationsTest.AesCtrInvalidCallerNonce
+ *
+ * Verifies that keymaster fails correctly when the user supplies an incorrect-size nonce.
+ */
+TEST_F(EncryptionOperationsTest, AesCtrInvalidCallerNonce) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .Authorization(TAG_BLOCK_MODE, BlockMode::CTR)
+                                             .Authorization(TAG_CALLER_NONCE)
+                                             .Padding(PaddingMode::NONE)));
+
+    auto params = AuthorizationSetBuilder()
+                      .BlockMode(BlockMode::CTR)
+                      .Padding(PaddingMode::NONE)
+                      .Authorization(TAG_NONCE, HidlBuf(string(1, 'a')));
+    EXPECT_EQ(ErrorCode::INVALID_NONCE, Begin(KeyPurpose::ENCRYPT, params));
+
+    params = AuthorizationSetBuilder()
+                 .BlockMode(BlockMode::CTR)
+                 .Padding(PaddingMode::NONE)
+                 .Authorization(TAG_NONCE, HidlBuf(string(15, 'a')));
+    EXPECT_EQ(ErrorCode::INVALID_NONCE, Begin(KeyPurpose::ENCRYPT, params));
+
+    params = AuthorizationSetBuilder()
+                 .BlockMode(BlockMode::CTR)
+                 .Padding(PaddingMode::NONE)
+                 .Authorization(TAG_NONCE, HidlBuf(string(17, 'a')));
+    EXPECT_EQ(ErrorCode::INVALID_NONCE, Begin(KeyPurpose::ENCRYPT, params));
+}
+
+/*
+ * EncryptionOperationsTest.AesCtrInvalidCallerNonce
+ *
+ * Verifies that keymaster fails correctly when the user supplies an incorrect-size nonce.
+ */
+TEST_F(EncryptionOperationsTest, AesCbcRoundTripSuccess) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .Authorization(TAG_BLOCK_MODE, BlockMode::CBC)
+                                             .Padding(PaddingMode::NONE)));
+    // Two-block message.
+    string message = "12345678901234567890123456789012";
+    auto params = AuthorizationSetBuilder().BlockMode(BlockMode::CBC).Padding(PaddingMode::NONE);
+    AuthorizationSet out_params;
+    string ciphertext1 = EncryptMessage(message, params, &out_params);
+    HidlBuf iv1 = CopyIv(out_params);
+    EXPECT_EQ(message.size(), ciphertext1.size());
+
+    out_params.Clear();
+
+    string ciphertext2 = EncryptMessage(message, params, &out_params);
+    HidlBuf iv2 = CopyIv(out_params);
+    EXPECT_EQ(message.size(), ciphertext2.size());
+
+    // IVs should be random, so ciphertexts should differ.
+    EXPECT_NE(ciphertext1, ciphertext2);
+
+    params.push_back(TAG_NONCE, iv1);
+    string plaintext = DecryptMessage(ciphertext1, params);
+    EXPECT_EQ(message, plaintext);
+}
+
+/*
+ * EncryptionOperationsTest.AesCallerNonce
+ *
+ * Verifies that AES caller-provided nonces work correctly.
+ */
+TEST_F(EncryptionOperationsTest, AesCallerNonce) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .Authorization(TAG_BLOCK_MODE, BlockMode::CBC)
+                                             .Authorization(TAG_CALLER_NONCE)
+                                             .Padding(PaddingMode::NONE)));
+
+    string message = "12345678901234567890123456789012";
+
+    // Don't specify nonce, should get a random one.
+    AuthorizationSetBuilder params =
+        AuthorizationSetBuilder().BlockMode(BlockMode::CBC).Padding(PaddingMode::NONE);
+    AuthorizationSet out_params;
+    string ciphertext = EncryptMessage(message, params, &out_params);
+    EXPECT_EQ(message.size(), ciphertext.size());
+    EXPECT_EQ(16U, out_params.GetTagValue(TAG_NONCE).value().size());
+
+    params.push_back(TAG_NONCE, out_params.GetTagValue(TAG_NONCE).value());
+    string plaintext = DecryptMessage(ciphertext, params);
+    EXPECT_EQ(message, plaintext);
+
+    // Now specify a nonce, should also work.
+    params = AuthorizationSetBuilder()
+                 .BlockMode(BlockMode::CBC)
+                 .Padding(PaddingMode::NONE)
+                 .Authorization(TAG_NONCE, HidlBuf("abcdefghijklmnop"));
+    out_params.Clear();
+    ciphertext = EncryptMessage(message, params, &out_params);
+
+    // Decrypt with correct nonce.
+    plaintext = DecryptMessage(ciphertext, params);
+    EXPECT_EQ(message, plaintext);
+
+    // Try with wrong nonce.
+    params = AuthorizationSetBuilder()
+                 .BlockMode(BlockMode::CBC)
+                 .Padding(PaddingMode::NONE)
+                 .Authorization(TAG_NONCE, HidlBuf("aaaaaaaaaaaaaaaa"));
+    plaintext = DecryptMessage(ciphertext, params);
+    EXPECT_NE(message, plaintext);
+}
+
+/*
+ * EncryptionOperationsTest.AesCallerNonceProhibited
+ *
+ * Verifies that caller-provided nonces are not permitted when not specified in the key
+ * authorizations.
+ */
+TEST_F(EncryptionOperationsTest, AesCallerNonceProhibited) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .Authorization(TAG_BLOCK_MODE, BlockMode::CBC)
+                                             .Padding(PaddingMode::NONE)));
+
+    string message = "12345678901234567890123456789012";
+
+    // Don't specify nonce, should get a random one.
+    AuthorizationSetBuilder params =
+        AuthorizationSetBuilder().BlockMode(BlockMode::CBC).Padding(PaddingMode::NONE);
+    AuthorizationSet out_params;
+    string ciphertext = EncryptMessage(message, params, &out_params);
+    EXPECT_EQ(message.size(), ciphertext.size());
+    EXPECT_EQ(16U, out_params.GetTagValue(TAG_NONCE).value().size());
+
+    params.push_back(TAG_NONCE, out_params.GetTagValue(TAG_NONCE).value());
+    string plaintext = DecryptMessage(ciphertext, params);
+    EXPECT_EQ(message, plaintext);
+
+    // Now specify a nonce, should fail
+    params = AuthorizationSetBuilder()
+                 .BlockMode(BlockMode::CBC)
+                 .Padding(PaddingMode::NONE)
+                 .Authorization(TAG_NONCE, HidlBuf("abcdefghijklmnop"));
+    out_params.Clear();
+    EXPECT_EQ(ErrorCode::CALLER_NONCE_PROHIBITED, Begin(KeyPurpose::ENCRYPT, params, &out_params));
+}
+
+/*
+ * EncryptionOperationsTest.AesGcmRoundTripSuccess
+ *
+ * Verifies that AES GCM mode works.
+ */
+TEST_F(EncryptionOperationsTest, AesGcmRoundTripSuccess) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .Authorization(TAG_BLOCK_MODE, BlockMode::GCM)
+                                             .Padding(PaddingMode::NONE)
+                                             .Authorization(TAG_MIN_MAC_LENGTH, 128)));
+
+    string aad = "foobar";
+    string message = "123456789012345678901234567890123456";
+
+    auto begin_params = AuthorizationSetBuilder()
+                            .BlockMode(BlockMode::GCM)
+                            .Padding(PaddingMode::NONE)
+                            .Authorization(TAG_MAC_LENGTH, 128);
+
+    auto update_params =
+        AuthorizationSetBuilder().Authorization(TAG_ASSOCIATED_DATA, aad.data(), aad.size());
+
+    // Encrypt
+    AuthorizationSet begin_out_params;
+    ASSERT_EQ(ErrorCode::OK, Begin(KeyPurpose::ENCRYPT, begin_params, &begin_out_params))
+        << "Begin encrypt";
+    string ciphertext;
+    AuthorizationSet update_out_params;
+    ASSERT_EQ(ErrorCode::OK,
+              Finish(op_handle_, update_params, message, "", &update_out_params, &ciphertext));
+
+    // Grab nonce
+    begin_params.push_back(begin_out_params);
+
+    // Decrypt.
+    ASSERT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, begin_params)) << "Begin decrypt";
+    string plaintext;
+    size_t input_consumed;
+    ASSERT_EQ(ErrorCode::OK, Update(op_handle_, update_params, ciphertext, &update_out_params,
+                                    &plaintext, &input_consumed));
+    EXPECT_EQ(ciphertext.size(), input_consumed);
+    EXPECT_EQ(ErrorCode::OK, Finish("", &plaintext));
+
+    EXPECT_EQ(message, plaintext);
+}
+
+/*
+ * EncryptionOperationsTest.AesGcmTooShortTag
+ *
+ * Verifies that AES GCM mode fails correctly when a too-short tag length is specified.
+ */
+TEST_F(EncryptionOperationsTest, AesGcmTooShortTag) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .BlockMode(BlockMode::GCM)
+                                             .Padding(PaddingMode::NONE)
+                                             .Authorization(TAG_MIN_MAC_LENGTH, 128)));
+    string message = "123456789012345678901234567890123456";
+    auto params = AuthorizationSetBuilder()
+                      .BlockMode(BlockMode::GCM)
+                      .Padding(PaddingMode::NONE)
+                      .Authorization(TAG_MAC_LENGTH, 96);
+
+    EXPECT_EQ(ErrorCode::INVALID_MAC_LENGTH, Begin(KeyPurpose::ENCRYPT, params));
+}
+
+/*
+ * EncryptionOperationsTest.AesGcmTooShortTagOnDecrypt
+ *
+ * Verifies that AES GCM mode fails correctly when a too-short tag is provided to decryption.
+ */
+TEST_F(EncryptionOperationsTest, AesGcmTooShortTagOnDecrypt) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .BlockMode(BlockMode::GCM)
+                                             .Padding(PaddingMode::NONE)
+                                             .Authorization(TAG_MIN_MAC_LENGTH, 128)));
+    string aad = "foobar";
+    string message = "123456789012345678901234567890123456";
+    auto params = AuthorizationSetBuilder()
+                      .BlockMode(BlockMode::GCM)
+                      .Padding(PaddingMode::NONE)
+                      .Authorization(TAG_MAC_LENGTH, 128);
+
+    auto finish_params =
+        AuthorizationSetBuilder().Authorization(TAG_ASSOCIATED_DATA, aad.data(), aad.size());
+
+    // Encrypt
+    AuthorizationSet begin_out_params;
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::ENCRYPT, params, &begin_out_params));
+    EXPECT_EQ(1U, begin_out_params.size());
+    ASSERT_TRUE(begin_out_params.GetTagValue(TAG_NONCE).isOk());
+
+    AuthorizationSet finish_out_params;
+    string ciphertext;
+    EXPECT_EQ(ErrorCode::OK, Finish(op_handle_, finish_params, message, "" /* signature */,
+                                    &finish_out_params, &ciphertext));
+
+    params = AuthorizationSetBuilder()
+                 .Authorizations(begin_out_params)
+                 .BlockMode(BlockMode::GCM)
+                 .Padding(PaddingMode::NONE)
+                 .Authorization(TAG_MAC_LENGTH, 96);
+
+    // Decrypt.
+    EXPECT_EQ(ErrorCode::INVALID_MAC_LENGTH, Begin(KeyPurpose::DECRYPT, params));
+}
+
+/*
+ * EncryptionOperationsTest.AesGcmCorruptKey
+ *
+ * Verifies that AES GCM mode fails correctly when the decryption key is incorrect.
+ */
+TEST_F(EncryptionOperationsTest, AesGcmCorruptKey) {
+    const uint8_t nonce_bytes[] = {
+        0xb7, 0x94, 0x37, 0xae, 0x08, 0xff, 0x35, 0x5d, 0x7d, 0x8a, 0x4d, 0x0f,
+    };
+    string nonce = make_string(nonce_bytes);
+    const uint8_t ciphertext_bytes[] = {
+        0xb3, 0xf6, 0x79, 0x9e, 0x8f, 0x93, 0x26, 0xf2, 0xdf, 0x1e, 0x80, 0xfc, 0xd2, 0xcb, 0x16,
+        0xd7, 0x8c, 0x9d, 0xc7, 0xcc, 0x14, 0xbb, 0x67, 0x78, 0x62, 0xdc, 0x6c, 0x63, 0x9b, 0x3a,
+        0x63, 0x38, 0xd2, 0x4b, 0x31, 0x2d, 0x39, 0x89, 0xe5, 0x92, 0x0b, 0x5d, 0xbf, 0xc9, 0x76,
+        0x76, 0x5e, 0xfb, 0xfe, 0x57, 0xbb, 0x38, 0x59, 0x40, 0xa7, 0xa4, 0x3b, 0xdf, 0x05, 0xbd,
+        0xda, 0xe3, 0xc9, 0xd6, 0xa2, 0xfb, 0xbd, 0xfc, 0xc0, 0xcb, 0xa0,
+    };
+    string ciphertext = make_string(ciphertext_bytes);
+
+    auto params = AuthorizationSetBuilder()
+                      .BlockMode(BlockMode::GCM)
+                      .Padding(PaddingMode::NONE)
+                      .Authorization(TAG_MAC_LENGTH, 128)
+                      .Authorization(TAG_NONCE, nonce.data(), nonce.size());
+
+    auto import_params = AuthorizationSetBuilder()
+                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                             .AesEncryptionKey(128)
+                             .BlockMode(BlockMode::GCM)
+                             .Padding(PaddingMode::NONE)
+                             .Authorization(TAG_CALLER_NONCE)
+                             .Authorization(TAG_MIN_MAC_LENGTH, 128);
+
+    // Import correct key and decrypt
+    const uint8_t key_bytes[] = {
+        0xba, 0x76, 0x35, 0x4f, 0x0a, 0xed, 0x6e, 0x8d,
+        0x91, 0xf4, 0x5c, 0x4f, 0xf5, 0xa0, 0x62, 0xdb,
+    };
+    string key = make_string(key_bytes);
+    ASSERT_EQ(ErrorCode::OK, ImportKey(import_params, KeyFormat::RAW, key));
+    string plaintext = DecryptMessage(ciphertext, params);
+    EXPECT_EQ(ErrorCode::OK, DeleteKey());
+
+    // Corrupt key and attempt to decrypt
+    key[0] = 0;
+    ASSERT_EQ(ErrorCode::OK, ImportKey(import_params, KeyFormat::RAW, key));
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params));
+    EXPECT_EQ(ErrorCode::VERIFICATION_FAILED, Finish(ciphertext, &plaintext));
+    EXPECT_EQ(ErrorCode::OK, DeleteKey());
+}
+
+/*
+ * EncryptionOperationsTest.AesGcmAadNoData
+ *
+ * Verifies that AES GCM mode works when provided additional authenticated data, but no data to
+ * encrypt.
+ */
+TEST_F(EncryptionOperationsTest, AesGcmAadNoData) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .BlockMode(BlockMode::GCM)
+                                             .Padding(PaddingMode::NONE)
+                                             .Authorization(TAG_MIN_MAC_LENGTH, 128)));
+
+    string aad = "1234567890123456";
+    auto params = AuthorizationSetBuilder()
+                      .BlockMode(BlockMode::GCM)
+                      .Padding(PaddingMode::NONE)
+                      .Authorization(TAG_MAC_LENGTH, 128);
+
+    auto finish_params =
+        AuthorizationSetBuilder().Authorization(TAG_ASSOCIATED_DATA, aad.data(), aad.size());
+
+    // Encrypt
+    AuthorizationSet begin_out_params;
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::ENCRYPT, params, &begin_out_params));
+    string ciphertext;
+    AuthorizationSet finish_out_params;
+    EXPECT_EQ(ErrorCode::OK, Finish(op_handle_, finish_params, "" /* input */, "" /* signature */,
+                                    &finish_out_params, &ciphertext));
+    EXPECT_TRUE(finish_out_params.empty());
+
+    // Grab nonce
+    params.push_back(begin_out_params);
+
+    // Decrypt.
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params));
+    string plaintext;
+    EXPECT_EQ(ErrorCode::OK, Finish(op_handle_, finish_params, ciphertext, "" /* signature */,
+                                    &finish_out_params, &plaintext))
+        << "(Possibly b/33615032)";
+
+    EXPECT_TRUE(finish_out_params.empty());
+
+    EXPECT_EQ("", plaintext);
+}
+
+/*
+ * EncryptionOperationsTest.AesGcmMultiPartAad
+ *
+ * Verifies that AES GCM mode works when provided additional authenticated data in multiple chunks.
+ */
+TEST_F(EncryptionOperationsTest, AesGcmMultiPartAad) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .BlockMode(BlockMode::GCM)
+                                             .Padding(PaddingMode::NONE)
+                                             .Authorization(TAG_MIN_MAC_LENGTH, 128)));
+
+    string message = "123456789012345678901234567890123456";
+    auto begin_params = AuthorizationSetBuilder()
+                            .BlockMode(BlockMode::GCM)
+                            .Padding(PaddingMode::NONE)
+                            .Authorization(TAG_MAC_LENGTH, 128);
+    AuthorizationSet begin_out_params;
+
+    auto update_params =
+        AuthorizationSetBuilder().Authorization(TAG_ASSOCIATED_DATA, "foo", (size_t)3);
+
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::ENCRYPT, begin_params, &begin_out_params));
+
+    // No data, AAD only.
+    string ciphertext;
+    size_t input_consumed;
+    AuthorizationSet update_out_params;
+    EXPECT_EQ(ErrorCode::OK, Update(op_handle_, update_params, "" /* input */, &update_out_params,
+                                    &ciphertext, &input_consumed));
+    EXPECT_EQ(0U, input_consumed);
+    EXPECT_EQ(0U, ciphertext.size());
+    EXPECT_TRUE(update_out_params.empty());
+
+    // AAD and data.
+    EXPECT_EQ(ErrorCode::OK, Update(op_handle_, update_params, message, &update_out_params,
+                                    &ciphertext, &input_consumed));
+    EXPECT_EQ(message.size(), input_consumed);
+    EXPECT_EQ(message.size(), ciphertext.size());
+    EXPECT_TRUE(update_out_params.empty());
+
+    EXPECT_EQ(ErrorCode::OK, Finish("" /* input */, &ciphertext));
+
+    // Grab nonce.
+    begin_params.push_back(begin_out_params);
+
+    // Decrypt
+    update_params =
+        AuthorizationSetBuilder().Authorization(TAG_ASSOCIATED_DATA, "foofoo", (size_t)6);
+
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, begin_params));
+    string plaintext;
+    EXPECT_EQ(ErrorCode::OK, Finish(op_handle_, update_params, ciphertext, "" /* signature */,
+                                    &update_out_params, &plaintext));
+    EXPECT_TRUE(update_out_params.empty());
+    EXPECT_EQ(message, plaintext);
+}
+
+/*
+ * EncryptionOperationsTest.AesGcmAadOutOfOrder
+ *
+ * Verifies that AES GCM mode fails correctly when given AAD after data to encipher.
+ */
+TEST_F(EncryptionOperationsTest, AesGcmAadOutOfOrder) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .BlockMode(BlockMode::GCM)
+                                             .Padding(PaddingMode::NONE)
+                                             .Authorization(TAG_MIN_MAC_LENGTH, 128)));
+
+    string message = "123456789012345678901234567890123456";
+    auto begin_params = AuthorizationSetBuilder()
+                            .BlockMode(BlockMode::GCM)
+                            .Padding(PaddingMode::NONE)
+                            .Authorization(TAG_MAC_LENGTH, 128);
+    AuthorizationSet begin_out_params;
+
+    auto update_params =
+        AuthorizationSetBuilder().Authorization(TAG_ASSOCIATED_DATA, "foo", (size_t)3);
+
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::ENCRYPT, begin_params, &begin_out_params));
+
+    // No data, AAD only.
+    string ciphertext;
+    size_t input_consumed;
+    AuthorizationSet update_out_params;
+    EXPECT_EQ(ErrorCode::OK, Update(op_handle_, update_params, "" /* input */, &update_out_params,
+                                    &ciphertext, &input_consumed));
+    EXPECT_EQ(0U, input_consumed);
+    EXPECT_EQ(0U, ciphertext.size());
+    EXPECT_TRUE(update_out_params.empty());
+
+    // AAD and data.
+    EXPECT_EQ(ErrorCode::OK, Update(op_handle_, update_params, message, &update_out_params,
+                                    &ciphertext, &input_consumed));
+    EXPECT_EQ(message.size(), input_consumed);
+    EXPECT_EQ(message.size(), ciphertext.size());
+    EXPECT_TRUE(update_out_params.empty());
+
+    // More AAD
+    EXPECT_EQ(ErrorCode::INVALID_TAG, Update(op_handle_, update_params, "", &update_out_params,
+                                             &ciphertext, &input_consumed));
+
+    op_handle_ = kOpHandleSentinel;
+}
+
+/*
+ * EncryptionOperationsTest.AesGcmBadAad
+ *
+ * Verifies that AES GCM decryption fails correctly when additional authenticated date is wrong.
+ */
+TEST_F(EncryptionOperationsTest, AesGcmBadAad) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .BlockMode(BlockMode::GCM)
+                                             .Padding(PaddingMode::NONE)
+                                             .Authorization(TAG_MIN_MAC_LENGTH, 128)));
+
+    string message = "12345678901234567890123456789012";
+    auto begin_params = AuthorizationSetBuilder()
+                            .BlockMode(BlockMode::GCM)
+                            .Padding(PaddingMode::NONE)
+                            .Authorization(TAG_MAC_LENGTH, 128);
+
+    auto finish_params =
+        AuthorizationSetBuilder().Authorization(TAG_ASSOCIATED_DATA, "foobar", (size_t)6);
+
+    // Encrypt
+    AuthorizationSet begin_out_params;
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::ENCRYPT, begin_params, &begin_out_params));
+    string ciphertext;
+    AuthorizationSet finish_out_params;
+    EXPECT_EQ(ErrorCode::OK, Finish(op_handle_, finish_params, message, "" /* signature */,
+                                    &finish_out_params, &ciphertext));
+
+    // Grab nonce
+    begin_params.push_back(begin_out_params);
+
+    finish_params = AuthorizationSetBuilder().Authorization(TAG_ASSOCIATED_DATA,
+                                                            "barfoo" /* Wrong AAD */, (size_t)6);
+
+    // Decrypt.
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, begin_params, &begin_out_params));
+    string plaintext;
+    EXPECT_EQ(ErrorCode::VERIFICATION_FAILED,
+              Finish(op_handle_, finish_params, ciphertext, "" /* signature */, &finish_out_params,
+                     &plaintext));
+}
+
+/*
+ * EncryptionOperationsTest.AesGcmWrongNonce
+ *
+ * Verifies that AES GCM decryption fails correctly when the nonce is incorrect.
+ */
+TEST_F(EncryptionOperationsTest, AesGcmWrongNonce) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .BlockMode(BlockMode::GCM)
+                                             .Padding(PaddingMode::NONE)
+                                             .Authorization(TAG_MIN_MAC_LENGTH, 128)));
+
+    string message = "12345678901234567890123456789012";
+    auto begin_params = AuthorizationSetBuilder()
+                            .BlockMode(BlockMode::GCM)
+                            .Padding(PaddingMode::NONE)
+                            .Authorization(TAG_MAC_LENGTH, 128);
+
+    auto finish_params =
+        AuthorizationSetBuilder().Authorization(TAG_ASSOCIATED_DATA, "foobar", (size_t)6);
+
+    // Encrypt
+    AuthorizationSet begin_out_params;
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::ENCRYPT, begin_params, &begin_out_params));
+    string ciphertext;
+    AuthorizationSet finish_out_params;
+    EXPECT_EQ(ErrorCode::OK, Finish(op_handle_, finish_params, message, "" /* signature */,
+                                    &finish_out_params, &ciphertext));
+
+    // Wrong nonce
+    begin_params.push_back(TAG_NONCE, HidlBuf("123456789012"));
+
+    // Decrypt.
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, begin_params, &begin_out_params));
+    string plaintext;
+    EXPECT_EQ(ErrorCode::VERIFICATION_FAILED,
+              Finish(op_handle_, finish_params, ciphertext, "" /* signature */, &finish_out_params,
+                     &plaintext));
+
+    // With wrong nonce, should have gotten garbage plaintext (or none).
+    EXPECT_NE(message, plaintext);
+}
+
+/*
+ * EncryptionOperationsTest.AesGcmCorruptTag
+ *
+ * Verifies that AES GCM decryption fails correctly when the tag is wrong.
+ */
+TEST_F(EncryptionOperationsTest, AesGcmCorruptTag) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .BlockMode(BlockMode::GCM)
+                                             .Padding(PaddingMode::NONE)
+                                             .Authorization(TAG_MIN_MAC_LENGTH, 128)));
+
+    string aad = "1234567890123456";
+    string message = "123456789012345678901234567890123456";
+
+    auto params = AuthorizationSetBuilder()
+                      .BlockMode(BlockMode::GCM)
+                      .Padding(PaddingMode::NONE)
+                      .Authorization(TAG_MAC_LENGTH, 128);
+
+    auto finish_params =
+        AuthorizationSetBuilder().Authorization(TAG_ASSOCIATED_DATA, aad.data(), aad.size());
+
+    // Encrypt
+    AuthorizationSet begin_out_params;
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::ENCRYPT, params, &begin_out_params));
+    string ciphertext;
+    AuthorizationSet finish_out_params;
+    EXPECT_EQ(ErrorCode::OK, Finish(op_handle_, finish_params, message, "" /* signature */,
+                                    &finish_out_params, &ciphertext));
+    EXPECT_TRUE(finish_out_params.empty());
+
+    // Corrupt tag
+    ++(*ciphertext.rbegin());
+
+    // Grab nonce
+    params.push_back(begin_out_params);
+
+    // Decrypt.
+    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params));
+    string plaintext;
+    EXPECT_EQ(ErrorCode::VERIFICATION_FAILED,
+              Finish(op_handle_, finish_params, ciphertext, "" /* signature */, &finish_out_params,
+                     &plaintext));
+    EXPECT_TRUE(finish_out_params.empty());
+}
+
+typedef KeymasterHidlTest MaxOperationsTest;
+
+/*
+ * MaxOperationsTest.TestLimitAes
+ *
+ * Verifies that the max uses per boot tag works correctly with AES keys.
+ */
+TEST_F(MaxOperationsTest, TestLimitAes) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .EcbMode()
+                                             .Padding(PaddingMode::NONE)
+                                             .Authorization(TAG_MAX_USES_PER_BOOT, 3)));
+
+    string message = "1234567890123456";
+
+    auto params = AuthorizationSetBuilder().EcbMode().Padding(PaddingMode::NONE);
+
+    EncryptMessage(message, params);
+    EncryptMessage(message, params);
+    EncryptMessage(message, params);
+
+    // Fourth time should fail.
+    EXPECT_EQ(ErrorCode::KEY_MAX_OPS_EXCEEDED, Begin(KeyPurpose::ENCRYPT, params));
+}
+
+/*
+ * MaxOperationsTest.TestLimitAes
+ *
+ * Verifies that the max uses per boot tag works correctly with RSA keys.
+ */
+TEST_F(MaxOperationsTest, TestLimitRsa) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .RsaSigningKey(1024, 3)
+                                             .NoDigestOrPadding()
+                                             .Authorization(TAG_MAX_USES_PER_BOOT, 3)));
+
+    string message = "1234567890123456";
+
+    auto params = AuthorizationSetBuilder().NoDigestOrPadding();
+
+    SignMessage(message, params);
+    SignMessage(message, params);
+    SignMessage(message, params);
+
+    // Fourth time should fail.
+    EXPECT_EQ(ErrorCode::KEY_MAX_OPS_EXCEEDED, Begin(KeyPurpose::SIGN, params));
+}
+
+typedef KeymasterHidlTest AddEntropyTest;
+
+/*
+ * AddEntropyTest.AddEntropy
+ *
+ * Verifies that the addRngEntropy method doesn't blow up.  There's no way to test that entropy is
+ * actually added.
+ */
+TEST_F(AddEntropyTest, AddEntropy) {
+    EXPECT_EQ(ErrorCode::OK, keymaster().addRngEntropy(HidlBuf("foo")));
+}
+
+/*
+ * AddEntropyTest.AddEmptyEntropy
+ *
+ * Verifies that the addRngEntropy method doesn't blow up when given an empty buffer.
+ */
+TEST_F(AddEntropyTest, AddEmptyEntropy) {
+    EXPECT_EQ(ErrorCode::OK, keymaster().addRngEntropy(HidlBuf()));
+}
+
+/*
+ * AddEntropyTest.AddLargeEntropy
+ *
+ * Verifies that the addRngEntropy method doesn't blow up when given a largish amount of data.
+ */
+TEST_F(AddEntropyTest, AddLargeEntropy) {
+    EXPECT_EQ(ErrorCode::OK, keymaster().addRngEntropy(HidlBuf(string(16 * 1024, 'a'))));
+}
+
+typedef KeymasterHidlTest AttestationTest;
+
+/*
+ * AttestationTest.RsaAttestation
+ *
+ * Verifies that attesting to RSA keys works and generates the expected output.
+ */
+TEST_F(AttestationTest, RsaAttestation) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .RsaSigningKey(1024, 3)
+                                             .Digest(Digest::NONE)
+                                             .Padding(PaddingMode::NONE)
+                                             .Authorization(TAG_INCLUDE_UNIQUE_ID)));
+
+    hidl_vec<hidl_vec<uint8_t>> cert_chain;
+    EXPECT_EQ(ErrorCode::OK, AttestKey(AuthorizationSetBuilder().Authorization(
+                                           TAG_ATTESTATION_CHALLENGE, HidlBuf("challenge")),
+                                       &cert_chain));
+    EXPECT_GE(cert_chain.size(), 2U);
+    EXPECT_TRUE(verify_chain(cert_chain));
+    EXPECT_TRUE(verify_attestation_record("challenge",                            //
+                                          key_characteristics_.softwareEnforced,  //
+                                          key_characteristics_.teeEnforced,       //
+                                          cert_chain[0]));
+}
+
+/*
+ * AttestationTest.EcAttestation
+ *
+ * Verifies that attesting to EC keys works and generates the expected output.
+ */
+TEST_F(AttestationTest, EcAttestation) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .EcdsaSigningKey(EcCurve::P_256)
+                                             .Digest(Digest::SHA_2_256)
+                                             .Authorization(TAG_INCLUDE_UNIQUE_ID)));
+
+    hidl_vec<hidl_vec<uint8_t>> cert_chain;
+    EXPECT_EQ(ErrorCode::OK, AttestKey(AuthorizationSetBuilder().Authorization(
+                                           TAG_ATTESTATION_CHALLENGE, HidlBuf("challenge")),
+                                       &cert_chain));
+    EXPECT_GE(cert_chain.size(), 2U);
+    EXPECT_TRUE(verify_chain(cert_chain));
+
+    EXPECT_TRUE(verify_attestation_record("challenge",                            //
+                                          key_characteristics_.softwareEnforced,  //
+                                          key_characteristics_.teeEnforced,       //
+                                          cert_chain[0]));
+}
+
+/*
+ * AttestationTest.AesAttestation
+ *
+ * Verifies that attesting to AES keys fails in the expected way.
+ */
+TEST_F(AttestationTest, AesAttestation) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .AesEncryptionKey(128)
+                                             .EcbMode()
+                                             .Padding(PaddingMode::PKCS7)));
+
+    hidl_vec<hidl_vec<uint8_t>> cert_chain;
+    EXPECT_EQ(ErrorCode::INCOMPATIBLE_ALGORITHM,
+              AttestKey(AuthorizationSetBuilder().Authorization(TAG_ATTESTATION_CHALLENGE,
+                                                                HidlBuf("challenge")),
+                        &cert_chain));
+}
+
+/*
+ * AttestationTest.HmacAttestation
+ *
+ * Verifies that attesting to HMAC keys fails in the expected way.
+ */
+TEST_F(AttestationTest, HmacAttestation) {
+    ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
+                                             .Authorization(TAG_NO_AUTH_REQUIRED)
+                                             .HmacKey(128)
+                                             .EcbMode()
+                                             .Digest(Digest::SHA_2_256)
+                                             .Authorization(TAG_MIN_MAC_LENGTH, 128)));
+
+    hidl_vec<hidl_vec<uint8_t>> cert_chain;
+    EXPECT_EQ(ErrorCode::INCOMPATIBLE_ALGORITHM,
+              AttestKey(AuthorizationSetBuilder().Authorization(TAG_ATTESTATION_CHALLENGE,
+                                                                HidlBuf("challenge")),
+                        &cert_chain));
+}
+
+}  // namespace test
+}  // namespace V3_0
+}  // namespace keymaster
+}  // namespace hardware
+}  // namespace android
+
+int main(int argc, char** argv) {
+    ::testing::InitGoogleTest(&argc, argv);
+    if (argc == 2) {
+        ALOGI("Running keymaster VTS against service \"%s\"", argv[1]);
+        service_name = argv[1];
+    }
+    int status = RUN_ALL_TESTS();
+    ALOGI("Test result = %d", status);
+    return status;
+}
diff --git a/keymaster/3.0/vts/functional/keymaster_tags.h b/keymaster/3.0/vts/functional/keymaster_tags.h
new file mode 100644
index 0000000..f241ef1
--- /dev/null
+++ b/keymaster/3.0/vts/functional/keymaster_tags.h
@@ -0,0 +1,450 @@
+/*
+ * Copyright 2014 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 SYSTEM_SECURITY_KEYSTORE_KEYMASTER_TAGS_H_
+#define SYSTEM_SECURITY_KEYSTORE_KEYMASTER_TAGS_H_
+
+/**
+ * This header contains various definitions that make working with keymaster tags safer and easier.
+ *
+ * It makes use of a fair amount of template metaprogramming. The metaprogramming serves the purpose
+ * of making it impossible to make certain classes of mistakes when operating on keymaster
+ * authorizations.  For example, it's an error to create a KeyParameter with tag == Tag::PURPOSE
+ * and then to assign Algorithm::RSA to algorithm element of its union. But because the user
+ * must choose the union field, there could be a mismatch which the compiler has now way to
+ * diagnose.
+ *
+ * The machinery in this header solves these problems by describing which union field corresponds
+ * to which Tag. Central to this mechanism is the template TypedTag. It has zero size and binds a
+ * numeric Tag to a type that the compiler understands. By means of the macro DECLARE_TYPED_TAG,
+ * we declare types for each of the tags defined in hardware/interfaces/keymaster/2.0/types.hal.
+ *
+ * The macro DECLARE_TYPED_TAG(name) generates a typename TAG_name_t and a zero sized instance
+ * TAG_name. Once these typed tags have been declared we define metafunctions mapping the each tag
+ * to its value c++ type and the correct union element of KeyParameter. This is done by means of
+ * the macros MAKE_TAG_*VALUE_ACCESSOR, which generates TypedTag2ValueType, a metafunction mapping
+ * a typed tag to the corresponding c++ type, and access function, accessTagValue returning a
+ * reference to the correct element of KeyParameter.
+ * E.g.:
+ *      given "KeyParameter param;" then "accessTagValue(TAG_PURPOSE, param)"
+ *      yields a reference to param.f.purpose
+ * If used in an assignment the compiler can now check the compatibility of the assigned value.
+ *
+ * For convenience we also provide the constructor like function Authorization().
+ * Authorization takes a typed tag and a value and checks at compile time whether the value given
+ * is suitable for the given tag. At runtime it creates a new KeyParameter initialized with the
+ * given tag and value and returns it by value.
+ *
+ * The second convenience function, authorizationValue, allows access to the KeyParameter value in
+ * a safe way. It takes a typed tag and a KeyParameter and returns a reference to the value wrapped
+ * by NullOr. NullOr has out-of-band information about whether it is save to access the wrapped
+ * reference.
+ * E.g.:
+ *      auto param = Authorization(TAG_ALGORITM, Algorithm::RSA);
+ *      auto value1 = authorizationValue(TAG_PURPOSE, param);
+ *      auto value2 = authorizationValue(TAG_ALGORITM, param);
+ * value1.isOk() yields false, but value2.isOk() yields true, thus value2.value() is save to access.
+ */
+
+#include <android/hardware/keymaster/3.0/IHwKeymasterDevice.h>
+#include <hardware/hw_auth_token.h>
+#include <type_traits>
+
+namespace android {
+namespace hardware {
+namespace keymaster {
+namespace V3_0 {
+
+// The following create the numeric values that KM_TAG_PADDING and KM_TAG_DIGEST used to have.  We
+// need these old values to be able to support old keys that use them.
+static const int32_t KM_TAG_DIGEST_OLD = static_cast<int32_t>(TagType::ENUM) | 5;
+static const int32_t KM_TAG_PADDING_OLD = static_cast<int32_t>(TagType::ENUM) | 7;
+
+constexpr TagType typeFromTag(Tag tag) {
+    return static_cast<TagType>(static_cast<uint32_t>(tag) & static_cast<uint32_t>(0xf0000000));
+}
+
+/**
+ * TypedTag is a templatized version of Tag, which provides compile-time checking of keymaster tag
+ * types. Instances are convertible to Tag, so they can be used wherever Tag is expected, and
+ * because they encode the tag type it's possible to create function overloads that only operate on
+ * tags with a particular type.
+ */
+template <TagType tag_type, Tag tag> struct TypedTag {
+    inline TypedTag() {
+        // Ensure that it's impossible to create a TypedTag instance whose 'tag' doesn't have type
+        // 'tag_type'.  Attempting to instantiate a tag with the wrong type will result in a compile
+        // error (no match for template specialization StaticAssert<false>), with no run-time cost.
+        static_assert(typeFromTag(tag) == tag_type, "mismatch between tag and tag_type");
+    }
+    constexpr operator Tag() { return tag; }
+    constexpr long maskedTag() {
+        return static_cast<long>(static_cast<uint32_t>(tag) & static_cast<uint32_t>(0x0fffffff));
+    }
+};
+
+template <Tag tag> struct Tag2TypedTag { typedef TypedTag<typeFromTag(tag), tag> type; };
+
+template <Tag tag> struct Tag2String;
+
+#define _TAGS_STRINGIFY(x) #x
+#define TAGS_STRINGIFY(x) _TAGS_STRINGIFY(x)
+
+#define DECLARE_TYPED_TAG(name)                                                                    \
+    typedef typename Tag2TypedTag<Tag::name>::type TAG_##name##_t;                                 \
+    extern TAG_##name##_t TAG_##name;                                                              \
+    template <> struct Tag2String<Tag::name> {                                                     \
+        static const char* value() { return "Tag::" TAGS_STRINGIFY(name); }                        \
+    }
+
+DECLARE_TYPED_TAG(INVALID);
+DECLARE_TYPED_TAG(KEY_SIZE);
+DECLARE_TYPED_TAG(MAC_LENGTH);
+DECLARE_TYPED_TAG(CALLER_NONCE);
+DECLARE_TYPED_TAG(MIN_MAC_LENGTH);
+DECLARE_TYPED_TAG(RSA_PUBLIC_EXPONENT);
+DECLARE_TYPED_TAG(ECIES_SINGLE_HASH_MODE);
+DECLARE_TYPED_TAG(INCLUDE_UNIQUE_ID);
+DECLARE_TYPED_TAG(ACTIVE_DATETIME);
+DECLARE_TYPED_TAG(ORIGINATION_EXPIRE_DATETIME);
+DECLARE_TYPED_TAG(USAGE_EXPIRE_DATETIME);
+DECLARE_TYPED_TAG(MIN_SECONDS_BETWEEN_OPS);
+DECLARE_TYPED_TAG(MAX_USES_PER_BOOT);
+DECLARE_TYPED_TAG(ALL_USERS);
+DECLARE_TYPED_TAG(USER_ID);
+DECLARE_TYPED_TAG(USER_SECURE_ID);
+DECLARE_TYPED_TAG(NO_AUTH_REQUIRED);
+DECLARE_TYPED_TAG(AUTH_TIMEOUT);
+DECLARE_TYPED_TAG(ALLOW_WHILE_ON_BODY);
+DECLARE_TYPED_TAG(ALL_APPLICATIONS);
+DECLARE_TYPED_TAG(APPLICATION_ID);
+DECLARE_TYPED_TAG(APPLICATION_DATA);
+DECLARE_TYPED_TAG(CREATION_DATETIME);
+DECLARE_TYPED_TAG(ROLLBACK_RESISTANT);
+DECLARE_TYPED_TAG(ROOT_OF_TRUST);
+DECLARE_TYPED_TAG(ASSOCIATED_DATA);
+DECLARE_TYPED_TAG(NONCE);
+DECLARE_TYPED_TAG(AUTH_TOKEN);
+DECLARE_TYPED_TAG(BOOTLOADER_ONLY);
+DECLARE_TYPED_TAG(OS_VERSION);
+DECLARE_TYPED_TAG(OS_PATCHLEVEL);
+DECLARE_TYPED_TAG(UNIQUE_ID);
+DECLARE_TYPED_TAG(ATTESTATION_CHALLENGE);
+DECLARE_TYPED_TAG(ATTESTATION_APPLICATION_ID);
+DECLARE_TYPED_TAG(RESET_SINCE_ID_ROTATION);
+
+DECLARE_TYPED_TAG(PURPOSE);
+DECLARE_TYPED_TAG(ALGORITHM);
+DECLARE_TYPED_TAG(BLOCK_MODE);
+DECLARE_TYPED_TAG(DIGEST);
+DECLARE_TYPED_TAG(PADDING);
+DECLARE_TYPED_TAG(BLOB_USAGE_REQUIREMENTS);
+DECLARE_TYPED_TAG(ORIGIN);
+DECLARE_TYPED_TAG(USER_AUTH_TYPE);
+DECLARE_TYPED_TAG(KDF);
+DECLARE_TYPED_TAG(EC_CURVE);
+
+template <typename... Elems> struct MetaList {};
+
+using all_tags_t = MetaList<
+    TAG_INVALID_t, TAG_KEY_SIZE_t, TAG_MAC_LENGTH_t, TAG_CALLER_NONCE_t, TAG_MIN_MAC_LENGTH_t,
+    TAG_RSA_PUBLIC_EXPONENT_t, TAG_ECIES_SINGLE_HASH_MODE_t, TAG_INCLUDE_UNIQUE_ID_t,
+    TAG_ACTIVE_DATETIME_t, TAG_ORIGINATION_EXPIRE_DATETIME_t, TAG_USAGE_EXPIRE_DATETIME_t,
+    TAG_MIN_SECONDS_BETWEEN_OPS_t, TAG_MAX_USES_PER_BOOT_t, TAG_ALL_USERS_t, TAG_USER_ID_t,
+    TAG_USER_SECURE_ID_t, TAG_NO_AUTH_REQUIRED_t, TAG_AUTH_TIMEOUT_t, TAG_ALLOW_WHILE_ON_BODY_t,
+    TAG_ALL_APPLICATIONS_t, TAG_APPLICATION_ID_t, TAG_APPLICATION_DATA_t, TAG_CREATION_DATETIME_t,
+    TAG_ROLLBACK_RESISTANT_t, TAG_ROOT_OF_TRUST_t, TAG_ASSOCIATED_DATA_t, TAG_NONCE_t,
+    TAG_AUTH_TOKEN_t, TAG_BOOTLOADER_ONLY_t, TAG_OS_VERSION_t, TAG_OS_PATCHLEVEL_t, TAG_UNIQUE_ID_t,
+    TAG_ATTESTATION_CHALLENGE_t, TAG_ATTESTATION_APPLICATION_ID_t, TAG_RESET_SINCE_ID_ROTATION_t,
+    TAG_PURPOSE_t, TAG_ALGORITHM_t, TAG_BLOCK_MODE_t, TAG_DIGEST_t, TAG_PADDING_t,
+    TAG_BLOB_USAGE_REQUIREMENTS_t, TAG_ORIGIN_t, TAG_USER_AUTH_TYPE_t, TAG_KDF_t, TAG_EC_CURVE_t>;
+
+/* implementation in keystore_utils.cpp */
+extern const char* stringifyTag(Tag tag);
+
+template <typename TypedTagType> struct TypedTag2ValueType;
+
+#define MAKE_TAG_VALUE_ACCESSOR(tag_type, field_name)                                              \
+    template <Tag tag> struct TypedTag2ValueType<TypedTag<tag_type, tag>> {                        \
+        typedef decltype(static_cast<KeyParameter*>(nullptr)->field_name) type;                    \
+    };                                                                                             \
+    template <Tag tag>                                                                             \
+    inline auto accessTagValue(TypedTag<tag_type, tag>, const KeyParameter& param)                 \
+        ->const decltype(param.field_name)& {                                                      \
+        return param.field_name;                                                                   \
+    }                                                                                              \
+    template <Tag tag>                                                                             \
+    inline auto accessTagValue(TypedTag<tag_type, tag>, KeyParameter& param)                       \
+        ->decltype(param.field_name)& {                                                            \
+        return param.field_name;                                                                   \
+    }
+
+MAKE_TAG_VALUE_ACCESSOR(TagType::ULONG, f.longInteger)
+MAKE_TAG_VALUE_ACCESSOR(TagType::ULONG_REP, f.longInteger)
+MAKE_TAG_VALUE_ACCESSOR(TagType::DATE, f.dateTime)
+MAKE_TAG_VALUE_ACCESSOR(TagType::UINT, f.integer)
+MAKE_TAG_VALUE_ACCESSOR(TagType::UINT_REP, f.integer)
+MAKE_TAG_VALUE_ACCESSOR(TagType::BOOL, f.boolValue)
+MAKE_TAG_VALUE_ACCESSOR(TagType::BYTES, blob)
+MAKE_TAG_VALUE_ACCESSOR(TagType::BIGNUM, blob)
+
+#define MAKE_TAG_ENUM_VALUE_ACCESSOR(typed_tag, field_name)                                        \
+    template <> struct TypedTag2ValueType<decltype(typed_tag)> {                                   \
+        typedef decltype(static_cast<KeyParameter*>(nullptr)->field_name) type;                    \
+    };                                                                                             \
+    inline auto accessTagValue(decltype(typed_tag), const KeyParameter& param)                     \
+        ->const decltype(param.field_name)& {                                                      \
+        return param.field_name;                                                                   \
+    }                                                                                              \
+    inline auto accessTagValue(decltype(typed_tag), KeyParameter& param)                           \
+        ->decltype(param.field_name)& {                                                            \
+        return param.field_name;                                                                   \
+    }
+
+MAKE_TAG_ENUM_VALUE_ACCESSOR(TAG_ALGORITHM, f.algorithm)
+MAKE_TAG_ENUM_VALUE_ACCESSOR(TAG_BLOB_USAGE_REQUIREMENTS, f.keyBlobUsageRequirements)
+MAKE_TAG_ENUM_VALUE_ACCESSOR(TAG_BLOCK_MODE, f.blockMode)
+MAKE_TAG_ENUM_VALUE_ACCESSOR(TAG_DIGEST, f.digest)
+MAKE_TAG_ENUM_VALUE_ACCESSOR(TAG_EC_CURVE, f.ecCurve)
+MAKE_TAG_ENUM_VALUE_ACCESSOR(TAG_KDF, f.keyDerivationFunction)
+MAKE_TAG_ENUM_VALUE_ACCESSOR(TAG_ORIGIN, f.origin)
+MAKE_TAG_ENUM_VALUE_ACCESSOR(TAG_PADDING, f.paddingMode)
+MAKE_TAG_ENUM_VALUE_ACCESSOR(TAG_PURPOSE, f.purpose)
+MAKE_TAG_ENUM_VALUE_ACCESSOR(TAG_USER_AUTH_TYPE, f.hardwareAuthenticatorType)
+
+template <TagType tag_type, Tag tag, typename ValueT>
+inline KeyParameter makeKeyParameter(TypedTag<tag_type, tag> ttag, ValueT&& value) {
+    KeyParameter param;
+    param.tag = tag;
+    param.f.longInteger = 0;
+    accessTagValue(ttag, param) = std::forward<ValueT>(value);
+    return param;
+}
+
+// the boolean case
+template <Tag tag> inline KeyParameter makeKeyParameter(TypedTag<TagType::BOOL, tag>) {
+    KeyParameter param;
+    param.tag = tag;
+    param.f.boolValue = true;
+    return param;
+}
+
+template <typename... Pack> struct FirstOrNoneHelper;
+template <typename First> struct FirstOrNoneHelper<First> { typedef First type; };
+template <> struct FirstOrNoneHelper<> {
+    struct type {};
+};
+
+template <typename... Pack> using FirstOrNone = typename FirstOrNoneHelper<Pack...>::type;
+
+template <TagType tag_type, Tag tag, typename... Args>
+inline KeyParameter Authorization(TypedTag<tag_type, tag> ttag, Args&&... args) {
+    static_assert(tag_type != TagType::BOOL || (sizeof...(args) == 0),
+                  "TagType::BOOL Authorizations do not take parameters. Presence is truth.");
+    static_assert(tag_type == TagType::BOOL || (sizeof...(args) == 1),
+                  "Authorization other then TagType::BOOL take exactly one parameter.");
+    static_assert(
+        tag_type == TagType::BOOL ||
+            std::is_convertible<std::remove_cv_t<std::remove_reference_t<FirstOrNone<Args...>>>,
+                                typename TypedTag2ValueType<TypedTag<tag_type, tag>>::type>::value,
+        "Invalid argument type for given tag.");
+
+    return makeKeyParameter(ttag, std::forward<Args>(args)...);
+}
+
+/**
+ * This class wraps a (mostly return) value and stores whether or not the wrapped value is valid out
+ * of band. Note that if the wrapped value is a reference it is unsafe to access the value if
+ * !isOk(). If the wrapped type is a pointer or value and !isOk(), it is still safe to access the
+ * wrapped value. In this case the pointer will be NULL though, and the value will be default
+ * constructed.
+ */
+template <typename ValueT> class NullOr {
+    template <typename T> struct reference_initializer {
+        static T&& init() { return *static_cast<std::remove_reference_t<T>*>(nullptr); }
+    };
+    template <typename T> struct pointer_initializer {
+        static T init() { return nullptr; }
+    };
+    template <typename T> struct value_initializer {
+        static T init() { return T(); }
+    };
+    template <typename T>
+    using initializer_t =
+        std::conditional_t<std::is_lvalue_reference<T>::value, reference_initializer<T>,
+                           std::conditional_t<std::is_pointer<T>::value, pointer_initializer<T>,
+                                              value_initializer<T>>>;
+
+  public:
+    NullOr() : value_(initializer_t<ValueT>::init()), null_(true) {}
+    NullOr(ValueT&& value) : value_(std::forward<ValueT>(value)), null_(false) {}
+
+    bool isOk() const { return !null_; }
+
+    const ValueT& value() const & { return value_; }
+    ValueT& value() & { return value_; }
+    ValueT&& value() && { return std::move(value_); }
+
+  private:
+    ValueT value_;
+    bool null_;
+};
+
+template <typename T> std::remove_reference_t<T> NullOrOr(NullOr<T>&& v) {
+    if (v.isOk()) return v;
+    return {};
+}
+
+template <typename Head, typename... Tail>
+std::remove_reference_t<Head> NullOrOr(Head&& head, Tail&&... tail) {
+    if (head.isOk()) return head;
+    return NullOrOr(std::forward<Tail>(tail)...);
+}
+
+template <typename Default, typename Wrapped>
+std::remove_reference_t<Wrapped> defaultOr(NullOr<Wrapped>&& optional, Default&& def) {
+    static_assert(std::is_convertible<std::remove_reference_t<Default>,
+                                      std::remove_reference_t<Wrapped>>::value,
+                  "Type of default value must match the type wrapped by NullOr");
+    if (optional.isOk()) return optional.value();
+    return def;
+}
+
+template <TagType tag_type, Tag tag>
+inline NullOr<const typename TypedTag2ValueType<TypedTag<tag_type, tag>>::type&>
+authorizationValue(TypedTag<tag_type, tag> ttag, const KeyParameter& param) {
+    if (tag != param.tag) return {};
+    return accessTagValue(ttag, param);
+}
+
+inline const char* stringify(Digest digest) {
+    switch (digest) {
+    case Digest::NONE:
+        return "None";
+    case Digest::MD5:
+        return "Md5";
+    case Digest::SHA1:
+        return "Sha1";
+    case Digest::SHA_2_224:
+        return "Sha224";
+    case Digest::SHA_2_256:
+        return "Sha256";
+    case Digest::SHA_2_384:
+        return "Sha384";
+    case Digest::SHA_2_512:
+        return "Sha512";
+    }
+    return "UNKNOWN DIGEST!";
+}
+
+inline const char* stringify(Algorithm algorithm) {
+    switch (algorithm) {
+    case Algorithm::RSA:
+        return "Rsa";
+    case Algorithm::EC:
+        return "Ec";
+    case Algorithm::AES:
+        return "Aes";
+    case Algorithm::HMAC:
+        return "Hmac";
+    }
+    return "UNKNOWN ALGORITHM";
+}
+
+inline const char* stringify(BlockMode block_mode) {
+    switch (block_mode) {
+    case BlockMode::ECB:
+        return "Ecb";
+    case BlockMode::CBC:
+        return "Cbc";
+    case BlockMode::CTR:
+        return "Ctr";
+    case BlockMode::GCM:
+        return "Gcm";
+    }
+    return "UNKNOWN BLOCK MODE";
+}
+
+inline const char* stringify(PaddingMode padding) {
+    switch (padding) {
+    case PaddingMode::NONE:
+        return "None";
+    case PaddingMode::RSA_OAEP:
+        return "RsaOaep";
+    case PaddingMode::RSA_PSS:
+        return "RsaPss";
+    case PaddingMode::RSA_PKCS1_1_5_ENCRYPT:
+        return "RsaPkcs115Encrypt";
+    case PaddingMode::RSA_PKCS1_1_5_SIGN:
+        return "RsaPkcs115Sign";
+    case PaddingMode::PKCS7:
+        return "Pkcs7";
+    }
+    return "UNKNOWN PADDING MODE";
+}
+
+inline const char* stringify(KeyOrigin origin) {
+    switch (origin) {
+    case KeyOrigin::GENERATED:
+        return "Generated";
+    case KeyOrigin::DERIVED:
+        return "Derived";
+    case KeyOrigin::IMPORTED:
+        return "Imported";
+    case KeyOrigin::UNKNOWN:
+        return "UNKNOWN (keymaster0 didn't record it)";
+    }
+    return "UNKOWN KEY ORIGIN VALUE";
+}
+
+inline const char* stringify(KeyPurpose purpose) {
+    switch (purpose) {
+    case KeyPurpose::ENCRYPT:
+        return "Encrypt";
+    case KeyPurpose::DECRYPT:
+        return "Decrypt";
+    case KeyPurpose::SIGN:
+        return "Sign";
+    case KeyPurpose::VERIFY:
+        return "Verify";
+    case KeyPurpose::DERIVE_KEY:
+        return "DeriveKey";
+    case KeyPurpose::WRAP_KEY:
+        return "WrapKey";
+    };
+    return "UNKNOWN KEY PURPOSE";
+}
+
+inline const char* stringify(EcCurve curve) {
+    switch (curve) {
+    case EcCurve::P_224:
+        return "P_224";
+    case EcCurve::P_256:
+        return "P_256";
+    case EcCurve::P_384:
+        return "P_384";
+    case EcCurve::P_521:
+        return "P_521";
+    }
+    return "UNKNOWN EC CURVE";
+}
+
+}  // namespace V3_0
+}  // namespace keymaster
+}  // namespace hardware
+}  // namespace android
+
+#endif  // SYSTEM_SECURITY_KEYSTORE_KEYMASTER_TAGS_H_
diff --git a/keymaster/3.0/vts/functional/keystore_tags_utils.cpp b/keymaster/3.0/vts/functional/keystore_tags_utils.cpp
new file mode 100644
index 0000000..8dd99db
--- /dev/null
+++ b/keymaster/3.0/vts/functional/keystore_tags_utils.cpp
@@ -0,0 +1,50 @@
+/*
+**
+** Copyright 2016, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include "keymaster_tags.h"
+
+namespace android {
+namespace hardware {
+namespace keymaster {
+namespace V3_0 {
+
+template <typename TagList> struct TagStringifier;
+
+template <typename... Tags> struct TagStringifier<MetaList<Tags...>> {
+    template <TagType tag_type, Tag tag>
+    static TypedTag<tag_type, tag> chooseString(TypedTag<tag_type, tag> ttag, Tag runtime_tag,
+                                                const char** result) {
+        if (tag == runtime_tag) {
+            *result = Tag2String<tag>::value();
+        }
+        return ttag;
+    }
+    static const char* stringify(Tag tag) {
+        const char* result = "unknown tag";
+        [](Tags&&...) {}(chooseString(Tags(), tag, &result)...);
+        return result;
+    }
+};
+
+const char* stringifyTag(Tag tag) {
+    return TagStringifier<all_tags_t>::stringify(tag);
+}
+
+}  // namespace V3_0
+}  // namespace keymaster
+}  // namespace hardware
+}  // namespace android
diff --git a/keymaster/3.0/vts/functional/openssl_utils.h b/keymaster/3.0/vts/functional/openssl_utils.h
new file mode 100644
index 0000000..2eba9ba
--- /dev/null
+++ b/keymaster/3.0/vts/functional/openssl_utils.h
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+template <typename T, void (*F)(T*)> struct UniquePtrDeleter {
+    void operator()(T* p) const { F(p); }
+};
+
+typedef UniquePtrDeleter<EVP_PKEY, EVP_PKEY_free> EVP_PKEY_Delete;
+
+#define MAKE_OPENSSL_PTR_TYPE(type)                                                                \
+    typedef std::unique_ptr<type, UniquePtrDeleter<type, type##_free>> type##_Ptr;
+
+MAKE_OPENSSL_PTR_TYPE(ASN1_OBJECT)
+MAKE_OPENSSL_PTR_TYPE(EVP_PKEY)
+MAKE_OPENSSL_PTR_TYPE(RSA)
+MAKE_OPENSSL_PTR_TYPE(X509)
+MAKE_OPENSSL_PTR_TYPE(BN_CTX)
+
+typedef std::unique_ptr<BIGNUM, UniquePtrDeleter<BIGNUM, BN_free>> BIGNUM_Ptr;
+
+inline const EVP_MD* openssl_digest(android::hardware::keymaster::V3_0::Digest digest) {
+    switch (digest) {
+    case android::hardware::keymaster::V3_0::Digest::NONE:
+        return nullptr;
+    case android::hardware::keymaster::V3_0::Digest::MD5:
+        return EVP_md5();
+    case android::hardware::keymaster::V3_0::Digest::SHA1:
+        return EVP_sha1();
+    case android::hardware::keymaster::V3_0::Digest::SHA_2_224:
+        return EVP_sha224();
+    case android::hardware::keymaster::V3_0::Digest::SHA_2_256:
+        return EVP_sha256();
+    case android::hardware::keymaster::V3_0::Digest::SHA_2_384:
+        return EVP_sha384();
+    case android::hardware::keymaster::V3_0::Digest::SHA_2_512:
+        return EVP_sha512();
+    }
+    return nullptr;
+}
diff --git a/light/2.0/types.hal b/light/2.0/types.hal
index cc2ec32..27b67e0 100644
--- a/light/2.0/types.hal
+++ b/light/2.0/types.hal
@@ -24,17 +24,17 @@
 };
 
 enum Flash : int32_t {
-    /*
+    /**
      * Keep the light steady on or off.
      */
     NONE,
 
-    /*
+    /**
      * Flash the light at specified rate.
      */
     TIMED,
 
-    /*
+    /**
      * Flash the light using hardware assist.
      */
     HARDWARE,
@@ -77,7 +77,7 @@
     LOW_PERSISTENCE,
 };
 
-/*
+/**
  * These light IDs correspond to logical lights, not physical.
  * So for example, if your INDICATOR light is in line with your
  * BUTTONS, it might make sense to also light the INDICATOR
diff --git a/memtrack/1.0/IMemtrack.hal b/memtrack/1.0/IMemtrack.hal
index ae9d960..a329032 100644
--- a/memtrack/1.0/IMemtrack.hal
+++ b/memtrack/1.0/IMemtrack.hal
@@ -16,7 +16,7 @@
 
 package android.hardware.memtrack@1.0;
 
-/*
+/**
  * The Memory Tracker HAL is designed to return information about
  * device-specific memory usage.
  * The primary goal is to be able to track memory that is not
@@ -30,7 +30,7 @@
  * setup actions and is called once before any calls to getMemory().
  */
 interface IMemtrack {
-    /*
+    /**
      * getMemory() populates MemtrackRecord vector with the sizes of memory
      * plus associated flags for that memory.
      *
diff --git a/memtrack/1.0/types.hal b/memtrack/1.0/types.hal
index 3d702b3..189312a 100644
--- a/memtrack/1.0/types.hal
+++ b/memtrack/1.0/types.hal
@@ -16,7 +16,7 @@
 
 package android.hardware.memtrack@1.0;
 
-/*
+/**
  * SMAPS_ACCOUNTED/SMAPS_UNACCOUNTED
  * Flags to differentiate memory that can already be accounted for in
  * /proc/<pid>/smaps,
@@ -56,7 +56,7 @@
     SECURE = 1 << 9,
 };
 
-/* Tags which define the usage of the memory buffers. */
+/** Tags which define the usage of the memory buffers. */
 enum MemtrackType : uint32_t {
     OTHER = 0,
     GL = 1,
@@ -79,7 +79,7 @@
  */
 struct MemtrackRecord {
     uint64_t sizeInBytes;
-    /*
+    /**
      * This is the bitfield for the MemtrackFlag indicating all the flags that
      * are valid for this record.
      */
diff --git a/power/1.0/IPower.hal b/power/1.0/IPower.hal
index 6cba42a..250f645 100644
--- a/power/1.0/IPower.hal
+++ b/power/1.0/IPower.hal
@@ -15,12 +15,12 @@
  */
 package android.hardware.power@1.0;
 
-/*
+/**
  * Constructor for the interface performs power management setup actions at
  * runtime startup, such as to set default cpufreq parameters.
  */
 interface IPower {
-    /*
+    /**
      * setInteractive() performs power management actions upon the
      * system entering interactive state (that is, the system is awake
      * and ready for interaction, often with UI devices such as
@@ -49,7 +49,7 @@
      */
     setInteractive(bool interactive);
 
-    /*
+    /**
      * powerHint() is called to pass hints on power requirements which
      * may result in adjustment of power/performance parameters of the
      * cpufreq governor and other controls.
@@ -62,7 +62,7 @@
      */
     powerHint(PowerHint hint, int32_t data);
 
-    /*
+    /**
      * setFeature() is called to turn on or off a particular feature
      * depending on the state parameter.
      *
@@ -71,7 +71,7 @@
      */
     setFeature(Feature feature, bool activate);
 
-    /*
+    /**
      * Platform-level sleep state stats:
      * Report cumulative info on the statistics on platform-level sleep states
      * since boot.
diff --git a/power/1.0/types.hal b/power/1.0/types.hal
index debdc35..f839283 100644
--- a/power/1.0/types.hal
+++ b/power/1.0/types.hal
@@ -15,9 +15,9 @@
  */
 package android.hardware.power@1.0;
 
-/* Power hint identifiers passed to powerHint() */
+/** Power hint identifiers passed to powerHint() */
 enum PowerHint : uint32_t {
-   /*
+   /**
     * Foreground app has started or stopped requesting a VSYNC pulse
     * from SurfaceFlinger. If the app has started requesting VSYNC
     * then CPU and GPU load is expected soon, and it may be appropriate
@@ -28,7 +28,7 @@
     VSYNC = 0x00000001,
 
 
-   /*
+   /**
     * User is interacting with the device, for example, touchscreen
     * events are incoming. CPU and GPU load may be expected soon,
     * and it may be appropriate to raise speeds of CPU, memory bus,
@@ -38,13 +38,14 @@
     INTERACTION = 0x00000002,
 
 
-    /* DO NOT USE VIDEO_ENCODE/_DECODE!  They will be removed in
+    /**
+     * DO NOT USE VIDEO_ENCODE/_DECODE!  They will be removed in
      * KLP.
      */
     VIDEO_ENCODE = 0x00000003,
     VIDEO_DECODE = 0x00000004,
 
-   /*
+   /**
     * Low power mode is activated or deactivated. Low power mode
     * is intended to save battery at the cost of performance. The data
     * parameter is non-zero when low power mode is activated, and zero
@@ -52,7 +53,7 @@
     */
     LOW_POWER = 0x00000005,
 
-   /*
+   /**
     * Sustained Performance mode is actived or deactivated. Sustained
     * performance mode is intended to provide a consistent level of
     * performance for a prolonged amount of time. The data parameter is
@@ -61,7 +62,7 @@
     */
     SUSTAINED_PERFORMANCE = 0x00000006,
 
-   /*
+   /**
     * VR Mode is activated or deactivated. VR mode is intended to
     * provide minimum guarantee for performance for the amount of time the
     * device can sustain it. The data parameter is non-zero when the mode
@@ -69,7 +70,7 @@
     */
     VR_MODE = 0x00000007,
 
-   /*
+   /**
     * This hint indicates that an application has been launched. Can be used
     * for device specific optimizations during application launch. The data
     * parameter is non-zero when the application starts to launch and zero when
@@ -79,7 +80,7 @@
 };
 
 enum Feature : uint32_t {
-    /*
+    /**
      * Enabling/Disabling this feature will allow/disallow the system
      * to wake up by tapping the screen twice.
      */
@@ -90,7 +91,7 @@
     SUCCESS = 0,
     FILESYSTEM_ERROR = 1
 };
-/*
+/**
  * Platform-level sleep state stats:
  * PowerStateVoter struct is useful for describing the individual voters
  * when a Platform-level sleep state is chosen by aggregation of votes from
@@ -100,24 +101,24 @@
  * entering the lowest Platform-level sleep state.
  */
 struct PowerStateVoter {
-    /*
+    /**
      * Name of the voter.
      */
      string name;
 
-    /*
+    /**
      * Total time in msec the voter voted for the platform sleep state since
      * boot.
      */
      uint64_t totalTimeInMsecVotedForSinceBoot;
 
-    /*
+    /**
      * Number of times the voter voted for the platform sleep state since boot.
      */
      uint64_t totalNumberOfTimesVotedSinceBoot;
 };
 
-/*
+/**
  * Platform-level sleep state stats:
  * PowerStatePlatformSleepState represents the Platform-level sleep state
  * the device is capable of getting into.
@@ -125,27 +126,27 @@
  * SoCs usually have more than one Platform-level sleep state.
  */
 struct PowerStatePlatformSleepState {
-    /*
+    /**
      * Platform-level Sleep state name.
      */
     string name;
 
-    /*
+    /**
      * Time spent in msec at this platform-level sleep state since boot.
      */
     uint64_t residencyInMsecSinceBoot;
 
-    /*
+    /**
      * Total number of times system entered this state.
      */
     uint64_t totalTransitions;
 
-    /*
+    /**
      * This platform-level sleep state can only be reached during system suspend
      */
     bool supportedOnlyInSuspend;
 
-    /*
+    /**
      * voters is useful if the Platform-level sleep state
      * is chosen by aggregation votes from multiple clients/system conditions.
      * All the voters have to say yes or all the system conditions need to be
diff --git a/renderscript/1.0/default/Context.cpp b/renderscript/1.0/default/Context.cpp
index ef17b463..389b6e7 100644
--- a/renderscript/1.0/default/Context.cpp
+++ b/renderscript/1.0/default/Context.cpp
@@ -63,7 +63,7 @@
 Return<void> Context::allocationAdapterOffset(Allocation alloc, const hidl_vec<uint32_t>& offsets) {
     RsAllocation _alloc = hidl_to_rs<RsAllocation>(alloc);
     const hidl_vec<uint32_t>& _offsets = offsets;
-    Device::getHal().AllocationAdapterOffset(mContext, _alloc, _offsets.data(), _offsets.size());
+    Device::getHal().AllocationAdapterOffset(mContext, _alloc, _offsets.data(), _offsets.size() * sizeof(uint32_t));
     return Void();
 }
 
@@ -552,7 +552,7 @@
     std::vector<RsScriptKernelID> _dstK    = hidl_to_rs<RsScriptKernelID>(dstK,    [](ScriptFieldID val) { return hidl_to_rs<RsScriptKernelID>(val); });
     std::vector<RsScriptFieldID>  _dstF    = hidl_to_rs<RsScriptFieldID>(dstF,     [](ScriptFieldID val) { return hidl_to_rs<RsScriptFieldID>(val); });
     std::vector<RsType>           _types   = hidl_to_rs<RsType>(types,             [](Type val) { return hidl_to_rs<RsType>(val); });
-    RsScriptGroup _scriptGroup = Device::getHal().ScriptGroupCreate(mContext, _kernels.data(), _kernels.size(), _srcK.data(), _srcK.size(), _dstK.data(), _dstK.size(), _dstF.data(), _dstF.size(), _types.data(), _types.size());
+    RsScriptGroup _scriptGroup = Device::getHal().ScriptGroupCreate(mContext, _kernels.data(), _kernels.size() * sizeof(RsScriptKernelID), _srcK.data(), _srcK.size() * sizeof(RsScriptKernelID), _dstK.data(), _dstK.size() * sizeof(RsScriptKernelID), _dstF.data(), _dstF.size() * sizeof(RsScriptFieldID), _types.data(), _types.size() * sizeof(RsType));
     return rs_to_hidl<ScriptGroup>(_scriptGroup);
 }
 
@@ -725,7 +725,7 @@
     size_t _len = data.size();
     RsElement _ve = hidl_to_rs<RsElement>(ve);
     const uint32_t* _dimsPtr = dims.data();
-    size_t _dimLen = dims.size();
+    size_t _dimLen = dims.size() * sizeof(uint32_t);
     Device::getHal().ScriptSetVarVE(mContext, _vs, _slot, _dataPtr, _len, _ve, _dimsPtr, _dimLen);
     return Void();
 }
diff --git a/renderscript/1.0/vts/functional/VtsCopyTests.cpp b/renderscript/1.0/vts/functional/VtsCopyTests.cpp
index 77217cb..168e681 100644
--- a/renderscript/1.0/vts/functional/VtsCopyTests.cpp
+++ b/renderscript/1.0/vts/functional/VtsCopyTests.cpp
@@ -43,9 +43,7 @@
     context->allocation1DWrite(allocation, 0, 0, (Size)dataIn.size(), _data);
     context->allocation1DRead(allocation, 0, 0, (uint32_t)dataOut.size(), (Ptr)dataOut.data(),
                               (Size)dataOut.size()*sizeof(float));
-    bool same = std::all_of(dataOut.begin(), dataOut.end(),
-                            [](float x){ static int val = 0; return x == (float)val++; });
-    EXPECT_EQ(true, same);
+    EXPECT_EQ(dataIn, dataOut);
 }
 
 /*
@@ -76,9 +74,7 @@
                                _data, 0);
     context->allocation2DRead(allocation, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 128, 128,
                               (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(float), 0);
-    bool same = std::all_of(dataOut.begin(), dataOut.end(),
-                            [](float x){ static int val = 0; return x == (float)val++; });
-    EXPECT_EQ(true, same);
+    EXPECT_EQ(dataIn, dataOut);
 }
 
 /*
@@ -108,9 +104,7 @@
     context->allocation3DWrite(allocation, 0, 0, 0, 0, 32, 32, 32, _data, 0);
     context->allocation3DRead(allocation, 0, 0, 0, 0, 32, 32, 32, (Ptr)dataOut.data(),
                               (Size)dataOut.size()*sizeof(float), 0);
-    bool same = std::all_of(dataOut.begin(), dataOut.end(),
-                            [](float x){ static int val = 0; return x == (float)val++; });
-    EXPECT_EQ(true, same);
+    EXPECT_EQ(dataIn, dataOut);
 }
 
 /*
@@ -139,18 +133,14 @@
                                                                 AllocationMipmapControl::NONE,
                                                                 _data,
                                                                 (int)AllocationUsageType::SCRIPT);
-    EXPECT_NE(allocation, Allocation(0));
+    EXPECT_NE(Allocation(0), allocation);
 
     context->allocationCopyToBitmap(allocation, (Ptr)dataOut1.data(),
                                     (Size)dataOut1.size()*sizeof(float));
-    bool same1 = std::all_of(dataOut1.begin(), dataOut1.end(),
-                             [](float x){ static int val = 0; return x == (float)val++; });
-    EXPECT_EQ(true, same1);
+    EXPECT_EQ(dataIn, dataOut1);
 
     context->allocationRead(allocation, (Ptr)dataOut2.data(), (Size)dataOut2.size()*sizeof(float));
-    bool same2 = std::all_of(dataOut2.begin(), dataOut2.end(),
-                             [](float x){ static int val = 0; return x == (float)val++; });
-    EXPECT_EQ(true, same2);
+    EXPECT_EQ(dataIn, dataOut2);
 }
 
 /*
@@ -368,24 +358,20 @@
 /*
  * This test creates a complex element type (uint8_t, uint32_t) out of known
  * elements. It then verifies the element structure was created correctly.
- * Finally, the test creates a 128-wide, 1-dimension allocation of this type
- * and transfers memory to and from this structure.
+ * Finally, the test creates a 1-wide, 1-dimension allocation of this type
+ * and transfers memory to and from a single cell of this Allocation.
  *
  * Calls: elementCreate, elementComplexCreate, elementGetSubElements,
  * typeCreate, allocationCreateTyped, allocationElementWrite,
  * allocationElementRead
- *
- * This test currently has a bug, and should be fixed by 3/17.
- * TODO(butlermichael)
  */
-/*
 TEST_F(RenderscriptHidlTest, ComplexElementTest) {
     Element element1 = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
     Element element2 = context->elementCreate(DataType::UNSIGNED_32, DataKind::USER, false, 1);
 
     hidl_vec<Element> eins = {element1, element2};
     hidl_vec<hidl_string> names = {hidl_string("first"), hidl_string("second")};
-    hidl_vec<Size> arraySizesPtr = {sizeof(uint8_t), sizeof(uint32_t)};
+    hidl_vec<Size> arraySizesPtr = {1, 1};
     Element element3 = context->elementComplexCreate(eins, names, arraySizesPtr);
     EXPECT_NE(Element(0), element3);
 
@@ -400,28 +386,25 @@
                                                         namesOut.push_back(_names[1]);
                                                         arraySizesOut = _arraySizes;
                                                     });
-    EXPECT_NE(Element(0), ids[0]);
-    EXPECT_NE(Element(0), ids[1]);
+    EXPECT_EQ(element1, ids[0]);
+    EXPECT_EQ(element2, ids[1]);
     EXPECT_EQ("first", namesOut[0]);
     EXPECT_EQ("second", namesOut[1]);
-    EXPECT_EQ(sizeof(uint8_t), arraySizesOut[0]);
-    EXPECT_EQ(sizeof(uint32_t), arraySizesOut[1]);
+    EXPECT_EQ(Size(1), arraySizesOut[0]);
+    EXPECT_EQ(Size(1), arraySizesOut[1]);
 
-    // 128 x (uint8_t, uint32_t)
-    Type type = context->typeCreate(element3, 128, 0, 0, false, false, YuvFormat::YUV_NONE);
-    // 128 x (uint8_t, uint32_t)
+    // 1 x (uint8_t, uint32_t)
+    Type type = context->typeCreate(element3, 1, 0, 0, false, false, YuvFormat::YUV_NONE);
+    // 1 x (uint8_t, uint32_t)
     Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                            (int)AllocationUsageType::SCRIPT,
                                                            (Ptr)nullptr);
-    std::vector<uint32_t> dataIn(128), dataOut(128);
+    std::vector<uint32_t> dataIn(1), dataOut(1);
     std::generate(dataIn.begin(), dataIn.end(), [](){ static uint32_t val = 0; return val++; });
     hidl_vec<uint8_t> _data;
     _data.setToExternal((uint8_t*)dataIn.data(), dataIn.size()*sizeof(uint32_t));
     context->allocationElementWrite(allocation, 0, 0, 0, 0, _data, 1);
     context->allocationElementRead(allocation, 0, 0, 0, 0, (Ptr)dataOut.data(),
                                    (Size)dataOut.size()*sizeof(uint32_t), 1);
-    bool same = std::all_of(dataOut.begin(), dataOut.end(),
-                            [](uint32_t x){ static uint32_t val = 0; return x == val++; });
-    EXPECT_EQ(true, same);
+    EXPECT_EQ(dataIn, dataOut);
 }
-*/
diff --git a/renderscript/1.0/vts/functional/VtsHalRenderscriptV1_0TargetTest.h b/renderscript/1.0/vts/functional/VtsHalRenderscriptV1_0TargetTest.h
index fc1b7e4..527fef0 100644
--- a/renderscript/1.0/vts/functional/VtsHalRenderscriptV1_0TargetTest.h
+++ b/renderscript/1.0/vts/functional/VtsHalRenderscriptV1_0TargetTest.h
@@ -32,6 +32,7 @@
 using ::android::hardware::renderscript::V1_0::AllocationCubemapFace;
 using ::android::hardware::renderscript::V1_0::AllocationMipmapControl;
 using ::android::hardware::renderscript::V1_0::AllocationUsageType;
+using ::android::hardware::renderscript::V1_0::Closure;
 using ::android::hardware::renderscript::V1_0::IContext;
 using ::android::hardware::renderscript::V1_0::IDevice;
 using ::android::hardware::renderscript::V1_0::ContextType;
@@ -62,7 +63,26 @@
 using ::android::hardware::hidl_string;
 using ::android::sp;
 
-// bitcode variables
+// bitcode slots
+extern const int mExportVarIdx_var_int;
+extern const int mExportVarIdx_var_long;
+extern const int mExportVarIdx_var_float;
+extern const int mExportVarIdx_var_double;
+extern const int mExportVarIdx_var_allocation;
+extern const int mExportVarIdx_var_uint32_t;
+extern const int mExportVarIdx_var_point2;
+extern const int mExportVarIdx_var_int_ptr;
+// bitcode invoke slots
+//extern const int mExportForEachIdx_root;
+extern const int mExportForEachIdx_increment;
+// bitcode reduce slots
+extern const int mExportReduceIdx_summation;
+// bitcode invoke slots
+extern const int mExportFuncIdx_function;
+extern const int mExportFuncIdx_functionV;
+extern const int mExportFuncIdx_setBuffer;
+extern const int mExportFuncIdx_setAllocation;
+// bitcode
 typedef signed char int8_t;
 extern const int8_t bitCode[];
 extern const int bitCodeLength;
diff --git a/renderscript/1.0/vts/functional/VtsMiscellaneousTests.cpp b/renderscript/1.0/vts/functional/VtsMiscellaneousTests.cpp
index c2b3354..39d63ca 100644
--- a/renderscript/1.0/vts/functional/VtsMiscellaneousTests.cpp
+++ b/renderscript/1.0/vts/functional/VtsMiscellaneousTests.cpp
@@ -15,6 +15,7 @@
  */
 
 #include "VtsHalRenderscriptV1_0TargetTest.h"
+#include <system/window.h>
 
 /*
  * ContextCreateAndDestroy:
@@ -81,7 +82,7 @@
                                           elementMetadata = _metadata; });
     EXPECT_EQ(DataType::FLOAT_32, (DataType)elementMetadata[0]);
     EXPECT_EQ(DataKind::USER, (DataKind)elementMetadata[1]);
-    EXPECT_EQ(false, ((uint32_t)elementMetadata[2] == 1) ? true : false);
+    EXPECT_EQ(false, elementMetadata[2]);
     EXPECT_EQ(1u, (uint32_t)elementMetadata[3]);
     EXPECT_EQ(0u, (uint32_t)elementMetadata[4]);
 
@@ -134,21 +135,17 @@
  * Calls: elementCreate, typeCreate, allocationCreateTyped, allocation2DWrite,
  * allocationGetNativeWindow, allocationSetNativeWindow, allocationIoSend,
  * allocationIoReceive, allocation2DRead
- *
- * This test currently has a bug, and should be fixed by 3/17.
- * TODO(butlermichael)
  */
-/*
 TEST_F(RenderscriptHidlTest, NativeWindowIoTest) {
     // uint8x4
     Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 4);
     // 512 x 512 x uint8x4
     Type type = context->typeCreate(element, 512, 512, 0, false, false, YuvFormat::YUV_NONE);
     std::vector<uint32_t> dataIn(512*512), dataOut(512*512);
-    std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (uint32_t)val++; });
+    std::generate(dataIn.begin(), dataIn.end(), [](){ static uint32_t val = 0; return val++; });
     hidl_vec<uint8_t> _data;
     _data.setToExternal((uint8_t*)dataIn.data(), dataIn.size()*sizeof(uint32_t));
-    // 512 x 512 x float1
+    // 512 x 512 x uint8x4
     Allocation allocationRecv = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                                (int)(AllocationUsageType::SCRIPT
                                                                | AllocationUsageType::IO_INPUT),
@@ -157,21 +154,20 @@
                                                                (int)(AllocationUsageType::SCRIPT
                                                                | AllocationUsageType::IO_OUTPUT),
                                                                (Ptr)nullptr);
-    context->allocation2DWrite(allocationSend, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 512, 512,
-                               _data, 0);
     NativeWindow nativeWindow = context->allocationGetNativeWindow(allocationRecv);
     EXPECT_NE(NativeWindow(0), nativeWindow);
 
+    ((ANativeWindow *)nativeWindow)->incStrong(nullptr);
+
     context->allocationSetNativeWindow(allocationSend, nativeWindow);
+    context->allocation2DWrite(allocationSend, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 512, 512,
+                               _data, 0);
     context->allocationIoSend(allocationSend);
     context->allocationIoReceive(allocationRecv);
     context->allocation2DRead(allocationRecv, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 512, 512,
                               (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(uint32_t), 0);
-    bool same = std::all_of(dataOut.begin(), dataOut.end(),
-                             [](uint32_t x){ static int val = 0; return x == (uint32_t)val++; });
-    EXPECT_EQ(true, same);
+    EXPECT_EQ(dataIn, dataOut);
 }
-*/
 
 /*
  * Three allocations are created, two with IO_INPUT and one with IO_OUTPUT. The
@@ -180,21 +176,17 @@
  * Calls: elementCreate, typeCreate, allocationCreateTyped,
  * allocationCreateFromBitmap, allocationSetupBufferQueue,
  * allocationShareBufferQueue
- *
- * This test currently has a bug, and should be fixed by 3/17.
- * TODO(butlermichael)
  */
-/*
 TEST_F(RenderscriptHidlTest, BufferQueueTest) {
-    // float1
-    Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
-    // 512 x 512 x float1
+    // uint8x4
+    Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 4);
+    // 512 x 512 x uint8x4
     Type type = context->typeCreate(element, 512, 512, 0, false, false, YuvFormat::YUV_NONE);
-    std::vector<float> dataIn(512*512), dataOut1(512*512), dataOut2(512*512);
-    std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
+    std::vector<uint32_t> dataIn(512*512), dataOut1(512*512), dataOut2(512*512);
+    std::generate(dataIn.begin(), dataIn.end(), [](){ static uint32_t val = 0; return val++; });
     hidl_vec<uint8_t> _data;
-    _data.setToExternal((uint8_t*)dataIn.data(), dataIn.size()*sizeof(float));
-    // 512 x 512 x float1
+    _data.setToExternal((uint8_t*)dataIn.data(), dataIn.size()*sizeof(uint32_t));
+    // 512 x 512 x uint8x4
     Allocation allocationRecv1 = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                                 (int)(AllocationUsageType::SCRIPT
                                                                 | AllocationUsageType::IO_INPUT),
@@ -203,16 +195,37 @@
                                                                 (int)(AllocationUsageType::SCRIPT
                                                                 | AllocationUsageType::IO_INPUT),
                                                                 (Ptr)nullptr);
-    Allocation allocationSend = context->allocationCreateFromBitmap(type,
-                                                                    AllocationMipmapControl::NONE,
-                                                                    _data,
-                                                                   (int)(AllocationUsageType::SCRIPT
-                                                                 | AllocationUsageType::IO_OUTPUT));
+    Allocation allocationSend  = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
+                                                                (int)(AllocationUsageType::SCRIPT
+                                                                | AllocationUsageType::IO_INPUT),
+                                                                (Ptr)nullptr);
     context->allocationSetupBufferQueue(allocationRecv1, 2);
-    context->allocationShareBufferQueue(allocationRecv1, allocationRecv2);
-    // TODO: test the buffer queue
+    context->allocationShareBufferQueue(allocationRecv2, allocationRecv1);
+
+    NativeWindow nativeWindow1 = context->allocationGetNativeWindow(allocationRecv1);
+    EXPECT_NE(NativeWindow(0), nativeWindow1);
+    NativeWindow nativeWindow2 = context->allocationGetNativeWindow(allocationRecv2);
+    EXPECT_EQ(nativeWindow2, nativeWindow1);
+
+    ((ANativeWindow *)nativeWindow1)->incStrong(nullptr);
+
+    context->allocationSetNativeWindow(allocationSend, nativeWindow1);
+    context->allocation2DWrite(allocationSend, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 512, 512,
+                               _data, 0);
+    context->allocationIoSend(allocationSend);
+    context->allocationIoReceive(allocationRecv1);
+    context->allocation2DRead(allocationRecv1, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 512, 512,
+                              (Ptr)dataOut1.data(), (Size)dataOut1.size()*sizeof(uint32_t), 0);
+    EXPECT_EQ(dataIn, dataOut1);
+
+    context->allocation2DWrite(allocationSend, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 512, 512,
+                               _data, 0);
+    context->allocationIoSend(allocationSend);
+    context->allocationIoReceive(allocationRecv2);
+    context->allocation2DRead(allocationRecv2, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 512, 512,
+                              (Ptr)dataOut2.data(), (Size)dataOut2.size()*sizeof(uint32_t), 0);
+    EXPECT_EQ(dataIn, dataOut2);
 }
-*/
 
 /*
  * This test sets up the message queue, sends a message, peeks at the message,
@@ -220,33 +233,29 @@
  *
  * Calls: contextInitToClient, contextSendMessage, contextPeekMessage,
  * contextGetMessage, contextDeinitToClient, contextLog
- *
- * This test currently has a bug, and should be fixed by 3/17.
- * TODO(butlermichael)
  */
-/*
 TEST_F(RenderscriptHidlTest, ContextMessageTest) {
     context->contextInitToClient();
 
-    std::string messageOut = "correct";
+    const char * message = "correct";
+    std::vector<char> messageSend(message, message + sizeof(message));
     hidl_vec<uint8_t> _data;
-    _data.setToExternal((uint8_t*)const_cast<char*>(messageOut.c_str()), messageOut.length());
+    _data.setToExternal((uint8_t*)messageSend.data(), messageSend.size());
     context->contextSendMessage(0, _data);
     MessageToClientType messageType;
     size_t size;
     uint32_t subID;
     context->contextPeekMessage([&](MessageToClientType _type, Size _size, uint32_t _subID){
                                 messageType = _type; size = (uint32_t)_size; subID = _subID; });
-    std::vector<char> messageIn(size, '\0');
-    context->contextGetMessage(messageIn.data(), messageIn.size(),
+    std::vector<char> messageRecv(size, '\0');
+    context->contextGetMessage(messageRecv.data(), messageRecv.size(),
                                [&](MessageToClientType _type, Size _size){
                                messageType = _type; size = (uint32_t)_size; });
-    EXPECT_EQ(messageOut, messageIn.data());
+    EXPECT_EQ(messageSend, messageRecv);
 
     context->contextDeinitToClient();
     context->contextLog();
 }
-*/
 
 /*
  * Call through a bunch of APIs and make sure they don’t crash. Assign the name
diff --git a/renderscript/1.0/vts/functional/VtsScriptTests.cpp b/renderscript/1.0/vts/functional/VtsScriptTests.cpp
index 9531e19..6bb375a 100644
--- a/renderscript/1.0/vts/functional/VtsScriptTests.cpp
+++ b/renderscript/1.0/vts/functional/VtsScriptTests.cpp
@@ -46,27 +46,30 @@
     EXPECT_NE(Script(0), script);
 
     // arg tests
-    context->scriptSetVarI(script, 0, 100);
+    context->scriptSetVarI(script, mExportVarIdx_var_int, 100);
     int resultI = 0;
-    context->scriptGetVarV(script, 0, sizeof(int), [&](const hidl_vec<uint8_t>& _data){
-                               resultI = *((int*)_data.data()); });
+    context->scriptGetVarV(script, mExportVarIdx_var_int, sizeof(int),
+                           [&](const hidl_vec<uint8_t>& _data){ resultI = *((int*)_data.data()); });
     EXPECT_EQ(100, resultI);
 
-    context->scriptSetVarJ(script, 1, 101l);
+    context->scriptSetVarJ(script, mExportVarIdx_var_long, 101l);
     int resultJ = 0;
-    context->scriptGetVarV(script, 1, sizeof(long), [&](const hidl_vec<uint8_t>& _data){
+    context->scriptGetVarV(script, mExportVarIdx_var_long, sizeof(long),
+                           [&](const hidl_vec<uint8_t>& _data){
                                resultJ = *((long*)_data.data()); });
-    EXPECT_EQ(101, resultJ);
+    EXPECT_EQ(101l, resultJ);
 
-    context->scriptSetVarF(script, 2, 102.0f);
+    context->scriptSetVarF(script, mExportVarIdx_var_float, 102.0f);
     int resultF = 0.0f;
-    context->scriptGetVarV(script, 2, sizeof(float), [&](const hidl_vec<uint8_t>& _data){
+    context->scriptGetVarV(script, mExportVarIdx_var_float, sizeof(float),
+                           [&](const hidl_vec<uint8_t>& _data){
                                resultF = *((float*)_data.data()); });
     EXPECT_EQ(102.0f, resultF);
 
-    context->scriptSetVarD(script, 3, 103.0);
+    context->scriptSetVarD(script, mExportVarIdx_var_double, 103.0);
     int resultD = 0.0;
-    context->scriptGetVarV(script, 3, sizeof(double), [&](const hidl_vec<uint8_t>& _data){
+    context->scriptGetVarV(script, mExportVarIdx_var_double, sizeof(double),
+                           [&](const hidl_vec<uint8_t>& _data){
                                resultD = *((double*)_data.data()); });
     EXPECT_EQ(103.0, resultD);
 
@@ -79,23 +82,21 @@
                                                              (int)AllocationUsageType::SCRIPT,
                                                              (Ptr)nullptr);
     Allocation allocationOut = Allocation(0);
-    context->scriptSetVarObj(script, 4, (ObjectBase)allocationIn);
-    context->scriptGetVarV(script, 4, sizeof(ObjectBase), [&](const hidl_vec<uint8_t>& _data){
+    context->scriptSetVarObj(script, mExportVarIdx_var_allocation, (ObjectBase)allocationIn);
+    context->scriptGetVarV(script, mExportVarIdx_var_allocation, sizeof(ObjectBase),
+                           [&](const hidl_vec<uint8_t>& _data){
                                allocationOut = (Allocation) *((ObjectBase*)_data.data()); });
     EXPECT_EQ(allocationOut, allocationIn);
 
-    std::vector<int> arrayIn = {500, 501, 502, 503};
-    std::vector<int> arrayOut(4);
-    hidl_vec<uint8_t> arrayData;
-    arrayData.setToExternal((uint8_t*)arrayIn.data(), arrayIn.size()*sizeof(int));
-    context->scriptSetVarV(script, 5, arrayData);
-    context->scriptGetVarV(script, 5, 4*sizeof(int), [&](const hidl_vec<uint8_t>& _data){
-                               arrayOut = std::vector<int>((int*)_data.data(),
-                                                           (int*)_data.data() + 4); });
-    EXPECT_EQ(500, arrayOut[0]);
-    EXPECT_EQ(501, arrayOut[1]);
-    EXPECT_EQ(502, arrayOut[2]);
-    EXPECT_EQ(503, arrayOut[3]);
+    uint32_t valueV = 104u;
+    hidl_vec<uint8_t> _dataV;
+    _dataV.setToExternal((uint8_t*)&valueV, sizeof(uint32_t));
+    context->scriptSetVarV(script, mExportVarIdx_var_uint32_t, _dataV);
+    uint32_t resultV = 0u;
+    context->scriptGetVarV(script, mExportVarIdx_var_uint32_t, sizeof(uint32_t),
+                           [&](const hidl_vec<uint8_t>& _data){
+                               resultV = *((uint32_t*)_data.data()); });
+    EXPECT_EQ(104u, resultV);
 
     std::vector<int> dataVE = {1000, 1001};
     std::vector<uint32_t> dimsVE = {1};
@@ -104,12 +105,13 @@
     hidl_vec<uint32_t> _dimsVE;
     _dataVE.setToExternal((uint8_t*)dataVE.data(), dataVE.size()*sizeof(int));
     _dimsVE.setToExternal((uint32_t*)dimsVE.data(), dimsVE.size());
-    // intx2
+    // intx2 to represent point2 which is {int, int}
     Element elementVE = context->elementCreate(DataType::SIGNED_32, DataKind::USER, false, 2);
-    context->scriptSetVarVE(script, 6, _dataVE, elementVE, _dimsVE);
-    context->scriptGetVarV(script, 6, 2*sizeof(int), [&](const hidl_vec<uint8_t>& _data){
-                               outVE = std::vector<int>((int*)_data.data(),
-                                                        (int*)_data.data() + 2); });
+    context->scriptSetVarVE(script, mExportVarIdx_var_point2, _dataVE, elementVE, _dimsVE);
+    context->scriptGetVarV(script, mExportVarIdx_var_point2, 2*sizeof(int),
+                           [&](const hidl_vec<uint8_t>& _data){
+                               outVE = std::vector<int>(
+                                   (int*)_data.data(), (int*)_data.data() + 2); });
     EXPECT_EQ(1000, outVE[0]);
     EXPECT_EQ(1001, outVE[1]);
 }
@@ -127,19 +129,47 @@
     EXPECT_NE(Script(0), script);
 
     // invoke test
-    int function_res = 0;
-    context->scriptInvoke(script, 0);
-    context->scriptGetVarV(script, 0, sizeof(int), [&](const hidl_vec<uint8_t>& _data){
-                               function_res = *((int*)_data.data()); });
-    EXPECT_NE(100, function_res);
+    int resultI = 0;
+    long resultJ = 0l;
+    float resultF = 0.0f;
+    double resultD = 0.0;
+    uint32_t resultV = 0u;
+    std::vector<int> resultVE(2);
+    context->scriptInvoke(script, mExportFuncIdx_function);
+    context->scriptGetVarV(script, mExportVarIdx_var_int, sizeof(int),
+                           [&](const hidl_vec<uint8_t>& _data){ resultI = *((int*)_data.data()); });
+    context->scriptGetVarV(script, mExportVarIdx_var_long, sizeof(long),
+                           [&](const hidl_vec<uint8_t>& _data){
+                               resultJ = *((long*)_data.data()); });
+    context->scriptGetVarV(script, mExportVarIdx_var_float, sizeof(float),
+                           [&](const hidl_vec<uint8_t>& _data){
+                               resultF = *((float*)_data.data()); });
+    context->scriptGetVarV(script, mExportVarIdx_var_double, sizeof(double),
+                           [&](const hidl_vec<uint8_t>& _data){
+                               resultD = *((double*)_data.data()); });
+    context->scriptGetVarV(script, mExportVarIdx_var_uint32_t, sizeof(uint32_t),
+                           [&](const hidl_vec<uint8_t>& _data){
+                               resultV = *((uint32_t*)_data.data()); });
+    context->scriptGetVarV(script, mExportVarIdx_var_point2, 2*sizeof(int),
+                           [&](const hidl_vec<uint8_t>& _data){
+                               resultVE = std::vector<int>(
+                                   (int*)_data.data(), (int*)_data.data() + 2); });
+    EXPECT_EQ(1, resultI);
+    EXPECT_EQ(2l, resultJ);
+    EXPECT_EQ(3.0f, resultF);
+    EXPECT_EQ(4.0, resultD);
+    EXPECT_EQ(5u, resultV);
+    EXPECT_EQ(6, resultVE[0]);
+    EXPECT_EQ(7, resultVE[1]);
 
     // invokeV test
     int functionV_arg = 5;
     int functionV_res = 0;
     hidl_vec<uint8_t> functionV_data;
     functionV_data.setToExternal((uint8_t*)&functionV_arg, sizeof(int));
-    context->scriptInvokeV(script, 1, functionV_data);
-    context->scriptGetVarV(script, 0, sizeof(int), [&](const hidl_vec<uint8_t>& _data){
+    context->scriptInvokeV(script, mExportFuncIdx_functionV, functionV_data);
+    context->scriptGetVarV(script, mExportVarIdx_var_int, sizeof(int),
+                           [&](const hidl_vec<uint8_t>& _data){
                                functionV_res = *((int*)_data.data()); });
     EXPECT_EQ(5, functionV_res);
 }
@@ -161,8 +191,9 @@
     Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
     // 64 x uint8_t
     Type type = context->typeCreate(element, 64, 0, 0, false, false, YuvFormat::YUV_NONE);
-    std::vector<uint8_t> dataIn(64), dataOut(64);
+    std::vector<uint8_t> dataIn(64), dataOut(64), expected(64);
     std::generate(dataIn.begin(), dataIn.end(), [](){ static uint8_t val = 0; return val++; });
+    std::generate(expected.begin(), expected.end(), [](){ static uint8_t val = 1; return val++; });
     hidl_vec<uint8_t> _data;
     _data.setToExternal((uint8_t*)dataIn.data(), dataIn.size());
     // 64 x float1
@@ -176,11 +207,9 @@
     hidl_vec<Allocation> vains;
     vains.setToExternal(&allocation, 1);
     hidl_vec<uint8_t> params;
-    context->scriptForEach(script, 1, vains, vout, params, nullptr);
+    context->scriptForEach(script, mExportForEachIdx_increment, vains, vout, params, nullptr);
     context->allocationRead(vout, (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(uint8_t));
-    bool same = std::all_of(dataOut.begin(), dataOut.end(),
-                            [](uint8_t x){ static uint8_t val = 1; return x == val++; });
-    EXPECT_EQ(true, same);
+    EXPECT_EQ(expected, dataOut);
 }
 
 /*
@@ -215,7 +244,7 @@
     context->allocation1DWrite(allocation, 0, 0, (Size)dataIn.size(), _data);
     hidl_vec<Allocation> vains;
     vains.setToExternal(&allocation, 1);
-    context->scriptReduce(script, 0, vains, vaout, nullptr);
+    context->scriptReduce(script, mExportReduceIdx_summation, vains, vaout, nullptr);
     context->contextFinish();
     context->allocationRead(vaout, (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(int));
     // sum of 0, 1, 2, ..., 62, 63
@@ -228,38 +257,34 @@
  * RenderScript script, represented in the bitcode.
  *
  * Calls: scriptCCreate, elementCreate, typeCreate, allocationCreateTyped,
- * allocationGetPointer, scriptBindAllocation
- *
- * This test currently has a bug, and should be fixed by 3/17.
- * TODO(butlermichael)
+ * scriptSetVarV, scriptBindAllocation, allocationRead
  */
-/*
 TEST_F(RenderscriptHidlTest, ScriptBindTest) {
     hidl_vec<uint8_t> bitcode;
     bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
     Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);
     EXPECT_NE(Script(0), script);
 
-    // uint8_t
+    // in32
     Element element = context->elementCreate(DataType::SIGNED_32, DataKind::USER, false, 1);
-    // 64 x uint8_t
+    // 64 x int32
     Type type = context->typeCreate(element, 64, 0, 0, false, false, YuvFormat::YUV_NONE);
-    // 64 x float1
+    // 64 x int32
     Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                            (int)AllocationUsageType::SCRIPT,
                                                            (Ptr)nullptr);
-    Ptr dataPtr1, dataPtr2;
-    Size stride;
-    context->allocationGetPointer(allocation, 0, AllocationCubemapFace::POSITIVE_X, 0,
-                                  [&](Ptr _dataPtr, Size _stride){ dataPtr1 = _dataPtr;
-                                      stride = _stride; });
-    context->scriptBindAllocation(script, allocation, 7);
-    context->allocationGetPointer(allocation, 0, AllocationCubemapFace::POSITIVE_X, 0,
-                                  [&](Ptr _dataPtr, Size _stride){ dataPtr2 = _dataPtr;
-                                      stride = _stride; });
-    EXPECT_NE(dataPtr1, dataPtr2);
+    std::vector<int> dataIn(64), dataOut(64), expected(64, 5);
+    hidl_vec<uint8_t> _data;
+    _data.setToExternal((uint8_t*)dataIn.data(), dataIn.size()*sizeof(int));
+    context->allocation1DWrite(allocation, 0, 0, (Size)dataIn.size(), _data);
+    context->scriptBindAllocation(script, allocation, mExportVarIdx_var_int_ptr);
+    int dim = 64;
+    hidl_vec<uint8_t> _dim;
+    _dim.setToExternal((uint8_t*)&dim, sizeof(int));
+    context->scriptInvokeV(script, mExportFuncIdx_setBuffer, _dim);
+    context->allocationRead(allocation, (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(int));
+    EXPECT_EQ(expected, dataOut);
 }
-*/
 
 /*
  * This test groups together two RenderScript intrinsic kernels to run one after
@@ -269,38 +294,25 @@
  * ScriptGroup.
  *
  * Calls: elementCreate, typeCreate, allocationCreateTyped, allocation2DWrite,
- * scriptIntrinsicCreate, scriptKernelIDCreate, scriptGroupCreate,
- * scriptGroupSetInput, scriptGroupSetOutput, scriptGroupExecute,
- * allocation2DRead
- *
- * This test currently has a bug, and should be fixed by 3/17.
- * TODO(butlermichael)
+ * scriptIntrinsicCreate, scriptKernelIDCreate, scriptFieldIDCreate,
+ * scriptGroupCreate, scriptGroupSetOutput, scriptGroupExecute, allocation2DRead
  */
-/*
 TEST_F(RenderscriptHidlTest, ScriptGroupTest) {
-    //std::vector<uint8_t> dataIn(256*256*1, 128), dataOut(256*256*3, 0);
-    std::vector<uint8_t> dataIn(256*256*1, 128), dataOut(256*256*4, 0);
+    std::vector<uint8_t> dataIn(256*256*1, 128), dataOut(256*256*4, 0), zeros(256*256*4, 0);
     hidl_vec<uint8_t> _dataIn, _dataOut;
     _dataIn.setToExternal(dataIn.data(), dataIn.size());
-    _dataOut.setToExternal(dataOut.data(), dataIn.size());
+    _dataOut.setToExternal(dataOut.data(), dataOut.size());
 
     // 256 x 256 YUV pixels
     Element element1 = context->elementCreate(DataType::UNSIGNED_8, DataKind::PIXEL_YUV, true, 1);
-    //Type type1 = context->typeCreate(element1, 256, 256, 0, false, false, YuvFormat::YUV_420_888);
-    Type type1 = context->typeCreate(element1, 256, 256, 0, false, false, YuvFormat::YUV_NV21);
+    Type type1 = context->typeCreate(element1, 256, 256, 0, false, false, YuvFormat::YUV_420_888);
     Allocation allocation1 = context->allocationCreateTyped(type1, AllocationMipmapControl::NONE,
                                                            (int)AllocationUsageType::SCRIPT,
                                                            (Ptr)nullptr);
     context->allocation2DWrite(allocation1, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 256, 256,
                                _dataIn, 0);
-    Script yuv2rgb = context->scriptIntrinsicCreate(ScriptIntrinsicID::ID_YUV_TO_RGB, element1);
-    EXPECT_NE(Script(0), yuv2rgb);
 
-    ScriptKernelID yuv2rgbKID = context->scriptKernelIDCreate(yuv2rgb, 0, 2);
-    EXPECT_NE(ScriptKernelID(0), yuv2rgbKID);
-
-    // 256 x 256 RGB pixels
-    //Element element2 = context->elementCreate(DataType::UNSIGNED_8, DataKind::PIXEL_RGB, true, 3);
+    // 256 x 256 RGBA pixels
     Element element2 = context->elementCreate(DataType::UNSIGNED_8, DataKind::PIXEL_RGBA, true, 4);
     Type type2 = context->typeCreate(element2, 256, 256, 0, false, false, YuvFormat::YUV_NONE);
     Allocation allocation2 = context->allocationCreateTyped(type2, AllocationMipmapControl::NONE,
@@ -308,83 +320,170 @@
                                                            (Ptr)nullptr);
     context->allocation2DWrite(allocation2, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 256, 256,
                                _dataOut, 0);
+
+    // create scripts
+    Script yuv2rgb = context->scriptIntrinsicCreate(ScriptIntrinsicID::ID_YUV_TO_RGB, element1);
+    EXPECT_NE(Script(0), yuv2rgb);
+
+    ScriptKernelID yuv2rgbKID = context->scriptKernelIDCreate(yuv2rgb, 0, 2);
+    EXPECT_NE(ScriptKernelID(0), yuv2rgbKID);
+
     Script blur = context->scriptIntrinsicCreate(ScriptIntrinsicID::ID_BLUR, element2);
     EXPECT_NE(Script(0), blur);
 
     ScriptKernelID blurKID = context->scriptKernelIDCreate(blur, 0, 2);
     EXPECT_NE(ScriptKernelID(0), blurKID);
+    ScriptFieldID blurFID = context->scriptFieldIDCreate(blur, 1);
+    EXPECT_NE(ScriptFieldID(0), blurFID);
 
     // ScriptGroup
     hidl_vec<ScriptKernelID> kernels = {yuv2rgbKID, blurKID};
     hidl_vec<ScriptKernelID> srcK = {yuv2rgbKID};
-    hidl_vec<ScriptKernelID> dstK = {blurKID};
-    hidl_vec<ScriptFieldID> dstF = {};
+    hidl_vec<ScriptKernelID> dstK = {ScriptKernelID(0)};
+    hidl_vec<ScriptFieldID> dstF = {blurFID};
     hidl_vec<Type> types = {type2};
     ScriptGroup scriptGroup = context->scriptGroupCreate(kernels, srcK, dstK, dstF, types);
     EXPECT_NE(ScriptGroup(0), scriptGroup);
 
-    context->scriptGroupSetInput(scriptGroup, yuv2rgbKID, allocation1);
+    context->scriptSetVarObj(yuv2rgb, 0, (ObjectBase)allocation1);
     context->scriptGroupSetOutput(scriptGroup, blurKID, allocation2);
     context->scriptGroupExecute(scriptGroup);
+    context->contextFinish();
 
     // verify contents were changed
     context->allocation2DRead(allocation2, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 256, 256,
                               (Ptr)dataOut.data(), (Size)dataOut.size(), 0);
-    bool same = std::all_of(dataOut.begin(), dataOut.end(), [](uint8_t x){ return x != 0; });
-    EXPECT_EQ(true, same);
+    EXPECT_NE(zeros, dataOut);
 }
-*/
 
 /*
  * Similar to the ScriptGroup test, this test verifies the execution flow of
  * RenderScript kernels and invokables.
  *
  * Calls: scriptFieldIDCreate, closureCreate, scriptInvokeIDCreate,
- * invokeClosureCreate, closureSetArg, closureSetGlobal, scriptGroup2Create,
- * scriptGroupExecute
- *
- * This test currently still a work in progress, and should be finished by 3/17.
- * TODO(butlermichael)
+ * invokeClosureCreate, closureSetGlobal, scriptGroup2Create, scriptGroupExecute
  */
-/*
 TEST_F(RenderscriptHidlTest, ScriptGroup2Test) {
+    hidl_vec<uint8_t> bitcode;
+    bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
+    Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);
+    EXPECT_NE(Script(0), script);
 
-    ScriptFieldID fieldID = context->scriptFieldIDCreate(script, slot);
+    std::vector<uint8_t> dataIn(128, 128), dataOut(128, 0), expected(128, 7+1);
+    hidl_vec<uint8_t> _dataIn, _dataOut;
+    _dataIn.setToExternal(dataIn.data(), dataIn.size());
+
+    // 256 x 256 YUV pixels
+    Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
+    Type type = context->typeCreate(element, 128, 0, 0, false, false, YuvFormat::YUV_NONE);
+    Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
+                                                           (int)AllocationUsageType::SCRIPT,
+                                                           (Ptr)nullptr);
+    context->allocation1DWrite(allocation, 0, 0, (Size)_dataIn.size(), _dataIn);
+
+    ScriptFieldID fieldID = context->scriptFieldIDCreate(script, mExportVarIdx_var_allocation);
     EXPECT_NE(ScriptFieldID(0), fieldID);
+    ASSERT_NE(ScriptFieldID(0), fieldID);
 
-    ScriptKernelID kernelID = context->scriptKernelIDCreate(script, slot, sig);
-    EXPECT_NE(ScriptKernelID(0), kernelID);
-
-    Allocation returnValue = 0;
-    hidl_vec<ScriptFieldID> fieldIDS = {};
-    hidl_vec<int64_t> values = {};
-    hidl_vec<int32_t> sizes = {};
-    hidl_veC<Closure> depClosures = {};
-    hidl_vec<ScriptFieldID> depFieldIDS = {};
-    Closure closure1 = context->closureCreate(kernelID, returnValue, fieldIDS, values, sizes,
-                                             depClosures, depFieldIDS);
-    EXPECT_NE(Closure(0), closure1);
-
-    ScriptInvokeID invokeID = context->scriptInvokeIDCreate(script, slot);
+    // invoke
+    ScriptInvokeID invokeID = context->scriptInvokeIDCreate(script, mExportFuncIdx_setAllocation);
     EXPECT_NE(ScriptInvokeID(0), invokeID);
+    ASSERT_NE(ScriptInvokeID(0), invokeID);
 
-    hidl_vec<uint8_t> params = {};
-    hidl_vec<ScriptFieldID> fieldsIDS2 = {};
-    hidl_vec<int64_t> values2 = {};
-    hidl_vec<int32_t> sizes2 = {};
-    Closure closure2 = context->invokeClosureCreate(invokeID, params, fieldIDS2, values2, sizes2);
+    int dim = 128;
+    hidl_vec<uint8_t> params;
+    params.setToExternal((uint8_t*)&dim, sizeof(dim));
+    hidl_vec<ScriptFieldID> fieldIDS1 = {fieldID};
+    hidl_vec<int64_t> values1 = {int64_t(0)};
+    hidl_vec<int32_t> sizes1 = {int32_t(0)};
+    Closure closure1 = context->invokeClosureCreate(invokeID, params, fieldIDS1, values1, sizes1);
+    EXPECT_NE(Closure(0), closure1);
+    ASSERT_NE(Closure(0), closure1);
+
+    // kernel
+    ScriptKernelID kernelID = context->scriptKernelIDCreate(script, mExportForEachIdx_increment, 3);
+    EXPECT_NE(ScriptKernelID(0), kernelID);
+    ASSERT_NE(ScriptKernelID(0), kernelID);
+
+    hidl_vec<ScriptFieldID> fieldIDS2 = {ScriptFieldID(0)};
+    hidl_vec<int64_t> values2 = {(int64_t)(intptr_t)allocation};
+    hidl_vec<int32_t> sizes2 = {-1 /* allocation */};
+    hidl_vec<Closure> depClosures2 = {closure1};
+    hidl_vec<ScriptFieldID> depFieldIDS2 = {fieldID};
+    Closure closure2 = context->closureCreate(kernelID, allocation /* returnValue */, fieldIDS2,
+                                              values2, sizes2, depClosures2, depFieldIDS2);
     EXPECT_NE(Closure(0), closure2);
+    ASSERT_NE(Closure(0), closure2);
 
-    context->closureSetArg(closure, index, value, size);
-    context->closureSetGlobal(closure, fieldID, value, size);
+    // set argument
+    context->closureSetGlobal(closure1, fieldID, (int64_t)(intptr_t)allocation,
+                              -1 /* allocation */);
 
+    // execute
     hidl_string name = "script_group_2_test";
-    hidl_string cacheDir = "data/local/tmp/";
-    hidl_vec<Closures> closures;
+    hidl_string cacheDir = "/data/local/tmp";
+    hidl_vec<Closure> closures = {closure1, closure2};
     ScriptGroup2 scriptGroup2 = context->scriptGroup2Create(name, cacheDir, closures);
     EXPECT_NE(ScriptGroup2(0), scriptGroup2);
+    ASSERT_NE(ScriptGroup2(0), scriptGroup2);
 
     context->scriptGroupExecute(scriptGroup2);
-    // verify script group launched...
+    context->allocationRead(allocation, (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(uint8_t));
+    EXPECT_EQ(expected, dataOut);
 }
-*/
+
+/*
+ * Similar to the ScriptGroup test, this test verifies a single kernel can be
+ * called by ScriptGroup with an unbound allocation specified before launch
+ *
+ * Calls: scriptFieldIDCreate, closureCreate, scriptInvokeIDCreate,
+ * invokeClosureCreate, closureSetArg, scriptGroup2Create, scriptGroupExecute
+ */
+TEST_F(RenderscriptHidlTest, ScriptGroup2KernelTest) {
+    hidl_vec<uint8_t> bitcode;
+    bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
+    Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);
+    EXPECT_NE(Script(0), script);
+
+    std::vector<uint8_t> dataIn(128, 128), dataOut(128, 0), expected(128, 128 + 1);
+    hidl_vec<uint8_t> _dataIn, _dataOut;
+    _dataIn.setToExternal(dataIn.data(), dataIn.size());
+
+    // 256 x 256 YUV pixels
+    Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
+    Type type = context->typeCreate(element, 128, 0, 0, false, false, YuvFormat::YUV_NONE);
+    Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
+                                                           (int)AllocationUsageType::SCRIPT,
+                                                           (Ptr)nullptr);
+    context->allocation1DWrite(allocation, 0, 0, (Size)_dataIn.size(), _dataIn);
+
+    // kernel
+    ScriptKernelID kernelID = context->scriptKernelIDCreate(script, mExportForEachIdx_increment, 3);
+    EXPECT_NE(ScriptKernelID(0), kernelID);
+    ASSERT_NE(ScriptKernelID(0), kernelID);
+
+    hidl_vec<ScriptFieldID> fieldIDS = {ScriptFieldID(0)};
+    hidl_vec<int64_t> values = {int64_t(0)};
+    hidl_vec<int32_t> sizes = {int32_t(0)};
+    hidl_vec<Closure> depClosures = {Closure(0)};
+    hidl_vec<ScriptFieldID> depFieldIDS = {ScriptFieldID(0)};
+    Closure closure = context->closureCreate(kernelID, allocation /* returnValue */, fieldIDS,
+                                              values, sizes, depClosures, depFieldIDS);
+    EXPECT_NE(Closure(0), closure);
+    ASSERT_NE(Closure(0), closure);
+
+    // set argument
+    context->closureSetArg(closure, 0 /* first argument */, (Ptr)allocation, -1);
+
+    // execute
+    hidl_string name = "script_group_2_test";
+    hidl_string cacheDir = "/data/local/tmp";
+    hidl_vec<Closure> closures = {closure};
+    ScriptGroup2 scriptGroup2 = context->scriptGroup2Create(name, cacheDir, closures);
+    EXPECT_NE(ScriptGroup2(0), scriptGroup2);
+    ASSERT_NE(ScriptGroup2(0), scriptGroup2);
+
+    context->scriptGroupExecute(scriptGroup2);
+    context->allocationRead(allocation, (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(uint8_t));
+    EXPECT_EQ(expected, dataOut);
+}
diff --git a/renderscript/1.0/vts/functional/bitcode.cpp b/renderscript/1.0/vts/functional/bitcode.cpp
index 72143c9..8a7d542 100644
--- a/renderscript/1.0/vts/functional/bitcode.cpp
+++ b/renderscript/1.0/vts/functional/bitcode.cpp
@@ -15,169 +15,215 @@
  */
 
 /*
-#include "shared.rsh"
-
-// types
-typedef struct Point2 {
-    int x;
-    int y;
-} Point_2;
-
-// variables
-int var_int;
-long var_long;
-float var_float;
-double var_double;
-rs_allocation var_allocation;
-int var_array[4];
-Point_2 var_point2;
-Point_2 *var_point2_ptr;
-
-// invoke
-void function() {
-    var_int = 1;
-    var_long = 2;
-    var_float = 3.0f;
-    var_double = 4.0;
-
-    var_array[0] = 5;
-    var_array[1] = 6;
-    var_array[2] = 7;
-    var_array[3] = 8;
-
-    var_point2.x = 9;
-    var_point2.y = 10;
-}
-
-// invokeV
-void functionV(int arg) {
-    var_int = arg;
-}
-
-// forEach
-uchar RS_KERNEL increment(uchar in) {
-    return in+1;
-}
-
-// reduction
-#pragma rs reduce(summation) accumulator(sumAccumulator) combiner(sumCombiner)
-
-static void sumAccumulator(int* accum, int val) {
-    *accum += val;
-}
-
-static void sumCombiner(int* accum, const int *val) {
-    *accum += *val;
-}
-*/
+ * // This .rs code was used to generate the 32-bit and 64-bit versions of the
+ * // bitcode shown below. It is left in here for reference, as many of the
+ * // variables are used in the the script tests.
+ *
+ * #include "shared.rsh"
+ *
+ * // types
+ * typedef struct Point2 {
+ *     int x;
+ *     int y;
+ * } Point_2;
+ *
+ * // variables
+ * int var_int;
+ * long var_long;
+ * float var_float;
+ * double var_double;
+ * rs_allocation var_allocation;
+ * uint32_t var_uint32_t;
+ * Point_2 var_point2;
+ * int *var_int_ptr;
+ *
+ * // invoke
+ * void function() {
+ *     var_int = 1;
+ *     var_long = 2;
+ *     var_float = 3.0f;
+ *     var_double = 4.0;
+ *     var_uint32_t = 5;
+ *     var_point2.x = 6;
+ *     var_point2.y = 7;
+ * }
+ *
+ * // invokeV
+ * void functionV(int arg) {
+ *     var_int = arg;
+ * }
+ *
+ * // set bound buffer
+ * void setBuffer(int dim) {
+ *     int i;
+ *     for (i = 0; i < dim; ++i) {
+ *         var_int_ptr[i] = 5;
+ *     }
+ * }
+ *
+ * // set allocation
+ * void setAllocation(int dim) {
+ *     int x;
+ *     for (x = 0; x < dim; ++x) {
+ *         rsSetElementAt_uchar(var_allocation, 7, x);
+ *     }
+ * }
+ *
+ * // forEach
+ * uchar RS_KERNEL increment(uchar in) {
+ *     return in+1;
+ * }
+ *
+ * // reduction
+ * #pragma rs reduce(summation) accumulator(sumAccumulator) combiner(sumCombiner)
+ *
+ * static void sumAccumulator(int* accum, int val) {
+ *     *accum += val;
+ * }
+ *
+ * static void sumCombiner(int* accum, const int *val) {
+ *     *accum += *val;
+ * }
+ */
 
 #include "VtsHalRenderscriptV1_0TargetTest.h"
 
+// bitcode slots
+const int mExportVarIdx_var_int = 0;
+const int mExportVarIdx_var_long = 1;
+const int mExportVarIdx_var_float = 2;
+const int mExportVarIdx_var_double = 3;
+const int mExportVarIdx_var_allocation = 4;
+const int mExportVarIdx_var_uint32_t = 5;
+const int mExportVarIdx_var_point2 = 6;
+const int mExportVarIdx_var_int_ptr = 7;
+// bitcode invoke slots
+//const int mExportForEachIdx_root = 0;
+const int mExportForEachIdx_increment = 1;
+// bitcode reduce slots
+const int mExportReduceIdx_summation = 0;
+// bitcode invoke slots
+const int mExportFuncIdx_function = 0;
+const int mExportFuncIdx_functionV = 1;
+const int mExportFuncIdx_setBuffer = 2;
+const int mExportFuncIdx_setAllocation = 3;
+
+// bitcode
 #ifndef __LP64__
 
 const int8_t bitCode[] = {
-     -34,  -64,   23,   11,    0,    0,    0,    0,   44,    0,    0,    0,  -84,   10,    0,    0,
+     -34,  -64,   23,   11,    0,    0,    0,    0,   44,    0,    0,    0,   -8,   12,    0,    0,
        0,    0,    0,    0,   -1,   -1,   -1,   -1,    0,    0,    0,    0,    1,   64,    4,    0,
       96,    9,    0,    0,    2,   64,    4,    0,    3,    0,    0,    0,   66,   67,  -64,  -34,
-      33,   12,    0,    0,  -88,    2,    0,    0,    1,   16,    0,    0,   18,    0,    0,    0,
+      33,   12,    0,    0,   59,    3,    0,    0,    1,   16,    0,    0,   18,    0,    0,    0,
        7, -127,   35, -111,   65,  -56,    4,   73,    6,   16,   50,   57, -110,    1, -124,   12,
       37,    5,    8,   25,   30,    4, -117,   98, -128,   24,   69,    2,   66, -110,   11,   66,
      -60,   16,   50,   20,   56,    8,   24,   73,   10,   50,   68,   36,   72,   10, -112,   33,
       35,  -60,   82, -128,   12,   25,   33,  114,   36,    7,  -56, -120,   17,   98,  -88,  -96,
-     -88,   64,  -58,  -16,    1,    0,    0,    0,   73,   24,    0,    0,   25,    0,    0,    0,
-      11, -124,   -1,   -1,   -1,   -1,   31,  -64,   96, -127,    1,    4,   65,  -16,   -1,   -1,
-      -1,   -1,    3,   24,   45,   32,    2,   16,    4,   65,   16,   36,   -2,   -1,   -1,   -1,
-     127,    0, -125,    5,   70,    0, -126,   32,    8, -126, -124,    0, -126,   32,    8, -126,
-     -60,   -1,   -1,   -1,   -1,   15,   96,  -80,   64,   -8,   -1,   -1,   -1,   -1,    1,   12,
-      22,    8,   -1,   -1,   -1,   -1,   63,    0,   11, -120,    0,    4,   65,   16,    4, -119,
-      -1,   -1,   -1,   -1,   31,  -64,   80,   88,   64,    4,  -64,   -1,   -1,   -1,   -1,   15,
-      96,    0,    0,    0, -119,   32,    0,    0,   33,    0,    0,    0,   50,   34, -120,    9,
-      32,  100, -123,    4,   19,   35,  -92, -124,    4,   19,   35,  -29, -124,  -95, -112,   20,
-      18,   76, -116, -116,   11, -124,  -60,   76,   16, -112,  -63,   28,    1,   24,   16,   48,
-      71,    0,   10,   36,  -52,    0,   16,   49,    4,   64,   70,   18,    0, -124,   92,   35,
-      77,   17,   37,   76,  126,  -22,   32,  -51,  100,   35,    1,    0,   72,  -71,   75, -102,
-      34,   74, -104,   -4,   72,   -6, -127,  101,  113,    4,   96,   66, -100,  -58,  -65,  115,
-      20,    4,  -60,  -48,   50,   71, -128,  -48,   67,  -48,    8,   64,    9,   36, -102, -118,
-      32,    1,   84,   21,  -31,  121,  -24,   42, -125,   20,    0, -108, -107,   65,   10,    2,
-     -38, -118,   32,   53,  -44, -103,    0,  -96,  -81,    8,   18,   72,  -31,   64,    0,    0,
+     -88,   64,  -58,  -16,    1,    0,    0,    0,   73,   24,    0,    0,   34,    0,    0,    0,
+      11, -124,   -1,   -1,   -1,   -1,   31,  -64,   96, -127,  -16,   -1,   -1,   -1,   -1,    3,
+      24,   44,   32, -124,  -32,   -1,   -1,   -1,   -1,    7,   96, -127,    1,    4,   65,  -16,
+      -1,   -1,   -1,   -1,    3,   24,   45,   32,    2,   16,    4,   65,   16,   36,   -2,   -1,
+      -1,   -1,  127,    0, -125,    5,   70,    0, -126,   32,    8, -126, -124,    0, -126,   32,
+       8, -126,  -60,   -1,   -1,   -1,   -1,   15,   96,  -80,   64,   -8,   -1,   -1,   -1,   -1,
+       1,   88,   64,    4,   32,    8, -126,   32,   72,   -4,   -1,   -1,   -1,   -1,    0, -122,
+     -62,    2,   34,    0,   65,   16,    4,   65,  -30,   -1,   -1,   -1,   -1,    7,   48,   20,
+      22,   16,   66,  -16,   -1,   -1,   -1,   -1,    3,   24,   44,   32,    2,  -32,   -1,   -1,
+      -1,   -1,    7,   48,    0,    0,    0,    0, -119,   32,    0,    0,   36,    0,    0,    0,
+      50,   34, -120,    9,   32,  100, -123,    4,   19,   35,  -92, -124,    4,   19,   35,  -29,
+    -124,  -95, -112,   20,   18,   76, -116, -116,   11, -124,  -60,   76,   16, -100,  -63,   28,
+       1,   24,   16,   48,   71,    0,   10,   36,  -52,    0,   16,   49,    4,   64,  -58,   53,
+     -46,   20,   81,  -62,  -28,  -89,   14,  -46,   76,   54,   18,    0, -128,   16,   10,  -18,
+    -110,  -90, -120,   18,   38,   63, -110,  126,   96,   89,   28,    1, -104,   16,  -89,  -15,
+     -17,   28,    5,    1,   45,  115,    4,    8,   53,  -28, -116,    0, -108,    0,  -94,  -88,
+       8,   16,   64,   83,    6,    0, -123, -128,  -86,    6,   32,  -85,    8,   77,   67,   88,
+      25,  -96,    0,   32,  -83,   12,   80,   16,   16,   87,    4, -120,   33,  -49,    4,    0,
+    -127,   69, -128,   66,   18,    7,    2,  -26,    8, -126,   41,    0,    0,    0,    0,    0,
       19,  -80,  112, -112, -121,  118,  -80, -121,   59,  104,    3,  119,  120,    7,  119,   40,
     -121,   54,   96, -121,  116,  112, -121,  122,  -64, -121,   54,   56,    7,  119,  -88, -121,
      114,    8,    7,  113,   72, -121,   13,  100,   80,   14,  109,    0,   15,  122,   48,    7,
      114,  -96,    7,  115,   32,    7,  109, -112,   14,  118,   64,    7,  122,   96,    7,  116,
      -48,    6,  -10,   16,    7,  114, -128,    7,  122,   96,    7,  116,  -96,    7,  113,   32,
        7,  120,  -48,    6,  -18,   48,    7,  114,  -48,    6,  -77,   96,    7,  116,  -96,  -13,
-      64, -118,    4,   50,   66,  100,    4,  -40,  -95,    4,  -64, -124,   12,    0,    0,    4,
-     -64,   14,  101,    0,   44, -124,    0,    0,   32,    0,  118,   40,    5,  112,   33,    3,
-       0,    0,    1,  -80,   67,   57,    0,   12,   33,    0,    0,    8, -128,   29,   74,    2,
-     100,  -56,    0,    0,   64,    0,  -20,   80,   22,   64,   67,    6,    0,    0,    2, -128,
-      13, -121,  -37,  -95,   56,  -64, -122,   12,    0,    0,    4,  -64,   14,   37,    2,   58,
-      96,    0,    0,   32,    0,  118,   40,   17,  -32,    1,    3,    0,    0,    1,   48,   68,
-     -95,    0,    0,    8,    0,    0,    0, -126,   33, -118,    5,    0,   64,    0,    0,    0,
-      16,   12,   81,   48,    0,    0,    4,    0,    0, -128,   96, -120,  -94,    1,  -64,   48,
-       0,    0,    0,    0,   67,   20,   14,    0,    6,    2,    0,    0,    0,   24,  -94,   80,
-       0,    0,   20,    0,    0,    0,  -63,   16,  -59,    3,    2,  -64,    0,    0,    0,    8,
-    -122,   40,   98,    0,    0,  -64,    1,    0,    0,   16,  100, -127,    0,    0,    0,    0,
-      13,    0,    0,    0,   50,   30, -104,   20,   25,   17,   76, -112, -116,    9,   38,   71,
-     -58,    4,   67,    2,   70,    0,   74,  -96,   16,   72,   24,    1,   32,   98,    4, -128,
-    -116,   17,    0,   66,   70,    0,   72,   25,    1,  -96,  101,    4, -128, -104,   17,    0,
-    -126,  108,  -75,    6,   91,  -50,    1,    0,  121,   24,    0,    0,  -30,    0,    0,    0,
-      26,    3,   76, -112,   70,    2,   19,   52,   68,    0,   38,   42,  119,   99,  104,   97,
-     114,   95,  115,  105,  122,  101,   67,    4, -128,   26,   98,    0,  -45,   24,    4,    0,
-     -59,  -90,   45,  -51,  -19,  -85,  -52,  -83,  -82,  -19,  107,   46,   77,  -81,  108, -120,
-       1,   76,   99,   64,    0,   20,   -7,   32,  -56, -115,   76,  -18,   45, -115,   12,  100,
-    -116,   45,  -52,  -19,   12,  -60,  -82,   76,  110,   46,  -19,  -51,   13,  100,  -58,    5,
-     -57,   69,  -26,  -90, -122,    6,    7,    6,    4,    4,   69,   44,  108,  -82, -116,   12,
-     -28,  -51,   13, -124, -119,  -55,  -86,    9,  100,  -58,    5,  -57,   69,  -26,  -90, -122,
-       6,    7,   38,  101, -120,   48,    6,    6,   15,  -69,   50,  -71,  -71,  -76,   55,   55,
-       6,   49,   67, -120,   49,   64,  -58,   32,   97,  -92,   22,  102,   23,  -10,    5,   23,
-      54,  -74,   22,  118,   86,  -10,  -27,   22,  -42,   86,  -58,  105,  -20,  -83,  -51,   37,
-     -52, -115,   76,  -18,   45, -115,  -52,   69,  110,  -50, -123,  -82,  108, -114,  110,    8,
-      49,    6,  -53,   24,   48,   60,  -20,  -62,  -28,  -66,  -46,  -36,  -24,   24,  -44,   12,
-      33,  -58,  -64,   25, -125, -121, -120,   93, -104,  -36,   23,  -37, -101,  -37,   25,    3,
-    -101,   33,  -60,   24,   68,   99,   32,   49,  -79,   11, -109,   -5,   50,   99,  123,   11,
-     -93,   27,   66, -116,    1,   53,    6,    9,   21,  -69,   48,  -71,   47,  -78,  -73,   58,
-      49,  -74,   50,    6,   50,   67, -120,   49,  -80,  -58,  -32,  -94,   99,   23,   38,   -9,
-      21,  -58,  -58,  -10,   54,   22,   70, -105,  -10,  -26,   70,   65,    6,  102,    8,   49,
-       6,  -39,   24,  104,   76,  -20,  -62,  -28,  -66,  -62,  -28,  -28,  -62,  -14,   -8,  -16,
-      12,  -67,  -71,  -51,  -47, -123,  -71,  -47,    5,  -55,  -55, -123,  -27,   -7,   12,   33,
-     -58, -128,   27, -125, -114, -118,   93, -104,  -36,   23,  -36,   91, -102,   27,  -99,   12,
-      13,  -88,  -73,   52,   55,   58, -103,   33,  -60,   24,  124,   99,    0,    6,  116,  -20,
-     -62,  -28,  -66,  -32,  -34,  -46,  -36,  -24,  100,  -66,  -32,  -24,  -28,  120,  -88,   64,
-     -67,  -91,  -71,  -47,  -55,   12,   33,  -58,   64,   12,  -58,   96,   12,   24,  -48,   12,
-      17,  -58,  -96,   12, -120, -104,  -43,  -71, -115,  -47,  -91,  -67,  -71,   13,   17,  -58,
-     -32,   12,   24,  -71,  -96, -107,  -79,  -63, -107,  -55,  125, -103,  -43,  -71, -115,  -47,
-     -91,  -67,  -71,   89,   13,   17,  -58,   32,   13,   72,  -56,  -67,  -67,  -47,   13,   17,
-     -58,   96,   13, -104,  -92,  -71, -115,  -55, -107,  -75, -107,  -71,  -47,   13,   17,  -58,
-     -96,   13,   24,  -64,   12,   17,  -58,  -32,   13,   40,  -52,  -44,   12,   17,  -58,   32,
-      14, -104,  -52,  -43,  -75,  -75, -123,  -47,  -91,  -67,  -71,  -47, -103,  -85,  107,   11,
-      26,   27,  -85,  107,  -85,   99,   11,  -93,  123, -109,   27,   66, -116,    1,   29, -116,
-      65,  -62,  101,  -82,  -82,  109,  -24,  -83,   77,   44,  -51,  -83,   76,  110, -120,   50,
-       6,  115,   48,    6,  101,   48,    6,  117,   32,    1,   99,   96,    7,   67, -124,   49,
-       0,    3,    6,  120,   28,  -46,  -36,  -24, -122,   16,   99, -112,    7,   99,  -96,    7,
-      12,  -14, -122,   16,   99,  -64,    7,   99,  -96,    7,  124,  -34,  -38,  -36,  -46,  -32,
-     -34,  -24,  -54,  -36,  -24,   64,  -58,  -48,  -62,  -28,   24,   77,  -91,  -75,  -63,  -79,
-    -107, -127,   12,  -67,   12,  -83,  -84, -128,   80,    9,    5,    5,   13,   17,  -58,  -32,
-      15, -122,    8,   66,   53,  -60,   24,    3,   63,   24,    3,   80,   16,  -86,   33,  -58,
-      24,  -24,  -63,   24, -120, -126,   80,   13,   49,  -58,   96,   20,  -58,   96,   20, -124,
-    -118,    4,  -37, -101,  -37,  -39,   16,   99,   12,   74,   97,   12,   68,   65,  -88, -122,
-      24,   99,   96,   10,   99,   96,   10,   66,  -59,  -62, -116,  -19,   45, -116,  110, -120,
-      49,    6,  -88,   48,    6,  -94,   32,   84,   67, -116,   49,   72, -123,   49,   72,    5,
-     -95,  -94,   65,  -10,   86,   39,  -58,   86,   54,  -60,   24, -125,   85,   24,    3,   81,
-      16,  -86,   33,  -58,   24,  -80,  -62,   24,  -80, -126,   80,   53,   98,   99,  -77,  107,
-     115,  105,  123,   35,  -85,   99,   43,  115,   49,   99,   11,   59, -101, -101,   34,   12,
-      69,   21,   54,   54,  -69,   54, -105,   52,  -78,   50,   55,  -70,   41,  -63,  -47,   99,
-       4,   78,   46,  -20,  -84,   45,  108, -118,  -96,   52,  117,   70,  -28,  -26,  -66,  -54,
-     -16,  -32,  -34,  -28,  -24,  -66,  -20,  -62,  -28,  -90,   32,  -48,   84,   97, -101,   23,
-       6,  100,   80,  104,   68,  110,  -18,  -21,   77,   76,  -83,  108, -116,  -18,  107, -114,
-     -19, -115,  110,  110,   74,   96,    6,  125,   70,  -28,  -26,  -66,  -54,  -16,  -32,  -34,
-     -28,  -24,  -66,  -52,  -22,  -36,  -58,  -90,    8,  104,  -96,    6,  -67,   70,  -28,  -26,
-     -66,  -54,  -16,  -32,  -34,  -28,  -24,  -66,  -52,  -34,  -28,  -54,  -62,  -58,  -48,  -66,
-     -36,  -62,  -38,  -54,  -90,    8,  108,  -32,    6, -107,   70,  -28,  -26,  -66,  -54,  -16,
-     -32,  -34,  -28,  -24,  -66,  -52,  -34,  -28,  -54,  -62,  -58,  -48,  -90,    8,  112,   32,
-       7, -115,   70,  -28,  -26,  -66,  -54,  -16,  -32,  -34,  -28,  -24,  -66,  -28,  -54,  -56,
-     -22,  -58,  -54,  -90,    4,  119,  -48,  103,   68,  110,  -18,  -85,   12,   15,  -18,   77,
-    -114,  -18, -117,   46,   15,  -82,  108,   74, -128,    7,   61,   74,  -96,  -34,  -46,  -36,
-     -24,  100,  -90,    8,  123,  -48,    7,    0,  121,   24,    0,    0,   92,    0,    0,    0,
+      64, -120,    4,   50,   66,  100,    4,  -40,  -95,    4,    0, -122,   12,    0,    0,    4,
+     -64,   14,  101,    0,   54, -124,    0,    0,   32,    0,  118,   40,    5,  -48,   33,    3,
+       0,    0,    1,  -80,   67,   57,    0,   15,   33,    0,    0,    8, -128,   29,   74,    0,
+      96,  -56,    0,    0,   64,    0,  -20,   80,   18,  -32,   67,    6,    0,    0,    2,   96,
+    -121,  -94,    0,   28,   50,    0,    0,   16,    0,  100,   96, -128,  -37,  -95,   60,   64,
+      24,    0,    3,    0,    0,    1,  -80,   67,  121,    0,   49,    0,    6,    0,    0,    2,
+      96, -120,   34,    1,    0,   16,    0,    0,    0,    4,   67,   20,   10,    0, -128,    0,
+       0,    0,   32,   24,  -94,   80,    0,    0,    4,    0,    0,    0,  -63,   16, -123,    2,
+       0,   64,    0,    0,    0,    8, -122,   40,   23,   16,    0,    3,    0,    0,   64,   48,
+      68,  -55,    0,    0,   32,    0,    0,    0, -126,   33,  -54,    6,    0,   67,    1,    0,
+       0,    0,   12,   81,   58,    0,   24,   12,    0,    0,    0,   96, -120,   34,    1,    0,
+      32,    0,    0,    0,    4,   67, -108,   15,    8, -128,    3,    0,    0,   32,   24,  -94,
+    -116,    1,    0,    0,    8,    0,    0,   64,   48,   68,   25,    3,    0,    0,   16,    0,
+       0, -128,   96, -120,   50,    6,    0,    0,   36,    0,    0,    0,   65,   22,    8,    0,
+      12,    0,    0,    0,   50,   30, -104,   24,   25,   17,   76, -112, -116,    9,   38,   71,
+     -58,    4,   67,    2,   70,    0,   74,  -96,   16,   72,   24,    1,  -96,   96,    4, -128,
+    -120,   17,    0,   50,   70,    0,    8,   25,    1,  -96,  101,    4, -128,   28,  -37,   13,
+     -62,  -74, -117,    0,  121,   24,    0,    0,  -13,    0,    0,    0,   26,    3,   76, -112,
+      70,    2,   19,   52,   68,    0,   48,   42,  119,   99,  104,   97,  114,   95,  115,  105,
+     122,  101,   67,    4,   32,   27,   98,    0,   24,   25,    4,   64,  -58,  -90,   45,  -51,
+     -19,  -85,  -52,  -83,  -82,  -19,  107,   46,   77,  -81,  108, -120,    1,   96,  100,   64,
+       0,   25,   -7,   32,  -56, -115,   76,  -18,   45, -115,   12,  100, -116,   45,  -52,  -19,
+      12,  -60,  -82,   76,  110,   46,  -19,  -51,   13,  100,  -58,    5,  -57,   69,  -26,  -90,
+    -122,    6,    7,    6,    4,    4,   69,   44,  108,  -82, -116,   12,  -28,  -51,   13, -124,
+    -119,  -55,  -86,    9,  100,  -58,    5,  -57,   69,  -26,  -90, -122,    6,    7,   38,  101,
+    -120,   64,    6,    6,   15,  -69,   50,  -71,  -71,  -76,   55,   55,    6,   49,   67,    8,
+      50,   64,  -56,   32,   97,  -92,   22,  102,   23,  -10,    5,   23,   54,  -74,   22,  118,
+      86,  -10,  -27,   22,  -42,   86,  -58,  105,  -20,  -83,  -51,   37,  -52, -115,   76,  -18,
+      45, -115,  -52,   69,  110,  -50, -123,  -82,  108, -114,  110,    8,   65,    6,   11,   25,
+      48,   60,  -20,  -62,  -28,  -66,  -46,  -36,  -24,   24,  -44,   12,   33,  -56,  -64,   33,
+    -125, -121, -120,   93, -104,  -36,   23,  -37, -101,  -37,   25,    3, -101,   33,    4,   25,
+      68,  100,   32,   49,  -79,   11, -109,   -5,   50,   99,  123,   11,  -93,   27,   66, -112,
+       1,   69,    6,    9,   21,  -69,   48,  -71,   47,  -78,  -73,   58,   49,  -74,   50,    6,
+      50,   67,    8,   50,  -80,  -56,  -32,  -94,   99,   23,   38,   -9,   21,  -58,  -58,  -10,
+      54,   22,   70, -105,  -10,  -26,   70,   65,    6,  102,    8,   65,    6,   25,   25,  104,
+     100,  -20,  -62,  -28,  -66,  -22,  -46,  -36,  -24,  102,  100,  -66,  -24,   24,  -28,   12,
+      33,  -56, -128,   35, -125, -114, -118,   93, -104,  -36,   23,  -36,   91, -102,   27,  -99,
+      12,   13,  -88,  -73,   52,   55,   58, -103,   33,    4,   25,  124,  100,    0,    6,   92,
+     -20,  -62,  -28,  -66,  -46,  -36,  -24,  -66,  -32,  -24,  -28,   72,  -88,  -92,  -71,  -47,
+      13,   33,  -56,   64,   12,  -56,   96,   12,   24,  -48,   12,   17,  -56,  -96,   12, -120,
+    -104,  -43,  -71, -115,  -47,  -91,  -67,  -71,   13,   17,  -56,  -32,   12,   24,  -71,  -96,
+    -107,  -79,  -63, -107,  -55,  125, -103,  -43,  -71, -115,  -47,  -91,  -67,  -71,   89,   13,
+      17,  -56,   32,   13,   24,  -71,  -96, -107,  -79,  -63, -107,  -55,  125,  -51, -107,  -47,
+       9,  -43, -103, -103, -107,  -55,   13,   17,  -56,   96,   13,   88,  -71,  -96, -107,  -79,
+     -63, -107,  -55,  125,  -51, -107,  -47,    5,  -79,  -79,  -67, -115, -123,  -47,  -91,  -67,
+     -71,   13,   17,  -56,  -96,   13,   72,  -56,  -67,  -67,  -47,   13,   17,  -56,  -32,   13,
+    -104,  -92,  -71, -115,  -55, -107,  -75, -107,  -71,  -47,   13,   17,  -56,   32,   14,   24,
+     -64,   12,   17,  -56,   96,   14,   40,  -52,  -44,   12,   17,  -56,  -96,   14, -104,  -52,
+     -43,  -75,  -75, -123,  -47,  -91,  -67,  -71,  -47, -103,  -85,  107,   11,   26,   27,  -85,
+     107,  -85,   99,   11,  -93,  123, -109,   27,   66, -112,    1,   30, -112,   65,  -62,  101,
+     -82,  -82,  109,  -24,  -83,   77,   44,  -51,  -83,   76,  110, -120,   66,    6,  119,   64,
+       6,  101,   64,    6,  121,    0,    1,  100,  -96,    7,   67,    4,   50,    0,    3,    6,
+     120,   28,  -46,  -36,  -24, -122,   16,  100,  -48,    7,  100,  -32,    7,   12,  -14, -122,
+      16,  100,    0,   10,  100,  -32,    7,  124,  -34,  -38,  -36,  -46,  -32,  -34,  -24,  -54,
+     -36,  -24,   64,  -58,  -48,  -62,  -28,   24,   77,  -91,  -75,  -63,  -79, -107, -127,   12,
+     -67,   12,  -83,  -84, -128,   80,    9,    5,    5,   13,   17,  -56,   96,   20, -122,    8,
+    -126,   54,  -60,   32,    3,   81,   32,    3,   82,   16,  -76,   33,    6,   25,   -8,    1,
+      25, -104, -126,  -96,   13,   49,  -56,  -32,   20,  -56,  -32,   20,    4, -115,    4,  -37,
+    -101,  -37,  -39,   16, -125,   12,   82, -127,   12,   76,   65,  -48, -122,   24,  100,  -96,
+      10,  100,  -96,   10, -126,  -58,  -62, -116,  -19,   45, -116,  110, -120,   65,    6,  -84,
+      64,    6,  -90,   32,  104,   67,   12,   50,  104,    5,   50,  104,    5,   65,  -93,   65,
+     -10,   86,   39,  -58,   86,   54,  -60,   32, -125,   87,   32,    3,   83,   16,  -76,   33,
+       6,   25,  -64,    2,   25,  -64, -126,  -96,  113,    9,  115,  -53,    3, -127,  123,   75,
+     115,  -93,   43, -109,   27,   98, -112, -127,   44, -112, -127,   41,    8,  -38,   16, -125,
+      12,  102, -127,   12,  102,   65,  -48,   26,  -79,  -79,  -39,  -75,  -71,  -76,  -67, -111,
+     -43,  -79, -107,  -71, -104,  -79, -123,  -99,  -51,   77,   17, -122,  -94,   10,   27, -101,
+      93, -101,   75,   26,   89, -103,   27,  -35, -108,  -32,  -24,   49,    2,   39,   23,  118,
+     -42,   22,   54,   69,   80, -102,   58,   35,  114,  115,   95,  101,  120,  112,  111,  114,
+     116,   95,  118,   97,  114,   83,   16,  104,  -86,  -80,  -51,   11,    3,   50,   40,   52,
+      34,   55,   -9,  -11,   38,  -90,   86,   54,   70,   -9,   53,  -57,  -10,   70,   55,   55,
+      37,   48, -125,   62,   35,  114,  115,   95,  101,  120,  112,  111,  114,  116,   95,  102,
+     117,  110,   99,   83,    8,   52,   80,    3,   54,  112, -125,   94,   35,  114,  115,   95,
+     101,  120,  112,  111,  114,  116,   95,  102,  111,  114,  101,   97,   99,  104,   95,  110,
+      97,  109,  101,   83,    4,   56, -112, -125,   74,   35,  114,  115,   95,  101,  120,  112,
+     111,  114,  116,   95,  102,  111,  114,  101,   97,   99,  104,   83,    4,   58,  -80, -125,
+      70,   35,  114,  115,   95,  101,  120,  112,  111,  114,  116,   95,  114,  101,  100,  117,
+      99,  101,   83, -126,   61,  -24,   51,   34,   55,   -9,   85, -122,    7,   -9,   38,   71,
+      -9,   69, -105,    7,   87,   54,   37,  -32, -125,   30,   37,   80,  111,  105,  110,  116,
+      50,   83, -124,   63,    8,    5,    0,    0,  121,   24,    0,    0,   92,    0,    0,    0,
       51,    8, -128,   28,  -60,  -31,   28,  102,   20,    1,   61, -120,   67,   56, -124,  -61,
     -116,   66, -128,    7,  121,  120,    7,  115, -104,  113,   12,  -26,    0,   15,  -19,   16,
       14,  -12, -128,   14,   51,   12,   66,   30,  -62,  -63,   29,  -50,  -95,   28,  102,   48,
@@ -201,236 +247,309 @@
     -127,   30,  -36,  -32,   28,  -28,  -31,   29,  -22,    1,   30,  102,   24,   81,   56,  -80,
       67,   58, -100, -125,   59,  -52,   80,   36,  118,   96,    7,  123,  104,    7,   55,   96,
     -121,  119,  120,    7,  120, -104,   81,   76,  -12, -112,   15,  -16,   80,   14,    0,    0,
-     113,   32,    0,    0,   56,    0,    0,    0,    6,   17,    6,   -1,   92,  -33, -111,  -60,
-      45,    4,   16,  -95,   65,   66,    8,   83,   90,  -33, -111,  -12,    3,  -53,  -30,    8,
-     -64, -124,   56, -115,   13,   40,   21,   16,   -3, -125,   67,    5,   11,   97,    5,   74,
-       5,   68,   -1,  -29,   32,  -51,  100,   27,   67, -126,   52,   66,   68,   48,   68,   51,
-    -103,    2,   82,   80, -115,   48,   33,   78,   99,    4,   73,    5,   68,   63,   16,   69,
-       0,  102,   17, -111,  127,   16,  -53,   67,   68,  127,   65,   53,  -62, -124,   56,  -51,
-     107,   14, -117,   68,   49, -100,  -61,    4,   72,   67,   68,  102,  -32,   84,   64,  -12,
-       3,  -53,  -30,    8,  -64, -124,   56, -115,   33,  112,  126,   36,   -7,   17,   49,   80,
-       2,  -15,   23, -115,   47,   81, -116,   38,    8,   20,   67,   45,  -64,  -28,   68,    6,
-     112,   84,   64,  -12,   35,  -51,  100,   13, -114,   68,   49, -102,   32,   80,   12,  -75,
-       0, -109,   19,   89,    0,   82,    1,  -47,  -65,   56, -115,   97,    7,   78,    5,   68,
-      -1,  -29,   32,  -51,  100,   -1,  -49,   20,  -39,    3,  -30,   71, -110,   63,   76,   78,
-     100,   11,   73,   65,   53,  -62, -124,   56,  -51,  107,    2,   73,    5,   68,  127,  -79,
-      56,  -64,  100,    9, -103,   31,   73,  126,   68,   12, -108,   64,   -4,   69,  -29,   75,
-      20,  -61,   57,   76, -128,   52,   68,    4,   97,   32,    0,    0,   54,    0,    0,    0,
-      19,    4,   65,   44,   16,    0,    0,    0,   20,    0,    0,    0,    4, -108,   66,   49,
-    -108,   67,   17,   20,   68,   25, -108,   68,   81, -112,   80,    4,   20,   12,  101,   36,
-       4,   32,    1,  -45,   80,   70,   66,    0,   18,   16,    6,   67,   25,    9,    1,   72,
-     -64,   24,   12,  101,   44,    5,   32,    1,  -46,   80,  -58,   82,    0,   18,   48,   13,
-     101,   36,    4,   32,    1,   18,   17,   99,    4,   32,    8, -126,   36,   24, -112,   49,
-      70,    0, -126,   32,    8, -126,   32,    8, -126,   36,   72,    0, -125,   17,  -64,   52,
-       0, -125,   17, -127,   25,   16,  -64,   96, -124,  -48,    6,    3,   48,   24,   49,  -72,
-       1,    1,   12,   70,  -80, -127,   55,    0, -125,   17,  103,  -16,   13,  -64,   96,    4,
-      26, -128,  -63,    0,   12,   70,  -92, -127,   24,   12,  -64,   96, -124,   26, -112,  -63,
-       0,   12,   70,  -84,   65,   25,   12,    0,    6,  -60,    0,    0,   13,    0,    0,    0,
-      91,    6,   32,   32, -123,   45,   67,   16, -100,  -62, -106,   65,    8,   84,   97,  -53,
-      48,    4,  -83,  -80,  101,   32,    2,   82,  -40,   50,   20,    1,   41,  108,   25, -116,
-    -128,   20,  -74,   12,   71,   64,   10,   91,    6,   36,   32, -123,   45,   67,   18, -112,
-       2,    0,    0,    0,    0,    0,    0,    0,   97,   32,    0,    0,   11,    0,    0,    0,
-      19,    4,  -63,   96,    4,  -32,   13,    0, -122,    3,    1,    0,    2,    0,    0,    0,
-     -26,   49,    0, -111,    1,    0,    0,    0,    1,   49,    0,    0,    2,    0,    0,    0,
-      91,    6,   32,   32,    5,    0,    0,    0,    0,    0,    0,    0,   97,   32,    0,    0,
-      11,    0,    0,    0,   19,    4,  -63,  121,   64,  -40,   55,  -63,  -32,  -64,  -32, -127,
-      12, -125,  112,   32,    5,    0,    0,    0,  -10,   65,    8,   78,   83, -103, -121, -128,
-      52,   22,   82,    8,   78,   83,  -43,    6,   50,    0,  -61,    0,    0,    0,    0,    0,
-      97,   32,    0,    0,   16,    0,    0,    0,   19,    4,    1,  121,  -61,  -64,  -32,    3,
-     -63,   96, -124,   23,    6,    3, -128,  -31,   64,    0,    0,    0,    4,    0,    0,    0,
-     -10,   49,   84,  -64,   98,   30,    5,   32,    8,   20,   99,   33,    3,   48,   12,    0,
-       1,   49,    0,    0,    3,    0,    0,    0,   91,    6,   32,   32, -123,   45, -125,   16,
-    -112,    2,    0,    0,    0,    0,    0,    0,   97,   32,    0,    0,   17,    0,    0,    0,
-      19,    4,    1,  125, -125,  -68,   97,   97,    0,    6,   32,   24, -116,  -16,  -60,   96,
-       0,   48,   28,    8,    4,    0,    0,    0,  -10,   49,   84,  -64,   98,   30,    5,   32,
-       8,   20,   99,   34,    3,   48,   12,    0,    1,   49,    0,    0,    4,    0,    0,    0,
-      91,    6,   32,   32, -123,   45,   67,   16, -112,  -62, -106,   97,    8,   72,    1,    0,
-       0,    0,    0,    0,   97,   32,    0,    0,    3,    0,    0,    0,   19,    4,  -63, -120,
-       1, -127,    4, -112, -127,    0,    0,    0,   97,   32,    0,    0,    9,    0,    0,    0,
-      19,    4,  -63,  120, -125,   39,   73,  -12, -115,   17,    3,    2,    8,   22,   48,  -64,
-     112,   32,    0,    0,    2,    0,    0,    0,    7,   80,   16,  -51,   20,   97,    0,    0,
-       0,    0,    0,    0,    0,    0,    0,    0,
+     113,   32,    0,    0,   78,    0,    0,    0,   70,  -64,   84,   64,  -12,   83,   72,   51,
+     -35,  -10,   63,  -39, -128,   82,    1,  -47,   63,   56,   84,  -80,   16,  -90, -128,   20,
+      84,   35,   76, -120,  -45, -104,  -63,   82,    1,  -47, -113,   52,  -45,   -1,   76, -111,
+      53,   52,   18,   49,  105,  -53,  -30,    8,  -64, -124,   56, -115,    5,   32,   21,   16,
+      -3, -117,  -45,   24,  -74, -112,   20,   84,   35,   76, -120,  -45,  -68,  -26, -112,    6,
+      -1,  108,  -45, -111,  -60,   18, -109,  -73,   16,   12,  -47,   76,  -38,  -12,   83,  -62,
+       1,   68,  -11,   29,   73,   63,  -80,   44, -114,    0,   76, -120,  -45,   28, -119,   77,
+    -124,  -63,   63,  -41,  119,   36,  113,   11,    1,   68,  104, -112,   16,  -62, -108,  -42,
+     119,   36,   -3,  -64,  -78,   56,    2,   48,   33,   78,   99,   22, -107,  127,   16,  -53,
+      67,   68,  -65,   68,   76,  -38,  -78,   56,    2,   48,   33,   78,   99,    2,   73,    5,
+      68,  127,  -79,   56,  -64,  100,    5,   74,    5,   68,   -1,  -29,   32,  -51,  100,  -37,
+      67, -126,   52,   66,   68,   48,   68,   51,   25,   67,   34,   17,  -45,   70,   21,    5,
+      17,   89,  -60,   34,   81,   12,  -25,   48,    1,  -46,   16, -111,   37,  100,  126,   36,
+      -7,   17,   49,   80,    2,  -15,   23, -115,   47,   81,   12,  -25,   48,    1,  -46,   16,
+    -111,   81,   68,   -2,   65,   44,   15,   17,   -3,    5,  -43,    8,   19,  -30,   52,  -81,
+      29,   56,   21,   16,   -3,  -64,  -78,   56,    2,   48,   33,   78,   99,    8, -100,   31,
+      73,  126,   68,   12, -108,   64,   -4,   69,  -29,   75,   20,  -93,    9,    2,  -59,   80,
+      11,   48,   57, -111,    1,   28,   21,   16,   -3,   72,   51,   89,   69,  -28,   31,  -60,
+     -14,   16,  -47,   47,   17,  -45,   70,   21,    5,   17,   25, -124,   35,   81, -116,   38,
+       8,   20,   67,   45,  -64,  -28,   68,   38, -127,   -8, -111,  -28,   15, -109,   19,    1,
+      97,   32,    0,    0,   37,    0,    0,    0,   19,    4,   65,   44,   16,    0,    0,    0,
+      12,    0,    0,    0,    4, -108,   66,   49, -108,    3,    9,   69,   64,  -63,   80,   70,
+      82,    0,   23, -128,   13,  101,   36,    5,  112,    1,   23,   17,   99,    4,   32,    8,
+    -126,   36,   24, -112,   49,   70,    0, -126,   32,    8, -126,   32,    8, -126,   36,   72,
+       0,    0,    0,    0, -125,   17,    0,   54,    0, -125,   17,   65,   25,   16,  -64,   96,
+    -124, -128,    6,    3,   48,   24,   49,  -92,    1,    1,   12,   70,   16,   98,   48,    0,
+    -125,   17,  103,   48,    6,    3,   48,   24,   97,    6,  100,   48,    0,   24,   16,    3,
+       9,    0,    0,    0,   91,    6,   32,   64, -123,   45,   67,   16,  -84,  -62, -106,   65,
+       8,   92,   97,  -53,   48,    4,  -79,  -80,  101,   32,    2,   84,  -40,   50,   20,    1,
+      42,  108,   25, -116,    0,   21,    0,    0,    0,    0,    0,    0,   97,   32,    0,    0,
+      11,    0,    0,    0,   19,    4,  -63,   96,    4,   32,    6,    3, -128,  -31,   64,    0,
+       2,    0,    0,    0,   38,   50,    0, -111,    1,    0,    0,    0,    1,   49,    0,    0,
+       2,    0,    0,    0,   91,    6,   32,   64,    5,    0,    0,    0,    0,    0,    0,    0,
+      97,   32,    0,    0,   38,    0,    0,    0,   19,    4,   68,   44,   16,    0,    0,    0,
+       1,    0,    0,    0,    4, -108,    2,    0,  -61,   13,   98,  112, -103,  -63,   44,   67,
+      48, -112,    1,   25,   99, -106,   64,   24,  -88,    0,  -82,    0,   13, -124,  -15, -124,
+      50,   48, -125,  -63, -120,   51,   24, -125,    1,   48,   51,  -64,   96,   48,  -36, -128,
+       6,   98,    0,    6,  -77,   12, -125, -112,    6,   24,   14,    4,   14,    0,    0,    0,
+      23,   96,   -8,   75,  -28,   63,  -57,   13,   44,   -2,   47,   68,  -56,  -12,   19, -125,
+      65,  -40,    9,    2,   68,   17, -128,   33,  -61,  101,   36, -124,  -64,   60,  -72, -119,
+      12,    3,  -62,   24,  -54, -128,   52, -126, -103,   16, -120,   79,  -25, -106, -126,   16,
+      23,   50,    9,   78,   51,    0,    0,    0,    1,   49,    0,    0,    3,    0,    0,    0,
+      91,    6,   33,  -96, -123,   45, -125,   17,  -96,    2,    0,    0,    0,    0,    0,    0,
+      97,   32,    0,    0,   36,    0,    0,    0,   19,    4,   67,   44,   16,    0,    0,    0,
+       3,    0,    0,    0,  -44, -108,    3,    5,  -74,  -52,    1,   85,   51,    0,    0,    0,
+     -61,   13,   98,  112, -103,  -63,   44,   67,   32, -104,  -63,   64,    5,  -96,    6,  -63,
+       5,   16,   25, -116,  -39, -122,   50,   64,    3,   96,  -60,  -64,   80,    2,   39,   13,
+     -58,  -32,   12,  -20,   12,   48,   24,   12,   55,  -88, -127,   24, -128,  -63,   44, -125,
+      16,  -84,    1, -122,    3,    1,    0,    0,   14,    0,    0,    0, -122,  114,   -8,   84,
+     -13,    0, -126,  114,    1, -122,  -65,   68,   -2,  115, -100,  -64,  -30,   -1,   66, -124,
+      76,   63,   49,   24, -124, -103,   16,    2,  -13,  -32,   38,   50,   12,    8,   99,   42,
+       3,  -46,    8,  118,   66,   92,   62,  -99,  -37,   10,   66,   92,  -56,   36,   56,  -51,
+       0,    0,    0,    0,    0,    0,    0,    0,   97,   32,    0,    0,   12,    0,    0,    0,
+      19,    4,  -63, -119,    1,   16,   54,    6,   24,   12, -114,   12,   26,  -56,   50,    8,
+       7,    2,    0,    0,    5,    0,    0,    0,   54,   66,    8,   78,   83, -103, -120, -128,
+      52,   86,   82,    8,   78,   83,  -43,   70,   50,    0,  -61,    0,    0,    0,    0,    0,
+      97,   32,    0,    0,   16,    0,    0,    0,   19,    4,    1, -119,  -63,   48,   50,   24,
+       3,   16,   12,   70, -120,   65,   25,   12,    0, -122,    3,    1,    4,    0,    0,    0,
+      54,   50,   84,  -64,   98,   34,    5,   32,    8,   20,   99,   37,    3,   48,   12,    0,
+       1,   49,    0,    0,    3,    0,    0,    0,   91,    6,   32,   64, -123,   45, -125,   16,
+     -96,    2,    0,    0,    0,    0,    0,    0,   97,   32,    0,    0,   18,    0,    0,    0,
+      19,    4,    1, -115,  -63,   32,   49,   24,   86,    6,  100,    0, -126,  -63,    8,   49,
+      48, -125,    1,  -64,  112,   32,    0,    0,    4,    0,    0,    0,   54,   50,   84,  -64,
+      98,   34,    5,   32,    8,   20,   99,   38,    3,   48,   12,    0,    1,   49,    0,    0,
+       4,    0,    0,    0,   91,    6,   32,   64, -123,   45,   67,   16,  -96,  -62, -106,   97,
+       8,   80,    1,    0,    0,    0,    0,    0,   97,   32,    0,    0,    3,    0,    0,    0,
+      19,    4,  -63, -120,    1,  -79,    4,  -45, -127,    0,    0,    0,   97,   32,    0,    0,
+       9,    0,    0,    0,   19,    4,  -63,  120, -125,   24,   92,   23, -115,  -63,   24,   49,
+      32, -128,   96,   33,    3,   12,    7,    2,    2,    0,    0,    0,    7,   80,   16,  -51,
+      20,   97,    0,    0,    0,    0,    0,    0,   97,   32,    0,    0,    9,    0,    0,    0,
+      19,    4,  -63,  120, -125,   24,   92,   23, -115,  -63,   24,   49,   32, -128, -128,   33,
+       3,   12,    7,    2,    2,    0,    0,    0,    7,   80,   16,  -51,   20,   97,    0,    0,
+       0,    0,    0,    0,   97,   32,    0,    0,    9,    0,    0,    0,   19,    4,  -63,  120,
+    -125,   24,   92,   23, -115,  -63,   24,   49,   32, -128,  -96,   33,    3,   12,    7,    2,
+       2,    0,    0,    0,    7,   80,   16,  -51,   20,   97,    0,    0,    0,    0,    0,    0,
+       0,    0,    0,    0,
 };
 
-const int bitCodeLength = 2776;
+const int bitCodeLength = 3364;
 
 #else
 
 const int8_t bitCode[] = {
-     -34,  -64,   23,   11,    0,    0,    0,    0,   44,    0,    0,    0, -116,   10,    0,    0,
+     -34,  -64,   23,   11,    0,    0,    0,    0,   44,    0,    0,    0,  108,   13,    0,    0,
        0,    0,    0,    0,   -1,   -1,   -1,   -1,    0,    0,    0,    0,    1,   64,    4,    0,
       96,    9,    0,    0,    2,   64,    4,    0,    3,    0,    0,    0,   66,   67,  -64,  -34,
-      33,   12,    0,    0,  -96,    2,    0,    0,    1,   16,    0,    0,   18,    0,    0,    0,
+      33,   12,    0,    0,   88,    3,    0,    0,    1,   16,    0,    0,   18,    0,    0,    0,
        7, -127,   35, -111,   65,  -56,    4,   73,    6,   16,   50,   57, -110,    1, -124,   12,
       37,    5,    8,   25,   30,    4, -117,   98, -128,   24,   69,    2,   66, -110,   11,   66,
      -60,   16,   50,   20,   56,    8,   24,   73,   10,   50,   68,   36,   72,   10, -112,   33,
       35,  -60,   82, -128,   12,   25,   33,  114,   36,    7,  -56, -120,   17,   98,  -88,  -96,
-     -88,   64,  -58,  -16,    1,    0,    0,    0,   73,   24,    0,    0,   24,    0,    0,    0,
+     -88,   64,  -58,  -16,    1,    0,    0,    0,   73,   24,    0,    0,   33,    0,    0,    0,
       11, -124,   -1,   -1,   -1,   -1,   31,  -64,   96, -127,  -16,   -1,   -1,   -1,   -1,    3,
-      24,   45,   32,    2,   16,    4,   65,   16,   36,   -2,   -1,   -1,   -1,  127,    0, -125,
-       5,   70,    0, -126,   32,    8, -126, -124,    0, -126,   32,    8, -126,  -60,   -1,   -1,
-      -1,   -1,   15,   96,  -80,   64,   -8,   -1,   -1,   -1,   -1,    1,   12,   22,    8,   -1,
-      -1,   -1,   -1,   63,    0,   11, -120,    0,    4,   65,   16,    4, -119,   -1,   -1,   -1,
-      -1,   31,  -64,   80,   88,   64,    4,  -64,   -1,   -1,   -1,   -1,   15,   96,    0,    0,
-    -119,   32,    0,    0,   34,    0,    0,    0,   50,   34, -120,    9,   32,  100, -123,    4,
-      19,   35,  -92, -124,    4,   19,   35,  -29, -124,  -95, -112,   20,   18,   76, -116, -116,
-      11, -124,  -60,   76,   16, -112,  -63,   28,    1,   24,   16,   48,   71,    0,   10,   36,
-     -52,    0,   16,   49,    4,   64,   70,   18,    0, -124,   28,   36,   77,   17,   37,   76,
-     126,  -22,   32,  -51,  100,   -5,   61, -114,    4,    0,   32,  -27,   46,  105, -118,   40,
-      97,  -14,   35,  -23,    7, -106,  -59,   17, -128,    9,  113,   26,  -65,  -49,   17,   49,
-      12,  -61,   64,   12,   45,  115,    4,    8,   61,    4, -115,    0, -108,   64,  -94,  -87,
-       8,   18,   64,   85,   17,  -98, -121,  -82,   50,   72,    1,   64,   89,   25,  -92,   32,
-     -96,  -83,    8,   82,   67,  -99,    9,    0,   -6, -118,   32, -127,   20,   14,    4,    0,
-      19,  -76,  112,    8,    7,  121,   24,    7,  116,  -80,    3,   58,  104,    3,  119,  120,
-       7,  119,   40, -121,   54,   96, -121,  116,  112, -121,  122,  -64, -121,   54,   56,    7,
-     119,  -88, -121,  114,    8,    7,  113,   72, -121,   13,  115,   80,   14,  109,  -48,   14,
-     122,   80,   14,  109, -112,   14,  120,  -96,    7,  120,  -96,    7,  115,   32,    7,  109,
-    -112,   14,  113,   96,    7,  122,   16,    7,  118,  -96,    7,  115,   32,    7,  109, -112,
-      14,  118,   64,    7,  122,   96,    7,  116,  -48,    6,  -23,   16,    7,  114, -128,    7,
-     122,   16,    7,  114, -128,    7,  109,  -32,   14,  115,   32,    7,  122,   96,    7,  116,
-     -48,    6,  -77,   16,    7,  114, -128,    7,   58,   15,  -92,   72,   32,   35,   68,   70,
-    -128,   29,   74,    0,   76,  -56,    0,    0,   64,    0,  -20,   80,    6, -128,   66,    8,
-       0,    0,    2,   96, -121,   82,    0,   21,   50,    0,    0,   16,    0,   59, -108,    3,
-     -80,   16,    2,    0, -128,    0,  -40,  -95,   36,  -64, -123,   12,    0,    0,    4,  -64,
-      14,  101,    1,   48,  100,    0,    0,   32,    0,  -40,  104,  -56,   29, -118,    3,  100,
-       8,    1,    0,   64,    0,  -20,   80,   34,   96,    3,    8,    0,    0,    2,   96, -121,
-      18,    1,   28,   64,    0,    0,   16,    0,   67,   20,   10,    0, -128,    0,    0,    0,
-      32,   24,  -94,   88,    0,    0,    4,    0,    0,    0,  -63,   16,    5,    3,    0,   64,
-       0,    0,    0,    8, -122,   40,   26,    0,   12,    3,    0,    0,    0,   48,   68,  -31,
-       0,   96,   32,    0,    0,    0, -128,   33,   10,    5,    0,   64,    1,    0,    0,   16,
-      12,   81,   60,   32,    0,   12,    0,    0, -128,   96, -120,   34,    6,    0,    0,   28,
-       0,    0,    0,   65,   22,    8,    0,    0,   13,    0,    0,    0,   50,   30, -104,   20,
-      25,   17,   76, -112, -116,    9,   38,   71,  -58,    4,   67,    2,   70,    0,   72,   24,
-       1,   32,   98,    4, -128, -116,   17,    0,   66,   70,    0,   72,   25,    1,  -96,  101,
-       4, -128, -104,   17,    0, -126,  108,  -75,    6,   91,  -50,    1,    0,    0,    0,    0,
-     121,   24,    0,    0,  -48,    0,    0,    0,   26,    3,   76, -112,   70,    2,   19,   68,
+      24,   44,   16,   -2,   -1,   -1,   -1,  127,    0,   22,   24,    1,    8, -126,   32,    8,
+      18,    2,    8, -126,   32,    8,   18,   -1,   -1,   -1,   -1,   63, -128,  -63,    2,  -31,
+      -1,   -1,   -1,   -1,    7,   48,   90,   64,    4,   32,    8, -126,   32,   72,   -4,   -1,
+      -1,   -1,   -1,    0,    6,   11, -116,    0,    4,   65,   16,    4,    9,    1,    4,   65,
+      16,    4, -119,   -1,   -1,   -1,   -1,   31,  -64,   96,    1,   17, -128,   32,    8, -126,
+      32,  -15,   -1,   -1,   -1,   -1,    3,   24,   10,   11, -120,    0,    4,   65,   16,    4,
+    -119,   -1,   -1,   -1,   -1,   31,  -64,   80,   88,   64,    4,  -64,   -1,   -1,   -1,   -1,
+      15,   96,    0,    0, -119,   32,    0,    0,   38,    0,    0,    0,   50,   34, -120,    9,
+      32,  100, -123,    4,   19,   35,  -92, -124,    4,   19,   35,  -29, -124,  -95, -112,   20,
+      18,   76, -116, -116,   11, -124,  -60,   76,   16,  -96,  -63,   28,    1,   24,   16,   48,
+      71,    0,   10,   36,  -52,    0,   16,   49,    4,   64,  -58,   65,  -46,   20,   81,  -62,
+     -28,  -89,   14,  -46,   76,  -74,  -33,  -29,   72,    0,    0,   66,   40,  -72,   75, -102,
+      34,   74, -104,   -4,   72,   -6, -127,  101,  113,    4,   96,   66, -100,  -58,  -17,  115,
+      68,   12,  -61,   48,  -48,   50,   71, -128,   80,   67,  -50,    8,   64,    9,   32, -118,
+    -118,    0,    1,   52,   21,    2,   98,   26, -128,  -86,   57, -126,  -96,   24, -112,  -29,
+       8,  -64,   69,   88,   17, -102, -122,  -76,   50,   64,    1,   64,   92,   25,  -96,   32,
+      32,  -81,    8,   16,   67,  -96,    9,    0,   18, -117,    0, -115,   68,   14,    4,   76,
+       1,    0,    0,    0,   19,  -76,  112,    8,    7,  121,   24,    7,  116,  -80,    3,   58,
+     104,    3,  119,  120,    7,  119,   40, -121,   54,   96, -121,  116,  112, -121,  122,  -64,
+    -121,   54,   56,    7,  119,  -88, -121,  114,    8,    7,  113,   72, -121,   13,  115,   80,
+      14,  109,  -48,   14,  122,   80,   14,  109, -112,   14,  120,  -96,    7,  120,  -96,    7,
+     115,   32,    7,  109, -112,   14,  113,   96,    7,  122,   16,    7,  118,  -96,    7,  115,
+      32,    7,  109, -112,   14,  118,   64,    7,  122,   96,    7,  116,  -48,    6,  -23,   16,
+       7,  114, -128,    7,  122,   16,    7,  114, -128,    7,  109,  -32,   14,  115,   32,    7,
+     122,   96,    7,  116,  -48,    6,  -77,   16,    7,  114, -128,    7,   58,   15, -124,   72,
+      32,   35,   68,   70, -128,   29,   74,    0,  100,  -56,    0,    0,   64,    0,  -20,   80,
+       6,   96,   67,    8,    0,    0,    2,   96, -121,   82,    0,   31,   50,    0,    0,   16,
+       0,   59, -108,    3,    0,    3, -124,    0,    0,   32,    0,  118,   40,    1, -112,   33,
+       3,    0,    0,    1,  -80,   67,   73, -128,   48,   64,    6,    0,    0,    2,   96, -121,
+     -94,    0,   30,   66,    0,    0,   16,    0,  100,   98, -128,  -36,  -95,   60,  -64,   24,
+       0,    4,    0,    0,    1,  -80,   67,  121,    0,   50,    0,    8,    0,    0,    2,   96,
+    -120,   34,    1,    0,   16,    0,    0,    0,    4,   67,   20,   10,    0, -128,    0,    0,
+       0,   32,   24,  -94,   80,    0,    0,    4,    0,    0,    0,  -63,   16, -123,    2,    0,
+      64,    0,    0,    0,    8, -122,   40,   22,   16,    0,    3,    0,    0,   64,   48,   68,
+     -55, -128,    0,   32,    0,    0,    0, -128,   33,  -54,    6,    0,   64,    1,    0,    0,
+      16,   12,   81,   58,    0,   24,   12,    0,    0,    0,   96, -120,  -14,    1,  -64,  112,
+       0,    0,    0,    0,   67,   20,    9,    0,    0,    1,    0,    0,   32,   24,  -94, -124,
+       1,   16,    0,    3,    0,    0,   64,   48,   68,   41,    3,    0,    0,   16,    0,    0,
+    -128,   96, -120,   82,    6,    0,    0,   32,    0,    0,    0,  -63,   16,  -91,   12,    0,
+       0,   72,    0,    0,    0, -126,   44,   16,   13,    0,    0,    0,   50,   30, -104,   24,
+      25,   17,   76, -112, -116,    9,   38,   71,  -58,    4,   67,    2,   70,    0,   72,   40,
+    -104,   17, -128, -126,   40,   16,   10,   70,    0, -120,   24,    1,   32,   99,    4, -128,
+    -112,   17,    0,   90,   70,    0,  -56,  -79,  -19,   34,  108,   63,    9,    0,    0,    0,
+     121,   24,    0,    0,  -22,    0,    0,    0,   26,    3,   76, -112,   70,    2,   19,   68,
       62,    8,  114,   35, -109,  123,   75,   35,    3,   25,   99,   11,  115,   59,    3,  -79,
       43, -109, -101,   75,  123,  115,    3, -103,  113,  -63,  113, -111,  -71,  -87,  -95,  -63,
     -127,    1,    1,   65,   17,   11, -101,   43,   35,    3,  121,  115,    3,   97,   98,  -78,
-     106,    2, -103,  113,  -63,  113, -111,  -71,  -87,  -95,  -63, -127,   73,   25,   34, -116,
-       1,  -64,  -61,  -82,   76,  110,   46,  -19,  -51, -115,   65,  -52,   16,   98,   12, -124,
-      49,   24,   24,  -87, -123,  -39, -123,  125,  -63, -123, -115,  -83, -123,  -99, -107,  125,
+     106,    2, -103,  113,  -63,  113, -111,  -71,  -87,  -95,  -63, -127,   73,   25,   34, -104,
+       1,  -64,  -61,  -82,   76,  110,   46,  -19,  -51, -115,   65,  -52,   16,  -62,   12,    4,
+      51,   24,   24,  -87, -123,  -39, -123,  125,  -63, -123, -115,  -83, -123,  -99, -107,  125,
      -71, -123,  -75, -107,  113,   26,  123,  107,  115,    9,  115,   35, -109,  123,   75,   35,
-     115, -111, -101,  115,  -95,   43, -101,  -93,   27,   66, -116,   65,   49,    6,    6,   15,
-     -69,   48,  -71,  -81,   52,   55,   58,    6,   53,   67, -120,   49,   64,  -58,   32,   33,
-      98,   23,   38,   -9,  -59,  -10,  -26,  118,  -58,  -64,  102,    8,   49,    6,  -53,   24,
-      48,   76,  -20,  -62,  -28,  -66,  -52,  -40,  -34,  -62,  -24, -122,   16,   99,  -32, -116,
+     115, -111, -101,  115,  -95,   43, -101,  -93,   27,   66, -104,   65,   97,    6,    6,   15,
+     -69,   48,  -71,  -81,   52,   55,   58,    6,   53,   67,    8,   51,   64,  -52,   32,   33,
+      98,   23,   38,   -9,  -59,  -10,  -26,  118,  -58,  -64,  102,    8,   97,    6, -117,   25,
+      48,   76,  -20,  -62,  -28,  -66,  -52,  -40,  -34,  -62,  -24, -122,   16,  102,  -32, -104,
      -63,   64,  -59,   46,   76,  -18, -117,  -20,  -83,   78, -116,  -83, -116, -127,  -52,   16,
-      98,   12,  -96,   49, -120,  -24,  -40, -123,  -55,  125, -123,  -79,  -79,  -67, -115, -123,
-     -47,  -91,  -67,  -71,   81, -112, -127,   25,   66, -116,  -63,   52,    6,   20,   19,  -69,
-      48,  -71,  -81,   48,   57,  -71,  -80,   60,   62,   60,   67,  111,  110,  115,  116,   97,
-     110,  116,   65,  114,  114,   97,  121,   62,   67, -120,   49,  -80,  -58,  -32,  -94,   98,
-      23,   38,   -9,    5,   -9, -106,  -26,   70,   39,   67,    3,  -22,   45,  -51, -115,   78,
-     102,    8,   49,    6,  -39,   24,  104,  116,  -20,  -62,  -28,  -66,  -32,  -34,  -46,  -36,
-     -24,  100,  -66,  -32,  -24,  -28,  120,  -88,   64,  -67,  -91,  -71,  -47,  -55,   12,   33,
-     -58, -128,   27, -125, -114,    1,  -51,   16,   97,   12,   62,   34,  102,  117,  110,   99,
-     116,  105,  111,  110,   67, -124,   49,    8,    3,   70,   46,  104,  101,  108,  112,  101,
-     114,   95,  102,  117,  110,   99,  116,  105,  111,  110,   86,   67, -124,   49,   24,    3,
-      18,  114,  111,  111,  116,   67, -124,   49,   40,    3,   38,  105,  110,   99,  114,  101,
-     109,  101,  110,  116,   67, -124,   49,   56,    3,    6,   48,   67, -124,   49,   72,    3,
-      10,   51,   53,   67, -124,   49,   88,    3,   38,  115,  117,  109,  109,   97,  116,  105,
-     111,  110,  116,  -26,  -22,  -38, -126,  -58,  -58,  -22,  -38,  -22,  -40,  -62,  -24,  -34,
-     -28, -122,   16,   99,  -32,    6,   99,   48,  112, -103,  -85,  107,   27,  122,  107,   19,
-      75,  115,   43, -109,   27,  -94, -116,   65,   27, -116,  -63,   55,    6,  111,   32,    1,
-      99,    0,    7,   67, -124,   49,  -48,   24,  -32,  113,   72,  115,  -93,   27,   66, -116,
-     -63,   28, -116,    1,   29,   48,  -56,   27,   66, -116, -127,   29, -116,    1,   29,  -16,
-     121,  107,  115,   75, -125,  123,  -93,   43,  115,  -93,    3,   25,   67,   11, -109,   99,
-      52, -107,  -42,    6,  -57,   86,    6,   50,  -12,   50,  -76,  -78,    2,   66,   37,   20,
-      20,   52,   68,   24, -125,   60,   24,   34,    8,  -45,   16,   99,   12,  -16,   96,   12,
-     -12,   64, -104, -122,   24,   99,   64,    7,   99,  -64,    7,  -62,   52,  -60,   24, -125,
-      62,   24, -125,   62,   16,   38,   18,  108,  111,  110,  103,   67, -116,   49,   -8, -125,
-      49,  -32,    3,   97,   26,   98, -116,    1,   40, -116,    1,   40,    8,   19,   11,   51,
-     -74,  -73,   48,  -70,   33,  -58,   24, -120,  -62,   24,  -16, -127,   48,   13,   49,  -58,
-      96,   20,  -58,   96,   20, -124, -119,    6,  -39,   91,  -99,   24,   91,  -39,   16,   99,
-      12,   74,   97,   12,   -8,   64, -104, -122,   24,   99,   96,   10,   99,   96,   10,  -62,
-      84, -123, -115,  -51,  -82,  -51,   37, -115,  -84,  -52, -115,  110,   74,   16,  -12,   24,
-    -127, -109,   11,   59,  107,   11, -101,   34,   16,   71,  -99,   17,  -71,  -71,  -81,   50,
-      60,  -72,   55,   57,  -70,   47,  -69,   48,  -71,   41, -120,  -46,   60,   82, -123,  109,
-      94,  -95,   17,  -71,  -71,  -81,   55,   49,  -75,  -78,   49,  -70,  -81,   57,  -74,   55,
-     -70,  -71,   41,    1,   24,  -12,   25, -111, -101,   -5,   42,  -61, -125,  123, -109,  -93,
-      -5,   50,  -85,  115,   27, -101,   34, -120,    1,   25,  -12,   26, -111, -101,   -5,   42,
-     -61, -125,  123, -109,  -93,   -5,   50,  123, -109,   43,   11,   27,   67,   -5,  114,   11,
-     107,   43, -101,   34, -104,    1,   26,   84,   26, -111, -101,   -5,   42,  -61, -125,  123,
-    -109,  -93,   -5,   50,  123, -109,   43,   11,   27,   67, -101,   34,  -88,    1,   27,   52,
-      26, -111, -101,   -5,   42,  -61, -125,  123, -109,  -93,   -5, -110,   43,   35,  -85,   27,
-      43, -101,   18,  -60,   65,  -97,   17,  -71,  -71,  -81,   50,   60,  -72,   55,   57,  -70,
-      47,  -70,   60,  -72,  -78,   41, -127,   28,  -12,   40, -127,  122,   75,  115,  -93, -109,
-    -103,   34,  -44,  -63,   29,    0,    0,    0,  121,   24,    0,    0,   92,    0,    0,    0,
-      51,    8, -128,   28,  -60,  -31,   28,  102,   20,    1,   61, -120,   67,   56, -124,  -61,
-    -116,   66, -128,    7,  121,  120,    7,  115, -104,  113,   12,  -26,    0,   15,  -19,   16,
-      14,  -12, -128,   14,   51,   12,   66,   30,  -62,  -63,   29,  -50,  -95,   28,  102,   48,
-       5,   61, -120,   67,   56, -124, -125,   27,  -52,    3,   61,  -56,   67,   61, -116,    3,
-      61,  -52,  120, -116,  116,  112,    7,  123,    8,    7,  121,   72, -121,  112,  112,    7,
-     122,  112,    3,  118,  120, -121,  112,   32, -121,   25,  -52,   17,   14,  -20, -112,   14,
-     -31,   48,   15,  110,   48,   15,  -29,  -16,   14,  -16,   80,   14,   51,   16,  -60,   29,
-     -34,   33,   28,  -40,   33,   29,  -62,   97,   30,  102,   48, -119,   59,  -68, -125,   59,
-     -48,   67,   57,  -76,    3,   60,  -68, -125,   60, -124,    3,   59,  -52,  -16,   20,  118,
-      96,    7,  123,  104,    7,   55,  104, -121,  114,  104,    7,   55, -128, -121,  112, -112,
-    -121,  112,   96,    7,  118,   40,    7,  118,   -8,    5,  118,  120, -121,  119, -128, -121,
-      95,    8, -121,  113,   24, -121,  114, -104, -121,  121, -104, -127,   44,  -18,  -16,   14,
-     -18,  -32,   14,  -11,  -64,   14,  -20,   48,    3,   98,  -56,  -95,   28,  -28,  -95,   28,
-     -52,  -95,   28,  -28,  -95,   28,  -36,   97,   28,  -54,   33,   28,  -60, -127,   29,  -54,
-      97,    6,  -42, -112,   67,   57,  -56,   67,   57, -104,   67,   57,  -56,   67,   57,  -72,
-     -61,   56, -108,   67,   56, -120,    3,   59, -108,  -61,   47,  -68, -125,   60,   -4, -126,
-      59,  -44,    3,   59,  -80,  -61,   12,  -57,  105, -121,  112,   88, -121,  114,  112, -125,
-     116,  104,    7,  120,   96, -121,  116,   24, -121,  116,  -96, -121,   25,  -50,   83,   15,
-     -18,    0,   15,  -14,   80,   14,  -28, -112,   14,  -29,   64,   15,  -31,   32,   14,  -20,
-      80,   14,   51,   32,   40,   29,  -36,  -63,   30,  -62,   65,   30,  -46,   33,   28,  -36,
-    -127,   30,  -36,  -32,   28,  -28,  -31,   29,  -22,    1,   30,  102,   24,   81,   56,  -80,
-      67,   58, -100, -125,   59,  -52,   80,   36,  118,   96,    7,  123,  104,    7,   55,   96,
-    -121,  119,  120,    7,  120, -104,   81,   76,  -12, -112,   15,  -16,   80,   14,    0,    0,
-     113,   32,    0,    0,   56,    0,    0,    0,    6,   17,    6,   -1,   92,  -33, -111,  -60,
-      45,    4,   16,  -95,   65,   66,    8,   83,   90,  -33, -111,  -12,    3,  -53,  -30,    8,
-     -64, -124,   56, -115,   13,   40,   21,   16,   -3, -125,   67,    5,   11,   97,    5,   74,
-       5,   68,   -1,  -29,   32,  -51,  100,   27,   67, -126,   52,   66,   68,   48,   68,   51,
-    -103,    2,   82,   80, -115,   48,   33,   78,   99,    4,   73,    5,   68,   63,   16,   69,
-       0,  102,   17, -111,  127,   16,  -53,   67,   68,  127,   65,   53,  -62, -124,   56,  -51,
-     107,   14, -117,   68,   49, -100,  -61,    4,   72,   67,   68,  102,  -32,   84,   64,  -12,
-       3,  -53,  -30,    8,  -64, -124,   56, -115,   33,  112,  126,   36,   -7,   17,   49,   80,
-       2,  -15,   23, -115,   47,   81, -116,   38,    8,   20,   67,   45,  -64,  -28,   68,    6,
-     112,   84,   64,  -12,   35,  -51,  100,   13, -114,   68,   49, -102,   32,   80,   12,  -75,
-       0, -109,   19,   89,    0,   82,    1,  -47,  -65,   56, -115,   97,    7,   78,    5,   68,
-      -1,  -29,   32,  -51,  100,   -1,  -49,   20,  -39,    3,  -30,   71, -110,   63,   76,   78,
-     100,   11,   73,   65,   53,  -62, -124,   56,  -51,  107,    2,   73,    5,   68,  127,  -79,
-      56,  -64,  100,    9, -103,   31,   73,  126,   68,   12, -108,   64,   -4,   69,  -29,   75,
-      20,  -61,   57,   76, -128,   52,   68,    4,   97,   32,    0,    0,   55,    0,    0,    0,
-      19,    4,   65,   44,   16,    0,    0,    0,   21,    0,    0,    0,    4, -108,   64,   41,
-      20,   67,   57,   20,   68,   73,   20,    5,    9,  101,   80,    2,   69,   64,  -63,   80,
-      70,   66,    8, -109,   48,    6,   67,   25,   75,   33,   76, -128,   52, -108,  -79,   20,
-     -62,    4,  112,   67,   25,    9,   33,   76,   66,   25,   12,  101,   36, -124,   48,    9,
-     100,   48, -108, -111,   16,  -62,   36,   76,   68, -116,   17, -128,   32,    8, -110,   96,
-      64,  -58,   24,    1,    8, -126,   32,    8, -126,   32,    8, -110,   32,    1,    0,    0,
-    -125,   17,    0,   55,    0, -125,   17,   65,   25,   16,  -64,   96, -124,  -64,    6,    3,
-      48,   24,   49,  -76,    1,    1,   12,   70,  -84,   65,   55,    0, -125,   17,  106,  -32,
-      13,  -64,   96,   68,   26,  124,    3,   48,   24,   97,    6,   96,   48,    0, -125,   17,
-     103,   16,    6,    3,   48,   24, -127,    6,   98,   48,    0,   24,   16,    3,    0,    0,
-      13,    0,    0,    0,   91,    6,   32,  -16, -125,   45,   67,   16, -124,  -62, -106,   65,
-       8,   72,   97,  -53,   48,    4,  -89,  -80,  101,   32,    2,   63,  -40,   50,   20, -127,
-      31,  108,   25, -116,  -64,   15,  -74,   12,   71,  -32,    7,   91,    6,   36,  -16, -125,
-      45,   67,   18,   -8,    1,    0,    0,    0,    0,    0,    0,    0,   97,   32,    0,    0,
-      11,    0,    0,    0,   19,    4,  -63,   96,    4,  -64,   13,    0, -122,    3,    1,    0,
-       2,    0,    0,    0,  -58,   49,    0, -111,    1,    0,    0,    0,    1,   49,    0,    0,
-       2,    0,    0,    0,   91,    6,   32,  -16,    3,    0,    0,    0,    0,    0,    0,    0,
+     -62,   12,   32,   51, -120,  -24,  -40, -123,  -55,  125, -123,  -79,  -79,  -67, -115, -123,
+     -47,  -91,  -67,  -71,   81, -112, -127,   25,   66, -104,  -63,  100,    6,   20,   25,  -69,
+      48,  -71,  -81,  -70,   52,   55,  -70,   25, -103,   47,   58,    6,   57,   67,    8,   51,
+     -80,  -52,  -32,  -94,   98,   23,   38,   -9,    5,   -9, -106,  -26,   70,   39,   67,    3,
+     -22,   45,  -51, -115,   78,  102,    8,   97,    6, -103,   25,  104,   92,  -20,  -62,  -28,
+     -66,  -46,  -36,  -24,  -66,  -32,  -24,  -28,   72,  -88,  -92,  -71,  -47,   13,   33,  -52,
+    -128,   51, -125, -114,    1,  -51,   16,  -63,   12,   62,   34,  102,  117,  110,   99,  116,
+     105,  111,  110,   67,    4,   51,    8,    3,   70,   46,  104,  101,  108,  112,  101,  114,
+      95,  102,  117,  110,   99,  116,  105,  111,  110,   86,   67,    4,   51,   24,    3,   70,
+      46,  104,  101,  108,  112,  101,  114,   95,  115,  101,  116,   66,  117,  102,  102,  101,
+     114,   67,    4,   51,   40,    3,   86,   46,  104,  101,  108,  112,  101,  114,   95,  115,
+     101,  116,   65,  108,  108,  111,   99,   97,  116,  105,  111,  110,   67,    4,   51,   56,
+       3,   18,  114,  111,  111,  116,   67,    4,   51,   72,    3,   38,  105,  110,   99,  114,
+     101,  109,  101,  110,  116,   67,    4,   51,   88,    3,    6,   48,   67,    4,   51,  104,
+       3,   10,   51,   53,   67,    4,   51,  120,    3,   38,  115,  117,  109,  109,   97,  116,
+     105,  111,  110,  116,  -26,  -22,  -38, -126,  -58,  -58,  -22,  -38,  -22,  -40,  -62,  -24,
+     -34,  -28, -122,   16,  102,   32,    7,  102,   48,  112, -103,  -85,  107,   27,  122,  107,
+      19,   75,  115,   43, -109,   27,  -94, -104,   65,   28, -104,  -63,  103,    6,  115,    0,
+       1,  102,   64,    7,   67,    4,   51,  -48,   24,  -32,  113,   72,  115,  -93,   27,   66,
+    -104,  -63,   29, -104,    1,   30,   48,  -56,   27,   66, -104, -127,   30, -104,    1,   30,
+     -16,  121,  107,  115,   75, -125,  123,  -93,   43,  115,  -93,    3,   25,   67,   11, -109,
+      99,   52, -107,  -42,    6,  -57,   86,    6,   50,  -12,   50,  -76,  -78,    2,   66,   37,
+      20,   20,   52,   68,   48, -125,   62,   24,   34,    8,  -38,   16,  -61,   12,   -8,  -64,
+      12,   -4,   64,  -48, -122,   24,  102, -128,    7,  102,    0,   10, -126,   54,  -60,   48,
+    -125,   80,   48, -125,   80,   16,   52,   18,  108,  111,  110,  103,   67,   12,   51,   24,
+       5,   51,    0,    5,   65,   27,   98, -104,    1,   41, -104,    1,   41,    8,   26,   11,
+      51,  -74,  -73,   48,  -70,   33, -122,   25, -104, -126,   25, -128, -126,  -96,   13,   49,
+     -52,  -32,   20,  -52,  -32,   20,    4, -115,    6,  -39,   91,  -99,   24,   91,  -39,   16,
+     -61,   12,   82,  -63,   12,   64,   65,  -48, -122,   24,  102,  -96,   10,  102,  -96,   10,
+    -126,  -58,   37,  -52,   45,   15,    4,  -18,   45,  -51, -115,  -82,   76,  110, -120,   97,
+       6,  -84,   96,    6,  -96,   32,  104,   67,   12,   51,  104,    5,   51,  104,    5,   65,
+      27,   34,    8,  -37,   16,   65,  -32, -122,    8,   66,   54,    4,   19,   52,   97,   51,
+       3,   87,   16,   54,   97,   51,    3,   87,   16,   56,   97,   51,    3,   87,   16,   50,
+      97,   51,    3,   87,  -88,  -62,  -58,  102,  -41,  -26, -110,   70,   86,  -26,   70,   55,
+      37,    8,  122, -116,  -64,  -55, -123,  -99,  -75, -123,   77,   17, -120,  -93,  -50, -120,
+     -36,  -36,   87,   25,   30,  -36, -101,   28,  -35, -105,   93, -104,  -36,   20,   68,  105,
+      30,  -87,  -62,   54,  -81,  -48, -120,  -36,  -36,  -41, -101, -104,   90,  -39,   24,  -35,
+     -41,   28,  -37,   27,  -35,  -36, -108,    0,   12,   -6, -116,  -56,  -51,  125, -107,  -31,
+     -63,  -67,  -55,  -47,  125, -103,  -43,  -71, -115,   77,   33,  -60, -128,   12,  -52,    0,
+      13,  122, -115,  -56,  -51,  125, -107,  -31,  -63,  -67,  -55,  -47,  125, -103,  -67,  -55,
+    -107, -123, -115,  -95,  125,  -71, -123,  -75, -107,   77,   17,  -44, -128,   13,   42, -115,
+     -56,  -51,  125, -107,  -31,  -63,  -67,  -55,  -47,  125, -103,  -67,  -55, -107, -123, -115,
+     -95,   77,   17,  -36,    0,   14,   26, -115,  -56,  -51,  125, -107,  -31,  -63,  -67,  -55,
+     -47,  125,  -55, -107, -111,  -43, -115, -107,   77,    9,  -22,  -96,  -49, -120,  -36,  -36,
+      87,   25,   30,  -36, -101,   28,  -35,   23,   93,   30,   92,  -39, -108,  -64,   14,  122,
+    -108,   64,  -67,  -91,  -71,  -47,  -55,   76,   17,  -14,   96,   15,    0,    0,    0,    0,
+     121,   24,    0,    0,   92,    0,    0,    0,   51,    8, -128,   28,  -60,  -31,   28,  102,
+      20,    1,   61, -120,   67,   56, -124,  -61, -116,   66, -128,    7,  121,  120,    7,  115,
+    -104,  113,   12,  -26,    0,   15,  -19,   16,   14,  -12, -128,   14,   51,   12,   66,   30,
+     -62,  -63,   29,  -50,  -95,   28,  102,   48,    5,   61, -120,   67,   56, -124, -125,   27,
+     -52,    3,   61,  -56,   67,   61, -116,    3,   61,  -52,  120, -116,  116,  112,    7,  123,
+       8,    7,  121,   72, -121,  112,  112,    7,  122,  112,    3,  118,  120, -121,  112,   32,
+    -121,   25,  -52,   17,   14,  -20, -112,   14,  -31,   48,   15,  110,   48,   15,  -29,  -16,
+      14,  -16,   80,   14,   51,   16,  -60,   29,  -34,   33,   28,  -40,   33,   29,  -62,   97,
+      30,  102,   48, -119,   59,  -68, -125,   59,  -48,   67,   57,  -76,    3,   60,  -68, -125,
+      60, -124,    3,   59,  -52,  -16,   20,  118,   96,    7,  123,  104,    7,   55,  104, -121,
+     114,  104,    7,   55, -128, -121,  112, -112, -121,  112,   96,    7,  118,   40,    7,  118,
+      -8,    5,  118,  120, -121,  119, -128, -121,   95,    8, -121,  113,   24, -121,  114, -104,
+    -121,  121, -104, -127,   44,  -18,  -16,   14,  -18,  -32,   14,  -11,  -64,   14,  -20,   48,
+       3,   98,  -56,  -95,   28,  -28,  -95,   28,  -52,  -95,   28,  -28,  -95,   28,  -36,   97,
+      28,  -54,   33,   28,  -60, -127,   29,  -54,   97,    6,  -42, -112,   67,   57,  -56,   67,
+      57, -104,   67,   57,  -56,   67,   57,  -72,  -61,   56, -108,   67,   56, -120,    3,   59,
+    -108,  -61,   47,  -68, -125,   60,   -4, -126,   59,  -44,    3,   59,  -80,  -61,   12,  -57,
+     105, -121,  112,   88, -121,  114,  112, -125,  116,  104,    7,  120,   96, -121,  116,   24,
+    -121,  116,  -96, -121,   25,  -50,   83,   15,  -18,    0,   15,  -14,   80,   14,  -28, -112,
+      14,  -29,   64,   15,  -31,   32,   14,  -20,   80,   14,   51,   32,   40,   29,  -36,  -63,
+      30,  -62,   65,   30,  -46,   33,   28,  -36, -127,   30,  -36,  -32,   28,  -28,  -31,   29,
+     -22,    1,   30,  102,   24,   81,   56,  -80,   67,   58, -100, -125,   59,  -52,   80,   36,
+     118,   96,    7,  123,  104,    7,   55,   96, -121,  119,  120,    7,  120, -104,   81,   76,
+     -12, -112,   15,  -16,   80,   14,    0,    0,  113,   32,    0,    0,   84,    0,    0,    0,
+      70,  -64,   84,   64,  -12,   83,   72,   51,  -35,  -10,   63,  -39, -128,   82,    1,  -47,
+      63,   56,   84,  -80,   16,  -90, -128,   20,   84,   35,   76, -120,  -45, -104,  -63,   82,
+       1,  -47, -113,   52,  -45,   -1,   76, -111,   53,   52,   18,   49,  105,  -53,  -30,    8,
+     -64, -124,   56, -115,   61,  100,  -53,   82,   49,   62,   67,   48,  -62, -125,   -7,   15,
+    -115,  -16,   -2,   67,   35,  -68, -113,  -24,  -72,    5,   32,   21,   16,   -3, -117,  -45,
+      24,  -74, -112,   20,   84,   35,   76, -120,  -45,  -68,  -26, -112,    6,   -1,  108,  -45,
+    -111,  -60,   18, -109,  -73,   16,   12,  -47,   76,  -38,  -12,   83,  -62,    1,   68,  -11,
+      29,   73,   63,  -80,   44, -114,    0,   76, -120,  -45,   28, -119,   81, -124,  -63,   63,
+     -41,  119,   36,  113,   11,    1,   68,  104, -112,   16,  -62, -108,  -42,  119,   36,   -3,
+     -64,  -78,   56,    2,   48,   33,   78,   99,    2,   73,    5,   68,  127,  -79,   56,  -64,
+     100,    9, -103,   31,   73,  126,   68,   12, -108,   64,   -4,   69,  -29,   75,   20,  -61,
+      57,   76, -128,   52,   68,  100,   23, -107,  127,   16,  -53,   67,   68,  -65,   68,   76,
+     -38,  -78,   56,    2,   48,   33,   78,   99,    5,   74,    5,   68,   -1,  -29,   32,  -51,
+     100,   27,   68, -126,   52,   66,   68,   48,   68,   51,   25,   67,   34,   17,  -45,   70,
+      21,    5,   17, -103,  -60,   34,   81,   12,  -25,   48,    1,  -46,   16, -111,   85,   68,
+      -2,   65,   44,   15,   17,   -3,    5,  -43,    8,   19,  -30,   52,  -81,   29,   56,   21,
+      16,   -3,  -64,  -78,   56,    2,   48,   33,   78,   99,    8, -100,   31,   73,  126,   68,
+      12, -108,   64,   -4,   69,  -29,   75,   20,  -93,    9,    2,  -59,   80,   11,   48,   57,
+    -111,    1,   28,   21,   16,   -3,   72,   51, -103,   69,  -28,   31,  -60,  -14,   16,  -47,
+      47,   17,  -45,   70,   21,    5,   17,   89, -124,   35,   81, -116,   38,    8,   20,   67,
+      45,  -64,  -28,   68,   54, -127,   -8, -111,  -28,   15, -109,   19,    1,    0,    0,    0,
+      97,   32,    0,    0,   38,    0,    0,    0,   19,    4,   65,   44,   16,    0,    0,    0,
+      12,    0,    0,    0,    4, -108,   64,   41,   20,   67,   57, -112,   80,    4,   20,   12,
+     101,   36, -123,  -96,    1,  100,   48, -108, -111,   20, -126,    6,   96,   68, -116,   17,
+    -128,   32,    8, -110,   96,   64,  -58,   24,    1,    8, -126,   32,    8, -126,   32,    8,
+    -110,   32,    1,    0, -125,   17,    0,   25,   12,  -64,   96,   68, -128,    6,    4,   48,
+      24,   33,  -84,  -63,    0,   12,   70,   12,  108,   64,    0, -125,   17,   68,   25,   12,
+     -64,   96, -124,   26, -104,  -63,    0,   12,   70,  -92,  -63,   25,   12,    0,    6,  -60,
+       0,    0,    0,    0,    9,    0,    0,    0,   91,    6,   32,   16, -123,   45,   67,   16,
+    -108,  -62, -106,   65,    8,   80,   97,  -53,   48,    4,  -85,  -80,  101,   32,    2,   81,
+     -40,   50,   20, -127,   40,  108,   25, -116,   64,   20,    0,    0,    0,    0,    0,    0,
+      97,   32,    0,    0,   11,    0,    0,    0,   19,    4,  -63,   96,    4,   64,    6,    3,
+    -128,  -31,   64,    0,    2,    0,    0,    0,   70,   50,    0, -111,    1,    0,    0,    0,
+       1,   49,    0,    0,    2,    0,    0,    0,   91,    6,   32,   16,    5,    0,    0,    0,
+       0,    0,    0,    0,   97,   32,    0,    0,   46,    0,    0,    0,   19,    4,   68,   44,
+      16,    0,    0,    0,    2,    0,    0,    0,    4, -108,    2,    9,   37,    0,    0,    0,
+     -61,   13,  100, -128, -103,  -63,   44,   67,   48, -100,    1,   25,  100, -106,   64,   24,
+     -88,   16,  -76,   96,   13, -124,  -15,    4,   52,   72, -125,  -63,    8,   53,   40, -125,
+       1,  -80,   52,   48,    3,   24,  -36,   26,    0,   48,  -36,  -64,    6,  100,    0,    6,
+     -77,   12, -125,  -48,    6,   24,   14,    4,   20,    0,    0,    0,  -90, -126,    0,   81,
+       4,   96,  -56,  112,   89, -118, -126,   52,   67,    5,   68, -110, -113,   84,  -58,  -78,
+      44,  -59,   20,   -7,   22,   50,   16,   72,  101,   43,   15,  -46,   12,   21,   16,   73,
+      62,   82,   -7,   13,  113,   77,   23,   96,   -8,   75,  -28,   63,  -57,   13,   44,   -2,
+      47,   68,  -56,  -12,   19, -125,   65,  -40,    9,   33,   48,   15,  110,   36,  -61, -128,
+      48,  -42, -126,   16,   23,   50,    9,   78,   51,    0,    0,    0,    1,   49,    0,    0,
+       3,    0,    0,    0,   91,    6,   33,  112, -123,   45, -125,   17, -120,    2,    0,    0,
+       0,    0,    0,    0,   97,   32,    0,    0,   45,    0,    0,    0,   19,    4,   68,   44,
+      16,    0,    0,    0,    5,    0,    0,    0,    4, -108,   64,   65, -112,   80,   64,  -44,
+    -108,    3,   93,   35,    0,  -28,  -40,   50,    7,    0,    0,    0,   51,   17,   12,   80,
+       6,  -60,  112,    3,   25,   96,  102,   48,  -53,   16,   12,  108,  112,  107,  -32,  -20,
+      44, -127,   48,   80,    1,   96,  -63,   27,    8,   35,    6,    8,    0,   60,  109,  -96,
+       6,  103,   96,    6,  105,   48,   98,   96,   40, -128,  -77,    6,  104,  -32,    6,  -26,
+       6,  101,    0, -125,  -31, -122,   55,   32,    3,   48, -104,  101,   24,    4,   56,  -64,
+     112,   32,    0,    0,   13,    0,    0,    0,  -74,   50,   76,  -52,  115,    1, -122,  -65,
+      68,   -2,  115,  -36,  -64,  -30,   -1,   66, -124,   76,   63,   49,   24, -124,  -79,   16,
+       2,  -13,  -32,   70,   50,   12,    8,   99,   47,    3,  -46,    8,  -26,   66,   92,   62,
+     -99,   27,   12,   66,   92,  -56,   36,   56,  -51,    0,    0,    0,    1,   49,    0,    0,
+       2,    0,    0,    0,   91,    6,  -93, -112,    5,    0,    0,    0,    0,    0,    0,    0,
       97,   32,    0,    0,   15,    0,    0,    0,   19,    4,   65,   44,   16,    0,    0,    0,
-       1,    0,    0,    0,    4, -108,    0,    0,  -57,    1,   97,   94,    7, -125,   -5,   30,
-      72,   48,    8,    7,    2,    0,    0,    0,    5,    0,    0,    0,  -26,   65,    8,   78,
-      83,   25, -121, -128,   52,    6,   82,    8,   78,   83,  -43,  -10,   49,    0,  -61,    0,
-       0,    0,    0,    0,   97,   32,    0,    0,   15,    0,    0,    0,   19,    4,    1,  113,
-     -61,  -68,   14,    4, -125,   17,  -36,   55,    0,   24,   14,    4,    4,    0,    0,    0,
-     -42,   49,   84,  -64,   98,   28,    5,   32,    8,   20,   99,   31,    3,   48,   12,    0,
-       1,   49,    0,    0,    3,    0,    0,    0,   91,    6,   32,  -16, -125,   45, -125,   16,
-      -8,    1,    0,    0,    0,    0,    0,    0,   97,   32,    0,    0,   17,    0,    0,    0,
-      19,    4,    1,  117, -125,  -72,   97,  -97,    7, -126,  -63,    8,   14,   12,    6,    0,
-     -61, -127,    0,    0,    4,    0,    0,    0,  -42,   49,   84,  -64,   98,   28,    5,   32,
-       8,   20,   99,   32,    3,   48,   12,    0,    1,   49,    0,    0,    4,    0,    0,    0,
-      91,    6,   32,  -16, -125,   45,   67,   16,   -8,  -63, -106,   97,    8,   -4,    0,    0,
-       0,    0,    0,    0,   97,   32,    0,    0,    3,    0,    0,    0,   19,    4,  -63, -120,
-       1, -127,    4, -112, -127,    0,    0,    0,   97,   32,    0,    0,    9,    0,    0,    0,
-      19,    4,  -63,  120,    3,   55,   73,  -44, -115,   17,    3,    2,    8,   22,   15,  -61,
-    -127,    0,    0,    0,    2,    0,    0,    0,    7,   80,   16,  -51,   20,   97,    0,    0,
+       1,    0,    0,    0,    4, -108,    0,    0,   71,    6,   64, -104,   25, -108,    1,   12,
+     -18,   12,   26,   72,   52,    8,    7,    2,    5,    0,    0,    0,  102,   66,    8,   78,
+      83,   25, -119, -128,   52, -122,   82,    8,   78,   83,  -43,  118,   50,    0,  -61,    0,
+       0,    0,    0,    0,   97,   32,    0,    0,   16,    0,    0,    0,   19,    4,    1, -111,
+     -63,   48,   51,   40,    3,   16,   12,   70, -112,  -63,   25,   12,    0, -122,    3,    1,
+       4,    0,    0,    0,   86,   50,   84,  -64,   98,   36,    5,   32,    8,   20,   99,   39,
+       3,   48,   12,    0,    1,   49,    0,    0,    3,    0,    0,    0,   91,    6,   32,   16,
+    -123,   45, -125,   16, -120,    2,    0,    0,    0,    0,    0,    0,   97,   32,    0,    0,
+      18,    0,    0,    0,   19,    4,    1, -107,  -63,   32,   50,   24,  118,    6,  102,    0,
+    -126,  -63,    8,   50,   64, -125,    1,  -64,  112,   32,    0,    0,    4,    0,    0,    0,
+      86,   50,   84,  -64,   98,   36,    5,   32,    8,   20,   99,   40,    3,   48,   12,    0,
+       1,   49,    0,    0,    4,    0,    0,    0,   91,    6,   32,   16, -123,   45,   67,   16,
+    -120,  -62, -106,   97,    8,   68,    1,    0,    0,    0,    0,    0,   97,   32,    0,    0,
+       3,    0,    0,    0,   19,    4,  -63, -120,    1,  -95,    4,  -44, -127,    0,    0,    0,
+      97,   32,    0,    0,    9,    0,    0,    0,   19,    4,  -63,  120,    3,   25,  104,   24,
+    -107,  -63,   24,   49,   32, -128,   96,   49,    3,   12,    7,    2,    2,    0,    0,    0,
+       7,   80,   16,  -51,   20,   97,    0,    0,    0,    0,    0,    0,   97,   32,    0,    0,
+       9,    0,    0,    0,   19,    4,  -63,  120,    3,   25,  104,   24, -107,  -63,   24,   49,
+      32, -128, -128,   49,    3,   12,    7,    2,    2,    0,    0,    0,    7,   80,   16,  -51,
+      20,   97,    0,    0,    0,    0,    0,    0,   97,   32,    0,    0,    9,    0,    0,    0,
+      19,    4,  -63,  120,    3,   25,  104,   24, -107,  -63,   24,   49,   32, -128,  -96,   49,
+       3,   12,    7,    2,    2,    0,    0,    0,    7,   80,   16,  -51,   20,   97,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0,
 };
 
-const int bitCodeLength = 2744;
+const int bitCodeLength = 3480;
 
 #endif
diff --git a/sensors/1.0/ISensors.hal b/sensors/1.0/ISensors.hal
index 5c8301a..8d41de2 100644
--- a/sensors/1.0/ISensors.hal
+++ b/sensors/1.0/ISensors.hal
@@ -37,7 +37,8 @@
      */
     setOperationMode(OperationMode mode) generates (Result result);
 
-    /* Activate/de-activate one sensor.
+    /**
+     * Activate/de-activate one sensor.
      *
      * After sensor de-activation, existing sensor events that have not
      * been picked up by poll() must be abandoned immediately so that
@@ -76,7 +77,7 @@
                 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
@@ -96,7 +97,7 @@
           int64_t samplingPeriodNs,
           int64_t maxReportLatencyNs) generates (Result result);
 
-    /*
+    /**
      * Trigger a flush of internal FIFO.
      *
      * Flush adds a FLUSH_COMPLETE metadata event to the end of the "batch mode"
@@ -113,7 +114,7 @@
      */
     flush(int32_t sensorHandle) generates (Result result);
 
-    /*
+    /**
      * Inject a single sensor event or push operation environment parameters to
      * device.
      *
@@ -137,7 +138,7 @@
      */
     injectSensorData(Event event) generates (Result result);
 
-    /*
+    /**
      * Register direct report channel.
      *
      * Register a direct channel with supplied shared memory information. Upon
@@ -156,7 +157,7 @@
     registerDirectChannel(SharedMemInfo mem)
             generates (Result result, int32_t channelHandle);
 
-    /*
+    /**
      * Unregister direct report channel.
      *
      * Unregister a direct channel previously registered using
@@ -169,7 +170,7 @@
      */
     unregisterDirectChannel(int32_t channelHandle) generates (Result result);
 
-    /*
+    /**
      * Configure direct sensor event report in direct channel.
      *
      * This function start, modify rate or stop direct report of a sensor in a
diff --git a/sensors/1.0/types.hal b/sensors/1.0/types.hal
index efb18c6..3926e2f 100644
--- a/sensors/1.0/types.hal
+++ b/sensors/1.0/types.hal
@@ -22,7 +22,7 @@
  * http://source.android.com/devices/sensors/index.html
  */
 
-/* Type enumerating various result codes returned from ISensors methods */
+/** Type enumerating various result codes returned from ISensors methods */
 enum Result : int32_t {
     OK,
     PERMISSION_DENIED                   = -1,
@@ -31,7 +31,7 @@
     INVALID_OPERATION                   = -38,
 };
 
-/*
+/**
  * Sensor HAL modes used in setOperationMode method
  */
 @export(name="", value_prefix="SENSOR_HAL_", value_suffix="_MODE")
@@ -40,7 +40,7 @@
     DATA_INJECTION                  = 1,
 };
 
-/*
+/**
  * Sensor type
  *
  * Each sensor has a type which defines what this sensor measures and how
@@ -88,7 +88,7 @@
  *  - 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
@@ -116,14 +116,15 @@
 
 @export(name="", value_prefix="SENSOR_TYPE_")
 enum SensorType : int32_t {
-    /* META_DATA is a special event type used to populate the MetaData
+    /**
+     * 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.
      */
     META_DATA                       = 0,
 
-    /*
+    /**
      * ACCELEROMETER
      * reporting-mode: continuous
      *
@@ -135,7 +136,7 @@
      */
     ACCELEROMETER                   = 1,
 
-    /*
+    /**
      * MAGNETIC_FIELD
      * reporting-mode: continuous
      *
@@ -147,7 +148,7 @@
      */
     MAGNETIC_FIELD                  = 2,
 
-    /*
+    /**
      * ORIENTATION
      * reporting-mode: continuous
      *
@@ -161,7 +162,7 @@
      */
     ORIENTATION                     = 3,
 
-    /*
+    /**
      * GYROSCOPE
      * reporting-mode: continuous
      *
@@ -173,7 +174,7 @@
      */
     GYROSCOPE                       = 4,
 
-    /*
+    /**
      * LIGHT
      * reporting-mode: on-change
      *
@@ -183,7 +184,7 @@
      */
     LIGHT                           = 5,
 
-    /*
+    /**
      * PRESSURE
      * reporting-mode: continuous
      *
@@ -194,10 +195,10 @@
      */
     PRESSURE                        = 6,
 
-    /* TEMPERATURE is deprecated in the HAL */
+    /** TEMPERATURE is deprecated in the HAL */
     TEMPERATURE                     = 7,
 
-    /*
+    /**
      * PROXIMITY
      * reporting-mode: on-change
      *
@@ -210,7 +211,7 @@
      */
     PROXIMITY                       = 8,
 
-    /*
+    /**
      * GRAVITY
      * reporting-mode: continuous
      *
@@ -222,7 +223,7 @@
      */
     GRAVITY                         = 9,
 
-    /*
+    /**
      * LINEAR_ACCELERATION
      * reporting-mode: continuous
      *
@@ -234,7 +235,7 @@
      */
     LINEAR_ACCELERATION             = 10,
 
-    /*
+    /**
      * ROTATION_VECTOR
      * reporting-mode: continuous
      *
@@ -246,7 +247,7 @@
      */
     ROTATION_VECTOR                 = 11,
 
-    /*
+    /**
      * RELATIVE_HUMIDITY
      * reporting-mode: on-change
      *
@@ -257,7 +258,7 @@
      */
     RELATIVE_HUMIDITY               = 12,
 
-    /*
+    /**
      * AMBIENT_TEMPERATURE
      * reporting-mode: on-change
      *
@@ -267,7 +268,7 @@
      */
     AMBIENT_TEMPERATURE             = 13,
 
-    /*
+    /**
      * MAGNETIC_FIELD_UNCALIBRATED
      * reporting-mode: continuous
      *
@@ -279,7 +280,7 @@
      */
     MAGNETIC_FIELD_UNCALIBRATED     = 14,
 
-    /*
+    /**
      * GAME_ROTATION_VECTOR
      * reporting-mode: continuous
      *
@@ -291,7 +292,7 @@
      */
     GAME_ROTATION_VECTOR            = 15,
 
-    /*
+    /**
      * GYROSCOPE_UNCALIBRATED
      * reporting-mode: continuous
      *
@@ -303,7 +304,7 @@
      */
     GYROSCOPE_UNCALIBRATED          = 16,
 
-    /*
+    /**
      * SIGNIFICANT_MOTION
      * reporting-mode: one-shot
      *
@@ -316,7 +317,7 @@
      */
     SIGNIFICANT_MOTION              = 17,
 
-    /*
+    /**
      * STEP_DETECTOR
      * reporting-mode: special
      *
@@ -328,7 +329,7 @@
      */
     STEP_DETECTOR                   = 18,
 
-    /*
+    /**
      * STEP_COUNTER
      * reporting-mode: on-change
      *
@@ -341,7 +342,7 @@
      */
     STEP_COUNTER                    = 19,
 
-    /*
+    /**
      * GEOMAGNETIC_ROTATION_VECTOR
      * reporting-mode: continuous
      *
@@ -353,7 +354,7 @@
      */
     GEOMAGNETIC_ROTATION_VECTOR     = 20,
 
-    /*
+    /**
      * HEART_RATE
      * reporting-mode: on-change
      *
@@ -377,7 +378,7 @@
      */
     HEART_RATE                      = 21,
 
-    /*
+    /**
      * WAKE_UP_TILT_DETECTOR
      * reporting-mode: special (setDelay has no impact)
      *
@@ -416,7 +417,7 @@
      */
     TILT_DETECTOR                   = 22,
 
-    /*
+    /**
      * WAKE_GESTURE
      * reporting-mode: one-shot
      *
@@ -437,7 +438,7 @@
      */
     WAKE_GESTURE                    = 23,
 
-    /*
+    /**
      * GLANCE_GESTURE
      * reporting-mode: one-shot
      *
@@ -474,7 +475,7 @@
      */
     PICK_UP_GESTURE                 = 25,
 
-    /*
+    /**
      * WRIST_TILT_GESTURE
      * trigger-mode: special
      * wake-up sensor: yes
@@ -489,7 +490,7 @@
      */
     WRIST_TILT_GESTURE              = 26,
 
-    /*
+    /**
      * DEVICE_ORIENTATION
      * reporting-mode: on-change
      *
@@ -523,7 +524,7 @@
      */
     DEVICE_ORIENTATION              = 27,
 
-    /*
+    /**
      * POSE_6DOF
      * trigger-mode: continuous
      *
@@ -541,7 +542,7 @@
      */
     POSE_6DOF                       = 28,
 
-    /*
+    /**
      * STATIONARY_DETECT
      * trigger mode: one shot
      *
@@ -555,7 +556,7 @@
      */
     STATIONARY_DETECT               = 29,
 
-    /*
+    /**
      * MOTION_DETECT
      * trigger mode: one shot
      *
@@ -573,7 +574,7 @@
      */
     MOTION_DETECT                   = 30,
 
-    /*
+    /**
      * HEART_BEAT
      * trigger mode: continuous
      *
@@ -680,7 +681,7 @@
      */
     ADDITIONAL_INFO                 = 33,
 
-    /*
+    /**
      * LOW_LATENCY_OFFBODY_DETECT
      * trigger-mode: on-change
      * wake-up sensor: yes
@@ -703,7 +704,7 @@
      */
     LOW_LATENCY_OFFBODY_DETECT      = 34,
 
-    /*
+    /**
      * ACCELEROMETER_UNCALIBRATED
      * reporting-mode: continuous
      *
@@ -715,7 +716,7 @@
      */
     ACCELEROMETER_UNCALIBRATED      = 35,
 
-    /*
+    /**
      * Base for device manufacturers private sensor types.
      * These sensor types can't be exposed in the SDK.
      */
@@ -724,7 +725,7 @@
 
 @export(name="", value_prefix="SENSOR_FLAG_")
 enum SensorFlagBits : uint32_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
@@ -735,7 +736,7 @@
      */
     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
@@ -746,7 +747,7 @@
     ONE_SHOT_MODE               = 4,
     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
@@ -756,42 +757,42 @@
      */
     DATA_INJECTION              = 0x10,
 
-    /*
+    /**
      * Set this flag if the sensor is a dynamically connected sensor. See
      * DynamicSensorInfo and DYNAMIC_SENSOR_META for details.
      */
     DYNAMIC_SENSOR              = 0x20,
 
-    /*
+    /**
      * Set this flag if sensor additional information is supported.
      * See ADDITIONAL_INFO and AdditionalInfo for details.
      */
     ADDITIONAL_INFO             = 0x40,
 
-    /*
+    /**
      * Set this flag if sensor suppor direct channel backed by ashmem.
      * See SharedMemType and registerDirectChannel for more details.
      */
     DIRECT_CHANNEL_ASHMEM       = 0x400,
 
-    /*
+    /**
      * Set this flag if sensor suppor direct channel backed by gralloc HAL memory.
      * See SharedMemType and registerDirectChannel for more details.
      */
     DIRECT_CHANNEL_GRALLOC      = 0x800,
 
-    /*
+    /**
      * Flags mask for reporting mode of sensor.
      */
     MASK_REPORTING_MODE         = 0xE,
 
-    /*
+    /**
      * Flags mask for direct report maximum rate level support.
      * See RateLevel.
      */
     MASK_DIRECT_REPORT          = 0x380,
 
-    /*
+    /**
      * Flags mask for all direct channel support bits.
      * See SharedMemType.
      */
@@ -809,30 +810,34 @@
 };
 
 struct SensorInfo {
-    /* handle that identifies this sensors. This handle is used to reference
+    /**
+     * handle that identifies this sensors. This handle is used to reference
      * this sensor throughout the HAL API.
      */
     int32_t sensorHandle;
 
-    /* Name of this sensor.
+    /**
+     * Name of this sensor.
      * All sensors of the same "type" must have a different "name".
      */
     string name;
 
-    /* vendor of the hardware part */
+    /** vendor of the hardware part */
     string vendor;
 
-    /* version of the hardware part + driver. The value of this field
+    /**
+     * 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. */
+    /** this sensor's type. */
     SensorType type;
 
-    /* type of this sensor as a string.
+    /**
+     * type of this sensor as a string.
      *
      * When defining an OEM specific sensor or sensor manufacturer specific
      * sensor, use your reserve domain name as a prefix.
@@ -843,16 +848,17 @@
      */
     string typeAsString;
 
-    /* maximum range of this sensor's value in SI units */
+    /** maximum range of this sensor's value in SI units */
     float maxRange;
 
-    /* smallest difference between two values reported by this sensor */
+    /** smallest difference between two values reported by this sensor */
     float resolution;
 
-    /* rough estimate of this sensor's power consumption in mA */
+    /** rough estimate of this sensor's power consumption in mA */
     float power;
 
-    /* this value depends on the reporting mode:
+    /**
+     * this value depends on the reporting mode:
      *
      *   continuous: minimum sample period allowed in microseconds
      *   on-change : 0
@@ -861,20 +867,23 @@
      */
     int32_t minDelay;
 
-    /* number of events reserved for this sensor in the batch mode FIFO.
+    /**
+     * 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.
+    /**
+     * 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.
+    /**
+     * 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
@@ -883,7 +892,8 @@
      */
     string requiredPermission;
 
-    /* This value is defined only for continuous mode and on-change sensors.
+    /**
+     * 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
@@ -901,7 +911,7 @@
      */
     int32_t maxDelay;
 
-    /* Bitmask of SensorFlagBits */
+    /** Bitmask of SensorFlagBits */
     bitfield<SensorFlagBits> flags;
 };
 
@@ -938,13 +948,14 @@
 };
 
 struct HeartRate {
-    /* Heart rate in beats per minute.
+    /**
+     * Heart rate in beats per minute.
      * Set to 0 when status is SensorStatus::UNRELIABLE or
      * SensorStatus::NO_CONTACT
      */
     float bpm;
 
-    /* Status of the heart rate sensor for this reading. */
+    /** Status of the heart rate sensor for this reading. */
     SensorStatus status;
 };
 
@@ -961,7 +972,8 @@
     bool connected;
     int32_t sensorHandle;
 
-    /* UUID of a dynamic sensor (using RFC 4122 byte order)
+    /**
+     * UUID of a dynamic sensor (using RFC 4122 byte order)
      * For UUID 12345678-90AB-CDEF-1122-334455667788 the uuid field is
      * initialized as:
      *   {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF, 0x11, ...}
@@ -971,53 +983,60 @@
 
 @export(name="additional_info_type_t")
 enum AdditionalInfoType : uint32_t {
-    /* Marks the beginning of additional information frames */
+    /** Marks the beginning of additional information frames */
     AINFO_BEGIN                       = 0,
 
-    /* Marks the end of additional information frames */
+    /** Marks the end of additional information frames */
     AINFO_END                         = 1,
 
-    /* Estimation of the delay that is not tracked by sensor timestamps. This
+    /**
+     * 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 */
+    /** float: Celsius temperature */
     AINFO_INTERNAL_TEMPERATURE,
 
-    /* First three rows of a homogeneous matrix, which represents calibration to
+    /**
+     * 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
+    /**
+     * 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,
+    /**
+     * float[2]: raw sample period in seconds,
      *           standard deviation of sampling period
      */
     AINFO_SAMPLING,
 
     // Sampling channel modeling information section
 
-    /* int32_t: noise type
+    /**
+     * int32_t: noise type
      * float[n]: parameters
      */
     AINFO_CHANNEL_NOISE               = 0x20000,
 
-    /* float[3]: sample period, standard deviation of sample period,
+    /**
+     * float[3]: sample period, standard deviation of sample period,
      * quantization unit
      */
     AINFO_CHANNEL_SAMPLER,
 
-    /* Represents a filter:
+    /**
+     * 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,
@@ -1031,48 +1050,56 @@
      */
     AINFO_CHANNEL_FILTER,
 
-    /* int32_t[2]: size in (row, column) ... 1st frame
+    /**
+     * 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
+    /**
+     * int32_t[2]: extrapolate method, interpolate method
      * float[n]: mapping key points in pairs, (in, out)...
      *           (may be used to model saturation).
      */
     AINFO_CHANNEL_NONLINEAR_MAP,
 
-    /* int32_t: resample method (0-th order, 1st order...)
+    /**
+     * int32_t: resample method (0-th order, 1st order...)
      * float[1]: resample ratio (upsampling if < 1.0, downsampling if > 1.0).
      */
     AINFO_CHANNEL_RESAMPLER,
 
-    /* Operation environment parameters section
+    /**
+     * Operation environment parameters section
      * Types in the following section is sent down (instead of reported from)
      * device as additional information to aid sensor operation. Data is sent
      * via injectSensorData() function to sensor handle -1 denoting all sensors
      * in device.
      */
 
-    /* Local geomagnetic field information based on device geo location. This
+    /**
+     * Local geomagnetic field information based on device geo location. This
      * type is primarily for for magnetic field calibration and rotation vector
      * sensor fusion.
      * float[3]: strength (uT), declination and inclination angle (rad).
      */
     AINFO_LOCAL_GEOMAGNETIC_FIELD     = 0x30000,
 
-    /* Local gravitational acceleration strength at device geo location.
+    /**
+     * Local gravitational acceleration strength at device geo location.
      * float: gravitational acceleration norm in m/s^2.
      */
     AINFO_LOCAL_GRAVITY,
 
-    /* Device dock state.
+    /**
+     * Device dock state.
      * int32_t: dock state following Android API Intent.EXTRA_DOCK_STATE
      * definition, undefined value is ignored.
      */
     AINFO_DOCK_STATE,
 
-    /* High performance mode hint. Device is able to use up more power and take
+    /**
+     * High performance mode hint. Device is able to use up more power and take
      * more reources to improve throughput and latency in high performance mode.
      * One possible use case is virtual reality, when sensor latency need to be
      * carefully controlled.
@@ -1081,7 +1108,8 @@
      */
     AINFO_HIGH_PERFORMANCE_MODE,
 
-    /* Magnetic field calibration hint. Device is notified when manually
+    /**
+     * Magnetic field calibration hint. Device is notified when manually
      * triggered magnetic field calibration procedure is started or stopped. The
      * calibration procedure is assumed timed out after 1 minute from start,
      * even if an explicit stop is not received.
@@ -1090,18 +1118,18 @@
      */
     AINFO_MAGNETIC_FIELD_CALIBRATION,
 
-    /* Custom information */
+    /** Custom information */
     AINFO_CUSTOM_START                = 0x10000000,
 
-    /* Debugging */
+    /** Debugging */
     AINFO_DEBUGGING_START             = 0x40000000,
 };
 
 struct AdditionalInfo {
-    /* type of payload data, see AdditionalInfoType */
+    /** type of payload data, see AdditionalInfoType */
     AdditionalInfoType type;
 
-    /* sequence number of this frame for this type */
+    /** sequence number of this frame for this type */
     int32_t serial;
 
     union Payload {
@@ -1121,27 +1149,31 @@
  * relative humidity in percent
  */
 union EventPayload {
-    /* SensorType::ACCELEROMETER, SensorType::MAGNETIC_FIELD,
+    /**
+     * SensorType::ACCELEROMETER, SensorType::MAGNETIC_FIELD,
      * SensorType::ORIENTATION, SensorType::GYROSCOPE, SensorType::GRAVITY,
      * SensorType::LINEAR_ACCELERATION
      */
     Vec3 vec3;
 
-    /* SensorType::ROTATION_VECTOR, SensorType::GAME_ROTATION_VECTOR,
+    /**
+     * SensorType::ROTATION_VECTOR, SensorType::GAME_ROTATION_VECTOR,
      * SensorType::GEOMAGNETIC_ROTATION_VECTOR
      */
     Vec4 vec4;
 
-    /* SensorType::MAGNETIC_FIELD_UNCALIBRATED,
+    /**
+     * SensorType::MAGNETIC_FIELD_UNCALIBRATED,
      * SensorType::GYROSCOPE_UNCALIBRATED
      * SensorType::ACCELEROMETER_UNCALIBRATED
      */
     Uncal uncal;
 
-    /* SensorType::META_DATA */
+    /** SensorType::META_DATA */
     MetaData meta;
 
-    /* SensorType::DEVICE_ORIENTATION, SensorType::LIGHT, SensorType::PRESSURE,
+    /**
+     * SensorType::DEVICE_ORIENTATION, SensorType::LIGHT, SensorType::PRESSURE,
      * SensorType::TEMPERATURE, SensorType::PROXIMITY,
      * SensorType::RELATIVE_HUMIDITY, SensorType::AMBIENT_TEMPERATURE,
      * SensorType::SIGNIFICANT_MOTION, SensorType::STEP_DETECTOR,
@@ -1153,35 +1185,35 @@
      */
     float scalar;
 
-    /* SensorType::STEP_COUNTER */
+    /** SensorType::STEP_COUNTER */
     uint64_t stepCount;
 
-    /* SensorType::HEART_RATE */
+    /** SensorType::HEART_RATE */
     HeartRate heartRate;
 
-    /* SensorType::POSE_6DOF */
+    /** SensorType::POSE_6DOF */
     float[15] pose6DOF;
 
-    /* SensorType::DYNAMIC_SENSOR_META */
+    /** SensorType::DYNAMIC_SENSOR_META */
     DynamicSensorInfo dynamic;
 
-    /* SensorType::ADDITIONAL_INFO */
+    /** SensorType::ADDITIONAL_INFO */
     AdditionalInfo additional;
 
-    /* undefined/custom sensor type >= SensorType::DEVICE_PRIVATE_BASE */
+    /** undefined/custom sensor type >= SensorType::DEVICE_PRIVATE_BASE */
     float[16] data;
 };
 
 struct Event {
-    /* Time measured in nanoseconds, in "elapsedRealtimeNano()'s" timebase. */
+    /** Time measured in nanoseconds, in "elapsedRealtimeNano()'s" timebase. */
     int64_t timestamp;
 
-    /* sensor identifier */
+    /** sensor identifier */
     int32_t sensorHandle;
 
     SensorType sensorType;
 
-    /* Union discriminated on sensorType */
+    /** Union discriminated on sensorType */
     EventPayload u;
 };
 
diff --git a/soundtrigger/2.0/ISoundTriggerHw.hal b/soundtrigger/2.0/ISoundTriggerHw.hal
index cf35ef1..0c235c9 100644
--- a/soundtrigger/2.0/ISoundTriggerHw.hal
+++ b/soundtrigger/2.0/ISoundTriggerHw.hal
@@ -22,106 +22,110 @@
 
 interface ISoundTriggerHw {
 
-    /*
+    /**
      * Sound trigger implementation descriptor read by the framework via
      * getProperties(). Used by SoundTrigger service to report to applications
      * and manage concurrency and policy.
      */
     struct Properties {
-        /* Implementor name */
+        /** Implementor name */
         string   implementor;
-        /* Implementation description */
+        /** Implementation description */
         string   description;
-        /* Implementation version */
+        /** Implementation version */
         uint32_t version;
-        /* Unique implementation ID. The UUID must change with each version of
+        /**
+         * Unique implementation ID. The UUID must change with each version of
            the engine implementation */
         Uuid     uuid;
-        /* Maximum number of concurrent sound models loaded */
+        /** Maximum number of concurrent sound models loaded */
         uint32_t maxSoundModels;
-        /* Maximum number of key phrases */
+        /** Maximum number of key phrases */
         uint32_t maxKeyPhrases;
-        /* Maximum number of concurrent users detected */
+        /** Maximum number of concurrent users detected */
         uint32_t maxUsers;
-        /* All supported modes. e.g RecognitionMode.VOICE_TRIGGER */
+        /** All supported modes. e.g RecognitionMode.VOICE_TRIGGER */
         uint32_t recognitionModes;
-        /* Supports seamless transition from detection to capture */
+        /** Supports seamless transition from detection to capture */
         bool     captureTransition;
-        /* Maximum buffering capacity in ms if captureTransition is true */
+        /** Maximum buffering capacity in ms if captureTransition is true */
         uint32_t maxBufferMs;
-        /* Supports capture by other use cases while detection is active */
+        /** Supports capture by other use cases while detection is active */
         bool     concurrentCapture;
-        /* Returns the trigger capture in event */
+        /** Returns the trigger capture in event */
         bool     triggerInEvent;
-        /* Rated power consumption when detection is active with TDB
+        /**
+         * Rated power consumption when detection is active with TDB
          * silence/sound/speech ratio */
         uint32_t powerConsumptionMw;
     };
 
 
-    /*
+    /**
      * Base sound model descriptor. This struct is the header of a larger block
      * passed to loadSoundModel() and contains the binary data of the
      * sound model.
      */
     struct SoundModel {
-        /* Model type. e.g. SoundModelType.KEYPHRASE */
+        /** Model type. e.g. SoundModelType.KEYPHRASE */
         SoundModelType type;
-        /* Unique sound model ID. */
+        /** Unique sound model ID. */
         Uuid           uuid;
-        /* Unique vendor ID. Identifies the engine the sound model
+        /**
+         * Unique vendor ID. Identifies the engine the sound model
          * was build for */
         Uuid           vendorUuid;
-        /* Opaque data transparent to Android framework */
+        /** Opaque data transparent to Android framework */
         vec<uint8_t>   data;
     };
 
-    /* Key phrase descriptor */
+    /** Key phrase descriptor */
     struct Phrase {
-        /* Unique keyphrase ID assigned at enrollment time */
+        /** Unique keyphrase ID assigned at enrollment time */
         uint32_t      id;
-        /* Recognition modes supported by this key phrase */
+        /** Recognition modes supported by this key phrase */
         uint32_t      recognitionModes;
-        /* List of users IDs associated with this key phrase */
+        /** List of users IDs associated with this key phrase */
         vec<uint32_t> users;
-        /* Locale - Java Locale style (e.g. en_US) */
+        /** Locale - Java Locale style (e.g. en_US) */
         string        locale;
-        /* Phrase text in UTF-8 format. */
+        /** Phrase text in UTF-8 format. */
         string        text;
     };
 
-    /*
+    /**
      * Specialized sound model for key phrase detection.
      * Proprietary representation of key phrases in binary data must match
      * information indicated by phrases field
      */
     struct PhraseSoundModel {
-        /* Common part of sound model descriptor */
+        /** Common part of sound model descriptor */
         SoundModel  common;
-        /* List of descriptors for key phrases supported by this sound model */
+        /** List of descriptors for key phrases supported by this sound model */
         vec<Phrase> phrases;
     };
 
-    /*
+    /**
      * Configuration for sound trigger capture session passed to
      * startRecognition() method
      */
     struct RecognitionConfig {
-        /* IO handle that will be used for capture. N/A if captureRequested
+        /**
+         * IO handle that will be used for capture. N/A if captureRequested
          * is false */
         AudioIoHandle   captureHandle;
-        /* Input device requested for detection capture */
+        /** Input device requested for detection capture */
         AudioDevice     captureDevice;
-        /* Capture and buffer audio for this recognition instance */
+        /** Capture and buffer audio for this recognition instance */
         bool            captureRequested;
-        /* Configuration for each key phrase */
+        /** Configuration for each key phrase */
         vec<PhraseRecognitionExtra> phrases;
-        /* Opaque capture configuration data transparent to the framework */
+        /** Opaque capture configuration data transparent to the framework */
         vec<uint8_t>    data;
     };
 
 
-    /*
+    /**
      * Retrieve implementation properties.
      * @return retval Operation completion status: 0 in case of success,
      *                -ENODEV in case of initialization error.
@@ -130,7 +134,7 @@
      */
     getProperties() generates (int32_t retval, Properties properties);
 
-    /*
+    /**
      * Load a sound model. Once loaded, recognition of this model can be
      * started and stopped. Only one active recognition per model at a time.
      * The SoundTrigger service must handle concurrent recognition requests by
@@ -158,7 +162,7 @@
                    CallbackCookie cookie)
             generates (int32_t retval, SoundModelHandle modelHandle);
 
-    /*
+    /**
      * Load a key phrase sound model. Once loaded, recognition of this model can
      * be started and stopped. Only one active recognition per model at a time.
      * The SoundTrigger service must handle concurrent recognition requests by
@@ -186,7 +190,7 @@
                    CallbackCookie cookie)
             generates (int32_t retval, SoundModelHandle modelHandle);
 
-    /*
+    /**
      * Unload a sound model. A sound model may be unloaded to make room for a
      * new one to overcome implementation limitations.
      * @param modelHandle the handle of the sound model to unload
@@ -197,7 +201,7 @@
     unloadSoundModel(SoundModelHandle modelHandle)
             generates (int32_t retval);
 
-    /*
+    /**
      * Start recognition on a given model. Only one recognition active
      * at a time per model. Once recognition succeeds of fails, the callback
      * is called.
@@ -221,7 +225,7 @@
                      CallbackCookie cookie)
             generates (int32_t retval);
 
-    /*
+    /**
      * Stop recognition on a given model.
      * The implementation must not call the recognition callback when stopped
      * via this method.
@@ -233,7 +237,7 @@
     stopRecognition(SoundModelHandle modelHandle)
             generates (int32_t retval);
 
-    /*
+    /**
      * Stop recognition on all models.
      * @return retval Operation completion status: 0 in case of success,
      *                -ENODEV in case of initialization error.
diff --git a/soundtrigger/2.0/ISoundTriggerHwCallback.hal b/soundtrigger/2.0/ISoundTriggerHwCallback.hal
index c6555f6..90132d9 100644
--- a/soundtrigger/2.0/ISoundTriggerHwCallback.hal
+++ b/soundtrigger/2.0/ISoundTriggerHwCallback.hal
@@ -29,62 +29,66 @@
         UPDATED  = 0,
     };
 
-    /*
+    /**
      * Generic recognition event sent via recognition callback
      */
     struct RecognitionEvent {
-        /* Recognition status e.g. SUCCESS */
+        /** Recognition status e.g. SUCCESS */
         RecognitionStatus status;
-        /* Sound model type for this event. e.g SoundModelType.TYPE_KEYPHRASE */
+        /** Sound model type for this event. e.g SoundModelType.TYPE_KEYPHRASE */
         SoundModelType    type;
-        /* Handle of loaded sound model which triggered the event */
+        /** Handle of loaded sound model which triggered the event */
         SoundModelHandle  model;
-        /* It is possible to capture audio from this */
-        /* utterance buffered by the implementation */
+        /** It is possible to capture audio from this */
+        /** utterance buffered by the implementation */
         bool              captureAvailable;
-        /* Audio session ID. framework use */
+        /** Audio session ID. framework use */
         int32_t           captureSession;
-        /* Delay in ms between end of model detection and start of audio
-        /* available for capture. A negative value is possible
+        /**
+         * Delay in ms between end of model detection and start of audio
+        /**
+         * available for capture. A negative value is possible
          * (e.g. if key phrase is also available for capture */
         int32_t           captureDelayMs;
-        /* Duration in ms of audio captured before the start of the trigger.
+        /**
+         * Duration in ms of audio captured before the start of the trigger.
          * 0 if none. */
         int32_t           capturePreambleMs;
-        /* The opaque data is the capture of the trigger sound */
+        /** The opaque data is the capture of the trigger sound */
         bool              triggerInData;
-        /* Audio format of either the trigger in event data or to use for
+        /**
+         * Audio format of either the trigger in event data or to use for
          * capture of the rest of the utterance */
         AudioConfig       audioConfig;
-        /* Opaque event data */
+        /** Opaque event data */
         vec<uint8_t>      data;
     };
 
-    /*
+    /**
      * Specialized recognition event for key phrase recognitions
      */
     struct PhraseRecognitionEvent {
-        /* Common part of the recognition event */
+        /** Common part of the recognition event */
         RecognitionEvent common;
-        /* List of descriptors for each recognized key phrase */
+        /** List of descriptors for each recognized key phrase */
         vec<PhraseRecognitionExtra> phraseExtras;
     };
 
-    /*
+    /**
      * Event sent via load sound model callback
      */
     struct ModelEvent {
-         /* Sound model status e.g. SoundModelStatus.UPDATED */
+         /** Sound model status e.g. SoundModelStatus.UPDATED */
         SoundModelStatus status;
-        /* Loaded sound model that triggered the event */
+        /** Loaded sound model that triggered the event */
         SoundModelHandle model;
-        /* Opaque event data, passed transparently by the framework */
+        /** Opaque event data, passed transparently by the framework */
         vec<uint8_t>     data;
     };
 
     typedef int32_t CallbackCookie;
 
-    /*
+    /**
      * Callback method called by the HAL when the sound recognition triggers
      * @param event A RecognitionEvent structure containing detailed results
      *              of the recognition triggered
@@ -93,7 +97,7 @@
      */
     recognitionCallback(RecognitionEvent event, CallbackCookie cookie);
 
-    /*
+    /**
      * Callback method called by the HAL when the sound recognition triggers
      * for a key phrase sound model.
      * @param event A RecognitionEvent structure containing detailed results
@@ -103,7 +107,7 @@
      */
     phraseRecognitionCallback(PhraseRecognitionEvent event,
                               CallbackCookie cookie);
-    /*
+    /**
      * Callback method called by the HAL when the sound model loading completes
      * @param event A ModelEvent structure containing detailed results of the
      *              model loading operation
diff --git a/soundtrigger/2.0/types.hal b/soundtrigger/2.0/types.hal
index 26928ba..fc7d019 100644
--- a/soundtrigger/2.0/types.hal
+++ b/soundtrigger/2.0/types.hal
@@ -16,66 +16,67 @@
 
 package android.hardware.soundtrigger@2.0;
 
-/*
+/**
  * Sound model types modes used in ISoundTriggerHw.SoundModel
  */
 enum SoundModelType : int32_t {
-    /* use for unspecified sound model type */
+    /** use for unspecified sound model type */
     UNKNOWN   = -1,
-    /* use for key phrase sound models */
+    /** use for key phrase sound models */
     KEYPHRASE = 0,
-    /* use for all models other than keyphrase */
+    /** use for all models other than keyphrase */
     GENERIC   = 1,
 };
 
 typedef int32_t SoundModelHandle;
 
 
-/*
+/**
  * Recognition modes used in ISoundTriggerHw.RecognitionConfig,
  * ISoundTriggerHw.Properties or PhraseRecognitionExtra
  */
 enum RecognitionMode : uint32_t {
-    /* simple voice trigger */
+    /** simple voice trigger */
     VOICE_TRIGGER       = (1 << 0),
-    /* trigger only if one user in model identified */
+    /** trigger only if one user in model identified */
     USER_IDENTIFICATION = (1 << 1),
-    /* trigger only if one user in mode authenticated */
+    /** trigger only if one user in mode authenticated */
     USER_AUTHENTICATION = (1 << 2),
-    /* generic sound trigger */
+    /** generic sound trigger */
     GENERIC_TRIGGER     = (1 << 3),
 };
 
-/*
+/**
  * Confidence level for each user in structure PhraseRecognitionExtra
  */
 struct ConfidenceLevel {
-    /* user ID */
+    /** user ID */
     uint32_t userId;
-    /* confidence level in percent (0 - 100): */
-    /* - min level for recognition configuration */
-    /* - detected level for recognition event */
+    /** confidence level in percent (0 - 100): */
+    /** - min level for recognition configuration */
+    /** - detected level for recognition event */
     uint32_t levelPercent;
 };
 
-/*
+/**
  * Specialized recognition event for key phrase detection
  */
 struct PhraseRecognitionExtra {
-    /* keyphrase ID */
+    /** keyphrase ID */
     uint32_t id;
-    /* recognition modes used for this keyphrase */
+    /** recognition modes used for this keyphrase */
     uint32_t recognitionModes;
-    /* confidence level for mode RecognitionMode.VOICE_TRIGGER */
+    /** confidence level for mode RecognitionMode.VOICE_TRIGGER */
     uint32_t confidenceLevel;
-    /* list of confidence levels per user for
+    /**
+     * list of confidence levels per user for
      * RecognitionMode.USER_IDENTIFICATION and
      * RecognitionMode.USER_AUTHENTICATION */
     vec<ConfidenceLevel> levels;
 };
 
-/* TODO(elaurent) remove when Java build problem is fixed */
+/** TODO(elaurent) remove when Java build problem is fixed */
 union Dummy {
   uint32_t dummy1;
   int32_t dummy2;
-};
\ No newline at end of file
+};
diff --git a/thermal/1.0/IThermal.hal b/thermal/1.0/IThermal.hal
index e5f70cb..31a65d4 100644
--- a/thermal/1.0/IThermal.hal
+++ b/thermal/1.0/IThermal.hal
@@ -18,7 +18,7 @@
 
 interface IThermal {
 
-    /*
+    /**
      * Retrieves temperatures in Celsius.
      *
      * @return status Status of the operation. If status code is FAILURE,
@@ -38,7 +38,7 @@
     getTemperatures()
         generates (ThermalStatus status, vec<Temperature> temperatures);
 
-    /*
+    /**
      * Retrieves CPU usage information of each core: active and total times
      * in ms since first boot.
      *
@@ -55,7 +55,7 @@
     @exit
     getCpuUsages() generates (ThermalStatus status, vec<CpuUsage> cpuUsages);
 
-    /*
+    /**
      * Retrieves the cooling devices information.
      *
      * @return status Status of the operation. If status code is FAILURE,
diff --git a/tv/cec/1.0/IHdmiCec.hal b/tv/cec/1.0/IHdmiCec.hal
index e8db265..2840417 100644
--- a/tv/cec/1.0/IHdmiCec.hal
+++ b/tv/cec/1.0/IHdmiCec.hal
@@ -18,11 +18,11 @@
 
 import IHdmiCecCallback;
 
-/*
+/**
  * HDMI-CEC HAL interface definition.
  */
 interface IHdmiCec {
-    /*
+    /**
      * Passes the logical address that must be used in this system.
      *
      * HAL must use it to configure the hardware so that the CEC commands
@@ -39,7 +39,7 @@
     @callflow(next={"*"})
     addLogicalAddress(CecLogicalAddress addr) generates (Result result);
 
-    /*
+    /**
      * Clears all the logical addresses.
      *
      * It is used when the system doesn't need to process CEC command any more,
@@ -50,7 +50,7 @@
     @exit
     clearLogicalAddress();
 
-    /*
+    /**
      * Gets the CEC physical address.
      *
      * The physical address depends on the topology of the network formed by
@@ -66,7 +66,7 @@
     @callflow(next="*")
     getPhysicalAddress() generates (Result result, uint16_t addr);
 
-    /*
+    /**
      * Transmits HDMI-CEC message to other HDMI device.
      *
      * The method must be designed to return in a certain amount of time and not
@@ -84,7 +84,7 @@
     @callflow(next="*")
     sendMessage(CecMessage message) generates (SendMessageResult result);
 
-    /*
+    /**
      * Sets a callback that HDMI-CEC HAL must later use for incoming CEC
      * messages or internal HDMI events.
      *
@@ -95,7 +95,7 @@
     @entry
     setCallback(IHdmiCecCallback callback);
 
-    /*
+    /**
      * Returns the CEC version supported by underlying hardware.
      *
      * @return version the CEC version supported by underlying hardware.
@@ -103,7 +103,7 @@
     @callflow(next={"*"})
     getCecVersion() generates (int32_t version);
 
-    /*
+    /**
      * Gets the identifier of the vendor.
      *
      * @return vendorId Identifier of the vendor that is the 24-bit unique
@@ -113,7 +113,7 @@
     @callflow(next={"*"})
     getVendorId() generates (uint32_t vendorId);
 
-    /*
+    /**
      * Gets the hdmi port information of underlying hardware.
      *
      * @return infos The list of HDMI port information
@@ -121,7 +121,7 @@
     @callflow(next={"*"})
     getPortInfo() generates (vec<HdmiPortInfo> infos);
 
-    /*
+    /**
      * Sets flags controlling the way HDMI-CEC service works down to HAL
      * implementation. Those flags must be used in case the feature needs update
      * in HAL itself, firmware or microcontroller.
@@ -132,7 +132,7 @@
     @callflow(next="*")
     setOption(OptionKey key, bool value);
 
-    /*
+    /**
      * Passes the updated language information of Android system. Contains
      * three-letter code as defined in ISO/FDIS 639-2. Must be used for HAL to
      * respond to <Get Menu Language> while in standby mode.
@@ -143,7 +143,7 @@
     @callflow(next="*")
     setLanguage(string language);
 
-    /*
+    /**
      * Configures ARC circuit in the hardware logic to start or stop the
      * feature.
      *
@@ -154,7 +154,7 @@
     @callflow(next="*")
     enableAudioReturnChannel(int32_t portId, bool enable);
 
-    /*
+    /**
      * Gets the connection status of the specified port.
      *
      * @param portId Port id to be inspected for the connection status.
diff --git a/tv/cec/1.0/IHdmiCecCallback.hal b/tv/cec/1.0/IHdmiCecCallback.hal
index 4a9d28f..754d19f 100644
--- a/tv/cec/1.0/IHdmiCecCallback.hal
+++ b/tv/cec/1.0/IHdmiCecCallback.hal
@@ -17,13 +17,13 @@
 package android.hardware.tv.cec@1.0;
 
 interface IHdmiCecCallback {
-    /*
+    /**
      * The callback function that must be called by HAL implementation to notify
      * the system of new CEC message arrival.
      */
     oneway onCecMessage(CecMessage message);
 
-    /*
+    /**
      * The callback function that must be called by HAL implementation to notify
      * the system of new hotplug event.
      */
diff --git a/tv/cec/1.0/types.hal b/tv/cec/1.0/types.hal
index ec2e373..a1853a3 100644
--- a/tv/cec/1.0/types.hal
+++ b/tv/cec/1.0/types.hal
@@ -48,7 +48,7 @@
     BROADCAST = 15, // as Destination address
 };
 
-/*
+/**
  * HDMI CEC message types. The assigned values represent opcode used in CEC
  * frame as specified in CEC Table 8-26 of the CEC Spec 1.4b.
  */
@@ -123,7 +123,7 @@
     ABORT = 0xFF,
 };
 
-/*
+/**
  * Operand description [Abort Reason]
  */
 enum AbortReason : int32_t {
@@ -144,7 +144,7 @@
     FAILURE_BUSY = 5,
 };
 
-/*
+/**
  * error code used for send_message.
  */
 enum SendMessageResult : int32_t {
@@ -154,7 +154,7 @@
     FAIL = 3,
 };
 
-/*
+/**
  * HDMI port type.
  */
 enum HdmiPortType : int32_t {
@@ -162,24 +162,27 @@
     OUTPUT = 1,
 };
 
-/*
+/**
  * Options used for IHdmiCec.setOption()
  */
 enum OptionKey : int32_t {
-    /* When set to false, HAL does not wake up the system upon receiving <Image
+    /**
+     * When set to false, HAL does not wake up the system upon receiving <Image
      * View On> or <Text View On>. Used when user changes the TV settings to
      * disable the auto TV on functionality.
      * True by default.
      */
     WAKEUP = 1,
 
-    /* When set to false, all the CEC commands are discarded. Used when user
+    /**
+     * When set to false, all the CEC commands are discarded. Used when user
      * changes the TV settings to disable CEC functionality.
      * True by default.
      */
     ENABLE_CEC = 2,
 
-    /* Setting this flag to false means Android system must stop handling CEC
+    /**
+     * Setting this flag to false means Android system must stop handling CEC
      * service and yield the control over to the microprocessor that is powered
      * on through the standby mode. When set to true, the system must gain the
      * control over, hence telling the microprocessor to stop handling the CEC
@@ -190,17 +193,18 @@
      */
     SYSTEM_CEC_CONTROL = 3,
 
-    /* Option 4 not used */
+    /** Option 4 not used */
 };
 
 struct CecMessage {
-    /* logical address of sender */
+    /** logical address of sender */
     CecLogicalAddress initiator;
 
-    /* logical address of receiver */
+    /** logical address of receiver */
     CecLogicalAddress destination;
 
-    /* The maximum size of body is 15 (MaxLength::MESSAGE_BODY) as specified in
+    /**
+     * The maximum size of body is 15 (MaxLength::MESSAGE_BODY) as specified in
      * the section 6 of the CEC Spec 1.4b. Overflowed data must be ignored. */
     vec<uint8_t> body;
 };
@@ -210,7 +214,7 @@
     uint32_t portId;
 };
 
-/*
+/**
  * HDMI port descriptor
  */
 struct HdmiPortInfo {
diff --git a/tv/input/1.0/ITvInput.hal b/tv/input/1.0/ITvInput.hal
index 43de276..95aff21 100644
--- a/tv/input/1.0/ITvInput.hal
+++ b/tv/input/1.0/ITvInput.hal
@@ -19,7 +19,7 @@
 import ITvInputCallback;
 
 interface ITvInput {
-    /*
+    /**
      * Sets a callback for events.
      *
      * Note that initially no device is available in the client side, so the
@@ -33,7 +33,7 @@
     @callflow(next={"getStreamConfigurations"})
     setCallback(ITvInputCallback callback);
 
-    /*
+    /**
      * Gets stream configurations for a specific device.
      *
      * The configs object is valid only until the next
@@ -48,7 +48,7 @@
     getStreamConfigurations(int32_t deviceId)
             generates (Result result, vec<TvStreamConfig> configurations);
 
-    /*
+    /**
      * Opens a specific stream in a device.
      *
      * @param deviceId Device ID for the steam to open.
@@ -65,7 +65,7 @@
     openStream(int32_t deviceId, int32_t streamId)
             generates (Result result, handle sidebandStream);
 
-    /*
+    /**
      * Closes a specific stream in a device.
      *
      * @param deviceId Device ID for the steam to open.
diff --git a/tv/input/1.0/ITvInputCallback.hal b/tv/input/1.0/ITvInputCallback.hal
index f2f07a0..6d88c5b 100644
--- a/tv/input/1.0/ITvInputCallback.hal
+++ b/tv/input/1.0/ITvInputCallback.hal
@@ -17,7 +17,7 @@
 package android.hardware.tv.input@1.0;
 
 interface ITvInputCallback {
-    /*
+    /**
      * Notifies the client that an event has occured. For possible event types,
      * check TvInputEventType.
      *
diff --git a/tv/input/1.0/types.hal b/tv/input/1.0/types.hal
index 60a3b7b..55dd6c0 100644
--- a/tv/input/1.0/types.hal
+++ b/tv/input/1.0/types.hal
@@ -26,7 +26,7 @@
     INVALID_STATE,
 };
 
-/* Type of physical TV input. */
+/** Type of physical TV input. */
 @export(name="", value_prefix="TV_INPUT_TYPE_")
 enum TvInputType : int32_t {
     OTHER = 1,         // Generic hardware.
@@ -41,7 +41,7 @@
     DISPLAY_PORT = 10,
 };
 
-/*
+/**
  * Status of cable connection.
  * This status is for devices having availability to detect the cable in a mechanical way,
  * regardless of whether the connected external device is electrically on or not.
@@ -67,7 +67,7 @@
 
 @export(name="", value_prefix="EVENT_")
 enum TvInputEventType : int32_t {
-    /*
+    /**
      * Hardware notifies the framework that a device is available.
      *
      * Note that DEVICE_AVAILABLE and DEVICE_UNAVAILABLE events do not represent
@@ -89,7 +89,7 @@
      */
     DEVICE_AVAILABLE = 1,
 
-    /*
+    /**
      * Hardware notifies the framework that a device is unavailable.
      *
      * HAL implementation must generate this event when a device registered
@@ -104,7 +104,7 @@
      */
     DEVICE_UNAVAILABLE = 2,
 
-    /*
+    /**
      * Stream configurations are changed. Client must regard all open streams
      * at the specific device are closed, and must call
      * getStreamConfigurations() again, opening some of them if necessary.
@@ -126,7 +126,7 @@
 
 struct TvInputEvent {
     TvInputEventType type;
-    /*
+    /**
      * DEVICE_AVAILABLE: all fields are relevant.
      * DEVICE_UNAVAILABLE: only deviceId is relevant.
      * STREAM_CONFIGURATIONS_CHANGED: only deviceId is relevant.
diff --git a/usb/1.0/IUsb.hal b/usb/1.0/IUsb.hal
index 965326a..f464379 100644
--- a/usb/1.0/IUsb.hal
+++ b/usb/1.0/IUsb.hal
@@ -19,7 +19,7 @@
 import IUsbCallback;
 
 interface IUsb {
-    /*
+    /**
      * This function is used to change the port role of a specific port.
      * For example, when PD_SWAP or PR_SWAP is supported.
      * This is function is asynchronous. The status of the role switch
@@ -31,7 +31,7 @@
      */
     oneway switchRole(string portName, PortRole role);
 
-    /*
+    /**
      * This function is used to register a callback function which is
      * called by the HAL whenever there is a change in the port state.
      * i.e. DATA_ROLE, POWER_ROLE or MODE.
@@ -44,7 +44,7 @@
      */
     oneway setCallback(IUsbCallback callback);
 
-    /*
+    /**
      * This functions is used to request the hal for the current status
      * status of the Type-C ports. This method is async/oneway. The result of the
      * query would be sent through the IUsbCallback object's notifyRoleSwitchStatus
diff --git a/usb/1.0/IUsbCallback.hal b/usb/1.0/IUsbCallback.hal
index b665ba3..fd91cbf 100644
--- a/usb/1.0/IUsbCallback.hal
+++ b/usb/1.0/IUsbCallback.hal
@@ -16,13 +16,13 @@
 
 package android.hardware.usb@1.0;
 
-/*
+/**
  * Callback object used for all the IUsb async methods which expects a result.
  * Caller is expected to register the callback object using setCallback method
  * to receive updates on the PortStatus.
  */
 interface IUsbCallback {
-    /*
+    /**
      * Used to convey the current port status to the caller.
      * Called either when PortState changes due to the port partner (or)
      * when caller requested for the PortStatus update through queryPortStatus.
@@ -34,7 +34,7 @@
      */
     oneway notifyPortStatusChange(vec<PortStatus> currentPortStatus, Status retval);
 
-    /*
+    /**
      * Used to notify the result of the switchRole call to the caller.
      *
      * @param portName name of the port for which the roleswap is requested.
diff --git a/usb/1.0/types.hal b/usb/1.0/types.hal
index 17cd8c7..302616e 100644
--- a/usb/1.0/types.hal
+++ b/usb/1.0/types.hal
@@ -19,42 +19,42 @@
 enum Status : uint32_t {
     SUCCESS = 0,
 
-    /*
+    /**
      * error value when the HAL operation fails for reasons not listed here.
      */
     ERROR = 1,
 
-    /*
+    /**
      * error value returned when input argument is invalid.
      */
     INVALID_ARGUMENT = 2,
 
-    /*
+    /**
      * error value returned when role string is unrecognized.
      */
     UNRECOGNIZED_ROLE = 3,
 };
 
-/*
+/**
  * Denotes the Port role type.
  * Passed as an argument for functions used to query or change port roles.
  */
 enum PortRoleType : uint32_t {
-    /*
+    /**
      * Denotes the data role of the port.
      * The port can either be a "host" or a "device" for data.
      * This maps to the PortDataRole enum.
      */
     DATA_ROLE = 0,
 
-    /*
+    /**
      * Denotes the power role of the port.
      * The port can either be a "source" or "sink" for power.
      * This maps to PortPowerRole enum.
      */
     POWER_ROLE = 1,
 
-    /*
+    /**
      * USB ports can be a pure DFP port which can only act
      * as a host. A UFP port which can only act as a device.
      * Or a dual role ports which can either can as a host or
@@ -65,19 +65,19 @@
 
 @export
 enum PortDataRole : uint32_t {
-    /*
+    /**
      * Indicates that the port does not have a data role.
      * In case of DRP, the current data role of the port is only resolved
      * when the type-c handshake happens.
      */
     NONE = 0,
 
-    /*
+    /**
      * Indicates that the port is acting as a host for data.
      */
     HOST = 1,
 
-    /*
+    /**
      * Indicated that the port is acting as a device for data.
      */
     DEVICE = 2,
@@ -87,19 +87,19 @@
 
 @export
 enum PortPowerRole : uint32_t {
-    /*
+    /**
      * Indicates that the port does not have a power role.
      * In case of DRP, the current power role of the port is only resolved
      * when the type-c handshake happens.
      */
     NONE = 0,
 
-    /*
+    /**
      * Indicates that the port is supplying power to the other port.
      */
     SOURCE = 1,
 
-    /*
+    /**
      * Indicates that the port is sinking power from the other port.
      */
     SINK = 2,
@@ -109,23 +109,23 @@
 
 @export
 enum PortMode : uint32_t {
-    /*
+    /**
      * Indicates that the port does not have a mode.
      * In case of DRP, the current mode of the port is only resolved
      * when the type-c handshake happens.
      */
     NONE = 0,
-    /*
+    /**
      * Indicates that port can only act as device for data and sink for power.
      */
     UFP = 1,
 
-    /*
+    /**
      * Indicates the port can only act as host for data and source for power.
      */
     DFP = 2,
 
-    /*
+    /**
      * Indicates can either act as UFP or DFP at a given point of time.
      */
     DRP = 3,
@@ -133,17 +133,17 @@
     NUM_MODES = 4,
 };
 
-/*
+/**
  * Used as a container to send port role information.
  */
 struct PortRole {
-    /*
+    /**
      * Indicates the type of Port Role.
      * Maps to the PortRoleType enum.
      */
     PortRoleType type;
 
-    /*
+    /**
      * when type is HAL_USB_DATA_ROLE pass values from enum PortDataRole.
      * when type is HAL_USB_POWER_ROLE pass values from enum PortPowerRole.
      * when type is HAL_USB_MODE pass values from enum PortMode.
@@ -151,40 +151,40 @@
     uint32_t role;
 };
 
-/*
+/**
  * Used as the container to report data back to the caller.
  * Represents the current connection status of a single USB port.
  */
 struct PortStatus {
-     /*
+     /**
       * Name of the port.
       * Used as the port's id by the caller.
       */
      string portName;
 
-     /*
+     /**
       * Data role of the port.
       */
      PortDataRole currentDataRole;
 
-     /*
+     /**
       * Power Role of thte port.
       */
      PortPowerRole currentPowerRole;
 
-     /*
+     /**
       * Mode in which the port is connected.
       * Can be UFP or DFP.
       */
      PortMode currentMode;
 
-     /*
+     /**
       * True indicates that the port's mode can
       * be changed. False otherwise.
       */
      bool canChangeMode;
 
-     /*
+     /**
       * True indicates that the port's data role
       * can be changed. False otherwise.
       * For example, true if Type-C PD PD_SWAP
@@ -192,7 +192,7 @@
       */
      bool canChangeDataRole;
 
-     /*
+     /**
       * True indicates that the port's power role
       * can be changed. False otherwise.
       * For example, true if Type-C PD PR_SWAP
@@ -200,7 +200,7 @@
       */
      bool canChangePowerRole;
 
-     /*
+     /**
       * Identifies the type of the local port.
       *
       * UFP - Indicates that port can only act as device for